mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 20:29:12 +02:00
e39970d494
Alphabetize migration guide
8.0 KiB
8.0 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.
End user migration
Setup and installation
- Chart.js is no longer providing the
Chart.bundle.js
andChart.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. moment
is no longer specified as an npm dependency. If you are using the time scale, you must include one of the available adapters and corresponding date library. If you are using a date library other than moment, you no longer need to exclude moment from your build.
Ticks
options.ticks.userCallback
was renamed tooptions.ticks.callback
Tooltip
xLabel
andyLabel
were removed. Please useindex
andvalue
Interactions
{mode: 'label'}
was replaced with{mode: 'index'}
{mode: 'single'}
was replaced with{mode: 'nearest', intersect: true}
modes['X-axis']
was replaced with{mode: 'index', intersect: false}
options.onClick
is now limited to the chart area
Customizability
custom
attribute of elements was removed. Please use scriptable options- The
hover
property of scriptable optionscontext
object was renamed toactive
to align it with the datalabels plugin. - The
zeroLine*
options of axes were removed. Use scriptable scale options instead.
Options
scales.[x/y]Axes
arrays were removed. Scales are now configured directly tooptions.scales
object with the object key being the scale Id.scales.[x/y]Axes.barPercentage
was moved to dataset optionbarPercentage
scales.[x/y]Axes.barThickness
was moved to dataset optionbarThickness
scales.[x/y]Axes.categoryPercentage
was moved to dataset optioncategoryPercentage
scales.[x/y]Axes.maxBarThickness
was moved to dataset optionmaxBarThickness
scales.[x/y]Axes.minBarLength
was moved to dataset optionminBarLength
scales.[x/y]Axes.ticks.beginAtZero
was renamed toscales[id].beginAtZero
scales.[x/y]Axes.ticks.max
was renamed toscales[id].max
scales.[x/y]Axes.ticks.min
was renamed toscales[id].min
scales.[x/y]Axes.ticks.reverse
was renamed toscales[id].reverse
scales.[x/y]Axes.ticks.suggestedMax
was renamed toscales[id].suggestedMax
scales.[x/y]Axes.ticks.suggestedMin
was renamed toscales[id].suggestedMin
scales.[x/y]Axes.time.format
was renamed toscales[id].time.parser
scales.[x/y]Axes.time.max
was renamed toscales[id].max
scales.[x/y]Axes.time.min
was renamed toscales[id].min
- The dataset option
tension
was renamed tolineTension
Animations
Animation system was completely rewritten in Chart.js v3. Each property can now be animated separately. Please see animations docs for details.
hover.animationDuration
is now configured inanimation.active.duration
responsiveAnimationDuration
is now configured inanimation.resize.duration
Developer migration
Removed
Chart.chart.chart
Chart.Controller
Chart.types
DatasetController.addElementAndReset
DatasetController.createMetaData
DatasetController.createMetaDataset
Element.getArea
Element.height
Element.initialize
Element.inLabelRange
helpers.addEvent
helpers.aliasPixel
helpers.configMerge
helpers.indexOf
helpers.lineTo
helpers.max
helpers.min
helpers.nextItem
helpers.numberOfLabelLines
helpers.previousItem
helpers.removeEvent
helpers.roundedRect
helpers.scaleMerge
helpers.where
IPlugin.afterScaleUpdate
. UseafterLayout
insteadLine.calculatePointY
Scale.getRightValue
Scale.handleDirectionalChanges
is now privateScale.mergeTicksOptions
Scale.ticksAsNumbers
Scale.tickValues
is now private- The tooltip item's
x
andy
attributes were removed. UsedatasetIndex
andindex
to get the element and any corresponding data from it
Removal of private APIs
Chart.data.datasets[datasetIndex]._meta
Element._ctx
Element._model
Element._view
TimeScale._getPixelForOffset
TimeScale.getLabelWidth
Renamed
Chart.Animation.animationObject
was renamed toChart.Animation
Chart.Animation.chartInstance
was renamed toChart.Animation.chart
DatasetController.updateElement
was renamed toDatasetController.updateElements
helpers._decimalPlaces
was renamed tohelpers.math._decimalPlaces
helpers.almostEquals
was renamed tohelpers.math.almostEquals
helpers.almostWhole
was renamed tohelpers.math.almostWhole
helpers.callCallback
was renamed tohelpers.callback
helpers.clear
was renamed tohelpers.canvas.clear
helpers.distanceBetweenPoints
was renamed tohelpers.math.distanceBetweenPoints
helpers.drawRoundedRectangle
was renamed tohelpers.canvas.roundedRect
helpers.getAngleFromPoint
was renamed tohelpers.math.getAngleFromPoint
helpers.getMaximumHeight
was renamed tohelpers.dom.getMaximumHeight
helpers.getMaximumWidth
was renamed tohelpers.dom.getMaximumWidth
helpers.getRelativePosition
was renamed tohelpers.dom.getRelativePosition
helpers.getStyle
was renamed tohelpers.dom.getStyle
helpers.getValueAtIndexOrDefault
was renamed tohelpers.valueAtIndexOrDefault
helpers.getValueOrDefault
was renamed tohelpers.valueOrDefault
helpers.easingEffects
was renamed tohelpers.easing.effects
helpers.log10
was renamed tohelpers.math.log10
helpers.isNumber
was renamed tohelpers.math.isNumber
helpers.sign
was renamed tohelpers.math.sign
helpers.retinaScale
was renamed tohelpers.dom.retinaScale
helpers.splineCurve
was renamed tohelpers.curve.splineCurve
helpers.splineCurveMonotone
was renamed tohelpers.curve.splineCurveMonotone
helpers.toDegrees
was renamed tohelpers.math.toDegrees
helpers.toRadians
was renamed tohelpers.math.toRadians
Scale.calculateTickRotation
was renamed toScale.calculateLabelRotation
TimeScale.getLabelCapacity
was renamed toTimeScale._getLabelCapacity
TimeScale.getPixelForOffset
was renamed toTimeScale._getPixelForOffset
TimeScale.tickFormatFunction
was renamed toTimeScale._tickFormatFunction
Tooltip.options.legendColorBackgroupd
was renamed toTooltip.options.multiKeyBackground
Renamed private APIs
helpers._alignPixel
was renamed tohelpers.canvas._alignPixel
helpers._decimalPlaces
was renamed tohelpers.math._decimalPlaces
Changed
Scales
Scale.getLabelForIndex
was replaced byscale.getLabelForValue
Scale.getPixelForValue
now has only one parameter. For theTimeScale
that parameter must be millis since the epoch
Ticks
Scale.afterBuildTicks
now has no parameters like the other callbacksScale.buildTicks
is now expected to return tick objectsScale.convertTicksToLabels
was renamed togenerateTickLabels
. It is now expected to set the label property on the ticks given as inputScale.ticks
now contains objects instead of strings- When the
autoSkip
option is enabled,Scale.ticks
now contains only the non-skipped ticks instead of all ticks.
Time Scale
getValueForPixel
now returns milliseconds since the epoch
Controllers
Core Controller
- The first parameter to
updateHoverStyle
is now an array of objects containing theelement
,datasetIndex
, andindex
Dataset Controllers
setHoverStyle
andremoveHoverStyle
now additionally take thedatasetIndex
andindex
Interactions
- Interaction mode methods now return an array of objects containing the
element
,datasetIndex
, andindex