CandleStickChart issue - Candles do not have the correct dat

Discussion about JFreeChart related to stockmarket charts.
Locked
jid1
Posts: 2
Joined: Fri Mar 02, 2012 11:51 am
antibot: No, of course not.

CandleStickChart issue - Candles do not have the correct dat

Post by jid1 » Fri Mar 02, 2012 12:09 pm

I have created a candleStickChart and have added another XYLineAndShapeRenderer. See data below. When my graph is displayed, I get highs, lows, closes at the correct date, but the candlesticks are in correctdate+29 minutes(in the middle of the periods). The date in the tooltip shows as well the correct date +29 minutes. The version of JFreechart I use is 1.0.14. I have also tried this but I still get the same error:

Code: Select all

domainAxis.setTickMarkPosition(DateTickMarkPosition.START);
I also debugged and retrieved the values from the dataset and the have an exact date. Finally I construct the dates with this statement so I don't see how an error could occur:

Code: Select all

   Calendar c = Calendar.getInstance();
    c.set(Calendar.MILLISECOND, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MINUTE, 0);
    long time = c.getTimeInMillis();
My main statements:

Code: Select all

private OHLCSeriesCollection ohDataset = new OHLCSeriesCollection();
private TimeSeriesCollection tsDataset = new TimeSeriesCollection();

private OHLCSeries ohclTs = new OHLCSeries("Spot");
private TimeSeries highs = new TimeSeries("A1");
private TimeSeries lows = new TimeSeries("A2");
private TimeSeries closes = new TimeSeries("A3");

JFreeChart c = ChartFactory.createCandlestickChart("chart", "Date",
            "Price", ohDataset, true);
XYPlot plot = c.getXYPlot();
CandlestickRenderer r = new CandlestickRenderer(20, false, ttG);
plot.setRenderer(0,r);
XYLineAndShapeRenderer cRender = new XYLineAndShapeRenderer(true,true);
plot.setRenderer(1, cRender);
I assume that this is common thing(but couldn't not find anything in the forums) so I pasted only the important bits of the code to make it easier. Let me know if you need more info.
Thanks in advance,
I

Locked