I have a chart in Highcharts (to be more specific: it’s a Highstocks chart, candlesticks type) and now I want to add some SVG shapes to it.
I know there is this renderer object, but it only accepts x- and y-coordinates relative to the canvas.
What I need is to add some shapes at a specific TIME (xAxis), so I either need it to accept x/y vales as the chart coordinates (not the canvas coordinates) (which I clearly doubt is possible) or we need to get the x/y-canvas-position of a specific point inside the chart.
Is there any way to do this?
To draw SVG shape and move it with the zoom , there is two ways i used the first one just take it as an idea and see if you can do it better than me , second way always works
the first way
Get the x coordinate for this shape :
as you know highstock use unix time , so lets say you want to add your shape at X data = 1326844540000 , now get the x position for 1326844540000 according to series[i] i will assume that you have one series so use series[0] , here is how you get the x-coor :
now use
.append()to add your SVG :this code will go inside (xAxis – events – setExtremes ) And o nchart load as well
the recommended way
the recommended and guranteed way is to create a flag give it an id and then you can do what ever you want by editing the
attr()of this flagUPDATE
<g>tag is what you will edit to draw what ever you want