Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom tooltip affact timeline #433

Closed
XiangyunHuang opened this issue Jun 8, 2022 · 2 comments
Closed

custom tooltip affact timeline #433

XiangyunHuang opened this issue Jun 8, 2022 · 2 comments

Comments

@XiangyunHuang
Copy link

I don't know why this happen and how can I avoid side effect when I add more infomation to tooltip

When I move mouse to timeline, strange thing happens.

截屏2022-06-08 16 00 25

a minimal reprex example

library(echarts4r)

mtcars |>
  group_by(cyl) |>
  e_charts(wt, timeline = TRUE) |>
  e_scatter(mpg, qsec) |>
  e_tooltip(formatter = htmlwidgets::JS("
      function(params){
        return('wt: ' + params.value[0] + '<br />mpg: ' + params.value[1])
      }
    ")
  )

sessioninfo

> sessionInfo(package = "echarts4r")
R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur/Monterey 10.16

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] zh_CN.UTF-8/zh_CN.UTF-8/zh_CN.UTF-8/C/zh_CN.UTF-8/zh_CN.UTF-8

attached base packages:
character(0)

other attached packages:
[1] echarts4r_0.4.4

loaded via a namespace (and not attached):
[1] compiler_4.2.0  graphics_4.2.0  utils_4.2.0     grDevices_4.2.0
[5] stats_4.2.0     datasets_4.2.0  methods_4.2.0   base_4.2.0     
> 
@JohnCoene
Copy link
Owner

Thank you for the detailed report.
That seems to be a bug in echarts.js, I don't understand why this would trigger a tooltip.

This "fixes" it

mtcars |>
  group_by(cyl) |>
  e_charts(wt, timeline = TRUE) |>
  e_scatter(mpg, qsec) |>
  e_tooltip(formatter = htmlwidgets::JS("
      function(params){
        if(params.value[0])
          return('wt: ' + params.value[0] + '<br />mpg: ' + params.value[1])

        return 'step:' + params.name;
      }
    ")
  )

@XiangyunHuang
Copy link
Author

Thanks, The problem is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants