鬼影重复注解

时间:2019-01-08 13:12:53

标签: r highcharts r-highcharter

我正在尝试创建一个在右侧带有注释的条形图。我可以使用以下代码实现此目的,但是它还会产生一些额外的鬼影注释,这些注释会在图表大小更改时移动。我在这里想念什么?

    library(highcharter)

    x <- rev(c(.27, .18, .03, .07)) * 100

    highchart() %>%
  hc_chart(type = "bar", 
           backgroundColor = "#eee",
           margin = c(0, 0, 0, 0)) %>%
  hc_add_series_labels_values(labels = 1:length(x),
                              dataLabels = list(enabled = TRUE, 
                                                inside = FALSE,
                                                format = '{y}% ',
                                                style = list(color = "contrast",
                                                             fontSize = "14px",
                                                             textOutline = "none",
                                                             fontWeight = "normal")),
                              values = rev(x),
                              color = rep("#333333", length(x))) %>%
  hc_legend(enabled = FALSE) %>%
  hc_tooltip(enabled = FALSE) %>%
  hc_yAxis(visible = FALSE, max = 110) %>%
  hc_add_annotations(
    list(
      list(xValue = 0.5, yValue = 100, title = list(text = 'A')),
      list(xValue = 1.5, yValue = 100, title = list(text = 'B')),
      list(xValue = 2.5, yValue = 100, title = list(text = 'C'))
    )
  )

enter image description here

0 个答案:

没有答案