从现有的Google可视化图表中获取DataTable

发布于 2024-12-27 07:49:19 字数 57 浏览 2 评论 0原文

我画了一张谷歌可视化表格。如何获取用于绘制图表的DataTable?例如,如何获取前5行第1列的值。

I have drawn a Google visualization table chart. How can I get the DataTable that is used to draw the chart? For example, how to get the value of first 5 rows and column 1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆消瘦 2025-01-03 07:49:19

如果您使用 ChartWrapper,您可以获得 DataTable像这样:

  var wrapper = new google.visualization.ChartWrapper({
    chartType: 'ColumnChart',
    dataTable: [['Germany', 'USA', 'Brazil', 'Canada', 'France', 'RU'],
                [700, 300, 400, 500, 600, 800]],
    options: {'title': 'Countries'},
    containerId: 'visualization'
  });
  wrapper.draw();
  // get the DT
  var dt = wrapper.getDataTable();
  console.log(dt);

如果您想从 DataTable 中获取值,可以使用 DataTable 的 getValue(rowIndex, columnIndex) 方法:

var dt = wrapper.getDataTable();
alert(dt.getValue(3, 1));

If you are using the ChartWrapper you can get the DataTable like this:

  var wrapper = new google.visualization.ChartWrapper({
    chartType: 'ColumnChart',
    dataTable: [['Germany', 'USA', 'Brazil', 'Canada', 'France', 'RU'],
                [700, 300, 400, 500, 600, 800]],
    options: {'title': 'Countries'},
    containerId: 'visualization'
  });
  wrapper.draw();
  // get the DT
  var dt = wrapper.getDataTable();
  console.log(dt);

If you want to get a value from the DataTable, you can use the getValue(rowIndex, columnIndex) method of a DataTable:

var dt = wrapper.getDataTable();
alert(dt.getValue(3, 1));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文