Victory Primitives
Victory is built around a set of simple, stateless components. Along with VictoryContainer, VictoryClipContainer, and VictoryLabel, the following list represents every simple element a Victory component might render. These simple components are responsible for supplying props to primitive components. Victory maintains a small subset of primitive components with additional logic in place to prevent unnecessary rendering. Extracting every rendered element into its own component allows Victory to support both web and React Native applications with very little additional code, as only a few components need to be modified to render react-native-svg elements rather than SVG elements. These primitives are also exposed for users to wrap, extend or reference when creating their own custom rendered components.
Primitive Components
Each of these primitive components renders SVG elements. The following components are the only Victory components that render SVG elements with the exception of VictoryContainer and VictoryPortal. These elements are used by other simple components such as Bar and Area.
Circle
Used by Background, VictoryClipContainer, and Voronoi
const Circle = (props) => <circle vectorEffect="non-scaling-stroke" {...props} />;ClipPath
Used by VictoryClipContainer and Voronoi
const ClipPath = (props) => (
<defs>
<clipPath id={props.clipId}>{props.children}</clipPath>
</defs>
);Line
Used by Axis, Candle, and ErrorBar
const Line = (props) => <line vectorEffect="non-scaling-stroke" {...props} />;Path
Used by Arc, Area, Bar, Curve, Flyout, Point, Slice, and Voronoi
const Path = (props) => <path {...props} />;Rect
Used by VictoryClipPath, Background, Border, and Candle
const Rect = (props) => <rect vectorEffect="non-scaling-stroke" {...props} />;Text
Used by VictoryLabel
const Text = (props) => {
const { children, title, desc, ...rest } = props;
return (
<text {...rest}>
{title && <title>{title}</title>}
{desc && <desc>{desc}</desc>}
{children}
</text>
);
};TSpan
Used by VictoryLabel
const TSpan = (props) => <tspan {...props} />;Simple Components
Arc
VictoryPolarAxis uses the Arc primitive to draw circular axes and grid lines. Arc renders a <Path> element. View the source
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop controlling the aria-label that will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toArcclassNamestring the class name that will be applied to the rendered pathclosedPathboolean a flag signifying whether this arc is should render a closed pathcxnumber the x coordinate of the center of the arc pathcynumber the y coordinate of the center of the arc pathdatumany the data point or tick corresponding to this arcendAnglenumber the end angle of the arc given in degreeseventsobject events to attach to the rendered elementgroupComponentelement the element used to group rendered elements default<g/>idstring or number an id to apply to the rendered componentpathComponentelement the rendered path element default<Path/>rnumber the radius of the arcrolestring the aria role to assign to the elementscaleobject the x and y scale of the parent chart withdomainandrangeappliedshapeRenderingstring the shape rendering attribute to apply to the rendered pathstartAnglenumber the start angle of the arc given in degreesstyleobject the styles to apply to the rendered elementtabIndexnumber or function will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toArctransformstring a transform that will be supplied to elements this component renders
Area
VictoryArea uses Area to represent an entire dataset. Area renders a <Path/> element, or a group of paths if the stroke of the area should be rendered in a different style from the filled section of the area. View the source
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop controlling the aria-label that will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toAreaclassNamestring the class name that will be applied to the rendered pathdataarray the entire dataset used to define the areaeventsobject events to attach to the rendered elementgroupComponentelement the element used to group rendered elements default<g/>idstring or number an id to apply to the rendered componentinterpolationstring or function the interpolation to use when calculating a pathoriginobject the svg coordinates of the center point of a polar chartpolarboolean a flag specifying whether the component is part of a polar chartpathComponentelement the rendered path element default<Path/>rolestring the aria role to assign to the elementscaleobject the x and y scale of the parent chart withdomainandrangeappliedshapeRenderingstring the shape rendering attribute to apply to the rendered pathstyleobject the styles to apply to the rendered elementtabIndexnumber or function that will be applied to rendered path. When this prop is given as a function it will be called with the rest of the props supplied toAreatransformstring a transform that will be supplied to elements this component renders
LineSegment
The LineSegment component renders straight lines. This component is used to render grids, ticks, and axis lines in VictoryAxis. View the source
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop controlling the aria-label that will be applied to the rendered lineComponent. When this prop is given as a function it will be called with the rest of the props supplied toLineSegmentclassNamestring the class name that will be applied to the rendered elementdataarray the entire datasetdatumobject the data point corresponding to this lineeventsobject events to attach to the rendered elementidstring or number an id to apply to the rendered componentindexnumber the index of this line within the datasetlineComponentelement the rendered line element default<Line/>rolestring the aria role to assign to the elementshapeRenderingstring the shape rendering attribute to apply to the rendered elementsstyleobject the styles to apply to the rendered elementtabIndexnumber or funciton will be applied to the rendered lineComponent. When this prop is given as a function it will be called with the rest of the props supplied toLineSegmenttransformstring a transform that will be supplied to elements this component rendersx1number the x coordinate of the beginning of the linex2number the x coordinate of the end of the liney1number the y coordinate of the beginning of the liney2number the y coordinate of the end of the line
Background
The Background component is used to render an SVG background on VictoryChart. Background will render a <Circle> for charts with polar={true} and a <Rect> element for all other charts. View the source
Props
classNamestring the class name that will be applied to the rendered pathcircleComponentelement the rendered circle element default<Circle/>eventsobject events to attach to the rendered elementheightnumber the height of the<rect/>elementidstring or number an id to apply to the rendered componentoriginobject the svg coordinates of the center point of a polar chartpolarboolean a flag specifying whether the component is part of a polar chartrectComponentelement the rendered rect element default<Rect/>rolestring the aria role to assign to the elementrxnumber the x radius of the rendered<rect/>elementrynumber the y radius of the rendered<rect/>elementscaleobject the x and y scale of the parent chart withdomainandrangeappliedshapeRenderingstring the shape rendering attribute to apply to the rendered pathstyleobject the styles to apply to the rendered elementwidthnumber the width of the<rect/>elementxnumber the x coordinate of the upper-left corner of the background for non-polar charts and center of the background for polar chartsynumber the y coordinate of the top of the background
Bar
VictoryBar uses Bar to represent a single data point as a bar extending horizontally or vertically from the independent axis. Bar renders a <Path> element. It is also used by VictoryHistogram to represent "bins" of data. View the source
Props
activeboolean a flag signifying whether the component is activealignment*"start", "middle", or "end" specifies how a bar path should be aligned in relation to its data pointariaLabelstring or function a prop controlling the aria-label that will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toBarbarRationumber a number between zero and one that will be used to calculate bar width when an explicit width is not givenbarWidthnumber or function A prop defining the width of the bar. When this prop is given as a function, it will be called with the rest of the props supplied toBar.classNamestring the class name that will be applied to the rendered pathcornerRadiusnumber, function or object the number of pixels of corner radius to apply when calculating a bar path. When this prop is given as a function, it will be called with the rest of the props supplied toBar. When given as an object, this prop may include values for top, bottom, topLeft, topRight, bottomLeft and bottomRight, with more specific values overriding less specific valuesdataarray the entire datasetdatumobject the data point corresponding to this bareventsobject events to attach to the rendered elementidstring or number an id to apply to the rendered componentindexnumber the index of this bar within the datasetoriginobject the svg coordinates of the center point of a polar chartpathComponentelement the rendered path element default<Path/>polarboolean a flag specifying whether the component is part of a polar chartrolestring the aria role to assign to the elementscaleobject the x and y scale of the parent chart withdomainandrangeappliedshapeRenderingstring the shape rendering attribute to apply to the rendered pathstyleobject the styles to apply to the rendered elementtabIndexnumber or function number applied to rendered path. When given as a function it will be called with the rest of the props supplied toBartransformstring a transform that will be supplied to elements this component renderswidthnumber the width of parent chart (used to calculate default bar widthstyle.widthis not supplied)xnumber the x coordinate of the top of the bary0number the y coordinate of the baseline of the barynumber the y coordinate of the top of the bar
Box
VictoryLegend uses the Box component to draw a border around a legend area. Box renders a <Rect/> element. View the source
note Box also exported as Border
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop that controls the a propcontrollings the aria-label that will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toBoxclassNamestring the class name that will be applied to the rendered elementeventsobject events to attach to the rendered elementheightnumber the height of the<rect/>elementidstring or number an id to apply to the rendered componentrectComponentelement the rendered path element default<Rect/>rolestring the aria role to assign to the elementshapeRenderingstring the shape rendering attribute to apply to the rendered elementstyleobject the styles to apply to the rendered elementtabIndexnumber or function will be applied to the rendered path. When given as a function it will be called with the rest of the props supplied toBoxtransformstring a transform that will be supplied to elements this component renderswidthnumber the width of the<rect/>elementxnumber the x coordinate of the upper-left corner of the<rect/>elementynumber the y coordinate of the upper-left corner of the<rect/>element
Candle
VictoryCandlestick uses Candle to represent a single data point as a candle. Candle renders a group with <Rect> and <Line> elements. View the source
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop controlling the aria-label that will be applied to the rendered<Rect>and<Line>elements. When this prop is given as a function it will be called with the rest of the props supplied toCandlecandleRationumber a number between zero and one that will be used to calculate candle width when an explicit width is not givencandleWidthnumber or function A prop defining the width of the candle. When this prop is given as a function, it will be called with the rest of the props supplied toCandle.classNamestring the class name that will be applied to the rendered elementclosenumber the y coordinate of the closing valuedataarray the entire datasetdatumobject the data point corresponding to this candleeventsobject events to attach to the rendered elementgroupComponentelement the element used to group rendered elements default<g/>highnumber the y coordinate of the high valueidstring or number an id to apply to the rendered componentindexnumber the index of this candle within the datasetlineComponentelement the rendered line element default<Line/>lownumber the y coordinate of the low valueopennumber the y coordinate of the opening valuerectComponentelement the rendered path element default<Rect/>rolestring the aria role to assign to the elementscaleobject the x and y scale of the parent chart withdomainandrangeappliedshapeRenderingstring the shape rendering attribute to apply to the rendered elementsstyleobject the styles to apply to the rendered elementtabIndexnumber or function a prop controlling the aria-label that will be applied to the rendered<Rect>and<Line>elements. When given as a function it will be called with the rest of the props supplied toCandletransformstring a transform that will be supplied to elements this component renderswidthnumber the width of parent chart (used to calculate default candle widthstyle.widthis not supplied)widthStrokeWidthnumber the stroke width of the candle wick. (style.strokeWidth will be used when this value is not given)xnumber the x coordinate of the candle
Curve
VictoryLine uses Curve to represent an entire dataset as a line or curve. Curve renders a <Path> element. View the source
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop controlling the aria-label that will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toCurveclassNamestring the class name that will be applied to the rendered elementdataarray the entire dataset used to define the curveeventsobject events to attach to the rendered elementgroupComponentelement the element used to group rendered elements default<g/>idstring or number an id to apply to the rendered componentinterpolationstring or function the interpolation to use when calculating a pathoriginobject the svg coordinates of the center point of a polar chartpathComponentelement the rendered path element default<Path/>polarboolean a flag specifying whether the component is part of a polar chartrolestring the aria role to assign to the elementscaleobject the x and y scale of the parent chart withdomainandrangeappliedshapeRenderingstring the shape rendering attribute to apply to the rendered pathstyleobject the styles to apply to the rendered elementtabIndexnumber or function will be applied to the rendered path. When given as a function it will be called with the rest of the props supplied toCurvetransformstring a transform that will be supplied to elements this component renders
ErrorBar
VictoryErrorBar uses ErrorBar to render x and y error bars. ErrorBar renders a group of <Line> elements. View the source
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop controlling the aria-label that will be applied to the group,g, containing the rendered<Line>elements. When this prop is given as a function it will be called with the rest of the props supplied toErrorBarborderWidthnumber the width of the cross-hairs on the end of each error bar default: 10classNamestring the class name that will be applied to the rendered elementdataarray the entire datasetdatumobject the data point corresponding to this error barerrorXnumber, array, or boolean errors in the x dimension.errorYnumber, array, or boolean errors in the y dimension.eventsobject events to attach to the rendered elementgroupComponentelement the element used to group rendered elements default<g/>idstring or number an id to apply to the rendered componentindexnumber the index of this error bar within the datasetlineComponentelement the rendered line element default<Line/>originobject the svg coordinates of the center point of a polar chartpolarboolean a flag specifying whether the component is part of a polar chartrolestring the aria role to assign to the elementscaleobject the x and y scale of the parent chart withdomainandrangeappliedshapeRenderingstring the shape rendering attribute to apply to the rendered elementsstyleobject the styles to apply to the rendered elementtabIndexnumber or function applies to the group,g, containing the<Line>elements. When this prop is given as a function it will be called with the rest of the props supplied toErrorBartransformstring a transform that will be supplied to elements this component rendersxnumber the x coordinate of the center of the error barynumber the y coordinate of the center of the error bar
Flyout
VictoryTooltip uses Flyout to render a flyout style path around text. Flyout renders <Path> element. View the source
Props
activeboolean a flag signifying whether the component is activecenterobject the center coordinates of the flyoutclassNamestring the class name that will be applied to the rendered elementcornerRadiusnumber the corner radius of the flyoutdataarray the entire dataset if applicabledatumobject the data point corresponding to this flyout if applicabledxnumber offset in the x dimension.dynumber offset in the y dimension.eventsobject events to attach to the rendered elementheightnumber the height of the flyoutidstring or number an id to apply to the rendered componentindexnumber the index of this flyout within the datasetorientation"top", "bottom", "left", "right"originobject the svg coordinates of the center point of a polar chartpathComponentelement the rendered path element default<Path/>pointerLengthnumber the length of the triangular pointerpointerWidthnumber the width of the base of the triangular pointerpolarboolean a flag specifying whether the component is part of a polar chartrolestring the aria role to assign to the elementshapeRenderingstring the shape rendering attribute to apply to the rendered elementsstyleobject the styles to apply to the rendered elementtransformstring a transform that will be supplied to elements this component renderswidthnumber the width of the flyoutxnumber the x coordinate of data point associated with this flyoutynumber the y coordinate of data point associated with this flyout
Point
VictoryScatter uses Point to render each point in a scatter plot. Point renders a <Path> element. View the source
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop controlling the aria-label that will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toPointclassNamestring the class name that will be applied to the rendered elementdataarray the entire datasetdatumobject the data point corresponding to this pointeventsobject events to attach to the rendered elementgetPathfunction a function ofx,y, andsizethat returns a path string. When this optional function is provided, it will be used to calculate a path, rather than one of the path functions corresponding to thesymbols supported byPoint.idstring or number an id to apply to the rendered componentindexnumber the index of this point within the datasetoriginobject the svg coordinates of the center point of a polar chartpathComponentelement the rendered path element default<Path/>polarboolean a flag specifying whether the component is part of a polar chartrolestring the aria role to assign to the elementscaleobject the x and y scale of the parent chart withdomainandrangeappliedshapeRenderingstring the shape rendering attribute to apply to the rendered pathsizenumber or function the size of the point. When this prop is given as a function, it will be called with the rest of the props supplied toPoint.styleobject the styles to apply to the rendered elementsymbol"circle", "cross", "diamond", "plus", "minus", "square", "star", "triangleDown", "triangleUp" which symbol the point should render. This prop may also be given as a function that returns one of the above options. When this prop is given as a function, it will be called with the rest of the props supplied toPoint.tabIndexnumber or function number will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toPointtransformstring a transform that will be supplied to elements this component rendersxnumber the x coordinate of the center of the pointynumber the y coordinate of the center of the point
Slice
VictoryPie uses Slice to render each slice in a pie chart. Slice renders a <Path> element. View the source
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop controlling the aria-label that will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toSliceclassNamestring the class name that will be applied to the rendered elementcornerRadiusnumber or function the corner radius to apply to this slice. When this prop is given as a function it will be called with the rest of the props supplied toSlice.dataarray the entire datasetdatumobject the data point corresponding to this sliceeventsobject events to attach to the rendered elementidstring or number an id to apply to the rendered componentindexnumber the index of this slice within the datasetinnerRadiusnumber or function the inner radius of the slice. When this prop is given as a function it will be called withdatumandactive.padAnglenumber or function the angular padding to add to the slice. When this prop is given as a function it will be called with the rest of the props supplied toSlice.pathComponentelement the rendered path element default<Path/>pathFunctionfunction a function that calculates the path of a given slice. When given, this prop will be called with thesliceobjectradiusnumber or function the outer radius of the slice. When this prop is given as a function it will be called with the rest of the props supplied toSlice.rolestring the aria role to assign to the elementshapeRenderingstring the shape rendering attribute to apply to the rendered pathsliceobject an object specifying the startAngle, endAngle, padAngle, and data of the slicesliceEndAnglenumber or function the end angle the slice. When this prop is given as a function it will be called with the rest of the props supplied toSlice.sliceStartAnglenumber or function the start angle of the slice. When this prop is given as a function it will be called with the rest of the props supplied toSlice.styleobject the styles to apply to the rendered elementtabIndexnumber or function number will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toSlice.transformstring a transform that will be supplied to elements this component renders
Voronoi
VictoryVoronoi uses Voronoi to render voronoi polygons. Voronoi renders either a <Path> element corresponding to a voronoi polygon, or a <Circle/> clipped with a <ClipPath> defined by the path of the polygon. View the source
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop controlling the aria-label that will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toVoronoicircleComponentelement the rendered circle element default<Circle/>classNamestring the class name that will be applied to the rendered elementclipPathComponentelement the rendered clipPath element default<ClipPath/>dataarray the entire datasetdatumobject the data point corresponding to this voronoi polygoneventsobject events to attach to the rendered elementgroupComponentelement the rendered group element default<g/>idstring or number an id to apply to the rendered componentindexnumber the index of this voronoi polygon within the datasetoriginobject the svg coordinates of the center point of a polar chartpathComponentelement the rendered path element default<Path/>polarboolean a flag specifying whether the component is part of a polar chartpolygonarray an array of points defining the polygonrolestring the aria role to assign to the elementshapeRenderingstring the shape rendering attribute to apply to the rendered pathsizenumber the maximum size of the voronoi polygonstyleobject the styles to apply to the rendered elementtabIndexnumber or function will be applied to the rendered path. When this prop is given as a function it will be called with the rest of the props supplied toVoronoitransformstring a transform that will be supplied to elements this component renders.xnumber the x coordinate of the data pointynumber the y coordinate of the data point
Whisker
VictoryBoxPlot uses the Whisker component to draw whiskers for the minimum and maximum values in a box plot. Whisker renders a group of <Line/> elements. View the source
Props
activeboolean a flag signifying whether the component is activeariaLabelstring or function a prop controlling the aria-label that will be applied to the rendered<Line>elements. When this prop is given as a function it will be called with the rest of the props supplied toWhiskerclassNamestring the class name that will be applied to the rendered elementeventsobject events to attach to the rendered elementgroupComponentelement the rendered group element default<g/>idstring or number an id to apply to the rendered componentlineComponentelement the rendered line element default<Line/>majorWhiskerobject an object with valuesx1,x2,y1,y2describing the major whisker lineminorWhiskerobject an object with valuesx1,x2,y1,y2describing the minor whisker linerolestring the aria role to assign to the elementshapeRenderingstring the shape rendering attribute to apply to the rendered elementstyleobject the styles to apply to the rendered elementtabIndexnumber or function will be applied to the rendered<Line>. When this prop is given as a function it will be called with the rest of the props supplied toWhiskertransformstring a transform that will be supplied to elements this component renders.