问题
Is there a way to bring a series to front in Highcharts without reversing the order of the series?
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.

回答1:
Highcharts has a zIndex property.
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.
来源:https://stackoverflow.com/questions/19797089/highcharts-series-z-index