@kiwa-lab/chart
v2.1.0
Published
Chart mock harness for kiwa — Recharts / Chart.js / D3 / Visx を統一 interface で invoke する in-process mock。 chart data + render (bar/line/pie/scatter) + axis 計算 + legend capture + tooltip dispatch までを real chart library と同じ signature で叩ける test infra。
Maintainers
Readme
@kiwa-lab/chart
Chart data + render mock harness for kiwa — Recharts / Chart.js / D3 / Visx を統一 interface で in-process から叩ける test infra。
Installation
pnpm add -D @kiwa-lab/chart
# or
npm install -D @kiwa-lab/chart
# or
yarn add -D @kiwa-lab/chartSupported providers
| Provider | Status | Render model | |---|---|---| | Recharts | ✅ Ready | React component tree | | Chart.js | ✅ Ready | canvas descriptor | | D3 | ✅ Ready | svg selection | | Visx | ✅ Ready | React + d3-scale |
Quick start
import { describe, expect, it } from 'vitest';
import {
createChartClient,
renderChart,
computeAxis,
captureLegend,
} from '@kiwa-lab/chart';
describe('bar chart', () => {
it('data から svg-like tree + axis tick を生成', () => {
const client = createChartClient({ provider: 'recharts' });
const spec = {
kind: 'bar' as const,
series: [{ name: 's1', data: [{ x: 1, y: 10 }, { x: 2, y: 20 }] }],
};
const chart = renderChart(client, spec);
const axis = computeAxis({ min: 0, max: 20, ticks: 5 });
const legend = captureLegend(chart);
expect(chart.nodes.length).toBeGreaterThan(0);
expect(axis.tickValues).toHaveLength(5);
expect(legend[0]!.name).toBe('s1');
});
});API reference
createChartClient({ provider: ChartProvider }): ChartClient— provider 別 clientrenderChart(client, spec: ChartSpec): RenderedChart— bar/line/pie/scatter を tree 化computeAxis(options: AxisOptions): AxisResult— tick + domain + scalecaptureLegend(chart: RenderedChart): LegendEntry[]— legend entry 抽出dispatchTooltip(chart, event: TooltipEvent): TooltipContent— interaction 経路
Test integration
vitest + /kiwa-chart skill で real canvas / svg render なしで data-to-visual pipeline を高速 verify。
License
UNLICENSED — see github.com/cardene777/kiwa.
