import org.jfree.chart.*
import org.jfree.chart.plot.*
import org.jfree.data.time.*
ts1 = new TimeSeries("A店")
// Hour(int hour, int day, int month, int year)
ts1.add(new Hour(9, 1, 2, 2010), 8d)
ts1.add(new Hour(10, 1, 2, 2010), 9d)
ts1.add(new Hour(11, 1, 2, 2010), 20d)
ts1.add(new Hour(12, 1, 2, 2010), 42d)
ts1.add(new Hour(13, 1, 2, 2010), 32d)
ts1.add(new Hour(14, 1, 2, 2010), 5d)
ts1.add(new Hour(15, 1, 2, 2010), 6d)
ts1.add(new Hour(17, 1, 2, 2010), 12d)
ts1.add(new Hour(18, 1, 2, 2010), 22d)
ts1.add(new Hour(19, 1, 2, 2010), 21d)
ts1.add(new Hour(20, 1, 2, 2010), 18d)
ts1.add(new Hour(21, 1, 2, 2010), 17d)
ts2 = new TimeSeries("B店")
ts2.add(new Hour(9, 1, 2, 2010), 10d)
ts2.add(new Hour(10, 1, 2, 2010), 7d)
ts2.add(new Hour(11, 1, 2, 2010), 6d)
ts2.add(new Hour(12, 1, 2, 2010), 32d)
ts2.add(new Hour(13, 1, 2, 2010), 22d)
ts2.add(new Hour(14, 1, 2, 2010), 2d)
ts2.add(new Hour(15, 1, 2, 2010), 3d)
ts2.add(new Hour(17, 1, 2, 2010), 9d)
ts2.add(new Hour(18, 1, 2, 2010), 18d)
ts2.add(new Hour(19, 1, 2, 2010), 22d)
ts2.add(new Hour(20, 1, 2, 2010), 32d)
ts2.add(new Hour(21, 1, 2, 2010), 33d)
tsc = new TimeSeriesCollection()
tsc.addSeries(ts1)
tsc.addSeries(ts2)
jfc = ChartFactory.createTimeSeriesChart(
"時間別売上推移",
"店舗",
"売上",
tsc,
true,
false,
false)
ChartUtilities.saveChartAsPNG(
new File("./time-series-chart.png"), jfc, 300, 200)
出力画像(time-series-chart.png)
動作環境
JDK1.6 Update 15, groovy 1.6.3, JFreeChart1.0.13, JCommon1.0.16
0 件のコメント:
コメントを投稿