参考:https://www.yuque.com/docs/share/df2b42d4-bc1f-4596-bc03-08cf3838171d
环境准备
# 环境准备
options("repos"=c(CRAN="https://mirrors.ustc.edu.cn/CRAN/"))
options(BioC_mirror="http://mirrors.ustc.edu.cn/bioc/")
install.packages("echarts4r")
library(echarts4r)
library(dplyr)
示例数据构建
df <- data.frame(
event = c("A3SS","A5SS","SE","RI","MXE"),
count = c(10, 24, 40, 17, 9))
绘图
# 绘图
df %>%
e_chart(event) %>%
e_pie(count, radius = c("30%", "60%"),
timeline = T,legend =F,name="Event and Percent") %>%
e_labels(
position = "outside",
labelLine = list(length = 30),
formatter = "{a|{a}}{abg|}\n{hr|}\n {b|{b}:}{c} {per|{d}%}",
backgroundColor = "#F6F8FC",
borderColor = "#8C8D8E",
borderWidth = 1,
borderRadius = 4,
rich = list(
a = list(
color = "#6E7079",
lineHeight = 22,
align = "center"
),
hr = list(
borderColor = "#8C8D8E",
width = "100%",
borderWidth = 1,
height = 0
),
b = list(
color = "#4C5058",
fontSize = 14,
fontWeight = "bold",
lineHeight = 33
),
per = list(
color = "#fff",
backgroundColor = "#4C5058",
padding = c(3, 4),
borderRadius = 4)))%>%
e_toolbox_feature(feature = c("saveAsImage")) #在Plots右上角添加了个下载png按钮