jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
717 stars 147 forks source link

Inverted ColumnRange chart #796

Open lyndon-bird opened 1 year ago

lyndon-bird commented 1 year ago

Hi there,

I am trying to replicate this inverted column range chart https://www.highcharts.com/demo/ios/columnrange.

It appears the inverted flag has no impact of a columnrange chart.

Thanks

Please include a minimal reproducible example -


library(dplyr)

options(highcharter.theme = hc_theme_smpl())

#### DATA ####
df <- data.frame(xval = 1:10) %>% 
  mutate(
    yval = 10 + xval + 10 * sin(xval),
    yval = round(yval, 1),
    zval = (xval*yval) - median(xval*yval),
    er = 10 * abs(rnorm(length(xval))) + 2,
    er = round(er, 1),
    l = yval - er,
    h = yval + er,
    col = yval,
    nm = paste("point", xval)
  )

head(df)

hchart(df, "columnrange", hcaes(x = xval, low = l, high = h, name = nm, color = col), inverted=TRUE)
JDenn0514 commented 1 month ago

In case you haven't figured this out yet, it's not actually a bug. You just need to add hc_chart(inverted = TRUE) to your code. Your full code would look like this:

hchart(df, 
       "columnrange", 
       hcaes(x = xval, low = l, high = h, name = nm, color = col)) %>%
  hc_chart(inverted = TRUE)

This is what my output looks like with your data and the code above:

Screenshot 2024-05-24 at 2 35 03 PM

Hope this helps!