echarts4r
echarts4r copied to clipboard
Is it possible to use HTML in label formatter?
Life would be a lot easier if I was allowed to use HTML in label formatting like the way that is possible in tooltips :) Is there a way, or a hack of some kind that would make this possible?
As an example, let's compare formatting of labels and tooltips:
df <- data.frame(xaxis = c(1,2,3), yaxis = c(1,2,3), label= c("<span><b>hi</b></span>", "hello", "hey"))
# whithout proper dealing with HTML
df %>%
e_charts(xaxis) %>%
e_scatter(yaxis, bind = label,
label = list(show = TRUE,
formatter = '{b}'))
# with proper dealing with HTML
df %>%
e_charts(xaxis) %>%
e_scatter(yaxis) %>%
e_add_nested('extra', label) %>%
e_tooltip(triggerOn="mousemove|click",
formatter = htmlwidgets::JS(
'function(params){
return params.data.extra.label;
}'
))
As you can see, the label formatter doesn't know how to use HTML, whilst the tooltip formatter does. Is there a way to make label formatter behave the same way as the tooltip formatter?
Many thanks in advance!