我尝试了无数种组合,但无法获得下面两个数据集中的第一个来显示点形状(正方形、圆形等)。代码如图所示:
final AFreeChart chart = ChartFactory.createTimeSeriesChart("","","",dataset,false,false,false);
chart.setBackgroundPaintType( new SolidColor( Color.BLACK ) );
final XYDataset dataset2 = MovingAverage.createMovingAverage(dataset,"Over a week",7 * 24 * 60 * 60 * 1000L,0L);
final XYPlot plot = (XYPlot) chart.getPlot();
plot.setDataset( 1, dataset2 );
plot.setBackgroundPaintType( new SolidColor( Color.BLACK ) );
plot.setDomainGridlinesVisible( true );
plot.setDomainGridlinePaintType( new SolidColor( Color.GRAY ) );
plot.setRangeGridlinesVisible( true );
plot.setRangeGridlinePaintType( new SolidColor( Color.GRAY ) );
final ValueAxis valueAxis = plot.getDomainAxis();
valueAxis.setTickLabelPaintType( new SolidColor( Color.WHITE ) );
valueAxis.setTickLabelFont( new Font( "Dialog", Typeface.NORMAL, 20 ) );
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setTickLabelPaintType( new SolidColor( Color.WHITE ) );
rangeAxis.setTickLabelFont( new Font( "Dialog", Typeface.NORMAL, 20 ) );
rangeAxis.setRange( m_dMin, m_dMax );
final StandardXYItemRenderer renderer0 = new StandardXYItemRenderer( StandardXYItemRenderer.SHAPES_AND_LINES );
final XYSplineRenderer renderer1 = new XYSplineRenderer();
plot.setRenderer( 0, renderer0 );
plot.setRenderer( 1, renderer1 );
renderer0.setSeriesPaintType( 0, new SolidColor( Color.YELLOW ) );
renderer0.setSeriesStroke( 0, (float) 2.0 );
renderer1.setSeriesPaintType( 0, new SolidColor( Color.GREEN ) );
renderer1.setSeriesStroke( 0, (float) 2.0 );
我已经成功地应用了一些自定义(例如每个系列的线条颜色和粗细),但形状让我难以理解。
此外,afreechart 上似乎几乎没有关于教程、示例等的内容。stackoverflow 上甚至没有 afreechart 标签。你们如何去探索这个图书馆?每一步对我来说就像根管一样。
谢谢你们。