开发者

In Google Charts API How do I get the Value of a cell in a DataTable?

I am probably just tired, but, I can't seem to pull the value of a single cell in a Google Charts API DataTable. I would guess it to be something like:

DataTable.getCell(row, col);

Am I just overlooking something extremely naive?

开发者_如何学C

Here is the API reference I have been using: http://code.google.com/apis/chart/interactive/docs/reference.html


I believe you want getValue()

http://code.google.com/apis/chart/interactive/docs/reference.html#DataTable_getValue


   <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["table"]});
      google.setOnLoadCallback(drawTable);

      function drawTable() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Name');
        data.addColumn('number', 'Salary');
        data.addColumn('number', 'Full Time Employee');
        data.addRows([
          ['Mike',  {v: 10000, f: '$10,000'}, 10],
          ['Jim',   {v:8000,   f: '$8,000'},  20],
          ['Alice', {v: 12500, f: '$12,500'}, 38],
          ['Bob',   {v: 7000,  f: '$7,000'},  20]
        ]);

        var table = new google.visualization.Table(document.getElementById('table_div'));

        table.draw(data, { showRowNumber: true });

      
            $("#table_div table tbody tr td").click(function () {
                alert($(this).html());
            });
      
      }
    </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div id="table_div">
    </div>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