简体   繁体   English

如果序列值不相似,则在Highcharts上自动分割y轴

[英]Automatically split y-axis on Highcharts if series' values are not similar

I have a page that allows people to select values to graph from a set of values and sometimes those will be very different, eg 1-10 for series A and 1000-1200 in series B. 我有一个页面,允许人们从一组值中选择要绘制图形的值,有时它们会非常不同,例如A系列为1-10,B系列为1000-1200。

Right now, that would make series A very difficult to read, but this could be solved by putting it in a different y-axis. 现在,这将使系列A非常难以阅读,但是可以通过将其放在不同的y轴上来解决。

Has anyone done this with Highcharts before / know of a nice way to handle it? 有人知道/有一个很好的方法来处理Highcharts吗?

I thought I had seen a plugin for this before (that I can't find now). 我以为以前曾经见过一个插件(现在找不到)。

The alternative will be to find the minimum and maximum for each line and split them up manually. 另一种方法是找到每行的最小值和最大值,然后手动将其拆分。

How about using just two separate yAxes? 仅使用两个单独的yAxes怎么样? Just like this: http://jsfiddle.net/p8f8ko6z/ 就像这样: http : //jsfiddle.net/p8f8ko6z/

$('#container').highcharts({
    xAxis: [{
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
            'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    }],
    yAxis: [{ // Primary yAxis

    }, { // Secondary yAxis
        opposite: true
    }],
    series: [{
        yAxis: 1,
        data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]

    }, {
        data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
    }]
});

So no matter what data you have, always use two separate axes. 因此,无论您拥有什么数据,都始终使用两个单独的轴。 You can add specific color and title to show which series is connected to which axis. 您可以添加特定的颜色和标题以显示哪个系列连接到哪个轴。

In the series options when you build the chart you can specify a secondary yaxis: 在构建图表时,可以在系列选项中指定次要Y轴:

Series: {
  yAxis: 1
}

series.area.yAxis series.area.yAxis

You can also separate the yAxis from each other: 您还可以将yAxis彼此分开:

Two panes, candlestick and volume 两个窗格,烛台和音量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM