To use a Dashboard
element, you need to feed the ChartWrapper
and ControlWrapper
tags into it. Right now you are using only ControlWrapper
and trying to associate it with a chart that is not participating in the dashboard itself (since this is not a ChartWrapper
object). I tried to create an annotated timeline chart as part of a toolbar, but was not successful:
function drawVisualization() { // Prepare the data var data = new google.visualization.DataTable(); data.addColumn('date', 'Date'); data.addColumn('number', 'Sold Pencils'); data.addColumn('string', 'title1'); data.addColumn('string', 'text1'); data.addColumn('number', 'Sold Pens'); data.addColumn('string', 'title2'); data.addColumn('string', 'text2'); data.addRows([ [new Date(2008, 1 ,1), 30000, null, null, 40645, null, null], [new Date(2008, 1 ,2), 14045, null, null, 20374, null, null], [new Date(2008, 1 ,3), 55022, null, null, 50766, null, null], [new Date(2008, 1 ,4), 75284, null, null, 14334, 'Out of Stock', 'Ran out of stock on pens at 4pm'], [new Date(2008, 1 ,5), 41476, 'Bought Pens', 'Bought 200k pens', 66467, null, null], [new Date(2008, 1 ,6), 33322, null, null, 39463, null, null] ]); // Define a slider control for the 'Donuts eaten' column var slider = new google.visualization.ControlWrapper({ 'controlType': 'NumberRangeFilter', 'containerId': 'control1', 'options': { 'filterColumnLabel': 'Sold Pencils', 'ui': {'labelStacking': 'vertical'} } }); // Define a time line chart var timeline = new google.visualization.ChartWrapper({ 'chartType': 'AnnotatedTimeLine', 'containerId': 'chart1', 'options': { 'width': 600, 'height': 300, } }); // Create the dashboard. new google.visualization.Dashboard(document.getElementById('dashboard')). // Configure the slider to affect the piechart bind(slider, timeline). // Draw the dashboard draw(data); }
He cannot draw a chart (although control works fine). Perhaps because the Annotated Time Line chart is a flash chart, it does not work well in dashboards. Or it just might be that the ChartWrapper object type does not allow annotated timelines. If I do the same with a line chart, it works:
function drawVisualization() { // Prepare the data var data = new google.visualization.DataTable(); data.addColumn('date', 'Date'); data.addColumn('number', 'Sold Pencils'); data.addColumn({type: 'string', role: 'annotation'}); data.addColumn({type: 'string', role: 'annotationText'}); data.addColumn('number', 'Sold Pens'); data.addColumn({type: 'string', role: 'annotation'}); data.addColumn({type: 'string', role: 'annotationText'}); data.addRows([ [new Date(2008, 1 ,1), 30000, null, null, 40645, null, null], [new Date(2008, 1 ,2), 14045, null, null, 20374, null, null], [new Date(2008, 1 ,3), 55022, null, null, 50766, null, null], [new Date(2008, 1 ,4), 75284, null, null, 14334, 'Out of Stock', 'Ran out of stock on pens at 4pm'], [new Date(2008, 1 ,5), 41476, 'Bought Pens', 'Bought 200k pens', 66467, null, null], [new Date(2008, 1 ,6), 33322, null, null, 39463, null, null] ]); // Define a slider control for the 'Donuts eaten' column var slider = new google.visualization.ControlWrapper({ 'controlType': 'NumberRangeFilter', 'containerId': 'control1', 'options': { 'filterColumnLabel': 'Sold Pencils', 'ui': {'labelStacking': 'vertical'} } }); // Define a time line chart var timeline = new google.visualization.ChartWrapper({ 'chartType': 'LineChart', 'containerId': 'chart1', 'options': { 'width': 600, 'height': 300, } }); // Create the dashboard. new google.visualization.Dashboard(document.getElementById('dashboard')). // Configure the slider to affect the piechart bind(slider, timeline). // Draw the dashboard draw(data); }