答案 0 :(得分:0)
可以在x轴上创建图线。也可以在两个轴上创建它:
xAxis: {
plotLines: [{
color: 'red', // Color value
dashStyle: 'longdashdot', // Style of the plot line. Default to solid
value: 3, // Value of where the line will appear
width: 2 // Width of the line
}]
},
参考:https://www.highcharts.com/docs/chart-concepts/plot-bands-and-plot-lines
答案 1 :(得分:0)
您可以使用SVGRenderer
类对象来渲染具有某些属性的rect。您需要做的就是获取特定的点像素值,通过Axis.toPixels
方法可以实现,然后仅根据获得的数据渲染rect
元素。这是代码:
var chart = Highcharts.chart('container', {
chart: {
events: {
load() {
var xAxis = this.xAxis[0],
yAxis = this.yAxis[0],
pointX = 5,
pointY = 125000,
secondPointY = 50000,
width = 4,
height = yAxis.toPixels(secondPointY) - yAxis.toPixels(pointY);
this.renderer.rect(
xAxis.toPixels(pointX) - (width / 2),
yAxis.toPixels(pointY),
width,
height
).attr({
fill: 'red'
}).add()
}
}
},
series: [{
name: 'Installation',
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
}]
});
API参考:
https://api.highcharts.com/class-reference/Highcharts.Axis#toPixels
https://api.highcharts.com/class-reference/Highcharts.SVGRenderer#rect