Skip to content

Commit 78438fa

Browse files
committed
rename vals to bdata
1 parent d260168 commit 78438fa

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

src/lib/array.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ exports.decodeTypedArraySpec = function(vIn) {
103103
if(!T) throw new Error('Error in dtype: "' + dtype + '"');
104104
var BYTES_PER_ELEMENT = T.BYTES_PER_ELEMENT;
105105

106-
var buffer = v.vals;
106+
var buffer = v.bdata;
107107
if(!isArrayBuffer(buffer)) {
108108
buffer = b64decode(buffer);
109109
}
@@ -149,8 +149,8 @@ exports.decodeTypedArraySpec = function(vIn) {
149149
throw new Error('Error in shape: "' + v.shape + '"');
150150
}
151151

152-
// attach dtype, shape & vals to array for json export
153-
out.vals = v.vals;
152+
// attach bdata, dtype & shape to array for json export
153+
out.bdata = v.bdata;
154154
out.dtype = v.dtype;
155155
out.shape = shape.join(',');
156156

@@ -162,19 +162,19 @@ exports.isTypedArraySpec = function(v) {
162162
isPlainObject(v) &&
163163
v.hasOwnProperty('dtype') && (typeof v.dtype === 'string') &&
164164

165+
v.hasOwnProperty('bdata') && (typeof v.bdata === 'string' || isArrayBuffer(v.bdata)) &&
166+
165167
(v.shape === undefined || (
166168
v.hasOwnProperty('shape') && (typeof v.shape === 'string' || typeof v.shape === 'number')
167-
)) &&
168-
169-
v.hasOwnProperty('vals') && (typeof v.vals === 'string' || isArrayBuffer(v.vals))
169+
))
170170
);
171171
};
172172

173173
function coerceTypedArraySpec(v) {
174174
return {
175+
bdata: v.bdata,
175176
dtype: v.dtype,
176-
shape: v.shape,
177-
vals: v.vals
177+
shape: v.shape
178178
};
179179
}
180180

