* `Chart.Animation.animationObject` was renamed to `Chart.Animation`
* `Chart.Animation.chartInstance` was renamed to `Chart.Animation.chart`
* `DatasetController.createMetaData` and `DatasetController.createMetaDataset` were replaced with `DatasetController.createElement`
+* `DatasetController.updateElement` was renamed to `DatasetController.updateElements`
* `TimeScale.getLabelCapacity` was renamed to `TimeScale._getLabelCapacity`
* `TimeScale.tickFormatFunction` was renamed to `TimeScale._tickFormatFunction`
* `TimeScale.getPixelForOffset` was renamed to `TimeScale._getPixelForOffset`
},
update: function(reset) {
- var me = this;
- var rects = me._cachedMeta.data;
- var i, ilen;
-
- me._ruler = me.getRuler();
+ const me = this;
+ const rects = me._cachedMeta.data;
- for (i = 0, ilen = rects.length; i < ilen; ++i) {
- me.updateElement(rects[i], i, reset);
- }
+ me.updateElements(rects, 0, rects.length, reset);
},
- updateElement: function(rectangle, index, reset) {
- var me = this;
- var options = me._resolveDataElementOptions(index);
+ updateElements: function(rectangles, start, count, reset) {
+ const me = this;
+ const vscale = me._cachedMeta.vScale;
+ const base = vscale.getBasePixel();
+ const horizontal = vscale.isHorizontal();
+ const ruler = me.getRuler();
+ let i;
+
+ for (i = 0; i < start + count; i++) {
+ const rectangle = rectangles[i];
+ const options = me._resolveDataElementOptions(i);
+ const vpixels = me.calculateBarValuePixels(i, options);
+ const ipixels = me.calculateBarIndexPixels(i, ruler, options);
+
+ rectangle._model = {
+ backgroundColor: options.backgroundColor,
+ borderColor: options.borderColor,
+ borderSkipped: options.borderSkipped,
+ borderWidth: options.borderWidth
+ };
+
+ const model = rectangle._model;
+
+ // all borders are drawn for floating bar
+ if (me._getParsed(i)._custom) {
+ model.borderSkipped = null;
+ }
- rectangle._model = {
- backgroundColor: options.backgroundColor,
- borderColor: options.borderColor,
- borderSkipped: options.borderSkipped,
- borderWidth: options.borderWidth
- };
+ model.horizontal = horizontal;
+ model.base = reset ? base : vpixels.base;
+ model.x = horizontal ? reset ? base : vpixels.head : ipixels.center;
+ model.y = horizontal ? ipixels.center : reset ? base : vpixels.head;
+ model.height = horizontal ? ipixels.size : undefined;
+ model.width = horizontal ? undefined : ipixels.size;
- // all borders are drawn for floating bar
- if (me._getParsed(index)._custom) {
- rectangle._model.borderSkipped = null;
+ rectangle.pivot(me.chart._animationsDisabled);
}
-
- me._updateElementGeometry(rectangle, index, reset, options);
-
- rectangle.pivot(me.chart._animationsDisabled);
- },
-
- /**
- * @private
- */
- _updateElementGeometry: function(rectangle, index, reset, options) {
- const me = this;
- const meta = me._cachedMeta;
- const model = rectangle._model;
- const vScale = meta.vScale;
- const base = vScale.getBasePixel();
- const horizontal = vScale.isHorizontal();
- const ruler = me._ruler || me.getRuler();
- const vpixels = me.calculateBarValuePixels(index, options);
- const ipixels = me.calculateBarIndexPixels(index, ruler, options);
-
- model.horizontal = horizontal;
- model.base = reset ? base : vpixels.base;
- model.x = horizontal ? reset ? base : vpixels.head : ipixels.center;
- model.y = horizontal ? ipixels.center : reset ? base : vpixels.head;
- model.height = horizontal ? ipixels.size : undefined;
- model.width = horizontal ? undefined : ipixels.size;
},
/**
const points = me._cachedMeta.data;
// Update Points
- helpers.each(points, function(point, index) {
- me.updateElement(point, index, reset);
- });
+ me.updateElements(points, 0, points.length, reset);
},
/**
* @protected
*/
- updateElement: function(point, index, reset) {
+ updateElements: function(points, start, count, reset) {
const me = this;
const meta = me._cachedMeta;
const xScale = meta.xScale;
const yScale = meta.yScale;
- const options = me._resolveDataElementOptions(index);
- const parsed = !reset && me._getParsed(index);
- const x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(parsed[xScale.id]);
- const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed[yScale.id]);
-
- point._options = options;
- point._model = {
- backgroundColor: options.backgroundColor,
- borderColor: options.borderColor,
- borderWidth: options.borderWidth,
- hitRadius: options.hitRadius,
- pointStyle: options.pointStyle,
- rotation: options.rotation,
- radius: reset ? 0 : options.radius,
- skip: isNaN(x) || isNaN(y),
- x: x,
- y: y,
- };
-
- point.pivot(me.chart._animationsDisabled);
+ let i;
+
+ for (i = start; i < start + count; i++) {
+ const point = points[i];
+ const options = me._resolveDataElementOptions(i);
+ const parsed = !reset && me._getParsed(i);
+ const x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(parsed[xScale.id]);
+ const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed[yScale.id]);
+
+ point._options = options;
+ point._model = {
+ backgroundColor: options.backgroundColor,
+ borderColor: options.borderColor,
+ borderWidth: options.borderWidth,
+ hitRadius: options.hitRadius,
+ pointStyle: options.pointStyle,
+ rotation: options.rotation,
+ radius: reset ? 0 : options.radius,
+ skip: isNaN(x) || isNaN(y),
+ x: x,
+ y: y,
+ };
+
+ point.pivot(me.chart._animationsDisabled);
+ }
},
/**
me.outerRadius = chart.outerRadius - chart.radiusLength * me._getRingWeightOffset(me.index);
me.innerRadius = Math.max(me.outerRadius - chart.radiusLength * chartWeight, 0);
- for (i = 0, ilen = arcs.length; i < ilen; ++i) {
- me.updateElement(arcs[i], i, reset);
- }
+ me.updateElements(arcs, 0, arcs.length, reset);
},
- updateElement: function(arc, index, reset) {
- var me = this;
- var chart = me.chart;
- var chartArea = chart.chartArea;
- var opts = chart.options;
- var animationOpts = opts.animation;
- var centerX = (chartArea.left + chartArea.right) / 2;
- var centerY = (chartArea.top + chartArea.bottom) / 2;
- var startAngle = opts.rotation; // non reset case handled later
- var endAngle = opts.rotation; // non reset case handled later
- var circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(arc._parsed * opts.circumference / DOUBLE_PI);
- var innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius;
- var outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius;
- var options = arc._options || {};
-
- helpers.extend(arc, {
- // Desired view properties
- _model: {
+
+ updateElements: function(arcs, start, count, reset) {
+ const me = this;
+ const chart = me.chart;
+ const chartArea = chart.chartArea;
+ const opts = chart.options;
+ const animationOpts = opts.animation;
+ const centerX = (chartArea.left + chartArea.right) / 2;
+ const centerY = (chartArea.top + chartArea.bottom) / 2;
+ const startAngle = opts.rotation; // non reset case handled later
+ const endAngle = opts.rotation; // non reset case handled later
+ const innerRadius = reset && animationOpts.animateScale ? 0 : me.innerRadius;
+ const outerRadius = reset && animationOpts.animateScale ? 0 : me.outerRadius;
+ var i;
+
+ for (i = 0; i < start + count; ++i) {
+ const arc = arcs[i];
+ const circumference = reset && animationOpts.animateRotate ? 0 : arc.hidden ? 0 : me.calculateCircumference(arc._parsed * opts.circumference / DOUBLE_PI);
+ const options = arc._options || {};
+ const model = {
+ // Desired view properties
backgroundColor: options.backgroundColor,
borderColor: options.borderColor,
borderWidth: options.borderWidth,
circumference: circumference,
outerRadius: outerRadius,
innerRadius: innerRadius
- }
- });
+ };
- var model = arc._model;
+ arc._model = model;
- // Set correct angles if not resetting
- if (!reset || !animationOpts.animateRotate) {
- if (index === 0) {
- model.startAngle = opts.rotation;
- } else {
- model.startAngle = me._cachedMeta.data[index - 1]._model.endAngle;
+ // Set correct angles if not resetting
+ if (!reset || !animationOpts.animateRotate) {
+ if (i === 0) {
+ model.startAngle = opts.rotation;
+ } else {
+ model.startAngle = me._cachedMeta.data[i - 1]._model.endAngle;
+ }
+
+ model.endAngle = model.startAngle + model.circumference;
}
- model.endAngle = model.startAngle + model.circumference;
+ arc.pivot(chart._animationsDisabled);
}
-
- arc.pivot(chart._animationsDisabled);
},
calculateTotal: function() {
},
update: function(reset) {
- var me = this;
- var meta = me._cachedMeta;
- var line = meta.dataset;
- var points = meta.data || [];
- var options = me.chart.options;
- var config = me._config;
- var showLine = me._showLine = valueOrDefault(config.showLine, options.showLines);
- var i, ilen;
+ const me = this;
+ const meta = me._cachedMeta;
+ const line = meta.dataset;
+ const points = meta.data || [];
+ const options = me.chart.options;
+ const config = me._config;
+ const showLine = me._showLine = valueOrDefault(config.showLine, options.showLines);
+ let i, ilen;
// Update Line
if (showLine) {
}
// Update Points
- for (i = 0, ilen = points.length; i < ilen; ++i) {
- me.updateElement(points[i], i, reset);
- }
+ me.updateElements(points, 0, points.length, reset);
if (showLine && line._model.tension !== 0) {
me.updateBezierControlPoints();
}
},
- updateElement: function(point, index, reset) {
+ updateElements: function(points, start, count, reset) {
const me = this;
const meta = me._cachedMeta;
const xScale = meta.xScale;
const yScale = meta.yScale;
const stacked = meta._stacked;
- const parsed = me._getParsed(index);
- const options = me._resolveDataElementOptions(index);
- const x = xScale.getPixelForValue(parsed[xScale.id]);
- const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(stacked ? me._applyStack(yScale, parsed) : parsed[yScale.id]);
-
- // Utility
- point._options = options;
-
- // Desired view properties
- point._model = {
- x: x,
- y: y,
- skip: isNaN(x) || isNaN(y),
- // Appearance
- radius: options.radius,
- pointStyle: options.pointStyle,
- rotation: options.rotation,
- backgroundColor: options.backgroundColor,
- borderColor: options.borderColor,
- borderWidth: options.borderWidth,
- // Tooltip
- hitRadius: options.hitRadius
- };
+ var i;
+
+ for (i = start; i < start + count; ++i) {
+ const point = points[i];
+ const parsed = me._getParsed(i);
+ const options = me._resolveDataElementOptions(i);
+ const x = xScale.getPixelForValue(parsed[xScale.id]);
+ const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(stacked ? me._applyStack(yScale, parsed) : parsed[yScale.id]);
+
+ // Utility
+ point._options = options;
+
+ // Desired view properties
+ point._model = {
+ x: x,
+ y: y,
+ skip: isNaN(x) || isNaN(y),
+ // Appearance
+ radius: options.radius,
+ pointStyle: options.pointStyle,
+ rotation: options.rotation,
+ backgroundColor: options.backgroundColor,
+ borderColor: options.borderColor,
+ borderWidth: options.borderWidth,
+ // Tooltip
+ hitRadius: options.hitRadius
+ };
+ }
},
/**
var ilen = points.length;
if (me._showLine) {
-
meta.dataset.draw();
}
start += angle;
}
- for (i = 0, ilen = arcs.length; i < ilen; ++i) {
- arcs[i]._options = me._resolveDataElementOptions(i);
- me.updateElement(arcs[i], i, reset);
- }
+ me.updateElements(arcs, 0, arcs.length, reset);
},
/**
me.innerRadius = me.outerRadius - chart.radiusLength;
},
- updateElement: function(arc, index, reset) {
- var me = this;
- var chart = me.chart;
- var dataset = me.getDataset();
- var opts = chart.options;
- var animationOpts = opts.animation;
- var scale = chart.scale;
-
- var centerX = scale.xCenter;
- var centerY = scale.yCenter;
-
- // var negHalfPI = -0.5 * Math.PI;
- var datasetStartAngle = opts.startAngle;
- var distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]);
- var startAngle = me._starts[index];
- var endAngle = startAngle + (arc.hidden ? 0 : me._angles[index]);
-
- var resetRadius = animationOpts.animateScale ? 0 : scale.getDistanceFromCenterForValue(dataset.data[index]);
- var options = arc._options || {};
-
- helpers.extend(arc, {
- // Desired view properties
- _model: {
+ updateElements: function(arcs, start, count, reset) {
+ const me = this;
+ const chart = me.chart;
+ const dataset = me.getDataset();
+ const opts = chart.options;
+ const animationOpts = opts.animation;
+ const scale = chart.scale;
+ const centerX = scale.xCenter;
+ const centerY = scale.yCenter;
+ var i;
+
+ for (i = 0; i < start + count; i++) {
+ const arc = arcs[i];
+ // var negHalfPI = -0.5 * Math.PI;
+ const datasetStartAngle = opts.startAngle;
+ const distance = arc.hidden ? 0 : scale.getDistanceFromCenterForValue(dataset.data[i]);
+ const startAngle = me._starts[i];
+ const endAngle = startAngle + (arc.hidden ? 0 : me._angles[i]);
+
+ const resetRadius = animationOpts.animateScale ? 0 : scale.getDistanceFromCenterForValue(dataset.data[i]);
+ const options = arc._options = me._resolveDataElementOptions(i);
+
+ arc._model = {
backgroundColor: options.backgroundColor,
borderColor: options.borderColor,
borderWidth: options.borderWidth,
outerRadius: reset ? resetRadius : distance,
startAngle: reset && animationOpts.animateRotate ? datasetStartAngle : startAngle,
endAngle: reset && animationOpts.animateRotate ? datasetStartAngle : endAngle
- }
- });
+ };
- arc.pivot(chart._animationsDisabled);
+ arc.pivot(chart._animationsDisabled);
+ }
},
countVisibleElements: function() {
line.pivot(animationsDisabled);
// Update Points
- for (i = 0, ilen = points.length; i < ilen; ++i) {
- me.updateElement(points[i], i, reset);
- }
+ me.updateElements(points, 0, points.length, reset);
// Update bezier control points
me.updateBezierControlPoints();
}
},
- updateElement: function(point, index, reset) {
- var me = this;
- var dataset = me.getDataset();
- var scale = me.chart.scale;
- var pointPosition = scale.getPointPositionForValue(index, dataset.data[index]);
- var options = me._resolveDataElementOptions(index);
- var x = reset ? scale.xCenter : pointPosition.x;
- var y = reset ? scale.yCenter : pointPosition.y;
-
- // Utility
- point._options = options;
-
- // Desired view properties
- point._model = {
- x: x, // value not used in dataset scale, but we want a consistent API between scales
- y: y,
- skip: isNaN(x) || isNaN(y),
- // Appearance
- radius: options.radius,
- pointStyle: options.pointStyle,
- rotation: options.rotation,
- backgroundColor: options.backgroundColor,
- borderColor: options.borderColor,
- borderWidth: options.borderWidth,
-
- // Tooltip
- hitRadius: options.hitRadius
- };
+ updateElements: function(points, start, count, reset) {
+ const me = this;
+ const dataset = me.getDataset();
+ const scale = me.chart.scale;
+ var i;
+
+ for (i = start; i < start + count; i++) {
+ const point = points[i];
+ const pointPosition = scale.getPointPositionForValue(i, dataset.data[i]);
+ const options = me._resolveDataElementOptions(i);
+ const x = reset ? scale.xCenter : pointPosition.x;
+ const y = reset ? scale.yCenter : pointPosition.y;
+
+ // Utility
+ point._options = options;
+
+ // Desired view properties
+ point._model = {
+ x: x, // value not used in dataset scale, but we want a consistent API between scales
+ y: y,
+ skip: isNaN(x) || isNaN(y),
+ // Appearance
+ radius: options.radius,
+ pointStyle: options.pointStyle,
+ rotation: options.rotation,
+ backgroundColor: options.backgroundColor,
+ borderColor: options.borderColor,
+ borderWidth: options.borderWidth,
+
+ // Tooltip
+ hitRadius: options.hitRadius
+ };
+ }
},
/**
});
}
-
function scaleClip(scale, allowedOverflow) {
var opts = scale && scale.options || {};
var reverse = opts.reverse;
insertElements: function(start, count) {
const me = this;
const elements = [];
+ const data = me._cachedMeta.data;
let i;
+
for (i = start; i < start + count; ++i) {
elements.push(me.createElement(me.dataElementType));
}
- me._cachedMeta.data.splice(start, 0, ...elements);
+ data.splice(start, 0, ...elements);
me._parse(start, count);
- for (i = 0; i < count; ++i) {
- me.updateElement(elements[i], start + i, true);
- }
+ me.updateElements(data, start, count);
},
/**