Skip to content

Commit

Permalink
Merge pull request #3578 from plotly/scattergl-no-clustering-below-1e…
Browse files Browse the repository at this point in the history
…5-pts

No scattergl clustering below 1e5 pts
  • Loading branch information
etpinard authored Feb 25, 2019
2 parents 4ec7dd1 + f6e8918 commit 3e15f17
Show file tree
Hide file tree
Showing 7 changed files with 273,595 additions and 4 deletions.
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

0 comments on commit 3e15f17

Please sign in to comment.