Skip to content

Commit

Permalink
Merge pull request #1457 from plotly/allow-duplicate-parcoords-dimens…
Browse files Browse the repository at this point in the history
…ion-labels

Allow multiple parcoords dimensions with the same label
  • Loading branch information
monfera committed Mar 9, 2017
2 parents 8c23c67 + 677b0d9 commit 2b24f9d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/traces/parcoords/parcoords.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function viewModel(model) {
viewModel.dimensions = dimensions.filter(visible).map(function(dimension, i) {
var domainToUnit = domainToUnitScale(dimension);
var foundKey = uniqueKeys[dimension.label];
uniqueKeys[dimension.label] = (foundKey ? 0 : foundKey) + 1;
uniqueKeys[dimension.label] = (foundKey || 0) + 1;
var key = dimension.label + (foundKey ? '__' + foundKey : '');
return {
key: key,
Expand Down
17 changes: 17 additions & 0 deletions test/jasmine/tests/parcoords_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,23 @@ describe('@noCI parcoords', function() {
});
});

it('Works with duplicate dimension labels', function(done) {

var mockCopy = Lib.extendDeep({}, mock2);

mockCopy.layout.width = 320;
mockCopy.data[0].dimensions[1].label = mockCopy.data[0].dimensions[0].label;

var gd = createGraphDiv();
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(function() {

expect(gd.data.length).toEqual(1);
expect(gd.data[0].dimensions.length).toEqual(2);
expect(document.querySelectorAll('.axis').length).toEqual(2);
done();
});
});

it('Works with a single line; also, use a longer color array than the number of lines', function(done) {

var mockCopy = Lib.extendDeep({}, mock2);
Expand Down

0 comments on commit 2b24f9d

Please sign in to comment.