Skip to content

Commit 2b24f9d

Browse files
authored
Merge pull request #1457 from plotly/allow-duplicate-parcoords-dimension-labels
Allow multiple parcoords dimensions with the same label
2 parents 8c23c67 + 677b0d9 commit 2b24f9d

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
@@ -285,6 +285,23 @@ describe('@noCI parcoords', function() {
285285
});
286286
});
287287

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

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

0 commit comments

Comments
 (0)