Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ERD fontSize config to an integer to prevent NaN errors #1379

Merged
merged 1 commit into from
May 1, 2020

Conversation

spopida
Copy link
Member

@spopida spopida commented Apr 30, 2020

馃搼 Summary

Change the fontSize config from a string to an integer to prevent NaN errors

Resolves #1362

馃搹 Design Decisions

This was a simple fix - the original code expressed the fontSize option for ERDs (in mermaidAPI.js) as a string, for example '12px'. But during positioning and sizing of nodes this value was used in simple arithmetic (e.g. to add padding). In fact that code itself was not necessary because the position and sizing of nodes is taken care of elsewhere, however the attempt to add a string to a padding factor was causing NaN errors during rendering. These errors were not fatal, and rendering worked anyway, but the errors needed to be sorted. This was as simple as:

  • Change the config option to an integer in mermaidAPI.js (which is consistent with other diagram types)
  • Change a few lines of code in the renderer to get rid of the unnecessary padding calculation
  • Change a couple of lines of code in the renderer to add the 'px' suffix to the style attribute of entity names and relationship labels

馃搵 Tasks

Make sure you

  • 馃摉 have read the contribution guidelines
  • 馃捇 have added unit/e2e tests (if appropriate)
  • 馃敄 targeted develop branch

@knsv knsv merged commit 4276fc0 into mermaid-js:develop May 1, 2020
@spopida spopida deleted the bug/1362_NaN_rendering_ERD branch May 6, 2020 16:31
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.

ERD: <text> attribute y: Expected length, "NaN"
2 participants