---
title: "Chart"
description: "Строит данные линиями, областями, столбцами или кольцом; SVG отрисовывается на сервере."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/chart"
---
# Chart

> Строит данные линиями, областями, столбцами или кольцом; SVG отрисовывается на сервере.

## Использование `2.15+`

Компонент Chart построен на [TanStack Charts](https://tanstack.com/charts/v1) и отрисовывает SVG на сервере.

TanStack Charts — необязательная peer-зависимость, сначала установите её:

```bash [pnpm]
pnpm add @tanstack/charts
```

```bash [yarn]
yarn add @tanstack/charts
```

```bash [npm]
npm install @tanstack/charts
```

```bash [bun]
bun add @tanstack/charts
```

### Данные

Пропс `data` принимает массив объектов, пропс `index` задаёт ключ для оси X, а пропс `categories` — ряды: у каждого есть `key` со значениями и необязательные `label` и `color`.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

> [!NOTE]
> Категории можно передать и строками, например `['desktop', 'mobile']`, если они хорошо читаются как названия.

> [!TIP]
> Пропс `aria-label` задаёт название графика для вспомогательных технологий.

### Тип

Пропс `type` меняет тип графика. По умолчанию — `line`.

> [!NOTE]
> При `donut` каждая строка `data` — отдельный сектор. `index` задаёт его подпись, а первый ключ `categories` — значение.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart type="donut" :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

### С накоплением

Пропс `stacked` складывает ряды друг на друга.

> [!WARNING]
> Пропс работает только при `type` равном `area` или `bar`.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart type="bar" stacked :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

### Кривая

Пропс `curve` меняет форму линии между значениями. По умолчанию — `linear`.

> [!WARNING]
> Пропс работает только при `type` равном `line` или `area`.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart type="line" curve="monotone" :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

### Цвета

Пропс `colors` задаёт цвет каждого ряда: цветами `air-*` (`air-primary`, `air-primary-success`, `air-primary-alert`, `air-primary-warning`, `air-primary-copilot`, `air-secondary-no-accent`) или любым CSS-цветом.

> [!NOTE]
> Цвета назначаются в порядке `categories`, а при `donut` — в порядке `data`. `color`, заданный у категории, приоритетнее. Если рядов больше, чем цветов, цвета повторяются в более светлых оттенках.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart :colors="{'0':'air-primary-success','1':'#8b5cf6'}" :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

> [!TIP]
> See: /docs/getting-started/theme/css-variables/#chart
> По умолчанию цвета берутся из CSS-переменных `--b24ui-chart-*`, которые можно переопределить в файле `main.css`.

### Точки

Пропс `points` рисует точку у каждого значения.

> [!WARNING]
> Пропс работает только при `type` равном `line`.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart points :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

### Сетка

Пропс `grid` включает и выключает горизонтальные линии сетки. По умолчанию — `true`.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart :grid="false" :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

### Оси

Пропсы `x-axis` и `y-axis` включают и выключают каждую ось. По умолчанию оба — `true`.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart :x-axis="false" :y-axis="false" :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

### Подписи осей

Пропсы `x-label` и `y-label` показывают заголовок вдоль каждой оси.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart x-label="Месяц" y-label="Посетители" :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

### Легенда

Пропс `legend` включает и выключает легенду.

> [!NOTE]
> По умолчанию легенда видна, если категорий больше одной (или секторов больше одного при `donut`).

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

### Подсказка

Пропс `tooltip` настраивает или скрывает [подсказку](https://b24-ui.bx-shef.by/raw/docs/components/tooltip.md), которая показывается у выбранных значений. По умолчанию — `true`.

> [!TIP]
> See: #with-tooltip-slot
> Содержимое подсказки заменяет слот `#tooltip`.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart :tooltip="false" :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

### Толщина

Пропс `thickness` задаёт толщину кольца в пикселях. По умолчанию — `24`.

> [!WARNING]
> Пропс работает только при `type` равном `donut`.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart type="donut" :thickness="12" :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

### Размер

Пропс `height` задаёт высоту графика в пикселях. По умолчанию — `300`.

> [!TIP]
> График занимает всю ширину контейнера. Пропс `aspect-ratio` выводит высоту из ширины, а пропс `width` задаёт фиксированную ширину.

> [!NOTE]
> При фиксированной высоте график плавно появляется после измерения контейнера. При `aspect-ratio` сразу показывается график, отрисованный на сервере.

```vue
<script setup lang="ts">
import type { ChartData } from '@bxshefby/b24ui-nuxt'

const data = ref<ChartData[]>([
  {
    month: 'Январь',
    desktop: 186,
    mobile: 80
  },
  {
    month: 'Февраль',
    desktop: 305,
    mobile: 200
  },
  {
    month: 'Март',
    desktop: 237,
    mobile: 120
  },
  {
    month: 'Апрель',
    desktop: 73,
    mobile: 190
  },
  {
    month: 'Май',
    desktop: 209,
    mobile: 130
  },
  {
    month: 'Июнь',
    desktop: 214,
    mobile: 140
  }
])
</script>

<template>
  <B24Chart :height="200" :data="data" index="month" :categories="{'0':{key:'desktop',label:'Компьютер'},'1':{key:'mobile',label:'Телефон'}}" />
</template>
```

## Примеры

### С форматированием значений

Пропс `format` форматирует значения на оси Y и в подсказке.

```vue [ChartFormatExample.vue]
<script setup lang="ts">
const data = [
  { month: 'Январь', revenue: 18600 },
  { month: 'Февраль', revenue: 30500 },
  { month: 'Март', revenue: 23700 },
  { month: 'Апрель', revenue: 27300 },
  { month: 'Май', revenue: 20900 },
  { month: 'Июнь', revenue: 31400 }
]

const currency = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', notation: 'compact' })
</script>

<template>
  <B24Chart
    type="bar"
    :data="data"
    index="month"
    :categories="[{ key: 'revenue', label: 'Выручка' }]"
    :format="value => currency.format(value)"
    aria-label="Выручка по месяцам"
  />
</template>
```

### С готовым описанием графика

Если остальных пропсов не хватает, пропс `definition` принимает готовое [описание графика TanStack Charts](https://tanstack.com/charts/v1/docs/concepts/chart-definitions).

> [!NOTE]
> See: https://tanstack.com/charts/v1
> Описание из примеров TanStack Charts отрисовывается как есть, с подсказкой и адаптивным размером.

```vue [ChartDefinitionExample.vue]
<script setup lang="ts">
import { defineChart, lineY, ruleY } from '@tanstack/charts'
import { scaleLinear } from '@tanstack/charts/scales/linear'
import { scalePoint } from '@tanstack/charts/scales/point'

const data = [
  { month: 'Январь', revenue: 186 },
  { month: 'Февраль', revenue: 305 },
  { month: 'Март', revenue: 237 },
  { month: 'Апрель', revenue: 273 },
  { month: 'Май', revenue: 209 },
  { month: 'Июнь', revenue: 314 }
]

const definition = defineChart({
  marks: [
    ruleY([250], { stroke: 'var(--ui-color-accent-main-alert)', strokeDasharray: '4 4' }),
    lineY(data, { x: 'month', y: 'revenue', stroke: 'var(--ui-color-accent-main-primary)', strokeWidth: 2, points: true })
  ],
  scales: {
    x: { scale: () => scalePoint<string>().padding(0.2) },
    y: { scale: scaleLinear, nice: true, grid: true, axis: { label: 'Выручка' } }
  }
})
</script>

<template>
  <B24Chart :definition="definition" aria-label="Выручка и целевой показатель" />
</template>
```

> [!TIP]
> See: /docs/getting-started/theme/css-variables/#chart
> Ряды без явного цвета берут цвет из CSS-переменных `--b24ui-chart-*`. Цвета, заданные в описании, сохраняются.

> [!CAUTION]
> Если в описании есть собственный `tooltip`, он показывается вместо пропса `tooltip`.

> [!WARNING]
> Примерам, которые импортируют пакеты `d3-*`, нужны эти пакеты в вашем проекте.

### Со слотом center

Слот `#center` показывает содержимое в центре кольцевого графика `donut`.

```vue [ChartCenterSlotExample.vue]
<script setup lang="ts">
const data = [
  { browser: 'Chrome', visitors: 275 },
  { browser: 'Safari', visitors: 200 },
  { browser: 'Firefox', visitors: 187 },
  { browser: 'Edge', visitors: 173 }
]
</script>

<template>
  <B24Chart
    type="donut"
    :data="data"
    index="browser"
    :categories="['visitors']"
    legend
    aria-label="Посетители по браузерам"
  >
    <template #center>
      <span class="text-(length:--ui-font-size-4xl) font-(--ui-font-weight-semi-bold) text-legend">835</span>
      <span class="text-(length:--ui-font-size-xs) text-description">Посетителей</span>
    </template>
  </B24Chart>
</template>
```

### Со слотом tooltip

Слот `#tooltip` заменяет содержимое подсказки. Он получает `title`, `rows` с их `label`, `value` и `color`, а также выбранные `points`.

```vue [ChartTooltipSlotExample.vue]
<script setup lang="ts">
const data = [
  { month: 'Январь', revenue: 18600, expenses: 12400 },
  { month: 'Февраль', revenue: 30500, expenses: 21800 },
  { month: 'Март', revenue: 23700, expenses: 25100 },
  { month: 'Апрель', revenue: 27300, expenses: 19600 },
  { month: 'Май', revenue: 20900, expenses: 22300 },
  { month: 'Июнь', revenue: 31400, expenses: 20700 }
]

const currency = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 })

function profit(month?: string) {
  const row = data.find(row => row.month === month)

  return row ? row.revenue - row.expenses : 0
}
</script>

<template>
  <B24Chart
    type="bar"
    :data="data"
    index="month"
    :categories="[{ key: 'revenue', label: 'Выручка', color: 'air-primary-success' }, { key: 'expenses', label: 'Расходы', color: 'air-primary-alert' }]"
    :format="value => currency.format(value)"
    aria-label="Выручка и расходы"
  >
    <template #tooltip="{ title, rows }">
      <p class="font-(--ui-font-weight-medium)">
        {{ title }}
      </p>

      <div v-for="row in rows" :key="row.label" class="flex items-center gap-2">
        <span class="size-2 rounded-full" :style="{ backgroundColor: row.color }" />
        <span class="opacity-75">{{ row.label }}</span>
        <span class="ms-auto ps-4 tabular-nums">{{ row.value }}</span>
      </div>

      <B24Separator class="my-1" />

      <div class="flex items-center gap-2">
        <span class="opacity-75">Прибыль</span>
        <B24Badge
          :color="profit(title) >= 0 ? 'air-primary-success' : 'air-primary-alert'"
          :label="currency.format(profit(title))"
          size="sm"
          class="ms-auto tabular-nums"
        />
      </div>
    </template>
  </B24Chart>
</template>
```

## API

### Пропсы

```ts
/**
 * Props for the Chart component
 */
interface ChartProps {
  /**
   * The type of chart to render.
   * @default 'line'
   */
  type?: "line" | "area" | "bar" | "donut" | undefined;
  /**
   * The rows to plot, one object per x value, or per slice with `donut`.
   */
  data?: T[] | undefined;
  /**
   * The key of each row used for the x axis, or for the slice labels with `donut`.
   */
  index?: keyof T & string | undefined;
  /**
   * The keys of each row plotted as series on the y axis, or objects to set their `label` and `color`.
   * With `donut`, the first one sets the slice values.
   */
  categories?: ((keyof T & string) | ChartCategory<T>)[] | undefined;
  /**
   * The series colors, in `categories` order, or in `data` order with `donut`. Accepts `air-*` colors or any CSS color.
   * When there are more series than colors, the colors repeat as lighter tints.
   * Defaults to the `--b24ui-chart-1` to `--b24ui-chart-6` CSS variables.
   */
  colors?: string[] | undefined;
  /**
   * Stack the series on top of each other. Only applies to `area` and `bar`.
   */
  stacked?: boolean | undefined;
  /**
   * The shape of the line between values. Only applies to `line` and `area`.
   * @default 'linear'
   */
  curve?: "linear" | "monotone" | "step" | undefined;
  /**
   * Draw a dot at each value. Only applies to `line`.
   * @default false
   */
  points?: boolean | undefined;
  /**
   * Display horizontal grid lines.
   * @default true
   */
  grid?: boolean | undefined;
  /**
   * Display the x axis.
   * @default true
   */
  xAxis?: boolean | undefined;
  /**
   * Display the y axis.
   * @default true
   */
  yAxis?: boolean | undefined;
  /**
   * A title displayed along the x axis.
   */
  xLabel?: string | undefined;
  /**
   * A title displayed along the y axis.
   */
  yLabel?: string | undefined;
  /**
   * Display a legend. Defaults to `true` when there is more than one category, or more than one slice with `donut`.
   */
  legend?: boolean | undefined;
  /**
   * Format the values on the y axis and in the tooltip.
   */
  format?: (value: number): string | undefined;
  /**
   * Display a tooltip on the focused values.
   * `{ content: { side: 'top', sideOffset: 12 } }`
   * @default true
   */
  tooltip?: boolean | TooltipProps | undefined;
  /**
   * Animate the chart when its data changes. Does not apply to `definition`, set `svgAnimation` on it instead.
   * @default true
   */
  transition?: boolean | undefined;
  /**
   * The width of the ring in pixels. Only applies to `donut`.
   * @default 24
   */
  thickness?: number | undefined;
  /**
   * The height of the chart in pixels. Defaults to `300` unless `aspectRatio` is set.
   */
  height?: number | undefined;
  /**
   * The width over height ratio of the chart, used when `height` is not set.
   */
  aspectRatio?: number | undefined;
  /**
   * A fixed width in pixels. The chart follows its container by default.
   */
  width?: number | undefined;
  /**
   * The width used on the server and before the container is measured.
   * @default 640
   */
  initialWidth?: number | undefined;
  /**
   * The accessible name of the chart. Defaults to the categories, set it when using `definition`.
   */
  ariaLabel?: string | undefined;
  /**
   * A longer description of the chart for assistive technologies.
   */
  ariaDescription?: string | undefined;
  /**
   * A complete TanStack Charts definition. Takes precedence over `data`, `index` and `categories`.
   * When it has its own `tooltip`, that one is used in place of the `tooltip` prop.
   */
  definition?: Omit<StaticChartDefinition<any, any, any, "dom">, "tooltip"> & { tooltip?: false | ChartTooltipInput<any, any, any, "dom"> | undefined; } | Omit<ResponsiveChartDefinition<any, any, any, "dom">, "tooltip"> & { tooltip?: false | ChartTooltipInput<any, any, any, "dom"> | undefined; } | undefined;
  b24ui?: { root?: SlotClass; base?: SlotClass; tooltip?: SlotClass; tooltipTitle?: SlotClass; tooltipRow?: SlotClass; tooltipIndicator?: SlotClass; tooltipLabel?: SlotClass; tooltipValue?: SlotClass; center?: SlotClass; } | undefined;
}
```

### Слоты

```ts
/**
 * Slots for the Chart component
 */
interface ChartSlots {
  tooltip(): any;
  center(): any;
}
```

### События

```ts
/**
 * Emitted events for the Chart component
 */
interface ChartEmits {
  select: (payload: [point: ChartPoint<any, ChartValue, ChartValue> | null]) => void;
  focusChange: (payload: [point: ChartPoint<any, ChartValue, ChartValue> | null]) => void;
  focusGroupChange: (payload: [points: readonly ChartPoint<any, ChartValue, ChartValue>[]]) => void;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    chart: {
      slots: {
        root: 'relative w-full text-(length:--ui-font-size-xs) text-muted **:data-reka-popper-content-wrapper:pointer-events-none [--ts-chart-tooltip-background:var(--ui-color-bg-content-inapp)] [--ts-chart-tooltip-color:var(--ui-color-base-8)] [--ts-chart-tooltip-border:1px_solid_var(--ui-color-bg-content-inapp)] [--ts-chart-tooltip-border-radius:var(--ui-border-radius-md)] [--ts-chart-tooltip-shadow:var(--popup-window-box-shadow)] [--ts-chart-tooltip-padding:6px_10px] [--ts-chart-tooltip-font:inherit]',
        base: 'opacity-0 in-data-measured:opacity-100 transition-opacity duration-150 [&_.ts-chart]:rounded-(--ui-border-radius-xs) [&_.ts-chart]:outline-0 [&_.ts-chart]:outline-(--ui-color-design-outline-focused-stroke) [&_.ts-chart:focus-visible]:outline-2',
        tooltip: 'flex-col items-stretch justify-start gap-[4px] h-auto min-h-0 min-w-32 py-[6px] px-[10px] pointer-events-none',
        tooltipTitle: 'font-(--ui-font-weight-medium)',
        tooltipRow: 'flex items-center gap-[6px] opacity-75 data-[active=true]:opacity-100',
        tooltipIndicator: 'size-2 shrink-0 rounded-full',
        tooltipLabel: 'truncate',
        tooltipValue: 'ms-auto ps-4 font-(--ui-font-weight-medium) tabular-nums',
        center: 'absolute inset-0 flex flex-col items-center justify-center pointer-events-none opacity-0 in-data-measured:opacity-100 transition-opacity duration-150'
      },
      variants: {
        type: {
          line: '',
          area: '',
          bar: '',
          donut: ''
        }
      }
    }
  }
})
```

## История изменений

<component-changelog>

</component-changelog>

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
