-
Notifications
You must be signed in to change notification settings - Fork 853
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attributes.textWrap: enable calc() expression for width and height (#…
- Loading branch information
1 parent
bff7079
commit 085efce
Showing
4 changed files
with
100 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
<p>Valid only for <code data-lang="svg"><text></code> subelements.</p> | ||
|
||
<p>Similar to the <code>text</code> <a href="#dia.attributes.text">attribute</a>, except the provided string is automatically wrapped to fit within the reference bounding box.</p> | ||
<p>It enables the text wrapping for the <code>text</code> <a href="#dia.attributes.text">attribute</a> (automatically breaks the lines to fit within the reference bounding box).</p> | ||
|
||
<p>Expects an object with a <code>text</code> property and optional <code>width</code> and <code>height</code>, which can adjust the final size of the wrapped text. Negative values decrease the dimension (e.g. to add padding around the wrapped text); positive values increase the dimension. Percentage values are accepted as well.</p> | ||
<p>It expects an object with several optional properties.</p> | ||
|
||
<p>If the text cannot fit into the bounding box as specified, the overflowing words are cut off. If the <code>ellipsis</code> option is provided, an ellipsis string is inserted before the cutoff. If no words can fit into the bounding box at all, no text is inserted. See <a href="#util.breakText">util.breakText</a> for more info.</p> | ||
<p><code>width</code> and <code>height</code> adjust the final size of the wrapped text. | ||
<ul> | ||
<li>If not provided, the text is wrapped to fit the reference bounding box</li> | ||
<li>It can be a <a href="#dia.attributes.calc">calc()</a> expression (e.g. <code>'calc(w - 10)'</code>)</li> | ||
<li>Percentage expression (e.g. <code>'50%'</code> is half the width or height)</li> | ||
<li>A positive number is an absolute dimension (e.g <code>50</code> fits the text within 50 pixels)</li> | ||
<li>A negative number is a relative dimension (e.g. <code>-10</code> is an equivalent to <code>'calc(w - 10)'</code> resp. <code>'calc(h - 10)'</code>)</li> | ||
<li>Use <code>null</code> to disable wrapping in a given dimension</li> | ||
</ul> | ||
</p> | ||
|
||
<pre><code>textWrap: { | ||
<p>If the text cannot fit into the bounding box as specified, the overflowing words are cut off. | ||
If the <code>ellipsis</code> option is provided, an ellipsis string is inserted before the cutoff. | ||
If no words can fit into the bounding box at all, no text is inserted. | ||
</p> | ||
|
||
<pre><code>element1.attr('label', { | ||
text: 'Text to wrap.', | ||
textWrap: { | ||
width: 'calc(w - 10)', // reference width minus 10 | ||
height: null', // no height restriction | ||
} | ||
}); | ||
|
||
element2.attr('label', { | ||
text: 'lorem ipsum dolor sit amet consectetur adipiscing elit', | ||
width: -10, // reference width minus 10 | ||
height: '50%', // half of the reference height | ||
ellipsis: true // could also be a custom string, e.g. '...!?' | ||
}</code></pre> | ||
textWrap: { | ||
width: -10, // reference width minus 10 | ||
height: '50%', // half of the reference height | ||
ellipsis: true // could also be a custom string, e.g. '...!?' | ||
} | ||
});</code></pre> | ||
|
||
<p>For more info see <a href="#util.breakText">util.breakText</a>.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters