Skip to content

Instantly share code, notes, and snippets.

@helgasoft
Last active June 27, 2022 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helgasoft/26288824026e9ebfcc8446406f6368f4 to your computer and use it in GitHub Desktop.
Save helgasoft/26288824026e9ebfcc8446406f6368f4 to your computer and use it in GitHub Desktop.
R | ECharts | large scatter without animation; loess, lm interpolation
library(ggplot2) # for diamonds data =56K recs
library(dplyr)
data <- diamonds |> select(price, carat, cut) |> group_by(cut)
library(echarty)
p <- data |>
ec.init( # series & dataset are preset here
dataZoom= list(type='inside'),
tooltip= list(show= TRUE))
p$x$opts$series <- lapply(p$x$opts$series, function(s) {
s$animation= FALSE; s$large= TRUE; s$symbolSize= 2; s
}) # update preset series
p
@helgasoft
Copy link
Author

How to disable default animation on large scatter charts - inquiry from @GBL-123

image

Note: if you like this solution, please consider granting a Github star ⭐ to echarty.

@GBL-123
Copy link

GBL-123 commented Feb 25, 2022

Thank you!😀

@helgasoft
Copy link
Author

Line interpolation (loess, lm) added to scatter chart, inquiry by @lhabegger.

ggdf <- data.frame(rank=1:7, value= c(4574,3246,2346,6234,6845,7545,5432), na=rep(NA,7))
tmp <- loess(value ~ rank, ggdf)
#  tmp <- lm(value ~ rank, ggdf)
p <- ggdf |> ec.init(legend= list(show=TRUE))
p$x$opts$series[[1]]$symbolSize <- 7
p$x$opts$series[[2]] <- list(type= 'line', name= 'loess', symbolSize= 2,
	data= ec.data(data.frame(seq_along(ggdf$rank), tmp$fitted), header=FALSE))
p

image
If you like this solution, please consider granting a Github star ⭐ to echarty.

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