This question is an followup on to Parallelcoordinates in R-highcharter R. Assume we have a parallelplot created by
library(highcharter)
library(purrr)
library(dplyr)
series_lst <-
iris %>%
as_tibble() %>%
asplit(1) %>%
imap(~list(
name = paste("observation", .y),
data = as.numeric(.x[1:4]),
color = "steelblue"
))
hc <-
highchart() %>%
hc_chart(parallelCoordinates = TRUE, type = "spline") %>%
hc_xAxis(categories = names(iris)[1:4]) %>%
hc_add_series_list(series_lst)
I now want to customize the y-Axis. Since I am using a dark theme in my app, I need to make the labels white. But in our example, lets say we want to make the y-axis labels red. In highcharter
, there are two functions for modifiing the y-axis - hc_yAxis
and hc_yAxis_multiples
.
I tried
hc %>% hc_yAxis(labels = list(style = list(color = "red")))
which results in making only the labels on the first axis red. I also tried
hc %>% hc_yAxis(labels = rep(list(style = list(color = "red")),4))
but nothing changes. Same for the other function where I tried
hc %>% hc_yAxis_multiples(labels = list(style = list(color = "red")))
hc %>% hc_yAxis_multiples(labels = rep(list(style = list(color = "red")),4))
In the example of highhcarts https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/demo/parallel-coordinates there are also more options for setting up the different y-axes, for example one can change the type or give cutom labels. How to achieve this with the R highcharter
-package?
yAxis_lst <- rep(
list(
list(
labels = list(style = list(color = "red"))
)
),
4
)
hc <-
highchart(hc_opts = list(yAxis = yAxis_lst)) %>%
hc_plotOptions(series = list(label = list(enabled = FALSE))) %>%
hc_chart(parallelCoordinates = TRUE, type = "spline", reflow = TRUE) %>%
hc_xAxis(categories = names(iris)[1:4]) %>%
hc_add_series_list(series_lst)
Yes, these lists look quite complicated :)
One advice I could give here is to use export_hc
function. This allows you to save your chart as a javascript code. This way you'll see exactly what each highcharter
function does under the hood and it'll be easier to to wrap your head around. Generally it is clear how js output should look to make it work (when you compare to working jsfiddle examples).
The workflow I use is following: