Charts

Scatter Plot

A scatter plot for the link between two quantities: both axes are labelled and start at zero, the ticks are rounded, and the dots are translucent so overlaps show.

  • chart
  • scatter
  • axes
  • svg

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/chart-019?lang=en

Время на странице и глубина просмотра

Ось X — seconds on page, ось Y — pages per visit. Обе оси начинаются с нуля.

Время на странице и глубина просмотра
Страницаseconds on pagepages per visit
Каталог122.4
Главная263.1
Компонент344.6
Блоки414.2
Документация486.1
Гайды555.4
Changelog637.2
Roadmap716.8
FAQ828.4
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-019" (Scatter Plot) 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-019.json

Registry item: https://vibeui.ru/r/chart-019.json
Installs to: components/vibeui/chart-019.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
A scatter plot for the link between two quantities: both axes are labelled and start at zero, the ticks are rounded, and the dots are translucent so overlaps show.

A scatter plot: two axes with rounded ticks, translucent dots, axis captions carrying direction and a horizontal grid. The data is mirrored in a hidden table with both coordinates. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Chart019 } from "@/components/vibeui/chart-019"

<Chart019
  xLabel="seconds on page"
  yLabel="pages per visit"
  dots={[{ label: "Catalog", x: 12, y: 2.4 }]}
/>

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-019-* palette — do not swap it for your theme tokens (bg-card, --chart-1 and the like)
- both axes starting at zero: on a scatter plot a truncated scale invents a correlation that is not there
- axis captions with units — without them a cloud of dots means nothing
- the translucency of the dots: without it overlaps collapse into a single dot and data is lost
- rotating the Y caption along its axis — a horizontal one eats a third of the card width
- the hidden table with both coordinates and aria-hidden on the svg

## 6. You may change
- the dots array: a label and a coordinate pair per point
- title — the chart heading
- xLabel and yLabel — the axis captions together with their units
- the accent through the accent prop — it colours the dots
- the dot radius and the chart height through the viewBox

## 7. Rules
- A trend line is deliberately absent: regression needs a model, this component only shows points.
- Beyond forty dots the cloud turns into a blot: aggregate or add transparency.
- Dots are not labelled on the plot: the names live in the table, otherwise the labels collide.
- 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-019.json
https://vibeui.ru/r/chart-019.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-chart-019-*. Серверный: хуков нет. Верх каждой оси округляется niceCeil до 1 / 2 / 2.5 / 5 × 10ⁿ, поэтому деления подписаны круглыми числами. Подпись оси Y повёрнута вдоль неё через transform: горизонтальная съела бы треть ширины карточки. Точки полупрозрачны, чтобы наложения читались как сгущение. Данные продублированы визуально скрытой таблицей с обеими координатами.

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 Chart019Dot = {
  label: string
  x: number
  y: number
}

export type Chart019Props = Omit<
  ComponentPropsWithoutRef<"figure">,
  "children" | "title"
> & {
  title?: string
  dots?: Chart019Dot[]
  xLabel?: string
  yLabel?: string
  accent?: string
}

// Идея компонента: диаграмма рассеяния для связи двух величин. Обе оси
// подписаны и начинаются от нуля, деления округляются до круглых чисел, а
// подпись оси Y повёрнута вдоль неё — иначе она съедает половину ширины.
// Точки полупрозрачны: наложения видно, и облако не превращается в кляксу.
const STYLES = `
:where([data-vibeui-block="chart-019"]){
--vibeui-chart-019-bg:oklch(1 0 0);
--vibeui-chart-019-fg:oklch(0.22 0.014 265);
--vibeui-chart-019-muted:oklch(0.55 0.014 265);
--vibeui-chart-019-border:oklch(0.91 0.006 265);
--vibeui-chart-019-grid:oklch(0.94 0.005 265);
--vibeui-chart-019-axis:oklch(0.78 0.01 265);
--vibeui-chart-019-accent:oklch(0.55 0.17 300);
--vibeui-chart-019-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="chart-019"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:26rem;box-sizing:border-box;margin:0;padding:0.875rem;
background:var(--vibeui-chart-019-bg);
border:1px solid var(--vibeui-chart-019-border);border-radius:0.875rem;
color:var(--vibeui-chart-019-fg);font-family:var(--vibeui-chart-019-font);
}
[data-vibeui-block="chart-019"] [data-part="title"]{margin:0;font-size:0.875rem;font-weight:650}
[data-vibeui-block="chart-019"] svg{display:block;width:100%;height:auto}
[data-vibeui-block="chart-019"] [data-part="grid"]{stroke:var(--vibeui-chart-019-grid);stroke-width:1}
[data-vibeui-block="chart-019"] [data-part="axis"]{stroke:var(--vibeui-chart-019-axis);stroke-width:1}
[data-vibeui-block="chart-019"] [data-part="dot"]{
fill:var(--vibeui-chart-019-accent);fill-opacity:0.6;
stroke:var(--vibeui-chart-019-accent);stroke-width:1;
}
[data-vibeui-block="chart-019"] [data-part="tick-x"]{
fill:var(--vibeui-chart-019-muted);font-size:8px;text-anchor:middle;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="chart-019"] [data-part="tick-y"]{
fill:var(--vibeui-chart-019-muted);font-size:8px;text-anchor:end;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="chart-019"] [data-part="axis-name"]{
fill:var(--vibeui-chart-019-fg);font-size:8.5px;font-weight:600;
}
[data-vibeui-block="chart-019"] [data-part="unit"]{margin:0;font-size:0.75rem;color:var(--vibeui-chart-019-muted)}
[data-vibeui-block="chart-019"] [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-019"] *{animation:none!important;transition:none!important}}
`

