Update chartjs htmlwidget

Sources:

https://www.htmlwidgets.org/develop_intro.html

https://www.chartjs.org/docs/latest/samples/area/line-datasets.html

inst/htmlwidgets/ # directory to add css, js, yaml, libraries

# To modify chartjs high level, go to 
chartjs/R/chartjs.R

# To modify each line of graphs
chartjs/R/series.R

# To adapt newer version of chartjs, I needed to modify 
chartjs/R/options.R

# to add fill in chartjs series
# in charts.R
cjs_base_chart <- function(chartjs, labels, fill, type){
  class(chartjs) <- c(class(chartjs), paste0("cjs_", type))
  chartjs$x$type <- type
  chartjs$x$data$labels <- labels
  chartjs$x$data$fill <- fill
  chartjs
}

How to create a htmlwidget template and install

install.packages("htmlwidgets")
install.packages("devtools")
devtools::create("mywidget")               # create package using devtools
htmlwidgets::scaffoldWidget("mywidget")    # create widget scaffolding
devtools::document()                     # roxygenize, NAMESPACE is updated
devtools::install()                        # install the package  

How to update htmlwidget

setwd("chartjs/")
devtools::document()
devtools::load_all()
devtools::build()

Update cjSeries

# make changes in chartjs/R/series.R 
devtools::document()
devtools::load_all()