1
votes

I have problem with the movement navigation of the chart I created using JFreeChart. From the example as included in the library source code, when we do a zoom, or move on the chart, the graph can be moved freely. But what I am currently trying to do is to have similar behavior like the actual trading platform, let's say Metatrader (MT4). When the chart is move left/right, the min/max of the dataset is changing, so the y-axis of the chart is updated accoringly. Basically I have idea on how to change the range of the y-axis using the below code:

ValueAxis y_range = plot.getRangeAxis(); range.setRange(min, max);

But now my problem is getting the min/max value where right now I think it should be from the current visible dataset on the screen.

Anyone have idea on how to get the min/max value of the current visible dataset of the chart? what the information I have currently is the full dataset. I have explored some forum related to JFreeChart and some suggesting to use the below:

static Range    findDomainBounds(XYDataset dataset)

But if I used my dataset, it will be the min/max from the whole dataset. If this is the only way to get the information I need, any idea how to get the only part of dataset of the current visible chart? (not the whole dataset)

Thanks so much for any help!!

1

1 Answers

1
votes

It's not clear which XYDataset you're using, but you can always extend AbstractXYDataset, as shown here, to obtain the min/max for your currently chosen axis range.