Skip to content

Commit b998a17

Browse files
committed
image: fix zmin/zmax description, test zmin/zmax with wrong length array
1 parent 10c9914 commit b998a17

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

src/traces/image/attributes.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ var cm = ['rgb', 'rgba', 'hsl', 'hsla'];
1717
var zminDesc = [];
1818
var zmaxDesc = [];
1919
for(var i = 0; i < cm.length; i++) {
20-
zminDesc.push('For the `' + cm[i] + '` colormodel, it is [' + colormodel[cm[i]].min.join(', ') + ']');
21-
zmaxDesc.push('For the `' + cm[i] + '` colormodel, it is [' + colormodel[cm[i]].max.join(', ') + ']');
20+
zminDesc.push('For the `' + cm[i] + '` colormodel, it is [' + colormodel[cm[i]].min.join(', ') + '].');
21+
zmaxDesc.push('For the `' + cm[i] + '` colormodel, it is [' + colormodel[cm[i]].max.join(', ') + '].');
2222
}
2323

2424
module.exports = extendFlat({
@@ -51,12 +51,12 @@ module.exports = extendFlat({
5151
editType: 'plot',
5252
description: [
5353
'Array defining the lower bound for each color component.',
54-
'Note that the default value will depend on the colormodel.'
55-
].concat(zminDesc).join(' ')
54+
'Note that the default value will depend on the colormodel.',
55+
zminDesc.join(' ')
56+
].join(' ')
5657
},
5758
zmax: {
5859
valType: 'info_array',
59-
dimensions: '1-2',
6060
items: [
6161
{valType: 'number', editType: 'plot'},
6262
{valType: 'number', editType: 'plot'},
@@ -67,8 +67,9 @@ module.exports = extendFlat({
6767
editType: 'plot',
6868
description: [
6969
'Array defining the higher bound for each color component.',
70-
'Note that the default value will depend on the colormodel.'
71-
].concat(zmaxDesc).join(' ')
70+
'Note that the default value will depend on the colormodel.',
71+
zmaxDesc.join(' ')
72+
].join(' ')
7273
},
7374
x0: {
7475
valType: 'number',

test/jasmine/tests/image_test.js

+21
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,27 @@ describe('image supplyDefaults', function() {
7777
supplyDefaults(traceIn, traceOut);
7878
});
7979
});
80+
81+
it('should handle incomplete zmin/zmax', function() {
82+
traceIn = {
83+
z: [[[1, 1, 1, 1]]],
84+
zmin: [10, 10],
85+
zmax: [null, 20]
86+
};
87+
supplyDefaults(traceIn, traceOut);
88+
expect(traceOut.zmin).toEqual([10, 10, 0], 'zmin default');
89+
expect(traceOut.zmax).toEqual([255, 20, 255], 'zmax default');
90+
91+
traceIn = {
92+
z: [[[1, 1, 1, 1]]],
93+
colormodel: 'hsla',
94+
zmin: [null, 10, null, null, 100],
95+
zmax: [20]
96+
};
97+
supplyDefaults(traceIn, traceOut);
98+
expect(traceOut.zmin).toEqual([0, 10, 0, 0], 'zmin default');
99+
expect(traceOut.zmax).toEqual([20, 100, 100, 1], 'zmax default');
100+
});
80101
});
81102

82103
describe('image plot', function() {

0 commit comments

Comments
 (0)