BarChart

BarChart is a component for drawing bar charts to compare multiple sets of data.

Usage

import { BarChart } from "@yamada-ui/react"
<BarChart.Root>
  <BarChart.Bar>
    <BarChart.LabelList />
  </BarChart.Bar>
  <BarChart.Label />
  <BarChart.ReferenceLine />
  <BarChart.Grid />
  <BarChart.XAxis />
  <BarChart.YAxis />
  <BarChart.Tooltip />
  <BarChart.Legend />
</BarChart.Root>

Composition

Change Size

Change Color Scheme

Change Color

Range

To display a range, set the values of the data items as [min, max] arrays.

Stacked

To stack the series, set stackId in series or barProps.stackId to a string.

Percent

To make the series a percentage, set stackId or barProps.stackId to a string and set chartProps.stackOffset to "expand".

Add Y Axis

To add the Y axis, set withYAxis to true. The default is false.

To change the orientation of the Y axis, set yAxisProps.orientation to "start" or "end". The default is "start".

Add Legend

To add the legend, set withLegend to true. The default is false. To change the placement of the legend, set legendProps.placement to "start-start", "end-end", etc. The default is "start-end".

Change Name

To change the name of the tooltip or legend, set name to a string in series.

Change Grid

To change the grid, set horizontal and vertical to a boolean in gridProps.

Add Label

To add a label, set label of series or barProps.label to true. The default is false.

Add Unit

To add a unit, use formatter or tickFormatter or set unit to a string.

Vertical

To make the chart vertical, set layout to "vertical" in chartProps and adjust the type of the axes.

Sync

To sync the chart, set syncId to a string.

Format

To format the chart, use formatter or tickFormatter etc.

Add Reference Line

Add Tick Line

To add a reference line, set tickLine to true in xAxisProps or yAxisProps. The default is false.

Add Axis Label

To add an axis label, set label to a string in xAxisProps or yAxisProps. The default is false.

Set Domain

To set the domain, set domain to an array in yAxisProps. To set the ticks, set ticks to an array in yAxisProps.

Change Gap

To change the gap, set barCategoryGap and barGap in chartProps to a number or string.

Change Radius

To change the radius, set radius in series or barProps.radius to a number or an array.

Add Tooltip Cursor

To add a tooltip cursor, set cursor to true in tooltipProps. The default is false.

Hide X Axis

To hide the X axis, set withXAxis to false. The default is true.

Hide Tooltip

To hide the tooltip, set withTooltip to false. The default is true.

Customize Axis

Customize Label

Customize Grid

Customize Tooltip Cursor

Props