Skip to content

Instantly share code, notes, and snippets.

@helgasoft
Last active September 11, 2025 19:34
Show Gist options
  • Save helgasoft/e914fe6f4a9ed9407f78e41cb18b3aaa to your computer and use it in GitHub Desktop.
Save helgasoft/e914fe6f4a9ed9407f78e41cb18b3aaa to your computer and use it in GitHub Desktop.
echarty announcements and temporary notes
#' This gist is for echarty announcements and notes
#' Comments are temporary, periodically deleted.
#' If you like echarty, please consider granting a Github star ⭐.
library(echarty)
data.frame(x = seq.int(1, 5, 1),
y = seq.int(1, 10, 2)) |>
ec.init(
series.param= list(
type='line', symbolSize= 10,
lineStyle = list(opacity= 0.7),
itemStyle = list(opacity= 1),
areaStyle= list(color= 'red', opacity= 0.5))
)
@helgasoft
Copy link
Author

helgasoft commented Feb 6, 2024

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 💐👑

@helgasoft
Copy link
Author

helgasoft commented Sep 10, 2025

@bianchenhao, ECharts v.6.0 is supported in latest version of echarty

remotes::install_github('helgasoft/echarty')  # latest
library(echarty)

mtx <- cor(swiss)
cols <- colnames(mtx)
mtx[upper.tri(mtx)] <- NA
datam <- as.data.frame(mtx)
datam <- tibble::rownames_to_column(datam, 'x')
# Convert to long format
long_data_base <- reshape( datam, direction= "long",
  idvar = "x",
  varying = list(colnames(mtx)),
  v.names = "value",
  timevar = "y",
  times = cols # Custom labels for timevar
)
datam <- na.omit(long_data_base)
row.names(datam) <- NULL
vals <- lapply(cols, \(x) { list(value=x) })

ec.init(
  title= list(text= 'demo: new matrix chart from ECharts v.6.0'),
  preset=F,   # to remove default axes
  matrix= list(x= list(data=vals), y= list(data=vals)),
  visualMap= list(type='continuous', min=-1,max=1, dimension=3, 
                 calculable=TRUE, orient='horizontal', bottom=0, left='center'),
  series= list(list(type= 'heatmap', coordinateSystem= 'matrix', 
                    data= ec.data(datam), 
    label= list(show=TRUE, formatter= ec.clmn('%R2@', 3))
  ))
)
image

If you like echarty, please consider granting a Github star ⭐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment