Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

gvisPieChart -custom change in pie slices colors and print the labels outside

$
0
0

I am using gvisPieChart in R and wanted to change the colors based on client requirement and also need to place the labels outside pie with small line pointing to the value from slice .

Code used

library(googleVis)
library(dplyr)

df <- data.frame(
  product(Current_Model_Salary_All_Dimensions$'Grouped_Function'),
  vl1=c(round((Current_Model_Salary_All_Dimensions$Amount/10000000),digits=2)))

df1 <- 
  df %>% 
  group_by(product) %>% 
  summarise(val1 = sum(val1)) %>% 
  arrange(desc(val1))

df2 <- 
  rbind(top_n(df1,6), slice(df1,7:n()) %>% 
          summarise(product="Grouped",val1=sum(val1)))

df3 <- if(count(df1)<6){df1} else {df2}
M <- gvisPieChart(df3,options=list(width=450, height=300,fontSize=10,legend='left'))
plot(M)

Viewing all articles
Browse latest Browse all 201839

Trending Articles