单击文本或图像时显示 Google 个饼图?

Show Google pie charts on click at text or image?

我没能设置 link onClick() - 操作会生成 Goolge 饼图。 Here 是通过 JSFiddle 的示例。

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
   <div id="piechart" style="width: 900px; height: 500px;"></div>

  google.charts.load('current', {'packages':['corechart']});
  google.charts.setOnLoadCallback(drawChart);
  function drawChart() {

    var data = google.visualization.arrayToDataTable([
      ['Task', 'Hours per Day'],
      ['Work',     11],
      ['Eat',      2],
      ['Commute',  2],
      ['Watch TV', 2],
      ['Sleep',    7]
    ]);

    var options = {
      title: 'My Daily Activities'
    };

    var chart = new google.visualization.PieChart(document.getElementById('piechart'));

    chart.draw(data, options);
  }

我想要一个可点击的文本或字符串,以便在点击后出现一个小 window 或弹出窗口 window,其中包含图表。这可能吗?

提前致谢。

这是完整的有效代码:

<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {

        var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['Work',     11],
          ['Eat',      2],
          ['Commute',  2],
          ['Watch TV', 2],
          ['Sleep',    7]
        ]);

        var options = {
          title: 'My Daily Activities'
        };

        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        chart.draw(data, options);
      }

      function your_function(){
        if (document.getElementById('piechart').style.display==='none') 
        {  
            document.getElementById('piechart').style.display='block';
        }
        else
        {
            document.getElementById('piechart').style.display='none';
        }
      }
    </script>
  </head>
  <body>
    <div id="piechart" style="width: 900px; height: 500px;" ></div>
    <p onclick="your_function();" >Click Me</p>
  </body>
</html>