Skip to content

Allow multiple parcoords dimensions with the same label #1457

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 2 commits into from
Mar 9, 2017
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
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