v_specs_custom_mark {vchartr} | R Documentation |
Add custom mark to chart
Description
Add custom mark to chart
Usage
v_specs_custom_mark(vc, ...)
Arguments
vc |
An htmlwidget created with |
... |
Options for the legend, see examples or online documentation. |
Value
A vchart()
htmlwidget
object.
Examples
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
)
)
[Package vchartr version 0.1.4 Index]