sisense.com
✅ You are viewing documentation for the latest version of Compose SDK.
Version:

Function BarChart

BarChart(props): Promise< ReactNode > | ReactNode

A React component representing categorical data with horizontal rectangular bars, whose lengths are proportional to the values that they represent.

Parameters

ParameterTypeDescription
propsBarChartPropsBar chart properties

Returns

Promise< ReactNode > | ReactNode

Bar Chart component

Example

Bar chart displaying total revenue per year from the Sample ECommerce data model.

import { BarChart } from '@sisense/sdk-ui';
import { measureFactory } from '@sisense/sdk-data';
import * as DM from './sample-ecommerce';

const CodeExample = () => (
  <BarChart
    dataSet={DM.DataSource}
    dataOptions={{
      category: [DM.Commerce.Date.Years],
      value: [measureFactory.sum(DM.Commerce.Revenue, 'Total Revenue')],
      breakBy: [DM.Commerce.Condition],
    }}
  />
);

export default CodeExample;
Bar chart example 1

Stacked bar chart variant, broken down by age range:

<BarChart
  dataSet={DM.DataSource}
  dataOptions={{
    category: [DM.Commerce.Date.Years],
    value: [measureFactory.sum(DM.Commerce.Revenue, 'Total Revenue')],
    breakBy: [DM.Commerce.AgeRange],
  }}
  styleOptions={{ subtype: 'bar/stacked' }}
/>
Bar chart example 2

Stacked percentage bar chart variant, using the same data:

<BarChart
  dataSet={DM.DataSource}
  dataOptions={{
    category: [DM.Commerce.Date.Years],
    value: [measureFactory.sum(DM.Commerce.Revenue, 'Total Revenue')],
    breakBy: [DM.Commerce.AgeRange],
  }}
  styleOptions={{ subtype: 'bar/stacked100' }}
/>
Bar chart example 3
Last Updated: