Reputation: 59
I created a chart, and a button to change series color to red. However, after the series color got changed to red, the export image (PNG/JPEG/PDF/SVG) still show the original color (blue) instead of the new color (red).
The way that I change a series color is as follows:
series.color = "#FF3030";
series.graph.attr({
stroke: "#FF3030"
});
series.legend.colorizeItem(series, series.visible);
$.each(series.data, function (i, point) {
point.graphic.attr({
fill: "#FF3030"
});
});
series.redraw();
I expect the exported image has the new color (red). The code is shared here. The same issue can happen if user change the line width programmatically. Anyone can help me to resolve these 2 issues, i.e., export the new color and width when exporting images.
Thanks in advance!
Alex
Upvotes: 0
Views: 1386
Reputation: 37588
When you export chart, then it is created again. So as a result, dynamic elements (modified in SVG) like color are skipped. You need to use series.update() and then exported image will be correct.
series.update({
color:'red'
});
http://api.highcharts.com/highcharts#Series.update()
Upvotes: 2