I want to disable the toggle of the legends on the right side. Still show the legends. The toggle does not make sense to me, it changes the percentage.
library(plotly)
# Data Preparation
labels = c('Beverage','Vegetable','Dairy','Fish')
values = c(4500, 2500, 1053, 500)
# Data Visualization
fig <- plot_ly(type='pie', labels=labels, values=values,
textinfo='label+percent',
insidetextorientation='radial')
fig <- fig %>% layout(title = "Number of Sales by Parts of Supermarket in a Day")
fig
Clicking the legend in plotly chart toggles whether to include that section so the percentages change to show each section as a % of the remaining total. Double clicking toggles to hide everything except what you double clicked.
You can disable this functionality with legend.itemclick and legend.itemdoubleclick in layout():
fig <- fig %>% layout(title = "Number of Sales by Parts of Supermarket in a Day",
legend = list(itemclick = FALSE,
itemdoubleclick = FALSE))