![](/img/trans.png)
[英]R Highcharter Issues with adding plotBands on y-axis where hc_yAxis_multiples used
[英]highcharter hc_axis not working correctly
跟进这篇文章,我无法使用下面的代码以正确的格式获取 x 轴标签。
hchart(visits, "column", x = as.Date(VisitDate), y = freq, group = Clinic) %>%
hc_xAxis(categories = allDates$VisitDate, title = list(text = 'Deadline'), type = 'datetime', dateTimeLabelFormats = list(month = "%b", year = "%y")) %>%
hc_plotOptions(column = list(
dataLabels = list(enabled = FALSE),
stacking = "normal",
enableMouseTracking = TRUE)
)
下面的结果图表的标签都搞砸了。
也可以指定间隔为 1 个月、15 天等。
hchart(visits, "column", hcaes(x = VisitDate, y = freq, group = Clinic)) %>%
hc_xAxis(categories = allDates$VisitDate, title = list(text = 'Deadline'), type = 'datetime', dateTimeLabelFormats = list(month = "%b", year = "%y")) %>%
hc_plotOptions(column = list(
dataLabels = list(enabled = FALSE),
stacking = "normal",
enableMouseTracking = TRUE)
)
您需要在 hchart 函数中添加 hcaes。 这里有一些很好的例子Highcharter 页面
此外,Highchart 更喜欢将日期作为时间戳以您想要的方式工作,请查看此答案plotband。
我希望这对你有帮助。 有一个美好的一天
编辑1:
使用此代码,您可以将选择范围添加到您想要的日期,但是我认为它不适用于此类数据和图表
hchart(visits, "column", hcaes(x = VisitDate, y = freq, group = Clinic))%>%
hc_xAxis(categories = allDates$VisitDate, title = list(text = 'Deadline'),
type = 'datetime', dateTimeLabelFormats = list(month = "%b", year = "%y"))
%>%
hc_plotOptions(column = list(
dataLabels = list(enabled = FALSE),
stacking = "normal",
enableMouseTracking = TRUE)
) %>%
hc_rangeSelector(enabled = TRUE, buttons = list(
list(type = "all", text = "All"),
list(type = "month", count = 1, text = "1m"),
list(type = "day", count = 15, text = "15d"),
list(type = "day", count = 1, text = "1d")
), selected = 3)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.