VictoryLine
For examples of VictoryLine
in action, visit the Line Chart examples.
Inherited Props
VictoryDatableProps
VictoryMultiLabelableProps
VictoryCommonProps
Component Props
eventKey
VictoryLine
uses the standard eventKey
prop. This prop is not commonly used. Read about the eventKey
prop in more detail here
VictoryLine
only renders one element per dataset, so only one event key will be generated.
events
VictoryLine
uses the standard events
prop. Read about it here
VictoryLine
will use the special eventKey
"all" rather than referring to data by index, as it renders only one element for an entire dataset
<div> <h3>Click the line below</h3> <VictoryChart theme={VictoryTheme.clean} > <VictoryLine events={[{ target: "parent", eventHandlers: { onClick: () => { return [ { target: "data", eventKey: "all", mutation: ({ style }) => { return style.stroke === "black" ? null : { style: { stroke: "black", strokeWidth: 5 } }; } } ]; } } }]} data={sampleData} theme={VictoryTheme.clean} /> </VictoryChart> </div>
interpolation
The interpolation
prop determines how data points should be connected when creating a path. Victory uses d3-shape for interpolating curves.
Polar line charts may use the following interpolation options: "basis", "cardinal", "catmullRom", "linear"
Cartesian line charts may use the following interpolation options: "basis", "bundle", "cardinal", "catmullRom", "linear", "monotoneX", "monotoneY", "natural", "step", "stepAfter", "stepBefore"
You can also provide a function if you need to adjust parameters for d3-shape curves or to use a custom curve function.
<VictoryChart theme={VictoryTheme.clean} > <VictoryLine interpolation="natural" data={sampleData} /> </VictoryChart>
style
VictoryLine
uses the standard style
prop. Read about it here
Since VictoryLine
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.
default (provided by default theme): See [grayscale theme][] for more detail
<VictoryLine style={{ data: { stroke: "#c43a31", strokeWidth: ({ data }) => data.length }, labels: { fontSize: 15, fill: ({ datum }) => datum.x === 3 ? "#000000" : "#c43a31" } }} data={sampleData} labels={({ datum }) => datum.x} />