Upgrading chart.js 1 to 2
Breaking1.1.1 → 2.9.4Breaking11Security4Deprecated17New147Changed64Fixed318Other266
BreakingUpgrade verdict
11 breaking changes and 3 security fixes.
In plain terms
- 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.
Must act 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).
What you must change
Breaking11
Removes date auto type conversions.
Renames Chart.layout to Chart.layouts.
Chart.layoutChart.layoutsDoughnut, polarArea and radar charts now default to aspectRatio 2 and are no longer square; set aspectRatio: 1 to restore the old behaviour.
aspectRatioRemoves the
lineArc setting for the radial linear scale, replaced by gridLines.circular and pointLabels.display.lineArcgridLines.circularpointLabels.displayRemoves the unused Chart.helpers.cancelAnimFrame method.
Chart.helpers.cancelAnimFrameThe default aspect ratio is now correctly applied, so polar, doughnut and radar charts render with an aspect ratio of 1 (square).
aspectRatioChart.defaults.doughnut.aspectRatioMakes
helpers._decimalPlaces private.helpers._decimalPlacesReplaces tooltip item xLabel and yLabel with label and value.
xLabelyLabellabelvalueRefactors 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.
onHoveronClickAllows sharing data between charts, requiring changes if dataset.metadata or dataset.metaDataset were used.
dataset.metadatadataset.metaDatasetSecurity3
Prevents global prototype pollution via the merge helper.
mergePrototype pollution in chart.js
mergeObject.create(null)High · CVSS 7.5Removes innerHTML usage from the DOM platform.
innerHTMLDeprecations to plan for
Deprecated16
Deprecates
Chart.{Type} classes.Chart.{Type}Deprecates
configMerge and scaleMerge helpers.configMergescaleMergeDocuments using parser instead of the deprecated format option.
parserformatDeprecates the time scale unitStepSize option in favour of stepSize.
unitStepSizestepSizeMerges
Chart.chart into Chart.Chart.chartChartMerges
Chart.Controller into Chart.Chart.ControllerChartMerges
Chart.Animation.animationObject into Chart.Animation.Chart.Animation.animationObjectChart.AnimationRemoves
Chart.Animation.chartInstance; use Chart.Animation.chart instead.Chart.Animation.chartInstanceChart.Animation.chartReplaces 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.afterLayoutExtending Chart.PlugingBase is no longer required and is strongly discouraged; use plain JavaScript objects to create and register plugins.
Chart.PlugingBaseRemoves deprecated Chart.pluginService from docs and replaces it with Chart.plugins.
Chart.pluginServiceChart.pluginsRenames
Chart.pluginService to Chart.plugins.Chart.pluginServiceChart.pluginsRenames the dataset tension property to lineTension; the old option still works in this release.
tensionlineTensionRenames the dataset radius property to pointRadius; the old option still works in this release.
radiuspointRadiusRenames Chart.defaults.Line to Chart.defaults.line; the old option still works in this release.
Chart.defaults.LineChart.defaults.lineChart.defaults.BarChart.defaults.bar