Closed FlavioLeccese92 closed 1 year ago
It required an updated version of the dependency.
A simplified version of your example: note the correction of the pie center
longitude = x
and latitude = y
library(dplyr)
flights <- read.csv(
paste0(
"https://raw.githubusercontent.com/plotly/datasets/",
"master/2011_february_aa_flight_paths.csv"
)
) |> head(30)
series <- flights |>
select(airport1, start_lat, start_lon) |>
distinct() |>
apply(1, as.list) |>
purrr::map(\(row) {
data <- lapply(LETTERS[1:4], \(l) {
list(name = l, value = sample(1:10, 1))
})
list(
data = data,
type = "pie",
coordinateSystem = "geo",
tooltip = list(formatter = "{b}: {c} ({d}%)"),
center = list(row$start_lon, row$start_lat),
radius = data |>
purrr::map("value") |>
purrr::reduce(\(c, p) {
c + p
})
)
})
opts <- list(
geo = list(
map = "world",
roam = TRUE,
itemStyle = list(
areaColor = "#e7e8ea"
)
),
series = series,
tooltip = list(),
legend = list()
)
e <- e_charts(width = NULL, height = NULL) |> e_list(opts)
path <- system.file("htmlwidgets/lib/echarts-4.8.0", package = "echarts4r")
dep <- htmltools::htmlDependency(
name = "echarts-world",
version = "1.0.0",
src = c(file = path),
script = "world.js"
)
e$dependencies <- append(e$dependencies, list(dep))
e
Reinstall to get the latest version of {echarts4r} and try again, feel free to reopen if this does not work.
@rdatasculptor I should add that as part of the standard API, not sure if it's already possible (with latest version - just updated)
Removing and reinstalling the development version worked! Thank you again!
Edit: Actually, now the chart above works BUT when running the Les Miserables e_graph(layout = "circular",...
example, nodes don't show up.
@JohnCoene were you suggesting to install the latest dev version or the latest CRAN one? Latest CRAN echarts4r (0.4.4) won't show the pies on the map.
Any suggestion? (cannot reopen this issue).
Thank you again
Latest dev from GitHub, I had to update the js dependencies for this pie-geo feature to work
Hi, thank you again for the incredible work you are doing!
I'm currently struggling with pie charts on a map. As I usually do for more complex charts, I try to replicate in R the javascript structure from official examples on the echarts website and use the
e_list()
function your package provides. Often it works smoothly but in some situation I really cannot understand what's wrong. For instance here. I share the draft code in R:Is there something wrong? Is it due to the world.js? Lines works pretty fine thought... Any suggestion?
Thank you!!