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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 01:05:11  来源:igfitidea点击:

drawing custom lines on highchart graph

javascriptjqueryhighcharts

提问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 rendererto draw the line?

你能用renderer来画线吗?

Here is the API doc for renderer. Look at the pathfunction.

这是rendererAPI 文档。看path功能。

Also check the Try itfor jsfiddle for pathfunction.

还要检查Try itfor jsfiddle 的path功能。

回答by Jb Drucker

You can also check the addPlotLineor addPlotBandmethods (http://api.highcharts.com/highcharts#Axis.addPlotLineand http://api.highcharts.com/highcharts#Axis.addPlotBand).

您还可以检查addPlotLineaddPlotBand方法(http://api.highcharts.com/highcharts#Axis.addPlotLinehttp://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 路径更容易、更快捷。