Usage
Props
Content
string | number
The value of the label.Can also be set as children:
<Label>foo</Label>string | number
Alternative way to set the label value.Can also be set via the
value prop: <Label value="foo" />ReactElement | function
Custom content for the label.Options:
ReactElement: Custom label elementfunction: Render function that receives label props and returns a React element
Position
LabelPosition
default:"middle"
The position of the label relative to the view box.Cartesian positions:
top,bottom,left,righttopLeft,topRight,bottomLeft,bottomRightinsideLeft,insideRight,insideTop,insideBottominsideTopLeft,insideTopRight,insideBottomLeft,insideBottomRightcenter,centerTop,centerBottommiddle
insideStart,insideEnd,endoutside,center,centerTop,centerBottom
number
default:"5"
The offset to the specified position.Direction of the offset depends on the position.
View box
ViewBox
The box of the viewing area, used for positioning.If undefined, viewBox is calculated based on surrounding context.
ViewBox
The parent view box, used for positioning calculations.
Text formatting
function
Function to customize how content is serialized before rendering.Should return renderable text (string or number).Signature:
(label: RenderableText) => RenderableTextAppearance
number
default:"0"
Text rotation angle in degrees.Positive values rotate clockwise, negative values rotate counterclockwise.
boolean
default:"false"
If true, enables character-level breaking instead of word-level breaking.
string
The fill color of the label text.
string
The stroke color of the label text.
number
The font size of the label text.
string
The font family of the label text.
string | number
The font weight of the label text.
Display
number
default:"2000"
The z-index of the label.Higher values render on top of lower values.
Other
string
CSS class name for the label element.
string
Unique identifier of this component.Used as an HTML attribute
id.number
The index of this label in a series of labels.
Context
The Label component consumes context from:- CartesianViewBoxContext
- PolarViewBoxContext
- CartesianLabelContext
- PolarLabelContext