Reputation: 387
I want to add new labels on each slice of a pie chart using HighcharteR (Highchart for R).
When a slice is selected, it is highlighted but not the others. I want that each label in slice react the same way too.
I found some post using javascript solution but not with HighcharteR.
Thanx for the clue
Upvotes: 1
Views: 783
Reputation: 18744
You need to assign a negative distance to the data labels to move the labels inside a pie chart. I suggest that you use % to keep things relative.
Here's an example.
library(highcharter)
df1 <- data.frame(a = c("Piece 1", "Piece 2", "Piece 3"),
b = c(10, 20, 40))
highchart() %>%
hc_add_series(df1, type = "pie",
dataLabels = list(distance = '-30%', # <- this puts labels inside
backgroundColor = "white"),
hcaes(x = a, y = b))
Upvotes: 1