Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
620 views
in Technique[技术] by (71.8m points)

charts - JFreeChart How the X Axis couple with Dataset provided

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:

  1. How the JFreeChart control to draw a placeholder on Range Axis depends on the Axis/data provided
  2. 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...