Skip to content

Commit e607cd1

Browse files
Add testQuiverHovertextData (only show hover data on arrow tail)
1 parent 5ab0586 commit e607cd1

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

plotly/Test_plotlyfig.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,5 +3295,37 @@ function testRoseBarpolarData(tc)
32953295
tc.verifyEqual(sum(p.data{1}.r), numel(angles));
32963296
try close(); catch; end
32973297
end
3298+
3299+
function testQuiverHovertextData(tc)
3300+
% quiver emits three traces: the shaft (no hover), a tail
3301+
% marker trace with a per-arrow "(x, y)<br>(u, v)" tooltip,
3302+
% and the arrowhead barbs (no hover).
3303+
fig = figure("Visible","off");
3304+
quiver(1:3, [2 4 6], [3 1 -2], [4 2 1]);
3305+
3306+
p = plotlyfig(fig,"visible","off");
3307+
3308+
tc.verifyNumElements(p.data, 3);
3309+
tc.verifyEqual(p.data{1}.hoverinfo, "skip");
3310+
tc.verifyEqual(p.data{3}.hoverinfo, "skip");
3311+
tc.verifyEqual(p.data{2}.mode, "markers");
3312+
tc.verifyEqual(p.data{2}.hoverinfo, "text");
3313+
3314+
shaftX = p.data{1}.x;
3315+
shaftY = p.data{1}.y;
3316+
expectedHovertext = {};
3317+
n = 1;
3318+
while n <= numel(shaftX)
3319+
if isnan(shaftX(n))
3320+
n = n + 1;
3321+
continue;
3322+
end
3323+
expectedHovertext{end+1} = sprintf("(%.2f, %.2f)<br>(%.2f, %.2f)", ...
3324+
shaftX(n), shaftY(n), shaftX(n+1)-shaftX(n), shaftY(n+1)-shaftY(n));
3325+
n = n + 2;
3326+
end
3327+
tc.verifyEqual(p.data{2}.hovertext, expectedHovertext);
3328+
try close(); catch; end
3329+
end
32983330
end
32993331
end

0 commit comments

Comments
 (0)