Google 使用 JSON 数据表返回的差异图表 [给定轴上的所有系列必须具有相同的数据类型]
Google Diff Charts using JSON datatable returning [all series on a given axis must be of the same data type]
我正在尝试使用 Google 可视化生成差异图表来比较两组数据。 (https://developers.google.com/chart/interactive/docs/gallery/diffchart)
数据A:
{"cols":[{"label":"Month","type":"string"},{"label":"Total","type":"number"},{"type":"string","role":"style","p":{"role":"style"}}],"rows":[{"c":[{"v":"8","f":"2014-08"},{"v":"68435.52"},{"v":"orange"}]}]}
数据B:
{"cols":[{"label":"Month","type":"string"},{"label":"Total","type":"number"},{"type":"string","role":"style","p":{"role":"style"}}],"rows":[{"c":[{"v":"9","f":"2014-09"},{"v":"67348.25"},{"v":"orange"}]}]}
但是每当我绘制图表时我总是收到这个错误:
all series on a given axis must be of the same data type
这是我的代码:
var dataA = new google.visualization.DataTable(data1);
var dataB = new google.visualization.DataTable(data2);
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
var diffData = chart.computeDiff(dataA, dataB);
chart.draw(diffData);
--
编辑:
jsFiddle:
http://jsfiddle.net/9svvm1rj/
在摆弄我的 JS 之后,我发现 "style" 列 ({"type":"string", "role":"style"}
) 导致了问题。
我不知道这是 Google 图表 API 上的错误还是尚未实现的功能,所以现在我删除了样式并且它起作用了。
这是工作 fiddle:http://jsfiddle.net/nb795hyx/
我正在尝试使用 Google 可视化生成差异图表来比较两组数据。 (https://developers.google.com/chart/interactive/docs/gallery/diffchart)
数据A:
{"cols":[{"label":"Month","type":"string"},{"label":"Total","type":"number"},{"type":"string","role":"style","p":{"role":"style"}}],"rows":[{"c":[{"v":"8","f":"2014-08"},{"v":"68435.52"},{"v":"orange"}]}]}
数据B:
{"cols":[{"label":"Month","type":"string"},{"label":"Total","type":"number"},{"type":"string","role":"style","p":{"role":"style"}}],"rows":[{"c":[{"v":"9","f":"2014-09"},{"v":"67348.25"},{"v":"orange"}]}]}
但是每当我绘制图表时我总是收到这个错误:
all series on a given axis must be of the same data type
这是我的代码:
var dataA = new google.visualization.DataTable(data1);
var dataB = new google.visualization.DataTable(data2);
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
var diffData = chart.computeDiff(dataA, dataB);
chart.draw(diffData);
--
编辑:
jsFiddle: http://jsfiddle.net/9svvm1rj/
在摆弄我的 JS 之后,我发现 "style" 列 ({"type":"string", "role":"style"}
) 导致了问题。
我不知道这是 Google 图表 API 上的错误还是尚未实现的功能,所以现在我删除了样式并且它起作用了。
这是工作 fiddle:http://jsfiddle.net/nb795hyx/