> ## Documentation Index
> Fetch the complete documentation index at: https://anvil.servicetitan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Grouped bar

> Grouped bar chart implementation for @servicetitan/anvil2-rn-charts-kit.

A grouped bar chart compares series side by side within each category. The variables are the series rather than the bars inside one series, so `variant` assigns color per series index. Use `monochrome` for four or fewer series, and `categorical` for five or more.

* Design rules: [Bar charts — grouped](/docs/web/data-visualization/bar-charts#rules-on-the-usage-of-grouped-bar-charts)
* Shared API / tooltips / palettes: [Chart component](/docs/kits/charts-react-native/chart)
* Plain bar / direct labels: [Bar](/docs/kits/charts-react-native/bar)

***

## Minimal option

Define one `bar` series per variable and leave `stack` unset. Orientation follows the axis layout rather than a `Chart` prop: the `category` axis holds the labels and the `value` axis holds the measurements.

```tsx theme={null}
const option: EChartsOption = {
  grid: { left: 48, right: 16, top: 24, bottom: 84 },
  legend: { bottom: 0 },
  xAxis: { type: "category", data: ["Q1", "Q2", "Q3", "Q4"] },
  yAxis: { type: "value" },
  series: [
    { type: "bar", name: "North", data: […] },
    { type: "bar", name: "South", data: […] },
    { type: "bar", name: "East", data: […] },
  ],
};

<Chart
  option={option}
  variant="monochrome"
  width={480}
  height={320}
  accessibilityLabel="Grouped bar. Sales by region and quarter."
/>;
```

***

## Variant styling

`variant` applies the following treatment:

| Concern       | Behavior                                             |
| ------------- | ---------------------------------------------------- |
| Color         | Palette by series index                              |
| Corner radius | Open end of each bar, following orientation and sign |
| Hover         | Series focus and blur                                |

Avoid hand-authoring `borderRadius` or palette hex values to reproduce this treatment.

***

## Tooltips

Pass `renderTooltip` to add tooltip content. See [Chart component](/docs/kits/charts-react-native/chart#tooltips).

```tsx theme={null}
import { Chart } from "@servicetitan/anvil2-rn-charts-kit";
import { TooltipSurface } from "@servicetitan/anvil2-rn";
import type { ChartTooltipInfo } from "@servicetitan/anvil2-rn-charts-kit";
import type { EChartsOption } from "@servicetitan/anvil2-rn-charts-kit";
import { Text, View } from "react-native";

function renderTooltip({ name, points }: ChartTooltipInfo) {
  return (
    <TooltipSurface
      accessibilityLabel={name}
      content={
        <View>
          <Text>{name}</Text>
          {points.map((point) => (
            <Text key={point.seriesIndex}>
              {point.seriesName ? `${point.seriesName}: ` : ""}
              {String(point.value)}
            </Text>
          ))}
        </View>
      }
    />
  );
}

const option: EChartsOption = {
  grid: { left: 48, right: 16, top: 24, bottom: 84 },
  legend: { bottom: 0 },
  xAxis: { type: "category", data: ["Q1", "Q2", "Q3", "Q4"] },
  yAxis: { type: "value" },
  series: [
    { type: "bar", name: "North", data: [320, 332, 301, 334] },
    { type: "bar", name: "South", data: [220, 182, 191, 234] },
    { type: "bar", name: "East", data: [150, 232, 201, 154] },
  ],
};

<Chart
  option={option}
  variant="monochrome"
  renderTooltip={renderTooltip}
  width={480}
  height={320}
  accessibilityLabel="Grouped bar. Sales by region and quarter."
/>;
```
