Skip to content

Commit 3fa20fb

Browse files
committed
add jasmine test
1 parent 9841646 commit 3fa20fb

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/jasmine/tests/hover_label_test.js

+54
Original file line numberDiff line numberDiff line change
@@ -4831,6 +4831,60 @@ describe('hovermode: (x|y)unified', function() {
48314831
.then(done, done.fail);
48324832
});
48334833

4834+
it('should format differing position using *xother* `hovertemplate` and in respect to `xhoverformat`', function(done) {
4835+
Plotly.newPlot(gd, [{
4836+
type: 'bar',
4837+
hovertemplate: '%{y:.1f} %{xother:.2f}',
4838+
x: [0, 1.001],
4839+
y: [1.001, 2.001]
4840+
}, {
4841+
x: [0, 0.749],
4842+
y: [1.999, 0.999]
4843+
}, {
4844+
hovertemplate: '%{y:.1f} %{xother}',
4845+
xhoverformat: '.1f',
4846+
x: [0, 1.251],
4847+
y: [2.001, 3.001]
4848+
}], {
4849+
hoverdistance: -1,
4850+
hovermode: 'x unified',
4851+
showlegend: false,
4852+
width: 500,
4853+
height: 500,
4854+
margin: {
4855+
t: 50,
4856+
b: 50,
4857+
l: 50,
4858+
r: 50
4859+
}
4860+
})
4861+
.then(function() {
4862+
_hover(gd, { xpx: 100, ypx: 200 });
4863+
assertLabel({title: '0', items: [
4864+
'trace 0 : 1.0 ',
4865+
'trace 1 : 1.999',
4866+
'trace 2 : 2.0 (0.0)'
4867+
]});
4868+
})
4869+
.then(function() {
4870+
_hover(gd, { xpx: 250, ypx: 200 });
4871+
assertLabel({title: '0.749', items: [
4872+
'trace 0 : 2.0 (1.00)',
4873+
'trace 1 : 0.999',
4874+
'trace 2 : 3.0 (1.3)'
4875+
]});
4876+
})
4877+
.then(function() {
4878+
_hover(gd, { xpx: 350, ypx: 200 });
4879+
assertLabel({title: '1.3', items: [
4880+
'trace 0 : 2.0 (1.00)',
4881+
'trace 1 : (0.749, 0.999)',
4882+
'trace 2 : 3.0 '
4883+
]});
4884+
})
4885+
.then(done, done.fail);
4886+
});
4887+
48344888
it('should display hover for two high-res scatter at different various intervals', function(done) {
48354889
var x1 = [];
48364890
var y1 = [];

0 commit comments

Comments
 (0)