我想将我的瀑布图的数据标签(默认情况下以列为中心)移动到每列上方。通过 Highcharts 选项,我发现了溢出选项和这篇关于如何使用 highcharts 移动数据标签的SO 帖子(虽然不是 highcharter)。
但是,实施建议的设置步骤crop = FALSE
并overflow = 'none'
没有移动数据标签。
这是建议设置的一个小示例:
library(highcharter)
dataframe <- data.frame(name = c("A","B","C", "D"),
y = c(12.10, 5.45, -8.60, NA),
isIntermediateSum = c(FALSE, FALSE, FALSE, FALSE),
isSum = c(FALSE, FALSE, FALSE, TRUE),
color = c("#377EB8", "#4DAF4A", "#E41A1C", "#377EB8"),
stringsAsFactors = F)
data_list = dataframe %>% list_parse()
highchart() %>%
hc_chart(type = "waterfall") %>%
hc_title(text = "") %>%
hc_subtitle(text = "") %>%
hc_xAxis(type = 'category') %>%
hc_yAxis(
title = list(text = ""),
labels = list(format = "{value:,.2f}%", useHTML = TRUE)
) %>%
hc_legend(enabled=FALSE) %>%
hc_tooltip(pointFormat = '<b>{point.y:,.2f}%</b>', useHTML = TRUE) %>%
hc_add_series(data = data_list,
dataLabels = list(
enabled=TRUE,
formatter= JS("function(){ return Highcharts.numberFormat(this.y, 2, ',') + '%';}"),
style=list(
color="#FFFFFF",
fontWeight="bold",
textShadow="0px 0px 3px black"
),
crop = FALSE,
overflow = 'none'
)
)
你们中有人知道如何移动数据标签吗?