Label
笛卡尔坐标系中 "position" 的参数含义
极坐标系中 "position" 的参数含义
径向坐标系中 "position" 的参数含义
父组件
Label consumes context provided by these components:
anglenumberoptional
Text rotation angle in degrees. Positive values rotate clockwise, negative values rotate counterclockwise.
默认值:
0backgroundTextBackgroundProps | false | trueoptional
Draws a background behind the label, for example to keep it readable on top of a filled shape.
truedraws the background with the styles from the theme'slabel.background. If neither sets afill, the fill is thepageBackgroundcolor from the theme, or white when no theme is set.- An object accepts SVG
<rect>attributes such asfill,strokeandrx, and apadding. It is merged over the theme styles key by key. falsedraws no background, even if the theme turns backgrounds on.undefineduses the theme'slabel.background, and draws no background without a theme.
The background is sized from the rendered text and follows curved label paths. It is not drawn for custom
content.Recharts 自 3.11
格式:
<Label position="inside" background /> <Label position="inside" background={{ fill: '#fff', rx: 2, padding: 4 }} />childrenReactNodeoptional
The value of label can be set as children or as the
valueprop格式:
<Label>foo</Label>classNamestringoptional
contentFunction | ReactNodeoptional
If set a React element, the option is the custom React element of rendering label. Use an SVG element or component, such as
<text>or<g>. HTML elements such as<div>are not valid inside the chart SVG and may trigger React DOM warnings. If set a function, the function will be called to render label content.格式:
<Label content={CustomizedLabel} /> const renderCustomLabel = (props) => <text {...props}>Custom Label</text>; <Label content={renderCustomLabel} />formatterFunctionoptional
Function to customize how content is serialized before rendering.
This should return a renderable text - something that the Text component can render. Typically, a string or number. Custom components are not supported here - use the
contentprop instead.idstringoptional
Unique identifier of this component. Used as an HTML attribute
id.indexnumberoptional
labelRefReact.RefObject<SVGTextElement> | nulloptional
offsetnumber | stringoptional
The offset to the specified "position". Direction of the offset depends on the position.
默认值:
5parentViewBoxRequired<CartesianViewBox> | Required<PolarViewBox>optional
position"bottom" | "center" | "centerBottom" | "centerTop" | "end" | "inside" | "insideBottom" | "insideBottomLeft" | "insideBottomRight" | "insideEnd" | "insideLeft" | "insideRight" | "insideStart" | "insideTop" | "insideTopLeft" | "insideTopRight" | "left" | "middle" | "outside" | "right" | "top" | { x?: string | number | undefined; y?: string | number | undefined; }optional
The position of label relative to the view box.
默认值:
"middle"textBreakAllbooleanoptional
默认值:
falsevaluefalse | null | number | string | trueoptional
The value of label can be set as children or as the
valueprop格式:
<Label value="foo" />viewBoxRequired<CartesianViewBox> | Required<PolarViewBox>optional
The box of viewing area. Used for positioning. If undefined, viewBox will be calculated based on surrounding context.
zIndexnumberoptional
Z-Index of this component and its children. The higher the value, the more on top it will be rendered. Components with higher zIndex will appear in front of components with lower zIndex. If undefined or 0, the content is rendered in the default layer without portals.
Recharts 自 3.4
默认值:
2000