Skip to main content

VictoryHistogram

info

For examples of VictoryHistogram in action, visit the Histogram Chart examples.

Inherited Props

Component Props


bins

type: number | number[] | Date[]

VictoryHistogram uses d3.bin to do binning.

The bins prop is used to specify how the data will be binned. There are a few options for this, the first being passing no value, ie the default behavior, which is letting d3.bin generate the buckets based on the data. The second is passing a number, which specifies approximately the number of bins to generate, this is not a guarantee (see d3.bin for more details). The last options are passing an array of numbers or dates (depending on the data), this array represents an array of thresholds. So for example if the bin prop provided is [0, 10, 20, 35], this would result in 3 bins, that would look like [0, 10) , [10, 20), [20, 35].

This prop allows for a lot of flexibility in how the data is displayed. For example it is possible to have uneven sized bins if so desired. It is also possible to group the data by days, weeks, or years.

Live View
Loading...
Live Editor
Live View
Loading...
Live Editor
Live View
Loading...
Live Editor

binSpacing

type: number

The binSpacing prop is used to specify space between each bin. binSpacing represents the number of pixels that will be between each bin (including at the beginning and end of the bins). By default, bins are rendered with no spacing.

Live View
Loading...
Live Editor

cornerRadius

type: Function | number | { top, bottom, topLeft, topRight, bottomLeft, bottomRight }

The cornerRadius prop specifies a radius to apply to each bar. If this prop is given as a single number, the radius will only be applied to the top of each bar. When this prop is given as a function, it will be evaluated for each bar with the props object corresponding to that bar.

Live View
Loading...
Live Editor

data

type: any[]

VictoryHistogram uses the standard data prop, except for it only expects each object within the array to have an x property. The x data accessor prop can be used to define a custom data property.

Because each bar represents a bin rather than a particular data point (like with VictoryScatter for example), when accessing datum via a prop that passes datum such as style, datum will have properties x, x0, x1, y, and binnedData. x is the midpoint between the bin, x0 is the beginning of the bin, x1 is the end of the bin, y is the aggregate amount of data points within that bin, and binnedData is an array of the original data points that were grouped into this bin.


eventKey

type: string | integer | string[] | Function

VictoryHistogram uses the standard eventKey prop to specify how event targets are addressed. This prop is not commonly used. Read about the eventKey prop in more detail here


events

type: object[]

VictoryHistogram uses the standard events prop. Read about it here

See the [Events Guide][] for more information on defining events.

Live View
Loading...
Live Editor

style

type: { parent: object, data: object, labels: object }

VictoryHistogram uses the standard style prop. Read about it here

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

Live View
Loading...
Live Editor