- - PR -
JFreeChartでの複合グラフの作成
1
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2006-06-30 21:33
初めて質問させていただきます。
JFreeChartでローソク足の株価と折れ線の移動平均線を 表示するグラフを作りたいのですが ローソク足のグラフと折れ線グラフを 一緒にすることができません。 setDatasetのところで java.lang.ClassCastException: org.jfree.data.time.TimeSeriesCollection というエラーが生じてしまいます。 どなたか分かる方がいらっしゃいましたら 教えていただけないでしょうか。 ======================================================== //データ設定 Date[] date = new Date[5]; double[] high = new double[5]; double[] low = new double[5]; double[] open = new double[5]; double[] close = new double[5]; double[] volume = new double[5]; date[0] = DateUtilities.createDate(2005, 10, 4); high[0] = 5700.0; low[0] = 4250.0; open[0] = 4500.0; close[0] = 4300.0; volume[0] = 14000.0; date[1] = DateUtilities.createDate(2005, 10, 5); high[1] = 5700.0; low[1] = 4230.0; open[1] = 5100.0; close[1] = 4730.0; volume[1] = 13000.0; date[2] = DateUtilities.createDate(2005, 10, 6);; high[2] = 5900.0; low[2] = 5300.0; open[2] = 5500.0; close[2] = 5800.0; volume[2] = 8000.0; date[3] = DateUtilities.createDate(2005, 10, 7); high[3] = 6100.0; low[3] = 4900.0; open[3] = 5100.0; close[3] = 5400.0; volume[3] = 23000.0; date[4] = DateUtilities.createDate(2005, 10, 8); high[4] = 7000.0; low[4] = 5000.0; open[4] = 5600.0; close[4] = 6300.0; volume[4] = 15000.0; OHLCDataset dataset = new DefaultHighLowDataset("Series 1", date, high, low, open, close, volume); JFreeChart chart = ChartFactory.createCandlestickChart("Sample Candlestick Chart", "Time", "Value", dataset, true); TimeSeries s1 = new TimeSeries("移動平均", Day.class); s1.add(new Day(4,10,2005), 6500); s1.add(new Day(5,10,2005), 6800); s1.add(new Day(6,10,2005), 7000); s1.add(new Day(7,10,2005), 6500); s1.add(new Day(8,10,2005), 7800); TimeSeriesCollection dataset2 = new TimeSeriesCollection(); dataset2.addSeries(s1); dataset2.setDomainIsPointsInTime(true); XYPlot plot=chart.getXYPlot(); plot.setDataset(1,dataset2); |
|
投稿日時: 2008-09-03 17:05
>> TimeSeries s1 = new TimeSeries("移動平均", Day.class);
XYSeries s1 = new XYSeries("移動平均"); >>s1.add(new Day(4,10,2005), 6500); >>s1.add(new Day(5,10,2005), 6800); >>s1.add(new Day(6,10,2005), 7000); >>s1.add(new Day(7,10,2005), 6500); >>s1.add(new Day(8,10,2005), 7800); s1.add(DateUtilities.createDate(2005, 10, 4).getTime(),6500); s1.add(DateUtilities.createDate(2005, 10, 5).getTime(),6800); s1.add(DateUtilities.createDate(2005, 10, 6).getTime(),7000); s1.add(DateUtilities.createDate(2005, 10, 7).getTime(),6500); s1.add(DateUtilities.createDate(2005, 10, .getTime(),7800); >> TimeSeriesCollection dataset2 = new TimeSeriesCollection(); XYSeriesCollection dataset2 = new XYSeriesCollection(); |
1