Klar

Charts / React BI charts / Comparison

Slope chart

Each line’s value in two years joined by a slope, coloured by direction against the median, so risers and fallers separate instantly.

React component SlopeChart, data through props. Side by side: who, which source, which version is ahead. Tags: slope, before-after, two-points, change, ranking, comparison.

Install

npm i klar-charts

import 'klar-charts/styles.css'
import { ThemeScope, SlopeChart } from 'klar-charts'

# or copy the source:
npx shadcn@latest add https://klar.run/r/bi-slope.json

Usage

<SlopeChart
  data={marginByLine}
  labels={['FY2025', 'FY2026']}
  height={500}
  format={(v) => `${v.toFixed(1)}%`}
  deltaFormat={pts}
  threshold={0.5}
  highlight={h as 'both' | 'risers' | 'fallers'}
/>

Related slope charts