目前,我正在使用CSS删除y轴的网格线和标签,如下图所示。
CSS:
.highcharts-yaxis-grid path:nth-child(1),.highcharts-yaxis-grid path:nth-child(2),
.highcharts-yaxis-grid path:nth-child(4),.highcharts-yaxis-grid path:nth-child(5){ stroke:transparent !important; }
.highcharts-yaxis-labels text:nth-child(1),.highcharts-yaxis-labels text:nth-child(2),
.highcharts-yaxis-labels text:nth-child(4),.highcharts-yaxis-labels text:nth-child(5){ fill:transparent !important; }
每当将图表下载为图像时,它们就会再次出现,这很有意义,因为它看不到我正在使用的css文件。
[我试图在高图或网上的任何东西上寻找答案,但是没有运气,所以在这里我提出这个问题。
例如,在load
事件中,您可以删除特定的labels
和gridLines
:
chart: {
events: {
load: function() {
var chart = this,
yAxis = chart.yAxis[0],
gridLines = yAxis.gridGroup.element.children,
ticks = yAxis.ticks,
tickPositions = yAxis.tickPositions;
gridLines[2].remove();
ticks[tickPositions[2]].label.element.remove();
}
}
}
实时演示: http://jsfiddle.net/BlackLabel/5m0s7th2/
API参考: https://api.highcharts.com/highcharts/chart.events.load