我需要获得代码,可以帮助我创建一个类似于图像http://www.jidesoft.com/images/line-chart-gradient-fill.png中显示的图表,它也应该是一个时间序列图表
发布于 2014-10-09 16:52:57
首先,我想推荐您购买JFreeChart开发人员指南。它包含大量优秀的示例,并支持此项目的维护者。
关于你的问题:我不知道你的主要目标是什么。
JFreeChart源代码提供的类TimeSeriesChartDemo1是一个很好的起点。
修改本demo的createChart方法,设置不同的渲染器:
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Legal & General Unit Trust Prices", // title
"Date", // x-axis label
"Price Per Unit", // y-axis label
dataset, // data
true, // create legend?
true, // generate tooltips?
false // generate URLs?
);
chart.setBackgroundPaint(Color.white);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
XYItemRenderer r = new XYAreaRenderer2();
r.setSeriesPaint(0, new Color(255, 0, 0, 50));
r.setSeriesPaint(0, new Color(0, 255, 0, 50));
plot.setRenderer(r);
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
return chart;
}https://stackoverflow.com/questions/26273159
复制相似问题