1212var d3 = require ( 'd3' ) ;
1313
1414var Color = require ( '../color' ) ;
15- var Drawing = require ( '../drawing' ) ;
1615
1716var ARROWPATHS = require ( './arrow_paths' ) ;
1817
@@ -27,13 +26,16 @@ var ARROWPATHS = require('./arrow_paths');
2726 * @param {number } options.arrowhead: head style - see ./arrow_paths
2827 * @param {number } options.arrowsize: relative size of the head vs line width
2928 * @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.
3034 */
3135module . exports = function drawArrowHead ( el3 , ends , options ) {
3236 var el = el3 . node ( ) ;
3337 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 ;
3739 var doStart = ends . indexOf ( 'start' ) >= 0 ;
3840 var doEnd = ends . indexOf ( 'end' ) >= 0 ;
3941 var backOff = headStyle . backoff * scale + options . standoff ;
@@ -125,8 +127,7 @@ module.exports = function drawArrowHead(el3, ends, options) {
125127 'scale(' + scale + ')'
126128 } )
127129 . style ( {
128- fill : stroke ,
129- opacity : opacity ,
130+ fill : Color . rgb ( options . arrowcolor ) ,
130131 'stroke-width' : 0
131132 } ) ;
132133 }
0 commit comments