6

I'm trying to figure out how to highlight a line (series) in Highcharts from an element that's not related to the Chart object in any way.

I went through the documentation, and don't really see a way of achieving this. I can get into the series elements using the series.get(id).

Seems like there are no methods that can be helpful - http://www.highcharts.com/ref/#series-object

Any ideas if that's even possible?

1 Answer 1

9

After a lot of digging and testing, I've managed to get this working - still not sure if this is the best way (probably not).

Chart.series.get(someId).graph.attr('stroke-width', '5')

Unfortunately, this is just getting into the actual DOM element and changing the value of the property of a single element, so if you need to change the stroke width, and the styles of the markers on this line, you'd have to loop through all elements, and apply changes manually.

UPDATE: Ok, there's a better way

But this is using the private API, so if the library changes thins, your code will not work:

Chart.series.get(someId).onMouseOver() and Chart.series.get(someId).onMouseOut().

This actually fires the defined hover-state.

1
  • I've not been able to get it to work but also take a look at series.setState() api.highcharts.com/class-reference/… . I ended up using series.hide() and series.show() to toggle the series on click.
    – k0nG
    Nov 20, 2018 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.