Skip to main content

GenericChart

A Recharts-based chart component that renders bar, line, area, pie, donut, composed, radar, scatter, and table charts from a unified ChartConfig object.

πŸ“– Storybook

Preview​

Import​

import { GenericChart } from "@xocialive/ui-components";

Basic usage​

import { GenericChart } from "@xocialive/ui-components";
import type { ChartConfig } from "@xocialive/ui-components";

const config: ChartConfig = {
type: "bar",
title: "Monthly Revenue",
data: [
{ month: "Jan", revenue: 42000 },
{ month: "Feb", revenue: 55000 },
{ month: "Mar", revenue: 48000 },
],
series: [{ dataKey: "revenue", name: "Revenue" }],
xAxis: { dataKey: "month" },
legend: { show: true },
};

<GenericChart config={config} />;

Chart types​

typeDescription
"bar"Vertical or horizontal bar chart
"line"Line chart
"area"Area chart
"pie"Pie / donut chart

Props​

PropTypeDefaultDescription
typeChartTypeβ€”Chart variant
dataobject[]β€”Data array
xKeystringβ€”Key used for the x-axis / pie labels
seriesSeriesConfig[]β€”Series definitions
heightnumber250Chart height in pixels
colorsstring[]CHART_COLORSColour array
showLegendbooleantrueToggle legend visibility
showGridbooleantrueToggle background grid lines
sxSxProps<Theme>β€”Wrapper style overrides