How to create Fatter Candlesticks?

Discussion about JFreeChart related to stockmarket charts.
Locked
aremington1612
Posts: 3
Joined: Thu Sep 17, 2015 2:54 am
antibot: No, of course not.

How to create Fatter Candlesticks?

Post by aremington1612 » Fri Sep 18, 2015 4:06 am

I'm developing a Swing app that displays daily financial data, and have chosen to use JFreeChart. I was able to learn how to create a candlestick chart, but my problem lies in customization.

You see, what I'm aiming for is more along the lines of

Image

While, so far all I've been able to manage is

Image

No matter how far I zoom in, the candlesticks do not increase in width.

I'm fairly certain that somehow the thin candlesticks have something to do with being bound to a certain time range.. I've tried to remedy that but am not sure what I'm doing wrong here.

Code:

Code: Select all

    public void showStockHistory(OHLCDataset dataset, String stockName) {
    JFreeChart candleChart = ChartFactory.createCandlestickChart("History of " + stockName, "Date", "Stock Points", dataset, true);

    XYPlot plot = candleChart.getXYPlot();
        plot.setDomainPannable(true);
        plot.setRangePannable(true);

    ValueAxis domain = plot.getDomainAxis();
        domain.setAutoRange(true);

    NumberAxis range = (NumberAxis)plot.getRangeAxis();
        range.setUpperMargin(0.0D);
        range.setLowerMargin(0.0D);
        range.setAutoRange(true);
        range.setAutoRangeIncludesZero(false);

    ChartPanel chartPanel = new ChartPanel(candleChart);
        chartPanel.setMouseWheelEnabled(true);
        chartPanel.setMouseZoomable(true);

    getViewport().add(chartPanel);
    }

csongi
Posts: 1
Joined: Sat Oct 24, 2015 1:26 pm
antibot: No, of course not.

Re: How to create Fatter Candlesticks?

Post by csongi » Mon Nov 16, 2015 9:59 am

Hi,

I got suck on this one s well. I tried some tricks similar to aremington1612's attempts but no luck! Also tried playing around with the candlestickrenderer. Could you please hint on what the trick is to get candles adjustable in width as you zoom in!

thanks in advance!

Locked