无法隐藏谷歌图表上趋势线上的工具提示(方程式)

时间:2014-10-23 17:50:05

标签: charts google-visualization

你可以帮我隐藏this page上谷歌图表上趋势线上的工具提示(等式)吗?

由于

以下是我使用的图表选项:

var options = {
        title: 'Weight of pro surfer vs. Volume of his pro model',
        hAxis: {title: 'Weight (kg)', minValue: 53, maxValue: 100}, //55
        vAxis: {title: 'Volume (l)'}, //, minValue: 20, maxValue: 40},   //20
        legend: 'none',
           colors: ['#000000'],
           series: {
                  1: { color: '#06b4c8' }, 
                  2: { color: '#575e6a' }
              },
        legend: {position: 'top right', textStyle: {fontSize: 8}},
        chartArea: {width: '60%'},
        //tooltip:{trigger:'none'}, //it hides all tooltips on the whole graph
        trendlines: { 0: {//type: 'exponential',
                    visibleInLegend: true,
                    color: 'grey',
                    lineWidth: 2,
                    opacity: 0.2,
                    tooltip:{trigger:'none'}, //does nothing
                    labelInLegend: 'Linear trendline\n(Performance)'
                    } 
                }    // Draw a trendline for data series 0.
    };

如果我在tooltip:{trigger:'none'},之前添加trendlines,则会隐藏整个图表的工具提示。

2 个答案:

答案 0 :(得分:16)

它已经实施但尚未记录:

trendlines: {0: {tooltip: false}}

答案 1 :(得分:5)

我能够做的唯一解决方案是从趋势线替换工具提示的文本。此示例使用jquery,因此如果您能够使用jquery,则可以使用:

      google.visualization.events.addListener(chart, 'onmouseover', function(e){
          $('svg *:contains("* x")').each(function(){
              $(this).text('')
          })
      })

如果没有,应该可以使用纯js进行复制,但这是主要的想法:找到附加了公式的工具提示,并将文本替换为空白

以下是一个工作示例:http://jsfiddle.net/juvian/aapdjbpt/

相关问题