Skip to content

Commit e8cc760

Browse files
committed
similar fix for parcoords.dimensions.values typedArray case
1 parent 12baea7 commit e8cc760

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/traces/parcoords/defaults.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ var maxDimensionCount = require('./constants').maxDimensionCount;
2020
var mergeLength = require('./merge_length');
2121

2222
function handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
23-
var lineColor = coerce('line.color', defaultColor);
2423

24+
var lineColor = coerce('line.color', defaultColor);
2525
if(!Array.isArray(lineColor) && Lib.isArrayOrTypedArray(lineColor)) {
2626
// should convert typed arrays e.g. integers to real numbers
2727
lineColor = traceOut.line.color = Array.prototype.slice.call(lineColor);
@@ -49,6 +49,11 @@ function dimensionDefaults(dimensionIn, dimensionOut) {
4949
}
5050

5151
var values = coerce('values');
52+
if(!Array.isArray(values) && Lib.isArrayOrTypedArray(values)) {
53+
// should convert typed arrays e.g. integers to real numbers
54+
values = dimensionOut.values = Array.prototype.slice.call(values);
55+
}
56+
5257
var visible = coerce('visible');
5358
if(!(values && values.length)) {
5459
visible = dimensionOut.visible = false;

test/jasmine/tests/parcoords_test.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('parcoords initialization tests', function() {
145145
});
146146
});
147147

148-
it('\'line.color\' should convert typed arrays to normal arrays', function() {
148+
it('\'dimensions.values\' and \'line.color\' should convert typed arrays to normal arrays', function() {
149149
var fullTrace = _supply({
150150
dimensions: [{
151151
range: [1, 5],
@@ -154,17 +154,19 @@ describe('parcoords initialization tests', function() {
154154
}, {
155155
range: [1, 5],
156156
label: 'B',
157-
values: [3, 1.5, 2],
157+
values: new Float64Array([3, 1.5, 2]),
158158
}, {
159159
range: [1, 5],
160160
label: 'C',
161-
values: [2, 4, 1],
161+
values: new Int32Array([2, 4, 1]),
162162
}],
163163
line: {
164164
color: new Int32Array([0, 1, 2])
165165
}
166166
});
167167
expect(Array.isArray(fullTrace.line.color) === true).toEqual(true);
168+
expect(Array.isArray(fullTrace.dimensions[1].values) === true).toEqual(true);
169+
expect(Array.isArray(fullTrace.dimensions[2].values) === true).toEqual(true);
168170
});
169171

170172
it('\'domain\' specification should have a default', function() {

0 commit comments

Comments
 (0)