Highcharts - 网格线高度

时间:2015-04-08 05:17:16

标签: highcharts

我希望高图的网格线仅出现在图表高度的75%以及图表的其余部分不应显示网格线。有没有办法设置网格线的高度?



xAxis: {               
    gridLineWidth: 1,               
    gridLineDashStyle: 'longdash',
    gridLineColor: '#B3BABB',
}




1 个答案:

答案 0 :(得分:1)

一般情况下,它不受支持,但简单的更改将允许您:http://jsfiddle.net/ngk6vtbh/

(function(H) {
    H.wrap(H.Tick.prototype, 'render', function(p, index, old, opacity) {
        var tick = this,
            d,
            size = 0.25; // = 75%, 0.5 = 50%, 0.75 = 25% etc.
        p.call(this, index, old, opacity);

        if(tick.gridLine && this.axis.isXAxis) {

            d = tick.gridLine.d.split(' '); // get default path

            d[2] = ( d[5] - d[2] ) * size + tick.axis.chart.plotTop; // modify path - don't forget about plotTop

            tick.gridLine.attr({
                d: d // apply new path
            });
        }

    });
})(Highcharts)