Charts
Stacked Columns
Columns split into layers: the height answers «how much in total», the shares inside answer «of what», and the legend names the series.
- chart
- stacked
- columns
- legend
Preview
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this in the header: https://vibeui.ru/c/chart-015?lang=en
- Новые
- Повторные
- Партнёрские
Единица измерения: orders per month. Максимум столбца — 130.
| Период | Новые | Повторные | Партнёрские | Всего |
|---|---|---|---|---|
| Май | 42 | 28 | 12 | 82 |
| Июн | 51 | 30 | 14 | 95 |
| Июл | 46 | 36 | 18 | 100 |
| Авг | 58 | 41 | 15 | 114 |
| Сен | 64 | 44 | 22 | 130 |
Show the full instructions
What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.
# Install and place "chart-015" (Stacked Columns) from VibeUI
## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/chart-015.json
Registry item: https://vibeui.ru/r/chart-015.json
Installs to: components/vibeui/chart-015.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.
Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.
## 2. What it is
Columns split into layers: the height answers «how much in total», the shares inside answer «of what», and the legend names the series.
Stacked columns: the column height is the period total against the global maximum, the layers inside are distributed by flex, the legend names the series and the axis labels the periods. The data is mirrored in a hidden table with totals. Zero dependencies, one file, no client JS.
## 3. How to use it
import { Chart015 } from "@/components/vibeui/chart-015"
<Chart015
title="Orders by source"
series={["New", "Returning"]}
periods={[{ label: "May", values: [42, 28] }]}
/>
Read the installed file for the full prop list.
## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.
Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)
## 5. Keep exactly as installed
- the local --vibeui-chart-015-* palette — do not swap it for your theme tokens (bg-card, --chart-1 and the like)
- the column height as a percentage of the global maximum: pixel maths breaks whenever the plot height changes
- distributing layers by flex-grow rather than per-layer percentages — the sum always adds up exactly
- column-reverse on the stack: the first series must stay at the base across every period
- the legend naming the series, not just their colours: a colour never names a series
- the hidden table with per-period totals and aria-hidden on the plot — the data must be readable as text
## 6. You may change
- the periods array and the series names
- title — the chart heading
- unit — the unit named in the caption under the chart
- the accent through the accent prop — it colours the first series
- the plot height through --vibeui-chart-015-height
## 7. Rules
- More than four series stop being distinguishable: the colours blur and thin layers vanish.
- The series order must match the order of numbers in each period's values — the component does not match them by name.
- A stack answers «what the whole is made of» but not «how did the second series move»: that wants separate lines.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.
## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.For developers
npx shadcn@latest add https://vibeui.ru/r/chart-015.jsonhttps://vibeui.ru/r/chart-015.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-chart-015-*. Серверный: хуков нет. Высота столбца — процент от общего максимума суммы периода, слои внутри складываются флексом по flex-grow, поэтому пересчёт долей в пиксели не нужен. Стек развёрнут column-reverse, чтобы первая серия оставалась у основания. Область помечена aria-hidden, данные продублированы визуально скрытой таблицей с итогом по каждому периоду.
Component source
The same file your agent installs. Here in case you would rather copy it by hand.
import type { ComponentPropsWithoutRef, CSSProperties } from "react"
export type Chart015Period = {
label: string
values: number[]
}
export type Chart015Props = Omit<
ComponentPropsWithoutRef<"figure">,
"children" | "title"
> & {
title?: string
series?: string[]
periods?: Chart015Period[]
unit?: string
accent?: string
}
// Идея компонента: столбцы, разложенные на слои. Высота всего столбца
// отвечает «сколько всего», а доли внутри — «из чего». Слои складываются
// флексом от суммы, а не пересчитываются в пиксели, поэтому высота области
// меняется одной переменной и ничего не ломает.
const STYLES = `
:where([data-vibeui-block="chart-015"]){
--vibeui-chart-015-bg:oklch(1 0 0);
--vibeui-chart-015-fg:oklch(0.22 0.014 265);
--vibeui-chart-015-muted:oklch(0.55 0.014 265);
--vibeui-chart-015-border:oklch(0.91 0.006 265);
--vibeui-chart-015-track:oklch(0.96 0.004 265);
--vibeui-chart-015-height:9rem;
--vibeui-chart-015-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="chart-015"]{
display:flex;flex-direction:column;gap:0.625rem;
width:100%;max-width:30rem;box-sizing:border-box;margin:0;padding:0.875rem;
background:var(--vibeui-chart-015-bg);
border:1px solid var(--vibeui-chart-015-border);border-radius:0.875rem;
color:var(--vibeui-chart-015-fg);font-family:var(--vibeui-chart-015-font);
}
[data-vibeui-block="chart-015"] [data-part="title"]{margin:0;font-size:0.875rem;font-weight:650}
[data-vibeui-block="chart-015"] [data-part="plot"]{
display:flex;align-items:flex-end;gap:0.5rem;height:var(--vibeui-chart-015-height);
padding-bottom:0.25rem;border-bottom:1px solid var(--vibeui-chart-015-border);
}
[data-vibeui-block="chart-015"] [data-part="column"]{
flex:1 1 0;display:flex;flex-direction:column;justify-content:flex-end;height:100%;
}
/* Слои идут снизу вверх, поэтому column-reverse: первый ряд серии остаётся
у основания и не прыгает между периодами. */
[data-vibeui-block="chart-015"] [data-part="stack"]{
display:flex;flex-direction:column-reverse;width:100%;border-radius:0.25rem;overflow:hidden;
background:var(--vibeui-chart-015-track);
}
[data-vibeui-block="chart-015"] [data-part="layer"]{
min-height:2px;background:var(--vibeui-chart-015-layer);
}
[data-vibeui-block="chart-015"] [data-part="axis"]{
display:flex;gap:0.5rem;margin:0;padding:0;list-style:none;
font-size:0.6875rem;color:var(--vibeui-chart-015-muted);
}
[data-vibeui-block="chart-015"] [data-part="axis"] li{flex:1 1 0;text-align:center}
[data-vibeui-block="chart-015"] [data-part="legend"]{
display:flex;flex-wrap:wrap;gap:0.25rem 0.875rem;margin:0;padding:0;list-style:none;
font-size:0.75rem;
}
[data-vibeui-block="chart-015"] [data-part="legend"] li{display:flex;align-items:center;gap:0.375rem}
[data-vibeui-block="chart-015"] [data-part="chip"]{
width:0.625rem;height:0.625rem;border-radius:2px;background:var(--vibeui-chart-015-layer);
}
[data-vibeui-block="chart-015"] [data-part="unit"]{margin:0;font-size:0.75rem;color:var(--vibeui-chart-015-muted)}
[data-vibeui-block="chart-015"] [data-part="data"]{
position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;
clip-path:inset(50%);white-space:nowrap;border:0;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="chart-015"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_SERIES = ["Новые", "Повторные", "Партнёрские"]
const DEFAULT_PERIODS: Chart015Period[] = [
{ label: "Май", values: [42, 28, 12] },
{ label: "Июн", values: [51, 30, 14] },
{ label: "Июл", values: [46, 36, 18] },
{ label: "Авг", values: [58, 41, 15] },
{ label: "Сен", values: [64, 44, 22] },
]
const HUES = [265, 200, 150, 40, 320]
/**
* Стековые столбцы с легендой серий и общей шкалой.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Chart015({
title = "Заказы по источникам",
series = DEFAULT_SERIES,
periods = DEFAULT_PERIODS,
unit = "заказов в месяц",
accent,
className,
style,
...props
}: Chart015Props) {
const totals = periods.map((period) =>
period.values.reduce((sum, value) => sum + value, 0),
)
const max = Math.max(...totals, 1)
const tone = (index: number) =>
accent && index === 0
? accent
: `oklch(${0.5 + index * 0.09} ${0.15 - index * 0.03} ${HUES[index % HUES.length]})`
const palette = {
...(accent ? { "--vibeui-chart-015-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-chart-015" precedence="medium">
{STYLES}
</style>
<figure
{...props}
data-vibeui-block="chart-015"
className={className}
style={palette}
>
<figcaption data-part="title">{title}</figcaption>
<div data-part="plot" aria-hidden="true">
{periods.map((period, periodIndex) => (
<div key={period.label} data-part="column">
<div
data-part="stack"
style={{ height: `${(totals[periodIndex] / max) * 100}%` }}
>
{period.values.map((value, seriesIndex) => (
<span
key={series[seriesIndex] ?? seriesIndex}
data-part="layer"
style={
{
flexGrow: value,
flexBasis: 0,
"--vibeui-chart-015-layer": tone(seriesIndex),
} as CSSProperties
}
/>
))}
</div>
</div>
))}
</div>
<ul data-part="axis" aria-hidden="true">
{periods.map((period) => (
<li key={period.label}>{period.label}</li>
))}
</ul>
<ul data-part="legend">
{series.map((name, index) => (
<li key={name}>
<span
data-part="chip"
aria-hidden="true"
style={
{ "--vibeui-chart-015-layer": tone(index) } as CSSProperties
}
/>
{name}
</li>
))}
</ul>
<p data-part="unit">
Единица измерения: {unit}. Максимум столбца — {max}.
</p>
<table data-part="data">
<caption>
{title}, {unit}
</caption>
<thead>
<tr>
<th scope="col">Период</th>
{series.map((name) => (
<th key={name} scope="col">
{name}
</th>
))}
<th scope="col">Всего</th>
</tr>
</thead>
<tbody>
{periods.map((period, periodIndex) => (
<tr key={period.label}>
<th scope="row">{period.label}</th>
{period.values.map((value, seriesIndex) => (
<td key={series[seriesIndex] ?? seriesIndex}>{value}</td>
))}
<td>{totals[periodIndex]}</td>
</tr>
))}
</tbody>
</table>
</figure>
</>
)
}