I'm doing some programmatic drawing in Highcharts using Highcharts.Renderer using path()
and rect()
. In the code below I have manually plotted the coordinates for the line and rect. In reality the are related to the main data series (dates with values).
How can I programmatically draw something and make the zoom work?
The main graph, with zoom:
chart: {
zoomType: 'x',
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
The programmtic drawing:
chart.renderer.rect(100, 110, 100, 100, 5)
.attr({
'stroke-width': 2,
stroke: 'red',
fill: 'transparent',
zIndex: 3
})
.add();
var path = [
'M', 100, 100,
'L', 130, 110,
'L', 160, 105,
'L', 190, 150,
];
chart.renderer.path(path)
.attr({
'stroke-width': 2,
stroke: 'blue',
zIndex: 4
})
.add();
http://jsfiddle.net/n8ro1b9m/1/