Skip to content

Commit 7d50630

Browse files
committed
only compare container color to schema color when it exists
- this piece here is called by Colorbar.supplyDefaults, but colorbars do not have a container-wide 'color' attribute unlike axes, so the comparison with layoutAttributes.color was off. - this bug did not affect the baselines as this routine is called again during Colorbar.draw with a set container color.
1 parent 39dd6dd commit 7d50630

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/plots/cartesian/tick_label_defaults.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
2525
var showTickLabels = coerce('showticklabels');
2626
if(showTickLabels) {
2727
var font = options.font || {};
28+
var contColor = containerOut.color;
2829
// as with titlefont.color, inherit axis.color only if one was
2930
// explicitly provided
30-
var dfltFontColor = (containerOut.color !== layoutAttributes.color.dflt) ?
31-
containerOut.color : font.color;
31+
var dfltFontColor = (contColor && contColor !== layoutAttributes.color.dflt) ?
32+
contColor : font.color;
3233
Lib.coerceFont(coerce, 'tickfont', {
3334
family: font.family,
3435
size: font.size,

test/jasmine/tests/colorbar_test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,46 @@ var d3 = require('d3');
22

33
var Plotly = require('@lib/index');
44
var Colorbar = require('@src/components/colorbar');
5+
56
var createGraphDiv = require('../assets/create_graph_div');
67
var destroyGraphDiv = require('../assets/destroy_graph_div');
78
var failTest = require('../assets/fail_test');
9+
var supplyAllDefaults = require('../assets/supply_defaults');
810
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;
911

1012

1113
describe('Test colorbar:', function() {
1214
'use strict';
1315

16+
describe('supplyDefaults:', function() {
17+
function _supply(trace, layout) {
18+
var gd = {
19+
data: [trace],
20+
layout: layout
21+
};
22+
supplyAllDefaults(gd);
23+
return gd._fullData[0];
24+
}
25+
26+
it('should fill in tickfont defaults', function() {
27+
var out = _supply({
28+
type: 'heatmap',
29+
z: [[1, 2, 3], [2, 3, 6]]
30+
});
31+
expect(out.colorbar.tickfont.color).toBe('#444', 'dflt color');
32+
});
33+
34+
it('should inherit tickfont defaults from global font', function() {
35+
var out = _supply({
36+
type: 'heatmap',
37+
z: [[1, 2, 3], [2, 3, 6]]
38+
}, {
39+
font: {color: 'red'}
40+
});
41+
expect(out.colorbar.tickfont.color).toBe('red', 'from global font');
42+
});
43+
});
44+
1445
describe('hasColorbar', function() {
1546
var hasColorbar = Colorbar.hasColorbar,
1647
trace;

0 commit comments

Comments
 (0)