Skip to content

Commit c7f073d

Browse files
committed
Move arrowheadsize under marker
1 parent f79bca8 commit c7f073d

File tree

4 files changed

+17
-29
lines changed

4 files changed

+17
-29
lines changed

src/traces/quiver/attributes.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').ax
77
var extendFlat = require('../../lib/extend').extendFlat;
88
var colorScaleAttrs = require('../../components/colorscale/attributes');
99
var dash = require('../../components/drawing/attributes').dash;
10+
var annotationAttrs = require('../../components/annotations/attributes');
1011

1112
var attrs = {
1213
x: {
@@ -79,26 +80,6 @@ var attrs = {
7980
uhoverformat: axisHoverFormat('u', 'noDate'),
8081
vhoverformat: axisHoverFormat('v', 'noDate'),
8182

82-
// Arrowhead sizing, consistent with annotations API naming
83-
arrowsize: {
84-
valType: 'number',
85-
min: 0.3,
86-
dflt: 1,
87-
editType: 'calc',
88-
description: [
89-
'Scales the size of the arrow head relative to a base size.',
90-
'Higher values produce larger heads.'
91-
].join(' ')
92-
},
93-
// Back-compat alias
94-
arrow_scale: {
95-
valType: 'number',
96-
min: 0,
97-
max: 1,
98-
editType: 'calc',
99-
description: 'Deprecated alias for `arrowsize`-based sizing. Prefer using `arrowsize`.'
100-
},
101-
10283
// Text and labels
10384
text: {
10485
valType: 'data_array',
@@ -125,9 +106,16 @@ var attrs = {
125106
description: 'Sets the text font.'
126107
}),
127108

128-
// Marker: color, colorscale, and line styling for arrows
109+
// Marker: color, colorscale, arrowhead sizing, and line styling for arrows
129110
marker: extendFlat(
130111
{
112+
arrowsize: extendFlat({}, annotationAttrs.arrowsize, {
113+
editType: 'calc',
114+
description: [
115+
'Sets the size of the arrow head relative to `marker.line.width`.',
116+
'A value of 1 (default) gives a head about 3x as wide as the line.'
117+
].join(' ')
118+
}),
131119
line: {
132120
width: {
133121
valType: 'number',

src/traces/quiver/defaults.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3636
coerce('anchor');
3737

3838
// Arrow styling
39-
coerce('arrowsize');
40-
coerce('arrow_scale'); // back-compat alias
39+
coerce('marker.arrowsize');
4140
coerce('hoverdistance');
4241

4342
// Line styling under marker.line

src/traces/quiver/plot.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
102102
var pxPerY = Math.abs(ya.c2p(cdi.y + 1) - ya.c2p(cdi.y));
103103
var scaleRatio = (pxPerX && pxPerY) ? (pxPerY / pxPerX) : 1;
104104
var baseHeadScale = 0.2;
105-
var arrowScale = (trace.arrowsize !== undefined)
106-
? (baseHeadScale * trace.arrowsize)
107-
: (trace.arrow_scale !== undefined ? trace.arrow_scale : baseHeadScale);
105+
var markerArrowsize = (trace.marker || {}).arrowsize;
106+
var arrowScale = (markerArrowsize !== undefined)
107+
? (baseHeadScale * markerArrowsize)
108+
: baseHeadScale;
108109
// Fixed arrowhead wedge angle (radians).
109110
// Arrow direction is fully determined by u,v (see barbAng below);
110111
// this constant only controls the opening of the head.

test/image/mocks/quiver_arrow-styling.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"v": [1, 1, 1],
1010
"sizemode": "scaled",
1111
"sizeref": 0.5,
12-
"arrowsize": 0.5,
1312
"anchor": "tail",
1413
"marker": {
1514
"color": "red",
15+
"arrowsize": 0.5,
1616
"line": {"width": 1}
1717
}
1818
},
@@ -25,10 +25,10 @@
2525
"v": [1, 1, 1],
2626
"sizemode": "scaled",
2727
"sizeref": 0.5,
28-
"arrowsize": 1.0,
2928
"anchor": "tail",
3029
"marker": {
3130
"color": "blue",
31+
"arrowsize": 1.0,
3232
"line": {"width": 2}
3333
}
3434
},
@@ -41,10 +41,10 @@
4141
"v": [1, 1, 1],
4242
"sizemode": "scaled",
4343
"sizeref": 0.5,
44-
"arrowsize": 2.0,
4544
"anchor": "tail",
4645
"marker": {
4746
"color": "green",
47+
"arrowsize": 2.0,
4848
"line": {"width": 3}
4949
}
5050
}

0 commit comments

Comments
 (0)