问题
I am having a little trouble to draw a horizontal line by using rcharts (highcharts) on a plot. I would like to use the plotLines from highcharts library to do this. Below is my code:
a$yAxis(title='my_Yaxis name', plotLines=list(color='red', value=10, width=2))
Without the plotLines, my chart display with no problem. Once i added in the plotLines, it is not working. I am not sure if rcharts support plotLines in highcharts?
Appreciate if any experts here can give advice. Thanks!
回答1:
Hello look at this example :
library("rCharts")
# Some data
x <- abs(rnorm(10))
# A graph with column
h <- Highcharts$new()
h$chart(type = "column")
h$series(data = x)
h$xAxis(categories = letters[1:10])
# the horizontal line
h$yAxis(title = list(text = "rnorm()"),
plotLines = list(list(
value = mean(x),
color = '#ff0000',
width = 3,
zIndex = 4,
label = list(text = "mean",
style = list( color = '#ff0000', fontWeight = 'bold' )
))))
h
It's missing a list()
in your plotLines
argument, it needs two list
.
来源:https://stackoverflow.com/questions/30703979/rcharts-highcharts-plotlines