Skip to content

Commit 39dd6dd

Browse files
committed
init violin box and meanline containers to {visible:false}
... instead of clearing them entirely, this is more consistent with what the react-chart-editor expects
1 parent 28bc3e9 commit 39dd6dd

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/traces/box/plot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function plotBoxAndWhiskers(sel, axes, trace, t) {
102102

103103
var paths = sel.selectAll('path.box').data((
104104
trace.type !== 'violin' ||
105-
trace.box
105+
(trace.box || {}).visible
106106
) ? Lib.identity : []);
107107

108108
paths.enter().append('path')
@@ -304,7 +304,7 @@ function plotBoxMean(sel, axes, trace, t) {
304304

305305
var paths = sel.selectAll('path.mean').data((
306306
(trace.type === 'box' && trace.boxmean) ||
307-
(trace.type === 'violin' && trace.box && trace.meanline)
307+
(trace.type === 'violin' && (trace.box || {}).visible && (trace.meanline || {}).visible)
308308
) ? Lib.identity : []);
309309

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

src/traces/violin/defaults.js

Lines changed: 2 additions & 2 deletions
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
};

test/jasmine/tests/violin_test.js

Lines changed: 2 additions & 2 deletions
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)