Additional options for series are not applied in "getSVG" method. #5982

Closed
AlexanderSokolov1 opened this Issue Nov 16, 2016 · 4 comments

Projects

None yet

2 participants

@AlexanderSokolov1

Expected behaviour

All additional options for series and its data points are applied and result svg string contains that changes.

Actual behaviour

Additional options for series are ignored

Live demo with steps to reproduce

http://jsfiddle.net/q6fLodmk/
When you click on "View SVG" button, the series title and data is not changed.

Source

In exporting.src.js file, line 323

// prepare for replicating the chart
options.series = []; // <--- all additional options now removed
each(chart.series, function (serie) {
    seriesOptions = merge(serie.userOptions, { // #4912
        animation: false, // turn off animation
	enableMouseTracking: false,
	showCheckbox: false,
	visible: serie.visible
    });

    if (!seriesOptions.isInternal) { // used for the navigator series that has its own option set
        options.series.push(seriesOptions);
    }
});

Affected browser(s)

All

@pawelfus
Collaborator
pawelfus commented Nov 17, 2016 edited

Thank for reporting!
I agree, it looks buggy. I don't think changing a data set for an exported chart is a good idea (unless you want to surprise an user ;) ), but for example changing series name should be possible: http://jsfiddle.net/q6fLodmk/2/

@pawelfus pawelfus added the Bug label Nov 17, 2016
@AlexanderSokolov1
AlexanderSokolov1 commented Nov 17, 2016 edited

Thank you for replay!
In my case, I have to hide deselected legend items from export, so I use the "showInLegend" series option with the "false" value, when export.
(Also I use the "Pie" chart, where I should set "showInLegend" option for series points like here:
http://jsfiddle.net/sNzrK/.)

I agreed with you about data set (x, y, value and etc. options should not be changed), but I think, that other properties is really useful to change :-).

@pawelfus
Collaborator

Workaround:
Change options inline, using userOptions in the original series object, for example: http://jsfiddle.net/q6fLodmk/3/

Snippet:

// Set new options:
chart.series[0].userOptions.name = "New Series Name";

var svg = chart.getSVG(additionalOptions);
document.body.innerHTML = '<div>' + svg + '</div>';

// Restore option
chart.series[0].userOptions.name = 'Series 1';
@AlexanderSokolov1

Yeah, workaround is a nice option, but it looks like a hack in the code and "additionalOptions" looses its point.
Anyway, thank you very much for the advice :-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment