SupPepper commited on
Commit ·
30b115e
1
Parent(s): 8640b91
Update index.html
Browse files- frontend/index.html +21 -10
frontend/index.html
CHANGED
|
@@ -837,12 +837,17 @@ function _buildBondGraph(chars, bonds) {
|
|
| 837 |
const side = (pairOffset[pairKey] > 1 && (pairUsed[pairKey] || 0) === 0) ? 1 : -1;
|
| 838 |
pairUsed[pairKey] = (pairUsed[pairKey] || 0) + 1;
|
| 839 |
|
| 840 |
-
// Perpendicular offset
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
const
|
| 844 |
-
const
|
| 845 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 846 |
|
| 847 |
const col = _bondColor(b.note, b.value);
|
| 848 |
const op = (0.35 + Math.abs(b.value) / 100 * 0.65).toFixed(2);
|
|
@@ -859,10 +864,16 @@ function _buildBondGraph(chars, bonds) {
|
|
| 859 |
stroke-linecap="round" marker-end="url(#${markerId})"/>`;
|
| 860 |
|
| 861 |
if (b.note) {
|
| 862 |
-
//
|
| 863 |
-
|
| 864 |
-
const
|
| 865 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 866 |
font-size="9" fill="${col}"
|
| 867 |
paint-order="stroke" stroke="rgba(10,8,18,.85)" stroke-width="3" stroke-linejoin="round"
|
| 868 |
font-family="Georgia,serif" font-style="italic">${b.note}</text>`;
|
|
|
|
| 837 |
const side = (pairOffset[pairKey] > 1 && (pairUsed[pairKey] || 0) === 0) ? 1 : -1;
|
| 838 |
pairUsed[pairKey] = (pairUsed[pairKey] || 0) + 1;
|
| 839 |
|
| 840 |
+
// Perpendicular offset — use a CANONICAL direction (sorted by id) so that both
|
| 841 |
+
// A→B and B→A get the same perpendicular axis; side then reliably puts them
|
| 842 |
+
// on opposite sides instead of accidentally cancelling out.
|
| 843 |
+
const [canonSrc, canonTgt] = b.source_id < b.target_id ? [src, tgt] : [tgt, src];
|
| 844 |
+
const cdx = canonTgt.x - canonSrc.x, cdy = canonTgt.y - canonSrc.y;
|
| 845 |
+
const clen = Math.sqrt(cdx * cdx + cdy * cdy) || 1;
|
| 846 |
+
const perpX = -cdy / clen, perpY = cdx / clen; // canonical perpendicular unit vector
|
| 847 |
+
|
| 848 |
+
const curveStrength = pairOffset[pairKey] > 1 ? 48 : 18;
|
| 849 |
+
const cpx = (src.x + tgt.x) / 2 + perpX * curveStrength * side;
|
| 850 |
+
const cpy = (src.y + tgt.y) / 2 + perpY * curveStrength * side;
|
| 851 |
|
| 852 |
const col = _bondColor(b.note, b.value);
|
| 853 |
const op = (0.35 + Math.abs(b.value) / 100 * 0.65).toFixed(2);
|
|
|
|
| 864 |
stroke-linecap="round" marker-end="url(#${markerId})"/>`;
|
| 865 |
|
| 866 |
if (b.note) {
|
| 867 |
+
// For bidirectional pairs, push each label further in its own canonical perpendicular
|
| 868 |
+
// direction so the two notes don't stack on top of each other.
|
| 869 |
+
const bidir = pairOffset[pairKey] > 1;
|
| 870 |
+
const baseLx = 0.25 * src.x + 0.5 * cpx + 0.25 * tgt.x;
|
| 871 |
+
const baseLy = 0.25 * src.y + 0.5 * cpy + 0.25 * tgt.y;
|
| 872 |
+
const labelOffsetX = bidir ? perpX * 10 * side : 0;
|
| 873 |
+
const labelOffsetY = bidir ? perpY * 10 * side : -4;
|
| 874 |
+
const lx = baseLx + labelOffsetX;
|
| 875 |
+
const ly = baseLy + labelOffsetY;
|
| 876 |
+
arcs += `<text x="${lx}" y="${ly}" text-anchor="middle"
|
| 877 |
font-size="9" fill="${col}"
|
| 878 |
paint-order="stroke" stroke="rgba(10,8,18,.85)" stroke-width="3" stroke-linejoin="round"
|
| 879 |
font-family="Georgia,serif" font-style="italic">${b.note}</text>`;
|