Google chart line chart - turn off tooltip for a s

2019-02-24 08:22发布

I know this question was already asked before Using Google Visualization API, how to turn off tooltips for a single column?, but i didn't get familiar answer.Please can somebody tell me how to turn off tooltip for a single column?.I tried this

chart.draw(data, {trigger:'none'});

but it turns off tooltip for all the columns.I want only one column with tooltip disabled and all other columns should have enabled tooltip.

3条回答
Deceive 欺骗
2楼-- · 2019-02-24 08:57

I too was just now looking for a way to disable tooltips for a single column inside my google line chart. The above answer isn't far off but I guess it isn't completely clear.

There is no way to "disable" tooltips for a single column, however you can disable interactivity for a single column which as far as I can tell results in the same wanted behavior. To do so, simply use the series inside the chart options as such:

series :{
0:{
enableInteractivity: false,
tooltip: 'none'}
}

Or a longer example:

var options = {
        tooltip: {isHtml: true},
        legend: 'none',
        chartArea: {
            width: 500,
        },
        lineWidth: 2,
        series: {
            0: { }, // Output
            1: { enableInteractivity: false, tooltip: 'none', lineDashStyle: [2, 2] },
            2: { enableInteractivity: false, tooltip: 'none' },
        },
        colors: ['#6f9654', '#1c91c0', '#7F3F98'],
    };

    var chart = new google.visualization.LineChart(document.getElementById('myChart'));

    chart.draw(dataTable, options);

I found the answer here: https://groups.google.com/forum/#!topic/google-visualization-api/ZADPolRZtxM

And this works for me.. I have a line chart with 3 columns (3 lines in the chart) and I was able to "disable" tooltips on 2 of them using this technique.

查看更多
ら.Afraid
3楼-- · 2019-02-24 09:05

I don't believe that it is possible, but you can disable interactivity which will prevent tool-tips showing by adding enableInteractivity: false to the series.

I hope this helps in your situation, it worked for mine...

查看更多
时光不老,我们不散
4楼-- · 2019-02-24 09:08

The option enableInteractivity: false blocked alse the series select option and etc.

You can do it with better way:

Option = {
  series : {      
          0: { tooltip : false}, // disable tooltip
          1: { tooltip : true}, // enable tooltip
          2: { tooltip : false},
          3: { tooltip : true},
          4: { tooltip : true},
      }
}

It works for me perfectly.

查看更多
登录 后发表回答