react ~10 KB 0 deps v0.1.0 ↗ GitHub ↗

@mshafiqyajid/react-chart

Pure SVG chart components — BarChart, LineChart, PieChart. Animations, legends, labels, multi-series. Zero external dependencies.

Playground #

JanFebMarAprMayJun

Install #

npm install @mshafiqyajid/react-chart

Quick start #

import { BarChart, LineChart, PieChart } from "@mshafiqyajid/react-chart/styled";
import "@mshafiqyajid/react-chart/styles.css";

const data = [
  { label: "Jan", value: 42 },
  { label: "Feb", value: 68 },
  { label: "Mar", value: 55 },
];

<BarChart data={data} height={240} showValues animated />
<LineChart data={data} height={240} showDots showGrid animated />
<PieChart data={pieData} showLegend animated />

BarChart props #

PropTypeDefaultDescription
dataDataPoint[] | SeriesDataPoint[]Chart data
widthnumber600SVG width
heightnumber300SVG height
direction"vertical" | "horizontal""vertical"Bar orientation
stackedbooleanfalseStacked bars (multi-series)
gapnumber4Gap between bars in pixels
radiusnumber3Bar corner radius
showValuesbooleanfalseShow value labels on bars
animatedbooleanfalseAnimate on mount
colorsstring[]Custom bar colors (overrides tone)
onClick(point, index) => voidBar click handler
xLabelstringX-axis label
yLabelstringY-axis label
tooltipbooleantrueShow hover tooltip

LineChart props #

PropTypeDefaultDescription
dataDataPoint[] | SeriesDataPoint[]Chart data
widthnumber600SVG width
heightnumber300SVG height
showGridbooleanfalseShow grid lines
showDotsbooleantrueShow data point dots
showLabelsbooleanfalseShow X-axis labels
showLegendbooleanfalseShow series legend
smoothbooleanfalseCurved line interpolation
tone"neutral" | "primary""neutral"Line color tone (flat data)
animatedbooleanfalseAnimate on mount
colorsstring[]Custom line colors (overrides tone)
areabooleanfalseFill area under the line
onClick(point, index) => voidData point click handler
xLabelstringX-axis label
yLabelstringY-axis label
tooltipbooleantrueShow hover tooltip

PieChart props #

PropTypeDefaultDescription
dataDataPoint[]Slice data (with optional color)
sizenumber300SVG size in px
donutbooleanfalseRender as donut chart
donutWidthnumber60Donut ring thickness
showLabelsbooleanfalseShow slice labels inside arcs
showLegendbooleanfalseShow color legend
animatedbooleanfalseAnimate on mount
onClick(slice, index) => voidSlice click handler
tooltipbooleantrueShow hover tooltip
innerLabelReactNodeLabel rendered in donut center
Edit this page on GitHub