Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Dynamically change font size for long text
raffi
<p>Hi,</p><p> </p><p>I have a table with a fixed size for the columns.</p><p> </p><p>When the text is too long it normally is wrapped, but I want to avoid that and change the font size instead (keeping the text always on one line).</p><p> </p><p>In scripting, I know how to change the font size but didn't find a way to know when the text is exceeding the cell (wrapped) or not, and how to determine the size suitable to make the text fit in the cell.</p><p> </p><p>I hope you can help me out.</p><p> </p><p>Kind Regards, Raffi</p>
Find more posts tagged with
Comments
lnix
<p>One way of doing this would be shrink the text size if the string is longer than a certain number of characters.</p><p> </p><p>Here's some pseudo code to do that:</p><pre class="_prettyXprint _lang-js">function shrink(longStr, chrWidth){ if (longStr) { strLen = longStr.length; if (strLen >= chrWidth) { //reduce text size } } } </pre><div>Then by placing the following code into the Expression Builder the output will break at the desired number of characters.</div><div>shrink(inputString, widthDesired);</div><div> </div><div>*Example: shrink(dataSetRow["PRODUCTDESCRIPTION"], 20) // Will shrink if longer than 20 characters</div>
raffi
<p>Dear Inix,</p><p> </p><p>Thanks a lot for your reply.</p><p> </p><p>However, my problem is how to determine whether the text is exceeding the cell and then make it smaller just enough to fit on the cell. Is there a way to find out whether the text has been wrapped ?</p>