Question

Here i create an dashboard http://jsbin.com/OJAnaji/27/edit (googl visualisation ) based on this data:

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]
    ]);

and all works fine except ColumnChart becouse there I get error: All series on a given axis must be of the same data type×

ColumnChart code:

var wrapper = new google.visualization.ChartWrapper({
    chartType: 'ColumnChart',
    containerId: 'chart3'
  });

and draw function:

// 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});

and HTML:

          <div class="col-md-4" style="float: left;" id="chart3"></div>

Is there any way for me to show (filter data) etc. column 'Name' on Y axis and 'Age' on X axis or column 'Name' on Y axis and 'Donuts eaten' on X axis ???

UPDATE: I was try this:

'view': {'columns': [0,3]}

but nothing happend

Was it helpful?

Solution

Did you specify the view in the wrapper?

var wrapper = new google.visualization.ChartWrapper({
    chartType: 'ColumnChart',
    containerId: 'chart3',
    view: {
        columns: [0,3]
    }
});

Incidentally, passing a second parameter to the Dashboad#draw call won't do anything - it doesn't accept any options:

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);

Those should instead be passed as the options parameter in the appropriate ChartWrapper (likely a wrapper for a Table, given the specified options).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top