const LEFT = 34
const RIGHT = 292
const TOP = 12
const BASE = 148

function niceCeil(value: number) {
  if (value <= 0) {
    return 1
  }

  const power = 10 ** Math.floor(Math.log10(value))

  for (const step of [1, 2, 2.5, 5]) {
    if (value <= step * power) {
      return step * power
    }
  }

  return 10 * power
}

const DEFAULT_DOTS: Chart019Dot[] = [
  { label: "Каталог", x: 12, y: 2.4 },
  { label: "Главная", x: 26, y: 3.1 },
  { label: "Компонент", x: 34, y: 4.6 },
  { label: "Блоки", x: 41, y: 4.2 },
  { label: "Документация", x: 48, y: 6.1 },
  { label: "Гайды", x: 55, y: 5.4 },
  { label: "Changelog", x: 63, y: 7.2 },
  { label: "Roadmap", x: 71, y: 6.8 },
  { label: "FAQ", x: 82, y: 8.4 },
]

/**
 * Диаграмма рассеяния двух величин с подписанными осями.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Chart019({
  title = "Время на странице и глубина просмотра",
  dots = DEFAULT_DOTS,
  xLabel = "секунд на странице",
  yLabel = "страниц за визит",
  accent,
  className,
  style,
  ...props
}: Chart019Props) {
  const xTop = niceCeil(Math.max(...dots.map((dot) => dot.x), 1))
  const yTop = niceCeil(Math.max(...dots.map((dot) => dot.y), 1))
  const xTicks = [0, xTop / 2, xTop]
  const yTicks = [0, yTop / 2, yTop]

  const palette = {
    ...(accent ? { "--vibeui-chart-019-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-chart-019" precedence="medium">
        {STYLES}
      </style>
      <figure
        {...props}
        data-vibeui-block="chart-019"
        className={className}
        style={palette}
      >
        <figcaption data-part="title">{title}</figcaption>
        <svg viewBox="0 0 300 178" aria-hidden="true" focusable="false">
          {yTicks.map((tick) => {
            const y = BASE - (tick / yTop) * (BASE - TOP)

            return (
              <g key={`y${tick}`}>
                <line data-part="grid" x1={LEFT} y1={y} x2={RIGHT} y2={y} />
                <text data-part="tick-y" x={LEFT - 6} y={y + 3}>
                  {tick}
                </text>
              </g>
            )
          })}
          {xTicks.map((tick) => {
            const x = LEFT + (tick / xTop) * (RIGHT - LEFT)

            return (
              <text key={`x${tick}`} data-part="tick-x" x={x} y={BASE + 13}>
                {tick}
              </text>
            )
          })}
          <line data-part="axis" x1={LEFT} y1={TOP} x2={LEFT} y2={BASE} />
          <line data-part="axis" x1={LEFT} y1={BASE} x2={RIGHT} y2={BASE} />
          {dots.map((dot) => (
            <circle
              key={dot.label}
              data-part="dot"
              cx={LEFT + (dot.x / xTop) * (RIGHT - LEFT)}
              cy={BASE - (dot.y / yTop) * (BASE - TOP)}
              r={4.5}
            />
          ))}
          <text data-part="axis-name" x={RIGHT} y={BASE + 26} textAnchor="end">
            {xLabel} →
          </text>
          {/* Подпись оси Y повёрнута вдоль неё: горизонтальная съела бы
              треть ширины карточки. */}
          <text
            data-part="axis-name"
            transform={`translate(11 ${BASE}) rotate(-90)`}
          >
            {yLabel} →
          </text>
        </svg>
        <p data-part="unit">
          Ось X — {xLabel}, ось Y — {yLabel}. Обе оси начинаются с нуля.
        </p>
        <table data-part="data">
          <caption>{title}</caption>
          <thead>
            <tr>
              <th scope="col">Страница</th>
              <th scope="col">{xLabel}</th>
              <th scope="col">{yLabel}</th>
            </tr>
          </thead>
          <tbody>
            {dots.map((dot) => (
              <tr key={dot.label}>
                <th scope="row">{dot.label}</th>
                <td>{dot.x}</td>
                <td>{dot.y}</td>
              </tr>
            ))}
          </tbody>
        </table>
      </figure>
    </>
  )
}