Home > Net >  NegativeColors in Highcharts with R
NegativeColors in Highcharts with R

Time:09-29

I'm trying to plot a graph with two colors according if it is positive or negative values, using highchart in R. I simplify a code in the next way:

x <- c(-3, -4, 1, 4, 8)


dt <- seq(as.Date("2018-01-01"), as.Date("2018-01-05"), by = "days")

ts <- xts(x, dt )
names(ts)="serie"
print(ts)

highchart(type="stock") %>%
  hc_add_series(ts$"serie",
                type = "lollipop",
                color="black") 

I'm trying to plot the graph with black color for positive values and green color for negative ones. I checked that we can use negativeColor in JS, ¿is there a way to use this on R? For example in JS: enter image description here

  • Related