d3plus / d3plus-text

A smart SVG text box with line wrapping and automatic font size scaling.
MIT License
105 stars 19 forks source link

TextBox with auto resize bug #79

Closed grozadanut closed 6 years ago

grozadanut commented 6 years ago

Expected Behavior

When using the TextBox with the fontResize set to true and passing a width and height, I expect the text to be wrapped to that container. In some cases depending on the text length and having a small width and big height, that doesn't happen.

Current Behavior

The text is enlarged way to much and goes out of the container bounds.

Steps to Reproduce (for bugs)

Provided a JSFiddle that reproduced the bug here: https://jsfiddle.net/74pg8we4/10/ Note that the big ok is the wrong behaviour, the small okkkkkk is what should happen.

image

nbond211 commented 6 years ago

Hey @gdany95 ! The issue is with the values you are supplying to fontMin and fontMax. The values should be numbers, or accessor functions that return numbers, not strings. Try changing your values to numbers and that should resolve the issue.

I updated the docs for the fontSize, fontMin, and fontMax methods to clarify that the static number you supply corresponds to a unit in pixels.

Hope this helps!