echarts4r
echarts4r copied to clipboard
Custom tooltip with option `trigger='axis'` not working with `e_add_nested()`
Based on this discussion https://github.com/JohnCoene/echarts4r/issues/504#issuecomment-2423238530 , I verified that the tooltip in the case below works if trigger='item' but not if trigger='axis' .
library(echarts4r)
library(dplyr)
mtcars |>
mutate(label = paste("Tooltip label:", hp + disp)) |>
e_charts_(x = 'wt') |>
e_line_(serie = 'qsec') |>
e_add_nested('extra', label) |>
e_tooltip(
trigger = "axis",
formatter = htmlwidgets::JS(
'function(params){
return params.data.extra.label;
}'
)
)
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
other attached packages:
[1] dplyr_1.1.4 echarts4r_0.4.5
Hey @JohnCoene , is there a workaround for it?
It is the last piece I need to replace plotly...
If I remember correctly the API for the axis trigger is vastly different from the normal tooltip. I generally suggest just console.log(params) to see what echarts.js gives.