I have plotly pie chart, and some times the title overlaps with labels. Though I know how to manually rotate the chart, I'd like to add a zoom in/zoom out mode bar button for users to zoom out if the chart ever overlaps. This button option is not visible by default for pie charts.
However, when I follow the instructions here about adding modebarbuttons, it doesn't work. I'd like all the default buttons that come with a pie chart + the zoom in/out.
library(dplyr)
library(plotly)
pie_chart_margins <- list(
l = 40,
r = 40,
b = 30,
t = 60,
pad = 4
)
data <- tibble(category = c("Big Project", "Work as Usual", "Other"),
score = c(75.4, 3.4, 1.2))
pie_chart_text_format <- list(
family = "Arial",
size = 11)
my_colors <- c("#CA001B", "#1D28B0", "#D71DA4", "#00A3AD", "#FF8200", "#753BBD", "#00B5E2", "#008578", "#EB6FBD", "#FE5000", "#6CC24A", "#D9D9D6", "#AD0C27", "#950078")
fig <- plot_ly(type='pie', labels=data$category , values=data$score,
textinfo='label+percent', marker = list(colors = my_colors), insidetextfont = list(color = '#FFFFFF'),
insidetextorientation='horizontal') %>%
config(modeBarButtonsToAdd = list(list("zoomIn2d"), list("zoomOut2d")))
fig %>% layout(font=pie_chart_text_format, showlegend = FALSE, title = list(text = "Required Project Capacity\nby Type",
font = "Arial"), margin = pie_chart_margins)