@@ -20,10 +20,25 @@ export interface TextOptions extends MarkOptions {
2020 y ?: ChannelValueSpec ;
2121 text ?: ChannelValue ;
2222 frameAnchor ?: FrameAnchor ;
23+
24+ /**
25+ * The [text anchor](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-anchor) for horizontal position; start, end, or middle.
26+ */
2327 textAnchor ?: TextAnchor ;
28+
29+ /**
30+ * The line anchor for vertical position; top, bottom, or middle.
31+ */
2432 lineAnchor ?: LineAnchor ;
33+
34+ /** The line height in ems; defaults to 1. */
2535 lineHeight ?: number ;
36+
37+ /**
38+ * The line width in ems, for wrapping.
39+ */
2640 lineWidth ?: number ;
41+
2742 /**
2843 * The **textOverflow** option can be used to truncate lines of text longer
2944 * than the given **lineWidth**. If the mark does not have a **title**
@@ -41,14 +56,56 @@ export interface TextOptions extends MarkOptions {
4156 * (…)
4257 */
4358 textOverflow ?: TextOverflow ;
59+
4460 /** If true, changes the default fontFamily and metrics to monospace. */
4561 monospace ?: boolean ;
46- /** The font family, *e.g.* "'Atkinson Hyperlegible',Roboto,sans-serif" */
62+
63+ /** The font name; defaults to
64+ * [system-ui](https://drafts.csswg.org/css-fonts-4/#valdef-font-family-system-ui).
65+ * For example, to use a custom font stack:
66+ *
67+ * ```js
68+ * Plot.text(labels, {
69+ * x: "x", y: "y", text: "label",
70+ * fontFamily: "'Atkinson Hyperlegible',Roboto,sans-serif",
71+ * })
72+ * ```
73+ */
4774 fontFamily ?: string ;
75+
76+ /** The font size in pixels; defaults to 10 */
4877 fontSize ?: ChannelValue ;
78+
79+ /**
80+ * The [font
81+ * style](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style);
82+ * defaults to normal.
83+ *
84+ * For italic font, use fontStyle: "italic".
85+ */
4986 fontStyle ?: string ;
87+
88+ /**
89+ * The [font
90+ * variant](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant);
91+ * defaults to normal.
92+ *
93+ * For tabular numbers, use fontVariant: "tabular-nums".
94+ */
5095 fontVariant ?: string ;
96+
97+ /**
98+ * The [font
99+ * weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight);
100+ * defaults to normal.
101+ *
102+ * For a boldface font, use *e.g.* fontWeight: "bold" or fontWeight: 700.
103+ */
51104 fontWeight ?: string | number ;
105+
106+ /**
107+ * The rotation angle in degrees clockwise; defaults to 0°.
108+ */
52109 rotate ?: ChannelValue ;
53110}
54111
@@ -67,9 +124,9 @@ export interface TextYOptions extends Omit<TextOptions, "x"> {
67124 * channel specifies the textual contents of the mark, with line breaks ('\n',
68125 * '\r\n', or '\r') denoting separate lines, rendered as tspan elements spaced
69126 * with a relative **lineHeight** that defaults to 1. The text can be split in
70- * lines of a given **lineWidth**, specified in percentage of the font size
71- * (e.g. 1000 for about 20 characters). Lines might be split on words that
72- * contain a soft-hyphen (\xad), replacing it with a dash (-) and a line feed.
127+ * lines of a given **lineWidth**, specified in ems (e.g. 10 for about 20
128+ * characters). Lines might be split on words that contain a soft-hyphen (\xad),
129+ * replacing it with a dash (-) and a line feed.
73130 *
74131 * If the text is specified as numbers or dates, a default formatter will
75132 * automatically be applied, and the **fontVariant** will default to
@@ -86,13 +143,12 @@ export interface TextYOptions extends Omit<TextOptions, "x"> {
86143 * Common font options include **fontFamily**, **fontSize**, **fontStyle**,
87144 * **fontWeight**, and **monospace**.
88145 *
89- * The optional **x** and **y** channels specify the position of the text, and
90- * the optional **y** categorical channel specifies its vertical anchor in data
91- * space. For screen-space positioning if **x** or **y** is omitted, use the
92- * **frameAnchor** options. Relative to the anchor, the text can be aligned with
93- * the **textAnchor** and **lineAnchor** options, and translated with the common
94- * **dx** and **dy** options. The text can be rotated with the **rotate**
95- * option, that defaults to 0°.
146+ * The optional **x** and **y** channels specify the position of the text in
147+ * data space. For screen-space positioning if **x** or **y** is omitted, use
148+ * one of the **frameAnchor** options. Relative to its anchor, the text can be
149+ * aligned with the **textAnchor** and **lineAnchor** options, and translated
150+ * with the common **dx** and **dy** options. The text can be rotated with the
151+ * **rotate** option, that defaults to 0°.
96152 *
97153 * The **textOverflow** option can be used to truncate lines of text longer than
98154 * the given **lineWidth**.
0 commit comments