JFreechart-获取当前显示的数据集的最小值和最大值以自动调整y轴 [英] JFreechart - getting the Min and Max of the current displayed dataset for auto-adjusting the y-axis

查看:164
本文介绍了JFreechart-获取当前显示的数据集的最小值和最大值以自动调整y轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JFreeChart创建的图表的移动导航遇到问题.从库源代码中包含的示例中,当我们进行缩放或在图表上移动时,可以自由移动图形.但是我目前正在尝试做的是具有与实际交易平台类似的行为,比如说Metatrader(MT4).当图表向左/向右移动时,数据集的最小值/最大值在变化,因此图表的y轴会相应更新.基本上,我对如何使用以下代码更改y轴的范围有所了解:

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.

任何人都对如何获取图表的当前可见数据集的最小/最大值有想法吗?我目前拥有的信息是完整的数据集. 我探索了一些与JFreeChart相关的论坛,并建议使用以下内容:

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)

非常感谢您的帮助!

推荐答案

目前尚不清楚您正在使用哪个XYDataset,但是您始终可以扩展AbstractXYDataset,如下所示:

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.

这篇关于JFreechart-获取当前显示的数据集的最小值和最大值以自动调整y轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