labelLine disappears when adjusting the font (echarts4r)

36 Views Asked by At

I have this code:

library(echarts4r)

data1 <- data.frame(
  one = LETTERS[1:3],
  two = c(130, 154, 543)
)

data1 |>
  e_charts(one) |>
  e_pie(two, roseType = "radius") |>
  e_tooltip() |>
  e_color(color = c("#f8766d", "#00ba38", "#619cff")) |>
  e_legend(textStyle = list(color = "#858383", fontSize = 18)) |>
  e_labels(textStyle = list(fontSize = 20, color = "#858383")) 

But note that when I modify the font, the labelLine disappears linking the label to the graphic.

I try this:

data1 |>
  e_charts(one) |>
  e_pie(two, roseType = "radius") |>
  e_tooltip() |>
  e_color(color = c("#f8766d", "#00ba38", "#619cff")) |>
  e_legend(textStyle = list(color = "#858383", fontSize = 18)) |>
  e_labels(textStyle = list(fontSize = 20, color = "#858383"), labelLine = list(color = "{value}", lineStyle = "{value}")) 

But it does not work. How can I keep the corresponding lines and colors on the graph even after changing the labels?

1

There are 1 best solutions below

0
On BEST ANSWER

I think it is better to set the textStyle for the pie chart labels via e_pie:

library(echarts4r)

data1 <- data.frame(
  one = LETTERS[1:3],
  two = c(130, 154, 543)
)

data1 |>
  e_charts(one) |>
  e_pie(two,
    roseType = "radius",
    label = list(
      textStyle = list(fontSize = 20, color = "#858383")
    )
  ) |>
  e_tooltip() |>
  e_color(color = c("#f8766d", "#00ba38", "#619cff")) |>
  e_legend(textStyle = list(color = "#858383", fontSize = 18))