Last active
October 23, 2025 03:36
-
-
Save helgasoft/e914fe6f4a9ed9407f78e41cb18b3aaa to your computer and use it in GitHub Desktop.
echarty announcements and temporary notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' 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( | |
| load= 'https://cdn.jsdelivr.net/gh/apache/echarts-custom-series@main/custom-series/segmentedDoughnut/dist/index.auto.js', | |
| ask= 'loadRemote', | |
| 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) ) | |
| ) |
@shahreyar-abeer, here is how to bind a data columns to opacity and other styling in echarty
remotes::install_github('helgasoft/echarty') # get latest
iris |> mutate(name= sample(c('pot1','pot2','pot3'), 150, TRUE),
opa= sample(c(0.4, 0.8, NA), 150, TRUE),
dsy= sample(c('rect','diamond','triangle'), 150, TRUE)
) |> distinct(name, Species, .keep_all= TRUE) |> group_by(name) |>
ec.init(
series.param= list(type='bar', encode= list(
data= list(value= c('Species', 'Petal.Width'),
itemStyle= list(opacity='opa', borderRadius=7,
decal= list(symbol= 'dsy', symbolSize=1.5) ))
))
)
If you like echarty, please consider granting a Github star ⭐.
@g-no, your shiny code can append data with echarty
remotes::install_github('helgasoft/echarty') # get latest
library(shiny)
ui <- fluidPage(
actionButton("append", "Append data pairs"),
ecs.output("plot")
)
server <- function(input, output, session) {
base <- data.frame(x = c(4, 3), y = c(4, 3))
output$plot <- ecs.render({
ec.init(
animation= list(show=F), legend= list(show=T),
series.param= list(type= 'line', name= "path",
data= ec.data(base)
)
)
})
observeEvent(input$append, {
new <- data.frame(x = c(2, 1), y = c(2, 1))
p <- ecs.proxy("plot")
p$x$opts$data <- ec.data(new)
p |> ecs.exec('p_append_data')
})
}
shinyApp(ui, server)
Cool! Thanks!
Is it possible to animate the plot, so that the data points appear in the order of the series (4,3,2,1 in the example; not sorted after x) with e.g. using an actionButton("play", "Play") and each dot appears 100ms after the previous one?
@g-no, sure, just update the append event:
observeEvent(input$append, {
for (i in 3:1) {
Sys.sleep(0.2)
new <- data.frame(x = c(i, i-1), y = c(i, i-1))
p <- ecs.proxy("plot")
p$x$opts$data <- ec.data(new)
p |> ecs.exec('p_append_data')
}
})
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 💐👑