Hi,
This is the best package to exploit Echarts. I really love it.
However, I've noticed an issue on e_mark_point() (also on e_mark_line() and e_mark_area()) that is the matching of the serie param uses .get_index(), which uses grep(), the regular expressions.
I don't understand the logic behind these three special functions. In my opinion, it's not consistent with other functions. More importantly, it makes the programming use of these functions difficult. Imagine if the series names contain character like () or the names like "abc" and "abcd".
For example:
library(echarts4r)
x <- data.frame(a = 1:10, b = 1:10)
e_chart(x, 'a') %>%
e_line('b', name = 'aa(bb)', smooth = TRUE, symbol = 'none') %>%
e_mark_point('aa(bb)', data = list(xAxis = 5, yAxis = 5, value = 5))
# Won't be marked unless using `aa\\(bb\\)`
and
library(echarts4r)
x <- data.frame(a = 1:10, b = 1:10, c = 1:20)
e_chart(x, 'a') %>%
e_line('b', name = 'abcdefg', smooth = TRUE, symbol = 'none') %>%
e_line('c', name = 'abcd', smooth = TRUE, symbol = 'none') %>%
e_mark_point('abcd', data = list(xAxis = 5, yAxis = 5, value = 5))
# the two series are both marked (click on the legend of abcd you will understand what I mean)
# but we only want the second. Have to use `^abcd$`
The related Code
|
index <- .get_index(e, serie) |
|
.get_index <- function(e, serie){ |
|
serie <- paste0(serie, collapse = "|") |
|
purrr::map(e$x$opts$series, "name") %>% |
|
unlist() %>% |
|
grep(serie, .) |
|
} |
My suggestion
My suggestion is completely get rid of grep(), making it exact match. Both regular expression way to match or partial match makes the function difficult to use programmingly.
Thanks!
Hi,
This is the best package to exploit Echarts. I really love it.
However, I've noticed an issue on
e_mark_point()(also one_mark_line()ande_mark_area()) that is the matching of theserieparam uses.get_index(), which usesgrep(), the regular expressions.I don't understand the logic behind these three special functions. In my opinion, it's not consistent with other functions. More importantly, it makes the programming use of these functions difficult. Imagine if the series names contain character like
()or the names like "abc" and "abcd".For example:
and
The related Code
echarts4r/R/mark.R
Line 51 in c2799f2
echarts4r/R/utils.R
Lines 550 to 555 in 5224fba
My suggestion
My suggestion is completely get rid of
grep(), making itexactmatch. Both regular expression way to match or partial match makes the function difficult to use programmingly.Thanks!