* `Line.calculatePointY`
* `LogarithmicScale.minNotZero`
* `Scale.getRightValue`
-* `Scale.handleDirectionalChanges` is now private
* `Scale.longestLabelWidth`
* `Scale.longestTextCache` is now private
* `Scale.margins` is now private
* `Scale.mergeTicksOptions`
* `Scale.ticksAsNumbers`
* `Scale.tickValues` is now private
+* `TimeScale.getLabelCapacity` is now private
+* `TimeScale.tickFormatFunction` is now private
* `Title.margins` is now private
* The tooltip item's `x` and `y` attributes were removed. Use `datasetIndex` and `index` to get the element and any corresponding data from it
* `Element._model`
* `Element._view`
* `LogarithmicScale._valueOffset`
-* `TimeScale._getPixelForOffset`
+* `TimeScale.getPixelForOffset`
* `TimeScale.getLabelWidth`
* `Tooltip._lastActive`
* `helpers.toDegrees` was renamed to `helpers.math.toDegrees`
* `helpers.toRadians` was renamed to `helpers.math.toRadians`
* `Scale.calculateTickRotation` was renamed to `Scale.calculateLabelRotation`
-* `TimeScale.getLabelCapacity` was renamed to `TimeScale._getLabelCapacity`
-* `TimeScale.getPixelForOffset` was renamed to `TimeScale._getPixelForOffset`
-* `TimeScale.tickFormatFunction` was renamed to `TimeScale._tickFormatFunction`
* `Tooltip.options.legendColorBackgroupd` was renamed to `Tooltip.options.multiKeyBackground`
#### Renamed private APIs
"dev": true
},
"@kurkle/color": {
- "version": "0.1.3",
- "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.1.3.tgz",
- "integrity": "sha512-AEYY1u0xlvb7gyT1Dfe4cg6Brfk7ymmyFJkx2KUIIf/u+lvOPhvUqSwNYMEtBCrEO6KW2Iqtdy174HNa9R51Sg=="
+ "version": "0.1.6",
+ "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.1.6.tgz",
+ "integrity": "sha512-jOb40/8Ih98jEQq4gsBw6Wo35hD/XDDfbM/DaikRdEwNMdJAs/bipZugzUDeegTqHMlFFuA4oN28PVINMedm4A=="
},
"@rollup/plugin-commonjs": {
"version": "11.0.2",
"object-visit": "^1.0.0"
}
},
+ "marked": {
+ "version": "0.8.0",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-0.8.0.tgz",
+ "integrity": "sha512-MyUe+T/Pw4TZufHkzAfDj6HarCBWia2y27/bhuYkTaiUnfDYFnCP3KUN+9oM7Wi6JA2rymtVYbQu3spE0GCmxQ==",
+ "dev": true
+ },
"matchdep": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/matchdep/-/matchdep-2.0.0.tgz",
}
},
"rollup": {
- "version": "1.31.0",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.31.0.tgz",
- "integrity": "sha512-9C6ovSyNeEwvuRuUUmsTpJcXac1AwSL1a3x+O5lpmQKZqi5mmrjauLeqIjvREC+yNRR8fPdzByojDng+af3nVw==",
+ "version": "1.31.1",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.31.1.tgz",
+ "integrity": "sha512-2JREN1YdrS/kpPzEd33ZjtuNbOuBC3ePfuZBdKEybvqcEcszW1ckyVqzcEiEe0nE8sqHK+pbJg+PsAgRJ8+1dg==",
"dev": true,
"requires": {
"@types/estree": "*",
"dev": true
},
"typedoc": {
- "version": "0.16.9",
- "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.16.9.tgz",
- "integrity": "sha512-UvOGoy76yqwCXwxPgatwgXWfsQ3FczyZ6ZNLjhCPK+TsDir6LiU3YB6N9XZmPv36E+7LA860mnc8a0v6YADKFw==",
+ "version": "0.16.10",
+ "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.16.10.tgz",
+ "integrity": "sha512-Eo1+K+XTiqSi4lz5cPrV4RncLv6abjCd/jfL5tTueNZGO2p8x2yDIrXkxL9C+SoLjJm2xpMs3CXYmTnilxk1cA==",
"dev": true,
"requires": {
"@types/minimatch": "3.0.3",
"graceful-fs": "^4.1.6"
}
},
- "marked": {
- "version": "0.8.0",
- "resolved": "https://registry.npmjs.org/marked/-/marked-0.8.0.tgz",
- "integrity": "sha512-MyUe+T/Pw4TZufHkzAfDj6HarCBWia2y27/bhuYkTaiUnfDYFnCP3KUN+9oM7Wi6JA2rymtVYbQu3spE0GCmxQ==",
- "dev": true
- },
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
+ },
+ "typescript": {
+ "version": "3.7.5",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz",
+ "integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==",
+ "dev": true
}
}
},
}
},
"typescript": {
- "version": "3.7.5",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz",
- "integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==",
+ "version": "3.8.2",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.2.tgz",
+ "integrity": "sha512-EgOVgL/4xfVrCMbhYKUQTdF37SQn4Iw73H5BgCrF1Abdun7Kwy/QZsE/ssAy0y4LxBbvua3PIbFsbRczWWnDdQ==",
"dev": true
},
"uglify-js": {
"dev": true
},
"underscore": {
- "version": "1.9.1",
- "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz",
- "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==",
+ "version": "1.9.2",
+ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.2.tgz",
+ "integrity": "sha512-D39qtimx0c1fI3ya1Lnhk3E9nONswSKhnffBI0gME9C99fYOkNi04xs8K6pePLhvl1frbDemkaBQ5ikWllR2HQ==",
"dev": true
},
"undertaker": {
"moment": "^2.10.2",
"pixelmatch": "^5.0.0",
"resize-observer-polyfill": "^1.5.1",
- "rollup": "^1.31.0",
+ "rollup": "^1.31.1",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-cleanup": "^3.1.1",
"rollup-plugin-terser": "^5.2.0",
- "typedoc": "^0.16.9",
- "typescript": "^3.7.5",
+ "typedoc": "^0.16.10",
+ "typescript": "^3.8.2",
"yargs": "^14.2.2"
},
"dependencies": {
- "@kurkle/color": "^0.1.3"
+ "@kurkle/color": "^0.1.6"
}
}
}
function parseFloatBar(arr, item, vScale, i) {
- const startValue = vScale._parse(arr[0], i);
- const endValue = vScale._parse(arr[1], i);
+ const startValue = vScale.parse(arr[0], i);
+ const endValue = vScale.parse(arr[1], i);
const min = Math.min(startValue, endValue);
const max = Math.max(startValue, endValue);
let barStart = min;
function parseArrayOrPrimitive(meta, data, start, count) {
const iScale = meta.iScale;
const vScale = meta.vScale;
- const labels = iScale._getLabels();
+ const labels = iScale.getLabels();
const singleScale = iScale === vScale;
const parsed = [];
let i, ilen, item, entry;
for (i = start, ilen = start + count; i < ilen; ++i) {
entry = data[i];
item = {};
- item[iScale.axis] = singleScale || iScale._parse(labels[i], i);
+ item[iScale.axis] = singleScale || iScale.parse(labels[i], i);
if (isArray(entry)) {
parseFloatBar(entry, item, vScale, i);
} else {
- item[vScale.axis] = vScale._parse(entry, i);
+ item[vScale.axis] = vScale.parse(entry, i);
}
parsed.push(item);
/**
* Overriding primitive data parsing since we support mixed primitive/array
* data for float bars
- * @private
+ * @protected
*/
- _parsePrimitiveData(meta, data, start, count) {
+ parsePrimitiveData(meta, data, start, count) {
return parseArrayOrPrimitive(meta, data, start, count);
}
/**
* Overriding array data parsing since we support mixed primitive/array
* data for float bars
- * @private
+ * @protected
*/
- _parseArrayData(meta, data, start, count) {
+ parseArrayData(meta, data, start, count) {
return parseArrayOrPrimitive(meta, data, start, count);
}
/**
* Overriding object data parsing since we support mixed primitive/array
* value-scale data for float bars
- * @private
+ * @protected
*/
- _parseObjectData(meta, data, start, count) {
+ parseObjectData(meta, data, start, count) {
const {iScale, vScale} = meta;
const vProp = vScale.axis;
const parsed = [];
for (i = start, ilen = start + count; i < ilen; ++i) {
obj = data[i];
item = {};
- item[iScale.axis] = iScale._parseObject(obj, iScale.axis, i);
+ item[iScale.axis] = iScale.parseObject(obj, iScale.axis, i);
value = obj[vProp];
if (isArray(value)) {
parseFloatBar(value, item, vScale, i);
} else {
- item[vScale.axis] = vScale._parseObject(obj, vProp, i);
+ item[vScale.axis] = vScale.parseObject(obj, vProp, i);
}
parsed.push(item);
}
}
/**
- * @private
+ * @protected
*/
- _getLabelAndValue(index) {
+ getLabelAndValue(index) {
const me = this;
const meta = me._cachedMeta;
const {iScale, vScale} = meta;
- const parsed = me._getParsed(index);
+ const parsed = me.getParsed(index);
const custom = parsed._custom;
const value = isFloatBar(custom)
? '[' + custom.start + ', ' + custom.end + ']'
const base = vscale.getBasePixel();
const horizontal = vscale.isHorizontal();
const ruler = me._getRuler();
- const firstOpts = me._resolveDataElementOptions(start, mode);
- const sharedOptions = me._getSharedOptions(mode, rectangles[start], firstOpts);
- const includeOptions = me._includeOptions(mode, sharedOptions);
+ const firstOpts = me.resolveDataElementOptions(start, mode);
+ const sharedOptions = me.getSharedOptions(mode, rectangles[start], firstOpts);
+ const includeOptions = me.includeOptions(mode, sharedOptions);
let i;
for (i = 0; i < rectangles.length; i++) {
const index = start + i;
- const options = me._resolveDataElementOptions(index, mode);
+ const options = me.resolveDataElementOptions(index, mode);
const vpixels = me._calculateBarValuePixels(index, options);
const ipixels = me._calculateBarIndexPixels(index, ruler, options);
// all borders are drawn for floating bar
/* TODO: float bars border skipping magic
- if (me._getParsed(i)._custom) {
+ if (me.getParsed(i)._custom) {
model.borderSkipped = null;
}
*/
if (includeOptions) {
properties.options = options;
}
- me._updateElement(rectangles[i], index, properties, mode);
+ me.updateElement(rectangles[i], index, properties, mode);
}
- me._updateSharedOptions(sharedOptions, mode);
+ me.updateSharedOptions(sharedOptions, mode);
}
/**
const me = this;
const meta = me._cachedMeta;
const iScale = meta.iScale;
- const metasets = iScale._getMatchingVisibleMetas(me._type);
+ const metasets = iScale.getMatchingVisibleMetas(me._type);
const stacked = iScale.options.stacked;
const ilen = metasets.length;
const stacks = [];
let i, ilen;
for (i = 0, ilen = meta.data.length; i < ilen; ++i) {
- pixels.push(iScale.getPixelForValue(me._getParsed(i)[iScale.axis]));
+ pixels.push(iScale.getPixelForValue(me.getParsed(i)[iScale.axis]));
}
return {
const meta = me._cachedMeta;
const vScale = meta.vScale;
const minBarLength = options.minBarLength;
- const parsed = me._getParsed(index);
+ const parsed = me.getParsed(index);
const custom = parsed._custom;
let value = parsed[vScale.axis];
let start = 0;
- let length = meta._stacked ? me._applyStack(vScale, parsed) : value;
+ let length = meta._stacked ? me.applyStack(vScale, parsed) : value;
let head, size;
if (length !== value) {
clipArea(chart.ctx, chart.chartArea);
for (; i < ilen; ++i) {
- if (!isNaN(me._getParsed(i)[vScale.axis])) {
+ if (!isNaN(me.getParsed(i)[vScale.axis])) {
rects[i].draw(me._ctx);
}
}
BarController.prototype.dataElementType = Rectangle;
-/**
- * @private
- */
-BarController.prototype._dataElementOptions = [
+BarController.prototype.dataElementOptions = [
'backgroundColor',
'borderColor',
'borderSkipped',
/**
* Parse array of objects
- * @private
+ * @protected
*/
- _parseObjectData(meta, data, start, count) {
+ parseObjectData(meta, data, start, count) {
const {xScale, yScale} = meta;
const parsed = [];
let i, ilen, item;
for (i = start, ilen = start + count; i < ilen; ++i) {
item = data[i];
parsed.push({
- x: xScale._parseObject(item, 'x', i),
- y: yScale._parseObject(item, 'y', i),
+ x: xScale.parseObject(item, 'x', i),
+ y: yScale.parseObject(item, 'y', i),
_custom: item && item.r && +item.r
});
}
}
/**
- * @private
+ * @protected
*/
- _getMaxOverflow() {
+ getMaxOverflow() {
const me = this;
const meta = me._cachedMeta;
let i = (meta.data || []).length - 1;
}
/**
- * @private
+ * @protected
*/
- _getLabelAndValue(index) {
+ getLabelAndValue(index) {
const me = this;
const meta = me._cachedMeta;
const {xScale, yScale} = meta;
- const parsed = me._getParsed(index);
+ const parsed = me.getParsed(index);
const x = xScale.getLabelForValue(parsed.x);
const y = yScale.getLabelForValue(parsed.y);
const r = parsed._custom;
};
}
- /**
- * @protected
- */
update(mode) {
const me = this;
const points = me._cachedMeta.data;
me.updateElements(points, 0, mode);
}
- /**
- * @protected
- */
updateElements(points, start, mode) {
const me = this;
const reset = mode === 'reset';
const {xScale, yScale} = me._cachedMeta;
- const firstOpts = me._resolveDataElementOptions(start, mode);
- const sharedOptions = me._getSharedOptions(mode, points[start], firstOpts);
- const includeOptions = me._includeOptions(mode, sharedOptions);
+ const firstOpts = me.resolveDataElementOptions(start, mode);
+ const sharedOptions = me.getSharedOptions(mode, points[start], firstOpts);
+ const includeOptions = me.includeOptions(mode, sharedOptions);
for (let i = 0; i < points.length; i++) {
const point = points[i];
const index = start + i;
- const parsed = !reset && me._getParsed(index);
+ const parsed = !reset && me.getParsed(index);
const x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(parsed.x);
const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y);
const properties = {
};
if (includeOptions) {
- properties.options = me._resolveDataElementOptions(i, mode);
+ properties.options = me.resolveDataElementOptions(i, mode);
if (reset) {
properties.options.radius = 0;
}
}
- me._updateElement(point, index, properties, mode);
+ me.updateElement(point, index, properties, mode);
}
- me._updateSharedOptions(sharedOptions, mode);
+ me.updateSharedOptions(sharedOptions, mode);
}
/**
- * @private
+ * @protected
*/
- _resolveDataElementOptions(index, mode) {
+ resolveDataElementOptions(index, mode) {
const me = this;
const chart = me.chart;
const dataset = me.getDataset();
- const parsed = me._getParsed(index);
- let values = super._resolveDataElementOptions(index, mode);
+ const parsed = me.getParsed(index);
+ let values = super.resolveDataElementOptions(index, mode);
// Scriptable options
const context = {
}
}
-/**
- * @protected
- */
BubbleController.prototype.dataElementType = Point;
-/**
- * @private
- */
-BubbleController.prototype._dataElementOptions = [
+BubbleController.prototype.dataElementOptions = [
'backgroundColor',
'borderColor',
'borderWidth',
/**
* Override data parsing, since we are not using scales
- * @private
*/
- _parse(start, count) {
+ parse(start, count) {
const data = this.getDataset().data;
const meta = this._cachedMeta;
let i, ilen;
const animateScale = reset && animationOpts.animateScale;
const innerRadius = animateScale ? 0 : me.innerRadius;
const outerRadius = animateScale ? 0 : me.outerRadius;
- const firstOpts = me._resolveDataElementOptions(start, mode);
- const sharedOptions = me._getSharedOptions(mode, arcs[start], firstOpts);
- const includeOptions = me._includeOptions(mode, sharedOptions);
+ const firstOpts = me.resolveDataElementOptions(start, mode);
+ const sharedOptions = me.getSharedOptions(mode, arcs[start], firstOpts);
+ const includeOptions = me.includeOptions(mode, sharedOptions);
let startAngle = opts.rotation;
let i;
innerRadius
};
if (includeOptions) {
- properties.options = me._resolveDataElementOptions(index, mode);
+ properties.options = me.resolveDataElementOptions(index, mode);
}
startAngle += circumference;
- me._updateElement(arc, index, properties, mode);
+ me.updateElement(arc, index, properties, mode);
}
- me._updateSharedOptions(sharedOptions, mode);
+ me.updateSharedOptions(sharedOptions, mode);
}
calculateTotal() {
arcs = meta.data;
controller = meta.controller;
if (controller !== me) {
- controller._configure();
+ controller.configure();
}
break;
}
}
for (i = 0, ilen = arcs.length; i < ilen; ++i) {
- options = controller._resolveDataElementOptions(i);
+ options = controller.resolveDataElementOptions(i);
if (options.borderAlign !== 'inner') {
max = Math.max(max, options.borderWidth || 0, options.hoverBorderWidth || 0);
}
DoughnutController.prototype.dataElementType = Arc;
-
-/**
- * @private
- */
-DoughnutController.prototype._dataElementOptions = [
+DoughnutController.prototype.dataElementOptions = [
'backgroundColor',
'borderColor',
'borderWidth',
export default class HorizontalBarController extends BarController {
/**
- * @private
+ * @protected
*/
- _getValueScaleId() {
+ getValueScaleId() {
return this._cachedMeta.xAxisID;
}
/**
- * @private
+ * @protected
*/
- _getIndexScaleId() {
+ getIndexScaleId() {
return this._cachedMeta.yAxisID;
}
}
if (showLine && mode !== 'resize') {
const properties = {
points,
- options: me._resolveDatasetElementOptions()
+ options: me.resolveDatasetElementOptions()
};
- me._updateElement(line, undefined, properties, mode);
+ me.updateElement(line, undefined, properties, mode);
}
// Update Points
const me = this;
const reset = mode === 'reset';
const {xScale, yScale, _stacked} = me._cachedMeta;
- const firstOpts = me._resolveDataElementOptions(start, mode);
- const sharedOptions = me._getSharedOptions(mode, points[start], firstOpts);
- const includeOptions = me._includeOptions(mode, sharedOptions);
+ const firstOpts = me.resolveDataElementOptions(start, mode);
+ const sharedOptions = me.getSharedOptions(mode, points[start], firstOpts);
+ const includeOptions = me.includeOptions(mode, sharedOptions);
const spanGaps = valueOrDefault(me._config.spanGaps, me.chart.options.spanGaps);
const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
let prevParsed;
for (let i = 0; i < points.length; ++i) {
const index = start + i;
const point = points[i];
- const parsed = me._getParsed(index);
+ const parsed = me.getParsed(index);
const x = xScale.getPixelForValue(parsed.x);
- const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(_stacked ? me._applyStack(yScale, parsed) : parsed.y);
+ const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(_stacked ? me.applyStack(yScale, parsed) : parsed.y);
const properties = {
x,
y,
};
if (includeOptions) {
- properties.options = me._resolveDataElementOptions(index, mode);
+ properties.options = me.resolveDataElementOptions(index, mode);
}
- me._updateElement(point, index, properties, mode);
+ me.updateElement(point, index, properties, mode);
prevParsed = parsed;
}
- me._updateSharedOptions(sharedOptions, mode);
+ me.updateSharedOptions(sharedOptions, mode);
}
/**
- * @private
+ * @protected
*/
- _resolveDatasetElementOptions(active) {
+ resolveDatasetElementOptions(active) {
const me = this;
const config = me._config;
const options = me.chart.options;
const lineOptions = options.elements.line;
- const values = super._resolveDatasetElementOptions(active);
+ const values = super.resolveDatasetElementOptions(active);
// The default behavior of lines is to break at null values, according
// to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-216718158
}
/**
- * @private
+ * @protected
*/
- _getMaxOverflow() {
+ getMaxOverflow() {
const me = this;
const meta = me._cachedMeta;
const border = me._showLine && meta.dataset.options.borderWidth || 0;
LineController.prototype.dataElementType = Point;
-/**
- * @private
- */
-LineController.prototype._datasetElementOptions = [
+LineController.prototype.datasetElementOptions = [
'backgroundColor',
'borderCapStyle',
'borderColor',
'fill'
];
-/**
- * @private
- */
-LineController.prototype._dataElementOptions = {
+LineController.prototype.dataElementOptions = {
backgroundColor: 'pointBackgroundColor',
borderColor: 'pointBorderColor',
borderWidth: 'pointBorderWidth',
}
/**
- * @private
+ * @protected
*/
- _getIndexScaleId() {
+ getIndexScaleId() {
return this._cachedMeta.rAxisID;
}
/**
- * @private
+ * @protected
*/
- _getValueScaleId() {
+ getValueScaleId() {
return this._cachedMeta.rAxisID;
}
outerRadius,
startAngle,
endAngle,
- options: me._resolveDataElementOptions(index)
+ options: me.resolveDataElementOptions(index)
};
- me._updateElement(arc, index, properties, mode);
+ me.updateElement(arc, index, properties, mode);
}
}
PolarAreaController.prototype.dataElementType = Arc;
-/**
- * @private
- */
-PolarAreaController.prototype._dataElementOptions = [
+PolarAreaController.prototype.dataElementOptions = [
'backgroundColor',
'borderColor',
'borderWidth',
export default class RadarController extends DatasetController {
/**
- * @private
+ * @protected
*/
- _getIndexScaleId() {
+ getIndexScaleId() {
return this._cachedMeta.rAxisID;
}
/**
- * @private
+ * @protected
*/
- _getValueScaleId() {
+ getValueScaleId() {
return this._cachedMeta.rAxisID;
}
/**
- * @private
+ * @protected
*/
- _getLabelAndValue(index) {
+ getLabelAndValue(index) {
const me = this;
const vScale = me._cachedMeta.vScale;
- const parsed = me._getParsed(index);
+ const parsed = me.getParsed(index);
return {
- label: vScale._getLabels()[index],
+ label: vScale.getLabels()[index],
value: '' + vScale.getLabelForValue(parsed[vScale.axis])
};
}
const meta = me._cachedMeta;
const line = meta.dataset;
const points = meta.data || [];
- const labels = meta.iScale._getLabels();
+ const labels = meta.iScale.getLabels();
const properties = {
points,
_loop: true,
_fullLoop: labels.length === points.length,
- options: me._resolveDatasetElementOptions()
+ options: me.resolveDatasetElementOptions()
};
- me._updateElement(line, undefined, properties, mode);
+ me.updateElement(line, undefined, properties, mode);
// Update Points
me.updateElements(points, 0, mode);
for (i = 0; i < points.length; i++) {
const point = points[i];
const index = start + i;
- const options = me._resolveDataElementOptions(index);
+ const options = me.resolveDataElementOptions(index);
const pointPosition = scale.getPointPositionForValue(index, dataset.data[index]);
const x = reset ? scale.xCenter : pointPosition.x;
options
};
- me._updateElement(point, index, properties, mode);
+ me.updateElement(point, index, properties, mode);
}
}
/**
- * @private
+ * @protected
*/
- _resolveDatasetElementOptions(active) {
+ resolveDatasetElementOptions(active) {
const me = this;
const config = me._config;
const options = me.chart.options;
- const values = super._resolveDatasetElementOptions(active);
+ const values = super.resolveDatasetElementOptions(active);
values.spanGaps = valueOrDefault(config.spanGaps, options.spanGaps);
values.tension = valueOrDefault(config.lineTension, options.elements.line.tension);
RadarController.prototype.dataElementType = Point;
-/**
- * @private
- */
-RadarController.prototype._datasetElementOptions = [
+RadarController.prototype.datasetElementOptions = [
'backgroundColor',
'borderColor',
'borderCapStyle',
'fill'
];
-/**
- * @private
- */
-RadarController.prototype._dataElementOptions = {
+RadarController.prototype.dataElementOptions = {
backgroundColor: 'pointBackgroundColor',
borderColor: 'pointBorderColor',
borderWidth: 'pointBorderWidth',
scale.axis = scale.options.position === 'chartArea' ? 'r' : scale.isHorizontal() ? 'x' : 'y';
// parse min/max value, so we can properly determine min/max for other scales
- scale._userMin = scale._parse(scale.options.min);
- scale._userMax = scale._parse(scale.options.max);
+ scale._userMin = scale.parse(scale.options.min);
+ scale._userMax = scale.parse(scale.options.max);
// TODO(SB): I think we should be able to remove this custom case (options.scale)
// and consider it as a regular scale part of the "scales"" map only! This would
// plugins options references might have change, let's invalidate the cache
// https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167
- plugins._invalidate(me);
+ plugins.invalidate(me);
if (plugins.notify(me, 'beforeUpdate') === false) {
return;
me._layers = [];
helpers.each(me.boxes, (box) => {
- // _configure is called twice, once in core.scale.update and once here.
+ // configure is called twice, once in core.scale.update and once here.
// Here the boxes are fully updated and at their final positions.
- if (box._configure) {
- box._configure();
+ if (box.configure) {
+ box.configure();
}
me._layers.push(...box._layers());
}, me);
}
/**
- * @private
+ * Gets the visible dataset metas in drawing order
+ * @return {object[]}
*/
- _getSortedVisibleDatasetMetas() {
+ getSortedVisibleDatasetMetas() {
return this._getSortedDatasetMetas(true);
}
return;
}
- const metasets = me._getSortedVisibleDatasetMetas();
+ const metasets = me.getSortedVisibleDatasetMetas();
for (let i = metasets.length - 1; i >= 0; --i) {
me._drawDataset(metasets[i]);
}
}
getVisibleDatasetCount() {
- return this._getSortedVisibleDatasetMetas().length;
+ return this.getSortedVisibleDatasetMetas().length;
}
isDatasetVisible(datasetIndex) {
import helpers from '../helpers/index';
import Animations from './core.animations';
+/**
+ * @typedef { import("../core/core.controller").default } Chart
+ * @typedef { import("../core/core.scale").default } Scale
+ */
+
const resolve = helpers.options.resolve;
const arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift'];
}
function getUserBounds(scale) {
- const {min, max, minDefined, maxDefined} = scale._getUserBounds();
+ const {min, max, minDefined, maxDefined} = scale.getUserBounds();
return {
min: minDefined ? min : Number.NEGATIVE_INFINITY,
max: maxDefined ? max : Number.POSITIVE_INFINITY
static extend = helpers.inherits;
+ /**
+ * @param {Chart} chart
+ * @param {number} datasetIndex
+ */
constructor(chart, datasetIndex) {
this.chart = chart;
this._ctx = chart.ctx;
initialize() {
const me = this;
const meta = me._cachedMeta;
- me._configure();
+ me.configure();
me.linkScales();
meta._stacked = isStacked(meta.vScale, meta);
me.addElements();
return this.chart.getDatasetMeta(this.index);
}
+ /**
+ * @param {string} scaleID
+ * @return {Scale}
+ */
getScaleForId(scaleID) {
return this.chart.scales[scaleID];
}
/**
- * @private
+ * @protected
*/
- _getValueScaleId() {
+ getValueScaleId() {
return this._cachedMeta.yAxisID;
}
/**
- * @private
+ * @protected
*/
- _getIndexScaleId() {
+ getIndexScaleId() {
return this._cachedMeta.xAxisID;
}
* @private
*/
_getValueScale() {
- return this.getScaleForId(this._getValueScaleId());
+ return this.getScaleForId(this.getValueScaleId());
}
/**
* @private
*/
_getIndexScale() {
- return this.getScaleForId(this._getIndexScaleId());
+ return this.getScaleForId(this.getIndexScaleId());
}
/**
_labelCheck() {
const me = this;
const iScale = me._cachedMeta.iScale;
- const labels = iScale ? iScale._getLabels() : me.chart.data.labels;
+ const labels = iScale ? iScale.getLabels() : me.chart.data.labels;
if (me._labels === labels) {
return false;
* Merges user-supplied and default dataset-level options
* @private
*/
- _configure() {
+ configure() {
const me = this;
me._config = helpers.merge({}, [
me.chart.options[me._type].datasets,
}
/**
- * @private
+ * @param {number} start
+ * @param {number} count
*/
- _parse(start, count) {
+ parse(start, count) {
const me = this;
const {_cachedMeta: meta, _data: data} = me;
const {iScale, vScale, _stacked} = meta;
meta._sorted = true;
} else {
if (helpers.isArray(data[start])) {
- parsed = me._parseArrayData(meta, data, start, count);
+ parsed = me.parseArrayData(meta, data, start, count);
} else if (helpers.isObject(data[start])) {
- parsed = me._parseObjectData(meta, data, start, count);
+ parsed = me.parseObjectData(meta, data, start, count);
} else {
- parsed = me._parsePrimitiveData(meta, data, start, count);
+ parsed = me.parsePrimitiveData(meta, data, start, count);
}
updateStacks(me, parsed);
}
- iScale._invalidateCaches();
- vScale._invalidateCaches();
+ iScale.invalidateCaches();
+ vScale.invalidateCaches();
}
/**
* @returns {object} parsed item - item containing index and a parsed value
* for each scale id.
* Example: {xScale0: 0, yScale0: 1}
- * @private
+ * @protected
*/
- _parsePrimitiveData(meta, data, start, count) {
+ parsePrimitiveData(meta, data, start, count) {
const {iScale, vScale} = meta;
const iAxis = iScale.axis;
const vAxis = vScale.axis;
- const labels = iScale._getLabels();
+ const labels = iScale.getLabels();
const singleScale = iScale === vScale;
const parsed = new Array(count);
let i, ilen, index;
for (i = 0, ilen = count; i < ilen; ++i) {
index = i + start;
parsed[i] = {
- [iAxis]: singleScale || iScale._parse(labels[index], index),
- [vAxis]: vScale._parse(data[index], index)
+ [iAxis]: singleScale || iScale.parse(labels[index], index),
+ [vAxis]: vScale.parse(data[index], index)
};
}
return parsed;
* @returns {object} parsed item - item containing index and a parsed value
* for each scale id.
* Example: {x: 0, y: 1}
- * @private
+ * @protected
*/
- _parseArrayData(meta, data, start, count) {
+ parseArrayData(meta, data, start, count) {
const {xScale, yScale} = meta;
const parsed = new Array(count);
let i, ilen, index, item;
index = i + start;
item = data[index];
parsed[i] = {
- x: xScale._parse(item[0], index),
- y: yScale._parse(item[1], index)
+ x: xScale.parse(item[0], index),
+ y: yScale.parse(item[1], index)
};
}
return parsed;
* @returns {object} parsed item - item containing index and a parsed value
* for each scale id. _custom is optional
* Example: {xScale0: 0, yScale0: 1, _custom: {r: 10, foo: 'bar'}}
- * @private
+ * @protected
*/
- _parseObjectData(meta, data, start, count) {
+ parseObjectData(meta, data, start, count) {
const {xScale, yScale} = meta;
const parsed = new Array(count);
let i, ilen, index, item;
index = i + start;
item = data[index];
parsed[i] = {
- x: xScale._parseObject(item, 'x', index),
- y: yScale._parseObject(item, 'y', index)
+ x: xScale.parseObject(item, 'x', index),
+ y: yScale.parseObject(item, 'y', index)
};
}
return parsed;
}
/**
- * @private
+ * @protected
*/
- _getParsed(index) {
+ getParsed(index) {
return this._cachedMeta._parsed[index];
}
/**
- * @private
+ * @protected
*/
- _applyStack(scale, parsed) {
+ applyStack(scale, parsed) {
const chart = this.chart;
const meta = this._cachedMeta;
const value = parsed[scale.axis];
}
/**
- * @private
+ * @protected
*/
- _getMinMax(scale, canStack) {
+ getMinMax(scale, canStack) {
const meta = this._cachedMeta;
const {data, _parsed} = meta;
const sorted = meta._sorted && scale === meta.iScale;
return {min, max};
}
- /**
- * @private
- */
- _getAllParsedValues(scale) {
+ getAllParsedValues(scale) {
const parsed = this._cachedMeta._parsed;
const values = [];
let i, ilen, value;
/**
* @return {number|boolean}
- * @private
+ * @protected
*/
- _getMaxOverflow() {
+ getMaxOverflow() {
return false;
}
/**
- * @private
+ * @protected
*/
- _getLabelAndValue(index) {
+ getLabelAndValue(index) {
const me = this;
const meta = me._cachedMeta;
const iScale = meta.iScale;
const vScale = meta.vScale;
- const parsed = me._getParsed(index);
+ const parsed = me.getParsed(index);
return {
label: iScale ? '' + iScale.getLabelForValue(parsed[iScale.axis]) : '',
value: vScale ? '' + vScale.getLabelForValue(parsed[vScale.axis]) : ''
_update(mode) {
const me = this;
const meta = me._cachedMeta;
- me._configure();
+ me.configure();
me._cachedAnimations = {};
me._cachedDataOpts = {};
me.update(mode);
- meta._clip = toClip(helpers.valueOrDefault(me._config.clip, defaultClip(meta.xScale, meta.yScale, me._getMaxOverflow())));
+ meta._clip = toClip(helpers.valueOrDefault(me._config.clip, defaultClip(meta.xScale, meta.yScale, me.getMaxOverflow())));
me._cacheScaleStackStatus();
}
const dataset = meta.dataset;
if (!me._config) {
- me._configure();
+ me.configure();
}
const options = dataset && index === undefined
- ? me._resolveDatasetElementOptions(active)
- : me._resolveDataElementOptions(index || 0, active && 'active');
+ ? me.resolveDatasetElementOptions(active)
+ : me.resolveDataElementOptions(index || 0, active && 'active');
if (active) {
me._addAutomaticHoverColors(index, options);
}
}
/**
- * @private
+ * @protected
*/
- _resolveDatasetElementOptions(active) {
+ resolveDatasetElementOptions(active) {
const me = this;
const chart = me.chart;
const datasetOpts = me._config;
// @ts-ignore
const options = chart.options.elements[me.datasetElementType._type] || {};
- const elementOptions = me._datasetElementOptions;
+ const elementOptions = me.datasetElementOptions;
const values = {};
const context = me._getContext(undefined, active);
let i, ilen, key, readKey, value;
}
/**
- * @private
+ * @protected
*/
- _resolveDataElementOptions(index, mode) {
+ resolveDataElementOptions(index, mode) {
const me = this;
const active = mode === 'active';
const cached = me._cachedDataOpts;
const datasetOpts = me._config;
// @ts-ignore
const options = chart.options.elements[me.dataElementType._type] || {};
- const elementOptions = me._dataElementOptions;
+ const elementOptions = me.dataElementOptions;
const values = {};
const context = me._getContext(index, active);
const info = {cacheable: !active};
/**
* Utility for checking if the options are shared and should be animated separately.
- * @private
+ * @protected
*/
- _getSharedOptions(mode, el, options) {
+ getSharedOptions(mode, el, options) {
if (!mode) {
// store element option sharing status for usage in interactions
this._sharedOptions = options && options.$shared;
/**
* Utility for determining if `options` should be included in the updated properties
- * @private
+ * @protected
*/
- _includeOptions(mode, sharedOptions) {
+ includeOptions(mode, sharedOptions) {
if (mode === 'hide' || mode === 'show') {
return true;
}
/**
* Utility for updating a element with new properties, using animations when appropriate.
- * @private
+ * @protected
*/
- _updateElement(element, index, properties, mode) {
+ updateElement(element, index, properties, mode) {
if (mode === 'reset' || mode === 'none') {
Object.assign(element, properties);
} else {
/**
* Utility to animate the shared options, that are potentially affecting multiple elements.
- * @private
+ * @protected
*/
- _updateSharedOptions(sharedOptions, mode) {
+ updateSharedOptions(sharedOptions, mode) {
if (sharedOptions) {
this._resolveAnimations(undefined, mode).update(sharedOptions.target, sharedOptions.options);
}
me._insertElements(numMeta, numData - numMeta);
if (changed && numMeta) {
// _insertElements parses the new elements. The old ones might need parsing too.
- me._parse(0, numMeta);
+ me.parse(0, numMeta);
}
} else if (numData < numMeta) {
meta.data.splice(numData, numMeta - numData);
meta._parsed.splice(numData, numMeta - numData);
- me._parse(0, numData);
+ me.parse(0, numData);
} else if (changed) {
- me._parse(0, numData);
+ me.parse(0, numData);
}
}
if (me._parsing) {
meta._parsed.splice(start, 0, ...new Array(count));
}
- me._parse(start, count);
+ me.parse(start, count);
me.updateElements(elements, start, 'reset');
}
DatasetController.prototype.dataElementType = null;
/**
- * Dataset element option keys to be resolved in _resolveDatasetElementOptions.
+ * Dataset element option keys to be resolved in resolveDatasetElementOptions.
* A derived controller may override this to resolve controller-specific options.
* The keys defined here are for backward compatibility for legend styles.
* @type {string[]}
- * @private
*/
-DatasetController.prototype._datasetElementOptions = [
+DatasetController.prototype.datasetElementOptions = [
'backgroundColor',
'borderCapStyle',
'borderColor',
];
/**
- * Data element option keys to be resolved in _resolveDataElementOptions.
+ * Data element option keys to be resolved in resolveDataElementOptions.
* A derived controller may override this to resolve controller-specific options.
* The keys defined here are for backward compatibility for legend styles.
* @type {string[]|object}
- * @private
*/
-DatasetController.prototype._dataElementOptions = [
+DatasetController.prototype.dataElementOptions = [
'backgroundColor',
'borderColor',
'borderWidth',
* @param {function} handler - the callback to execute for each visible item
*/
function evaluateAllVisibleItems(chart, handler) {
- const metasets = chart._getSortedVisibleDatasetMetas();
+ const metasets = chart.getSortedVisibleDatasetMetas();
let index, data, element;
for (let i = 0, ilen = metasets.length; i < ilen; ++i) {
* @param {boolean} [intersect] - consider intersecting items
*/
function optimizedEvaluateItems(chart, axis, position, handler, intersect) {
- const metasets = chart._getSortedVisibleDatasetMetas();
+ const metasets = chart.getSortedVisibleDatasetMetas();
const value = position[axis];
for (let i = 0, ilen = metasets.length; i < ilen; ++i) {
const {index, data} = metasets[i];
return [];
}
- chart._getSortedVisibleDatasetMetas().forEach((meta) => {
+ chart.getSortedVisibleDatasetMetas().forEach((meta) => {
const index = items[0].index;
const element = meta.data[index];
* but in some cases, this reference can be changed by the user when updating options.
* https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167
* @param {Chart} chart
- * @private
*/
- _invalidate(chart) {
+ invalidate(chart) {
delete chart.$plugins;
}
}
* Parse a supported input value to internal representation.
* @param {*} raw
* @param {number} index
- * @private
* @since 3.0
*/
- _parse(raw, index) { // eslint-disable-line no-unused-vars
+ parse(raw, index) { // eslint-disable-line no-unused-vars
return raw;
}
* @param {object} obj
* @param {string} axis
* @param {number} index
- * @private
* @since 3.0
+ * @protected
*/
- _parseObject(obj, axis, index) {
+ parseObject(obj, axis, index) {
if (obj[axis] !== undefined) {
- return this._parse(obj[axis], index);
+ return this.parse(obj[axis], index);
}
return null;
}
/**
* @return {{min: number, max: number, minDefined: boolean, maxDefined: boolean}}
- * @private
+ * @protected
* @since 3.0
*/
- _getUserBounds() {
+ getUserBounds() {
let min = this._userMin;
let max = this._userMax;
if (isNullOrUndef(min) || isNaN(min)) {
/**
* @param {boolean} canStack
* @return {{min: number, max: number}}
- * @private
+ * @protected
* @since 3.0
*/
- _getMinMax(canStack) {
+ getMinMax(canStack) {
const me = this;
// eslint-disable-next-line prefer-const
- let {min, max, minDefined, maxDefined} = me._getUserBounds();
+ let {min, max, minDefined, maxDefined} = me.getUserBounds();
let minmax;
if (minDefined && maxDefined) {
return {min, max};
}
- const metas = me._getMatchingVisibleMetas();
+ const metas = me.getMatchingVisibleMetas();
for (let i = 0, ilen = metas.length; i < ilen; ++i) {
- minmax = metas[i].controller._getMinMax(me, canStack);
+ minmax = metas[i].controller.getMinMax(me, canStack);
if (!minDefined) {
min = Math.min(min, minmax.min);
}
return {min, max};
}
- /**
- * @private
- */
- _invalidateCaches() {}
+ invalidateCaches() {}
/**
* Get the padding needed for the scale
/**
* @return {string[]}
- * @private
*/
- _getLabels() {
+ getLabels() {
const data = this.chart.data;
return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels || [];
}
const samplingEnabled = sampleSize < me.ticks.length;
me._convertTicksToLabels(samplingEnabled ? sample(me.ticks, sampleSize) : me.ticks);
- // _configure is called twice, once here, once from core.controller.updateLayout.
+ // configure is called twice, once here, once from core.controller.updateLayout.
// Here we haven't been positioned yet, but dimensions are correct.
- // Variables set in _configure are needed for calculateLabelRotation, and
+ // Variables set in configure are needed for calculateLabelRotation, and
// it's ok that coordinates are not correct there, only dimensions matter.
- me._configure();
+ me.configure();
// Tick Rotation
me.beforeCalculateLabelRotation();
}
/**
- * @private
+ * @protected
*/
- _configure() {
+ configure() {
const me = this;
let reversePixels = me.options.reverse;
let startPixel, endPixel;
return !!display;
}
- return this._getMatchingVisibleMetas().length > 0;
+ return this.getMatchingVisibleMetas().length > 0;
}
/**
}
/**
- * @private
+ * @protected
*/
- _drawGrid(chartArea) {
+ drawGrid(chartArea) {
const me = this;
const gridLines = me.options.gridLines;
const ctx = me.ctx;
}
/**
- * @private
+ * @protected
*/
- _drawLabels(chartArea) {
+ drawLabels(chartArea) {
const me = this;
const optionTicks = me.options.ticks;
}
/**
- * @private
+ * @protected
*/
- _drawTitle(chartArea) { // eslint-disable-line no-unused-vars
+ drawTitle(chartArea) { // eslint-disable-line no-unused-vars
const me = this;
const ctx = me.ctx;
const options = me.options;
return;
}
- me._drawGrid(chartArea);
- me._drawTitle();
- me._drawLabels(chartArea);
+ me.drawGrid(chartArea);
+ me.drawTitle();
+ me.drawLabels(chartArea);
}
/**
return [{
z: gz,
draw(chartArea) {
- me._drawGrid(chartArea);
- me._drawTitle();
+ me.drawGrid(chartArea);
+ me.drawTitle();
}
}, {
z: tz,
draw(chartArea) {
- me._drawLabels(chartArea);
+ me.drawLabels(chartArea);
}
}];
}
* Returns visible dataset metas that are attached to this scale
* @param {string} [type] - if specified, also filter by dataset type
* @return {object[]}
- * @private
*/
- _getMatchingVisibleMetas(type) {
+ getMatchingVisibleMetas(type) {
const me = this;
- const metas = me.chart._getSortedVisibleDatasetMetas();
+ const metas = me.chart.getSortedVisibleDatasetMetas();
const axisID = me.axis + 'AxisID';
const result = [];
let i, ilen;
import colorLib from '@kurkle/color';
-/**
- * @param {string | CanvasGradient | CanvasPattern} value
- */
const isPatternOrGradient = (value) => value instanceof CanvasGradient || value instanceof CanvasPattern;
-/**
- * @param {string|CanvasGradient|CanvasPattern} value
- * @return {CanvasGradient|CanvasPattern|colorLib}
- */
export function color(value) {
return isPatternOrGradient(value) ? value : colorLib(value);
}
-/**
- * @param {string|CanvasGradient|CanvasPattern} value
- * @return {string|CanvasGradient|CanvasPattern}
- */
export function getHoverColor(value) {
return isPatternOrGradient(value)
? value
function computeCircularBoundary(source) {
const {scale, fill} = source;
const options = scale.options;
- const length = scale._getLabels().length;
+ const length = scale.getLabels().length;
const target = [];
const start = options.reverse ? scale.max : scale.min;
const end = options.reverse ? scale.min : scale.max;
},
beforeDatasetsDraw(chart) {
- const metasets = chart._getSortedVisibleDatasetMetas();
+ const metasets = chart.getSortedVisibleDatasetMetas();
const area = chart.chartArea;
let i, meta;
return;
}
- me._drawTitle();
+ me.drawTitle();
const rtlHelper = getRtlAdapter(opts.rtl, me.left, me._minSize.width);
const ctx = me.ctx;
const fontColor = valueOrDefault(labelOpts.fontColor, defaults.fontColor);
}
/**
- * @private
+ * @protected
*/
- _drawTitle() {
+ drawTitle() {
const me = this;
const opts = me.options;
const titleOpts = opts.title;
*/
function createTooltipItem(chart, item) {
const {datasetIndex, index} = item;
- const {label, value} = chart.getDatasetMeta(datasetIndex).controller._getLabelAndValue(index);
+ const {label, value} = chart.getDatasetMeta(datasetIndex).controller.getLabelAndValue(index);
return {
label,
this._valueRange = 0;
}
- /**
- * @private
- */
- _parse(raw, index) {
- const labels = this._getLabels();
+ parse(raw, index) {
+ const labels = this.getLabels();
if (labels[index] === raw) {
return index;
}
determineDataLimits() {
const me = this;
- const max = me._getLabels().length - 1;
+ const max = me.getLabels().length - 1;
me.min = Math.max(me._userMin || 0, 0);
me.max = Math.min(me._userMax || max, max);
const min = me.min;
const max = me.max;
const offset = me.options.offset;
- let labels = me._getLabels();
+ let labels = me.getLabels();
// If we are viewing some subset of labels, slice the original array
labels = (min === 0 && max === labels.length - 1) ? labels : labels.slice(min, max + 1);
getLabelForValue(value) {
const me = this;
- const labels = me._getLabels();
+ const labels = me.getLabels();
if (value >= 0 && value < labels.length) {
return labels[value];
}
/**
- * @private
+ * @protected
*/
- _configure() {
+ configure() {
const me = this;
- Scale.prototype._configure.call(me);
+ super.configure();
if (!me.isHorizontal()) {
// For backward compatibility, vertical category scale reverse is inverted.
const me = this;
if (typeof value !== 'number') {
- value = me._parse(value);
+ value = me.parse(value);
}
return me.getPixelForDecimal((value - me._startValue) / me._valueRange);
determineDataLimits() {
const me = this;
const options = me.options;
- const minmax = me._getMinMax(true);
+ const minmax = me.getMinMax(true);
const min = minmax.min;
const max = minmax.max;
/**
* Returns the maximum number of ticks based on the scale dimension
- * @private
+ * @protected
*/
- _computeTickLimit() {
+ computeTickLimit() {
const me = this;
if (me.isHorizontal()) {
/**
* Called after the ticks are built
- * @private
+ * @protected
*/
- _handleDirectionalChanges(ticks) {
+ handleDirectionalChanges(ticks) {
// If we are in a vertical orientation the top value is the highest so reverse the array
return this.isHorizontal() ? ticks : ticks.reverse();
}
this._valueRange = 0;
}
- /**
- * @private
- */
- _parse(raw, index) { // eslint-disable-line no-unused-vars
+ parse(raw, index) { // eslint-disable-line no-unused-vars
if (isNullOrUndef(raw)) {
return NaN;
}
if (stepSize) {
maxTicks = Math.ceil(me.max / stepSize) - Math.floor(me.min / stepSize) + 1;
} else {
- maxTicks = me._computeTickLimit();
+ maxTicks = me.computeTickLimit();
maxTicksLimit = maxTicksLimit || 11;
}
}
/**
- * @private
+ * @protected
*/
- _computeTickLimit() {
+ computeTickLimit() {
return Number.POSITIVE_INFINITY;
}
/**
- * @private
+ * @protected
*/
- _handleDirectionalChanges(ticks) {
+ handleDirectionalChanges(ticks) {
return ticks;
}
};
let ticks = generateTicks(numericGeneratorOptions, me);
- ticks = me._handleDirectionalChanges(ticks);
+ ticks = me.handleDirectionalChanges(ticks);
// At this point, we need to update our max and min given the tick values since we have expanded the
// range of the scale
}
/**
- * @private
+ * @protected
*/
- _configure() {
+ configure() {
const me = this;
const ticks = me.ticks;
let start = me.min;
let end = me.max;
- Scale.prototype._configure.call(me);
+ super.configure();
if (me.options.offset && ticks.length) {
const offset = (end - start) / Math.max(ticks.length - 1, 1) / 2;
this._valueRange = 0;
}
- /**
- * @private
- */
- _parse(raw, index) {
- const value = LinearScaleBase.prototype._parse.apply(this, [raw, index]);
+ parse(raw, index) {
+ const value = LinearScaleBase.prototype.parse.apply(this, [raw, index]);
if (value === 0) {
return undefined;
}
determineDataLimits() {
const me = this;
- const minmax = me._getMinMax(true);
+ const minmax = me.getMinMax(true);
const min = minmax.min;
const max = minmax.max;
}
/**
- * @private
+ * @protected
*/
- _configure() {
+ configure() {
const me = this;
const start = me.min;
- Scale.prototype._configure.call(me);
+ super.configure();
me._startValue = log10(start);
me._valueRange = log10(me.max) - log10(start);
determineDataLimits() {
const me = this;
- const minmax = me._getMinMax(false);
+ const minmax = me.getMinMax(false);
const min = minmax.min;
const max = minmax.max;
/**
* Returns the maximum number of ticks based on the scale dimension
- * @private
+ * @protected
*/
- _computeTickLimit() {
+ computeTickLimit() {
return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options));
}
}
/**
- * @private
+ * @protected
*/
- _drawGrid() {
+ drawGrid() {
const me = this;
const ctx = me.ctx;
const opts = me.options;
}
/**
- * @private
+ * @protected
*/
- _drawLabels() {
+ drawLabels() {
const me = this;
const ctx = me.ctx;
const opts = me.options;
}
/**
- * @private
+ * @protected
*/
- _drawTitle() {}
+ drawTitle() {}
}
return timestamps;
}
- const metas = scale._getMatchingVisibleMetas();
+ const metas = scale.getMatchingVisibleMetas();
if (isSeries && metas.length) {
- return metas[0].controller._getAllParsedValues(scale);
+ return metas[0].controller.getAllParsedValues(scale);
}
for (i = 0, ilen = metas.length; i < ilen; ++i) {
- timestamps = timestamps.concat(metas[i].controller._getAllParsedValues(scale));
+ timestamps = timestamps.concat(metas[i].controller.getAllParsedValues(scale));
}
// We can not assume data is in order or unique - not even for single dataset
return timestamps;
}
- const labels = scale._getLabels();
+ const labels = scale.getLabels();
for (i = 0, ilen = labels.length; i < ilen; ++i) {
timestamps.push(parse(scale, labels[i]));
}
const max = scale.max;
const options = scale.options;
const timeOpts = options.time;
+ // @ts-ignore
const minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, scale._getLabelCapacity(min));
const stepSize = valueOrDefault(timeOpts.stepSize, 1);
const weekday = minor === 'week' ? timeOpts.isoWeekday : false;
* @param {*} raw
* @param {number} index
* @return {number}
- * @private
*/
- _parse(raw, index) { // eslint-disable-line no-unused-vars
+ parse(raw, index) { // eslint-disable-line no-unused-vars
if (raw === undefined) {
return NaN;
}
* @param {string} axis
* @param {number} index
* @return {number|null}
- * @private
*/
- _parseObject(obj, axis, index) {
+ parseObject(obj, axis, index) {
if (obj && obj.t) {
- return this._parse(obj.t, index);
+ return this.parse(obj.t, index);
}
if (obj[axis] !== undefined) {
- return this._parse(obj[axis], index);
+ return this.parse(obj[axis], index);
}
return null;
}
- /**
- * @private
- */
- _invalidateCaches() {
+ invalidateCaches() {
this._cache = {
data: [],
labels: [],
const adapter = me._adapter;
const unit = options.time.unit || 'day';
// eslint-disable-next-line prefer-const
- let {min, max, minDefined, maxDefined} = me._getUserBounds();
+ let {min, max, minDefined, maxDefined} = me.getUserBounds();
/**
* @param {object} bounds
// If `bounds` is `'ticks'` and `ticks.source` is `'labels'`,
// data bounds are ignored (and don't need to be determined)
if (options.bounds !== 'ticks' || options.ticks.source !== 'labels') {
- _applyBounds(me._getMinMax(false));
+ _applyBounds(me.getMinMax(false));
}
}
});
var controller = chart.getDatasetMeta(0).controller;
- expect(controller._getValueScaleId()).toBe('test');
+ expect(controller.getValueScaleId()).toBe('test');
});
});
var controller = meta.controller;
var first, last;
- first = controller._getParsed(0);
- last = controller._getParsed(5);
+ first = controller.getParsed(0);
+ last = controller.getParsed(5);
data.push({x: 6, y: 6}, {x: 7, y: 7}, {x: 8, y: 8});
data.push({x: 9, y: 9});
expect(meta.data.length).toBe(10);
- expect(controller._getParsed(0)).toBe(first);
- expect(controller._getParsed(5)).toBe(last);
+ expect(controller.getParsed(0)).toBe(first);
+ expect(controller.getParsed(5)).toBe(last);
- last = controller._getParsed(9);
+ last = controller.getParsed(9);
data.pop();
expect(meta.data.length).toBe(9);
- expect(controller._getParsed(0)).toBe(first);
- expect(controller._getParsed(9)).toBe(undefined);
- expect(controller._getParsed(8)).toEqual({x: 8, y: 8});
+ expect(controller.getParsed(0)).toBe(first);
+ expect(controller.getParsed(9)).toBe(undefined);
+ expect(controller.getParsed(8)).toEqual({x: 8, y: 8});
- last = controller._getParsed(8);
+ last = controller.getParsed(8);
data.shift();
data.shift();
data.shift();
expect(meta.data.length).toBe(6);
- expect(controller._getParsed(5)).toBe(last);
+ expect(controller.getParsed(5)).toBe(last);
- first = controller._getParsed(0);
- last = controller._getParsed(5);
+ first = controller.getParsed(0);
+ last = controller.getParsed(5);
data.splice(1, 4, {x: 10, y: 10}, {x: 11, y: 11});
expect(meta.data.length).toBe(4);
- expect(controller._getParsed(0)).toBe(first);
- expect(controller._getParsed(3)).toBe(last);
- expect(controller._getParsed(1)).toEqual({x: 10, y: 10});
+ expect(controller.getParsed(0)).toBe(first);
+ expect(controller.getParsed(3)).toBe(last);
+ expect(controller.getParsed(1)).toEqual({x: 10, y: 10});
data.unshift({x: 12, y: 12}, {x: 13, y: 13}, {x: 14, y: 14}, {x: 15, y: 15});
data.unshift({x: 16, y: 16}, {x: 17, y: 17});
expect(meta.data.length).toBe(10);
- expect(controller._getParsed(6)).toBe(first);
- expect(controller._getParsed(9)).toBe(last);
+ expect(controller.getParsed(6)).toBe(first);
+ expect(controller.getParsed(9)).toBe(last);
});
it('should re-synchronize metadata when the data object reference changes', function() {
var xScale = chart.scales.x;
var controller = chart.getDatasetMeta(0).controller;
- expect(xScale.getLabelForValue(controller._getParsed(0)[xScale.id])).toBeTruthy();
- expect(xScale.getLabelForValue(controller._getParsed(0)[xScale.id])).toBe('Jan 1, 2015, 8:00:00 pm');
+ expect(xScale.getLabelForValue(controller.getParsed(0)[xScale.id])).toBeTruthy();
+ expect(xScale.getLabelForValue(controller.getParsed(0)[xScale.id])).toBe('Jan 1, 2015, 8:00:00 pm');
expect(xScale.getLabelForValue(xScale.getValueForPixel(xScale.getPixelForTick(6)))).toBe('Jan 10, 2015, 12:00:00 pm');
});
var xScale = chart.scales.x;
var controller = chart.getDatasetMeta(0).controller;
- var value = controller._getParsed(0)[xScale.id];
+ var value = controller.getParsed(0)[xScale.id];
expect(xScale.getLabelForValue(value)).toBeTruthy();
expect(xScale.getLabelForValue(value)).toBe('Jan 1, 2015, 8:00:00 pm');
});
var xScale = chart.scales.x;
var controller = chart.getDatasetMeta(0).controller;
- var label = xScale.getLabelForValue(controller._getParsed(0)[xScale.id]);
+ var label = xScale.getLabelForValue(controller.getParsed(0)[xScale.id]);
expect(label).toEqual('Jan 8, 2018, 5:14:23 am');
});