echarts4r icon indicating copy to clipboard operation
echarts4r copied to clipboard

Custom tooltip with option `trigger='axis'` not working with `e_add_nested()`

Open GitHunter0 opened this issue 1 year ago • 2 comments

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

GitHunter0 avatar Oct 21 '24 12:10 GitHunter0

Hey @JohnCoene , is there a workaround for it?

It is the last piece I need to replace plotly...

GitHunter0 avatar Oct 25 '25 14:10 GitHunter0

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.

JohnCoene avatar Oct 25 '25 15:10 JohnCoene