在这里,我创建了一个仪表板http://jsbin.com/OJAnaji/27/edit (googl可视化)基于这些数据:
data = google.visualization.arrayToDataTable([
['Name', 'Gender', 'Age', 'Donuts eaten'],
['Michael' , 'Male', 12, 5],
['Elisa', 'Female', 20, 7],
['Robert', 'Male', 7, 3],
['John', 'Male', 54, 2],
['Jessica', 'Female', 22, 6],
['Aaron', 'Male', 3, 1],
['Margareth', 'Female', 42, 8],
['Miranda', 'Female', 33, 6]
]);除了ColumnChart之外,所有的工作都很好,因为我得到了错误:给定轴上的所有级数都必须是相同的数据类型×。
ColumnChart代码:
var wrapper = new google.visualization.ChartWrapper({
chartType: 'ColumnChart',
containerId: 'chart3'
});并绘制功能:
// Create a dashboard
new google.visualization.Dashboard(document.getElementById('dashboard')).
// Establish bindings, declaring the both the slider and the category
// picker will drive both charts.
bind([slider, categoryPicker, stringFilter], [pie, table, wrapper]).
// Draw the entire dashboard.
draw(data, {'allowHtml':true, 'cssClassNames': 'cssClassNames'});
}
google.load('visualization', '1', {packages:['controls'], callback: drawVisualization});和HTML:
<div class="col-md-4" style="float: left;" id="chart3"></div>我有没有办法在Y轴上显示(过滤数据)等列'Name‘,在X轴上显示’年龄‘,在Y轴上显示列'Name’,在X轴上显示‘甜甜圈吃’?
更新:我正在尝试这个:
“视图”:{“列”:0,3}
但什么都没发生
发布于 2014-02-18 17:43:43
您在包装器中指定视图了吗?
var wrapper = new google.visualization.ChartWrapper({
chartType: 'ColumnChart',
containerId: 'chart3',
view: {
columns: [0,3]
}
});顺便说一句,向Dashboad#draw调用传递第二个参数不会有任何效果--它不接受任何选项:
new google.visualization.Dashboard(document.getElementById('dashboard')).
// Establish bindings, declaring the both the slider and the category
// picker will drive both charts.
bind([slider, categoryPicker, stringFilter], [pie, table, wrapper]).
// Draw the entire dashboard.
draw(data);相反,这些应该作为options参数在适当的ChartWrapper中传递(在指定的选项下,很可能是Table的包装器)。
https://stackoverflow.com/questions/21768295
复制相似问题