google.charts.load('current', {
packages: ['controls']
}).then(function() {
var myData = new google.visualization.DataTable();
myData.addColumn('date', 'Date');
myData.addColumn('number', 'Hours Worked');
myData.addRows([
[new Date(2014, 6, 12), 9],
[new Date(2014, 6, 13), 8],
[new Date(2014, 6, 14), 10],
[new Date(2014, 6, 15), 8],
[new Date(2014, 6, 16), 0]
]);
var dash_container = document.getElementById('dashboard_div'),
myDashboard = new google.visualization.Dashboard(dash_container);
var myDateSlider = new google.visualization.ControlWrapper({
controlType: 'ChartRangeFilter',
containerId: 'control_div',
options: {
filterColumnLabel: 'Date'
}
});
var myTable = new google.visualization.ChartWrapper({
chartType : 'Table',
containerId : 'table_div'
});
google.visualization.events.addListener(myTable, 'ready', drawLine);
var myLine = new google.visualization.ChartWrapper({
chartType : 'LineChart',
containerId : 'line_div'
});
myDashboard.bind(myDateSlider, myTable);
myDashboard.draw(myData);
function drawLine() {
var dataTable = myTable.getDataTable();
var dateRange = dataTable.getColumnRange(0);
var xTicks = dataTable.getDistinctValues(0);
myLine.setDataTable(dataTable);
myLine.setOption('hAxis.ticks', xTicks);
myLine.setOption('hAxis.viewWindow.min', dateRange.min);
myLine.setOption('hAxis.viewWindow.max', dateRange.max);
myLine.draw();
}
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="dashboard_div">
<div id="control_div"></div>
<div id="line_div"></div>
<div id="table_div"></div>
</div>
コードはどこですか?何を試しましたか? – borracciaBlu
@borracciaBlu私のコードは、与えられたデモとほぼ同じです – Alvis