最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I make the google charts tool-tip stay on click for clicking links in it - Stack Overflow

programmeradmin7浏览0评论

I have a google chart with tool-tips. The tooltip text may contain some links

For tool-tip trigger , I have 2 mutually exclusive options : "selection" or "focus"

Here is an example with "focus" trigger : /

      function drawVisualization() {
       var dataTable = new google.visualization.DataTable();
       dataTable.addColumn('number', 'Voltage (V)');
       dataTable.addColumn('number', 'Current (mA.)');
       dataTable.addColumn({role:'tooltip', type:'string','p':{html:true} });
       dataTable.addRows([
         [150, 64 , "<a href='/'>/</a>"],
         [160, 256 , "<a href='/'>/</a>"]
       ]);

         // Create and draw the visualization.
         new google.visualization.BarChart(document.getElementById('visualization')).
             draw(dataTable,
                  {title:"test",
                   width:600, height:400,
                   tooltip : {isHtml:true,trigger:'focus'}
                  }
             );
      }


      google.setOnLoadCallback(drawVisualization);

How do I get both to work at the same time ie :
1. Hover on the data point to view the values
2. Click on the data point to make it stay and then click the hyperlink inside tooltip

Ultimate objective is to trigger the tooltip on hover and still be able to click the hyperlink in tooltip before it disappears ?

I have a google chart with tool-tips. The tooltip text may contain some links

For tool-tip trigger , I have 2 mutually exclusive options : "selection" or "focus"

Here is an example with "focus" trigger : http://jsfiddle/5Y2kk/2/

      function drawVisualization() {
       var dataTable = new google.visualization.DataTable();
       dataTable.addColumn('number', 'Voltage (V)');
       dataTable.addColumn('number', 'Current (mA.)');
       dataTable.addColumn({role:'tooltip', type:'string','p':{html:true} });
       dataTable.addRows([
         [150, 64 , "<a href='https://www.google./'>https://www.google./</a>"],
         [160, 256 , "<a href='https://www.google./'>https://www.google./</a>"]
       ]);

         // Create and draw the visualization.
         new google.visualization.BarChart(document.getElementById('visualization')).
             draw(dataTable,
                  {title:"test",
                   width:600, height:400,
                   tooltip : {isHtml:true,trigger:'focus'}
                  }
             );
      }


      google.setOnLoadCallback(drawVisualization);

How do I get both to work at the same time ie :
1. Hover on the data point to view the values
2. Click on the data point to make it stay and then click the hyperlink inside tooltip

Ultimate objective is to trigger the tooltip on hover and still be able to click the hyperlink in tooltip before it disappears ?

Share Improve this question asked Jul 24, 2014 at 6:06 FacePalmFacePalm 11.8k5 gold badges49 silver badges51 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

Set the tooltip.trigger option to 'both':

tooltip: {
    isHtml: true,
    trigger: 'both'
}
发布评论

评论列表(0)

  1. 暂无评论