2012-11-12 2 views
2

시간별 캔들 차트 (안드로이드)를 만들고 afreeChart 라이브러리를 찾고 싶습니다. jfreeCharts를 기반으로 한 Afreechart입니다.Jfree : 시간대 캔들 스틱 차트는 어떻게합니까?

공공 정적 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 클래스를 찾고 있지만 시간별 메서드를 찾지 못했습니다. 어떻게 매 초마다 한 개의 초 대신 한 개의 초를 만드나요? 어쩌면 누군가가 모범을 보았을까요? 감사합니다.

답변

2

OHLCDataset의 구현 중에서 OHLCSeriesCollectionaddSeries(OHLCSeries series)을 포함합니다. OHLCSeriesadd(RegularTimePeriod period, …)을 허용하고 RegularTimePeriod은 서브 클래스 Hour을 포함합니다. Hour을 사용한 예는 here입니다.

+0

감사합니다. 그것은 나를 도왔다. –