优化分布
This commit is contained in:
@@ -977,16 +977,22 @@
|
|||||||
const isForward = (start === pts[0]);
|
const isForward = (start === pts[0]);
|
||||||
|
|
||||||
// Calculate curveness: ensure all lines are slightly curved
|
// Calculate curveness: ensure all lines are slightly curved
|
||||||
|
// Use a canonical hash of the route endpoints to deterministically decide the curve direction
|
||||||
|
// This helps spread lines across the map even for single routes
|
||||||
|
const names = [route.source, route.dest].sort();
|
||||||
|
const routeHash = (names[0] + names[1]).split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
||||||
|
const baseSign = (routeHash % 2 === 0 ? 1 : -1);
|
||||||
|
|
||||||
let finalCurve = 0;
|
let finalCurve = 0;
|
||||||
if (count === 1) {
|
if (count === 1) {
|
||||||
finalCurve = 0.15; // Default slight curve for single lines
|
// Single lines get a decent curve, alternating direction based on hash
|
||||||
|
finalCurve = 0.2 * baseSign;
|
||||||
} else {
|
} else {
|
||||||
// Spread overlapping lines: 0.15, -0.15, 0.3, -0.3...
|
// Multiple lines between same points fan out with increasing magnitude
|
||||||
// This creates an "eye" or "fan" effect where no line is straight
|
const magnitude = 0.2 + Math.floor(i / 2) * 0.15;
|
||||||
const magnitude = 0.15 + Math.floor(i / 2) * 0.15;
|
|
||||||
const spread = (i % 2 === 0) ? magnitude : -magnitude;
|
const spread = (i % 2 === 0) ? magnitude : -magnitude;
|
||||||
// Adjust sign based on direction so they occupy unique visual slots
|
// Apply baseSign to ensure the whole group isn't biased to one side
|
||||||
finalCurve = isForward ? spread : -spread;
|
finalCurve = isForward ? (spread * baseSign) : (-spread * baseSign);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalSeries.push({
|
finalSeries.push({
|
||||||
|
|||||||
Reference in New Issue
Block a user