简体   繁体   English

如何在highcharts中缩放缩放事件上的svg路径?

[英]How can I scale an svg path on zoom event in highcharts?

I have built a module so that a user can draw an svg line over a highchart using the Renderer. 我已经构建了一个模块,以便用户可以使用渲染器在高图上绘制svg线。 But when the user zooms into the highchart, the size and position of the drawn line do not change. 但是,当用户放大高图时,绘制线的大小和位置不会改变。

I need these attributes of the line to change as well, like if the user zooms into the chart, the position of the points of the line should be recalculated, and the updated line should be shown. 我还需要更改线的这些属性,例如,如果用户放大图表,则应重新计算线的点的位置,并应显示更新的线。

For example in the following fiddle: 例如下面的小提琴:
http://jsfiddle.net/kXKB8/ http://jsfiddle.net/kXKB8/

chart.renderer.path(['M', 0, 0, 'L', 100, 100, 200, 50, 300, 100])
    .attr({
        'stroke-width': 2,
        stroke: 'red'
    })
    .add();

I need the red svg line to resize accordingly when I change the slider 更换滑块时,我需要红色的svg线相应地调整大小

Is there a function for doing this, or do I have to code manually? 有执行此操作的功能,还是必须手动编码?
If I have to do it manually, please give me an idea of how I can proceed. 如果我必须手动执行此操作,请告诉我如何进行。

您可以捕获调整大小的$(window).resize(function{ //... }) ,然后销毁对象并添加具有新计算位置/大小的新对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM