> ## 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.

# Area

> Area chart implementation for @servicetitan/anvil2-charts-kit.

An area chart shows trends with magnitude, drawing filled bands under the line. Anvil2 documents stacked area only, not overlapped. Use `monochrome` for four or fewer variables, and `categorical` for five or more. Area charts do not use the semantic palette.

* Design rules: [Area charts](https://anvil.servicetitan.com/docs/data-visualization/area-charts.md)
* Shared API / selection / tooltips / palettes: [Chart component](https://anvil.servicetitan.com/docs/charts/web/chart.md)

***

## Minimal option

An ECharts area is a line series with `areaStyle` set. An empty object is enough, because `variant` fills the band. Set `stack` in the option: stacking carries meaning rather than styling, and Anvil2 area charts are stacked.

charts-react-area

[StackBlitz demo](https://stackblitz.com/github/servicetitan/anvil2-docs-live-code/tree/main/examples/charts-react-area?file=src/App.tsx)

```tsx lines expandable theme={null}
import { Chart, type EChartsOption } from "@servicetitan/anvil2-charts-kit";
import "@servicetitan/anvil2-charts-kit/styles.css";

function App() {
  const option: EChartsOption = {
    grid: { left: 48, right: 16, top: 24, bottom: 84 },
    legend: { bottom: 0 },
    xAxis: {
      type: "category",
      boundaryGap: false,
      data: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
    },
    yAxis: { type: "value" },
    series: [
      {
        type: "line",
        name: "Revenue",
        stack: "total",
        data: [320, 332, 301, 334, 390, 330],
        areaStyle: {},
      },
      {
        type: "line",
        name: "Costs",
        stack: "total",
        data: [220, 182, 191, 234, 290, 330],
        areaStyle: {},
      },
      {
        type: "line",
        name: "Profit",
        stack: "total",
        data: [150, 232, 201, 154, 190, 330],
        areaStyle: {},
      },
    ],
  };

  return (
    <Chart
      option={option}
      variant="monochrome"
      width={480}
      height={300}
      accessibilityLabel="Area chart. Stacked revenue components by month."
    />
  );
}

export default App;
```

***

## Variant styling

`variant` applies the following treatment:

| Concern | Behavior |
| - | - |
| Band fill | Palette by series index, solid, with striped or outlined monochrome steps |
| Band separators | Surface-colored stroke between stacked bands |
| Markers | Disabled, since the bands already separate the series |

Avoid adding fades, opacities, or separator strokes to reproduce this treatment, and avoid overlapped areas that rely on transparency instead of stacking.

***

## Tooltips

Pass `renderTooltip` to add hover content. See [Chart component](https://anvil.servicetitan.com/docs/charts/web/chart.md#tooltips). Area charts have no markers to hit, so the chart reports the whole category and `points` holds one entry per series.

charts-react-area-tooltip

[StackBlitz demo](https://stackblitz.com/github/servicetitan/anvil2-docs-live-code/tree/main/examples/charts-react-area-tooltip?file=src/App.tsx)

```tsx lines expandable theme={null}
import {
  Chart,
  type ChartTooltipInfo,
  type EChartsOption,
} from "@servicetitan/anvil2-charts-kit";
import "@servicetitan/anvil2-charts-kit/styles.css";
import { CartoTheme, Text, TooltipSurface } from "@servicetitan/anvil2-ai-kit";
// This file is most likely already in your workspace
import "@servicetitan/anvil2-ai-kit/styles.css";

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

function App() {
  const option: EChartsOption = {
    grid: { left: 48, right: 16, top: 24, bottom: 84 },
    legend: { bottom: 0 },
    xAxis: {
      type: "category",
      boundaryGap: false,
      data: ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
    },
    yAxis: { type: "value" },
    series: [
      {
        type: "line",
        name: "Revenue",
        stack: "total",
        data: [320, 332, 301, 334, 390, 330],
        areaStyle: {},
      },
      {
        type: "line",
        name: "Costs",
        stack: "total",
        data: [220, 182, 191, 234, 290, 330],
        areaStyle: {},
      },
      {
        type: "line",
        name: "Profit",
        stack: "total",
        data: [150, 232, 201, 154, 190, 330],
        areaStyle: {},
      },
    ],
  };

  return (
    <CartoTheme>
      <Chart
        option={option}
        variant="monochrome"
        renderTooltip={renderTooltip}
        width={480}
        height={300}
        accessibilityLabel="Area chart. Stacked revenue components by month."
      />
    </CartoTheme>
  );
}

export default App;
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.