Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reordering legend data (with workaround) #591

Open
Mkranj opened this issue Nov 20, 2023 · 0 comments
Open

Reordering legend data (with workaround) #591

Mkranj opened this issue Nov 20, 2023 · 0 comments
Labels
wontfix This will not be worked on

Comments

@Mkranj
Copy link
Contributor

Mkranj commented Nov 20, 2023

Hi,
I'm plotting a chart with multiple bars and need to stack them in one order, and display the legend in another. I thought I could rearrange the legend data by supplying the data argument, but that actually creates a separate data object in the JSON.

I've found a workaround by modifying the data in the saved object, and then it gives the expected result. Here's a reproducible example:

library(echarts4r)

dataset <- data.frame(
  categories = letters[1:5],
  smaller = 1:5,
  larger = 21:25
)

my_chart <- e_charts(dataset, x = categories) %>%
  e_bar(serie = larger, name = "Big") %>%
  e_bar(serie = smaller, name = "Small") %>%
  e_legend(data = list("Small", "Big"))

# This one creates two "data"s
my_chart
my_chart %>% e_inspect()

# This reorganises as wanted
my_chart$x$opts$legend$data <- list("Small", "Big")

my_chart

Is there a way to reorganise the data by providing the list directly to e_legend, instead of modifying a chart stored as an object?

@munoztd0 munoztd0 added the wontfix This will not be worked on label Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants