--- title: "HTML Widgets: Advanced Topics" date: "`r Sys.Date()`" output: html_document: highlight: kate toc: true toc_depth: 4 mathjax: null vignette: > %\VignetteIndexEntry{Advanced} %\VignetteEngine{knitr::rmarkdown} \usepackage[utf8]{inputenc} --- ## Overview This article covers several aspects of creating widgets that are not required by all widgets, but are an essential part of getting bindings to certain types of JavaScript libraries to work properly. Topics covered include: * Transforming JSON representations of R objects into representations required by JavaScript libraries (e.g. an R data frame to a d3 dataset). * Tracking instance-specific widget data within JavaScript bindings. * Passing JavaScript functions from R to JavaScript (e.g. a user provided formatting or drawing function) * Generating custom HTML to enclose a widget (the default is a `
widget_html.widgetname
so it need not be formally exported from your package or otherwise registered with **htmlwidgets**.
(**htmlwidgets** 1.5.2 and earlier used a convention of widgetname_html
. This is still supported for now, but the new widget_html.widgetname
convention is recommended going forward, as it seems less likely to lead to false positives.)
Most widgets won't need a custom HTML function but if you need to generate custom HTML for your widget (e.g. you need an `` or a `` rather than a `