Limit date range of XYPlot x-axis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
reynard80
Posts: 5
Joined: Tue Feb 27, 2018 7:45 pm
antibot: No, of course not.

Limit date range of XYPlot x-axis

Post by reynard80 » Tue Feb 27, 2018 7:51 pm

I'm working on a chart with financial data, using a large dataset. When I generate the chart, the x-axis is generated for the full range of dates. This makes the chart unreadable, as there are too much ticks. For example, I have a dataset for a week, with data for every minute.

I would like to show the chart's x-axis initially with just a limited date range, for example just 2 hours. The chart should then be pannable so that the rest of the date range can also be viewed. In other words, I would like the chart to contain a maximum amount of ticks, so that they don't overlap etc.

I have searched for various parameters but haven't been able to implement this. Is this possible? If so, how?

blahfunk
Posts: 8
Joined: Wed Jan 17, 2018 5:52 pm
antibot: No, of course not.

Re: Limit date range of XYPlot x-axis

Post by blahfunk » Tue Feb 27, 2018 8:10 pm

You want to use a TimeSeries chart. The ticks then are relative to your view. I had a chart that was having the same issues are yours as my dataset is massive for the project I was creating (hourly data intervals). Use the chartfactory of a timeseries and use a dataset of a TimeSeriesCollection (desended of an abstractXYDataset) and you will arrive at your solution. The x-axis will allow you to zoom into the time section you need and not have so many ticks: http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=119704

reynard80
Posts: 5
Joined: Tue Feb 27, 2018 7:45 pm
antibot: No, of course not.

Re: Limit date range of XYPlot x-axis

Post by reynard80 » Tue Feb 27, 2018 9:12 pm

Thanks for your reply. I should have specified my question better though, as I need a Candlestick chart for this project. It is a TimeSeries but a ohlcDataset. So, is it possible to do this in such a chart? It would be ideal if the x-axis would be 'scrollable' to the left and right to move through the time series.

I already tried to work with a JScrollPane; while that did work in a way, it wasn't really a good solution as the axis labels and titles were scrolling outside the pane as well.

reynard80
Posts: 5
Joined: Tue Feb 27, 2018 7:45 pm
antibot: No, of course not.

Re: Limit date range of XYPlot x-axis

Post by reynard80 » Mon Mar 05, 2018 4:02 pm

I have managed to solve this problem by just disabling the zoom on the y-axis. This enables the user to zoom and pan on the x-axis as desired.

Locked