dreamRs / billboarder

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

bb_linechart with points and without #10

Closed pro100mir closed 5 years ago

pro100mir commented 5 years ago

Hi

Is it possible to have on a bb_linechart data1 having points showed and data2 points not showed? Similar like in this example: https://naver.github.io/billboard.js/demo/#LineChartOptions.LinePoint

Thank you, Mircea

pvictor commented 5 years ago

Hello Mircea,

Yes that's possible, here some examples :

library(billboarder)

mydata <- data.frame(
  index = seq_len(100),
  Sine = sin(1:100/10),
  Cosine = 0.5 * cos(1:100/10),
  "Sine.2" = sin(1:100/10) * 0.25 + 0.5
)

# Without mapping
billboarder() %>% 
  bb_linechart(data = mydata, type = "spline") %>% 
  bb_point(show = TRUE) %>% 
  bb_line(point = c("Cosine", "Sine.2"))

# with mapping and one serie
billboarder() %>% 
  bb_linechart(
    data = mydata, 
    mapping = bbaes(index, Cosine), type = "line"
  ) %>%
  bb_point(show = TRUE) %>% 
  bb_line(point = TRUE)

# with mapping and multiple series
mydata2 <- tidyr::gather(data = mydata, "variable", "value", -index)

billboarder() %>% 
  bb_linechart(
    data = mydata2,
    mapping = bbaes(index, value, group = variable), 
    type = "line"
  ) %>%
  bb_point(show = TRUE) %>% 
  bb_line(point = c("Cosine", "Sine.2"))

Victor

pro100mir commented 5 years ago

Thanks a lot!