Skip to content
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

Coloring of new series doesn't take current colors of the chart into account #5990

Closed
newlukai opened this issue Nov 17, 2016 · 6 comments
Closed
Labels
Status: Stale This issue hasn't had any activity for a while, and will be auto-closed if no further updates occur. Type: Undecided

Comments

@newlukai
Copy link

Expected behaviour

After removing a series from the chart a newly added series should be colored in the same color the removed series used.

Actual behaviour

The new series is colored in the next color available in the options.colors array.

Live demo with steps to reproduce

Replacing all series
In the live demo use the "Another chart" button to dynamically change the series displayed. The two series are drawn using the primary and secondary color. Hitting the button again, removes the series and adds them again. This time, the series are drawn using the third and fourth color. Would be great if the coloring would start at zero again.

chart.colorCount doesn't work
An approach to start coloring with the primary color after removing all series would be to limit the color count in chart.colorCount. But as you can see (hit "New series" multiple times), this setting doesn't work as expected, the colors are chosen from the complete options.colors array.

Affected browser(s)

All, I think.

@pawelfus
Copy link
Contributor

Hi @newlukai

Thanks for reporting this. However, I don't think it's a bug:

  • replacing all series:
    It starts from first color because the original series has colorByPoint - then first series doesn't have color from colors array. So in the first update, colors counter is still set to 0.
  • chart.colorCount
    This option works in styled mode as described in the API.

You can always set colors array in options: http://jsfiddle.net/nw53pbwq/ or alternatively set color for each series separately.

@newlukai
Copy link
Author

Hi @pawelfus ,

sorry for the late answer, I didn't have a chance to care about this issue.

In my opinion, it is still a bug. Going one step back and thinking about a simple set with two entities: one you would call the first one, the other is the second one. Once I remove those two entities, leaving the set empty, and put two other entities in this set, why should these replacing entities be a third one and a fourth one?

What do you think?

In my application I create charts dynamically. If Highcharts would reset the colors counter to zero once all series are removed, I wouldn't need to count the displayed series and adjust the colors array accordingly.

@pawelfus
Copy link
Contributor

Thank you for the feedback!

I see your point and I agree, that would be convenient in a certain cases. Actually, there is a discussion about the same issue: #6168 and #6138. Will chart.resetColorCounter() (or simple chart.colorCounter = 0; method be helpful in your case too? In that way, anyone can decide if colors should start from the last one or from the first one.

@crh225
Copy link

crh225 commented Dec 21, 2016

@pawelfus chart.resetColorCounter() will defiantly be helpful. at my company, all charts must have the same color in a certain order.

if you add chart.resetColorCounter() can you also add chart.resetMarkerCounter()

@oysteinmoseng
Copy link
Member

Ref #6138 colorCounter and symbolCounter is now automatically reset when there are no series in the chart.

@stale
Copy link

stale bot commented Sep 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the Status: Stale This issue hasn't had any activity for a while, and will be auto-closed if no further updates occur. label Sep 24, 2019
@stale stale bot closed this as completed Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale This issue hasn't had any activity for a while, and will be auto-closed if no further updates occur. Type: Undecided
Projects
None yet
Development

No branches or pull requests

4 participants