Skip to content
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

Preserve ui state across Plotly.react redraws #3236

Merged
merged 35 commits into from
Nov 30, 2018
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3a70fee
make hover label test independent of selection order
alexcjohnson Nov 3, 2018
a86ca58
fix and :lock: bug with impliedEdits and groupby transform
alexcjohnson Oct 31, 2018
4ca328a
remove impliedEdits that got forgotten in #3044
alexcjohnson Oct 31, 2018
082ac38
alias `Lib.nestedProperty` separately in plot_api
alexcjohnson Oct 31, 2018
b134a52
fix obscure undo/redo bug with container array relayout removal
alexcjohnson Oct 31, 2018
c62cf25
clean up handleHover3d
alexcjohnson Nov 2, 2018
a11ec44
add _gui(Restyle|Relayout|Update) and _storeDirectGUIEdit and track c…
alexcjohnson Nov 2, 2018
10ddbb9
fix and :lock: problem with dragging colorbars in sub-containers
alexcjohnson Nov 6, 2018
4af2bf8
add and coerce uirevision attributes
alexcjohnson Nov 8, 2018
03baca7
use uirevisions in Plotly.react to preserve ui state
alexcjohnson Nov 9, 2018
6a9d0d7
add selectedpoints to uirevision framework
alexcjohnson Nov 9, 2018
a443747
break Plotly.react tests out of plot_api_test into plot_api_react_test
alexcjohnson Nov 9, 2018
54304b4
test uirevision + react logic
alexcjohnson Nov 9, 2018
86b90d4
remove `apply` arg from _storeDirectGUIEdit
alexcjohnson Nov 10, 2018
502082f
:palm_tree: uirevision tests
alexcjohnson Nov 10, 2018
5182f6a
fix and :lock: polar uirevisions
alexcjohnson Nov 10, 2018
89dde84
:lock: ternary uirevisions
alexcjohnson Nov 10, 2018
778ec15
fix and :lock: mapbox uirevisions
alexcjohnson Nov 10, 2018
21f5db5
fix and :lock: editable shapes & annotations uirevision
alexcjohnson Nov 11, 2018
8f0f075
:palm_tree: uirevision tests
alexcjohnson Nov 11, 2018
eb728fe
fix and :lock: editable: true uirevisions
alexcjohnson Nov 11, 2018
c95ae07
revert form of rangeslider relayout call (but it's still _guiRelayout)
alexcjohnson Nov 12, 2018
7ab8630
comment on uirevision<->uid in trace.uirevision attribute description
alexcjohnson Nov 12, 2018
756308f
record real initial axis (auto)range so we can update to autorange
alexcjohnson Nov 13, 2018
874a72a
remove now-obsolete comment about autorange/autofill
alexcjohnson Nov 13, 2018
090231b
fix and :lock: selectionrevision with groupby
alexcjohnson Nov 13, 2018
5a27c00
update trace.uirevision description with what it does/doesn't control
alexcjohnson Nov 13, 2018
2034941
partial preGUI fix for 3D camera
alexcjohnson Nov 19, 2018
6cfe7c5
Merge branch 'master' into ui-key
alexcjohnson Nov 29, 2018
8d11985
write camera.up back to layout only when necessary
alexcjohnson Nov 29, 2018
d9b3aea
Merge branch 'master' into ui-key
alexcjohnson Nov 29, 2018
0621e43
update uirevisions for new title attribute structure #3276
alexcjohnson Nov 30, 2018
bdef7d3
more permissive tickson rotation test for AJ's machine
alexcjohnson Nov 30, 2018
2b77911
looser acceptance for title centering, to work on AJ's machine
alexcjohnson Nov 30, 2018
067bd7d
biger tickwidth difference in tickson rotation test
alexcjohnson Nov 30, 2018
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
75 changes: 57 additions & 18 deletions test/jasmine/assets/custom_assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ exports.assertHoverLabelStyle = function(g, expectation, msg, textSelector) {
expect(textStyle.fill).toBe(expectation.fontColor, msg + ': font.color');
};

function assertLabelContent(label, expectation, msg) {
if(!expectation) expectation = '';

function getLabelContent(label) {
var lines = label.selectAll('tspan.line');
var content = [];

Expand All @@ -77,8 +75,15 @@ function assertLabelContent(label, expectation, msg) {
} else {
fill(label);
}
return content.join('\n');
}

function assertLabelContent(label, expectation, msg) {
if(!expectation) expectation = '';

var content = getLabelContent(label);

expect(content.join('\n')).toBe(expectation, msg + ': text content');
expect(content).toBe(expectation, msg + ': text content');
}

function count(selector) {
Expand Down Expand Up @@ -130,35 +135,63 @@ exports.assertHoverLabelContent = function(expectation, msg) {
expect(ptCnt)
.toBe(expectation.name.length, ptMsg + ' # of visible labels');

var bboxes = [];
var observed = [];
var expected = expectation.nums.map(function(num, i) {
return {
num: num,
name: expectation.name[i],
order: (expectation.hOrder || expectation.vOrder || []).indexOf(i)
};
});
d3.selectAll(ptSelector).each(function(_, i) {
var g = d3.select(this);
var numsSel = g.select('text.nums');
var nameSel = g.select('text.name');

assertLabelContent(numsSel, expectation.nums[i], ptMsg + ' (nums ' + i + ')');
assertLabelContent(nameSel, expectation.name[i], ptMsg + ' (name ' + i + ')');
// Label selection can be out of order... dunno why, but on AJ's Mac,
// just for certain box and violin cases, the order looks correct but
// it's different from what we see in CI (and presumably on
// other systems) which looks wrong.
// Anyway we don't *really* care about the order within the selection,
// we just care that each label is correct. So collect all the info
// about each label, and sort both observed and expected identically.
observed.push({
num: getLabelContent(numsSel),
name: getLabelContent(nameSel),
bbox: this.getBoundingClientRect(),
order: -1
});

if('isRotated' in expectation) {
expect(g.attr('transform').match(reRotate))
.negateIf(expectation.isRotated)
.toBe(null, ptMsg + ' ' + i + ' should be rotated');
}

bboxes.push({bbox: this.getBoundingClientRect(), index: i});
});
if(expectation.vOrder) {
bboxes.sort(function(a, b) {
return (a.bbox.top + a.bbox.bottom - b.bbox.top - b.bbox.bottom) / 2;
if(expectation.vOrder || expectation.hOrder) {
var o2 = observed.slice();
o2.sort(function(a, b) {
return expectation.vOrder ?
(a.bbox.top + a.bbox.bottom - b.bbox.top - b.bbox.bottom) / 2 :
(b.bbox.left + b.bbox.right - a.bbox.left - a.bbox.right) / 2;
});
expect(bboxes.map(function(d) { return d.index; })).toEqual(expectation.vOrder);
}
if(expectation.hOrder) {
bboxes.sort(function(a, b) {
return (b.bbox.left + b.bbox.right - a.bbox.left - a.bbox.right) / 2;
o2.forEach(function(item, i) {
item.order = i;
delete item.bbox;
});
expect(bboxes.map(function(d) { return d.index; })).toEqual(expectation.hOrder);
}
observed.sort(labelSorter);
expected.sort(labelSorter);
alexcjohnson marked this conversation as resolved.
Show resolved Hide resolved
// don't use .toEqual here because we want the message
expect(observed.length).toBe(expected.length, ptMsg);
observed.forEach(function(obsi, i) {
var expi = expected[i];
expect(obsi.num).toBe(expi.num, ptMsg + ' (nums ' + i + ')');
expect(obsi.name).toBe(expi.name, ptMsg + ' (name ' + i + ')');
if(expectation.vOrder || expectation.hOrder) {
expect(obsi.order).toBe(expi.order, ptMsg + ' (order ' + i + ')');
}
});
} else {
if(expectation.nums) {
fail(ptMsg + ': expecting *nums* labels, did not find any.');
Expand All @@ -181,6 +214,12 @@ exports.assertHoverLabelContent = function(expectation, msg) {
}
};

function labelSorter(a, b) {
if(a.name !== b.name) return a.name > b.name ? 1 : -1;
if(a.num !== b.num) return a.num > b.num ? 1 : -1;
return a.order - b.order;
}

exports.assertClip = function(sel, isClipped, size, msg) {
expect(sel.size()).toBe(size, msg + ' clip path (selection size)');

Expand Down