0
任何人都可以在Google聊天儀表板中建議我使用代碼實現向下鑽取功能。在谷歌圖表儀表板中鑽取
說如果我點擊一年,它應該鑽到下一級別說月,然後到幾周,然後幾天。
其稱爲向下鑽取功能。 這是代碼是爲圖...我想知道如何在儀表板中使用 - 說類別過濾器。
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Category', 'Name', 'Value'],
['Foo', 'Fiz', 5],
['Foo', 'Buz', 2],
['Bar', 'Qud', 7],
['Bar', 'Piz', 4],
['Cad', 'Baz', 6],
['Cad', 'Nar', 8]
]);
var aggregateData = google.visualization.data.group(data, [0], [{
type: 'number',
label: 'Value',
column: 2,
aggregation: google.visualization.data.sum
}]);
var topLevel = true;
var chart = new google.visualization.ColumnChart(document.querySelector('#chart'));
var options = {
height: 400,
width: 600
};
function draw (category) {
if (topLevel) {
// rename the title
options.title = 'Top Level data';
// draw the chart using the aggregate data
chart.draw(aggregateData, options);
}
else {
var view = new google.visualization.DataView(data);
// use columns "Name" and "Value"
view.setColumns([1, 2]);
// filter the data based on the category
view.setRows(data.getFilteredRows([{column: 0, value: category}]));
// rename the title
options.title = 'Category: ' + category;
// draw the chart using the view
chart.draw(view, options);
}
}
google.visualization.events.addListener(chart, 'select', function() {
if (topLevel) {
var selection = chart.getSelection();
// drill down if the selection isn't empty
if (selection.length) {
var category = aggregateData.getValue(selection[0].row, 0);
topLevel = false;
draw(category);
}
}
else {
// go back to the top
topLevel = true;
draw();
}
});
draw();
}
//google.load('visualization', '1', {packages: ['corechart'], callback: drawchart});
//google.load('visualization', '1', {packages: ['corechart'], callback: drawchart});
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart"></div>
</body>
</html>
問候, 般若
什麼是地獄是一個向下鑽探功能? – danhardman 2014-10-31 11:48:04
@E先生說如果我點擊一年,它應該深入到下一個級別說月,然後到幾周,然後幾天。 其稱爲向下鑽取功能。 – Prajna 2014-10-31 11:57:28
發佈你到目前爲止的一些代碼 – danhardman 2014-10-31 12:02:41