Skip to content

Commit 3e15f17

Browse files
authoredFeb 25, 2019
Merge pull request #3578 from plotly/scattergl-no-clustering-below-1e5-pts
No scattergl clustering below 1e5 pts
2 parents 4ec7dd1 + f6e8918 commit 3e15f17

7 files changed

+273595
-4
lines changed
 

‎src/traces/scattergl/index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function calc(gd, trace) {
4343
var ya = AxisIDs.getFromId(gd, trace.yaxis);
4444
var subplot = fullLayout._plots[trace.xaxis + trace.yaxis];
4545
var len = trace._length;
46+
var hasTooManyPoints = len >= TOO_MANY_POINTS;
4647
var len2 = len * 2;
4748
var stash = {};
4849
var i, xx, yy;
@@ -73,7 +74,7 @@ function calc(gd, trace) {
7374

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

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

118119
// save scene opts batch
17 KB
Loading
136 KB
Loading
Loading
Loading

‎test/image/mocks/gl2d_no-clustering.json

+136,793
Large diffs are not rendered by default.

‎test/image/mocks/gl2d_no-clustering2.json

+136,797
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.