Skip to content

Add missing fields to fullData #2850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/plots/cartesian/tick_label_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
var showTickLabels = coerce('showticklabels');
if(showTickLabels) {
var font = options.font || {};
var contColor = containerOut.color;
// as with titlefont.color, inherit axis.color only if one was
// explicitly provided
var dfltFontColor = (containerOut.color !== layoutAttributes.color.dflt) ?
containerOut.color : font.color;
var dfltFontColor = (contColor && contColor !== layoutAttributes.color.dflt) ?
contColor : font.color;
Lib.coerceFont(coerce, 'tickfont', {
family: font.family,
size: font.size,
Expand Down
4 changes: 2 additions & 2 deletions src/traces/box/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function plotBoxAndWhiskers(sel, axes, trace, t) {

var paths = sel.selectAll('path.box').data((
trace.type !== 'violin' ||
trace.box
trace.box.visible
) ? Lib.identity : []);

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

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

paths.enter().append('path')
Expand Down
4 changes: 2 additions & 2 deletions src/traces/violin/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
var boxLineColor = coerce2('box.line.color', lineColor);
var boxLineWidth = coerce2('box.line.width', lineWidth);
var boxVisible = coerce('box.visible', Boolean(boxWidth || boxFillColor || boxLineColor || boxLineWidth));
if(!boxVisible) delete traceOut.box;
if(!boxVisible) traceOut.box = {visible: false};

var meanLineColor = coerce2('meanline.color', lineColor);
var meanLineWidth = coerce2('meanline.width', lineWidth);
var meanLineVisible = coerce('meanline.visible', Boolean(meanLineColor || meanLineWidth));
if(!meanLineVisible) delete traceOut.meanline;
if(!meanLineVisible) traceOut.meanline = {visible: false};
};
4 changes: 2 additions & 2 deletions src/traces/violin/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) {
d.pathLength = d.path.getTotalLength() / (hasBothSides ? 2 : 1);
});

var boxAttrs = trace.box || {};
var boxAttrs = trace.box;
var boxWidth = boxAttrs.width;
var boxLineWidth = (boxAttrs.line || {}).width;
var bdPosScaled;
Expand Down Expand Up @@ -170,7 +170,7 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) {
});

var fn;
if(!(trace.box || {}).visible && (trace.meanline || {}).visible) {
if(!trace.box.visible && trace.meanline.visible) {
fn = Lib.identity;
}

Expand Down
31 changes: 31 additions & 0 deletions test/jasmine/tests/colorbar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,46 @@ var d3 = require('d3');

var Plotly = require('@lib/index');
var Colorbar = require('@src/components/colorbar');

var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
var supplyAllDefaults = require('../assets/supply_defaults');
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;


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

describe('supplyDefaults:', function() {
function _supply(trace, layout) {
var gd = {
data: [trace],
layout: layout
};
supplyAllDefaults(gd);
return gd._fullData[0];
}

it('should fill in tickfont defaults', function() {
var out = _supply({
type: 'heatmap',
z: [[1, 2, 3], [2, 3, 6]]
});
expect(out.colorbar.tickfont.color).toBe('#444', 'dflt color');
});

it('should inherit tickfont defaults from global font', function() {
var out = _supply({
type: 'heatmap',
z: [[1, 2, 3], [2, 3, 6]]
}, {
font: {color: 'red'}
});
expect(out.colorbar.tickfont.color).toBe('red', 'from global font');
});
});

describe('hasColorbar', function() {
var hasColorbar = Colorbar.hasColorbar,
trace;
Expand Down
10 changes: 9 additions & 1 deletion test/jasmine/tests/gl2d_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ describe('@gl Test removal of gl contexts', function() {
gd = createGraphDiv();
});

afterEach(destroyGraphDiv);
afterEach(function() {
Plotly.purge(gd);
destroyGraphDiv();
});

it('Plots.cleanPlot should remove gl context from the graph div of a gl2d plot', function(done) {
Plotly.plot(gd, [{
Expand All @@ -41,6 +44,7 @@ describe('@gl Test removal of gl contexts', function() {

expect(!!gd._fullLayout._plots.xy._scene).toBe(false);
})
.catch(failTest)
.then(done);
});

Expand Down Expand Up @@ -83,6 +87,7 @@ describe('@gl Test removal of gl contexts', function() {
firstCanvas !== secondCanvas && firstGlContext.isContextLost()
);
})
.catch(failTest)
.then(done);
});
});
Expand Down Expand Up @@ -118,6 +123,7 @@ describe('@gl Test gl plot side effects', function() {
var rangeSlider = document.getElementsByClassName('range-slider')[0];
expect(rangeSlider).not.toBeDefined();
})
.catch(failTest)
.then(done);
});

Expand Down Expand Up @@ -160,6 +166,7 @@ describe('@gl Test gl plot side effects', function() {

return Plotly.purge(gd);
})
.catch(failTest)
.then(done);
});

Expand All @@ -184,6 +191,7 @@ describe('@gl Test gl plot side effects', function() {
.then(function() {
expect(d3.selectAll('canvas').size()).toEqual(0);
})
.catch(failTest)
.then(done);
});

Expand Down
4 changes: 2 additions & 2 deletions test/jasmine/tests/violin_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ describe('Test violin defaults', function() {
color: 'red'
}
});
expect(traceOut.box).toBeUndefined();
expect(traceOut.meanline).toBeUndefined();
expect(traceOut.box).toEqual({visible: false});
expect(traceOut.meanline).toEqual({visible: false});
});

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