VictoryArea
For examples of VictoryArea
in action, visit the Area Chart examples.
Inherited Props
VictoryDatableProps
- dataComponentoverridden
VictoryMultiLabelableProps
- labelComponentoverridden
VictoryCommonProps
- groupComponentoverridden
Component Props
dataComponent
VictoryArea
overrides the standard dataComponent
prop and supplies the following props to its dataComponent
:
data
events
groupComponent
interpolation
origin
(for polar charts)polar
scale
style
Because VictoryArea
renders a single element to represent the entire dataset, the dataComponent
it renders will not have access to datum
like the dataComponent
elements rendered by other Victory components such as VictoryScatter
.
eventKey
VictoryArea
uses the standard eventKey
prop. Read about the eventKey
prop in more detail here
VictoryArea
only renders one element per dataset, so only one event key will be generated.
events
VictoryArea
uses the standard events
prop. Read about it in detail
See the Events Guide for more information on defining events.
VictoryArea
uses the special eventKey
"all" rather than referring to data by index, as it renders only one element for an entire dataset
<div style={{ margin: 50 }}> <h3>Click the area chart element</h3> <VictoryArea events={[ { target: "data", eventHandlers: { onClick: () => { return [ { eventKey: "all", mutation: (props) => { const fill = props.style && props.style.fill; return fill === "black" ? null : { style: { fill: "black", }, }; }, }, ]; }, }, }, ]} data={sampleData} theme={VictoryTheme.clean} /> </div>
groupComponent
VictoryArea
uses the standard groupComponent
prop. Read about it in detail
VictoryArea
uses VictoryClipContainer
as its default groupComponent
VictoryClipContainer
renders a <g>
tag with a clipPath
def
. This allows continuous data components to transition smoothly when new data points enter and exit.
Using a custom groupComponent
with VictoryArea
may result in broken animations.
<VictoryChart theme={VictoryTheme.clean} > <VictoryArea groupComponent={ <VictoryClipContainer clipPadding={{ top: 5, right: 10, }} /> } style={{ data: { stroke: "#c43a31", strokeWidth: 5, strokeLinecap: "round", }, }} data={sampleData} /> </VictoryChart>
interpolation
The interpolation
prop determines how data points should be connected when creating a path. Victory uses d3-shape for interpolating curves.
Interpolation Options
Both cartesian and polar charts may use the following interpolation options:
"basis"
"cardinal"
"catmullRom"
"linear"
Cartesian charts may also use the following interpolation options:
"monotoneX"
"monotoneY"
"natural"
"step"
"stepAfter"
"stepBefore"
You can also provide a custom curve function.
<VictoryArea interpolation="natural" data={sampleData} theme={VictoryTheme.clean} />
labelComponent
VictoryArea
uses the standard labelComponent
prop. Read about it in detail
To enable tooltips on VictoryArea
, it is necessary to use VictoryVoronoiContainer
<VictoryArea data={sampleData} labels={({ datum }) => datum.y} labelComponent={ <VictoryLabel renderInPortal dy={-20} /> } theme={VictoryTheme.clean} />
style
Defines the style of the component using VictoryStyleInterface.
Since VictoryArea
renders a single element to represent an entire dataset, it is not possible to use functional styles to change the style of the line as a function of an individual datum
. Instead, try using gradient fills for styling continuous data.
<VictoryArea style={{ data: { fill: "#c43a31", fillOpacity: 0.7, stroke: "#c43a31", strokeWidth: 3, }, labels: { fontSize: 15, fill: ({ datum }) => datum.x === 3 ? "#000000" : "#c43a31", }, }} data={sampleData} labels={({ datum }) => datum.x} theme={VictoryTheme.clean} />