Last active
June 27, 2022 18:41
-
-
Save helgasoft/26288824026e9ebfcc8446406f6368f4 to your computer and use it in GitHub Desktop.
R | ECharts | large scatter without animation; loess, lm interpolation
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
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 |
Thank you!😀
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
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
How to disable default animation on large scatter charts - inquiry from @GBL-123
Note: if you like this solution, please consider granting a Github star ⭐ to echarty.