Skip to content

Splom marker edits regression fixups #3161

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 5 commits into from
Oct 29, 2018
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
34 changes: 20 additions & 14 deletions src/traces/splom/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ var extendFlat = require('../../lib/extend').extendFlat;
var scatterMarkerAttrs = scatterAttrs.marker;
var scatterMarkerLineAttrs = scatterMarkerAttrs.line;

var markerLineAttrs = extendFlat(colorAttrs('marker.line', {editTypeOverride: 'calc'}), {
width: extendFlat({}, scatterMarkerLineAttrs.width, {editType: 'calc'}),
editType: 'calc'
});

var markerAttrs = extendFlat(colorAttrs('marker'), {
symbol: scatterMarkerAttrs.symbol,
size: extendFlat({}, scatterMarkerAttrs.size, {editType: 'markerSize'}),
sizeref: scatterMarkerAttrs.sizeref,
sizemin: scatterMarkerAttrs.sizemin,
sizemode: scatterMarkerAttrs.sizemode,
opacity: scatterMarkerAttrs.opacity,
colorbar: scatterMarkerAttrs.colorbar,
line: markerLineAttrs,
editType: 'calc'
});

markerAttrs.color.editType = markerAttrs.cmin.editType = markerAttrs.cmax.editType = 'style';

function makeAxesValObject(axLetter) {
return {
valType: 'info_array',
Expand Down Expand Up @@ -105,20 +124,7 @@ module.exports = {
].join(' ')
}),

marker: extendFlat({}, colorAttrs('marker'), {
symbol: scatterMarkerAttrs.symbol,
size: extendFlat({}, scatterMarkerAttrs.size, {editType: 'markerSize'}),
sizeref: scatterMarkerAttrs.sizeref,
sizemin: scatterMarkerAttrs.sizemin,
sizemode: scatterMarkerAttrs.sizemode,
opacity: scatterMarkerAttrs.opacity,
colorbar: scatterMarkerAttrs.colorbar,
line: extendFlat({}, colorAttrs('marker.line'), {
width: scatterMarkerLineAttrs.width,
editType: 'calc'
}),
editType: 'calc'
}),
marker: markerAttrs,

xaxes: makeAxesValObject('x'),
yaxes: makeAxesValObject('y'),
Expand Down
14 changes: 8 additions & 6 deletions src/traces/splom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,17 @@ function editStyle(gd, cd0) {
var trace = cd0.trace;
var scene = gd._fullLayout._splomScenes[trace.uid];

calcColorscales(trace);
if(scene) {
calcColorscales(trace);

Lib.extendFlat(scene.matrixOptions, convertMarkerStyle(trace));
// TODO [un]selected styles?
Lib.extendFlat(scene.matrixOptions, convertMarkerStyle(trace));
// TODO [un]selected styles?

var opts = Lib.extendFlat({}, scene.matrixOptions, scene.viewOpts);
var opts = Lib.extendFlat({}, scene.matrixOptions, scene.viewOpts);

// TODO this is too long for arrayOk attributes!
scene.matrix.update(opts, null);
// TODO this is too long for arrayOk attributes!
scene.matrix.update(opts, null);
}
}

function hoverPoints(pointData, xval, yval) {
Expand Down
85 changes: 85 additions & 0 deletions test/jasmine/tests/splom_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,50 @@ describe('Test splom interactions:', function() {
.catch(failTest)
.then(done);
});

it('@gl should not fail when editing graph with visible:false traces', function(done) {
Plotly.plot(gd, [{
type: 'splom',
dimensions: [{values: []}, {values: []}]
}, {
type: 'splom',
dimensions: [{values: [1, 2, 3]}, {values: [2, 3, 4]}]
}])
.then(function() {
var fullData = gd._fullData;
var fullLayout = gd._fullLayout;
var splomScenes = fullLayout._splomScenes;
var opts = splomScenes[fullData[1].uid].matrixOptions;

expect(fullData[0].visible).toBe(false, 'trace 0 visible');
expect(fullData[1].visible).toBe(true, 'trace 1 visible');
expect(Object.keys(splomScenes).length).toBe(1, '# of splom scenes');

expect(opts.opacity).toBe(1, 'marker opacity');
expect(opts.color).toEqual(new Uint8Array([255, 127, 14, 255]), 'marker color');
expect(opts.colors).toBe(undefined, 'marker colors');

return Plotly.restyle(gd, 'marker.opacity', [undefined, [0.2, 0.3, 0.4]]);
})
.then(function() {
var fullData = gd._fullData;
var fullLayout = gd._fullLayout;
var opts = fullLayout._splomScenes[fullData[1].uid].matrixOptions;

// ignored by regl-splom
expect(opts.opacity).toBe(1, 'marker opacity');
// ignored by regl-splom
expect(opts.color).toEqual(new Uint8Array([255, 127, 14, 255]), 'marker color');
// marker.opacity applied here
expect(opts.colors).toBeCloseTo2DArray([
[1, 0.498, 0.0549, 0.2],
[1, 0.498, 0.0549, 0.3],
[1, 0.498, 0.0549, 0.4]
], 'marker colors');
})
.catch(failTest)
.then(done);
});
});

describe('Test splom update switchboard:', function() {
Expand Down Expand Up @@ -1129,6 +1173,31 @@ describe('Test splom update switchboard:', function() {
expect(toPlainArray(scene.matrixOptions.colors[2]))
.toBeCloseToArray([0, 0, 1, 1], 1, msg + '- 2');

return Plotly.restyle(gd, {
'marker.cmin': -3,
'marker.cmax': 3,
'marker.color': [[1, 2, 3]]
});
})
.then(function() {
var msg = 'after colorscale marker.color restyle';

assertSpies(msg, [
['supplyDefaults', 1],
['doCalcdata', 0],
['doTicks', 0],
['clear', 1],
['update', 1],
['draw', 1]
]);

expect(toPlainArray(scene.matrixOptions.colors[0]))
.toBeCloseToArray([0.890, 0.6, 0.4078, 1], 1, msg + '- 0');
expect(toPlainArray(scene.matrixOptions.colors[1]))
.toBeCloseToArray([0.81176, 0.3333, 0.2431, 1], 1, msg + '- 1');
expect(toPlainArray(scene.matrixOptions.colors[2]))
.toBeCloseToArray([0.6980, 0.0392, 0.1098, 1], 1, msg + '- 2');

return Plotly.restyle(gd, 'marker.size', 20);
})
.then(function() {
Expand Down Expand Up @@ -1164,6 +1233,22 @@ describe('Test splom update switchboard:', function() {
expect(scene.matrixOptions.sizes).toBeCloseToArray([2, 5, 10], 1, msg);
expect(gd._fullLayout.xaxis.range)
.toBeCloseToArray([0.853, 3.235], 1, 'xrng ' + msg);

return Plotly.restyle(gd, 'marker.symbol', 'square');
})
.then(function() {
var msg = 'after scalar marker.symbol restyle';

assertSpies(msg, [
['supplyDefaults', 1],
['doCalcdata', 0],
['doTicks', 0],
['clear', 1],
['update', 1],
['draw', 1]
]);

expect(scene.matrixOptions.marker).not.toBeNull(msg);
})
.catch(failTest)
.then(done);
Expand Down