【问题标题】:R highcharter add multiple annotations with shapesR highcharter 添加多个带有形状的注释
【发布时间】:2018-07-31 03:33:18
【问题描述】:

我想在 Highcharter 中添加带有形状的注释

这是我的数据

data <- data.frame(a=c(1:12), b=runif(12, 1, 100))

I want to do this 带有一些注释形状的列 columns with multiple annotations shapes

我已经参考了Highcharter annotation on date x-axis not working - RHighcharter - add multiple text annotations

但我还是做不到,这是我的示例代码

library(highcharter)

hc <- highchart() %>%
  hc_add_series(data, type='column', hcaes(a,b), marker=list(enabled=FALSE))
hc %>% 
  hc_annotations(
    list(
      shapes = list(
        list(
          point = list(
            x = data$a[5],
            y = data$b[5],
            xAxis = 0,
            yAxis = 0
          ),
          type = 'circle'
        )
      )
    )
  )

感谢您考虑我的要求!

【问题讨论】:

  • hcaes(a,b)hcaes("a","b")
  • 但是 hcaes(a,b) 也可以工作?
  • 在上一个开发版本中是可以的。现在我有了最后一个版本。

标签: r annotations shapes r-highcharter


【解决方案1】:

试试看:

library(highcharter)
data <- data.frame(a=c(1:12), b=runif(12, 1, 100))
hc <- highchart() %>%
  hc_add_series(data, type='column', hcaes(a,b), marker=list(enabled=FALSE))
hc<-hc%>% 
  hc_add_annotation( 
    labels = list(
      list(
        point = list(
          xAxis =0 ,
          yAxis =0 ,
          x =data$a[5],
          y = data$b[5],
          xAxis=0,
          yAxis=0     
        ),
        text = "Is it OK?"
      )
    )
  )

hc%>% 
  hc_add_annotation(
    shapes=list(
      list(
      point=list(
      x=data$a[5],
      y=data$b[5],
      xAxis=0,
      yAxis=0),
      type= 'circle',
      r=10)))

【讨论】:

    猜你喜欢
    • 2017-12-25
    • 2022-01-12
    • 2020-08-26
    • 2021-09-29
    • 1970-01-01
    • 2016-07-03
    • 1970-01-01
    • 2020-04-07
    • 2020-08-14
    相关资源
    最近更新 更多