javascript 在 highchart 图上绘制自定义线
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7727810/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
drawing custom lines on highchart graph
提问by Vade
I have recently been working with the highchart api to plot some data on a website, and I have need to be able to add a custom vertical "line" to symbolise something happening for example a press release.
我最近一直在使用 highchart api 在网站上绘制一些数据,我需要能够添加自定义垂直“线”来象征正在发生的事情,例如新闻稿。
I have thought about adding a column element to the chart as a seperate series but this is less than ideal.
我曾考虑将一个列元素作为一个单独的系列添加到图表中,但这并不理想。
if anyone has any ideas that would be awesome
如果有人有任何很棒的想法
thanks
谢谢
回答by Bhesh Gurung
Can you use the the renderer
to draw the line?
你能用renderer
来画线吗?
Here is the API doc for renderer. Look at the path
function.
Also check the Try itfor jsfiddle for path
function.
还要检查Try itfor jsfiddle 的path
功能。
回答by Jb Drucker
You can also check the addPlotLine
or addPlotBand
methods (http://api.highcharts.com/highcharts#Axis.addPlotLineand http://api.highcharts.com/highcharts#Axis.addPlotBand).
您还可以检查addPlotLine
或addPlotBand
方法(http://api.highcharts.com/highcharts#Axis.addPlotLine和http://api.highcharts.com/highcharts#Axis.addPlotBand)。
It may be easier and quicker to use than drawing a SVG path, unless your line isn't straight.
除非您的线条不直,否则使用起来可能比绘制 SVG 路径更容易、更快捷。