GuideWeb ComponentsChartChart Bar

Bar Chart

A bar chart component UI is a visual representation of data using rectangular bars. These charts are commonly used to compare quantities across different categories.

TypeResource
DesignFigma
WebWeb Storybook
CodeGitlab

Usage

import { BarChart } from 'bio-bind-ui';
<BarChart
  data={{
    datasets: [
      {
        backgroundColor: [
          '#34ADC0',
          '#B0DFE7',
          '#FF6E00',
          '#FFD2B0',
          '#F79009',
          '#FEF0C7',
        ],
        data: [800, null, null, null, null, null],
        label: 'Data 1',
        skipNull: true,
      },
      {
        backgroundColor: [
          '#34ADC0',
          '#B0DFE7',
          '#FF6E00',
          '#FFD2B0',
          '#F79009',
          '#FEF0C7',
        ],
        data: [null, 200, null, null, null, null],
        label: 'Data 2',
        skipNull: true,
      },
      {
        backgroundColor: [
          '#34ADC0',
          '#B0DFE7',
          '#FF6E00',
          '#FFD2B0',
          '#F79009',
          '#FEF0C7',
        ],
        data: [null, null, 400, null, null, null],
        label: 'Data 3',
        skipNull: true,
      },
      {
        backgroundColor: [
          '#34ADC0',
          '#B0DFE7',
          '#FF6E00',
          '#FFD2B0',
          '#F79009',
          '#FEF0C7',
        ],
        data: [null, null, null, 600, null, null],
        label: 'Data 4',
        skipNull: true,
      },
      {
        backgroundColor: [
          '#34ADC0',
          '#B0DFE7',
          '#FF6E00',
          '#FFD2B0',
          '#F79009',
          '#FEF0C7',
        ],
        data: [null, null, null, null, 900, null],
        label: 'Data 5',
        skipNull: true,
      },
      {
        backgroundColor: [
          '#34ADC0',
          '#B0DFE7',
          '#FF6E00',
          '#FFD2B0',
          '#F79009',
          '#FEF0C7',
        ],
        data: [null, null, null, null, null, 250],
        label: 'Data 6',
        skipNull: true,
      },
    ],
    labels: ['January', 'February', 'March', 'April', 'May', 'June'],
  }}
  id='bar-chart'
  mode='light'
  name='Bar Chart Vertical'
  options={{
    plugins: {
      legend: {
        position: 'top',
      },
    },
    scales: {
      x: {
        title: {
          display: true,
          text: 'Month',
        },
      },
      y: {
        max: 1000,
        min: 0,
        ticks: {
          maxTicksLimit: 1000,
          stepSize: 100,
        },
        title: {
          display: true,
          text: 'Value',
        },
      },
    },
  }}
  size='md'
  width={700}
/>

Examples

Size (Optional)

Use size for change the size of bar chart component: sm, md, lg


Vertical (Optional)

Vertical flag of the chart: horizontal or vertical



Props

PropsRequiredDefaultTypeDescription
idtrue-stringA unique identifier for the chart component. This ID is used for referencing or targeting the chart in other parts of the application.
nametrue-stringThe name of the chart component. This can be used for labeling or identifying the chart within the UI.
datatrue-ChartData<'bar'>The main data input for the chart. It includes labels for the x-axis and datasets containing the values and styles for the bars.
optionsfalse-ChartOptions<'bar'>An optional configuration object that allows customization of the chart’s appearance or behavior, such as colors, axis labels, or display preferences.
modefalselightlight darkThe mode of the chart bar. Determines whether the chart uses a light or dark theme.
sizefalsemdsm md lgThe size of the chart bar. Can be small (sm), medium (md), or large (lg).
widthfalse-numberThe width of the chart bar.
heightfalse-numberThe height of the chart bar.
horizontalfalse-booleanA flag to determine whether the bar chart should be rendered horizontally.
BIND © Biofarma Innovate Next-level Design .