src/lib/coerce.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ exports.valObjectMeta = {
2424
'but this array can be provided in several forms:',
2525
'(1) a regular {array} object',
2626
'(2) a typed array (e.g. Float32Array)',
27-
'(3) an object with keys dtype, vals, and optionally shape.',
27+
'(3) an object with keys dtype, bdata, and optionally shape.',
2828
'In this 3rd form, dtype is one of *i1*, *u1*, *c1*,',
2929
'*i2*, *u2*, *i4*, *u4*, *f4*, or *f8*.',
30-
'vals is either a base64-encoded string or the ArrayBuffer of',
30+
'`bdata` is either a base64-encoded string or the ArrayBuffer of',
3131
'an integer or float typed array.',
3232
'For either multi-dimensional arrays you must also',
3333
'provide its dimensions separated by comma via `shape`.',

src/plots/plots.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2230,16 +2230,16 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults, includeConfi
22302230
var dIsTypedArray = Lib.isTypedArray(d);
22312231

22322232
if((dIsArray || dIsTypedArray) && d.dtype && d.shape) {
2233-
var vals = d.vals;
2233+
var bdata = d.bdata;
22342234
return stripObj({
22352235
dtype: d.dtype,
22362236
shape: d.shape,
22372237

2238-
vals:
2238+
bdata:
22392239
// case of ArrayBuffer
2240-
Lib.isArrayBuffer(vals) ? b64encode.encode(vals) :
2240+
Lib.isArrayBuffer(bdata) ? b64encode.encode(bdata) :
22412241
// case of b64 string
2242-
vals
2242+
bdata
22432243

22442244
}, keepFunction);
22452245
}

test/jasmine/tests/toimage_test.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,9 @@ describe('Plotly.toImage', function() {
343343

344344
Plotly.newPlot(gd, [{
345345
type: 'surface',
346-
x: {vals: x, dtype: 'f8'},
347-
y: {vals: y, dtype: 'f4'},
348-
z: {vals: z, dtype: 'u2', shape: '3,2'}
346+
x: {bdata: x, dtype: 'f8'},
347+
y: {bdata: y, dtype: 'f4'},
348+
z: {bdata: z, dtype: 'u2', shape: '3,2'}
349349
}])
350350
.then(function(gd) {
351351
var trace = gd._fullData[0];
@@ -366,9 +366,9 @@ describe('Plotly.toImage', function() {
366366

367367
expect(trace.visible).toEqual(true);
368368

369-
expect(trace.x.vals).toEqual('VVVVVVVV1b8AAAAAAAAAAFVVVVVVVdU/');
370-
expect(trace.y.vals).toEqual('q6qqPquqqr4=');
371-
expect(trace.z.vals).toEqual('AABkAMgALAGQAfQB');
369+
expect(trace.x.bdata).toEqual('VVVVVVVV1b8AAAAAAAAAAFVVVVVVVdU/');
370+
expect(trace.y.bdata).toEqual('q6qqPquqqr4=');
371+
expect(trace.z.bdata).toEqual('AABkAMgALAGQAfQB');
372372

373373
expect(trace.x.dtype).toEqual('f8');
374374
expect(trace.x.shape).toEqual('3');
@@ -392,9 +392,9 @@ describe('Plotly.toImage', function() {
392392

393393
Plotly.newPlot(gd, [{
394394
type: 'surface',
395-
x: {vals: x, dtype: 'f8', shape: '3'},
396-
y: {vals: y, dtype: 'f4', shape: '2'},
397-
z: {vals: z, dtype: 'u2', shape: '3,2'}
395+
x: {bdata: x, dtype: 'f8', shape: '3'},
396+
y: {bdata: y, dtype: 'f4', shape: '2'},
397+
z: {bdata: z, dtype: 'u2', shape: '3,2'}
398398
}])
399399
.then(function(gd) {
400400
var trace = gd._fullData[0];
@@ -415,9 +415,9 @@ describe('Plotly.toImage', function() {
415415

416416
expect(trace.visible).toEqual(true);
417417

418-
expect(trace.x.vals).toEqual('VVVVVVVV1b8AAAAAAAAAAFVVVVVVVdU/');
419-
expect(trace.y.vals).toEqual('q6qqPquqqr4=');
420-
expect(trace.z.vals).toEqual('AABkAMgALAGQAfQB');
418+
expect(trace.x.bdata).toEqual('VVVVVVVV1b8AAAAAAAAAAFVVVVVVVdU/');
419+
expect(trace.y.bdata).toEqual('q6qqPquqqr4=');
420+
expect(trace.z.bdata).toEqual('AABkAMgALAGQAfQB');
421421

422422
expect(trace.x.dtype).toEqual('f8');
423423
expect(trace.x.shape).toEqual('3');

test/plot-schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@
479479
"requiredOpts": []
480480
},
481481
"data_array": {
482-
"description": "An {array} of data. The value must represent an {array} or it will be ignored, but this array can be provided in several forms: (1) a regular {array} object (2) a typed array (e.g. Float32Array) (3) an object with keys dtype, vals, and optionally shape. In this 3rd form, dtype is one of *i1*, *u1*, *c1*, *i2*, *u2*, *i4*, *u4*, *f4*, or *f8*. vals is either a base64-encoded string or the ArrayBuffer of an integer or float typed array. For either multi-dimensional arrays you must also provide its dimensions separated by comma via `shape`. For exmaple using `dtype`: *f4* and `shape`: *100,5* you can declare a 2-D array that has 5 rows and 100 columns containing float32 values i.e. 4 bits per value. `shape` is optional for one dimensional arrays.",
482+
"description": "An {array} of data. The value must represent an {array} or it will be ignored, but this array can be provided in several forms: (1) a regular {array} object (2) a typed array (e.g. Float32Array) (3) an object with keys dtype, bdata, and optionally shape. In this 3rd form, dtype is one of *i1*, *u1*, *c1*, *i2*, *u2*, *i4*, *u4*, *f4*, or *f8*. `bdata` is either a base64-encoded string or the ArrayBuffer of an integer or float typed array. For either multi-dimensional arrays you must also provide its dimensions separated by comma via `shape`. For exmaple using `dtype`: *f4* and `shape`: *100,5* you can declare a 2-D array that has 5 rows and 100 columns containing float32 values i.e. 4 bits per value. `shape` is optional for one dimensional arrays.",
483483
"otherOpts": [
484484
"dflt"
485485
],

0 commit comments

Comments
 (0)