{"id":13482089,"url":"https://github.com/d3plus/d3plus-text","last_synced_at":"2025-04-06T03:10:30.423Z","repository":{"id":36489245,"uuid":"40794855","full_name":"d3plus/d3plus-text","owner":"d3plus","description":"A smart SVG text box with line wrapping and automatic font size scaling.","archived":false,"fork":false,"pushed_at":"2024-03-26T15:22:13.000Z","size":1891,"stargazers_count":108,"open_issues_count":19,"forks_count":18,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-30T02:06:06.095Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d3plus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-16T01:19:27.000Z","updated_at":"2025-03-23T10:49:35.000Z","dependencies_parsed_at":"2024-05-04T05:32:30.387Z","dependency_job_id":"d29af734-af72-4d46-8198-71911e9bd665","html_url":"https://github.com/d3plus/d3plus-text","commit_stats":{"total_commits":500,"total_committers":9,"mean_commits":55.55555555555556,"dds":"0.11199999999999999","last_synced_commit":"8d62074a06608e838ac328a7e2e9bee990a1c11d"},"previous_names":[],"tags_count":88,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3plus%2Fd3plus-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3plus%2Fd3plus-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3plus%2Fd3plus-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3plus%2Fd3plus-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d3plus","download_url":"https://codeload.github.com/d3plus/d3plus-text/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:00:58.887Z","updated_at":"2025-04-06T03:10:30.405Z","avatar_url":"https://github.com/d3plus.png","language":"JavaScript","funding_links":[],"categories":["Miscellaneous"],"sub_categories":[],"readme":"# d3plus-text\n\nA smart SVG text box with line wrapping and automatic font size scaling.\n\n## Installing\n\nIf using npm, `npm install d3plus-text`. Otherwise, you can download the [latest release from GitHub](https://github.com/d3plus/d3plus-text/releases/latest) or load from a [CDN](https://cdn.jsdelivr.net/npm/d3plus-text@1).\n\n```js\nimport modules from \"d3plus-text\";\n```\n\nd3plus-text can be loaded as a standalone library or bundled as part of [D3plus](https://github.com/d3plus/d3plus). ES modules, AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3plus` global is exported:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/d3plus-text@1\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  console.log(d3plus);\n\u003c/script\u003e\n```\n\n## Examples\n\nLive examples can be found on [d3plus.org](https://d3plus.org/), which includes a collection of example visualizations using [d3plus-react](https://github.com/d3plus/d3plus-react/). These examples are powered by the [d3plus-storybook](https://github.com/d3plus/d3plus-storybook/) repo, and PRs are always welcome. :beers:\n\n## API Reference\n\n##### \n* [TextBox](#TextBox)\n\n##### \n* [fontExists](#fontExists) - Given either a single font-family or a list of fonts, returns the name of the first font that can be rendered, or `false` if none are installed on the user's machine.\n* [rtl](#rtl) - Returns `true` if the \u003chtml\u003e or \u003cbody\u003e element has either the \"dir\" HTML attribute or the \"direction\" CSS property set to \"rtl\". Accepts an optional DOM element as an argument, whose own inherited state will be evaluated rather than the default html/body logic.\n* [stringify](#stringify) - Coerces value into a String.\n* [strip](#strip) - Removes all non ASCII characters from a string.\n* [textSplit](#textSplit) - Splits a given sentence into an array of words.\n* [htmlDecode](#htmlDecode) - Strips HTML and \"un-escapes\" escape characters.\n* [textWidth](#textWidth) - Given a text string, returns the predicted pixel width of the string when placed into DOM.\n* [textWrap](#textWrap) - Based on the defined styles and dimensions, breaks a string into an array of strings for each line of text.\n* [titleCase](#titleCase) - Capitalizes the first letter of each word in a phrase/sentence.\n* [trim](#trim) - Cross-browser implementation of [trim](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim).\n* [trimLeft](#trimLeft) - Cross-browser implementation of [trimLeft](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimLeft).\n* [trimRight](#trimRight) - Cross-browser implementation of [trimRight](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimRight).\n\n---\n\n\u003ca name=\"TextBox\"\u003e\u003c/a\u003e\n#### **TextBox** [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L28)\n\n\nThis is a global class, and extends all of the methods and functionality of [\u003ccode\u003eBaseClass\u003c/code\u003e](https://github.com/d3plus/d3plus-common#BaseClass).\n\n\n* [TextBox](#TextBox) ⇐ [\u003ccode\u003eBaseClass\u003c/code\u003e](https://github.com/d3plus/d3plus-common#BaseClass)\n    * [new TextBox()](#new_TextBox_new)\n    * [.render([*callback*])](#TextBox.render)\n    * [.ariaHidden(*value*)](#TextBox.ariaHidden) ↩︎\n    * [.data([*data*])](#TextBox.data) ↩︎\n    * [.delay([*value*])](#TextBox.delay) ↩︎\n    * [.duration([*value*])](#TextBox.duration) ↩︎\n    * [.ellipsis([*value*])](#TextBox.ellipsis) ↩︎\n    * [.fontColor([*value*])](#TextBox.fontColor) ↩︎\n    * [.fontFamily([*value*])](#TextBox.fontFamily) ↩︎\n    * [.fontMax([*value*])](#TextBox.fontMax) ↩︎\n    * [.fontMin([*value*])](#TextBox.fontMin) ↩︎\n    * [.fontOpacity([*value*])](#TextBox.fontOpacity) ↩︎\n    * [.fontResize([*value*])](#TextBox.fontResize) ↩︎\n    * [.fontSize([*value*])](#TextBox.fontSize) ↩︎\n    * [.fontStroke([*value*])](#TextBox.fontStroke) ↩︎\n    * [.fontStrokeWidth([*value*])](#TextBox.fontStrokeWidth) ↩︎\n    * [.fontWeight([*value*])](#TextBox.fontWeight) ↩︎\n    * [.height([*value*])](#TextBox.height) ↩︎\n    * [.html([*value* \u0026#x3D; {\n                i: \u0026#x27;font-style: italic;\u0026#x27;,\n                em: \u0026#x27;font-style: italic;\u0026#x27;,\n                b: \u0026#x27;font-weight: bold;\u0026#x27;,\n                strong: \u0026#x27;font-weight: bold;\u0026#x27;\n            }])](#TextBox.html) ↩︎\n    * [.id([*value*])](#TextBox.id) ↩︎\n    * [.lineHeight([*value*])](#TextBox.lineHeight) ↩︎\n    * [.maxLines([*value*])](#TextBox.maxLines) ↩︎\n    * [.overflow([*value*])](#TextBox.overflow) ↩︎\n    * [.padding([*value*])](#TextBox.padding) ↩︎\n    * [.pointerEvents([*value*])](#TextBox.pointerEvents) ↩︎\n    * [.rotate([*value*])](#TextBox.rotate) ↩︎\n    * [.rotateAnchor(_)](#TextBox.rotateAnchor) ↩︎\n    * [.select([*selector*])](#TextBox.select) ↩︎\n    * [.split([*value*])](#TextBox.split) ↩︎\n    * [.text([*value*])](#TextBox.text) ↩︎\n    * [.textAnchor([*value*])](#TextBox.textAnchor) ↩︎\n    * [.verticalAlign([*value*])](#TextBox.verticalAlign) ↩︎\n    * [.width([*value*])](#TextBox.width) ↩︎\n    * [.x([*value*])](#TextBox.x) ↩︎\n    * [.y([*value*])](#TextBox.y) ↩︎\n\n\n\u003ca name=\"new_TextBox_new\" href=\"#new_TextBox_new\"\u003e#\u003c/a\u003e new **TextBox**()\n\nCreates a wrapped text box for each point in an array of data. See [this example](https://d3plus.org/examples/d3plus-text/getting-started/) for help getting started using the TextBox class.\n\n\n\n\n\n\u003ca name=\"TextBox.render\" href=\"#TextBox.render\"\u003e#\u003c/a\u003e TextBox.**render**([*callback*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L83)\n\nRenders the text boxes. If a *callback* is specified, it will be called once the shapes are done drawing.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox).\n\n\n\u003ca name=\"TextBox.ariaHidden\" href=\"#TextBox.ariaHidden\"\u003e#\u003c/a\u003e TextBox.**ariaHidden**(*value*) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L412)\n\nIf *value* is specified, sets the aria-hidden attribute to the specified function or string and returns the current class instance.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.data\" href=\"#TextBox.data\"\u003e#\u003c/a\u003e TextBox.**data**([*data*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L424)\n\nSets the data array to the specified array. A text box will be drawn for each object in the array.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.delay\" href=\"#TextBox.delay\"\u003e#\u003c/a\u003e TextBox.**delay**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L434)\n\nSets the animation delay to the specified number in milliseconds.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.duration\" href=\"#TextBox.duration\"\u003e#\u003c/a\u003e TextBox.**duration**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L444)\n\nSets the animation duration to the specified number in milliseconds.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.ellipsis\" href=\"#TextBox.ellipsis\"\u003e#\u003c/a\u003e TextBox.**ellipsis**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L458)\n\nSets the function that handles what to do when a line is truncated. It should return the new value for the line, and is passed 2 arguments: the String of text for the line in question, and the number of the line. By default, an ellipsis is added to the end of any line except if it is the first word that cannot fit (in that case, an empty string is returned).\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\ndefault accessor\n\n```js\nfunction(text, line) {\n  return line ? text.replace(/\\.|,$/g, \"\") + \"...\" : \"\";\n}\n```\n\n\n\u003ca name=\"TextBox.fontColor\" href=\"#TextBox.fontColor\"\u003e#\u003c/a\u003e TextBox.**fontColor**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L468)\n\nSets the font color to the specified accessor function or static string, which is inferred from the [DOM selection](#textBox.select) by default.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.fontFamily\" href=\"#TextBox.fontFamily\"\u003e#\u003c/a\u003e TextBox.**fontFamily**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L478)\n\nDefines the font-family to be used. The value passed can be either a *String* name of a font, a comma-separated list of font-family fallbacks, an *Array* of fallbacks, or a *Function* that returns either a *String* or an *Array*. If supplying multiple fallback fonts, the [fontExists](#fontExists) function will be used to determine the first available font on the client's machine.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.fontMax\" href=\"#TextBox.fontMax\"\u003e#\u003c/a\u003e TextBox.**fontMax**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L488)\n\nSets the maximum font size to the specified accessor function or static number (which corresponds to pixel units), which is used when [dynamically resizing fonts](#textBox.fontResize).\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.fontMin\" href=\"#TextBox.fontMin\"\u003e#\u003c/a\u003e TextBox.**fontMin**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L498)\n\nSets the minimum font size to the specified accessor function or static number (which corresponds to pixel units), which is used when [dynamically resizing fonts](#textBox.fontResize).\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.fontOpacity\" href=\"#TextBox.fontOpacity\"\u003e#\u003c/a\u003e TextBox.**fontOpacity**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L508)\n\nSets the font opacity to the specified accessor function or static number between 0 and 1.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.fontResize\" href=\"#TextBox.fontResize\"\u003e#\u003c/a\u003e TextBox.**fontResize**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L518)\n\nToggles font resizing, which can either be defined as a static boolean for all data points, or an accessor function that returns a boolean. See [this example](http://d3plus.org/examples/d3plus-text/resizing-text/) for a side-by-side comparison.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.fontSize\" href=\"#TextBox.fontSize\"\u003e#\u003c/a\u003e TextBox.**fontSize**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L528)\n\nSets the font size to the specified accessor function or static number (which corresponds to pixel units), which is inferred from the [DOM selection](#textBox.select) by default.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.fontStroke\" href=\"#TextBox.fontStroke\"\u003e#\u003c/a\u003e TextBox.**fontStroke**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L538)\n\nSets the font stroke color for the rendered text.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.fontStrokeWidth\" href=\"#TextBox.fontStrokeWidth\"\u003e#\u003c/a\u003e TextBox.**fontStrokeWidth**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L548)\n\nSets the font stroke width for the rendered text.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.fontWeight\" href=\"#TextBox.fontWeight\"\u003e#\u003c/a\u003e TextBox.**fontWeight**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L558)\n\nSets the font weight to the specified accessor function or static number, which is inferred from the [DOM selection](#textBox.select) by default.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.height\" href=\"#TextBox.height\"\u003e#\u003c/a\u003e TextBox.**height**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L572)\n\nSets the height for each box to the specified accessor function or static number.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\ndefault accessor\n\n```js\nfunction(d) {\n  return d.height || 200;\n}\n```\n\n\n\u003ca name=\"TextBox.html\" href=\"#TextBox.html\"\u003e#\u003c/a\u003e TextBox.**html**([*value* \u0026#x3D; {\n                i: \u0026#x27;font-style: italic;\u0026#x27;,\n                em: \u0026#x27;font-style: italic;\u0026#x27;,\n                b: \u0026#x27;font-weight: bold;\u0026#x27;,\n                strong: \u0026#x27;font-weight: bold;\u0026#x27;\n            }]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L587)\n\nConfigures the ability to render simple HTML tags. Defaults to supporting `\u003cb\u003e`, `\u003cstrong\u003e`, `\u003ci\u003e`, and `\u003cem\u003e`, set to false to disable or provide a mapping of tags to svg styles\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.id\" href=\"#TextBox.id\"\u003e#\u003c/a\u003e TextBox.**id**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L602)\n\nDefines the unique id for each box to the specified accessor function or static number.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\ndefault accessor\n\n```js\nfunction(d, i) {\n  return d.id || i + \"\";\n}\n```\n\n\n\u003ca name=\"TextBox.lineHeight\" href=\"#TextBox.lineHeight\"\u003e#\u003c/a\u003e TextBox.**lineHeight**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L612)\n\nSets the line height to the specified accessor function or static number, which is 1.2 times the [font size](#textBox.fontSize) by default.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.maxLines\" href=\"#TextBox.maxLines\"\u003e#\u003c/a\u003e TextBox.**maxLines**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L622)\n\nRestricts the maximum number of lines to wrap onto, which is null (unlimited) by default.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.overflow\" href=\"#TextBox.overflow\"\u003e#\u003c/a\u003e TextBox.**overflow**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L632)\n\nSets the text overflow to the specified accessor function or static boolean.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.padding\" href=\"#TextBox.padding\"\u003e#\u003c/a\u003e TextBox.**padding**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L642)\n\nSets the padding to the specified accessor function, CSS shorthand string, or static number, which is 0 by default.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.pointerEvents\" href=\"#TextBox.pointerEvents\"\u003e#\u003c/a\u003e TextBox.**pointerEvents**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L652)\n\nSets the pointer-events to the specified accessor function or static string.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.rotate\" href=\"#TextBox.rotate\"\u003e#\u003c/a\u003e TextBox.**rotate**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L662)\n\nSets the rotate percentage for each box to the specified accessor function or static string.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.rotateAnchor\" href=\"#TextBox.rotateAnchor\"\u003e#\u003c/a\u003e TextBox.**rotateAnchor**(_) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L672)\n\nSets the anchor point around which to rotate the text box.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.select\" href=\"#TextBox.select\"\u003e#\u003c/a\u003e TextBox.**select**([*selector*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L682)\n\nSets the SVG container element to the specified d3 selector or DOM element. If not explicitly specified, an SVG element will be added to the page for use.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.split\" href=\"#TextBox.split\"\u003e#\u003c/a\u003e TextBox.**split**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L692)\n\nSets the word split behavior to the specified function, which when passed a string is expected to return that string split into an array of words.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.text\" href=\"#TextBox.text\"\u003e#\u003c/a\u003e TextBox.**text**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L706)\n\nSets the text for each box to the specified accessor function or static string.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\ndefault accessor\n\n```js\nfunction(d) {\n  return d.text;\n}\n```\n\n\n\u003ca name=\"TextBox.textAnchor\" href=\"#TextBox.textAnchor\"\u003e#\u003c/a\u003e TextBox.**textAnchor**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L716)\n\nSets the horizontal text anchor to the specified accessor function or static string, whose values are analagous to the SVG [text-anchor](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-anchor) property.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.verticalAlign\" href=\"#TextBox.verticalAlign\"\u003e#\u003c/a\u003e TextBox.**verticalAlign**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L726)\n\nSets the vertical alignment to the specified accessor function or static string. Accepts `\"top\"`, `\"middle\"`, and `\"bottom\"`.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\n\n\n\u003ca name=\"TextBox.width\" href=\"#TextBox.width\"\u003e#\u003c/a\u003e TextBox.**width**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L740)\n\nSets the width for each box to the specified accessor function or static number.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\ndefault accessor\n\n```js\nfunction(d) {\n  return d.width || 200;\n}\n```\n\n\n\u003ca name=\"TextBox.x\" href=\"#TextBox.x\"\u003e#\u003c/a\u003e TextBox.**x**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L754)\n\nSets the x position for each box to the specified accessor function or static number. The number given should correspond to the left side of the textBox.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\ndefault accessor\n\n```js\nfunction(d) {\n  return d.x || 0;\n}\n```\n\n\n\u003ca name=\"TextBox.y\" href=\"#TextBox.y\"\u003e#\u003c/a\u003e TextBox.**y**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/TextBox.js#L768)\n\nSets the y position for each box to the specified accessor function or static number. The number given should correspond to the top side of the textBox.\n\n\nThis is a static method of [\u003ccode\u003eTextBox\u003c/code\u003e](#TextBox), and is chainable with other methods of this Class.\ndefault accessor\n\n```js\nfunction(d) {\n  return d.y || 0;\n}\n```\n\n---\n\n\u003ca name=\"fontExists\"\u003e\u003c/a\u003e\n#### d3plus.**fontExists**(font) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/fontExists.js#L10)\n\nGiven either a single font-family or a list of fonts, returns the name of the first font that can be rendered, or `false` if none are installed on the user's machine.\n\n\nThis is a global function.\n\n---\n\n\u003ca name=\"rtl\"\u003e\u003c/a\u003e\n#### d3plus.**rtl**([elem]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/rtl.js#L5)\n\nReturns `true` if the \u003chtml\u003e or \u003cbody\u003e element has either the \"dir\" HTML attribute or the \"direction\" CSS property set to \"rtl\". Accepts an optional DOM element as an argument, whose own inherited state will be evaluated rather than the default html/body logic.\n\n\nThis is a global function.\n\n---\n\n\u003ca name=\"stringify\"\u003e\u003c/a\u003e\n#### d3plus.**stringify**(value) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/stringify.js#L1)\n\nCoerces value into a String.\n\n\nThis is a global function.\n\n---\n\n\u003ca name=\"strip\"\u003e\u003c/a\u003e\n#### d3plus.**strip**(value, [spacer]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/strip.js#L18)\n\nRemoves all non ASCII characters from a string.\n\n\nThis is a global function.\n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| value | \u003ccode\u003eString\u003c/code\u003e |  |  |\n| [spacer] | \u003ccode\u003eString\u003c/code\u003e | \u003ccode\u003e\u0026quot;-\u0026quot;\u003c/code\u003e | The character(s) to be used in place of spaces. |\n\n\n---\n\n\u003ca name=\"textSplit\"\u003e\u003c/a\u003e\n#### d3plus.**textSplit**(sentence) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textSplit.js#L50)\n\nSplits a given sentence into an array of words.\n\n\nThis is a global function.\n\n---\n\n\u003ca name=\"htmlDecode\"\u003e\u003c/a\u003e\n#### d3plus.**htmlDecode**(input) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWidth.js#L5)\n\nStrips HTML and \"un-escapes\" escape characters.\n\n\nThis is a global function.\n\n---\n\n\u003ca name=\"textWidth\"\u003e\u003c/a\u003e\n#### d3plus.**textWidth**(text, [style]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWidth.js#L12)\n\nGiven a text string, returns the predicted pixel width of the string when placed into DOM.\n\n\nThis is a global function.\n\n| Param | Type | Description |\n| --- | --- | --- |\n| text | \u003ccode\u003eString\u003c/code\u003e \\| \u003ccode\u003eArray\u003c/code\u003e | Can be either a single string or an array of strings to analyze. |\n| [style] | \u003ccode\u003eObject\u003c/code\u003e | An object of CSS font styles to apply. Accepts any of the valid [CSS font property](http://www.w3schools.com/cssref/pr_font_font.asp) values. |\n\n\n---\n\n\u003ca name=\"textWrap\"\u003e\u003c/a\u003e\n#### d3plus.**textWrap**() [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWrap.js#L6)\n\nBased on the defined styles and dimensions, breaks a string into an array of strings for each line of text.\n\n\nThis is a global function.\n\n\n* [textWrap()](#textWrap)\n    * [.fontFamily([*value*])](#textWrap.fontFamily)\n    * [.fontSize([*value*])](#textWrap.fontSize)\n    * [.fontWeight([*value*])](#textWrap.fontWeight)\n    * [.height([*value*])](#textWrap.height)\n    * [.lineHeight([*value*])](#textWrap.lineHeight)\n    * [.maxLines([*value*])](#textWrap.maxLines)\n    * [.overflow([*value*])](#textWrap.overflow)\n    * [.split([*value*])](#textWrap.split)\n    * [.width([*value*])](#textWrap.width)\n\n\n\u003ca name=\"textWrap.fontFamily\" href=\"#textWrap.fontFamily\"\u003e#\u003c/a\u003e d3plus..**fontFamily**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWrap.js#L89)\n\nIf *value* is specified, sets the font family accessor to the specified function or string and returns this generator. If *value* is not specified, returns the current font family.\n\n\nThis is a static method of [\u003ccode\u003etextWrap\u003c/code\u003e](#textWrap).\n\n\n\u003ca name=\"textWrap.fontSize\" href=\"#textWrap.fontSize\"\u003e#\u003c/a\u003e d3plus..**fontSize**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWrap.js#L98)\n\nIf *value* is specified, sets the font size accessor to the specified function or number and returns this generator. If *value* is not specified, returns the current font size.\n\n\nThis is a static method of [\u003ccode\u003etextWrap\u003c/code\u003e](#textWrap).\n\n\n\u003ca name=\"textWrap.fontWeight\" href=\"#textWrap.fontWeight\"\u003e#\u003c/a\u003e d3plus..**fontWeight**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWrap.js#L107)\n\nIf *value* is specified, sets the font weight accessor to the specified function or number and returns this generator. If *value* is not specified, returns the current font weight.\n\n\nThis is a static method of [\u003ccode\u003etextWrap\u003c/code\u003e](#textWrap).\n\n\n\u003ca name=\"textWrap.height\" href=\"#textWrap.height\"\u003e#\u003c/a\u003e d3plus..**height**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWrap.js#L116)\n\nIf *value* is specified, sets height limit to the specified value and returns this generator. If *value* is not specified, returns the current value.\n\n\nThis is a static method of [\u003ccode\u003etextWrap\u003c/code\u003e](#textWrap).\n\n\n\u003ca name=\"textWrap.lineHeight\" href=\"#textWrap.lineHeight\"\u003e#\u003c/a\u003e d3plus..**lineHeight**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWrap.js#L125)\n\nIf *value* is specified, sets the line height accessor to the specified function or number and returns this generator. If *value* is not specified, returns the current line height accessor, which is 1.1 times the [font size](#textWrap.fontSize) by default.\n\n\nThis is a static method of [\u003ccode\u003etextWrap\u003c/code\u003e](#textWrap).\n\n\n\u003ca name=\"textWrap.maxLines\" href=\"#textWrap.maxLines\"\u003e#\u003c/a\u003e d3plus..**maxLines**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWrap.js#L134)\n\nIf *value* is specified, sets the maximum number of lines allowed when wrapping.\n\n\nThis is a static method of [\u003ccode\u003etextWrap\u003c/code\u003e](#textWrap).\n\n\n\u003ca name=\"textWrap.overflow\" href=\"#textWrap.overflow\"\u003e#\u003c/a\u003e d3plus..**overflow**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWrap.js#L143)\n\nIf *value* is specified, sets the overflow to the specified boolean and returns this generator. If *value* is not specified, returns the current overflow value.\n\n\nThis is a static method of [\u003ccode\u003etextWrap\u003c/code\u003e](#textWrap).\n\n\n\u003ca name=\"textWrap.split\" href=\"#textWrap.split\"\u003e#\u003c/a\u003e d3plus..**split**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWrap.js#L152)\n\nIf *value* is specified, sets the word split function to the specified function and returns this generator. If *value* is not specified, returns the current word split function.\n\n\nThis is a static method of [\u003ccode\u003etextWrap\u003c/code\u003e](#textWrap).\n\n\n\u003ca name=\"textWrap.width\" href=\"#textWrap.width\"\u003e#\u003c/a\u003e d3plus..**width**([*value*]) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/textWrap.js#L161)\n\nIf *value* is specified, sets width limit to the specified value and returns this generator. If *value* is not specified, returns the current value.\n\n\nThis is a static method of [\u003ccode\u003etextWrap\u003c/code\u003e](#textWrap).\n\n---\n\n\u003ca name=\"titleCase\"\u003e\u003c/a\u003e\n#### d3plus.**titleCase**(str) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/titleCase.js#L6)\n\nCapitalizes the first letter of each word in a phrase/sentence.\n\n\nThis is a global function.\n\n---\n\n\u003ca name=\"trim\"\u003e\u003c/a\u003e\n#### d3plus.**trim**(str) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/trim.js#L1)\n\nCross-browser implementation of [trim](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim).\n\n\nThis is a global function.\n\n---\n\n\u003ca name=\"trimLeft\"\u003e\u003c/a\u003e\n#### d3plus.**trimLeft**(str) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/trim.js#L10)\n\nCross-browser implementation of [trimLeft](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimLeft).\n\n\nThis is a global function.\n\n---\n\n\u003ca name=\"trimRight\"\u003e\u003c/a\u003e\n#### d3plus.**trimRight**(str) [\u003c\u003e](https://github.com/d3plus/d3plus-text/blob/master/src/trim.js#L19)\n\nCross-browser implementation of [trimRight](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimRight).\n\n\nThis is a global function.\n\n---\n\n\n\n###### \u003csub\u003eDocumentation generated on Wed, 06 Mar 2024 16:14:10 GMT\u003c/sub\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3plus%2Fd3plus-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd3plus%2Fd3plus-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3plus%2Fd3plus-text/lists"}