Skip to content

Commit b369dd6

Browse files
authored
Merge pull request #2329 from plotly/hoverformat-visible-false-axes
Coerce hoverformat on visible-false axes
2 parents 9037720 + 9e6b488 commit b369dd6

File tree

8 files changed

+57
-17
lines changed

8 files changed

+57
-17
lines changed

src/components/colorbar/defaults.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) {
5353

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

56-
handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear',
57-
{outerTicks: false, font: layout.font, noHover: true});
58-
59-
handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear',
60-
{outerTicks: false, font: layout.font, noHover: true});
56+
var opts = {outerTicks: false, font: layout.font};
57+
handleTickLabelDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);
58+
handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts);
6159

6260
coerce('title', layout._dfltTitle.colorbar);
6361
Lib.coerceFont(coerce, 'titlefont', layout.font);

src/plots/cartesian/axis_defaults.js

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
5959
orderedCategories(letter, containerOut.categoryorder, containerOut.categoryarray, options.data) :
6060
[];
6161

62+
63+
if(axType !== 'category' && !options.noHover) coerce('hoverformat');
64+
6265
if(!visible) return containerOut;
6366

6467
var dfltColor = coerce('color');

src/plots/cartesian/tick_label_defaults.js

-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
var Lib = require('../../lib');
1313
var layoutAttributes = require('./layout_attributes');
1414

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

@@ -48,8 +45,6 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
4845
}
4946
}
5047
}
51-
52-
if(axType !== 'category' && !options.noHover) coerce('hoverformat');
5348
};
5449

5550
/*

src/plots/polar/layout_defaults.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ function handleDefaults(contIn, contOut, coerce, opts) {
143143
if(visible) {
144144
handleTickValueDefaults(axIn, axOut, coerceAxis, axOut.type);
145145
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type, {
146-
noHover: false,
147146
tickSuffixDflt: axOut.thetaunit === 'degrees' ? '°' : undefined
148147
});
149148
handleTickMarkDefaults(axIn, axOut, coerceAxis, {outerTicks: true});
@@ -174,7 +173,7 @@ function handleDefaults(contIn, contOut, coerce, opts) {
174173
coerceAxis('layer');
175174
}
176175

177-
coerceAxis('hoverformat');
176+
if(axType !== 'category') coerceAxis('hoverformat');
178177

179178
axOut._input = axIn;
180179
}

src/plots/ternary/layout/axis_defaults.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ module.exports = function supplyLayoutDefaults(containerIn, containerOut, option
4444
coerce('min');
4545

4646
handleTickValueDefaults(containerIn, containerOut, coerce, 'linear');
47-
handleTickLabelDefaults(containerIn, containerOut, coerce, 'linear',
48-
{ noHover: false });
47+
handleTickLabelDefaults(containerIn, containerOut, coerce, 'linear', {});
4948
handleTickMarkDefaults(containerIn, containerOut, coerce,
5049
{ outerTicks: true });
5150

src/traces/carpet/axis_defaults.js

-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ var autoType = require('../../plots/cartesian/axis_autotype');
2929
* font: the default font to inherit
3030
* outerTicks: boolean, should ticks default to outside?
3131
* showGrid: boolean, should gridlines be shown by default?
32-
* noHover: boolean, this axis doesn't support hover effects?
3332
* data: the plot data to use in choosing auto type
3433
* bgColor: the plot background color, to calculate default gridline colors
3534
*/
@@ -38,8 +37,6 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options)
3837
font = options.font || {},
3938
attributes = carpetAttrs[letter + 'axis'];
4039

41-
options.noHover = true;
42-
4340
function coerce(attr, dflt) {
4441
return Lib.coerce(containerIn, containerOut, attributes, attr, dflt);
4542
}

test/jasmine/tests/axes_test.js

+12
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,18 @@ describe('Test axes', function() {
535535
expect(layoutOut[axName].scaleratio).toBeUndefined();
536536
});
537537
});
538+
539+
it('should coerce hoverformat even on visible: false axes', function() {
540+
layoutIn = {
541+
xaxis: {
542+
visible: false,
543+
hoverformat: 'g'
544+
}
545+
};
546+
547+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
548+
expect(layoutOut.xaxis.hoverformat).toEqual('g');
549+
});
538550
});
539551

540552
describe('constraints relayout', function() {

test/jasmine/tests/polar_test.js

+37
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,43 @@ describe('Test polar plots defaults:', function() {
168168
expect(Lib.log).toHaveBeenCalledWith('Polar plots do not support date angular axes yet.');
169169
expect(layoutOut.polar.angularaxis.type).toBe('linear');
170170
});
171+
172+
it('should not coerce hoverformat on category axes', function() {
173+
_supply({}, [{
174+
type: 'scatterpolar',
175+
r: ['a', 'b'],
176+
theta: ['c', 'd'],
177+
visible: true,
178+
subplot: 'polar'
179+
}]);
180+
181+
expect(layoutOut.polar.radialaxis.hoverformat).toBeUndefined();
182+
expect(layoutOut.polar.angularaxis.hoverformat).toBeUndefined();
183+
});
184+
185+
it('should coerce hoverformat even for `visible: false` axes', function() {
186+
_supply({
187+
polar: {
188+
radialaxis: {
189+
visible: false,
190+
hoverformat: 'g'
191+
},
192+
angularaxis: {
193+
visible: false,
194+
hoverformat: 'g'
195+
}
196+
}
197+
}, [{
198+
type: 'scatterpolar',
199+
r: [1, 2],
200+
theta: [90, 180],
201+
visible: true,
202+
subplot: 'polar'
203+
}]);
204+
205+
expect(layoutOut.polar.radialaxis.hoverformat).toBe('g');
206+
expect(layoutOut.polar.angularaxis.hoverformat).toBe('g');
207+
});
171208
});
172209

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

0 commit comments

Comments
 (0)