JFREE:如何使用小时时间烛台图表



我想用小时的时间制作蜡烛图(Android),并查找afreechart库供使用。基于JFReecharts的Afreechart。

我有一个每日烛台的例子:

公共静态OHLCDATASET CreateTataSet1(){

    Date[] date = new Date[47];
    double[] high = new double[47];
    double[] low = new double[47];
    double[] open = new double[47];
    double[] close = new double[47];
    double[] volume = new double[47];
    int jan = 1;
    int feb = 2;
    for(int i = 0; i < 47; i++) {
        if(i <= 27) {
            date[i] = createDate(2001, jan, i+4, 12, 0);
        } else {
            date[i] = createDate(2001, feb, i-27, 12, 0);
        }
        high[i] = 45 + Math.random() * 20;
        low[i] = high[i] - (Math.random() * 30 + 3);
        do {
            open[i] = high[i] - Math.random() * (high[i] - low[i]);
            close[i] = low[i] + Math.random() * (high[i] - low[i]);
        } while(Math.abs(open[i] - close[i]) < 1);
    }
    return new DefaultHighLowDataset("Series 1", date, high, low, open, close, volume);
}
private static final Calendar calendar = Calendar.getInstance();
/**
 * Returns a date using the default locale and timezone.
 * @param y the year (YYYY).
 * @param m the month (1-12).
 * @param d the day of the month.
 * @param hour the hour of the day.
 * @param min the minute of the hour.
 * @return A date.
 */
private static Date createDate(int y, int m, int d, int hour, int min) {
    calendar.clear();
    calendar.set(y, m - 1, d, hour, min);
    return calendar.getTime();
}

defaulthighlowdataset不适合日期值。我在开发人员指南JFReechart中查找OHLC课程,但找不到小时的方法。如何每小时创建一个蜡烛,而不是每个日期期间一个蜡烛?也许有人有榜样?谢谢!

OHLCDataset的实现中,OHLCSeriesCollection包括addSeries(OHLCSeries series)OHLCSeries允许add(RegularTimePeriod period, …)RegularTimePeriod包括子类Hour。此处讨论了使用Hour的示例。

相关内容

  • 没有找到相关文章

最新更新