-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
Pie charts with coord_system = "geo" #511
Comments
It required an updated version of the dependency. A simplified version of your example: note the correction of the pie 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 |
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!!
The text was updated successfully, but these errors were encountered: