HighCharts series Z index

本秂侑毒 提交于 2019-12-21 07:00:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!