I want to dynamically added several primitive shapes like text and images into highcharts / highstock.
Please see this fiddle.
$(function () {
v
You can use chart.exportChart() function to achieve that: http://jsfiddle.net/B6s7V/38/
The same solution as here.
$("#export").click(function () {
chart.exportChart(null, {
chart: {
events: {
load: function () {
this.renderer.image('http://highcharts.com/demo/gfx/sun.png', 100, 100, 30, 30).add();
}
}
}
});
});
When you export a chart, the chart SVG is regenerated from the original .Chart
call. If you want to add things after the chart has drawn, do it in the charts:events:load
callback.
chart: {
renderTo: 'container',
spacingBottom: 50,
events: {
load: function(){
this.renderer.image('http://highcharts.com/demo/gfx/sun.png', 100, 100, 30, 30).add();
}
}
},
See updated fiddle here.