Description Usage Value Examples
'dataui' also ships a standalone version of the 'JavaScript' allowing
for usage outside of a traditional htmlwidget
context. The variable dataui
is added to window
object. Usage of html_dependency_dataui
should likely
be accompanied with html_dependency_react
along with
html_dependency_reacttools
for hydrate
.
1 |
htmltools::htmlDependency
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | library(htmltools)
library(dataui)
browsable(
tagList(
reactR::html_dependency_react(),
reactR::html_dependency_reacttools(),
html_dependency_dataui(),
tags$div(id = "chart"),
tags$div(id = "chart-hydrate"),
tags$div(id = "chart-hydrate-fromwidget"),
tags$script(HTML(
sprintf(
"
const sparklineProps = {
ariaLabel: 'This is a Sparkline of...',
width: 500,
height: 100,
margin: { top: 24, right: 80, bottom: 24, left: 8 },
};
const data = {data: [1,2,3,4,5,6]}
const renderTooltip = function (_ref) {
var datum = _ref.datum;
return React.createElement(
'div',
null,
datum.x && React.createElement(
'div',
null,
datum.x
),
React.createElement(
'div',
null,
datum.y ? datum.y.toFixed(2) : \"--\"
)
);
}
const spk = React.createElement(
dataui.SparklineWithTooltip,
Object.assign(
data,
sparklineProps,
{renderTooltip: renderTooltip}
),
React.createElement(dataui.SparklineLineSeries)
)
ReactDOM.render(spk, document.getElementById('chart'))
const spk_hydrate = window.reactR.hydrate(
dataui,
{
name: 'SparklineWithTooltip',
attribs: {...sparklineProps, ...data, ...renderTooltip},
children: [
{name: 'SparklineLineSeries', attribs: {stroke: 'purple'}, children: []}
]
}
)
ReactDOM.render(spk_hydrate, document.getElementById('chart-hydrate'))
const spk_hydrate_from_widget = window.reactR.hydrate(
dataui,
%s
)
ReactDOM.render(spk_hydrate_from_widget, document.getElementById('chart-hydrate-fromwidget'))
",
jsonlite::toJSON(
dui_sparkline(data = 1:6, components = list(dui_sparklineseries(stroke="gray")))$x$tag,
auto_unbox = TRUE,
force = TRUE
)
)
))
)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.