Bar plots in dygraphs

I am trying to replicate the below graph to my dataset (df)

dyBarChart <- function(dygraph) {
  dyPlotter(dygraph = dygraph,
            name = "BarChart",
            path = system.file("plotters/barchart.js",
                               package = "dygraphs"))
}

dygraph(mdeaths) %>%
  dyRangeSelector() %>%
  dyBarChart()

Above it the example where bar plot is applied on mdeaths .

My dataset df is shown below

df1 <- structure(list(Year = c(2021, 2022, 2020, 2021, 2022, 2020, 2021, 
2020, 2021, 2020, 2021, 2020, 2021, 2020, 2021, 2020, 2021, 2020, 
2021, 2020, 2021, 2020, 2021, 2020, 2021), mon_day = c("January", 
"January", "February", "February", "February", "March", "March", 
"April", "April", "May", "May", "June", "June", "July", "July", 
"August", "August", "September", "September", "October", "October", 
"November", "November", "December", "December"), `R` = c(-427, 
-389, 18, -357, -230, -383, -259, -1233, -232, -875, -190, -489, 
-299, -448, -577, -662, -762, -552, -621, -488, -409, -290, -76, 
-155, -10)), row.names = c(NA, -25L), groups = structure(list(
    Year = c(2020, 2021, 2022), .rows = structure(list(c(3L, 
    6L, 8L, 10L, 12L, 14L, 16L, 18L, 20L, 22L, 24L), c(1L, 4L, 
    7L, 9L, 11L, 13L, 15L, 17L, 19L, 21L, 23L, 25L), c(2L, 5L
    )), ptype = integer(0), class = c("vctrs_list_of", "vctrs_vctr", 
    "list"))), row.names = c(NA, -3L), class = c("tbl_df", "tbl", 
"data.frame"), .drop = TRUE), class = c("grouped_df", "tbl_df", 
"tbl", "data.frame"))

So I need to plot bar plot for the above datasets using dygraphs. I know we have to convert df to time series but not sure how to convert. Can any one help?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.