mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
3.6 KiB
3.6 KiB
Chart.js 3.x Migration Guide
Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released in April 2016. In the years since then, as Chart.js has grown in popularity and feature set, we've learned some lessons about how to better create a charting library. In order to improve performance, offer new features, and improve maintainability it was necessary to break backwards compatibility, but we aimed to do so only when necessary.
Setup
Chart.js is no longer providing the Chart.bundle.js and Chart.bundle.min.js. Please see the installation and integration docs for details on the recommended way to setup Chart.js if you were using these builds.
End user migration
Ticks
options.ticks.userCallbackwas renamed tooptions.ticks.callback
Tooltip
xLabelandyLabelwere removed. Please useindexandvalue
Interactions
options.onClickis now limited to the chart area{mode: 'single'}was replaced with{mode: 'nearest', intersect: true}{mode: 'label'}was replaced with{mode: 'index'}modes['X-axis']was replaced with{mode: 'index', intersect: false}
Customizability
customattribute of elements was removed. Please use scriptable options
Options
- The dataset option
tensionwas renamed tolineTension scales.[x/y]Axes.barPercentagewas moved to dataset optionbarPercentagescales.[x/y]Axes.barThicknesswas moved to dataset optionbarThicknessscales.[x/y]Axes.categoryPercentagewas moved to dataset optioncategoryPercentagescales.[x/y]Axes.minBarLengthwas moved to dataset optionminBarLengthscales.[x/y]Axes.maxBarThicknesswas moved to dataset optionmaxBarThicknessscales.[x/y]Axes.time.formatwas renamed toscales.[x/y]Axes.time.parserscales.[x/y]Axes.time.minwas renamed toscales.[x/y]Axes.ticks.minscales.[x/y]Axes.time.maxwas renamed toscales.[x/y]Axes.ticks.max
Developer migration
Removed
afterScaleUpdatehelpers.addEventhelpers.aliasPixelhelpers.configMergehelpers.indexOfhelpers.minhelpers.maxhelpers.numberOfLabelLineshelpers.removeEventhelpers.scaleMergescale.getRightValuescale.mergeTicksOptionsscale.ticksAsNumbersChart.ControllerChart.chart.chartChart.typesLine.calculatePointY- Made
scale.handleDirectionalChangesprivate - Made
scale.tickValuesprivate
Renamed
helpers.clearwas renamed tohelpers.canvas.clearhelpers.drawRoundedRectanglewas renamed tohelpers.canvas.roundedRecthelpers.callCallbackwas renamed tohelpers.callbackhelpers.getValueOrDefaultwas renamed tohelpers.valueOrDefaulthelpers.getValueAtIndexOrDefaultwas renamed tohelpers.valueAtIndexOrDefaulthelpers.easingEffectswas renamed tohelpers.easing.effectshelpers.log10was renamed tohelpers.math.log10Chart.Animation.animationObjectwas renamed toChart.AnimationChart.Animation.chartInstancewas renamed toChart.Animation.chart
Changed
Scales
scale.getLabelForIndexwas replaced byscale.getLabelForValuescale.getPixelForValuenow has only one parameter
Ticks
scale.ticksnow contains objects instead of stringsbuildTicksis now expected to return tick objectsafterBuildTicksnow has no parameters like the other callbacksconvertTicksToLabelswas renamed togenerateTickLabels. It is now expected to set the label property on the ticks given as input
Time Scale
getValueForPixelnow returns milliseconds since the epoch