如何在wordpress中嵌入谷歌电子表格图表?

时间:2014-01-14 19:17:49

标签: javascript wordpress google-sheets

我想在wordpress帖子中嵌入一个图表。 我正在使用google工作表中使用发布功能生成的脚本。

如果我将生成的脚本添加到通用html页面,我可以看到图表。

如果我将生成的脚本添加到wordpress帖子,我会收到以下错误: “给定轴上的所有系列必须具有相同的数据类型×”

我是否需要修改wordpress页面中的脚本或其他内容才能正确显示图表?

由于

这是由Google表生成的代码:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/static/modules/gviz/1.0/chart.js"> {"dataSourceUrl":"//docs.google.com/spreadsheet/tq?key=0AgtmZPWzQ7lldEt2S2VLajBRQVNFLV9pRFY2bTRQLVE&transpose=0&headers=1&range=A2%3AB1010&gid=0&pub=1","options":{"titleTextStyle":{"bold":true,"color":"#000","fontSize":16},"curveType":"","animation":{"duration":500},"width":1270,"lineWidth":2,"hAxis":{"useFormatFromData":true,"title":"Data","minValue":null,"viewWindowMode":null,"viewWindow":null,"maxValue":null},"vAxes":[{"useFormatFromData":true,"title":"\u00b5g/m\u00b3","minValue":null,"logScale":false,"viewWindow":{"max":null,"min":null},"maxValue":null},{"useFormatFromData":true,"minValue":null,"logScale":false,"viewWindow":{"max":null,"min":null},"maxValue":null}],"booleanRole":"certainty","title":"Via Ariosto, SO2","height":469,"interpolateNulls":false,"legend":"right","focusTarget":"series","useFirstColumnAsDomain":false,"tooltip":{"trigger":"none"}},"state":{},"view":{},"isDefaultVisualization":false,"chartType":"LineChart","chartName":"Chart 1"} </script>

1 个答案:

答案 0 :(得分:1)

另一种选择是使用明确设计用于与Google Charts API集成的WordPress插件。 Inline Google Spreadsheet Viewer plugin for WordPresss使用Google电子表格作为数据源,您可以在多个Google图表和图形可视化中轻松显示该数据。