How to create Fatter Candlesticks?

Discussion about JFreeChart related to stockmarket charts.

How to create Fatter Candlesticks?

Postby 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);
    }
aremington1612
 
Posts: 3
Joined: Thu Sep 17, 2015 2:54 am

Re: How to create Fatter Candlesticks?

Postby 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!
csongi
 
Posts: 1
Joined: Sat Oct 24, 2015 1:26 pm


Return to JFreeChart - Stockmarket

Who is online

Users browsing this forum: No registered users and 1 guest

cron