I came cross a problem with CandleStick chart and after digging deeper I am curious how the JFreeChart to auto coupling the A axis with dataset provided.
The case is after provided a common dataset of OHLCDataset which contains common stock trading daily data, after rendering I get a candle stick chart looks good. But I found it does draw the placeholder on x axis for weekend or holiday, in case the dataset doesn't contain any of those data. Apparently the dataset doesn't provide any API contains trade data for missing days(holiday), I suspect it's X Axis(I used DateAxis) to automatically added those date.
My questions are:
- How the JFreeChart control to draw a placeholder on Range Axis depends on the Axis/data provided
- How to remove those placeholder from range axis, or let's say how to ask JfreeChart to draw chart according to dataset item exactly?
enter image description here
OHLCDataset ohlcDataset = createOHLCDataset(series, symbol);
CandlestickRenderer renderer = new CandlestickRenderer();
renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_AVERAGE);
timeAxis = new DateAxis("Date", TimeZone.getDefault(), Locale.CANADA);
timeAxis.setLowerMargin(0.02); // reduce the default margins on the time axis
timeAxis.setUpperMargin(0.02);
NumberAxis valueAxis1 = new NumberAxis("Price");
valueAxis1.setAutoRangeIncludesZero(false); // override default
XYPlot subplot1 = new XYPlot(ohlcDataset, timeAxis, valueAxis1, renderer);
subplot1.setBackgroundPaint(Color.white);
.......
Cheers!
question from:
https://stackoverflow.com/questions/65916326/jfreechart-how-the-x-axis-couple-with-dataset-provided 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…