Derek Kurth
Derek Kurth

Reputation: 1898

How to disable tooltips for the highcharts-regression plugin?

I've created a simple Highcharts scatter plot with three data points. It uses the highcharts-regression plug-in to add a series showing the linear regression line. I would like tooltips to display for the data points but not for the regression line, so I have disabled the tooltip like this:

series: [{
  regression: true,
  name: 'Test input',
  color: 'rgba(223, 83, 83, .5)',
  data: [
    [1, 1],
    [2, 3],
    [3, 9],       
  ],
  regressionSettings: {
    tooltip: {
      enabled: false // <---- I expect this to disable the tooltip
    },
  }
}]

http://jsfiddle.net/f34mza2q/1/

As you can see from the jsfiddle, the tooltips still pop up for the regression line. How can I turn off the tooltips here (and still keep them for the data points)?

I've tried a couple of other things:

Neither seemed to have any effect.

UPDATE: Based on ppotaczek's answer below, here's what I did to turn off tooltips for all regression lines on the chart:

Highcharts.chart('mychart', {
    // ...
    events: {
        load: function() {
            var trendlines = this.series.filter(c => c.options.isRegressionLine);
            for (i in trendlines) {
                trendlines[i].update({
                    enableMouseTracking: false
                });
            }
        }
    },
    //...
});

Upvotes: 0

Views: 551

Answers (2)

ppotaczek
ppotaczek

Reputation: 39099

This highcharts-regression plugin is not official Highcharts plugin, but please look at the documentation: https://api.highcharts.com/highcharts/series.line.tooltip, you can not disable tooltip for individual series in the way you try. You should use enableMouseTracking property, but it is not supported in regressionSettings. To workaround, you can use update method on created regression series in this way:

            load: function() {
                this.series[1].update({
                    enableMouseTracking: false
                });
            }

Live demo: http://jsfiddle.net/BlackLabel/dt42v3uz/

API: https://api.highcharts.com/highcharts/series.column.enableMouseTracking

Upvotes: 2

Issam EL-GUERCH
Issam EL-GUERCH

Reputation: 414

as mentioned in documentation HIGHCHARTS REGRESSION the tooltip object fellow the stander configuration of highchart disabling or enabling for the entire chart. unless you want to search the generated html/css and remove the tooltips with jquery.

Upvotes: 0

Related Questions