javascript HighCharts 系列 Z 指数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19797089/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HighCharts series Z index
提问by Nuno Nogueira
Is there a way to bring a series to front in Highcharts without reversing the order of the series?
有没有办法在不颠倒系列顺序的情况下将系列放在 Highcharts 前面?
In my code, I've used:
在我的代码中,我使用了:
$('#graf-1').highcharts({
chart: {
zoomType: 'xy'
},
title: {
text: 'Title'
},
subtitle: {
text: 'Source:'
},
xAxis: [{
categories: datax
}],
yAxis: [{ // Primary yAxis
labels: {
format: '{value} ',
style: {
color: '#89A54E'
}
},
title: {
text: eixoy,
style: {
color: '#89A54E'
}
}
}, { // Secondary yAxis
title: {
text: eixoz,
style: {
color: '#4572A7'
}
},
labels: {
format: '{value} %',
style: {
color: '#4572A7'
}
},
opposite: true
}],
tooltip: {
shared: true
},
legend: {
layout: 'vertical',
align: 'left',
x: 120,
verticalAlign: 'top',
y: 100,
floating: true,
backgroundColor: '#FFFFFF'
},
series: [{
name: eixoz,
color: '#4572A7',
type: 'line',
yAxis: 1,
data: dataz,
tooltip: {
valueSuffix: ' %'
}
}, {
name: eixoy,
color: '#89A54E',
type: 'column',
data: datay,
tooltip: {
valueSuffix: ' '
}
}]
});
This is producing a chart with two y axis, where the line is displayed under the column. I want to have the line over the column (like z-index). However, I can't find the method to do it.
这将生成一个带有两个 y 轴的图表,其中线条显示在列下方。我想在列上放置一行(如 z-index)。但是,我找不到这样做的方法。
回答by Mark
Highcharts has a zIndexproperty.
Highcharts 有一个zIndex属性。
series: [{
name: eixoz,
color: '#4572A7',
type: 'line',
yAxis: 1,
data: dataz,
tooltip: {
valueSuffix: ' %'
},
zIndex: 2
}, {
name: eixoy,
color: '#89A54E',
type: 'column',
data: datay,
tooltip: {
valueSuffix: ' '
},
zIndex: 1
}]
See this fiddle.
看到这个小提琴。