ViolinChart
See the distribution, the agreement or the uncertainty in the values you supply.
@luc/ui/chartsWhat it shows
Compare distribution shapes across groups when a supplied density outline is more informative than a box summary.
Live preview
Three supplied density outlines with the median the caller computed; nothing here is fitted.
<ViolinChart
groups={[
{
label: "Baseline",
tone: "neutral",
marker: { value: 0, label: "median" },
bins: [
{ value: -2, density: 0.04 },
{ value: -1.4, density: 0.14 },
{ value: -0.8, density: 0.31 },
{ value: -0.2, density: 0.45 },
{ value: 0.4, density: 0.38 },
{ value: 1, density: 0.2 },
{ value: 1.6, density: 0.07 },
],
},
{
label: "Trend",
tone: "accent",
marker: { value: 0.6, label: "median" },
bins: [
{ value: -1.2, density: 0.03 },
{ value: -0.5, density: 0.12 },
{ value: 0.2, density: 0.34 },
{ value: 0.9, density: 0.46 },
{ value: 1.6, density: 0.3 },
{ value: 2.3, density: 0.13 },
{ value: 3, density: 0.04 },
],
},
{
label: "Carry",
tone: "info",
bins: [
{ value: -2.6, density: 0.06 },
{ value: -1.9, density: 0.17 },
{ value: -1.2, density: 0.33 },
{ value: -0.5, density: 0.42 },
{ value: 0.2, density: 0.29 },
{ value: 0.9, density: 0.14 },
{ value: 1.6, density: 0.05 },
],
},
]}
valueFormat={{ kind: "percent", decimals: 1 }}
height={320}
ariaLabel="Density per family"
/>Controls
Presets
Title
Also the chart's accessible name when no `ariaLabel` is given.
Height
Value format
Presentation only: the chart formats what it is given and never converts a unit.
State
Accessible name
Leave it empty and the chart names itself from the title and the family.
The outline is supplied, never fitted: this fixture is the caller's own density estimate.
Code
import { ViolinChart } from "@luc/ui/charts";
const groups = [
{
label: "1D",
tone: "accent",
bins: [
{ value: 0, density: 0.1 },
{ value: 0.01, density: 0.6 },
{ value: 0.02, density: 1 },
{ value: 0.03, density: 0.55 },
{ value: 0.04, density: 0.12 },
],
marker: { value: 0.02 },
},
{
label: "20D",
tone: "neutral",
bins: [
{ value: 0.02, density: 0.1 },
{ value: 0.04, density: 0.55 },
{ value: 0.06, density: 1 },
{ value: 0.08, density: 0.6 },
{ value: 0.1, density: 0.15 },
],
marker: { value: 0.06 },
},
];
<ViolinChart groups={groups} />Not controllable here
groups— The density outline is the caller's model output; the preview supplies a fixed outline and the copied code writes it out.onReady— A callback is your application's behaviour, not a previewable value.className— Layout and width belong to the page that places the chart.
Copy for an AI agentA specification an agent can act on: the import, the setup, the chosen props, the data contract and the accessibility expectation.
Implement `ViolinChart` from Luc UI. It is: See the distribution, the agreement or the uncertainty in the values you supply.
Import it with: import { ViolinChart } from "@luc/ui/charts";
Requires: react ^19.0.0; react-dom ^19.0.0; react-hook-form ^7.0.0 (optional, for @luc/ui/forms/react-hook-form); tailwindcss ^4.0.0; node >= 22 (repository tools). Import the stylesheet once at the app root and wrap the tree in `LucProvider`. Both come from the package that publishes @luc.
Chosen configuration: `title=""`, `height={260}`, `state="ready"`, `valueFormat="auto"`, `ariaLabel=""`.
Accessibility: keep the component's own semantics. Do not re-implement its ARIA wiring, do not add roles it does not declare, and make sure every interactive element is reachable and operable from the keyboard with a visible focus state.
Styling: use Luc UI design tokens and the component's own props. Do not restyle with raw colour literals and do not override the component's internal structure with page CSS.
Motion: respect `prefers-reduced-motion`. The component already does, so do not disable it.
Reproduce this state:
```tsx
const groups = [
{
label: "1D",
tone: "accent",
bins: [
{ value: 0, density: 0.1 },
{ value: 0.01, density: 0.6 },
{ value: 0.02, density: 1 },
{ value: 0.03, density: 0.55 },
{ value: 0.04, density: 0.12 },
],
marker: { value: 0.02 },
},
{
label: "20D",
tone: "neutral",
bins: [
{ value: 0.02, density: 0.1 },
{ value: 0.04, density: 0.55 },
{ value: 0.06, density: 1 },
{ value: 0.08, density: 0.6 },
{ value: 0.1, density: 0.15 },
],
marker: { value: 0.06 },
},
];
<ViolinChart groups={groups} />
```Usage
The values are prepared by the caller: this component draws the points it is given and computes no statistic of its own, so units, scaling and any summary have to be settled before the data reaches it.
It is drawn by the ECharts engine.
Worked examples with real data are on the family overview: Statistical
import { ViolinChart } from "@luc/ui/charts";<ViolinChart
groups={[
{
label: "Baseline",
tone: "neutral",
marker: { value: 0, label: "median" },
bins: [
{ value: -2, density: 0.04 },
{ value: -1.4, density: 0.14 },
{ value: -0.8, density: 0.31 },
{ value: -0.2, density: 0.45 },
{ value: 0.4, density: 0.38 },
{ value: 1, density: 0.2 },
{ value: 1.6, density: 0.07 },
],
},
{
label: "Trend",
tone: "accent",
marker: { value: 0.6, label: "median" },
bins: [
{ value: -1.2, density: 0.03 },
{ value: -0.5, density: 0.12 },
{ value: 0.2, density: 0.34 },
{ value: 0.9, density: 0.46 },
{ value: 1.6, density: 0.3 },
{ value: 2.3, density: 0.13 },
{ value: 3, density: 0.04 },
],
},
{
label: "Carry",
tone: "info",
bins: [
{ value: -2.6, density: 0.06 },
{ value: -1.9, density: 0.17 },
{ value: -1.2, density: 0.33 },
{ value: -0.5, density: 0.42 },
{ value: 0.2, density: 0.29 },
{ value: 0.9, density: 0.14 },
{ value: 1.6, density: 0.05 },
],
},
]}
valueFormat={{ kind: "percent", decimals: 1 }}
height={320}
ariaLabel="Density per family"
/>Data contract
`groups` contain `label`, density `bins` of `{ value, density }`, and an optional supplied `marker`. The chart draws density; it does not fit a kernel.
Important configuration
Use `valueFormat` for the measured unit, show the median marker only when it was computed upstream, and keep group order meaningful.
Guidelines
When not to use
Do not pass raw observations as density bins or compare violins built with different bandwidths without saying so.
Configuration
| Export | Kind | Signature |
|---|---|---|
ViolinChart | 12 documented props | ({ groups, valueFormat, title, description, state, height, className, ariaLabel, ariaDescription, onReady, onEvent, eager, }: ViolinChartProps) => import("@types/react").JSX.Element |
ViolinChart props
Type: ViolinChartProps
Values the compiler reads from the declaration.
| Prop | Type | Default | Notes |
|---|---|---|---|
ariaDescription? | string | undefined | — | |
ariaLabel? | string | undefined | — | |
className? | string | undefined | — | |
description? | string | undefined | — | |
eager? | boolean | undefined | — | Create the engine on mount rather than when the surface is approached. |
groups | readonly ViolinGroup[] | — | |
height? | string | number | undefined | — | |
onEvent? | ((event: EChartEvent) => void) | undefined | — | |
onReady? | ((chart: EChartsInstance) => void) | undefined | — | |
state? | ChartState | undefined | — | |
title? | string | undefined | — | |
valueFormat? | ChartFormat | undefined | — |
Accessibility
A chart is a picture of data, so it needs a name that states what it shows, and the numbers must exist as text somewhere on the page — in a table or a written summary — because a drawing is not readable by a screen reader and cannot be copied.
What happens on the server, and when hydration changes it.
Family
Statistical
Distributions, agreement and uncertainty — all from prepared values.
Related