1

I want to add annotations with shapes in Highcharter

Here is my data

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

I want to do this columns with some annotations shapes columns with multiple annotations shapes

I have already take reference with Highcharter annotation on date x-axis not working - R and Highcharter - add multiple text annotations

but I still can't make it, here is my example code

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'
        )
      )
    )
  )

Thank you for considering my request!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
chuanchuan
  • 25
  • 4

1 Answers1

2

Try it:

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)))

enter image description here

Iman
  • 2,224
  • 15
  • 35