@@ -271,7 +271,7 @@ function sankeyModel(layout, d, traceIndex) {
271
271
nodeLineWidth : trace . node . line . width ,
272
272
linkLineColor : trace . link . line . color ,
273
273
linkLineWidth : trace . link . line . width ,
274
- linkArrowWidth : trace . link . arrowwidth ,
274
+ linkArrowLength : trace . link . arrowlen ,
275
275
valueFormat : trace . valueformat ,
276
276
valueSuffix : trace . valuesuffix ,
277
277
textFont : trace . textfont ,
@@ -310,7 +310,7 @@ function linkModel(d, l, i) {
310
310
linkPath : linkPath ,
311
311
linkLineColor : d . linkLineColor ,
312
312
linkLineWidth : d . linkLineWidth ,
313
- linkArrowWidth : d . linkArrowWidth ,
313
+ linkArrowLength : d . linkArrowLength ,
314
314
valueFormat : d . valueFormat ,
315
315
valueSuffix : d . valueSuffix ,
316
316
sankey : d . sankey ,
@@ -320,7 +320,7 @@ function linkModel(d, l, i) {
320
320
} ;
321
321
}
322
322
323
- function createCircularClosedPathString ( link , arrowWidth ) {
323
+ function createCircularClosedPathString ( link , arrowLen ) {
324
324
// Using coordinates computed by d3-sankey-circular
325
325
var pathString = '' ;
326
326
var offset = link . width / 2 ;
@@ -330,17 +330,17 @@ function createCircularClosedPathString(link, arrowWidth) {
330
330
pathString =
331
331
// start at the left of the target node
332
332
'M ' +
333
- ( coords . targetX - arrowWidth ) + ' ' + ( coords . targetY + offset ) + ' ' +
333
+ ( coords . targetX - arrowLen ) + ' ' + ( coords . targetY + offset ) + ' ' +
334
334
'L' +
335
- ( coords . rightInnerExtent - arrowWidth ) + ' ' + ( coords . targetY + offset ) +
335
+ ( coords . rightInnerExtent - arrowLen ) + ' ' + ( coords . targetY + offset ) +
336
336
'A' +
337
337
( coords . rightLargeArcRadius + offset ) + ' ' + ( coords . rightSmallArcRadius + offset ) + ' 0 0 1 ' +
338
- ( coords . rightFullExtent - offset - arrowWidth ) + ' ' + ( coords . targetY - coords . rightSmallArcRadius ) +
338
+ ( coords . rightFullExtent - offset - arrowLen ) + ' ' + ( coords . targetY - coords . rightSmallArcRadius ) +
339
339
'L' +
340
- ( coords . rightFullExtent - offset - arrowWidth ) + ' ' + coords . verticalRightInnerExtent +
340
+ ( coords . rightFullExtent - offset - arrowLen ) + ' ' + coords . verticalRightInnerExtent +
341
341
'A' +
342
342
( coords . rightLargeArcRadius + offset ) + ' ' + ( coords . rightLargeArcRadius + offset ) + ' 0 0 1 ' +
343
- ( coords . rightInnerExtent - arrowWidth ) + ' ' + ( coords . verticalFullExtent - offset ) +
343
+ ( coords . rightInnerExtent - arrowLen ) + ' ' + ( coords . verticalFullExtent - offset ) +
344
344
'L' +
345
345
coords . leftInnerExtent + ' ' + ( coords . verticalFullExtent - offset ) +
346
346
'A' +
@@ -368,35 +368,35 @@ function createCircularClosedPathString(link, arrowWidth) {
368
368
( coords . leftLargeArcRadius - offset ) + ' ' + ( coords . leftLargeArcRadius - offset ) + ' 0 0 0 ' +
369
369
coords . leftInnerExtent + ' ' + ( coords . verticalFullExtent + offset ) +
370
370
'L' +
371
- ( coords . rightInnerExtent - arrowWidth ) + ' ' + ( coords . verticalFullExtent + offset ) +
371
+ ( coords . rightInnerExtent - arrowLen ) + ' ' + ( coords . verticalFullExtent + offset ) +
372
372
'A' +
373
373
( coords . rightLargeArcRadius - offset ) + ' ' + ( coords . rightLargeArcRadius - offset ) + ' 0 0 0 ' +
374
- ( coords . rightFullExtent + offset - arrowWidth ) + ' ' + coords . verticalRightInnerExtent +
374
+ ( coords . rightFullExtent + offset - arrowLen ) + ' ' + coords . verticalRightInnerExtent +
375
375
'L' +
376
- ( coords . rightFullExtent + offset - arrowWidth ) + ' ' + ( coords . targetY - coords . rightSmallArcRadius ) +
376
+ ( coords . rightFullExtent + offset - arrowLen ) + ' ' + ( coords . targetY - coords . rightSmallArcRadius ) +
377
377
'A' +
378
378
( coords . rightLargeArcRadius - offset ) + ' ' + ( coords . rightSmallArcRadius - offset ) + ' 0 0 0 ' +
379
- ( coords . rightInnerExtent - arrowWidth ) + ' ' + ( coords . targetY - offset ) +
379
+ ( coords . rightInnerExtent - arrowLen ) + ' ' + ( coords . targetY - offset ) +
380
380
'L' +
381
- ( coords . targetX - arrowWidth ) + ' ' + ( coords . targetY - offset ) +
382
- ( arrowWidth > 0 ? 'L' + coords . targetX + ' ' + ( coords . targetY ) : '' ) +
381
+ ( coords . targetX - arrowLen ) + ' ' + ( coords . targetY - offset ) +
382
+ ( arrowLen > 0 ? 'L' + coords . targetX + ' ' + ( coords . targetY ) : '' ) +
383
383
'Z' ;
384
384
} else {
385
385
// Bottom path
386
386
pathString =
387
387
// start at the left of the target node
388
388
'M ' +
389
- ( coords . targetX - arrowWidth ) + ' ' + ( coords . targetY - offset ) + ' ' +
389
+ ( coords . targetX - arrowLen ) + ' ' + ( coords . targetY - offset ) + ' ' +
390
390
'L' +
391
- ( coords . rightInnerExtent - arrowWidth ) + ' ' + ( coords . targetY - offset ) +
391
+ ( coords . rightInnerExtent - arrowLen ) + ' ' + ( coords . targetY - offset ) +
392
392
'A' +
393
393
( coords . rightLargeArcRadius + offset ) + ' ' + ( coords . rightSmallArcRadius + offset ) + ' 0 0 0 ' +
394
- ( coords . rightFullExtent - offset - arrowWidth ) + ' ' + ( coords . targetY + coords . rightSmallArcRadius ) +
394
+ ( coords . rightFullExtent - offset - arrowLen ) + ' ' + ( coords . targetY + coords . rightSmallArcRadius ) +
395
395
'L' +
396
- ( coords . rightFullExtent - offset - arrowWidth ) + ' ' + coords . verticalRightInnerExtent +
396
+ ( coords . rightFullExtent - offset - arrowLen ) + ' ' + coords . verticalRightInnerExtent +
397
397
'A' +
398
398
( coords . rightLargeArcRadius + offset ) + ' ' + ( coords . rightLargeArcRadius + offset ) + ' 0 0 0 ' +
399
- ( coords . rightInnerExtent - arrowWidth ) + ' ' + ( coords . verticalFullExtent + offset ) +
399
+ ( coords . rightInnerExtent - arrowLen ) + ' ' + ( coords . verticalFullExtent + offset ) +
400
400
'L' +
401
401
coords . leftInnerExtent + ' ' + ( coords . verticalFullExtent + offset ) +
402
402
'A' +
@@ -424,18 +424,18 @@ function createCircularClosedPathString(link, arrowWidth) {
424
424
( coords . leftLargeArcRadius - offset ) + ' ' + ( coords . leftLargeArcRadius - offset ) + ' 0 0 1 ' +
425
425
coords . leftInnerExtent + ' ' + ( coords . verticalFullExtent - offset ) +
426
426
'L' +
427
- ( coords . rightInnerExtent - arrowWidth ) + ' ' + ( coords . verticalFullExtent - offset ) +
427
+ ( coords . rightInnerExtent - arrowLen ) + ' ' + ( coords . verticalFullExtent - offset ) +
428
428
'A' +
429
429
( coords . rightLargeArcRadius - offset ) + ' ' + ( coords . rightLargeArcRadius - offset ) + ' 0 0 1 ' +
430
- ( coords . rightFullExtent + offset - arrowWidth ) + ' ' + coords . verticalRightInnerExtent +
430
+ ( coords . rightFullExtent + offset - arrowLen ) + ' ' + coords . verticalRightInnerExtent +
431
431
'L' +
432
- ( coords . rightFullExtent + offset - arrowWidth ) + ' ' + ( coords . targetY + coords . rightSmallArcRadius ) +
432
+ ( coords . rightFullExtent + offset - arrowLen ) + ' ' + ( coords . targetY + coords . rightSmallArcRadius ) +
433
433
'A' +
434
434
( coords . rightLargeArcRadius - offset ) + ' ' + ( coords . rightSmallArcRadius - offset ) + ' 0 0 1 ' +
435
- ( coords . rightInnerExtent - arrowWidth ) + ' ' + ( coords . targetY + offset ) +
435
+ ( coords . rightInnerExtent - arrowLen ) + ' ' + ( coords . targetY + offset ) +
436
436
'L' +
437
- ( coords . targetX - arrowWidth ) + ' ' + ( coords . targetY + offset ) +
438
- ( arrowWidth > 0 ? 'L' + coords . targetX + ' ' + ( coords . targetY ) : '' ) +
437
+ ( coords . targetX - arrowLen ) + ' ' + ( coords . targetY + offset ) +
438
+ ( arrowLen > 0 ? 'L' + coords . targetX + ' ' + ( coords . targetY ) : '' ) +
439
439
'Z' ;
440
440
}
441
441
return pathString ;
@@ -444,12 +444,16 @@ function createCircularClosedPathString(link, arrowWidth) {
444
444
function linkPath ( ) {
445
445
var curvature = 0.5 ;
446
446
function path ( d ) {
447
+ var arrowLen = d . linkArrowLength ;
447
448
if ( d . link . circular ) {
448
- return createCircularClosedPathString ( d . link , d . linkArrowWidth ) ;
449
+ return createCircularClosedPathString ( d . link , arrowLen ) ;
449
450
} else {
450
- var arrowWidth = d . linkArrowWidth ;
451
+ var maxArrowLength = Math . abs ( ( d . link . target . x0 - d . link . source . x1 ) / 2 ) ;
452
+ if ( arrowLen > maxArrowLength ) {
453
+ arrowLen = maxArrowLength ;
454
+ }
451
455
var x0 = d . link . source . x1 ;
452
- var x1 = d . link . target . x0 - arrowWidth ;
456
+ var x1 = d . link . target . x0 - arrowLen ;
453
457
var xi = interpolateNumber ( x0 , x1 ) ;
454
458
var x2 = xi ( curvature ) ;
455
459
var x3 = xi ( 1 - curvature ) ;
@@ -465,7 +469,7 @@ function linkPath() {
465
469
' ' + x2 + ',' + y0b +
466
470
' ' + x0 + ',' + y0b ;
467
471
468
- var rightEnd = arrowWidth > 0 ? 'L' + ( x1 + arrowWidth ) + ',' + ( y1a + d . link . width / 2 ) : '' ;
472
+ var rightEnd = arrowLen > 0 ? 'L' + ( x1 + arrowLen ) + ',' + ( y1a + d . link . width / 2 ) : '' ;
469
473
rightEnd += 'L' + x1 + ',' + y1b ;
470
474
return start + upperCurve + rightEnd + lowerCurve + 'Z' ;
471
475
}
0 commit comments