Hi I am trying to plot a pie chart in R plotly for my shiny app where I want to format hover numbers to K or M but couldn't the correct solution for that Here is a reproducible code that I am using, any help would be appreciated
full_data<-data.frame("Name"=c("Q1","Q1","Q2","Q2","Q3","Q3"),"Values"=c(245645,866556,26440,65046,641131,463265))
desc<-full_data%>%group_by(Name)%>%summarise(values=sum(Values))
fig<-plot_ly(desc,labels=~Name,values=~values,type = "pie",
insidetextfont = list(color = 'white'),
marker = list(colors = colors,
line = list(color = '#FFFFFF', width = 1),hoverformat = ',.0f'))%>%
layout(title = list(text='<b> Volume(lbs.) </b>',x=0,y=1,titlefont=20),
font=list(family="Corbel",size=15,color="rgb(33,33,33"),
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
legend=list(font=list(size=18)),
margin = list(pad = 10,t=60))
fig
Here you can see hover number is 1,112,201 what I want this as 1.1M or if the number is less than a million let's say the number is 125,463 then it should be 125.5K while we hover over the pie chart
Thank you in advance