Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

htmlwidgets #177

Open
moodymudskipper opened this issue May 25, 2023 · 0 comments
Open

htmlwidgets #177

moodymudskipper opened this issue May 25, 2023 · 0 comments
Labels
Milestone

Comments

@moodymudskipper
Copy link
Collaborator

These work but the output is very verbose, I'm not sure if we can have a general constructor for htmlwidgets but it's worth investigating. constructors for common widgets would be great in any case.

constructive::construct(rhandsontable::rhandsontable(cars))
#> list(
#>   x = list(
#>     data = "[{\"speed\":4,\"dist\":2},{\"speed\":4,\"dist\":10},{\"speed\":7,\"dist\":4},{\"speed\":7,\"dist\":22},{\"speed\":8,\"dist\":16},{\"speed\":9,\"dist\":10},{\"speed\":10,\"dist\":18},{\"speed\":10,\"dist\":26},{\"speed\":10,\"dist\":34},{\"speed\":11,\"dist\":17},{\"speed\":11,\"dist\":28},{\"speed\":12,\"dist\":14},{\"speed\":12,\"dist\":20},{\"speed\":12,\"dist\":24},{\"speed\":12,\"dist\":28},{\"speed\":13,\"dist\":26},{\"speed\":13,\"dist\":34},{\"speed\":13,\"dist\":34},{\"speed\":13,\"dist\":46},{\"speed\":14,\"dist\":26},{\"speed\":14,\"dist\":36},{\"speed\":14,\"dist\":60},{\"speed\":14,\"dist\":80},{\"speed\":15,\"dist\":20},{\"speed\":15,\"dist\":26},{\"speed\":15,\"dist\":54},{\"speed\":16,\"dist\":32},{\"speed\":16,\"dist\":40},{\"speed\":17,\"dist\":32},{\"speed\":17,\"dist\":40},{\"speed\":17,\"dist\":50},{\"speed\":18,\"dist\":42},{\"speed\":18,\"dist\":56},{\"speed\":18,\"dist\":76},{\"speed\":18,\"dist\":84},{\"speed\":19,\"dist\":36},{\"speed\":19,\"dist\":46},{\"speed\":19,\"dist\":68},{\"speed\":20,\"dist\":32},{\"speed\":20,\"dist\":48},{\"speed\":20,\"dist\":52},{\"speed\":20,\"dist\":56},{\"speed\":20,\"dist\":64},{\"speed\":22,\"dist\":66},{\"speed\":23,\"dist\":54},{\"speed\":24,\"dist\":70},{\"speed\":24,\"dist\":92},{\"speed\":24,\"dist\":93},{\"speed\":24,\"dist\":120},{\"speed\":25,\"dist\":85}]" |>
#>       structure(class = "json"),
#>     rClass = "data.frame",
#>     rColClasses = list(speed = "numeric", dist = "numeric"),
#>     rColnames = list("speed", "dist"),
#>     rColHeaders = c("speed", "dist"),
#>     rRowHeaders = NULL,
#>     rDataDim = c(50L, 2L),
#>     selectCallback = FALSE,
#>     colHeaders = c("speed", "dist"),
#>     rowHeaders = c(
#>       "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
#>       "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27",
#>       "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40",
#>       "41", "42", "43", "44", "45", "46", "47", "48", "49", "50"
#>     ),
#>     columns = list(
#>       list(
#>         type = "numeric",
#>         numericFormat = list(pattern = "0.00"),
#>         renderer = "customRenderer" |>
#>           structure(class = "JS_EVAL"),
#>         default = NA
#>       ),
#>       list(
#>         type = "numeric",
#>         numericFormat = list(pattern = "0.00"),
#>         renderer = "customRenderer" |>
#>           structure(class = "JS_EVAL"),
#>         default = NA
#>       )
#>     ),
#>     width = NULL,
#>     height = NULL,
#>     debug = 0,
#>     search = FALSE,
#>     stretchH = "none",
#>     comments = FALSE,
#>     contextMenu = list(
#>       items = list(
#>         row_above = list(),
#>         row_below = list(),
#>         remove_row = list(),
#>         hsep3 = list(name = "---------"),
#>         undo = list(),
#>         redo = list(),
#>         hsep4 = list(name = "---------"),
#>         alignment = list()
#>       )
#>     )
#>   ),
#>   width = NULL,
#>   height = NULL,
#>   sizingPolicy = list(
#>     defaultWidth = "100%",
#>     defaultHeight = "100%",
#>     padding = 5,
#>     fill = NULL,
#>     viewer = list(
#>       defaultWidth = NULL,
#>       defaultHeight = NULL,
#>       padding = NULL,
#>       fill = TRUE,
#>       suppress = FALSE,
#>       paneHeight = NULL
#>     ),
#>     browser = list(
#>       defaultWidth = NULL,
#>       defaultHeight = NULL,
#>       padding = NULL,
#>       fill = FALSE,
#>       external = FALSE
#>     ),
#>     knitr = list(defaultWidth = NULL, defaultHeight = NULL, figure = TRUE)
#>   ),
#>   dependencies = NULL,
#>   elementId = NULL,
#>   preRenderHook = NULL,
#>   jsHooks = list()
#> ) |>
#>   structure(class = c("rhandsontable", "htmlwidget"), package = "rhandsontable")
constructive::construct(reactable::reactable(cars))
#> list(
#>   x = list(
#>     tag = list(
#>       name = "Reactable",
#>       attribs = list(
#>         data = "{\"speed\":[4,4,7,7,8,9,10,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,16,16,17,17,17,18,18,18,18,19,19,19,20,20,20,20,20,22,23,24,24,24,24,25],\"dist\":[2,10,4,22,16,10,18,26,34,17,28,14,20,24,28,26,34,34,46,26,36,60,80,20,26,54,32,40,32,40,50,42,56,76,84,36,46,68,32,48,52,56,64,66,54,70,92,93,120,85]}" |>
#>           structure(class = "json"),
#>         columns = list(
#>           list(accessor = "speed", name = "speed", type = "numeric"),
#>           list(accessor = "dist", name = "dist", type = "numeric")
#>         ),
#>         defaultPageSize = 10,
#>         paginationType = "numbers",
#>         showPageInfo = TRUE,
#>         minRows = 1,
#>         dataKey = "07a804ae7aace5484d58a1b2320892d9"
#>       ),
#>       children = list()
#>     ) |>
#>       structure(class = c("reactR_component", "shiny.tag")),
#>     class = "reactR_markup"
#>   ),
#>   width = "auto",
#>   height = "auto",
#>   sizingPolicy = list(
#>     defaultWidth = NULL,
#>     defaultHeight = NULL,
#>     padding = NULL,
#>     fill = NULL,
#>     viewer = list(
#>       defaultWidth = NULL,
#>       defaultHeight = NULL,
#>       padding = NULL,
#>       fill = TRUE,
#>       suppress = FALSE,
#>       paneHeight = NULL
#>     ),
#>     browser = list(
#>       defaultWidth = NULL,
#>       defaultHeight = NULL,
#>       padding = NULL,
#>       fill = FALSE,
#>       external = FALSE
#>     ),
#>     knitr = list(defaultWidth = NULL, defaultHeight = NULL, figure = FALSE)
#>   ),
#>   dependencies = list(),
#>   elementId = NULL,
#>   preRenderHook = NULL,
#>   jsHooks = list()
#> ) |>
#>   structure(class = c("reactable", "htmlwidget"), package = "reactable")
constructive::construct(DT::datatable(cars))
#> list(
#>   x = list(
#>     filter = "none",
#>     vertical = FALSE,
#>     data = data.frame(
#>       ` ` = c(
#>         "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
#>         "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27",
#>         "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40",
#>         "41", "42", "43", "44", "45", "46", "47", "48", "49", "50"
#>       ),
#>       speed = rep(
#>         c(4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25),
#>         c(
#>           2L, 2L, 1L, 1L, 3L, 2L, 4L, 4L, 4L, 3L, 2L, 3L, 4L, 3L, 5L,
#>           1L, 1L, 4L, 1L
#>         )
#>       ),
#>       dist = c(
#>         2, 10, 4, 22, 16, 10, 18, 26, 34, 17, 28, 14, 20, 24, 28, 26, 34, 34, 46, 26,
#>         36, 60, 80, 20, 26, 54, 32, 40, 32, 40, 50, 42, 56, 76, 84, 36, 46, 68, 32,
#>         48, 52, 56, 64, 66, 54, 70, 92, 93, 120, 85
#>       ),
#>       check.names = FALSE
#>     ),
#>     container = "<table class=\"display\">\n  <thead>\n    <tr>\n      <th> </th>\n      <th>speed</th>\n      <th>dist</th>\n    </tr>\n  </thead>\n</table>",
#>     options = list(
#>       columnDefs = list(
#>         list(className = "dt-right", targets = c(1, 2)),
#>         list(orderable = FALSE, targets = 0)
#>       ),
#>       order = list(),
#>       autoWidth = FALSE,
#>       orderClasses = FALSE
#>     ) |>
#>       structure(escapeIdx = "true"),
#>     selection = list(mode = "multiple", selected = NULL, target = "row", selectable = NULL)
#>   ) |>
#>     structure(colnames = c(" ", "speed", "dist"), rownames = TRUE),
#>   width = NULL,
#>   height = NULL,
#>   sizingPolicy = list(
#>     defaultWidth = "100%",
#>     defaultHeight = "auto",
#>     padding = NULL,
#>     fill = NULL,
#>     viewer = list(
#>       defaultWidth = NULL,
#>       defaultHeight = NULL,
#>       padding = NULL,
#>       fill = TRUE,
#>       suppress = FALSE,
#>       paneHeight = NULL
#>     ),
#>     browser = list(
#>       defaultWidth = NULL,
#>       defaultHeight = NULL,
#>       padding = NULL,
#>       fill = FALSE,
#>       external = FALSE
#>     ),
#>     knitr = list(defaultWidth = NULL, defaultHeight = NULL, figure = FALSE)
#>   ),
#>   dependencies = list(
#>     list(
#>       name = "jquery",
#>       version = "3.6.0",
#>       src = list(file = "lib/3.6.0"),
#>       meta = NULL,
#>       script = "jquery-3.6.0.min.js",
#>       stylesheet = NULL,
#>       head = NULL,
#>       attachment = NULL,
#>       package = "jquerylib",
#>       all_files = TRUE
#>     ) |>
#>       structure(class = "html_dependency"),
#>     list(
#>       name = "dt-core",
#>       version = "1.12.1",
#>       src = list(
#>         file = "/Users/Antoine/Library/R/arm64/4.2/library/DT/htmlwidgets/lib/datatables"
#>       ),
#>       meta = NULL,
#>       script = "js/jquery.dataTables.min.js",
#>       stylesheet = c("css/jquery.dataTables.min.css", "css/jquery.dataTables.extra.css"),
#>       head = NULL,
#>       attachment = NULL,
#>       package = NULL,
#>       all_files = FALSE
#>     ) |>
#>       structure(class = "html_dependency"),
#>     list(
#>       name = "jquery",
#>       version = "3.5.1",
#>       src = list(file = "lib/jquery"),
#>       meta = NULL,
#>       script = "jquery.min.js",
#>       stylesheet = NULL,
#>       head = NULL,
#>       attachment = NULL,
#>       package = "crosstalk",
#>       all_files = TRUE
#>     ) |>
#>       structure(class = "html_dependency"),
#>     list(
#>       name = "crosstalk",
#>       version = "1.2.0",
#>       src = list(file = "www"),
#>       meta = NULL,
#>       script = "js/crosstalk.min.js",
#>       stylesheet = "css/crosstalk.min.css",
#>       head = NULL,
#>       attachment = NULL,
#>       package = "crosstalk",
#>       all_files = TRUE
#>     ) |>
#>       structure(class = "html_dependency")
#>   ),
#>   elementId = NULL,
#>   preRenderHook = (function(instance) {
#>     data = instance[["x"]][["data"]]
#>     if (object.size(data) > 1500000 && getOption("DT.warn.size", TRUE)) warning("It seems your data is too big for client-side DataTables. You may ", "consider server-side processing: https://rstudio.github.io/DT/server.html")
#>     data = escapeData(data, escape, colnames)
#>     data = unname(data)
#>     instance$x$data = data
#>     instance
#>   }) |>
#>     (`environment<-`)(constructive::env("0x149150bd0", parents = "namespace:DT")),
#>   jsHooks = list()
#> ) |>
#>   structure(class = c("datatables", "htmlwidget"), package = "DT")

Created on 2023-05-25 with reprex v2.0.2

@moodymudskipper moodymudskipper added this to the 0.2 milestone May 28, 2023
@moodymudskipper moodymudskipper modified the milestones: 0.2, backlog Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant