echarts4r icon indicating copy to clipboard operation
echarts4r copied to clipboard

Label alignment within e_map

Open svenb78 opened this issue 3 years ago • 1 comments

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: Map

No matter what config for e_labels I use, I don't get them clearly separated. What can I do?

svenb78 avatar Aug 15 '22 12:08 svenb78

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))

helgasoft avatar Aug 17 '22 04:08 helgasoft