Migrate from Recharts

fromRecharts reads JSX, or an object with chart, data, and children. LineChart, AreaChart, BarChart, PieChart, ScatterChart, and ComposedChart map. A missing Legend or Tooltip becomes legend: false or tooltip: false, matching Recharts, which draws neither unless you add the component.

The spec then runs validate() and repair(). Unmapped keys come back as warnings. @chartkitdev/convert is unpublished and is not in the ChartKit bundles.

ts
import { fromRecharts } from "@chartkitdev/convert";

const { spec, warnings } = fromRecharts(jsx);

Mapped

  • LineChart line
  • AreaChart area
  • BarChart grouped and stacked (stackId)
  • horizontal bars (layout vertical)
  • Pie and Pie innerRadius as donut
  • ScatterChart
  • bubble when ZAxis is set
  • ComposedChart combo
  • stacked bars beside an unstacked line
  • Legend, Tooltip, CartesianGrid
  • XAxis and YAxis labels
  • ReferenceLine and ReferenceArea
  • curve monotone, linear, and step

Warned, not mapped

  • RadialBarChart
  • Brush, ErrorBar, and LabelList
  • custom shapes and render props
  • JSX spreads and unbound identifiers

Pie innerRadius in pixels is divided by 100 and stored as a fraction. That is an approximation. RadialBarChart, Brush, ErrorBar, LabelList, custom shapes, JSX spreads, and unbound identifiers warn. ReferenceLine and ReferenceArea become rule and band annotations.

Try this source in the converter. Getting started renders one spec next to the charts you already have.