Unfortunately, there is no way to get the color of a slice. You can, however, use the 'colors' option to specify your own colors. You will then be able to match the row to the index in your color array.
- Sergey On Sat, May 11, 2013 at 3:07 AM, 葉鎰維 <[email protected]> wrote: > Dear all, > > I have a problem to click the slice of pie chart and I wanna get the value > and slice color. > > I know how to get the value but I don't known which method or attribute > can I use to get the color I selected. > > this is the related script: > > var chart = new > google.visualization.PieChart(document.getElementById('chart_div')); > > //click slice to show the value and color > function selectHandler() { > var selectedItem = chart.getSelection()[0]; > if (selectedItem) { > var val = data.getValue(selectedItem.row, 0); > alert('value: ' + val); > } > } > google.visualization.events.addListener(chart, 'select', selectHandler); > > > > Please help me, thanks! > > Brian > > -- > You received this message because you are subscribed to the Google Groups > "Google Chart 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-chart-api?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Google Chart 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-chart-api?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
