ramnathv / htmlwidgets

HTML Widgets for R
http://htmlwidgets.org
Other
792 stars 205 forks source link

How to pass information into the ellipsis argument of the widget's custom HTML function? #482

Open daattali opened 11 months ago

daattali commented 11 months ago

The documentation shows that it's possible to create a custom HTML container for a widget:

WIDGETNAME_html <- function(id, style, class, ...){
  tags$span(id = id, class = class)
}

How can I, as the widget developer, pass information into the ellipsis argument?

More specifically, suppose I have the following widget definition:

MYWIDGET <- function(data, big = TRUE) {
  javascript_data = list()
  htmlwidgets::createWidget(name = 'MYWIDGET', x = javascript_data, width = 400, height = 400, big = big)
}

I would want the big argument to be passed to the custom HTML constructor so that I can add an HTML class to the tag. I know I can pass the information into the x parameter, and then deal with it from javascript, but I want to know how to access a variable in the widget's html construction before it gets into the javascript layer.