Skip to content

Commit 7d250aa

Browse files
committed
allow multiple parcoords dimensions with the same name
1 parent 20a47fd commit 7d250aa

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/traces/parcoords/parcoords.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function viewModel(model) {
176176
viewModel.dimensions = dimensions.filter(visible).map(function(dimension, i) {
177177
var domainToUnit = domainToUnitScale(dimension);
178178
var foundKey = uniqueKeys[dimension.label];
179-
uniqueKeys[dimension.label] = (foundKey ? 0 : foundKey) + 1;
179+
uniqueKeys[dimension.label] = (foundKey || 0) + 1;
180180
var key = dimension.label + (foundKey ? '__' + foundKey : '');
181181
return {
182182
key: key,

test/jasmine/tests/parcoords_test.js

+17
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,23 @@ describe('parcoords', function() {
288288
});
289289
});
290290

291+
it('Works with duplicate dimension labels', function(done) {
292+
293+
var mockCopy = Lib.extendDeep({}, mock2);
294+
295+
mockCopy.layout.width = 320;
296+
mockCopy.data[0].dimensions[1].label = mockCopy.data[0].dimensions[0].label;
297+
298+
var gd = createGraphDiv();
299+
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(function() {
300+
301+
expect(gd.data.length).toEqual(1);
302+
expect(gd.data[0].dimensions.length).toEqual(2);
303+
expect(document.querySelectorAll('.axis').length).toEqual(2);
304+
done();
305+
});
306+
});
307+
291308
it('Works with a single line; also, use a longer color array than the number of lines', function(done) {
292309

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

0 commit comments

Comments
 (0)