Skip to content

No scattergl clustering below 1e5 pts #3578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/traces/scattergl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function calc(gd, trace) {
var ya = AxisIDs.getFromId(gd, trace.yaxis);
var subplot = fullLayout._plots[trace.xaxis + trace.yaxis];
var len = trace._length;
var hasTooManyPoints = len >= TOO_MANY_POINTS;
var len2 = len * 2;
var stash = {};
var i, xx, yy;
Expand Down Expand Up @@ -73,7 +74,7 @@ function calc(gd, trace) {

// we don't build a tree for log axes since it takes long to convert log2px
// and it is also
if(xa.type !== 'log' && ya.type !== 'log') {
if(hasTooManyPoints && (xa.type !== 'log' && ya.type !== 'log')) {
// FIXME: delegate this to webworker
stash.tree = cluster(positions);
} else {
Expand All @@ -93,7 +94,7 @@ function calc(gd, trace) {
// use average marker size instead to speed things up.
setFirstScatter(fullLayout, trace);
var ppad;
if(len < TOO_MANY_POINTS) {
if(!hasTooManyPoints) {
ppad = calcMarkerSize(trace, len);
} else if(opts.marker) {
ppad = 2 * (opts.marker.sizeAvg || Math.max(opts.marker.size, 3));
Expand All @@ -111,8 +112,8 @@ function calc(gd, trace) {

// FIXME: organize it in a more appropriate manner, probably in sceneOptions
// put point-cluster instance for optimized regl calc
if(opts.marker && len >= TOO_MANY_POINTS) {
opts.marker.cluster = stash.tree;
if(opts.marker) {
opts.marker.snap = stash.tree || TOO_MANY_POINTS;
}

// save scene opts batch
Expand Down
Binary file added test/image/baselines/gl2d_no-clustering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/image/baselines/gl2d_no-clustering2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_scatter-color-clustering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_scatter-continuous-clustering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading