Edit this page

VictoryAxis

VictoryAxis renders a single axis which can be used on its own or composed with VictoryChart.

            

Props

animate

VictoryAxis uses the standard animate prop. Read about it here

See the Animations Guide for more detail on animations

animate={{
  duration: 2000,
  easing: "bounce"
}}

axisComponent

The axisComponent prop takes a component instance which will be responsible for rendering an axis line. The new element created from the passed axisComponent will be provided with the following props calculated by VictoryAxis: x1, y1, x2, y2, style and events. Any of these props may be overridden by passing in props to the supplied component, or modified or ignored within the custom component itself. If an axisComponent is not provided, VictoryAxis will use its default Line component.

default: axisComponent={<Line type={"axis"}/>}

axisComponent={<Line events={{ onClick: handleClick }}/>}

axisLabelComponent

The axisLabelComponent prop takes a component instance which will be used to render the axis label. The new element created from the passed axisLabelComponent will be supplied with the following props: x, y, verticalAnchor, textAnchor, angle, transform, style and events. Any of these props may be overridden by passing in props to the supplied component, or modified or ignored within the custom component itself. If axisLabelComponent is omitted, a new VictoryLabel will be created with props described above.

default: axisLabelComponent={<VictoryLabel/>}

axisLabelComponent={<VictoryLabel dy={20}/>}

containerComponent

VictoryAxis uses the standard containerComponent prop. Read about it here

containerComponent={<VictoryZoomContainer dimension="x"/>}

crossAxis

The crossAxis boolean prop specifies whether a given axis is intended to cross another axis. When this prop is true, zeroes will be removed from the array of ticks so that they do not clutter the origin of the chart. When VictoryAxis is nested within VictoryChart, VictoryChart will determine a value for the crossAxis prop based on domain, but this prop may be overridden by supplying a crossAxis prop directly to the VictoryAxis child component.

default: crossAxis={false}

dependentAxis

The dependentAxis boolean prop specifies whether the axis corresponds to the dependent variable (usually y). This prop is useful when composing VictoryAxis with other components to form a chart.

default: dependentAxis={false}

            

domain

VictoryAxis uses the standard domain prop. Read about it here

domain={{x: [0, 100], y: [0, 1]}}

domainPadding

VictoryAxis uses the standard domainPadding prop. Read about it here

domainPadding={{x: [10, -10], y: 5}}

events

VictoryAxis uses the standard events prop. Read about it here

See the Events Guide for more information on defining events.

note: valid event targets for VictoryAxis are "axis", "axisLabel", "grid", "ticks", and "tickLabels". Targets that correspond to only one element {"axis" and "axisLabel") should use the special eventKey "all".

fixLabelOverlap

When true, this prop reduces the number of tick labels to fit the length of the axis. Labels are removed at approximately even intervals from the original array of labels. This feature only works well for labels that are approximately evenly spaced.

default: fixLabelOverlap={false}

gridComponent

The gridComponent prop takes a component instance which will be responsible for rendering a grid element. The new element created from the passed gridComponent will be provided with the following props calculated by VictoryAxis: x1, y1, x2, y2, tick, style and events. Any of these props may be overridden by passing in props to the supplied component, or modified or ignored within the custom component itself. If a gridComponent is not provided, VictoryAxis will use its default Line component.

default: gridComponent={<Line type={"grid"}/>}

gridComponent={<Line events={{ onClick: handleClick }}/>}

groupComponent

VictoryAxis uses the standard groupComponent prop. Read about it here

default: <g/>

groupComponent={<g transform="translate(10, 10)" />}

height

VictoryAxis uses the standard height prop. Read about it here

default (provided by default theme): height={300}

height={400}

label

The label prop defines the label that will appear with the axis. This prop should be given as a string.

            

name

VictoryAxis uses the standard name prop. Read about it here

name="series-1"

offsetX

The offsetX prop defines how far from the edge of its permitted area an axis should be offset in the x direction. If this prop is not given, the offset will be calculated based on font size, axis orientation, and label padding. When VictoryAxis is used with VictoryChart, VictoryChart will determine a value for offsetX that makes the axes line up correctly, but this value may be overridden by supplying an offsetX prop directly to the VictoryAxis child component.

note: The offsetX prop is relative to the edge corresponding to the orientation of the axis, e.g. the left edge when orientation="left".

            

offsetY

