簡體   English   中英

如何在Google時間軸上啟用“選定”工具提示?

[英]How to enable “selected” tooltip on Google Timelines?

我已經使用Google Charts API創建了時間表。

<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

<script type="text/javascript">
  google.charts.load("current", {packages:["timeline"]});
  google.charts.setOnLoadCallback(drawChart);
  function drawChart() {

    var today = new Date();
    var datenow= today.getFullYear()+','+(today.getMonth()+1)+','+today.getDate();
    var container = document.getElementById('example3.1');
    var chart = new google.visualization.Timeline(container);
    var dataTable = new google.visualization.DataTable();
    dataTable.addColumn({ type: 'string', id: 'Position' });
    dataTable.addColumn({ type: 'string', id: 'Name' });
    dataTable.addColumn({ type: 'date', id: 'Start' });
    dataTable.addColumn({ type: 'date', id: 'End' });
    dataTable.addRows([
      [ 'Arrgh\'s Era', 'Arrgh\'s Era', new Date(2014, 11, 19), new Date(datenow)],
      [ 'Grand Admiral', 'Ogaden', new Date(2014, 11, 19), new Date(2015, 4, 18) ],
      [ 'Grand Admiral', 'Warpool', new Date(2015, 4, 19), new Date(2015, 5, 18) ],
      [ 'Grand Admiral', 'Ogaden', new Date(2015, 5, 19), new Date(2015, 11, 18) ],
      [ 'Grand Admiral', 'Jacob Hanson', new Date(2015, 11, 19), new Date(2016, 3, 18)],
      [ 'Grand Admiral', 'Ogaden', new Date(2016, 3, 19), new Date(2016, 10, 18)],
      [ 'Grand Admiral', 'DragonK', new Date(2016, 10, 19), new Date(2017, 3, 18)],
      [ 'Grand Admiral', 'Bluebear', new Date(2017, 3, 19), new Date(2017, 9, 18)],
      [ 'Grand Admiral', 'Ripper', new Date(2017, 9, 19), new Date(datenow)],
    ]);

    chart.draw(dataTable);
  }
</script>


  </head>
  <body>
    <div id="example3.1" style="height: 200px;"></div>
  </body>
</html>

結果時間表

我要實現的是,僅在選擇條形時(未懸停),才應顯示工具提示。 我嘗試在圖表options使用tooltip: { trigger: 'selection' } 這將導致空白頁。

我究竟做錯了什么? 我在Google Chart API頁面上看到了其他方式,但它們似乎適用於其他Chart類型,而不是時間軸。

時間線圖表只能將觸發器的值設置為“焦點”或不設置,默認值為“焦點”,並且只能將其懸停。 另一個問題是時間線圖表的工具提示不持久

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM