-
-
Save helgasoft/e914fe6f4a9ed9407f78e41cb18b3aaa to your computer and use it in GitHub Desktop.
| #' This gist is for echarty announcements and notes | |
| #' Comments are temporary, periodically deleted. | |
| #' If you like echarty, please consider granting a Github star β. | |
| remotes::install_github('helgasoft/echarty') # get latest | |
| library(echarty) | |
| #------ segmentedDoughnut with ECharts v.6+ ----- | |
| ec.init( | |
| series.param= list( | |
| type= 'custom', renderItem= 'segmentedDoughnut', | |
| coordinateSystem= 'none', | |
| itemPayload= list( | |
| radius= list('50%','65%'), segmentCount= 8, | |
| label= list(show=T, formatter= '{c}/{b}', fontSize=35, color= '#555') | |
| ), | |
| data= list(5) ) | |
| ) |
@lcauquil, ECharts boxplot outliers are only values and do not hold other dataset info like names.
However, echarty allows parameter update with ec.upd where outlier names could be merged.
remotes::install_github('helgasoft/echarty') # get latest
library(echarty)
df <- starwars |> select(name,mass) |> na.omit()
ds <- ec.data(df, format='boxplot', layout= 'v')
ec.init(
dataset= ds$dataset, series= ds$series, xAxis= ds$xAxis, yAxis= ds$yAxis,
legend= list(show= TRUE), tooltip= list(show= TRUE),
dataZoom= list(type='slider', yAxisIndex=1)
) |>
ec.upd({
xn <- 'starwars' # X-axis name for outliers
dataset[[2]]$transform$config$itemNameFormatter <- xn # set explicit X name to match the outliers
box_obj <- boxplot(df$mass, plot= FALSE)
# Find the indices of the rows containing outliers
dd <- ec.data(df[df$mass %in% box_obj$out,] |> mutate(value= lapply(mass, \(x) list(xn,x))),
format= 'names')
series <- append(series, list(list(type='scatter', name='outliers', data=dd)))
})
If you like echarty, please consider granting a Github star β
Sorry, but it's not working
library(echarty)
library(dplyr)
df <- starwars |> select(name,mass) |> na.omit()
ds <- ec.data(df, format='boxplot', layout= 'v')
ec.init(
dataset= ds$dataset, series= ds$series, xAxis= ds$xAxis, yAxis= ds$yAxis,
legend= list(show= TRUE), tooltip= list(show= TRUE),
dataZoom= list(type='slider', yAxisIndex=1)
) |>
ec.upd({
xn <- 'starwars' # X-axis name for outliers
dataset[[2]]$transform$config$itemNameFormatter <- xn # set explicit X name to match the outliers
box_obj <- boxplot(df$mass, plot= FALSE)
# Find the indices of the rows containing outliers
dd <- ec.data(df[df$mass %in% box_obj$out,] |> mutate(value= lapply(mass, (x) list(xn,x))),
format= 'names')
series <- append(series, list(list(type='scatter', name='outliers', data=dd)))
})
Erreur dans r1[[colp[[xy]]]] : indice hors limites
sessionInfo()
R version 4.6.0 (2026-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)
Matrix products: default
LAPACK version 3.12.1
locale:
[1] LC_COLLATE=French_France.utf8 LC_CTYPE=French_France.utf8 LC_MONETARY=French_France.utf8 LC_NUMERIC=C
[5] LC_TIME=French_France.utf8
time zone: Europe/Paris
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.2.1 echarty_1.7.3
loaded via a namespace (and not attached):
[1] vctrs_0.7.3 cli_3.6.6 data.tree_1.2.0 rlang_1.3.0 stringi_1.8.9 otel_0.2.0 processx_3.9.0
[8] generics_0.1.4 ellmer_0.4.2 S7_0.2.2 coro_1.1.0 glue_1.8.1 htmltools_0.5.9 ps_1.9.3
[15] pak_0.11.1 tibble_3.3.1 fastmap_1.2.0 lifecycle_1.0.5 httr2_1.3.0 compiler_4.6.0 htmlwidgets_1.6.4
[22] pkgconfig_2.0.3 rstudioapi_0.19.0 digest_0.6.39 R6_2.6.1 tidyselect_1.2.1 pillar_1.11.1 callr_3.8.0
[29] magrittr_2.0.5 withr_3.0.3 tools_4.6.0
Ok, it's fine, I think that I had to restart my session.
Thank you very much for the support !
echarty is on WebR - see the Coder.
Live R-code execution inside a single web page. No Rmd. No server. No installation. Wow!
Thanks to: @seanbirchall for the idea and @timelyportfolio for the solution ππ