Hi Andrew,
Thank you so much. I changed my code and it worked perfectly. But still I
am seeing another problem.
I have code to calculate total kbUsage for perticular MDN. That was working
before. But now it just gives total no of rows returned from the DB,
instead of total of all kbUsage.
var group = google.visualization.data.group(newData , [{
// we need a key column to group on, but since we want all rows
grouped into 1,
// then it needs a constant value
column: 2,
aggregation: google.visualization.data.sum,
type: 'number',
modifier: function () {
return 1;
}
}],
[{
// get the total of all KBUsage
column: 2, //instead of column 2, if i pass 0 (MDN) or (1) category, i
get the actual values of that column in my next alert.
label: 'Total Byte',
type: 'number',
aggregation: function (values) {
var product = 0;
var n = values.length;
for (i = 0; i < n; i++) {
//alert(values[i]); //This alert returns 1 everytime for column: 2,
instead of actual value
product = product + values[i];
}
return product;
}
}]);
document.getElementById('avg').innerHTML = group.getValue(0, 1);
Thanks
On Wednesday, August 6, 2014 8:41:58 AM UTC-4, Andrew Gallant wrote:
> First, you need to remove the "view" parameter from the PieChart's
> ChartWrapper - it is not needed since you are constructing a new DataTable
> for the PieChart to draw from.
>
> var pie = new google.visualization.ChartWrapper({
> chartType: 'PieChart',
> containerId: 'chart1',
> options: options
> });
>
> Second, I see that you are using a document ready event handler to set up
> your AJAX request, which then calls the drawChart function. The problem
> with this approach is that it is possible for document ready to fire, the
> user to trigger the AJAX request, and the AJAX request to return all before
> the Visualization API finishes loading; if this happens, your code will
> throw errors trying to render the charts, or the chart will render
> improperly. It seems unlikely, but I've dealt with other users who have
> run into this exact problem before. If you change from a document ready
> event handler to a callback from the google loader, you can avoid this
> problem:
>
> google.load('visualization', '1', { 'packages': ['corechart', 'controls'],
> callback: function () {
> // code from your document ready handler
> }});
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.