setwd("C:\\Users\\USER\\Desktop")
df <- readxl::read_xlsx("io2021tonow.xlsx")
# library(stringr)
# df[,1] <- apply(df[,1], 2, function(x) paste0(str_sub(x,1,4),"-",str_sub(x,5,6)))
library(echarts4r)
df %>%
e_chart(年月,reorder=TRUE) %>%
e_line(出口) %>%
e_line(进口) %>%
e_bar(贸易差额) %>%
# e_labels(show = TRUE, position = "top",rotate=TRUE) %>%
e_animation(duration = 10000) %>%
# e_tooltip(formatter = e_tooltip_item_formatter("currency"),
# axisPointer = list(type = "cross")) %>%
e_axis_labels(x = "年月",y = "亿元人民币") %>%
e_title("2021年1月~2022年3月海关进出口统计",
subtext="http://www.customs.gov.cn/",left="25%") %>%
e_legend(show = TRUE,type = "plain",top="95%")