Highcharter - Add Multiple Text Annotations
I have a stacked column plot where I need a text annotation below each column. I only found a way to add one annotation. Adding a second annotation yields the error All arguments m
Solution 1:
That is a known issue and it's solve with the next functions:
hc_add_annotation
hc_add_annotations
Example of use:
hc %>%
hc_add_annotation(xValue = 0, yValue = -2, title = list(text = '-6 pp')) %>%
hc_add_annotation(xValue = 1, yValue = -4.5, title = list(text = '-5 pp'))
hc %>%
hc_add_annotations(
list(
list(xValue = 0, yValue = -2, title = list(text = '-6 pp')),
list(xValue = 1, yValue = -4.5, title = list(text = '-5 pp'))
)
)
Or even better:
df <- data_frame(
xValue = c(0, 1),
yValue = c(-2, -4.5),
title = c("-6pp", "-5pp")
)
df <- df %>%
mutate(title = map(title, function(x) list(text = x)))
df#> # A tibble: 2 x 3#> xValue yValue title#> <dbl> <dbl> <list>#> 1 0 -2.0 <list [1]>#> 2 1 -4.5 <list [1]>
hc %>%
hc_add_annotations(df)
Reference: https://github.com/jbkunst/highcharter/issues/171
Post a Comment for "Highcharter - Add Multiple Text Annotations"