highstock,如何防止图表重新缩放 [英] highstock, how to prevent chart rescaling

查看:139
本文介绍了highstock,如何防止图表重新缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试验highchart,有一件事情是很多图表作为一项功能,那就是重新缩放当前视图以仅显示当前正在查看的数据点以适合图表。



例如,给定这些数据点在很长一段时间内:

  [1,50,100,1,50,100,200] 

图表会显示最初的比例为1-200.



当您将图表向左移动以查看较早的数据时,200会离开视图,并且图形会被重新缩放进入1 - 100,然后1 - 50,然后1 - 1,然后它再次增长到1 - 100.

问题 与此明显
如果您想通过回滚历史记录来获取有关数据的任何意义,则无法真正实现。


尽管我同意有时需要重新调整比例,但情况并非总是如此。

有时您只想按原样查看图表,在数据差异很大的情况下使用大范围,而无需重新缩放以适应所有数据点。

我试图设置 reflow:false ,但这不起作用。



任何想法都可以或不可以?

编辑:



以下是一个试图在示例中显示其中一些问题的小提琴:

https://jsfiddle.net/3Ld2zmum/1/



如果你只需滚动默认缩放,然后你会突然看到有一个数据点,在我的情况下应该被忽略。我想看看它周围的数据。我不希望它影响缩放级别。

现在,我无法有效地分析这一点的数据,因为图表不断地放大和缩小。

重新缩放的问题在于,高/低数据点会自动缩放所有其他数据,因此当数据集中存在突然变化时,它会变得非常小。



我可以选择一个很小的时间段,但是如此小的范围分析海量数据就变得非常困难。



在想过这个之后,我明白要解决这个问题的唯一方法就是在y轴上引入某种滚动,所以当您向左移动时,实际上只能看到空白

您必须手动向下滚动以查看数据。这样,缩放不会干扰数据的实际方向,也不会被可能改变数据流的数据所迷惑。

在这种情况下,有时候最好只允许向左滚动,而不进行缩放,从而允许数据在y轴上离开视图,并允许你可以研究围绕大差异的数据,而无需将rangeSelector调整为非常小的范围,以避免在短时间间隔内出现这种数据点。



这是否有意义?

解决方案

- 您可以设置yAxis的缩放比例, yAxis.min yAxis.max 值如下:

  yAxis:{
min:0,
max:13000 ,
title:{
text:'AAA'
}
},

是的,您需要设置某种最大值,或者事先知道最大值应该是多少,或者通过计算数据的最大值并添加某种填充。


I am experimenting with highcharts and there is one thing that many charts have as a functionality and that is to rescale the current view to show only the datapoints that currently are in view to fit the chart.

For instance, given these datapoints on a large time period, :

[1, 50, 100, 1, 50, 100, 200 ] 

The chart will show up initially with a scale of say 1 - 200.

When you then move the chart left to view older data, 200 gets out of the view, and the graph gets rescaled into 1 - 100, then 1 - 50, then 1 - 1, then it grows again to 1 - 100.

The problem with this should be obvious. If you are trying to get any sense of the data by scrolling back in history, you can't really.

Although I do agree that sometimes it is desirable to rescale, it isn't always the case.

Sometimes you just want to view the graph as is, using a large range around large discrepancies in the data, without rescaling to try to fit all datapoints.

I have tried to set reflow: false but this did not work.

Any ideas on wether this is possible or not?

Edit:

Here is a fiddle that attemps to show some of these problems in example:

https://jsfiddle.net/3Ld2zmum/1/

If you just scroll on the default zoom, then you will suddenly see there is a datapoint that in my case should be ignored. I would like to see the data around it. I do not want it to affect the zoom level.

Right now, I am prevented from effeciently analyzing data around this point because the graph keeps scaling up and down.

The problem with rescaling is that a high/low datapoint will automatically zoom all other data out so it becomes really small when there are hugh sudden variances in the dataset.

I can choose a small timeperiod, but then it becomes really difficult to analyze huge amounts of data with such a small range.

After having thought about this, i understand that the only way to solve this issue would be to introduce some kind of scroll on the y axis, so that when you move left, you will actually see only white space.

You would have to manually scroll down to see the data. That way, the scaling won't interfer with the actual direction of the data and you won't get confused by data that can change the flow of the data.

In such circumstances again, it would sometimes be preferable to just allow scroll left, without rescaling, allowing the data to get out of view on the y-axis, and allowing you to study data around the big discreprancy without adjusting the rangeSelector to a really small one to avoid such datapoints on short intervals.

Does this make any sense?

解决方案

To stop the auto-scaling of the yAxis you can set the yAxis.min and yAxis.max values like so:

    yAxis: {
        min: 0,
        max: 13000,
        title: {
            text: 'AAA'
        }
    },

Yes, you will need to set some sort of max value either by knowing ahead of time what the max should be or by calculating the data's max value and adding some kind of padding.

这篇关于highstock,如何防止图表重新缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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