Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 57a9e72

Browse filesBrowse files
committed
Provide a default hovertemplate label for attribute "base" in bar traces
1 parent 24c740b commit 57a9e72
Copy full SHA for 57a9e72

File tree

Expand file treeCollapse file tree

2 files changed

+47
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+47
-0
lines changed

‎src/traces/bar/hover.js

Copy file name to clipboardExpand all lines: src/traces/bar/hover.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ function hoverOnBars(pointData, xval, yval, hovermode) {
164164

165165
pointData.labelLabel = hoverLabelText(pa, pointData[posLetter + 'LabelVal']);
166166
pointData.valueLabel = hoverLabelText(sa, pointData[sizeLetter + 'LabelVal']);
167+
pointData.baseLabel = hoverLabelText(sa, di.b);
167168

168169
// spikelines always want "closest" distance regardless of hovermode
169170
pointData.spikeDistance = (sizeFn(di) + thisBarPositionFn(di)) / 2 - maxHoverDistance;

‎test/jasmine/tests/bar_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/bar_test.js
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,6 +2495,52 @@ describe('bar hover', function() {
24952495
.catch(failTest)
24962496
.then(done);
24972497
});
2498+
2499+
it('should provide a default label for base in hovertemplate', function(done) {
2500+
gd = createGraphDiv();
2501+
2502+
function _hover(xpx, ypx) {
2503+
return function() {
2504+
Fx.hover(gd, {xpx: xpx, ypx: ypx}, 'xy');
2505+
Lib.clearThrottle();
2506+
};
2507+
}
2508+
2509+
Plotly.plot(gd, {
2510+
data: [{
2511+
type: 'bar',
2512+
orientation: 'h',
2513+
base: ['2020-04-06 22:17:00'],
2514+
x: [11520000.0],
2515+
y: ['test'],
2516+
hovertemplate: ['%{base}<br>%{x}']
2517+
}],
2518+
layout: {
2519+
xaxis: { type: 'date', tickprefix: '*', ticksuffix: '*' },
2520+
width: 400,
2521+
height: 400,
2522+
margin: {l: 0, t: 0, r: 0, b: 0},
2523+
hovermode: 'closest'
2524+
}
2525+
})
2526+
.then(_hover(200, 200))
2527+
.then(function() {
2528+
assertHoverLabelContent({
2529+
nums: '*Apr 6, 2020, 22:17*\n*Apr 7, 2020, 01:29*',
2530+
name: 'trace 0'
2531+
});
2532+
return Plotly.relayout(gd, 'xaxis.tickformat', '%d');
2533+
})
2534+
.then(_hover(200, 200))
2535+
.then(function() {
2536+
assertHoverLabelContent({
2537+
nums: '*06*\n*07*',
2538+
name: 'trace 0'
2539+
});
2540+
})
2541+
.catch(failTest)
2542+
.then(done);
2543+
});
24982544
});
24992545

25002546
describe('with special width/offset combinations', function() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.