Comparison · Intermediate

Slope chart

Change in size and rank between two points in time.

Open in playground
Use when
Comparing just two points in time, such as last year's and this year's share
Avoid when
3 or more points in time (use a line or bump chart)

Try it

21

Slope chart

Market share by brand (%)
Slope chartSlope chart. 2024 to 2025: Our brand 18%→27%, Brand A 31%→28%, Brand B 24%→21%, Brand C 15%→14%, Brand D 12%→10%.Our brand 18%27% Our brandBrand A 31%28% Brand ABrand B 24%21% Brand BBrand C 15%14% Brand CBrand D 12%10% Brand D
Slope chart data
Our brand2024 18% → 2025 27%
Brand A2024 31% → 2025 28%
Brand B2024 24% → 2025 21%
Brand C2024 15% → 2025 14%
Brand D2024 12% → 2025 10%
Only we rose sharplyIntermediate

Hover over the chart, or Tab in and use the arrow keys to move between items. The numbers are sample data.

Code

SlopeChart.tsx
import { ChartCard, SlopeChart } from "ztd-charts";

const data = [
  {"brand":"Our brand","period":"2024","share":18},
  {"brand":"Our brand","period":"2025","share":27},
  {"brand":"Brand A","period":"2024","share":31},
  {"brand":"Brand A","period":"2025","share":28},
  {"brand":"Brand B","period":"2024","share":24},
  {"brand":"Brand B","period":"2025","share":21},
  // … 4 more rows
];

export function Example() {
  return (
    <ChartCard number="21" title="Slope chart" subtitle="Market share by brand (%)" takeaway="Only we rose sharply" level="intermediate" replay>
      <SlopeChart
        data={data}
        label="brand"
        x="period"
        value="share"
        unit="%"
      />
    </ChartCard>
  );
}

Props

<SlopeChart> takes these props. Rows marked Common work the same on every chart.

28 props

Prop
dataRequiredAn array of objects. Pass CSV, REST or database rows as they areobject[]
labelRequiredItem name fieldstring | (d, i) => string
xPeriod field (long tables)string | (d, i) => string
valueValue field (long tables)string | (d, i) => number
startWide table: start value fieldstring
endWide table: end value fieldstring
periodLabelsTitles above the two axesstring[]
heightCommonHeight in px. Without it, each chart picks a default that fits its widthnumber
widthCommonFixed width in px. Without it, the chart fits its parentnumber
highlightCommonItem to highlight. An index, a name, an array, or "max" | "min" | "first" | "last" | "none"number | string | (number|string)[] | "max" …
formatCommonValue format. "number" | "integer" | "percent" (values are already percents: 42 → "42%") | "ratio" (0.42 → "42%") | "compact" | "currency" (KRW for Korean locales, otherwise USD; for another currency pass Intl options with currency) | "decimal" or Intl.NumberFormat options"number" | "percent" | "compact" | …
unitCommonUnit appended to values. For example "%" or "ms"string
localeCommonLocale for numbers, dates and the text a chart writes itself (tooltips, screen reader sentences). "ko" or "ko-*" switches to Korean. Falls back to the ThemeProvider localestringDefault "en-US"
animateCommonEntry and update animationbooleanDefault true
durationCommonAnimation length (ms)number
easingCommonMotion curve"spring" | "easeOut" | "easeInOut" | "linear"Default "spring"
staggerCommonDelay between items as they enter (ms)number
reducedMotionCommon"auto" follows the OS setting. true always turns motion offanyDefault "auto"
animateOnViewCommonPlay when the chart scrolls into viewbooleanDefault true
showLabelsCommonLabels drawn on the chart (values and names)booleanDefault true
tooltipCommonShow tooltips. { template: "{label} · {value} · owner {owner}" } writes them: {label}, {value}, {series} or any other column of the row. \n starts a new line, and a line with an empty value is left outtooltipDefault true
syncIdCommonCharts with the same syncId show the hovered x together (line, area, bar, candlestick). <ChartGrid sync> sets one for every chart inside itstring
ariaLabelCommonName for screen readersstring
descriptionCommonDescription for screen readers. Built from the data when omittedstring
onHoverCommonRuns when hover or keyboard focus moves to another item(e: ChartEvent | null) => void
onClickCommonRuns on click, Enter or Space(e: ChartEvent) => void
replayKeyCommonReplays the entry animation when it changesstring | number
themeCommonChanges theme tokens for this chart onlyPartial<ChartTheme>