Skip to content

Commit 5479a43

Browse files
committedFeb 25, 2019
do not attempt to cluster scattergl data < 1e5 pts
- note that to do so for 1e4 < pts < 1e5, we must set the regl-scatter2d "snap" option too 1e5 (aka TOO_MANY_POINTS) as regl-scatter2d uses a dflt value of 1e4.
1 parent 13b925c commit 5479a43

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-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

0 commit comments

Comments
 (0)
Please sign in to comment.