Skip to content

Fix ERD diagram circular layout for schemas with many tables#1255

Draft
Copilot wants to merge 5 commits intomasterfrom
copilot/fix-erd-diagram-arrangement
Draft

Fix ERD diagram circular layout for schemas with many tables#1255
Copilot wants to merge 5 commits intomasterfrom
copilot/fix-erd-diagram-arrangement

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 12, 2025

ERD diagrams with many tables (e.g., MySQL's performance_schema with 80+ tables) rendered as tightly packed circles at all zoom levels, making them difficult to read and arrange.

Root Cause

The initial circular layout radius calculation in GraphLayout.createCircle() was undersized:

// Old: insufficient spacing
const radius = (nodeCount * nodeRadius) / (2 * Math.PI) + nodeRadius;

This formula used maximum node radius without accounting for actual node dimensions or adequate spacing between nodes.

Changes

  • Calculate radius based on total perimeter needed for all nodes
  • Use average node diameter instead of maximum radius
  • Apply adaptive multiplier: 1.5× for >20 nodes, 1.2× otherwise
  • Increase margin allocation from implicit 2× to 4× NODE_MARGIN
// New: proper spacing calculation
const avgNodeDiameter = _.mean(circleSortedNodes.map(x => x.radius * 2)) || 0;
const totalPerimeter = nodeCount * (avgNodeDiameter + NODE_MARGIN * 4);
const radiusMultiplier = nodeCount > 20 ? 1.5 : 1.2;
const radius = Math.max(
  (totalPerimeter / (2 * Math.PI)) * radiusMultiplier,
  nodeRadius * 3
);

The larger initial radius gives the springy force-directed algorithm sufficient space to distribute nodes into more readable layouts.

Original prompt

This section details on the original issue you should resolve

<issue_title>BUG: ERD diagram always auto arrange as a circle</issue_title>
<issue_description>Describe the bug
ERD diagram always auto arrange as a circle. Even when I zoom in then click arrange, it still force renders as a circle.

To Reproduce
Steps to reproduce the behavior:

  1. Connect to a database, in my case, I'm using performance_schema of mysql
  2. Right click to performance_schema, click on "Show diagram"
  3. See error

Expected behavior
Able to arrange as row and column or grid

Screenshots

  1. Zoom - 10%
    image
  2. Zoom - 60%
    image

Version Information (please complete the following information):

  • OS: Ubuntu
  • App Version: 5.3.4
  • Install source: Docker, deploying on bare metal k8s
  • Type - Web/Application
  • Database engine: MySQL
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits November 12, 2025 08:54
Co-authored-by: Stelinkaa <82719799+Stelinkaa@users.noreply.github.com>
Co-authored-by: Stelinkaa <82719799+Stelinkaa@users.noreply.github.com>
Co-authored-by: Stelinkaa <82719799+Stelinkaa@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ERD diagram auto arrange issue Fix ERD diagram circular layout for schemas with many tables Nov 12, 2025
Copilot AI requested a review from Stelinkaa November 12, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: ERD diagram always auto arrange as a circle

2 participants