简体   繁体   English

如何禁用highcharts-regression插件的工具提示?

[英]How to disable tooltips for the highcharts-regression plugin?

I've created a simple Highcharts scatter plot with three data points. 我用三个数据点创建了一个简单的Highcharts散点图。 It uses the highcharts-regression plug-in to add a series showing the linear regression line. 它使用highcharts-regression插件添加显示线性回归线的序列。 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/ http://jsfiddle.net/f34mza2q/1/

As you can see from the jsfiddle, the tooltips still pop up for the regression line. 从jsfiddle中可以看到,回归线仍然弹出工具提示。 How can I turn off the tooltips here (and still keep them for the data points)? 如何在此处关闭工具提示(并仍然保留它们作为数据点)?

I've tried a couple of other things: 我尝试了其他几件事:

  • adding a style: 'display: "none"' to regressionSettings.tooltip 向regressionSettings.tooltip添加样式:“显示:无”
  • setting regressionSettings.enableMouseTracking to false 将returnSettings.enableMouseTracking设置为false

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: 更新:根据ppataczek的以下回答,这是我为图表上的所有回归线关闭工具提示的操作:

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

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. 这个highcharts-regression插件不是官方的Highcharts插件,但是请查看文档: https : highcharts-regression ,您不能以尝试的方式禁用各个系列的工具提示。 You should use enableMouseTracking property, but it is not supported in regressionSettings . 您应该使用enableMouseTracking属性,但它不支持的regressionSettings To workaround, you can use update method on created regression series in this way: 要解决此问题,您可以通过以下方式对创建的回归系列使用update方法:

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

Live demo: http://jsfiddle.net/BlackLabel/dt42v3uz/ 现场演示: http : //jsfiddle.net/BlackLabel/dt42v3uz/

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

as mentioned in documentation HIGHCHARTS REGRESSION the tooltip object fellow the stander configuration of highchart disabling or enabling for the entire chart. 如文档HIGHCHARTS REGRESSION中所述,工具提示对象与对整个图表禁用或启用highchart的标准配置相同。 unless you want to search the generated html/css and remove the tooltips with jquery. 除非您要搜索生成的html / css并使用jquery删除工具提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM