mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-07 04:39:06 +02:00
1f3cf3c28d
* Remove createElement and pre-allocate arrays * Address review comment
6.2 KiB
6.2 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
options.onClick
is 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
custom
attribute of elements was removed. Please use scriptable options- The
zeroLine*
options of axes were removed. Use scriptable scale options instead. - The
hover
property of scriptable optionscontext
object was renamed toactive
to align it with the datalabels plugin.
Options
- The dataset option
tension
was renamed tolineTension
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.minBarLength
was moved to dataset optionminBarLength
scales.[x/y]Axes.maxBarThickness
was moved to dataset optionmaxBarThickness
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
Developer migration
Removed
helpers.addEvent
helpers.aliasPixel
helpers.configMerge
helpers.indexOf
helpers.lineTo
helpers.min
helpers.max
helpers.nextItem
helpers.numberOfLabelLines
helpers.previousItem
helpers.removeEvent
helpers.roundedRect
helpers.scaleMerge
Chart.Controller
Chart.chart.chart
Chart.types
DatasetController.addElementAndReset
DatasetController.createMetaData
DatasetController.createMetaDataset
Element.getArea
Element.height
Element.initialize
Element.inLabelRange
IPlugin.afterScaleUpdate
. UseafterLayout
insteadLine.calculatePointY
Scale.getRightValue
Scale.mergeTicksOptions
Scale.ticksAsNumbers
Scale.handleDirectionalChanges
is now privateScale.tickValues
is now private
Removal of private APIs
Chart.data.datasets[datasetIndex]._meta
Element._ctx
Element._model.datasetLabel
Element._model.label
Point._model.tension
Point._model.steppedLine
TimeScale._getPixelForOffset
TimeScale.getLabelWidth
Renamed
helpers.clear
was renamed tohelpers.canvas.clear
helpers.drawRoundedRectangle
was renamed tohelpers.canvas.roundedRect
helpers.callCallback
was renamed tohelpers.callback
helpers.getValueOrDefault
was renamed tohelpers.valueOrDefault
helpers.getValueAtIndexOrDefault
was renamed tohelpers.valueAtIndexOrDefault
helpers.easingEffects
was renamed tohelpers.easing.effects
helpers.log10
was renamed tohelpers.math.log10
Chart.Animation.animationObject
was renamed toChart.Animation
Chart.Animation.chartInstance
was renamed toChart.Animation.chart
DatasetController.updateElement
was renamed toDatasetController.updateElements
TimeScale.getLabelCapacity
was renamed toTimeScale._getLabelCapacity
TimeScale.tickFormatFunction
was renamed toTimeScale._tickFormatFunction
TimeScale.getPixelForOffset
was renamed toTimeScale._getPixelForOffset
Renamed private APIs
helpers._alignPixel
was renamed tohelpers.canvas._alignPixel
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
- When the
autoSkip
option is enabled,Scale.ticks
now contains only the non-skipped ticks instead of all ticks. Scale.ticks
now contains objects instead of stringsScale.buildTicks
is now expected to return tick objectsScale.afterBuildTicks
now has no parameters like the other callbacksScale.convertTicksToLabels
was renamed togenerateTickLabels
. It is now expected to set the label property on the ticks given as input
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
now additionally takes thedatasetIndex
andindex
Interactions
- Interaction mode methods now return an array of objects containing the
element
,datasetIndex
, andindex