Jfree:怎么办阴阳烛图与小时 [英] Jfree:how do CandleStick chart with hour period

查看:223
本文介绍了Jfree:怎么办阴阳烛图与小时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要做出以每小时时期蜡烛图(机器人),并期待在afreeChart库使用。 Afreechart基于所述jfreeCharts。

I want make candle chart(android) with hourly period, and looking the afreeChart library for use. Afreechart based on the jfreeCharts.

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

I have an example a candlestick with daily period:

公共静态OHLCDataset createDataset1(){

public static OHLCDataset createDataset1() {

    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类,但没有找到每小时的方法。如何创建一个蜡烛每隔一小时时间,而不是一支蜡烛的每一个日期时间?也许有人有例子吗?
谢谢!

DefaultHighLowDataset don't work with not Date values. I looking OHLC class in Developer Guide Jfreechart but don't find hourly methods. How create one candle every hour period instead of one candle every date period? Maybe someone have example? Thank you!

推荐答案

其中的 OHLCDataset OHLCSeriesCollection 包括 addSeries(OHLCSeries系列)。一个 OHLCSeries 允许一个添加(RegularTimePeriod期间,...) RegularTimePeriod 包含子类小时。使用小时的例子这里讨论

Among the implementations of OHLCDataset, OHLCSeriesCollection includes addSeries(OHLCSeries series). An OHLCSeries allows one to add(RegularTimePeriod period, …), and RegularTimePeriod includes the subclass Hour. An example using Hour is discussed here.

这篇关于Jfree:怎么办阴阳烛图与小时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