dreamRs / billboarder

:bar_chart: R Htmlwidget for billboard.js
https://dreamrs.github.io/billboarder/
Other
174 stars 21 forks source link

Would u mind posting an example of a rotated axis groupd bar chart? #30

Closed lukr90 closed 1 year ago

lukr90 commented 1 year ago

I am having difficulty reproducing a running example. Would appreciate it very much if you could post one like the below :-) https://naver.github.io/billboard.js/demo/#Axis.RotatedAxisGroupedBar

pvictor commented 1 year ago

Hello,

Here you go :

library(billboarder)

mydata <- data.frame(
  "Index" = letters[1:6],
  "Male" = c(-83, -143, -100, -120, -150, -85),
  "Female" = c(130, 100, 140, 175, 150, 50)
)

billboarder() %>% 
  bb_barchart(
    data = mydata,
    stacked = TRUE,
    rotated = TRUE
  ) %>% 
  bb_data(
    labels = list(
      format = JS("function(v, id) {return Math.abs(v);}")
    )
  ) %>% 
  bb_y_grid(
    show = TRUE,
    lines = list(
      list(value = 0, class = "base-line")
    )
  ) %>% 
  bb_y_axis(
    tick = list(
      format = JS("function(v) {return Math.abs(v);}")
    )
  ) %>% 
  bb_x_axis(show = FALSE) %>% 
  bb_add_style(".base-line line" = "stroke-width: 3px; stroke: #000;")

image

Victor

lukr90 commented 1 year ago

great, thanks! :)