[英]Jfree:how do CandleStick chart with hour period
我想以小時為單位制作蠟燭圖(android),並查看 afreeChart 庫以供使用。 基於 jfreeCharts 的 Afreechart。
我有一個帶有每日周期的燭台示例:
公共靜態 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 類,但沒有找到每小時方法。 如何每小時創建一根蠟燭,而不是每個日期期間創建一根蠟燭? 也許有人有例子? 謝謝!
在OHLCDataset
的實現中, OHLCSeriesCollection
包括addSeries(OHLCSeries series)
。 OHLCSeries
允許add(RegularTimePeriod period, …)
,而RegularTimePeriod
包含子類Hour
。 此處討論了使用Hour
的示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.