JohnCoene / echarts4r

🐳 ECharts 5 for R
http://echarts4r.john-coene.com/
Other
585 stars 82 forks source link

Multiple label positions in e_pie chart #563

Closed Mariaf1714 closed 10 months ago

Mariaf1714 commented 10 months ago

Hallo, Is it possible to display a part of the label (for example formatter = "{c} %") using position = "inside"and another part of the label (formatter = '{b}') with the position = "outside" in a e_pie chart? The names in {b} should not be displayed in a legend.

Thank you!

rdatasculptor commented 10 months ago

Hi @Mariaf1714

You can use two equivalent e_pie charts in one echart with different label positions.

Like this:

library(echarts4r)

df <- data.frame(name = c("this", "is", "an", "example"),
                 percentage = c(10, 20, 30, 40))

df |>
  e_charts(name) %>%
  e_pie(percentage, 
        label = list(formatter = "{c} %",
                     position = "inside")) |>
  e_pie(percentage, 
        label = list(formatter = '{b}')) |>
  e_legend(show = FALSE)

the result looks like this:

image

Is this the result you intended? If yes, please close the issue, thanks!

Mariaf1714 commented 10 months ago

This is exactly the result that I intended. Thank you!!

Mariaf1714 commented 10 months ago

The code works. Thank you very much.