Skip to content

OrigamChartVariwide ​

Variwide chart family. Encodes two metrics simultaneously per category:

  • Bar HEIGHT → primary value (value field) mapped to the Y axis scale.
  • Bar WIDTH → secondary value (width field) proportional to its share of the total sum of widths.

Classic use-cases: GDP × population, revenue × market share, response time × request count.

Use this component when the type is fixed at variwide. Use OrigamChart with type="variwide" when you need runtime switching between chart families.

Import ​

ts
import { OrigamChartVariwide } from '@origam/ds'

Quick start ​

vue
<template>
  <origam-chart-variwide
    :series="[{
      name: 'GDP × Population',
      data: [
        { category: 'US', value: 23, width: 331 },
        { category: 'China', value: 18, width: 1411 },
        { category: 'Germany', value: 4.2, width: 83 }
      ]
    }]"
    :height="360"
    title="GDP × Population (2023)"
    subtitle="Width = population (M) · Height = GDP (T$)"
  />
</template>

<script setup lang="ts">
import { OrigamChartVariwide } from '@origam/ds'
</script>

Data shape ​

series[0].data accepts an array of IChartVariwideDatum:

ts
interface IChartVariwideDatum {
  category: string       // X-axis label
  value: number          // primary metric → bar HEIGHT
  width: number          // secondary metric → proportional bar WIDTH
  color?: TIntent | string  // optional per-datum color override
}

Plain number items (from IChartSeries.data) are accepted for compatibility; their width defaults to 1 (equal-width columns).

Props ​

Data ​

NameTypeDefaultDescription
seriesArray<IChartSeries>requiredReads series[0] only. Each datum becomes one column. Extra series are silently ignored.

Visual ​

NameTypeDefaultDescription
heightnumber | string360Chart height in px. Ignored when aspectRatio is set.
aspectRatiostringundefinedCSS aspect-ratio shorthand. Overrides height.
colorSchemeArray<TIntent | string>8-intent cyclePalette applied when a datum has no color. Supports intent names and raw CSS values.
titlestringundefinedOptional title above the chart. Replaceable via the #title slot.
subtitlestringundefinedOptional subtitle below the title.
barGapnumber2Gap in SVG pixels between adjacent columns. 0 = flush.
showLabelbooleantrueRender the primary value as a text label above each bar.
showAxisbooleantrueRender X (category) and Y (value) axes with tick marks and labels.
showGridbooleantrueRender horizontal grid lines aligned with Y-axis ticks.

Behaviour ​

NameTypeDefaultDescription
animatedbooleantrueAnimate bars on first paint. Respects prefers-reduced-motion.
animationDurationnumber600Animation duration in ms.
showLegendbooleanfalseToggle the legend block (off by default — variwide labels are on the X axis).
legendPositionTChartLegendPosition'bottom'Legend anchor: 'top', 'bottom', 'left', 'right'.
showTooltipbooleantrueToggle the hover tooltip.

Formatting ​

NameTypeDefaultDescription
xAxisFormat(value: string | number) => stringidentityApplied to X-axis category tick labels.
yAxisFormat(value: number) => stringString(value)Applied to Y-axis tick labels, the above-bar label, and the tooltip primary value.
yMinnumberautoOverride the computed Y minimum.
yMaxnumberautoOverride the computed Y maximum.

Emits ​

NamePayloadDescription
point-click(point: IChartPoint, event: MouseEvent | KeyboardEvent)Click or keyboard activation on a bar. point.x is the category label; point.y is the primary value.
legend-click(series: IChartSeries, index: number)Click on a legend entry.
series-toggle(series: IChartSeries, visible: boolean)Resulting visibility flip after a legend click.

Slots ​

NameBindingsDescription
tooltip{ point: IChartPoint, series: IChartSeries, category: string, value: number, widthValue: number, formattedValue: string, formattedWidth: string, color: string }Replace the default tooltip card. Receives both encodings.
legend-item{ series: IChartSeries, index: number, visible: boolean }Replace one legend entry.
title—Replace the title + subtitle block.
empty—Rendered when series is empty or has no valid data.

Behaviour notes ​

