如何显示DataTable的json表示?谷歌图表

How to display the json representation of a DataTable? GoogleCharts

本文关键字:表示 json 谷歌 DataTable 何显示 显示      更新时间:2023-09-26

在其文档中,它说:

toJSON((|String|返回的JSON表示形式的字符串版本图表。

假设我创建了一个DataTable,它存储在数据中:

var data = new google.visualization.DataTable();

如何以与显示图表相同的方式显示此信息?

图表使用以下行显示:

new google.visualization.ColumnChart(document.getElementById('visualization')).
          draw(data,
               {title:"S&P 500 Up/Down Performance Since 1980",
                width:600, height:400,
                isStacked:"true",
                bar:{groupWidth: "90%"},
                legend:"none" }
          );

我想显示数据,而不是数据。toJson((.

如有任何帮助或指示,我们将不胜感激。谢谢

试试这个:

new google.visualization.ColumnChart(document.getElementById('visualization')).
          draw(data.toJson(),
               {title:"S&P 500 Up/Down Performance Since 1980",
                width:600, height:400,
                isStacked:"true",
                bar:{groupWidth: "90%"},
                legend:"none" }
          );

您的长时间未在ColumnChart 中添加toJson()