JohnCoene / echarts4r

🐳 ECharts 5 for R
http://echarts4r.john-coene.com/
Other
585 stars 82 forks source link

Colouring bars in bar chart for polar configuration #635

Open MrMisc opened 2 weeks ago

MrMisc commented 2 weeks ago

Hi again!

I have been having lots of fun using echarts packages for a while now but I was wondering if anyone could help me unravel this problem for me, using this example

I really want to colour the bars in a radial plot I have

image

I have tried the following, an attempt at extending this solution


bigtable %>%mutate(Timestamp = as.POSIXct(Timestamp, format="%Y-%m-%dT%H:%M:%S", tz="UTC")) %>%
  filter(Liberation..>0 & Player.Count>0) %>% 
  arrange(Liberation..) %>%
  mutate(colors = ifelse(Event<100, "purple","cyan")) %>% 
  # mutate(Event = exp_scale(Event)) %>%  
  e_charts(Name) %>%
  e_polar() %>% 
  e_angle_axis(max = 100) %>% 
  e_radius_axis(Name,axisLabel = list(fontSize = 11, rotate = 20, interval = 0)) %>% 
  e_bar(Liberation.., colors,coord_system = "polar",
        emphasis = list(focus = 'self'),
        label = list(
          formatter = '{c}%',
          fontSize = 9,
          show = TRUE,
          rotate = 0,
          align = 'left',
          verticalAlign = 'middle',
          position = 'insideBottom',
          rich = list(name = list())
        )) %>%
  e_add_nested("itemStyle",colors) %>% 
  e_theme("chalk") %>% 
  e_datazoom(bottom = "5%", height = 4) %>% 
  e_legend(show = FALSE) %>% 
  e_title("Liberation Status of all active planets","HELLDIVERS 2") %>% 
  e_tooltip()

Any guidance would be greatly appreciated. Thank you!