score:9

Accepted answer

ok. after so many trial and errors, i managed to do this. here is how i did (providing here to help future readers).

i added a column called value in my dataset

data1 <- data1 %>% mutate(value = ifelse(changelabel == ">20% decrease",1,
                          ifelse(changelabel == "<20% decrease",2,
                          ifelse(changelabel == "<20% increase",3,
                          ifelse(changelabel == ">20% increase",4, 5)))))

and then i created a data class for color axis:

dclass <- data_frame(from = seq(1, 4, by = 1),
                     name = c(">20% decrease","<20% decrease","<20% increase",">20% increase"),
                     color = c("#00b0f0","#b7dee8","#92d050","#00b050"))
dclass <- list_parse(dclass)

then in my chart making code i added this line:

hc_coloraxis(dataclasses = dclass)

now it works with proper legend as i expected.


Related Query

More Query from same tag