always visible tooltip on google chart on page load?

人盡茶涼 提交于 2019-12-08 19:53:54

问题


Is there any way to make google charts tooltip always visible, no matter where the mouse pointer is? it should be constantly on after page load


回答1:


The best I could come up with is:

http://jsfiddle.net/xDfLd/

But if you interact with the chart (ie, click on different pie segments, or different line segments), the tooltip will disappear. Setting enableInteractivity:false I'll file a bug that tooltips and selections should still display when interactivity is off anyway.




回答2:


I combined what Jeremy posted with Yasen's comment and came to this solution:

var options = {
  enableInteractivity: false,
  selectionMode: 'multiple',
  tooltip: {
    trigger: 'selection'
  }
};

google.visualization.events.addListener(chart, 'ready', function(e) {
  var selected_rows = [];
  for (var i = 0; i < your_total_number_of_rows - 1; i++) {
    selected_rows.push({row: i, column: null});
  }
  chart.setSelection(selected_rows);
});

chart.draw(data, options);

This shows all the tooltips on load and prevents the user from messing around with them. Works great with the Pie Chart.




回答3:


Use tooltip: { trigger: 'selection' } when defining options for the chart.



来源:https://stackoverflow.com/questions/22635602/always-visible-tooltip-on-google-chart-on-page-load

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