Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Match arrowhead attributes for annotations
  • Loading branch information
degzhaus committed Nov 29, 2025
commit f7dddbc61a0798987f791c05a0028af286bb5f00
36 changes: 28 additions & 8 deletions src/traces/quiver/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ var attrs = {
'or *cm*/*center*/*middle* to center the arrow on (x,y).'
].join(' ')
},
arrow_scale: {
valType: 'number',
dflt: 0.3,
min: 0,
max: 1,
editType: 'calc',
description: 'Value multiplied to length of barb to get length of arrowhead. Default = 0.3'
},
angle: {
valType: 'number',
dflt: Math.PI / 9,
Expand All @@ -95,6 +87,26 @@ var attrs = {
description: 'Maximum distance (in pixels) to look for nearby arrows on hover.'
},

// Arrowhead sizing, consistent with annotations API naming
arrowsize: {
valType: 'number',
min: 0.3,
dflt: 1,
editType: 'calc',
description: [
'Scales the size of the arrow head relative to a base size.',
'Higher values produce larger heads.'
].join(' ')
},
// Back-compat alias
arrow_scale: {
valType: 'number',
min: 0,
max: 1,
editType: 'calc',
description: 'Deprecated alias for `arrowsize`-based sizing. Prefer using `arrowsize`.'
},

// Line styling for arrows
line: {
color: {
Expand Down Expand Up @@ -135,6 +147,14 @@ var attrs = {
editType: 'style'
},

// Alias consistent with annotations; maps to line.width
arrowwidth: {
valType: 'number',
min: 0.1,
editType: 'style',
description: 'Sets the width (in px) of the arrow line (alias of `line.width`).'
},

// Text and labels
text: {
valType: 'data_array',
Expand Down
6 changes: 4 additions & 2 deletions src/traces/quiver/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
coerce('anchor');

// Set default values using coerce
coerce('arrow_scale', 0.3);
coerce('arrowsize', 1);
// back-compat
coerce('arrow_scale');
coerce('angle', Math.PI / 9);
coerce('scaleratio');
coerce('hoverdistance', 20);

// Line styling
traceOut.line = {
color: traceIn.line && traceIn.line.color ? traceIn.line.color : defaultColor,
width: traceIn.line && traceIn.line.width ? traceIn.line.width : 1,
width: (traceIn.arrowwidth !== undefined) ? traceIn.arrowwidth : (traceIn.line && traceIn.line.width ? traceIn.line.width : 1),
dash: traceIn.line && traceIn.line.dash ? traceIn.line.dash : 'solid',
shape: traceIn.line && traceIn.line.shape ? traceIn.line.shape : 'linear',
smoothing: traceIn.line && traceIn.line.smoothing ? traceIn.line.smoothing : 1,
Expand Down
5 changes: 4 additions & 1 deletion src/traces/quiver/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition

// Compute arrow in data space
var scaleRatio = trace.scaleratio || 1;
var arrowScale = trace.arrow_scale || 0.2;
var baseHeadScale = 0.2;
var arrowScale = (trace.arrowsize !== undefined)
? (baseHeadScale * trace.arrowsize)
: (trace.arrow_scale !== undefined ? trace.arrow_scale : baseHeadScale);
var angle = trace.angle || Math.PI / 12; // small default

var u = (trace.u && trace.u[cdi.i]) || 0;
Expand Down
Loading