2

1時間ごとのローソク足チャート(android)を作成し、afreeChartライブラリを探して使用したいと思います。jfreeChartsに基づくAfreechart。

月経のあるローソク足の例があります。

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クラスを探していますが、毎時メソッドが見つかりません。日付期間ごとに1つのキャンドルではなく、1時間ごとに1つのキャンドルを作成するにはどうすればよいですか?多分誰かが例を持っていますか?ありがとうございました!

4

1 に答える 1

3

の実装の中にはOHLCDatasetOHLCSeriesCollectionが含まれaddSeries(OHLCSeries series)ます。は、をOHLCSeries許可し、サブクラスadd(RegularTimePeriod period, …)を含みます。使用例については、ここで説明します。RegularTimePeriodHourHour

于 2012-11-13T17:53:23.577 に答える