echarts4r
echarts4r copied to clipboard
Label alignment within e_map
Hi,
the following code produces a simple map referring to administrative level in Germany called "Bundesland":
df <- data.frame(
Bundesland = c(
"Baden-Württemberg", "Bayern", "Berlin"
, "Brandenburg", "Bremen", "Hamburg"
, "Hessen", "Mecklenburg-Vorpommern", "Niedersachsen"
, "Nordrhein-Westfalen", "Rheinland-Pfalz", "Saarland"
, "Sachsen", "Sachsen-Anhalt", "Schleswig-Holstein", "Thüringen"
)
, Anzahl = sample(1:16, 16)
)
Deutschland <- jsonlite::read_json("https://code.highcharts.com/mapdata/countries/de/de-all.geo.json")
chart_geo <- df %>%
e_charts(x = Bundesland) %>%
e_map_register("DE", Deutschland) %>%
e_map(Anzahl, map = "DE") %>%
e_visual_map(
Anzahl
, inRange = list(color = c("#d7d7de", "#9acbed", "#045085"))
) %>%
e_labels(
show = TRUE
, formatter = "{c}"
, position = "bottom"
, align = "right"
, verticalAlign = "middle"
, distance = 60
#, rotate = -30
, fontSize = 10
)
chart_geo
As one can see, the labels for "Berlin" and "Brandenburg" are nearly overlapping:

No matter what config for e_labels I use, I don't get them clearly separated. What can I do?
Did some testing and it looks like most of labelLayout goodies do not work for map series.
Maybe the best one can do is to hide overlapping labels:
e_map(Anzahl, map = "DE", roam=TRUE, labelLayout= list(hideOverlap= TRUE))