// Single View Specification{ "data": ... , "mark": "text", "encoding": ... , ...}
text
mark represents each data point with a text instead of a point.
// Single View Specification{ ... "mark": { "type": "text", ... }, "encoding": ... , ...}
A text mark definition can contain anystandard mark properties and the following special properties:
Property | Type | Description |
---|---|---|
angle | Number |ExprRef | The rotation angle of the text, in degrees. |
align | String |ExprRef | The horizontal alignment of the text or ranged marks (area, bar, image, rect, rule). One of Note: Expression reference isnot supported for range marks. |
baseline | String |ExprRef | For text marks, the vertical text baseline. One of For range marks, the vertical alignment of the marks. One of Note: Expression reference isnot supported for range marks. |
dir | String |ExprRef | The direction of the text. One of Default value: |
dx | Number |ExprRef | The horizontal offset, in pixels, between the text label and its anchor point. The offset is applied after rotation by theangle property. |
dy | Number |ExprRef | The vertical offset, in pixels, between the text label and its anchor point. The offset is applied after rotation by theangle property. |
ellipsis | String |ExprRef | The ellipsis string for text truncated in response to the limit parameter. Default value: |
font | String |ExprRef | The typeface to set the text in (e.g., |
fontSize | Number |ExprRef | The font size, in pixels. Default value: |
fontStyle | String |ExprRef | The font style (e.g., |
fontWeight | String | Number |ExprRef | The font weight. This can be either a string (e.g |
limit | Number |ExprRef | The maximum length of the text mark in pixels. The text value will be automatically truncated if the rendered size exceeds the limit. Default value: |
lineHeight | Number |ExprRef | The line height in pixels (the spacing between subsequent lines of text) for multi-line text marks. |
radius | Number |ExprRef | For arc mark, the primary (outer) radius in pixels. For text marks, polar coordinate radial offset, in pixels, of the text from the origin determined by the Default value: |
text | Text |ExprRef | Placeholder text if the |
theta | Number |ExprRef |
|
You can also usetext
marks as labels for other marks and set offset (dx
ordy
),align
, andbaseline
properties of the mark definition.
Mapping a field totext
channel of text mark sets the mark’s text value. For example, we can make a colored scatterplot with text marks showing the initial character of its origin, instead ofpoint
marks.
By mapping geographic coordinate data tolongitude
andlatitude
channels of a correspondingprojection, we can show text at accurate locations. The example below shows the name of every US state capital at the location of the capital.
// Top-level View Specification{ ... "config": { "text": ..., ... }}
Thetext
property of the top-levelconfig
object sets the default properties for all text marks. Ifmark property encoding channels are specified for marks, these config values will be overridden.