Is it possible to do drill down in pie chart?

Is it possible to do drill down in pie chart?

You mean something like this: https://plot.ly/javascript/pie-chart/#donut-chart ?

I’m assuming drill down refers to something like this, http://www.highcharts.com/demo/column-drilldown

where clicking on one section of a graph allows the user to explore just that series in another graph.

hi!
the thought is good…
please elaborate on the real case scenario…

As drilling down on a pie chat seems a little out of the way, as pie chart only provides us with %ages

The real case scenario would be to increase granularity.

Suppose the pie chart represented the number of votes different presidential candidates have received in America, such as Candidate A has 51% of the popular vote and Candidate B has 49%.

After the user clicks on Candidate A, the user is presented with another graph that shows the votes Candidate A has received broken down by state. Clicking on a state then breaks down the vote count by city.

Any way to do this within plotly?

yes! it can be done I guess…

one way could be to use the on click events
once you click it redirect to a different chart or anything you want to display!

Could you please provide some example codes on how click events will work on Pie chart. I want to pass the value from Pie chart to datatable. Please help.

Take a look at a pie chart example, e.g. http://codepen.io/plotly/pen/af6e1b07afd67fcf684af199893069e2/

Then add some event handler lines to the end of the script, for example

myDiv.on('plotly_hover', function(d) {console.log('hover', d);});
myDiv.on('plotly_unhover', function(d) {console.log('unhover', d);});
myDiv.on('plotly_click', function(d) {console.log('click', d);});

then open the Dev Tools console of your browser and see the events logged.
Events reference: https://plot.ly/javascript/plotlyjs-events/

Thanks for the response. I forgot to mention that I am working on Shiny and would like to add click event feature on Pie Chart. I tried the below code and it’s not working as expected.

output$plotly <- renderPlotly({
colors <- c(‘rgb(211,94,96)’, ‘rgb(128,133,133)’, ‘rgb(144,103,167)’, ‘rgb(171,104,87)’, ‘rgb(114,147,203)’)
p <- plot_ly(data, labels = ~variable1, values = ~variable2, type = ‘pie’,
textposition = ‘inside’,
textinfo = ‘label+percent’,
insidetextfont = list(color = ‘#FFFFFF’),
hoverinfo = ‘label+percent+text’,
text = ~paste(‘Count -’, cnt),
marker = list(colors = colors,
line = list(color = ‘#FFFFFF’, width = 1)),
showlegend = T) %>%
layout(title = ‘Pie Chart with Click Event’,
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
dragmode = “select”)
p
})

output$click <- renderPrint({
d <- event_data(“plotly_click”)
if (is.null(d)) “Click events appear here (double-click to clear)” else d
})