5
5
NODE_STROKE_WIDTH ,
6
6
NODE_RADIUS ,
7
7
ZOOM_PROPS ,
8
+ EDGE_CAPTION_EXTERNAL ,
8
9
} from './constants'
9
10
10
11
const DEFAULT_OPTIONS = {
@@ -208,7 +209,7 @@ function StraightArrow(
208
209
209
210
// for shortCaptionLength we use textBoundingBox = text.node().getComputedTextLength(),
210
211
this . outline = function ( shortCaptionLength : number ) {
211
- if ( captionLayout === "external" ) {
212
+ if ( captionLayout === EDGE_CAPTION_EXTERNAL ) {
212
213
const startBreak = startArrow + ( this . shaftLength - shortCaptionLength ) / 2
213
214
const endBreak = endShaft - ( this . shaftLength - shortCaptionLength ) / 2
214
215
@@ -443,7 +444,7 @@ function ArcArrow(
443
444
] . join ( " " )
444
445
}
445
446
446
- if ( captionLayout === "external" ) {
447
+ if ( captionLayout === EDGE_CAPTION_EXTERNAL ) {
447
448
let captionSweep = shortCaptionLength / arcRadius
448
449
if ( this . deflection > 0 ) {
449
450
captionSweep *= - 1
@@ -1333,26 +1334,26 @@ function GraphD3(_selector: HTMLDivElement, _options: any): IGraphD3 {
1333
1334
1334
1335
return ( ( ) => {
1335
1336
const result = [ ]
1336
- for ( var nodePair of Array . from ( nodePairs ) ) {
1337
- for ( var relationship of Array . from ( nodePair . relationships ) ) {
1337
+ for ( let nodePair of Array . from ( nodePairs ) ) {
1338
+ for ( let relationship of Array . from ( nodePair . relationships ) ) {
1338
1339
delete relationship . arrow
1339
1340
}
1340
1341
1341
- var middleRelationshipIndex = ( nodePair . relationships . length - 1 ) / 2
1342
- var defaultDeflectionStep = 30
1342
+ let middleRelationshipIndex = ( nodePair . relationships . length - 1 ) / 2
1343
+ let defaultDeflectionStep = 30
1343
1344
const maximumTotalDeflection = 150
1344
1345
const numberOfSteps = nodePair . relationships . length - 1
1345
1346
const totalDeflection = defaultDeflectionStep * numberOfSteps
1346
1347
1347
- var deflectionStep =
1348
+ let deflectionStep =
1348
1349
totalDeflection > maximumTotalDeflection
1349
1350
? maximumTotalDeflection / numberOfSteps
1350
1351
: defaultDeflectionStep
1351
1352
1352
1353
result . push (
1353
1354
( ( ) => {
1354
1355
for ( let i = 0 ; i < nodePair . relationships . length ; i ++ ) {
1355
- var ref
1356
+ let ref
1356
1357
relationship = nodePair . relationships [ i ]
1357
1358
const nodeRadius = options . nodeRadius
1358
1359
const shaftWidth = options . relationshipWidth
@@ -1378,7 +1379,7 @@ function GraphD3(_selector: HTMLDivElement, _options: any): IGraphD3 {
1378
1379
shaftWidth ,
1379
1380
headWidth ,
1380
1381
headHeight ,
1381
- relationship . captionLayout || "external"
1382
+ relationship . captionLayout || EDGE_CAPTION_EXTERNAL
1382
1383
)
1383
1384
} else {
1384
1385
let deflection =
@@ -1396,7 +1397,7 @@ function GraphD3(_selector: HTMLDivElement, _options: any): IGraphD3 {
1396
1397
shaftWidth ,
1397
1398
headWidth ,
1398
1399
headHeight ,
1399
- relationship . captionLayout || "external"
1400
+ relationship . captionLayout || EDGE_CAPTION_EXTERNAL
1400
1401
)
1401
1402
}
1402
1403
}
@@ -1462,8 +1463,8 @@ function GraphD3(_selector: HTMLDivElement, _options: any): IGraphD3 {
1462
1463
if ( ! nodePair . isLoop ( ) ) {
1463
1464
const dx = nodePair . nodeA . x - nodePair . nodeB . x
1464
1465
const dy = nodePair . nodeA . y - nodePair . nodeB . y
1465
- var angle = ( ( Math . atan2 ( dy , dx ) / Math . PI ) * 180 + 360 ) % 360
1466
- var centreDistance = Math . sqrt ( square ( dx ) + square ( dy ) )
1466
+ let angle = ( ( Math . atan2 ( dy , dx ) / Math . PI ) * 180 + 360 ) % 360
1467
+ let centreDistance = Math . sqrt ( square ( dx ) + square ( dy ) )
1467
1468
result . push (
1468
1469
( ( ) => {
1469
1470
const result1 : number [ ] = [ ]
@@ -1488,12 +1489,12 @@ function GraphD3(_selector: HTMLDivElement, _options: any): IGraphD3 {
1488
1489
function distributeAnglesForLoopArrows ( nodePairs : NodePair [ ] , relationships : IRelationship [ ] ) {
1489
1490
return ( ( ) => {
1490
1491
const result = [ ]
1491
- for ( var nodePair of Array . from ( nodePairs ) ) {
1492
+ for ( let nodePair of Array . from ( nodePairs ) ) {
1492
1493
if ( nodePair . isLoop ( ) ) {
1493
- var i : number , separation : number
1494
+ let i : number , separation : number
1494
1495
let angles = [ ]
1495
1496
const node = nodePair . nodeA
1496
- for ( var relationship of Array . from ( relationships ) ) {
1497
+ for ( let relationship of Array . from ( relationships ) ) {
1497
1498
if ( ! relationship . isLoop ( ) ) {
1498
1499
if ( relationship . source === node ) {
1499
1500
angles . push ( relationship . naturalAngle )
@@ -1505,8 +1506,8 @@ function GraphD3(_selector: HTMLDivElement, _options: any): IGraphD3 {
1505
1506
}
1506
1507
angles = angles . map ( ( a ) => ( a + 360 ) % 360 ) . sort ( ( a , b ) => a - b )
1507
1508
if ( angles . length > 0 ) {
1508
- var end : number , start : number
1509
- var biggestGap = {
1509
+ let end : number , start : number
1510
+ let biggestGap = {
1510
1511
start : 0 ,
1511
1512
end : 0 ,
1512
1513
}
0 commit comments