candlestick plot of sparse data

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Chris von recklinghausen

candlestick plot of sparse data

Post by Chris von recklinghausen » Wed Sep 11, 2002 6:28 pm

Data I'm trying to plot using ChartFactory.createCandlestickChart only exists for Mondays through Fridays. The problem is that the library is creating entries for Saturdays and Sundays with zeroes for the open/high/low/close/volume data, and that's skewing the autoscaling, such that the meaningful data is crowded at the top of the plot, and the vertical scale always goes down to zero.

Is there a straightforward way to deal with this issue without having to either come up with a rearchitected candlestick chart class or putting in fake data for Saturdays and Sundays (which is unacceptable in the long run)? The demo code for candlestick plots has data that is contiguous.

David Gilbert

Re: candlestick plot of sparse data

Post by David Gilbert » Thu Sep 12, 2002 9:30 am

There's nothing you can do (at present) about the date axis leaving space for Saturdays and Sundays, it just shows a continuous time line. But you don't need to include any data for those days. Some time, I will write a new date axis that allows you to leave out some days/periods.

The problem with the vertical scale is easily fixed. By default, numerical axes include zero when auto-calculating the range to include zero. You can control this behaviour using the setAutoRangeIncludesZero(boolean) method, something like this:

XYPlot plot = myChart.getXYPlot();
NumberAxis axis = (NumberAxis)plot.getRangeAxis();
axis.setAutoRangeIncludesZero(false);

Regards,

DG.

Locked