Skip to content

Commit 40f6ce3

Browse files
authored
Merge pull request #2850 from plotly/missing-fulldata
Add missing fields to fullData
2 parents 344a6c5 + 2ed8a6a commit 40f6ce3

File tree

6 files changed

+42
-10
lines changed

6 files changed

+42
-10
lines changed

Diff for: src/plots/cartesian/tick_label_defaults.js

+3-2
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,

Diff for: src/traces/box/plot.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function plotBoxAndWhiskers(sel, axes, trace, t) {
9090

9191
var paths = sel.selectAll('path.box').data((
9292
trace.type !== 'violin' ||
93-
trace.box
93+
trace.box.visible
9494
) ? Lib.identity : []);
9595

9696
paths.enter().append('path')
@@ -292,7 +292,7 @@ function plotBoxMean(sel, axes, trace, t) {
292292

293293
var paths = sel.selectAll('path.mean').data((
294294
(trace.type === 'box' && trace.boxmean) ||
295-
(trace.type === 'violin' && trace.box && trace.meanline)
295+
(trace.type === 'violin' && trace.box.visible && trace.meanline.visible)
296296
) ? Lib.identity : []);
297297

298298
paths.enter().append('path')

Diff for: src/traces/violin/defaults.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4646
var boxLineColor = coerce2('box.line.color', lineColor);
4747
var boxLineWidth = coerce2('box.line.width', lineWidth);
4848
var boxVisible = coerce('box.visible', Boolean(boxWidth || boxFillColor || boxLineColor || boxLineWidth));
49-
if(!boxVisible) delete traceOut.box;
49+
if(!boxVisible) traceOut.box = {visible: false};
5050

5151
var meanLineColor = coerce2('meanline.color', lineColor);
5252
var meanLineWidth = coerce2('meanline.width', lineWidth);
5353
var meanLineVisible = coerce('meanline.visible', Boolean(meanLineColor || meanLineWidth));
54-
if(!meanLineVisible) delete traceOut.meanline;
54+
if(!meanLineVisible) traceOut.meanline = {visible: false};
5555
};

Diff for: src/traces/violin/plot.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) {
138138
d.pathLength = d.path.getTotalLength() / (hasBothSides ? 2 : 1);
139139
});
140140

141-
var boxAttrs = trace.box || {};
141+
var boxAttrs = trace.box;
142142
var boxWidth = boxAttrs.width;
143143
var boxLineWidth = (boxAttrs.line || {}).width;
144144
var bdPosScaled;
@@ -170,7 +170,7 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) {
170170
});
171171

172172
var fn;
173-
if(!(trace.box || {}).visible && (trace.meanline || {}).visible) {
173+
if(!trace.box.visible && trace.meanline.visible) {
174174
fn = Lib.identity;
175175
}
176176

Diff for: test/jasmine/tests/colorbar_test.js

+31
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;

Diff for: test/jasmine/tests/violin_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ describe('Test violin defaults', function() {
124124
color: 'red'
125125
}
126126
});
127-
expect(traceOut.box).toBeUndefined();
128-
expect(traceOut.meanline).toBeUndefined();
127+
expect(traceOut.box).toEqual({visible: false});
128+
expect(traceOut.meanline).toEqual({visible: false});
129129
});
130130

131131
it('should use violin style settings to default inner style attribute', function() {

0 commit comments

Comments
 (0)