Is there any way to preselect a slice on a Google Pie chart

659 views
Skip to first unread message

S_OSTA

unread,
May 23, 2012, 8:47:29 AM5/23/12
to Google Visualization API
Hello All

Given a simple pie chart like https://developers.google.com/chart/interactive/docs/gallery/piechart#Example

If I click on one of the slices it becomes selected (indicated by a
coloured arc appearing at the edge of the slice) but is there any way
to draw this pie with slice 1 preselected?

Thanks for your help.

asgallant

unread,
May 23, 2012, 11:20:56 AM5/23/12
to google-visua...@googlegroups.com
Yes, call the chart's #setSelection method in a 'ready' event listener:

google.visualization.events.addListener(pie'ready'function ({
       // set the selection to the first row in the chart 
    pie.setSelection([{row0}]);
}); 

S_OSTA

unread,
May 24, 2012, 9:00:52 AM5/24/12
to google-visua...@googlegroups.com
Thanks asgallant,

Worked like a charm.

asgallant

unread,
May 24, 2012, 9:23:01 AM5/24/12
to google-visua...@googlegroups.com
You're welcome.
Reply all
Reply to author
Forward
0 new messages