Highcharts - 网格线高度 [英] Highcharts - Grid line height

查看:453
本文介绍了Highcharts - 网格线高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望高图的网格线只出现至图表高度的75%,而图表的其余部分不应显示网格线。有没有一种方法来设置网格线的高度?



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

解决方案

通常情况下,它不被支持,但简单的更改将允许你: http://jsfiddle.net/ngk6vtbh/

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

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

d = tick.gridLine.d.split(''); //获取默认路径

d [2] =(d [5] - d [2])* size + tick.axis.chart.plotTop; //修改路径 - 不要忘记plotTop

tick.gridLine.attr({
d:d //应用新路径
});
}

});
})(Highcharts)


I want the grid lines of highchart to appear only till 75% of the chart height and rest of the chart should not show the grid lines. Is there a way to set the height of grid line?

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

解决方案

In general, it is not supported, but simple change will allow you that: 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)

这篇关于Highcharts - 网格线高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