Responsive drawing surface (#1324). The SVG viewBox follows the measured box of the chart (useChartSize, a ResizeObserver), not a fixed 600 × 400 canvas. The plot fills the container width and height, the geometry is recomputed, and text, strokes and markers keep their real pixel size instead of being scaled with the viewBox. Until the box is measured (SSR, first paint) the 600 × 400 fallback is used, so hydration is unchanged. Give the chart a height / aspectRatio to change the box ratio.

Single-series only. The component reads series[0] exclusively. Extra series are ignored.

Width encoding geometry. Total column widths = Σ datum.width. Each bar gets plotWidth × (datum.width / totalWidth) - barGap SVG pixels wide. A country with population 1411 M (China) will be ~21× wider than one with 67 M (UK), making the two-dimensional encoding visually immediate.

Y scale. The Y axis maps from yMin (default min(0, min(values))) to yMax (default max(values)). Bars grow upward from y = scaleY(0).

Axis ticks. The X axis places one tick at the center of each column; the label is the category string (optionally formatted via xAxisFormat). The Y axis emits 5 evenly-spaced ticks (optionally formatted via yAxisFormat).

Empty state. When series is empty or series[0].data is empty, the #empty slot is rendered instead of the SVG.

Custom tooltip. The #tooltip slot receives both encoded values (value + widthValue / formattedValue + formattedWidth) so you can display both metrics with their respective units.

Accessibility. Each bar is a focusable <rect> with role="button" and an aria-label carrying the category, formatted value, and width value. The chart is a single tab stop (roving tabindex, #1333): Tab enters it once, the arrow keys move between points, Tab leaves it — see the key table in the OrigamChart page. Enter or Space activates a bar. The SVG carries a <title> and <desc> for screen-reader context.

Accessibility — the <desc> summary is localised AND agrees in number. The <desc> text is not an English literal: it resolves through the DS t() mechanism against origam.chart.variwide.desc*, and the grammatical form is chosen by Intl.PluralRules for the ACTIVE locale — never by a count === 1 test in the component. A translator supplies only the forms their language needs (_one / _other cover en and fr; a Russian translation adds _few with no component change), and a category a locale does not define falls back to _other rather than leaking the raw key.

Animation. Bars grow upward from the baseline on mount via a CSS scaleY keyframe. The animation is skipped when animated=false or prefers-reduced-motion: reduce is set.

Examples ​

GDP × Population ​

vue
<template>
  <origam-chart-variwide
    :series="[{
      name: 'GDP × Population',
      data: [
        { category: 'US', value: 23, width: 331 },
        { category: 'China', value: 18, width: 1411 },
        { category: 'Germany', value: 4.2, width: 83 },
        { category: 'Japan', value: 4.9, width: 125 },
        { category: 'India', value: 3.5, width: 1393 },
        { category: 'UK', value: 3.1, width: 67 }
      ]
    }]"
    :y-axis-format="(v) => v + ' T$'"
    :height="400"
    title="GDP × Population (2023)"
    subtitle="Width = population (M) · Height = GDP (T$)"
  />
</template>

<script setup lang="ts">
import { OrigamChartVariwide } from '@origam/ds'
</script>

Revenue × Market share with custom tooltip ​

vue
<template>
  <origam-chart-variwide
    :series="[{
      name: 'Revenue × Market share',
      data: [
        { category: 'Phone', value: 120, width: 38, color: 'primary' },
        { category: 'Laptop', value: 95, width: 22, color: 'success' },
        { category: 'Tablet', value: 42, width: 15, color: 'warning' },
        { category: 'Watch', value: 28, width: 14, color: 'danger' },
        { category: 'Earbuds', value: 18, width: 11, color: 'info' }
      ]
    }]"
    :height="360"
  >
    <template #tooltip="{ category, formattedValue, widthValue }">
      <div>
        <strong>{{ category }}</strong>
        <p>Revenue: {{ formattedValue }} M€</p>
        <p>Market share: {{ widthValue }}%</p>
      </div>
    </template>
  </origam-chart-variwide>
</template>

<script setup lang="ts">
import { OrigamChartVariwide } from '@origam/ds'
</script>

Composable reference ​

OrigamChartVariwide is a self-contained component — it does not ship a dedicated composable. All geometry is computed inside the component's <script setup> as pure computed() functions that depend only on props.