The offsetY prop defines how far from the edge of its permitted area an axis should be offset in the y direction. If this prop is not given, the offset will be calculated based on font size, axis orientation, and label padding. When VictoryAxis is used with VictoryChart, VictoryChart will determine a value for offsetY that makes the axes line up correctly, but this value may be overridden by supplying an offsetY prop directly to the VictoryAxis child component.

note: The offsetY prop is relative to the edge corresponding to the orientation of the axis, e.g. the bottom edge when orientation="bottom".

            

orientation

The orientation prop specifies the position and orientation of your axis. Options are "top", "bottom", "left", and "right".

            

padding

VictoryAxis uses the standard padding prop. Read about it here

default (provided by default theme): padding={50}

padding={{ top: 20, bottom: 60 }}

range

The range prop is usually controlled by VictoryChart. It will not typically be necessary to set a range prop manually

Read about the range prop in detail

scale

VictoryAxis uses the standard scale prop. Read about it here

note: Though VictoryAxis can take a scale prop with scales defined for both x and y, only the scale that corresponds the the given axis will be used.

default: scale="linear"

scale={{x: "time"}}

sharedEvents

The sharedEvents prop is used internally to coordinate events between components. It should not be set manually.

standalone

VictoryAxis uses the standard standalone prop. Read about it here

note: When VictoryAxis is nested within a component like VictoryChart, this prop will be set to false

default: standalone={true}

            

style

The style prop defines the style of the component. The style prop should be given as an object with styles defined for parent, axis, axisLabel, grid, ticks, and tickLabels. Any valid svg styles are supported, but width, height, and padding should be specified via props as they determine relative layout for components in VictoryChart. Functional styles may be defined for grid, tick, and tickLabel style properties, and they will be evaluated with each tick.

note: When a component is rendered as a child of another Victory component, or within a custom <svg> element with standalone={false} parent styles will be applied to the enclosing <g> tag. Many styles that can be applied to a parent <svg> will not be expressed when applied to a <g>.

note: custom angle and verticalAnchor properties may be included in labels styles.

default (provided by default theme): See grayscale theme for more detail

            

theme

VictoryAxis uses the standard theme prop. Read about it here

See the Themes Guide for information about creating custom themes.

default: theme={VictoryTheme.grayscale}

theme={VictoryTheme.material}

tickComponent

The tickComponent prop takes a component instance which will be responsible for rendering a tick element. The new element created from the passed tickComponent will be provided with the following props calculated by VictoryAxis: x1, y1, x2, y2, tick, style and events. Any of these props may be overridden by passing in props to the supplied component, or modified or ignored within the custom component itself. If a tickComponent is not provided, VictoryAxis will use its default Line component.

default: tickComponent={<Line type={"tick"}/>}

tickComponent={<Line events={{ onClick: handleClick }}/>}

tickCount

The tickCount prop specifies approximately how many ticks should be drawn on the axis if tickValues are not explicitly provided. This value is calculated by d3Scale and prioritizes returning "nice" values and evenly spaced ticks over an exact number of ticks. If an exact number of ticks are required, ticks should be specified via the tickValues prop. This prop must have a value greater than zero.

default: tickCount={5}

tickFormat

The tickFormat prop specifies how tick values should be labeled. The tickFormat prop can be given as an array of values to display for each tick, or as a function to be applied to every tickValue.

            

tickLabelComponent

The tickLabelComponent prop takes a component instance which will be used to render the axis label. The new element created from the passed tickLabelComponent will be supplied with the following props: x, y, tick, verticalAnchor, textAnchor, angle, transform, style and events. Any of these props may be overridden by passing in props to the supplied component, or modified or ignored within the custom component itself. If tickLabelComponent is omitted, a new VictoryLabel will be created with props described above.

default: tickLabelComponent={<VictoryLabel/>}

tickLabelComponent={<VictoryLabel dy={20}/>}

tickValues

The tickValues prop explicitly specifies a set of tick values to draw on the axis. This prop should be given as an array of unique values of the same type (i.e., all numbers). The tickValues prop is used to specify the values of each tick, so numeric values are typically appropriate. An array of strings or dates may be supplied for categorical and time series data respectively. Use the [tickFormat] prop to specify how ticks should be labeled.

            

width

VictoryAxis uses the standard width prop. Read about it here

default (provided by default theme): width={450}

width={400}