Highcharts: HTML DataLabels and refreshing without any cause javascript exception

Created on 27 Feb 2017  ·  3Comments  ·  Source: highcharts/highcharts

Me again with another obscure issue.

I use a conditional HTML dataLabels to display an image depending on the value of a point.

Sometimes, when I pass from a chart with dataLabels present to a chart without any, I get a javascript exception:

TypeError: Cannot set property 'onmouseover' of undefined

This only happens on these conditions:

  • DataLabel is set to useHTML: true
  • We had a chart rendered with at least one dataLabels present followed to a "setData()" call changing the values so that no dataLabels is present.
  • We call .update() on the series properties (even if the properties to merge are empty).

Expected behavior

No error

Actual behavior

Exception thrown

Live demo with steps to reproduce

http://jsfiddle.net/gts29eq7/1/

Click the button.

Affected browser(s)

All

Workaround

I know I can return an empty string instead of null in the dataLabels, but this cause massive slowdown with many points.
I can also disable useHTML, but then I can't display pictures.

As a side note, your github new issue template have a typo in "behavior" (behaviour)

Bug

Most helpful comment

@Dunge Thanks for reporting, we will fix this as soon as possible.

_Internal Note: Fails on Html.js L320 because there is a series.dataLabelGroup but no div element_

All 3 comments

@Dunge Thanks for reporting, we will fix this as soon as possible.

_Internal Note: Fails on Html.js L320 because there is a series.dataLabelGroup but no div element_

@jon-a-nygaard Any updates on a fix for this? Thanks!

The root cause is that the SVG group has a HTML counterpart, and while the HTML counterpart is deleted, the SVGWrapper's overridden on function is not. The same thing theoretically happens with translateXSetter and translateYSetter. I'll fix this by simply checking for parents[0].div, but a complete fix would require that we restore the original functions when deleting the div in SvgRenderer.js.

Was this page helpful?
0 / 5 - 0 ratings