[英]Highcharts how to align two charts yAxis on the same line
How to align two highcharts yAxis on the same line? 如何在同一行上对齐两个高图yAxis?
I'm having two charts on the same page one below other. 我在同一页上有两个图表,一个又一个。 Is there way in highcharts to specify yAxis of both the charts to start on the same line? 高图表中是否可以指定两个图表的yAxis从同一行开始?
Actual: 实际:
Expected 预期
Thanks in advance 提前致谢
In general, you can set static left margins by chart.marginLeft
http://jsfiddle.net/BlackLabel/f3frd95v/ 通常,您可以通过chart.marginLeft
http://jsfiddle.net/BlackLabel/f3frd95v/来设置静态左页边距
However, it's not great solution if we don't know how much space we need. 但是,如果我们不知道需要多少空间,则不是很好的解决方案。 In that case I suggest to update charts after render: http://jsfiddle.net/BlackLabel/f3frd95v/1/ 在这种情况下,我建议渲染后更新图表: http : //jsfiddle.net/BlackLabel/f3frd95v/1/
var chart1 = Highcharts.chart('container', {
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
var chart2 = Highcharts.chart('container2', {
yAxis: {
labels: {
format: '{value}'
}
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4].map(function(p) {
return p * 1e7;
})
}]
});
var leftMargin1 = chart1.plotLeft,
leftMargin2 = chart2.plotLeft;
if (leftMargin1 > leftMargin2) {
chart2.update({
chart: {
marginLeft: leftMargin1
}
});
} else if (leftMargin2 > leftMargin1) {
chart1.update({
chart: {
marginLeft: leftMargin2
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.