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().getRenderer().setSeriesPaint(
0, new java.awt.Color(0x22, 0x33, 0x88)
)
jfc.getPlot().getRenderer().setSeriesPaint(
1, new java.awt.Color(0x70, 0x70, 0x33)
)
ChartUtilities.saveChartAsPNG(new File("./line-color.png"), jfc, 300, 200)
出力画像(line-color.png)
動作環境
JDK1.6 Update 15, groovy 1.6.3, JFreeChart1.0.13, JCommon1.0.16
0 件のコメント:
コメントを投稿