Highcharter - 将数据标签移动到列的顶部

Highcharter - move data label to top of column

我想将瀑布图中的数据标签(默认情况下以列为中心)移动到每列上方。 查看 Highcharts 选项,我发现 overflow option and this SO post 关于如何使用 highcharts 移动数据标签(虽然不是 highcharter)。

但是,实施建议的设置 crop = FALSEoverflow = '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'
                )
  )

你们中有人知道如何移动数据标签吗?

如果我理解正确的话

verticalAlign: StringSince 2.3.3 The vertical alignment of a data label. Can be one of top, middle or bottom. The default value depends on the data, for instance in a column chart, the label is above positive values and below negative values.

doc

        dataLabels: {verticalAlign: 'top'}

JS Fiddle: http://jsfiddle.net/obryLg6q/


新 fiddle: http://jsfiddle.net/obryLg6q/1/

        crop: false,
        overflow: 'none',
        x: 0,
        y: -30, // above the bar

set dataLabels.inside to false: jsfiddle.net/obryLg6q/2 – Grzegorz Blachliński 18 mins ago

Highcharts 开发者评论。我认为你应该听从这个建议)

       crop: false,
       overflow: 'none',
       inside: false