How to crate CandelStick chart.Pleas help me???

Discussion about JFreeChart related to stockmarket charts.
Locked
cehov
Posts: 3
Joined: Tue Apr 19, 2005 4:16 pm

How to crate CandelStick chart.Pleas help me???

Post by cehov » Wed Apr 20, 2005 7:20 am

Hi,

I'm new to JfreeChart.My question is , how can I create a CandelsticK chart, I know that I should use "createCandelStickChart" but I have a problem with data how cen I add data to candelstick chart. I know to create pie,bar,line area chart but I have a problem with CandelStick chart .Can someone send me an example(source code).I know that my englis isn't perfectly and sorry for this!!

ratna

Post by ratna » Fri Sep 23, 2005 3:07 pm

May be you can create OHLCDataset as CandleStick Dataset.

Example:

OHLCDataset ohlcDataset=createDataCandle();
JFreeChart jfreechart1 = ChartFactory.createCandlestickCha("Candlestick Demo", "Time", "Value", ohlcDataset, true);

public OHLCDataset createDataCandle()
{
Date adate[] = new Date[a.getVolumeArray().length];
double ad[] = new double[a.getVolumeArray().length];
double ad1[] = new double[a.getVolumeArray().length];
double ad2[] = new double[a.getVolumeArray().length];
double ad3[] = new double[a.getVolumeArray().length];
double ad4[] = new double[a.getVolumeArray().length];
int i = 1;
byte byte0 = 2;
for(int is=0;is<a.getVolumeArray().length;is++)
{
adate[is] = new Date(a.getDateArray()[is]);
ad[is] = a.getHighPriceArray()[is];
ad1[is] = a.getLowPriceArray()[is];
ad2[is] = a.getOpenPriceArray()[is];
ad3[is] = a.getClosePriceArray()[is];
ad4[is] = a.getVolumeArray()[is];
}
return new DefaultHighLowDataset("Series 1", adate, ad, ad1, ad2, ad3, ad4);
}

Hope this can help you. Good Luck.

Locked