return custom && custom.barStart !== undefined && custom.barEnd !== undefined;
}
-export default DatasetController.extend({
+class BarController extends DatasetController {
- dataElementType: Rectangle,
-
- /**
- * @private
- */
- _dataElementOptions: [
- 'backgroundColor',
- 'borderColor',
- 'borderSkipped',
- 'borderWidth',
- 'barPercentage',
- 'barThickness',
- 'categoryPercentage',
- 'maxBarThickness',
- 'minBarLength'
- ],
+ constructor(chart, datasetIndex) {
+ super(chart, datasetIndex);
+ }
/**
* Overriding primitive data parsing since we support mixed primitive/array
* data for float bars
* @private
*/
- _parsePrimitiveData: function() {
+ _parsePrimitiveData() {
return parseArrayOrPrimitive.apply(this, arguments);
- },
+ }
/**
* Overriding array data parsing since we support mixed primitive/array
* data for float bars
* @private
*/
- _parseArrayData: function() {
+ _parseArrayData() {
return parseArrayOrPrimitive.apply(this, arguments);
- },
+ }
/**
* Overriding object data parsing since we support mixed primitive/array
* value-scale data for float bars
* @private
*/
- _parseObjectData: function(meta, data, start, count) {
+ _parseObjectData(meta, data, start, count) {
const {iScale, vScale} = meta;
const vProp = vScale.axis;
const parsed = [];
parsed.push(item);
}
return parsed;
- },
+ }
/**
* @private
*/
- _getLabelAndValue: function(index) {
+ _getLabelAndValue(index) {
const me = this;
const meta = me._cachedMeta;
const {iScale, vScale} = meta;
label: '' + iScale.getLabelForValue(parsed[iScale.axis]),
value: value
};
- },
+ }
- initialize: function() {
+ initialize() {
var me = this;
var meta;
meta = me._cachedMeta;
meta.stack = me.getDataset().stack;
meta.bar = true;
- },
+ }
- update: function(mode) {
+ update(mode) {
const me = this;
const rects = me._cachedMeta.data;
me.updateElements(rects, 0, mode);
- },
+ }
- updateElements: function(rectangles, start, mode) {
+ updateElements(rectangles, start, mode) {
const me = this;
const reset = mode === 'reset';
const vscale = me._cachedMeta.vScale;
}
me._updateSharedOptions(sharedOptions, mode);
- },
+ }
/**
* Returns the stacks based on groups and bar visibility.
* @returns {string[]} The list of stack IDs
* @private
*/
- _getStacks: function(last) {
+ _getStacks(last) {
const me = this;
const meta = me._cachedMeta;
const iScale = meta.iScale;
}
return stacks;
- },
+ }
/**
* Returns the effective number of stacks based on groups and bar visibility.
* @private
*/
- getStackCount: function() {
+ getStackCount() {
return this._getStacks().length;
- },
+ }
/**
* Returns the stack index for the given dataset based on groups and bar visibility.
* @returns {number} The stack index
* @private
*/
- getStackIndex: function(datasetIndex, name) {
+ getStackIndex(datasetIndex, name) {
var stacks = this._getStacks(datasetIndex);
var index = (name !== undefined)
? stacks.indexOf(name)
return (index === -1)
? stacks.length - 1
: index;
- },
+ }
/**
* @private
*/
- getRuler: function() {
+ getRuler() {
const me = this;
const meta = me._cachedMeta;
const iScale = meta.iScale;
stackCount: me.getStackCount(),
scale: iScale
};
- },
+ }
/**
* Note: pixel values are not clamped to the scale area.
* @private
*/
- calculateBarValuePixels: function(index, options) {
+ calculateBarValuePixels(index, options) {
const me = this;
const meta = me._cachedMeta;
const vScale = meta.vScale;
head: head,
center: head + size / 2
};
- },
+ }
/**
* @private
*/
- calculateBarIndexPixels: function(index, ruler, options) {
+ calculateBarIndexPixels(index, ruler, options) {
var me = this;
var range = options.barThickness === 'flex'
? computeFlexCategoryTraits(index, ruler, options)
center: center,
size: size
};
- },
+ }
- draw: function() {
+ draw() {
const me = this;
const chart = me.chart;
const meta = me._cachedMeta;
unclipArea(chart.ctx);
}
-});
+}
+
+BarController.prototype.dataElementType = Rectangle;
+
+/**
+ * @private
+ */
+BarController.prototype._dataElementOptions = [
+ 'backgroundColor',
+ 'borderColor',
+ 'borderSkipped',
+ 'borderWidth',
+ 'barPercentage',
+ 'barThickness',
+ 'categoryPercentage',
+ 'maxBarThickness',
+ 'minBarLength'
+];
+
+export default BarController;
}
});
-export default DatasetController.extend({
- /**
- * @protected
- */
- dataElementType: Point,
+class BubbleController extends DatasetController {
- /**
- * @private
- */
- _dataElementOptions: [
- 'backgroundColor',
- 'borderColor',
- 'borderWidth',
- 'hitRadius',
- 'radius',
- 'pointStyle',
- 'rotation'
- ],
+ constructor(chart, datasetIndex) {
+ super(chart, datasetIndex);
+ }
/**
* Parse array of objects
* @private
*/
- _parseObjectData: function(meta, data, start, count) {
+ _parseObjectData(meta, data, start, count) {
const {xScale, yScale} = meta;
const parsed = [];
let i, ilen, item;
});
}
return parsed;
- },
+ }
/**
* @private
*/
- _getMaxOverflow: function() {
+ _getMaxOverflow() {
const me = this;
const meta = me._cachedMeta;
let i = (meta.data || []).length - 1;
max = Math.max(max, me.getStyle(i, true).radius);
}
return max > 0 && max;
- },
+ }
/**
* @private
*/
- _getLabelAndValue: function(index) {
+ _getLabelAndValue(index) {
const me = this;
const meta = me._cachedMeta;
const {xScale, yScale} = meta;
label: meta.label,
value: '(' + x + ', ' + y + (r ? ', ' + r : '') + ')'
};
- },
+ }
/**
* @protected
*/
- update: function(mode) {
+ update(mode) {
const me = this;
const points = me._cachedMeta.data;
// Update Points
me.updateElements(points, 0, mode);
- },
+ }
/**
* @protected
*/
- updateElements: function(points, start, mode) {
+ updateElements(points, start, mode) {
const me = this;
const reset = mode === 'reset';
const {xScale, yScale} = me._cachedMeta;
}
me._updateSharedOptions(sharedOptions, mode);
- },
+ }
/**
* @private
*/
- _resolveDataElementOptions: function(index, mode) {
+ _resolveDataElementOptions(index, mode) {
var me = this;
var chart = me.chart;
var dataset = me.getDataset();
return values;
}
-});
+}
+
+/**
+ * @protected
+ */
+BubbleController.prototype.dataElementType = Point;
+
+/**
+ * @private
+ */
+BubbleController.prototype._dataElementOptions = [
+ 'backgroundColor',
+ 'borderColor',
+ 'borderWidth',
+ 'hitRadius',
+ 'radius',
+ 'pointStyle',
+ 'rotation'
+];
+
+
+export default BubbleController;
import DatasetController from '../core/core.datasetController';
import defaults from '../core/core.defaults';
import Arc from '../elements/element.arc';
-import {isArray, noop, valueOrDefault} from '../helpers/helpers.core';
+import {isArray, valueOrDefault} from '../helpers/helpers.core';
const PI = Math.PI;
const DOUBLE_PI = PI * 2;
}
});
-export default DatasetController.extend({
+class DoughnutController extends DatasetController {
- dataElementType: Arc,
-
- linkScales: noop,
+ constructor(chart, datasetIndex) {
+ super(chart, datasetIndex);
+ }
- /**
- * @private
- */
- _dataElementOptions: [
- 'backgroundColor',
- 'borderColor',
- 'borderWidth',
- 'borderAlign',
- 'hoverBackgroundColor',
- 'hoverBorderColor',
- 'hoverBorderWidth',
- ],
+ linkScales() {}
/**
* Override data parsing, since we are not using scales
* @private
*/
- _parse: function(start, count) {
+ _parse(start, count) {
var data = this.getDataset().data;
var meta = this._cachedMeta;
var i, ilen;
for (i = start, ilen = start + count; i < ilen; ++i) {
meta._parsed[i] = +data[i];
}
- },
+ }
// Get index of the dataset in relation to the visible datasets. This allows determining the inner and outer radius correctly
- getRingIndex: function(datasetIndex) {
+ getRingIndex(datasetIndex) {
var ringIndex = 0;
for (var j = 0; j < datasetIndex; ++j) {
}
return ringIndex;
- },
+ }
- update: function(mode) {
+ update(mode) {
var me = this;
var chart = me.chart;
var chartArea = chart.chartArea;
me.innerRadius = Math.max(me.outerRadius - chart.radiusLength * chartWeight, 0);
me.updateElements(arcs, 0, mode);
- },
+ }
/**
* @private
*/
- _circumference: function(i, reset) {
+ _circumference(i, reset) {
const me = this;
const opts = me.chart.options;
const meta = me._cachedMeta;
return reset && opts.animation.animateRotate ? 0 : meta.data[i].hidden ? 0 : me.calculateCircumference(meta._parsed[i] * opts.circumference / DOUBLE_PI);
- },
+ }
- updateElements: function(arcs, start, mode) {
+ updateElements(arcs, start, mode) {
const me = this;
const reset = mode === 'reset';
const chart = me.chart;
me._updateElement(arc, index, properties, mode);
}
- },
+ }
- calculateTotal: function() {
+ calculateTotal() {
const meta = this._cachedMeta;
const metaData = meta.data;
let total = 0;
}*/
return total;
- },
+ }
- calculateCircumference: function(value) {
+ calculateCircumference(value) {
var total = this._cachedMeta.total;
if (total > 0 && !isNaN(value)) {
return DOUBLE_PI * (Math.abs(value) / total);
}
return 0;
- },
+ }
// gets the max border or hover width to properly scale pie charts
- getMaxBorderWidth: function(arcs) {
+ getMaxBorderWidth(arcs) {
var me = this;
var max = 0;
var chart = me.chart;
}
}
return max;
- },
+ }
/**
* Get radius length offset of the dataset in relation to the visible datasets weights. This allows determining the inner and outer radius correctly
* @private
*/
- _getRingWeightOffset: function(datasetIndex) {
+ _getRingWeightOffset(datasetIndex) {
var ringWeightOffset = 0;
for (var i = 0; i < datasetIndex; ++i) {
}
return ringWeightOffset;
- },
+ }
/**
* @private
*/
- _getRingWeight: function(dataSetIndex) {
+ _getRingWeight(dataSetIndex) {
return Math.max(valueOrDefault(this.chart.data.datasets[dataSetIndex].weight, 1), 0);
- },
+ }
/**
* Returns the sum of all visibile data set weights. This value can be 0.
* @private
*/
- _getVisibleDatasetWeightTotal: function() {
+ _getVisibleDatasetWeightTotal() {
return this._getRingWeightOffset(this.chart.data.datasets.length);
}
-});
+}
+
+DoughnutController.prototype.dataElementType = Arc;
+
+
+/**
+ * @private
+ */
+DoughnutController.prototype._dataElementOptions = [
+ 'backgroundColor',
+ 'borderColor',
+ 'borderWidth',
+ 'borderAlign',
+ 'hoverBackgroundColor',
+ 'hoverBorderColor',
+ 'hoverBorderWidth',
+];
+
+export default DoughnutController;
}
});
-export default BarController.extend({
+class HorizontalBarController extends BarController {
+
+ constructor(chart, datasetIndex) {
+ super(chart, datasetIndex);
+ }
+
/**
* @private
*/
- _getValueScaleId: function() {
+ _getValueScaleId() {
return this._cachedMeta.xAxisID;
- },
+ }
/**
* @private
*/
- _getIndexScaleId: function() {
+ _getIndexScaleId() {
return this._cachedMeta.yAxisID;
}
-});
+}
+
+export default HorizontalBarController;
}
});
-export default DatasetController.extend({
+class LineController extends DatasetController {
- datasetElementType: Line,
-
- dataElementType: Point,
-
- /**
- * @private
- */
- _datasetElementOptions: [
- 'backgroundColor',
- 'borderCapStyle',
- 'borderColor',
- 'borderDash',
- 'borderDashOffset',
- 'borderJoinStyle',
- 'borderWidth',
- 'capBezierPoints',
- 'cubicInterpolationMode',
- 'fill'
- ],
-
- /**
- * @private
- */
- _dataElementOptions: {
- backgroundColor: 'pointBackgroundColor',
- borderColor: 'pointBorderColor',
- borderWidth: 'pointBorderWidth',
- hitRadius: 'pointHitRadius',
- hoverHitRadius: 'pointHitRadius',
- hoverBackgroundColor: 'pointHoverBackgroundColor',
- hoverBorderColor: 'pointHoverBorderColor',
- hoverBorderWidth: 'pointHoverBorderWidth',
- hoverRadius: 'pointHoverRadius',
- pointStyle: 'pointStyle',
- radius: 'pointRadius',
- rotation: 'pointRotation'
- },
+ constructor(chart, datasetIndex) {
+ super(chart, datasetIndex);
+ }
- update: function(mode) {
+ update(mode) {
const me = this;
const meta = me._cachedMeta;
const line = meta.dataset;
if (meta.visible) {
me.updateElements(points, 0, mode);
}
- },
+ }
- updateElements: function(points, start, mode) {
+ updateElements(points, start, mode) {
const me = this;
const reset = mode === 'reset';
const {xScale, yScale, _stacked} = me._cachedMeta;
}
me._updateSharedOptions(sharedOptions, mode);
- },
+ }
/**
* @private
*/
- _resolveDatasetElementOptions: function() {
+ _resolveDatasetElementOptions() {
const me = this;
const config = me._config;
const options = me.chart.options;
values.steppedLine = resolve([config.steppedLine, lineOptions.stepped]);
return values;
- },
+ }
/**
* @private
*/
- _getMaxOverflow: function() {
+ _getMaxOverflow() {
const me = this;
const meta = me._cachedMeta;
const border = me._showLine && meta.dataset.options.borderWidth || 0;
const firstPoint = data[0].size();
const lastPoint = data[data.length - 1].size();
return Math.max(border, firstPoint, lastPoint) / 2;
- },
+ }
- draw: function() {
+ draw() {
const me = this;
const ctx = me._ctx;
const chart = me.chart;
for (i = 0, ilen = active.length; i < ilen; ++i) {
active[i].draw(ctx, area);
}
- },
-});
+ }
+}
+
+LineController.prototype.datasetElementType = Line;
+
+LineController.prototype.dataElementType = Point;
+
+/**
+ * @private
+ */
+LineController.prototype._datasetElementOptions = [
+ 'backgroundColor',
+ 'borderCapStyle',
+ 'borderColor',
+ 'borderDash',
+ 'borderDashOffset',
+ 'borderJoinStyle',
+ 'borderWidth',
+ 'capBezierPoints',
+ 'cubicInterpolationMode',
+ 'fill'
+];
+
+/**
+ * @private
+ */
+LineController.prototype._dataElementOptions = {
+ backgroundColor: 'pointBackgroundColor',
+ borderColor: 'pointBorderColor',
+ borderWidth: 'pointBorderWidth',
+ hitRadius: 'pointHitRadius',
+ hoverHitRadius: 'pointHitRadius',
+ hoverBackgroundColor: 'pointHoverBackgroundColor',
+ hoverBorderColor: 'pointHoverBorderColor',
+ hoverBorderWidth: 'pointHoverBorderWidth',
+ hoverRadius: 'pointHoverRadius',
+ pointStyle: 'pointStyle',
+ radius: 'pointRadius',
+ rotation: 'pointRotation'
+};
+
+export default LineController;
return toRadians(deg) - 0.5 * Math.PI;
}
-export default DatasetController.extend({
+class PolarAreaController extends DatasetController {
- dataElementType: Arc,
-
- /**
- * @private
- */
- _dataElementOptions: [
- 'backgroundColor',
- 'borderColor',
- 'borderWidth',
- 'borderAlign',
- 'hoverBackgroundColor',
- 'hoverBorderColor',
- 'hoverBorderWidth',
- ],
+ constructor(chart, datasetIndex) {
+ super(chart, datasetIndex);
+ }
/**
* @private
*/
- _getIndexScaleId: function() {
+ _getIndexScaleId() {
return this._cachedMeta.rAxisID;
- },
+ }
/**
* @private
*/
- _getValueScaleId: function() {
+ _getValueScaleId() {
return this._cachedMeta.rAxisID;
- },
+ }
- update: function(mode) {
+ update(mode) {
const arcs = this._cachedMeta.data;
this._updateRadius();
this.updateElements(arcs, 0, mode);
- },
+ }
/**
* @private
*/
- _updateRadius: function() {
+ _updateRadius() {
var me = this;
var chart = me.chart;
var chartArea = chart.chartArea;
me.outerRadius = chart.outerRadius - (chart.radiusLength * me.index);
me.innerRadius = me.outerRadius - chart.radiusLength;
- },
+ }
- updateElements: function(arcs, start, mode) {
+ updateElements(arcs, start, mode) {
const me = this;
const reset = mode === 'reset';
const chart = me.chart;
me._updateElement(arc, index, properties, mode);
}
- },
+ }
- countVisibleElements: function() {
+ countVisibleElements() {
var dataset = this.getDataset();
var meta = this._cachedMeta;
var count = 0;
});
return count;
- },
+ }
/**
* @private
*/
- _computeAngle: function(index) {
+ _computeAngle(index) {
var me = this;
var meta = me._cachedMeta;
var count = meta.count;
(2 * Math.PI) / count
], context, index);
}
-});
+}
+
+PolarAreaController.prototype.dataElementType = Arc;
+
+/**
+ * @private
+ */
+PolarAreaController.prototype._dataElementOptions = [
+ 'backgroundColor',
+ 'borderColor',
+ 'borderWidth',
+ 'borderAlign',
+ 'hoverBackgroundColor',
+ 'hoverBorderColor',
+ 'hoverBorderWidth'
+];
+
+export default PolarAreaController;
}
});
-export default DatasetController.extend({
- datasetElementType: Line,
+class RadarController extends DatasetController {
- dataElementType: Point,
-
- /**
- * @private
- */
- _datasetElementOptions: [
- 'backgroundColor',
- 'borderWidth',
- 'borderColor',
- 'borderCapStyle',
- 'borderDash',
- 'borderDashOffset',
- 'borderJoinStyle',
- 'fill'
- ],
-
- /**
- * @private
- */
- _dataElementOptions: {
- backgroundColor: 'pointBackgroundColor',
- borderColor: 'pointBorderColor',
- borderWidth: 'pointBorderWidth',
- hitRadius: 'pointHitRadius',
- hoverBackgroundColor: 'pointHoverBackgroundColor',
- hoverBorderColor: 'pointHoverBorderColor',
- hoverBorderWidth: 'pointHoverBorderWidth',
- hoverRadius: 'pointHoverRadius',
- pointStyle: 'pointStyle',
- radius: 'pointRadius',
- rotation: 'pointRotation'
- },
+ constructor(chart, datasetIndex) {
+ super(chart, datasetIndex);
+ }
/**
* @private
*/
- _getIndexScaleId: function() {
+ _getIndexScaleId() {
return this._cachedMeta.rAxisID;
- },
+ }
/**
* @private
*/
- _getValueScaleId: function() {
+ _getValueScaleId() {
return this._cachedMeta.rAxisID;
- },
+ }
/**
* @private
*/
- _getLabelAndValue: function(index) {
+ _getLabelAndValue(index) {
const me = this;
const vScale = me._cachedMeta.vScale;
const parsed = me._getParsed(index);
label: vScale._getLabels()[index],
value: '' + vScale.getLabelForValue(parsed[vScale.axis])
};
- },
+ }
- update: function(mode) {
+ update(mode) {
const me = this;
const meta = me._cachedMeta;
const line = meta.dataset;
me.updateElements(points, 0, mode);
line.updateControlPoints(me.chart.chartArea);
- },
+ }
- updateElements: function(points, start, mode) {
+ updateElements(points, start, mode) {
const me = this;
const dataset = me.getDataset();
const scale = me.chart.scales.r;
me._updateElement(point, index, properties, mode);
}
- },
+ }
/**
* @private
*/
- _resolveDatasetElementOptions: function() {
+ _resolveDatasetElementOptions() {
const me = this;
const config = me._config;
const options = me.chart.options;
return values;
}
-});
+}
+
+RadarController.prototype.datasetElementType = Line;
+
+RadarController.prototype.dataElementType = Point;
+
+/**
+ * @private
+ */
+RadarController.prototype._datasetElementOptions = [
+ 'backgroundColor',
+ 'borderWidth',
+ 'borderColor',
+ 'borderCapStyle',
+ 'borderDash',
+ 'borderDashOffset',
+ 'borderJoinStyle',
+ 'fill'
+];
+
+/**
+ * @private
+ */
+RadarController.prototype._dataElementOptions = {
+ backgroundColor: 'pointBackgroundColor',
+ borderColor: 'pointBorderColor',
+ borderWidth: 'pointBorderWidth',
+ hitRadius: 'pointHitRadius',
+ hoverBackgroundColor: 'pointHoverBackgroundColor',
+ hoverBorderColor: 'pointHoverBorderColor',
+ hoverBorderWidth: 'pointHoverBorderWidth',
+ hoverRadius: 'pointHoverRadius',
+ pointStyle: 'pointStyle',
+ radius: 'pointRadius',
+ rotation: 'pointRotation'
+};
+
+export default RadarController;