Constructor
Creates a new bar series instance.Properties
Color of the bars. Defaults to Blue-500.
Name of the series displayed in the legend.
Whether the series is visible on the chart.
Array of data points to render. Each point has
x and y properties.Width of bars relative to category width, from 0 to 1.
Enable delta mode to show bar heights relative to minimum value for better visualization of small variations.
Alignment of the bar relative to the X value. Use ‘start’ for histograms, ‘center’ for standard bar charts.
Scale instance for X-axis coordinate transformation.
Scale instance for Y-axis coordinate transformation.
Whether animations are enabled for this series.
Duration of animations in milliseconds.
Methods
setData
Updates the series data and triggers animation if enabled.Array of data points where each point contains
x and y values.setScales
Sets the X and Y scales for coordinate transformation.Scale instance for X-axis transformation.
Scale instance for Y-axis transformation.
render
Renders the bar series on the canvas. Called automatically during the chart render cycle.enableAnimation
Enables animation for the series with an optional custom duration.Animation duration in milliseconds.
disableAnimation
Disables animation for the series.startAnimation
Manually triggers the render animation.getDataAt
Returns the data point at the given position if it intersects with a bar.Position to query, typically mouse coordinates in pixels.
The data point if the position intersects with a bar, or null otherwise.
Data format
Bar series accepts an array of Point objects:Configuration
When using the Chart API, configure bar series through the series config:BarSeriesConfig
Bar width
ThebarWidth property controls how much of the available space each bar occupies:
Delta mode
Delta mode is useful for visualizing small variations in data by adjusting the baseline:- Bars start from the minimum value in the dataset (with 10% buffer)
- Better highlights differences when all values are large and similar
- Automatically calculates appropriate baseline
Bar alignment
Control how bars align relative to their X position:- Center
- Start
- End
Default alignment, centers bars on their X value:Use for standard bar charts.
Animation
By default, bar series animates on initial render and data updates. The animation:- Uses easeOutCubic easing function
- Grows bars from baseline to target height
- Duration is 600ms by default
- Can be customized or disabled
Stacking
Bar stacking is handled by the Chart class, which preprocesses data and addsy0 properties to each point. When a point has a y0 property, the bar is drawn from y0 to y instead of from 0 to y.