Repository navigation
Conversation
… grid to_canvas sized each community's group box for a ceil(sqrt(n))-column grid (w = 220*ceil(sqrt(n))) but the node-placement loop hardcoded 3 columns, so the cards spanned only ~600px no matter how large the community while the box kept widening. Any community larger than ~9 members rendered as a cramped 3-wide strip squeezed into the left of an over-wide, mostly-empty box: for 25 members the cards filled ~600px of an 1100px-wide box and wrapped into 9 rows where 5 would do. Compute the column count (inner_cols = ceil(sqrt(n))) once per community and reuse it for both the box dimensions (w/h) and the placement loop, so the cards fill the box. The height now divides by inner_cols too (it had used ceil(n/3)), matching the width. inner_cols floors at 1, so empty/size-1 communities keep their 600x400 minimum with no divide-by-zero. Purely cosmetic, no data change. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…columns # Conflicts: # CHANGELOG.md
…id (#1452) to_canvas sized each community group box for a ceil(sqrt(n))-column grid but the placement loop hardcoded 3 columns, so any community bigger than ~9 members rendered as a cramped 3-wide strip in an over-wide, mostly-empty box (and the box width/height didn't even agree — w used sqrt(n), h used /3). The column count is now computed once per community (inner_cols) and reused for box width, box height, and card placement, so the cards fill the box. Cosmetic, no data change. Ported from PR #1459 by @TPAteeq onto current v8 (clean: only the grid math changed, the #1457 dedup helper is untouched). Verified the geometry on a real canvas: n=25 -> 5x5 grid with every card inside its box; n=10 -> 4 columns. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Thanks @TPAteeq — this is a real bug and the fix is right. The group box was sized for a Landed on Closing as merged-by-port. Appreciate the contribution. |
…id (Graphify-Labs#1452) to_canvas sized each community group box for a ceil(sqrt(n))-column grid but the placement loop hardcoded 3 columns, so any community bigger than ~9 members rendered as a cramped 3-wide strip in an over-wide, mostly-empty box (and the box width/height didn't even agree — w used sqrt(n), h used /3). The column count is now computed once per community (inner_cols) and reused for box width, box height, and card placement, so the cards fill the box. Cosmetic, no data change. Ported from PR Graphify-Labs#1459 by @TPAteeq onto current v8 (clean: only the grid math changed, the Graphify-Labs#1457 dedup helper is untouched). Verified the geometry on a real canvas: n=25 -> 5x5 grid with every card inside its box; n=10 -> 4 columns. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Closes #1452.
to_canvas()sizes each community's group box for aceil(sqrt(n))-columngrid (
w = 220 * ceil(sqrt(n))), but the node-placement loop that fills thebox hardcoded exactly 3 columns (
col = m_idx % 3). So the cards spanonly ~600px (3 cards wide) no matter how large the community, while the box
keeps widening with
sqrt(n)— for any community larger than ~9 members theresult is a cramped 3-wide strip squeezed into the left of an over-wide,
mostly-empty box. (The height term was inconsistent in the other direction:
it used
ceil(n / 3)while the width usedsqrt(n), so the two dimensionsdidn't even agree on a column count — the height happened to track the
3-wide layout's rows, so it's the width that's left empty.)
Concretely, a 25-member community:
Purely cosmetic (no data loss), but it makes the canvas effectively
unreadable for any non-trivial community — the primary use case for the
canvas output is visually browsing graph structure.
Fix
Compute the column count once per community
(
inner_cols = max(1, ceil(sqrt(n)))) and reuse that single value for boththe box dimensions and the placement loop, instead of recomputing
sqrt(n)in one place and hardcoding
3in the other:w = max(600, 220 * inner_cols)h = max(400, 100 * ceil(n / inner_cols) + 120)— now divides by the sameinner_colsthe width uses, so the two dimensions agree.col = m_idx % inner_cols,row = m_idx // inner_cols.inner_colsfloors at 1, so empty / single-node communities keep theirexisting 600×400 minimum and there's no divide-by-zero. This matches the
reporter's suggested fix.
Testing
test_to_canvas_node_grid_matches_box_columnsintests/test_export.py, over a perfect-square (25 → 5×5) and a non-square(10 → 4 cols with a partial last row) member count. It pins the column
and row counts (the load-bearing checks: distinct card x/y positions must
equal
ceil(sqrt(n))andceil(n / cols)) and that every card sits insideits box. Both counts are red on the pre-fix code for both n
(n=25: cols 3≠5, rows 9≠5), green after.
tests/test_export.py(28) plus the canvas/obsidian-adjacent suites pass.filled 5×5 grid inside a 1100×620 box instead of a 3-wide strip occupying
~600px of an 1100×1020 box.