r - R highcharter 向下钻取图表问题
问题描述
我正在按照这个示例构建一个向下钻取的柱形图。一切似乎都很好,除了向下钻取功能不起作用。我的数据框与示例中的数据框之间的主要区别在于我有一个日期列。
library(tidyr)
library(highcharter)
library(dplyr)
library(purrr)
df1 = tibble(Date = c("6/30/2020", "6/30/2020", "6/30/2020", "6/30/2020", "6/30/2020", "5/31/2020","5/31/2020","5/31/2020","5/31/2020"),
Class = c("NUS", "NUS", "NUS", "US", "US", "NUS", "NUS", "US", "US"),
Type = c("C", "E", "S", "C", "E", "C", "E","C","E"),
Value = c(4.6, 1.3, 4.6, 5.0, 2.0, 5.2, 1.2, 5.0,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
解决方案
推荐阅读
- react-native - 到达导航结束后反应本机重置导航
- cordova - 在ionic的相机预览插件的stopRecordVideo()函数返回的文件路径上找不到视频
- mysql - 表字段中的 MySQL 查询参数
- python - 如何将日期时间对象转换为浮点数?AttributeError:“datetime.datetime”对象没有属性“datetime_to_float”
- flutter - Flutter 如何显示当前日期和接下来的 5 天日期?
- android - Android:多种屏幕尺寸的多种翻译
- php - OpenSSL 获取私钥和公钥函数返回 False
- javascript - CreateReactApp:在运行时嵌入最终用户插件
- postgresql - 在potgresql中获得拒绝关系的权限
- php - 如何在本地使用 selectize.js?