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

multiple selections on parcoords axes #2415

Merged
merged 26 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9208cc3
- factored out brushing
monfera Feb 5, 2018
40b0c2b
- full refactor of shader code, DRY, optimizations etc.
monfera Mar 3, 2018
7f507c3
remove constraintrange from parcoords mocks
alexcjohnson Mar 6, 2018
d25d261
tweak the parcoords constraint grabber ranges
alexcjohnson Mar 9, 2018
367e294
parcoords constraint cleanup
alexcjohnson Mar 12, 2018
1030542
dimension.multiselect boolean attr
alexcjohnson Mar 12, 2018
c046397
Merge branch 'master' into parcoords-multiselect-squashed
alexcjohnson Mar 12, 2018
a4f4a5f
info_array dimensions='1-2'
alexcjohnson Mar 13, 2018
a78db76
finalize multiselect functionality
alexcjohnson Mar 15, 2018
01ba11e
:hocho: fdescribe
alexcjohnson Mar 15, 2018
68e9e48
lint axisbrush
alexcjohnson Mar 15, 2018
cb00901
fail -> failTest - fail is a jasmine global
alexcjohnson Mar 15, 2018
f2690ac
fix one more filter bug, refactor parcoords test to hopefully reuse c…
alexcjohnson Mar 15, 2018
ec44922
refactor more of parcoords test to use Plotly.react
alexcjohnson Mar 15, 2018
352a884
parentElement -> parentNode
alexcjohnson Mar 15, 2018
57085e1
shorten parcoords snap tweening during tests
alexcjohnson Mar 15, 2018
fff668a
@flaky on ordinal constraint snap test
alexcjohnson Mar 15, 2018
6fe2d79
I give up... @noCI my new tests
alexcjohnson Mar 15, 2018
2911ae6
:hocho: parcoords memory leak
alexcjohnson Mar 16, 2018
fa1a436
parcoords create/update pattern
alexcjohnson Mar 16, 2018
0e75c5a
parcoords test cleanup
alexcjohnson Mar 16, 2018
a7bd686
click to select an ordinal value
alexcjohnson Mar 17, 2018
6432b89
cleanup, and remove some obsolete code
alexcjohnson Mar 17, 2018
03d8779
tweaked parcoords mocks
alexcjohnson Mar 19, 2018
f147644
Revert "tweaked parcoords mocks"
alexcjohnson Mar 19, 2018
c3cc927
fix bug introduced in cleanup
alexcjohnson Mar 19, 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
25 changes: 18 additions & 7 deletions src/lib/coerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,11 @@ exports.valObjectMeta = {
'An {array} of plot information.'
].join(' '),
requiredOpts: ['items'],
// set dimensions=2 for a 2D array
// set `dimensions=2` for a 2D array or '1-2' for either
// `items` may be a single object instead of an array, in which case
// `freeLength` must be true.
// if `dimensions='1-2'` and items is a 1D array, then the value can
// either be a matching 1D array or an array of such matching 1D arrays
otherOpts: ['dflt', 'freeLength', 'dimensions'],
coerceFunction: function(v, propOut, dflt, opts) {

Expand All @@ -278,7 +280,7 @@ exports.valObjectMeta = {
return out;
}

var twoD = opts.dimensions === 2;
var twoD = opts.dimensions === 2 || (opts.dimensions === '1-2' && Array.isArray(v) && Array.isArray(v[0]));

if(!Array.isArray(v)) {
propOut.set(dflt);
Expand All @@ -288,19 +290,28 @@ exports.valObjectMeta = {
var items = opts.items;
var vOut = [];
var arrayItems = Array.isArray(items);
var len = arrayItems ? items.length : v.length;
var arrayItems2D = arrayItems && twoD && Array.isArray(items[0]);
var innerItemsOnly = twoD && arrayItems && !arrayItems2D;
var len = (arrayItems && !innerItemsOnly) ? items.length : v.length;

var i, j, len2, vNew;
var i, j, row, item, len2, vNew;

dflt = Array.isArray(dflt) ? dflt : [];

if(twoD) {
for(i = 0; i < len; i++) {
vOut[i] = [];
var row = Array.isArray(v[i]) ? v[i] : [];
len2 = arrayItems ? items[i].length : row.length;
row = Array.isArray(v[i]) ? v[i] : [];
if(innerItemsOnly) len2 = items.length;
else if(arrayItems) len2 = items[i].length;
else len2 = row.length;

for(j = 0; j < len2; j++) {
vNew = coercePart(row[j], arrayItems ? items[i][j] : items, (dflt[i] || [])[j]);
if(innerItemsOnly) item = items[j];
else if(arrayItems) item = items[i][j];
else item = items;

vNew = coercePart(row[j], item, (dflt[i] || [])[j]);
if(vNew !== undefined) vOut[i][j] = vNew;
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/traces/parcoords/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ module.exports = {
editType: 'calc',
description: 'The shown name of the dimension.'
},
// TODO: better way to determine ordinal vs continuous axes,
// so users can use tickvals/ticktext with a continuous axis.
tickvals: extendFlat({}, axesAttrs.tickvals, {editType: 'calc'}),
ticktext: extendFlat({}, axesAttrs.ticktext, {editType: 'calc'}),
tickformat: {
Expand Down Expand Up @@ -79,16 +81,26 @@ module.exports = {
constraintrange: {
valType: 'info_array',
role: 'info',
freeLength: true,
dimensions: '1-2',
items: [
{valType: 'number', editType: 'calc'},
{valType: 'number', editType: 'calc'}
],
editType: 'calc',
description: [
'The domain range to which the filter on the dimension is constrained. Must be an array',
'of `[fromValue, toValue]` with finite numbers as elements.'
'of `[fromValue, toValue]` with `fromValue <= toValue`, or if `multiselect` is not',
'disabled, you may give an array of arrays, where each inner array is `[fromValue, toValue]`.'
].join(' ')
},
multiselect: {
valType: 'boolean',
dflt: true,
role: 'info',
editType: 'calc',
description: 'Do we allow multiple selection ranges or just a single range?'
},
values: {
valType: 'data_array',
role: 'info',
Expand Down
Loading