According to this, I thought I could change the max value shown in the visual map like so:
e_visual_map(value, max = 100)
But this seems to have no effect.
Here is a full example:
library(echarts4r)
# Sample data
df <- data.frame(
category = c("Low Avg", "High Avg", "Low Avg", "High Avg"),
max = c("Low Max", "High Max", "High Max", "Low Max"),
value = c(10, 40, 20, 30) # replace with your actual values
)
df |>
e_charts(category) |>
e_heatmap(max, value, ) |>
e_visual_map(value, max = 100) |>
e_x_axis(max, type = "category") |>
e_y_axis(category, type = "category")
I expect the slider max value to be 100 instead of 40.
Not sure whether this is intended or whether this is a bug. After a look at the source the issue is that when you pass a serie
to e_visual_map
the min
and max
values are set according to range of the data:
https://github.com/JohnCoene/echarts4r/blob/8f1d2ea10504c3aa0f77cc1bff91526ed7b6967f/R/opts.R#L109
Hence, your max
value will have no effect as it gets overwritten.
One option would be to not pass the name of the serie
to e_visual_map
in which case the max
value does get set or overwritten
df |>
e_charts(category) |>
e_heatmap(max, value, ) |>
e_visual_map(max = 100) |>
e_x_axis(max, type = "category") |>
e_y_axis(category, type = "category")
A second option would be to pass a scale
function to the scale
argument:
library(echarts4r)
df |>
e_charts(category) |>
e_heatmap(max, value) |>
e_visual_map(value, scale = function(x) scales::rescale(x, to = c(0, 100))) |>
e_x_axis(max, type = "category") |>
e_y_axis(category, type = "category")