Skip to content
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

Coerce hoverformat on visible-false axes #2329

Merged
merged 3 commits into from
Feb 5, 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
8 changes: 3 additions & 5 deletions src/components/colorbar/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {

handleTickValueDefaults(colorbarIn, colorbarOut, coerce, 'linear');

handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear',
{outerTicks: false, font: layout.font, noHover: true});

handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear',
{outerTicks: false, font: layout.font, noHover: true});
var opts = {outerTicks: false, font: layout.font};
handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);
handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);

coerce('title', layout._dfltTitle.colorbar);
Lib.coerceFont(coerce, 'titlefont', layout.font);
Expand Down
3 changes: 3 additions & 0 deletions src/plots/cartesian/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
orderedCategories(letter, containerOut.categoryorder, containerOut.categoryarray, options.data) :
[];


if(axType !== 'category' && !options.noHover) coerce('hoverformat');

if(!visible) return containerOut;

var dfltColor = coerce('color');
Expand Down
5 changes: 0 additions & 5 deletions src/plots/cartesian/tick_label_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
var Lib = require('../../lib');
var layoutAttributes = require('./layout_attributes');

/**
* options: inherits font, outerTicks, noHover from axes.handleAxisDefaults
*/
module.exports = function handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options) {
var showAttrDflt = getShowAttrDflt(containerIn);

Expand Down Expand Up @@ -48,8 +45,6 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
}
}
}

if(axType !== 'category' && !options.noHover) coerce('hoverformat');
};

/*
Expand Down
3 changes: 1 addition & 2 deletions src/plots/polar/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ function handleDefaults(contIn, contOut, coerce, opts) {
if(visible) {
handleTickValueDefaults(axIn, axOut, coerceAxis, axOut.type);
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type, {
noHover: false,
tickSuffixDflt: axOut.thetaunit === 'degrees' ? '°' : undefined
});
handleTickMarkDefaults(axIn, axOut, coerceAxis, {outerTicks: true});
Expand Down Expand Up @@ -174,7 +173,7 @@ function handleDefaults(contIn, contOut, coerce, opts) {
coerceAxis('layer');
}

coerceAxis('hoverformat');
if(axType !== 'category') coerceAxis('hoverformat');

axOut._input = axIn;
}
Expand Down
3 changes: 1 addition & 2 deletions src/plots/ternary/layout/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ module.exports = function supplyLayoutDefaults(containerIn, containerOut, option
coerce('min');

handleTickValueDefaults(containerIn, containerOut, coerce, 'linear');
handleTickLabelDefaults(containerIn, containerOut, coerce, 'linear',
{ noHover: false });
handleTickLabelDefaults(containerIn, containerOut, coerce, 'linear', {});
handleTickMarkDefaults(containerIn, containerOut, coerce,
{ outerTicks: true });

Expand Down
3 changes: 0 additions & 3 deletions src/traces/carpet/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var autoType = require('../../plots/cartesian/axis_autotype');
* font: the default font to inherit
* outerTicks: boolean, should ticks default to outside?
* showGrid: boolean, should gridlines be shown by default?
* noHover: boolean, this axis doesn't support hover effects?
* data: the plot data to use in choosing auto type
* bgColor: the plot background color, to calculate default gridline colors
*/
Expand All @@ -38,8 +37,6 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options)
font = options.font || {},
attributes = carpetAttrs[letter + 'axis'];

options.noHover = true;

function coerce(attr, dflt) {
return Lib.coerce(containerIn, containerOut, attributes, attr, dflt);
}
Expand Down
12 changes: 12 additions & 0 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,18 @@ describe('Test axes', function() {
expect(layoutOut[axName].scaleratio).toBeUndefined();
});
});

it('should coerce hoverformat even on visible: false axes', function() {
layoutIn = {
xaxis: {
visible: false,
hoverformat: 'g'
}
};

supplyLayoutDefaults(layoutIn, layoutOut, fullData);
expect(layoutOut.xaxis.hoverformat).toEqual('g');
});
});

describe('constraints relayout', function() {
Expand Down
37 changes: 37 additions & 0 deletions test/jasmine/tests/polar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,43 @@ describe('Test polar plots defaults:', function() {
expect(Lib.log).toHaveBeenCalledWith('Polar plots do not support date angular axes yet.');
expect(layoutOut.polar.angularaxis.type).toBe('linear');
});

it('should not coerce hoverformat on category axes', function() {
_supply({}, [{
type: 'scatterpolar',
r: ['a', 'b'],
theta: ['c', 'd'],
visible: true,
subplot: 'polar'
}]);

expect(layoutOut.polar.radialaxis.hoverformat).toBeUndefined();
expect(layoutOut.polar.angularaxis.hoverformat).toBeUndefined();
});

it('should coerce hoverformat even for `visible: false` axes', function() {
_supply({
polar: {
radialaxis: {
visible: false,
hoverformat: 'g'
},
angularaxis: {
visible: false,
hoverformat: 'g'
}
}
}, [{
type: 'scatterpolar',
r: [1, 2],
theta: [90, 180],
visible: true,
subplot: 'polar'
}]);

expect(layoutOut.polar.radialaxis.hoverformat).toBe('g');
expect(layoutOut.polar.angularaxis.hoverformat).toBe('g');
});
});

describe('Test relayout on polar subplots:', function() {
Expand Down