R Highcharter细分图表问题

问题描述

我正在遵循this示例来构建明细柱形图。一切似乎都很好,只是向下钻取功能不起作用。我的数据框与示例中的数据框之间的主要区别在于,我有一个日期列。

library(tidyr)
library(highcharter)
library(dplyr)
library(purrr)
df1 = tibble(Date = c("6/30/2020","6/30/2020","5/31/2020","5/31/2020"),Class = c("NUS","NUS","US","US"),Type = c("C","E","S","C","E"),Value = c(4.6,1.3,4.6,5.0,2.0,5.2,1.2,1.9))

#Summarise by Date and Class
df2 <- ddply(df1,c("Date","Class"),summarise,Sum = sum(Value))
df2$drilldown <- tolower(df2$Class)

#To lists
dsnus <- list_parse2(df1[df1$Class=="NUS",])
dsus <- list_parse2(df1[df1$Class=="US",])

hc <- highchart() %>%
  hc_title(text = "Basic drilldown") %>%
  hc_xAxis(type = "category") %>%
  hc_legend(enabled = FALSE) %>%
  hc_plotOptions(
    series = list(
      boderWidth = 0,dataLabels = list(enabled = TRUE))) %>%
  hc_add_series(
    data = df2,type = "column",hcaes(name = Date,y = Sum,group = Class),colorByPoint = TRUE)

hc <- hc %>%
  hc_drilldown(allowPointDrilldown = TRUE,series = list(
      list(id = "us",data = dsus),list(
        id = "nus",data = dsnus)))

hc

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)