12
12
var d3 = require ( 'd3' ) ;
13
13
14
14
var Color = require ( '../color' ) ;
15
- var Drawing = require ( '../drawing' ) ;
16
15
17
16
var ARROWPATHS = require ( './arrow_paths' ) ;
18
17
@@ -27,13 +26,16 @@ var ARROWPATHS = require('./arrow_paths');
27
26
* @param {number } options.arrowhead: head style - see ./arrow_paths
28
27
* @param {number } options.arrowsize: relative size of the head vs line width
29
28
* @param {number } options.standoff: distance in px to move the arrow point from its target
29
+ * @param {number } options.arrowwidth: width of the arrow line
30
+ * @param {string } options.arrowcolor: color of the arrow line, for the head to match
31
+ * Note that the opacity of this color is ignored, as it's assumed the container
32
+ * of both the line and head has opacity applied to it so there isn't greater opacity
33
+ * where they overlap.
30
34
*/
31
35
module . exports = function drawArrowHead ( el3 , ends , options ) {
32
36
var el = el3 . node ( ) ;
33
37
var headStyle = ARROWPATHS [ options . arrowhead || 0 ] ;
34
- var scale = ( Drawing . getPx ( el3 , 'stroke-width' ) || 1 ) * options . arrowsize ;
35
- var stroke = el3 . style ( 'stroke' ) || Color . defaultLine ;
36
- var opacity = el3 . style ( 'stroke-opacity' ) || 1 ;
38
+ var scale = ( options . arrowwidth || 1 ) * options . arrowsize ;
37
39
var doStart = ends . indexOf ( 'start' ) >= 0 ;
38
40
var doEnd = ends . indexOf ( 'end' ) >= 0 ;
39
41
var backOff = headStyle . backoff * scale + options . standoff ;
@@ -125,8 +127,7 @@ module.exports = function drawArrowHead(el3, ends, options) {
125
127
'scale(' + scale + ')'
126
128
} )
127
129
. style ( {
128
- fill : stroke ,
129
- opacity : opacity ,
130
+ fill : Color . rgb ( options . arrowcolor ) ,
130
131
'stroke-width' : 0
131
132
} ) ;
132
133
}
0 commit comments