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

Changing colorIndex doesn't update styles if called through Point#update #8791

Closed
DiegoCardoso opened this issue Aug 16, 2018 · 1 comment
Closed
Labels

Comments

@DiegoCardoso
Copy link

@DiegoCardoso DiegoCardoso commented Aug 16, 2018

This is probably a follow-up to #6660

Expected behaviour

I want to reproduce the Solid Gauge demo for styled mode, but using colorIndex instead of yAxis.stops.
So, when I call point.update({colorIndex: newIndex, y: newVal}), I want both color and value to be updated.

(I know that I could set stops and use a non styled colorIndex, like 99 to reproduce it, but I don't know if it's hacky or the proper way of doing that for styled mode)

Actual behaviour

Only value is updated and color keeps the same as before.

Live demo with steps to reproduce

https://jsfiddle.net/hvcw9p02/

Product version

Tested with lastest HC version (6.1.1)

Affected browser(s)

Tested on Chrome

@pawelfus
Copy link
Contributor

@pawelfus pawelfus commented Aug 16, 2018

Hi @DiegoCardoso

Thank you for reporting this issue. It's a bug, colorIndex is not updated, even though it should be. colorIndex defines highcharts-color-colorIndex class. Workaround is to manually change this class after update: https://jsfiddle.net/BlackLabel/hvcw9p02/3/

Snippet:

  const point = chartSpeed.series[0].points[0];
  point.update({
    y: 120,
    colorIndex: 8
  });
  point.colorIndex = 8;
  point.graphic.addClass('highcharts-color-8');
  point.graphic.removeClass('highcharts-color-3');

If you don't need an animation, you can destroy previous graphic element: https://jsfiddle.net/BlackLabel/hvcw9p02/6/

  const point = chartSpeed.series[0].points[0];
  point.graphic = point.graphic.destroy();
  point.update({
    y: 120,
    colorIndex: 8
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants