要在图表下方添加该行,您可以使用xAxis
和适当的选项,但要添加自定义标签,您需要使用Highcharts.SVGRenderer
:
chart: {
...,
events: {
load: function() {
var ticks = this.xAxis[0].ticks,
customLabels = ['total: 13', 'Zone of Mediocrity', 'Stocks: 47', 'Good, not great', 'total: 13', 'Zone of "Greatness"'],
counter = 0,
xPos,
tickPos;
addEvents.call(this);
Highcharts.objectEach(ticks, function(el) {
if (tickPos) {
xPos = tickPos.x + (el.mark.getBBox().x - tickPos.x) / 2;
drawCustomLabel.call(
this,
customLabels[counter],
xPos,
tickPos.y + 10
);
drawCustomLabel.call(
this,
customLabels[counter + 1],
xPos,
tickPos.y + 30
);
counter += 2;
}
tickPos = el.mark.getBBox();
el.mark.attr({
translateY: 7.5
});
}, this);
}
}
}
要将图表系列划分为几个元素,请使用zones
。可以通过以下方式添加click
事件:
function addEvents() {
var series = this.series[0];
series['zone-area-0'].element.addEventListener('click', function() {
console.log('zone-area-0');
});
...
}
现场演示:http://jsfiddle.net/BlackLabel/e619th3c/
API:
https://api.highcharts.com/class-reference/Highcharts.SVGRenderer
https://api.highcharts.com/highcharts/series.areaspline.zones