echarts4r icon indicating copy to clipboard operation
echarts4r copied to clipboard

NaN displayed in tooltip with e_mapbox

Open maxlavoie opened this issue 5 years ago • 3 comments
trafficstars

First, awesome package!

But I do have one question. Using one of your example:

url <- paste0("https://ecomfe.github.io/echarts-examples/",
              "public/data-gl/asset/data/population.json")
data <- jsonlite::fromJSON(url)
data <- as.data.frame(data)
names(data) <- c("lon", "lat", "value")

data %>%
    e_charts(lon) %>%
    e_mapbox(
        token = "YOUR_MAPBOX_TOKEN",
        style = "mapbox://styles/mapbox/dark-v9"
    ) %>%
    e_bar_3d(lat, value, coord_system = "mapbox") %>%
    e_visual_map()

Any idea why NaN is displayed when I hover on any of the points? I tried with a personal example with e_tooltip(). I succeeded in displaying the information I needed, but the NaN was still being displayed. thanks!

maxlavoie avatar Jul 31 '20 12:07 maxlavoie

Hi Max,

I'm afraid this is a bug on echarts.js itself, it must be said that the support for mapbox is poor. I updated the underlying mapbox-gl dependency and went through all the docs but can't find anything on that, sorry. :(

JohnCoene avatar Jul 31 '20 15:07 JohnCoene

Thanks, John for the follow-up.

maxlavoie avatar Jul 31 '20 15:07 maxlavoie

I have check the code and the manual page of Echarts.js, and I think it's a tiny bug of Echarts.js itself, also not the problem of mapbox.

See the offical demo below: https://echarts.apache.org/examples/en/editor.html?c=bar3d-dataset&gl=1

The NaN is also show on the graph when you hover it.

According the offical documentation, the default option should be false, but actually, it is set to true here. https://echarts.apache.org/en/option-gl.html#series-scatter3D.emphasis.label.show

Back to your question, you may try the solution here:

library(echarts4r)

url <- paste0(
  "https://echarts.apache.org/examples/",
  "data-gl/asset/data/population.json"
)
data <- jsonlite::fromJSON(url)
data <- as.data.frame(data)
names(data) <- c("lon", "lat", "value")

data %>%
  e_charts(lon) %>%
  e_mapbox(
    token = "YOUR_MAPBOX_TOKEN",
    style = "mapbox://styles/mapbox/dark-v9"
  ) %>%
  e_bar_3d(lat, value, coord_system = "mapbox", emphasis = list(label = list(show = FALSE))) %>%
  e_visual_map()

After that, you could use e_tooltip() to customize your tooltip. image


PS: This is not the bug of {echarts4r}, so maybe no PR required here, but considering to check the source code of echarts.js and open an issue or PR in the original library repository.

swsoyee avatar Oct 20 '20 15:10 swsoyee