Skip to content

Commit 8cc59a9

Browse files
committed
add axis.color bleading test with 2d and 3d axes
1 parent fbd0a0b commit 8cc59a9

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

test/jasmine/tests/axes_test.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,67 @@ describe('Test axes', function() {
321321
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
322322
expect(layoutOut._hasCartesian).toBe(undefined);
323323
});
324+
325+
it('should use \'axis.color\' as default for \'axis.titlefont.color\'', function() {
326+
layoutIn = {
327+
xaxis: { color: 'red' },
328+
yaxis: {},
329+
yaxis2: { titlefont: { color: 'yellow' } }
330+
};
331+
332+
layoutOut.font = { color: 'blue' },
333+
334+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
335+
expect(layoutOut.xaxis.titlefont.color).toEqual('red');
336+
expect(layoutOut.yaxis.titlefont.color).toEqual('blue');
337+
expect(layoutOut.yaxis2.titlefont.color).toEqual('yellow');
338+
});
339+
340+
it('should use \'axis.color\' as default for \'axis.linecolor\'', function() {
341+
layoutIn = {
342+
xaxis: { showline: true, color: 'red' },
343+
yaxis: { linecolor: 'blue' },
344+
yaxis2: { showline: true }
345+
};
346+
347+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
348+
expect(layoutOut.xaxis.linecolor).toEqual('red');
349+
expect(layoutOut.yaxis.linecolor).toEqual('blue');
350+
expect(layoutOut.yaxis2.linecolor).toEqual('#444');
351+
});
352+
353+
it('should use \'axis.color\' as default for \'axis.zerolinecolor\'', function() {
354+
layoutIn = {
355+
xaxis: { showzeroline: true, color: 'red' },
356+
yaxis: { zerolinecolor: 'blue' },
357+
yaxis2: { showzeroline: true }
358+
};
359+
360+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
361+
expect(layoutOut.xaxis.zerolinecolor).toEqual('red');
362+
expect(layoutOut.yaxis.zerolinecolor).toEqual('blue');
363+
expect(layoutOut.yaxis2.zerolinecolor).toEqual('#444');
364+
});
365+
366+
it('should use combo of \'axis.color\', bgcolor and lightFraction as default for \'axis.gridcolor\'', function() {
367+
layoutIn = {
368+
paper_bgcolor: 'green',
369+
plot_bgcolor: 'yellow',
370+
xaxis: { showgrid: true, color: 'red' },
371+
yaxis: { gridcolor: 'blue' },
372+
yaxis2: { showgrid: true }
373+
};
374+
375+
var bgColor = Color.combine('yellow', 'green'),
376+
frac = 100 * (0xe - 0x4) / (0xf - 0x4);
377+
378+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
379+
expect(layoutOut.xaxis.gridcolor)
380+
.toEqual(tinycolor.mix('red', bgColor, frac).toRgbString());
381+
expect(layoutOut.yaxis.gridcolor).toEqual('blue');
382+
expect(layoutOut.yaxis2.gridcolor)
383+
.toEqual(tinycolor.mix('#444', bgColor, frac).toRgbString());
384+
});
324385
});
325386

326387
describe('handleTickDefaults', function() {

test/jasmine/tests/gl3dlayout_test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
var Gl3d = require('@src/plots/gl3d');
22

3+
var tinycolor = require('tinycolor2');
4+
var Color = require('@src/components/color');
5+
36

47
describe('Test Gl3d layout defaults', function() {
58
'use strict';
@@ -226,5 +229,27 @@ describe('Test Gl3d layout defaults', function() {
226229
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
227230
expect(layoutIn.scene).toBe(undefined);
228231
});
232+
233+
it('should use combo of \'axis.color\', bgcolor and lightFraction as default for \'axis.gridcolor\'', function() {
234+
layoutIn = {
235+
paper_bgcolor: 'green',
236+
scene: {
237+
bgcolor: 'yellow',
238+
xaxis: { showgrid: true, color: 'red' },
239+
yaxis: { gridcolor: 'blue' },
240+
zaxis: { showgrid: true }
241+
}
242+
};
243+
244+
var bgColor = Color.combine('yellow', 'green'),
245+
frac = 100 * (204 - 0x44) / (255 - 0x44);
246+
247+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
248+
expect(layoutOut.scene.xaxis.gridcolor)
249+
.toEqual(tinycolor.mix('red', bgColor, frac).toRgbString());
250+
expect(layoutOut.scene.yaxis.gridcolor).toEqual('blue');
251+
expect(layoutOut.scene.zaxis.gridcolor)
252+
.toEqual(tinycolor.mix('#444', bgColor, frac).toRgbString());
253+
});
229254
});
230255
});

0 commit comments

Comments
 (0)