New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type 'spline' changed to 'line' causes problems going to other types after that. #2322

Closed
jfallon1 opened this Issue Oct 4, 2013 · 5 comments

Comments

Projects
None yet
4 participants
@jfallon1

jfallon1 commented Oct 4, 2013

I am using 3.0.6. The specific issue noted in Issue #2270 has been fixed. However, there are other similar problems.

I have 3 series in a chart of type=spline. I can toggle between line and spline correctly. However, when I go from Line to Area I get an AreaSpline instead. And when I click Line I get a Spline instead. Clicking Line after that does nothing. But if I click Spline and THEN click Line the chart is re-drawn correctly.

Similarly, if I click Column it renders correctly. But when I click Line after that it renders a Spline instead.

Same thing for Scatter and Pie charts.

Bottom line - if the chart is first set up as a Spline then you click a button to change it to Line, the renderings of other buttons do not work correctly going forward or coming back to Line.

On the positive side: if the chart starts life as a Line chart then all transitions to other types seem to work correctly.

-Joe

@pawelfus

This comment has been minimized.

Show comment
Hide comment
@pawelfus

pawelfus Oct 29, 2013

Contributor

Workaround: remove defaultSeriesType: http://jsfiddle.net/j932J/1/

Contributor

pawelfus commented Oct 29, 2013

Workaround: remove defaultSeriesType: http://jsfiddle.net/j932J/1/

@TorsteinHonsi

This comment has been minimized.

Show comment
Hide comment
@TorsteinHonsi

TorsteinHonsi Oct 31, 2013

Collaborator

The problem is that the getPointSpline method is not removed from the prototype chain when switching. A drop-in workaround is to set it to null on basic series, to make sure it is overwritten when switching from spline:

$(function () {
    Highcharts.Series.prototype.getPointSpline = null;
});

Demonstrated here: http://jsfiddle.net/highcharts/W2etK/

A permanent fix would not only resolve this case, but also similar potential cases where a method survives switching where it shouldn't.

Collaborator

TorsteinHonsi commented Oct 31, 2013

The problem is that the getPointSpline method is not removed from the prototype chain when switching. A drop-in workaround is to set it to null on basic series, to make sure it is overwritten when switching from spline:

$(function () {
    Highcharts.Series.prototype.getPointSpline = null;
});

Demonstrated here: http://jsfiddle.net/highcharts/W2etK/

A permanent fix would not only resolve this case, but also similar potential cases where a method survives switching where it shouldn't.

@emmerich

This comment has been minimized.

Show comment
Hide comment
@emmerich

emmerich Nov 8, 2013

It's because when a Series is created it's given a specific prototype given its type (for example, OHLCSeries). When the type changes, this prototype isn't changed. This is the core issue.

You can also reproduce this by creating a Candlestick series and switching it to type Line.

emmerich commented Nov 8, 2013

It's because when a Series is created it's given a specific prototype given its type (for example, OHLCSeries). When the type changes, this prototype isn't changed. This is the core issue.

You can also reproduce this by creating a Candlestick series and switching it to type Line.

@TorsteinHonsi

This comment has been minimized.

Show comment
Hide comment
@TorsteinHonsi

TorsteinHonsi Nov 11, 2013

Collaborator

Yes that's the core issue, but it's not easy to change. So the current approach is to replace all the methods of the prototype object.

Collaborator

TorsteinHonsi commented Nov 11, 2013

Yes that's the core issue, but it's not easy to change. So the current approach is to replace all the methods of the prototype object.

@TorsteinHonsi

This comment has been minimized.

Show comment
Hide comment
@TorsteinHonsi

TorsteinHonsi Feb 14, 2017

Collaborator

Here's a new demo, probably of the same issue: http://jsfiddle.net/highcharts/97651yvn/5/. The console log shows how a prototype property from Candlestick is first removed, then it appears again on the second time the button is clicked.

Collaborator

TorsteinHonsi commented Feb 14, 2017

Here's a new demo, probably of the same issue: http://jsfiddle.net/highcharts/97651yvn/5/. The console log shows how a prototype property from Candlestick is first removed, then it appears again on the second time the button is clicked.

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