import org.jfree.chart.*
import org.jfree.chart.plot.*
import org.jfree.data.category.*
dcd = new DefaultCategoryDataset()
dcd.with {
addValue(100, "ABC Inc.", "Jan 2010")
addValue(110, "ABC Inc.", "Feb 2010")
addValue(120, "ABC Inc.", "Mar 2010")
addValue(90, "DEF Corp.", "Jan 2010")
addValue(120, "DEF Corp.", "Feb 2010")
addValue(110, "DEF Corp.", "Mar 2010")
}
jfc = ChartFactory.createLineChart(
"売上推移",
"年月",
"売上",
dcd,
PlotOrientation.VERTICAL,
true,
false,
false)
// グラフのグリッド線の色を設定
jfc.getPlot().setRangeGridlinePaint(new java.awt.Color(0, 192, 0))
ChartUtilities.saveChartAsPNG(new File("./gridline.png"), jfc, 300, 200)
出力画像(gridline.png)
動作環境
JDK1.6 Update 15, groovy 1.6.3, JFreeChart1.0.13, JCommon1.0.16
0 件のコメント:
コメントを投稿