Skip to content

Commit ce0527e

Browse files
Simplify mock and added jasmine test
1 parent 7ff8cee commit ce0527e

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

test/image/mocks/multicategory_series.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,7 @@
15811581
},
15821582
"hovermode": "x unified",
15831583
"title": {
1584-
"text": "Multicategory Mock with Tickmode 'sync'"
1584+
"text": "Multicategory Mock"
15851585
},
15861586
"xaxis": {
15871587
"visible": false,
@@ -1609,7 +1609,6 @@
16091609
],
16101610
"type": "linear",
16111611
"side": "left",
1612-
"tickmode": "sync",
16131612
"overlaying": "y"
16141613
},
16151614
"showlegend": true

test/jasmine/tests/hover_label_test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,6 +2640,39 @@ describe('Hover on multicategory axes', function() {
26402640
})
26412641
.then(done, done.fail);
26422642
});
2643+
2644+
fit('should work with series', function(done) {
2645+
var fig = Lib.extendDeep({}, require('@mocks/multicategory_series.json'));
2646+
fig.data = [fig.data[0]];
2647+
fig.layout.width = 500;
2648+
fig.layout.height = 500;
2649+
2650+
Plotly.newPlot(gd, fig)
2651+
.then(function() {
2652+
gd.on('plotly_hover', function(d) {
2653+
eventData = d.points[0];
2654+
});
2655+
})
2656+
.then(function() { _hover(200, 200); })
2657+
.then(function() {
2658+
assertHoverLabelContent({
2659+
nums: 'x: 2017 - q3\ny: Group 3 - A\nz: 2.303'
2660+
});
2661+
expect(eventData.x).toEqual(['2017', 'q3']);
2662+
})
2663+
.then(function() {
2664+
return Plotly.restyle(gd, 'hovertemplate', '%{z} @ %{x} | %{y}');
2665+
})
2666+
.then(function() { _hover(200, 200); })
2667+
.then(function() {
2668+
assertHoverLabelContent({
2669+
nums: '2.303 @ 2017 - q3 | Group 3 - A',
2670+
name: 'w/ 2d z'
2671+
});
2672+
expect(eventData.x).toEqual(['2017', 'q3']);
2673+
})
2674+
.then(done, done.fail);
2675+
});
26432676
});
26442677

26452678
describe('hover on traces with (x|y)period positioning', function() {

0 commit comments

Comments
 (0)