@@ -406,7 +406,7 @@ const createDiagram = () => {
406
406
if (! diagramContainer .value ) return
407
407
408
408
const width = diagramContainer .value .clientWidth
409
- const height = 800 // Increased height for better spacing
409
+ const height = 1200 // Further increased height for better vertical spacing
410
410
const cardWidth = 310 // Card width defined here for consistent reference
411
411
412
412
// Clear existing visualization
@@ -487,35 +487,29 @@ const createDiagram = () => {
487
487
const g = svg .append (' g' )
488
488
489
489
// Apply initial zoom to see all content
490
- const initialScale = 0.7 // Reduced scale to see more content
491
- svg .call (zoom .transform , d3 .zoomIdentity .translate (width / 2 - width * initialScale / 2 , 20 ).scale (initialScale ))
490
+ const initialScale = 0.55 // Further reduced scale to see more content
491
+ svg .call (zoom .transform , d3 .zoomIdentity .translate (width / 2 - width * initialScale / 2 , 10 ).scale (initialScale ))
492
492
493
493
// Set initial positions for models based on the reference image layout
494
494
const initialPositions: Record <string , {x: number , y: number }> = {
495
- // Top row
496
- ' team' : { x: width * 0.25 , y: 150 },
495
+ // Top row - more evenly spaced
496
+ ' team' : { x: width * 0.2 , y: 150 },
497
497
' user' : { x: width * 0.5 , y: 150 },
498
- ' post' : { x: width * 0.75 , y: 150 },
498
+ ' post' : { x: width * 0.8 , y: 150 },
499
499
500
- // Second row
501
- ' accessToken' : { x: width * 0.25 , y: 450 },
500
+ // Second row - better distributed
501
+ ' accessToken' : { x: width * 0.2 , y: 450 },
502
+ ' subscriber' : { x: width * 0.8 , y: 450 },
502
503
503
- // Third row - left side
504
- ' project' : { x: width * 0.25 , y: 700 },
504
+ // Third row - more evenly spaced
505
+ ' project' : { x: width * 0.2 , y: 750 },
506
+ ' order' : { x: width * 0.5 , y: 750 },
507
+ ' subscriberEmail' : { x: width * 0.8 , y: 750 },
505
508
506
- // Fourth row - left side
507
- ' deployment' : { x: width * 0.1 , y: 900 },
508
- ' release' : { x: width * 0.4 , y: 900 },
509
-
510
- // Second row - right side
511
- ' subscriber' : { x: width * 0.75 , y: 450 },
512
-
513
- // Third row - right side
514
- ' subscriberEmail' : { x: width * 0.75 , y: 700 },
515
- ' order' : { x: width * 0.5 , y: 700 },
516
-
517
- // Fourth row - right side
518
- ' orderItem' : { x: width * 0.5 , y: 900 }
509
+ // Fourth row - better distributed with more horizontal spacing
510
+ ' deployment' : { x: width * 0.1 , y: 1050 },
511
+ ' release' : { x: width * 0.35 , y: 1050 },
512
+ ' orderItem' : { x: width * 0.65 , y: 1050 }
519
513
}
520
514
521
515
// Apply initial positions to models and store them for dragging
@@ -782,11 +776,14 @@ const createDiagram = () => {
782
776
// Calculate control points for the curve
783
777
const dx = targetModel .posX - sourceModel .posX
784
778
const dy = targetModel .posY - sourceModel .posY
785
- const dr = Math .sqrt (dx * dx + dy * dy ) * 1.5 // Increased curve factor for better arcs
779
+ const distance = Math .sqrt (dx * dx + dy * dy )
780
+
781
+ // Adjust curve factor based on distance between nodes
782
+ const curveFactor = distance > 500 ? 1.5 : 2.5
783
+ const dr = distance * curveFactor
786
784
787
785
// Determine if we need a clockwise or counter-clockwise arc
788
- const sweep = (sourceId === ' user' && targetId === ' team' ) ||
789
- (sourceId === ' team' && targetId === ' user' ) ? 0 : 1 ;
786
+ const sweep = determineArcSweep (sourceId , targetId );
790
787
791
788
// Create curved path
792
789
linkGroup .append (' path' )
@@ -860,6 +857,32 @@ const createDiagram = () => {
860
857
.alphaDecay (0.02 ) // Slower decay for smoother animation
861
858
}
862
859
860
+ // Helper function to determine arc sweep direction
861
+ function determineArcSweep(sourceId : string , targetId : string ): number {
862
+ // Define specific pairs that should use counter-clockwise arcs
863
+ const counterClockwisePairs = [
864
+ [' user' , ' team' ],
865
+ [' team' , ' user' ],
866
+ [' user' , ' post' ],
867
+ [' user' , ' subscriber' ],
868
+ [' user' , ' deployment' ],
869
+ [' project' , ' deployment' ],
870
+ [' project' , ' release' ],
871
+ [' subscriber' , ' subscriberEmail' ],
872
+ [' order' , ' orderItem' ]
873
+ ];
874
+
875
+ // Check if this pair should use counter-clockwise arc
876
+ for (const pair of counterClockwisePairs ) {
877
+ if ((sourceId === pair [0 ] && targetId === pair [1 ]) ||
878
+ (sourceId === pair [1 ] && targetId === pair [0 ])) {
879
+ return 0 ; // Counter-clockwise
880
+ }
881
+ }
882
+
883
+ return 1 ; // Default to clockwise
884
+ }
885
+
863
886
// Function to update links after dragging
864
887
function updateLinks() {
865
888
if (! diagramContainer .value ) return
@@ -882,11 +905,14 @@ function updateLinks() {
882
905
// Calculate control points for the curve
883
906
const dx = targetModel .posX - sourceModel .posX
884
907
const dy = targetModel .posY - sourceModel .posY
885
- const dr = Math .sqrt (dx * dx + dy * dy ) * 1.5 // Increased curve factor for better arcs
908
+ const distance = Math .sqrt (dx * dx + dy * dy )
909
+
910
+ // Adjust curve factor based on distance between nodes
911
+ const curveFactor = distance > 500 ? 1.5 : 2.5
912
+ const dr = distance * curveFactor
886
913
887
914
// Determine if we need a clockwise or counter-clockwise arc
888
- const sweep = (sourceId === ' user' && targetId === ' team' ) ||
889
- (sourceId === ' team' && targetId === ' user' ) ? 0 : 1 ;
915
+ const sweep = determineArcSweep (sourceId , targetId );
890
916
891
917
// Create curved path
892
918
linkGroup .append (' path' )
@@ -971,7 +997,7 @@ onUnmounted(() => {
971
997
</button >
972
998
</div >
973
999
</div >
974
- <div ref =" diagramContainer" class =" w-full h-[800px ] bg-gray-50 dark:bg-blue-gray-800 rounded-lg" ></div >
1000
+ <div ref =" diagramContainer" class =" w-full h-[1200px ] bg-gray-50 dark:bg-blue-gray-800 rounded-lg" ></div >
975
1001
</div >
976
1002
</div >
977
1003
</div >
0 commit comments