Skip to content

Commit 980855c

Browse files
committed
Merge branch 'splom-feature' into splom-zoom-perf
(to get tests to pass)
2 parents cc1b3de + 2e6b610 commit 980855c

19 files changed

+374
-111
lines changed

.circleci/config.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,25 @@ jobs:
9797
- store_artifacts:
9898
path: build
9999

100+
test-image2:
101+
docker:
102+
- image: plotly/testbed:latest
103+
working_directory: /var/www/streambed/image_server/plotly.js/
104+
steps:
105+
- checkout
106+
- attach_workspace:
107+
at: /var/www/streambed/image_server/plotly.js/
108+
- run:
109+
name: Run and setup container
110+
command: |
111+
supervisord &
112+
npm run docker -- setup
113+
- run:
114+
name: Run image tests
115+
command: ./.circleci/test.sh image2
116+
- store_artifacts:
117+
path: build
118+
100119
test-syntax:
101120
docker:
102121
- image: circleci/node:8.9.4
@@ -123,6 +142,9 @@ workflows:
123142
- test-image:
124143
requires:
125144
- build
145+
- test-image2:
146+
requires:
147+
- build
126148
- test-syntax:
127149
requires:
128150
- build

.circleci/test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ case $1 in
4141

4242
image)
4343
npm run test-image || EXIT_STATE=$?
44+
exit $EXIT_STATE
45+
;;
46+
47+
image2)
4448
npm run test-export || EXIT_STATE=$?
4549
npm run test-image-gl2d || EXIT_STATE=$?
4650
exit $EXIT_STATE

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plot_api/subroutines.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,11 @@ exports.doLegend = function(gd) {
457457

458458
exports.doTicksRelayout = function(gd) {
459459
Axes.doTicks(gd, 'redraw');
460+
461+
if(gd._fullLayout._hasOnlyLargeSploms) {
462+
Registry.subplotsRegistry.splom.plot(gd);
463+
}
464+
460465
exports.drawMainTitle(gd);
461466
return Plots.previousPromises(gd);
462467
};

src/plots/cartesian/type_defaults.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,20 @@ function getFirstNonEmptyTrace(data, id, axLetter) {
106106
for(var i = 0; i < data.length; i++) {
107107
var trace = data[i];
108108

109+
if(trace.type === 'splom' &&
110+
trace._commonLength > 0 &&
111+
trace['_' + axLetter + 'axes'][id]
112+
) {
113+
return trace;
114+
}
115+
109116
if((trace[axLetter + 'axis'] || axLetter) === id) {
110117
if(isBoxWithoutPositionCoords(trace, axLetter)) {
111118
return trace;
112119
}
113120
else if((trace[axLetter] || []).length || trace[axLetter + '0']) {
114121
return trace;
115122
}
116-
else if(trace.type === 'splom' &&
117-
trace._commonLength > 0 &&
118-
trace[axLetter + 'axes'].indexOf(id) === 0
119-
) {
120-
return trace;
121-
}
122123
}
123124
}
124125
}

src/plots/plots.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,16 +414,14 @@ plots.supplyDefaults = function(gd) {
414414

415415
// turn on flag to optimize large splom-only graphs
416416
// mostly by omitting SVG layers during Cartesian.drawFramework
417-
if(
417+
newFullLayout._hasOnlyLargeSploms = (
418418
newFullLayout._basePlotModules.length === 1 &&
419419
newFullLayout._basePlotModules[0].name === 'splom' &&
420420
splomXa.length > 15 &&
421421
splomYa.length > 15 &&
422422
newFullLayout.shapes.length === 0 &&
423423
newFullLayout.images.length === 0
424-
) {
425-
newFullLayout._hasOnlyLargeSploms = 1;
426-
}
424+
);
427425

428426
// TODO remove in v2.0.0
429427
// add has-plot-type refs to fullLayout for backward compatibility

src/traces/scattergl/convert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function convertStyle(gd, trace) {
9090
}
9191

9292
function convertMarkerStyle(trace) {
93-
var count = trace._length || (trace.dimensions || [])._length;
93+
var count = trace._length || trace._commonLength;
9494
var optsIn = trace.marker;
9595
var optsOut = {};
9696
var i;

src/traces/splom/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module.exports = {
9191
// ...
9292
// more options
9393

94-
editType: 'plot'
94+
editType: 'calc'
9595
},
9696

9797
showupperhalf: {

src/traces/splom/base_plot.js

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ function dragOne(gd, trace, scene) {
6363

6464
var xa = AxisIDs.getFromId(gd, trace._diag[i][0]);
6565
if(xa) {
66-
rng[0] = xa.range[0];
67-
rng[2] = xa.range[1];
66+
rng[0] = xa.r2l(xa.range[0]);
67+
rng[2] = xa.r2l(xa.range[1]);
6868
}
6969

7070
var ya = AxisIDs.getFromId(gd, trace._diag[i][1]);
7171
if(ya) {
72-
rng[1] = ya.range[0];
73-
rng[3] = ya.range[1];
72+
rng[1] = ya.r2l(ya.range[0]);
73+
rng[3] = ya.r2l(ya.range[1]);
7474
}
7575

7676
k++;
@@ -94,17 +94,16 @@ function drawGrid(gd) {
9494
if(!splomGrid) {
9595
splomGrid = fullLayout._splomGrid = createLine(regl);
9696
}
97-
splomGrid.update(makeGridData(gd));
97+
98+
splomGrid._data = makeGridData(gd);
99+
splomGrid.update(splomGrid._data);
98100
splomGrid.draw();
99101
}
100102

101-
// this clocks in at ~30ms at 50x50 - we could perf this up!
102103
function makeGridData(gd) {
103104
var fullLayout = gd._fullLayout;
104105
var gs = fullLayout._size;
105106
var fullView = [0, 0, fullLayout.width, fullLayout.height];
106-
var splomXa = Object.keys(fullLayout._splomAxes.x);
107-
var splomYa = Object.keys(fullLayout._splomAxes.y);
108107
var lookup = {};
109108
var k;
110109

@@ -128,45 +127,39 @@ function makeGridData(gd) {
128127
}
129128
}
130129

131-
for(var i = 0; i < splomXa.length; i++) {
132-
var xa = AxisIDs.getFromId(gd, splomXa[i]);
130+
for(k in fullLayout._splomSubplots) {
131+
var sp = fullLayout._plots[k];
132+
var xa = sp.xaxis;
133+
var ya = sp.yaxis;
133134
var xVals = xa._vals;
134-
var xShowZl = showZeroLine(xa);
135-
136-
for(var j = 0; j < splomYa.length; j++) {
137-
var ya = AxisIDs.getFromId(gd, splomYa[j]);
138-
var yVals = ya._vals;
139-
var yShowZl = showZeroLine(ya);
140-
141-
// ya.l2p assumes top-to-bottom coordinate system (a la SVG),
142-
// we need to compute bottom-to-top offsets and slopes:
143-
var yOffset = gs.b + ya.domain[0] * gs.h;
144-
var ym = -ya._m;
145-
var yb = -ym * ya.r2l(ya.range[0], ya.calendar);
146-
147-
var x, y;
148-
149-
if(xa.showgrid) {
150-
for(k = 0; k < xVals.length; k++) {
151-
x = xa._offset + xa.l2p(xVals[k].x);
152-
push('grid', xa, x, yOffset, x, yOffset + ya._length);
153-
}
154-
}
155-
if(xShowZl) {
156-
x = xa._offset + xa.l2p(0);
157-
push('zeroline', xa, x, yOffset, x, yOffset + ya._length);
158-
}
159-
if(ya.showgrid) {
160-
for(k = 0; k < yVals.length; k++) {
161-
y = yOffset + yb + ym * yVals[k].x;
162-
push('grid', ya, xa._offset, y, xa._offset + xa._length, y);
163-
}
135+
var yVals = ya._vals;
136+
// ya.l2p assumes top-to-bottom coordinate system (a la SVG),
137+
// we need to compute bottom-to-top offsets and slopes:
138+
var yOffset = gs.b + ya.domain[0] * gs.h;
139+
var ym = -ya._m;
140+
var yb = -ym * ya.r2l(ya.range[0], ya.calendar);
141+
var x, y;
142+
143+
if(xa.showgrid) {
144+
for(k = 0; k < xVals.length; k++) {
145+
x = xa._offset + xa.l2p(xVals[k].x);
146+
push('grid', xa, x, yOffset, x, yOffset + ya._length);
164147
}
165-
if(yShowZl) {
166-
y = yOffset + yb + 0;
167-
push('zeroline', ya, xa._offset, y, xa._offset + xa._length, y);
148+
}
149+
if(showZeroLine(xa)) {
150+
x = xa._offset + xa.l2p(0);
151+
push('zeroline', xa, x, yOffset, x, yOffset + ya._length);
152+
}
153+
if(ya.showgrid) {
154+
for(k = 0; k < yVals.length; k++) {
155+
y = yOffset + yb + ym * yVals[k].x;
156+
push('grid', ya, xa._offset, y, xa._offset + xa._length, y);
168157
}
169158
}
159+
if(showZeroLine(ya)) {
160+
y = yOffset + yb + 0;
161+
push('zeroline', ya, xa._offset, y, xa._offset + xa._length, y);
162+
}
170163
}
171164

172165
var gridBatches = [];
@@ -178,7 +171,6 @@ function makeGridData(gd) {
178171
}
179172

180173
// just like in Axes.doTicks but without the loop over traces
181-
// TODO dry this up
182174
function showZeroLine(ax) {
183175
var rng = Lib.simpleMap(ax.range, ax.r2l);
184176
var p0 = ax.l2p(0);

src/traces/splom/defaults.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2121
}
2222

2323
var dimLength = handleDimensionsDefaults(traceIn, traceOut);
24-
if(!dimLength) {
24+
25+
var showDiag = coerce('diagonal.visible');
26+
var showUpper = coerce('showupperhalf');
27+
var showLower = coerce('showlowerhalf');
28+
29+
if(!dimLength || (!showDiag && !showUpper && !showLower)) {
2530
traceOut.visible = false;
2631
return;
2732
}
@@ -34,13 +39,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3439
var isBubble = subTypes.isBubble(traceOut);
3540
coerce('marker.line.width', isOpen || isBubble ? 1 : 0);
3641

37-
// TODO if all 3 below are false,
38-
// should we set `visible: false` and exit early?
39-
40-
coerce('diagonal.visible');
41-
coerce('showupperhalf');
42-
coerce('showlowerhalf');
43-
4442
handleAxisDefaults(traceIn, traceOut, layout, coerce);
4543

4644
Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
@@ -107,6 +105,10 @@ function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
107105
var xaxes = coerce('xaxes', fillAxisIdArray('x', axDfltLength));
108106
var yaxes = coerce('yaxes', fillAxisIdArray('y', axDfltLength));
109107

108+
// to avoid costly indexOf
109+
traceOut._xaxes = arrayToHashObject(xaxes);
110+
traceOut._yaxes = arrayToHashObject(yaxes);
111+
110112
// allow users to under-specify number of axes
111113
var axLength = Math.min(axDfltLength, xaxes.length, yaxes.length);
112114

@@ -170,3 +172,11 @@ function fillAxisStash(layout, axId, dim) {
170172
stash[axId] = (dim || {}).label || '';
171173
}
172174
}
175+
176+
function arrayToHashObject(arr) {
177+
var obj = {};
178+
for(var i = 0; i < arr.length; i++) {
179+
obj[arr[i]] = 1;
180+
}
181+
return obj;
182+
}

0 commit comments

Comments
 (0)