You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* textOverflow
* more textOverflow options; work with utf8 chars rather than string indices
* format
* the measure for … determines how some strings are clipped
* clip-end, ellipsis-end
* roll back the changes to lineWrap, treat unknown char width as 1em, fix clipping
* monospace emoji is 1 char
* tests
* monospace emoji
* undo changes to the metric
linearize the overflow function
* tests
* restore comment, clean up
* clarify the role of this function: it returns the length of the current character; should allow to generalize to multi-code point chars.
* cleaner
* glyph length
* test readCharacter
* isPictographic
* tweak
* cut
* more rigorous clip tests
* add failing tests
* better middle clip; fix names
* center ellipsis
* comments
* splitText
* separate splitting from clipping
* splitLines, clipLine
* inferFontVariant
* maybeTextOverflow
* widthof(text) shorthand
* include ellipsis in default width map
* add a multiline film title to the test, and remove obsolete comments
* optimize and improve readability
* Update README
---------
Co-authored-by: Mike Bostock <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2030,6 +2030,7 @@ The following text-specific constant options are also supported:
2030
2030
* **lineAnchor** - the line anchor for vertical position; top, bottom, or middle
2031
2031
* **lineHeight** - the line height in ems; defaults to 1
2032
2032
* **lineWidth** - the line width in ems, for wrapping; defaults to Infinity
2033
+
* **textOverflow** - how to wrap or clip lines longer than the specified line width
2033
2034
* **monospace** - if true, changes the default fontFamily and metrics to monospace
2034
2035
* **fontFamily** - the font name; defaults to [system-ui](https://drafts.csswg.org/css-fonts-4/#valdef-font-family-system-ui)
2035
2036
* **fontSize** - the font size in pixels; defaults to 10
@@ -2041,6 +2042,15 @@ The following text-specific constant options are also supported:
2041
2042
2042
2043
If a **lineWidth** is specified, input text values will be wrapped as needed to fit while preserving existing newlines. The line wrapping implementation is rudimentary; for non-ASCII, non-U.S. English text, or for when a different font is used, you may get better results by hard-wrapping the text yourself (by supplying newlines in the input). If the **monospace** option is truthy, the default **fontFamily** changes to “ui-monospace, monospace”, and the **lineWidth** option is interpreted as characters (ch) rather than ems.
2043
2044
2045
+
The **textOverflow** option can be used to truncate lines of text longer than the given **lineWidth**. If the mark does not have a **title** channel, a title with the non-truncated text is also added. The following **textOverflow** values are supported:
* *clip* or *clip-end* - remove characters from the end
2049
+
* *clip-start* - remove characters from the start
2050
+
* *ellipsis* or *ellipsis-end* - replace characters from the end with an ellipsis (…)
2051
+
* *ellipsis-start* - replace characters from the start with an ellipsis (…)
2052
+
* *ellipsis-middle* - replace characters from the middle with an ellipsis (…)
2053
+
2044
2054
The **fontSize** and **rotate** options can be specified as either channels or constants. When fontSize or rotate is specified as a number, it is interpreted as a constant; otherwise it is interpreted as a channel.
2045
2055
2046
2056
If the **frameAnchor** option is not specified, then **textAnchor** and **lineAnchor** default to middle. Otherwise, **textAnchor** defaults to start if **frameAnchor** is on the left, end if **frameAnchor** is on the right, and otherwise middle. Similarly, **lineAnchor** defaults to top if **frameAnchor** is on the top, bottom if **frameAnchor** is on the bottom, and otherwise middle.
0 commit comments