nilsole
nilsole

Reputation: 1723

Highcharts - updating series leads to tooltip-related error (mouseOver)

As can be seen in this simple fiddle, triggering the mouseOver event on a data point and updating the series' properties via series.update() leads to a js error:

Uncaught TypeError: Cannot read property 'tooltipOptions' of null

The code:

plotOptions: {
         series: {
             cursor: 'pointer',
             point: {
                 events: {
                     mouseOver: function () {
                         console.log('why does an error appear?');
                         this.series.update({
                             lineWidth: 10
                         });
                     },
                     mouseOut: function () {
                         console.log('bla');
                     }
                 }
             }
         }
     },

What have I done wrong? Thanks for info.

When setting the tooltip to enabled: false, the error message is:

Uncaught TypeError: object is not a function highcharts.js:300
  r.onMouseOver                              highcharts.js:300
  Wa.runPointActions                         highcharts.js:158
  Wa.onContainerMouseMove                    highcharts.js:165
  b.onmousemove                              highcharts.js:167

Upvotes: 1

Views: 1736

Answers (2)

TMichel
TMichel

Reputation: 4442

You can set the enableMouseTracking option as false first to get rid of the error:

chart.options.plotOptions.pie.enableMouseTracking = false;

Upvotes: 0

Sebastian Bochan
Sebastian Bochan

Reputation: 37588

The problem is that when you use mouseOver event, then you catch this event many times, so series update is also called many times. You should consider another event like click, which will be called one time.

Upvotes: 3

Related Questions