以下是我要修改的Highcharts示例的链接。我希望正确的2个y轴成为一个。目前,图表上的每一行对应一个y轴,因为它们具有不同的比例。我想要创建的图表将有1个右轴,但对应于图表中两条线的最低和最高极限。例如,如果A行的低值为5(并且低于B行中的任何值),则行B的极值为90(并且高于A中的任何值),这两个值用于轴。图表上的两条线应对应一个比例。
链接:http://www.highcharts.com/demo/combo-multi-axes
Curernt代码:
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
},
title: {
text: 'Example 1'
},
xAxis: [{
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
}],
yAxis: [{ // Primary yAxis
labels: {
formatter: function() {
return this.value +'%';
},
style: {
color: '#89A54E'
}
},
title: {
text: 'Percent Change',
style: {
color: '#89A54E'
}
},
opposite: true
}, { // Secondary yAxis
gridLineWidth: 0,
title: {
text: 'Measure',
style: {
color: '#4572A7'
}
},
labels: {
formatter: function() {
return this.value + 'k';
},
style: {
color: '#4572A7'
}
}
}, { // Tertiary yAxis
gridLineWidth: 0,
title: {
text: '',
style: {
color: '#AA4643'
}
},
labels: {
formatter: function() {
return this.value +' %';
},
style: {
color: '#AA4643'
}
},
opposite: true
}],
series: [{
name: 'Measures', //Button on Graph -- Measures
color: '#363534',
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],
}, {
name: 'Percentage Change 1', //Button on Graph -- Purple
type: 'spline',
color: '#E17000',
yAxis: 2,
data: [30,40,35,25,14,25,39,28,21,78,23,36,5],
marker: {
enabled: false
},
dashStyle: 'shortdot'
}, {
name: 'Percentage Change 2', //Button on Graph -- Orange
color: '#A31A7E',
type: 'spline',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 35],
}]
});
});
答案 0 :(得分:0)
首先,或许可以考虑另一种表示数据的方式。多种尺度可能是精神紧张。
第二,也许这有帮助吗?我删除了$(document).ready...
包装器。
var chart;
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
},
title: {
text: 'Example 1'
},
xAxis: [{
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
}],
yAxis: [{ // Primary yAxis
labels: {
formatter: function() {
return this.value +'%';
},
style: {
color: '#878787'
}
},
title: {
text: 'Percent Change',
style: {
color: '#878787'
}
},
opposite: true
}, { // Secondary yAxis
gridLineWidth: 0,
title: {
text: 'Measure',
style: {
color: '#4572A7'
}
},
labels: {
formatter: function() {
return this.value + 'k';
},
style: {
color: '#4572A7'
}
}
}],
series: [{
name: 'Measures', //Button on Graph -- Measures
color: '#363534',
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],
}, {
name: 'Percentage Change 1', //Button on Graph -- Purple
type: 'spline',
color: '#E17000',
data: [30,40,35,25,14,25,39,28,21,78,23,36,5],
marker: {
enabled: false
},
dashStyle: 'shortdot'
}, {
name: 'Percentage Change 2', //Button on Graph -- Orange
color: '#A31A7E',
type: 'spline',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 35],
}] });
答案 1 :(得分:0)
可以选择为系列数组设置yAxis属性。使两个系列对象的yAxis:0。无论图表上的系列项数是多少,都应该给出一个Y轴。