删除R中 highcharts 面积图中白色

vcirk6k6  于 2022-11-10  发布在  Highcharts
关注(0)|答案(1)|浏览(175)

我正在尝试删除面积图(使用highchart在R中创建)左右两侧的白色区域,该区域在下图中以红色显示。

我的可复制代码:

library(highcharter)

type <- c("A", "B", "C", "D","A", "B", "C", "D","A", "B", "C", "D")
total <- c(3300, 6080, 2780, 14054, 3638, 6360, 2722, 14148, 2681, 4761, 2080, 10080)
year <- c(2018, 2018, 2018, 2018, 2019, 2019, 2019, 2019, 2020, 2020, 2020, 2020)
df <- data.frame(type, year, total)

highchart() %>%

  hc_chart(type="area") %>%
  hc_add_series(data = subset(df, type == "D"), name = "D", type = "area", hcaes(x = year, y = total)) %>%
  hc_add_series(data = subset(df, type == "B"), name = "B", type = "area", hcaes(x = year, y = total)) %>%
  hc_add_series(data = subset(df, type == "C"), name = "C", type = "area", hcaes(x = year, y = total)) %>%
  hc_add_series(data = subset(df, type == "A"), name = "A", type = "area", hcaes(x = year, y = total)) %>%

  hc_xAxis(title = "", categories = c("2018", "2019", "2020"))

我在网上找过,但我不知道JavaScript,所以很难弄清楚。

hs1ihplo

hs1ihplo1#

我将hc_xAxis更改为使用tickPositions而不是categories。

hc_xAxis(title = "", 
           min = 2018, max = 2020, 
           tickPositions = c(2018, 2019, 2020))

相关问题