Skip to content

Instantly share code, notes, and snippets.

@helgasoft
Last active December 6, 2021 17:46
Show Gist options
  • Save helgasoft/0ddddb9c77d2e12aaf7fc98c32ddd09f to your computer and use it in GitHub Desktop.
Save helgasoft/0ddddb9c77d2e12aaf7fc98c32ddd09f to your computer and use it in GitHub Desktop.
R | ECharts | Display big datasets with scatterGL and cartesian2d (GPU processing)
# ------ 1) prepare data
library(tibble)
dim <- 12500 # sample data half-quantity
slip <- if (dim %% 2) 0.1 else -0.1
setData <- function(offset) {
t <- tibble(x = runif(dim, max=10),
y = offset + sin(x) - x * slip * runif(dim))
round(t,3)
}
# two sets, same data shifted vertically
dat <- rbind(setData(0), setData(1))
# ------ 2) show data
library(echarty)
p <- ec.init(load='3D') |> ec.theme('dark-mushroom')
p$x$opts <- list(
title = list(text=paste('scatterGL -',nrow(dat),'points + zoom')),
xAxis = list(show=TRUE),
yAxis = list(show=TRUE),
series= list(type= 'scatterGL', data= ec.data(dat, 'dataset', FALSE),
symbolSize=3, large=TRUE,
itemStyle=list(opacity=0.4, color='cyan')
),
dataZoom = list(type='inside',start=50)
)
p
@helgasoft
Copy link
Author

helgasoft commented Dec 6, 2021

@docal555, @uzpaka - a solution to the problem.
If you like it, please consider giving a Github star ⭐ to echarty.

image

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