在谷歌可视化数据表上调用onclick()。

时间:2013-07-17 10:21:42

标签: javascript html onclick google-visualization

我必须在下面提到的arraytodatatable上调用onclick。请帮我正确的语法。在数据表内部单击时,应调用一个函数。

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
  google.load("visualization", "1", {packages:["treemap"]});
  google.load("visualization", "1", {packages:["corechart"]});

  google.setOnLoadCallback(drawChart);
  function drawChart() {
    // Create and populate the data table.
    var data = google.visualization.arrayToDataTable([
      ['Location', 'Parent', 'Market trade volume (size)', 'Market increase/decrease (color)'],
      ['IDC',    null,                 0,                               0],
      ['AVANADE','IDC',10,100],
      ['AVA-APAC','AVANADE',10,0],
      ['AVA-CAP','AVANADE',10,100],
      ['AVA-EALA-ROE','AVANADE',10,0],
      ['AVA-EALA-UKI','AVANADE',10,0],
      ['AVA-NA-EAST','AVANADE',10,-100],
      ['AVA-NA-KeyAcc','AVANADE',10,-100],
      ['AVA-NA-WEST','AVANADE',10,100],
      ['AVA-TI','AVANADE',10,0],
      ['PRD','IDC',10,0],
      ['PRD-APAC','PRD',20,-100],
      ['PRD-CAP','PRD',20,100],
      ['PRD-EALA-ROE','PRD',200,-100],
      ['PRD-EALA-UKI','PRD',20,-100],
      ['PRD-NA-EAST','PRD',20,-100],
      ['PRD-NA-KeyAcc','PRD',20,100],
      ['PRD-NA-WEST','PRD',20,100],
      ['PRD-TI','PRD',20,100]
    ]);

1 个答案:

答案 0 :(得分:0)

试试这个

google.visualization.events.addListener(data, 'select', selectHandler);

其中selectHandler是您调用的函数