我有一个使用样条线的高图,并希望将网格线保留在样条线以下,以便每个网格线满足样条线但不会进一步。这可能吗?Highcharts网格线高度低于样条线
我发现这篇文章,但不知道如何修改它来做我想做的。 Highcharts - Grid line height
$(function() {
Highcharts.theme = {
colors: ["#0085e1"],
chart: {
backgroundColor: "transparent"
},
tooltip: {
backgroundColor: '#0085e1',
style: {
color: '#ffffff'
}
},
};
(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
console.log(d[5]);
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.setOptions(Highcharts.theme);
Highcharts.setOptions({lang: { thousandsSep: ','}});
$('#homechart').highcharts({
chart: {
type: 'spline',
},
title: {
text: '',
x: -20 //center
},
legend: {
enable: false
},
xAxis: {
categories: ['2011', '2012', '2013', '2014', '2015', '2016'],
gridLineWidth: 0,
gridLineColor: '#e5f2fd',
minorTickWidth: 0
},
yAxis: {
title: {
text: null
},
labels: {
enabled: false
},
gridLineColor: 'transparent'
},
tooltip: {
formatter:function(){
var nosheets = this.y.toLocaleString();
return nosheets + ' sheets';
},
borderRadius: 20,
style: {
padding: 5
}
},
plotOptions: {
spline: {
marker: {
radius: 5,
lineColor: '#0085e1',
lineWidth: 1
}
}
},
series: [{
name: 'Sheets',
data: [0, 1000, 835000, 5100000, 15300000, 33400000]
}]
});
});
var text = $("text");
text.each(function(index, domElement) {
var $element = $(domElement);
if ($element.text() === "Highcharts.com") {
$element.hide(); }
});
});
您可以添加在这里你的代码或小提琴来说明这个问题。 –
@plumwd''不再进一步'是什么意思? – IsraGab
你的意思是你只想在你的样条线下面显示灰线? – IsraGab