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

e_parallel and additional arguments not passed to Echarts API? #223

Closed
michaelbgarcia opened this issue Oct 29, 2020 · 3 comments
Closed

Comments

@michaelbgarcia
Copy link

michaelbgarcia commented Oct 29, 2020

Hi John, thank you for the wonderful package! I recently created a parallel graph and tried to format the lines. I noticed in the source code for echarts4r:::e_parallel.echarts4r that ... is passed to dplyr::select(...), even though the help documentation says otherwise (https://echarts4r.john-coene.com/reference/e_parallel.html):

function (e, ..., name = NULL, rm_x = TRUE, rm_y = TRUE) 
{
    e <- .rm_axis(e, rm_x, "x")
    e <- .rm_axis(e, rm_y, "y")
    df <- e$x$data[[1]] %>% dplyr::select(...)
    

I imagine this was by design to simplify creating a parallel chart, but it was an expected behavior after using e_scatter, e_bar and the like.

JohnCoene added a commit that referenced this issue Oct 29, 2020
JohnCoene added a commit that referenced this issue Oct 29, 2020
@JohnCoene
Copy link
Owner

JohnCoene commented Oct 29, 2020

Yes, indeed that was wrong. Although it is because e_parallel cannot follow the same logic as other cartesians (it's not [x, y]), one can plot multiple columns.

I just pushed a fix: thank you for reporting this!

df <- data.frame(
  price = rnorm(5, 10),
  amount = rnorm(5, 15),
  letter = LETTERS[1:5]
)

df %>%
  e_charts() %>%
  e_parallel(price, amount, letter, opts = list(smooth = TRUE))

Feel free to reopen if that does not work.

JohnCoene added a commit that referenced this issue Oct 29, 2020
@sugs01
Copy link

sugs01 commented Jan 9, 2021

Hi, John, I test you code above, which give an error as follow:
Error : Must subset columns with a valid subscript vector.
x Subscript has the wrong type list.
i It must be numeric or character.

< rlang::last_error()
<error/vctrs_error_subscript_type>
Must subset columns with a valid subscript vector.
x Subscript has the wrong type list.
i It must be numeric or character.
Backtrace:

  1. df %>% e_charts() %>% e_parallel(price, amount, letter, opts = list(smooth = TRUE))
  2. dplyr:::select.data.frame(., ...)
  3. tidyselect::eval_select(expr(c(...)), .data)
  4. tidyselect:::eval_select_impl(...)
  5. tidyselect:::vars_select_eval(...)
  6. tidyselect:::walk_data_tree(expr, data_mask, context_mask)
  7. tidyselect:::eval_c(expr, data_mask, context_mask)
  8. tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
  9. tidyselect:::walk_data_tree(new, data_mask, context_mask)
  10. tidyselect:::as_indices_sel_impl(...)
  11. tidyselect:::as_indices_impl(x, vars, strict = strict)
  12. vctrs::vec_as_subscript(x, logical = "error")
    Run rlang::last_trace() to see the full context.

rlang::last_trace()
<error/vctrs_error_subscript_type>
Must subset columns with a valid subscript vector.
x Subscript has the wrong type list.
i It must be numeric or character.
Backtrace:
x

  1. +-df %>% e_charts() %>% e_parallel(price, amount, letter, opts = list(smooth = TRUE))
  2. +-echarts4r::e_parallel(., price, amount, letter, opts = list(smooth = TRUE))
  3. +-echarts4r:::e_parallel.echarts4r(., price, amount, letter, opts = list(smooth = TRUE))
  4. | -e$x$data[[1]] %>% dplyr::select(...)
  5. +-dplyr::select(., ...)
  6. -dplyr:::select.data.frame(., ...)
  7. -tidyselect::eval_select(expr(c(...)), .data)
  8. \-tidyselect:::eval_select_impl(...)
    
  9.   +-tidyselect:::with_subscript_errors(...)
    
  10.   | +-base::tryCatch(...)
    
  11.   | | \-base:::tryCatchList(expr, classes, parentenv, handlers)
    
  12.   | |   \-base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
    
  13.   | |     \-base:::doTryCatch(return(expr), name, parentenv, handler)
    
  14.   | \-tidyselect:::instrument_base_errors(expr)
    
  15.   |   \-base::withCallingHandlers(...)
    
  16.   \-tidyselect:::vars_select_eval(...)
    
  17.     \-tidyselect:::walk_data_tree(expr, data_mask, context_mask)
    
  18.       \-tidyselect:::eval_c(expr, data_mask, context_mask)
    
  19.         \-tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
    
  20.           \-tidyselect:::walk_data_tree(new, data_mask, context_mask)
    
  21.             \-tidyselect:::as_indices_sel_impl(...)
    
  22.               \-tidyselect:::as_indices_impl(x, vars, strict = strict)
    
  23.                 \-vctrs::vec_as_subscript(x, logical = "error")
    

@JohnCoene
Copy link
Owner

Which version of {echarts4r} are you on? I just tried and it works on my machine. Could you install the dev version from github and try again?

remotes::install_github("JohnCoene/echarts4r")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants