Skip to content

Upgrading chart.js 1 to 2

Breaking1.1.1 → 2.9.4Breaking11Security4Deprecated17New147Changed64Fixed318Other266

BreakingUpgrade verdict

11 breaking changes and 3 security fixes.

  • Dates are no longer automatically converted between types.
  • Renames Chart.layout to Chart.layouts.
  • Doughnut, polar area and radar charts are no longer square by default. Set the aspect ratio to 1 to get the old square shape back.
  • If you used the old radar chart line setting, switch to the two new options instead.
Top 5 of 30 that need code or config changes

Adds chartjs-color ^2.1.0, moment ^2.10.2.

Installs 6 packages in all (was 0).

Breaking11
Removes date auto type conversions.
Renames Chart.layout to Chart.layouts.
Chart.layoutChart.layouts
Doughnut, polarArea and radar charts now default to aspectRatio 2 and are no longer square; set aspectRatio: 1 to restore the old behaviour.
aspectRatio
Removes the lineArc setting for the radial linear scale, replaced by gridLines.circular and pointLabels.display.
lineArcgridLines.circularpointLabels.display
Removes the unused Chart.helpers.cancelAnimFrame method.
Chart.helpers.cancelAnimFrame
The default aspect ratio is now correctly applied, so polar, doughnut and radar charts render with an aspect ratio of 1 (square).
aspectRatioChart.defaults.doughnut.aspectRatio
Makes helpers._decimalPlaces private.
helpers._decimalPlaces
Replaces tooltip item xLabel and yLabel with label and value.
xLabelyLabellabelvalue
Refactors the bar controller internals, so custom chart types extending the bar controller must be updated.
The onHover callback now receives 3 parameters, with the event that triggered the hover as the 2nd parameter.
onHoveronClick
Allows sharing data between charts, requiring changes if dataset.metadata or dataset.metaDataset were used.
dataset.metadatadataset.metaDataset
Security3
Prevents global prototype pollution via the merge helper.
merge
Prototype pollution in chart.js
mergeObject.create(null)High · CVSS 7.5
Removes innerHTML usage from the DOM platform.
innerHTML
Deprecated16
Deprecates Chart.{Type} classes.
Chart.{Type}
Deprecates configMerge and scaleMerge helpers.
configMergescaleMerge
Documents using parser instead of the deprecated format option.
parserformat
Deprecates the time scale unitStepSize option in favour of stepSize.
unitStepSizestepSize
Merges Chart.chart into Chart.
Chart.chartChart
Merges Chart.Controller into Chart.
Chart.ControllerChart
Merges Chart.Animation.animationObject into Chart.Animation.
Chart.Animation.animationObjectChart.Animation
Removes Chart.Animation.chartInstance; use Chart.Animation.chart instead.
Chart.Animation.chartInstanceChart.Animation.chart
Replaces the 'zero', 'top', 'bottom' fill modes with 'origin', 'start', 'end'.
'zero''top''bottom''origin''start''end'
Deprecates IPlugin.afterScaleUpdate in favor of the IPlugin.afterLayout hook.
IPlugin.afterScaleUpdateIPlugin.afterLayout
Extending Chart.PlugingBase is no longer required and is strongly discouraged; use plain JavaScript objects to create and register plugins.
Chart.PlugingBase
Removes deprecated Chart.pluginService from docs and replaces it with Chart.plugins.
Chart.pluginServiceChart.plugins
Renames Chart.pluginService to Chart.plugins.
Chart.pluginServiceChart.plugins
Renames the dataset tension property to lineTension; the old option still works in this release.
tensionlineTension
Renames the dataset radius property to pointRadius; the old option still works in this release.
radiuspointRadius
Renames Chart.defaults.Line to Chart.defaults.line; the old option still works in this release.
Chart.defaults.LineChart.defaults.lineChart.defaults.BarChart.defaults.bar