Highcharts Drawing a line with chart.renderer.path

匿名 (未验证) 提交于 2019-12-03 01:36:02

问题:

I'm looking at this formula:

http://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands 

And here is how I draw it:

chart.renderer.path(['M', someNumber, 10, 'V', 1500, 0])                 .attr({                     'stroke-width': 2,                     stroke: 'red',                     id: 'vert'                 })                 .add(); 

And the line is drawn but it goes through the whole graph. I want it to be small. I think that to make it smaller i need to change the '10' but whatever value I put (even 10.000) the line's length remains the same.

回答1:

In the path attribute:

path(['M', someNumber, 10, 'V', 1500, 0]) 

The 'M' means moveto, "someNumber", 10 are the x, y coordinates you are moving to (this does not draw just moves the "pen" to where you want to start the line). The 'V' means draw a vertical line, the 1500 is the y position to stop drawing it. I do not believe you need the 0 (the V attribute only takes one parameter).

If you want the length of the line to be smaller adjust the 1500 parameter.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!