Skip to content

Commit b24759d

Browse files
committed
fix scattercarpet 'y' hover format + add tests
1 parent c89c895 commit b24759d

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/traces/scattercarpet/hover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
6767
var tj = ij[1] - j0;
6868

6969
var xy = carpet.evalxy([], i0, j0, ti, tj);
70-
text.push('y: ' + xy[1].toFixed(3));
70+
text.push('y = ' + xy[1].toFixed(3));
7171

7272
newPointData.extraText = text.join('<br>');
7373

test/jasmine/tests/carpet_test.js

+39
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ var createGraphDiv = require('../assets/create_graph_div');
1111
var destroyGraphDiv = require('../assets/destroy_graph_div');
1212
var fail = require('../assets/fail_test');
1313

14+
var mouseEvent = require('../assets/mouse_event');
15+
var assertHoverLabelContent = require('../assets/custom_assertions').assertHoverLabelContent;
16+
1417
describe('carpet supplyDefaults', function() {
1518
'use strict';
1619

@@ -565,3 +568,39 @@ describe('scattercarpet array attributes', function() {
565568
.then(done);
566569
});
567570
});
571+
572+
describe('scattercarpet hover labels', function() {
573+
var gd;
574+
575+
afterEach(destroyGraphDiv);
576+
577+
function run(pos, fig, content) {
578+
gd = createGraphDiv();
579+
580+
return Plotly.plot(gd, fig).then(function() {
581+
mouseEvent('mousemove', pos[0], pos[1]);
582+
assertHoverLabelContent([content, null]);
583+
});
584+
}
585+
586+
it('should generate hover label (base)', function(done) {
587+
var fig = Lib.extendDeep({}, require('@mocks/scattercarpet.json'));
588+
589+
run(
590+
[200, 200], fig,
591+
[['a = 0.200', 'b = 3.500', 'y = 2.900'], 'a = 0.2']
592+
)
593+
.then(done);
594+
});
595+
596+
it('should generate hover label with \'hoverinfo\' set', function(done) {
597+
var fig = Lib.extendDeep({}, require('@mocks/scattercarpet.json'));
598+
fig.data[5].hoverinfo = 'a+y';
599+
600+
run(
601+
[200, 200], fig,
602+
[['a = 0.200', 'y = 2.900'], null]
603+
)
604+
.then(done);
605+
});
606+
});

0 commit comments

Comments
 (0)