JFreechart - getting the Min and Max of the current displayed dataset for auto-adjusting the y-axis

回眸只為那壹抹淺笑 提交于 2019-12-11 05:03:48

问题


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:


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.



来源:https://stackoverflow.com/questions/13217759/jfreechart-getting-the-min-and-max-of-the-current-displayed-dataset-for-auto-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!