In Mermaid's class diagrams, the nodeSpacing and rankSpacing configuration options are intended to control the spacing between nodes. However, there have been reports of these settings not functioning as expected in certain contexts.
For instance, in flowchart diagrams, users have observed that nodeSpacing and rankSpacing do not apply when nodes are placed within subgraphs. This issue was documented in a GitHub issue, where the user noted that while these settings work for nodes outside subgraphs, they fail to affect spacing within subgraphs[1].
Additionally, a pull request titled "Flowchart: Apply nodeSpacing/rankSpacing config to subgraphs" was merged in February 2024, indicating that this specific issue was addressed for flowchart diagrams[2].
Regarding class diagrams, the official Mermaid documentation lists nodeSpacing and rankSpacing as configurable properties[3]. However, if these settings are not producing the desired effect in your class diagrams, it could be due to a similar issue that was previously identified in flowchart diagrams.
To address this:
-
Update Mermaid: Ensure you're using the latest version of Mermaid, as updates often include bug fixes and improvements.
-
Check Configuration Syntax: Verify that your configuration settings are correctly applied. For example, configurations can be set using the %%{init: {'classDiagram': {'nodeSpacing': 50, 'rankSpacing': 50}}}%% directive at the beginning of your diagram code.
-
Consult Documentation: Review the Mermaid class diagram configuration schema[3] to ensure you're using the correct properties and values.
-
Report Issues: If the problem persists, consider reporting it on the Mermaid GitHub repository. Providing specific details about your configuration and the issues you're encountering can help the developers address the problem more effectively.
By following these steps, you can help identify whether the issue is due to a configuration error, a bug, or a limitation within the current implementation of Mermaid's class diagrams.