Reputation: 21
Thanks for reading. I am creating a Nightingale Rose Charts using e_pie (echarts4r). I tried to show only top five labels outside the circle but it failed. How can I achieve it?
df<-read.table(text='province revenue
西藏 28
青海 36
新疆 38
内蒙古 40
海南 42
广西 46
吉林 47
黑龙江 49
甘肃 50
宁夏 53
云南 55
山西 65
贵州 68
河北 72
陕西 80
江西 81
河南 82
福建 90
重庆 99
全国 100
辽宁 102
四川 107
湖北 110
天津 117
湖南 128
安徽 135
山东 136
上海 157
浙江 186
北京 203
江苏 247
广东 340
',header=T)
df%>%
e_charts(x=province)%>%
e_pie(revenue,roseType='radius',radius=c('5%','80%'),
legend = F,
label= list(
position = 'outside',
formatter= ("{c} ({d})")
)) %>%
e_visual_map(inRange = list(color = c( '#9055A2','#FBFFB9', "#e94e77")))
Upvotes: 2
Views: 233
Reputation: 3228
Is this what you are looking for? From what I understand, you are trying to arrange the top 5 values of revenue and plot them:
library(tidyverse)
df%>%
arrange(desc(revenue)) %>%
slice(1:5) %>%
e_charts(x=province)%>%
e_pie(revenue,roseType='radius',radius=c('5%','80%'),
legend = F,
label= list(
position = 'outside',
formatter= ("{c} ({d})")
)) %>%
e_visual_map(inRange = list(color = c( '#9055A2','#FBFFB9', "#e94e77")))
Like so:
Upvotes: 1