优化线条
This commit is contained in:
@@ -976,18 +976,26 @@
|
||||
const pts = [start, end].slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
||||
const isForward = (start === pts[0]);
|
||||
|
||||
// Simplified calculation to reduce crossings
|
||||
// Maintaining a consistent direction for single lines ensures that parallel paths stay parallel
|
||||
// Normalization and special routing rules
|
||||
const lowS = (route.source || '').toLowerCase().trim();
|
||||
const lowD = (route.dest || '').toLowerCase().trim();
|
||||
const isSeattleJapan = ( (lowS === 'seattle' || lowS === 'us seattle') && lowD === 'japan' ) ||
|
||||
( (lowD === 'seattle' || lowD === 'us seattle') && lowS === 'japan' );
|
||||
|
||||
let finalCurve = 0;
|
||||
if (count === 1) {
|
||||
// Subtle consistent curve for single routes
|
||||
if (isSeattleJapan) {
|
||||
// Special rule: Seattle ↔ Japan route curves upward (North)
|
||||
// For Seattle -> Japan (Westbound): Right is North (+).
|
||||
// For Japan -> Seattle (Eastbound): Right is South (+), so North is (-).
|
||||
const isWestbound = (lowS === 'seattle' || lowS === 'us seattle');
|
||||
finalCurve = isWestbound ? 0.3 : -0.3;
|
||||
} else if (count === 1) {
|
||||
// Subtle consistent curve for single routes to maintain parallelism
|
||||
finalCurve = 0.12;
|
||||
} else {
|
||||
// Symmetrical fan-out for multiple lines between the same points
|
||||
// This spreads them cleanly into "eye" shapes without biased clustering
|
||||
const magnitude = 0.12 + Math.floor(i / 2) * 0.12;
|
||||
const spread = (i % 2 === 0) ? magnitude : -magnitude;
|
||||
// Ensure visual consistency regardless of the data direction (A->B or B->A)
|
||||
finalCurve = isForward ? spread : -spread;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user