Reputation: 295
I know the following code produces the following plot
library('echarts4r')
dat <- structure(list(
labels = c("string4",
"string3",
"string2",
"string1"),
quantity = c(19L,
10L,
15L,
20L)),
row.names = 4:1,
class = "data.frame")
dat <- dat[order(dat$labels, decreasing = TRUE),]
dat |>
e_charts(y = labels, reorder = FALSE) |>
e_parallel(labels, quantity, opts = list(smooth = TRUE))
I want these labels (the ones pointed by the blue arrows) to be shown on the left instead of on the right of the vertical line. How can I move them to the left side?
I've taken a look at the documentation, as suggested by @socialscientist in its answer, and I've tried the following to no avail.
The following doesn't throw an error, but doesn't move the labels.
df <- data.frame(
labels = c("string4", "string3", "string2", "string1"),
column2 = c(19L, 10L, 15L, 20L))
df |>
e_charts(y = labels) |>
e_labels(position = 'left') |>
e_parallel(labels, column2)
The following throws an error.
df <- data.frame(
labels = c("string4", "string3", "string2", "string1"),
column2 = c(19L, 10L, 15L, 20L))
df |>
e_charts(y = labels) |>
e_parallel(labels, column2) |>
e_labels(position = 'left')
The folowing doesn't throw an error, but doesn't move the labels.
df <- data.frame(
labels = c("string4", "string3", "string2", "string1"),
column2 = c(19L, 10L, 15L, 20L))
df |>
e_charts(y = labels) |>
e_labels(offset = c(123, 123)) |>
e_parallel(labels, column2)
The following doesn't throw an error, but doesn't move the labels.
df <- data.frame(
labels = c("string4", "string3", "string2", "string1"),
column2 = c(19L, 10L, 15L, 20L))
df |>
e_charts(y = labels) |>
e_labels(position = 'insideRight', distance = 123) |>
e_parallel(labels, column2)
Upvotes: 3
Views: 129
Reputation: 18714
I couldn't find an effectively method to feed the necessary input into e_parallel
. However, You can change it as an after thought.
I used this function to flip the defaults for axisTick.length
and axisLabel.margin
and axisLabel.align
for the parallelAxis
(left side only).
fixLabs <- function(plt) {
plt$x$opts$parallelAxis[[1]]$axisTick <- list(length = -5) # default is +5
plt$x$opts$parallelAxis[[1]]$axisLabel <- list(margin = -8, # default is +8
align = "right")
plt
}
This is how you use it.
dat |>
e_charts(y = labels, reorder = FALSE) |>
e_parallel(labels, quantity,
opts = list(smooth = TRUE)) %>%
fixLabs()
Upvotes: 0