Google chart line chart - turn off tooltip for a single column

China☆狼群 提交于 2019-12-01 20:34:49

问题


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.


回答1:


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.




回答2:


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...




回答3:


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.



来源:https://stackoverflow.com/questions/22627791/google-chart-line-chart-turn-off-tooltip-for-a-single-column

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!