当前位置: 代码迷 >> J2EE >> jfreechart 实现K线图好折线图的组合有关问题
  详细解决方案

jfreechart 实现K线图好折线图的组合有关问题

热度:187   发布时间:2016-04-22 02:40:06.0
jfreechart 实现K线图好折线图的组合问题
我想在K线图部分在加上链条折线图,请问高手该怎么实现,请帮帮忙!!

package com.applet;

import java.awt.Color;//颜色系统
import java.text.SimpleDateFormat;//时间格式
import java.awt.Paint;//画笔系统
import org.jfree.data.time.*;
import org.jfree.data.time.ohlc.OHLCSeries;
import org.jfree.data.time.ohlc.OHLCSeriesCollection;
import org.jfree.chart.renderer.xy.*;
import org.jfree.chart.axis.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.*;
public class Bar1 {

public static void main(String[] args) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");// 设置日期格式
double highValue = Double.MIN_VALUE;// 设置K线数据当中的最大值
double minValue = Double.MAX_VALUE;// 设置K线数据当中的最小值
double high2Value = Double.MIN_VALUE;// 设置成交量的最大值
double min2Value = Double.MAX_VALUE;
OHLCSeries series = new OHLCSeries("");
series.add(new Day(28, 9, 2007), 9.2, 9.58, 9.16, 9.34);
series.add(new Day(27, 9, 2007), 8.9, 9.06, 8.83, 8.96);
series.add(new Day(26, 9, 2007), 9.0, 9.1, 8.82, 9.04);
series.add(new Day(25, 9, 2007), 9.25, 9.33, 8.88, 9.00);
series.add(new Day(24, 9, 2007), 9.05, 9.50, 8.91, 9.25);
series.add(new Day(21, 9, 2007), 8.68, 9.05, 8.40, 9.00);
series.add(new Day(20, 9, 2007), 8.68, 8.95, 8.50, 8.69);
series.add(new Day(19, 9, 2007), 8.80, 8.94, 8.50, 8.66);
series.add(new Day(18, 9, 2007), 8.88, 9.17, 8.69, 8.80);
series.add(new Day(17, 9, 2007), 8.26, 8.98, 8.15, 8.89);
series.add(new Day(14, 9, 2007), 8.44, 8.45, 8.13, 8.33);
series.add(new Day(13, 9, 2007), 8.13, 8.46, 7.97, 8.42);
series.add(new Day(12, 9, 2007), 8.2, 8.4, 7.81, 8.13);
series.add(new Day(11, 9, 2007), 9.0, 9.0, 8.1, 8.24);
series.add(new Day(10, 9, 2007), 8.6, 9.03, 8.40, 8.95);
series.add(new Day(7, 9, 2007), 8.89, 9.04, 8.70, 8.73);
series.add(new Day(6, 9, 2007), 8.4, 9.08, 8.33, 8.88);
series.add(new Day(5, 9, 2007), 8.2, 8.74, 8.17, 8.36);
series.add(new Day(4, 9, 2007), 7.7, 8.46, 7.67, 8.27);
series.add(new Day(3, 9, 2007), 7.5, 7.8, 7.48, 7.69);
series.add(new Day(31, 8, 2007), 7.4, 7.6, 7.28, 7.43);
series.add(new Day(30, 8, 2007), 7.42, 7.56, 7.31, 7.40);
series.add(new Day(29, 8, 2007), 7.42, 7.66, 7.22, 7.33);
series.add(new Day(28, 8, 2007), 7.31, 7.70, 7.15, 7.56);
series.add(new Day(27, 8, 2007), 7.05, 7.46, 7.02, 7.41);
series.add(new Day(24, 8, 2007), 7.05, 7.09, 6.90, 6.99);
series.add(new Day(23, 8, 2007), 7.12, 7.16, 7.00, 7.03);
series.add(new Day(22, 8, 2007), 6.96, 7.15, 6.93, 7.11);
series.add(new Day(21, 8, 2007), 7.10, 7.15, 7.02, 7.07);
series.add(new Day(20, 8, 2007), 7.02, 7.19, 6.94, 7.14);
final OHLCSeriesCollection seriesCollection = new OHLCSeriesCollection();  
  seriesCollection.addSeries(series);
TimeSeries series2 = new TimeSeries("");// 对应时间成交量数据
series2.add(new Day(28, 9, 2007), 260659400 / 100);
series2.add(new Day(27, 9, 2007), 119701900 / 100);
series2.add(new Day(26, 9, 2007), 109719000 / 100);
series2.add(new Day(25, 9, 2007), 178492400 / 100);
series2.add(new Day(24, 9, 2007), 269978500 / 100);
series2.add(new Day(21, 9, 2007), 361042300 / 100);
series2.add(new Day(20, 9, 2007), 173912600 / 100);
series2.add(new Day(19, 9, 2007), 154622600 / 100);
series2.add(new Day(18, 9, 2007), 200661600 / 100);
series2.add(new Day(17, 9, 2007), 312799600 / 100);
series2.add(new Day(14, 9, 2007), 141652900 / 100);
series2.add(new Day(13, 9, 2007), 221260400 / 100);
series2.add(new Day(12, 9, 2007), 274795400 / 100);
series2.add(new Day(11, 9, 2007), 289287300 / 100);
series2.add(new Day(10, 9, 2007), 289063600 / 100);
series2.add(new Day(7, 9, 2007), 351575300 / 100);
series2.add(new Day(6, 9, 2007), 451357300 / 100);