I Have Problem in Google chart.
I am using asp.net Mvc. After I fetch data from controller, I pass it into Google chart .
When i use manual data, for example:
['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 'Rwanda', 'Average'],
['2004/05',  165,      938,         522,             998,           450,      614.6],
It Show me correctly .
But how can i add my data dynamically into Google chart ?
This is my code:
for (var i = 0; i < chartsdata.length; i++) {
    var data = google.visualization.arrayToDataTable([
        ['Element', 'Density', {role: 'style'}],
        [chartsdata[i].MonthValue, chartsdata[i].CountValue, '#b87333']
    ]);
    var options = {
        title: ''
    };
    var chart = new google.visualization.ComboChart(document.getElementById('chartdiv'));
    chart.draw(data, options);
}
                you can use "google.visualization.DataTable()" and its "addRow()"  Google code
var data = new google.visualization.DataTable();
data.addColumn('string', 'Month');
data.addColumn('number', 'Count');
for (var i = 0; i < chartsdata.length; i++) {
     data.addRow([chartsdata[i].month, chartsdata[i].count]);
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With