Migrate from Chart.js

fromChartJs reads a config object, including new Chart(ctx, config) and a const config = { ... } assignment. v3 options.plugins and options.scales map fully. v2 options.title, options.legend, and scales.xAxes or yAxes map in part and warn.

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 { fromChartJs } from "@chartkitdev/convert";

const { spec, warnings } = fromChartJs(config);

Mapped

  • line
  • area (dataset.fill)
  • bar
  • bar grouped
  • bar stacked
  • grouped stacks (several stack ids)
  • horizontal bar (indexAxis y)
  • pie
  • doughnut
  • scatter
  • bubble
  • combo (mixed dataset types)
  • title
  • legend
  • tooltip
  • axis title, min, max, beginAtZero, grid
  • series colour
  • v2 title, legend, and xAxes/yAxes

Warned, not mapped

  • radar
  • polarArea
  • time scale adapters
  • plugins.annotation and other plugins
  • scriptable options and canvas gradients
  • per-point colour arrays on bars (first colour only)
  • more than two y axes

Radar, polarArea, time-scale adapters, annotation plugins, scriptable options, canvas gradients, and a third y axis warn. A per-point colour array keeps the first colour and warns. A stack id is a stack group: series that share it stack. A stack id used once stays beside the others.

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