score:3

Accepted answer

i believe the color has to be called separately outside hcaes, but your approach seems more intuitive/sensible, so shame it's not working. the following works:

hchart(
  newdata,
  "bar",
  hcaes(
    x = gender,
    group = is_churner,
    y = percent,
    label = nominal
  ), color = c("green", "red")
) %>%
  hc_title(text = "") %>%
  hc_yaxis(
    title = list(text = ""),
    labels = list(format = "{value}")
  ) %>%
  hc_xaxis(title = list(text = "")) %>%
  hc_tooltip(
    pointformat = "
    percent: {point.y:,.0f}%<br>
    nominal: {point.label:,.0f}<br>"
  )

the following also works:

hchart(
  newdata,
  "bar",
  hcaes(
    x = gender,
    group = is_churner,
    y = percent,
    label = nominal
  )
) %>%
  hc_title(text = "") %>%
  hc_yaxis(
    title = list(text = ""),
    labels = list(format = "{value}")
  ) %>%
  hc_xaxis(title = list(text = "")) %>%
  hc_tooltip(
    pointformat = "
    percent: {point.y:,.0f}%<br>
    nominal: {point.label:,.0f}<br>"
  ) %>% 
  hc_colors(c("green", "red"))

i've deleted color from hcaes and added it instead to hc_colors.

score:0

i have had the same issue, in my case it turned out that my css files overruled the colors i specified in the hchart color.

when i removed te relevant lines in the css files the color command did work in the way you originally specified. you do not need to call it separately outside hcaes.


Related Query

More Query from same tag