本文介绍了高图中柱状图类别的多个y轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个小问题。我试图使用highcharts制作像这样的列图:



单个系列包括春季,夏季,秋季和冬季,以及我使用各种变量的类别,如空气湿度,压力等现在问题是我想要使用多个Y轴,因为明显的湿度范围在0到100之间,压力在1000左右,它们也有不同的单位。
在文档中我发现可以设置多个轴,但问题在于它只显示如何为每个系列指定轴。然而,在这种情况下,我显然不希望系列中有单独的轴(湿度与春季,夏季等类似),但我想要为各个类别分别设置不同的轴。
有没有人知道这是可能的,如果怎么做?

解决方案

是的,可以参考



诀窍是在你的系列中使用yAxis,指定一个整数。如上例所示:

 系列:[{
name:'Rainfall',
color: '#4572A7',
类型:'列',
yAxis:1,
数据:[49.9,71.5,106.4,129.2,144.0,176.0,135.6,148.5,216.4,194.1, 95.6,54.4],
工具提示:{
valueSuffix:'mm'
}

},{
名称:'海平面压力',
type:'spline',
color:'#AA4643',
yAxis:2,
data:[1016,1016,1015.9,1015.5,1012.3,1009.5,1009.6,
marker:{
enabled:false
},
dashStyle:'shortdot',
tooltip:{
valueSuffix:'mb'
}

}


I ran into a slight problem. Im trying to make a column graph like this one using highcharts:http://www.highcharts.com/demo/column-basic

The individual series are spring, summer, fall and winter and as categories I use various varibales such as air humidity, pressure etc. Now the problem is that I wanted to use multiple y-axes, because obviously humidity for example ranges between 0 and 100, pressure is around 1000 and they have different units as well.In the documentation I found that it is possible to set multiple axes but the problem is that it only shows how to specifiy axis for each series. In this case however, I obviously do not want separate axes for series (humidity is similiar in spring, summer etc.), but I want different axes for the individual categories.Does anyone know it this is possible and if how?

解决方案

Yes that is possible, see http://www.highcharts.com/demo/combo-multi-axes

The trick is to use yAxis in your series, specifying an integer. As in the above example:

series: [{
            name: 'Rainfall',
            color: '#4572A7',
            type: 'column',
            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],
            tooltip: {
                valueSuffix: ' mm'
            }

        }, {
            name: 'Sea-Level Pressure',
            type: 'spline',
            color: '#AA4643',
            yAxis: 2,
            data: [1016, 1016, 1015.9, 1015.5, 1012.3, 1009.5, 1009.6, 1010.2, 1013.1, 1016.9, 1018.2, 1016.7],
            marker: {
                enabled: false
            },
            dashStyle: 'shortdot',
            tooltip: {
                valueSuffix: ' mb'
            }

        }

这篇关于高图中柱状图类别的多个y轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 19:46