Retrieving data from a vertical bar and pie chart

109 views
Skip to first unread message

Wesley Chin

unread,
Sep 11, 2012, 7:19:26 AM9/11/12
to google-visua...@googlegroups.com
Hi everyone,

I have 2 working charts (a vertical bar and a pie chart) that are displaying totals for me.  I want to add up all the totals that are displayed on each chart and put it into the heading, is that possible?  I have a div with the heading (I am using html, PHP and javascript) and would like to put the total in it.  How can I achieve that?

Regards,
Wesley

asgallant

unread,
Sep 11, 2012, 11:52:57 AM9/11/12
to google-visua...@googlegroups.com
You can use the group function to sum columns in your DataTable, and then insert that total into your heading:

// group the data table to get the sum of column 1
var group google.visualization.data.group(data[{
    column0,
    type'number',
    // modify column 0 to return the same for all rows
    // so we can get the sum of everything in column 1
    modifierfunction ({
        return 0;
    }
}][{
    // get the sum of column 1
    column1,
    type'number',
    aggregationgoogle.visualization.data.sum
}]);

var sum group.getValue(01);
// put the sum wherever you need it

Wesley Chin

unread,
Sep 12, 2012, 4:07:48 AM9/12/12
to google-visua...@googlegroups.com
Thank you very very much!  Worked perfectly!

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/RwjXWUUKn-0J.

To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

asgallant

unread,
Sep 12, 2012, 11:45:09 AM9/12/12
to google-visua...@googlegroups.com
You're welcome.
To unsubscribe from this group, send email to google-visualization-api+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages