v_specs_custom_mark | R Documentation |
Add custom mark to chart
v_specs_custom_mark(vc, ...)
vc |
An htmlwidget created with |
... |
Options for the legend, see examples or online documentation. |
A vchart()
htmlwidget
object.
library(vchartr)
world_electricity %>%
subset(type == "detail") %>%
vchart() %>%
v_bar(
aes(source, generation, player = year),
direction = "h",
data_id = "mydata"
) %>%
v_specs_custom_mark(
type = "text",
dataId = "mydata",
style = list(
textBaseline = "bottom",
fontSize = 60,
textAlign = "right",
fontWeight = 700,
text = JS("datum => datum.player"),
x = JS(
"(datum, ctx) => {",
" return ctx.vchart.getChart().getCanvasRect().width - 50;",
"}"
),
y = JS(
"(datum, ctx) => {",
" return ctx.vchart.getChart().getCanvasRect().height - 150;",
"}"
),
fill = "grey",
fillOpacity = 0.5
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.