cz1980
cz1980

Reputation: 59

Highcharts: export image show wrong color and line width if user change the color and/or line width

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

Answers (1)

Sebastian Bochan
Sebastian Bochan

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.

http://jsfiddle.net/anVxk/2/

 series.update({
        color:'red'
    });

http://api.highcharts.com/highcharts#Series.update()

Upvotes: 2

Related Questions