diff --git a/dist/next b/dist/next deleted file mode 120000 index fad0a3463f..0000000000 --- a/dist/next +++ /dev/null @@ -1 +0,0 @@ -3.0.0-dev \ No newline at end of file diff --git a/dist/next/Chart.esm.js b/dist/next/Chart.esm.js new file mode 100644 index 0000000000..e8d32a4bc7 --- /dev/null +++ b/dist/next/Chart.esm.js @@ -0,0 +1,11575 @@ +/*! + * Chart.js v3.0.0-alpha + * https://www.chartjs.org + * (c) 2020 Chart.js Contributors + * Released under the MIT License + */ +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function noop() {} +var uid = function () { + var id = 0; + return function () { + return id++; + }; +}(); +function isNullOrUndef(value) { + return value === null || typeof value === 'undefined'; +} +function isArray(value) { + if (Array.isArray && Array.isArray(value)) { + return true; + } + var type = Object.prototype.toString.call(value); + if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') { + return true; + } + return false; +} +function isObject(value) { + return value !== null && Object.prototype.toString.call(value) === '[object Object]'; +} +var isNumberFinite = value => (typeof value === 'number' || value instanceof Number) && isFinite(+value); +function valueOrDefault(value, defaultValue) { + return typeof value === 'undefined' ? defaultValue : value; +} +function valueAtIndexOrDefault(value, index, defaultValue) { + return valueOrDefault(isArray(value) ? value[index] : value, defaultValue); +} +function callback(fn, args, thisArg) { + if (fn && typeof fn.call === 'function') { + return fn.apply(thisArg, args); + } +} +function each(loopable, fn, thisArg, reverse) { + var i, len, keys; + if (isArray(loopable)) { + len = loopable.length; + if (reverse) { + for (i = len - 1; i >= 0; i--) { + fn.call(thisArg, loopable[i], i); + } + } else { + for (i = 0; i < len; i++) { + fn.call(thisArg, loopable[i], i); + } + } + } else if (isObject(loopable)) { + keys = Object.keys(loopable); + len = keys.length; + for (i = 0; i < len; i++) { + fn.call(thisArg, loopable[keys[i]], keys[i]); + } + } +} +function arrayEquals(a0, a1) { + var i, ilen, v0, v1; + if (!a0 || !a1 || a0.length !== a1.length) { + return false; + } + for (i = 0, ilen = a0.length; i < ilen; ++i) { + v0 = a0[i]; + v1 = a1[i]; + if (v0 instanceof Array && v1 instanceof Array) { + if (!arrayEquals(v0, v1)) { + return false; + } + } else if (v0 !== v1) { + return false; + } + } + return true; +} +function _elementsEqual(a0, a1) { + var i, ilen, v0, v1; + if (!a0 || !a1 || a0.length !== a1.length) { + return false; + } + for (i = 0, ilen = a0.length; i < ilen; ++i) { + v0 = a0[i]; + v1 = a1[i]; + if (v0.datasetIndex !== v1.datasetIndex || v0.index !== v1.index) { + return false; + } + } + return true; +} +function clone(source) { + if (isArray(source)) { + return source.map(clone); + } + if (isObject(source)) { + var target = {}; + var keys = Object.keys(source); + var klen = keys.length; + var k = 0; + for (; k < klen; ++k) { + target[keys[k]] = clone(source[keys[k]]); + } + return target; + } + return source; +} +function _merger(key, target, source, options) { + var tval = target[key]; + var sval = source[key]; + if (isObject(tval) && isObject(sval)) { + merge(tval, sval, options); + } else { + target[key] = clone(sval); + } +} +function merge(target, source, options) { + var sources = isArray(source) ? source : [source]; + var ilen = sources.length; + if (!isObject(target)) { + return target; + } + options = options || {}; + var merger = options.merger || _merger; + for (var i = 0; i < ilen; ++i) { + source = sources[i]; + if (!isObject(source)) { + continue; + } + var keys = Object.keys(source); + for (var k = 0, klen = keys.length; k < klen; ++k) { + merger(keys[k], target, source, options); + } + } + return target; +} +function mergeIf(target, source) { + return merge(target, source, { + merger: _mergerIf + }); +} +function _mergerIf(key, target, source) { + var tval = target[key]; + var sval = source[key]; + if (isObject(tval) && isObject(sval)) { + mergeIf(tval, sval); + } else if (!Object.prototype.hasOwnProperty.call(target, key)) { + target[key] = clone(sval); + } +} +function inherits(extensions) { + var me = this; + var ChartElement = extensions && Object.prototype.hasOwnProperty.call(extensions, 'constructor') ? extensions.constructor : function () { + return me.apply(this, arguments); + }; + var Surrogate = function Surrogate() { + this.constructor = ChartElement; + }; + Surrogate.prototype = me.prototype; + ChartElement.prototype = new Surrogate(); + ChartElement.extend = inherits; + if (extensions) { + _extends(ChartElement.prototype, extensions); + } + ChartElement.__super__ = me.prototype; + return ChartElement; +} +function _deprecated(scope, value, previous, current) { + if (value !== undefined) { + console.warn(scope + ': "' + previous + '" is deprecated. Please use "' + current + '" instead'); + } +} + +var coreHelpers = /*#__PURE__*/Object.freeze({ +__proto__: null, +noop: noop, +uid: uid, +isNullOrUndef: isNullOrUndef, +isArray: isArray, +isObject: isObject, +isFinite: isNumberFinite, +valueOrDefault: valueOrDefault, +valueAtIndexOrDefault: valueAtIndexOrDefault, +callback: callback, +each: each, +arrayEquals: arrayEquals, +_elementsEqual: _elementsEqual, +clone: clone, +_merger: _merger, +merge: merge, +mergeIf: mergeIf, +_mergerIf: _mergerIf, +inherits: inherits, +_deprecated: _deprecated +}); + +var PI = Math.PI; +var RAD_PER_DEG = PI / 180; +var DOUBLE_PI = PI * 2; +var HALF_PI = PI / 2; +var QUARTER_PI = PI / 4; +var TWO_THIRDS_PI = PI * 2 / 3; +function _measureText(ctx, data, gc, longest, string) { + var textWidth = data[string]; + if (!textWidth) { + textWidth = data[string] = ctx.measureText(string).width; + gc.push(string); + } + if (textWidth > longest) { + longest = textWidth; + } + return longest; +} +function _longestText(ctx, font, arrayOfThings, cache) { + cache = cache || {}; + var data = cache.data = cache.data || {}; + var gc = cache.garbageCollect = cache.garbageCollect || []; + if (cache.font !== font) { + data = cache.data = {}; + gc = cache.garbageCollect = []; + cache.font = font; + } + ctx.save(); + ctx.font = font; + var longest = 0; + var ilen = arrayOfThings.length; + var i, j, jlen, thing, nestedThing; + for (i = 0; i < ilen; i++) { + thing = arrayOfThings[i]; + if (thing !== undefined && thing !== null && isArray(thing) !== true) { + longest = _measureText(ctx, data, gc, longest, thing); + } else if (isArray(thing)) { + for (j = 0, jlen = thing.length; j < jlen; j++) { + nestedThing = thing[j]; + if (nestedThing !== undefined && nestedThing !== null && !isArray(nestedThing)) { + longest = _measureText(ctx, data, gc, longest, nestedThing); + } + } + } + } + ctx.restore(); + var gcLen = gc.length / 2; + if (gcLen > arrayOfThings.length) { + for (i = 0; i < gcLen; i++) { + delete data[gc[i]]; + } + gc.splice(0, gcLen); + } + return longest; +} +function _alignPixel(chart, pixel, width) { + var devicePixelRatio = chart.currentDevicePixelRatio; + var halfWidth = width / 2; + return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth; +} +function clear(chart) { + chart.ctx.clearRect(0, 0, chart.width, chart.height); +} +function drawPoint(ctx, options, x, y) { + var type, xOffset, yOffset, size, cornerRadius; + var style = options.pointStyle; + var rotation = options.rotation; + var radius = options.radius; + var rad = (rotation || 0) * RAD_PER_DEG; + if (style && typeof style === 'object') { + type = style.toString(); + if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') { + ctx.save(); + ctx.translate(x, y); + ctx.rotate(rad); + ctx.drawImage(style, -style.width / 2, -style.height / 2, style.width, style.height); + ctx.restore(); + return; + } + } + if (isNaN(radius) || radius <= 0) { + return; + } + ctx.beginPath(); + switch (style) { + default: + ctx.arc(x, y, radius, 0, DOUBLE_PI); + ctx.closePath(); + break; + case 'triangle': + ctx.moveTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); + rad += TWO_THIRDS_PI; + ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); + rad += TWO_THIRDS_PI; + ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); + ctx.closePath(); + break; + case 'rectRounded': + cornerRadius = radius * 0.516; + size = radius - cornerRadius; + xOffset = Math.cos(rad + QUARTER_PI) * size; + yOffset = Math.sin(rad + QUARTER_PI) * size; + ctx.arc(x - xOffset, y - yOffset, cornerRadius, rad - PI, rad - HALF_PI); + ctx.arc(x + yOffset, y - xOffset, cornerRadius, rad - HALF_PI, rad); + ctx.arc(x + xOffset, y + yOffset, cornerRadius, rad, rad + HALF_PI); + ctx.arc(x - yOffset, y + xOffset, cornerRadius, rad + HALF_PI, rad + PI); + ctx.closePath(); + break; + case 'rect': + if (!rotation) { + size = Math.SQRT1_2 * radius; + ctx.rect(x - size, y - size, 2 * size, 2 * size); + break; + } + rad += QUARTER_PI; + case 'rectRot': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + yOffset, y - xOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.lineTo(x - yOffset, y + xOffset); + ctx.closePath(); + break; + case 'crossRot': + rad += QUARTER_PI; + case 'cross': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.moveTo(x + yOffset, y - xOffset); + ctx.lineTo(x - yOffset, y + xOffset); + break; + case 'star': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.moveTo(x + yOffset, y - xOffset); + ctx.lineTo(x - yOffset, y + xOffset); + rad += QUARTER_PI; + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.moveTo(x + yOffset, y - xOffset); + ctx.lineTo(x - yOffset, y + xOffset); + break; + case 'line': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + break; + case 'dash': + ctx.moveTo(x, y); + ctx.lineTo(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius); + break; + } + ctx.fill(); + if (options.borderWidth > 0) { + ctx.stroke(); + } +} +function _isPointInArea(point, area) { + var epsilon = 0.5; + return point.x > area.left - epsilon && point.x < area.right + epsilon && point.y > area.top - epsilon && point.y < area.bottom + epsilon; +} +function clipArea(ctx, area) { + ctx.save(); + ctx.beginPath(); + ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top); + ctx.clip(); +} +function unclipArea(ctx) { + ctx.restore(); +} +function _steppedLineTo(ctx, previous, target, flip, mode) { + if (!previous) { + return ctx.lineTo(target.x, target.y); + } + if (mode === 'middle') { + var midpoint = (previous.x + target.x) / 2.0; + ctx.lineTo(midpoint, previous.y); + ctx.lineTo(midpoint, target.y); + } else if (mode === 'after' !== !!flip) { + ctx.lineTo(previous.x, target.y); + } else { + ctx.lineTo(target.x, previous.y); + } + ctx.lineTo(target.x, target.y); +} +function _bezierCurveTo(ctx, previous, target, flip) { + if (!previous) { + return ctx.lineTo(target.x, target.y); + } + ctx.bezierCurveTo(flip ? previous.controlPointPreviousX : previous.controlPointNextX, flip ? previous.controlPointPreviousY : previous.controlPointNextY, flip ? target.controlPointNextX : target.controlPointPreviousX, flip ? target.controlPointNextY : target.controlPointPreviousY, target.x, target.y); +} + +var canvas = /*#__PURE__*/Object.freeze({ +__proto__: null, +_measureText: _measureText, +_longestText: _longestText, +_alignPixel: _alignPixel, +clear: clear, +drawPoint: drawPoint, +_isPointInArea: _isPointInArea, +clipArea: clipArea, +unclipArea: unclipArea, +_steppedLineTo: _steppedLineTo, +_bezierCurveTo: _bezierCurveTo +}); + +var PI$1 = Math.PI; +var TAU = 2 * PI$1; +var PITAU = TAU + PI$1; +function _factorize(value) { + var result = []; + var sqrt = Math.sqrt(value); + var i; + for (i = 1; i < sqrt; i++) { + if (value % i === 0) { + result.push(i); + result.push(value / i); + } + } + if (sqrt === (sqrt | 0)) { + result.push(sqrt); + } + result.sort((a, b) => a - b).pop(); + return result; +} +var log10 = Math.log10 || function (x) { + var exponent = Math.log(x) * Math.LOG10E; + var powerOf10 = Math.round(exponent); + var isPowerOf10 = x === Math.pow(10, powerOf10); + return isPowerOf10 ? powerOf10 : exponent; +}; +function isNumber(n) { + return !isNaN(parseFloat(n)) && isFinite(n); +} +function almostEquals(x, y, epsilon) { + return Math.abs(x - y) < epsilon; +} +function almostWhole(x, epsilon) { + var rounded = Math.round(x); + return rounded - epsilon <= x && rounded + epsilon >= x; +} +function _setMinAndMaxByKey(array, target, property) { + var i, ilen, value; + for (i = 0, ilen = array.length; i < ilen; i++) { + value = array[i][property]; + if (!isNaN(value)) { + target.min = Math.min(target.min, value); + target.max = Math.max(target.max, value); + } + } +} +var sign = Math.sign ? function (x) { + return Math.sign(x); +} : function (x) { + x = +x; + if (x === 0 || isNaN(x)) { + return x; + } + return x > 0 ? 1 : -1; +}; +function toRadians(degrees) { + return degrees * (PI$1 / 180); +} +function toDegrees(radians) { + return radians * (180 / PI$1); +} +function _decimalPlaces(x) { + if (!isNumberFinite(x)) { + return; + } + var e = 1; + var p = 0; + while (Math.round(x * e) / e !== x) { + e *= 10; + p++; + } + return p; +} +function getAngleFromPoint(centrePoint, anglePoint) { + var distanceFromXCenter = anglePoint.x - centrePoint.x; + var distanceFromYCenter = anglePoint.y - centrePoint.y; + var radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); + var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter); + if (angle < -0.5 * PI$1) { + angle += TAU; + } + return { + angle, + distance: radialDistanceFromCenter + }; +} +function distanceBetweenPoints(pt1, pt2) { + return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2)); +} +function _angleDiff(a, b) { + return (a - b + PITAU) % TAU - PI$1; +} +function _normalizeAngle(a) { + return (a % TAU + TAU) % TAU; +} +function _angleBetween(angle, start, end) { + var a = _normalizeAngle(angle); + var s = _normalizeAngle(start); + var e = _normalizeAngle(end); + var angleToStart = _normalizeAngle(s - a); + var angleToEnd = _normalizeAngle(e - a); + var startToAngle = _normalizeAngle(a - s); + var endToAngle = _normalizeAngle(a - e); + return a === s || a === e || angleToStart > angleToEnd && startToAngle < endToAngle; +} +function _limitValue(value, min, max) { + return Math.max(min, Math.min(max, value)); +} + +var math = /*#__PURE__*/Object.freeze({ +__proto__: null, +_factorize: _factorize, +log10: log10, +isNumber: isNumber, +almostEquals: almostEquals, +almostWhole: almostWhole, +_setMinAndMaxByKey: _setMinAndMaxByKey, +sign: sign, +toRadians: toRadians, +toDegrees: toDegrees, +_decimalPlaces: _decimalPlaces, +getAngleFromPoint: getAngleFromPoint, +distanceBetweenPoints: distanceBetweenPoints, +_angleDiff: _angleDiff, +_normalizeAngle: _normalizeAngle, +_angleBetween: _angleBetween, +_limitValue: _limitValue +}); + +var EPSILON = Number.EPSILON || 1e-14; +function splineCurve(firstPoint, middlePoint, afterPoint, t) { + var previous = firstPoint.skip ? middlePoint : firstPoint; + var current = middlePoint; + var next = afterPoint.skip ? middlePoint : afterPoint; + var d01 = Math.sqrt(Math.pow(current.x - previous.x, 2) + Math.pow(current.y - previous.y, 2)); + var d12 = Math.sqrt(Math.pow(next.x - current.x, 2) + Math.pow(next.y - current.y, 2)); + var s01 = d01 / (d01 + d12); + var s12 = d12 / (d01 + d12); + s01 = isNaN(s01) ? 0 : s01; + s12 = isNaN(s12) ? 0 : s12; + var fa = t * s01; + var fb = t * s12; + return { + previous: { + x: current.x - fa * (next.x - previous.x), + y: current.y - fa * (next.y - previous.y) + }, + next: { + x: current.x + fb * (next.x - previous.x), + y: current.y + fb * (next.y - previous.y) + } + }; +} +function splineCurveMonotone(points) { + var pointsWithTangents = (points || []).map(point => ({ + model: point, + deltaK: 0, + mK: 0 + })); + var pointsLen = pointsWithTangents.length; + var i, pointBefore, pointCurrent, pointAfter; + for (i = 0; i < pointsLen; ++i) { + pointCurrent = pointsWithTangents[i]; + if (pointCurrent.model.skip) { + continue; + } + pointBefore = i > 0 ? pointsWithTangents[i - 1] : null; + pointAfter = i < pointsLen - 1 ? pointsWithTangents[i + 1] : null; + if (pointAfter && !pointAfter.model.skip) { + var slopeDeltaX = pointAfter.model.x - pointCurrent.model.x; + pointCurrent.deltaK = slopeDeltaX !== 0 ? (pointAfter.model.y - pointCurrent.model.y) / slopeDeltaX : 0; + } + if (!pointBefore || pointBefore.model.skip) { + pointCurrent.mK = pointCurrent.deltaK; + } else if (!pointAfter || pointAfter.model.skip) { + pointCurrent.mK = pointBefore.deltaK; + } else if (sign(pointBefore.deltaK) !== sign(pointCurrent.deltaK)) { + pointCurrent.mK = 0; + } else { + pointCurrent.mK = (pointBefore.deltaK + pointCurrent.deltaK) / 2; + } + } + var alphaK, betaK, tauK, squaredMagnitude; + for (i = 0; i < pointsLen - 1; ++i) { + pointCurrent = pointsWithTangents[i]; + pointAfter = pointsWithTangents[i + 1]; + if (pointCurrent.model.skip || pointAfter.model.skip) { + continue; + } + if (almostEquals(pointCurrent.deltaK, 0, EPSILON)) { + pointCurrent.mK = pointAfter.mK = 0; + continue; + } + alphaK = pointCurrent.mK / pointCurrent.deltaK; + betaK = pointAfter.mK / pointCurrent.deltaK; + squaredMagnitude = Math.pow(alphaK, 2) + Math.pow(betaK, 2); + if (squaredMagnitude <= 9) { + continue; + } + tauK = 3 / Math.sqrt(squaredMagnitude); + pointCurrent.mK = alphaK * tauK * pointCurrent.deltaK; + pointAfter.mK = betaK * tauK * pointCurrent.deltaK; + } + var deltaX; + for (i = 0; i < pointsLen; ++i) { + pointCurrent = pointsWithTangents[i]; + if (pointCurrent.model.skip) { + continue; + } + pointBefore = i > 0 ? pointsWithTangents[i - 1] : null; + pointAfter = i < pointsLen - 1 ? pointsWithTangents[i + 1] : null; + if (pointBefore && !pointBefore.model.skip) { + deltaX = (pointCurrent.model.x - pointBefore.model.x) / 3; + pointCurrent.model.controlPointPreviousX = pointCurrent.model.x - deltaX; + pointCurrent.model.controlPointPreviousY = pointCurrent.model.y - deltaX * pointCurrent.mK; + } + if (pointAfter && !pointAfter.model.skip) { + deltaX = (pointAfter.model.x - pointCurrent.model.x) / 3; + pointCurrent.model.controlPointNextX = pointCurrent.model.x + deltaX; + pointCurrent.model.controlPointNextY = pointCurrent.model.y + deltaX * pointCurrent.mK; + } + } +} +function capControlPoint(pt, min, max) { + return Math.max(Math.min(pt, max), min); +} +function capBezierPoints(points, area) { + var i, ilen, point; + for (i = 0, ilen = points.length; i < ilen; ++i) { + point = points[i]; + if (!_isPointInArea(point, area)) { + continue; + } + if (i > 0 && _isPointInArea(points[i - 1], area)) { + point.controlPointPreviousX = capControlPoint(point.controlPointPreviousX, area.left, area.right); + point.controlPointPreviousY = capControlPoint(point.controlPointPreviousY, area.top, area.bottom); + } + if (i < points.length - 1 && _isPointInArea(points[i + 1], area)) { + point.controlPointNextX = capControlPoint(point.controlPointNextX, area.left, area.right); + point.controlPointNextY = capControlPoint(point.controlPointNextY, area.top, area.bottom); + } + } +} +function _updateBezierControlPoints(points, options, area, loop) { + var i, ilen, point, controlPoints; + if (options.spanGaps) { + points = points.filter(pt => !pt.skip); + } + if (options.cubicInterpolationMode === 'monotone') { + splineCurveMonotone(points); + } else { + var prev = loop ? points[points.length - 1] : points[0]; + for (i = 0, ilen = points.length; i < ilen; ++i) { + point = points[i]; + controlPoints = splineCurve(prev, point, points[Math.min(i + 1, ilen - (loop ? 0 : 1)) % ilen], options.tension); + point.controlPointPreviousX = controlPoints.previous.x; + point.controlPointPreviousY = controlPoints.previous.y; + point.controlPointNextX = controlPoints.next.x; + point.controlPointNextY = controlPoints.next.y; + prev = point; + } + } + if (options.capBezierPoints) { + capBezierPoints(points, area); + } +} + +var curve = /*#__PURE__*/Object.freeze({ +__proto__: null, +splineCurve: splineCurve, +splineCurveMonotone: splineCurveMonotone, +_updateBezierControlPoints: _updateBezierControlPoints +}); + +function isConstrainedValue(value) { + return value !== undefined && value !== null && value !== 'none'; +} +function _getParentNode(domNode) { + var parent = domNode.parentNode; + if (parent && parent.toString() === '[object ShadowRoot]') { + parent = parent.host; + } + return parent; +} +function parseMaxStyle(styleValue, node, parentProperty) { + var valueInPixels; + if (typeof styleValue === 'string') { + valueInPixels = parseInt(styleValue, 10); + if (styleValue.indexOf('%') !== -1) { + valueInPixels = valueInPixels / 100 * node.parentNode[parentProperty]; + } + } else { + valueInPixels = styleValue; + } + return valueInPixels; +} +function getConstraintDimension(domNode, maxStyle, percentageProperty) { + var view = document.defaultView; + var parentNode = _getParentNode(domNode); + var constrainedNode = view.getComputedStyle(domNode)[maxStyle]; + var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle]; + var hasCNode = isConstrainedValue(constrainedNode); + var hasCContainer = isConstrainedValue(constrainedContainer); + var infinity = Number.POSITIVE_INFINITY; + if (hasCNode || hasCContainer) { + return Math.min(hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity, hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity); + } +} +function getStyle(el, property) { + return el.currentStyle ? el.currentStyle[property] : document.defaultView.getComputedStyle(el, null).getPropertyValue(property); +} +function getConstraintWidth(domNode) { + return getConstraintDimension(domNode, 'max-width', 'clientWidth'); +} +function getConstraintHeight(domNode) { + return getConstraintDimension(domNode, 'max-height', 'clientHeight'); +} +function _calculatePadding(container, padding, parentDimension) { + padding = getStyle(container, padding); + return padding.indexOf('%') > -1 ? parentDimension * parseInt(padding, 10) / 100 : parseInt(padding, 10); +} +function getRelativePosition(evt, chart) { + var mouseX, mouseY; + var e = evt.originalEvent || evt; + var canvasElement = chart.canvas; + var boundingRect = canvasElement.getBoundingClientRect(); + var touches = e.touches; + if (touches && touches.length > 0) { + mouseX = touches[0].clientX; + mouseY = touches[0].clientY; + } else { + mouseX = e.clientX; + mouseY = e.clientY; + } + var paddingLeft = parseFloat(getStyle(canvasElement, 'padding-left')); + var paddingTop = parseFloat(getStyle(canvasElement, 'padding-top')); + var paddingRight = parseFloat(getStyle(canvasElement, 'padding-right')); + var paddingBottom = parseFloat(getStyle(canvasElement, 'padding-bottom')); + var width = boundingRect.right - boundingRect.left - paddingLeft - paddingRight; + var height = boundingRect.bottom - boundingRect.top - paddingTop - paddingBottom; + mouseX = Math.round((mouseX - boundingRect.left - paddingLeft) / width * canvasElement.width / chart.currentDevicePixelRatio); + mouseY = Math.round((mouseY - boundingRect.top - paddingTop) / height * canvasElement.height / chart.currentDevicePixelRatio); + return { + x: mouseX, + y: mouseY + }; +} +function getMaximumWidth(domNode) { + var container = _getParentNode(domNode); + if (!container) { + if (typeof domNode.clientWidth === 'number') { + return domNode.clientWidth; + } + return domNode.width; + } + var clientWidth = container.clientWidth; + var paddingLeft = _calculatePadding(container, 'padding-left', clientWidth); + var paddingRight = _calculatePadding(container, 'padding-right', clientWidth); + var w = clientWidth - paddingLeft - paddingRight; + var cw = getConstraintWidth(domNode); + return isNaN(cw) ? w : Math.min(w, cw); +} +function getMaximumHeight(domNode) { + var container = _getParentNode(domNode); + if (!container) { + if (typeof domNode.clientHeight === 'number') { + return domNode.clientHeight; + } + return domNode.height; + } + var clientHeight = container.clientHeight; + var paddingTop = _calculatePadding(container, 'padding-top', clientHeight); + var paddingBottom = _calculatePadding(container, 'padding-bottom', clientHeight); + var h = clientHeight - paddingTop - paddingBottom; + var ch = getConstraintHeight(domNode); + return isNaN(ch) ? h : Math.min(h, ch); +} +function retinaScale(chart, forceRatio) { + var pixelRatio = chart.currentDevicePixelRatio = forceRatio || typeof window !== 'undefined' && window.devicePixelRatio || 1; + var { + canvas, + width, + height + } = chart; + canvas.height = height * pixelRatio; + canvas.width = width * pixelRatio; + chart.ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0); + if (canvas.style && !canvas.style.height && !canvas.style.width) { + canvas.style.height = height + 'px'; + canvas.style.width = width + 'px'; + } +} + +var dom = /*#__PURE__*/Object.freeze({ +__proto__: null, +_getParentNode: _getParentNode, +getStyle: getStyle, +getRelativePosition: getRelativePosition, +getMaximumWidth: getMaximumWidth, +getMaximumHeight: getMaximumHeight, +retinaScale: retinaScale +}); + +var effects = { + linear(t) { + return t; + }, + easeInQuad(t) { + return t * t; + }, + easeOutQuad(t) { + return -t * (t - 2); + }, + easeInOutQuad(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t; + } + return -0.5 * (--t * (t - 2) - 1); + }, + easeInCubic(t) { + return t * t * t; + }, + easeOutCubic(t) { + return (t -= 1) * t * t + 1; + }, + easeInOutCubic(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t * t; + } + return 0.5 * ((t -= 2) * t * t + 2); + }, + easeInQuart(t) { + return t * t * t * t; + }, + easeOutQuart(t) { + return -((t -= 1) * t * t * t - 1); + }, + easeInOutQuart(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t * t * t; + } + return -0.5 * ((t -= 2) * t * t * t - 2); + }, + easeInQuint(t) { + return t * t * t * t * t; + }, + easeOutQuint(t) { + return (t -= 1) * t * t * t * t + 1; + }, + easeInOutQuint(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t * t * t * t; + } + return 0.5 * ((t -= 2) * t * t * t * t + 2); + }, + easeInSine(t) { + return -Math.cos(t * (Math.PI / 2)) + 1; + }, + easeOutSine(t) { + return Math.sin(t * (Math.PI / 2)); + }, + easeInOutSine(t) { + return -0.5 * (Math.cos(Math.PI * t) - 1); + }, + easeInExpo(t) { + return t === 0 ? 0 : Math.pow(2, 10 * (t - 1)); + }, + easeOutExpo(t) { + return t === 1 ? 1 : -Math.pow(2, -10 * t) + 1; + }, + easeInOutExpo(t) { + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if ((t /= 0.5) < 1) { + return 0.5 * Math.pow(2, 10 * (t - 1)); + } + return 0.5 * (-Math.pow(2, -10 * --t) + 2); + }, + easeInCirc(t) { + if (t >= 1) { + return t; + } + return -(Math.sqrt(1 - t * t) - 1); + }, + easeOutCirc(t) { + return Math.sqrt(1 - (t -= 1) * t); + }, + easeInOutCirc(t) { + if ((t /= 0.5) < 1) { + return -0.5 * (Math.sqrt(1 - t * t) - 1); + } + return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1); + }, + easeInElastic(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if (!p) { + p = 0.3; + } + { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p)); + }, + easeOutElastic(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if (!p) { + p = 0.3; + } + { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p) + 1; + }, + easeInOutElastic(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 0.5) === 2) { + return 1; + } + if (!p) { + p = 0.45; + } + { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + if (t < 1) { + return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p) * 0.5 + 1; + }, + easeInBack(t) { + var s = 1.70158; + return t * t * ((s + 1) * t - s); + }, + easeOutBack(t) { + var s = 1.70158; + return (t -= 1) * t * ((s + 1) * t + s) + 1; + }, + easeInOutBack(t) { + var s = 1.70158; + if ((t /= 0.5) < 1) { + return 0.5 * (t * t * (((s *= 1.525) + 1) * t - s)); + } + return 0.5 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2); + }, + easeInBounce(t) { + return 1 - effects.easeOutBounce(1 - t); + }, + easeOutBounce(t) { + if (t < 1 / 2.75) { + return 7.5625 * t * t; + } + if (t < 2 / 2.75) { + return 7.5625 * (t -= 1.5 / 2.75) * t + 0.75; + } + if (t < 2.5 / 2.75) { + return 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375; + } + return 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375; + }, + easeInOutBounce(t) { + if (t < 0.5) { + return effects.easeInBounce(t * 2) * 0.5; + } + return effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5; + } +}; + +class Defaults { + constructor() { + this.color = 'rgba(0,0,0,0.1)'; + this.elements = {}; + this.events = ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove']; + this.fontColor = '#666'; + this.fontFamily = "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"; + this.fontSize = 12; + this.fontStyle = 'normal'; + this.lineHeight = 1.2; + this.hover = { + onHover: null, + mode: 'nearest', + intersect: true + }; + this.maintainAspectRatio = true; + this.onClick = null; + this.responsive = true; + this.showLines = true; + this.plugins = undefined; + this.scale = undefined; + this.legend = undefined; + this.title = undefined; + this.tooltips = undefined; + this.doughnut = undefined; + } + set(scope, values) { + return merge(this[scope] || (this[scope] = {}), values); + } +} +var defaults = new Defaults(); + +function toFontString(font) { + if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) { + return null; + } + return (font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family; +} +function toLineHeight(value, size) { + var matches = ('' + value).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/); + if (!matches || matches[1] === 'normal') { + return size * 1.2; + } + value = +matches[2]; + switch (matches[3]) { + case 'px': + return value; + case '%': + value /= 100; + break; + } + return size * value; +} +function toPadding(value) { + var t, r, b, l; + if (isObject(value)) { + t = +value.top || 0; + r = +value.right || 0; + b = +value.bottom || 0; + l = +value.left || 0; + } else { + t = r = b = l = +value || 0; + } + return { + top: t, + right: r, + bottom: b, + left: l, + height: t + b, + width: l + r + }; +} +function _parseFont(options) { + var size = valueOrDefault(options.fontSize, defaults.fontSize); + if (typeof size === 'string') { + size = parseInt(size, 10); + } + var font = { + family: valueOrDefault(options.fontFamily, defaults.fontFamily), + lineHeight: toLineHeight(valueOrDefault(options.lineHeight, defaults.lineHeight), size), + size, + style: valueOrDefault(options.fontStyle, defaults.fontStyle), + weight: null, + string: '' + }; + font.string = toFontString(font); + return font; +} +function resolve(inputs, context, index, info) { + var cacheable = true; + var i, ilen, value; + for (i = 0, ilen = inputs.length; i < ilen; ++i) { + value = inputs[i]; + if (value === undefined) { + continue; + } + if (context !== undefined && typeof value === 'function') { + value = value(context); + cacheable = false; + } + if (index !== undefined && isArray(value)) { + value = value[index]; + cacheable = false; + } + if (value !== undefined) { + if (info && !cacheable) { + info.cacheable = false; + } + return value; + } + } +} + +var options = /*#__PURE__*/Object.freeze({ +__proto__: null, +toLineHeight: toLineHeight, +toPadding: toPadding, +_parseFont: _parseFont, +resolve: resolve +}); + +var getRightToLeftAdapter = function getRightToLeftAdapter(rectX, width) { + return { + x(x) { + return rectX + rectX + width - x; + }, + setWidth(w) { + width = w; + }, + textAlign(align) { + if (align === 'center') { + return align; + } + return align === 'right' ? 'left' : 'right'; + }, + xPlus(x, value) { + return x - value; + }, + leftForLtr(x, itemWidth) { + return x - itemWidth; + } + }; +}; +var getLeftToRightAdapter = function getLeftToRightAdapter() { + return { + x(x) { + return x; + }, + setWidth(w) { + }, + textAlign(align) { + return align; + }, + xPlus(x, value) { + return x + value; + }, + leftForLtr(x, _itemWidth) { + return x; + } + }; +}; +function getRtlAdapter(rtl, rectX, width) { + return rtl ? getRightToLeftAdapter(rectX, width) : getLeftToRightAdapter(); +} +function overrideTextDirection(ctx, direction) { + var style, original; + if (direction === 'ltr' || direction === 'rtl') { + style = ctx.canvas.style; + original = [style.getPropertyValue('direction'), style.getPropertyPriority('direction')]; + style.setProperty('direction', direction, 'important'); + ctx.prevTextDirection = original; + } +} +function restoreTextDirection(ctx, original) { + if (original !== undefined) { + delete ctx.prevTextDirection; + ctx.canvas.style.setProperty('direction', original[0], original[1]); + } +} + +var rtl = /*#__PURE__*/Object.freeze({ +__proto__: null, +getRtlAdapter: getRtlAdapter, +overrideTextDirection: overrideTextDirection, +restoreTextDirection: restoreTextDirection +}); + +/*! + * @kurkle/color v0.1.7 + * https://github.com/kurkle/color#readme + * (c) 2020 Jukka Kurkela + * Released under the MIT License + */ +var map = { + 0: 0, + 1: 1, + 2: 2, + 3: 3, + 4: 4, + 5: 5, + 6: 6, + 7: 7, + 8: 8, + 9: 9, + A: 10, + B: 11, + C: 12, + D: 13, + E: 14, + F: 15, + a: 10, + b: 11, + c: 12, + d: 13, + e: 14, + f: 15 +}; +var hex = '0123456789ABCDEF'; +var h1 = b => hex[b & 0xF]; +var h2 = b => hex[(b & 0xF0) >> 4] + hex[b & 0xF]; +var eq = b => (b & 0xF0) >> 4 === (b & 0xF); +function isShort(v) { + return eq(v.r) && eq(v.g) && eq(v.b) && eq(v.a); +} +function hexParse(str) { + var len = str.length; + var ret; + if (str[0] === '#') { + if (len === 4 || len === 5) { + ret = { + r: 255 & map[str[1]] * 17, + g: 255 & map[str[2]] * 17, + b: 255 & map[str[3]] * 17, + a: len === 5 ? map[str[4]] * 17 : 255 + }; + } else if (len === 7 || len === 9) { + ret = { + r: map[str[1]] << 4 | map[str[2]], + g: map[str[3]] << 4 | map[str[4]], + b: map[str[5]] << 4 | map[str[6]], + a: len === 9 ? map[str[7]] << 4 | map[str[8]] : 255 + }; + } + } + return ret; +} +function hexString(v) { + var f = isShort(v) ? h1 : h2; + return v ? '#' + f(v.r) + f(v.g) + f(v.b) + (v.a < 255 ? f(v.a) : '') : v; +} +function round(v) { + return v + 0.5 | 0; +} +var lim = (v, l, h) => Math.max(Math.min(v, h), l); +function p2b(v) { + return lim(round(v * 2.55), 0, 255); +} +function n2b(v) { + return lim(round(v * 255), 0, 255); +} +function b2n(v) { + return lim(round(v / 2.55) / 100, 0, 1); +} +function n2p(v) { + return lim(round(v * 100), 0, 100); +} +var RGB_RE = /^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/; +function rgbParse(str) { + var m = RGB_RE.exec(str); + var a = 255; + var r, g, b; + if (!m) { + return; + } + if (m[7] !== r) { + var v = +m[7]; + a = 255 & (m[8] ? p2b(v) : v * 255); + } + r = +m[1]; + g = +m[3]; + b = +m[5]; + r = 255 & (m[2] ? p2b(r) : r); + g = 255 & (m[4] ? p2b(g) : g); + b = 255 & (m[6] ? p2b(b) : b); + return { + r: r, + g: g, + b: b, + a: a + }; +} +function rgbString(v) { + return v && (v.a < 255 ? "rgba(".concat(v.r, ", ").concat(v.g, ", ").concat(v.b, ", ").concat(b2n(v.a), ")") : "rgb(".concat(v.r, ", ").concat(v.g, ", ").concat(v.b, ")")); +} +var HUE_RE = /^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/; +function hsl2rgbn(h, s, l) { + var a = s * Math.min(l, 1 - l); + var f = function f(n) { + var k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (n + h / 30) % 12; + return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1); + }; + return [f(0), f(8), f(4)]; +} +function hsv2rgbn(h, s, v) { + var f = function f(n) { + var k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (n + h / 60) % 6; + return v - v * s * Math.max(Math.min(k, 4 - k, 1), 0); + }; + return [f(5), f(3), f(1)]; +} +function hwb2rgbn(h, w, b) { + var rgb = hsl2rgbn(h, 1, 0.5); + var i; + if (w + b > 1) { + i = 1 / (w + b); + w *= i; + b *= i; + } + for (i = 0; i < 3; i++) { + rgb[i] *= 1 - w - b; + rgb[i] += w; + } + return rgb; +} +function rgb2hsl(v) { + var range = 255; + var r = v.r / range; + var g = v.g / range; + var b = v.b / range; + var max = Math.max(r, g, b); + var min = Math.min(r, g, b); + var l = (max + min) / 2; + var h, s, d; + if (max !== min) { + d = max - min; + s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4; + h = h * 60 + 0.5; + } + return [h | 0, s || 0, l]; +} +function calln(f, a, b, c) { + return (Array.isArray(a) ? f(a[0], a[1], a[2]) : f(a, b, c)).map(n2b); +} +function hsl2rgb(h, s, l) { + return calln(hsl2rgbn, h, s, l); +} +function hwb2rgb(h, w, b) { + return calln(hwb2rgbn, h, w, b); +} +function hsv2rgb(h, s, v) { + return calln(hsv2rgbn, h, s, v); +} +function hue(h) { + return (h % 360 + 360) % 360; +} +function hueParse(str) { + var m = HUE_RE.exec(str); + var a = 255; + var v; + if (!m) { + return; + } + if (m[5] !== v) { + a = m[6] ? p2b(+m[5]) : n2b(+m[5]); + } + var h = hue(+m[2]); + var p1 = +m[3] / 100; + var p2 = +m[4] / 100; + if (m[1] === 'hwb') { + v = hwb2rgb(h, p1, p2); + } else if (m[1] === 'hsv') { + v = hsv2rgb(h, p1, p2); + } else { + v = hsl2rgb(h, p1, p2); + } + return { + r: v[0], + g: v[1], + b: v[2], + a: a + }; +} +function rotate(v, deg) { + var h = rgb2hsl(v); + h[0] = hue(h[0] + deg); + h = hsl2rgb(h); + v.r = h[0]; + v.g = h[1]; + v.b = h[2]; +} +function hslString(v) { + if (!v) { + return; + } + var a = rgb2hsl(v); + var h = a[0]; + var s = n2p(a[1]); + var l = n2p(a[2]); + return v.a < 255 ? "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(b2n(v.a), ")") : "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)"); +} +var map$1 = { + x: 'dark', + Z: 'light', + Y: 're', + X: 'blu', + W: 'gr', + V: 'medium', + U: 'slate', + A: 'ee', + T: 'ol', + S: 'or', + B: 'ra', + C: 'lateg', + D: 'ights', + R: 'in', + Q: 'turquois', + E: 'hi', + P: 'ro', + O: 'al', + N: 'le', + M: 'de', + L: 'yello', + F: 'en', + K: 'ch', + G: 'arks', + H: 'ea', + I: 'ightg', + J: 'wh' +}; +function unpack(obj) { + var unpacked = {}; + var keys = Object.keys(obj); + var tkeys = Object.keys(map$1); + var i, j, k, ok, nk; + for (i = 0; i < keys.length; i++) { + ok = nk = keys[i]; + for (j = 0; j < tkeys.length; j++) { + k = tkeys[j]; + nk = nk.replace(k, map$1[k]); + } + k = parseInt(obj[ok], 16); + unpacked[nk] = [k >> 16 & 0xFF, k >> 8 & 0xFF, k & 0xFF]; + } + return unpacked; +} +var names = unpack({ + OiceXe: 'f0f8ff', + antiquewEte: 'faebd7', + aqua: 'ffff', + aquamarRe: '7fffd4', + azuY: 'f0ffff', + beige: 'f5f5dc', + bisque: 'ffe4c4', + black: '0', + blanKedOmond: 'ffebcd', + Xe: 'ff', + XeviTet: '8a2be2', + bPwn: 'a52a2a', + burlywood: 'deb887', + caMtXe: '5f9ea0', + KartYuse: '7fff00', + KocTate: 'd2691e', + cSO: 'ff7f50', + cSnflowerXe: '6495ed', + cSnsilk: 'fff8dc', + crimson: 'dc143c', + cyan: 'ffff', + xXe: '8b', + xcyan: '8b8b', + xgTMnPd: 'b8860b', + xWay: 'a9a9a9', + xgYF: '6400', + xgYy: 'a9a9a9', + xkhaki: 'bdb76b', + xmagFta: '8b008b', + xTivegYF: '556b2f', + xSange: 'ff8c00', + xScEd: '9932cc', + xYd: '8b0000', + xsOmon: 'e9967a', + xsHgYF: '8fbc8f', + xUXe: '483d8b', + xUWay: '2f4f4f', + xUgYy: '2f4f4f', + xQe: 'ced1', + xviTet: '9400d3', + dAppRk: 'ff1493', + dApskyXe: 'bfff', + dimWay: '696969', + dimgYy: '696969', + dodgerXe: '1e90ff', + fiYbrick: 'b22222', + flSOwEte: 'fffaf0', + foYstWAn: '228b22', + fuKsia: 'ff00ff', + gaRsbSo: 'dcdcdc', + ghostwEte: 'f8f8ff', + gTd: 'ffd700', + gTMnPd: 'daa520', + Way: '808080', + gYF: '8000', + gYFLw: 'adff2f', + gYy: '808080', + honeyMw: 'f0fff0', + hotpRk: 'ff69b4', + RdianYd: 'cd5c5c', + Rdigo: '4b0082', + ivSy: 'fffff0', + khaki: 'f0e68c', + lavFMr: 'e6e6fa', + lavFMrXsh: 'fff0f5', + lawngYF: '7cfc00', + NmoncEffon: 'fffacd', + ZXe: 'add8e6', + ZcSO: 'f08080', + Zcyan: 'e0ffff', + ZgTMnPdLw: 'fafad2', + ZWay: 'd3d3d3', + ZgYF: '90ee90', + ZgYy: 'd3d3d3', + ZpRk: 'ffb6c1', + ZsOmon: 'ffa07a', + ZsHgYF: '20b2aa', + ZskyXe: '87cefa', + ZUWay: '778899', + ZUgYy: '778899', + ZstAlXe: 'b0c4de', + ZLw: 'ffffe0', + lime: 'ff00', + limegYF: '32cd32', + lRF: 'faf0e6', + magFta: 'ff00ff', + maPon: '800000', + VaquamarRe: '66cdaa', + VXe: 'cd', + VScEd: 'ba55d3', + VpurpN: '9370db', + VsHgYF: '3cb371', + VUXe: '7b68ee', + VsprRggYF: 'fa9a', + VQe: '48d1cc', + VviTetYd: 'c71585', + midnightXe: '191970', + mRtcYam: 'f5fffa', + mistyPse: 'ffe4e1', + moccasR: 'ffe4b5', + navajowEte: 'ffdead', + navy: '80', + Tdlace: 'fdf5e6', + Tive: '808000', + TivedBb: '6b8e23', + Sange: 'ffa500', + SangeYd: 'ff4500', + ScEd: 'da70d6', + pOegTMnPd: 'eee8aa', + pOegYF: '98fb98', + pOeQe: 'afeeee', + pOeviTetYd: 'db7093', + papayawEp: 'ffefd5', + pHKpuff: 'ffdab9', + peru: 'cd853f', + pRk: 'ffc0cb', + plum: 'dda0dd', + powMrXe: 'b0e0e6', + purpN: '800080', + YbeccapurpN: '663399', + Yd: 'ff0000', + Psybrown: 'bc8f8f', + PyOXe: '4169e1', + saddNbPwn: '8b4513', + sOmon: 'fa8072', + sandybPwn: 'f4a460', + sHgYF: '2e8b57', + sHshell: 'fff5ee', + siFna: 'a0522d', + silver: 'c0c0c0', + skyXe: '87ceeb', + UXe: '6a5acd', + UWay: '708090', + UgYy: '708090', + snow: 'fffafa', + sprRggYF: 'ff7f', + stAlXe: '4682b4', + tan: 'd2b48c', + teO: '8080', + tEstN: 'd8bfd8', + tomato: 'ff6347', + Qe: '40e0d0', + viTet: 'ee82ee', + JHt: 'f5deb3', + wEte: 'ffffff', + wEtesmoke: 'f5f5f5', + Lw: 'ffff00', + LwgYF: '9acd32' +}); +names.transparent = [0, 0, 0, 0]; +function nameParse(str) { + var a = names[str]; + return a && { + r: a[0], + g: a[1], + b: a[2], + a: a.length === 4 ? a[3] : 255 + }; +} +function modHSL(v, i, ratio) { + if (v) { + var tmp = rgb2hsl(v); + tmp[i] = Math.max(0, Math.min(tmp[i] + tmp[i] * ratio, i === 0 ? 360 : 1)); + tmp = hsl2rgb(tmp); + v.r = tmp[0]; + v.g = tmp[1]; + v.b = tmp[2]; + } +} +function clone$1(v, proto) { + return v ? _extends(proto || {}, v) : v; +} +function fromObject(input) { + var v = { + r: 0, + g: 0, + b: 0, + a: 255 + }; + if (Array.isArray(input)) { + if (input.length >= 3) { + v = { + r: input[0], + g: input[1], + b: input[2], + a: 255 + }; + if (input.length > 3) { + v.a = n2b(input[3]); + } + } + } else { + v = clone$1(input, { + r: 0, + g: 0, + b: 0, + a: 1 + }); + v.a = n2b(v.a); + } + return v; +} +function functionParse(str) { + if (str.charAt(0) === 'r') { + return rgbParse(str); + } + return hueParse(str); +} +class Color { + constructor(input) { + if (input instanceof Color) { + return input; + } + var type = typeof input; + var v; + if (type === 'object') { + v = fromObject(input); + } else if (type === 'string') { + v = hexParse(input) || nameParse(input) || functionParse(input); + } + this._rgb = v; + this._valid = !!v; + } + get valid() { + return this._valid; + } + get rgb() { + var v = clone$1(this._rgb); + if (v) { + v.a = b2n(v.a); + } + return v; + } + set rgb(obj) { + this._rgb = fromObject(obj); + } + rgbString() { + return rgbString(this._rgb); + } + hexString() { + return hexString(this._rgb); + } + hslString() { + return hslString(this._rgb); + } + mix(color, weight) { + var me = this; + if (color) { + var c1 = me.rgb; + var c2 = color.rgb; + var w2; + var p = weight === w2 ? 0.5 : weight; + var w = 2 * p - 1; + var a = c1.a - c2.a; + var w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2.0; + w2 = 1 - w1; + c1.r = 0xFF & w1 * c1.r + w2 * c2.r + 0.5; + c1.g = 0xFF & w1 * c1.g + w2 * c2.g + 0.5; + c1.b = 0xFF & w1 * c1.b + w2 * c2.b + 0.5; + c1.a = p * c1.a + (1 - p) * c2.a; + me.rgb = c1; + } + return me; + } + clone() { + return new Color(this.rgb); + } + alpha(a) { + this._rgb.a = n2b(a); + return this; + } + clearer(ratio) { + var rgb = this._rgb; + rgb.a *= 1 - ratio; + return this; + } + greyscale() { + var rgb = this._rgb; + var val = round(rgb.r * 0.3 + rgb.g * 0.59 + rgb.b * 0.11); + rgb.r = rgb.g = rgb.b = val; + return this; + } + opaquer(ratio) { + var rgb = this._rgb; + rgb.a *= 1 + ratio; + return this; + } + negate() { + var v = this._rgb; + v.r = 255 - v.r; + v.g = 255 - v.g; + v.b = 255 - v.b; + return this; + } + lighten(ratio) { + modHSL(this._rgb, 2, ratio); + return this; + } + darken(ratio) { + modHSL(this._rgb, 2, -ratio); + return this; + } + saturate(ratio) { + modHSL(this._rgb, 1, ratio); + return this; + } + desaturate(ratio) { + modHSL(this._rgb, 1, -ratio); + return this; + } + rotate(deg) { + rotate(this._rgb, deg); + return this; + } +} +function index_esm(input) { + return new Color(input); +} + +var isPatternOrGradient = value => value instanceof CanvasGradient || value instanceof CanvasPattern; +function color(value) { + return isPatternOrGradient(value) ? value : index_esm(value); +} +function getHoverColor(value) { + return isPatternOrGradient(value) ? value : index_esm(value).saturate(0.5).darken(0.1).hexString(); +} + +var helpers = _objectSpread2({}, coreHelpers, { + canvas, + curve, + dom, + easing: { + effects + }, + options, + math, + rtl, + requestAnimFrame: function () { + if (typeof window === 'undefined') { + return function (callback) { + callback(); + }; + } + return window.requestAnimationFrame; + }(), + fontString(pixelSize, fontStyle, fontFamily) { + return fontStyle + ' ' + pixelSize + 'px ' + fontFamily; + }, + color, + getHoverColor +}); + +function drawFPS(chart, count, date, lastDate) { + var fps = 1000 / (date - lastDate) | 0; + var ctx = chart.ctx; + ctx.save(); + ctx.clearRect(0, 0, 50, 24); + ctx.fillStyle = 'black'; + ctx.textAlign = 'right'; + if (count) { + ctx.fillText(count, 50, 8); + ctx.fillText(fps + ' fps', 50, 18); + } + ctx.restore(); +} +class Animator { + constructor() { + this._request = null; + this._charts = new Map(); + this._running = false; + this._lastDate = undefined; + } + _notify(chart, anims, date, type) { + var callbacks = anims.listeners[type] || []; + var numSteps = anims.duration; + callbacks.forEach(fn => fn({ + chart, + numSteps, + currentStep: date - anims.start + })); + } + _refresh() { + var me = this; + if (me._request) { + return; + } + me._running = true; + me._request = helpers.requestAnimFrame.call(window, () => { + me._update(); + me._request = null; + if (me._running) { + me._refresh(); + } + }); + } + _update() { + var me = this; + var date = Date.now(); + var remaining = 0; + me._charts.forEach((anims, chart) => { + if (!anims.running || !anims.items.length) { + return; + } + var items = anims.items; + var i = items.length - 1; + var draw = false; + var item; + for (; i >= 0; --i) { + item = items[i]; + if (item._active) { + item.tick(date); + draw = true; + } else { + items[i] = items[items.length - 1]; + items.pop(); + } + } + if (draw) { + chart.draw(); + } + if (chart.options.animation.debug) { + drawFPS(chart, items.length, date, me._lastDate); + } + me._notify(chart, anims, date, 'progress'); + if (!items.length) { + anims.running = false; + me._notify(chart, anims, date, 'complete'); + } + remaining += items.length; + }); + me._lastDate = date; + if (remaining === 0) { + me._running = false; + } + } + _getAnims(chart) { + var charts = this._charts; + var anims = charts.get(chart); + if (!anims) { + anims = { + running: false, + items: [], + listeners: { + complete: [], + progress: [] + } + }; + charts.set(chart, anims); + } + return anims; + } + listen(chart, event, cb) { + this._getAnims(chart).listeners[event].push(cb); + } + add(chart, items) { + if (!items || !items.length) { + return; + } + this._getAnims(chart).items.push(...items); + } + has(chart) { + return this._getAnims(chart).items.length > 0; + } + start(chart) { + var anims = this._charts.get(chart); + if (!anims) { + return; + } + anims.running = true; + anims.start = Date.now(); + anims.duration = anims.items.reduce((acc, cur) => Math.max(acc, cur._duration), 0); + this._refresh(); + } + running(chart) { + if (!this._running) { + return false; + } + var anims = this._charts.get(chart); + if (!anims || !anims.running || !anims.items.length) { + return false; + } + return true; + } + stop(chart) { + var anims = this._charts.get(chart); + if (!anims || !anims.items.length) { + return; + } + var items = anims.items; + var i = items.length - 1; + for (; i >= 0; --i) { + items[i].cancel(); + } + anims.items = []; + this._notify(chart, anims, Date.now(), 'complete'); + } + remove(chart) { + return this._charts.delete(chart); + } +} +var Animator$1 = new Animator(); + +var transparent = 'transparent'; +var interpolators = { + boolean(from, to, factor) { + return factor > 0.5 ? to : from; + }, + color(from, to, factor) { + var c0 = helpers.color(from || transparent); + var c1 = c0.valid && helpers.color(to || transparent); + return c1 && c1.valid ? c1.mix(c0, factor).hexString() : to; + }, + number(from, to, factor) { + return from + (to - from) * factor; + } +}; +class Animation { + constructor(cfg, target, prop, to) { + var currentValue = target[prop]; + to = resolve([cfg.to, to, currentValue, cfg.from]); + var from = resolve([cfg.from, currentValue, to]); + this._active = true; + this._fn = cfg.fn || interpolators[cfg.type || typeof from]; + this._easing = effects[cfg.easing || 'linear']; + this._start = Math.floor(Date.now() + (cfg.delay || 0)); + this._duration = Math.floor(cfg.duration); + this._loop = !!cfg.loop; + this._target = target; + this._prop = prop; + this._from = from; + this._to = to; + } + active() { + return this._active; + } + update(cfg, to, date) { + var me = this; + if (me._active) { + var currentValue = me._target[me._prop]; + var elapsed = date - me._start; + var remain = me._duration - elapsed; + me._start = date; + me._duration = Math.floor(Math.max(remain, cfg.duration)); + me._to = resolve([cfg.to, to, currentValue, cfg.from]); + me._from = resolve([cfg.from, currentValue, to]); + } + } + cancel() { + var me = this; + if (me._active) { + me.tick(Date.now()); + me._active = false; + } + } + tick(date) { + var me = this; + var elapsed = date - me._start; + var duration = me._duration; + var prop = me._prop; + var from = me._from; + var loop = me._loop; + var to = me._to; + var factor; + me._active = from !== to && (loop || elapsed < duration); + if (!me._active) { + me._target[prop] = to; + return; + } + if (elapsed < 0) { + me._target[prop] = from; + return; + } + factor = elapsed / duration % 2; + factor = loop && factor > 1 ? 2 - factor : factor; + factor = me._easing(Math.min(1, Math.max(0, factor))); + me._target[prop] = me._fn(from, to, factor); + } +} + +var numbers = ['x', 'y', 'borderWidth', 'radius', 'tension']; +var colors = ['borderColor', 'backgroundColor']; +defaults.set('animation', { + duration: 1000, + easing: 'easeOutQuart', + onProgress: noop, + onComplete: noop, + colors: { + type: 'color', + properties: colors + }, + numbers: { + type: 'number', + properties: numbers + }, + active: { + duration: 400 + }, + resize: { + duration: 0 + }, + show: { + colors: { + type: 'color', + properties: colors, + from: 'transparent' + }, + visible: { + type: 'boolean', + duration: 0 + } + }, + hide: { + colors: { + type: 'color', + properties: colors, + to: 'transparent' + }, + visible: { + type: 'boolean', + easing: 'easeInExpo' + } + } +}); +function copyOptions(target, values) { + var oldOpts = target.options; + var newOpts = values.options; + if (!oldOpts || !newOpts || newOpts.$shared) { + return; + } + if (oldOpts.$shared) { + target.options = _extends({}, oldOpts, newOpts, { + $shared: false + }); + } else { + _extends(oldOpts, newOpts); + } + delete values.options; +} +function extensibleConfig(animations) { + var result = {}; + Object.keys(animations).forEach(key => { + var value = animations[key]; + if (!isObject(value)) { + result[key] = value; + } + }); + return result; +} +class Animations { + constructor(chart, animations) { + this._chart = chart; + this._properties = new Map(); + this.configure(animations); + } + configure(animations) { + if (!isObject(animations)) { + return; + } + var animatedProps = this._properties; + var animDefaults = extensibleConfig(animations); + Object.keys(animations).forEach(key => { + var cfg = animations[key]; + if (!isObject(cfg)) { + return; + } + (cfg.properties || [key]).forEach(prop => { + if (!animatedProps.has(prop)) { + animatedProps.set(prop, _extends({}, animDefaults, cfg)); + } else if (prop === key) { + animatedProps.set(prop, _extends({}, animatedProps.get(prop), cfg)); + } + }); + }); + } + _animateOptions(target, values) { + var newOptions = values.options; + var animations = []; + if (!newOptions) { + return animations; + } + var options = target.options; + if (options) { + if (options.$shared) { + target.options = options = _extends({}, options, { + $shared: false, + $animations: {} + }); + } + animations = this._createAnimations(options, newOptions); + } else { + target.options = newOptions; + } + return animations; + } + _createAnimations(target, values) { + var animatedProps = this._properties; + var animations = []; + var running = target.$animations || (target.$animations = {}); + var props = Object.keys(values); + var date = Date.now(); + var i; + for (i = props.length - 1; i >= 0; --i) { + var prop = props[i]; + if (prop.charAt(0) === '$') { + continue; + } + if (prop === 'options') { + animations.push(...this._animateOptions(target, values)); + continue; + } + var value = values[prop]; + var animation = running[prop]; + var cfg = animatedProps.get(prop); + if (animation) { + if (cfg && animation.active()) { + animation.update(cfg, value, date); + continue; + } else { + animation.cancel(); + } + } + if (!cfg || !cfg.duration) { + target[prop] = value; + continue; + } + running[prop] = animation = new Animation(cfg, target, prop, value); + animations.push(animation); + } + return animations; + } + update(target, values) { + if (this._properties.size === 0) { + copyOptions(target, values); + _extends(target, values); + return; + } + var animations = this._createAnimations(target, values); + if (animations.length) { + Animator$1.add(this._chart, animations); + return true; + } + } +} + +var resolve$1 = helpers.options.resolve; +var arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift']; +function listenArrayEvents(array, listener) { + if (array._chartjs) { + array._chartjs.listeners.push(listener); + return; + } + Object.defineProperty(array, '_chartjs', { + configurable: true, + enumerable: false, + value: { + listeners: [listener] + } + }); + arrayEvents.forEach(key => { + var method = '_onData' + key.charAt(0).toUpperCase() + key.slice(1); + var base = array[key]; + Object.defineProperty(array, key, { + configurable: true, + enumerable: false, + value() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + var res = base.apply(this, args); + array._chartjs.listeners.forEach(object => { + if (typeof object[method] === 'function') { + object[method](...args); + } + }); + return res; + } + }); + }); +} +function scaleClip(scale, allowedOverflow) { + var opts = scale && scale.options || {}; + var reverse = opts.reverse; + var min = opts.min === undefined ? allowedOverflow : 0; + var max = opts.max === undefined ? allowedOverflow : 0; + return { + start: reverse ? max : min, + end: reverse ? min : max + }; +} +function defaultClip(xScale, yScale, allowedOverflow) { + if (allowedOverflow === false) { + return false; + } + var x = scaleClip(xScale, allowedOverflow); + var y = scaleClip(yScale, allowedOverflow); + return { + top: y.end, + right: x.end, + bottom: y.start, + left: x.start + }; +} +function toClip(value) { + var t, r, b, l; + if (helpers.isObject(value)) { + t = value.top; + r = value.right; + b = value.bottom; + l = value.left; + } else { + t = r = b = l = value; + } + return { + top: t, + right: r, + bottom: b, + left: l + }; +} +function unlistenArrayEvents(array, listener) { + var stub = array._chartjs; + if (!stub) { + return; + } + var listeners = stub.listeners; + var index = listeners.indexOf(listener); + if (index !== -1) { + listeners.splice(index, 1); + } + if (listeners.length > 0) { + return; + } + arrayEvents.forEach(key => { + delete array[key]; + }); + delete array._chartjs; +} +function getSortedDatasetIndices(chart, filterVisible) { + var keys = []; + var metasets = chart._getSortedDatasetMetas(filterVisible); + var i, ilen; + for (i = 0, ilen = metasets.length; i < ilen; ++i) { + keys.push(metasets[i].index); + } + return keys; +} +function applyStack(stack, value, dsIndex, allOther) { + var keys = stack.keys; + var i, ilen, datasetIndex, otherValue; + for (i = 0, ilen = keys.length; i < ilen; ++i) { + datasetIndex = +keys[i]; + if (datasetIndex === dsIndex) { + if (allOther) { + continue; + } + break; + } + otherValue = stack.values[datasetIndex]; + if (!isNaN(otherValue) && (value === 0 || helpers.math.sign(value) === helpers.math.sign(otherValue))) { + value += otherValue; + } + } + return value; +} +function convertObjectDataToArray(data) { + var keys = Object.keys(data); + var adata = new Array(keys.length); + var i, ilen, key; + for (i = 0, ilen = keys.length; i < ilen; ++i) { + key = keys[i]; + adata[i] = { + x: key, + y: data[key] + }; + } + return adata; +} +function isStacked(scale, meta) { + var stacked = scale && scale.options.stacked; + return stacked || stacked === undefined && meta.stack !== undefined; +} +function getStackKey(indexScale, valueScale, meta) { + return indexScale.id + '.' + valueScale.id + '.' + meta.stack + '.' + meta.type; +} +function getUserBounds(scale) { + var { + min, + max, + minDefined, + maxDefined + } = scale.getUserBounds(); + return { + min: minDefined ? min : Number.NEGATIVE_INFINITY, + max: maxDefined ? max : Number.POSITIVE_INFINITY + }; +} +function getOrCreateStack(stacks, stackKey, indexValue) { + var subStack = stacks[stackKey] || (stacks[stackKey] = {}); + return subStack[indexValue] || (subStack[indexValue] = {}); +} +function updateStacks(controller, parsed) { + var { + chart, + _cachedMeta: meta + } = controller; + var stacks = chart._stacks || (chart._stacks = {}); + var { + iScale, + vScale, + index: datasetIndex + } = meta; + var iAxis = iScale.axis; + var vAxis = vScale.axis; + var key = getStackKey(iScale, vScale, meta); + var ilen = parsed.length; + var stack; + for (var i = 0; i < ilen; ++i) { + var item = parsed[i]; + var { + [iAxis]: index, + [vAxis]: value + } = item; + var itemStacks = item._stacks || (item._stacks = {}); + stack = itemStacks[vAxis] = getOrCreateStack(stacks, key, index); + stack[datasetIndex] = value; + } +} +function getFirstScaleId(chart, axis) { + var scales = chart.scales; + return Object.keys(scales).filter(key => scales[key].axis === axis).shift(); +} +class DatasetController { + constructor(chart, datasetIndex) { + this.chart = chart; + this._ctx = chart.ctx; + this.index = datasetIndex; + this._cachedAnimations = {}; + this._cachedDataOpts = {}; + this._cachedMeta = this.getMeta(); + this._type = this._cachedMeta.type; + this._config = undefined; + this._parsing = false; + this._data = undefined; + this._dataCopy = undefined; + this._objectData = undefined; + this._labels = undefined; + this._scaleStacked = {}; + this.initialize(); + } + initialize() { + var me = this; + var meta = me._cachedMeta; + me.configure(); + me.linkScales(); + meta._stacked = isStacked(meta.vScale, meta); + me.addElements(); + } + updateIndex(datasetIndex) { + this.index = datasetIndex; + } + linkScales() { + var me = this; + var chart = me.chart; + var meta = me._cachedMeta; + var dataset = me.getDataset(); + var xid = meta.xAxisID = dataset.xAxisID || getFirstScaleId(chart, 'x'); + var yid = meta.yAxisID = dataset.yAxisID || getFirstScaleId(chart, 'y'); + var rid = meta.rAxisID = dataset.rAxisID || getFirstScaleId(chart, 'r'); + meta.xScale = me.getScaleForId(xid); + meta.yScale = me.getScaleForId(yid); + meta.rScale = me.getScaleForId(rid); + meta.iScale = me._getIndexScale(); + meta.vScale = me._getValueScale(); + } + getDataset() { + return this.chart.data.datasets[this.index]; + } + getMeta() { + return this.chart.getDatasetMeta(this.index); + } + getScaleForId(scaleID) { + return this.chart.scales[scaleID]; + } + getValueScaleId() { + return this._cachedMeta.yAxisID; + } + getIndexScaleId() { + return this._cachedMeta.xAxisID; + } + _getValueScale() { + return this.getScaleForId(this.getValueScaleId()); + } + _getIndexScale() { + return this.getScaleForId(this.getIndexScaleId()); + } + _getOtherScale(scale) { + var meta = this._cachedMeta; + return scale === meta.iScale ? meta.vScale : meta.iScale; + } + reset() { + this._update('reset'); + } + _destroy() { + if (this._data) { + unlistenArrayEvents(this._data, this); + } + } + _dataCheck() { + var me = this; + var dataset = me.getDataset(); + var data = dataset.data || (dataset.data = []); + if (helpers.isObject(data)) { + if (me._objectData === data) { + return false; + } + me._data = convertObjectDataToArray(data); + me._objectData = data; + } else { + if (me._data === data && helpers.arrayEquals(data, me._dataCopy)) { + return false; + } + if (me._data) { + unlistenArrayEvents(me._data, me); + } + me._dataCopy = data.slice(0); + if (data && Object.isExtensible(data)) { + listenArrayEvents(data, me); + } + me._data = data; + } + return true; + } + _labelCheck() { + var me = this; + var iScale = me._cachedMeta.iScale; + var labels = iScale ? iScale.getLabels() : me.chart.data.labels; + if (me._labels === labels) { + return false; + } + me._labels = labels; + return true; + } + addElements() { + var me = this; + var meta = me._cachedMeta; + me._dataCheck(); + var data = me._data; + var metaData = meta.data = new Array(data.length); + for (var i = 0, ilen = data.length; i < ilen; ++i) { + metaData[i] = new me.dataElementType(); + } + if (me.datasetElementType) { + meta.dataset = new me.datasetElementType(); + } + } + buildOrUpdateElements() { + var me = this; + var dataChanged = me._dataCheck(); + var labelsChanged = me._labelCheck(); + var scaleChanged = me._scaleCheck(); + var meta = me._cachedMeta; + var dataset = me.getDataset(); + var stackChanged = false; + meta._stacked = isStacked(meta.vScale, meta); + if (meta.stack !== dataset.stack) { + stackChanged = true; + meta._parsed.forEach(parsed => { + delete parsed._stacks[meta.vScale.id][meta.index]; + }); + meta.stack = dataset.stack; + } + me._resyncElements(dataChanged || labelsChanged || scaleChanged || stackChanged); + if (stackChanged) { + updateStacks(me, meta._parsed); + } + } + configure() { + var me = this; + me._config = helpers.merge({}, [me.chart.options[me._type].datasets, me.getDataset()], { + merger(key, target, source) { + if (key !== 'data') { + helpers._merger(key, target, source); + } + } + }); + me._parsing = resolve$1([me._config.parsing, me.chart.options.parsing, true]); + } + parse(start, count) { + var me = this; + var { + _cachedMeta: meta, + _data: data + } = me; + var { + iScale, + vScale, + _stacked + } = meta; + var iAxis = iScale.axis; + var sorted = true; + var i, parsed, cur, prev; + if (start > 0) { + sorted = meta._sorted; + prev = meta._parsed[start - 1]; + } + if (me._parsing === false) { + meta._parsed = data; + meta._sorted = true; + } else { + if (helpers.isArray(data[start])) { + parsed = me.parseArrayData(meta, data, start, count); + } else if (helpers.isObject(data[start])) { + parsed = me.parseObjectData(meta, data, start, count); + } else { + parsed = me.parsePrimitiveData(meta, data, start, count); + } + for (i = 0; i < count; ++i) { + meta._parsed[i + start] = cur = parsed[i]; + if (sorted) { + if (prev && cur[iAxis] < prev[iAxis]) { + sorted = false; + } + prev = cur; + } + } + meta._sorted = sorted; + } + if (_stacked) { + updateStacks(me, parsed); + } + iScale.invalidateCaches(); + vScale.invalidateCaches(); + } + parsePrimitiveData(meta, data, start, count) { + var { + iScale, + vScale + } = meta; + var iAxis = iScale.axis; + var vAxis = vScale.axis; + var labels = iScale.getLabels(); + var singleScale = iScale === vScale; + var parsed = new Array(count); + var 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) + }; + } + return parsed; + } + parseArrayData(meta, data, start, count) { + var { + xScale, + yScale + } = meta; + var parsed = new Array(count); + var i, ilen, index, item; + for (i = 0, ilen = count; i < ilen; ++i) { + index = i + start; + item = data[index]; + parsed[i] = { + x: xScale.parse(item[0], index), + y: yScale.parse(item[1], index) + }; + } + return parsed; + } + parseObjectData(meta, data, start, count) { + var { + xScale, + yScale + } = meta; + var parsed = new Array(count); + var i, ilen, index, item; + for (i = 0, ilen = count; i < ilen; ++i) { + index = i + start; + item = data[index]; + parsed[i] = { + x: xScale.parseObject(item, 'x', index), + y: yScale.parseObject(item, 'y', index) + }; + } + return parsed; + } + getParsed(index) { + return this._cachedMeta._parsed[index]; + } + applyStack(scale, parsed) { + var chart = this.chart; + var meta = this._cachedMeta; + var value = parsed[scale.axis]; + var stack = { + keys: getSortedDatasetIndices(chart, true), + values: parsed._stacks[scale.axis] + }; + return applyStack(stack, value, meta.index); + } + getMinMax(scale, canStack) { + var meta = this._cachedMeta; + var _parsed = meta._parsed; + var sorted = meta._sorted && scale === meta.iScale; + var ilen = _parsed.length; + var otherScale = this._getOtherScale(scale); + var stack = canStack && meta._stacked && { + keys: getSortedDatasetIndices(this.chart, true), + values: null + }; + var min = Number.POSITIVE_INFINITY; + var max = Number.NEGATIVE_INFINITY; + var { + min: otherMin, + max: otherMax + } = getUserBounds(otherScale); + var i, value, parsed, otherValue; + function _compute() { + if (stack) { + stack.values = parsed._stacks[scale.axis]; + min = Math.min(min, value); + max = Math.max(max, value); + value = applyStack(stack, value, meta.index, true); + } + min = Math.min(min, value); + max = Math.max(max, value); + } + function _skip() { + parsed = _parsed[i]; + value = parsed[scale.axis]; + otherValue = parsed[otherScale.axis]; + return isNaN(value) || otherMin > otherValue || otherMax < otherValue; + } + for (i = 0; i < ilen; ++i) { + if (_skip()) { + continue; + } + _compute(); + if (sorted) { + break; + } + } + if (sorted) { + for (i = ilen - 1; i >= 0; --i) { + if (_skip()) { + continue; + } + _compute(); + break; + } + } + return { + min, + max + }; + } + getAllParsedValues(scale) { + var parsed = this._cachedMeta._parsed; + var values = []; + var i, ilen, value; + for (i = 0, ilen = parsed.length; i < ilen; ++i) { + value = parsed[i][scale.axis]; + if (!isNaN(value)) { + values.push(value); + } + } + return values; + } + _cacheScaleStackStatus() { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale; + var vScale = meta.vScale; + var cache = me._scaleStacked = {}; + if (iScale && vScale) { + cache[iScale.id] = iScale.options.stacked; + cache[vScale.id] = vScale.options.stacked; + } + } + _scaleCheck() { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale; + var vScale = meta.vScale; + var cache = me._scaleStacked; + return !cache || !iScale || !vScale || cache[iScale.id] !== iScale.options.stacked || cache[vScale.id] !== vScale.options.stacked; + } + getMaxOverflow() { + return false; + } + getLabelAndValue(index) { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale; + var vScale = meta.vScale; + var parsed = me.getParsed(index); + return { + label: iScale ? '' + iScale.getLabelForValue(parsed[iScale.axis]) : '', + value: vScale ? '' + vScale.getLabelForValue(parsed[vScale.axis]) : '' + }; + } + _update(mode) { + var me = this; + var meta = me._cachedMeta; + me.configure(); + me._cachedAnimations = {}; + me._cachedDataOpts = {}; + me.update(mode); + meta._clip = toClip(helpers.valueOrDefault(me._config.clip, defaultClip(meta.xScale, meta.yScale, me.getMaxOverflow()))); + me._cacheScaleStackStatus(); + } + update(mode) {} + draw() { + var ctx = this._ctx; + var meta = this._cachedMeta; + var elements = meta.data || []; + var ilen = elements.length; + var i = 0; + if (meta.dataset) { + meta.dataset.draw(ctx); + } + for (; i < ilen; ++i) { + elements[i].draw(ctx); + } + } + _addAutomaticHoverColors(index, options) { + var me = this; + var getHoverColor = helpers.getHoverColor; + var normalOptions = me.getStyle(index); + var missingColors = Object.keys(normalOptions).filter(key => key.indexOf('Color') !== -1 && !(key in options)); + var i = missingColors.length - 1; + var color; + for (; i >= 0; i--) { + color = missingColors[i]; + options[color] = getHoverColor(normalOptions[color]); + } + } + getStyle(index, active) { + var me = this; + var meta = me._cachedMeta; + var dataset = meta.dataset; + if (!me._config) { + me.configure(); + } + var options = dataset && index === undefined ? me.resolveDatasetElementOptions(active) : me.resolveDataElementOptions(index || 0, active && 'active'); + if (active) { + me._addAutomaticHoverColors(index, options); + } + return options; + } + _getContext(index, active) { + return { + chart: this.chart, + dataIndex: index, + dataset: this.getDataset(), + datasetIndex: this.index, + active + }; + } + resolveDatasetElementOptions(active) { + var me = this; + var chart = me.chart; + var datasetOpts = me._config; + var options = chart.options.elements[me.datasetElementType._type] || {}; + var elementOptions = me.datasetElementOptions; + var values = {}; + var context = me._getContext(undefined, active); + var i, ilen, key, readKey, value; + for (i = 0, ilen = elementOptions.length; i < ilen; ++i) { + key = elementOptions[i]; + readKey = active ? 'hover' + key.charAt(0).toUpperCase() + key.slice(1) : key; + value = resolve$1([datasetOpts[readKey], options[readKey]], context); + if (value !== undefined) { + values[key] = value; + } + } + return values; + } + resolveDataElementOptions(index, mode) { + var me = this; + var active = mode === 'active'; + var cached = me._cachedDataOpts; + if (cached[mode]) { + return cached[mode]; + } + var chart = me.chart; + var datasetOpts = me._config; + var options = chart.options.elements[me.dataElementType._type] || {}; + var elementOptions = me.dataElementOptions; + var values = {}; + var context = me._getContext(index, active); + var info = { + cacheable: !active + }; + var keys, i, ilen, key, value, readKey; + if (helpers.isArray(elementOptions)) { + for (i = 0, ilen = elementOptions.length; i < ilen; ++i) { + key = elementOptions[i]; + readKey = active ? 'hover' + key.charAt(0).toUpperCase() + key.slice(1) : key; + value = resolve$1([datasetOpts[readKey], options[readKey]], context, index, info); + if (value !== undefined) { + values[key] = value; + } + } + } else { + keys = Object.keys(elementOptions); + for (i = 0, ilen = keys.length; i < ilen; ++i) { + key = keys[i]; + readKey = active ? 'hover' + key.charAt(0).toUpperCase() + key.slice(1) : key; + value = resolve$1([datasetOpts[elementOptions[readKey]], datasetOpts[readKey], options[readKey]], context, index, info); + if (value !== undefined) { + values[key] = value; + } + } + } + if (info.cacheable) { + values.$shared = true; + cached[mode] = values; + } + return values; + } + _resolveAnimations(index, mode, active) { + var me = this; + var chart = me.chart; + var cached = me._cachedAnimations; + mode = mode || 'default'; + if (cached[mode]) { + return cached[mode]; + } + var info = { + cacheable: true + }; + var context = me._getContext(index, active); + var datasetAnim = resolve$1([me._config.animation], context, index, info); + var chartAnim = resolve$1([chart.options.animation], context, index, info); + var config = helpers.mergeIf({}, [datasetAnim, chartAnim]); + if (config[mode]) { + config = _extends({}, config, config[mode]); + } + var animations = new Animations(chart, config); + if (info.cacheable) { + cached[mode] = animations && Object.freeze(animations); + } + return animations; + } + getSharedOptions(mode, el, options) { + if (!mode) { + this._sharedOptions = options && options.$shared; + } + if (mode !== 'reset' && options && options.$shared && el && el.options && el.options.$shared) { + return { + target: el.options, + options + }; + } + } + includeOptions(mode, sharedOptions) { + if (mode === 'hide' || mode === 'show') { + return true; + } + return mode !== 'resize' && !sharedOptions; + } + updateElement(element, index, properties, mode) { + if (mode === 'reset' || mode === 'none') { + _extends(element, properties); + } else { + this._resolveAnimations(index, mode).update(element, properties); + } + } + updateSharedOptions(sharedOptions, mode) { + if (sharedOptions) { + this._resolveAnimations(undefined, mode).update(sharedOptions.target, sharedOptions.options); + } + } + _setStyle(element, index, mode, active) { + element.active = active; + this._resolveAnimations(index, mode, active).update(element, { + options: this.getStyle(index, active) + }); + } + removeHoverStyle(element, datasetIndex, index) { + this._setStyle(element, index, 'active', false); + } + setHoverStyle(element, datasetIndex, index) { + this._setStyle(element, index, 'active', true); + } + _removeDatasetHoverStyle() { + var element = this._cachedMeta.dataset; + if (element) { + this._setStyle(element, undefined, 'active', false); + } + } + _setDatasetHoverStyle() { + var element = this._cachedMeta.dataset; + if (element) { + this._setStyle(element, undefined, 'active', true); + } + } + _resyncElements(changed) { + var me = this; + var meta = me._cachedMeta; + var numMeta = meta.data.length; + var numData = me._data.length; + if (numData > numMeta) { + me._insertElements(numMeta, numData - numMeta); + if (changed && 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); + } else if (changed) { + me.parse(0, numData); + } + } + _insertElements(start, count) { + var me = this; + var elements = new Array(count); + var meta = me._cachedMeta; + var data = meta.data; + var i; + for (i = 0; i < count; ++i) { + elements[i] = new me.dataElementType(); + } + data.splice(start, 0, ...elements); + if (me._parsing) { + meta._parsed.splice(start, 0, ...new Array(count)); + } + me.parse(start, count); + me.updateElements(elements, start, 'reset'); + } + updateElements(element, start, mode) {} + _removeElements(start, count) { + var me = this; + if (me._parsing) { + me._cachedMeta._parsed.splice(start, count); + } + me._cachedMeta.data.splice(start, count); + } + _onDataPush() { + var count = arguments.length; + this._insertElements(this.getDataset().data.length - count, count); + } + _onDataPop() { + this._removeElements(this._cachedMeta.data.length - 1, 1); + } + _onDataShift() { + this._removeElements(0, 1); + } + _onDataSplice(start, count) { + this._removeElements(start, count); + this._insertElements(start, arguments.length - 2); + } + _onDataUnshift() { + this._insertElements(0, arguments.length); + } +} +_defineProperty(DatasetController, "extend", helpers.inherits); +DatasetController.prototype.datasetElementType = null; +DatasetController.prototype.dataElementType = null; +DatasetController.prototype.datasetElementOptions = ['backgroundColor', 'borderCapStyle', 'borderColor', 'borderDash', 'borderDashOffset', 'borderJoinStyle', 'borderWidth']; +DatasetController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderWidth', 'pointStyle']; + +class Element { + constructor() { + this.x = undefined; + this.y = undefined; + this.active = false; + this.options = undefined; + this.$animations = undefined; + } + tooltipPosition(useFinalPosition) { + var { + x, + y + } = this.getProps(['x', 'y'], useFinalPosition); + return { + x, + y + }; + } + hasValue() { + return isNumber(this.x) && isNumber(this.y); + } + getProps(props, final) { + var me = this; + var anims = this.$animations; + if (!final || !anims) { + return me; + } + var ret = {}; + props.forEach(prop => { + ret[prop] = anims[prop] && anims[prop].active ? anims[prop]._to : me[prop]; + }); + return ret; + } +} +_defineProperty(Element, "extend", inherits); + +var TAU$1 = Math.PI * 2; +defaults.set('elements', { + arc: { + backgroundColor: defaults.color, + borderAlign: 'center', + borderColor: '#fff', + borderWidth: 2 + } +}); +function clipArc(ctx, arc) { + var { + startAngle, + endAngle, + pixelMargin, + x, + y + } = arc; + var angleMargin = pixelMargin / arc.outerRadius; + ctx.beginPath(); + ctx.arc(x, y, arc.outerRadius, startAngle - angleMargin, endAngle + angleMargin); + if (arc.innerRadius > pixelMargin) { + angleMargin = pixelMargin / arc.innerRadius; + ctx.arc(x, y, arc.innerRadius - pixelMargin, endAngle + angleMargin, startAngle - angleMargin, true); + } else { + ctx.arc(x, y, pixelMargin, endAngle + Math.PI / 2, startAngle - Math.PI / 2); + } + ctx.closePath(); + ctx.clip(); +} +function drawFullCircleBorders(ctx, vm, arc, inner) { + var endAngle = arc.endAngle; + var i; + if (inner) { + arc.endAngle = arc.startAngle + TAU$1; + clipArc(ctx, arc); + arc.endAngle = endAngle; + if (arc.endAngle === arc.startAngle && arc.fullCircles) { + arc.endAngle += TAU$1; + arc.fullCircles--; + } + } + ctx.beginPath(); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.startAngle + TAU$1, arc.startAngle, true); + for (i = 0; i < arc.fullCircles; ++i) { + ctx.stroke(); + } + ctx.beginPath(); + ctx.arc(arc.x, arc.y, vm.outerRadius, arc.startAngle, arc.startAngle + TAU$1); + for (i = 0; i < arc.fullCircles; ++i) { + ctx.stroke(); + } +} +function drawBorder(ctx, vm, arc) { + var options = vm.options; + var inner = options.borderAlign === 'inner'; + if (inner) { + ctx.lineWidth = options.borderWidth * 2; + ctx.lineJoin = 'round'; + } else { + ctx.lineWidth = options.borderWidth; + ctx.lineJoin = 'bevel'; + } + if (arc.fullCircles) { + drawFullCircleBorders(ctx, vm, arc, inner); + } + if (inner) { + clipArc(ctx, arc); + } + ctx.beginPath(); + ctx.arc(arc.x, arc.y, vm.outerRadius, arc.startAngle, arc.endAngle); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true); + ctx.closePath(); + ctx.stroke(); +} +class Arc extends Element { + constructor(cfg) { + super(); + this.options = undefined; + this.circumference = undefined; + this.startAngle = undefined; + this.endAngle = undefined; + this.innerRadius = undefined; + this.outerRadius = undefined; + if (cfg) { + _extends(this, cfg); + } + } + inRange(chartX, chartY, useFinalPosition) { + var point = this.getProps(['x', 'y'], useFinalPosition); + var { + angle, + distance + } = getAngleFromPoint(point, { + x: chartX, + y: chartY + }); + var { + startAngle, + endAngle, + innerRadius, + outerRadius, + circumference + } = this.getProps(['startAngle', 'endAngle', 'innerRadius', 'outerRadius', 'circumference'], useFinalPosition); + var betweenAngles = circumference >= TAU$1 || _angleBetween(angle, startAngle, endAngle); + var withinRadius = distance >= innerRadius && distance <= outerRadius; + return betweenAngles && withinRadius; + } + getCenterPoint(useFinalPosition) { + var { + x, + y, + startAngle, + endAngle, + innerRadius, + outerRadius + } = this.getProps(['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius'], useFinalPosition); + var halfAngle = (startAngle + endAngle) / 2; + var halfRadius = (innerRadius + outerRadius) / 2; + return { + x: x + Math.cos(halfAngle) * halfRadius, + y: y + Math.sin(halfAngle) * halfRadius + }; + } + tooltipPosition(useFinalPosition) { + return this.getCenterPoint(useFinalPosition); + } + draw(ctx) { + var me = this; + var options = me.options; + var pixelMargin = options.borderAlign === 'inner' ? 0.33 : 0; + var arc = { + x: me.x, + y: me.y, + innerRadius: me.innerRadius, + outerRadius: Math.max(me.outerRadius - pixelMargin, 0), + pixelMargin, + startAngle: me.startAngle, + endAngle: me.endAngle, + fullCircles: Math.floor(me.circumference / TAU$1) + }; + var i; + ctx.save(); + ctx.fillStyle = options.backgroundColor; + ctx.strokeStyle = options.borderColor; + if (arc.fullCircles) { + arc.endAngle = arc.startAngle + TAU$1; + ctx.beginPath(); + ctx.arc(arc.x, arc.y, arc.outerRadius, arc.startAngle, arc.endAngle); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true); + ctx.closePath(); + for (i = 0; i < arc.fullCircles; ++i) { + ctx.fill(); + } + arc.endAngle = arc.startAngle + me.circumference % TAU$1; + } + ctx.beginPath(); + ctx.arc(arc.x, arc.y, arc.outerRadius, arc.startAngle, arc.endAngle); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true); + ctx.closePath(); + ctx.fill(); + if (options.borderWidth) { + drawBorder(ctx, me, arc); + } + ctx.restore(); + } +} +_defineProperty(Arc, "_type", 'arc'); + +function _pointInLine(p1, p2, t, mode) { + return { + x: p1.x + t * (p2.x - p1.x), + y: p1.y + t * (p2.y - p1.y) + }; +} +function _steppedInterpolation(p1, p2, t, mode) { + return { + x: p1.x + t * (p2.x - p1.x), + y: mode === 'middle' ? t < 0.5 ? p1.y : p2.y : mode === 'after' ? t < 1 ? p1.y : p2.y : t > 0 ? p2.y : p1.y + }; +} +function _bezierInterpolation(p1, p2, t, mode) { + var cp1 = { + x: p1.controlPointNextX, + y: p1.controlPointNextY + }; + var cp2 = { + x: p2.controlPointPreviousX, + y: p2.controlPointPreviousY + }; + var a = _pointInLine(p1, cp1, t); + var b = _pointInLine(cp1, cp2, t); + var c = _pointInLine(cp2, p2, t); + var d = _pointInLine(a, b, t); + var e = _pointInLine(b, c, t); + return _pointInLine(d, e, t); +} + +function propertyFn(property) { + if (property === 'angle') { + return { + between: _angleBetween, + compare: _angleDiff, + normalize: _normalizeAngle + }; + } + return { + between: (n, s, e) => n >= s && n <= e, + compare: (a, b) => a - b, + normalize: x => x + }; +} +function makeSubSegment(start, end, loop, count) { + return { + start: start % count, + end: end % count, + loop: loop && (end - start + 1) % count === 0 + }; +} +function getSegment(segment, points, bounds) { + var { + property, + start: startBound, + end: endBound + } = bounds; + var { + between, + normalize + } = propertyFn(property); + var count = points.length; + var { + start, + end, + loop + } = segment; + var i, ilen; + if (loop) { + start += count; + end += count; + for (i = 0, ilen = count; i < ilen; ++i) { + if (!between(normalize(points[start % count][property]), startBound, endBound)) { + break; + } + start--; + end--; + } + start %= count; + end %= count; + } + if (end < start) { + end += count; + } + return { + start, + end, + loop + }; +} +function _boundSegment(segment, points, bounds) { + if (!bounds) { + return [segment]; + } + var { + property, + start: startBound, + end: endBound + } = bounds; + var count = points.length; + var { + compare, + between, + normalize + } = propertyFn(property); + var { + start, + end, + loop + } = getSegment(segment, points, bounds); + var result = []; + var inside = false; + var subStart = null; + var i, value, point, prev; + for (i = start; i <= end; ++i) { + point = points[i % count]; + if (point.skip) { + continue; + } + value = normalize(point[property]); + inside = between(value, startBound, endBound); + if (subStart === null && inside) { + subStart = i > start && compare(value, startBound) > 0 ? prev : i; + } + if (subStart !== null && (!inside || compare(value, endBound) === 0)) { + result.push(makeSubSegment(subStart, i, loop, count)); + subStart = null; + } + prev = i; + } + if (subStart !== null) { + result.push(makeSubSegment(subStart, end, loop, count)); + } + return result; +} +function _boundSegments(line, bounds) { + var result = []; + var segments = line.segments; + for (var i = 0; i < segments.length; i++) { + var sub = _boundSegment(segments[i], line.points, bounds); + if (sub.length) { + result.push(...sub); + } + } + return result; +} +function findStartAndEnd(points, count, loop, spanGaps) { + var start = 0; + var end = count - 1; + if (loop && !spanGaps) { + while (start < count && !points[start].skip) { + start++; + } + } + while (start < count && points[start].skip) { + start++; + } + start %= count; + if (loop) { + end += start; + } + while (end > start && points[end % count].skip) { + end--; + } + end %= count; + return { + start, + end + }; +} +function solidSegments(points, start, max, loop) { + var count = points.length; + var result = []; + var last = start; + var prev = points[start]; + var end; + for (end = start + 1; end <= max; ++end) { + var cur = points[end % count]; + if (cur.skip || cur.stop) { + if (!prev.skip) { + loop = false; + result.push({ + start: start % count, + end: (end - 1) % count, + loop + }); + start = last = cur.stop ? end : null; + } + } else { + last = end; + if (prev.skip) { + start = end; + } + } + prev = cur; + } + if (last !== null) { + result.push({ + start: start % count, + end: last % count, + loop + }); + } + return result; +} +function _computeSegments(line) { + var points = line.points; + var spanGaps = line.options.spanGaps; + var count = points.length; + if (!count) { + return []; + } + var loop = !!line._loop; + var { + start, + end + } = findStartAndEnd(points, count, loop, spanGaps); + if (spanGaps === true) { + return [{ + start, + end, + loop + }]; + } + var max = end < start ? end + count : end; + var completeLoop = !!line._fullLoop && start === 0 && end === count - 1; + return solidSegments(points, start, max, completeLoop); +} + +var defaultColor = defaults.color; +defaults.set('elements', { + line: { + backgroundColor: defaultColor, + borderCapStyle: 'butt', + borderColor: defaultColor, + borderDash: [], + borderDashOffset: 0, + borderJoinStyle: 'miter', + borderWidth: 3, + capBezierPoints: true, + fill: true, + tension: 0.4 + } +}); +function setStyle(ctx, vm) { + ctx.lineCap = vm.borderCapStyle; + ctx.setLineDash(vm.borderDash); + ctx.lineDashOffset = vm.borderDashOffset; + ctx.lineJoin = vm.borderJoinStyle; + ctx.lineWidth = vm.borderWidth; + ctx.strokeStyle = vm.borderColor; +} +function lineTo(ctx, previous, target) { + ctx.lineTo(target.x, target.y); +} +function getLineMethod(options) { + if (options.stepped) { + return _steppedLineTo; + } + if (options.tension) { + return _bezierCurveTo; + } + return lineTo; +} +function pathSegment(ctx, line, segment, params) { + var { + start, + end, + loop + } = segment; + var { + points, + options + } = line; + var lineMethod = getLineMethod(options); + var count = points.length; + var { + move = true, + reverse + } = params || {}; + var ilen = end < start ? count + end - start : end - start; + var i, point, prev; + for (i = 0; i <= ilen; ++i) { + point = points[(start + (reverse ? ilen - i : i)) % count]; + if (point.skip) { + continue; + } else if (move) { + ctx.moveTo(point.x, point.y); + move = false; + } else { + lineMethod(ctx, prev, point, reverse, options.stepped); + } + prev = point; + } + if (loop) { + point = points[(start + (reverse ? ilen : 0)) % count]; + lineMethod(ctx, prev, point, reverse, options.stepped); + } + return !!loop; +} +function fastPathSegment(ctx, line, segment, params) { + var points = line.points; + var count = points.length; + var { + start, + end + } = segment; + var { + move = true, + reverse + } = params || {}; + var ilen = end < start ? count + end - start : end - start; + var avgX = 0; + var countX = 0; + var i, point, prevX, minY, maxY, lastY; + if (move) { + point = points[(start + (reverse ? ilen : 0)) % count]; + ctx.moveTo(point.x, point.y); + } + for (i = 0; i <= ilen; ++i) { + point = points[(start + (reverse ? ilen - i : i)) % count]; + if (point.skip) { + continue; + } + var x = point.x; + var y = point.y; + var truncX = x | 0; + if (truncX === prevX) { + if (y < minY) { + minY = y; + } else if (y > maxY) { + maxY = y; + } + avgX = (countX * avgX + x) / ++countX; + } else { + if (minY !== maxY) { + ctx.lineTo(avgX, maxY); + ctx.lineTo(avgX, minY); + ctx.lineTo(avgX, lastY); + } + ctx.lineTo(x, y); + prevX = truncX; + countX = 0; + minY = maxY = y; + } + lastY = y; + } +} +function _getSegmentMethod(line) { + var opts = line.options; + var borderDash = opts.borderDash && opts.borderDash.length; + var useFastPath = !line._loop && !opts.tension && !opts.stepped && !borderDash; + return useFastPath ? fastPathSegment : pathSegment; +} +function _getInterpolationMethod(options) { + if (options.stepped) { + return _steppedInterpolation; + } + if (options.tension) { + return _bezierInterpolation; + } + return _pointInLine; +} +class Line extends Element { + constructor(cfg) { + super(); + this.options = undefined; + this._loop = undefined; + this._fullLoop = undefined; + this._controlPointsUpdated = undefined; + this._points = undefined; + this._segments = undefined; + if (cfg) { + _extends(this, cfg); + } + } + updateControlPoints(chartArea) { + var me = this; + if (me._controlPointsUpdated) { + return; + } + var options = me.options; + if (options.tension && !options.stepped) { + var loop = options.spanGaps ? me._loop : me._fullLoop; + _updateBezierControlPoints(me._points, options, chartArea, loop); + } + } + set points(points) { + this._points = points; + delete this._segments; + } + get points() { + return this._points; + } + get segments() { + return this._segments || (this._segments = _computeSegments(this)); + } + first() { + var segments = this.segments; + var points = this.points; + return segments.length && points[segments[0].start]; + } + last() { + var segments = this.segments; + var points = this.points; + var count = segments.length; + return count && points[segments[count - 1].end]; + } + interpolate(point, property) { + var me = this; + var options = me.options; + var value = point[property]; + var points = me.points; + var segments = _boundSegments(me, { + property, + start: value, + end: value + }); + if (!segments.length) { + return; + } + var result = []; + var _interpolate = _getInterpolationMethod(options); + var i, ilen; + for (i = 0, ilen = segments.length; i < ilen; ++i) { + var { + start, + end + } = segments[i]; + var p1 = points[start]; + var p2 = points[end]; + if (p1 === p2) { + result.push(p1); + continue; + } + var t = Math.abs((value - p1[property]) / (p2[property] - p1[property])); + var interpolated = _interpolate(p1, p2, t, options.stepped); + interpolated[property] = point[property]; + result.push(interpolated); + } + return result.length === 1 ? result[0] : result; + } + pathSegment(ctx, segment, params) { + var segmentMethod = _getSegmentMethod(this); + return segmentMethod(ctx, this, segment, params); + } + path(ctx) { + var me = this; + var segments = me.segments; + var ilen = segments.length; + var segmentMethod = _getSegmentMethod(me); + var loop = me._loop; + for (var i = 0; i < ilen; ++i) { + loop &= segmentMethod(ctx, me, segments[i]); + } + return !!loop; + } + draw(ctx) { + var me = this; + if (!me.points.length) { + return; + } + ctx.save(); + setStyle(ctx, me.options); + ctx.beginPath(); + if (me.path(ctx)) { + ctx.closePath(); + } + ctx.stroke(); + ctx.restore(); + } +} +_defineProperty(Line, "_type", 'line'); + +var defaultColor$1 = defaults.color; +defaults.set('elements', { + point: { + backgroundColor: defaultColor$1, + borderColor: defaultColor$1, + borderWidth: 1, + hitRadius: 1, + hoverBorderWidth: 1, + hoverRadius: 4, + pointStyle: 'circle', + radius: 3 + } +}); +class Point extends Element { + constructor(cfg) { + super(); + this.options = undefined; + this.skip = undefined; + this.stop = undefined; + if (cfg) { + _extends(this, cfg); + } + } + inRange(mouseX, mouseY, useFinalPosition) { + var options = this.options; + var { + x, + y + } = this.getProps(['x', 'y'], useFinalPosition); + return Math.pow(mouseX - x, 2) + Math.pow(mouseY - y, 2) < Math.pow(options.hitRadius + options.radius, 2); + } + inXRange(mouseX, useFinalPosition) { + var options = this.options; + var { + x + } = this.getProps(['x'], useFinalPosition); + return Math.abs(mouseX - x) < options.radius + options.hitRadius; + } + inYRange(mouseY, useFinalPosition) { + var options = this.options; + var { + y + } = this.getProps(['x'], useFinalPosition); + return Math.abs(mouseY - y) < options.radius + options.hitRadius; + } + getCenterPoint(useFinalPosition) { + var { + x, + y + } = this.getProps(['x', 'y'], useFinalPosition); + return { + x, + y + }; + } + size() { + var options = this.options || {}; + var radius = Math.max(options.radius, options.hoverRadius) || 0; + var borderWidth = radius && options.borderWidth || 0; + return (radius + borderWidth) * 2; + } + draw(ctx, chartArea) { + var me = this; + var options = me.options; + if (me.skip || options.radius <= 0) { + return; + } + if (chartArea === undefined || _isPointInArea(me, chartArea)) { + ctx.strokeStyle = options.borderColor; + ctx.lineWidth = options.borderWidth; + ctx.fillStyle = options.backgroundColor; + drawPoint(ctx, options, me.x, me.y); + } + } + getRange() { + var options = this.options || {}; + return options.radius + options.hitRadius; + } +} +_defineProperty(Point, "_type", 'point'); + +var defaultColor$2 = defaults.color; +defaults.set('elements', { + rectangle: { + backgroundColor: defaultColor$2, + borderColor: defaultColor$2, + borderSkipped: 'bottom', + borderWidth: 0 + } +}); +function getBarBounds(bar, useFinalPosition) { + var { + x, + y, + base, + width, + height + } = bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition); + var left, right, top, bottom, half; + if (bar.horizontal) { + half = height / 2; + left = Math.min(x, base); + right = Math.max(x, base); + top = y - half; + bottom = y + half; + } else { + half = width / 2; + left = x - half; + right = x + half; + top = Math.min(y, base); + bottom = Math.max(y, base); + } + return { + left, + top, + right, + bottom + }; +} +function swap(orig, v1, v2) { + return orig === v1 ? v2 : orig === v2 ? v1 : orig; +} +function parseBorderSkipped(bar) { + var edge = bar.options.borderSkipped; + var res = {}; + if (!edge) { + return res; + } + if (bar.horizontal) { + if (bar.base > bar.x) { + edge = swap(edge, 'left', 'right'); + } + } else if (bar.base < bar.y) { + edge = swap(edge, 'bottom', 'top'); + } + res[edge] = true; + return res; +} +function skipOrLimit(skip, value, min, max) { + return skip ? 0 : Math.max(Math.min(value, max), min); +} +function parseBorderWidth(bar, maxW, maxH) { + var value = bar.options.borderWidth; + var skip = parseBorderSkipped(bar); + var t, r, b, l; + if (isObject(value)) { + t = +value.top || 0; + r = +value.right || 0; + b = +value.bottom || 0; + l = +value.left || 0; + } else { + t = r = b = l = +value || 0; + } + return { + t: skipOrLimit(skip.top, t, 0, maxH), + r: skipOrLimit(skip.right, r, 0, maxW), + b: skipOrLimit(skip.bottom, b, 0, maxH), + l: skipOrLimit(skip.left, l, 0, maxW) + }; +} +function boundingRects(bar) { + var bounds = getBarBounds(bar); + var width = bounds.right - bounds.left; + var height = bounds.bottom - bounds.top; + var border = parseBorderWidth(bar, width / 2, height / 2); + return { + outer: { + x: bounds.left, + y: bounds.top, + w: width, + h: height + }, + inner: { + x: bounds.left + border.l, + y: bounds.top + border.t, + w: width - border.l - border.r, + h: height - border.t - border.b + } + }; +} +function inRange(bar, x, y, useFinalPosition) { + var skipX = x === null; + var skipY = y === null; + var bounds = !bar || skipX && skipY ? false : getBarBounds(bar, useFinalPosition); + return bounds && (skipX || x >= bounds.left && x <= bounds.right) && (skipY || y >= bounds.top && y <= bounds.bottom); +} +class Rectangle extends Element { + constructor(cfg) { + super(); + this.options = undefined; + this.horizontal = undefined; + this.base = undefined; + this.width = undefined; + this.height = undefined; + if (cfg) { + _extends(this, cfg); + } + } + draw(ctx) { + var options = this.options; + var { + inner, + outer + } = boundingRects(this); + ctx.save(); + if (outer.w !== inner.w || outer.h !== inner.h) { + ctx.beginPath(); + ctx.rect(outer.x, outer.y, outer.w, outer.h); + ctx.clip(); + ctx.rect(inner.x, inner.y, inner.w, inner.h); + ctx.fillStyle = options.borderColor; + ctx.fill('evenodd'); + } + ctx.fillStyle = options.backgroundColor; + ctx.fillRect(inner.x, inner.y, inner.w, inner.h); + ctx.restore(); + } + inRange(mouseX, mouseY, useFinalPosition) { + return inRange(this, mouseX, mouseY, useFinalPosition); + } + inXRange(mouseX, useFinalPosition) { + return inRange(this, mouseX, null, useFinalPosition); + } + inYRange(mouseY, useFinalPosition) { + return inRange(this, null, mouseY, useFinalPosition); + } + getCenterPoint(useFinalPosition) { + var { + x, + y, + base, + horizontal + } = this.getProps(['x', 'y', 'base', 'horizontal'], useFinalPosition); + return { + x: horizontal ? (x + base) / 2 : x, + y: horizontal ? y : (y + base) / 2 + }; + } + getRange(axis) { + return axis === 'x' ? this.width / 2 : this.height / 2; + } +} +_defineProperty(Rectangle, "_type", 'rectangle'); + +var elements = /*#__PURE__*/Object.freeze({ +__proto__: null, +Arc: Arc, +Line: Line, +Point: Point, +Rectangle: Rectangle +}); + +defaults.set('bar', { + hover: { + mode: 'index' + }, + datasets: { + categoryPercentage: 0.8, + barPercentage: 0.9, + animation: { + numbers: { + type: 'number', + properties: ['x', 'y', 'base', 'width', 'height'] + } + } + }, + scales: { + x: { + type: 'category', + offset: true, + gridLines: { + offsetGridLines: true + } + }, + y: { + type: 'linear', + beginAtZero: true + } + } +}); +function computeMinSampleSize(scale, pixels) { + var min = scale._length; + var prev, curr, i, ilen; + for (i = 1, ilen = pixels.length; i < ilen; ++i) { + min = Math.min(min, Math.abs(pixels[i] - pixels[i - 1])); + } + for (i = 0, ilen = scale.ticks.length; i < ilen; ++i) { + curr = scale.getPixelForTick(i); + min = i > 0 ? Math.min(min, Math.abs(curr - prev)) : min; + prev = curr; + } + return min; +} +function computeFitCategoryTraits(index, ruler, options) { + var thickness = options.barThickness; + var count = ruler.stackCount; + var size, ratio; + if (isNullOrUndef(thickness)) { + size = ruler.min * options.categoryPercentage; + ratio = options.barPercentage; + } else { + size = thickness * count; + ratio = 1; + } + return { + chunk: size / count, + ratio, + start: ruler.pixels[index] - size / 2 + }; +} +function computeFlexCategoryTraits(index, ruler, options) { + var pixels = ruler.pixels; + var curr = pixels[index]; + var prev = index > 0 ? pixels[index - 1] : null; + var next = index < pixels.length - 1 ? pixels[index + 1] : null; + var percent = options.categoryPercentage; + if (prev === null) { + prev = curr - (next === null ? ruler.end - ruler.start : next - curr); + } + if (next === null) { + next = curr + curr - prev; + } + var start = curr - (curr - Math.min(prev, next)) / 2 * percent; + var size = Math.abs(next - prev) / 2 * percent; + return { + chunk: size / ruler.stackCount, + ratio: options.barPercentage, + start + }; +} +function parseFloatBar(arr, item, vScale, i) { + var startValue = vScale.parse(arr[0], i); + var endValue = vScale.parse(arr[1], i); + var min = Math.min(startValue, endValue); + var max = Math.max(startValue, endValue); + var barStart = min; + var barEnd = max; + if (Math.abs(min) > Math.abs(max)) { + barStart = max; + barEnd = min; + } + item[vScale.axis] = barEnd; + item._custom = { + barStart, + barEnd, + start: startValue, + end: endValue, + min, + max + }; +} +function parseArrayOrPrimitive(meta, data, start, count) { + var iScale = meta.iScale; + var vScale = meta.vScale; + var labels = iScale.getLabels(); + var singleScale = iScale === vScale; + var parsed = []; + var 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); + if (isArray(entry)) { + parseFloatBar(entry, item, vScale, i); + } else { + item[vScale.axis] = vScale.parse(entry, i); + } + parsed.push(item); + } + return parsed; +} +function isFloatBar(custom) { + return custom && custom.barStart !== undefined && custom.barEnd !== undefined; +} +class BarController extends DatasetController { + parsePrimitiveData(meta, data, start, count) { + return parseArrayOrPrimitive(meta, data, start, count); + } + parseArrayData(meta, data, start, count) { + return parseArrayOrPrimitive(meta, data, start, count); + } + parseObjectData(meta, data, start, count) { + var { + iScale, + vScale + } = meta; + var vProp = vScale.axis; + var parsed = []; + var i, ilen, item, obj, value; + for (i = start, ilen = start + count; i < ilen; ++i) { + obj = data[i]; + item = {}; + 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); + } + parsed.push(item); + } + return parsed; + } + getLabelAndValue(index) { + var me = this; + var meta = me._cachedMeta; + var { + iScale, + vScale + } = meta; + var parsed = me.getParsed(index); + var custom = parsed._custom; + var value = isFloatBar(custom) ? '[' + custom.start + ', ' + custom.end + ']' : '' + vScale.getLabelForValue(parsed[vScale.axis]); + return { + label: '' + iScale.getLabelForValue(parsed[iScale.axis]), + value + }; + } + initialize() { + var me = this; + super.initialize(); + var meta = me._cachedMeta; + meta.stack = me.getDataset().stack; + meta.bar = true; + } + update(mode) { + var me = this; + var meta = me._cachedMeta; + me.updateElements(meta.data, 0, mode); + } + updateElements(rectangles, start, mode) { + var me = this; + var reset = mode === 'reset'; + var vscale = me._cachedMeta.vScale; + var base = vscale.getBasePixel(); + var horizontal = vscale.isHorizontal(); + var ruler = me._getRuler(); + var firstOpts = me.resolveDataElementOptions(start, mode); + var sharedOptions = me.getSharedOptions(mode, rectangles[start], firstOpts); + var includeOptions = me.includeOptions(mode, sharedOptions); + var i; + for (i = 0; i < rectangles.length; i++) { + var index = start + i; + var options = me.resolveDataElementOptions(index, mode); + var vpixels = me._calculateBarValuePixels(index, options); + var ipixels = me._calculateBarIndexPixels(index, ruler, options); + var properties = { + horizontal, + base: reset ? base : vpixels.base, + x: horizontal ? reset ? base : vpixels.head : ipixels.center, + y: horizontal ? ipixels.center : reset ? base : vpixels.head, + height: horizontal ? ipixels.size : undefined, + width: horizontal ? undefined : ipixels.size + }; + if (includeOptions) { + properties.options = options; + } + me.updateElement(rectangles[i], index, properties, mode); + } + me.updateSharedOptions(sharedOptions, mode); + } + _getStacks(last) { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale; + var metasets = iScale.getMatchingVisibleMetas(me._type); + var stacked = iScale.options.stacked; + var ilen = metasets.length; + var stacks = []; + var i, item; + for (i = 0; i < ilen; ++i) { + item = metasets[i]; + if (stacked === false || stacks.indexOf(item.stack) === -1 || stacked === undefined && item.stack === undefined) { + stacks.push(item.stack); + } + if (item.index === last) { + break; + } + } + if (!stacks.length) { + stacks.push(undefined); + } + return stacks; + } + _getStackCount() { + return this._getStacks().length; + } + _getStackIndex(datasetIndex, name) { + var stacks = this._getStacks(datasetIndex); + var index = name !== undefined ? stacks.indexOf(name) : -1; + return index === -1 ? stacks.length - 1 : index; + } + _getRuler() { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale; + var pixels = []; + var i, ilen; + for (i = 0, ilen = meta.data.length; i < ilen; ++i) { + pixels.push(iScale.getPixelForValue(me.getParsed(i)[iScale.axis])); + } + var min = computeMinSampleSize(iScale, pixels); + return { + min, + pixels, + start: iScale._startPixel, + end: iScale._endPixel, + stackCount: me._getStackCount(), + scale: iScale + }; + } + _calculateBarValuePixels(index, options) { + var me = this; + var meta = me._cachedMeta; + var vScale = meta.vScale; + var minBarLength = options.minBarLength; + var parsed = me.getParsed(index); + var custom = parsed._custom; + var value = parsed[vScale.axis]; + var start = 0; + var length = meta._stacked ? me.applyStack(vScale, parsed) : value; + var head, size; + if (length !== value) { + start = length - value; + length = value; + } + if (isFloatBar(custom)) { + value = custom.barStart; + length = custom.barEnd - custom.barStart; + if (value !== 0 && sign(value) !== sign(custom.barEnd)) { + start = 0; + } + start += value; + } + var base = _limitValue(vScale.getPixelForValue(start), vScale._startPixel - 10, vScale._endPixel + 10); + head = vScale.getPixelForValue(start + length); + size = head - base; + if (minBarLength !== undefined && Math.abs(size) < minBarLength) { + size = size < 0 ? -minBarLength : minBarLength; + head = base + size; + } + return { + size, + base, + head, + center: head + size / 2 + }; + } + _calculateBarIndexPixels(index, ruler, options) { + var me = this; + var range = options.barThickness === 'flex' ? computeFlexCategoryTraits(index, ruler, options) : computeFitCategoryTraits(index, ruler, options); + var stackIndex = me._getStackIndex(me.index, me._cachedMeta.stack); + var center = range.start + range.chunk * stackIndex + range.chunk / 2; + var size = Math.min(valueOrDefault(options.maxBarThickness, Infinity), range.chunk * range.ratio); + return { + base: center - size / 2, + head: center + size / 2, + center, + size + }; + } + draw() { + var me = this; + var chart = me.chart; + var meta = me._cachedMeta; + var vScale = meta.vScale; + var rects = meta.data; + var ilen = rects.length; + var i = 0; + clipArea(chart.ctx, chart.chartArea); + for (; i < ilen; ++i) { + if (!isNaN(me.getParsed(i)[vScale.axis])) { + rects[i].draw(me._ctx); + } + } + unclipArea(chart.ctx); + } +} +BarController.prototype.dataElementType = Rectangle; +BarController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderSkipped', 'borderWidth', 'barPercentage', 'barThickness', 'categoryPercentage', 'maxBarThickness', 'minBarLength']; + +defaults.set('bubble', { + animation: { + numbers: { + properties: ['x', 'y', 'borderWidth', 'radius'] + } + }, + scales: { + x: { + type: 'linear' + }, + y: { + type: 'linear' + } + }, + tooltips: { + callbacks: { + title() { + return ''; + } + } + } +}); +class BubbleController extends DatasetController { + parseObjectData(meta, data, start, count) { + var { + xScale, + yScale + } = meta; + var parsed = []; + var 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), + _custom: item && item.r && +item.r + }); + } + return parsed; + } + getMaxOverflow() { + var me = this; + var meta = me._cachedMeta; + var i = (meta.data || []).length - 1; + var max = 0; + for (; i >= 0; --i) { + max = Math.max(max, me.getStyle(i, true).radius); + } + return max > 0 && max; + } + getLabelAndValue(index) { + var me = this; + var meta = me._cachedMeta; + var { + xScale, + yScale + } = meta; + var parsed = me.getParsed(index); + var x = xScale.getLabelForValue(parsed.x); + var y = yScale.getLabelForValue(parsed.y); + var r = parsed._custom; + return { + label: meta.label, + value: '(' + x + ', ' + y + (r ? ', ' + r : '') + ')' + }; + } + update(mode) { + var me = this; + var points = me._cachedMeta.data; + me.updateElements(points, 0, mode); + } + updateElements(points, start, mode) { + var me = this; + var reset = mode === 'reset'; + var { + xScale, + yScale + } = me._cachedMeta; + var firstOpts = me.resolveDataElementOptions(start, mode); + var sharedOptions = me.getSharedOptions(mode, points[start], firstOpts); + var includeOptions = me.includeOptions(mode, sharedOptions); + for (var i = 0; i < points.length; i++) { + var point = points[i]; + var index = start + i; + var parsed = !reset && me.getParsed(index); + var x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(parsed.x); + var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y); + var properties = { + x, + y, + skip: isNaN(x) || isNaN(y) + }; + if (includeOptions) { + properties.options = me.resolveDataElementOptions(i, mode); + if (reset) { + properties.options.radius = 0; + } + } + me.updateElement(point, index, properties, mode); + } + me.updateSharedOptions(sharedOptions, mode); + } + resolveDataElementOptions(index, mode) { + var me = this; + var chart = me.chart; + var dataset = me.getDataset(); + var parsed = me.getParsed(index); + var values = super.resolveDataElementOptions(index, mode); + var context = { + chart, + dataIndex: index, + dataset, + datasetIndex: me.index + }; + if (values.$shared) { + values = _extends({}, values, { + $shared: false + }); + } + if (mode !== 'active') { + values.radius = 0; + } + values.radius += resolve([parsed && parsed._custom, me._config.radius, chart.options.elements.point.radius], context, index); + return values; + } +} +BubbleController.prototype.dataElementType = Point; +BubbleController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderWidth', 'hitRadius', 'radius', 'pointStyle', 'rotation']; + +var PI$2 = Math.PI; +var DOUBLE_PI$1 = PI$2 * 2; +var HALF_PI$1 = PI$2 / 2; +defaults.set('doughnut', { + animation: { + numbers: { + type: 'number', + properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y'] + }, + animateRotate: true, + animateScale: false + }, + legend: { + labels: { + generateLabels(chart) { + var data = chart.data; + if (data.labels.length && data.datasets.length) { + return data.labels.map((label, i) => { + var meta = chart.getDatasetMeta(0); + var style = meta.controller.getStyle(i); + return { + text: label, + fillStyle: style.backgroundColor, + strokeStyle: style.borderColor, + lineWidth: style.borderWidth, + hidden: !chart.getDataVisibility(i), + index: i + }; + }); + } + return []; + } + }, + onClick(e, legendItem) { + this.chart.toggleDataVisibility(legendItem.index); + this.chart.update(); + } + }, + cutoutPercentage: 50, + rotation: -HALF_PI$1, + circumference: DOUBLE_PI$1, + tooltips: { + callbacks: { + title() { + return ''; + }, + label(tooltipItem, data) { + var dataLabel = data.labels[tooltipItem.index]; + var value = ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]; + if (isArray(dataLabel)) { + dataLabel = dataLabel.slice(); + dataLabel[0] += value; + } else { + dataLabel += value; + } + return dataLabel; + } + } + } +}); +function getRatioAndOffset(rotation, circumference, cutout) { + var ratioX = 1; + var ratioY = 1; + var offsetX = 0; + var offsetY = 0; + if (circumference < DOUBLE_PI$1) { + var startAngle = rotation % DOUBLE_PI$1; + startAngle += startAngle >= PI$2 ? -DOUBLE_PI$1 : startAngle < -PI$2 ? DOUBLE_PI$1 : 0; + var endAngle = startAngle + circumference; + var startX = Math.cos(startAngle); + var startY = Math.sin(startAngle); + var endX = Math.cos(endAngle); + var endY = Math.sin(endAngle); + var contains0 = startAngle <= 0 && endAngle >= 0 || endAngle >= DOUBLE_PI$1; + var contains90 = startAngle <= HALF_PI$1 && endAngle >= HALF_PI$1 || endAngle >= DOUBLE_PI$1 + HALF_PI$1; + var contains180 = startAngle === -PI$2 || endAngle >= PI$2; + var contains270 = startAngle <= -HALF_PI$1 && endAngle >= -HALF_PI$1 || endAngle >= PI$2 + HALF_PI$1; + var minX = contains180 ? -1 : Math.min(startX, startX * cutout, endX, endX * cutout); + var minY = contains270 ? -1 : Math.min(startY, startY * cutout, endY, endY * cutout); + var maxX = contains0 ? 1 : Math.max(startX, startX * cutout, endX, endX * cutout); + var maxY = contains90 ? 1 : Math.max(startY, startY * cutout, endY, endY * cutout); + ratioX = (maxX - minX) / 2; + ratioY = (maxY - minY) / 2; + offsetX = -(maxX + minX) / 2; + offsetY = -(maxY + minY) / 2; + } + return { + ratioX, + ratioY, + offsetX, + offsetY + }; +} +class DoughnutController extends DatasetController { + constructor(chart, datasetIndex) { + super(chart, datasetIndex); + this.innerRadius = undefined; + this.outerRadius = undefined; + this.offsetX = undefined; + this.offsetY = undefined; + } + linkScales() {} + 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]; + } + } + getRingIndex(datasetIndex) { + var ringIndex = 0; + for (var j = 0; j < datasetIndex; ++j) { + if (this.chart.isDatasetVisible(j)) { + ++ringIndex; + } + } + return ringIndex; + } + update(mode) { + var me = this; + var chart = me.chart; + var { + chartArea, + options + } = chart; + var meta = me._cachedMeta; + var arcs = meta.data; + var cutout = options.cutoutPercentage / 100 || 0; + var chartWeight = me._getRingWeight(me.index); + var { + ratioX, + ratioY, + offsetX, + offsetY + } = getRatioAndOffset(options.rotation, options.circumference, cutout); + var borderWidth = me.getMaxBorderWidth(); + var maxWidth = (chartArea.right - chartArea.left - borderWidth) / ratioX; + var maxHeight = (chartArea.bottom - chartArea.top - borderWidth) / ratioY; + var outerRadius = Math.max(Math.min(maxWidth, maxHeight) / 2, 0); + var innerRadius = Math.max(outerRadius * cutout, 0); + var radiusLength = (outerRadius - innerRadius) / me._getVisibleDatasetWeightTotal(); + me.offsetX = offsetX * outerRadius; + me.offsetY = offsetY * outerRadius; + meta.total = me.calculateTotal(); + me.outerRadius = outerRadius - radiusLength * me._getRingWeightOffset(me.index); + me.innerRadius = Math.max(me.outerRadius - radiusLength * chartWeight, 0); + me.updateElements(arcs, 0, mode); + } + _circumference(i, reset) { + var me = this; + var opts = me.chart.options; + var meta = me._cachedMeta; + return reset && opts.animation.animateRotate ? 0 : this.chart.getDataVisibility(i) ? me.calculateCircumference(meta._parsed[i] * opts.circumference / DOUBLE_PI$1) : 0; + } + updateElements(arcs, start, mode) { + var me = this; + var reset = mode === 'reset'; + 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 animateScale = reset && animationOpts.animateScale; + var innerRadius = animateScale ? 0 : me.innerRadius; + var outerRadius = animateScale ? 0 : me.outerRadius; + var firstOpts = me.resolveDataElementOptions(start, mode); + var sharedOptions = me.getSharedOptions(mode, arcs[start], firstOpts); + var includeOptions = me.includeOptions(mode, sharedOptions); + var startAngle = opts.rotation; + var i; + for (i = 0; i < start; ++i) { + startAngle += me._circumference(i, reset); + } + for (i = 0; i < arcs.length; ++i) { + var index = start + i; + var circumference = me._circumference(index, reset); + var arc = arcs[i]; + var properties = { + x: centerX + me.offsetX, + y: centerY + me.offsetY, + startAngle, + endAngle: startAngle + circumference, + circumference, + outerRadius, + innerRadius + }; + if (includeOptions) { + properties.options = me.resolveDataElementOptions(index, mode); + } + startAngle += circumference; + me.updateElement(arc, index, properties, mode); + } + me.updateSharedOptions(sharedOptions, mode); + } + calculateTotal() { + var meta = this._cachedMeta; + var metaData = meta.data; + var total = 0; + var i; + for (i = 0; i < metaData.length; i++) { + var value = meta._parsed[i]; + if (!isNaN(value) && this.chart.getDataVisibility(i)) { + total += Math.abs(value); + } + } + return total; + } + calculateCircumference(value) { + var total = this._cachedMeta.total; + if (total > 0 && !isNaN(value)) { + return DOUBLE_PI$1 * (Math.abs(value) / total); + } + return 0; + } + getMaxBorderWidth(arcs) { + var me = this; + var max = 0; + var chart = me.chart; + var i, ilen, meta, controller, options; + if (!arcs) { + for (i = 0, ilen = chart.data.datasets.length; i < ilen; ++i) { + if (chart.isDatasetVisible(i)) { + meta = chart.getDatasetMeta(i); + arcs = meta.data; + controller = meta.controller; + if (controller !== me) { + controller.configure(); + } + break; + } + } + } + if (!arcs) { + return 0; + } + for (i = 0, ilen = arcs.length; i < ilen; ++i) { + options = controller.resolveDataElementOptions(i); + if (options.borderAlign !== 'inner') { + max = Math.max(max, options.borderWidth || 0, options.hoverBorderWidth || 0); + } + } + return max; + } + _getRingWeightOffset(datasetIndex) { + var ringWeightOffset = 0; + for (var i = 0; i < datasetIndex; ++i) { + if (this.chart.isDatasetVisible(i)) { + ringWeightOffset += this._getRingWeight(i); + } + } + return ringWeightOffset; + } + _getRingWeight(datasetIndex) { + return Math.max(valueOrDefault(this.chart.data.datasets[datasetIndex].weight, 1), 0); + } + _getVisibleDatasetWeightTotal() { + return this._getRingWeightOffset(this.chart.data.datasets.length) || 1; + } +} +DoughnutController.prototype.dataElementType = Arc; +DoughnutController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderWidth', 'borderAlign', 'hoverBackgroundColor', 'hoverBorderColor', 'hoverBorderWidth']; + +defaults.set('horizontalBar', { + hover: { + mode: 'index', + axis: 'y' + }, + scales: { + x: { + type: 'linear', + beginAtZero: true + }, + y: { + type: 'category', + offset: true, + gridLines: { + offsetGridLines: true + } + } + }, + datasets: { + categoryPercentage: 0.8, + barPercentage: 0.9 + }, + elements: { + rectangle: { + borderSkipped: 'left' + } + }, + tooltips: { + mode: 'index', + axis: 'y' + } +}); +class HorizontalBarController extends BarController { + getValueScaleId() { + return this._cachedMeta.xAxisID; + } + getIndexScaleId() { + return this._cachedMeta.yAxisID; + } +} + +defaults.set('line', { + showLines: true, + spanGaps: false, + hover: { + mode: 'index' + }, + scales: { + x: { + type: 'category' + }, + y: { + type: 'linear' + } + } +}); +class LineController extends DatasetController { + constructor(chart, datasetIndex) { + super(chart, datasetIndex); + this._showLine = false; + } + update(mode) { + 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); + if (showLine && mode !== 'resize') { + var properties = { + points, + options: me.resolveDatasetElementOptions() + }; + me.updateElement(line, undefined, properties, mode); + } + me.updateElements(points, 0, mode); + } + updateElements(points, start, mode) { + var me = this; + var reset = mode === 'reset'; + var { + xScale, + yScale, + _stacked + } = me._cachedMeta; + var firstOpts = me.resolveDataElementOptions(start, mode); + var sharedOptions = me.getSharedOptions(mode, points[start], firstOpts); + var includeOptions = me.includeOptions(mode, sharedOptions); + var spanGaps = valueOrDefault(me._config.spanGaps, me.chart.options.spanGaps); + var maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY; + var prevParsed; + for (var i = 0; i < points.length; ++i) { + var index = start + i; + var point = points[i]; + var parsed = me.getParsed(index); + var x = xScale.getPixelForValue(parsed.x); + var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(_stacked ? me.applyStack(yScale, parsed) : parsed.y); + var properties = { + x, + y, + skip: isNaN(x) || isNaN(y), + stop: i > 0 && parsed.x - prevParsed.x > maxGapLength + }; + if (includeOptions) { + properties.options = me.resolveDataElementOptions(index, mode); + } + me.updateElement(point, index, properties, mode); + prevParsed = parsed; + } + me.updateSharedOptions(sharedOptions, mode); + } + resolveDatasetElementOptions(active) { + var me = this; + var config = me._config; + var options = me.chart.options; + var lineOptions = options.elements.line; + var values = super.resolveDatasetElementOptions(active); + values.spanGaps = valueOrDefault(config.spanGaps, options.spanGaps); + values.tension = valueOrDefault(config.lineTension, lineOptions.tension); + values.stepped = resolve([config.stepped, lineOptions.stepped]); + return values; + } + getMaxOverflow() { + var me = this; + var meta = me._cachedMeta; + var border = me._showLine && meta.dataset.options.borderWidth || 0; + var data = meta.data || []; + if (!data.length) { + return border; + } + var firstPoint = data[0].size(); + var lastPoint = data[data.length - 1].size(); + return Math.max(border, firstPoint, lastPoint) / 2; + } + draw() { + var me = this; + var ctx = me._ctx; + var chart = me.chart; + var meta = me._cachedMeta; + var points = meta.data || []; + var area = chart.chartArea; + var active = []; + var ilen = points.length; + var i, point; + if (me._showLine) { + meta.dataset.draw(ctx, area); + } + for (i = 0; i < ilen; ++i) { + point = points[i]; + if (point.active) { + active.push(point); + } else { + point.draw(ctx, area); + } + } + for (i = 0, ilen = active.length; i < ilen; ++i) { + active[i].draw(ctx, area); + } + } +} +LineController.prototype.datasetElementType = Line; +LineController.prototype.dataElementType = Point; +LineController.prototype.datasetElementOptions = ['backgroundColor', 'borderCapStyle', 'borderColor', 'borderDash', 'borderDashOffset', 'borderJoinStyle', 'borderWidth', 'capBezierPoints', 'cubicInterpolationMode', 'fill']; +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' +}; + +defaults.set('polarArea', { + animation: { + numbers: { + type: 'number', + properties: ['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius'] + }, + animateRotate: true, + animateScale: true + }, + scales: { + r: { + type: 'radialLinear', + angleLines: { + display: false + }, + beginAtZero: true, + gridLines: { + circular: true + }, + pointLabels: { + display: false + } + } + }, + startAngle: 0, + legend: { + labels: { + generateLabels(chart) { + var data = chart.data; + if (data.labels.length && data.datasets.length) { + return data.labels.map((label, i) => { + var meta = chart.getDatasetMeta(0); + var style = meta.controller.getStyle(i); + return { + text: label, + fillStyle: style.backgroundColor, + strokeStyle: style.borderColor, + lineWidth: style.borderWidth, + hidden: !chart.getDataVisibility(i), + index: i + }; + }); + } + return []; + } + }, + onClick(e, legendItem) { + this.chart.toggleDataVisibility(legendItem.index); + this.chart.update(); + } + }, + tooltips: { + callbacks: { + title() { + return ''; + }, + label(item, data) { + return data.labels[item.index] + ': ' + item.value; + } + } + } +}); +function getStartAngleRadians(deg) { + return toRadians(deg) - 0.5 * Math.PI; +} +class PolarAreaController extends DatasetController { + constructor(chart, datasetIndex) { + super(chart, datasetIndex); + this.innerRadius = undefined; + this.outerRadius = undefined; + } + getIndexScaleId() { + return this._cachedMeta.rAxisID; + } + getValueScaleId() { + return this._cachedMeta.rAxisID; + } + update(mode) { + var arcs = this._cachedMeta.data; + this._updateRadius(); + this.updateElements(arcs, 0, mode); + } + _updateRadius() { + var me = this; + var chart = me.chart; + var chartArea = chart.chartArea; + var opts = chart.options; + var minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top); + var outerRadius = Math.max(minSize / 2, 0); + var innerRadius = Math.max(opts.cutoutPercentage ? outerRadius / 100 * opts.cutoutPercentage : 1, 0); + var radiusLength = (outerRadius - innerRadius) / chart.getVisibleDatasetCount(); + me.outerRadius = outerRadius - radiusLength * me.index; + me.innerRadius = me.outerRadius - radiusLength; + } + updateElements(arcs, start, mode) { + var me = this; + var reset = mode === 'reset'; + var chart = me.chart; + var dataset = me.getDataset(); + var opts = chart.options; + var animationOpts = opts.animation; + var scale = chart.scales.r; + var centerX = scale.xCenter; + var centerY = scale.yCenter; + var datasetStartAngle = getStartAngleRadians(opts.startAngle); + var angle = datasetStartAngle; + var i; + me._cachedMeta.count = me.countVisibleElements(); + for (i = 0; i < start; ++i) { + angle += me._computeAngle(i); + } + for (i = 0; i < arcs.length; i++) { + var arc = arcs[i]; + var index = start + i; + var startAngle = angle; + var endAngle = angle + me._computeAngle(index); + var outerRadius = this.chart.getDataVisibility(index) ? scale.getDistanceFromCenterForValue(dataset.data[index]) : 0; + angle = endAngle; + if (reset) { + if (animationOpts.animateScale) { + outerRadius = 0; + } + if (animationOpts.animateRotate) { + startAngle = datasetStartAngle; + endAngle = datasetStartAngle; + } + } + var properties = { + x: centerX, + y: centerY, + innerRadius: 0, + outerRadius, + startAngle, + endAngle, + options: me.resolveDataElementOptions(index) + }; + me.updateElement(arc, index, properties, mode); + } + } + countVisibleElements() { + var dataset = this.getDataset(); + var meta = this._cachedMeta; + var count = 0; + meta.data.forEach((element, index) => { + if (!isNaN(dataset.data[index]) && this.chart.getDataVisibility(index)) { + count++; + } + }); + return count; + } + _computeAngle(index) { + var me = this; + var meta = me._cachedMeta; + var count = meta.count; + var dataset = me.getDataset(); + if (isNaN(dataset.data[index]) || !this.chart.getDataVisibility(index)) { + return 0; + } + var context = { + chart: me.chart, + dataIndex: index, + dataset, + datasetIndex: me.index + }; + return resolve([me.chart.options.elements.arc.angle, 2 * Math.PI / count], context, index); + } +} +PolarAreaController.prototype.dataElementType = Arc; +PolarAreaController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderWidth', 'borderAlign', 'hoverBackgroundColor', 'hoverBorderColor', 'hoverBorderWidth']; + +defaults.set('pie', clone(defaults.doughnut)); +defaults.set('pie', { + cutoutPercentage: 0 +}); + +defaults.set('radar', { + spanGaps: false, + scales: { + r: { + type: 'radialLinear' + } + }, + elements: { + line: { + tension: 0 + } + } +}); +class RadarController extends DatasetController { + getIndexScaleId() { + return this._cachedMeta.rAxisID; + } + getValueScaleId() { + return this._cachedMeta.rAxisID; + } + getLabelAndValue(index) { + var me = this; + var vScale = me._cachedMeta.vScale; + var parsed = me.getParsed(index); + return { + label: vScale.getLabels()[index], + value: '' + vScale.getLabelForValue(parsed[vScale.axis]) + }; + } + update(mode) { + var me = this; + var meta = me._cachedMeta; + var line = meta.dataset; + var points = meta.data || []; + var labels = meta.iScale.getLabels(); + var properties = { + points, + _loop: true, + _fullLoop: labels.length === points.length, + options: me.resolveDatasetElementOptions() + }; + me.updateElement(line, undefined, properties, mode); + me.updateElements(points, 0, mode); + line.updateControlPoints(me.chart.chartArea); + } + updateElements(points, start, mode) { + var me = this; + var dataset = me.getDataset(); + var scale = me.chart.scales.r; + var reset = mode === 'reset'; + var i; + for (i = 0; i < points.length; i++) { + var point = points[i]; + var index = start + i; + var options = me.resolveDataElementOptions(index); + var pointPosition = scale.getPointPositionForValue(index, dataset.data[index]); + var x = reset ? scale.xCenter : pointPosition.x; + var y = reset ? scale.yCenter : pointPosition.y; + var properties = { + x, + y, + angle: pointPosition.angle, + skip: isNaN(x) || isNaN(y), + options + }; + me.updateElement(point, index, properties, mode); + } + } + resolveDatasetElementOptions(active) { + var me = this; + var config = me._config; + var options = me.chart.options; + var values = super.resolveDatasetElementOptions(active); + values.spanGaps = valueOrDefault(config.spanGaps, options.spanGaps); + values.tension = valueOrDefault(config.lineTension, options.elements.line.tension); + return values; + } +} +RadarController.prototype.datasetElementType = Line; +RadarController.prototype.dataElementType = Point; +RadarController.prototype.datasetElementOptions = ['backgroundColor', 'borderColor', 'borderCapStyle', 'borderDash', 'borderDashOffset', 'borderJoinStyle', 'borderWidth', 'fill']; +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' +}; + +defaults.set('scatter', { + scales: { + x: { + type: 'linear' + }, + y: { + type: 'linear' + } + }, + datasets: { + showLine: false + }, + tooltips: { + callbacks: { + title() { + return ''; + }, + label(item) { + return '(' + item.label + ', ' + item.value + ')'; + } + } + } +}); + +var controllers = { + bar: BarController, + bubble: BubbleController, + doughnut: DoughnutController, + horizontalBar: HorizontalBarController, + line: LineController, + polarArea: PolarAreaController, + pie: DoughnutController, + radar: RadarController, + scatter: LineController +}; + +function _lookup(table, value) { + var hi = table.length - 1; + var lo = 0; + var mid; + while (hi - lo > 1) { + mid = lo + hi >> 1; + if (table[mid] < value) { + lo = mid; + } else { + hi = mid; + } + } + return { + lo, + hi + }; +} +function _lookupByKey(table, key, value) { + var hi = table.length - 1; + var lo = 0; + var mid; + while (hi - lo > 1) { + mid = lo + hi >> 1; + if (table[mid][key] < value) { + lo = mid; + } else { + hi = mid; + } + } + return { + lo, + hi + }; +} +function _rlookupByKey(table, key, value) { + var hi = table.length - 1; + var lo = 0; + var mid; + while (hi - lo > 1) { + mid = lo + hi >> 1; + if (table[mid][key] < value) { + hi = mid; + } else { + lo = mid; + } + } + return { + lo, + hi + }; +} +function _filterBetween(values, min, max) { + var start = 0; + var end = values.length; + while (start < end && values[start] < min) { + start++; + } + while (end > start && values[end - 1] > max) { + end--; + } + return start > 0 || end < values.length ? values.slice(start, end) : values; +} + +function getRelativePosition$1(e, chart) { + if ('native' in e) { + return { + x: e.x, + y: e.y + }; + } + return helpers.dom.getRelativePosition(e, chart); +} +function evaluateAllVisibleItems(chart, handler) { + var metasets = chart.getSortedVisibleDatasetMetas(); + var index, data, element; + for (var i = 0, ilen = metasets.length; i < ilen; ++i) { + ({ + index, + data + } = metasets[i]); + for (var j = 0, jlen = data.length; j < jlen; ++j) { + element = data[j]; + if (!element.skip) { + handler(element, index, j); + } + } + } +} +function binarySearch(metaset, axis, value, intersect) { + var { + controller, + data, + _sorted + } = metaset; + var iScale = controller._cachedMeta.iScale; + if (iScale && axis === iScale.axis && _sorted && data.length) { + var lookupMethod = iScale._reversePixels ? _rlookupByKey : _lookupByKey; + if (!intersect) { + return lookupMethod(data, axis, value); + } else if (controller._sharedOptions) { + var el = data[0]; + var range = typeof el.getRange === 'function' && el.getRange(axis); + if (range) { + var start = lookupMethod(data, axis, value - range); + var end = lookupMethod(data, axis, value + range); + return { + lo: start.lo, + hi: end.hi + }; + } + } + } + return { + lo: 0, + hi: data.length - 1 + }; +} +function optimizedEvaluateItems(chart, axis, position, handler, intersect) { + var metasets = chart.getSortedVisibleDatasetMetas(); + var value = position[axis]; + for (var i = 0, ilen = metasets.length; i < ilen; ++i) { + var { + index, + data + } = metasets[i]; + var { + lo, + hi + } = binarySearch(metasets[i], axis, value, intersect); + for (var j = lo; j <= hi; ++j) { + var element = data[j]; + if (!element.skip) { + handler(element, index, j); + } + } + } +} +function getDistanceMetricForAxis(axis) { + var useX = axis.indexOf('x') !== -1; + var useY = axis.indexOf('y') !== -1; + return function (pt1, pt2) { + var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0; + var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0; + return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)); + }; +} +function getIntersectItems(chart, position, axis, useFinalPosition) { + var items = []; + if (!_isPointInArea(position, chart.chartArea)) { + return items; + } + var evaluationFunc = function evaluationFunc(element, datasetIndex, index) { + if (element.inRange(position.x, position.y, useFinalPosition)) { + items.push({ + element, + datasetIndex, + index + }); + } + }; + optimizedEvaluateItems(chart, axis, position, evaluationFunc, true); + return items; +} +function getNearestItems(chart, position, axis, intersect, useFinalPosition) { + var distanceMetric = getDistanceMetricForAxis(axis); + var minDistance = Number.POSITIVE_INFINITY; + var items = []; + if (!_isPointInArea(position, chart.chartArea)) { + return items; + } + var evaluationFunc = function evaluationFunc(element, datasetIndex, index) { + if (intersect && !element.inRange(position.x, position.y, useFinalPosition)) { + return; + } + var center = element.getCenterPoint(useFinalPosition); + var distance = distanceMetric(position, center); + if (distance < minDistance) { + items = [{ + element, + datasetIndex, + index + }]; + minDistance = distance; + } else if (distance === minDistance) { + items.push({ + element, + datasetIndex, + index + }); + } + }; + optimizedEvaluateItems(chart, axis, position, evaluationFunc); + return items; +} +var Interaction = { + modes: { + index(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var axis = options.axis || 'x'; + var items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition) : getNearestItems(chart, position, axis, false, useFinalPosition); + var elements = []; + if (!items.length) { + return []; + } + chart.getSortedVisibleDatasetMetas().forEach(meta => { + var index = items[0].index; + var element = meta.data[index]; + if (element && !element.skip) { + elements.push({ + element, + datasetIndex: meta.index, + index + }); + } + }); + return elements; + }, + dataset(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var axis = options.axis || 'xy'; + var items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition) : getNearestItems(chart, position, axis, false, useFinalPosition); + if (items.length > 0) { + var datasetIndex = items[0].datasetIndex; + var data = chart.getDatasetMeta(datasetIndex).data; + items = []; + for (var i = 0; i < data.length; ++i) { + items.push({ + element: data[i], + datasetIndex, + index: i + }); + } + } + return items; + }, + point(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var axis = options.axis || 'xy'; + return getIntersectItems(chart, position, axis, useFinalPosition); + }, + nearest(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var axis = options.axis || 'xy'; + return getNearestItems(chart, position, axis, options.intersect, useFinalPosition); + }, + x(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var items = []; + var intersectsItem = false; + evaluateAllVisibleItems(chart, (element, datasetIndex, index) => { + if (element.inXRange(position.x, useFinalPosition)) { + items.push({ + element, + datasetIndex, + index + }); + } + if (element.inRange(position.x, position.y, useFinalPosition)) { + intersectsItem = true; + } + }); + if (options.intersect && !intersectsItem) { + return []; + } + return items; + }, + y(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var items = []; + var intersectsItem = false; + evaluateAllVisibleItems(chart, (element, datasetIndex, index) => { + if (element.inYRange(position.y, useFinalPosition)) { + items.push({ + element, + datasetIndex, + index + }); + } + if (element.inRange(position.x, position.y, useFinalPosition)) { + intersectsItem = true; + } + }); + if (options.intersect && !intersectsItem) { + return []; + } + return items; + } + } +}; + +var STATIC_POSITIONS = ['left', 'top', 'right', 'bottom']; +function filterByPosition(array, position) { + return array.filter(v => v.pos === position); +} +function filterDynamicPositionByAxis(array, axis) { + return array.filter(v => STATIC_POSITIONS.indexOf(v.pos) === -1 && v.box.axis === axis); +} +function sortByWeight(array, reverse) { + return array.sort((a, b) => { + var v0 = reverse ? b : a; + var v1 = reverse ? a : b; + return v0.weight === v1.weight ? v0.index - v1.index : v0.weight - v1.weight; + }); +} +function wrapBoxes(boxes) { + var layoutBoxes = []; + var i, ilen, box; + for (i = 0, ilen = (boxes || []).length; i < ilen; ++i) { + box = boxes[i]; + layoutBoxes.push({ + index: i, + box, + pos: box.position, + horizontal: box.isHorizontal(), + weight: box.weight + }); + } + return layoutBoxes; +} +function setLayoutDims(layouts, params) { + var i, ilen, layout; + for (i = 0, ilen = layouts.length; i < ilen; ++i) { + layout = layouts[i]; + layout.width = layout.horizontal ? layout.box.fullWidth && params.availableWidth : params.vBoxMaxWidth; + layout.height = layout.horizontal && params.hBoxMaxHeight; + } +} +function buildLayoutBoxes(boxes) { + var layoutBoxes = wrapBoxes(boxes); + var left = sortByWeight(filterByPosition(layoutBoxes, 'left'), true); + var right = sortByWeight(filterByPosition(layoutBoxes, 'right')); + var top = sortByWeight(filterByPosition(layoutBoxes, 'top'), true); + var bottom = sortByWeight(filterByPosition(layoutBoxes, 'bottom')); + var centerHorizontal = filterDynamicPositionByAxis(layoutBoxes, 'x'); + var centerVertical = filterDynamicPositionByAxis(layoutBoxes, 'y'); + return { + leftAndTop: left.concat(top), + rightAndBottom: right.concat(centerVertical).concat(bottom).concat(centerHorizontal), + chartArea: filterByPosition(layoutBoxes, 'chartArea'), + vertical: left.concat(right).concat(centerVertical), + horizontal: top.concat(bottom).concat(centerHorizontal) + }; +} +function getCombinedMax(maxPadding, chartArea, a, b) { + return Math.max(maxPadding[a], chartArea[a]) + Math.max(maxPadding[b], chartArea[b]); +} +function updateDims(chartArea, params, layout) { + var box = layout.box; + var maxPadding = chartArea.maxPadding; + if (layout.size) { + chartArea[layout.pos] -= layout.size; + } + layout.size = layout.horizontal ? box.height : box.width; + chartArea[layout.pos] += layout.size; + if (box.getPadding) { + var boxPadding = box.getPadding(); + maxPadding.top = Math.max(maxPadding.top, boxPadding.top); + maxPadding.left = Math.max(maxPadding.left, boxPadding.left); + maxPadding.bottom = Math.max(maxPadding.bottom, boxPadding.bottom); + maxPadding.right = Math.max(maxPadding.right, boxPadding.right); + } + var newWidth = params.outerWidth - getCombinedMax(maxPadding, chartArea, 'left', 'right'); + var newHeight = params.outerHeight - getCombinedMax(maxPadding, chartArea, 'top', 'bottom'); + if (newWidth !== chartArea.w || newHeight !== chartArea.h) { + chartArea.w = newWidth; + chartArea.h = newHeight; + return layout.horizontal ? newWidth !== chartArea.w : newHeight !== chartArea.h; + } +} +function handleMaxPadding(chartArea) { + var maxPadding = chartArea.maxPadding; + function updatePos(pos) { + var change = Math.max(maxPadding[pos] - chartArea[pos], 0); + chartArea[pos] += change; + return change; + } + chartArea.y += updatePos('top'); + chartArea.x += updatePos('left'); + updatePos('right'); + updatePos('bottom'); +} +function getMargins(horizontal, chartArea) { + var maxPadding = chartArea.maxPadding; + function marginForPositions(positions) { + var margin = { + left: 0, + top: 0, + right: 0, + bottom: 0 + }; + positions.forEach(pos => { + margin[pos] = Math.max(chartArea[pos], maxPadding[pos]); + }); + return margin; + } + return horizontal ? marginForPositions(['left', 'right']) : marginForPositions(['top', 'bottom']); +} +function fitBoxes(boxes, chartArea, params) { + var refitBoxes = []; + var i, ilen, layout, box, refit, changed; + for (i = 0, ilen = boxes.length; i < ilen; ++i) { + layout = boxes[i]; + box = layout.box; + box.update(layout.width || chartArea.w, layout.height || chartArea.h, getMargins(layout.horizontal, chartArea)); + if (updateDims(chartArea, params, layout)) { + changed = true; + if (refitBoxes.length) { + refit = true; + } + } + if (!box.fullWidth) { + refitBoxes.push(layout); + } + } + return refit ? fitBoxes(refitBoxes, chartArea, params) || changed : changed; +} +function placeBoxes(boxes, chartArea, params) { + var userPadding = params.padding; + var x = chartArea.x; + var y = chartArea.y; + var i, ilen, layout, box; + for (i = 0, ilen = boxes.length; i < ilen; ++i) { + layout = boxes[i]; + box = layout.box; + if (layout.horizontal) { + box.left = box.fullWidth ? userPadding.left : chartArea.left; + box.right = box.fullWidth ? params.outerWidth - userPadding.right : chartArea.left + chartArea.w; + box.top = y; + box.bottom = y + box.height; + box.width = box.right - box.left; + y = box.bottom; + } else { + box.left = x; + box.right = x + box.width; + box.top = chartArea.top; + box.bottom = chartArea.top + chartArea.h; + box.height = box.bottom - box.top; + x = box.right; + } + } + chartArea.x = x; + chartArea.y = y; +} +defaults.set('layout', { + padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + } +}); +var layouts = { + addBox(chart, item) { + if (!chart.boxes) { + chart.boxes = []; + } + item.fullWidth = item.fullWidth || false; + item.position = item.position || 'top'; + item.weight = item.weight || 0; + item._layers = item._layers || function () { + return [{ + z: 0, + draw(chartArea) { + item.draw(chartArea); + } + }]; + }; + chart.boxes.push(item); + }, + removeBox(chart, layoutItem) { + var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1; + if (index !== -1) { + chart.boxes.splice(index, 1); + } + }, + configure(chart, item, options) { + var props = ['fullWidth', 'position', 'weight']; + var ilen = props.length; + var i = 0; + var prop; + for (; i < ilen; ++i) { + prop = props[i]; + if (Object.prototype.hasOwnProperty.call(options, prop)) { + item[prop] = options[prop]; + } + } + }, + update(chart, width, height) { + if (!chart) { + return; + } + var layoutOptions = chart.options.layout || {}; + var padding = toPadding(layoutOptions.padding); + var availableWidth = width - padding.width; + var availableHeight = height - padding.height; + var boxes = buildLayoutBoxes(chart.boxes); + var verticalBoxes = boxes.vertical; + var horizontalBoxes = boxes.horizontal; + var params = Object.freeze({ + outerWidth: width, + outerHeight: height, + padding, + availableWidth, + vBoxMaxWidth: availableWidth / 2 / verticalBoxes.length, + hBoxMaxHeight: availableHeight / 2 + }); + var chartArea = _extends({ + maxPadding: _extends({}, padding), + w: availableWidth, + h: availableHeight, + x: padding.left, + y: padding.top + }, padding); + setLayoutDims(verticalBoxes.concat(horizontalBoxes), params); + fitBoxes(verticalBoxes, chartArea, params); + if (fitBoxes(horizontalBoxes, chartArea, params)) { + fitBoxes(verticalBoxes, chartArea, params); + } + handleMaxPadding(chartArea); + placeBoxes(boxes.leftAndTop, chartArea, params); + chartArea.x += chartArea.w; + chartArea.y += chartArea.h; + placeBoxes(boxes.rightAndBottom, chartArea, params); + chart.chartArea = { + left: chartArea.left, + top: chartArea.top, + right: chartArea.left + chartArea.w, + bottom: chartArea.top + chartArea.h, + height: chartArea.h, + width: chartArea.w + }; + each(boxes.chartArea, layout => { + var box = layout.box; + _extends(box, chart.chartArea); + box.update(chartArea.w, chartArea.h); + }); + } +}; + +class BasePlatform { + acquireContext(canvas, options) {} + releaseContext(context) { + return false; + } + addEventListener(chart, type, listener) {} + removeEventListener(chart, type, listener) {} + getDevicePixelRatio() { + return 1; + } +} + +class BasicPlatform extends BasePlatform { + acquireContext(item) { + return item && item.getContext && item.getContext('2d') || null; + } +} + +var EXPANDO_KEY = '$chartjs'; +var EVENT_TYPES = { + touchstart: 'mousedown', + touchmove: 'mousemove', + touchend: 'mouseup', + pointerenter: 'mouseenter', + pointerdown: 'mousedown', + pointermove: 'mousemove', + pointerup: 'mouseup', + pointerleave: 'mouseout', + pointerout: 'mouseout' +}; +function readUsedSize(element, property) { + var value = helpers.dom.getStyle(element, property); + var matches = value && value.match(/^(\d+)(\.\d+)?px$/); + return matches ? +matches[1] : undefined; +} +function initCanvas(canvas, config) { + var style = canvas.style; + var renderHeight = canvas.getAttribute('height'); + var renderWidth = canvas.getAttribute('width'); + canvas[EXPANDO_KEY] = { + initial: { + height: renderHeight, + width: renderWidth, + style: { + display: style.display, + height: style.height, + width: style.width + } + } + }; + style.display = style.display || 'block'; + style.boxSizing = style.boxSizing || 'border-box'; + if (renderWidth === null || renderWidth === '') { + var displayWidth = readUsedSize(canvas, 'width'); + if (displayWidth !== undefined) { + canvas.width = displayWidth; + } + } + if (renderHeight === null || renderHeight === '') { + if (canvas.style.height === '') { + canvas.height = canvas.width / (config.options.aspectRatio || 2); + } else { + var displayHeight = readUsedSize(canvas, 'height'); + if (displayHeight !== undefined) { + canvas.height = displayHeight; + } + } + } + return canvas; +} +var supportsEventListenerOptions = function () { + var passiveSupported = false; + try { + var options = { + get passive() { + passiveSupported = true; + return false; + } + }; + window.addEventListener('test', null, options); + window.removeEventListener('test', null, options); + } catch (e) { + } + return passiveSupported; +}(); +var eventListenerOptions = supportsEventListenerOptions ? { + passive: true +} : false; +function addListener(node, type, listener) { + node.addEventListener(type, listener, eventListenerOptions); +} +function removeListener(node, type, listener) { + node.removeEventListener(type, listener, eventListenerOptions); +} +function createEvent(type, chart, x, y, nativeEvent) { + return { + type, + chart, + native: nativeEvent || null, + x: x !== undefined ? x : null, + y: y !== undefined ? y : null + }; +} +function fromNativeEvent(event, chart) { + var type = EVENT_TYPES[event.type] || event.type; + var pos = helpers.dom.getRelativePosition(event, chart); + return createEvent(type, chart, pos.x, pos.y, event); +} +function throttled(fn, thisArg) { + var ticking = false; + var args = []; + return function () { + for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) { + rest[_key] = arguments[_key]; + } + args = Array.prototype.slice.call(rest); + if (!ticking) { + ticking = true; + helpers.requestAnimFrame.call(window, () => { + ticking = false; + fn.apply(thisArg, args); + }); + } + }; +} +function watchForResize(element, fn) { + var resize = throttled((width, height) => { + var w = element.clientWidth; + fn(width, height); + if (w < element.clientWidth) { + fn(); + } + }, window); + var observer = new ResizeObserver(entries => { + var entry = entries[0]; + resize(entry.contentRect.width, entry.contentRect.height); + }); + observer.observe(element); + return observer; +} +function watchForAttachment(element, fn) { + var observer = new MutationObserver(entries => { + var parent = _getParentNode(element); + entries.forEach(entry => { + for (var i = 0; i < entry.addedNodes.length; i++) { + var added = entry.addedNodes[i]; + if (added === element || added === parent) { + fn(entry.target); + } + } + }); + }); + observer.observe(document, { + childList: true, + subtree: true + }); + return observer; +} +function watchForDetachment(element, fn) { + var parent = _getParentNode(element); + if (!parent) { + return; + } + var observer = new MutationObserver(entries => { + entries.forEach(entry => { + for (var i = 0; i < entry.removedNodes.length; i++) { + if (entry.removedNodes[i] === element) { + fn(); + break; + } + } + }); + }); + observer.observe(parent, { + childList: true + }); + return observer; +} +function removeObserver(proxies, type) { + var observer = proxies[type]; + if (observer) { + observer.disconnect(); + proxies[type] = undefined; + } +} +function unlistenForResize(proxies) { + removeObserver(proxies, 'attach'); + removeObserver(proxies, 'detach'); + removeObserver(proxies, 'resize'); +} +function listenForResize(canvas, proxies, listener) { + var detached = () => listenForResize(canvas, proxies, listener); + unlistenForResize(proxies); + var container = _getParentNode(canvas); + if (container) { + proxies.resize = watchForResize(container, listener); + proxies.detach = watchForDetachment(canvas, detached); + } else { + proxies.attach = watchForAttachment(canvas, () => { + removeObserver(proxies, 'attach'); + var parent = _getParentNode(canvas); + proxies.resize = watchForResize(parent, listener); + proxies.detach = watchForDetachment(canvas, detached); + }); + } +} +class DomPlatform extends BasePlatform { + acquireContext(canvas, config) { + var context = canvas && canvas.getContext && canvas.getContext('2d'); + if (context && context.canvas === canvas) { + initCanvas(canvas, config); + return context; + } + return null; + } + releaseContext(context) { + var canvas = context.canvas; + if (!canvas[EXPANDO_KEY]) { + return false; + } + var initial = canvas[EXPANDO_KEY].initial; + ['height', 'width'].forEach(prop => { + var value = initial[prop]; + if (helpers.isNullOrUndef(value)) { + canvas.removeAttribute(prop); + } else { + canvas.setAttribute(prop, value); + } + }); + var style = initial.style || {}; + Object.keys(style).forEach(key => { + canvas.style[key] = style[key]; + }); + canvas.width = canvas.width; + delete canvas[EXPANDO_KEY]; + return true; + } + addEventListener(chart, type, listener) { + this.removeEventListener(chart, type); + var canvas = chart.canvas; + var proxies = chart.$proxies || (chart.$proxies = {}); + if (type === 'resize') { + return listenForResize(canvas, proxies, listener); + } + var proxy = proxies[type] = throttled(event => { + if (chart.ctx !== null) { + listener(fromNativeEvent(event, chart)); + } + }, chart); + addListener(canvas, type, proxy); + } + removeEventListener(chart, type) { + var canvas = chart.canvas; + var proxies = chart.$proxies || (chart.$proxies = {}); + if (type === 'resize') { + return unlistenForResize(proxies); + } + var proxy = proxies[type]; + if (!proxy) { + return; + } + removeListener(canvas, type, proxy); + proxies[type] = undefined; + } + getDevicePixelRatio() { + return window.devicePixelRatio; + } +} + +var platforms = { + BasicPlatform, + DomPlatform, + BasePlatform +}; + +defaults.set('plugins', {}); +class PluginService { + constructor() { + this._plugins = []; + this._cacheId = 0; + } + register(plugins) { + var p = this._plugins; + [].concat(plugins).forEach(plugin => { + if (p.indexOf(plugin) === -1) { + p.push(plugin); + } + }); + this._cacheId++; + } + unregister(plugins) { + var p = this._plugins; + [].concat(plugins).forEach(plugin => { + var idx = p.indexOf(plugin); + if (idx !== -1) { + p.splice(idx, 1); + } + }); + this._cacheId++; + } + clear() { + this._plugins = []; + this._cacheId++; + } + count() { + return this._plugins.length; + } + getAll() { + return this._plugins; + } + notify(chart, hook, args) { + var descriptors = this._descriptors(chart); + var ilen = descriptors.length; + var i, descriptor, plugin, params, method; + for (i = 0; i < ilen; ++i) { + descriptor = descriptors[i]; + plugin = descriptor.plugin; + method = plugin[hook]; + if (typeof method === 'function') { + params = [chart].concat(args || []); + params.push(descriptor.options); + if (method.apply(plugin, params) === false) { + return false; + } + } + } + return true; + } + _descriptors(chart) { + var cache = chart.$plugins || (chart.$plugins = {}); + if (cache.id === this._cacheId) { + return cache.descriptors; + } + var plugins = []; + var descriptors = []; + var config = chart && chart.config || {}; + var options = config.options && config.options.plugins || {}; + this._plugins.concat(config.plugins || []).forEach(plugin => { + var idx = plugins.indexOf(plugin); + if (idx !== -1) { + return; + } + var id = plugin.id; + var opts = options[id]; + if (opts === false) { + return; + } + if (opts === true) { + opts = clone(defaults.plugins[id]); + } + plugins.push(plugin); + descriptors.push({ + plugin, + options: opts || {} + }); + }); + cache.descriptors = descriptors; + cache.id = this._cacheId; + return descriptors; + } + invalidate(chart) { + delete chart.$plugins; + } +} +var pluginsCore = new PluginService(); + +var scaleService = { + constructors: {}, + defaults: {}, + registerScale(scaleConstructor) { + var me = this; + var type = scaleConstructor.id; + me.constructors[type] = scaleConstructor; + me.defaults[type] = clone(scaleConstructor.defaults); + }, + getScaleConstructor(type) { + return Object.prototype.hasOwnProperty.call(this.constructors, type) ? this.constructors[type] : undefined; + }, + getScaleDefaults(type) { + return Object.prototype.hasOwnProperty.call(this.defaults, type) ? merge({}, [defaults.scale, this.defaults[type]]) : {}; + }, + updateScaleDefaults(type, additions) { + var me = this; + if (Object.prototype.hasOwnProperty.call(me.defaults, type)) { + me.defaults[type] = _extends(me.defaults[type], additions); + } + }, + addScalesToLayout(chart) { + each(chart.scales, scale => { + scale.fullWidth = scale.options.fullWidth; + scale.position = scale.options.position; + scale.weight = scale.options.weight; + layouts.addBox(chart, scale); + }); + } +}; + +var version = "3.0.0-alpha"; + +var valueOrDefault$1 = helpers.valueOrDefault; +function mergeScaleConfig(config, options) { + options = options || {}; + var chartDefaults = defaults[config.type] || { + scales: {} + }; + var configScales = options.scales || {}; + var firstIDs = {}; + var scales = {}; + Object.keys(configScales).forEach(id => { + var axis = id[0]; + firstIDs[axis] = firstIDs[axis] || id; + scales[id] = helpers.mergeIf({}, [configScales[id], chartDefaults.scales[axis]]); + }); + if (options.scale) { + scales[options.scale.id || 'r'] = helpers.mergeIf({}, [options.scale, chartDefaults.scales.r]); + firstIDs.r = firstIDs.r || options.scale.id || 'r'; + } + config.data.datasets.forEach(dataset => { + var datasetDefaults = defaults[dataset.type || config.type] || { + scales: {} + }; + var defaultScaleOptions = datasetDefaults.scales || {}; + Object.keys(defaultScaleOptions).forEach(defaultID => { + var id = dataset[defaultID + 'AxisID'] || firstIDs[defaultID] || defaultID; + scales[id] = scales[id] || {}; + helpers.mergeIf(scales[id], [configScales[id], defaultScaleOptions[defaultID]]); + }); + }); + Object.keys(scales).forEach(key => { + var scale = scales[key]; + helpers.mergeIf(scale, scaleService.getScaleDefaults(scale.type)); + }); + return scales; +} +function mergeConfig() +{ + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + return helpers.merge({}, args, { + merger(key, target, source, options) { + if (key !== 'scales' && key !== 'scale') { + helpers._merger(key, target, source, options); + } + } + }); +} +function initConfig(config) { + config = config || {}; + var data = config.data = config.data || { + datasets: [], + labels: [] + }; + data.datasets = data.datasets || []; + data.labels = data.labels || []; + var scaleConfig = mergeScaleConfig(config, config.options); + config.options = mergeConfig(defaults, defaults[config.type], config.options || {}); + config.options.scales = scaleConfig; + return config; +} +function isAnimationDisabled(config) { + return !config.animation; +} +function updateConfig(chart) { + var newOptions = chart.options; + helpers.each(chart.scales, scale => { + layouts.removeBox(chart, scale); + }); + var scaleConfig = mergeScaleConfig(chart.config, newOptions); + newOptions = mergeConfig(defaults, defaults[chart.config.type], newOptions); + chart.options = chart.config.options = newOptions; + chart.options.scales = scaleConfig; + chart._animationsDisabled = isAnimationDisabled(newOptions); + chart.ensureScalesHaveIDs(); + chart.buildOrUpdateScales(); +} +var KNOWN_POSITIONS = new Set(['top', 'bottom', 'left', 'right', 'chartArea']); +function positionIsHorizontal(position, axis) { + return position === 'top' || position === 'bottom' || !KNOWN_POSITIONS.has(position) && axis === 'x'; +} +function compare2Level(l1, l2) { + return function (a, b) { + return a[l1] === b[l1] ? a[l2] - b[l2] : a[l1] - b[l1]; + }; +} +function onAnimationsComplete(ctx) { + var chart = ctx.chart; + var animationOptions = chart.options.animation; + pluginsCore.notify(chart, 'afterRender'); + helpers.callback(animationOptions && animationOptions.onComplete, [ctx], chart); +} +function onAnimationProgress(ctx) { + var chart = ctx.chart; + var animationOptions = chart.options.animation; + helpers.callback(animationOptions && animationOptions.onProgress, [ctx], chart); +} +function isDomSupported() { + return typeof window !== 'undefined' && typeof document !== 'undefined'; +} +function getCanvas(item) { + if (isDomSupported() && typeof item === 'string') { + item = document.getElementById(item); + } else if (item.length) { + item = item[0]; + } + if (item && item.canvas) { + item = item.canvas; + } + return item; +} +class Chart { + constructor(item, config) { + var me = this; + config = initConfig(config); + var initialCanvas = getCanvas(item); + this.platform = me._initializePlatform(initialCanvas, config); + var context = me.platform.acquireContext(initialCanvas, config); + var canvas = context && context.canvas; + var height = canvas && canvas.height; + var width = canvas && canvas.width; + this.id = helpers.uid(); + this.ctx = context; + this.canvas = canvas; + this.config = config; + this.width = width; + this.height = height; + this.aspectRatio = height ? width / height : null; + this.options = config.options; + this._bufferedRender = false; + this._layers = []; + this._metasets = []; + this.boxes = []; + this.currentDevicePixelRatio = undefined; + this.chartArea = undefined; + this.data = undefined; + this.active = undefined; + this.lastActive = []; + this._lastEvent = undefined; + this._listeners = {}; + this._sortedMetasets = []; + this._updating = false; + this.scales = {}; + this.scale = undefined; + this.$plugins = undefined; + this.$proxies = {}; + this._hiddenIndices = {}; + Chart.instances[me.id] = me; + Object.defineProperty(me, 'data', { + get() { + return me.config.data; + }, + set(value) { + me.config.data = value; + } + }); + if (!context || !canvas) { + console.error("Failed to create chart: can't acquire context from the given item"); + return; + } + Animator$1.listen(me, 'complete', onAnimationsComplete); + Animator$1.listen(me, 'progress', onAnimationProgress); + me._initialize(); + me.update(); + } + _initialize() { + var me = this; + pluginsCore.notify(me, 'beforeInit'); + if (me.options.responsive) { + me.resize(true); + } else { + helpers.dom.retinaScale(me, me.options.devicePixelRatio); + } + me.bindEvents(); + pluginsCore.notify(me, 'afterInit'); + return me; + } + _initializePlatform(canvas, config) { + if (config.platform) { + return new config.platform(); + } else if (!isDomSupported() || typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) { + return new BasicPlatform(); + } + return new DomPlatform(); + } + clear() { + helpers.canvas.clear(this); + return this; + } + stop() { + Animator$1.stop(this); + return this; + } + resize(silent, width, height) { + var me = this; + var options = me.options; + var canvas = me.canvas; + var aspectRatio = options.maintainAspectRatio && me.aspectRatio; + if (width === undefined || height === undefined) { + width = getMaximumWidth(canvas); + height = getMaximumHeight(canvas); + } + var newWidth = Math.max(0, Math.floor(width)); + var newHeight = Math.max(0, Math.floor(aspectRatio ? newWidth / aspectRatio : height)); + var oldRatio = me.currentDevicePixelRatio; + var newRatio = options.devicePixelRatio || me.platform.getDevicePixelRatio(); + if (me.width === newWidth && me.height === newHeight && oldRatio === newRatio) { + return; + } + canvas.width = me.width = newWidth; + canvas.height = me.height = newHeight; + if (canvas.style) { + canvas.style.width = newWidth + 'px'; + canvas.style.height = newHeight + 'px'; + } + helpers.dom.retinaScale(me, newRatio); + if (!silent) { + var newSize = { + width: newWidth, + height: newHeight + }; + pluginsCore.notify(me, 'resize', [newSize]); + if (options.onResize) { + options.onResize(me, newSize); + } + me.update('resize'); + } + } + ensureScalesHaveIDs() { + var options = this.options; + var scalesOptions = options.scales || {}; + var scaleOptions = options.scale; + helpers.each(scalesOptions, (axisOptions, axisID) => { + axisOptions.id = axisID; + }); + if (scaleOptions) { + scaleOptions.id = scaleOptions.id || 'scale'; + } + } + buildOrUpdateScales() { + var me = this; + var options = me.options; + var scaleOpts = options.scales; + var scales = me.scales || {}; + var updated = Object.keys(scales).reduce((obj, id) => { + obj[id] = false; + return obj; + }, {}); + var items = []; + if (scaleOpts) { + items = items.concat(Object.keys(scaleOpts).map(axisID => { + var axisOptions = scaleOpts[axisID]; + var isRadial = axisID.charAt(0).toLowerCase() === 'r'; + var isHorizontal = axisID.charAt(0).toLowerCase() === 'x'; + return { + options: axisOptions, + dposition: isRadial ? 'chartArea' : isHorizontal ? 'bottom' : 'left', + dtype: isRadial ? 'radialLinear' : isHorizontal ? 'category' : 'linear' + }; + })); + } + helpers.each(items, item => { + var scaleOptions = item.options; + var id = scaleOptions.id; + var scaleType = valueOrDefault$1(scaleOptions.type, item.dtype); + if (scaleOptions.position === undefined || positionIsHorizontal(scaleOptions.position, scaleOptions.axis || id[0]) !== positionIsHorizontal(item.dposition)) { + scaleOptions.position = item.dposition; + } + updated[id] = true; + var scale = null; + if (id in scales && scales[id].type === scaleType) { + scale = scales[id]; + scale.options = scaleOptions; + scale.ctx = me.ctx; + scale.chart = me; + } else { + var scaleClass = scaleService.getScaleConstructor(scaleType); + if (!scaleClass) { + return; + } + scale = new scaleClass({ + id, + type: scaleType, + options: scaleOptions, + ctx: me.ctx, + chart: me + }); + scales[scale.id] = scale; + } + scale.axis = scale.options.position === 'chartArea' ? 'r' : scale.isHorizontal() ? 'x' : 'y'; + scale._userMin = scale.parse(scale.options.min); + scale._userMax = scale.parse(scale.options.max); + if (item.isDefault) { + me.scale = scale; + } + }); + helpers.each(updated, (hasUpdated, id) => { + if (!hasUpdated) { + delete scales[id]; + } + }); + me.scales = scales; + scaleService.addScalesToLayout(this); + } + _updateMetasetIndex(meta, index) { + var metasets = this._metasets; + var oldIndex = meta.index; + if (oldIndex !== index) { + metasets[oldIndex] = metasets[index]; + metasets[index] = meta; + meta.index = index; + } + } + _updateMetasets() { + var me = this; + var metasets = me._metasets; + var numData = me.data.datasets.length; + var numMeta = metasets.length; + if (numMeta > numData) { + for (var i = numData; i < numMeta; ++i) { + me._destroyDatasetMeta(i); + } + metasets.splice(numData, numMeta - numData); + } + me._sortedMetasets = metasets.slice(0).sort(compare2Level('order', 'index')); + } + buildOrUpdateControllers() { + var me = this; + var newControllers = []; + var datasets = me.data.datasets; + var i, ilen; + for (i = 0, ilen = datasets.length; i < ilen; i++) { + var dataset = datasets[i]; + var meta = me.getDatasetMeta(i); + var type = dataset.type || me.config.type; + if (meta.type && meta.type !== type) { + me._destroyDatasetMeta(i); + meta = me.getDatasetMeta(i); + } + meta.type = type; + meta.order = dataset.order || 0; + me._updateMetasetIndex(meta, i); + meta.label = '' + dataset.label; + meta.visible = me.isDatasetVisible(i); + if (meta.controller) { + meta.controller.updateIndex(i); + meta.controller.linkScales(); + } else { + var ControllerClass = controllers[meta.type]; + if (ControllerClass === undefined) { + throw new Error('"' + meta.type + '" is not a chart type.'); + } + meta.controller = new ControllerClass(me, i); + newControllers.push(meta.controller); + } + } + me._updateMetasets(); + return newControllers; + } + _resetElements() { + var me = this; + helpers.each(me.data.datasets, (dataset, datasetIndex) => { + me.getDatasetMeta(datasetIndex).controller.reset(); + }, me); + } + reset() { + this._resetElements(); + pluginsCore.notify(this, 'reset'); + } + update(mode) { + var me = this; + var i, ilen; + me._updating = true; + updateConfig(me); + pluginsCore.invalidate(me); + if (pluginsCore.notify(me, 'beforeUpdate') === false) { + return; + } + var newControllers = me.buildOrUpdateControllers(); + for (i = 0, ilen = me.data.datasets.length; i < ilen; i++) { + me.getDatasetMeta(i).controller.buildOrUpdateElements(); + } + me._updateLayout(); + if (me.options.animation) { + helpers.each(newControllers, controller => { + controller.reset(); + }); + } + me._updateDatasets(mode); + pluginsCore.notify(me, 'afterUpdate'); + me._layers.sort(compare2Level('z', '_idx')); + if (me._lastEvent) { + me._eventHandler(me._lastEvent, true); + } + me.render(); + me._updating = false; + } + _updateLayout() { + var me = this; + if (pluginsCore.notify(me, 'beforeLayout') === false) { + return; + } + layouts.update(me, me.width, me.height); + me._layers = []; + helpers.each(me.boxes, box => { + if (box.configure) { + box.configure(); + } + me._layers.push(...box._layers()); + }, me); + me._layers.forEach((item, index) => { + item._idx = index; + }); + pluginsCore.notify(me, 'afterLayout'); + } + _updateDatasets(mode) { + var me = this; + var isFunction = typeof mode === 'function'; + if (pluginsCore.notify(me, 'beforeDatasetsUpdate') === false) { + return; + } + for (var i = 0, ilen = me.data.datasets.length; i < ilen; ++i) { + me._updateDataset(i, isFunction ? mode({ + datasetIndex: i + }) : mode); + } + pluginsCore.notify(me, 'afterDatasetsUpdate'); + } + _updateDataset(index, mode) { + var me = this; + var meta = me.getDatasetMeta(index); + var args = { + meta, + index, + mode + }; + if (pluginsCore.notify(me, 'beforeDatasetUpdate', [args]) === false) { + return; + } + meta.controller._update(mode); + pluginsCore.notify(me, 'afterDatasetUpdate', [args]); + } + render() { + var me = this; + var animationOptions = me.options.animation; + if (pluginsCore.notify(me, 'beforeRender') === false) { + return; + } + var onComplete = function onComplete() { + pluginsCore.notify(me, 'afterRender'); + helpers.callback(animationOptions && animationOptions.onComplete, [], me); + }; + if (Animator$1.has(me)) { + if (!Animator$1.running(me)) { + Animator$1.start(me); + } + } else { + me.draw(); + onComplete(); + } + } + draw() { + var me = this; + var i; + me.clear(); + if (me.width <= 0 || me.height <= 0) { + return; + } + if (pluginsCore.notify(me, 'beforeDraw') === false) { + return; + } + var layers = me._layers; + for (i = 0; i < layers.length && layers[i].z <= 0; ++i) { + layers[i].draw(me.chartArea); + } + me._drawDatasets(); + for (; i < layers.length; ++i) { + layers[i].draw(me.chartArea); + } + pluginsCore.notify(me, 'afterDraw'); + } + _getSortedDatasetMetas(filterVisible) { + var me = this; + var metasets = me._sortedMetasets; + var result = []; + var i, ilen; + for (i = 0, ilen = metasets.length; i < ilen; ++i) { + var meta = metasets[i]; + if (!filterVisible || meta.visible) { + result.push(meta); + } + } + return result; + } + getSortedVisibleDatasetMetas() { + return this._getSortedDatasetMetas(true); + } + _drawDatasets() { + var me = this; + if (pluginsCore.notify(me, 'beforeDatasetsDraw') === false) { + return; + } + var metasets = me.getSortedVisibleDatasetMetas(); + for (var i = metasets.length - 1; i >= 0; --i) { + me._drawDataset(metasets[i]); + } + pluginsCore.notify(me, 'afterDatasetsDraw'); + } + _drawDataset(meta) { + var me = this; + var ctx = me.ctx; + var clip = meta._clip; + var area = me.chartArea; + var args = { + meta, + index: meta.index + }; + if (pluginsCore.notify(me, 'beforeDatasetDraw', [args]) === false) { + return; + } + helpers.canvas.clipArea(ctx, { + left: clip.left === false ? 0 : area.left - clip.left, + right: clip.right === false ? me.width : area.right + clip.right, + top: clip.top === false ? 0 : area.top - clip.top, + bottom: clip.bottom === false ? me.height : area.bottom + clip.bottom + }); + meta.controller.draw(); + helpers.canvas.unclipArea(ctx); + pluginsCore.notify(me, 'afterDatasetDraw', [args]); + } + getElementAtEvent(e) { + return Interaction.modes.nearest(this, e, { + intersect: true + }); + } + getElementsAtEvent(e) { + return Interaction.modes.index(this, e, { + intersect: true + }); + } + getElementsAtXAxis(e) { + return Interaction.modes.index(this, e, { + intersect: false + }); + } + getElementsAtEventForMode(e, mode, options, useFinalPosition) { + var method = Interaction.modes[mode]; + if (typeof method === 'function') { + return method(this, e, options, useFinalPosition); + } + return []; + } + getDatasetAtEvent(e) { + return Interaction.modes.dataset(this, e, { + intersect: true + }); + } + getDatasetMeta(datasetIndex) { + var me = this; + var dataset = me.data.datasets[datasetIndex]; + var metasets = me._metasets; + var meta = metasets.filter(x => x._dataset === dataset).pop(); + if (!meta) { + meta = metasets[datasetIndex] = { + type: null, + data: [], + dataset: null, + controller: null, + hidden: null, + xAxisID: null, + yAxisID: null, + order: dataset.order || 0, + index: datasetIndex, + _dataset: dataset, + _parsed: [], + _sorted: false + }; + } + return meta; + } + getVisibleDatasetCount() { + return this.getSortedVisibleDatasetMetas().length; + } + isDatasetVisible(datasetIndex) { + var meta = this.getDatasetMeta(datasetIndex); + return typeof meta.hidden === 'boolean' ? !meta.hidden : !this.data.datasets[datasetIndex].hidden; + } + setDatasetVisibility(datasetIndex, visible) { + var meta = this.getDatasetMeta(datasetIndex); + meta.hidden = !visible; + } + toggleDataVisibility(index) { + this._hiddenIndices[index] = !this._hiddenIndices[index]; + } + getDataVisibility(index) { + return !this._hiddenIndices[index]; + } + _updateDatasetVisibility(datasetIndex, visible) { + var me = this; + var mode = visible ? 'show' : 'hide'; + var meta = me.getDatasetMeta(datasetIndex); + var anims = meta.controller._resolveAnimations(undefined, mode); + me.setDatasetVisibility(datasetIndex, visible); + anims.update(meta, { + visible + }); + me.update(ctx => ctx.datasetIndex === datasetIndex ? mode : undefined); + } + hide(datasetIndex) { + this._updateDatasetVisibility(datasetIndex, false); + } + show(datasetIndex) { + this._updateDatasetVisibility(datasetIndex, true); + } + _destroyDatasetMeta(datasetIndex) { + var me = this; + var meta = me._metasets && me._metasets[datasetIndex]; + if (meta) { + meta.controller._destroy(); + delete me._metasets[datasetIndex]; + } + } + destroy() { + var me = this; + var canvas = me.canvas; + var i, ilen; + me.stop(); + Animator$1.remove(me); + for (i = 0, ilen = me.data.datasets.length; i < ilen; ++i) { + me._destroyDatasetMeta(i); + } + if (canvas) { + me.unbindEvents(); + helpers.canvas.clear(me); + me.platform.releaseContext(me.ctx); + me.canvas = null; + me.ctx = null; + } + pluginsCore.notify(me, 'destroy'); + delete Chart.instances[me.id]; + } + toBase64Image() { + return this.canvas.toDataURL(...arguments); + } + bindEvents() { + var me = this; + var listeners = me._listeners; + var listener = function listener(e) { + me._eventHandler(e); + }; + helpers.each(me.options.events, type => { + me.platform.addEventListener(me, type, listener); + listeners[type] = listener; + }); + if (me.options.responsive) { + listener = function listener(width, height) { + if (me.canvas) { + me.resize(false, width, height); + } + }; + me.platform.addEventListener(me, 'resize', listener); + listeners.resize = listener; + } + } + unbindEvents() { + var me = this; + var listeners = me._listeners; + if (!listeners) { + return; + } + delete me._listeners; + helpers.each(listeners, (listener, type) => { + me.platform.removeEventListener(me, type, listener); + }); + } + updateHoverStyle(items, mode, enabled) { + var prefix = enabled ? 'set' : 'remove'; + var meta, item, i, ilen; + if (mode === 'dataset') { + meta = this.getDatasetMeta(items[0].datasetIndex); + meta.controller['_' + prefix + 'DatasetHoverStyle'](); + } + for (i = 0, ilen = items.length; i < ilen; ++i) { + item = items[i]; + if (item) { + this.getDatasetMeta(item.datasetIndex).controller[prefix + 'HoverStyle'](item.element, item.datasetIndex, item.index); + } + } + } + _updateHoverStyles() { + var me = this; + var options = me.options || {}; + var hoverOptions = options.hover; + if (me.lastActive.length) { + me.updateHoverStyle(me.lastActive, hoverOptions.mode, false); + } + if (me.active.length && hoverOptions.mode) { + me.updateHoverStyle(me.active, hoverOptions.mode, true); + } + } + _eventHandler(e, replay) { + var me = this; + if (pluginsCore.notify(me, 'beforeEvent', [e, replay]) === false) { + return; + } + me._handleEvent(e, replay); + pluginsCore.notify(me, 'afterEvent', [e, replay]); + me.render(); + return me; + } + _handleEvent(e, replay) { + var me = this; + var options = me.options; + var hoverOptions = options.hover; + var useFinalPosition = replay; + var changed = false; + if (e.type === 'mouseout') { + me.active = []; + me._lastEvent = null; + } else { + me.active = me.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions, useFinalPosition); + me._lastEvent = e.type === 'click' ? me._lastEvent : e; + } + helpers.callback(options.onHover || options.hover.onHover, [e.native, me.active], me); + if (e.type === 'mouseup' || e.type === 'click') { + if (options.onClick && helpers.canvas._isPointInArea(e, me.chartArea)) { + options.onClick.call(me, e.native, me.active); + } + } + changed = !helpers._elementsEqual(me.active, me.lastActive); + if (changed || replay) { + me._updateHoverStyles(); + } + me.lastActive = me.active; + return changed; + } +} +_defineProperty(Chart, "version", version); +_defineProperty(Chart, "instances", {}); + +function abstract() { + throw new Error('This method is not implemented: either no adapter can be found or an incomplete integration was provided.'); +} +class DateAdapter { + constructor(options) { + this.options = options || {}; + } + formats() { + return abstract(); + } + parse(value, format) { + return abstract(); + } + format(timestamp, format) { + return abstract(); + } + add(timestamp, amount, unit) { + return abstract(); + } + diff(a, b, unit) { + return abstract(); + } + startOf(timestamp, unit, weekday) { + return abstract(); + } + endOf(timestamp, unit) { + return abstract(); + } +} +DateAdapter.override = function (members) { + _extends(DateAdapter.prototype, members); +}; +var _adapters = { + _date: DateAdapter +}; + +var formatters = { + values(value) { + return isArray(value) ? value : '' + value; + }, + numeric(tickValue, index, ticks) { + if (tickValue === 0) { + return '0'; + } + var delta = ticks.length > 3 ? ticks[2].value - ticks[1].value : ticks[1].value - ticks[0].value; + if (Math.abs(delta) > 1 && tickValue !== Math.floor(tickValue)) { + delta = tickValue - Math.floor(tickValue); + } + var logDelta = log10(Math.abs(delta)); + var maxTick = Math.max(Math.abs(ticks[0].value), Math.abs(ticks[ticks.length - 1].value)); + var minTick = Math.min(Math.abs(ticks[0].value), Math.abs(ticks[ticks.length - 1].value)); + var locale = this.chart.options.locale; + if (maxTick < 1e-4 || minTick > 1e+7) { + var logTick = log10(Math.abs(tickValue)); + var numExponential = Math.floor(logTick) - Math.floor(logDelta); + numExponential = Math.max(Math.min(numExponential, 20), 0); + return tickValue.toExponential(numExponential); + } + var numDecimal = -1 * Math.floor(logDelta); + numDecimal = Math.max(Math.min(numDecimal, 20), 0); + return new Intl.NumberFormat(locale, { + minimumFractionDigits: numDecimal, + maximumFractionDigits: numDecimal + }).format(tickValue); + } +}; +formatters.logarithmic = function (tickValue, index, ticks) { + if (tickValue === 0) { + return '0'; + } + var remain = tickValue / Math.pow(10, Math.floor(log10(tickValue))); + if (remain === 1 || remain === 2 || remain === 5) { + return formatters.numeric.call(this, tickValue, index, ticks); + } + return ''; +}; +var Ticks = { + formatters +}; + +defaults.set('scale', { + display: true, + offset: false, + reverse: false, + beginAtZero: false, + gridLines: { + display: true, + color: 'rgba(0,0,0,0.1)', + lineWidth: 1, + drawBorder: true, + drawOnChartArea: true, + drawTicks: true, + tickMarkLength: 10, + offsetGridLines: false, + borderDash: [], + borderDashOffset: 0.0 + }, + scaleLabel: { + display: false, + labelString: '', + padding: { + top: 4, + bottom: 4 + } + }, + ticks: { + minRotation: 0, + maxRotation: 50, + mirror: false, + lineWidth: 0, + strokeStyle: '', + padding: 0, + display: true, + autoSkip: true, + autoSkipPadding: 0, + labelOffset: 0, + callback: Ticks.formatters.values, + minor: {}, + major: {} + } +}); +function sample(arr, numItems) { + var result = []; + var increment = arr.length / numItems; + var len = arr.length; + var i = 0; + for (; i < len; i += increment) { + result.push(arr[Math.floor(i)]); + } + return result; +} +function getPixelForGridLine(scale, index, offsetGridLines) { + var length = scale.ticks.length; + var validIndex = Math.min(index, length - 1); + var start = scale._startPixel; + var end = scale._endPixel; + var epsilon = 1e-6; + var lineValue = scale.getPixelForTick(validIndex); + var offset; + if (offsetGridLines) { + if (length === 1) { + offset = Math.max(lineValue - start, end - lineValue); + } else if (index === 0) { + offset = (scale.getPixelForTick(1) - lineValue) / 2; + } else { + offset = (lineValue - scale.getPixelForTick(validIndex - 1)) / 2; + } + lineValue += validIndex < index ? offset : -offset; + if (lineValue < start - epsilon || lineValue > end + epsilon) { + return; + } + } + return lineValue; +} +function garbageCollect(caches, length) { + each(caches, cache => { + var gc = cache.gc; + var gcLen = gc.length / 2; + var i; + if (gcLen > length) { + for (i = 0; i < gcLen; ++i) { + delete cache.data[gc[i]]; + } + gc.splice(0, gcLen); + } + }); +} +function getTickMarkLength(options) { + return options.drawTicks ? options.tickMarkLength : 0; +} +function getScaleLabelHeight(options) { + if (!options.display) { + return 0; + } + var font = _parseFont(options); + var padding = toPadding(options.padding); + return font.lineHeight + padding.height; +} +function getEvenSpacing(arr) { + var len = arr.length; + var i, diff; + if (len < 2) { + return false; + } + for (diff = arr[0], i = 1; i < len; ++i) { + if (arr[i] - arr[i - 1] !== diff) { + return false; + } + } + return diff; +} +function calculateSpacing(majorIndices, ticks, ticksLimit) { + var evenMajorSpacing = getEvenSpacing(majorIndices); + var spacing = ticks.length / ticksLimit; + if (!evenMajorSpacing) { + return Math.max(spacing, 1); + } + var factors = _factorize(evenMajorSpacing); + for (var i = 0, ilen = factors.length - 1; i < ilen; i++) { + var factor = factors[i]; + if (factor > spacing) { + return factor; + } + } + return Math.max(spacing, 1); +} +function getMajorIndices(ticks) { + var result = []; + var i, ilen; + for (i = 0, ilen = ticks.length; i < ilen; i++) { + if (ticks[i].major) { + result.push(i); + } + } + return result; +} +function skipMajors(ticks, newTicks, majorIndices, spacing) { + var count = 0; + var next = majorIndices[0]; + var i; + spacing = Math.ceil(spacing); + for (i = 0; i < ticks.length; i++) { + if (i === next) { + newTicks.push(ticks[i]); + count++; + next = majorIndices[count * spacing]; + } + } +} +function skip(ticks, newTicks, spacing, majorStart, majorEnd) { + var start = valueOrDefault(majorStart, 0); + var end = Math.min(valueOrDefault(majorEnd, ticks.length), ticks.length); + var count = 0; + var length, i, next; + spacing = Math.ceil(spacing); + if (majorEnd) { + length = majorEnd - majorStart; + spacing = length / Math.floor(length / spacing); + } + next = start; + while (next < 0) { + count++; + next = Math.round(start + count * spacing); + } + for (i = Math.max(start, 0); i < end; i++) { + if (i === next) { + newTicks.push(ticks[i]); + count++; + next = Math.round(start + count * spacing); + } + } +} +class Scale extends Element { + constructor(cfg) { + super(); + this.id = cfg.id; + this.type = cfg.type; + this.options = cfg.options; + this.ctx = cfg.ctx; + this.chart = cfg.chart; + this.top = undefined; + this.bottom = undefined; + this.left = undefined; + this.right = undefined; + this.width = undefined; + this.height = undefined; + this._margins = { + left: 0, + right: 0, + top: 0, + bottom: 0 + }; + this.maxWidth = undefined; + this.maxHeight = undefined; + this.paddingTop = undefined; + this.paddingBottom = undefined; + this.paddingLeft = undefined; + this.paddingRight = undefined; + this.axis = undefined; + this.labelRotation = undefined; + this.min = undefined; + this.max = undefined; + this.ticks = []; + this._gridLineItems = null; + this._labelItems = null; + this._labelSizes = null; + this._length = 0; + this._longestTextCache = {}; + this._startPixel = undefined; + this._endPixel = undefined; + this._reversePixels = false; + this._userMax = undefined; + this._userMin = undefined; + this._ticksLength = 0; + this._borderValue = 0; + } + parse(raw, index) { + return raw; + } + parseObject(obj, axis, index) { + if (obj[axis] !== undefined) { + return this.parse(obj[axis], index); + } + return null; + } + getUserBounds() { + var min = this._userMin; + var max = this._userMax; + if (isNullOrUndef(min) || isNaN(min)) { + min = Number.POSITIVE_INFINITY; + } + if (isNullOrUndef(max) || isNaN(max)) { + max = Number.NEGATIVE_INFINITY; + } + return { + min, + max, + minDefined: isNumberFinite(min), + maxDefined: isNumberFinite(max) + }; + } + getMinMax(canStack) { + var me = this; + var { + min, + max, + minDefined, + maxDefined + } = me.getUserBounds(); + var minmax; + if (minDefined && maxDefined) { + return { + min, + max + }; + } + var metas = me.getMatchingVisibleMetas(); + for (var i = 0, ilen = metas.length; i < ilen; ++i) { + minmax = metas[i].controller.getMinMax(me, canStack); + if (!minDefined) { + min = Math.min(min, minmax.min); + } + if (!maxDefined) { + max = Math.max(max, minmax.max); + } + } + return { + min, + max + }; + } + invalidateCaches() {} + getPadding() { + var me = this; + return { + left: me.paddingLeft || 0, + top: me.paddingTop || 0, + right: me.paddingRight || 0, + bottom: me.paddingBottom || 0 + }; + } + getTicks() { + return this.ticks; + } + getLabels() { + var data = this.chart.data; + return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels || []; + } + beforeUpdate() { + callback(this.options.beforeUpdate, [this]); + } + update(maxWidth, maxHeight, margins) { + var me = this; + var tickOpts = me.options.ticks; + var sampleSize = tickOpts.sampleSize; + me.beforeUpdate(); + me.maxWidth = maxWidth; + me.maxHeight = maxHeight; + me._margins = _extends({ + left: 0, + right: 0, + top: 0, + bottom: 0 + }, margins); + me.ticks = null; + me._labelSizes = null; + me._gridLineItems = null; + me._labelItems = null; + me.beforeSetDimensions(); + me.setDimensions(); + me.afterSetDimensions(); + me.beforeDataLimits(); + me.determineDataLimits(); + me.afterDataLimits(); + me.beforeBuildTicks(); + me.ticks = me.buildTicks() || []; + me.afterBuildTicks(); + var samplingEnabled = sampleSize < me.ticks.length; + me._convertTicksToLabels(samplingEnabled ? sample(me.ticks, sampleSize) : me.ticks); + me.configure(); + me.beforeCalculateLabelRotation(); + me.calculateLabelRotation(); + me.afterCalculateLabelRotation(); + me.beforeFit(); + me.fit(); + me.afterFit(); + me.ticks = tickOpts.display && (tickOpts.autoSkip || tickOpts.source === 'auto') ? me._autoSkip(me.ticks) : me.ticks; + if (samplingEnabled) { + me._convertTicksToLabels(me.ticks); + } + me.afterUpdate(); + } + configure() { + var me = this; + var reversePixels = me.options.reverse; + var startPixel, endPixel; + if (me.isHorizontal()) { + startPixel = me.left; + endPixel = me.right; + } else { + startPixel = me.top; + endPixel = me.bottom; + reversePixels = !reversePixels; + } + me._startPixel = startPixel; + me._endPixel = endPixel; + me._reversePixels = reversePixels; + me._length = endPixel - startPixel; + } + afterUpdate() { + callback(this.options.afterUpdate, [this]); + } + beforeSetDimensions() { + callback(this.options.beforeSetDimensions, [this]); + } + setDimensions() { + var me = this; + if (me.isHorizontal()) { + me.width = me.maxWidth; + me.left = 0; + me.right = me.width; + } else { + me.height = me.maxHeight; + me.top = 0; + me.bottom = me.height; + } + me.paddingLeft = 0; + me.paddingTop = 0; + me.paddingRight = 0; + me.paddingBottom = 0; + } + afterSetDimensions() { + callback(this.options.afterSetDimensions, [this]); + } + beforeDataLimits() { + callback(this.options.beforeDataLimits, [this]); + } + determineDataLimits() {} + afterDataLimits() { + callback(this.options.afterDataLimits, [this]); + } + beforeBuildTicks() { + callback(this.options.beforeBuildTicks, [this]); + } + buildTicks() { + return []; + } + afterBuildTicks() { + callback(this.options.afterBuildTicks, [this]); + } + beforeTickToLabelConversion() { + callback(this.options.beforeTickToLabelConversion, [this]); + } + generateTickLabels(ticks) { + var me = this; + var tickOpts = me.options.ticks; + var i, ilen, tick; + for (i = 0, ilen = ticks.length; i < ilen; i++) { + tick = ticks[i]; + tick.label = callback(tickOpts.callback, [tick.value, i, ticks], me); + } + } + afterTickToLabelConversion() { + callback(this.options.afterTickToLabelConversion, [this]); + } + beforeCalculateLabelRotation() { + callback(this.options.beforeCalculateLabelRotation, [this]); + } + calculateLabelRotation() { + var me = this; + var options = me.options; + var tickOpts = options.ticks; + var numTicks = me.ticks.length; + var minRotation = tickOpts.minRotation || 0; + var maxRotation = tickOpts.maxRotation; + var labelRotation = minRotation; + var tickWidth, maxHeight, maxLabelDiagonal; + if (!me._isVisible() || !tickOpts.display || minRotation >= maxRotation || numTicks <= 1 || !me.isHorizontal()) { + me.labelRotation = minRotation; + return; + } + var labelSizes = me._getLabelSizes(); + var maxLabelWidth = labelSizes.widest.width; + var maxLabelHeight = labelSizes.highest.height - labelSizes.highest.offset; + var maxWidth = Math.min(me.maxWidth, me.chart.width - maxLabelWidth); + tickWidth = options.offset ? me.maxWidth / numTicks : maxWidth / (numTicks - 1); + if (maxLabelWidth + 6 > tickWidth) { + tickWidth = maxWidth / (numTicks - (options.offset ? 0.5 : 1)); + maxHeight = me.maxHeight - getTickMarkLength(options.gridLines) - tickOpts.padding - getScaleLabelHeight(options.scaleLabel); + maxLabelDiagonal = Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight); + labelRotation = toDegrees(Math.min(Math.asin(Math.min((labelSizes.highest.height + 6) / tickWidth, 1)), Math.asin(Math.min(maxHeight / maxLabelDiagonal, 1)) - Math.asin(maxLabelHeight / maxLabelDiagonal))); + labelRotation = Math.max(minRotation, Math.min(maxRotation, labelRotation)); + } + me.labelRotation = labelRotation; + } + afterCalculateLabelRotation() { + callback(this.options.afterCalculateLabelRotation, [this]); + } + beforeFit() { + callback(this.options.beforeFit, [this]); + } + fit() { + var me = this; + var minSize = { + width: 0, + height: 0 + }; + var chart = me.chart; + var opts = me.options; + var tickOpts = opts.ticks; + var scaleLabelOpts = opts.scaleLabel; + var gridLineOpts = opts.gridLines; + var display = me._isVisible(); + var labelsBelowTicks = opts.position !== 'top' && me.axis === 'x'; + var isHorizontal = me.isHorizontal(); + if (isHorizontal) { + minSize.width = me.maxWidth; + } else if (display) { + minSize.width = getTickMarkLength(gridLineOpts) + getScaleLabelHeight(scaleLabelOpts); + } + if (!isHorizontal) { + minSize.height = me.maxHeight; + } else if (display) { + minSize.height = getTickMarkLength(gridLineOpts) + getScaleLabelHeight(scaleLabelOpts); + } + if (tickOpts.display && display && me.ticks.length) { + var labelSizes = me._getLabelSizes(); + var firstLabelSize = labelSizes.first; + var lastLabelSize = labelSizes.last; + var widestLabelSize = labelSizes.widest; + var highestLabelSize = labelSizes.highest; + var lineSpace = highestLabelSize.offset * 0.8; + var tickPadding = tickOpts.padding; + if (isHorizontal) { + var isRotated = me.labelRotation !== 0; + var angleRadians = toRadians(me.labelRotation); + var cosRotation = Math.cos(angleRadians); + var sinRotation = Math.sin(angleRadians); + var labelHeight = sinRotation * widestLabelSize.width + cosRotation * (highestLabelSize.height - (isRotated ? highestLabelSize.offset : 0)) + (isRotated ? 0 : lineSpace); + minSize.height = Math.min(me.maxHeight, minSize.height + labelHeight + tickPadding); + var offsetLeft = me.getPixelForTick(0) - me.left; + var offsetRight = me.right - me.getPixelForTick(me.ticks.length - 1); + var paddingLeft, paddingRight; + if (isRotated) { + paddingLeft = labelsBelowTicks ? cosRotation * firstLabelSize.width + sinRotation * firstLabelSize.offset : sinRotation * (firstLabelSize.height - firstLabelSize.offset); + paddingRight = labelsBelowTicks ? sinRotation * (lastLabelSize.height - lastLabelSize.offset) : cosRotation * lastLabelSize.width + sinRotation * lastLabelSize.offset; + } else { + paddingLeft = firstLabelSize.width / 2; + paddingRight = lastLabelSize.width / 2; + } + me.paddingLeft = Math.max((paddingLeft - offsetLeft) * me.width / (me.width - offsetLeft), 0) + 3; + me.paddingRight = Math.max((paddingRight - offsetRight) * me.width / (me.width - offsetRight), 0) + 3; + } else { + var labelWidth = tickOpts.mirror ? 0 : + widestLabelSize.width + tickPadding + lineSpace; + minSize.width = Math.min(me.maxWidth, minSize.width + labelWidth); + me.paddingTop = firstLabelSize.height / 2; + me.paddingBottom = lastLabelSize.height / 2; + } + } + me._handleMargins(); + if (isHorizontal) { + me.width = me._length = chart.width - me._margins.left - me._margins.right; + me.height = minSize.height; + } else { + me.width = minSize.width; + me.height = me._length = chart.height - me._margins.top - me._margins.bottom; + } + } + _handleMargins() { + var me = this; + if (me._margins) { + me._margins.left = Math.max(me.paddingLeft, me._margins.left); + me._margins.top = Math.max(me.paddingTop, me._margins.top); + me._margins.right = Math.max(me.paddingRight, me._margins.right); + me._margins.bottom = Math.max(me.paddingBottom, me._margins.bottom); + } + } + afterFit() { + callback(this.options.afterFit, [this]); + } + isHorizontal() { + var { + axis, + position + } = this.options; + return position === 'top' || position === 'bottom' || axis === 'x'; + } + isFullWidth() { + return this.options.fullWidth; + } + _convertTicksToLabels(ticks) { + var me = this; + me.beforeTickToLabelConversion(); + me.generateTickLabels(ticks); + me.afterTickToLabelConversion(); + } + _getLabelSizes() { + var me = this; + var labelSizes = me._labelSizes; + if (!labelSizes) { + me._labelSizes = labelSizes = me._computeLabelSizes(); + } + return labelSizes; + } + _computeLabelSizes() { + var me = this; + var ctx = me.ctx; + var caches = me._longestTextCache; + var sampleSize = me.options.ticks.sampleSize; + var widths = []; + var heights = []; + var offsets = []; + var ticks = me.ticks; + if (sampleSize < ticks.length) { + ticks = sample(ticks, sampleSize); + } + var length = ticks.length; + var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, height, nestedLabel; + for (i = 0; i < length; ++i) { + label = ticks[i].label; + tickFont = me._resolveTickFontOptions(i); + ctx.font = fontString = tickFont.string; + cache = caches[fontString] = caches[fontString] || { + data: {}, + gc: [] + }; + lineHeight = tickFont.lineHeight; + width = height = 0; + if (!isNullOrUndef(label) && !isArray(label)) { + width = _measureText(ctx, cache.data, cache.gc, width, label); + height = lineHeight; + } else if (isArray(label)) { + for (j = 0, jlen = label.length; j < jlen; ++j) { + nestedLabel = label[j]; + if (!isNullOrUndef(nestedLabel) && !isArray(nestedLabel)) { + width = _measureText(ctx, cache.data, cache.gc, width, nestedLabel); + height += lineHeight; + } + } + } + widths.push(width); + heights.push(height); + offsets.push(lineHeight / 2); + } + garbageCollect(caches, length); + var widest = widths.indexOf(Math.max.apply(null, widths)); + var highest = heights.indexOf(Math.max.apply(null, heights)); + function valueAt(idx) { + return { + width: widths[idx] || 0, + height: heights[idx] || 0, + offset: offsets[idx] || 0 + }; + } + return { + first: valueAt(0), + last: valueAt(length - 1), + widest: valueAt(widest), + highest: valueAt(highest) + }; + } + getLabelForValue(value) { + return value; + } + getPixelForValue(value) { + return NaN; + } + getValueForPixel(pixel) {} + getPixelForTick(index) { + var ticks = this.ticks; + if (index < 0 || index > ticks.length - 1) { + return null; + } + return this.getPixelForValue(ticks[index].value); + } + getPixelForDecimal(decimal) { + var me = this; + if (me._reversePixels) { + decimal = 1 - decimal; + } + return me._startPixel + decimal * me._length; + } + getDecimalForPixel(pixel) { + var decimal = (pixel - this._startPixel) / this._length; + return this._reversePixels ? 1 - decimal : decimal; + } + getBasePixel() { + return this.getPixelForValue(this.getBaseValue()); + } + getBaseValue() { + var { + min, + max + } = this; + return min < 0 && max < 0 ? max : min > 0 && max > 0 ? min : 0; + } + _autoSkip(ticks) { + var me = this; + var tickOpts = me.options.ticks; + var ticksLimit = tickOpts.maxTicksLimit || me._length / me._tickSize(); + var majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : []; + var numMajorIndices = majorIndices.length; + var first = majorIndices[0]; + var last = majorIndices[numMajorIndices - 1]; + var newTicks = []; + if (numMajorIndices > ticksLimit) { + skipMajors(ticks, newTicks, majorIndices, numMajorIndices / ticksLimit); + return newTicks; + } + var spacing = calculateSpacing(majorIndices, ticks, ticksLimit); + if (numMajorIndices > 0) { + var i, ilen; + var avgMajorSpacing = numMajorIndices > 1 ? Math.round((last - first) / (numMajorIndices - 1)) : null; + skip(ticks, newTicks, spacing, isNullOrUndef(avgMajorSpacing) ? 0 : first - avgMajorSpacing, first); + for (i = 0, ilen = numMajorIndices - 1; i < ilen; i++) { + skip(ticks, newTicks, spacing, majorIndices[i], majorIndices[i + 1]); + } + skip(ticks, newTicks, spacing, last, isNullOrUndef(avgMajorSpacing) ? ticks.length : last + avgMajorSpacing); + return newTicks; + } + skip(ticks, newTicks, spacing); + return newTicks; + } + _tickSize() { + var me = this; + var optionTicks = me.options.ticks; + var rot = toRadians(me.labelRotation); + var cos = Math.abs(Math.cos(rot)); + var sin = Math.abs(Math.sin(rot)); + var labelSizes = me._getLabelSizes(); + var padding = optionTicks.autoSkipPadding || 0; + var w = labelSizes ? labelSizes.widest.width + padding : 0; + var h = labelSizes ? labelSizes.highest.height + padding : 0; + return me.isHorizontal() ? h * cos > w * sin ? w / cos : h / sin : h * sin < w * cos ? h / cos : w / sin; + } + _isVisible() { + var display = this.options.display; + if (display !== 'auto') { + return !!display; + } + return this.getMatchingVisibleMetas().length > 0; + } + _computeGridLineItems(chartArea) { + var me = this; + var axis = me.axis; + var chart = me.chart; + var options = me.options; + var { + gridLines, + position + } = options; + var offsetGridLines = gridLines.offsetGridLines; + var isHorizontal = me.isHorizontal(); + var ticks = me.ticks; + var ticksLength = ticks.length + (offsetGridLines ? 1 : 0); + var tl = getTickMarkLength(gridLines); + var items = []; + var context = { + scale: me, + tick: ticks[0] + }; + var axisWidth = gridLines.drawBorder ? resolve([gridLines.borderWidth, gridLines.lineWidth, 0], context, 0) : 0; + var axisHalfWidth = axisWidth / 2; + var alignBorderValue = function alignBorderValue(pixel) { + return _alignPixel(chart, pixel, axisWidth); + }; + var borderValue, i, lineValue, alignedLineValue; + var tx1, ty1, tx2, ty2, x1, y1, x2, y2; + if (position === 'top') { + borderValue = alignBorderValue(me.bottom); + ty1 = me.bottom - tl; + ty2 = borderValue - axisHalfWidth; + y1 = alignBorderValue(chartArea.top) + axisHalfWidth; + y2 = chartArea.bottom; + } else if (position === 'bottom') { + borderValue = alignBorderValue(me.top); + y1 = chartArea.top; + y2 = alignBorderValue(chartArea.bottom) - axisHalfWidth; + ty1 = borderValue + axisHalfWidth; + ty2 = me.top + tl; + } else if (position === 'left') { + borderValue = alignBorderValue(me.right); + tx1 = me.right - tl; + tx2 = borderValue - axisHalfWidth; + x1 = alignBorderValue(chartArea.left) + axisHalfWidth; + x2 = chartArea.right; + } else if (position === 'right') { + borderValue = alignBorderValue(me.left); + x1 = chartArea.left; + x2 = alignBorderValue(chartArea.right) - axisHalfWidth; + tx1 = borderValue + axisHalfWidth; + tx2 = me.left + tl; + } else if (axis === 'x') { + if (position === 'center') { + borderValue = alignBorderValue((chartArea.top + chartArea.bottom) / 2); + } else if (isObject(position)) { + var positionAxisID = Object.keys(position)[0]; + var value = position[positionAxisID]; + borderValue = alignBorderValue(me.chart.scales[positionAxisID].getPixelForValue(value)); + } + y1 = chartArea.top; + y2 = chartArea.bottom; + ty1 = borderValue + axisHalfWidth; + ty2 = ty1 + tl; + } else if (axis === 'y') { + if (position === 'center') { + borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2); + } else if (isObject(position)) { + var _positionAxisID = Object.keys(position)[0]; + var _value = position[_positionAxisID]; + borderValue = alignBorderValue(me.chart.scales[_positionAxisID].getPixelForValue(_value)); + } + tx1 = borderValue - axisHalfWidth; + tx2 = tx1 - tl; + x1 = chartArea.left; + x2 = chartArea.right; + } + for (i = 0; i < ticksLength; ++i) { + var tick = ticks[i] || {}; + context = { + scale: me, + tick + }; + var lineWidth = resolve([gridLines.lineWidth], context, i); + var lineColor = resolve([gridLines.color], context, i); + var borderDash = gridLines.borderDash || []; + var borderDashOffset = resolve([gridLines.borderDashOffset], context, i); + lineValue = getPixelForGridLine(me, i, offsetGridLines); + if (lineValue === undefined) { + continue; + } + alignedLineValue = _alignPixel(chart, lineValue, lineWidth); + if (isHorizontal) { + tx1 = tx2 = x1 = x2 = alignedLineValue; + } else { + ty1 = ty2 = y1 = y2 = alignedLineValue; + } + items.push({ + tx1, + ty1, + tx2, + ty2, + x1, + y1, + x2, + y2, + width: lineWidth, + color: lineColor, + borderDash, + borderDashOffset + }); + } + me._ticksLength = ticksLength; + me._borderValue = borderValue; + return items; + } + _computeLabelItems(chartArea) { + var me = this; + var axis = me.axis; + var options = me.options; + var { + position, + ticks: optionTicks + } = options; + var isMirrored = optionTicks.mirror; + var isHorizontal = me.isHorizontal(); + var ticks = me.ticks; + var tickPadding = optionTicks.padding; + var tl = getTickMarkLength(options.gridLines); + var rotation = -toRadians(me.labelRotation); + var items = []; + var i, ilen, tick, label, x, y, textAlign, pixel, font, lineHeight, lineCount, textOffset; + if (position === 'top') { + y = me.bottom - tl - tickPadding; + textAlign = !rotation ? 'center' : 'left'; + } else if (position === 'bottom') { + y = me.top + tl + tickPadding; + textAlign = !rotation ? 'center' : 'right'; + } else if (position === 'left') { + x = me.right - (isMirrored ? 0 : tl) - tickPadding; + textAlign = isMirrored ? 'left' : 'right'; + } else if (position === 'right') { + x = me.left + (isMirrored ? 0 : tl) + tickPadding; + textAlign = isMirrored ? 'right' : 'left'; + } else if (axis === 'x') { + if (position === 'center') { + y = (chartArea.top + chartArea.bottom) / 2 + tl + tickPadding; + } else if (isObject(position)) { + var positionAxisID = Object.keys(position)[0]; + var value = position[positionAxisID]; + y = me.chart.scales[positionAxisID].getPixelForValue(value) + tl + tickPadding; + } + textAlign = !rotation ? 'center' : 'right'; + } else if (axis === 'y') { + if (position === 'center') { + x = (chartArea.left + chartArea.right) / 2 - tl - tickPadding; + } else if (isObject(position)) { + var _positionAxisID2 = Object.keys(position)[0]; + var _value2 = position[_positionAxisID2]; + x = me.chart.scales[_positionAxisID2].getPixelForValue(_value2); + } + textAlign = 'right'; + } + for (i = 0, ilen = ticks.length; i < ilen; ++i) { + tick = ticks[i]; + label = tick.label; + pixel = me.getPixelForTick(i) + optionTicks.labelOffset; + font = me._resolveTickFontOptions(i); + lineHeight = font.lineHeight; + lineCount = isArray(label) ? label.length : 1; + if (isHorizontal) { + x = pixel; + if (position === 'top') { + textOffset = (Math.sin(rotation) * (lineCount / 2) + 0.5) * lineHeight; + textOffset -= (rotation === 0 ? lineCount - 0.5 : Math.cos(rotation) * (lineCount / 2)) * lineHeight; + } else { + textOffset = Math.sin(rotation) * (lineCount / 2) * lineHeight; + textOffset += (rotation === 0 ? 0.5 : Math.cos(rotation) * (lineCount / 2)) * lineHeight; + } + } else { + y = pixel; + textOffset = (1 - lineCount) * lineHeight / 2; + } + items.push({ + x, + y, + rotation, + label, + font, + textOffset, + textAlign + }); + } + return items; + } + drawGrid(chartArea) { + var me = this; + var gridLines = me.options.gridLines; + var ctx = me.ctx; + var chart = me.chart; + var context = { + scale: me, + tick: me.ticks[0] + }; + var axisWidth = gridLines.drawBorder ? resolve([gridLines.borderWidth, gridLines.lineWidth, 0], context, 0) : 0; + var items = me._gridLineItems || (me._gridLineItems = me._computeGridLineItems(chartArea)); + var i, ilen; + if (gridLines.display) { + for (i = 0, ilen = items.length; i < ilen; ++i) { + var item = items[i]; + var width = item.width; + var color = item.color; + if (width && color) { + ctx.save(); + ctx.lineWidth = width; + ctx.strokeStyle = color; + if (ctx.setLineDash) { + ctx.setLineDash(item.borderDash); + ctx.lineDashOffset = item.borderDashOffset; + } + ctx.beginPath(); + if (gridLines.drawTicks) { + ctx.moveTo(item.tx1, item.ty1); + ctx.lineTo(item.tx2, item.ty2); + } + if (gridLines.drawOnChartArea) { + ctx.moveTo(item.x1, item.y1); + ctx.lineTo(item.x2, item.y2); + } + ctx.stroke(); + ctx.restore(); + } + } + } + if (axisWidth) { + var firstLineWidth = axisWidth; + context = { + scale: me, + tick: me.ticks[me._ticksLength - 1] + }; + var lastLineWidth = resolve([gridLines.lineWidth, 1], context, me._ticksLength - 1); + var borderValue = me._borderValue; + var x1, x2, y1, y2; + if (me.isHorizontal()) { + x1 = _alignPixel(chart, me.left, firstLineWidth) - firstLineWidth / 2; + x2 = _alignPixel(chart, me.right, lastLineWidth) + lastLineWidth / 2; + y1 = y2 = borderValue; + } else { + y1 = _alignPixel(chart, me.top, firstLineWidth) - firstLineWidth / 2; + y2 = _alignPixel(chart, me.bottom, lastLineWidth) + lastLineWidth / 2; + x1 = x2 = borderValue; + } + ctx.lineWidth = axisWidth; + ctx.strokeStyle = resolve([gridLines.borderColor, gridLines.color], context, 0); + ctx.beginPath(); + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.stroke(); + } + } + drawLabels(chartArea) { + var me = this; + var optionTicks = me.options.ticks; + if (!optionTicks.display) { + return; + } + var ctx = me.ctx; + var items = me._labelItems || (me._labelItems = me._computeLabelItems(chartArea)); + var i, j, ilen, jlen; + for (i = 0, ilen = items.length; i < ilen; ++i) { + var item = items[i]; + var tickFont = item.font; + var useStroke = tickFont.lineWidth > 0 && tickFont.strokeStyle !== ''; + ctx.save(); + ctx.translate(item.x, item.y); + ctx.rotate(item.rotation); + ctx.font = tickFont.string; + ctx.fillStyle = tickFont.color; + ctx.textBaseline = 'middle'; + ctx.textAlign = item.textAlign; + if (useStroke) { + ctx.strokeStyle = tickFont.strokeStyle; + ctx.lineWidth = tickFont.lineWidth; + } + var label = item.label; + var y = item.textOffset; + if (isArray(label)) { + for (j = 0, jlen = label.length; j < jlen; ++j) { + if (useStroke) { + ctx.strokeText('' + label[j], 0, y); + } + ctx.fillText('' + label[j], 0, y); + y += tickFont.lineHeight; + } + } else { + if (useStroke) { + ctx.strokeText(label, 0, y); + } + ctx.fillText(label, 0, y); + } + ctx.restore(); + } + } + drawTitle(chartArea) { + var me = this; + var ctx = me.ctx; + var options = me.options; + var scaleLabel = options.scaleLabel; + if (!scaleLabel.display) { + return; + } + var scaleLabelFontColor = valueOrDefault(scaleLabel.fontColor, defaults.fontColor); + var scaleLabelFont = _parseFont(scaleLabel); + var scaleLabelPadding = toPadding(scaleLabel.padding); + var halfLineHeight = scaleLabelFont.lineHeight / 2; + var scaleLabelAlign = scaleLabel.align; + var position = options.position; + var isReverse = me.options.reverse; + var rotation = 0; + var textAlign; + var scaleLabelX, scaleLabelY; + if (me.isHorizontal()) { + switch (scaleLabelAlign) { + case 'start': + scaleLabelX = me.left + (isReverse ? me.width : 0); + textAlign = isReverse ? 'right' : 'left'; + break; + case 'end': + scaleLabelX = me.left + (isReverse ? 0 : me.width); + textAlign = isReverse ? 'left' : 'right'; + break; + default: + scaleLabelX = me.left + me.width / 2; + textAlign = 'center'; + } + scaleLabelY = position === 'top' ? me.top + halfLineHeight + scaleLabelPadding.top : me.bottom - halfLineHeight - scaleLabelPadding.bottom; + } else { + var isLeft = position === 'left'; + scaleLabelX = isLeft ? me.left + halfLineHeight + scaleLabelPadding.top : me.right - halfLineHeight - scaleLabelPadding.top; + switch (scaleLabelAlign) { + case 'start': + scaleLabelY = me.top + (isReverse ? 0 : me.height); + textAlign = isReverse === isLeft ? 'right' : 'left'; + break; + case 'end': + scaleLabelY = me.top + (isReverse ? me.height : 0); + textAlign = isReverse === isLeft ? 'left' : 'right'; + break; + default: + scaleLabelY = me.top + me.height / 2; + textAlign = 'center'; + } + rotation = isLeft ? -0.5 * Math.PI : 0.5 * Math.PI; + } + ctx.save(); + ctx.translate(scaleLabelX, scaleLabelY); + ctx.rotate(rotation); + ctx.textAlign = textAlign; + ctx.textBaseline = 'middle'; + ctx.fillStyle = scaleLabelFontColor; + ctx.font = scaleLabelFont.string; + ctx.fillText(scaleLabel.labelString, 0, 0); + ctx.restore(); + } + draw(chartArea) { + var me = this; + if (!me._isVisible()) { + return; + } + me.drawGrid(chartArea); + me.drawTitle(); + me.drawLabels(chartArea); + } + _layers() { + var me = this; + var opts = me.options; + var tz = opts.ticks && opts.ticks.z || 0; + var gz = opts.gridLines && opts.gridLines.z || 0; + if (!me._isVisible() || tz === gz || me.draw !== me._draw) { + return [{ + z: tz, + draw(chartArea) { + me.draw(chartArea); + } + }]; + } + return [{ + z: gz, + draw(chartArea) { + me.drawGrid(chartArea); + me.drawTitle(); + } + }, { + z: tz, + draw(chartArea) { + me.drawLabels(chartArea); + } + }]; + } + getMatchingVisibleMetas(type) { + var me = this; + var metas = me.chart.getSortedVisibleDatasetMetas(); + var axisID = me.axis + 'AxisID'; + var result = []; + var i, ilen; + for (i = 0, ilen = metas.length; i < ilen; ++i) { + var meta = metas[i]; + if (meta[axisID] === me.id && (!type || meta.type === type)) { + result.push(meta); + } + } + return result; + } + _resolveTickFontOptions(index) { + var me = this; + var options = me.options.ticks; + var context = { + chart: me.chart, + scale: me, + tick: me.ticks[index], + index + }; + return _extends(_parseFont({ + fontFamily: resolve([options.fontFamily], context), + fontSize: resolve([options.fontSize], context), + fontStyle: resolve([options.fontStyle], context), + lineHeight: resolve([options.lineHeight], context) + }), { + color: resolve([options.fontColor, defaults.fontColor], context), + lineWidth: resolve([options.lineWidth], context), + strokeStyle: resolve([options.strokeStyle], context) + }); + } +} +Scale.prototype._draw = Scale.prototype.draw; + +var defaultConfig = {}; +class CategoryScale extends Scale { + constructor(cfg) { + super(cfg); + this._numLabels = 0; + this._startValue = undefined; + this._valueRange = 0; + } + parse(raw, index) { + var labels = this.getLabels(); + if (labels[index] === raw) { + return index; + } + var first = labels.indexOf(raw); + var last = labels.lastIndexOf(raw); + return first === -1 || first !== last ? index : first; + } + determineDataLimits() { + var me = this; + var max = me.getLabels().length - 1; + me.min = Math.max(me._userMin || 0, 0); + me.max = Math.min(me._userMax || max, max); + } + buildTicks() { + var me = this; + var min = me.min; + var max = me.max; + var offset = me.options.offset; + var labels = me.getLabels(); + labels = min === 0 && max === labels.length - 1 ? labels : labels.slice(min, max + 1); + me._numLabels = labels.length; + me._valueRange = Math.max(labels.length - (offset ? 0 : 1), 1); + me._startValue = me.min - (offset ? 0.5 : 0); + return labels.map(l => ({ + value: l + })); + } + getLabelForValue(value) { + var me = this; + var labels = me.getLabels(); + if (value >= 0 && value < labels.length) { + return labels[value]; + } + return value; + } + configure() { + var me = this; + super.configure(); + if (!me.isHorizontal()) { + me._reversePixels = !me._reversePixels; + } + } + getPixelForValue(value) { + var me = this; + if (typeof value !== 'number') { + value = me.parse(value); + } + return me.getPixelForDecimal((value - me._startValue) / me._valueRange); + } + getPixelForTick(index) { + var me = this; + var ticks = me.ticks; + if (index < 0 || index > ticks.length - 1) { + return null; + } + return me.getPixelForValue(index * me._numLabels / ticks.length + me.min); + } + getValueForPixel(pixel) { + var me = this; + var value = Math.round(me._startValue + me.getDecimalForPixel(pixel) * me._valueRange); + return Math.min(Math.max(value, 0), me.ticks.length - 1); + } + getBasePixel() { + return this.bottom; + } +} +_defineProperty(CategoryScale, "id", 'category'); +_defineProperty(CategoryScale, "defaults", defaultConfig); + +function niceNum(range, round) { + var exponent = Math.floor(log10(range)); + var fraction = range / Math.pow(10, exponent); + var niceFraction; + if (round) { + if (fraction < 1.5) { + niceFraction = 1; + } else if (fraction < 3) { + niceFraction = 2; + } else if (fraction < 7) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } else if (fraction <= 1.0) { + niceFraction = 1; + } else if (fraction <= 2) { + niceFraction = 2; + } else if (fraction <= 5) { + niceFraction = 5; + } else { + niceFraction = 10; + } + return niceFraction * Math.pow(10, exponent); +} +function generateTicks(generationOptions, dataRange) { + var ticks = []; + var MIN_SPACING = 1e-14; + var { + stepSize, + min, + max, + precision + } = generationOptions; + var unit = stepSize || 1; + var maxNumSpaces = generationOptions.maxTicks - 1; + var { + min: rmin, + max: rmax + } = dataRange; + var spacing = niceNum((rmax - rmin) / maxNumSpaces / unit) * unit; + var factor, niceMin, niceMax, numSpaces; + if (spacing < MIN_SPACING && isNullOrUndef(min) && isNullOrUndef(max)) { + return [{ + value: rmin + }, { + value: rmax + }]; + } + numSpaces = Math.ceil(rmax / spacing) - Math.floor(rmin / spacing); + if (numSpaces > maxNumSpaces) { + spacing = niceNum(numSpaces * spacing / maxNumSpaces / unit) * unit; + } + if (stepSize || isNullOrUndef(precision)) { + factor = Math.pow(10, _decimalPlaces(spacing)); + } else { + factor = Math.pow(10, precision); + spacing = Math.ceil(spacing * factor) / factor; + } + niceMin = Math.floor(rmin / spacing) * spacing; + niceMax = Math.ceil(rmax / spacing) * spacing; + if (stepSize && !isNullOrUndef(min) && !isNullOrUndef(max)) { + if (almostWhole((max - min) / stepSize, spacing / 1000)) { + niceMin = min; + niceMax = max; + } + } + numSpaces = (niceMax - niceMin) / spacing; + if (almostEquals(numSpaces, Math.round(numSpaces), spacing / 1000)) { + numSpaces = Math.round(numSpaces); + } else { + numSpaces = Math.ceil(numSpaces); + } + niceMin = Math.round(niceMin * factor) / factor; + niceMax = Math.round(niceMax * factor) / factor; + ticks.push({ + value: isNullOrUndef(min) ? niceMin : min + }); + for (var j = 1; j < numSpaces; ++j) { + ticks.push({ + value: Math.round((niceMin + j * spacing) * factor) / factor + }); + } + ticks.push({ + value: isNullOrUndef(max) ? niceMax : max + }); + return ticks; +} +class LinearScaleBase extends Scale { + constructor(cfg) { + super(cfg); + this.start = undefined; + this.end = undefined; + this._startValue = undefined; + this._endValue = undefined; + this._valueRange = 0; + } + parse(raw, index) { + if (isNullOrUndef(raw)) { + return NaN; + } + if ((typeof raw === 'number' || raw instanceof Number) && !isFinite(+raw)) { + return NaN; + } + return +raw; + } + handleTickRangeOptions() { + var me = this; + var opts = me.options; + if (opts.beginAtZero) { + var minSign = sign(me.min); + var maxSign = sign(me.max); + if (minSign < 0 && maxSign < 0) { + me.max = 0; + } else if (minSign > 0 && maxSign > 0) { + me.min = 0; + } + } + var setMin = opts.min !== undefined || opts.suggestedMin !== undefined; + var setMax = opts.max !== undefined || opts.suggestedMax !== undefined; + if (opts.min !== undefined) { + me.min = opts.min; + } else if (opts.suggestedMin !== undefined) { + if (me.min === null) { + me.min = opts.suggestedMin; + } else { + me.min = Math.min(me.min, opts.suggestedMin); + } + } + if (opts.max !== undefined) { + me.max = opts.max; + } else if (opts.suggestedMax !== undefined) { + if (me.max === null) { + me.max = opts.suggestedMax; + } else { + me.max = Math.max(me.max, opts.suggestedMax); + } + } + if (setMin !== setMax) { + if (me.min >= me.max) { + if (setMin) { + me.max = me.min + 1; + } else { + me.min = me.max - 1; + } + } + } + if (me.min === me.max) { + me.max++; + if (!opts.beginAtZero) { + me.min--; + } + } + } + getTickLimit() { + var me = this; + var tickOpts = me.options.ticks; + var { + maxTicksLimit, + stepSize + } = tickOpts; + var maxTicks; + if (stepSize) { + maxTicks = Math.ceil(me.max / stepSize) - Math.floor(me.min / stepSize) + 1; + } else { + maxTicks = me.computeTickLimit(); + maxTicksLimit = maxTicksLimit || 11; + } + if (maxTicksLimit) { + maxTicks = Math.min(maxTicksLimit, maxTicks); + } + return maxTicks; + } + computeTickLimit() { + return Number.POSITIVE_INFINITY; + } + handleDirectionalChanges(ticks) { + return ticks; + } + buildTicks() { + var me = this; + var opts = me.options; + var tickOpts = opts.ticks; + var maxTicks = me.getTickLimit(); + maxTicks = Math.max(2, maxTicks); + var numericGeneratorOptions = { + maxTicks, + min: opts.min, + max: opts.max, + precision: tickOpts.precision, + stepSize: valueOrDefault(tickOpts.fixedStepSize, tickOpts.stepSize) + }; + var ticks = generateTicks(numericGeneratorOptions, me); + ticks = me.handleDirectionalChanges(ticks); + _setMinAndMaxByKey(ticks, me, 'value'); + if (opts.reverse) { + ticks.reverse(); + me.start = me.max; + me.end = me.min; + } else { + me.start = me.min; + me.end = me.max; + } + return ticks; + } + configure() { + var me = this; + var ticks = me.ticks; + var start = me.min; + var end = me.max; + super.configure(); + if (me.options.offset && ticks.length) { + var offset = (end - start) / Math.max(ticks.length - 1, 1) / 2; + start -= offset; + end += offset; + } + me._startValue = start; + me._endValue = end; + me._valueRange = end - start; + } + getLabelForValue(value) { + return new Intl.NumberFormat(this.options.locale).format(value); + } +} + +var defaultConfig$1 = { + ticks: { + callback: Ticks.formatters.numeric + } +}; +class LinearScale extends LinearScaleBase { + determineDataLimits() { + var me = this; + var options = me.options; + var minmax = me.getMinMax(true); + var min = minmax.min; + var max = minmax.max; + me.min = isNumberFinite(min) ? min : valueOrDefault(options.suggestedMin, 0); + me.max = isNumberFinite(max) ? max : valueOrDefault(options.suggestedMax, 1); + if (options.stacked && min > 0) { + me.min = 0; + } + me.handleTickRangeOptions(); + } + computeTickLimit() { + var me = this; + if (me.isHorizontal()) { + return Math.ceil(me.width / 40); + } + var tickFont = _parseFont(me.options.ticks); + return Math.ceil(me.height / tickFont.lineHeight); + } + handleDirectionalChanges(ticks) { + return this.isHorizontal() ? ticks : ticks.reverse(); + } + getPixelForValue(value) { + var me = this; + return me.getPixelForDecimal((value - me._startValue) / me._valueRange); + } + getValueForPixel(pixel) { + return this._startValue + this.getDecimalForPixel(pixel) * this._valueRange; + } +} +_defineProperty(LinearScale, "id", 'linear'); +_defineProperty(LinearScale, "defaults", defaultConfig$1); + +function isMajor(tickVal) { + var remain = tickVal / Math.pow(10, Math.floor(log10(tickVal))); + return remain === 1; +} +function finiteOrDefault(value, def) { + return isNumberFinite(value) ? value : def; +} +function generateTicks$1(generationOptions, dataRange) { + var endExp = Math.floor(log10(dataRange.max)); + var endSignificand = Math.ceil(dataRange.max / Math.pow(10, endExp)); + var ticks = []; + var tickVal = finiteOrDefault(generationOptions.min, Math.pow(10, Math.floor(log10(dataRange.min)))); + var exp = Math.floor(log10(tickVal)); + var significand = Math.floor(tickVal / Math.pow(10, exp)); + var precision = exp < 0 ? Math.pow(10, Math.abs(exp)) : 1; + do { + ticks.push({ + value: tickVal, + major: isMajor(tickVal) + }); + ++significand; + if (significand === 10) { + significand = 1; + ++exp; + precision = exp >= 0 ? 1 : precision; + } + tickVal = Math.round(significand * Math.pow(10, exp) * precision) / precision; + } while (exp < endExp || exp === endExp && significand < endSignificand); + var lastTick = finiteOrDefault(generationOptions.max, tickVal); + ticks.push({ + value: lastTick, + major: isMajor(tickVal) + }); + return ticks; +} +var defaultConfig$2 = { + ticks: { + callback: Ticks.formatters.logarithmic, + major: { + enabled: true + } + } +}; +class LogarithmicScale extends Scale { + constructor(cfg) { + super(cfg); + this.start = undefined; + this.end = undefined; + this._startValue = undefined; + this._valueRange = 0; + } + parse(raw, index) { + var value = LinearScaleBase.prototype.parse.apply(this, [raw, index]); + if (value === 0) { + return undefined; + } + return isNumberFinite(value) && value > 0 ? value : NaN; + } + determineDataLimits() { + var me = this; + var minmax = me.getMinMax(true); + var min = minmax.min; + var max = minmax.max; + me.min = isNumberFinite(min) ? Math.max(0, min) : null; + me.max = isNumberFinite(max) ? Math.max(0, max) : null; + me.handleTickRangeOptions(); + } + handleTickRangeOptions() { + var me = this; + var DEFAULT_MIN = 1; + var DEFAULT_MAX = 10; + var min = me.min; + var max = me.max; + if (min === max) { + if (min <= 0) { + min = DEFAULT_MIN; + max = DEFAULT_MAX; + } else { + min = Math.pow(10, Math.floor(log10(min)) - 1); + max = Math.pow(10, Math.floor(log10(max)) + 1); + } + } + if (min <= 0) { + min = Math.pow(10, Math.floor(log10(max)) - 1); + } + if (max <= 0) { + max = Math.pow(10, Math.floor(log10(min)) + 1); + } + me.min = min; + me.max = max; + } + buildTicks() { + var me = this; + var opts = me.options; + var generationOptions = { + min: me._userMin, + max: me._userMax + }; + var ticks = generateTicks$1(generationOptions, me); + var reverse = !me.isHorizontal(); + _setMinAndMaxByKey(ticks, me, 'value'); + if (opts.reverse) { + reverse = !reverse; + me.start = me.max; + me.end = me.min; + } else { + me.start = me.min; + me.end = me.max; + } + if (reverse) { + ticks.reverse(); + } + return ticks; + } + getLabelForValue(value) { + return value === undefined ? '0' : new Intl.NumberFormat(this.options.locale).format(value); + } + configure() { + var me = this; + var start = me.min; + super.configure(); + me._startValue = log10(start); + me._valueRange = log10(me.max) - log10(start); + } + getPixelForValue(value) { + var me = this; + if (value === undefined || value === 0) { + value = me.min; + } + return me.getPixelForDecimal(value === me.min ? 0 : (log10(value) - me._startValue) / me._valueRange); + } + getValueForPixel(pixel) { + var me = this; + var decimal = me.getDecimalForPixel(pixel); + return Math.pow(10, me._startValue + decimal * me._valueRange); + } +} +_defineProperty(LogarithmicScale, "id", 'logarithmic'); +_defineProperty(LogarithmicScale, "defaults", defaultConfig$2); + +var valueOrDefault$2 = helpers.valueOrDefault; +var valueAtIndexOrDefault$1 = helpers.valueAtIndexOrDefault; +var resolve$2 = helpers.options.resolve; +var defaultConfig$3 = { + display: true, + animate: true, + position: 'chartArea', + angleLines: { + display: true, + color: 'rgba(0,0,0,0.1)', + lineWidth: 1, + borderDash: [], + borderDashOffset: 0.0 + }, + gridLines: { + circular: false + }, + ticks: { + showLabelBackdrop: true, + backdropColor: 'rgba(255,255,255,0.75)', + backdropPaddingY: 2, + backdropPaddingX: 2, + callback: Ticks.formatters.numeric + }, + pointLabels: { + display: true, + fontSize: 10, + callback(label) { + return label; + } + } +}; +function getTickBackdropHeight(opts) { + var tickOpts = opts.ticks; + if (tickOpts.display && opts.display) { + return valueOrDefault$2(tickOpts.fontSize, defaults.fontSize) + tickOpts.backdropPaddingY * 2; + } + return 0; +} +function measureLabelSize(ctx, lineHeight, label) { + if (helpers.isArray(label)) { + return { + w: _longestText(ctx, ctx.font, label), + h: label.length * lineHeight + }; + } + return { + w: ctx.measureText(label).width, + h: lineHeight + }; +} +function determineLimits(angle, pos, size, min, max) { + if (angle === min || angle === max) { + return { + start: pos - size / 2, + end: pos + size / 2 + }; + } else if (angle < min || angle > max) { + return { + start: pos - size, + end: pos + }; + } + return { + start: pos, + end: pos + size + }; +} +function fitWithPointLabels(scale) { + var plFont = helpers.options._parseFont(scale.options.pointLabels); + var furthestLimits = { + l: 0, + r: scale.width, + t: 0, + b: scale.height - scale.paddingTop + }; + var furthestAngles = {}; + var i, textSize, pointPosition; + scale.ctx.font = plFont.string; + scale._pointLabelSizes = []; + var valueCount = scale.chart.data.labels.length; + for (i = 0; i < valueCount; i++) { + pointPosition = scale.getPointPosition(i, scale.drawingArea + 5); + textSize = measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointLabels[i]); + scale._pointLabelSizes[i] = textSize; + var angleRadians = scale.getIndexAngle(i); + var angle = toDegrees(angleRadians); + var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180); + var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270); + if (hLimits.start < furthestLimits.l) { + furthestLimits.l = hLimits.start; + furthestAngles.l = angleRadians; + } + if (hLimits.end > furthestLimits.r) { + furthestLimits.r = hLimits.end; + furthestAngles.r = angleRadians; + } + if (vLimits.start < furthestLimits.t) { + furthestLimits.t = vLimits.start; + furthestAngles.t = angleRadians; + } + if (vLimits.end > furthestLimits.b) { + furthestLimits.b = vLimits.end; + furthestAngles.b = angleRadians; + } + } + scale._setReductions(scale.drawingArea, furthestLimits, furthestAngles); +} +function getTextAlignForAngle(angle) { + if (angle === 0 || angle === 180) { + return 'center'; + } else if (angle < 180) { + return 'left'; + } + return 'right'; +} +function fillText(ctx, text, position, lineHeight) { + var y = position.y + lineHeight / 2; + var i, ilen; + if (helpers.isArray(text)) { + for (i = 0, ilen = text.length; i < ilen; ++i) { + ctx.fillText(text[i], position.x, y); + y += lineHeight; + } + } else { + ctx.fillText(text, position.x, y); + } +} +function adjustPointPositionForLabelHeight(angle, textSize, position) { + if (angle === 90 || angle === 270) { + position.y -= textSize.h / 2; + } else if (angle > 270 || angle < 90) { + position.y -= textSize.h; + } +} +function drawPointLabels(scale) { + var ctx = scale.ctx; + var opts = scale.options; + var pointLabelOpts = opts.pointLabels; + var tickBackdropHeight = getTickBackdropHeight(opts); + var outerDistance = scale.getDistanceFromCenterForValue(opts.ticks.reverse ? scale.min : scale.max); + var plFont = helpers.options._parseFont(pointLabelOpts); + ctx.save(); + ctx.font = plFont.string; + ctx.textBaseline = 'middle'; + for (var i = scale.chart.data.labels.length - 1; i >= 0; i--) { + var extra = i === 0 ? tickBackdropHeight / 2 : 0; + var pointLabelPosition = scale.getPointPosition(i, outerDistance + extra + 5); + var pointLabelFontColor = valueAtIndexOrDefault$1(pointLabelOpts.fontColor, i, defaults.fontColor); + ctx.fillStyle = pointLabelFontColor; + var angleRadians = scale.getIndexAngle(i); + var angle = toDegrees(angleRadians); + ctx.textAlign = getTextAlignForAngle(angle); + adjustPointPositionForLabelHeight(angle, scale._pointLabelSizes[i], pointLabelPosition); + fillText(ctx, scale.pointLabels[i], pointLabelPosition, plFont.lineHeight); + } + ctx.restore(); +} +function drawRadiusLine(scale, gridLineOpts, radius, index) { + var ctx = scale.ctx; + var circular = gridLineOpts.circular; + var valueCount = scale.chart.data.labels.length; + var lineColor = valueAtIndexOrDefault$1(gridLineOpts.color, index - 1, undefined); + var lineWidth = valueAtIndexOrDefault$1(gridLineOpts.lineWidth, index - 1, undefined); + var pointPosition; + if (!circular && !valueCount || !lineColor || !lineWidth) { + return; + } + ctx.save(); + ctx.strokeStyle = lineColor; + ctx.lineWidth = lineWidth; + if (ctx.setLineDash) { + ctx.setLineDash(gridLineOpts.borderDash || []); + ctx.lineDashOffset = gridLineOpts.borderDashOffset || 0.0; + } + ctx.beginPath(); + if (circular) { + ctx.arc(scale.xCenter, scale.yCenter, radius, 0, Math.PI * 2); + } else { + pointPosition = scale.getPointPosition(0, radius); + ctx.moveTo(pointPosition.x, pointPosition.y); + for (var i = 1; i < valueCount; i++) { + pointPosition = scale.getPointPosition(i, radius); + ctx.lineTo(pointPosition.x, pointPosition.y); + } + } + ctx.closePath(); + ctx.stroke(); + ctx.restore(); +} +function numberOrZero(param) { + return isNumber(param) ? param : 0; +} +class RadialLinearScale extends LinearScaleBase { + constructor(cfg) { + super(cfg); + this.xCenter = undefined; + this.yCenter = undefined; + this.drawingArea = undefined; + this.pointLabels = []; + } + setDimensions() { + var me = this; + me.width = me.maxWidth; + me.height = me.maxHeight; + me.paddingTop = getTickBackdropHeight(me.options) / 2; + me.xCenter = Math.floor(me.width / 2); + me.yCenter = Math.floor((me.height - me.paddingTop) / 2); + me.drawingArea = Math.min(me.height - me.paddingTop, me.width) / 2; + } + determineDataLimits() { + var me = this; + var minmax = me.getMinMax(false); + var min = minmax.min; + var max = minmax.max; + me.min = helpers.isFinite(min) && !isNaN(min) ? min : 0; + me.max = helpers.isFinite(max) && !isNaN(max) ? max : 0; + me.handleTickRangeOptions(); + } + computeTickLimit() { + return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options)); + } + generateTickLabels(ticks) { + var me = this; + LinearScaleBase.prototype.generateTickLabels.call(me, ticks); + me.pointLabels = me.chart.data.labels.map((value, index) => { + var label = helpers.callback(me.options.pointLabels.callback, [value, index], me); + return label || label === 0 ? label : ''; + }); + } + fit() { + var me = this; + var opts = me.options; + if (opts.display && opts.pointLabels.display) { + fitWithPointLabels(me); + } else { + me.setCenterPoint(0, 0, 0, 0); + } + } + _setReductions(largestPossibleRadius, furthestLimits, furthestAngles) { + var me = this; + var radiusReductionLeft = furthestLimits.l / Math.sin(furthestAngles.l); + var radiusReductionRight = Math.max(furthestLimits.r - me.width, 0) / Math.sin(furthestAngles.r); + var radiusReductionTop = -furthestLimits.t / Math.cos(furthestAngles.t); + var radiusReductionBottom = -Math.max(furthestLimits.b - (me.height - me.paddingTop), 0) / Math.cos(furthestAngles.b); + radiusReductionLeft = numberOrZero(radiusReductionLeft); + radiusReductionRight = numberOrZero(radiusReductionRight); + radiusReductionTop = numberOrZero(radiusReductionTop); + radiusReductionBottom = numberOrZero(radiusReductionBottom); + me.drawingArea = Math.min(Math.floor(largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2), Math.floor(largestPossibleRadius - (radiusReductionTop + radiusReductionBottom) / 2)); + me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReductionTop, radiusReductionBottom); + } + setCenterPoint(leftMovement, rightMovement, topMovement, bottomMovement) { + var me = this; + var maxRight = me.width - rightMovement - me.drawingArea; + var maxLeft = leftMovement + me.drawingArea; + var maxTop = topMovement + me.drawingArea; + var maxBottom = me.height - me.paddingTop - bottomMovement - me.drawingArea; + me.xCenter = Math.floor((maxLeft + maxRight) / 2 + me.left); + me.yCenter = Math.floor((maxTop + maxBottom) / 2 + me.top + me.paddingTop); + } + getIndexAngle(index) { + var chart = this.chart; + var angleMultiplier = Math.PI * 2 / chart.data.labels.length; + var options = chart.options || {}; + var startAngle = options.startAngle || 0; + return _normalizeAngle(index * angleMultiplier + toRadians(startAngle)); + } + getDistanceFromCenterForValue(value) { + var me = this; + if (helpers.isNullOrUndef(value)) { + return NaN; + } + var scalingFactor = me.drawingArea / (me.max - me.min); + if (me.options.reverse) { + return (me.max - value) * scalingFactor; + } + return (value - me.min) * scalingFactor; + } + getPointPosition(index, distanceFromCenter) { + var me = this; + var angle = me.getIndexAngle(index) - Math.PI / 2; + return { + x: Math.cos(angle) * distanceFromCenter + me.xCenter, + y: Math.sin(angle) * distanceFromCenter + me.yCenter, + angle + }; + } + getPointPositionForValue(index, value) { + return this.getPointPosition(index, this.getDistanceFromCenterForValue(value)); + } + getBasePosition(index) { + return this.getPointPositionForValue(index || 0, this.getBaseValue()); + } + drawGrid() { + var me = this; + var ctx = me.ctx; + var opts = me.options; + var gridLineOpts = opts.gridLines; + var angleLineOpts = opts.angleLines; + var lineWidth = valueOrDefault$2(angleLineOpts.lineWidth, gridLineOpts.lineWidth); + var lineColor = valueOrDefault$2(angleLineOpts.color, gridLineOpts.color); + var i, offset, position; + if (opts.pointLabels.display) { + drawPointLabels(me); + } + if (gridLineOpts.display) { + me.ticks.forEach((tick, index) => { + if (index !== 0) { + offset = me.getDistanceFromCenterForValue(me.ticks[index].value); + drawRadiusLine(me, gridLineOpts, offset, index); + } + }); + } + if (angleLineOpts.display && lineWidth && lineColor) { + ctx.save(); + ctx.lineWidth = lineWidth; + ctx.strokeStyle = lineColor; + if (ctx.setLineDash) { + ctx.setLineDash(resolve$2([angleLineOpts.borderDash, gridLineOpts.borderDash, []])); + ctx.lineDashOffset = resolve$2([angleLineOpts.borderDashOffset, gridLineOpts.borderDashOffset, 0.0]); + } + for (i = me.chart.data.labels.length - 1; i >= 0; i--) { + offset = me.getDistanceFromCenterForValue(opts.ticks.reverse ? me.min : me.max); + position = me.getPointPosition(i, offset); + ctx.beginPath(); + ctx.moveTo(me.xCenter, me.yCenter); + ctx.lineTo(position.x, position.y); + ctx.stroke(); + } + ctx.restore(); + } + } + drawLabels() { + var me = this; + var ctx = me.ctx; + var opts = me.options; + var tickOpts = opts.ticks; + if (!tickOpts.display) { + return; + } + var startAngle = me.getIndexAngle(0); + var tickFont = helpers.options._parseFont(tickOpts); + var tickFontColor = valueOrDefault$2(tickOpts.fontColor, defaults.fontColor); + var offset, width; + ctx.save(); + ctx.font = tickFont.string; + ctx.translate(me.xCenter, me.yCenter); + ctx.rotate(startAngle); + ctx.textAlign = 'center'; + ctx.textBaseline = 'middle'; + me.ticks.forEach((tick, index) => { + if (index === 0 && !opts.reverse) { + return; + } + offset = me.getDistanceFromCenterForValue(me.ticks[index].value); + if (tickOpts.showLabelBackdrop) { + width = ctx.measureText(tick.label).width; + ctx.fillStyle = tickOpts.backdropColor; + ctx.fillRect(-width / 2 - tickOpts.backdropPaddingX, -offset - tickFont.size / 2 - tickOpts.backdropPaddingY, width + tickOpts.backdropPaddingX * 2, tickFont.size + tickOpts.backdropPaddingY * 2); + } + ctx.fillStyle = tickFontColor; + ctx.fillText(tick.label, 0, -offset); + }); + ctx.restore(); + } + drawTitle() {} +} +_defineProperty(RadialLinearScale, "id", 'radialLinear'); +_defineProperty(RadialLinearScale, "defaults", defaultConfig$3); + +var MAX_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; +var INTERVALS = { + millisecond: { + common: true, + size: 1, + steps: 1000 + }, + second: { + common: true, + size: 1000, + steps: 60 + }, + minute: { + common: true, + size: 60000, + steps: 60 + }, + hour: { + common: true, + size: 3600000, + steps: 24 + }, + day: { + common: true, + size: 86400000, + steps: 30 + }, + week: { + common: false, + size: 604800000, + steps: 4 + }, + month: { + common: true, + size: 2.628e9, + steps: 12 + }, + quarter: { + common: false, + size: 7.884e9, + steps: 4 + }, + year: { + common: true, + size: 3.154e10 + } +}; +var UNITS = +Object.keys(INTERVALS); +function sorter(a, b) { + return a - b; +} +function arrayUnique(items) { + var set = new Set(); + var i, ilen; + for (i = 0, ilen = items.length; i < ilen; ++i) { + set.add(items[i]); + } + if (set.size === ilen) { + return items; + } + return [...set]; +} +function parse(scale, input) { + if (isNullOrUndef(input)) { + return null; + } + var adapter = scale._adapter; + var options = scale.options.time; + var { + parser, + round, + isoWeekday + } = options; + var value = input; + if (typeof parser === 'function') { + value = parser(value); + } + if (!isNumberFinite(value)) { + value = typeof parser === 'string' ? adapter.parse(value, parser) : adapter.parse(value); + } + if (value === null) { + return value; + } + if (round) { + value = round === 'week' && isoWeekday ? scale._adapter.startOf(value, 'isoWeek', isoWeekday) : scale._adapter.startOf(value, round); + } + return +value; +} +function getDataTimestamps(scale) { + var isSeries = scale.options.distribution === 'series'; + var timestamps = scale._cache.data || []; + var i, ilen; + if (timestamps.length) { + return timestamps; + } + var metas = scale.getMatchingVisibleMetas(); + if (isSeries && metas.length) { + return metas[0].controller.getAllParsedValues(scale); + } + for (i = 0, ilen = metas.length; i < ilen; ++i) { + timestamps = timestamps.concat(metas[i].controller.getAllParsedValues(scale)); + } + return scale._cache.data = arrayUnique(timestamps.sort(sorter)); +} +function getLabelTimestamps(scale) { + var isSeries = scale.options.distribution === 'series'; + var timestamps = scale._cache.labels || []; + var i, ilen; + if (timestamps.length) { + return timestamps; + } + var labels = scale.getLabels(); + for (i = 0, ilen = labels.length; i < ilen; ++i) { + timestamps.push(parse(scale, labels[i])); + } + return scale._cache.labels = isSeries ? timestamps : arrayUnique(timestamps.sort(sorter)); +} +function getAllTimestamps(scale) { + var timestamps = scale._cache.all || []; + if (timestamps.length) { + return timestamps; + } + var data = getDataTimestamps(scale); + var label = getLabelTimestamps(scale); + if (data.length && label.length) { + timestamps = arrayUnique(data.concat(label).sort(sorter)); + } else { + timestamps = data.length ? data : label; + } + timestamps = scale._cache.all = timestamps; + return timestamps; +} +function buildLookupTable(timestamps, min, max, distribution) { + if (distribution === 'linear' || !timestamps.length) { + return [{ + time: min, + pos: 0 + }, { + time: max, + pos: 1 + }]; + } + var table = []; + var items = [min]; + var i, ilen, prev, curr, next; + for (i = 0, ilen = timestamps.length; i < ilen; ++i) { + curr = timestamps[i]; + if (curr > min && curr < max) { + items.push(curr); + } + } + items.push(max); + for (i = 0, ilen = items.length; i < ilen; ++i) { + next = items[i + 1]; + prev = items[i - 1]; + curr = items[i]; + if (prev === undefined || next === undefined || Math.round((next + prev) / 2) !== curr) { + table.push({ + time: curr, + pos: i / (ilen - 1) + }); + } + } + return table; +} +function interpolate(table, skey, sval, tkey) { + var { + lo, + hi + } = _lookupByKey(table, skey, sval); + var prev = table[lo]; + var next = table[hi]; + var span = next[skey] - prev[skey]; + var ratio = span ? (sval - prev[skey]) / span : 0; + var offset = (next[tkey] - prev[tkey]) * ratio; + return prev[tkey] + offset; +} +function determineUnitForAutoTicks(minUnit, min, max, capacity) { + var ilen = UNITS.length; + for (var i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) { + var interval = INTERVALS[UNITS[i]]; + var factor = interval.steps ? interval.steps : MAX_INTEGER; + if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) { + return UNITS[i]; + } + } + return UNITS[ilen - 1]; +} +function determineUnitForFormatting(scale, numTicks, minUnit, min, max) { + for (var i = UNITS.length - 1; i >= UNITS.indexOf(minUnit); i--) { + var unit = UNITS[i]; + if (INTERVALS[unit].common && scale._adapter.diff(max, min, unit) >= numTicks - 1) { + return unit; + } + } + return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0]; +} +function determineMajorUnit(unit) { + for (var i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i) { + if (INTERVALS[UNITS[i]].common) { + return UNITS[i]; + } + } +} +function addTick(timestamps, ticks, time) { + if (!timestamps.length) { + return; + } + var { + lo, + hi + } = _lookup(timestamps, time); + var timestamp = timestamps[lo] >= time ? timestamps[lo] : timestamps[hi]; + ticks.add(timestamp); +} +function generate(scale) { + var adapter = scale._adapter; + var min = scale.min; + var max = scale.max; + var options = scale.options; + var timeOpts = options.time; + var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, scale._getLabelCapacity(min)); + var stepSize = valueOrDefault(timeOpts.stepSize, 1); + var weekday = minor === 'week' ? timeOpts.isoWeekday : false; + var ticks = new Set(); + var first = min; + var time; + if (weekday) { + first = +adapter.startOf(first, 'isoWeek', weekday); + } + first = +adapter.startOf(first, weekday ? 'day' : minor); + if (adapter.diff(max, min, minor) > 100000 * stepSize) { + throw new Error(min + ' and ' + max + ' are too far apart with stepSize of ' + stepSize + ' ' + minor); + } + if (scale.options.ticks.source === 'data') { + var timestamps = getDataTimestamps(scale); + for (time = first; time < max; time = +adapter.add(time, stepSize, minor)) { + addTick(timestamps, ticks, time); + } + if (time === max || options.bounds === 'ticks') { + addTick(timestamps, ticks, time); + } + } else { + for (time = first; time < max; time = +adapter.add(time, stepSize, minor)) { + ticks.add(time); + } + if (time === max || options.bounds === 'ticks') { + ticks.add(time); + } + } + return [...ticks]; +} +function computeOffsets(table, timestamps, min, max, options) { + var start = 0; + var end = 0; + var first, last; + if (options.offset && timestamps.length) { + first = interpolate(table, 'time', timestamps[0], 'pos'); + if (timestamps.length === 1) { + start = 1 - first; + } else { + start = (interpolate(table, 'time', timestamps[1], 'pos') - first) / 2; + } + last = interpolate(table, 'time', timestamps[timestamps.length - 1], 'pos'); + if (timestamps.length === 1) { + end = last; + } else { + end = (last - interpolate(table, 'time', timestamps[timestamps.length - 2], 'pos')) / 2; + } + } + return { + start, + end, + factor: 1 / (start + 1 + end) + }; +} +function setMajorTicks(scale, ticks, map, majorUnit) { + var adapter = scale._adapter; + var first = +adapter.startOf(ticks[0].value, majorUnit); + var last = ticks[ticks.length - 1].value; + var major, index; + for (major = first; major <= last; major = +adapter.add(major, 1, majorUnit)) { + index = map[major]; + if (index >= 0) { + ticks[index].major = true; + } + } + return ticks; +} +function ticksFromTimestamps(scale, values, majorUnit) { + var ticks = []; + var map = {}; + var ilen = values.length; + var i, value; + for (i = 0; i < ilen; ++i) { + value = values[i]; + map[value] = i; + ticks.push({ + value, + major: false + }); + } + return ilen === 0 || !majorUnit ? ticks : setMajorTicks(scale, ticks, map, majorUnit); +} +function getTimestampsForTicks(scale) { + if (scale.options.ticks.source === 'labels') { + return getLabelTimestamps(scale); + } + return generate(scale); +} +function getTimestampsForTable(scale) { + return scale.options.distribution === 'series' ? getAllTimestamps(scale) : [scale.min, scale.max]; +} +function getLabelBounds(scale) { + var arr = getLabelTimestamps(scale); + var min = Number.POSITIVE_INFINITY; + var max = Number.NEGATIVE_INFINITY; + if (arr.length) { + min = arr[0]; + max = arr[arr.length - 1]; + } + return { + min, + max + }; +} +var defaultConfig$4 = { + distribution: 'linear', + bounds: 'data', + adapters: {}, + time: { + parser: false, + unit: false, + round: false, + isoWeekday: false, + minUnit: 'millisecond', + displayFormats: {} + }, + ticks: { + autoSkip: false, + source: 'auto', + major: { + enabled: false + } + } +}; +class TimeScale extends Scale { + constructor(props) { + super(props); + var options = this.options; + var time = options.time || (options.time = {}); + var adapter = this._adapter = new _adapters._date(options.adapters.date); + this._cache = { + data: [], + labels: [], + all: [] + }; + this._unit = 'day'; + this._majorUnit = undefined; + this._offsets = {}; + this._table = []; + mergeIf(time.displayFormats, adapter.formats()); + } + parse(raw, index) { + if (raw === undefined) { + return NaN; + } + return parse(this, raw); + } + parseObject(obj, axis, index) { + if (obj && obj.t) { + return this.parse(obj.t, index); + } + if (obj[axis] !== undefined) { + return this.parse(obj[axis], index); + } + return null; + } + invalidateCaches() { + this._cache = { + data: [], + labels: [], + all: [] + }; + } + determineDataLimits() { + var me = this; + var options = me.options; + var adapter = me._adapter; + var unit = options.time.unit || 'day'; + var { + min, + max, + minDefined, + maxDefined + } = me.getUserBounds(); + function _applyBounds(bounds) { + if (!minDefined && !isNaN(bounds.min)) { + min = Math.min(min, bounds.min); + } + if (!maxDefined && !isNaN(bounds.max)) { + max = Math.max(max, bounds.max); + } + } + if (!minDefined || !maxDefined) { + _applyBounds(getLabelBounds(me)); + if (options.bounds !== 'ticks' || options.ticks.source !== 'labels') { + _applyBounds(me.getMinMax(false)); + } + } + min = isNumberFinite(min) && !isNaN(min) ? min : +adapter.startOf(Date.now(), unit); + max = isNumberFinite(max) && !isNaN(max) ? max : +adapter.endOf(Date.now(), unit) + 1; + me.min = Math.min(min, max); + me.max = Math.max(min + 1, max); + } + buildTicks() { + var me = this; + var options = me.options; + var timeOpts = options.time; + var tickOpts = options.ticks; + var distribution = options.distribution; + var timestamps = getTimestampsForTicks(me); + if (options.bounds === 'ticks' && timestamps.length) { + me.min = me._userMin || timestamps[0]; + me.max = me._userMax || timestamps[timestamps.length - 1]; + } + var min = me.min; + var max = me.max; + var ticks = _filterBetween(timestamps, min, max); + me._unit = timeOpts.unit || (tickOpts.autoSkip ? determineUnitForAutoTicks(timeOpts.minUnit, me.min, me.max, me._getLabelCapacity(min)) : determineUnitForFormatting(me, ticks.length, timeOpts.minUnit, me.min, me.max)); + me._majorUnit = !tickOpts.major.enabled || me._unit === 'year' ? undefined : determineMajorUnit(me._unit); + me._table = buildLookupTable(getTimestampsForTable(me), min, max, distribution); + me._offsets = computeOffsets(me._table, getDataTimestamps(me), min, max, options); + if (options.reverse) { + ticks.reverse(); + } + return ticksFromTimestamps(me, ticks, me._majorUnit); + } + getLabelForValue(value) { + var me = this; + var adapter = me._adapter; + var timeOpts = me.options.time; + if (timeOpts.tooltipFormat) { + return adapter.format(value, timeOpts.tooltipFormat); + } + return adapter.format(value, timeOpts.displayFormats.datetime); + } + _tickFormatFunction(time, index, ticks, format) { + var me = this; + var options = me.options; + var formats = options.time.displayFormats; + var unit = me._unit; + var majorUnit = me._majorUnit; + var minorFormat = unit && formats[unit]; + var majorFormat = majorUnit && formats[majorUnit]; + var tick = ticks[index]; + var major = majorUnit && majorFormat && tick && tick.major; + var label = me._adapter.format(time, format || (major ? majorFormat : minorFormat)); + var formatter = options.ticks.callback; + return formatter ? formatter(label, index, ticks) : label; + } + generateTickLabels(ticks) { + var i, ilen, tick; + for (i = 0, ilen = ticks.length; i < ilen; ++i) { + tick = ticks[i]; + tick.label = this._tickFormatFunction(tick.value, i, ticks); + } + } + getPixelForValue(value) { + var me = this; + var offsets = me._offsets; + var pos = interpolate(me._table, 'time', value, 'pos'); + return me.getPixelForDecimal((offsets.start + pos) * offsets.factor); + } + getValueForPixel(pixel) { + var me = this; + var offsets = me._offsets; + var pos = me.getDecimalForPixel(pixel) / offsets.factor - offsets.end; + return interpolate(me._table, 'pos', pos, 'time'); + } + _getLabelSize(label) { + var me = this; + var ticksOpts = me.options.ticks; + var tickLabelWidth = me.ctx.measureText(label).width; + var angle = toRadians(me.isHorizontal() ? ticksOpts.maxRotation : ticksOpts.minRotation); + var cosRotation = Math.cos(angle); + var sinRotation = Math.sin(angle); + var tickFontSize = valueOrDefault(ticksOpts.fontSize, defaults.fontSize); + return { + w: tickLabelWidth * cosRotation + tickFontSize * sinRotation, + h: tickLabelWidth * sinRotation + tickFontSize * cosRotation + }; + } + _getLabelCapacity(exampleTime) { + var me = this; + var timeOpts = me.options.time; + var displayFormats = timeOpts.displayFormats; + var format = displayFormats[timeOpts.unit] || displayFormats.millisecond; + var exampleLabel = me._tickFormatFunction(exampleTime, 0, ticksFromTimestamps(me, [exampleTime], me._majorUnit), format); + var size = me._getLabelSize(exampleLabel); + var capacity = Math.floor(me.isHorizontal() ? me.width / size.w : me.height / size.h) - 1; + return capacity > 0 ? capacity : 1; + } +} +_defineProperty(TimeScale, "id", 'time'); +_defineProperty(TimeScale, "defaults", defaultConfig$4); + +var scales = /*#__PURE__*/Object.freeze({ +__proto__: null, +CategoryScale: CategoryScale, +LinearScale: LinearScale, +LogarithmicScale: LogarithmicScale, +RadialLinearScale: RadialLinearScale, +TimeScale: TimeScale +}); + +defaults.set('plugins', { + filler: { + propagate: true + } +}); +function getLineByIndex(chart, index) { + var meta = chart.getDatasetMeta(index); + var visible = meta && chart.isDatasetVisible(index); + return visible ? meta.dataset : null; +} +function parseFillOption(line) { + var options = line.options; + var fillOption = options.fill; + var fill = valueOrDefault(fillOption && fillOption.target, fillOption); + if (fill === undefined) { + fill = !!options.backgroundColor; + } + if (fill === false || fill === null) { + return false; + } + if (fill === true) { + return 'origin'; + } + return fill; +} +function decodeFill(line, index, count) { + var fill = parseFillOption(line); + var target = parseFloat(fill); + if (isNumberFinite(target) && Math.floor(target) === target) { + if (fill[0] === '-' || fill[0] === '+') { + target = index + target; + } + if (target === index || target < 0 || target >= count) { + return false; + } + return target; + } + return ['origin', 'start', 'end'].indexOf(fill) >= 0 ? fill : false; +} +function computeLinearBoundary(source) { + var { + scale = {}, + fill + } = source; + var target = null; + var horizontal; + if (fill === 'start') { + target = scale.bottom; + } else if (fill === 'end') { + target = scale.top; + } else if (scale.getBasePixel) { + target = scale.getBasePixel(); + } + if (isNumberFinite(target)) { + horizontal = scale.isHorizontal(); + return { + x: horizontal ? target : null, + y: horizontal ? null : target + }; + } + return null; +} +class simpleArc { + constructor(opts) { + this.x = opts.x; + this.y = opts.y; + this.radius = opts.radius; + } + pathSegment(ctx, bounds, opts) { + var { + x, + y, + radius + } = this; + bounds = bounds || { + start: 0, + end: Math.PI * 2 + }; + if (opts.reverse) { + ctx.arc(x, y, radius, bounds.end, bounds.start, true); + } else { + ctx.arc(x, y, radius, bounds.start, bounds.end); + } + return !opts.bounds; + } + interpolate(point, property) { + var { + x, + y, + radius + } = this; + var angle = point.angle; + if (property === 'angle') { + return { + x: x + Math.cos(angle) * radius, + y: y + Math.sin(angle) * radius, + angle + }; + } + } +} +function computeCircularBoundary(source) { + var { + scale, + fill + } = source; + var options = scale.options; + var length = scale.getLabels().length; + var target = []; + var start = options.reverse ? scale.max : scale.min; + var end = options.reverse ? scale.min : scale.max; + var value = fill === 'start' ? start : fill === 'end' ? end : scale.getBaseValue(); + var i, center; + if (options.gridLines.circular) { + center = scale.getPointPositionForValue(0, start); + return new simpleArc({ + x: center.x, + y: center.y, + radius: scale.getDistanceFromCenterForValue(value) + }); + } + for (i = 0; i < length; ++i) { + target.push(scale.getPointPositionForValue(i, value)); + } + return target; +} +function computeBoundary(source) { + var scale = source.scale || {}; + if (scale.getPointPositionForValue) { + return computeCircularBoundary(source); + } + return computeLinearBoundary(source); +} +function pointsFromSegments(boundary, line) { + var { + x = null, + y = null + } = boundary || {}; + var linePoints = line.points; + var points = []; + line.segments.forEach(segment => { + var first = linePoints[segment.start]; + var last = linePoints[segment.end]; + if (y !== null) { + points.push({ + x: first.x, + y, + _prop: 'x', + _ref: first + }); + points.push({ + x: last.x, + y, + _prop: 'x', + _ref: last + }); + } else if (x !== null) { + points.push({ + x, + y: first.y, + _prop: 'y', + _ref: first + }); + points.push({ + x, + y: last.y, + _prop: 'y', + _ref: last + }); + } + }); + return points; +} +function getTarget(source) { + var { + chart, + fill, + line + } = source; + if (isNumberFinite(fill)) { + return getLineByIndex(chart, fill); + } + var boundary = computeBoundary(source); + var points = []; + var _loop = false; + var _refPoints = false; + if (boundary instanceof simpleArc) { + return boundary; + } + if (isArray(boundary)) { + _loop = true; + points = boundary; + } else { + points = pointsFromSegments(boundary, line); + _refPoints = true; + } + return points.length ? new Line({ + points, + options: { + tension: 0 + }, + _loop, + _fullLoop: _loop, + _refPoints + }) : null; +} +function resolveTarget(sources, index, propagate) { + var source = sources[index]; + var fill = source.fill; + var visited = [index]; + var target; + if (!propagate) { + return fill; + } + while (fill !== false && visited.indexOf(fill) === -1) { + if (!isNumberFinite(fill)) { + return fill; + } + target = sources[fill]; + if (!target) { + return false; + } + if (target.visible) { + return fill; + } + visited.push(fill); + fill = target.fill; + } + return false; +} +function _clip(ctx, target, clipY) { + ctx.beginPath(); + target.path(ctx); + ctx.lineTo(target.last().x, clipY); + ctx.lineTo(target.first().x, clipY); + ctx.closePath(); + ctx.clip(); +} +function getBounds(property, first, last, loop) { + if (loop) { + return; + } + var start = first[property]; + var end = last[property]; + if (property === 'angle') { + start = _normalizeAngle(start); + end = _normalizeAngle(end); + } + return { + property, + start, + end + }; +} +function _getEdge(a, b, prop, fn) { + if (a && b) { + return fn(a[prop], b[prop]); + } + return a ? a[prop] : b ? b[prop] : 0; +} +function _segments(line, target, property) { + var segments = line.segments; + var points = line.points; + var tpoints = target.points; + var parts = []; + if (target._refPoints) { + for (var i = 0, ilen = tpoints.length; i < ilen; ++i) { + var point = tpoints[i]; + var prop = point._prop; + if (prop) { + point[prop] = point._ref[prop]; + } + } + } + for (var _i = 0; _i < segments.length; _i++) { + var segment = segments[_i]; + var bounds = getBounds(property, points[segment.start], points[segment.end], segment.loop); + if (!target.segments) { + parts.push({ + source: segment, + target: bounds, + start: points[segment.start], + end: points[segment.end] + }); + continue; + } + var subs = _boundSegments(target, bounds); + for (var j = 0; j < subs.length; ++j) { + var sub = subs[j]; + var subBounds = getBounds(property, tpoints[sub.start], tpoints[sub.end], sub.loop); + var fillSources = _boundSegment(segment, points, subBounds); + for (var k = 0; k < fillSources.length; k++) { + parts.push({ + source: fillSources[k], + target: sub, + start: { + [property]: _getEdge(bounds, subBounds, 'start', Math.max) + }, + end: { + [property]: _getEdge(bounds, subBounds, 'end', Math.min) + } + }); + } + } + } + return parts; +} +function clipBounds(ctx, scale, bounds) { + var { + top, + bottom + } = scale.chart.chartArea; + var { + property, + start, + end + } = bounds || {}; + if (property === 'x') { + ctx.beginPath(); + ctx.rect(start, top, end - start, bottom - top); + ctx.clip(); + } +} +function interpolatedLineTo(ctx, target, point, property) { + var interpolatedPoint = target.interpolate(point, property); + if (interpolatedPoint) { + ctx.lineTo(interpolatedPoint.x, interpolatedPoint.y); + } +} +function _fill(ctx, cfg) { + var { + line, + target, + property, + color, + scale + } = cfg; + var segments = _segments(cfg.line, cfg.target, property); + ctx.fillStyle = color; + for (var i = 0, ilen = segments.length; i < ilen; ++i) { + var { + source: src, + target: tgt, + start, + end + } = segments[i]; + ctx.save(); + clipBounds(ctx, scale, getBounds(property, start, end)); + ctx.beginPath(); + var lineLoop = !!line.pathSegment(ctx, src); + if (lineLoop) { + ctx.closePath(); + } else { + interpolatedLineTo(ctx, target, end, property); + } + var targetLoop = !!target.pathSegment(ctx, tgt, { + move: lineLoop, + reverse: true + }); + var loop = lineLoop && targetLoop; + if (!loop) { + interpolatedLineTo(ctx, target, start, property); + } + ctx.closePath(); + ctx.fill(loop ? 'evenodd' : 'nonzero'); + ctx.restore(); + } +} +function doFill(ctx, cfg) { + var { + line, + target, + above, + below, + area, + scale + } = cfg; + var property = line._loop ? 'angle' : 'x'; + ctx.save(); + if (property === 'x' && below !== above) { + _clip(ctx, target, area.top); + _fill(ctx, { + line, + target, + color: above, + scale, + property + }); + ctx.restore(); + ctx.save(); + _clip(ctx, target, area.bottom); + } + _fill(ctx, { + line, + target, + color: below, + scale, + property + }); + ctx.restore(); +} +var filler = { + id: 'filler', + afterDatasetsUpdate(chart, options) { + var count = (chart.data.datasets || []).length; + var propagate = options.propagate; + var sources = []; + var meta, i, line, source; + for (i = 0; i < count; ++i) { + meta = chart.getDatasetMeta(i); + line = meta.dataset; + source = null; + if (line && line.options && line instanceof Line) { + source = { + visible: chart.isDatasetVisible(i), + fill: decodeFill(line, i, count), + chart, + scale: meta.vScale, + line, + target: undefined + }; + } + meta.$filler = source; + sources.push(source); + } + for (i = 0; i < count; ++i) { + source = sources[i]; + if (!source || source.fill === false) { + continue; + } + source.fill = resolveTarget(sources, i, propagate); + source.target = source.fill !== false && getTarget(source); + } + }, + beforeDatasetsDraw(chart) { + var metasets = chart.getSortedVisibleDatasetMetas(); + var area = chart.chartArea; + var i, meta; + for (i = metasets.length - 1; i >= 0; --i) { + meta = metasets[i].$filler; + if (meta) { + meta.line.updateControlPoints(area); + } + } + }, + beforeDatasetDraw(chart, args) { + var area = chart.chartArea; + var ctx = chart.ctx; + var meta = args.meta.$filler; + if (!meta || meta.fill === false) { + return; + } + var { + line, + target, + scale + } = meta; + var lineOpts = line.options; + var fillOption = lineOpts.fill; + var color = lineOpts.backgroundColor || defaults.color; + var { + above = color, + below = color + } = fillOption || {}; + if (target && line.points.length) { + clipArea(ctx, area); + doFill(ctx, { + line, + target, + above, + below, + area, + scale + }); + unclipArea(ctx); + } + } +}; + +defaults.set('legend', { + display: true, + position: 'top', + align: 'center', + fullWidth: true, + reverse: false, + weight: 1000, + onClick(e, legendItem) { + var index = legendItem.datasetIndex; + var ci = this.chart; + if (ci.isDatasetVisible(index)) { + ci.hide(index); + legendItem.hidden = true; + } else { + ci.show(index); + legendItem.hidden = false; + } + }, + onHover: null, + onLeave: null, + labels: { + boxWidth: 40, + padding: 10, + generateLabels(chart) { + var datasets = chart.data.datasets; + var options = chart.options.legend || {}; + var usePointStyle = options.labels && options.labels.usePointStyle; + return chart._getSortedDatasetMetas().map(meta => { + var style = meta.controller.getStyle(usePointStyle ? 0 : undefined); + return { + text: datasets[meta.index].label, + fillStyle: style.backgroundColor, + hidden: !meta.visible, + lineCap: style.borderCapStyle, + lineDash: style.borderDash, + lineDashOffset: style.borderDashOffset, + lineJoin: style.borderJoinStyle, + lineWidth: style.borderWidth, + strokeStyle: style.borderColor, + pointStyle: style.pointStyle, + rotation: style.rotation, + datasetIndex: meta.index + }; + }, this); + } + }, + title: { + display: false, + position: 'center', + text: '' + } +}); +function getBoxWidth(labelOpts, fontSize) { + return labelOpts.usePointStyle && labelOpts.boxWidth > fontSize ? fontSize : labelOpts.boxWidth; +} +class Legend extends Element { + constructor(config) { + super(); + _extends(this, config); + this.legendHitBoxes = []; + this._hoveredItem = null; + this.doughnutMode = false; + this.chart = config.chart; + this.options = config.options; + this.ctx = config.ctx; + this.legendItems = undefined; + this.columnWidths = undefined; + this.columnHeights = undefined; + this.lineWidths = undefined; + this._minSize = undefined; + this.maxHeight = undefined; + this.maxWidth = undefined; + this.top = undefined; + this.bottom = undefined; + this.left = undefined; + this.right = undefined; + this.height = undefined; + this.width = undefined; + this._margins = undefined; + this.paddingTop = undefined; + this.paddingBottom = undefined; + this.paddingLeft = undefined; + this.paddingRight = undefined; + this.position = undefined; + this.weight = undefined; + this.fullWidth = undefined; + } + beforeUpdate() {} + update(maxWidth, maxHeight, margins) { + var me = this; + me.beforeUpdate(); + me.maxWidth = maxWidth; + me.maxHeight = maxHeight; + me._margins = margins; + me.beforeSetDimensions(); + me.setDimensions(); + me.afterSetDimensions(); + me.beforeBuildLabels(); + me.buildLabels(); + me.afterBuildLabels(); + me.beforeFit(); + me.fit(); + me.afterFit(); + me.afterUpdate(); + } + afterUpdate() {} + beforeSetDimensions() {} + setDimensions() { + var me = this; + if (me.isHorizontal()) { + me.width = me.maxWidth; + me.left = 0; + me.right = me.width; + } else { + me.height = me.maxHeight; + me.top = 0; + me.bottom = me.height; + } + me.paddingLeft = 0; + me.paddingTop = 0; + me.paddingRight = 0; + me.paddingBottom = 0; + me._minSize = { + width: 0, + height: 0 + }; + } + afterSetDimensions() {} + beforeBuildLabels() {} + buildLabels() { + var me = this; + var labelOpts = me.options.labels || {}; + var legendItems = callback(labelOpts.generateLabels, [me.chart], me) || []; + if (labelOpts.filter) { + legendItems = legendItems.filter(item => labelOpts.filter(item, me.chart.data)); + } + if (me.options.reverse) { + legendItems.reverse(); + } + me.legendItems = legendItems; + } + afterBuildLabels() {} + beforeFit() {} + fit() { + var me = this; + var opts = me.options; + var labelOpts = opts.labels; + var display = opts.display; + var ctx = me.ctx; + var labelFont = _parseFont(labelOpts); + var fontSize = labelFont.size; + var hitboxes = me.legendHitBoxes = []; + var minSize = me._minSize; + var isHorizontal = me.isHorizontal(); + var titleHeight = me._computeTitleHeight(); + if (isHorizontal) { + minSize.width = me.maxWidth; + minSize.height = display ? 10 : 0; + } else { + minSize.width = display ? 10 : 0; + minSize.height = me.maxHeight; + } + if (!display) { + me.width = minSize.width = me.height = minSize.height = 0; + return; + } + ctx.font = labelFont.string; + if (isHorizontal) { + var lineWidths = me.lineWidths = [0]; + var totalHeight = titleHeight; + ctx.textAlign = 'left'; + ctx.textBaseline = 'middle'; + me.legendItems.forEach((legendItem, i) => { + var boxWidth = getBoxWidth(labelOpts, fontSize); + var width = boxWidth + fontSize / 2 + ctx.measureText(legendItem.text).width; + if (i === 0 || lineWidths[lineWidths.length - 1] + width + 2 * labelOpts.padding > minSize.width) { + totalHeight += fontSize + labelOpts.padding; + lineWidths[lineWidths.length - (i > 0 ? 0 : 1)] = 0; + } + hitboxes[i] = { + left: 0, + top: 0, + width, + height: fontSize + }; + lineWidths[lineWidths.length - 1] += width + labelOpts.padding; + }); + minSize.height += totalHeight; + } else { + var vPadding = labelOpts.padding; + var columnWidths = me.columnWidths = []; + var columnHeights = me.columnHeights = []; + var totalWidth = labelOpts.padding; + var currentColWidth = 0; + var currentColHeight = 0; + var heightLimit = minSize.height - titleHeight; + me.legendItems.forEach((legendItem, i) => { + var boxWidth = getBoxWidth(labelOpts, fontSize); + var itemWidth = boxWidth + fontSize / 2 + ctx.measureText(legendItem.text).width; + if (i > 0 && currentColHeight + fontSize + 2 * vPadding > heightLimit) { + totalWidth += currentColWidth + labelOpts.padding; + columnWidths.push(currentColWidth); + columnHeights.push(currentColHeight); + currentColWidth = 0; + currentColHeight = 0; + } + currentColWidth = Math.max(currentColWidth, itemWidth); + currentColHeight += fontSize + vPadding; + hitboxes[i] = { + left: 0, + top: 0, + width: itemWidth, + height: fontSize + }; + }); + totalWidth += currentColWidth; + columnWidths.push(currentColWidth); + columnHeights.push(currentColHeight); + minSize.width += totalWidth; + } + me.width = minSize.width; + me.height = minSize.height; + } + afterFit() {} + isHorizontal() { + return this.options.position === 'top' || this.options.position === 'bottom'; + } + draw() { + var me = this; + var opts = me.options; + var labelOpts = opts.labels; + var defaultColor = defaults.color; + var lineDefault = defaults.elements.line; + var legendHeight = me.height; + var columnHeights = me.columnHeights; + var legendWidth = me.width; + var lineWidths = me.lineWidths; + if (!opts.display) { + return; + } + me.drawTitle(); + var rtlHelper = getRtlAdapter(opts.rtl, me.left, me._minSize.width); + var ctx = me.ctx; + var fontColor = valueOrDefault(labelOpts.fontColor, defaults.fontColor); + var labelFont = _parseFont(labelOpts); + var fontSize = labelFont.size; + var cursor; + ctx.textAlign = rtlHelper.textAlign('left'); + ctx.textBaseline = 'middle'; + ctx.lineWidth = 0.5; + ctx.strokeStyle = fontColor; + ctx.fillStyle = fontColor; + ctx.font = labelFont.string; + var boxWidth = getBoxWidth(labelOpts, fontSize); + var hitboxes = me.legendHitBoxes; + var drawLegendBox = function drawLegendBox(x, y, legendItem) { + if (isNaN(boxWidth) || boxWidth <= 0) { + return; + } + ctx.save(); + var lineWidth = valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth); + ctx.fillStyle = valueOrDefault(legendItem.fillStyle, defaultColor); + ctx.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapStyle); + ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, lineDefault.borderDashOffset); + ctx.lineJoin = valueOrDefault(legendItem.lineJoin, lineDefault.borderJoinStyle); + ctx.lineWidth = lineWidth; + ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, defaultColor); + if (ctx.setLineDash) { + ctx.setLineDash(valueOrDefault(legendItem.lineDash, lineDefault.borderDash)); + } + if (labelOpts && labelOpts.usePointStyle) { + var drawOptions = { + radius: boxWidth * Math.SQRT2 / 2, + pointStyle: legendItem.pointStyle, + rotation: legendItem.rotation, + borderWidth: lineWidth + }; + var centerX = rtlHelper.xPlus(x, boxWidth / 2); + var centerY = y + fontSize / 2; + drawPoint(ctx, drawOptions, centerX, centerY); + } else { + ctx.fillRect(rtlHelper.leftForLtr(x, boxWidth), y, boxWidth, fontSize); + if (lineWidth !== 0) { + ctx.strokeRect(rtlHelper.leftForLtr(x, boxWidth), y, boxWidth, fontSize); + } + } + ctx.restore(); + }; + var fillText = function fillText(x, y, legendItem, textWidth) { + var halfFontSize = fontSize / 2; + var xLeft = rtlHelper.xPlus(x, boxWidth + halfFontSize); + var yMiddle = y + halfFontSize; + ctx.fillText(legendItem.text, xLeft, yMiddle); + if (legendItem.hidden) { + ctx.beginPath(); + ctx.lineWidth = 2; + ctx.moveTo(xLeft, yMiddle); + ctx.lineTo(rtlHelper.xPlus(xLeft, textWidth), yMiddle); + ctx.stroke(); + } + }; + var alignmentOffset = function alignmentOffset(dimension, blockSize) { + switch (opts.align) { + case 'start': + return labelOpts.padding; + case 'end': + return dimension - blockSize; + default: + return (dimension - blockSize + labelOpts.padding) / 2; + } + }; + var isHorizontal = me.isHorizontal(); + var titleHeight = this._computeTitleHeight(); + if (isHorizontal) { + cursor = { + x: me.left + alignmentOffset(legendWidth, lineWidths[0]), + y: me.top + labelOpts.padding + titleHeight, + line: 0 + }; + } else { + cursor = { + x: me.left + labelOpts.padding, + y: me.top + alignmentOffset(legendHeight, columnHeights[0]) + titleHeight, + line: 0 + }; + } + overrideTextDirection(me.ctx, opts.textDirection); + var itemHeight = fontSize + labelOpts.padding; + me.legendItems.forEach((legendItem, i) => { + var textWidth = ctx.measureText(legendItem.text).width; + var width = boxWidth + fontSize / 2 + textWidth; + var x = cursor.x; + var y = cursor.y; + rtlHelper.setWidth(me._minSize.width); + if (isHorizontal) { + if (i > 0 && x + width + labelOpts.padding > me.left + me._minSize.width) { + y = cursor.y += itemHeight; + cursor.line++; + x = cursor.x = me.left + alignmentOffset(legendWidth, lineWidths[cursor.line]); + } + } else if (i > 0 && y + itemHeight > me.top + me._minSize.height) { + x = cursor.x = x + me.columnWidths[cursor.line] + labelOpts.padding; + cursor.line++; + y = cursor.y = me.top + alignmentOffset(legendHeight, columnHeights[cursor.line]); + } + var realX = rtlHelper.x(x); + drawLegendBox(realX, y, legendItem); + hitboxes[i].left = rtlHelper.leftForLtr(realX, hitboxes[i].width); + hitboxes[i].top = y; + fillText(realX, y, legendItem, textWidth); + if (isHorizontal) { + cursor.x += width + labelOpts.padding; + } else { + cursor.y += itemHeight; + } + }); + restoreTextDirection(me.ctx, opts.textDirection); + } + drawTitle() { + var me = this; + var opts = me.options; + var titleOpts = opts.title; + var titleFont = _parseFont(titleOpts); + var titlePadding = toPadding(titleOpts.padding); + if (!titleOpts.display) { + return; + } + var rtlHelper = getRtlAdapter(opts.rtl, me.left, me._minSize.width); + var ctx = me.ctx; + var fontColor = valueOrDefault(titleOpts.fontColor, defaults.fontColor); + var position = titleOpts.position; + var x, textAlign; + var halfFontSize = titleFont.size / 2; + var y = me.top + titlePadding.top + halfFontSize; + var left = me.left; + var maxWidth = me.width; + if (this.isHorizontal()) { + maxWidth = Math.max(...me.lineWidths); + switch (opts.align) { + case 'start': + break; + case 'end': + left = me.right - maxWidth; + break; + default: + left = (me.left + me.right) / 2 - maxWidth / 2; + break; + } + } else { + var maxHeight = Math.max(...me.columnHeights); + switch (opts.align) { + case 'start': + break; + case 'end': + y += me.height - maxHeight; + break; + default: + y += (me.height - maxHeight) / 2; + break; + } + } + switch (position) { + case 'start': + x = left; + textAlign = 'left'; + break; + case 'end': + x = left + maxWidth; + textAlign = 'right'; + break; + default: + x = left + maxWidth / 2; + textAlign = 'center'; + break; + } + ctx.textAlign = rtlHelper.textAlign(textAlign); + ctx.textBaseline = 'middle'; + ctx.strokeStyle = fontColor; + ctx.fillStyle = fontColor; + ctx.font = titleFont.string; + ctx.fillText(titleOpts.text, x, y); + } + _computeTitleHeight() { + var titleOpts = this.options.title; + var titleFont = _parseFont(titleOpts); + var titlePadding = toPadding(titleOpts.padding); + return titleOpts.display ? titleFont.lineHeight + titlePadding.height : 0; + } + _getLegendItemAt(x, y) { + var me = this; + var i, hitBox, lh; + if (x >= me.left && x <= me.right && y >= me.top && y <= me.bottom) { + lh = me.legendHitBoxes; + for (i = 0; i < lh.length; ++i) { + hitBox = lh[i]; + if (x >= hitBox.left && x <= hitBox.left + hitBox.width && y >= hitBox.top && y <= hitBox.top + hitBox.height) { + return me.legendItems[i]; + } + } + } + return null; + } + handleEvent(e) { + var me = this; + var opts = me.options; + var type = e.type === 'mouseup' ? 'click' : e.type; + if (type === 'mousemove') { + if (!opts.onHover && !opts.onLeave) { + return; + } + } else if (type === 'click') { + if (!opts.onClick) { + return; + } + } else { + return; + } + var hoveredItem = me._getLegendItemAt(e.x, e.y); + if (type === 'click') { + if (hoveredItem && opts.onClick) { + opts.onClick.call(me, e.native, hoveredItem); + } + } else { + if (opts.onLeave && hoveredItem !== me._hoveredItem) { + if (me._hoveredItem) { + opts.onLeave.call(me, e.native, me._hoveredItem); + } + me._hoveredItem = hoveredItem; + } + if (opts.onHover && hoveredItem) { + opts.onHover.call(me, e.native, hoveredItem); + } + } + } +} +function createNewLegendAndAttach(chart, legendOpts) { + var legend = new Legend({ + ctx: chart.ctx, + options: legendOpts, + chart + }); + layouts.configure(chart, legend, legendOpts); + layouts.addBox(chart, legend); + chart.legend = legend; +} +var legend = { + id: 'legend', + _element: Legend, + beforeInit(chart) { + var legendOpts = chart.options.legend; + if (legendOpts) { + createNewLegendAndAttach(chart, legendOpts); + } + }, + afterUpdate(chart) { + var legendOpts = chart.options.legend; + var legend = chart.legend; + if (legendOpts) { + mergeIf(legendOpts, defaults.legend); + if (legend) { + layouts.configure(chart, legend, legendOpts); + legend.options = legendOpts; + legend.buildLabels(); + } else { + createNewLegendAndAttach(chart, legendOpts); + } + } else if (legend) { + layouts.removeBox(chart, legend); + delete chart.legend; + } + }, + afterEvent(chart, e) { + var legend = chart.legend; + if (legend) { + legend.handleEvent(e); + } + } +}; + +defaults.set('title', { + align: 'center', + display: false, + fontStyle: 'bold', + fullWidth: true, + padding: 10, + position: 'top', + text: '', + weight: 2000 +}); +class Title extends Element { + constructor(config) { + super(); + _extends(this, config); + this.chart = config.chart; + this.options = config.options; + this.ctx = config.ctx; + this._margins = undefined; + this._padding = undefined; + this.legendHitBoxes = []; + this.top = undefined; + this.bottom = undefined; + this.left = undefined; + this.right = undefined; + this.width = undefined; + this.height = undefined; + this.maxWidth = undefined; + this.maxHeight = undefined; + this.position = undefined; + this.weight = undefined; + this.fullWidth = undefined; + } + beforeUpdate() {} + update(maxWidth, maxHeight, margins) { + var me = this; + me.beforeUpdate(); + me.maxWidth = maxWidth; + me.maxHeight = maxHeight; + me._margins = margins; + me.beforeSetDimensions(); + me.setDimensions(); + me.afterSetDimensions(); + me.beforeBuildLabels(); + me.buildLabels(); + me.afterBuildLabels(); + me.beforeFit(); + me.fit(); + me.afterFit(); + me.afterUpdate(); + } + afterUpdate() {} + beforeSetDimensions() {} + setDimensions() { + var me = this; + if (me.isHorizontal()) { + me.width = me.maxWidth; + me.left = 0; + me.right = me.width; + } else { + me.height = me.maxHeight; + me.top = 0; + me.bottom = me.height; + } + } + afterSetDimensions() {} + beforeBuildLabels() {} + buildLabels() {} + afterBuildLabels() {} + beforeFit() {} + fit() { + var me = this; + var opts = me.options; + var minSize = {}; + var isHorizontal = me.isHorizontal(); + if (!opts.display) { + me.width = minSize.width = me.height = minSize.height = 0; + return; + } + var lineCount = helpers.isArray(opts.text) ? opts.text.length : 1; + me._padding = helpers.options.toPadding(opts.padding); + var textSize = lineCount * helpers.options._parseFont(opts).lineHeight + me._padding.height; + me.width = minSize.width = isHorizontal ? me.maxWidth : textSize; + me.height = minSize.height = isHorizontal ? textSize : me.maxHeight; + } + afterFit() {} + isHorizontal() { + var pos = this.options.position; + return pos === 'top' || pos === 'bottom'; + } + draw() { + var me = this; + var ctx = me.ctx; + var opts = me.options; + if (!opts.display) { + return; + } + var fontOpts = helpers.options._parseFont(opts); + var lineHeight = fontOpts.lineHeight; + var offset = lineHeight / 2 + me._padding.top; + var rotation = 0; + var top = me.top; + var left = me.left; + var bottom = me.bottom; + var right = me.right; + var maxWidth, titleX, titleY; + var align; + if (me.isHorizontal()) { + switch (opts.align) { + case 'start': + titleX = left; + align = 'left'; + break; + case 'end': + titleX = right; + align = 'right'; + break; + default: + titleX = left + (right - left) / 2; + align = 'center'; + break; + } + titleY = top + offset; + maxWidth = right - left; + } else { + titleX = opts.position === 'left' ? left + offset : right - offset; + switch (opts.align) { + case 'start': + titleY = opts.position === 'left' ? bottom : top; + align = 'left'; + break; + case 'end': + titleY = opts.position === 'left' ? top : bottom; + align = 'right'; + break; + default: + titleY = top + (bottom - top) / 2; + align = 'center'; + break; + } + maxWidth = bottom - top; + rotation = Math.PI * (opts.position === 'left' ? -0.5 : 0.5); + } + ctx.save(); + ctx.fillStyle = helpers.valueOrDefault(opts.fontColor, defaults.fontColor); + ctx.font = fontOpts.string; + ctx.translate(titleX, titleY); + ctx.rotate(rotation); + ctx.textAlign = align; + ctx.textBaseline = 'middle'; + var text = opts.text; + if (helpers.isArray(text)) { + var y = 0; + for (var i = 0; i < text.length; ++i) { + ctx.fillText(text[i], 0, y, maxWidth); + y += lineHeight; + } + } else { + ctx.fillText(text, 0, 0, maxWidth); + } + ctx.restore(); + } +} +function createNewTitleBlockAndAttach(chart, titleOpts) { + var title = new Title({ + ctx: chart.ctx, + options: titleOpts, + chart + }); + layouts.configure(chart, title, titleOpts); + layouts.addBox(chart, title); + chart.titleBlock = title; +} +var title = { + id: 'title', + _element: Title, + beforeInit(chart) { + var titleOpts = chart.options.title; + if (titleOpts) { + createNewTitleBlockAndAttach(chart, titleOpts); + } + }, + beforeUpdate(chart) { + var titleOpts = chart.options.title; + var titleBlock = chart.titleBlock; + if (titleOpts) { + helpers.mergeIf(titleOpts, defaults.title); + if (titleBlock) { + layouts.configure(chart, titleBlock, titleOpts); + titleBlock.options = titleOpts; + } else { + createNewTitleBlockAndAttach(chart, titleOpts); + } + } else if (titleBlock) { + layouts.removeBox(chart, titleBlock); + delete chart.titleBlock; + } + } +}; + +var valueOrDefault$3 = helpers.valueOrDefault; +var getRtlHelper = helpers.rtl.getRtlAdapter; +defaults.set('tooltips', { + enabled: true, + custom: null, + mode: 'nearest', + position: 'average', + intersect: true, + backgroundColor: 'rgba(0,0,0,0.8)', + titleFontStyle: 'bold', + titleSpacing: 2, + titleMarginBottom: 6, + titleFontColor: '#fff', + titleAlign: 'left', + bodySpacing: 2, + bodyFontColor: '#fff', + bodyAlign: 'left', + footerFontStyle: 'bold', + footerSpacing: 2, + footerMarginTop: 6, + footerFontColor: '#fff', + footerAlign: 'left', + yPadding: 6, + xPadding: 6, + caretPadding: 2, + caretSize: 5, + cornerRadius: 6, + multiKeyBackground: '#fff', + displayColors: true, + borderColor: 'rgba(0,0,0,0)', + borderWidth: 0, + animation: { + duration: 400, + easing: 'easeOutQuart', + numbers: { + type: 'number', + properties: ['x', 'y', 'width', 'height', 'caretX', 'caretY'] + }, + opacity: { + easing: 'linear', + duration: 200 + } + }, + callbacks: { + beforeTitle: helpers.noop, + title(tooltipItems, data) { + var title = ''; + var labels = data.labels; + var labelCount = labels ? labels.length : 0; + if (tooltipItems.length > 0) { + var item = tooltipItems[0]; + if (item.label) { + title = item.label; + } else if (labelCount > 0 && item.index < labelCount) { + title = labels[item.index]; + } + } + return title; + }, + afterTitle: helpers.noop, + beforeBody: helpers.noop, + beforeLabel: helpers.noop, + label(tooltipItem, data) { + var label = data.datasets[tooltipItem.datasetIndex].label || ''; + if (label) { + label += ': '; + } + var value = tooltipItem.value; + if (!helpers.isNullOrUndef(value)) { + label += value; + } + return label; + }, + labelColor(tooltipItem, chart) { + var meta = chart.getDatasetMeta(tooltipItem.datasetIndex); + var options = meta.controller.getStyle(tooltipItem.index); + return { + borderColor: options.borderColor, + backgroundColor: options.backgroundColor + }; + }, + labelTextColor() { + return this.options.bodyFontColor; + }, + afterLabel: helpers.noop, + afterBody: helpers.noop, + beforeFooter: helpers.noop, + footer: helpers.noop, + afterFooter: helpers.noop + } +}); +var positioners = { + average(items) { + if (!items.length) { + return false; + } + var i, len; + var x = 0; + var y = 0; + var count = 0; + for (i = 0, len = items.length; i < len; ++i) { + var el = items[i].element; + if (el && el.hasValue()) { + var pos = el.tooltipPosition(); + x += pos.x; + y += pos.y; + ++count; + } + } + return { + x: x / count, + y: y / count + }; + }, + nearest(items, eventPosition) { + var x = eventPosition.x; + var y = eventPosition.y; + var minDistance = Number.POSITIVE_INFINITY; + var i, len, nearestElement; + for (i = 0, len = items.length; i < len; ++i) { + var el = items[i].element; + if (el && el.hasValue()) { + var center = el.getCenterPoint(); + var d = helpers.math.distanceBetweenPoints(eventPosition, center); + if (d < minDistance) { + minDistance = d; + nearestElement = el; + } + } + } + if (nearestElement) { + var tp = nearestElement.tooltipPosition(); + x = tp.x; + y = tp.y; + } + return { + x, + y + }; + } +}; +function pushOrConcat(base, toPush) { + if (toPush) { + if (helpers.isArray(toPush)) { + Array.prototype.push.apply(base, toPush); + } else { + base.push(toPush); + } + } + return base; +} +function splitNewlines(str) { + if ((typeof str === 'string' || str instanceof String) && str.indexOf('\n') > -1) { + return str.split('\n'); + } + return str; +} +function createTooltipItem(chart, item) { + var { + datasetIndex, + index + } = item; + var { + label, + value + } = chart.getDatasetMeta(datasetIndex).controller.getLabelAndValue(index); + return { + label, + value, + index, + datasetIndex + }; +} +function resolveOptions(options) { + options = _extends({}, defaults.tooltips, options); + options.bodyFontFamily = valueOrDefault$3(options.bodyFontFamily, defaults.fontFamily); + options.bodyFontStyle = valueOrDefault$3(options.bodyFontStyle, defaults.fontStyle); + options.bodyFontSize = valueOrDefault$3(options.bodyFontSize, defaults.fontSize); + options.boxHeight = valueOrDefault$3(options.boxHeight, options.bodyFontSize); + options.boxWidth = valueOrDefault$3(options.boxWidth, options.bodyFontSize); + options.titleFontFamily = valueOrDefault$3(options.titleFontFamily, defaults.fontFamily); + options.titleFontStyle = valueOrDefault$3(options.titleFontStyle, defaults.fontStyle); + options.titleFontSize = valueOrDefault$3(options.titleFontSize, defaults.fontSize); + options.footerFontFamily = valueOrDefault$3(options.footerFontFamily, defaults.fontFamily); + options.footerFontStyle = valueOrDefault$3(options.footerFontStyle, defaults.fontStyle); + options.footerFontSize = valueOrDefault$3(options.footerFontSize, defaults.fontSize); + return options; +} +function getTooltipSize(tooltip) { + var ctx = tooltip._chart.ctx; + var { + body, + footer, + options, + title + } = tooltip; + var { + bodyFontSize, + footerFontSize, + titleFontSize, + boxWidth, + boxHeight + } = options; + var titleLineCount = title.length; + var footerLineCount = footer.length; + var bodyLineItemCount = body.length; + var height = options.yPadding * 2; + var width = 0; + var combinedBodyLength = body.reduce((count, bodyItem) => count + bodyItem.before.length + bodyItem.lines.length + bodyItem.after.length, 0); + combinedBodyLength += tooltip.beforeBody.length + tooltip.afterBody.length; + if (titleLineCount) { + height += titleLineCount * titleFontSize + (titleLineCount - 1) * options.titleSpacing + options.titleMarginBottom; + } + if (combinedBodyLength) { + var bodyLineHeight = options.displayColors ? Math.max(boxHeight, bodyFontSize) : bodyFontSize; + height += bodyLineItemCount * bodyLineHeight + (combinedBodyLength - bodyLineItemCount) * bodyFontSize + (combinedBodyLength - 1) * options.bodySpacing; + } + if (footerLineCount) { + height += options.footerMarginTop + footerLineCount * footerFontSize + (footerLineCount - 1) * options.footerSpacing; + } + var widthPadding = 0; + var maxLineWidth = function maxLineWidth(line) { + width = Math.max(width, ctx.measureText(line).width + widthPadding); + }; + ctx.save(); + ctx.font = helpers.fontString(titleFontSize, options.titleFontStyle, options.titleFontFamily); + helpers.each(tooltip.title, maxLineWidth); + ctx.font = helpers.fontString(bodyFontSize, options.bodyFontStyle, options.bodyFontFamily); + helpers.each(tooltip.beforeBody.concat(tooltip.afterBody), maxLineWidth); + widthPadding = options.displayColors ? boxWidth + 2 : 0; + helpers.each(body, bodyItem => { + helpers.each(bodyItem.before, maxLineWidth); + helpers.each(bodyItem.lines, maxLineWidth); + helpers.each(bodyItem.after, maxLineWidth); + }); + widthPadding = 0; + ctx.font = helpers.fontString(footerFontSize, options.footerFontStyle, options.footerFontFamily); + helpers.each(tooltip.footer, maxLineWidth); + ctx.restore(); + width += 2 * options.xPadding; + return { + width, + height + }; +} +function determineAlignment(chart, options, size) { + var { + x, + y, + width, + height + } = size; + var chartArea = chart.chartArea; + var xAlign = 'center'; + var yAlign = 'center'; + if (y < height) { + yAlign = 'top'; + } else if (y > chart.height - height) { + yAlign = 'bottom'; + } + var lf, rf; + var midX = (chartArea.left + chartArea.right) / 2; + var midY = (chartArea.top + chartArea.bottom) / 2; + if (yAlign === 'center') { + lf = value => value <= midX; + rf = value => value > midX; + } else { + lf = value => value <= width / 2; + rf = value => value >= chart.width - width / 2; + } + var olf = value => value + width + options.caretSize + options.caretPadding > chart.width; + var orf = value => value - width - options.caretSize - options.caretPadding < 0; + var yf = value => value <= midY ? 'top' : 'bottom'; + if (lf(x)) { + xAlign = 'left'; + if (olf(x)) { + xAlign = 'center'; + yAlign = yf(y); + } + } else if (rf(x)) { + xAlign = 'right'; + if (orf(x)) { + xAlign = 'center'; + yAlign = yf(y); + } + } + return { + xAlign: options.xAlign ? options.xAlign : xAlign, + yAlign: options.yAlign ? options.yAlign : yAlign + }; +} +function alignX(size, xAlign, chartWidth) { + var { + x, + width + } = size; + if (xAlign === 'right') { + x -= width; + } else if (xAlign === 'center') { + x -= width / 2; + if (x + width > chartWidth) { + x = chartWidth - width; + } + if (x < 0) { + x = 0; + } + } + return x; +} +function alignY(size, yAlign, paddingAndSize) { + var { + y, + height + } = size; + if (yAlign === 'top') { + y += paddingAndSize; + } else if (yAlign === 'bottom') { + y -= height + paddingAndSize; + } else { + y -= height / 2; + } + return y; +} +function getBackgroundPoint(options, size, alignment, chart) { + var { + caretSize, + caretPadding, + cornerRadius + } = options; + var { + xAlign, + yAlign + } = alignment; + var paddingAndSize = caretSize + caretPadding; + var radiusAndPadding = cornerRadius + caretPadding; + var x = alignX(size, xAlign, chart.width); + var y = alignY(size, yAlign, paddingAndSize); + if (yAlign === 'center') { + if (xAlign === 'left') { + x += paddingAndSize; + } else if (xAlign === 'right') { + x -= paddingAndSize; + } + } else if (xAlign === 'left') { + x -= radiusAndPadding; + } else if (xAlign === 'right') { + x += radiusAndPadding; + } + return { + x, + y + }; +} +function getAlignedX(tooltip, align) { + var options = tooltip.options; + return align === 'center' ? tooltip.x + tooltip.width / 2 : align === 'right' ? tooltip.x + tooltip.width - options.xPadding : tooltip.x + options.xPadding; +} +function getBeforeAfterBodyLines(callback) { + return pushOrConcat([], splitNewlines(callback)); +} +class Tooltip extends Element { + constructor(config) { + super(); + this.opacity = 0; + this._active = []; + this._chart = config._chart; + this._eventPosition = undefined; + this._size = undefined; + this._cachedAnimations = undefined; + this.$animations = undefined; + this.options = undefined; + this.dataPoints = undefined; + this.title = undefined; + this.beforeBody = undefined; + this.body = undefined; + this.afterBody = undefined; + this.footer = undefined; + this.xAlign = undefined; + this.yAlign = undefined; + this.x = undefined; + this.y = undefined; + this.height = undefined; + this.width = undefined; + this.caretX = undefined; + this.caretY = undefined; + this.labelColors = undefined; + this.labelTextColors = undefined; + this.initialize(); + } + initialize() { + var me = this; + me.options = resolveOptions(me._chart.options.tooltips); + } + _resolveAnimations() { + var me = this; + var cached = me._cachedAnimations; + if (cached) { + return cached; + } + var chart = me._chart; + var opts = chart.options.animation && me.options.animation; + var animations = new Animations(me._chart, opts); + me._cachedAnimations = Object.freeze(animations); + return animations; + } + getTitle(tooltipitem, data) { + var me = this; + var opts = me.options; + var callbacks = opts.callbacks; + var beforeTitle = callbacks.beforeTitle.apply(me, [tooltipitem, data]); + var title = callbacks.title.apply(me, [tooltipitem, data]); + var afterTitle = callbacks.afterTitle.apply(me, [tooltipitem, data]); + var lines = []; + lines = pushOrConcat(lines, splitNewlines(beforeTitle)); + lines = pushOrConcat(lines, splitNewlines(title)); + lines = pushOrConcat(lines, splitNewlines(afterTitle)); + return lines; + } + getBeforeBody(tooltipitem, data) { + return getBeforeAfterBodyLines(this.options.callbacks.beforeBody.apply(this, [tooltipitem, data])); + } + getBody(tooltipItems, data) { + var me = this; + var callbacks = me.options.callbacks; + var bodyItems = []; + helpers.each(tooltipItems, tooltipItem => { + var bodyItem = { + before: [], + lines: [], + after: [] + }; + pushOrConcat(bodyItem.before, splitNewlines(callbacks.beforeLabel.call(me, tooltipItem, data))); + pushOrConcat(bodyItem.lines, callbacks.label.call(me, tooltipItem, data)); + pushOrConcat(bodyItem.after, splitNewlines(callbacks.afterLabel.call(me, tooltipItem, data))); + bodyItems.push(bodyItem); + }); + return bodyItems; + } + getAfterBody(tooltipitem, data) { + return getBeforeAfterBodyLines(this.options.callbacks.afterBody.apply(this, [tooltipitem, data])); + } + getFooter(tooltipitem, data) { + var me = this; + var callbacks = me.options.callbacks; + var beforeFooter = callbacks.beforeFooter.apply(me, [tooltipitem, data]); + var footer = callbacks.footer.apply(me, [tooltipitem, data]); + var afterFooter = callbacks.afterFooter.apply(me, [tooltipitem, data]); + var lines = []; + lines = pushOrConcat(lines, splitNewlines(beforeFooter)); + lines = pushOrConcat(lines, splitNewlines(footer)); + lines = pushOrConcat(lines, splitNewlines(afterFooter)); + return lines; + } + _createItems() { + var me = this; + var active = me._active; + var options = me.options; + var data = me._chart.data; + var labelColors = []; + var labelTextColors = []; + var tooltipItems = []; + var i, len; + for (i = 0, len = active.length; i < len; ++i) { + tooltipItems.push(createTooltipItem(me._chart, active[i])); + } + if (options.filter) { + tooltipItems = tooltipItems.filter(a => options.filter(a, data)); + } + if (options.itemSort) { + tooltipItems = tooltipItems.sort((a, b) => options.itemSort(a, b, data)); + } + helpers.each(tooltipItems, tooltipItem => { + labelColors.push(options.callbacks.labelColor.call(me, tooltipItem, me._chart)); + labelTextColors.push(options.callbacks.labelTextColor.call(me, tooltipItem, me._chart)); + }); + me.labelColors = labelColors; + me.labelTextColors = labelTextColors; + me.dataPoints = tooltipItems; + return tooltipItems; + } + update(changed) { + var me = this; + var options = me.options; + var active = me._active; + var properties; + if (!active.length) { + if (me.opacity !== 0) { + properties = { + opacity: 0 + }; + } + } else { + var data = me._chart.data; + var position = positioners[options.position].call(me, active, me._eventPosition); + var tooltipItems = me._createItems(); + me.title = me.getTitle(tooltipItems, data); + me.beforeBody = me.getBeforeBody(tooltipItems, data); + me.body = me.getBody(tooltipItems, data); + me.afterBody = me.getAfterBody(tooltipItems, data); + me.footer = me.getFooter(tooltipItems, data); + var size = me._size = getTooltipSize(me); + var positionAndSize = _extends({}, position, size); + var alignment = determineAlignment(me._chart, options, positionAndSize); + var backgroundPoint = getBackgroundPoint(options, positionAndSize, alignment, me._chart); + me.xAlign = alignment.xAlign; + me.yAlign = alignment.yAlign; + properties = { + opacity: 1, + x: backgroundPoint.x, + y: backgroundPoint.y, + width: size.width, + height: size.height, + caretX: position.x, + caretY: position.y + }; + } + if (properties) { + me._resolveAnimations().update(me, properties); + } + if (changed && options.custom) { + options.custom.call(me); + } + } + drawCaret(tooltipPoint, ctx, size) { + var caretPosition = this.getCaretPosition(tooltipPoint, size); + ctx.lineTo(caretPosition.x1, caretPosition.y1); + ctx.lineTo(caretPosition.x2, caretPosition.y2); + ctx.lineTo(caretPosition.x3, caretPosition.y3); + } + getCaretPosition(tooltipPoint, size) { + var { + xAlign, + yAlign, + options + } = this; + var { + cornerRadius, + caretSize + } = options; + var { + x: ptX, + y: ptY + } = tooltipPoint; + var { + width, + height + } = size; + var x1, x2, x3, y1, y2, y3; + if (yAlign === 'center') { + y2 = ptY + height / 2; + if (xAlign === 'left') { + x1 = ptX; + x2 = x1 - caretSize; + } else { + x1 = ptX + width; + x2 = x1 + caretSize; + } + x3 = x1; + y1 = y2 + caretSize; + y3 = y2 - caretSize; + } else { + if (xAlign === 'left') { + x2 = ptX + cornerRadius + caretSize; + } else if (xAlign === 'right') { + x2 = ptX + width - cornerRadius - caretSize; + } else { + x2 = this.caretX; + } + x1 = x2 - caretSize; + x3 = x2 + caretSize; + if (yAlign === 'top') { + y1 = ptY; + y2 = y1 - caretSize; + } else { + y1 = ptY + height; + y2 = y1 + caretSize; + } + y3 = y1; + } + return { + x1, + x2, + x3, + y1, + y2, + y3 + }; + } + drawTitle(pt, ctx) { + var me = this; + var options = me.options; + var title = me.title; + var length = title.length; + var titleFontSize, titleSpacing, i; + if (length) { + var rtlHelper = getRtlHelper(options.rtl, me.x, me.width); + pt.x = getAlignedX(me, options.titleAlign); + ctx.textAlign = rtlHelper.textAlign(options.titleAlign); + ctx.textBaseline = 'middle'; + titleFontSize = options.titleFontSize; + titleSpacing = options.titleSpacing; + ctx.fillStyle = options.titleFontColor; + ctx.font = helpers.fontString(titleFontSize, options.titleFontStyle, options.titleFontFamily); + for (i = 0; i < length; ++i) { + ctx.fillText(title[i], rtlHelper.x(pt.x), pt.y + titleFontSize / 2); + pt.y += titleFontSize + titleSpacing; + if (i + 1 === length) { + pt.y += options.titleMarginBottom - titleSpacing; + } + } + } + } + _drawColorBox(ctx, pt, i, rtlHelper) { + var me = this; + var options = me.options; + var labelColors = me.labelColors[i]; + var { + boxHeight, + boxWidth, + bodyFontSize + } = options; + var colorX = getAlignedX(me, 'left'); + var rtlColorX = rtlHelper.x(colorX); + var yOffSet = boxHeight < bodyFontSize ? (bodyFontSize - boxHeight) / 2 : 0; + var colorY = pt.y + yOffSet; + ctx.fillStyle = options.multiKeyBackground; + ctx.fillRect(rtlHelper.leftForLtr(rtlColorX, boxWidth), colorY, boxWidth, boxHeight); + ctx.lineWidth = 1; + ctx.strokeStyle = labelColors.borderColor; + ctx.strokeRect(rtlHelper.leftForLtr(rtlColorX, boxWidth), colorY, boxWidth, boxHeight); + ctx.fillStyle = labelColors.backgroundColor; + ctx.fillRect(rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - 2), colorY + 1, boxWidth - 2, boxHeight - 2); + ctx.fillStyle = me.labelTextColors[i]; + } + drawBody(pt, ctx) { + var me = this; + var { + body, + options + } = me; + var { + bodyFontSize, + bodySpacing, + bodyAlign, + displayColors, + boxHeight, + boxWidth + } = options; + var bodyLineHeight = bodyFontSize; + var xLinePadding = 0; + var rtlHelper = getRtlHelper(options.rtl, me.x, me.width); + var fillLineOfText = function fillLineOfText(line) { + ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyLineHeight / 2); + pt.y += bodyLineHeight + bodySpacing; + }; + var bodyAlignForCalculation = rtlHelper.textAlign(bodyAlign); + var bodyItem, textColor, lines, i, j, ilen, jlen; + ctx.textAlign = bodyAlign; + ctx.textBaseline = 'middle'; + ctx.font = helpers.fontString(bodyFontSize, options.bodyFontStyle, options.bodyFontFamily); + pt.x = getAlignedX(me, bodyAlignForCalculation); + ctx.fillStyle = options.bodyFontColor; + helpers.each(me.beforeBody, fillLineOfText); + xLinePadding = displayColors && bodyAlignForCalculation !== 'right' ? bodyAlign === 'center' ? boxWidth / 2 + 1 : boxWidth + 2 : 0; + for (i = 0, ilen = body.length; i < ilen; ++i) { + bodyItem = body[i]; + textColor = me.labelTextColors[i]; + ctx.fillStyle = textColor; + helpers.each(bodyItem.before, fillLineOfText); + lines = bodyItem.lines; + if (displayColors && lines.length) { + me._drawColorBox(ctx, pt, i, rtlHelper); + bodyLineHeight = Math.max(bodyFontSize, boxHeight); + } + for (j = 0, jlen = lines.length; j < jlen; ++j) { + fillLineOfText(lines[j]); + bodyLineHeight = bodyFontSize; + } + helpers.each(bodyItem.after, fillLineOfText); + } + xLinePadding = 0; + bodyLineHeight = bodyFontSize; + helpers.each(me.afterBody, fillLineOfText); + pt.y -= bodySpacing; + } + drawFooter(pt, ctx) { + var me = this; + var options = me.options; + var footer = me.footer; + var length = footer.length; + var footerFontSize, i; + if (length) { + var rtlHelper = getRtlHelper(options.rtl, me.x, me.width); + pt.x = getAlignedX(me, options.footerAlign); + pt.y += options.footerMarginTop; + ctx.textAlign = rtlHelper.textAlign(options.footerAlign); + ctx.textBaseline = 'middle'; + footerFontSize = options.footerFontSize; + ctx.fillStyle = options.footerFontColor; + ctx.font = helpers.fontString(footerFontSize, options.footerFontStyle, options.footerFontFamily); + for (i = 0; i < length; ++i) { + ctx.fillText(footer[i], rtlHelper.x(pt.x), pt.y + footerFontSize / 2); + pt.y += footerFontSize + options.footerSpacing; + } + } + } + drawBackground(pt, ctx, tooltipSize) { + var { + xAlign, + yAlign, + options + } = this; + var { + x, + y + } = pt; + var { + width, + height + } = tooltipSize; + var radius = options.cornerRadius; + ctx.fillStyle = options.backgroundColor; + ctx.strokeStyle = options.borderColor; + ctx.lineWidth = options.borderWidth; + ctx.beginPath(); + ctx.moveTo(x + radius, y); + if (yAlign === 'top') { + this.drawCaret(pt, ctx, tooltipSize); + } + ctx.lineTo(x + width - radius, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); + if (yAlign === 'center' && xAlign === 'right') { + this.drawCaret(pt, ctx, tooltipSize); + } + ctx.lineTo(x + width, y + height - radius); + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); + if (yAlign === 'bottom') { + this.drawCaret(pt, ctx, tooltipSize); + } + ctx.lineTo(x + radius, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); + if (yAlign === 'center' && xAlign === 'left') { + this.drawCaret(pt, ctx, tooltipSize); + } + ctx.lineTo(x, y + radius); + ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.closePath(); + ctx.fill(); + if (options.borderWidth > 0) { + ctx.stroke(); + } + } + _updateAnimationTarget() { + var me = this; + var chart = me._chart; + var options = me.options; + var anims = me.$animations; + var animX = anims && anims.x; + var animY = anims && anims.y; + if (animX || animY) { + var position = positioners[options.position].call(me, me._active, me._eventPosition); + if (!position) { + return; + } + var size = me._size = getTooltipSize(me); + var positionAndSize = _extends({}, position, me._size); + var alignment = determineAlignment(chart, options, positionAndSize); + var point = getBackgroundPoint(options, positionAndSize, alignment, chart); + if (animX._to !== point.x || animY._to !== point.y) { + me.xAlign = alignment.xAlign; + me.yAlign = alignment.yAlign; + me.width = size.width; + me.height = size.height; + me.caretX = position.x; + me.caretY = position.y; + me._resolveAnimations().update(me, point); + } + } + } + draw(ctx) { + var me = this; + var options = me.options; + var opacity = me.opacity; + if (!opacity) { + return; + } + me._updateAnimationTarget(); + var tooltipSize = { + width: me.width, + height: me.height + }; + var pt = { + x: me.x, + y: me.y + }; + opacity = Math.abs(opacity) < 1e-3 ? 0 : opacity; + var hasTooltipContent = me.title.length || me.beforeBody.length || me.body.length || me.afterBody.length || me.footer.length; + if (options.enabled && hasTooltipContent) { + ctx.save(); + ctx.globalAlpha = opacity; + me.drawBackground(pt, ctx, tooltipSize); + helpers.rtl.overrideTextDirection(ctx, options.textDirection); + pt.y += options.yPadding; + me.drawTitle(pt, ctx); + me.drawBody(pt, ctx); + me.drawFooter(pt, ctx); + helpers.rtl.restoreTextDirection(ctx, options.textDirection); + ctx.restore(); + } + } + handleEvent(e, replay) { + var me = this; + var options = me.options; + var lastActive = me._active || []; + var changed = false; + var active = []; + if (e.type !== 'mouseout') { + active = me._chart.getElementsAtEventForMode(e, options.mode, options, replay); + if (options.reverse) { + active.reverse(); + } + } + changed = replay || !helpers._elementsEqual(active, lastActive); + if (changed) { + me._active = active; + if (options.enabled || options.custom) { + me._eventPosition = { + x: e.x, + y: e.y + }; + me.update(true); + } + } + return changed; + } +} +Tooltip.positioners = positioners; +var tooltip = { + id: 'tooltip', + _element: Tooltip, + positioners, + afterInit(chart) { + var tooltipOpts = chart.options.tooltips; + if (tooltipOpts) { + chart.tooltip = new Tooltip({ + _chart: chart + }); + } + }, + beforeUpdate(chart) { + if (chart.tooltip) { + chart.tooltip.initialize(); + } + }, + reset(chart) { + if (chart.tooltip) { + chart.tooltip.initialize(); + } + }, + afterDraw(chart) { + var tooltip = chart.tooltip; + var args = { + tooltip + }; + if (pluginsCore.notify(chart, 'beforeTooltipDraw', [args]) === false) { + return; + } + tooltip.draw(chart.ctx); + pluginsCore.notify(chart, 'afterTooltipDraw', [args]); + }, + afterEvent(chart, e, replay) { + if (chart.tooltip) { + var useFinalPosition = replay; + chart.tooltip.handleEvent(e, useFinalPosition); + } + } +}; + +var plugins = { + filler, + legend, + title, + tooltip +}; + +Chart.helpers = helpers; +Chart._adapters = _adapters; +Chart.Animation = Animation; +Chart.Animator = Animator$1; +Chart.animationService = Animations; +Chart.controllers = controllers; +Chart.DatasetController = DatasetController; +Chart.defaults = defaults; +Chart.Element = Element; +Chart.elements = elements; +Chart.Interaction = Interaction; +Chart.layouts = layouts; +Chart.platforms = platforms; +Chart.plugins = pluginsCore; +Chart.Scale = Scale; +Chart.scaleService = scaleService; +Chart.Ticks = Ticks; +Object.keys(scales).forEach(key => Chart.scaleService.registerScale(scales[key])); +for (var k in plugins) { + if (Object.prototype.hasOwnProperty.call(plugins, k)) { + Chart.plugins.register(plugins[k]); + } +} +if (typeof window !== 'undefined') { + window.Chart = Chart; +} + +export default Chart; diff --git a/dist/next/Chart.esm.min.js b/dist/next/Chart.esm.min.js new file mode 100644 index 0000000000..d46af0f7c2 --- /dev/null +++ b/dist/next/Chart.esm.min.js @@ -0,0 +1,13 @@ +/*! + * Chart.js v3.0.0-alpha + * https://www.chartjs.org + * (c) 2020 Chart.js Contributors + * Released under the MIT License + */ +function t(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function e(){return(e=Object.assign||function(t){for(var e=1;e("number"==typeof t||t instanceof Number)&&isFinite(+t);function d(t,e){return void 0===t?e:t}function c(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function u(t,e,i,a){var r,n,o;if(s(t))if(n=t.length,a)for(r=n-1;r>=0;r--)e.call(i,t[r],r);else for(r=0;ra&&(a=n),a}function D(t,e,i,a){var r=(a=a||{}).data=a.data||{},n=a.garbageCollect=a.garbageCollect||[];a.font!==e&&(r=a.data={},n=a.garbageCollect=[],a.font=e),t.save(),t.font=e;var o,l,h,d,c,u=0,f=i.length;for(o=0;oi.length){for(o=0;o0&&t.stroke()}}function C(t,e){return t.x>e.left-.5&&t.xe.top-.5&&t.yt-e).pop(),i}var W=Math.log10||function(t){var e=Math.log(t)*Math.LOG10E,i=Math.round(e);return t===Math.pow(10,i)?i:e};function N(t){return!isNaN(parseFloat(t))&&isFinite(t)}function H(t,e,i){return Math.abs(t-e)=t}function Y(t,e,i){var a,r,n;for(a=0,r=t.length;a0?1:-1};function X(t){return t*(R/180)}function q(t){return t*(180/R)}function $(t){if(h(t)){for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i}}function K(t,e){var i=e.x-t.x,a=e.y-t.y,r=Math.sqrt(i*i+a*a),n=Math.atan2(a,i);return n<-.5*R&&(n+=z),{angle:n,distance:r}}function G(t,e){return(t-e+B)%z-R}function Z(t){return(t%z+z)%z}function Q(t,e,i){var a=Z(t),r=Z(e),n=Z(i),o=Z(r-a),s=Z(n-a),l=Z(a-r),h=Z(a-n);return a===r||a===n||o>s&&l({model:t,deltaK:0,mK:0})),c=d.length;for(e=0;e0?d[e-1]:null,(r=e0?d[e-1]:null,r=e!t.skip)),"monotone"===e.cubicInterpolationMode)at(t);else{var l=a?t[t.length-1]:t[0];for(r=0,n=t.length;r0&&C(t[i-1],e)&&(r.controlPointPreviousX=rt(r.controlPointPreviousX,e.left,e.right),r.controlPointPreviousY=rt(r.controlPointPreviousY,e.top,e.bottom)),i-1?i*parseInt(e,10)/100:parseInt(e,10)}function ft(t){var e=lt(t);if(!e)return"number"==typeof t.clientWidth?t.clientWidth:t.width;var i=e.clientWidth,a=i-ut(e,"padding-left",i)-ut(e,"padding-right",i),r=function(t){return dt(t,"max-width","clientWidth")}(t);return isNaN(r)?a:Math.min(a,r)}function pt(t){var e=lt(t);if(!e)return"number"==typeof t.clientHeight?t.clientHeight:t.height;var i=e.clientHeight,a=i-ut(e,"padding-top",i)-ut(e,"padding-bottom",i),r=function(t){return dt(t,"max-height","clientHeight")}(t);return isNaN(r)?a:Math.min(a,r)}var gt=Object.freeze({__proto__:null,_getParentNode:lt,getStyle:ct,getRelativePosition:function(t,e){var i,a,r=t.originalEvent||t,n=e.canvas,o=n.getBoundingClientRect(),s=r.touches;s&&s.length>0?(i=s[0].clientX,a=s[0].clientY):(i=r.clientX,a=r.clientY);var l=parseFloat(ct(n,"padding-left")),h=parseFloat(ct(n,"padding-top")),d=parseFloat(ct(n,"padding-right")),c=parseFloat(ct(n,"padding-bottom")),u=o.right-o.left-l-d,f=o.bottom-o.top-h-c;return{x:i=Math.round((i-o.left-l)/u*n.width/e.currentDevicePixelRatio),y:a=Math.round((a-o.top-h)/f*n.height/e.currentDevicePixelRatio)}},getMaximumWidth:ft,getMaximumHeight:pt,retinaScale:function(t,e){var i=t.currentDevicePixelRatio=e||"undefined"!=typeof window&&window.devicePixelRatio||1,{canvas:a,width:r,height:n}=t;a.height=n*i,a.width=r*i,t.ctx.setTransform(i,0,0,i,0,0),!a.style||a.style.height||a.style.width||(a.style.height=n+"px",a.style.width=r+"px")}}),vt={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*(Math.PI/2)),easeOutSine:t=>Math.sin(t*(Math.PI/2)),easeInOutSine:t=>-.5*(Math.cos(Math.PI*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*--t)),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic(t){var e,i=0;return 0===t?0:1===t?1:(i||(i=.3),e=i/(2*Math.PI)*Math.asin(1),-1*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i))},easeOutElastic(t){var e,i=0;return 0===t?0:1===t?1:(i||(i=.3),e=i/(2*Math.PI)*Math.asin(1),1*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/i)+1)},easeInOutElastic(t){var e,i=0;return 0===t?0:2==(t/=.5)?1:(i||(i=.45),e=i/(2*Math.PI)*Math.asin(1),t<1?1*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)*-.5:1*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)*.5+1)},easeInBack(t){var e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){var e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-vt.easeOutBounce(1-t),easeOutBounce:t=>t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,easeInOutBounce:t=>t<.5?.5*vt.easeInBounce(2*t):.5*vt.easeOutBounce(2*t-1)+.5};var mt=new class{constructor(){this.color="rgba(0,0,0,0.1)",this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.fontColor="#666",this.fontFamily="'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",this.fontSize=12,this.fontStyle="normal",this.lineHeight=1.2,this.hover={onHover:null,mode:"nearest",intersect:!0},this.maintainAspectRatio=!0,this.onClick=null,this.responsive=!0,this.showLines=!0,this.plugins=void 0,this.scale=void 0,this.legend=void 0,this.title=void 0,this.tooltips=void 0,this.doughnut=void 0}set(t,e){return g(this[t]||(this[t]={}),e)}};function bt(t,e){var i=(""+t).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}function xt(t){var e,i,a,r;return l(t)?(e=+t.top||0,i=+t.right||0,a=+t.bottom||0,r=+t.left||0):e=i=a=r=+t||0,{top:e,right:i,bottom:a,left:r,height:e+a,width:r+i}}function yt(t){var e=d(t.fontSize,mt.fontSize);"string"==typeof e&&(e=parseInt(e,10));var i={family:d(t.fontFamily,mt.fontFamily),lineHeight:bt(d(t.lineHeight,mt.lineHeight),e),size:e,style:d(t.fontStyle,mt.fontStyle),weight:null,string:""};return i.string=function(t){return!t||o(t.size)||o(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}(i),i}function _t(t,e,i,a){var r,n,o,l=!0;for(r=0,n=t.length;rt+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,i):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function kt(t,e){var i,a;"ltr"!==e&&"rtl"!==e||(a=[(i=t.canvas.style).getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=a)}function St(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}var Pt=Object.freeze({__proto__:null,getRtlAdapter:wt,overrideTextDirection:kt,restoreTextDirection:St}),Dt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},At="0123456789ABCDEF",Ot=t=>At[15&t],Ct=t=>At[(240&t)>>4]+At[15&t],Tt=t=>(240&t)>>4==(15&t); +/*! + * @kurkle/color v0.1.7 + * https://github.com/kurkle/color#readme + * (c) 2020 Jukka Kurkela + * Released under the MIT License + */function Ft(t){var e=function(t){return Tt(t.r)&&Tt(t.g)&&Tt(t.b)&&Tt(t.a)}(t)?Ot:Ct;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function It(t){return t+.5|0}var Lt=(t,e,i)=>Math.max(Math.min(t,i),e);function Et(t){return Lt(It(2.55*t),0,255)}function Rt(t){return Lt(It(255*t),0,255)}function zt(t){return Lt(It(t/2.55)/100,0,1)}function Bt(t){return Lt(It(100*t),0,100)}var Vt=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;var Wt=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Nt(t,e,i){var a=e*Math.min(i,1-i),r=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(e+t/30)%12;return i-a*Math.max(Math.min(r-3,9-r,1),-1)};return[r(0),r(8),r(4)]}function Ht(t,e,i){var a=function(a){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(a+t/60)%6;return i-i*e*Math.max(Math.min(r,4-r,1),0)};return[a(5),a(3),a(1)]}function jt(t,e,i){var a,r=Nt(t,1,.5);for(e+i>1&&(e*=a=1/(e+i),i*=a),a=0;a<3;a++)r[a]*=1-e-i,r[a]+=e;return r}function Yt(t){var e,i,a,r=t.r/255,n=t.g/255,o=t.b/255,s=Math.max(r,n,o),l=Math.min(r,n,o),h=(s+l)/2;return s!==l&&(a=s-l,i=h>.5?a/(2-s-l):a/(s+l),e=60*(e=s===r?(n-o)/a+(n>16&255,a>>8&255,255&a]}return o}({OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"});function Zt(t,e,i){if(t){var a=Yt(t);a[e]=Math.max(0,Math.min(a[e]+a[e]*i,0===e?360:1)),a=Xt(a),t.r=a[0],t.g=a[1],t.b=a[2]}}function Qt(t,i){return t?e(i||{},t):t}function Jt(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=Rt(t[3]))):(e=Qt(t,{r:0,g:0,b:0,a:1})).a=Rt(e.a),e}function te(t){return"r"===t.charAt(0)?function(t){var e,i,a,r=Vt.exec(t),n=255;if(r){if(r[7]!==e){var o=+r[7];n=255&(r[8]?Et(o):255*o)}return e=+r[1],i=+r[3],a=+r[5],{r:e=255&(r[2]?Et(e):e),g:i=255&(r[4]?Et(i):i),b:a=255&(r[6]?Et(a):a),a:n}}}(t):$t(t)}Gt.transparent=[0,0,0,0];class ee{constructor(t){if(t instanceof ee)return t;var e,i,a,r,n=typeof t;"object"===n?e=Jt(t):"string"===n&&(r=(i=t).length,"#"===i[0]&&(4===r||5===r?a={r:255&17*Dt[i[1]],g:255&17*Dt[i[2]],b:255&17*Dt[i[3]],a:5===r?17*Dt[i[4]]:255}:7!==r&&9!==r||(a={r:Dt[i[1]]<<4|Dt[i[2]],g:Dt[i[3]]<<4|Dt[i[4]],b:Dt[i[5]]<<4|Dt[i[6]],a:9===r?Dt[i[7]]<<4|Dt[i[8]]:255})),e=a||function(t){var e=Gt[t];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}(t)||te(t)),this._rgb=e,this._valid=!!e}get valid(){return this._valid}get rgb(){var t=Qt(this._rgb);return t&&(t.a=zt(t.a)),t}set rgb(t){this._rgb=Jt(t)}rgbString(){return(t=this._rgb)&&(t.a<255?"rgba(".concat(t.r,", ").concat(t.g,", ").concat(t.b,", ").concat(zt(t.a),")"):"rgb(".concat(t.r,", ").concat(t.g,", ").concat(t.b,")"));var t}hexString(){return Ft(this._rgb)}hslString(){return function(t){if(t){var e=Yt(t),i=e[0],a=Bt(e[1]),r=Bt(e[2]);return t.a<255?"hsla(".concat(i,", ").concat(a,"%, ").concat(r,"%, ").concat(zt(t.a),")"):"hsl(".concat(i,", ").concat(a,"%, ").concat(r,"%)")}}(this._rgb)}mix(t,e){if(t){var i,a=this.rgb,r=t.rgb,n=e===i?.5:e,o=2*n-1,s=a.a-r.a,l=((o*s==-1?o:(o+s)/(1+o*s))+1)/2;i=1-l,a.r=255&l*a.r+i*r.r+.5,a.g=255&l*a.g+i*r.g+.5,a.b=255&l*a.b+i*r.b+.5,a.a=n*a.a+(1-n)*r.a,this.rgb=a}return this}clone(){return new ee(this.rgb)}alpha(t){return this._rgb.a=Rt(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){var t=this._rgb,e=It(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.a*=1+t,this}negate(){var t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return Zt(this._rgb,2,t),this}darken(t){return Zt(this._rgb,2,-t),this}saturate(t){return Zt(this._rgb,1,t),this}desaturate(t){return Zt(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=Yt(t);i[0]=qt(i[0]+e),i=Xt(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function ie(t){return new ee(t)}var ae=t=>t instanceof CanvasGradient||t instanceof CanvasPattern;var re=function(e){for(var a=1;ae+" "+t+"px "+i,color:function(t){return ae(t)?t:ie(t)},getHoverColor:function(t){return ae(t)?t:ie(t).saturate(.5).darken(.1).hexString()}});var ne=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,a){var r=e.listeners[a]||[],n=e.duration;r.forEach(a=>a({chart:t,numSteps:n,currentStep:i-e.start}))}_refresh(){var t=this;t._request||(t._running=!0,t._request=re.requestAnimFrame.call(window,()=>{t._update(),t._request=null,t._running&&t._refresh()}))}_update(){var t=this,e=Date.now(),i=0;t._charts.forEach((a,r)=>{if(a.running&&a.items.length){for(var n,o=a.items,s=o.length-1,l=!1;s>=0;--s)(n=o[s])._active?(n.tick(e),l=!0):(o[s]=o[o.length-1],o.pop());l&&r.draw(),r.options.animation.debug&&function(t,e,i,a){var r=1e3/(i-a)|0,n=t.ctx;n.save(),n.clearRect(0,0,50,24),n.fillStyle="black",n.textAlign="right",e&&(n.fillText(e,50,8),n.fillText(r+" fps",50,18)),n.restore()}(r,o.length,e,t._lastDate),t._notify(r,a,e,"progress"),o.length||(a.running=!1,t._notify(r,a,e,"complete")),i+=o.length}}),t._lastDate=e,0===i&&(t._running=!1)}_getAnims(t){var e=this._charts,i=e.get(t);return i||(i={running:!1,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){var e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((t,e)=>Math.max(t,e._duration),0),this._refresh())}running(t){if(!this._running)return!1;var e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){var e=this._charts.get(t);if(e&&e.items.length){for(var i=e.items,a=i.length-1;a>=0;--a)i[a].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}}remove(t){return this._charts.delete(t)}},oe={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){var a=re.color(t||"transparent"),r=a.valid&&re.color(e||"transparent");return r&&r.valid?r.mix(a,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class se{constructor(t,e,i,a){var r=e[i];a=_t([t.to,a,r,t.from]);var n=_t([t.from,r,a]);this._active=!0,this._fn=t.fn||oe[t.type||typeof n],this._easing=vt[t.easing||"linear"],this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=i,this._from=n,this._to=a}active(){return this._active}update(t,e,i){var a=this;if(a._active){var r=a._target[a._prop],n=i-a._start,o=a._duration-n;a._start=i,a._duration=Math.floor(Math.max(o,t.duration)),a._to=_t([t.to,e,r,t.from]),a._from=_t([t.from,r,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1)}tick(t){var e,i=this,a=t-i._start,r=i._duration,n=i._prop,o=i._from,s=i._loop,l=i._to;i._active=o!==l&&(s||a1?2-e:e,e=i._easing(Math.min(1,Math.max(0,e))),i._target[n]=i._fn(o,l,e)):i._target[n]=l}}var le=["borderColor","backgroundColor"];mt.set("animation",{duration:1e3,easing:"easeOutQuart",onProgress:a,onComplete:a,colors:{type:"color",properties:le},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]},active:{duration:400},resize:{duration:0},show:{colors:{type:"color",properties:le,from:"transparent"},visible:{type:"boolean",duration:0}},hide:{colors:{type:"color",properties:le,to:"transparent"},visible:{type:"boolean",easing:"easeInExpo"}}});class he{constructor(t,e){this._chart=t,this._properties=new Map,this.configure(e)}configure(t){if(l(t)){var i=this._properties,a=function(t){var e={};return Object.keys(t).forEach(i=>{var a=t[i];l(a)||(e[i]=a)}),e}(t);Object.keys(t).forEach(r=>{var n=t[r];l(n)&&(n.properties||[r]).forEach(t=>{i.has(t)?t===r&&i.set(t,e({},i.get(t),n)):i.set(t,e({},a,n))})})}}_animateOptions(t,i){var a=i.options,r=[];if(!a)return r;var n=t.options;return n?(n.$shared&&(t.options=n=e({},n,{$shared:!1,$animations:{}})),r=this._createAnimations(n,a)):t.options=a,r}_createAnimations(t,e){var i,a=this._properties,r=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),s=Date.now();for(i=o.length-1;i>=0;--i){var l=o[i];if("$"!==l.charAt(0))if("options"!==l){var h=e[l],d=n[l],c=a.get(l);if(d){if(c&&d.active()){d.update(c,h,s);continue}d.cancel()}c&&c.duration?(n[l]=d=new se(c,t,l,h),r.push(d)):t[l]=h}else r.push(...this._animateOptions(t,e))}return r}update(t,i){if(0===this._properties.size)return function(t,i){var a=t.options,r=i.options;a&&r&&!r.$shared&&(a.$shared?t.options=e({},a,r,{$shared:!1}):e(a,r),delete i.options)}(t,i),void e(t,i);var a=this._createAnimations(t,i);return a.length?(ne.add(this._chart,a),!0):void 0}}var de=re.options.resolve,ce=["push","pop","shift","splice","unshift"];function ue(t,e){var i=t&&t.options||{},a=i.reverse,r=void 0===i.min?e:0,n=void 0===i.max?e:0;return{start:a?n:r,end:a?r:n}}function fe(t,e){var i=t._chartjs;if(i){var a=i.listeners,r=a.indexOf(e);-1!==r&&a.splice(r,1),a.length>0||(ce.forEach(e=>{delete t[e]}),delete t._chartjs)}}function pe(t,e){var i,a,r=[],n=t._getSortedDatasetMetas(e);for(i=0,a=n.length;ii[t].axis===e).shift()}class ye{constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedAnimations={},this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this._config=void 0,this._parsing=!1,this._data=void 0,this._dataCopy=void 0,this._objectData=void 0,this._labels=void 0,this._scaleStacked={},this.initialize()}initialize(){var t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=ve(t.vScale,t),this.addElements()}updateIndex(t){this.index=t}linkScales(){var t=this,e=t.chart,i=t._cachedMeta,a=t.getDataset(),r=i.xAxisID=a.xAxisID||xe(e,"x"),n=i.yAxisID=a.yAxisID||xe(e,"y"),o=i.rAxisID=a.rAxisID||xe(e,"r");i.xScale=t.getScaleForId(r),i.yScale=t.getScaleForId(n),i.rScale=t.getScaleForId(o),i.iScale=t._getIndexScale(),i.vScale=t._getValueScale()}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}getValueScaleId(){return this._cachedMeta.yAxisID}getIndexScaleId(){return this._cachedMeta.xAxisID}_getValueScale(){return this.getScaleForId(this.getValueScaleId())}_getIndexScale(){return this.getScaleForId(this.getIndexScaleId())}_getOtherScale(t){var e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){this._data&&fe(this._data,this)}_dataCheck(){var t,e,i=this,a=i.getDataset(),r=a.data||(a.data=[]);if(re.isObject(r)){if(i._objectData===r)return!1;i._data=function(t){var e,i,a,r=Object.keys(t),n=new Array(r.length);for(e=0,i=r.length;e{var i="_onData"+e.charAt(0).toUpperCase()+e.slice(1),a=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(){for(var e=arguments.length,r=new Array(e),n=0;n{"function"==typeof t[i]&&t[i](...r)}),o}})}))),i._data=r}return!0}_labelCheck(){var t=this._cachedMeta.iScale,e=t?t.getLabels():this.chart.data.labels;return this._labels!==e&&(this._labels=e,!0)}addElements(){var t=this,e=t._cachedMeta;t._dataCheck();for(var i=t._data,a=e.data=new Array(i.length),r=0,n=i.length;r{delete t._stacks[r.vScale.id][r.index]}),r.stack=n.stack),t._resyncElements(e||i||a||o),o&&be(t,r._parsed)}configure(){var t=this;t._config=re.merge({},[t.chart.options[t._type].datasets,t.getDataset()],{merger(t,e,i){"data"!==t&&re._merger(t,e,i)}}),t._parsing=de([t._config.parsing,t.chart.options.parsing,!0])}parse(t,e){var i,a,r,n,o=this,{_cachedMeta:s,_data:l}=o,{iScale:h,vScale:d,_stacked:c}=s,u=h.axis,f=!0;if(t>0&&(f=s._sorted,n=s._parsed[t-1]),!1===o._parsing)s._parsed=l,s._sorted=!0;else{for(a=re.isArray(l[t])?o.parseArrayData(s,l,t,e):re.isObject(l[t])?o.parseObjectData(s,l,t,e):o.parsePrimitiveData(s,l,t,e),i=0;in||g=0;--i)if(!m()){v();break}return{min:u,max:f}}getAllParsedValues(t){var e,i,a,r=this._cachedMeta._parsed,n=[];for(e=0,i=r.length;e-1!==t.indexOf("Color")&&!(t in e)),o=n.length-1;o>=0;o--)i=n[o],e[i]=a(r[i])}getStyle(t,e){var i=this,a=i._cachedMeta.dataset;i._config||i.configure();var r=a&&void 0===t?i.resolveDatasetElementOptions(e):i.resolveDataElementOptions(t||0,e&&"active");return e&&i._addAutomaticHoverColors(t,r),r}_getContext(t,e){return{chart:this.chart,dataIndex:t,dataset:this.getDataset(),datasetIndex:this.index,active:e}}resolveDatasetElementOptions(t){var e,i,a,r,n,o=this,s=o.chart,l=o._config,h=s.options.elements[o.datasetElementType._type]||{},d=o.datasetElementOptions,c={},u=o._getContext(void 0,t);for(e=0,i=d.length;ea?(e._insertElements(a,r-a),t&&a&&e.parse(0,a)):r{r[t]=a[t]&&a[t].active?a[t]._to:i[t]}),r}}t(_e,"extend",b);var Me=2*Math.PI;function we(t,e){var{startAngle:i,endAngle:a,pixelMargin:r,x:n,y:o}=e,s=r/e.outerRadius;t.beginPath(),t.arc(n,o,e.outerRadius,i-s,a+s),e.innerRadius>r?(s=r/e.innerRadius,t.arc(n,o,e.innerRadius-r,a+s,i-s,!0)):t.arc(n,o,r,a+Math.PI/2,i-Math.PI/2),t.closePath(),t.clip()}function ke(t,e,i){var a=e.options,r="inner"===a.borderAlign;r?(t.lineWidth=2*a.borderWidth,t.lineJoin="round"):(t.lineWidth=a.borderWidth,t.lineJoin="bevel"),i.fullCircles&&function(t,e,i,a){var r,n=i.endAngle;for(a&&(i.endAngle=i.startAngle+Me,we(t,i),i.endAngle=n,i.endAngle===i.startAngle&&i.fullCircles&&(i.endAngle+=Me,i.fullCircles--)),t.beginPath(),t.arc(i.x,i.y,i.innerRadius,i.startAngle+Me,i.startAngle,!0),r=0;r=Me||Q(r,o,s))&&(n>=l&&n<=h)}getCenterPoint(t){var{x:e,y:i,startAngle:a,endAngle:r,innerRadius:n,outerRadius:o}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),s=(a+r)/2,l=(n+o)/2;return{x:e+Math.cos(s)*l,y:i+Math.sin(s)*l}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){var e,i=this,a=i.options,r="inner"===a.borderAlign?.33:0,n={x:i.x,y:i.y,innerRadius:i.innerRadius,outerRadius:Math.max(i.outerRadius-r,0),pixelMargin:r,startAngle:i.startAngle,endAngle:i.endAngle,fullCircles:Math.floor(i.circumference/Me)};if(t.save(),t.fillStyle=a.backgroundColor,t.strokeStyle=a.borderColor,n.fullCircles){for(n.endAngle=n.startAngle+Me,t.beginPath(),t.arc(n.x,n.y,n.outerRadius,n.startAngle,n.endAngle),t.arc(n.x,n.y,n.innerRadius,n.endAngle,n.startAngle,!0),t.closePath(),e=0;e0?e.y:t.y}}function Ae(t,e,i,a){var r={x:t.controlPointNextX,y:t.controlPointNextY},n={x:e.controlPointPreviousX,y:e.controlPointPreviousY},o=Pe(t,r,i),s=Pe(r,n,i),l=Pe(n,e,i),h=Pe(o,s,i),d=Pe(s,l,i);return Pe(h,d,i)}function Oe(t){return"angle"===t?{between:Q,compare:G,normalize:Z}:{between:(t,e,i)=>t>=e&&t<=i,compare:(t,e)=>t-e,normalize:t=>t}}function Ce(t,e,i,a){return{start:t%a,end:e%a,loop:i&&(e-t+1)%a==0}}function Te(t,e,i){if(!i)return[t];var a,r,n,o,{property:s,start:l,end:h}=i,d=e.length,{compare:c,between:u,normalize:f}=Oe(s),{start:p,end:g,loop:v}=function(t,e,i){var a,r,{property:n,start:o,end:s}=i,{between:l,normalize:h}=Oe(n),d=e.length,{start:c,end:u,loop:f}=t;if(f){for(c+=d,u+=d,a=0,r=d;ap&&c(r,l)>0?o:a),null===x||b&&0!==c(r,h)||(m.push(Ce(x,a,v,d)),x=null),o=a);return null!==x&&m.push(Ce(x,g,v,d)),m}function Fe(t,e){for(var i=[],a=t.segments,r=0;rl&&(l=y),m=(b*m+x)/++b):(s!==l&&(t.lineTo(m,l),t.lineTo(m,s),t.lineTo(m,h)),t.lineTo(x,y),o=_,b=0,s=l=y),h=y}}function ze(t){var e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._loop||e.tension||e.stepped||i)?Re:Ee}mt.set("elements",{line:{backgroundColor:Ie,borderCapStyle:"butt",borderColor:Ie,borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,fill:!0,tension:.4}});class Be extends _e{constructor(t){super(),this.options=void 0,this._loop=void 0,this._fullLoop=void 0,this._controlPointsUpdated=void 0,this._points=void 0,this._segments=void 0,t&&e(this,t)}updateControlPoints(t){var e=this;if(!e._controlPointsUpdated){var i=e.options;if(i.tension&&!i.stepped){var a=i.spanGaps?e._loop:e._fullLoop;nt(e._points,i,t,a)}}}set points(t){this._points=t,delete this._segments}get points(){return this._points}get segments(){return this._segments||(this._segments=function(t){var e=t.points,i=t.options.spanGaps,a=e.length;if(!a)return[];var r=!!t._loop,{start:n,end:o}=function(t,e,i,a){var r=0,n=e-1;if(i&&!a)for(;rr&&t[n%e].skip;)n--;return{start:r,end:n%=e}}(e,a,r,i);return!0===i?[{start:n,end:o,loop:r}]:function(t,e,i,a){var r,n=t.length,o=[],s=e,l=t[e];for(r=e+1;r<=i;++r){var h=t[r%n];h.skip||h.stop?l.skip||(a=!1,o.push({start:e%n,end:(r-1)%n,loop:a}),e=s=h.stop?r:null):(s=r,l.skip&&(e=r)),l=h}return null!==s&&o.push({start:e%n,end:s%n,loop:a}),o}(e,n,ot.x&&(e=je(e,"left","right")):t.base=o.left&&e<=o.right)&&(n||i>=o.top&&i<=o.bottom)}mt.set("elements",{rectangle:{backgroundColor:Ne,borderColor:Ne,borderSkipped:"bottom",borderWidth:0}});class qe extends _e{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,t&&e(this,t)}draw(t){var e,i,a,r,n,o=this.options,{inner:s,outer:l}=(i=He(e=this),a=i.right-i.left,r=i.bottom-i.top,n=Ue(e,a/2,r/2),{outer:{x:i.left,y:i.top,w:a,h:r},inner:{x:i.left+n.l,y:i.top+n.t,w:a-n.l-n.r,h:r-n.t-n.b}});t.save(),l.w===s.w&&l.h===s.h||(t.beginPath(),t.rect(l.x,l.y,l.w,l.h),t.clip(),t.rect(s.x,s.y,s.w,s.h),t.fillStyle=o.borderColor,t.fill("evenodd")),t.fillStyle=o.backgroundColor,t.fillRect(s.x,s.y,s.w,s.h),t.restore()}inRange(t,e,i){return Xe(this,t,e,i)}inXRange(t,e){return Xe(this,t,null,e)}inYRange(t,e){return Xe(this,null,t,e)}getCenterPoint(t){var{x:e,y:i,base:a,horizontal:r}=this.getProps(["x","y","base","horizontal"],t);return{x:r?(e+a)/2:e,y:r?i:(i+a)/2}}getRange(t){return"x"===t?this.width/2:this.height/2}}t(qe,"_type","rectangle");var $e=Object.freeze({__proto__:null,Arc:Se,Line:Be,Point:We,Rectangle:qe});function Ke(t,e,i,a){var r=i.parse(t[0],a),n=i.parse(t[1],a),o=Math.min(r,n),s=Math.max(r,n),l=o,h=s;Math.abs(o)>Math.abs(s)&&(l=s,h=o),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:r,end:n,min:o,max:s}}function Ge(t,e,i,a){var r,n,o,l,h=t.iScale,d=t.vScale,c=h.getLabels(),u=h===d,f=[];for(r=i,n=i+a;r0?Math.min(o,Math.abs(a-i)):o,i=a;return o}(a,r),pixels:r,start:a._startPixel,end:a._endPixel,stackCount:this._getStackCount(),scale:a}}_calculateBarValuePixels(t,e){var i,a,r=this._cachedMeta,n=r.vScale,o=e.minBarLength,s=this.getParsed(t),l=s._custom,h=s[n.axis],d=0,c=r._stacked?this.applyStack(n,s):h;c!==h&&(d=c-h,c=h),Ze(l)&&(h=l.barStart,c=l.barEnd-l.barStart,0!==h&&U(h)!==U(l.barEnd)&&(d=0),d+=h);var u=J(n.getPixelForValue(d),n._startPixel-10,n._endPixel+10);return a=(i=n.getPixelForValue(d+c))-u,void 0!==o&&Math.abs(a)0?a[t-1]:null,o=t""}}});class Je extends ye{parseObjectData(t,e,i,a){var r,n,o,{xScale:s,yScale:l}=t,h=[];for(r=i,n=i+a;r=0;--t)e=Math.max(e,this.getStyle(t,!0).radius);return e>0&&e}getLabelAndValue(t){var e=this._cachedMeta,{xScale:i,yScale:a}=e,r=this.getParsed(t),n=i.getLabelForValue(r.x),o=a.getLabelForValue(r.y),s=r._custom;return{label:e.label,value:"("+n+", "+o+(s?", "+s:"")+")"}}update(t){var e=this._cachedMeta.data;this.updateElements(e,0,t)}updateElements(t,e,i){for(var a=this,r="reset"===i,{xScale:n,yScale:o}=a._cachedMeta,s=a.resolveDataElementOptions(e,i),l=a.getSharedOptions(i,t[e],s),h=a.includeOptions(i,l),d=0;d{var a=t.getDatasetMeta(0).controller.getStyle(i);return{text:e,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,lineWidth:a.borderWidth,hidden:!t.getDataVisibility(i),index:i}}):[]}},onClick(t,e){this.chart.toggleDataVisibility(e.index),this.chart.update()}},cutoutPercentage:50,rotation:-ii,circumference:ei,tooltips:{callbacks:{title:()=>"",label(t,e){var i=e.labels[t.index],a=": "+e.datasets[t.datasetIndex].data[t.index];return s(i)?(i=i.slice())[0]+=a:i+=a,i}}}});class ai extends ye{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){var i,a,r=this.getDataset().data,n=this._cachedMeta;for(i=t,a=t+e;i=ti?-ei:s<-ti?ei:0)+e,h=Math.cos(s),d=Math.sin(s),c=Math.cos(l),u=Math.sin(l),f=s<=0&&l>=0||l>=ei,p=s<=ii&&l>=ii||l>=ei+ii,g=s<=-ii&&l>=-ii||l>=ti+ii,v=s===-ti||l>=ti?-1:Math.min(h,h*i,c,c*i),m=g?-1:Math.min(d,d*i,u,u*i),b=f?1:Math.max(h,h*i,c,c*i),x=p?1:Math.max(d,d*i,u,u*i);a=(b-v)/2,r=(x-m)/2,n=-(b+v)/2,o=-(x+m)/2}return{ratioX:a,ratioY:r,offsetX:n,offsetY:o}}(r.rotation,r.circumference,s),f=e.getMaxBorderWidth(),p=(a.right-a.left-f)/h,g=(a.bottom-a.top-f)/d,v=Math.max(Math.min(p,g)/2,0),m=(v-Math.max(v*s,0))/e._getVisibleDatasetWeightTotal();e.offsetX=c*v,e.offsetY=u*v,n.total=e.calculateTotal(),e.outerRadius=v-m*e._getRingWeightOffset(e.index),e.innerRadius=Math.max(e.outerRadius-m*l,0),e.updateElements(o,0,t)}_circumference(t,e){var i=this.chart.options,a=this._cachedMeta;return e&&i.animation.animateRotate?0:this.chart.getDataVisibility(t)?this.calculateCircumference(a._parsed[t]*i.circumference/ei):0}updateElements(t,e,i){var a,r=this,n="reset"===i,o=r.chart,s=o.chartArea,l=o.options,h=l.animation,d=(s.left+s.right)/2,c=(s.top+s.bottom)/2,u=n&&h.animateScale,f=u?0:r.innerRadius,p=u?0:r.outerRadius,g=r.resolveDataElementOptions(e,i),v=r.getSharedOptions(i,t[e],g),m=r.includeOptions(i,v),b=l.rotation;for(a=0;a0&&!isNaN(t)?ei*(Math.abs(t)/e):0}getMaxBorderWidth(t){var e,i,a,r,n,o=0,s=this.chart;if(!t)for(e=0,i=s.data.datasets.length;e0&&b.x-a.x>p};u&&(_.options=r.resolveDataElementOptions(v,i)),r.updateElement(m,v,_,i),a=b}r.updateSharedOptions(c,i)}resolveDatasetElementOptions(t){var e=this._config,i=this.chart.options,a=i.elements.line,r=super.resolveDatasetElementOptions(t);return r.spanGaps=d(e.spanGaps,i.spanGaps),r.tension=d(e.lineTension,a.tension),r.stepped=_t([e.stepped,a.stepped]),r}getMaxOverflow(){var t=this._cachedMeta,e=this._showLine&&t.dataset.options.borderWidth||0,i=t.data||[];if(!i.length)return e;var a=i[0].size(),r=i[i.length-1].size();return Math.max(e,a,r)/2}draw(){var t,e,i=this._ctx,a=this.chart,r=this._cachedMeta,n=r.data||[],o=a.chartArea,s=[],l=n.length;for(this._showLine&&r.dataset.draw(i,o),t=0;t{var a=t.getDatasetMeta(0).controller.getStyle(i);return{text:e,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,lineWidth:a.borderWidth,hidden:!t.getDataVisibility(i),index:i}}):[]}},onClick(t,e){this.chart.toggleDataVisibility(e.index),this.chart.update()}},tooltips:{callbacks:{title:()=>"",label:(t,e)=>e.labels[t.index]+": "+t.value}}});class ni extends ye{constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getIndexScaleId(){return this._cachedMeta.rAxisID}getValueScaleId(){return this._cachedMeta.rAxisID}update(t){var e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,t)}_updateRadius(){var t=this,e=t.chart,i=e.chartArea,a=e.options,r=Math.min(i.right-i.left,i.bottom-i.top),n=Math.max(r/2,0),o=(n-Math.max(a.cutoutPercentage?n/100*a.cutoutPercentage:1,0))/e.getVisibleDatasetCount();t.outerRadius=n-o*t.index,t.innerRadius=t.outerRadius-o}updateElements(t,e,i){var a,r=this,n="reset"===i,o=r.chart,s=r.getDataset(),l=o.options,h=l.animation,d=o.scales.r,c=d.xCenter,u=d.yCenter,f=X(l.startAngle)-.5*Math.PI,p=f;for(r._cachedMeta.count=r.countVisibleElements(),a=0;a{!isNaN(t.data[a])&&this.chart.getDataVisibility(a)&&i++}),i}_computeAngle(t){var e=this,i=e._cachedMeta.count,a=e.getDataset();if(isNaN(a.data[t])||!this.chart.getDataVisibility(t))return 0;var r={chart:e.chart,dataIndex:t,dataset:a,datasetIndex:e.index};return _t([e.chart.options.elements.arc.angle,2*Math.PI/i],r,t)}}ni.prototype.dataElementType=Se,ni.prototype.dataElementOptions=["backgroundColor","borderColor","borderWidth","borderAlign","hoverBackgroundColor","hoverBorderColor","hoverBorderWidth"],mt.set("pie",f(mt.doughnut)),mt.set("pie",{cutoutPercentage:0}),mt.set("radar",{spanGaps:!1,scales:{r:{type:"radialLinear"}},elements:{line:{tension:0}}});class oi extends ye{getIndexScaleId(){return this._cachedMeta.rAxisID}getValueScaleId(){return this._cachedMeta.rAxisID}getLabelAndValue(t){var e=this._cachedMeta.vScale,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}update(t){var e=this,i=e._cachedMeta,a=i.dataset,r=i.data||[],n={points:r,_loop:!0,_fullLoop:i.iScale.getLabels().length===r.length,options:e.resolveDatasetElementOptions()};e.updateElement(a,void 0,n,t),e.updateElements(r,0,t),a.updateControlPoints(e.chart.chartArea)}updateElements(t,e,i){var a,r=this.getDataset(),n=this.chart.scales.r,o="reset"===i;for(a=0;a"",label:t=>"("+t.label+", "+t.value+")"}}});var si={bar:Qe,bubble:Je,doughnut:ai,horizontalBar:class extends Qe{getValueScaleId(){return this._cachedMeta.xAxisID}getIndexScaleId(){return this._cachedMeta.yAxisID}},line:ri,polarArea:ni,pie:ai,radar:oi,scatter:ri};function li(t,e,i){for(var a,r=t.length-1,n=0;r-n>1;)t[a=n+r>>1][e]1;)t[a=n+r>>1][e]{var e=o[0].index,i=t.data[e];i&&!i.skip&&s.push({element:i,datasetIndex:t.index,index:e})}),s):[]},dataset(t,e,i,a){var r=di(e,t),n=i.axis||"xy",o=i.intersect?pi(t,r,n,a):gi(t,r,n,!1,a);if(o.length>0){var s=o[0].datasetIndex,l=t.getDatasetMeta(s).data;o=[];for(var h=0;hpi(t,di(e,t),i.axis||"xy",a),nearest:(t,e,i,a)=>gi(t,di(e,t),i.axis||"xy",i.intersect,a),x(t,e,i,a){var r=di(e,t),n=[],o=!1;return ci(t,(t,e,i)=>{t.inXRange(r.x,a)&&n.push({element:t,datasetIndex:e,index:i}),t.inRange(r.x,r.y,a)&&(o=!0)}),i.intersect&&!o?[]:n},y(t,e,i,a){var r=di(e,t),n=[],o=!1;return ci(t,(t,e,i)=>{t.inYRange(r.y,a)&&n.push({element:t,datasetIndex:e,index:i}),t.inRange(r.x,r.y,a)&&(o=!0)}),i.intersect&&!o?[]:n}}},mi=["left","top","right","bottom"];function bi(t,e){return t.filter(t=>t.pos===e)}function xi(t,e){return t.filter(t=>-1===mi.indexOf(t.pos)&&t.box.axis===e)}function yi(t,e){return t.sort((t,i)=>{var a=e?i:t,r=e?t:i;return a.weight===r.weight?a.index-r.index:a.weight-r.weight})}function _i(t,e,i,a){return Math.max(t[i],e[i])+Math.max(t[a],e[a])}function Mi(t,e,i){var a=i.box,r=t.maxPadding;if(i.size&&(t[i.pos]-=i.size),i.size=i.horizontal?a.height:a.width,t[i.pos]+=i.size,a.getPadding){var n=a.getPadding();r.top=Math.max(r.top,n.top),r.left=Math.max(r.left,n.left),r.bottom=Math.max(r.bottom,n.bottom),r.right=Math.max(r.right,n.right)}var o=e.outerWidth-_i(r,t,"left","right"),s=e.outerHeight-_i(r,t,"top","bottom");if(o!==t.w||s!==t.h)return t.w=o,t.h=s,i.horizontal?o!==t.w:s!==t.h}function wi(t,e){var i=e.maxPadding;function a(t){var a={left:0,top:0,right:0,bottom:0};return t.forEach(t=>{a[t]=Math.max(e[t],i[t])}),a}return a(t?["left","right"]:["top","bottom"])}function ki(t,e,i){var a,r,n,o,s,l,h=[];for(a=0,r=t.length;a{var a=i.box;e(a,t.chartArea),a.update(c.w,c.h)})}}};class Di{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}}class Ai extends Di{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}}var Oi={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"};function Ci(t,e){var i=re.dom.getStyle(t,e),a=i&&i.match(/^(\d+)(\.\d+)?px$/);return a?+a[1]:void 0}var Ti=!!function(){var t=!1;try{var e={get passive(){return t=!0,!1}};window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(t){}return t}()&&{passive:!0};function Fi(t,e){var i=!1,a=[];return function(){for(var r=arguments.length,n=new Array(r),o=0;o{i=!1,t.apply(e,a)}))}}function Ii(t,e){var i=Fi((i,a)=>{var r=t.clientWidth;e(i,a),r{var e=t[0];i(e.contentRect.width,e.contentRect.height)});return a.observe(t),a}function Li(t,e){var i=lt(t);if(i){var a=new MutationObserver(i=>{i.forEach(i=>{for(var a=0;azi(t,e,i);Ri(e);var r,n,o,s=lt(t);s?(e.resize=Ii(s,i),e.detach=Li(t,a)):e.attach=(r=t,n=()=>{Ei(e,"attach");var r=lt(t);e.resize=Ii(r,i),e.detach=Li(t,a)},(o=new MutationObserver(t=>{var e=lt(r);t.forEach(t=>{for(var i=0;i{var a=i[t];re.isNullOrUndef(a)?e.removeAttribute(t):e.setAttribute(t,a)});var a=i.style||{};return Object.keys(a).forEach(t=>{e.style[t]=a[t]}),e.width=e.width,delete e.$chartjs,!0}addEventListener(t,e,i){this.removeEventListener(t,e);var a=t.canvas,r=t.$proxies||(t.$proxies={});if("resize"===e)return zi(a,r,i);!function(t,e,i){t.addEventListener(e,i,Ti)}(a,e,r[e]=Fi(e=>{null!==t.ctx&&i(function(t,e){var i=Oi[t.type]||t.type,a=re.dom.getRelativePosition(t,e);return function(t,e,i,a,r){return{type:t,chart:e,native:r||null,x:void 0!==i?i:null,y:void 0!==a?a:null}}(i,e,a.x,a.y,t)}(e,t))},t))}removeEventListener(t,e){var i=t.canvas,a=t.$proxies||(t.$proxies={});if("resize"===e)return Ri(a);var r=a[e];r&&(!function(t,e,i){t.removeEventListener(e,i,Ti)}(i,e,r),a[e]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}}var Vi={BasicPlatform:Ai,DomPlatform:Bi,BasePlatform:Di};mt.set("plugins",{});var Wi=new class{constructor(){this._plugins=[],this._cacheId=0}register(t){var e=this._plugins;[].concat(t).forEach(t=>{-1===e.indexOf(t)&&e.push(t)}),this._cacheId++}unregister(t){var e=this._plugins;[].concat(t).forEach(t=>{var i=e.indexOf(t);-1!==i&&e.splice(i,1)}),this._cacheId++}clear(){this._plugins=[],this._cacheId++}count(){return this._plugins.length}getAll(){return this._plugins}notify(t,e,i){var a,r,n,o,s,l=this._descriptors(t),h=l.length;for(a=0;a{if(-1===i.indexOf(t)){var e=t.id,r=n[e];!1!==r&&(!0===r&&(r=f(mt.plugins[e])),i.push(t),a.push({plugin:t,options:r||{}}))}}),e.descriptors=a,e.id=this._cacheId,a}invalidate(t){delete t.$plugins}},Ni={constructors:{},defaults:{},registerScale(t){var e=t.id;this.constructors[e]=t,this.defaults[e]=f(t.defaults)},getScaleConstructor(t){return Object.prototype.hasOwnProperty.call(this.constructors,t)?this.constructors[t]:void 0},getScaleDefaults(t){return Object.prototype.hasOwnProperty.call(this.defaults,t)?g({},[mt.scale,this.defaults[t]]):{}},updateScaleDefaults(t,i){Object.prototype.hasOwnProperty.call(this.defaults,t)&&(this.defaults[t]=e(this.defaults[t],i))},addScalesToLayout(t){u(t.scales,e=>{e.fullWidth=e.options.fullWidth,e.position=e.options.position,e.weight=e.options.weight,Pi.addBox(t,e)})}},Hi=re.valueOrDefault;function ji(t,e){e=e||{};var i=mt[t.type]||{scales:{}},a=e.scales||{},r={},n={};return Object.keys(a).forEach(t=>{var e=t[0];r[e]=r[e]||t,n[t]=re.mergeIf({},[a[t],i.scales[e]])}),e.scale&&(n[e.scale.id||"r"]=re.mergeIf({},[e.scale,i.scales.r]),r.r=r.r||e.scale.id||"r"),t.data.datasets.forEach(e=>{var i=(mt[e.type||t.type]||{scales:{}}).scales||{};Object.keys(i).forEach(t=>{var o=e[t+"AxisID"]||r[t]||t;n[o]=n[o]||{},re.mergeIf(n[o],[a[o],i[t]])})}),Object.keys(n).forEach(t=>{var e=n[t];re.mergeIf(e,Ni.getScaleDefaults(e.type))}),n}function Yi(){for(var t=arguments.length,e=new Array(t),i=0;ii.config.data,set(t){i.config.data=t}}),r&&n?(ne.listen(i,"complete",$i),ne.listen(i,"progress",Ki),i._initialize(),i.update()):console.error("Failed to create chart: can't acquire context from the given item")}_initialize(){var t=this;return Wi.notify(t,"beforeInit"),t.options.responsive?t.resize(!0):re.dom.retinaScale(t,t.options.devicePixelRatio),t.bindEvents(),Wi.notify(t,"afterInit"),t}_initializePlatform(t,e){return e.platform?new e.platform:!Gi()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?new Ai:new Bi}clear(){return re.canvas.clear(this),this}stop(){return ne.stop(this),this}resize(t,e,i){var a=this,r=a.options,n=a.canvas,o=r.maintainAspectRatio&&a.aspectRatio;void 0!==e&&void 0!==i||(e=ft(n),i=pt(n));var s=Math.max(0,Math.floor(e)),l=Math.max(0,Math.floor(o?s/o:i)),h=a.currentDevicePixelRatio,d=r.devicePixelRatio||a.platform.getDevicePixelRatio();if((a.width!==s||a.height!==l||h!==d)&&(n.width=a.width=s,n.height=a.height=l,n.style&&(n.style.width=s+"px",n.style.height=l+"px"),re.dom.retinaScale(a,d),!t)){var c={width:s,height:l};Wi.notify(a,"resize",[c]),r.onResize&&r.onResize(a,c),a.update("resize")}}ensureScalesHaveIDs(){var t=this.options,e=t.scales||{},i=t.scale;re.each(e,(t,e)=>{t.id=e}),i&&(i.id=i.id||"scale")}buildOrUpdateScales(){var t=this,e=t.options.scales,i=t.scales||{},a=Object.keys(i).reduce((t,e)=>(t[e]=!1,t),{}),r=[];e&&(r=r.concat(Object.keys(e).map(t=>{var i=e[t],a="r"===t.charAt(0).toLowerCase(),r="x"===t.charAt(0).toLowerCase();return{options:i,dposition:a?"chartArea":r?"bottom":"left",dtype:a?"radialLinear":r?"category":"linear"}}))),re.each(r,e=>{var r=e.options,n=r.id,o=Hi(r.type,e.dtype);void 0!==r.position&&Xi(r.position,r.axis||n[0])===Xi(e.dposition)||(r.position=e.dposition),a[n]=!0;var s=null;if(n in i&&i[n].type===o)(s=i[n]).options=r,s.ctx=t.ctx,s.chart=t;else{var l=Ni.getScaleConstructor(o);if(!l)return;s=new l({id:n,type:o,options:r,ctx:t.ctx,chart:t}),i[s.id]=s}s.axis="chartArea"===s.options.position?"r":s.isHorizontal()?"x":"y",s._userMin=s.parse(s.options.min),s._userMax=s.parse(s.options.max),e.isDefault&&(t.scale=s)}),re.each(a,(t,e)=>{t||delete i[e]}),t.scales=i,Ni.addScalesToLayout(this)}_updateMetasetIndex(t,e){var i=this._metasets,a=t.index;a!==e&&(i[a]=i[e],i[e]=t,t.index=e)}_updateMetasets(){var t=this._metasets,e=this.data.datasets.length,i=t.length;if(i>e){for(var a=e;a{t.getDatasetMeta(i).controller.reset()},t)}reset(){this._resetElements(),Wi.notify(this,"reset")}update(t){var e,i,a=this;if(a._updating=!0,function(t){var e=t.options;re.each(t.scales,e=>{Pi.removeBox(t,e)});var i=ji(t.config,e);e=Yi(mt,mt[t.config.type],e),t.options=t.config.options=e,t.options.scales=i,t._animationsDisabled=!e.animation,t.ensureScalesHaveIDs(),t.buildOrUpdateScales()}(a),Wi.invalidate(a),!1!==Wi.notify(a,"beforeUpdate")){var r=a.buildOrUpdateControllers();for(e=0,i=a.data.datasets.length;e{t.reset()}),a._updateDatasets(t),Wi.notify(a,"afterUpdate"),a._layers.sort(qi("z","_idx")),a._lastEvent&&a._eventHandler(a._lastEvent,!0),a.render(),a._updating=!1}}_updateLayout(){var t=this;!1!==Wi.notify(t,"beforeLayout")&&(Pi.update(t,t.width,t.height),t._layers=[],re.each(t.boxes,e=>{e.configure&&e.configure(),t._layers.push(...e._layers())},t),t._layers.forEach((t,e)=>{t._idx=e}),Wi.notify(t,"afterLayout"))}_updateDatasets(t){var e="function"==typeof t;if(!1!==Wi.notify(this,"beforeDatasetsUpdate")){for(var i=0,a=this.data.datasets.length;i=0;--e)this._drawDataset(t[e]);Wi.notify(this,"afterDatasetsDraw")}}_drawDataset(t){var e=this,i=e.ctx,a=t._clip,r=e.chartArea,n={meta:t,index:t.index};!1!==Wi.notify(e,"beforeDatasetDraw",[n])&&(re.canvas.clipArea(i,{left:!1===a.left?0:r.left-a.left,right:!1===a.right?e.width:r.right+a.right,top:!1===a.top?0:r.top-a.top,bottom:!1===a.bottom?e.height:r.bottom+a.bottom}),t.controller.draw(),re.canvas.unclipArea(i),Wi.notify(e,"afterDatasetDraw",[n]))}getElementAtEvent(t){return vi.modes.nearest(this,t,{intersect:!0})}getElementsAtEvent(t){return vi.modes.index(this,t,{intersect:!0})}getElementsAtXAxis(t){return vi.modes.index(this,t,{intersect:!1})}getElementsAtEventForMode(t,e,i,a){var r=vi.modes[e];return"function"==typeof r?r(this,t,i,a):[]}getDatasetAtEvent(t){return vi.modes.dataset(this,t,{intersect:!0})}getDatasetMeta(t){var e=this.data.datasets[t],i=this._metasets,a=i.filter(t=>t._dataset===e).pop();return a||(a=i[t]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1}),a}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){var e=this.getDatasetMeta(t);return"boolean"==typeof e.hidden?!e.hidden:!this.data.datasets[t].hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateDatasetVisibility(t,e){var i=e?"show":"hide",a=this.getDatasetMeta(t),r=a.controller._resolveAnimations(void 0,i);this.setDatasetVisibility(t,e),r.update(a,{visible:e}),this.update(e=>e.datasetIndex===t?i:void 0)}hide(t){this._updateDatasetVisibility(t,!1)}show(t){this._updateDatasetVisibility(t,!0)}_destroyDatasetMeta(t){var e=this._metasets&&this._metasets[t];e&&(e.controller._destroy(),delete this._metasets[t])}destroy(){var t,e,i=this,a=i.canvas;for(i.stop(),ne.remove(i),t=0,e=i.data.datasets.length;t{t.platform.addEventListener(t,a,i),e[a]=i}),t.options.responsive&&(i=function(e,i){t.canvas&&t.resize(!1,e,i)},t.platform.addEventListener(t,"resize",i),e.resize=i)}unbindEvents(){var t=this,e=t._listeners;e&&(delete t._listeners,re.each(e,(e,i)=>{t.platform.removeEventListener(t,i,e)}))}updateHoverStyle(t,e,i){var a,r,n,o=i?"set":"remove";for("dataset"===e&&this.getDatasetMeta(t[0].datasetIndex).controller["_"+o+"DatasetHoverStyle"](),r=0,n=t.length;rs(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";var a=i.length>3?i[2].value-i[1].value:i[1].value-i[0].value;Math.abs(a)>1&&t!==Math.floor(t)&&(a=t-Math.floor(t));var r=W(Math.abs(a)),n=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value)),o=Math.min(Math.abs(i[0].value),Math.abs(i[i.length-1].value)),s=this.chart.options.locale;if(n<1e-4||o>1e7){var l=W(Math.abs(t)),h=Math.floor(l)-Math.floor(r);return h=Math.max(Math.min(h,20),0),t.toExponential(h)}var d=-1*Math.floor(r);return d=Math.max(Math.min(d,20),0),new Intl.NumberFormat(s,{minimumFractionDigits:d,maximumFractionDigits:d}).format(t)},logarithmic:function(t,e,i){if(0===t)return"0";var a=t/Math.pow(10,Math.floor(W(t)));return 1===a||2===a||5===a?ea.numeric.call(this,t,e,i):""}},ia={formatters:ea};function aa(t,e){for(var i=[],a=t.length/e,r=t.length,n=0;ns+1e-6)))return l}function na(t){return t.drawTicks?t.tickMarkLength:0}function oa(t){if(!t.display)return 0;var e=yt(t),i=xt(t.padding);return e.lineHeight+i.height}function sa(t,e,i,a,r){var n,o,s,l=d(a,0),h=Math.min(d(r,t.length),t.length),c=0;for(i=Math.ceil(i),r&&(i=(n=r-a)/Math.floor(n/i)),s=l;s<0;)c++,s=Math.round(l+c*i);for(o=Math.max(l,0);o=l||o<=1||!a.isHorizontal())a.labelRotation=s;else{var d=a._getLabelSizes(),c=d.widest.width,u=d.highest.height-d.highest.offset,f=Math.min(a.maxWidth,a.chart.width-c);c+6>(t=r.offset?a.maxWidth/o:f/(o-1))&&(t=f/(o-(r.offset?.5:1)),e=a.maxHeight-na(r.gridLines)-n.padding-oa(r.scaleLabel),i=Math.sqrt(c*c+u*u),h=q(Math.min(Math.asin(Math.min((d.highest.height+6)/t,1)),Math.asin(Math.min(e/i,1))-Math.asin(u/i))),h=Math.max(s,Math.min(l,h))),a.labelRotation=h}}afterCalculateLabelRotation(){c(this.options.afterCalculateLabelRotation,[this])}beforeFit(){c(this.options.beforeFit,[this])}fit(){var t=this,e={width:0,height:0},i=t.chart,a=t.options,r=a.ticks,n=a.scaleLabel,o=a.gridLines,s=t._isVisible(),l="top"!==a.position&&"x"===t.axis,h=t.isHorizontal();if(h?e.width=t.maxWidth:s&&(e.width=na(o)+oa(n)),h?s&&(e.height=na(o)+oa(n)):e.height=t.maxHeight,r.display&&s&&t.ticks.length){var d=t._getLabelSizes(),c=d.first,u=d.last,f=d.widest,p=d.highest,g=.8*p.offset,v=r.padding;if(h){var m=0!==t.labelRotation,b=X(t.labelRotation),x=Math.cos(b),y=Math.sin(b),_=y*f.width+x*(p.height-(m?p.offset:0))+(m?0:g);e.height=Math.min(t.maxHeight,e.height+_+v);var M,w,k=t.getPixelForTick(0)-t.left,S=t.right-t.getPixelForTick(t.ticks.length-1);m?(M=l?x*c.width+y*c.offset:y*(c.height-c.offset),w=l?y*(u.height-u.offset):x*u.width+y*u.offset):(M=c.width/2,w=u.width/2),t.paddingLeft=Math.max((M-k)*t.width/(t.width-k),0)+3,t.paddingRight=Math.max((w-S)*t.width/(t.width-S),0)+3}else{var P=r.mirror?0:f.width+v+g;e.width=Math.min(t.maxWidth,e.width+P),t.paddingTop=c.height/2,t.paddingBottom=u.height/2}}t._handleMargins(),h?(t.width=t._length=i.width-t._margins.left-t._margins.right,t.height=e.height):(t.width=e.width,t.height=t._length=i.height-t._margins.top-t._margins.bottom)}_handleMargins(){var t=this;t._margins&&(t._margins.left=Math.max(t.paddingLeft,t._margins.left),t._margins.top=Math.max(t.paddingTop,t._margins.top),t._margins.right=Math.max(t.paddingRight,t._margins.right),t._margins.bottom=Math.max(t.paddingBottom,t._margins.bottom))}afterFit(){c(this.options.afterFit,[this])}isHorizontal(){var{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullWidth(){return this.options.fullWidth}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t),this.afterTickToLabelConversion()}_getLabelSizes(){var t=this._labelSizes;return t||(this._labelSizes=t=this._computeLabelSizes()),t}_computeLabelSizes(){var t=this,e=t.ctx,i=t._longestTextCache,a=t.options.ticks.sampleSize,r=[],n=[],l=[],h=t.ticks;a{var i,a=t.gc,r=a.length/2;if(r>e){for(i=0;ie.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){return this._reversePixels&&(t=1-t),this._startPixel+t*this._length}getDecimalForPixel(t){var e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){var{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}_autoSkip(t){var e=this.options.ticks,i=e.maxTicksLimit||this._length/this._tickSize(),a=e.major.enabled?function(t){var e,i,a=[];for(e=0,i=t.length;ei)return function(t,e,i,a){var r,n=0,o=i[0];for(a=Math.ceil(a),r=0;rr)return l}return Math.max(r,1)}(a,t,i);if(r>0){var d,c,u=r>1?Math.round((s-n)/(r-1)):null;for(sa(t,l,h,o(u)?0:n-u,n),d=0,c=r-1;do*a?o/i:s/a:s*a0}_computeGridLineItems(t){var e,i,a,r,n,o,s,h,d,c,u,f,p=this,g=p.axis,v=p.chart,m=p.options,{gridLines:b,position:x}=m,y=b.offsetGridLines,_=p.isHorizontal(),M=p.ticks,w=M.length+(y?1:0),k=na(b),S=[],P={scale:p,tick:M[0]},D=b.drawBorder?_t([b.borderWidth,b.lineWidth,0],P,0):0,O=D/2,C=function(t){return A(v,t,D)};if("top"===x)e=C(p.bottom),o=p.bottom-k,h=e-O,c=C(t.top)+O,f=t.bottom;else if("bottom"===x)e=C(p.top),c=t.top,f=C(t.bottom)-O,o=e+O,h=p.top+k;else if("left"===x)e=C(p.right),n=p.right-k,s=e-O,d=C(t.left)+O,u=t.right;else if("right"===x)e=C(p.left),d=t.left,u=C(t.right)-O,n=e+O,s=p.left+k;else if("x"===g){if("center"===x)e=C((t.top+t.bottom)/2);else if(l(x)){var T=Object.keys(x)[0],F=x[T];e=C(p.chart.scales[T].getPixelForValue(F))}c=t.top,f=t.bottom,h=(o=e+O)+k}else if("y"===g){if("center"===x)e=C((t.left+t.right)/2);else if(l(x)){var I=Object.keys(x)[0],L=x[I];e=C(p.chart.scales[I].getPixelForValue(L))}s=(n=e-O)-k,d=t.left,u=t.right}for(i=0;i0&&""!==d.strokeStyle;o.save(),o.translate(h.x,h.y),o.rotate(h.rotation),o.font=d.string,o.fillStyle=d.color,o.textBaseline="middle",o.textAlign=h.textAlign,c&&(o.strokeStyle=d.strokeStyle,o.lineWidth=d.lineWidth);var u=h.label,f=h.textOffset;if(s(u))for(a=0,n=u.length;a({value:t}))}getLabelForValue(t){var e=this.getLabels();return t>=0&&te.length-1?null:this.getPixelForValue(t*this._numLabels/e.length+this.min)}getValueForPixel(t){var e=Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange);return Math.min(Math.max(e,0),this.ticks.length-1)}getBasePixel(){return this.bottom}}function da(t,e){var i=Math.floor(W(t)),a=t/Math.pow(10,i);return(e?a<1.5?1:a<3?2:a<7?5:10:a<=1?1:a<=2?2:a<=5?5:10)*Math.pow(10,i)}t(ha,"id","category"),t(ha,"defaults",{});class ca extends la{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return o(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?NaN:+t}handleTickRangeOptions(){var t=this,e=t.options;if(e.beginAtZero){var i=U(t.min),a=U(t.max);i<0&&a<0?t.max=0:i>0&&a>0&&(t.min=0)}var r=void 0!==e.min||void 0!==e.suggestedMin,n=void 0!==e.max||void 0!==e.suggestedMax;void 0!==e.min?t.min=e.min:void 0!==e.suggestedMin&&(null===t.min?t.min=e.suggestedMin:t.min=Math.min(t.min,e.suggestedMin)),void 0!==e.max?t.max=e.max:void 0!==e.suggestedMax&&(null===t.max?t.max=e.suggestedMax:t.max=Math.max(t.max,e.suggestedMax)),r!==n&&t.min>=t.max&&(r?t.max=t.min+1:t.min=t.max-1),t.min===t.max&&(t.max++,e.beginAtZero||t.min--)}getTickLimit(){var t,e=this.options.ticks,{maxTicksLimit:i,stepSize:a}=e;return a?t=Math.ceil(this.max/a)-Math.floor(this.min/a)+1:(t=this.computeTickLimit(),i=i||11),i&&(t=Math.min(i,t)),t}computeTickLimit(){return Number.POSITIVE_INFINITY}handleDirectionalChanges(t){return t}buildTicks(){var t=this,e=t.options,i=e.ticks,a=t.getTickLimit(),r=function(t,e){var i,a,r,n,s=[],{stepSize:l,min:h,max:d,precision:c}=t,u=l||1,f=t.maxTicks-1,{min:p,max:g}=e,v=da((g-p)/f/u)*u;if(v<1e-14&&o(h)&&o(d))return[{value:p},{value:g}];(n=Math.ceil(g/v)-Math.floor(p/v))>f&&(v=da(n*v/f/u)*u),l||o(c)?i=Math.pow(10,$(v)):(i=Math.pow(10,c),v=Math.ceil(v*i)/i),a=Math.floor(p/v)*v,r=Math.ceil(g/v)*v,!l||o(h)||o(d)||j((d-h)/l,v/1e3)&&(a=h,r=d),n=H(n=(r-a)/v,Math.round(n),v/1e3)?Math.round(n):Math.ceil(n),a=Math.round(a*i)/i,r=Math.round(r*i)/i,s.push({value:o(h)?a:h});for(var m=1;m0&&(t.min=0),t.handleTickRangeOptions()}computeTickLimit(){if(this.isHorizontal())return Math.ceil(this.width/40);var t=yt(this.options.ticks);return Math.ceil(this.height/t.lineHeight)}handleDirectionalChanges(t){return this.isHorizontal()?t:t.reverse()}getPixelForValue(t){return this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}function pa(t){return 1===t/Math.pow(10,Math.floor(W(t)))}function ga(t,e){return h(t)?t:e}t(fa,"id","linear"),t(fa,"defaults",ua);var va={ticks:{callback:ia.formatters.logarithmic,major:{enabled:!0}}};class ma extends la{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){var i=ca.prototype.parse.apply(this,[t,e]);if(0!==i)return h(i)&&i>0?i:NaN}determineDataLimits(){var t=this.getMinMax(!0),e=t.min,i=t.max;this.min=h(e)?Math.max(0,e):null,this.max=h(i)?Math.max(0,i):null,this.handleTickRangeOptions()}handleTickRangeOptions(){var t=this.min,e=this.max;t===e&&(t<=0?(t=1,e=10):(t=Math.pow(10,Math.floor(W(t))-1),e=Math.pow(10,Math.floor(W(e))+1))),t<=0&&(t=Math.pow(10,Math.floor(W(e))-1)),e<=0&&(e=Math.pow(10,Math.floor(W(t))+1)),this.min=t,this.max=e}buildTicks(){var t=this,e=t.options,i=function(t,e){var i=Math.floor(W(e.max)),a=Math.ceil(e.max/Math.pow(10,i)),r=[],n=ga(t.min,Math.pow(10,Math.floor(W(e.min)))),o=Math.floor(W(n)),s=Math.floor(n/Math.pow(10,o)),l=o<0?Math.pow(10,Math.abs(o)):1;do{r.push({value:n,major:pa(n)}),10===++s&&(s=1,l=++o>=0?1:l),n=Math.round(s*Math.pow(10,o)*l)/l}while(ot}};function Ma(t){var e=t.ticks;return e.display&&t.display?ba(e.fontSize,mt.fontSize)+2*e.backdropPaddingY:0}function wa(t,e,i,a,r){return t===a||t===r?{start:e-i/2,end:e+i/2}:tr?{start:e-i,end:e}:{start:e,end:e+i}}function ka(t){return 0===t||180===t?"center":t<180?"left":"right"}function Sa(t,e,i,a){var r,n,o=i.y+a/2;if(re.isArray(e))for(r=0,n=e.length;r270||t<90)&&(i.y-=e.h)}function Da(t){return N(t)?t:0}class Aa extends ca{constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this.pointLabels=[]}setDimensions(){var t=this;t.width=t.maxWidth,t.height=t.maxHeight,t.paddingTop=Ma(t.options)/2,t.xCenter=Math.floor(t.width/2),t.yCenter=Math.floor((t.height-t.paddingTop)/2),t.drawingArea=Math.min(t.height-t.paddingTop,t.width)/2}determineDataLimits(){var t=this.getMinMax(!1),e=t.min,i=t.max;this.min=re.isFinite(e)&&!isNaN(e)?e:0,this.max=re.isFinite(i)&&!isNaN(i)?i:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/Ma(this.options))}generateTickLabels(t){var e=this;ca.prototype.generateTickLabels.call(e,t),e.pointLabels=e.chart.data.labels.map((t,i)=>{var a=re.callback(e.options.pointLabels.callback,[t,i],e);return a||0===a?a:""})}fit(){var t=this.options;t.display&&t.pointLabels.display?function(t){var e,i,a,r=re.options._parseFont(t.options.pointLabels),n={l:0,r:t.width,t:0,b:t.height-t.paddingTop},o={};t.ctx.font=r.string,t._pointLabelSizes=[];var s,l,h,d=t.chart.data.labels.length;for(e=0;en.r&&(n.r=f.end,o.r=c),p.startn.b&&(n.b=p.end,o.b=c)}t._setReductions(t.drawingArea,n,o)}(this):this.setCenterPoint(0,0,0,0)}_setReductions(t,e,i){var a=this,r=e.l/Math.sin(i.l),n=Math.max(e.r-a.width,0)/Math.sin(i.r),o=-e.t/Math.cos(i.t),s=-Math.max(e.b-(a.height-a.paddingTop),0)/Math.cos(i.b);r=Da(r),n=Da(n),o=Da(o),s=Da(s),a.drawingArea=Math.min(Math.floor(t-(r+n)/2),Math.floor(t-(o+s)/2)),a.setCenterPoint(r,n,o,s)}setCenterPoint(t,e,i,a){var r=this,n=r.width-e-r.drawingArea,o=t+r.drawingArea,s=i+r.drawingArea,l=r.height-r.paddingTop-a-r.drawingArea;r.xCenter=Math.floor((o+n)/2+r.left),r.yCenter=Math.floor((s+l)/2+r.top+r.paddingTop)}getIndexAngle(t){var e=this.chart;return Z(t*(2*Math.PI/e.data.labels.length)+X((e.options||{}).startAngle||0))}getDistanceFromCenterForValue(t){var e=this;if(re.isNullOrUndef(t))return NaN;var i=e.drawingArea/(e.max-e.min);return e.options.reverse?(e.max-t)*i:(t-e.min)*i}getPointPosition(t,e){var i=this.getIndexAngle(t)-Math.PI/2;return{x:Math.cos(i)*e+this.xCenter,y:Math.sin(i)*e+this.yCenter,angle:i}}getPointPositionForValue(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}drawGrid(){var t,e,i,a=this,r=a.ctx,n=a.options,o=n.gridLines,s=n.angleLines,l=ba(s.lineWidth,o.lineWidth),h=ba(s.color,o.color);if(n.pointLabels.display&&function(t){var e=t.ctx,i=t.options,a=i.pointLabels,r=Ma(i),n=t.getDistanceFromCenterForValue(i.ticks.reverse?t.min:t.max),o=re.options._parseFont(a);e.save(),e.font=o.string,e.textBaseline="middle";for(var s=t.chart.data.labels.length-1;s>=0;s--){var l=0===s?r/2:0,h=t.getPointPosition(s,n+l+5),d=xa(a.fontColor,s,mt.fontColor);e.fillStyle=d;var c=q(t.getIndexAngle(s));e.textAlign=ka(c),Pa(c,t._pointLabelSizes[s],h),Sa(e,t.pointLabels[s],h,o.lineHeight)}e.restore()}(a),o.display&&a.ticks.forEach((t,i)=>{0!==i&&(e=a.getDistanceFromCenterForValue(a.ticks[i].value),function(t,e,i,a){var r,n=t.ctx,o=e.circular,s=t.chart.data.labels.length,l=xa(e.color,a-1,void 0),h=xa(e.lineWidth,a-1,void 0);if((o||s)&&l&&h){if(n.save(),n.strokeStyle=l,n.lineWidth=h,n.setLineDash&&(n.setLineDash(e.borderDash||[]),n.lineDashOffset=e.borderDashOffset||0),n.beginPath(),o)n.arc(t.xCenter,t.yCenter,i,0,2*Math.PI);else{r=t.getPointPosition(0,i),n.moveTo(r.x,r.y);for(var d=1;d=0;t--)e=a.getDistanceFromCenterForValue(n.ticks.reverse?a.min:a.max),i=a.getPointPosition(t,e),r.beginPath(),r.moveTo(a.xCenter,a.yCenter),r.lineTo(i.x,i.y),r.stroke();r.restore()}}drawLabels(){var t=this,e=t.ctx,i=t.options,a=i.ticks;if(a.display){var r,n,o=t.getIndexAngle(0),s=re.options._parseFont(a),l=ba(a.fontColor,mt.fontColor);e.save(),e.font=s.string,e.translate(t.xCenter,t.yCenter),e.rotate(o),e.textAlign="center",e.textBaseline="middle",t.ticks.forEach((o,h)=>{(0!==h||i.reverse)&&(r=t.getDistanceFromCenterForValue(t.ticks[h].value),a.showLabelBackdrop&&(n=e.measureText(o.label).width,e.fillStyle=a.backdropColor,e.fillRect(-n/2-a.backdropPaddingX,-r-s.size/2-a.backdropPaddingY,n+2*a.backdropPaddingX,s.size+2*a.backdropPaddingY)),e.fillStyle=l,e.fillText(o.label,0,-r))}),e.restore()}}drawTitle(){}}t(Aa,"id","radialLinear"),t(Aa,"defaults",_a);var Oa=Number.MAX_SAFE_INTEGER||9007199254740991,Ca={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Ta=Object.keys(Ca);function Fa(t,e){return t-e}function Ia(t){var e,i,a=new Set;for(e=0,i=t.length;e1;)t[i=r+a>>1]=i?t[a]:t[r];e.add(n)}}function Wa(t,e,i){var a,r,n=[],o={},s=e.length;for(a=0;a=0&&(e[n].major=!0);return e}(t,n,o,i):n}function Na(t){return"labels"===t.options.ticks.source?Ra(t):function(t){var e,i=t._adapter,a=t.min,r=t.max,n=t.options,o=n.time,s=o.unit||Ba(o.minUnit,a,r,t._getLabelCapacity(a)),l=d(o.stepSize,1),h="week"===s&&o.isoWeekday,c=new Set,u=a;if(h&&(u=+i.startOf(u,"isoWeek",h)),u=+i.startOf(u,h?"day":s),i.diff(r,a,s)>1e5*l)throw new Error(a+" and "+r+" are too far apart with stepSize of "+l+" "+s);if("data"===t.options.ticks.source){var f=Ea(t);for(e=u;ea&&t[r-1]>i;)r--;return a>0||r=Ta.indexOf(i);n--){var o=Ta[n];if(Ca[o].common&&t._adapter.diff(r,a,o)>=e-1)return o}return Ta[i?Ta.indexOf(i):0]}(t,l.length,i.minUnit,t.min,t.max)),t._majorUnit=a.major.enabled&&"year"!==t._unit?function(t){for(var e=Ta.indexOf(t)+1,i=Ta.length;ee&&s0?s:1}}t(ja,"id","time"),t(ja,"defaults",{distribution:"linear",bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{autoSkip:!1,source:"auto",major:{enabled:!1}}});var Ya=Object.freeze({__proto__:null,CategoryScale:ha,LinearScale:fa,LogarithmicScale:ma,RadialLinearScale:Aa,TimeScale:ja});function Ua(t,e,i){var a=function(t){var e=t.options,i=e.fill,a=d(i&&i.target,i);return void 0===a&&(a=!!e.backgroundColor),!1!==a&&null!==a&&(!0===a?"origin":a)}(t),r=parseFloat(a);return h(r)&&Math.floor(r)===r?("-"!==a[0]&&"+"!==a[0]||(r=e+r),!(r===e||r<0||r>=i)&&r):["origin","start","end"].indexOf(a)>=0&&a}mt.set("plugins",{filler:{propagate:!0}});class Xa{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,e,i){var{x:a,y:r,radius:n}=this;return e=e||{start:0,end:2*Math.PI},i.reverse?t.arc(a,r,n,e.end,e.start,!0):t.arc(a,r,n,e.start,e.end),!i.bounds}interpolate(t,e){var{x:i,y:a,radius:r}=this,n=t.angle;if("angle"===e)return{x:i+Math.cos(n)*r,y:a+Math.sin(n)*r,angle:n}}}function qa(t){return(t.scale||{}).getPointPositionForValue?function(t){var e,i,{scale:a,fill:r}=t,n=a.options,o=a.getLabels().length,s=[],l=n.reverse?a.max:a.min,h=n.reverse?a.min:a.max,d="start"===r?l:"end"===r?h:a.getBaseValue();if(n.gridLines.circular)return i=a.getPointPositionForValue(0,l),new Xa({x:i.x,y:i.y,radius:a.getDistanceFromCenterForValue(d)});for(e=0;e{var e=r[t.start],o=r[t.end];null!==a?(n.push({x:e.x,y:a,_prop:"x",_ref:e}),n.push({x:o.x,y:a,_prop:"x",_ref:o})):null!==i&&(n.push({x:i,y:e.y,_prop:"y",_ref:e}),n.push({x:i,y:o.y,_prop:"y",_ref:o}))}),n}(r,a),l=!0),n.length?new Be({points:n,options:{tension:0},_loop:o,_fullLoop:o,_refPoints:l}):null)}function Ka(t,e,i){var a,r=t[e].fill,n=[e];if(!i)return r;for(;!1!==r&&-1===n.indexOf(r);){if(!h(r))return r;if(!(a=t[r]))return!1;if(a.visible)return r;n.push(r),r=a.fill}return!1}function Ga(t,e,i){t.beginPath(),e.path(t),t.lineTo(e.last().x,i),t.lineTo(e.first().x,i),t.closePath(),t.clip()}function Za(t,e,i,a){if(!a){var r=e[t],n=i[t];return"angle"===t&&(r=Z(r),n=Z(n)),{property:t,start:r,end:n}}}function Qa(t,e,i,a){return t&&e?a(t[i],e[i]):t?t[i]:e?e[i]:0}function Ja(t,e,i){var{top:a,bottom:r}=e.chart.chartArea,{property:n,start:o,end:s}=i||{};"x"===n&&(t.beginPath(),t.rect(o,a,s-o,r-a),t.clip())}function tr(t,e,i,a){var r=e.interpolate(i,a);r&&t.lineTo(r.x,r.y)}function er(t,e){var{line:i,target:a,property:r,color:n,scale:o}=e,s=function(t,e,i){var a=t.segments,r=t.points,n=e.points,o=[];if(e._refPoints)for(var s=0,l=n.length;s=0;--e)(i=a[e].$filler)&&i.line.updateControlPoints(r)},beforeDatasetDraw(t,e){var i=t.chartArea,a=t.ctx,r=e.meta.$filler;if(r&&!1!==r.fill){var{line:n,target:o,scale:s}=r,l=n.options,h=l.fill,d=l.backgroundColor||mt.color,{above:c=d,below:u=d}=h||{};o&&n.points.length&&(T(a,i),function(t,e){var{line:i,target:a,above:r,below:n,area:o,scale:s}=e,l=i._loop?"angle":"x";t.save(),"x"===l&&n!==r&&(Ga(t,a,o.top),er(t,{line:i,target:a,color:r,scale:s,property:l}),t.restore(),t.save(),Ga(t,a,o.bottom)),er(t,{line:i,target:a,color:n,scale:s,property:l}),t.restore()}(a,{line:n,target:o,above:c,below:u,area:i,scale:s}),F(a))}}};function ar(t,e){return t.usePointStyle&&t.boxWidth>e?e:t.boxWidth}mt.set("legend",{display:!0,position:"top",align:"center",fullWidth:!0,reverse:!1,weight:1e3,onClick(t,e){var i=e.datasetIndex,a=this.chart;a.isDatasetVisible(i)?(a.hide(i),e.hidden=!0):(a.show(i),e.hidden=!1)},onHover:null,onLeave:null,labels:{boxWidth:40,padding:10,generateLabels(t){var e=t.data.datasets,i=t.options.legend||{},a=i.labels&&i.labels.usePointStyle;return t._getSortedDatasetMetas().map(t=>{var i=t.controller.getStyle(a?0:void 0);return{text:e[t.index].label,fillStyle:i.backgroundColor,hidden:!t.visible,lineCap:i.borderCapStyle,lineDash:i.borderDash,lineDashOffset:i.borderDashOffset,lineJoin:i.borderJoinStyle,lineWidth:i.borderWidth,strokeStyle:i.borderColor,pointStyle:i.pointStyle,rotation:i.rotation,datasetIndex:t.index}},this)}},title:{display:!1,position:"center",text:""}});class rr extends _e{constructor(t){super(),e(this,t),this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnWidths=void 0,this.columnHeights=void 0,this.lineWidths=void 0,this._minSize=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.position=void 0,this.weight=void 0,this.fullWidth=void 0}beforeUpdate(){}update(t,e,i){var a=this;a.beforeUpdate(),a.maxWidth=t,a.maxHeight=e,a._margins=i,a.beforeSetDimensions(),a.setDimensions(),a.afterSetDimensions(),a.beforeBuildLabels(),a.buildLabels(),a.afterBuildLabels(),a.beforeFit(),a.fit(),a.afterFit(),a.afterUpdate()}afterUpdate(){}beforeSetDimensions(){}setDimensions(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t._minSize={width:0,height:0}}afterSetDimensions(){}beforeBuildLabels(){}buildLabels(){var t=this,e=t.options.labels||{},i=c(e.generateLabels,[t.chart],t)||[];e.filter&&(i=i.filter(i=>e.filter(i,t.chart.data))),t.options.reverse&&i.reverse(),t.legendItems=i}afterBuildLabels(){}beforeFit(){}fit(){var t=this,e=t.options,i=e.labels,a=e.display,r=t.ctx,n=yt(i),o=n.size,s=t.legendHitBoxes=[],l=t._minSize,h=t.isHorizontal(),d=t._computeTitleHeight();if(h?(l.width=t.maxWidth,l.height=a?10:0):(l.width=a?10:0,l.height=t.maxHeight),a){if(r.font=n.string,h){var c=t.lineWidths=[0],u=d;r.textAlign="left",r.textBaseline="middle",t.legendItems.forEach((t,e)=>{var a=ar(i,o)+o/2+r.measureText(t.text).width;(0===e||c[c.length-1]+a+2*i.padding>l.width)&&(u+=o+i.padding,c[c.length-(e>0?0:1)]=0),s[e]={left:0,top:0,width:a,height:o},c[c.length-1]+=a+i.padding}),l.height+=u}else{var f=i.padding,p=t.columnWidths=[],g=t.columnHeights=[],v=i.padding,m=0,b=0,x=l.height-d;t.legendItems.forEach((t,e)=>{var a=ar(i,o)+o/2+r.measureText(t.text).width;e>0&&b+o+2*f>x&&(v+=m+i.padding,p.push(m),g.push(b),m=0,b=0),m=Math.max(m,a),b+=o+f,s[e]={left:0,top:0,width:a,height:o}}),v+=m,p.push(m),g.push(b),l.width+=v}t.width=l.width,t.height=l.height}else t.width=l.width=t.height=l.height=0}afterFit(){}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){var t=this,e=t.options,i=e.labels,a=mt.color,r=mt.elements.line,n=t.height,o=t.columnHeights,s=t.width,l=t.lineWidths;if(e.display){t.drawTitle();var h,c=wt(e.rtl,t.left,t._minSize.width),u=t.ctx,f=d(i.fontColor,mt.fontColor),p=yt(i),g=p.size;u.textAlign=c.textAlign("left"),u.textBaseline="middle",u.lineWidth=.5,u.strokeStyle=f,u.fillStyle=f,u.font=p.string;var v=ar(i,g),m=t.legendHitBoxes,b=function(t,a){switch(e.align){case"start":return i.padding;case"end":return t-a;default:return(t-a+i.padding)/2}},x=t.isHorizontal(),y=this._computeTitleHeight();h=x?{x:t.left+b(s,l[0]),y:t.top+i.padding+y,line:0}:{x:t.left+i.padding,y:t.top+b(n,o[0])+y,line:0},kt(t.ctx,e.textDirection);var _=g+i.padding;t.legendItems.forEach((e,f)=>{var p=u.measureText(e.text).width,y=v+g/2+p,M=h.x,w=h.y;c.setWidth(t._minSize.width),x?f>0&&M+y+i.padding>t.left+t._minSize.width&&(w=h.y+=_,h.line++,M=h.x=t.left+b(s,l[h.line])):f>0&&w+_>t.top+t._minSize.height&&(M=h.x=M+t.columnWidths[h.line]+i.padding,h.line++,w=h.y=t.top+b(n,o[h.line]));var k=c.x(M);!function(t,e,n){if(!(isNaN(v)||v<=0)){u.save();var o=d(n.lineWidth,r.borderWidth);if(u.fillStyle=d(n.fillStyle,a),u.lineCap=d(n.lineCap,r.borderCapStyle),u.lineDashOffset=d(n.lineDashOffset,r.borderDashOffset),u.lineJoin=d(n.lineJoin,r.borderJoinStyle),u.lineWidth=o,u.strokeStyle=d(n.strokeStyle,a),u.setLineDash&&u.setLineDash(d(n.lineDash,r.borderDash)),i&&i.usePointStyle){var s={radius:v*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:o},l=c.xPlus(t,v/2);O(u,s,l,e+g/2)}else u.fillRect(c.leftForLtr(t,v),e,v,g),0!==o&&u.strokeRect(c.leftForLtr(t,v),e,v,g);u.restore()}}(k,w,e),m[f].left=c.leftForLtr(k,m[f].width),m[f].top=w,function(t,e,i,a){var r=g/2,n=c.xPlus(t,v+r),o=e+r;u.fillText(i.text,n,o),i.hidden&&(u.beginPath(),u.lineWidth=2,u.moveTo(n,o),u.lineTo(c.xPlus(n,a),o),u.stroke())}(k,w,e,p),x?h.x+=y+i.padding:h.y+=_}),St(t.ctx,e.textDirection)}}drawTitle(){var t=this,e=t.options,i=e.title,a=yt(i),r=xt(i.padding);if(i.display){var n,o,s=wt(e.rtl,t.left,t._minSize.width),l=t.ctx,h=d(i.fontColor,mt.fontColor),c=i.position,u=a.size/2,f=t.top+r.top+u,p=t.left,g=t.width;if(this.isHorizontal())switch(g=Math.max(...t.lineWidths),e.align){case"start":break;case"end":p=t.right-g;break;default:p=(t.left+t.right)/2-g/2}else{var v=Math.max(...t.columnHeights);switch(e.align){case"start":break;case"end":f+=t.height-v;break;default:f+=(t.height-v)/2}}switch(c){case"start":n=p,o="left";break;case"end":n=p+g,o="right";break;default:n=p+g/2,o="center"}l.textAlign=s.textAlign(o),l.textBaseline="middle",l.strokeStyle=h,l.fillStyle=h,l.font=a.string,l.fillText(i.text,n,f)}}_computeTitleHeight(){var t=this.options.title,e=yt(t),i=xt(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){var i,a,r,n=this;if(t>=n.left&&t<=n.right&&e>=n.top&&e<=n.bottom)for(r=n.legendHitBoxes,i=0;i=(a=r[i]).left&&t<=a.left+a.width&&e>=a.top&&e<=a.top+a.height)return n.legendItems[i];return null}handleEvent(t){var e=this,i=e.options,a="mouseup"===t.type?"click":t.type;if("mousemove"===a){if(!i.onHover&&!i.onLeave)return}else{if("click"!==a)return;if(!i.onClick)return}var r=e._getLegendItemAt(t.x,t.y);"click"===a?r&&i.onClick&&i.onClick.call(e,t.native,r):(i.onLeave&&r!==e._hoveredItem&&(e._hoveredItem&&i.onLeave.call(e,t.native,e._hoveredItem),e._hoveredItem=r),i.onHover&&r&&i.onHover.call(e,t.native,r))}}function nr(t,e){var i=new rr({ctx:t.ctx,options:e,chart:t});Pi.configure(t,i,e),Pi.addBox(t,i),t.legend=i}var or={id:"legend",_element:rr,beforeInit(t){var e=t.options.legend;e&&nr(t,e)},afterUpdate(t){var e=t.options.legend,i=t.legend;e?(v(e,mt.legend),i?(Pi.configure(t,i,e),i.options=e,i.buildLabels()):nr(t,e)):i&&(Pi.removeBox(t,i),delete t.legend)},afterEvent(t,e){var i=t.legend;i&&i.handleEvent(e)}};mt.set("title",{align:"center",display:!1,fontStyle:"bold",fullWidth:!0,padding:10,position:"top",text:"",weight:2e3});class sr extends _e{constructor(t){super(),e(this,t),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._margins=void 0,this._padding=void 0,this.legendHitBoxes=[],this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.maxWidth=void 0,this.maxHeight=void 0,this.position=void 0,this.weight=void 0,this.fullWidth=void 0}beforeUpdate(){}update(t,e,i){var a=this;a.beforeUpdate(),a.maxWidth=t,a.maxHeight=e,a._margins=i,a.beforeSetDimensions(),a.setDimensions(),a.afterSetDimensions(),a.beforeBuildLabels(),a.buildLabels(),a.afterBuildLabels(),a.beforeFit(),a.fit(),a.afterFit(),a.afterUpdate()}afterUpdate(){}beforeSetDimensions(){}setDimensions(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height)}afterSetDimensions(){}beforeBuildLabels(){}buildLabels(){}afterBuildLabels(){}beforeFit(){}fit(){var t=this,e=t.options,i={},a=t.isHorizontal();if(e.display){var r=re.isArray(e.text)?e.text.length:1;t._padding=re.options.toPadding(e.padding);var n=r*re.options._parseFont(e).lineHeight+t._padding.height;t.width=i.width=a?t.maxWidth:n,t.height=i.height=a?n:t.maxHeight}else t.width=i.width=t.height=i.height=0}afterFit(){}isHorizontal(){var t=this.options.position;return"top"===t||"bottom"===t}draw(){var t=this,e=t.ctx,i=t.options;if(i.display){var a,r,n,o,s=re.options._parseFont(i),l=s.lineHeight,h=l/2+t._padding.top,d=0,c=t.top,u=t.left,f=t.bottom,p=t.right;if(t.isHorizontal()){switch(i.align){case"start":r=u,o="left";break;case"end":r=p,o="right";break;default:r=u+(p-u)/2,o="center"}n=c+h,a=p-u}else{switch(r="left"===i.position?u+h:p-h,i.align){case"start":n="left"===i.position?f:c,o="left";break;case"end":n="left"===i.position?c:f,o="right";break;default:n=c+(f-c)/2,o="center"}a=f-c,d=Math.PI*("left"===i.position?-.5:.5)}e.save(),e.fillStyle=re.valueOrDefault(i.fontColor,mt.fontColor),e.font=s.string,e.translate(r,n),e.rotate(d),e.textAlign=o,e.textBaseline="middle";var g=i.text;if(re.isArray(g))for(var v=0,m=0;m0){var n=t[0];n.label?i=n.label:r>0&&n.index-1?t.split("\n"):t}function gr(t,e){var{datasetIndex:i,index:a}=e,{label:r,value:n}=t.getDatasetMeta(i).controller.getLabelAndValue(a);return{label:r,value:n,index:a,datasetIndex:i}}function vr(t){var e=t._chart.ctx,{body:i,footer:a,options:r,title:n}=t,{bodyFontSize:o,footerFontSize:s,titleFontSize:l,boxWidth:h,boxHeight:d}=r,c=n.length,u=a.length,f=i.length,p=2*r.yPadding,g=0,v=i.reduce((t,e)=>t+e.before.length+e.lines.length+e.after.length,0);(v+=t.beforeBody.length+t.afterBody.length,c&&(p+=c*l+(c-1)*r.titleSpacing+r.titleMarginBottom),v)&&(p+=f*(r.displayColors?Math.max(d,o):o)+(v-f)*o+(v-1)*r.bodySpacing);u&&(p+=r.footerMarginTop+u*s+(u-1)*r.footerSpacing);var m=0,b=function(t){g=Math.max(g,e.measureText(t).width+m)};return e.save(),e.font=re.fontString(l,r.titleFontStyle,r.titleFontFamily),re.each(t.title,b),e.font=re.fontString(o,r.bodyFontStyle,r.bodyFontFamily),re.each(t.beforeBody.concat(t.afterBody),b),m=r.displayColors?h+2:0,re.each(i,t=>{re.each(t.before,b),re.each(t.lines,b),re.each(t.after,b)}),m=0,e.font=re.fontString(s,r.footerFontStyle,r.footerFontFamily),re.each(t.footer,b),e.restore(),{width:g+=2*r.xPadding,height:p}}function mr(t,e,i){var a,r,{x:n,y:o,width:s,height:l}=i,h=t.chartArea,d="center",c="center";ot.height-l&&(c="bottom");var u=(h.left+h.right)/2,f=(h.top+h.bottom)/2;"center"===c?(a=t=>t<=u,r=t=>t>u):(a=t=>t<=s/2,r=e=>e>=t.width-s/2);var p=t=>t<=f?"top":"bottom";return a(n)?(d="left",n+s+e.caretSize+e.caretPadding>t.width&&(d="center",c=p(o))):r(n)&&(d="right",(t=>t-s-e.caretSize-e.caretPadding<0)(n)&&(d="center",c=p(o))),{xAlign:e.xAlign?e.xAlign:d,yAlign:e.yAlign?e.yAlign:c}}function br(t,e,i,a){var{caretSize:r,caretPadding:n,cornerRadius:o}=t,{xAlign:s,yAlign:l}=i,h=r+n,d=o+n,c=function(t,e,i){var{x:a,width:r}=t;return"right"===e?a-=r:"center"===e&&((a-=r/2)+r>i&&(a=i-r),a<0&&(a=0)),a}(e,s,a.width);return"center"===l?"left"===s?c+=h:"right"===s&&(c-=h):"left"===s?c-=d:"right"===s&&(c+=d),{x:c,y:function(t,e,i){var{y:a,height:r}=t;return"top"===e?a+=i:a-="bottom"===e?r+i:r/2,a}(e,l,h)}}function xr(t,e){var i=t.options;return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-i.xPadding:t.x+i.xPadding}function yr(t){return fr([],pr(t))}class _r extends _e{constructor(t){super(),this.opacity=0,this._active=[],this._chart=t._chart,this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this.$animations=void 0,this.options=void 0,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelTextColors=void 0,this.initialize()}initialize(){this.options=function(t){return(t=e({},mt.tooltips,t)).bodyFontFamily=dr(t.bodyFontFamily,mt.fontFamily),t.bodyFontStyle=dr(t.bodyFontStyle,mt.fontStyle),t.bodyFontSize=dr(t.bodyFontSize,mt.fontSize),t.boxHeight=dr(t.boxHeight,t.bodyFontSize),t.boxWidth=dr(t.boxWidth,t.bodyFontSize),t.titleFontFamily=dr(t.titleFontFamily,mt.fontFamily),t.titleFontStyle=dr(t.titleFontStyle,mt.fontStyle),t.titleFontSize=dr(t.titleFontSize,mt.fontSize),t.footerFontFamily=dr(t.footerFontFamily,mt.fontFamily),t.footerFontStyle=dr(t.footerFontStyle,mt.fontStyle),t.footerFontSize=dr(t.footerFontSize,mt.fontSize),t}(this._chart.options.tooltips)}_resolveAnimations(){var t=this,e=t._cachedAnimations;if(e)return e;var i=t._chart.options.animation&&t.options.animation,a=new he(t._chart,i);return t._cachedAnimations=Object.freeze(a),a}getTitle(t,e){var i=this.options.callbacks,a=i.beforeTitle.apply(this,[t,e]),r=i.title.apply(this,[t,e]),n=i.afterTitle.apply(this,[t,e]),o=[];return o=fr(o,pr(a)),o=fr(o,pr(r)),o=fr(o,pr(n))}getBeforeBody(t,e){return yr(this.options.callbacks.beforeBody.apply(this,[t,e]))}getBody(t,e){var i=this,a=i.options.callbacks,r=[];return re.each(t,t=>{var n={before:[],lines:[],after:[]};fr(n.before,pr(a.beforeLabel.call(i,t,e))),fr(n.lines,a.label.call(i,t,e)),fr(n.after,pr(a.afterLabel.call(i,t,e))),r.push(n)}),r}getAfterBody(t,e){return yr(this.options.callbacks.afterBody.apply(this,[t,e]))}getFooter(t,e){var i=this.options.callbacks,a=i.beforeFooter.apply(this,[t,e]),r=i.footer.apply(this,[t,e]),n=i.afterFooter.apply(this,[t,e]),o=[];return o=fr(o,pr(a)),o=fr(o,pr(r)),o=fr(o,pr(n))}_createItems(){var t,e,i=this,a=i._active,r=i.options,n=i._chart.data,o=[],s=[],l=[];for(t=0,e=a.length;tr.filter(t,n))),r.itemSort&&(l=l.sort((t,e)=>r.itemSort(t,e,n))),re.each(l,t=>{o.push(r.callbacks.labelColor.call(i,t,i._chart)),s.push(r.callbacks.labelTextColor.call(i,t,i._chart))}),i.labelColors=o,i.labelTextColors=s,i.dataPoints=l,l}update(t){var i,a=this,r=a.options,n=a._active;if(n.length){var o=a._chart.data,s=ur[r.position].call(a,n,a._eventPosition),l=a._createItems();a.title=a.getTitle(l,o),a.beforeBody=a.getBeforeBody(l,o),a.body=a.getBody(l,o),a.afterBody=a.getAfterBody(l,o),a.footer=a.getFooter(l,o);var h=a._size=vr(a),d=e({},s,h),c=mr(a._chart,r,d),u=br(r,d,c,a._chart);a.xAlign=c.xAlign,a.yAlign=c.yAlign,i={opacity:1,x:u.x,y:u.y,width:h.width,height:h.height,caretX:s.x,caretY:s.y}}else 0!==a.opacity&&(i={opacity:0});i&&a._resolveAnimations().update(a,i),t&&r.custom&&r.custom.call(a)}drawCaret(t,e,i){var a=this.getCaretPosition(t,i);e.lineTo(a.x1,a.y1),e.lineTo(a.x2,a.y2),e.lineTo(a.x3,a.y3)}getCaretPosition(t,e){var i,a,r,n,o,s,{xAlign:l,yAlign:h,options:d}=this,{cornerRadius:c,caretSize:u}=d,{x:f,y:p}=t,{width:g,height:v}=e;return"center"===h?(a="left"===l?(i=f)-u:(i=f+g)+u,r=i,n=(o=p+v/2)+u,s=o-u):(i=(a="left"===l?f+c+u:"right"===l?f+g-c-u:this.caretX)-u,r=a+u,o="top"===h?(n=p)-u:(n=p+v)+u,s=n),{x1:i,x2:a,x3:r,y1:n,y2:o,y3:s}}drawTitle(t,e){var i,a,r,n=this,o=n.options,s=n.title,l=s.length;if(l){var h=cr(o.rtl,n.x,n.width);for(t.x=xr(n,o.titleAlign),e.textAlign=h.textAlign(o.titleAlign),e.textBaseline="middle",i=o.titleFontSize,a=o.titleSpacing,e.fillStyle=o.titleFontColor,e.font=re.fontString(i,o.titleFontStyle,o.titleFontFamily),r=0;r0&&e.stroke()}_updateAnimationTarget(){var t=this,i=t._chart,a=t.options,r=t.$animations,n=r&&r.x,o=r&&r.y;if(n||o){var s=ur[a.position].call(t,t._active,t._eventPosition);if(!s)return;var l=t._size=vr(t),h=e({},s,t._size),d=mr(i,a,h),c=br(a,h,d,i);n._to===c.x&&o._to===c.y||(t.xAlign=d.xAlign,t.yAlign=d.yAlign,t.width=l.width,t.height=l.height,t.caretX=s.x,t.caretY=s.y,t._resolveAnimations().update(t,c))}}draw(t){var e=this,i=e.options,a=e.opacity;if(a){e._updateAnimationTarget();var r={width:e.width,height:e.height},n={x:e.x,y:e.y};a=Math.abs(a)<.001?0:a;var o=e.title.length||e.beforeBody.length||e.body.length||e.afterBody.length||e.footer.length;i.enabled&&o&&(t.save(),t.globalAlpha=a,e.drawBackground(n,t,r),re.rtl.overrideTextDirection(t,i.textDirection),n.y+=i.yPadding,e.drawTitle(n,t),e.drawBody(n,t),e.drawFooter(n,t),re.rtl.restoreTextDirection(t,i.textDirection),t.restore())}}handleEvent(t,e){var i,a=this,r=a.options,n=a._active||[],o=[];return"mouseout"!==t.type&&(o=a._chart.getElementsAtEventForMode(t,r.mode,r,e),r.reverse&&o.reverse()),(i=e||!re._elementsEqual(o,n))&&(a._active=o,(r.enabled||r.custom)&&(a._eventPosition={x:t.x,y:t.y},a.update(!0))),i}}_r.positioners=ur;var Mr={filler:ir,legend:or,title:hr,tooltip:{id:"tooltip",_element:_r,positioners:ur,afterInit(t){t.options.tooltips&&(t.tooltip=new _r({_chart:t}))},beforeUpdate(t){t.tooltip&&t.tooltip.initialize()},reset(t){t.tooltip&&t.tooltip.initialize()},afterDraw(t){var e=t.tooltip,i={tooltip:e};!1!==Wi.notify(t,"beforeTooltipDraw",[i])&&(e.draw(t.ctx),Wi.notify(t,"afterTooltipDraw",[i]))},afterEvent(t,e,i){if(t.tooltip){var a=i;t.tooltip.handleEvent(e,a)}}}};for(var wr in Zi.helpers=re,Zi._adapters=ta,Zi.Animation=se,Zi.Animator=ne,Zi.animationService=he,Zi.controllers=si,Zi.DatasetController=ye,Zi.defaults=mt,Zi.Element=_e,Zi.elements=$e,Zi.Interaction=vi,Zi.layouts=Pi,Zi.platforms=Vi,Zi.plugins=Wi,Zi.Scale=la,Zi.scaleService=Ni,Zi.Ticks=ia,Object.keys(Ya).forEach(t=>Zi.scaleService.registerScale(Ya[t])),Mr)Object.prototype.hasOwnProperty.call(Mr,wr)&&Zi.plugins.register(Mr[wr]);"undefined"!=typeof window&&(window.Chart=Zi);export default Zi; diff --git a/dist/next/Chart.js b/dist/next/Chart.js new file mode 100644 index 0000000000..b20a08ccf4 --- /dev/null +++ b/dist/next/Chart.js @@ -0,0 +1,13209 @@ +/*! + * Chart.js v3.0.0-alpha + * https://www.chartjs.org + * (c) 2020 Chart.js Contributors + * Released under the MIT License + */ +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : +typeof define === 'function' && define.amd ? define(factory) : +(global = global || self, global.Chart = factory()); +}(this, (function () { 'use strict'; + +var MapShim = function () { + if (typeof Map !== 'undefined') { + return Map; + } + function getIndex(arr, key) { + var result = -1; + arr.some(function (entry, index) { + if (entry[0] === key) { + result = index; + return true; + } + return false; + }); + return result; + } + return ( + function () { + function class_1() { + this.__entries__ = []; + } + Object.defineProperty(class_1.prototype, "size", { + get: function get() { + return this.__entries__.length; + }, + enumerable: true, + configurable: true + }); + class_1.prototype.get = function (key) { + var index = getIndex(this.__entries__, key); + var entry = this.__entries__[index]; + return entry && entry[1]; + }; + class_1.prototype.set = function (key, value) { + var index = getIndex(this.__entries__, key); + if (~index) { + this.__entries__[index][1] = value; + } else { + this.__entries__.push([key, value]); + } + }; + class_1.prototype["delete"] = function (key) { + var entries = this.__entries__; + var index = getIndex(entries, key); + if (~index) { + entries.splice(index, 1); + } + }; + class_1.prototype.has = function (key) { + return !!~getIndex(this.__entries__, key); + }; + class_1.prototype.clear = function () { + this.__entries__.splice(0); + }; + class_1.prototype.forEach = function (callback, ctx) { + if (ctx === void 0) { + ctx = null; + } + for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) { + var entry = _a[_i]; + callback.call(ctx, entry[1], entry[0]); + } + }; + return class_1; + }() + ); +}(); +var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document; +var global$1 = function () { + if (typeof global !== 'undefined' && global.Math === Math) { + return global; + } + if (typeof self !== 'undefined' && self.Math === Math) { + return self; + } + if (typeof window !== 'undefined' && window.Math === Math) { + return window; + } + return Function('return this')(); +}(); +var requestAnimationFrame$1 = function () { + if (typeof requestAnimationFrame === 'function') { + return requestAnimationFrame.bind(global$1); + } + return function (callback) { + return setTimeout(function () { + return callback(Date.now()); + }, 1000 / 60); + }; +}(); +var trailingTimeout = 2; +function throttle(callback, delay) { + var leadingCall = false, + trailingCall = false, + lastCallTime = 0; + function resolvePending() { + if (leadingCall) { + leadingCall = false; + callback(); + } + if (trailingCall) { + proxy(); + } + } + function timeoutCallback() { + requestAnimationFrame$1(resolvePending); + } + function proxy() { + var timeStamp = Date.now(); + if (leadingCall) { + if (timeStamp - lastCallTime < trailingTimeout) { + return; + } + trailingCall = true; + } else { + leadingCall = true; + trailingCall = false; + setTimeout(timeoutCallback, delay); + } + lastCallTime = timeStamp; + } + return proxy; +} +var REFRESH_DELAY = 20; +var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight']; +var mutationObserverSupported = typeof MutationObserver !== 'undefined'; +var ResizeObserverController = +function () { + function ResizeObserverController() { + this.connected_ = false; + this.mutationEventsAdded_ = false; + this.mutationsObserver_ = null; + this.observers_ = []; + this.onTransitionEnd_ = this.onTransitionEnd_.bind(this); + this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY); + } + ResizeObserverController.prototype.addObserver = function (observer) { + if (!~this.observers_.indexOf(observer)) { + this.observers_.push(observer); + } + if (!this.connected_) { + this.connect_(); + } + }; + ResizeObserverController.prototype.removeObserver = function (observer) { + var observers = this.observers_; + var index = observers.indexOf(observer); + if (~index) { + observers.splice(index, 1); + } + if (!observers.length && this.connected_) { + this.disconnect_(); + } + }; + ResizeObserverController.prototype.refresh = function () { + var changesDetected = this.updateObservers_(); + if (changesDetected) { + this.refresh(); + } + }; + ResizeObserverController.prototype.updateObservers_ = function () { + var activeObservers = this.observers_.filter(function (observer) { + return observer.gatherActive(), observer.hasActive(); + }); + activeObservers.forEach(function (observer) { + return observer.broadcastActive(); + }); + return activeObservers.length > 0; + }; + ResizeObserverController.prototype.connect_ = function () { + if (!isBrowser || this.connected_) { + return; + } + document.addEventListener('transitionend', this.onTransitionEnd_); + window.addEventListener('resize', this.refresh); + if (mutationObserverSupported) { + this.mutationsObserver_ = new MutationObserver(this.refresh); + this.mutationsObserver_.observe(document, { + attributes: true, + childList: true, + characterData: true, + subtree: true + }); + } else { + document.addEventListener('DOMSubtreeModified', this.refresh); + this.mutationEventsAdded_ = true; + } + this.connected_ = true; + }; + ResizeObserverController.prototype.disconnect_ = function () { + if (!isBrowser || !this.connected_) { + return; + } + document.removeEventListener('transitionend', this.onTransitionEnd_); + window.removeEventListener('resize', this.refresh); + if (this.mutationsObserver_) { + this.mutationsObserver_.disconnect(); + } + if (this.mutationEventsAdded_) { + document.removeEventListener('DOMSubtreeModified', this.refresh); + } + this.mutationsObserver_ = null; + this.mutationEventsAdded_ = false; + this.connected_ = false; + }; + ResizeObserverController.prototype.onTransitionEnd_ = function (_a) { + var _b = _a.propertyName, + propertyName = _b === void 0 ? '' : _b; + var isReflowProperty = transitionKeys.some(function (key) { + return !!~propertyName.indexOf(key); + }); + if (isReflowProperty) { + this.refresh(); + } + }; + ResizeObserverController.getInstance = function () { + if (!this.instance_) { + this.instance_ = new ResizeObserverController(); + } + return this.instance_; + }; + ResizeObserverController.instance_ = null; + return ResizeObserverController; +}(); +var defineConfigurable = function defineConfigurable(target, props) { + for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) { + var key = _a[_i]; + Object.defineProperty(target, key, { + value: props[key], + enumerable: false, + writable: false, + configurable: true + }); + } + return target; +}; +var getWindowOf = function getWindowOf(target) { + var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView; + return ownerGlobal || global$1; +}; +var emptyRect = createRectInit(0, 0, 0, 0); +function toFloat(value) { + return parseFloat(value) || 0; +} +function getBordersSize(styles) { + var positions = []; + for (var _i = 1; _i < arguments.length; _i++) { + positions[_i - 1] = arguments[_i]; + } + return positions.reduce(function (size, position) { + var value = styles['border-' + position + '-width']; + return size + toFloat(value); + }, 0); +} +function getPaddings(styles) { + var positions = ['top', 'right', 'bottom', 'left']; + var paddings = {}; + for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) { + var position = positions_1[_i]; + var value = styles['padding-' + position]; + paddings[position] = toFloat(value); + } + return paddings; +} +function getSVGContentRect(target) { + var bbox = target.getBBox(); + return createRectInit(0, 0, bbox.width, bbox.height); +} +function getHTMLElementContentRect(target) { + var clientWidth = target.clientWidth, + clientHeight = target.clientHeight; + if (!clientWidth && !clientHeight) { + return emptyRect; + } + var styles = getWindowOf(target).getComputedStyle(target); + var paddings = getPaddings(styles); + var horizPad = paddings.left + paddings.right; + var vertPad = paddings.top + paddings.bottom; + var width = toFloat(styles.width), + height = toFloat(styles.height); + if (styles.boxSizing === 'border-box') { + if (Math.round(width + horizPad) !== clientWidth) { + width -= getBordersSize(styles, 'left', 'right') + horizPad; + } + if (Math.round(height + vertPad) !== clientHeight) { + height -= getBordersSize(styles, 'top', 'bottom') + vertPad; + } + } + if (!isDocumentElement(target)) { + var vertScrollbar = Math.round(width + horizPad) - clientWidth; + var horizScrollbar = Math.round(height + vertPad) - clientHeight; + if (Math.abs(vertScrollbar) !== 1) { + width -= vertScrollbar; + } + if (Math.abs(horizScrollbar) !== 1) { + height -= horizScrollbar; + } + } + return createRectInit(paddings.left, paddings.top, width, height); +} +var isSVGGraphicsElement = function () { + if (typeof SVGGraphicsElement !== 'undefined') { + return function (target) { + return target instanceof getWindowOf(target).SVGGraphicsElement; + }; + } + return function (target) { + return target instanceof getWindowOf(target).SVGElement && typeof target.getBBox === 'function'; + }; +}(); +function isDocumentElement(target) { + return target === getWindowOf(target).document.documentElement; +} +function getContentRect(target) { + if (!isBrowser) { + return emptyRect; + } + if (isSVGGraphicsElement(target)) { + return getSVGContentRect(target); + } + return getHTMLElementContentRect(target); +} +function createReadOnlyRect(_a) { + var x = _a.x, + y = _a.y, + width = _a.width, + height = _a.height; + var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object; + var rect = Object.create(Constr.prototype); + defineConfigurable(rect, { + x: x, + y: y, + width: width, + height: height, + top: y, + right: x + width, + bottom: height + y, + left: x + }); + return rect; +} +function createRectInit(x, y, width, height) { + return { + x: x, + y: y, + width: width, + height: height + }; +} +var ResizeObservation = +function () { + function ResizeObservation(target) { + this.broadcastWidth = 0; + this.broadcastHeight = 0; + this.contentRect_ = createRectInit(0, 0, 0, 0); + this.target = target; + } + ResizeObservation.prototype.isActive = function () { + var rect = getContentRect(this.target); + this.contentRect_ = rect; + return rect.width !== this.broadcastWidth || rect.height !== this.broadcastHeight; + }; + ResizeObservation.prototype.broadcastRect = function () { + var rect = this.contentRect_; + this.broadcastWidth = rect.width; + this.broadcastHeight = rect.height; + return rect; + }; + return ResizeObservation; +}(); +var ResizeObserverEntry = +function () { + function ResizeObserverEntry(target, rectInit) { + var contentRect = createReadOnlyRect(rectInit); + defineConfigurable(this, { + target: target, + contentRect: contentRect + }); + } + return ResizeObserverEntry; +}(); +var ResizeObserverSPI = +function () { + function ResizeObserverSPI(callback, controller, callbackCtx) { + this.activeObservations_ = []; + this.observations_ = new MapShim(); + if (typeof callback !== 'function') { + throw new TypeError('The callback provided as parameter 1 is not a function.'); + } + this.callback_ = callback; + this.controller_ = controller; + this.callbackCtx_ = callbackCtx; + } + ResizeObserverSPI.prototype.observe = function (target) { + if (!arguments.length) { + throw new TypeError('1 argument required, but only 0 present.'); + } + if (typeof Element === 'undefined' || !(Element instanceof Object)) { + return; + } + if (!(target instanceof getWindowOf(target).Element)) { + throw new TypeError('parameter 1 is not of type "Element".'); + } + var observations = this.observations_; + if (observations.has(target)) { + return; + } + observations.set(target, new ResizeObservation(target)); + this.controller_.addObserver(this); + this.controller_.refresh(); + }; + ResizeObserverSPI.prototype.unobserve = function (target) { + if (!arguments.length) { + throw new TypeError('1 argument required, but only 0 present.'); + } + if (typeof Element === 'undefined' || !(Element instanceof Object)) { + return; + } + if (!(target instanceof getWindowOf(target).Element)) { + throw new TypeError('parameter 1 is not of type "Element".'); + } + var observations = this.observations_; + if (!observations.has(target)) { + return; + } + observations["delete"](target); + if (!observations.size) { + this.controller_.removeObserver(this); + } + }; + ResizeObserverSPI.prototype.disconnect = function () { + this.clearActive(); + this.observations_.clear(); + this.controller_.removeObserver(this); + }; + ResizeObserverSPI.prototype.gatherActive = function () { + var _this = this; + this.clearActive(); + this.observations_.forEach(function (observation) { + if (observation.isActive()) { + _this.activeObservations_.push(observation); + } + }); + }; + ResizeObserverSPI.prototype.broadcastActive = function () { + if (!this.hasActive()) { + return; + } + var ctx = this.callbackCtx_; + var entries = this.activeObservations_.map(function (observation) { + return new ResizeObserverEntry(observation.target, observation.broadcastRect()); + }); + this.callback_.call(ctx, entries, ctx); + this.clearActive(); + }; + ResizeObserverSPI.prototype.clearActive = function () { + this.activeObservations_.splice(0); + }; + ResizeObserverSPI.prototype.hasActive = function () { + return this.activeObservations_.length > 0; + }; + return ResizeObserverSPI; +}(); +var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim(); +var ResizeObserver$1 = +function () { + function ResizeObserver(callback) { + if (!(this instanceof ResizeObserver)) { + throw new TypeError('Cannot call a class as a function.'); + } + if (!arguments.length) { + throw new TypeError('1 argument required, but only 0 present.'); + } + var controller = ResizeObserverController.getInstance(); + var observer = new ResizeObserverSPI(callback, controller, this); + observers.set(this, observer); + } + return ResizeObserver; +}(); +['observe', 'unobserve', 'disconnect'].forEach(function (method) { + ResizeObserver$1.prototype[method] = function () { + var _a; + return (_a = observers.get(this))[method].apply(_a, arguments); + }; +}); +var index = function () { + if (typeof global$1.ResizeObserver !== 'undefined') { + return global$1.ResizeObserver; + } + return ResizeObserver$1; +}(); + +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + return _extends.apply(this, arguments); +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf(subClass, superClass); +} + +function _getPrototypeOf(o) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o); + }; + return _getPrototypeOf(o); +} + +function _setPrototypeOf(o, p) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { + o.__proto__ = p; + return o; + }; + + return _setPrototypeOf(o, p); +} + +function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) return false; + if (Reflect.construct.sham) return false; + if (typeof Proxy === "function") return true; + + try { + Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); + return true; + } catch (e) { + return false; + } +} + +function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return self; +} + +function _possibleConstructorReturn(self, call) { + if (call && (typeof call === "object" || typeof call === "function")) { + return call; + } + + return _assertThisInitialized(self); +} + +function _createSuper(Derived) { + return function () { + var Super = _getPrototypeOf(Derived), + result; + + if (_isNativeReflectConstruct()) { + var NewTarget = _getPrototypeOf(this).constructor; + + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + + return _possibleConstructorReturn(this, result); + }; +} + +function _superPropBase(object, property) { + while (!Object.prototype.hasOwnProperty.call(object, property)) { + object = _getPrototypeOf(object); + if (object === null) break; + } + + return object; +} + +function _get(target, property, receiver) { + if (typeof Reflect !== "undefined" && Reflect.get) { + _get = Reflect.get; + } else { + _get = function _get(target, property, receiver) { + var base = _superPropBase(target, property); + + if (!base) return; + var desc = Object.getOwnPropertyDescriptor(base, property); + + if (desc.get) { + return desc.get.call(receiver); + } + + return desc.value; + }; + } + + return _get(target, property, receiver || target); +} + +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} + +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} + +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); +} + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(n); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} + +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + + return arr2; +} + +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + +function noop() {} +var uid = function () { + var id = 0; + return function () { + return id++; + }; +}(); +function isNullOrUndef(value) { + return value === null || typeof value === 'undefined'; +} +function isArray(value) { + if (Array.isArray && Array.isArray(value)) { + return true; + } + var type = Object.prototype.toString.call(value); + if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') { + return true; + } + return false; +} +function isObject(value) { + return value !== null && Object.prototype.toString.call(value) === '[object Object]'; +} +var isNumberFinite = function isNumberFinite(value) { + return (typeof value === 'number' || value instanceof Number) && isFinite(+value); +}; +function valueOrDefault(value, defaultValue) { + return typeof value === 'undefined' ? defaultValue : value; +} +function valueAtIndexOrDefault(value, index, defaultValue) { + return valueOrDefault(isArray(value) ? value[index] : value, defaultValue); +} +function callback(fn, args, thisArg) { + if (fn && typeof fn.call === 'function') { + return fn.apply(thisArg, args); + } +} +function each(loopable, fn, thisArg, reverse) { + var i, len, keys; + if (isArray(loopable)) { + len = loopable.length; + if (reverse) { + for (i = len - 1; i >= 0; i--) { + fn.call(thisArg, loopable[i], i); + } + } else { + for (i = 0; i < len; i++) { + fn.call(thisArg, loopable[i], i); + } + } + } else if (isObject(loopable)) { + keys = Object.keys(loopable); + len = keys.length; + for (i = 0; i < len; i++) { + fn.call(thisArg, loopable[keys[i]], keys[i]); + } + } +} +function arrayEquals(a0, a1) { + var i, ilen, v0, v1; + if (!a0 || !a1 || a0.length !== a1.length) { + return false; + } + for (i = 0, ilen = a0.length; i < ilen; ++i) { + v0 = a0[i]; + v1 = a1[i]; + if (v0 instanceof Array && v1 instanceof Array) { + if (!arrayEquals(v0, v1)) { + return false; + } + } else if (v0 !== v1) { + return false; + } + } + return true; +} +function _elementsEqual(a0, a1) { + var i, ilen, v0, v1; + if (!a0 || !a1 || a0.length !== a1.length) { + return false; + } + for (i = 0, ilen = a0.length; i < ilen; ++i) { + v0 = a0[i]; + v1 = a1[i]; + if (v0.datasetIndex !== v1.datasetIndex || v0.index !== v1.index) { + return false; + } + } + return true; +} +function clone(source) { + if (isArray(source)) { + return source.map(clone); + } + if (isObject(source)) { + var target = {}; + var keys = Object.keys(source); + var klen = keys.length; + var k = 0; + for (; k < klen; ++k) { + target[keys[k]] = clone(source[keys[k]]); + } + return target; + } + return source; +} +function _merger(key, target, source, options) { + var tval = target[key]; + var sval = source[key]; + if (isObject(tval) && isObject(sval)) { + merge(tval, sval, options); + } else { + target[key] = clone(sval); + } +} +function merge(target, source, options) { + var sources = isArray(source) ? source : [source]; + var ilen = sources.length; + if (!isObject(target)) { + return target; + } + options = options || {}; + var merger = options.merger || _merger; + for (var i = 0; i < ilen; ++i) { + source = sources[i]; + if (!isObject(source)) { + continue; + } + var keys = Object.keys(source); + for (var k = 0, klen = keys.length; k < klen; ++k) { + merger(keys[k], target, source, options); + } + } + return target; +} +function mergeIf(target, source) { + return merge(target, source, { + merger: _mergerIf + }); +} +function _mergerIf(key, target, source) { + var tval = target[key]; + var sval = source[key]; + if (isObject(tval) && isObject(sval)) { + mergeIf(tval, sval); + } else if (!Object.prototype.hasOwnProperty.call(target, key)) { + target[key] = clone(sval); + } +} +function inherits(extensions) { + var me = this; + var ChartElement = extensions && Object.prototype.hasOwnProperty.call(extensions, 'constructor') ? extensions.constructor : function () { + return me.apply(this, arguments); + }; + var Surrogate = function Surrogate() { + this.constructor = ChartElement; + }; + Surrogate.prototype = me.prototype; + ChartElement.prototype = new Surrogate(); + ChartElement.extend = inherits; + if (extensions) { + _extends(ChartElement.prototype, extensions); + } + ChartElement.__super__ = me.prototype; + return ChartElement; +} +function _deprecated(scope, value, previous, current) { + if (value !== undefined) { + console.warn(scope + ': "' + previous + '" is deprecated. Please use "' + current + '" instead'); + } +} + +var coreHelpers = /*#__PURE__*/Object.freeze({ +__proto__: null, +noop: noop, +uid: uid, +isNullOrUndef: isNullOrUndef, +isArray: isArray, +isObject: isObject, +isFinite: isNumberFinite, +valueOrDefault: valueOrDefault, +valueAtIndexOrDefault: valueAtIndexOrDefault, +callback: callback, +each: each, +arrayEquals: arrayEquals, +_elementsEqual: _elementsEqual, +clone: clone, +_merger: _merger, +merge: merge, +mergeIf: mergeIf, +_mergerIf: _mergerIf, +inherits: inherits, +_deprecated: _deprecated +}); + +var PI = Math.PI; +var RAD_PER_DEG = PI / 180; +var DOUBLE_PI = PI * 2; +var HALF_PI = PI / 2; +var QUARTER_PI = PI / 4; +var TWO_THIRDS_PI = PI * 2 / 3; +function _measureText(ctx, data, gc, longest, string) { + var textWidth = data[string]; + if (!textWidth) { + textWidth = data[string] = ctx.measureText(string).width; + gc.push(string); + } + if (textWidth > longest) { + longest = textWidth; + } + return longest; +} +function _longestText(ctx, font, arrayOfThings, cache) { + cache = cache || {}; + var data = cache.data = cache.data || {}; + var gc = cache.garbageCollect = cache.garbageCollect || []; + if (cache.font !== font) { + data = cache.data = {}; + gc = cache.garbageCollect = []; + cache.font = font; + } + ctx.save(); + ctx.font = font; + var longest = 0; + var ilen = arrayOfThings.length; + var i, j, jlen, thing, nestedThing; + for (i = 0; i < ilen; i++) { + thing = arrayOfThings[i]; + if (thing !== undefined && thing !== null && isArray(thing) !== true) { + longest = _measureText(ctx, data, gc, longest, thing); + } else if (isArray(thing)) { + for (j = 0, jlen = thing.length; j < jlen; j++) { + nestedThing = thing[j]; + if (nestedThing !== undefined && nestedThing !== null && !isArray(nestedThing)) { + longest = _measureText(ctx, data, gc, longest, nestedThing); + } + } + } + } + ctx.restore(); + var gcLen = gc.length / 2; + if (gcLen > arrayOfThings.length) { + for (i = 0; i < gcLen; i++) { + delete data[gc[i]]; + } + gc.splice(0, gcLen); + } + return longest; +} +function _alignPixel(chart, pixel, width) { + var devicePixelRatio = chart.currentDevicePixelRatio; + var halfWidth = width / 2; + return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth; +} +function clear(chart) { + chart.ctx.clearRect(0, 0, chart.width, chart.height); +} +function drawPoint(ctx, options, x, y) { + var type, xOffset, yOffset, size, cornerRadius; + var style = options.pointStyle; + var rotation = options.rotation; + var radius = options.radius; + var rad = (rotation || 0) * RAD_PER_DEG; + if (style && _typeof(style) === 'object') { + type = style.toString(); + if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') { + ctx.save(); + ctx.translate(x, y); + ctx.rotate(rad); + ctx.drawImage(style, -style.width / 2, -style.height / 2, style.width, style.height); + ctx.restore(); + return; + } + } + if (isNaN(radius) || radius <= 0) { + return; + } + ctx.beginPath(); + switch (style) { + default: + ctx.arc(x, y, radius, 0, DOUBLE_PI); + ctx.closePath(); + break; + case 'triangle': + ctx.moveTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); + rad += TWO_THIRDS_PI; + ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); + rad += TWO_THIRDS_PI; + ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); + ctx.closePath(); + break; + case 'rectRounded': + cornerRadius = radius * 0.516; + size = radius - cornerRadius; + xOffset = Math.cos(rad + QUARTER_PI) * size; + yOffset = Math.sin(rad + QUARTER_PI) * size; + ctx.arc(x - xOffset, y - yOffset, cornerRadius, rad - PI, rad - HALF_PI); + ctx.arc(x + yOffset, y - xOffset, cornerRadius, rad - HALF_PI, rad); + ctx.arc(x + xOffset, y + yOffset, cornerRadius, rad, rad + HALF_PI); + ctx.arc(x - yOffset, y + xOffset, cornerRadius, rad + HALF_PI, rad + PI); + ctx.closePath(); + break; + case 'rect': + if (!rotation) { + size = Math.SQRT1_2 * radius; + ctx.rect(x - size, y - size, 2 * size, 2 * size); + break; + } + rad += QUARTER_PI; + case 'rectRot': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + yOffset, y - xOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.lineTo(x - yOffset, y + xOffset); + ctx.closePath(); + break; + case 'crossRot': + rad += QUARTER_PI; + case 'cross': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.moveTo(x + yOffset, y - xOffset); + ctx.lineTo(x - yOffset, y + xOffset); + break; + case 'star': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.moveTo(x + yOffset, y - xOffset); + ctx.lineTo(x - yOffset, y + xOffset); + rad += QUARTER_PI; + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + ctx.moveTo(x + yOffset, y - xOffset); + ctx.lineTo(x - yOffset, y + xOffset); + break; + case 'line': + xOffset = Math.cos(rad) * radius; + yOffset = Math.sin(rad) * radius; + ctx.moveTo(x - xOffset, y - yOffset); + ctx.lineTo(x + xOffset, y + yOffset); + break; + case 'dash': + ctx.moveTo(x, y); + ctx.lineTo(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius); + break; + } + ctx.fill(); + if (options.borderWidth > 0) { + ctx.stroke(); + } +} +function _isPointInArea(point, area) { + var epsilon = 0.5; + return point.x > area.left - epsilon && point.x < area.right + epsilon && point.y > area.top - epsilon && point.y < area.bottom + epsilon; +} +function clipArea(ctx, area) { + ctx.save(); + ctx.beginPath(); + ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top); + ctx.clip(); +} +function unclipArea(ctx) { + ctx.restore(); +} +function _steppedLineTo(ctx, previous, target, flip, mode) { + if (!previous) { + return ctx.lineTo(target.x, target.y); + } + if (mode === 'middle') { + var midpoint = (previous.x + target.x) / 2.0; + ctx.lineTo(midpoint, previous.y); + ctx.lineTo(midpoint, target.y); + } else if (mode === 'after' !== !!flip) { + ctx.lineTo(previous.x, target.y); + } else { + ctx.lineTo(target.x, previous.y); + } + ctx.lineTo(target.x, target.y); +} +function _bezierCurveTo(ctx, previous, target, flip) { + if (!previous) { + return ctx.lineTo(target.x, target.y); + } + ctx.bezierCurveTo(flip ? previous.controlPointPreviousX : previous.controlPointNextX, flip ? previous.controlPointPreviousY : previous.controlPointNextY, flip ? target.controlPointNextX : target.controlPointPreviousX, flip ? target.controlPointNextY : target.controlPointPreviousY, target.x, target.y); +} + +var canvas = /*#__PURE__*/Object.freeze({ +__proto__: null, +_measureText: _measureText, +_longestText: _longestText, +_alignPixel: _alignPixel, +clear: clear, +drawPoint: drawPoint, +_isPointInArea: _isPointInArea, +clipArea: clipArea, +unclipArea: unclipArea, +_steppedLineTo: _steppedLineTo, +_bezierCurveTo: _bezierCurveTo +}); + +var PI$1 = Math.PI; +var TAU = 2 * PI$1; +var PITAU = TAU + PI$1; +function _factorize(value) { + var result = []; + var sqrt = Math.sqrt(value); + var i; + for (i = 1; i < sqrt; i++) { + if (value % i === 0) { + result.push(i); + result.push(value / i); + } + } + if (sqrt === (sqrt | 0)) { + result.push(sqrt); + } + result.sort(function (a, b) { + return a - b; + }).pop(); + return result; +} +var log10 = Math.log10 || function (x) { + var exponent = Math.log(x) * Math.LOG10E; + var powerOf10 = Math.round(exponent); + var isPowerOf10 = x === Math.pow(10, powerOf10); + return isPowerOf10 ? powerOf10 : exponent; +}; +function isNumber(n) { + return !isNaN(parseFloat(n)) && isFinite(n); +} +function almostEquals(x, y, epsilon) { + return Math.abs(x - y) < epsilon; +} +function almostWhole(x, epsilon) { + var rounded = Math.round(x); + return rounded - epsilon <= x && rounded + epsilon >= x; +} +function _setMinAndMaxByKey(array, target, property) { + var i, ilen, value; + for (i = 0, ilen = array.length; i < ilen; i++) { + value = array[i][property]; + if (!isNaN(value)) { + target.min = Math.min(target.min, value); + target.max = Math.max(target.max, value); + } + } +} +var sign = Math.sign ? function (x) { + return Math.sign(x); +} : function (x) { + x = +x; + if (x === 0 || isNaN(x)) { + return x; + } + return x > 0 ? 1 : -1; +}; +function toRadians(degrees) { + return degrees * (PI$1 / 180); +} +function toDegrees(radians) { + return radians * (180 / PI$1); +} +function _decimalPlaces(x) { + if (!isNumberFinite(x)) { + return; + } + var e = 1; + var p = 0; + while (Math.round(x * e) / e !== x) { + e *= 10; + p++; + } + return p; +} +function getAngleFromPoint(centrePoint, anglePoint) { + var distanceFromXCenter = anglePoint.x - centrePoint.x; + var distanceFromYCenter = anglePoint.y - centrePoint.y; + var radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter); + var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter); + if (angle < -0.5 * PI$1) { + angle += TAU; + } + return { + angle: angle, + distance: radialDistanceFromCenter + }; +} +function distanceBetweenPoints(pt1, pt2) { + return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2)); +} +function _angleDiff(a, b) { + return (a - b + PITAU) % TAU - PI$1; +} +function _normalizeAngle(a) { + return (a % TAU + TAU) % TAU; +} +function _angleBetween(angle, start, end) { + var a = _normalizeAngle(angle); + var s = _normalizeAngle(start); + var e = _normalizeAngle(end); + var angleToStart = _normalizeAngle(s - a); + var angleToEnd = _normalizeAngle(e - a); + var startToAngle = _normalizeAngle(a - s); + var endToAngle = _normalizeAngle(a - e); + return a === s || a === e || angleToStart > angleToEnd && startToAngle < endToAngle; +} +function _limitValue(value, min, max) { + return Math.max(min, Math.min(max, value)); +} + +var math = /*#__PURE__*/Object.freeze({ +__proto__: null, +_factorize: _factorize, +log10: log10, +isNumber: isNumber, +almostEquals: almostEquals, +almostWhole: almostWhole, +_setMinAndMaxByKey: _setMinAndMaxByKey, +sign: sign, +toRadians: toRadians, +toDegrees: toDegrees, +_decimalPlaces: _decimalPlaces, +getAngleFromPoint: getAngleFromPoint, +distanceBetweenPoints: distanceBetweenPoints, +_angleDiff: _angleDiff, +_normalizeAngle: _normalizeAngle, +_angleBetween: _angleBetween, +_limitValue: _limitValue +}); + +var EPSILON = Number.EPSILON || 1e-14; +function splineCurve(firstPoint, middlePoint, afterPoint, t) { + var previous = firstPoint.skip ? middlePoint : firstPoint; + var current = middlePoint; + var next = afterPoint.skip ? middlePoint : afterPoint; + var d01 = Math.sqrt(Math.pow(current.x - previous.x, 2) + Math.pow(current.y - previous.y, 2)); + var d12 = Math.sqrt(Math.pow(next.x - current.x, 2) + Math.pow(next.y - current.y, 2)); + var s01 = d01 / (d01 + d12); + var s12 = d12 / (d01 + d12); + s01 = isNaN(s01) ? 0 : s01; + s12 = isNaN(s12) ? 0 : s12; + var fa = t * s01; + var fb = t * s12; + return { + previous: { + x: current.x - fa * (next.x - previous.x), + y: current.y - fa * (next.y - previous.y) + }, + next: { + x: current.x + fb * (next.x - previous.x), + y: current.y + fb * (next.y - previous.y) + } + }; +} +function splineCurveMonotone(points) { + var pointsWithTangents = (points || []).map(function (point) { + return { + model: point, + deltaK: 0, + mK: 0 + }; + }); + var pointsLen = pointsWithTangents.length; + var i, pointBefore, pointCurrent, pointAfter; + for (i = 0; i < pointsLen; ++i) { + pointCurrent = pointsWithTangents[i]; + if (pointCurrent.model.skip) { + continue; + } + pointBefore = i > 0 ? pointsWithTangents[i - 1] : null; + pointAfter = i < pointsLen - 1 ? pointsWithTangents[i + 1] : null; + if (pointAfter && !pointAfter.model.skip) { + var slopeDeltaX = pointAfter.model.x - pointCurrent.model.x; + pointCurrent.deltaK = slopeDeltaX !== 0 ? (pointAfter.model.y - pointCurrent.model.y) / slopeDeltaX : 0; + } + if (!pointBefore || pointBefore.model.skip) { + pointCurrent.mK = pointCurrent.deltaK; + } else if (!pointAfter || pointAfter.model.skip) { + pointCurrent.mK = pointBefore.deltaK; + } else if (sign(pointBefore.deltaK) !== sign(pointCurrent.deltaK)) { + pointCurrent.mK = 0; + } else { + pointCurrent.mK = (pointBefore.deltaK + pointCurrent.deltaK) / 2; + } + } + var alphaK, betaK, tauK, squaredMagnitude; + for (i = 0; i < pointsLen - 1; ++i) { + pointCurrent = pointsWithTangents[i]; + pointAfter = pointsWithTangents[i + 1]; + if (pointCurrent.model.skip || pointAfter.model.skip) { + continue; + } + if (almostEquals(pointCurrent.deltaK, 0, EPSILON)) { + pointCurrent.mK = pointAfter.mK = 0; + continue; + } + alphaK = pointCurrent.mK / pointCurrent.deltaK; + betaK = pointAfter.mK / pointCurrent.deltaK; + squaredMagnitude = Math.pow(alphaK, 2) + Math.pow(betaK, 2); + if (squaredMagnitude <= 9) { + continue; + } + tauK = 3 / Math.sqrt(squaredMagnitude); + pointCurrent.mK = alphaK * tauK * pointCurrent.deltaK; + pointAfter.mK = betaK * tauK * pointCurrent.deltaK; + } + var deltaX; + for (i = 0; i < pointsLen; ++i) { + pointCurrent = pointsWithTangents[i]; + if (pointCurrent.model.skip) { + continue; + } + pointBefore = i > 0 ? pointsWithTangents[i - 1] : null; + pointAfter = i < pointsLen - 1 ? pointsWithTangents[i + 1] : null; + if (pointBefore && !pointBefore.model.skip) { + deltaX = (pointCurrent.model.x - pointBefore.model.x) / 3; + pointCurrent.model.controlPointPreviousX = pointCurrent.model.x - deltaX; + pointCurrent.model.controlPointPreviousY = pointCurrent.model.y - deltaX * pointCurrent.mK; + } + if (pointAfter && !pointAfter.model.skip) { + deltaX = (pointAfter.model.x - pointCurrent.model.x) / 3; + pointCurrent.model.controlPointNextX = pointCurrent.model.x + deltaX; + pointCurrent.model.controlPointNextY = pointCurrent.model.y + deltaX * pointCurrent.mK; + } + } +} +function capControlPoint(pt, min, max) { + return Math.max(Math.min(pt, max), min); +} +function capBezierPoints(points, area) { + var i, ilen, point; + for (i = 0, ilen = points.length; i < ilen; ++i) { + point = points[i]; + if (!_isPointInArea(point, area)) { + continue; + } + if (i > 0 && _isPointInArea(points[i - 1], area)) { + point.controlPointPreviousX = capControlPoint(point.controlPointPreviousX, area.left, area.right); + point.controlPointPreviousY = capControlPoint(point.controlPointPreviousY, area.top, area.bottom); + } + if (i < points.length - 1 && _isPointInArea(points[i + 1], area)) { + point.controlPointNextX = capControlPoint(point.controlPointNextX, area.left, area.right); + point.controlPointNextY = capControlPoint(point.controlPointNextY, area.top, area.bottom); + } + } +} +function _updateBezierControlPoints(points, options, area, loop) { + var i, ilen, point, controlPoints; + if (options.spanGaps) { + points = points.filter(function (pt) { + return !pt.skip; + }); + } + if (options.cubicInterpolationMode === 'monotone') { + splineCurveMonotone(points); + } else { + var prev = loop ? points[points.length - 1] : points[0]; + for (i = 0, ilen = points.length; i < ilen; ++i) { + point = points[i]; + controlPoints = splineCurve(prev, point, points[Math.min(i + 1, ilen - (loop ? 0 : 1)) % ilen], options.tension); + point.controlPointPreviousX = controlPoints.previous.x; + point.controlPointPreviousY = controlPoints.previous.y; + point.controlPointNextX = controlPoints.next.x; + point.controlPointNextY = controlPoints.next.y; + prev = point; + } + } + if (options.capBezierPoints) { + capBezierPoints(points, area); + } +} + +var curve = /*#__PURE__*/Object.freeze({ +__proto__: null, +splineCurve: splineCurve, +splineCurveMonotone: splineCurveMonotone, +_updateBezierControlPoints: _updateBezierControlPoints +}); + +function isConstrainedValue(value) { + return value !== undefined && value !== null && value !== 'none'; +} +function _getParentNode(domNode) { + var parent = domNode.parentNode; + if (parent && parent.toString() === '[object ShadowRoot]') { + parent = parent.host; + } + return parent; +} +function parseMaxStyle(styleValue, node, parentProperty) { + var valueInPixels; + if (typeof styleValue === 'string') { + valueInPixels = parseInt(styleValue, 10); + if (styleValue.indexOf('%') !== -1) { + valueInPixels = valueInPixels / 100 * node.parentNode[parentProperty]; + } + } else { + valueInPixels = styleValue; + } + return valueInPixels; +} +function getConstraintDimension(domNode, maxStyle, percentageProperty) { + var view = document.defaultView; + var parentNode = _getParentNode(domNode); + var constrainedNode = view.getComputedStyle(domNode)[maxStyle]; + var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle]; + var hasCNode = isConstrainedValue(constrainedNode); + var hasCContainer = isConstrainedValue(constrainedContainer); + var infinity = Number.POSITIVE_INFINITY; + if (hasCNode || hasCContainer) { + return Math.min(hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity, hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity); + } +} +function getStyle(el, property) { + return el.currentStyle ? el.currentStyle[property] : document.defaultView.getComputedStyle(el, null).getPropertyValue(property); +} +function getConstraintWidth(domNode) { + return getConstraintDimension(domNode, 'max-width', 'clientWidth'); +} +function getConstraintHeight(domNode) { + return getConstraintDimension(domNode, 'max-height', 'clientHeight'); +} +function _calculatePadding(container, padding, parentDimension) { + padding = getStyle(container, padding); + return padding.indexOf('%') > -1 ? parentDimension * parseInt(padding, 10) / 100 : parseInt(padding, 10); +} +function getRelativePosition(evt, chart) { + var mouseX, mouseY; + var e = evt.originalEvent || evt; + var canvasElement = chart.canvas; + var boundingRect = canvasElement.getBoundingClientRect(); + var touches = e.touches; + if (touches && touches.length > 0) { + mouseX = touches[0].clientX; + mouseY = touches[0].clientY; + } else { + mouseX = e.clientX; + mouseY = e.clientY; + } + var paddingLeft = parseFloat(getStyle(canvasElement, 'padding-left')); + var paddingTop = parseFloat(getStyle(canvasElement, 'padding-top')); + var paddingRight = parseFloat(getStyle(canvasElement, 'padding-right')); + var paddingBottom = parseFloat(getStyle(canvasElement, 'padding-bottom')); + var width = boundingRect.right - boundingRect.left - paddingLeft - paddingRight; + var height = boundingRect.bottom - boundingRect.top - paddingTop - paddingBottom; + mouseX = Math.round((mouseX - boundingRect.left - paddingLeft) / width * canvasElement.width / chart.currentDevicePixelRatio); + mouseY = Math.round((mouseY - boundingRect.top - paddingTop) / height * canvasElement.height / chart.currentDevicePixelRatio); + return { + x: mouseX, + y: mouseY + }; +} +function getMaximumWidth(domNode) { + var container = _getParentNode(domNode); + if (!container) { + if (typeof domNode.clientWidth === 'number') { + return domNode.clientWidth; + } + return domNode.width; + } + var clientWidth = container.clientWidth; + var paddingLeft = _calculatePadding(container, 'padding-left', clientWidth); + var paddingRight = _calculatePadding(container, 'padding-right', clientWidth); + var w = clientWidth - paddingLeft - paddingRight; + var cw = getConstraintWidth(domNode); + return isNaN(cw) ? w : Math.min(w, cw); +} +function getMaximumHeight(domNode) { + var container = _getParentNode(domNode); + if (!container) { + if (typeof domNode.clientHeight === 'number') { + return domNode.clientHeight; + } + return domNode.height; + } + var clientHeight = container.clientHeight; + var paddingTop = _calculatePadding(container, 'padding-top', clientHeight); + var paddingBottom = _calculatePadding(container, 'padding-bottom', clientHeight); + var h = clientHeight - paddingTop - paddingBottom; + var ch = getConstraintHeight(domNode); + return isNaN(ch) ? h : Math.min(h, ch); +} +function retinaScale(chart, forceRatio) { + var pixelRatio = chart.currentDevicePixelRatio = forceRatio || typeof window !== 'undefined' && window.devicePixelRatio || 1; + var canvas = chart.canvas, + width = chart.width, + height = chart.height; + canvas.height = height * pixelRatio; + canvas.width = width * pixelRatio; + chart.ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0); + if (canvas.style && !canvas.style.height && !canvas.style.width) { + canvas.style.height = height + 'px'; + canvas.style.width = width + 'px'; + } +} + +var dom = /*#__PURE__*/Object.freeze({ +__proto__: null, +_getParentNode: _getParentNode, +getStyle: getStyle, +getRelativePosition: getRelativePosition, +getMaximumWidth: getMaximumWidth, +getMaximumHeight: getMaximumHeight, +retinaScale: retinaScale +}); + +var effects = { + linear: function linear(t) { + return t; + }, + easeInQuad: function easeInQuad(t) { + return t * t; + }, + easeOutQuad: function easeOutQuad(t) { + return -t * (t - 2); + }, + easeInOutQuad: function easeInOutQuad(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t; + } + return -0.5 * (--t * (t - 2) - 1); + }, + easeInCubic: function easeInCubic(t) { + return t * t * t; + }, + easeOutCubic: function easeOutCubic(t) { + return (t -= 1) * t * t + 1; + }, + easeInOutCubic: function easeInOutCubic(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t * t; + } + return 0.5 * ((t -= 2) * t * t + 2); + }, + easeInQuart: function easeInQuart(t) { + return t * t * t * t; + }, + easeOutQuart: function easeOutQuart(t) { + return -((t -= 1) * t * t * t - 1); + }, + easeInOutQuart: function easeInOutQuart(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t * t * t; + } + return -0.5 * ((t -= 2) * t * t * t - 2); + }, + easeInQuint: function easeInQuint(t) { + return t * t * t * t * t; + }, + easeOutQuint: function easeOutQuint(t) { + return (t -= 1) * t * t * t * t + 1; + }, + easeInOutQuint: function easeInOutQuint(t) { + if ((t /= 0.5) < 1) { + return 0.5 * t * t * t * t * t; + } + return 0.5 * ((t -= 2) * t * t * t * t + 2); + }, + easeInSine: function easeInSine(t) { + return -Math.cos(t * (Math.PI / 2)) + 1; + }, + easeOutSine: function easeOutSine(t) { + return Math.sin(t * (Math.PI / 2)); + }, + easeInOutSine: function easeInOutSine(t) { + return -0.5 * (Math.cos(Math.PI * t) - 1); + }, + easeInExpo: function easeInExpo(t) { + return t === 0 ? 0 : Math.pow(2, 10 * (t - 1)); + }, + easeOutExpo: function easeOutExpo(t) { + return t === 1 ? 1 : -Math.pow(2, -10 * t) + 1; + }, + easeInOutExpo: function easeInOutExpo(t) { + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if ((t /= 0.5) < 1) { + return 0.5 * Math.pow(2, 10 * (t - 1)); + } + return 0.5 * (-Math.pow(2, -10 * --t) + 2); + }, + easeInCirc: function easeInCirc(t) { + if (t >= 1) { + return t; + } + return -(Math.sqrt(1 - t * t) - 1); + }, + easeOutCirc: function easeOutCirc(t) { + return Math.sqrt(1 - (t -= 1) * t); + }, + easeInOutCirc: function easeInOutCirc(t) { + if ((t /= 0.5) < 1) { + return -0.5 * (Math.sqrt(1 - t * t) - 1); + } + return 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1); + }, + easeInElastic: function easeInElastic(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if (!p) { + p = 0.3; + } + { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p)); + }, + easeOutElastic: function easeOutElastic(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if (t === 1) { + return 1; + } + if (!p) { + p = 0.3; + } + { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + return a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p) + 1; + }, + easeInOutElastic: function easeInOutElastic(t) { + var s = 1.70158; + var p = 0; + var a = 1; + if (t === 0) { + return 0; + } + if ((t /= 0.5) === 2) { + return 1; + } + if (!p) { + p = 0.45; + } + { + s = p / (2 * Math.PI) * Math.asin(1 / a); + } + if (t < 1) { + return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p)); + } + return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p) * 0.5 + 1; + }, + easeInBack: function easeInBack(t) { + var s = 1.70158; + return t * t * ((s + 1) * t - s); + }, + easeOutBack: function easeOutBack(t) { + var s = 1.70158; + return (t -= 1) * t * ((s + 1) * t + s) + 1; + }, + easeInOutBack: function easeInOutBack(t) { + var s = 1.70158; + if ((t /= 0.5) < 1) { + return 0.5 * (t * t * (((s *= 1.525) + 1) * t - s)); + } + return 0.5 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2); + }, + easeInBounce: function easeInBounce(t) { + return 1 - effects.easeOutBounce(1 - t); + }, + easeOutBounce: function easeOutBounce(t) { + if (t < 1 / 2.75) { + return 7.5625 * t * t; + } + if (t < 2 / 2.75) { + return 7.5625 * (t -= 1.5 / 2.75) * t + 0.75; + } + if (t < 2.5 / 2.75) { + return 7.5625 * (t -= 2.25 / 2.75) * t + 0.9375; + } + return 7.5625 * (t -= 2.625 / 2.75) * t + 0.984375; + }, + easeInOutBounce: function easeInOutBounce(t) { + if (t < 0.5) { + return effects.easeInBounce(t * 2) * 0.5; + } + return effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5; + } +}; + +var Defaults = function () { + function Defaults() { + _classCallCheck(this, Defaults); + this.color = 'rgba(0,0,0,0.1)'; + this.elements = {}; + this.events = ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove']; + this.fontColor = '#666'; + this.fontFamily = "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"; + this.fontSize = 12; + this.fontStyle = 'normal'; + this.lineHeight = 1.2; + this.hover = { + onHover: null, + mode: 'nearest', + intersect: true + }; + this.maintainAspectRatio = true; + this.onClick = null; + this.responsive = true; + this.showLines = true; + this.plugins = undefined; + this.scale = undefined; + this.legend = undefined; + this.title = undefined; + this.tooltips = undefined; + this.doughnut = undefined; + } + _createClass(Defaults, [{ + key: "set", + value: function set(scope, values) { + return merge(this[scope] || (this[scope] = {}), values); + } + }]); + return Defaults; +}(); +var defaults = new Defaults(); + +function toFontString(font) { + if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) { + return null; + } + return (font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family; +} +function toLineHeight(value, size) { + var matches = ('' + value).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/); + if (!matches || matches[1] === 'normal') { + return size * 1.2; + } + value = +matches[2]; + switch (matches[3]) { + case 'px': + return value; + case '%': + value /= 100; + break; + } + return size * value; +} +function toPadding(value) { + var t, r, b, l; + if (isObject(value)) { + t = +value.top || 0; + r = +value.right || 0; + b = +value.bottom || 0; + l = +value.left || 0; + } else { + t = r = b = l = +value || 0; + } + return { + top: t, + right: r, + bottom: b, + left: l, + height: t + b, + width: l + r + }; +} +function _parseFont(options) { + var size = valueOrDefault(options.fontSize, defaults.fontSize); + if (typeof size === 'string') { + size = parseInt(size, 10); + } + var font = { + family: valueOrDefault(options.fontFamily, defaults.fontFamily), + lineHeight: toLineHeight(valueOrDefault(options.lineHeight, defaults.lineHeight), size), + size: size, + style: valueOrDefault(options.fontStyle, defaults.fontStyle), + weight: null, + string: '' + }; + font.string = toFontString(font); + return font; +} +function resolve(inputs, context, index, info) { + var cacheable = true; + var i, ilen, value; + for (i = 0, ilen = inputs.length; i < ilen; ++i) { + value = inputs[i]; + if (value === undefined) { + continue; + } + if (context !== undefined && typeof value === 'function') { + value = value(context); + cacheable = false; + } + if (index !== undefined && isArray(value)) { + value = value[index]; + cacheable = false; + } + if (value !== undefined) { + if (info && !cacheable) { + info.cacheable = false; + } + return value; + } + } +} + +var options = /*#__PURE__*/Object.freeze({ +__proto__: null, +toLineHeight: toLineHeight, +toPadding: toPadding, +_parseFont: _parseFont, +resolve: resolve +}); + +var getRightToLeftAdapter = function getRightToLeftAdapter(rectX, width) { + return { + x: function x(_x) { + return rectX + rectX + width - _x; + }, + setWidth: function setWidth(w) { + width = w; + }, + textAlign: function textAlign(align) { + if (align === 'center') { + return align; + } + return align === 'right' ? 'left' : 'right'; + }, + xPlus: function xPlus(x, value) { + return x - value; + }, + leftForLtr: function leftForLtr(x, itemWidth) { + return x - itemWidth; + } + }; +}; +var getLeftToRightAdapter = function getLeftToRightAdapter() { + return { + x: function x(_x2) { + return _x2; + }, + setWidth: function setWidth(w) { + }, + textAlign: function textAlign(align) { + return align; + }, + xPlus: function xPlus(x, value) { + return x + value; + }, + leftForLtr: function leftForLtr(x, _itemWidth) { + return x; + } + }; +}; +function getRtlAdapter(rtl, rectX, width) { + return rtl ? getRightToLeftAdapter(rectX, width) : getLeftToRightAdapter(); +} +function overrideTextDirection(ctx, direction) { + var style, original; + if (direction === 'ltr' || direction === 'rtl') { + style = ctx.canvas.style; + original = [style.getPropertyValue('direction'), style.getPropertyPriority('direction')]; + style.setProperty('direction', direction, 'important'); + ctx.prevTextDirection = original; + } +} +function restoreTextDirection(ctx, original) { + if (original !== undefined) { + delete ctx.prevTextDirection; + ctx.canvas.style.setProperty('direction', original[0], original[1]); + } +} + +var rtl = /*#__PURE__*/Object.freeze({ +__proto__: null, +getRtlAdapter: getRtlAdapter, +overrideTextDirection: overrideTextDirection, +restoreTextDirection: restoreTextDirection +}); + +/*! + * @kurkle/color v0.1.7 + * https://github.com/kurkle/color#readme + * (c) 2020 Jukka Kurkela + * Released under the MIT License + */ +var map = { + 0: 0, + 1: 1, + 2: 2, + 3: 3, + 4: 4, + 5: 5, + 6: 6, + 7: 7, + 8: 8, + 9: 9, + A: 10, + B: 11, + C: 12, + D: 13, + E: 14, + F: 15, + a: 10, + b: 11, + c: 12, + d: 13, + e: 14, + f: 15 +}; +var hex = '0123456789ABCDEF'; +var h1 = function h1(b) { + return hex[b & 0xF]; +}; +var h2 = function h2(b) { + return hex[(b & 0xF0) >> 4] + hex[b & 0xF]; +}; +var eq = function eq(b) { + return (b & 0xF0) >> 4 === (b & 0xF); +}; +function isShort(v) { + return eq(v.r) && eq(v.g) && eq(v.b) && eq(v.a); +} +function hexParse(str) { + var len = str.length; + var ret; + if (str[0] === '#') { + if (len === 4 || len === 5) { + ret = { + r: 255 & map[str[1]] * 17, + g: 255 & map[str[2]] * 17, + b: 255 & map[str[3]] * 17, + a: len === 5 ? map[str[4]] * 17 : 255 + }; + } else if (len === 7 || len === 9) { + ret = { + r: map[str[1]] << 4 | map[str[2]], + g: map[str[3]] << 4 | map[str[4]], + b: map[str[5]] << 4 | map[str[6]], + a: len === 9 ? map[str[7]] << 4 | map[str[8]] : 255 + }; + } + } + return ret; +} +function _hexString(v) { + var f = isShort(v) ? h1 : h2; + return v ? '#' + f(v.r) + f(v.g) + f(v.b) + (v.a < 255 ? f(v.a) : '') : v; +} +function round(v) { + return v + 0.5 | 0; +} +var lim = function lim(v, l, h) { + return Math.max(Math.min(v, h), l); +}; +function p2b(v) { + return lim(round(v * 2.55), 0, 255); +} +function n2b(v) { + return lim(round(v * 255), 0, 255); +} +function b2n(v) { + return lim(round(v / 2.55) / 100, 0, 1); +} +function n2p(v) { + return lim(round(v * 100), 0, 100); +} +var RGB_RE = /^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/; +function rgbParse(str) { + var m = RGB_RE.exec(str); + var a = 255; + var r, g, b; + if (!m) { + return; + } + if (m[7] !== r) { + var v = +m[7]; + a = 255 & (m[8] ? p2b(v) : v * 255); + } + r = +m[1]; + g = +m[3]; + b = +m[5]; + r = 255 & (m[2] ? p2b(r) : r); + g = 255 & (m[4] ? p2b(g) : g); + b = 255 & (m[6] ? p2b(b) : b); + return { + r: r, + g: g, + b: b, + a: a + }; +} +function _rgbString(v) { + return v && (v.a < 255 ? "rgba(".concat(v.r, ", ").concat(v.g, ", ").concat(v.b, ", ").concat(b2n(v.a), ")") : "rgb(".concat(v.r, ", ").concat(v.g, ", ").concat(v.b, ")")); +} +var HUE_RE = /^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/; +function hsl2rgbn(h, s, l) { + var a = s * Math.min(l, 1 - l); + var f = function f(n) { + var k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (n + h / 30) % 12; + return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1); + }; + return [f(0), f(8), f(4)]; +} +function hsv2rgbn(h, s, v) { + var f = function f(n) { + var k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (n + h / 60) % 6; + return v - v * s * Math.max(Math.min(k, 4 - k, 1), 0); + }; + return [f(5), f(3), f(1)]; +} +function hwb2rgbn(h, w, b) { + var rgb = hsl2rgbn(h, 1, 0.5); + var i; + if (w + b > 1) { + i = 1 / (w + b); + w *= i; + b *= i; + } + for (i = 0; i < 3; i++) { + rgb[i] *= 1 - w - b; + rgb[i] += w; + } + return rgb; +} +function rgb2hsl(v) { + var range = 255; + var r = v.r / range; + var g = v.g / range; + var b = v.b / range; + var max = Math.max(r, g, b); + var min = Math.min(r, g, b); + var l = (max + min) / 2; + var h, s, d; + if (max !== min) { + d = max - min; + s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4; + h = h * 60 + 0.5; + } + return [h | 0, s || 0, l]; +} +function calln(f, a, b, c) { + return (Array.isArray(a) ? f(a[0], a[1], a[2]) : f(a, b, c)).map(n2b); +} +function hsl2rgb(h, s, l) { + return calln(hsl2rgbn, h, s, l); +} +function hwb2rgb(h, w, b) { + return calln(hwb2rgbn, h, w, b); +} +function hsv2rgb(h, s, v) { + return calln(hsv2rgbn, h, s, v); +} +function hue(h) { + return (h % 360 + 360) % 360; +} +function hueParse(str) { + var m = HUE_RE.exec(str); + var a = 255; + var v; + if (!m) { + return; + } + if (m[5] !== v) { + a = m[6] ? p2b(+m[5]) : n2b(+m[5]); + } + var h = hue(+m[2]); + var p1 = +m[3] / 100; + var p2 = +m[4] / 100; + if (m[1] === 'hwb') { + v = hwb2rgb(h, p1, p2); + } else if (m[1] === 'hsv') { + v = hsv2rgb(h, p1, p2); + } else { + v = hsl2rgb(h, p1, p2); + } + return { + r: v[0], + g: v[1], + b: v[2], + a: a + }; +} +function _rotate(v, deg) { + var h = rgb2hsl(v); + h[0] = hue(h[0] + deg); + h = hsl2rgb(h); + v.r = h[0]; + v.g = h[1]; + v.b = h[2]; +} +function _hslString(v) { + if (!v) { + return; + } + var a = rgb2hsl(v); + var h = a[0]; + var s = n2p(a[1]); + var l = n2p(a[2]); + return v.a < 255 ? "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(b2n(v.a), ")") : "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)"); +} +var map$1 = { + x: 'dark', + Z: 'light', + Y: 're', + X: 'blu', + W: 'gr', + V: 'medium', + U: 'slate', + A: 'ee', + T: 'ol', + S: 'or', + B: 'ra', + C: 'lateg', + D: 'ights', + R: 'in', + Q: 'turquois', + E: 'hi', + P: 'ro', + O: 'al', + N: 'le', + M: 'de', + L: 'yello', + F: 'en', + K: 'ch', + G: 'arks', + H: 'ea', + I: 'ightg', + J: 'wh' +}; +function unpack(obj) { + var unpacked = {}; + var keys = Object.keys(obj); + var tkeys = Object.keys(map$1); + var i, j, k, ok, nk; + for (i = 0; i < keys.length; i++) { + ok = nk = keys[i]; + for (j = 0; j < tkeys.length; j++) { + k = tkeys[j]; + nk = nk.replace(k, map$1[k]); + } + k = parseInt(obj[ok], 16); + unpacked[nk] = [k >> 16 & 0xFF, k >> 8 & 0xFF, k & 0xFF]; + } + return unpacked; +} +var names = unpack({ + OiceXe: 'f0f8ff', + antiquewEte: 'faebd7', + aqua: 'ffff', + aquamarRe: '7fffd4', + azuY: 'f0ffff', + beige: 'f5f5dc', + bisque: 'ffe4c4', + black: '0', + blanKedOmond: 'ffebcd', + Xe: 'ff', + XeviTet: '8a2be2', + bPwn: 'a52a2a', + burlywood: 'deb887', + caMtXe: '5f9ea0', + KartYuse: '7fff00', + KocTate: 'd2691e', + cSO: 'ff7f50', + cSnflowerXe: '6495ed', + cSnsilk: 'fff8dc', + crimson: 'dc143c', + cyan: 'ffff', + xXe: '8b', + xcyan: '8b8b', + xgTMnPd: 'b8860b', + xWay: 'a9a9a9', + xgYF: '6400', + xgYy: 'a9a9a9', + xkhaki: 'bdb76b', + xmagFta: '8b008b', + xTivegYF: '556b2f', + xSange: 'ff8c00', + xScEd: '9932cc', + xYd: '8b0000', + xsOmon: 'e9967a', + xsHgYF: '8fbc8f', + xUXe: '483d8b', + xUWay: '2f4f4f', + xUgYy: '2f4f4f', + xQe: 'ced1', + xviTet: '9400d3', + dAppRk: 'ff1493', + dApskyXe: 'bfff', + dimWay: '696969', + dimgYy: '696969', + dodgerXe: '1e90ff', + fiYbrick: 'b22222', + flSOwEte: 'fffaf0', + foYstWAn: '228b22', + fuKsia: 'ff00ff', + gaRsbSo: 'dcdcdc', + ghostwEte: 'f8f8ff', + gTd: 'ffd700', + gTMnPd: 'daa520', + Way: '808080', + gYF: '8000', + gYFLw: 'adff2f', + gYy: '808080', + honeyMw: 'f0fff0', + hotpRk: 'ff69b4', + RdianYd: 'cd5c5c', + Rdigo: '4b0082', + ivSy: 'fffff0', + khaki: 'f0e68c', + lavFMr: 'e6e6fa', + lavFMrXsh: 'fff0f5', + lawngYF: '7cfc00', + NmoncEffon: 'fffacd', + ZXe: 'add8e6', + ZcSO: 'f08080', + Zcyan: 'e0ffff', + ZgTMnPdLw: 'fafad2', + ZWay: 'd3d3d3', + ZgYF: '90ee90', + ZgYy: 'd3d3d3', + ZpRk: 'ffb6c1', + ZsOmon: 'ffa07a', + ZsHgYF: '20b2aa', + ZskyXe: '87cefa', + ZUWay: '778899', + ZUgYy: '778899', + ZstAlXe: 'b0c4de', + ZLw: 'ffffe0', + lime: 'ff00', + limegYF: '32cd32', + lRF: 'faf0e6', + magFta: 'ff00ff', + maPon: '800000', + VaquamarRe: '66cdaa', + VXe: 'cd', + VScEd: 'ba55d3', + VpurpN: '9370db', + VsHgYF: '3cb371', + VUXe: '7b68ee', + VsprRggYF: 'fa9a', + VQe: '48d1cc', + VviTetYd: 'c71585', + midnightXe: '191970', + mRtcYam: 'f5fffa', + mistyPse: 'ffe4e1', + moccasR: 'ffe4b5', + navajowEte: 'ffdead', + navy: '80', + Tdlace: 'fdf5e6', + Tive: '808000', + TivedBb: '6b8e23', + Sange: 'ffa500', + SangeYd: 'ff4500', + ScEd: 'da70d6', + pOegTMnPd: 'eee8aa', + pOegYF: '98fb98', + pOeQe: 'afeeee', + pOeviTetYd: 'db7093', + papayawEp: 'ffefd5', + pHKpuff: 'ffdab9', + peru: 'cd853f', + pRk: 'ffc0cb', + plum: 'dda0dd', + powMrXe: 'b0e0e6', + purpN: '800080', + YbeccapurpN: '663399', + Yd: 'ff0000', + Psybrown: 'bc8f8f', + PyOXe: '4169e1', + saddNbPwn: '8b4513', + sOmon: 'fa8072', + sandybPwn: 'f4a460', + sHgYF: '2e8b57', + sHshell: 'fff5ee', + siFna: 'a0522d', + silver: 'c0c0c0', + skyXe: '87ceeb', + UXe: '6a5acd', + UWay: '708090', + UgYy: '708090', + snow: 'fffafa', + sprRggYF: 'ff7f', + stAlXe: '4682b4', + tan: 'd2b48c', + teO: '8080', + tEstN: 'd8bfd8', + tomato: 'ff6347', + Qe: '40e0d0', + viTet: 'ee82ee', + JHt: 'f5deb3', + wEte: 'ffffff', + wEtesmoke: 'f5f5f5', + Lw: 'ffff00', + LwgYF: '9acd32' +}); +names.transparent = [0, 0, 0, 0]; +function nameParse(str) { + var a = names[str]; + return a && { + r: a[0], + g: a[1], + b: a[2], + a: a.length === 4 ? a[3] : 255 + }; +} +function modHSL(v, i, ratio) { + if (v) { + var tmp = rgb2hsl(v); + tmp[i] = Math.max(0, Math.min(tmp[i] + tmp[i] * ratio, i === 0 ? 360 : 1)); + tmp = hsl2rgb(tmp); + v.r = tmp[0]; + v.g = tmp[1]; + v.b = tmp[2]; + } +} +function clone$1(v, proto) { + return v ? _extends(proto || {}, v) : v; +} +function fromObject(input) { + var v = { + r: 0, + g: 0, + b: 0, + a: 255 + }; + if (Array.isArray(input)) { + if (input.length >= 3) { + v = { + r: input[0], + g: input[1], + b: input[2], + a: 255 + }; + if (input.length > 3) { + v.a = n2b(input[3]); + } + } + } else { + v = clone$1(input, { + r: 0, + g: 0, + b: 0, + a: 1 + }); + v.a = n2b(v.a); + } + return v; +} +function functionParse(str) { + if (str.charAt(0) === 'r') { + return rgbParse(str); + } + return hueParse(str); +} +var Color = function () { + function Color(input) { + _classCallCheck(this, Color); + if (input instanceof Color) { + return input; + } + var type = _typeof(input); + var v; + if (type === 'object') { + v = fromObject(input); + } else if (type === 'string') { + v = hexParse(input) || nameParse(input) || functionParse(input); + } + this._rgb = v; + this._valid = !!v; + } + _createClass(Color, [{ + key: "rgbString", + value: function rgbString() { + return _rgbString(this._rgb); + } + }, { + key: "hexString", + value: function hexString() { + return _hexString(this._rgb); + } + }, { + key: "hslString", + value: function hslString() { + return _hslString(this._rgb); + } + }, { + key: "mix", + value: function mix(color, weight) { + var me = this; + if (color) { + var c1 = me.rgb; + var c2 = color.rgb; + var w2; + var p = weight === w2 ? 0.5 : weight; + var w = 2 * p - 1; + var a = c1.a - c2.a; + var w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2.0; + w2 = 1 - w1; + c1.r = 0xFF & w1 * c1.r + w2 * c2.r + 0.5; + c1.g = 0xFF & w1 * c1.g + w2 * c2.g + 0.5; + c1.b = 0xFF & w1 * c1.b + w2 * c2.b + 0.5; + c1.a = p * c1.a + (1 - p) * c2.a; + me.rgb = c1; + } + return me; + } + }, { + key: "clone", + value: function clone() { + return new Color(this.rgb); + } + }, { + key: "alpha", + value: function alpha(a) { + this._rgb.a = n2b(a); + return this; + } + }, { + key: "clearer", + value: function clearer(ratio) { + var rgb = this._rgb; + rgb.a *= 1 - ratio; + return this; + } + }, { + key: "greyscale", + value: function greyscale() { + var rgb = this._rgb; + var val = round(rgb.r * 0.3 + rgb.g * 0.59 + rgb.b * 0.11); + rgb.r = rgb.g = rgb.b = val; + return this; + } + }, { + key: "opaquer", + value: function opaquer(ratio) { + var rgb = this._rgb; + rgb.a *= 1 + ratio; + return this; + } + }, { + key: "negate", + value: function negate() { + var v = this._rgb; + v.r = 255 - v.r; + v.g = 255 - v.g; + v.b = 255 - v.b; + return this; + } + }, { + key: "lighten", + value: function lighten(ratio) { + modHSL(this._rgb, 2, ratio); + return this; + } + }, { + key: "darken", + value: function darken(ratio) { + modHSL(this._rgb, 2, -ratio); + return this; + } + }, { + key: "saturate", + value: function saturate(ratio) { + modHSL(this._rgb, 1, ratio); + return this; + } + }, { + key: "desaturate", + value: function desaturate(ratio) { + modHSL(this._rgb, 1, -ratio); + return this; + } + }, { + key: "rotate", + value: function rotate(deg) { + _rotate(this._rgb, deg); + return this; + } + }, { + key: "valid", + get: function get() { + return this._valid; + } + }, { + key: "rgb", + get: function get() { + var v = clone$1(this._rgb); + if (v) { + v.a = b2n(v.a); + } + return v; + }, + set: function set(obj) { + this._rgb = fromObject(obj); + } + }]); + return Color; +}(); +function index_esm(input) { + return new Color(input); +} + +var isPatternOrGradient = function isPatternOrGradient(value) { + return value instanceof CanvasGradient || value instanceof CanvasPattern; +}; +function color(value) { + return isPatternOrGradient(value) ? value : index_esm(value); +} +function getHoverColor(value) { + return isPatternOrGradient(value) ? value : index_esm(value).saturate(0.5).darken(0.1).hexString(); +} + +var helpers = _objectSpread2({}, coreHelpers, { + canvas: canvas, + curve: curve, + dom: dom, + easing: { + effects: effects + }, + options: options, + math: math, + rtl: rtl, + requestAnimFrame: function () { + if (typeof window === 'undefined') { + return function (callback) { + callback(); + }; + } + return window.requestAnimationFrame; + }(), + fontString: function fontString(pixelSize, fontStyle, fontFamily) { + return fontStyle + ' ' + pixelSize + 'px ' + fontFamily; + }, + color: color, + getHoverColor: getHoverColor +}); + +var BasePlatform = function () { + function BasePlatform() { + _classCallCheck(this, BasePlatform); + } + _createClass(BasePlatform, [{ + key: "acquireContext", + value: function acquireContext(canvas, options) {} + }, { + key: "releaseContext", + value: function releaseContext(context) { + return false; + } + }, { + key: "addEventListener", + value: function addEventListener(chart, type, listener) {} + }, { + key: "removeEventListener", + value: function removeEventListener(chart, type, listener) {} + }, { + key: "getDevicePixelRatio", + value: function getDevicePixelRatio() { + return 1; + } + }]); + return BasePlatform; +}(); + +var EXPANDO_KEY = '$chartjs'; +var EVENT_TYPES = { + touchstart: 'mousedown', + touchmove: 'mousemove', + touchend: 'mouseup', + pointerenter: 'mouseenter', + pointerdown: 'mousedown', + pointermove: 'mousemove', + pointerup: 'mouseup', + pointerleave: 'mouseout', + pointerout: 'mouseout' +}; +function readUsedSize(element, property) { + var value = helpers.dom.getStyle(element, property); + var matches = value && value.match(/^(\d+)(\.\d+)?px$/); + return matches ? +matches[1] : undefined; +} +function initCanvas(canvas, config) { + var style = canvas.style; + var renderHeight = canvas.getAttribute('height'); + var renderWidth = canvas.getAttribute('width'); + canvas[EXPANDO_KEY] = { + initial: { + height: renderHeight, + width: renderWidth, + style: { + display: style.display, + height: style.height, + width: style.width + } + } + }; + style.display = style.display || 'block'; + style.boxSizing = style.boxSizing || 'border-box'; + if (renderWidth === null || renderWidth === '') { + var displayWidth = readUsedSize(canvas, 'width'); + if (displayWidth !== undefined) { + canvas.width = displayWidth; + } + } + if (renderHeight === null || renderHeight === '') { + if (canvas.style.height === '') { + canvas.height = canvas.width / (config.options.aspectRatio || 2); + } else { + var displayHeight = readUsedSize(canvas, 'height'); + if (displayHeight !== undefined) { + canvas.height = displayHeight; + } + } + } + return canvas; +} +var supportsEventListenerOptions = function () { + var passiveSupported = false; + try { + var options = { + get passive() { + passiveSupported = true; + return false; + } + }; + window.addEventListener('test', null, options); + window.removeEventListener('test', null, options); + } catch (e) { + } + return passiveSupported; +}(); +var eventListenerOptions = supportsEventListenerOptions ? { + passive: true +} : false; +function addListener(node, type, listener) { + node.addEventListener(type, listener, eventListenerOptions); +} +function removeListener(node, type, listener) { + node.removeEventListener(type, listener, eventListenerOptions); +} +function createEvent(type, chart, x, y, nativeEvent) { + return { + type: type, + chart: chart, + "native": nativeEvent || null, + x: x !== undefined ? x : null, + y: y !== undefined ? y : null + }; +} +function fromNativeEvent(event, chart) { + var type = EVENT_TYPES[event.type] || event.type; + var pos = helpers.dom.getRelativePosition(event, chart); + return createEvent(type, chart, pos.x, pos.y, event); +} +function throttled(fn, thisArg) { + var ticking = false; + var args = []; + return function () { + for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) { + rest[_key] = arguments[_key]; + } + args = Array.prototype.slice.call(rest); + if (!ticking) { + ticking = true; + helpers.requestAnimFrame.call(window, function () { + ticking = false; + fn.apply(thisArg, args); + }); + } + }; +} +function watchForResize(element, fn) { + var resize = throttled(function (width, height) { + var w = element.clientWidth; + fn(width, height); + if (w < element.clientWidth) { + fn(); + } + }, window); + var observer = new ResizeObserver(function (entries) { + var entry = entries[0]; + resize(entry.contentRect.width, entry.contentRect.height); + }); + observer.observe(element); + return observer; +} +function watchForAttachment(element, fn) { + var observer = new MutationObserver(function (entries) { + var parent = _getParentNode(element); + entries.forEach(function (entry) { + for (var i = 0; i < entry.addedNodes.length; i++) { + var added = entry.addedNodes[i]; + if (added === element || added === parent) { + fn(entry.target); + } + } + }); + }); + observer.observe(document, { + childList: true, + subtree: true + }); + return observer; +} +function watchForDetachment(element, fn) { + var parent = _getParentNode(element); + if (!parent) { + return; + } + var observer = new MutationObserver(function (entries) { + entries.forEach(function (entry) { + for (var i = 0; i < entry.removedNodes.length; i++) { + if (entry.removedNodes[i] === element) { + fn(); + break; + } + } + }); + }); + observer.observe(parent, { + childList: true + }); + return observer; +} +function removeObserver(proxies, type) { + var observer = proxies[type]; + if (observer) { + observer.disconnect(); + proxies[type] = undefined; + } +} +function unlistenForResize(proxies) { + removeObserver(proxies, 'attach'); + removeObserver(proxies, 'detach'); + removeObserver(proxies, 'resize'); +} +function listenForResize(canvas, proxies, listener) { + var detached = function detached() { + return listenForResize(canvas, proxies, listener); + }; + unlistenForResize(proxies); + var container = _getParentNode(canvas); + if (container) { + proxies.resize = watchForResize(container, listener); + proxies.detach = watchForDetachment(canvas, detached); + } else { + proxies.attach = watchForAttachment(canvas, function () { + removeObserver(proxies, 'attach'); + var parent = _getParentNode(canvas); + proxies.resize = watchForResize(parent, listener); + proxies.detach = watchForDetachment(canvas, detached); + }); + } +} +var DomPlatform = function (_BasePlatform) { + _inherits(DomPlatform, _BasePlatform); + var _super = _createSuper(DomPlatform); + function DomPlatform() { + _classCallCheck(this, DomPlatform); + return _super.apply(this, arguments); + } + _createClass(DomPlatform, [{ + key: "acquireContext", + value: function acquireContext(canvas, config) { + var context = canvas && canvas.getContext && canvas.getContext('2d'); + if (context && context.canvas === canvas) { + initCanvas(canvas, config); + return context; + } + return null; + } + }, { + key: "releaseContext", + value: function releaseContext(context) { + var canvas = context.canvas; + if (!canvas[EXPANDO_KEY]) { + return false; + } + var initial = canvas[EXPANDO_KEY].initial; + ['height', 'width'].forEach(function (prop) { + var value = initial[prop]; + if (helpers.isNullOrUndef(value)) { + canvas.removeAttribute(prop); + } else { + canvas.setAttribute(prop, value); + } + }); + var style = initial.style || {}; + Object.keys(style).forEach(function (key) { + canvas.style[key] = style[key]; + }); + canvas.width = canvas.width; + delete canvas[EXPANDO_KEY]; + return true; + } + }, { + key: "addEventListener", + value: function addEventListener(chart, type, listener) { + this.removeEventListener(chart, type); + var canvas = chart.canvas; + var proxies = chart.$proxies || (chart.$proxies = {}); + if (type === 'resize') { + return listenForResize(canvas, proxies, listener); + } + var proxy = proxies[type] = throttled(function (event) { + if (chart.ctx !== null) { + listener(fromNativeEvent(event, chart)); + } + }, chart); + addListener(canvas, type, proxy); + } + }, { + key: "removeEventListener", + value: function removeEventListener(chart, type) { + var canvas = chart.canvas; + var proxies = chart.$proxies || (chart.$proxies = {}); + if (type === 'resize') { + return unlistenForResize(proxies); + } + var proxy = proxies[type]; + if (!proxy) { + return; + } + removeListener(canvas, type, proxy); + proxies[type] = undefined; + } + }, { + key: "getDevicePixelRatio", + value: function getDevicePixelRatio() { + return window.devicePixelRatio; + } + }]); + return DomPlatform; +}(BasePlatform); + +function drawFPS(chart, count, date, lastDate) { + var fps = 1000 / (date - lastDate) | 0; + var ctx = chart.ctx; + ctx.save(); + ctx.clearRect(0, 0, 50, 24); + ctx.fillStyle = 'black'; + ctx.textAlign = 'right'; + if (count) { + ctx.fillText(count, 50, 8); + ctx.fillText(fps + ' fps', 50, 18); + } + ctx.restore(); +} +var Animator = function () { + function Animator() { + _classCallCheck(this, Animator); + this._request = null; + this._charts = new Map(); + this._running = false; + this._lastDate = undefined; + } + _createClass(Animator, [{ + key: "_notify", + value: function _notify(chart, anims, date, type) { + var callbacks = anims.listeners[type] || []; + var numSteps = anims.duration; + callbacks.forEach(function (fn) { + return fn({ + chart: chart, + numSteps: numSteps, + currentStep: date - anims.start + }); + }); + } + }, { + key: "_refresh", + value: function _refresh() { + var me = this; + if (me._request) { + return; + } + me._running = true; + me._request = helpers.requestAnimFrame.call(window, function () { + me._update(); + me._request = null; + if (me._running) { + me._refresh(); + } + }); + } + }, { + key: "_update", + value: function _update() { + var me = this; + var date = Date.now(); + var remaining = 0; + me._charts.forEach(function (anims, chart) { + if (!anims.running || !anims.items.length) { + return; + } + var items = anims.items; + var i = items.length - 1; + var draw = false; + var item; + for (; i >= 0; --i) { + item = items[i]; + if (item._active) { + item.tick(date); + draw = true; + } else { + items[i] = items[items.length - 1]; + items.pop(); + } + } + if (draw) { + chart.draw(); + } + if (chart.options.animation.debug) { + drawFPS(chart, items.length, date, me._lastDate); + } + me._notify(chart, anims, date, 'progress'); + if (!items.length) { + anims.running = false; + me._notify(chart, anims, date, 'complete'); + } + remaining += items.length; + }); + me._lastDate = date; + if (remaining === 0) { + me._running = false; + } + } + }, { + key: "_getAnims", + value: function _getAnims(chart) { + var charts = this._charts; + var anims = charts.get(chart); + if (!anims) { + anims = { + running: false, + items: [], + listeners: { + complete: [], + progress: [] + } + }; + charts.set(chart, anims); + } + return anims; + } + }, { + key: "listen", + value: function listen(chart, event, cb) { + this._getAnims(chart).listeners[event].push(cb); + } + }, { + key: "add", + value: function add(chart, items) { + var _this$_getAnims$items; + if (!items || !items.length) { + return; + } + (_this$_getAnims$items = this._getAnims(chart).items).push.apply(_this$_getAnims$items, _toConsumableArray(items)); + } + }, { + key: "has", + value: function has(chart) { + return this._getAnims(chart).items.length > 0; + } + }, { + key: "start", + value: function start(chart) { + var anims = this._charts.get(chart); + if (!anims) { + return; + } + anims.running = true; + anims.start = Date.now(); + anims.duration = anims.items.reduce(function (acc, cur) { + return Math.max(acc, cur._duration); + }, 0); + this._refresh(); + } + }, { + key: "running", + value: function running(chart) { + if (!this._running) { + return false; + } + var anims = this._charts.get(chart); + if (!anims || !anims.running || !anims.items.length) { + return false; + } + return true; + } + }, { + key: "stop", + value: function stop(chart) { + var anims = this._charts.get(chart); + if (!anims || !anims.items.length) { + return; + } + var items = anims.items; + var i = items.length - 1; + for (; i >= 0; --i) { + items[i].cancel(); + } + anims.items = []; + this._notify(chart, anims, Date.now(), 'complete'); + } + }, { + key: "remove", + value: function remove(chart) { + return this._charts["delete"](chart); + } + }]); + return Animator; +}(); +var Animator$1 = new Animator(); + +var transparent = 'transparent'; +var interpolators = { + "boolean": function boolean(from, to, factor) { + return factor > 0.5 ? to : from; + }, + color: function color(from, to, factor) { + var c0 = helpers.color(from || transparent); + var c1 = c0.valid && helpers.color(to || transparent); + return c1 && c1.valid ? c1.mix(c0, factor).hexString() : to; + }, + number: function number(from, to, factor) { + return from + (to - from) * factor; + } +}; +var Animation = function () { + function Animation(cfg, target, prop, to) { + _classCallCheck(this, Animation); + var currentValue = target[prop]; + to = resolve([cfg.to, to, currentValue, cfg.from]); + var from = resolve([cfg.from, currentValue, to]); + this._active = true; + this._fn = cfg.fn || interpolators[cfg.type || _typeof(from)]; + this._easing = effects[cfg.easing || 'linear']; + this._start = Math.floor(Date.now() + (cfg.delay || 0)); + this._duration = Math.floor(cfg.duration); + this._loop = !!cfg.loop; + this._target = target; + this._prop = prop; + this._from = from; + this._to = to; + } + _createClass(Animation, [{ + key: "active", + value: function active() { + return this._active; + } + }, { + key: "update", + value: function update(cfg, to, date) { + var me = this; + if (me._active) { + var currentValue = me._target[me._prop]; + var elapsed = date - me._start; + var remain = me._duration - elapsed; + me._start = date; + me._duration = Math.floor(Math.max(remain, cfg.duration)); + me._to = resolve([cfg.to, to, currentValue, cfg.from]); + me._from = resolve([cfg.from, currentValue, to]); + } + } + }, { + key: "cancel", + value: function cancel() { + var me = this; + if (me._active) { + me.tick(Date.now()); + me._active = false; + } + } + }, { + key: "tick", + value: function tick(date) { + var me = this; + var elapsed = date - me._start; + var duration = me._duration; + var prop = me._prop; + var from = me._from; + var loop = me._loop; + var to = me._to; + var factor; + me._active = from !== to && (loop || elapsed < duration); + if (!me._active) { + me._target[prop] = to; + return; + } + if (elapsed < 0) { + me._target[prop] = from; + return; + } + factor = elapsed / duration % 2; + factor = loop && factor > 1 ? 2 - factor : factor; + factor = me._easing(Math.min(1, Math.max(0, factor))); + me._target[prop] = me._fn(from, to, factor); + } + }]); + return Animation; +}(); + +var numbers = ['x', 'y', 'borderWidth', 'radius', 'tension']; +var colors = ['borderColor', 'backgroundColor']; +defaults.set('animation', { + duration: 1000, + easing: 'easeOutQuart', + onProgress: noop, + onComplete: noop, + colors: { + type: 'color', + properties: colors + }, + numbers: { + type: 'number', + properties: numbers + }, + active: { + duration: 400 + }, + resize: { + duration: 0 + }, + show: { + colors: { + type: 'color', + properties: colors, + from: 'transparent' + }, + visible: { + type: 'boolean', + duration: 0 + } + }, + hide: { + colors: { + type: 'color', + properties: colors, + to: 'transparent' + }, + visible: { + type: 'boolean', + easing: 'easeInExpo' + } + } +}); +function copyOptions(target, values) { + var oldOpts = target.options; + var newOpts = values.options; + if (!oldOpts || !newOpts || newOpts.$shared) { + return; + } + if (oldOpts.$shared) { + target.options = _extends({}, oldOpts, newOpts, { + $shared: false + }); + } else { + _extends(oldOpts, newOpts); + } + delete values.options; +} +function extensibleConfig(animations) { + var result = {}; + Object.keys(animations).forEach(function (key) { + var value = animations[key]; + if (!isObject(value)) { + result[key] = value; + } + }); + return result; +} +var Animations = function () { + function Animations(chart, animations) { + _classCallCheck(this, Animations); + this._chart = chart; + this._properties = new Map(); + this.configure(animations); + } + _createClass(Animations, [{ + key: "configure", + value: function configure(animations) { + if (!isObject(animations)) { + return; + } + var animatedProps = this._properties; + var animDefaults = extensibleConfig(animations); + Object.keys(animations).forEach(function (key) { + var cfg = animations[key]; + if (!isObject(cfg)) { + return; + } + (cfg.properties || [key]).forEach(function (prop) { + if (!animatedProps.has(prop)) { + animatedProps.set(prop, _extends({}, animDefaults, cfg)); + } else if (prop === key) { + animatedProps.set(prop, _extends({}, animatedProps.get(prop), cfg)); + } + }); + }); + } + }, { + key: "_animateOptions", + value: function _animateOptions(target, values) { + var newOptions = values.options; + var animations = []; + if (!newOptions) { + return animations; + } + var options = target.options; + if (options) { + if (options.$shared) { + target.options = options = _extends({}, options, { + $shared: false, + $animations: {} + }); + } + animations = this._createAnimations(options, newOptions); + } else { + target.options = newOptions; + } + return animations; + } + }, { + key: "_createAnimations", + value: function _createAnimations(target, values) { + var animatedProps = this._properties; + var animations = []; + var running = target.$animations || (target.$animations = {}); + var props = Object.keys(values); + var date = Date.now(); + var i; + for (i = props.length - 1; i >= 0; --i) { + var prop = props[i]; + if (prop.charAt(0) === '$') { + continue; + } + if (prop === 'options') { + animations.push.apply(animations, _toConsumableArray(this._animateOptions(target, values))); + continue; + } + var value = values[prop]; + var animation = running[prop]; + var cfg = animatedProps.get(prop); + if (animation) { + if (cfg && animation.active()) { + animation.update(cfg, value, date); + continue; + } else { + animation.cancel(); + } + } + if (!cfg || !cfg.duration) { + target[prop] = value; + continue; + } + running[prop] = animation = new Animation(cfg, target, prop, value); + animations.push(animation); + } + return animations; + } + }, { + key: "update", + value: function update(target, values) { + if (this._properties.size === 0) { + copyOptions(target, values); + _extends(target, values); + return; + } + var animations = this._createAnimations(target, values); + if (animations.length) { + Animator$1.add(this._chart, animations); + return true; + } + } + }]); + return Animations; +}(); + +var resolve$1 = helpers.options.resolve; +var arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift']; +function listenArrayEvents(array, listener) { + if (array._chartjs) { + array._chartjs.listeners.push(listener); + return; + } + Object.defineProperty(array, '_chartjs', { + configurable: true, + enumerable: false, + value: { + listeners: [listener] + } + }); + arrayEvents.forEach(function (key) { + var method = '_onData' + key.charAt(0).toUpperCase() + key.slice(1); + var base = array[key]; + Object.defineProperty(array, key, { + configurable: true, + enumerable: false, + value: function value() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + var res = base.apply(this, args); + array._chartjs.listeners.forEach(function (object) { + if (typeof object[method] === 'function') { + object[method].apply(object, args); + } + }); + return res; + } + }); + }); +} +function scaleClip(scale, allowedOverflow) { + var opts = scale && scale.options || {}; + var reverse = opts.reverse; + var min = opts.min === undefined ? allowedOverflow : 0; + var max = opts.max === undefined ? allowedOverflow : 0; + return { + start: reverse ? max : min, + end: reverse ? min : max + }; +} +function defaultClip(xScale, yScale, allowedOverflow) { + if (allowedOverflow === false) { + return false; + } + var x = scaleClip(xScale, allowedOverflow); + var y = scaleClip(yScale, allowedOverflow); + return { + top: y.end, + right: x.end, + bottom: y.start, + left: x.start + }; +} +function toClip(value) { + var t, r, b, l; + if (helpers.isObject(value)) { + t = value.top; + r = value.right; + b = value.bottom; + l = value.left; + } else { + t = r = b = l = value; + } + return { + top: t, + right: r, + bottom: b, + left: l + }; +} +function unlistenArrayEvents(array, listener) { + var stub = array._chartjs; + if (!stub) { + return; + } + var listeners = stub.listeners; + var index = listeners.indexOf(listener); + if (index !== -1) { + listeners.splice(index, 1); + } + if (listeners.length > 0) { + return; + } + arrayEvents.forEach(function (key) { + delete array[key]; + }); + delete array._chartjs; +} +function getSortedDatasetIndices(chart, filterVisible) { + var keys = []; + var metasets = chart._getSortedDatasetMetas(filterVisible); + var i, ilen; + for (i = 0, ilen = metasets.length; i < ilen; ++i) { + keys.push(metasets[i].index); + } + return keys; +} +function _applyStack(stack, value, dsIndex, allOther) { + var keys = stack.keys; + var i, ilen, datasetIndex, otherValue; + for (i = 0, ilen = keys.length; i < ilen; ++i) { + datasetIndex = +keys[i]; + if (datasetIndex === dsIndex) { + if (allOther) { + continue; + } + break; + } + otherValue = stack.values[datasetIndex]; + if (!isNaN(otherValue) && (value === 0 || helpers.math.sign(value) === helpers.math.sign(otherValue))) { + value += otherValue; + } + } + return value; +} +function convertObjectDataToArray(data) { + var keys = Object.keys(data); + var adata = new Array(keys.length); + var i, ilen, key; + for (i = 0, ilen = keys.length; i < ilen; ++i) { + key = keys[i]; + adata[i] = { + x: key, + y: data[key] + }; + } + return adata; +} +function isStacked(scale, meta) { + var stacked = scale && scale.options.stacked; + return stacked || stacked === undefined && meta.stack !== undefined; +} +function getStackKey(indexScale, valueScale, meta) { + return indexScale.id + '.' + valueScale.id + '.' + meta.stack + '.' + meta.type; +} +function getUserBounds(scale) { + var _scale$getUserBounds = scale.getUserBounds(), + min = _scale$getUserBounds.min, + max = _scale$getUserBounds.max, + minDefined = _scale$getUserBounds.minDefined, + maxDefined = _scale$getUserBounds.maxDefined; + return { + min: minDefined ? min : Number.NEGATIVE_INFINITY, + max: maxDefined ? max : Number.POSITIVE_INFINITY + }; +} +function getOrCreateStack(stacks, stackKey, indexValue) { + var subStack = stacks[stackKey] || (stacks[stackKey] = {}); + return subStack[indexValue] || (subStack[indexValue] = {}); +} +function updateStacks(controller, parsed) { + var chart = controller.chart, + meta = controller._cachedMeta; + var stacks = chart._stacks || (chart._stacks = {}); + var iScale = meta.iScale, + vScale = meta.vScale, + datasetIndex = meta.index; + var iAxis = iScale.axis; + var vAxis = vScale.axis; + var key = getStackKey(iScale, vScale, meta); + var ilen = parsed.length; + var stack; + for (var i = 0; i < ilen; ++i) { + var item = parsed[i]; + var index = item[iAxis], + value = item[vAxis]; + var itemStacks = item._stacks || (item._stacks = {}); + stack = itemStacks[vAxis] = getOrCreateStack(stacks, key, index); + stack[datasetIndex] = value; + } +} +function getFirstScaleId(chart, axis) { + var scales = chart.scales; + return Object.keys(scales).filter(function (key) { + return scales[key].axis === axis; + }).shift(); +} +var DatasetController = function () { + function DatasetController(chart, datasetIndex) { + _classCallCheck(this, DatasetController); + this.chart = chart; + this._ctx = chart.ctx; + this.index = datasetIndex; + this._cachedAnimations = {}; + this._cachedDataOpts = {}; + this._cachedMeta = this.getMeta(); + this._type = this._cachedMeta.type; + this._config = undefined; + this._parsing = false; + this._data = undefined; + this._dataCopy = undefined; + this._objectData = undefined; + this._labels = undefined; + this._scaleStacked = {}; + this.initialize(); + } + _createClass(DatasetController, [{ + key: "initialize", + value: function initialize() { + var me = this; + var meta = me._cachedMeta; + me.configure(); + me.linkScales(); + meta._stacked = isStacked(meta.vScale, meta); + me.addElements(); + } + }, { + key: "updateIndex", + value: function updateIndex(datasetIndex) { + this.index = datasetIndex; + } + }, { + key: "linkScales", + value: function linkScales() { + var me = this; + var chart = me.chart; + var meta = me._cachedMeta; + var dataset = me.getDataset(); + var xid = meta.xAxisID = dataset.xAxisID || getFirstScaleId(chart, 'x'); + var yid = meta.yAxisID = dataset.yAxisID || getFirstScaleId(chart, 'y'); + var rid = meta.rAxisID = dataset.rAxisID || getFirstScaleId(chart, 'r'); + meta.xScale = me.getScaleForId(xid); + meta.yScale = me.getScaleForId(yid); + meta.rScale = me.getScaleForId(rid); + meta.iScale = me._getIndexScale(); + meta.vScale = me._getValueScale(); + } + }, { + key: "getDataset", + value: function getDataset() { + return this.chart.data.datasets[this.index]; + } + }, { + key: "getMeta", + value: function getMeta() { + return this.chart.getDatasetMeta(this.index); + } + }, { + key: "getScaleForId", + value: function getScaleForId(scaleID) { + return this.chart.scales[scaleID]; + } + }, { + key: "getValueScaleId", + value: function getValueScaleId() { + return this._cachedMeta.yAxisID; + } + }, { + key: "getIndexScaleId", + value: function getIndexScaleId() { + return this._cachedMeta.xAxisID; + } + }, { + key: "_getValueScale", + value: function _getValueScale() { + return this.getScaleForId(this.getValueScaleId()); + } + }, { + key: "_getIndexScale", + value: function _getIndexScale() { + return this.getScaleForId(this.getIndexScaleId()); + } + }, { + key: "_getOtherScale", + value: function _getOtherScale(scale) { + var meta = this._cachedMeta; + return scale === meta.iScale ? meta.vScale : meta.iScale; + } + }, { + key: "reset", + value: function reset() { + this._update('reset'); + } + }, { + key: "_destroy", + value: function _destroy() { + if (this._data) { + unlistenArrayEvents(this._data, this); + } + } + }, { + key: "_dataCheck", + value: function _dataCheck() { + var me = this; + var dataset = me.getDataset(); + var data = dataset.data || (dataset.data = []); + if (helpers.isObject(data)) { + if (me._objectData === data) { + return false; + } + me._data = convertObjectDataToArray(data); + me._objectData = data; + } else { + if (me._data === data && helpers.arrayEquals(data, me._dataCopy)) { + return false; + } + if (me._data) { + unlistenArrayEvents(me._data, me); + } + me._dataCopy = data.slice(0); + if (data && Object.isExtensible(data)) { + listenArrayEvents(data, me); + } + me._data = data; + } + return true; + } + }, { + key: "_labelCheck", + value: function _labelCheck() { + var me = this; + var iScale = me._cachedMeta.iScale; + var labels = iScale ? iScale.getLabels() : me.chart.data.labels; + if (me._labels === labels) { + return false; + } + me._labels = labels; + return true; + } + }, { + key: "addElements", + value: function addElements() { + var me = this; + var meta = me._cachedMeta; + me._dataCheck(); + var data = me._data; + var metaData = meta.data = new Array(data.length); + for (var i = 0, ilen = data.length; i < ilen; ++i) { + metaData[i] = new me.dataElementType(); + } + if (me.datasetElementType) { + meta.dataset = new me.datasetElementType(); + } + } + }, { + key: "buildOrUpdateElements", + value: function buildOrUpdateElements() { + var me = this; + var dataChanged = me._dataCheck(); + var labelsChanged = me._labelCheck(); + var scaleChanged = me._scaleCheck(); + var meta = me._cachedMeta; + var dataset = me.getDataset(); + var stackChanged = false; + meta._stacked = isStacked(meta.vScale, meta); + if (meta.stack !== dataset.stack) { + stackChanged = true; + meta._parsed.forEach(function (parsed) { + delete parsed._stacks[meta.vScale.id][meta.index]; + }); + meta.stack = dataset.stack; + } + me._resyncElements(dataChanged || labelsChanged || scaleChanged || stackChanged); + if (stackChanged) { + updateStacks(me, meta._parsed); + } + } + }, { + key: "configure", + value: function configure() { + var me = this; + me._config = helpers.merge({}, [me.chart.options[me._type].datasets, me.getDataset()], { + merger: function merger(key, target, source) { + if (key !== 'data') { + helpers._merger(key, target, source); + } + } + }); + me._parsing = resolve$1([me._config.parsing, me.chart.options.parsing, true]); + } + }, { + key: "parse", + value: function parse(start, count) { + var me = this; + var meta = me._cachedMeta, + data = me._data; + var iScale = meta.iScale, + vScale = meta.vScale, + _stacked = meta._stacked; + var iAxis = iScale.axis; + var sorted = true; + var i, parsed, cur, prev; + if (start > 0) { + sorted = meta._sorted; + prev = meta._parsed[start - 1]; + } + if (me._parsing === false) { + meta._parsed = data; + meta._sorted = true; + } else { + if (helpers.isArray(data[start])) { + parsed = me.parseArrayData(meta, data, start, count); + } else if (helpers.isObject(data[start])) { + parsed = me.parseObjectData(meta, data, start, count); + } else { + parsed = me.parsePrimitiveData(meta, data, start, count); + } + for (i = 0; i < count; ++i) { + meta._parsed[i + start] = cur = parsed[i]; + if (sorted) { + if (prev && cur[iAxis] < prev[iAxis]) { + sorted = false; + } + prev = cur; + } + } + meta._sorted = sorted; + } + if (_stacked) { + updateStacks(me, parsed); + } + iScale.invalidateCaches(); + vScale.invalidateCaches(); + } + }, { + key: "parsePrimitiveData", + value: function parsePrimitiveData(meta, data, start, count) { + var iScale = meta.iScale, + vScale = meta.vScale; + var iAxis = iScale.axis; + var vAxis = vScale.axis; + var labels = iScale.getLabels(); + var singleScale = iScale === vScale; + var parsed = new Array(count); + var i, ilen, index; + for (i = 0, ilen = count; i < ilen; ++i) { + var _parsed$i; + index = i + start; + parsed[i] = (_parsed$i = {}, _defineProperty(_parsed$i, iAxis, singleScale || iScale.parse(labels[index], index)), _defineProperty(_parsed$i, vAxis, vScale.parse(data[index], index)), _parsed$i); + } + return parsed; + } + }, { + key: "parseArrayData", + value: function parseArrayData(meta, data, start, count) { + var xScale = meta.xScale, + yScale = meta.yScale; + var parsed = new Array(count); + var i, ilen, index, item; + for (i = 0, ilen = count; i < ilen; ++i) { + index = i + start; + item = data[index]; + parsed[i] = { + x: xScale.parse(item[0], index), + y: yScale.parse(item[1], index) + }; + } + return parsed; + } + }, { + key: "parseObjectData", + value: function parseObjectData(meta, data, start, count) { + var xScale = meta.xScale, + yScale = meta.yScale; + var parsed = new Array(count); + var i, ilen, index, item; + for (i = 0, ilen = count; i < ilen; ++i) { + index = i + start; + item = data[index]; + parsed[i] = { + x: xScale.parseObject(item, 'x', index), + y: yScale.parseObject(item, 'y', index) + }; + } + return parsed; + } + }, { + key: "getParsed", + value: function getParsed(index) { + return this._cachedMeta._parsed[index]; + } + }, { + key: "applyStack", + value: function applyStack(scale, parsed) { + var chart = this.chart; + var meta = this._cachedMeta; + var value = parsed[scale.axis]; + var stack = { + keys: getSortedDatasetIndices(chart, true), + values: parsed._stacks[scale.axis] + }; + return _applyStack(stack, value, meta.index); + } + }, { + key: "getMinMax", + value: function getMinMax(scale, canStack) { + var meta = this._cachedMeta; + var _parsed = meta._parsed; + var sorted = meta._sorted && scale === meta.iScale; + var ilen = _parsed.length; + var otherScale = this._getOtherScale(scale); + var stack = canStack && meta._stacked && { + keys: getSortedDatasetIndices(this.chart, true), + values: null + }; + var min = Number.POSITIVE_INFINITY; + var max = Number.NEGATIVE_INFINITY; + var _getUserBounds = getUserBounds(otherScale), + otherMin = _getUserBounds.min, + otherMax = _getUserBounds.max; + var i, value, parsed, otherValue; + function _compute() { + if (stack) { + stack.values = parsed._stacks[scale.axis]; + min = Math.min(min, value); + max = Math.max(max, value); + value = _applyStack(stack, value, meta.index, true); + } + min = Math.min(min, value); + max = Math.max(max, value); + } + function _skip() { + parsed = _parsed[i]; + value = parsed[scale.axis]; + otherValue = parsed[otherScale.axis]; + return isNaN(value) || otherMin > otherValue || otherMax < otherValue; + } + for (i = 0; i < ilen; ++i) { + if (_skip()) { + continue; + } + _compute(); + if (sorted) { + break; + } + } + if (sorted) { + for (i = ilen - 1; i >= 0; --i) { + if (_skip()) { + continue; + } + _compute(); + break; + } + } + return { + min: min, + max: max + }; + } + }, { + key: "getAllParsedValues", + value: function getAllParsedValues(scale) { + var parsed = this._cachedMeta._parsed; + var values = []; + var i, ilen, value; + for (i = 0, ilen = parsed.length; i < ilen; ++i) { + value = parsed[i][scale.axis]; + if (!isNaN(value)) { + values.push(value); + } + } + return values; + } + }, { + key: "_cacheScaleStackStatus", + value: function _cacheScaleStackStatus() { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale; + var vScale = meta.vScale; + var cache = me._scaleStacked = {}; + if (iScale && vScale) { + cache[iScale.id] = iScale.options.stacked; + cache[vScale.id] = vScale.options.stacked; + } + } + }, { + key: "_scaleCheck", + value: function _scaleCheck() { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale; + var vScale = meta.vScale; + var cache = me._scaleStacked; + return !cache || !iScale || !vScale || cache[iScale.id] !== iScale.options.stacked || cache[vScale.id] !== vScale.options.stacked; + } + }, { + key: "getMaxOverflow", + value: function getMaxOverflow() { + return false; + } + }, { + key: "getLabelAndValue", + value: function getLabelAndValue(index) { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale; + var vScale = meta.vScale; + var parsed = me.getParsed(index); + return { + label: iScale ? '' + iScale.getLabelForValue(parsed[iScale.axis]) : '', + value: vScale ? '' + vScale.getLabelForValue(parsed[vScale.axis]) : '' + }; + } + }, { + key: "_update", + value: function _update(mode) { + var me = this; + var meta = me._cachedMeta; + me.configure(); + me._cachedAnimations = {}; + me._cachedDataOpts = {}; + me.update(mode); + meta._clip = toClip(helpers.valueOrDefault(me._config.clip, defaultClip(meta.xScale, meta.yScale, me.getMaxOverflow()))); + me._cacheScaleStackStatus(); + } + }, { + key: "update", + value: function update(mode) {} + }, { + key: "draw", + value: function draw() { + var ctx = this._ctx; + var meta = this._cachedMeta; + var elements = meta.data || []; + var ilen = elements.length; + var i = 0; + if (meta.dataset) { + meta.dataset.draw(ctx); + } + for (; i < ilen; ++i) { + elements[i].draw(ctx); + } + } + }, { + key: "_addAutomaticHoverColors", + value: function _addAutomaticHoverColors(index, options) { + var me = this; + var getHoverColor = helpers.getHoverColor; + var normalOptions = me.getStyle(index); + var missingColors = Object.keys(normalOptions).filter(function (key) { + return key.indexOf('Color') !== -1 && !(key in options); + }); + var i = missingColors.length - 1; + var color; + for (; i >= 0; i--) { + color = missingColors[i]; + options[color] = getHoverColor(normalOptions[color]); + } + } + }, { + key: "getStyle", + value: function getStyle(index, active) { + var me = this; + var meta = me._cachedMeta; + var dataset = meta.dataset; + if (!me._config) { + me.configure(); + } + var options = dataset && index === undefined ? me.resolveDatasetElementOptions(active) : me.resolveDataElementOptions(index || 0, active && 'active'); + if (active) { + me._addAutomaticHoverColors(index, options); + } + return options; + } + }, { + key: "_getContext", + value: function _getContext(index, active) { + return { + chart: this.chart, + dataIndex: index, + dataset: this.getDataset(), + datasetIndex: this.index, + active: active + }; + } + }, { + key: "resolveDatasetElementOptions", + value: function resolveDatasetElementOptions(active) { + var me = this; + var chart = me.chart; + var datasetOpts = me._config; + var options = chart.options.elements[me.datasetElementType._type] || {}; + var elementOptions = me.datasetElementOptions; + var values = {}; + var context = me._getContext(undefined, active); + var i, ilen, key, readKey, value; + for (i = 0, ilen = elementOptions.length; i < ilen; ++i) { + key = elementOptions[i]; + readKey = active ? 'hover' + key.charAt(0).toUpperCase() + key.slice(1) : key; + value = resolve$1([datasetOpts[readKey], options[readKey]], context); + if (value !== undefined) { + values[key] = value; + } + } + return values; + } + }, { + key: "resolveDataElementOptions", + value: function resolveDataElementOptions(index, mode) { + var me = this; + var active = mode === 'active'; + var cached = me._cachedDataOpts; + if (cached[mode]) { + return cached[mode]; + } + var chart = me.chart; + var datasetOpts = me._config; + var options = chart.options.elements[me.dataElementType._type] || {}; + var elementOptions = me.dataElementOptions; + var values = {}; + var context = me._getContext(index, active); + var info = { + cacheable: !active + }; + var keys, i, ilen, key, value, readKey; + if (helpers.isArray(elementOptions)) { + for (i = 0, ilen = elementOptions.length; i < ilen; ++i) { + key = elementOptions[i]; + readKey = active ? 'hover' + key.charAt(0).toUpperCase() + key.slice(1) : key; + value = resolve$1([datasetOpts[readKey], options[readKey]], context, index, info); + if (value !== undefined) { + values[key] = value; + } + } + } else { + keys = Object.keys(elementOptions); + for (i = 0, ilen = keys.length; i < ilen; ++i) { + key = keys[i]; + readKey = active ? 'hover' + key.charAt(0).toUpperCase() + key.slice(1) : key; + value = resolve$1([datasetOpts[elementOptions[readKey]], datasetOpts[readKey], options[readKey]], context, index, info); + if (value !== undefined) { + values[key] = value; + } + } + } + if (info.cacheable) { + values.$shared = true; + cached[mode] = values; + } + return values; + } + }, { + key: "_resolveAnimations", + value: function _resolveAnimations(index, mode, active) { + var me = this; + var chart = me.chart; + var cached = me._cachedAnimations; + mode = mode || 'default'; + if (cached[mode]) { + return cached[mode]; + } + var info = { + cacheable: true + }; + var context = me._getContext(index, active); + var datasetAnim = resolve$1([me._config.animation], context, index, info); + var chartAnim = resolve$1([chart.options.animation], context, index, info); + var config = helpers.mergeIf({}, [datasetAnim, chartAnim]); + if (config[mode]) { + config = _extends({}, config, config[mode]); + } + var animations = new Animations(chart, config); + if (info.cacheable) { + cached[mode] = animations && Object.freeze(animations); + } + return animations; + } + }, { + key: "getSharedOptions", + value: function getSharedOptions(mode, el, options) { + if (!mode) { + this._sharedOptions = options && options.$shared; + } + if (mode !== 'reset' && options && options.$shared && el && el.options && el.options.$shared) { + return { + target: el.options, + options: options + }; + } + } + }, { + key: "includeOptions", + value: function includeOptions(mode, sharedOptions) { + if (mode === 'hide' || mode === 'show') { + return true; + } + return mode !== 'resize' && !sharedOptions; + } + }, { + key: "updateElement", + value: function updateElement(element, index, properties, mode) { + if (mode === 'reset' || mode === 'none') { + _extends(element, properties); + } else { + this._resolveAnimations(index, mode).update(element, properties); + } + } + }, { + key: "updateSharedOptions", + value: function updateSharedOptions(sharedOptions, mode) { + if (sharedOptions) { + this._resolveAnimations(undefined, mode).update(sharedOptions.target, sharedOptions.options); + } + } + }, { + key: "_setStyle", + value: function _setStyle(element, index, mode, active) { + element.active = active; + this._resolveAnimations(index, mode, active).update(element, { + options: this.getStyle(index, active) + }); + } + }, { + key: "removeHoverStyle", + value: function removeHoverStyle(element, datasetIndex, index) { + this._setStyle(element, index, 'active', false); + } + }, { + key: "setHoverStyle", + value: function setHoverStyle(element, datasetIndex, index) { + this._setStyle(element, index, 'active', true); + } + }, { + key: "_removeDatasetHoverStyle", + value: function _removeDatasetHoverStyle() { + var element = this._cachedMeta.dataset; + if (element) { + this._setStyle(element, undefined, 'active', false); + } + } + }, { + key: "_setDatasetHoverStyle", + value: function _setDatasetHoverStyle() { + var element = this._cachedMeta.dataset; + if (element) { + this._setStyle(element, undefined, 'active', true); + } + } + }, { + key: "_resyncElements", + value: function _resyncElements(changed) { + var me = this; + var meta = me._cachedMeta; + var numMeta = meta.data.length; + var numData = me._data.length; + if (numData > numMeta) { + me._insertElements(numMeta, numData - numMeta); + if (changed && 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); + } else if (changed) { + me.parse(0, numData); + } + } + }, { + key: "_insertElements", + value: function _insertElements(start, count) { + var me = this; + var elements = new Array(count); + var meta = me._cachedMeta; + var data = meta.data; + var i; + for (i = 0; i < count; ++i) { + elements[i] = new me.dataElementType(); + } + data.splice.apply(data, [start, 0].concat(elements)); + if (me._parsing) { + var _meta$_parsed; + (_meta$_parsed = meta._parsed).splice.apply(_meta$_parsed, [start, 0].concat(_toConsumableArray(new Array(count)))); + } + me.parse(start, count); + me.updateElements(elements, start, 'reset'); + } + }, { + key: "updateElements", + value: function updateElements(element, start, mode) {} + }, { + key: "_removeElements", + value: function _removeElements(start, count) { + var me = this; + if (me._parsing) { + me._cachedMeta._parsed.splice(start, count); + } + me._cachedMeta.data.splice(start, count); + } + }, { + key: "_onDataPush", + value: function _onDataPush() { + var count = arguments.length; + this._insertElements(this.getDataset().data.length - count, count); + } + }, { + key: "_onDataPop", + value: function _onDataPop() { + this._removeElements(this._cachedMeta.data.length - 1, 1); + } + }, { + key: "_onDataShift", + value: function _onDataShift() { + this._removeElements(0, 1); + } + }, { + key: "_onDataSplice", + value: function _onDataSplice(start, count) { + this._removeElements(start, count); + this._insertElements(start, arguments.length - 2); + } + }, { + key: "_onDataUnshift", + value: function _onDataUnshift() { + this._insertElements(0, arguments.length); + } + }]); + return DatasetController; +}(); +_defineProperty(DatasetController, "extend", helpers.inherits); +DatasetController.prototype.datasetElementType = null; +DatasetController.prototype.dataElementType = null; +DatasetController.prototype.datasetElementOptions = ['backgroundColor', 'borderCapStyle', 'borderColor', 'borderDash', 'borderDashOffset', 'borderJoinStyle', 'borderWidth']; +DatasetController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderWidth', 'pointStyle']; + +var Element$1 = function () { + function Element() { + _classCallCheck(this, Element); + this.x = undefined; + this.y = undefined; + this.active = false; + this.options = undefined; + this.$animations = undefined; + } + _createClass(Element, [{ + key: "tooltipPosition", + value: function tooltipPosition(useFinalPosition) { + var _this$getProps = this.getProps(['x', 'y'], useFinalPosition), + x = _this$getProps.x, + y = _this$getProps.y; + return { + x: x, + y: y + }; + } + }, { + key: "hasValue", + value: function hasValue() { + return isNumber(this.x) && isNumber(this.y); + } + }, { + key: "getProps", + value: function getProps(props, _final) { + var me = this; + var anims = this.$animations; + if (!_final || !anims) { + return me; + } + var ret = {}; + props.forEach(function (prop) { + ret[prop] = anims[prop] && anims[prop].active ? anims[prop]._to : me[prop]; + }); + return ret; + } + }]); + return Element; +}(); +_defineProperty(Element$1, "extend", inherits); + +var TAU$1 = Math.PI * 2; +defaults.set('elements', { + arc: { + backgroundColor: defaults.color, + borderAlign: 'center', + borderColor: '#fff', + borderWidth: 2 + } +}); +function clipArc(ctx, arc) { + var startAngle = arc.startAngle, + endAngle = arc.endAngle, + pixelMargin = arc.pixelMargin, + x = arc.x, + y = arc.y; + var angleMargin = pixelMargin / arc.outerRadius; + ctx.beginPath(); + ctx.arc(x, y, arc.outerRadius, startAngle - angleMargin, endAngle + angleMargin); + if (arc.innerRadius > pixelMargin) { + angleMargin = pixelMargin / arc.innerRadius; + ctx.arc(x, y, arc.innerRadius - pixelMargin, endAngle + angleMargin, startAngle - angleMargin, true); + } else { + ctx.arc(x, y, pixelMargin, endAngle + Math.PI / 2, startAngle - Math.PI / 2); + } + ctx.closePath(); + ctx.clip(); +} +function drawFullCircleBorders(ctx, vm, arc, inner) { + var endAngle = arc.endAngle; + var i; + if (inner) { + arc.endAngle = arc.startAngle + TAU$1; + clipArc(ctx, arc); + arc.endAngle = endAngle; + if (arc.endAngle === arc.startAngle && arc.fullCircles) { + arc.endAngle += TAU$1; + arc.fullCircles--; + } + } + ctx.beginPath(); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.startAngle + TAU$1, arc.startAngle, true); + for (i = 0; i < arc.fullCircles; ++i) { + ctx.stroke(); + } + ctx.beginPath(); + ctx.arc(arc.x, arc.y, vm.outerRadius, arc.startAngle, arc.startAngle + TAU$1); + for (i = 0; i < arc.fullCircles; ++i) { + ctx.stroke(); + } +} +function drawBorder(ctx, vm, arc) { + var options = vm.options; + var inner = options.borderAlign === 'inner'; + if (inner) { + ctx.lineWidth = options.borderWidth * 2; + ctx.lineJoin = 'round'; + } else { + ctx.lineWidth = options.borderWidth; + ctx.lineJoin = 'bevel'; + } + if (arc.fullCircles) { + drawFullCircleBorders(ctx, vm, arc, inner); + } + if (inner) { + clipArc(ctx, arc); + } + ctx.beginPath(); + ctx.arc(arc.x, arc.y, vm.outerRadius, arc.startAngle, arc.endAngle); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true); + ctx.closePath(); + ctx.stroke(); +} +var Arc = function (_Element) { + _inherits(Arc, _Element); + var _super = _createSuper(Arc); + function Arc(cfg) { + var _this; + _classCallCheck(this, Arc); + _this = _super.call(this); + _this.options = undefined; + _this.circumference = undefined; + _this.startAngle = undefined; + _this.endAngle = undefined; + _this.innerRadius = undefined; + _this.outerRadius = undefined; + if (cfg) { + _extends(_assertThisInitialized(_this), cfg); + } + return _this; + } + _createClass(Arc, [{ + key: "inRange", + value: function inRange(chartX, chartY, useFinalPosition) { + var point = this.getProps(['x', 'y'], useFinalPosition); + var _getAngleFromPoint = getAngleFromPoint(point, { + x: chartX, + y: chartY + }), + angle = _getAngleFromPoint.angle, + distance = _getAngleFromPoint.distance; + var _this$getProps = this.getProps(['startAngle', 'endAngle', 'innerRadius', 'outerRadius', 'circumference'], useFinalPosition), + startAngle = _this$getProps.startAngle, + endAngle = _this$getProps.endAngle, + innerRadius = _this$getProps.innerRadius, + outerRadius = _this$getProps.outerRadius, + circumference = _this$getProps.circumference; + var betweenAngles = circumference >= TAU$1 || _angleBetween(angle, startAngle, endAngle); + var withinRadius = distance >= innerRadius && distance <= outerRadius; + return betweenAngles && withinRadius; + } + }, { + key: "getCenterPoint", + value: function getCenterPoint(useFinalPosition) { + var _this$getProps2 = this.getProps(['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius'], useFinalPosition), + x = _this$getProps2.x, + y = _this$getProps2.y, + startAngle = _this$getProps2.startAngle, + endAngle = _this$getProps2.endAngle, + innerRadius = _this$getProps2.innerRadius, + outerRadius = _this$getProps2.outerRadius; + var halfAngle = (startAngle + endAngle) / 2; + var halfRadius = (innerRadius + outerRadius) / 2; + return { + x: x + Math.cos(halfAngle) * halfRadius, + y: y + Math.sin(halfAngle) * halfRadius + }; + } + }, { + key: "tooltipPosition", + value: function tooltipPosition(useFinalPosition) { + return this.getCenterPoint(useFinalPosition); + } + }, { + key: "draw", + value: function draw(ctx) { + var me = this; + var options = me.options; + var pixelMargin = options.borderAlign === 'inner' ? 0.33 : 0; + var arc = { + x: me.x, + y: me.y, + innerRadius: me.innerRadius, + outerRadius: Math.max(me.outerRadius - pixelMargin, 0), + pixelMargin: pixelMargin, + startAngle: me.startAngle, + endAngle: me.endAngle, + fullCircles: Math.floor(me.circumference / TAU$1) + }; + var i; + ctx.save(); + ctx.fillStyle = options.backgroundColor; + ctx.strokeStyle = options.borderColor; + if (arc.fullCircles) { + arc.endAngle = arc.startAngle + TAU$1; + ctx.beginPath(); + ctx.arc(arc.x, arc.y, arc.outerRadius, arc.startAngle, arc.endAngle); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true); + ctx.closePath(); + for (i = 0; i < arc.fullCircles; ++i) { + ctx.fill(); + } + arc.endAngle = arc.startAngle + me.circumference % TAU$1; + } + ctx.beginPath(); + ctx.arc(arc.x, arc.y, arc.outerRadius, arc.startAngle, arc.endAngle); + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true); + ctx.closePath(); + ctx.fill(); + if (options.borderWidth) { + drawBorder(ctx, me, arc); + } + ctx.restore(); + } + }]); + return Arc; +}(Element$1); +_defineProperty(Arc, "_type", 'arc'); + +function _pointInLine(p1, p2, t, mode) { + return { + x: p1.x + t * (p2.x - p1.x), + y: p1.y + t * (p2.y - p1.y) + }; +} +function _steppedInterpolation(p1, p2, t, mode) { + return { + x: p1.x + t * (p2.x - p1.x), + y: mode === 'middle' ? t < 0.5 ? p1.y : p2.y : mode === 'after' ? t < 1 ? p1.y : p2.y : t > 0 ? p2.y : p1.y + }; +} +function _bezierInterpolation(p1, p2, t, mode) { + var cp1 = { + x: p1.controlPointNextX, + y: p1.controlPointNextY + }; + var cp2 = { + x: p2.controlPointPreviousX, + y: p2.controlPointPreviousY + }; + var a = _pointInLine(p1, cp1, t); + var b = _pointInLine(cp1, cp2, t); + var c = _pointInLine(cp2, p2, t); + var d = _pointInLine(a, b, t); + var e = _pointInLine(b, c, t); + return _pointInLine(d, e, t); +} + +function propertyFn(property) { + if (property === 'angle') { + return { + between: _angleBetween, + compare: _angleDiff, + normalize: _normalizeAngle + }; + } + return { + between: function between(n, s, e) { + return n >= s && n <= e; + }, + compare: function compare(a, b) { + return a - b; + }, + normalize: function normalize(x) { + return x; + } + }; +} +function makeSubSegment(start, end, loop, count) { + return { + start: start % count, + end: end % count, + loop: loop && (end - start + 1) % count === 0 + }; +} +function getSegment(segment, points, bounds) { + var property = bounds.property, + startBound = bounds.start, + endBound = bounds.end; + var _propertyFn = propertyFn(property), + between = _propertyFn.between, + normalize = _propertyFn.normalize; + var count = points.length; + var start = segment.start, + end = segment.end, + loop = segment.loop; + var i, ilen; + if (loop) { + start += count; + end += count; + for (i = 0, ilen = count; i < ilen; ++i) { + if (!between(normalize(points[start % count][property]), startBound, endBound)) { + break; + } + start--; + end--; + } + start %= count; + end %= count; + } + if (end < start) { + end += count; + } + return { + start: start, + end: end, + loop: loop + }; +} +function _boundSegment(segment, points, bounds) { + if (!bounds) { + return [segment]; + } + var property = bounds.property, + startBound = bounds.start, + endBound = bounds.end; + var count = points.length; + var _propertyFn2 = propertyFn(property), + compare = _propertyFn2.compare, + between = _propertyFn2.between, + normalize = _propertyFn2.normalize; + var _getSegment = getSegment(segment, points, bounds), + start = _getSegment.start, + end = _getSegment.end, + loop = _getSegment.loop; + var result = []; + var inside = false; + var subStart = null; + var i, value, point, prev; + for (i = start; i <= end; ++i) { + point = points[i % count]; + if (point.skip) { + continue; + } + value = normalize(point[property]); + inside = between(value, startBound, endBound); + if (subStart === null && inside) { + subStart = i > start && compare(value, startBound) > 0 ? prev : i; + } + if (subStart !== null && (!inside || compare(value, endBound) === 0)) { + result.push(makeSubSegment(subStart, i, loop, count)); + subStart = null; + } + prev = i; + } + if (subStart !== null) { + result.push(makeSubSegment(subStart, end, loop, count)); + } + return result; +} +function _boundSegments(line, bounds) { + var result = []; + var segments = line.segments; + for (var i = 0; i < segments.length; i++) { + var sub = _boundSegment(segments[i], line.points, bounds); + if (sub.length) { + result.push.apply(result, _toConsumableArray(sub)); + } + } + return result; +} +function findStartAndEnd(points, count, loop, spanGaps) { + var start = 0; + var end = count - 1; + if (loop && !spanGaps) { + while (start < count && !points[start].skip) { + start++; + } + } + while (start < count && points[start].skip) { + start++; + } + start %= count; + if (loop) { + end += start; + } + while (end > start && points[end % count].skip) { + end--; + } + end %= count; + return { + start: start, + end: end + }; +} +function solidSegments(points, start, max, loop) { + var count = points.length; + var result = []; + var last = start; + var prev = points[start]; + var end; + for (end = start + 1; end <= max; ++end) { + var cur = points[end % count]; + if (cur.skip || cur.stop) { + if (!prev.skip) { + loop = false; + result.push({ + start: start % count, + end: (end - 1) % count, + loop: loop + }); + start = last = cur.stop ? end : null; + } + } else { + last = end; + if (prev.skip) { + start = end; + } + } + prev = cur; + } + if (last !== null) { + result.push({ + start: start % count, + end: last % count, + loop: loop + }); + } + return result; +} +function _computeSegments(line) { + var points = line.points; + var spanGaps = line.options.spanGaps; + var count = points.length; + if (!count) { + return []; + } + var loop = !!line._loop; + var _findStartAndEnd = findStartAndEnd(points, count, loop, spanGaps), + start = _findStartAndEnd.start, + end = _findStartAndEnd.end; + if (spanGaps === true) { + return [{ + start: start, + end: end, + loop: loop + }]; + } + var max = end < start ? end + count : end; + var completeLoop = !!line._fullLoop && start === 0 && end === count - 1; + return solidSegments(points, start, max, completeLoop); +} + +var defaultColor = defaults.color; +defaults.set('elements', { + line: { + backgroundColor: defaultColor, + borderCapStyle: 'butt', + borderColor: defaultColor, + borderDash: [], + borderDashOffset: 0, + borderJoinStyle: 'miter', + borderWidth: 3, + capBezierPoints: true, + fill: true, + tension: 0.4 + } +}); +function setStyle(ctx, vm) { + ctx.lineCap = vm.borderCapStyle; + ctx.setLineDash(vm.borderDash); + ctx.lineDashOffset = vm.borderDashOffset; + ctx.lineJoin = vm.borderJoinStyle; + ctx.lineWidth = vm.borderWidth; + ctx.strokeStyle = vm.borderColor; +} +function lineTo(ctx, previous, target) { + ctx.lineTo(target.x, target.y); +} +function getLineMethod(options) { + if (options.stepped) { + return _steppedLineTo; + } + if (options.tension) { + return _bezierCurveTo; + } + return lineTo; +} +function pathSegment(ctx, line, segment, params) { + var start = segment.start, + end = segment.end, + loop = segment.loop; + var points = line.points, + options = line.options; + var lineMethod = getLineMethod(options); + var count = points.length; + var _ref = params || {}, + _ref$move = _ref.move, + move = _ref$move === void 0 ? true : _ref$move, + reverse = _ref.reverse; + var ilen = end < start ? count + end - start : end - start; + var i, point, prev; + for (i = 0; i <= ilen; ++i) { + point = points[(start + (reverse ? ilen - i : i)) % count]; + if (point.skip) { + continue; + } else if (move) { + ctx.moveTo(point.x, point.y); + move = false; + } else { + lineMethod(ctx, prev, point, reverse, options.stepped); + } + prev = point; + } + if (loop) { + point = points[(start + (reverse ? ilen : 0)) % count]; + lineMethod(ctx, prev, point, reverse, options.stepped); + } + return !!loop; +} +function fastPathSegment(ctx, line, segment, params) { + var points = line.points; + var count = points.length; + var start = segment.start, + end = segment.end; + var _ref2 = params || {}, + _ref2$move = _ref2.move, + move = _ref2$move === void 0 ? true : _ref2$move, + reverse = _ref2.reverse; + var ilen = end < start ? count + end - start : end - start; + var avgX = 0; + var countX = 0; + var i, point, prevX, minY, maxY, lastY; + if (move) { + point = points[(start + (reverse ? ilen : 0)) % count]; + ctx.moveTo(point.x, point.y); + } + for (i = 0; i <= ilen; ++i) { + point = points[(start + (reverse ? ilen - i : i)) % count]; + if (point.skip) { + continue; + } + var x = point.x; + var y = point.y; + var truncX = x | 0; + if (truncX === prevX) { + if (y < minY) { + minY = y; + } else if (y > maxY) { + maxY = y; + } + avgX = (countX * avgX + x) / ++countX; + } else { + if (minY !== maxY) { + ctx.lineTo(avgX, maxY); + ctx.lineTo(avgX, minY); + ctx.lineTo(avgX, lastY); + } + ctx.lineTo(x, y); + prevX = truncX; + countX = 0; + minY = maxY = y; + } + lastY = y; + } +} +function _getSegmentMethod(line) { + var opts = line.options; + var borderDash = opts.borderDash && opts.borderDash.length; + var useFastPath = !line._loop && !opts.tension && !opts.stepped && !borderDash; + return useFastPath ? fastPathSegment : pathSegment; +} +function _getInterpolationMethod(options) { + if (options.stepped) { + return _steppedInterpolation; + } + if (options.tension) { + return _bezierInterpolation; + } + return _pointInLine; +} +var Line = function (_Element) { + _inherits(Line, _Element); + var _super = _createSuper(Line); + function Line(cfg) { + var _this; + _classCallCheck(this, Line); + _this = _super.call(this); + _this.options = undefined; + _this._loop = undefined; + _this._fullLoop = undefined; + _this._controlPointsUpdated = undefined; + _this._points = undefined; + _this._segments = undefined; + if (cfg) { + _extends(_assertThisInitialized(_this), cfg); + } + return _this; + } + _createClass(Line, [{ + key: "updateControlPoints", + value: function updateControlPoints(chartArea) { + var me = this; + if (me._controlPointsUpdated) { + return; + } + var options = me.options; + if (options.tension && !options.stepped) { + var loop = options.spanGaps ? me._loop : me._fullLoop; + _updateBezierControlPoints(me._points, options, chartArea, loop); + } + } + }, { + key: "first", + value: function first() { + var segments = this.segments; + var points = this.points; + return segments.length && points[segments[0].start]; + } + }, { + key: "last", + value: function last() { + var segments = this.segments; + var points = this.points; + var count = segments.length; + return count && points[segments[count - 1].end]; + } + }, { + key: "interpolate", + value: function interpolate(point, property) { + var me = this; + var options = me.options; + var value = point[property]; + var points = me.points; + var segments = _boundSegments(me, { + property: property, + start: value, + end: value + }); + if (!segments.length) { + return; + } + var result = []; + var _interpolate = _getInterpolationMethod(options); + var i, ilen; + for (i = 0, ilen = segments.length; i < ilen; ++i) { + var _segments$i = segments[i], + start = _segments$i.start, + end = _segments$i.end; + var p1 = points[start]; + var p2 = points[end]; + if (p1 === p2) { + result.push(p1); + continue; + } + var t = Math.abs((value - p1[property]) / (p2[property] - p1[property])); + var interpolated = _interpolate(p1, p2, t, options.stepped); + interpolated[property] = point[property]; + result.push(interpolated); + } + return result.length === 1 ? result[0] : result; + } + }, { + key: "pathSegment", + value: function pathSegment(ctx, segment, params) { + var segmentMethod = _getSegmentMethod(this); + return segmentMethod(ctx, this, segment, params); + } + }, { + key: "path", + value: function path(ctx) { + var me = this; + var segments = me.segments; + var ilen = segments.length; + var segmentMethod = _getSegmentMethod(me); + var loop = me._loop; + for (var i = 0; i < ilen; ++i) { + loop &= segmentMethod(ctx, me, segments[i]); + } + return !!loop; + } + }, { + key: "draw", + value: function draw(ctx) { + var me = this; + if (!me.points.length) { + return; + } + ctx.save(); + setStyle(ctx, me.options); + ctx.beginPath(); + if (me.path(ctx)) { + ctx.closePath(); + } + ctx.stroke(); + ctx.restore(); + } + }, { + key: "points", + set: function set(points) { + this._points = points; + delete this._segments; + }, + get: function get() { + return this._points; + } + }, { + key: "segments", + get: function get() { + return this._segments || (this._segments = _computeSegments(this)); + } + }]); + return Line; +}(Element$1); +_defineProperty(Line, "_type", 'line'); + +var defaultColor$1 = defaults.color; +defaults.set('elements', { + point: { + backgroundColor: defaultColor$1, + borderColor: defaultColor$1, + borderWidth: 1, + hitRadius: 1, + hoverBorderWidth: 1, + hoverRadius: 4, + pointStyle: 'circle', + radius: 3 + } +}); +var Point = function (_Element) { + _inherits(Point, _Element); + var _super = _createSuper(Point); + function Point(cfg) { + var _this; + _classCallCheck(this, Point); + _this = _super.call(this); + _this.options = undefined; + _this.skip = undefined; + _this.stop = undefined; + if (cfg) { + _extends(_assertThisInitialized(_this), cfg); + } + return _this; + } + _createClass(Point, [{ + key: "inRange", + value: function inRange(mouseX, mouseY, useFinalPosition) { + var options = this.options; + var _this$getProps = this.getProps(['x', 'y'], useFinalPosition), + x = _this$getProps.x, + y = _this$getProps.y; + return Math.pow(mouseX - x, 2) + Math.pow(mouseY - y, 2) < Math.pow(options.hitRadius + options.radius, 2); + } + }, { + key: "inXRange", + value: function inXRange(mouseX, useFinalPosition) { + var options = this.options; + var _this$getProps2 = this.getProps(['x'], useFinalPosition), + x = _this$getProps2.x; + return Math.abs(mouseX - x) < options.radius + options.hitRadius; + } + }, { + key: "inYRange", + value: function inYRange(mouseY, useFinalPosition) { + var options = this.options; + var _this$getProps3 = this.getProps(['x'], useFinalPosition), + y = _this$getProps3.y; + return Math.abs(mouseY - y) < options.radius + options.hitRadius; + } + }, { + key: "getCenterPoint", + value: function getCenterPoint(useFinalPosition) { + var _this$getProps4 = this.getProps(['x', 'y'], useFinalPosition), + x = _this$getProps4.x, + y = _this$getProps4.y; + return { + x: x, + y: y + }; + } + }, { + key: "size", + value: function size() { + var options = this.options || {}; + var radius = Math.max(options.radius, options.hoverRadius) || 0; + var borderWidth = radius && options.borderWidth || 0; + return (radius + borderWidth) * 2; + } + }, { + key: "draw", + value: function draw(ctx, chartArea) { + var me = this; + var options = me.options; + if (me.skip || options.radius <= 0) { + return; + } + if (chartArea === undefined || _isPointInArea(me, chartArea)) { + ctx.strokeStyle = options.borderColor; + ctx.lineWidth = options.borderWidth; + ctx.fillStyle = options.backgroundColor; + drawPoint(ctx, options, me.x, me.y); + } + } + }, { + key: "getRange", + value: function getRange() { + var options = this.options || {}; + return options.radius + options.hitRadius; + } + }]); + return Point; +}(Element$1); +_defineProperty(Point, "_type", 'point'); + +var defaultColor$2 = defaults.color; +defaults.set('elements', { + rectangle: { + backgroundColor: defaultColor$2, + borderColor: defaultColor$2, + borderSkipped: 'bottom', + borderWidth: 0 + } +}); +function getBarBounds(bar, useFinalPosition) { + var _bar$getProps = bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition), + x = _bar$getProps.x, + y = _bar$getProps.y, + base = _bar$getProps.base, + width = _bar$getProps.width, + height = _bar$getProps.height; + var left, right, top, bottom, half; + if (bar.horizontal) { + half = height / 2; + left = Math.min(x, base); + right = Math.max(x, base); + top = y - half; + bottom = y + half; + } else { + half = width / 2; + left = x - half; + right = x + half; + top = Math.min(y, base); + bottom = Math.max(y, base); + } + return { + left: left, + top: top, + right: right, + bottom: bottom + }; +} +function swap(orig, v1, v2) { + return orig === v1 ? v2 : orig === v2 ? v1 : orig; +} +function parseBorderSkipped(bar) { + var edge = bar.options.borderSkipped; + var res = {}; + if (!edge) { + return res; + } + if (bar.horizontal) { + if (bar.base > bar.x) { + edge = swap(edge, 'left', 'right'); + } + } else if (bar.base < bar.y) { + edge = swap(edge, 'bottom', 'top'); + } + res[edge] = true; + return res; +} +function skipOrLimit(skip, value, min, max) { + return skip ? 0 : Math.max(Math.min(value, max), min); +} +function parseBorderWidth(bar, maxW, maxH) { + var value = bar.options.borderWidth; + var skip = parseBorderSkipped(bar); + var t, r, b, l; + if (isObject(value)) { + t = +value.top || 0; + r = +value.right || 0; + b = +value.bottom || 0; + l = +value.left || 0; + } else { + t = r = b = l = +value || 0; + } + return { + t: skipOrLimit(skip.top, t, 0, maxH), + r: skipOrLimit(skip.right, r, 0, maxW), + b: skipOrLimit(skip.bottom, b, 0, maxH), + l: skipOrLimit(skip.left, l, 0, maxW) + }; +} +function boundingRects(bar) { + var bounds = getBarBounds(bar); + var width = bounds.right - bounds.left; + var height = bounds.bottom - bounds.top; + var border = parseBorderWidth(bar, width / 2, height / 2); + return { + outer: { + x: bounds.left, + y: bounds.top, + w: width, + h: height + }, + inner: { + x: bounds.left + border.l, + y: bounds.top + border.t, + w: width - border.l - border.r, + h: height - border.t - border.b + } + }; +} +function _inRange(bar, x, y, useFinalPosition) { + var skipX = x === null; + var skipY = y === null; + var bounds = !bar || skipX && skipY ? false : getBarBounds(bar, useFinalPosition); + return bounds && (skipX || x >= bounds.left && x <= bounds.right) && (skipY || y >= bounds.top && y <= bounds.bottom); +} +var Rectangle = function (_Element) { + _inherits(Rectangle, _Element); + var _super = _createSuper(Rectangle); + function Rectangle(cfg) { + var _this; + _classCallCheck(this, Rectangle); + _this = _super.call(this); + _this.options = undefined; + _this.horizontal = undefined; + _this.base = undefined; + _this.width = undefined; + _this.height = undefined; + if (cfg) { + _extends(_assertThisInitialized(_this), cfg); + } + return _this; + } + _createClass(Rectangle, [{ + key: "draw", + value: function draw(ctx) { + var options = this.options; + var _boundingRects = boundingRects(this), + inner = _boundingRects.inner, + outer = _boundingRects.outer; + ctx.save(); + if (outer.w !== inner.w || outer.h !== inner.h) { + ctx.beginPath(); + ctx.rect(outer.x, outer.y, outer.w, outer.h); + ctx.clip(); + ctx.rect(inner.x, inner.y, inner.w, inner.h); + ctx.fillStyle = options.borderColor; + ctx.fill('evenodd'); + } + ctx.fillStyle = options.backgroundColor; + ctx.fillRect(inner.x, inner.y, inner.w, inner.h); + ctx.restore(); + } + }, { + key: "inRange", + value: function inRange(mouseX, mouseY, useFinalPosition) { + return _inRange(this, mouseX, mouseY, useFinalPosition); + } + }, { + key: "inXRange", + value: function inXRange(mouseX, useFinalPosition) { + return _inRange(this, mouseX, null, useFinalPosition); + } + }, { + key: "inYRange", + value: function inYRange(mouseY, useFinalPosition) { + return _inRange(this, null, mouseY, useFinalPosition); + } + }, { + key: "getCenterPoint", + value: function getCenterPoint(useFinalPosition) { + var _this$getProps = this.getProps(['x', 'y', 'base', 'horizontal'], useFinalPosition), + x = _this$getProps.x, + y = _this$getProps.y, + base = _this$getProps.base, + horizontal = _this$getProps.horizontal; + return { + x: horizontal ? (x + base) / 2 : x, + y: horizontal ? y : (y + base) / 2 + }; + } + }, { + key: "getRange", + value: function getRange(axis) { + return axis === 'x' ? this.width / 2 : this.height / 2; + } + }]); + return Rectangle; +}(Element$1); +_defineProperty(Rectangle, "_type", 'rectangle'); + +var elements = /*#__PURE__*/Object.freeze({ +__proto__: null, +Arc: Arc, +Line: Line, +Point: Point, +Rectangle: Rectangle +}); + +defaults.set('bar', { + hover: { + mode: 'index' + }, + datasets: { + categoryPercentage: 0.8, + barPercentage: 0.9, + animation: { + numbers: { + type: 'number', + properties: ['x', 'y', 'base', 'width', 'height'] + } + } + }, + scales: { + x: { + type: 'category', + offset: true, + gridLines: { + offsetGridLines: true + } + }, + y: { + type: 'linear', + beginAtZero: true + } + } +}); +function computeMinSampleSize(scale, pixels) { + var min = scale._length; + var prev, curr, i, ilen; + for (i = 1, ilen = pixels.length; i < ilen; ++i) { + min = Math.min(min, Math.abs(pixels[i] - pixels[i - 1])); + } + for (i = 0, ilen = scale.ticks.length; i < ilen; ++i) { + curr = scale.getPixelForTick(i); + min = i > 0 ? Math.min(min, Math.abs(curr - prev)) : min; + prev = curr; + } + return min; +} +function computeFitCategoryTraits(index, ruler, options) { + var thickness = options.barThickness; + var count = ruler.stackCount; + var size, ratio; + if (isNullOrUndef(thickness)) { + size = ruler.min * options.categoryPercentage; + ratio = options.barPercentage; + } else { + size = thickness * count; + ratio = 1; + } + return { + chunk: size / count, + ratio: ratio, + start: ruler.pixels[index] - size / 2 + }; +} +function computeFlexCategoryTraits(index, ruler, options) { + var pixels = ruler.pixels; + var curr = pixels[index]; + var prev = index > 0 ? pixels[index - 1] : null; + var next = index < pixels.length - 1 ? pixels[index + 1] : null; + var percent = options.categoryPercentage; + if (prev === null) { + prev = curr - (next === null ? ruler.end - ruler.start : next - curr); + } + if (next === null) { + next = curr + curr - prev; + } + var start = curr - (curr - Math.min(prev, next)) / 2 * percent; + var size = Math.abs(next - prev) / 2 * percent; + return { + chunk: size / ruler.stackCount, + ratio: options.barPercentage, + start: start + }; +} +function parseFloatBar(arr, item, vScale, i) { + var startValue = vScale.parse(arr[0], i); + var endValue = vScale.parse(arr[1], i); + var min = Math.min(startValue, endValue); + var max = Math.max(startValue, endValue); + var barStart = min; + var barEnd = max; + if (Math.abs(min) > Math.abs(max)) { + barStart = max; + barEnd = min; + } + item[vScale.axis] = barEnd; + item._custom = { + barStart: barStart, + barEnd: barEnd, + start: startValue, + end: endValue, + min: min, + max: max + }; +} +function parseArrayOrPrimitive(meta, data, start, count) { + var iScale = meta.iScale; + var vScale = meta.vScale; + var labels = iScale.getLabels(); + var singleScale = iScale === vScale; + var parsed = []; + var 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); + if (isArray(entry)) { + parseFloatBar(entry, item, vScale, i); + } else { + item[vScale.axis] = vScale.parse(entry, i); + } + parsed.push(item); + } + return parsed; +} +function isFloatBar(custom) { + return custom && custom.barStart !== undefined && custom.barEnd !== undefined; +} +var BarController = function (_DatasetController) { + _inherits(BarController, _DatasetController); + var _super = _createSuper(BarController); + function BarController() { + _classCallCheck(this, BarController); + return _super.apply(this, arguments); + } + _createClass(BarController, [{ + key: "parsePrimitiveData", + value: function parsePrimitiveData(meta, data, start, count) { + return parseArrayOrPrimitive(meta, data, start, count); + } + }, { + key: "parseArrayData", + value: function parseArrayData(meta, data, start, count) { + return parseArrayOrPrimitive(meta, data, start, count); + } + }, { + key: "parseObjectData", + value: function parseObjectData(meta, data, start, count) { + var iScale = meta.iScale, + vScale = meta.vScale; + var vProp = vScale.axis; + var parsed = []; + var i, ilen, item, obj, value; + for (i = start, ilen = start + count; i < ilen; ++i) { + obj = data[i]; + item = {}; + 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); + } + parsed.push(item); + } + return parsed; + } + }, { + key: "getLabelAndValue", + value: function getLabelAndValue(index) { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale, + vScale = meta.vScale; + var parsed = me.getParsed(index); + var custom = parsed._custom; + var value = isFloatBar(custom) ? '[' + custom.start + ', ' + custom.end + ']' : '' + vScale.getLabelForValue(parsed[vScale.axis]); + return { + label: '' + iScale.getLabelForValue(parsed[iScale.axis]), + value: value + }; + } + }, { + key: "initialize", + value: function initialize() { + var me = this; + _get(_getPrototypeOf(BarController.prototype), "initialize", this).call(this); + var meta = me._cachedMeta; + meta.stack = me.getDataset().stack; + meta.bar = true; + } + }, { + key: "update", + value: function update(mode) { + var me = this; + var meta = me._cachedMeta; + me.updateElements(meta.data, 0, mode); + } + }, { + key: "updateElements", + value: function updateElements(rectangles, start, mode) { + var me = this; + var reset = mode === 'reset'; + var vscale = me._cachedMeta.vScale; + var base = vscale.getBasePixel(); + var horizontal = vscale.isHorizontal(); + var ruler = me._getRuler(); + var firstOpts = me.resolveDataElementOptions(start, mode); + var sharedOptions = me.getSharedOptions(mode, rectangles[start], firstOpts); + var includeOptions = me.includeOptions(mode, sharedOptions); + var i; + for (i = 0; i < rectangles.length; i++) { + var index = start + i; + var options = me.resolveDataElementOptions(index, mode); + var vpixels = me._calculateBarValuePixels(index, options); + var ipixels = me._calculateBarIndexPixels(index, ruler, options); + var properties = { + horizontal: horizontal, + base: reset ? base : vpixels.base, + x: horizontal ? reset ? base : vpixels.head : ipixels.center, + y: horizontal ? ipixels.center : reset ? base : vpixels.head, + height: horizontal ? ipixels.size : undefined, + width: horizontal ? undefined : ipixels.size + }; + if (includeOptions) { + properties.options = options; + } + me.updateElement(rectangles[i], index, properties, mode); + } + me.updateSharedOptions(sharedOptions, mode); + } + }, { + key: "_getStacks", + value: function _getStacks(last) { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale; + var metasets = iScale.getMatchingVisibleMetas(me._type); + var stacked = iScale.options.stacked; + var ilen = metasets.length; + var stacks = []; + var i, item; + for (i = 0; i < ilen; ++i) { + item = metasets[i]; + if (stacked === false || stacks.indexOf(item.stack) === -1 || stacked === undefined && item.stack === undefined) { + stacks.push(item.stack); + } + if (item.index === last) { + break; + } + } + if (!stacks.length) { + stacks.push(undefined); + } + return stacks; + } + }, { + key: "_getStackCount", + value: function _getStackCount() { + return this._getStacks().length; + } + }, { + key: "_getStackIndex", + value: function _getStackIndex(datasetIndex, name) { + var stacks = this._getStacks(datasetIndex); + var index = name !== undefined ? stacks.indexOf(name) : -1; + return index === -1 ? stacks.length - 1 : index; + } + }, { + key: "_getRuler", + value: function _getRuler() { + var me = this; + var meta = me._cachedMeta; + var iScale = meta.iScale; + var pixels = []; + var i, ilen; + for (i = 0, ilen = meta.data.length; i < ilen; ++i) { + pixels.push(iScale.getPixelForValue(me.getParsed(i)[iScale.axis])); + } + var min = computeMinSampleSize(iScale, pixels); + return { + min: min, + pixels: pixels, + start: iScale._startPixel, + end: iScale._endPixel, + stackCount: me._getStackCount(), + scale: iScale + }; + } + }, { + key: "_calculateBarValuePixels", + value: function _calculateBarValuePixels(index, options) { + var me = this; + var meta = me._cachedMeta; + var vScale = meta.vScale; + var minBarLength = options.minBarLength; + var parsed = me.getParsed(index); + var custom = parsed._custom; + var value = parsed[vScale.axis]; + var start = 0; + var length = meta._stacked ? me.applyStack(vScale, parsed) : value; + var head, size; + if (length !== value) { + start = length - value; + length = value; + } + if (isFloatBar(custom)) { + value = custom.barStart; + length = custom.barEnd - custom.barStart; + if (value !== 0 && sign(value) !== sign(custom.barEnd)) { + start = 0; + } + start += value; + } + var base = _limitValue(vScale.getPixelForValue(start), vScale._startPixel - 10, vScale._endPixel + 10); + head = vScale.getPixelForValue(start + length); + size = head - base; + if (minBarLength !== undefined && Math.abs(size) < minBarLength) { + size = size < 0 ? -minBarLength : minBarLength; + head = base + size; + } + return { + size: size, + base: base, + head: head, + center: head + size / 2 + }; + } + }, { + key: "_calculateBarIndexPixels", + value: function _calculateBarIndexPixels(index, ruler, options) { + var me = this; + var range = options.barThickness === 'flex' ? computeFlexCategoryTraits(index, ruler, options) : computeFitCategoryTraits(index, ruler, options); + var stackIndex = me._getStackIndex(me.index, me._cachedMeta.stack); + var center = range.start + range.chunk * stackIndex + range.chunk / 2; + var size = Math.min(valueOrDefault(options.maxBarThickness, Infinity), range.chunk * range.ratio); + return { + base: center - size / 2, + head: center + size / 2, + center: center, + size: size + }; + } + }, { + key: "draw", + value: function draw() { + var me = this; + var chart = me.chart; + var meta = me._cachedMeta; + var vScale = meta.vScale; + var rects = meta.data; + var ilen = rects.length; + var i = 0; + clipArea(chart.ctx, chart.chartArea); + for (; i < ilen; ++i) { + if (!isNaN(me.getParsed(i)[vScale.axis])) { + rects[i].draw(me._ctx); + } + } + unclipArea(chart.ctx); + } + }]); + return BarController; +}(DatasetController); +BarController.prototype.dataElementType = Rectangle; +BarController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderSkipped', 'borderWidth', 'barPercentage', 'barThickness', 'categoryPercentage', 'maxBarThickness', 'minBarLength']; + +defaults.set('bubble', { + animation: { + numbers: { + properties: ['x', 'y', 'borderWidth', 'radius'] + } + }, + scales: { + x: { + type: 'linear' + }, + y: { + type: 'linear' + } + }, + tooltips: { + callbacks: { + title: function title() { + return ''; + } + } + } +}); +var BubbleController = function (_DatasetController) { + _inherits(BubbleController, _DatasetController); + var _super = _createSuper(BubbleController); + function BubbleController() { + _classCallCheck(this, BubbleController); + return _super.apply(this, arguments); + } + _createClass(BubbleController, [{ + key: "parseObjectData", + value: function parseObjectData(meta, data, start, count) { + var xScale = meta.xScale, + yScale = meta.yScale; + var parsed = []; + var 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), + _custom: item && item.r && +item.r + }); + } + return parsed; + } + }, { + key: "getMaxOverflow", + value: function getMaxOverflow() { + var me = this; + var meta = me._cachedMeta; + var i = (meta.data || []).length - 1; + var max = 0; + for (; i >= 0; --i) { + max = Math.max(max, me.getStyle(i, true).radius); + } + return max > 0 && max; + } + }, { + key: "getLabelAndValue", + value: function getLabelAndValue(index) { + var me = this; + var meta = me._cachedMeta; + var xScale = meta.xScale, + yScale = meta.yScale; + var parsed = me.getParsed(index); + var x = xScale.getLabelForValue(parsed.x); + var y = yScale.getLabelForValue(parsed.y); + var r = parsed._custom; + return { + label: meta.label, + value: '(' + x + ', ' + y + (r ? ', ' + r : '') + ')' + }; + } + }, { + key: "update", + value: function update(mode) { + var me = this; + var points = me._cachedMeta.data; + me.updateElements(points, 0, mode); + } + }, { + key: "updateElements", + value: function updateElements(points, start, mode) { + var me = this; + var reset = mode === 'reset'; + var _me$_cachedMeta = me._cachedMeta, + xScale = _me$_cachedMeta.xScale, + yScale = _me$_cachedMeta.yScale; + var firstOpts = me.resolveDataElementOptions(start, mode); + var sharedOptions = me.getSharedOptions(mode, points[start], firstOpts); + var includeOptions = me.includeOptions(mode, sharedOptions); + for (var i = 0; i < points.length; i++) { + var point = points[i]; + var index = start + i; + var parsed = !reset && me.getParsed(index); + var x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(parsed.x); + var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y); + var properties = { + x: x, + y: y, + skip: isNaN(x) || isNaN(y) + }; + if (includeOptions) { + properties.options = me.resolveDataElementOptions(i, mode); + if (reset) { + properties.options.radius = 0; + } + } + me.updateElement(point, index, properties, mode); + } + me.updateSharedOptions(sharedOptions, mode); + } + }, { + key: "resolveDataElementOptions", + value: function resolveDataElementOptions(index, mode) { + var me = this; + var chart = me.chart; + var dataset = me.getDataset(); + var parsed = me.getParsed(index); + var values = _get(_getPrototypeOf(BubbleController.prototype), "resolveDataElementOptions", this).call(this, index, mode); + var context = { + chart: chart, + dataIndex: index, + dataset: dataset, + datasetIndex: me.index + }; + if (values.$shared) { + values = _extends({}, values, { + $shared: false + }); + } + if (mode !== 'active') { + values.radius = 0; + } + values.radius += resolve([parsed && parsed._custom, me._config.radius, chart.options.elements.point.radius], context, index); + return values; + } + }]); + return BubbleController; +}(DatasetController); +BubbleController.prototype.dataElementType = Point; +BubbleController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderWidth', 'hitRadius', 'radius', 'pointStyle', 'rotation']; + +var PI$2 = Math.PI; +var DOUBLE_PI$1 = PI$2 * 2; +var HALF_PI$1 = PI$2 / 2; +defaults.set('doughnut', { + animation: { + numbers: { + type: 'number', + properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y'] + }, + animateRotate: true, + animateScale: false + }, + legend: { + labels: { + generateLabels: function generateLabels(chart) { + var data = chart.data; + if (data.labels.length && data.datasets.length) { + return data.labels.map(function (label, i) { + var meta = chart.getDatasetMeta(0); + var style = meta.controller.getStyle(i); + return { + text: label, + fillStyle: style.backgroundColor, + strokeStyle: style.borderColor, + lineWidth: style.borderWidth, + hidden: !chart.getDataVisibility(i), + index: i + }; + }); + } + return []; + } + }, + onClick: function onClick(e, legendItem) { + this.chart.toggleDataVisibility(legendItem.index); + this.chart.update(); + } + }, + cutoutPercentage: 50, + rotation: -HALF_PI$1, + circumference: DOUBLE_PI$1, + tooltips: { + callbacks: { + title: function title() { + return ''; + }, + label: function label(tooltipItem, data) { + var dataLabel = data.labels[tooltipItem.index]; + var value = ': ' + data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]; + if (isArray(dataLabel)) { + dataLabel = dataLabel.slice(); + dataLabel[0] += value; + } else { + dataLabel += value; + } + return dataLabel; + } + } + } +}); +function getRatioAndOffset(rotation, circumference, cutout) { + var ratioX = 1; + var ratioY = 1; + var offsetX = 0; + var offsetY = 0; + if (circumference < DOUBLE_PI$1) { + var startAngle = rotation % DOUBLE_PI$1; + startAngle += startAngle >= PI$2 ? -DOUBLE_PI$1 : startAngle < -PI$2 ? DOUBLE_PI$1 : 0; + var endAngle = startAngle + circumference; + var startX = Math.cos(startAngle); + var startY = Math.sin(startAngle); + var endX = Math.cos(endAngle); + var endY = Math.sin(endAngle); + var contains0 = startAngle <= 0 && endAngle >= 0 || endAngle >= DOUBLE_PI$1; + var contains90 = startAngle <= HALF_PI$1 && endAngle >= HALF_PI$1 || endAngle >= DOUBLE_PI$1 + HALF_PI$1; + var contains180 = startAngle === -PI$2 || endAngle >= PI$2; + var contains270 = startAngle <= -HALF_PI$1 && endAngle >= -HALF_PI$1 || endAngle >= PI$2 + HALF_PI$1; + var minX = contains180 ? -1 : Math.min(startX, startX * cutout, endX, endX * cutout); + var minY = contains270 ? -1 : Math.min(startY, startY * cutout, endY, endY * cutout); + var maxX = contains0 ? 1 : Math.max(startX, startX * cutout, endX, endX * cutout); + var maxY = contains90 ? 1 : Math.max(startY, startY * cutout, endY, endY * cutout); + ratioX = (maxX - minX) / 2; + ratioY = (maxY - minY) / 2; + offsetX = -(maxX + minX) / 2; + offsetY = -(maxY + minY) / 2; + } + return { + ratioX: ratioX, + ratioY: ratioY, + offsetX: offsetX, + offsetY: offsetY + }; +} +var DoughnutController = function (_DatasetController) { + _inherits(DoughnutController, _DatasetController); + var _super = _createSuper(DoughnutController); + function DoughnutController(chart, datasetIndex) { + var _this; + _classCallCheck(this, DoughnutController); + _this = _super.call(this, chart, datasetIndex); + _this.innerRadius = undefined; + _this.outerRadius = undefined; + _this.offsetX = undefined; + _this.offsetY = undefined; + return _this; + } + _createClass(DoughnutController, [{ + key: "linkScales", + value: function linkScales() {} + }, { + key: "parse", + value: function 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]; + } + } + }, { + key: "getRingIndex", + value: function getRingIndex(datasetIndex) { + var ringIndex = 0; + for (var j = 0; j < datasetIndex; ++j) { + if (this.chart.isDatasetVisible(j)) { + ++ringIndex; + } + } + return ringIndex; + } + }, { + key: "update", + value: function update(mode) { + var me = this; + var chart = me.chart; + var chartArea = chart.chartArea, + options = chart.options; + var meta = me._cachedMeta; + var arcs = meta.data; + var cutout = options.cutoutPercentage / 100 || 0; + var chartWeight = me._getRingWeight(me.index); + var _getRatioAndOffset = getRatioAndOffset(options.rotation, options.circumference, cutout), + ratioX = _getRatioAndOffset.ratioX, + ratioY = _getRatioAndOffset.ratioY, + offsetX = _getRatioAndOffset.offsetX, + offsetY = _getRatioAndOffset.offsetY; + var borderWidth = me.getMaxBorderWidth(); + var maxWidth = (chartArea.right - chartArea.left - borderWidth) / ratioX; + var maxHeight = (chartArea.bottom - chartArea.top - borderWidth) / ratioY; + var outerRadius = Math.max(Math.min(maxWidth, maxHeight) / 2, 0); + var innerRadius = Math.max(outerRadius * cutout, 0); + var radiusLength = (outerRadius - innerRadius) / me._getVisibleDatasetWeightTotal(); + me.offsetX = offsetX * outerRadius; + me.offsetY = offsetY * outerRadius; + meta.total = me.calculateTotal(); + me.outerRadius = outerRadius - radiusLength * me._getRingWeightOffset(me.index); + me.innerRadius = Math.max(me.outerRadius - radiusLength * chartWeight, 0); + me.updateElements(arcs, 0, mode); + } + }, { + key: "_circumference", + value: function _circumference(i, reset) { + var me = this; + var opts = me.chart.options; + var meta = me._cachedMeta; + return reset && opts.animation.animateRotate ? 0 : this.chart.getDataVisibility(i) ? me.calculateCircumference(meta._parsed[i] * opts.circumference / DOUBLE_PI$1) : 0; + } + }, { + key: "updateElements", + value: function updateElements(arcs, start, mode) { + var me = this; + var reset = mode === 'reset'; + 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 animateScale = reset && animationOpts.animateScale; + var innerRadius = animateScale ? 0 : me.innerRadius; + var outerRadius = animateScale ? 0 : me.outerRadius; + var firstOpts = me.resolveDataElementOptions(start, mode); + var sharedOptions = me.getSharedOptions(mode, arcs[start], firstOpts); + var includeOptions = me.includeOptions(mode, sharedOptions); + var startAngle = opts.rotation; + var i; + for (i = 0; i < start; ++i) { + startAngle += me._circumference(i, reset); + } + for (i = 0; i < arcs.length; ++i) { + var index = start + i; + var circumference = me._circumference(index, reset); + var arc = arcs[i]; + var properties = { + x: centerX + me.offsetX, + y: centerY + me.offsetY, + startAngle: startAngle, + endAngle: startAngle + circumference, + circumference: circumference, + outerRadius: outerRadius, + innerRadius: innerRadius + }; + if (includeOptions) { + properties.options = me.resolveDataElementOptions(index, mode); + } + startAngle += circumference; + me.updateElement(arc, index, properties, mode); + } + me.updateSharedOptions(sharedOptions, mode); + } + }, { + key: "calculateTotal", + value: function calculateTotal() { + var meta = this._cachedMeta; + var metaData = meta.data; + var total = 0; + var i; + for (i = 0; i < metaData.length; i++) { + var value = meta._parsed[i]; + if (!isNaN(value) && this.chart.getDataVisibility(i)) { + total += Math.abs(value); + } + } + return total; + } + }, { + key: "calculateCircumference", + value: function calculateCircumference(value) { + var total = this._cachedMeta.total; + if (total > 0 && !isNaN(value)) { + return DOUBLE_PI$1 * (Math.abs(value) / total); + } + return 0; + } + }, { + key: "getMaxBorderWidth", + value: function getMaxBorderWidth(arcs) { + var me = this; + var max = 0; + var chart = me.chart; + var i, ilen, meta, controller, options; + if (!arcs) { + for (i = 0, ilen = chart.data.datasets.length; i < ilen; ++i) { + if (chart.isDatasetVisible(i)) { + meta = chart.getDatasetMeta(i); + arcs = meta.data; + controller = meta.controller; + if (controller !== me) { + controller.configure(); + } + break; + } + } + } + if (!arcs) { + return 0; + } + for (i = 0, ilen = arcs.length; i < ilen; ++i) { + options = controller.resolveDataElementOptions(i); + if (options.borderAlign !== 'inner') { + max = Math.max(max, options.borderWidth || 0, options.hoverBorderWidth || 0); + } + } + return max; + } + }, { + key: "_getRingWeightOffset", + value: function _getRingWeightOffset(datasetIndex) { + var ringWeightOffset = 0; + for (var i = 0; i < datasetIndex; ++i) { + if (this.chart.isDatasetVisible(i)) { + ringWeightOffset += this._getRingWeight(i); + } + } + return ringWeightOffset; + } + }, { + key: "_getRingWeight", + value: function _getRingWeight(datasetIndex) { + return Math.max(valueOrDefault(this.chart.data.datasets[datasetIndex].weight, 1), 0); + } + }, { + key: "_getVisibleDatasetWeightTotal", + value: function _getVisibleDatasetWeightTotal() { + return this._getRingWeightOffset(this.chart.data.datasets.length) || 1; + } + }]); + return DoughnutController; +}(DatasetController); +DoughnutController.prototype.dataElementType = Arc; +DoughnutController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderWidth', 'borderAlign', 'hoverBackgroundColor', 'hoverBorderColor', 'hoverBorderWidth']; + +defaults.set('horizontalBar', { + hover: { + mode: 'index', + axis: 'y' + }, + scales: { + x: { + type: 'linear', + beginAtZero: true + }, + y: { + type: 'category', + offset: true, + gridLines: { + offsetGridLines: true + } + } + }, + datasets: { + categoryPercentage: 0.8, + barPercentage: 0.9 + }, + elements: { + rectangle: { + borderSkipped: 'left' + } + }, + tooltips: { + mode: 'index', + axis: 'y' + } +}); +var HorizontalBarController = function (_BarController) { + _inherits(HorizontalBarController, _BarController); + var _super = _createSuper(HorizontalBarController); + function HorizontalBarController() { + _classCallCheck(this, HorizontalBarController); + return _super.apply(this, arguments); + } + _createClass(HorizontalBarController, [{ + key: "getValueScaleId", + value: function getValueScaleId() { + return this._cachedMeta.xAxisID; + } + }, { + key: "getIndexScaleId", + value: function getIndexScaleId() { + return this._cachedMeta.yAxisID; + } + }]); + return HorizontalBarController; +}(BarController); + +defaults.set('line', { + showLines: true, + spanGaps: false, + hover: { + mode: 'index' + }, + scales: { + x: { + type: 'category' + }, + y: { + type: 'linear' + } + } +}); +var LineController = function (_DatasetController) { + _inherits(LineController, _DatasetController); + var _super = _createSuper(LineController); + function LineController(chart, datasetIndex) { + var _this; + _classCallCheck(this, LineController); + _this = _super.call(this, chart, datasetIndex); + _this._showLine = false; + return _this; + } + _createClass(LineController, [{ + key: "update", + value: function update(mode) { + 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); + if (showLine && mode !== 'resize') { + var properties = { + points: points, + options: me.resolveDatasetElementOptions() + }; + me.updateElement(line, undefined, properties, mode); + } + me.updateElements(points, 0, mode); + } + }, { + key: "updateElements", + value: function updateElements(points, start, mode) { + var me = this; + var reset = mode === 'reset'; + var _me$_cachedMeta = me._cachedMeta, + xScale = _me$_cachedMeta.xScale, + yScale = _me$_cachedMeta.yScale, + _stacked = _me$_cachedMeta._stacked; + var firstOpts = me.resolveDataElementOptions(start, mode); + var sharedOptions = me.getSharedOptions(mode, points[start], firstOpts); + var includeOptions = me.includeOptions(mode, sharedOptions); + var spanGaps = valueOrDefault(me._config.spanGaps, me.chart.options.spanGaps); + var maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY; + var prevParsed; + for (var i = 0; i < points.length; ++i) { + var index = start + i; + var point = points[i]; + var parsed = me.getParsed(index); + var x = xScale.getPixelForValue(parsed.x); + var y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(_stacked ? me.applyStack(yScale, parsed) : parsed.y); + var properties = { + x: x, + y: y, + skip: isNaN(x) || isNaN(y), + stop: i > 0 && parsed.x - prevParsed.x > maxGapLength + }; + if (includeOptions) { + properties.options = me.resolveDataElementOptions(index, mode); + } + me.updateElement(point, index, properties, mode); + prevParsed = parsed; + } + me.updateSharedOptions(sharedOptions, mode); + } + }, { + key: "resolveDatasetElementOptions", + value: function resolveDatasetElementOptions(active) { + var me = this; + var config = me._config; + var options = me.chart.options; + var lineOptions = options.elements.line; + var values = _get(_getPrototypeOf(LineController.prototype), "resolveDatasetElementOptions", this).call(this, active); + values.spanGaps = valueOrDefault(config.spanGaps, options.spanGaps); + values.tension = valueOrDefault(config.lineTension, lineOptions.tension); + values.stepped = resolve([config.stepped, lineOptions.stepped]); + return values; + } + }, { + key: "getMaxOverflow", + value: function getMaxOverflow() { + var me = this; + var meta = me._cachedMeta; + var border = me._showLine && meta.dataset.options.borderWidth || 0; + var data = meta.data || []; + if (!data.length) { + return border; + } + var firstPoint = data[0].size(); + var lastPoint = data[data.length - 1].size(); + return Math.max(border, firstPoint, lastPoint) / 2; + } + }, { + key: "draw", + value: function draw() { + var me = this; + var ctx = me._ctx; + var chart = me.chart; + var meta = me._cachedMeta; + var points = meta.data || []; + var area = chart.chartArea; + var active = []; + var ilen = points.length; + var i, point; + if (me._showLine) { + meta.dataset.draw(ctx, area); + } + for (i = 0; i < ilen; ++i) { + point = points[i]; + if (point.active) { + active.push(point); + } else { + point.draw(ctx, area); + } + } + for (i = 0, ilen = active.length; i < ilen; ++i) { + active[i].draw(ctx, area); + } + } + }]); + return LineController; +}(DatasetController); +LineController.prototype.datasetElementType = Line; +LineController.prototype.dataElementType = Point; +LineController.prototype.datasetElementOptions = ['backgroundColor', 'borderCapStyle', 'borderColor', 'borderDash', 'borderDashOffset', 'borderJoinStyle', 'borderWidth', 'capBezierPoints', 'cubicInterpolationMode', 'fill']; +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' +}; + +defaults.set('polarArea', { + animation: { + numbers: { + type: 'number', + properties: ['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius'] + }, + animateRotate: true, + animateScale: true + }, + scales: { + r: { + type: 'radialLinear', + angleLines: { + display: false + }, + beginAtZero: true, + gridLines: { + circular: true + }, + pointLabels: { + display: false + } + } + }, + startAngle: 0, + legend: { + labels: { + generateLabels: function generateLabels(chart) { + var data = chart.data; + if (data.labels.length && data.datasets.length) { + return data.labels.map(function (label, i) { + var meta = chart.getDatasetMeta(0); + var style = meta.controller.getStyle(i); + return { + text: label, + fillStyle: style.backgroundColor, + strokeStyle: style.borderColor, + lineWidth: style.borderWidth, + hidden: !chart.getDataVisibility(i), + index: i + }; + }); + } + return []; + } + }, + onClick: function onClick(e, legendItem) { + this.chart.toggleDataVisibility(legendItem.index); + this.chart.update(); + } + }, + tooltips: { + callbacks: { + title: function title() { + return ''; + }, + label: function label(item, data) { + return data.labels[item.index] + ': ' + item.value; + } + } + } +}); +function getStartAngleRadians(deg) { + return toRadians(deg) - 0.5 * Math.PI; +} +var PolarAreaController = function (_DatasetController) { + _inherits(PolarAreaController, _DatasetController); + var _super = _createSuper(PolarAreaController); + function PolarAreaController(chart, datasetIndex) { + var _this; + _classCallCheck(this, PolarAreaController); + _this = _super.call(this, chart, datasetIndex); + _this.innerRadius = undefined; + _this.outerRadius = undefined; + return _this; + } + _createClass(PolarAreaController, [{ + key: "getIndexScaleId", + value: function getIndexScaleId() { + return this._cachedMeta.rAxisID; + } + }, { + key: "getValueScaleId", + value: function getValueScaleId() { + return this._cachedMeta.rAxisID; + } + }, { + key: "update", + value: function update(mode) { + var arcs = this._cachedMeta.data; + this._updateRadius(); + this.updateElements(arcs, 0, mode); + } + }, { + key: "_updateRadius", + value: function _updateRadius() { + var me = this; + var chart = me.chart; + var chartArea = chart.chartArea; + var opts = chart.options; + var minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top); + var outerRadius = Math.max(minSize / 2, 0); + var innerRadius = Math.max(opts.cutoutPercentage ? outerRadius / 100 * opts.cutoutPercentage : 1, 0); + var radiusLength = (outerRadius - innerRadius) / chart.getVisibleDatasetCount(); + me.outerRadius = outerRadius - radiusLength * me.index; + me.innerRadius = me.outerRadius - radiusLength; + } + }, { + key: "updateElements", + value: function updateElements(arcs, start, mode) { + var me = this; + var reset = mode === 'reset'; + var chart = me.chart; + var dataset = me.getDataset(); + var opts = chart.options; + var animationOpts = opts.animation; + var scale = chart.scales.r; + var centerX = scale.xCenter; + var centerY = scale.yCenter; + var datasetStartAngle = getStartAngleRadians(opts.startAngle); + var angle = datasetStartAngle; + var i; + me._cachedMeta.count = me.countVisibleElements(); + for (i = 0; i < start; ++i) { + angle += me._computeAngle(i); + } + for (i = 0; i < arcs.length; i++) { + var arc = arcs[i]; + var index = start + i; + var startAngle = angle; + var endAngle = angle + me._computeAngle(index); + var outerRadius = this.chart.getDataVisibility(index) ? scale.getDistanceFromCenterForValue(dataset.data[index]) : 0; + angle = endAngle; + if (reset) { + if (animationOpts.animateScale) { + outerRadius = 0; + } + if (animationOpts.animateRotate) { + startAngle = datasetStartAngle; + endAngle = datasetStartAngle; + } + } + var properties = { + x: centerX, + y: centerY, + innerRadius: 0, + outerRadius: outerRadius, + startAngle: startAngle, + endAngle: endAngle, + options: me.resolveDataElementOptions(index) + }; + me.updateElement(arc, index, properties, mode); + } + } + }, { + key: "countVisibleElements", + value: function countVisibleElements() { + var _this2 = this; + var dataset = this.getDataset(); + var meta = this._cachedMeta; + var count = 0; + meta.data.forEach(function (element, index) { + if (!isNaN(dataset.data[index]) && _this2.chart.getDataVisibility(index)) { + count++; + } + }); + return count; + } + }, { + key: "_computeAngle", + value: function _computeAngle(index) { + var me = this; + var meta = me._cachedMeta; + var count = meta.count; + var dataset = me.getDataset(); + if (isNaN(dataset.data[index]) || !this.chart.getDataVisibility(index)) { + return 0; + } + var context = { + chart: me.chart, + dataIndex: index, + dataset: dataset, + datasetIndex: me.index + }; + return resolve([me.chart.options.elements.arc.angle, 2 * Math.PI / count], context, index); + } + }]); + return PolarAreaController; +}(DatasetController); +PolarAreaController.prototype.dataElementType = Arc; +PolarAreaController.prototype.dataElementOptions = ['backgroundColor', 'borderColor', 'borderWidth', 'borderAlign', 'hoverBackgroundColor', 'hoverBorderColor', 'hoverBorderWidth']; + +defaults.set('pie', clone(defaults.doughnut)); +defaults.set('pie', { + cutoutPercentage: 0 +}); + +defaults.set('radar', { + spanGaps: false, + scales: { + r: { + type: 'radialLinear' + } + }, + elements: { + line: { + tension: 0 + } + } +}); +var RadarController = function (_DatasetController) { + _inherits(RadarController, _DatasetController); + var _super = _createSuper(RadarController); + function RadarController() { + _classCallCheck(this, RadarController); + return _super.apply(this, arguments); + } + _createClass(RadarController, [{ + key: "getIndexScaleId", + value: function getIndexScaleId() { + return this._cachedMeta.rAxisID; + } + }, { + key: "getValueScaleId", + value: function getValueScaleId() { + return this._cachedMeta.rAxisID; + } + }, { + key: "getLabelAndValue", + value: function getLabelAndValue(index) { + var me = this; + var vScale = me._cachedMeta.vScale; + var parsed = me.getParsed(index); + return { + label: vScale.getLabels()[index], + value: '' + vScale.getLabelForValue(parsed[vScale.axis]) + }; + } + }, { + key: "update", + value: function update(mode) { + var me = this; + var meta = me._cachedMeta; + var line = meta.dataset; + var points = meta.data || []; + var labels = meta.iScale.getLabels(); + var properties = { + points: points, + _loop: true, + _fullLoop: labels.length === points.length, + options: me.resolveDatasetElementOptions() + }; + me.updateElement(line, undefined, properties, mode); + me.updateElements(points, 0, mode); + line.updateControlPoints(me.chart.chartArea); + } + }, { + key: "updateElements", + value: function updateElements(points, start, mode) { + var me = this; + var dataset = me.getDataset(); + var scale = me.chart.scales.r; + var reset = mode === 'reset'; + var i; + for (i = 0; i < points.length; i++) { + var point = points[i]; + var index = start + i; + var options = me.resolveDataElementOptions(index); + var pointPosition = scale.getPointPositionForValue(index, dataset.data[index]); + var x = reset ? scale.xCenter : pointPosition.x; + var y = reset ? scale.yCenter : pointPosition.y; + var properties = { + x: x, + y: y, + angle: pointPosition.angle, + skip: isNaN(x) || isNaN(y), + options: options + }; + me.updateElement(point, index, properties, mode); + } + } + }, { + key: "resolveDatasetElementOptions", + value: function resolveDatasetElementOptions(active) { + var me = this; + var config = me._config; + var options = me.chart.options; + var values = _get(_getPrototypeOf(RadarController.prototype), "resolveDatasetElementOptions", this).call(this, active); + values.spanGaps = valueOrDefault(config.spanGaps, options.spanGaps); + values.tension = valueOrDefault(config.lineTension, options.elements.line.tension); + return values; + } + }]); + return RadarController; +}(DatasetController); +RadarController.prototype.datasetElementType = Line; +RadarController.prototype.dataElementType = Point; +RadarController.prototype.datasetElementOptions = ['backgroundColor', 'borderColor', 'borderCapStyle', 'borderDash', 'borderDashOffset', 'borderJoinStyle', 'borderWidth', 'fill']; +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' +}; + +defaults.set('scatter', { + scales: { + x: { + type: 'linear' + }, + y: { + type: 'linear' + } + }, + datasets: { + showLine: false + }, + tooltips: { + callbacks: { + title: function title() { + return ''; + }, + label: function label(item) { + return '(' + item.label + ', ' + item.value + ')'; + } + } + } +}); + +var controllers = { + bar: BarController, + bubble: BubbleController, + doughnut: DoughnutController, + horizontalBar: HorizontalBarController, + line: LineController, + polarArea: PolarAreaController, + pie: DoughnutController, + radar: RadarController, + scatter: LineController +}; + +function _lookup(table, value) { + var hi = table.length - 1; + var lo = 0; + var mid; + while (hi - lo > 1) { + mid = lo + hi >> 1; + if (table[mid] < value) { + lo = mid; + } else { + hi = mid; + } + } + return { + lo: lo, + hi: hi + }; +} +function _lookupByKey(table, key, value) { + var hi = table.length - 1; + var lo = 0; + var mid; + while (hi - lo > 1) { + mid = lo + hi >> 1; + if (table[mid][key] < value) { + lo = mid; + } else { + hi = mid; + } + } + return { + lo: lo, + hi: hi + }; +} +function _rlookupByKey(table, key, value) { + var hi = table.length - 1; + var lo = 0; + var mid; + while (hi - lo > 1) { + mid = lo + hi >> 1; + if (table[mid][key] < value) { + hi = mid; + } else { + lo = mid; + } + } + return { + lo: lo, + hi: hi + }; +} +function _filterBetween(values, min, max) { + var start = 0; + var end = values.length; + while (start < end && values[start] < min) { + start++; + } + while (end > start && values[end - 1] > max) { + end--; + } + return start > 0 || end < values.length ? values.slice(start, end) : values; +} + +function getRelativePosition$1(e, chart) { + if ('native' in e) { + return { + x: e.x, + y: e.y + }; + } + return helpers.dom.getRelativePosition(e, chart); +} +function evaluateAllVisibleItems(chart, handler) { + var metasets = chart.getSortedVisibleDatasetMetas(); + var index, data, element; + for (var i = 0, ilen = metasets.length; i < ilen; ++i) { + var _metasets$i = metasets[i]; + index = _metasets$i.index; + data = _metasets$i.data; + for (var j = 0, jlen = data.length; j < jlen; ++j) { + element = data[j]; + if (!element.skip) { + handler(element, index, j); + } + } + } +} +function binarySearch(metaset, axis, value, intersect) { + var controller = metaset.controller, + data = metaset.data, + _sorted = metaset._sorted; + var iScale = controller._cachedMeta.iScale; + if (iScale && axis === iScale.axis && _sorted && data.length) { + var lookupMethod = iScale._reversePixels ? _rlookupByKey : _lookupByKey; + if (!intersect) { + return lookupMethod(data, axis, value); + } else if (controller._sharedOptions) { + var el = data[0]; + var range = typeof el.getRange === 'function' && el.getRange(axis); + if (range) { + var start = lookupMethod(data, axis, value - range); + var end = lookupMethod(data, axis, value + range); + return { + lo: start.lo, + hi: end.hi + }; + } + } + } + return { + lo: 0, + hi: data.length - 1 + }; +} +function optimizedEvaluateItems(chart, axis, position, handler, intersect) { + var metasets = chart.getSortedVisibleDatasetMetas(); + var value = position[axis]; + for (var i = 0, ilen = metasets.length; i < ilen; ++i) { + var _metasets$i2 = metasets[i], + index = _metasets$i2.index, + data = _metasets$i2.data; + var _binarySearch = binarySearch(metasets[i], axis, value, intersect), + lo = _binarySearch.lo, + hi = _binarySearch.hi; + for (var j = lo; j <= hi; ++j) { + var element = data[j]; + if (!element.skip) { + handler(element, index, j); + } + } + } +} +function getDistanceMetricForAxis(axis) { + var useX = axis.indexOf('x') !== -1; + var useY = axis.indexOf('y') !== -1; + return function (pt1, pt2) { + var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0; + var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0; + return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)); + }; +} +function getIntersectItems(chart, position, axis, useFinalPosition) { + var items = []; + if (!_isPointInArea(position, chart.chartArea)) { + return items; + } + var evaluationFunc = function evaluationFunc(element, datasetIndex, index) { + if (element.inRange(position.x, position.y, useFinalPosition)) { + items.push({ + element: element, + datasetIndex: datasetIndex, + index: index + }); + } + }; + optimizedEvaluateItems(chart, axis, position, evaluationFunc, true); + return items; +} +function getNearestItems(chart, position, axis, intersect, useFinalPosition) { + var distanceMetric = getDistanceMetricForAxis(axis); + var minDistance = Number.POSITIVE_INFINITY; + var items = []; + if (!_isPointInArea(position, chart.chartArea)) { + return items; + } + var evaluationFunc = function evaluationFunc(element, datasetIndex, index) { + if (intersect && !element.inRange(position.x, position.y, useFinalPosition)) { + return; + } + var center = element.getCenterPoint(useFinalPosition); + var distance = distanceMetric(position, center); + if (distance < minDistance) { + items = [{ + element: element, + datasetIndex: datasetIndex, + index: index + }]; + minDistance = distance; + } else if (distance === minDistance) { + items.push({ + element: element, + datasetIndex: datasetIndex, + index: index + }); + } + }; + optimizedEvaluateItems(chart, axis, position, evaluationFunc); + return items; +} +var Interaction = { + modes: { + index: function index(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var axis = options.axis || 'x'; + var items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition) : getNearestItems(chart, position, axis, false, useFinalPosition); + var elements = []; + if (!items.length) { + return []; + } + chart.getSortedVisibleDatasetMetas().forEach(function (meta) { + var index = items[0].index; + var element = meta.data[index]; + if (element && !element.skip) { + elements.push({ + element: element, + datasetIndex: meta.index, + index: index + }); + } + }); + return elements; + }, + dataset: function dataset(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var axis = options.axis || 'xy'; + var items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition) : getNearestItems(chart, position, axis, false, useFinalPosition); + if (items.length > 0) { + var datasetIndex = items[0].datasetIndex; + var data = chart.getDatasetMeta(datasetIndex).data; + items = []; + for (var i = 0; i < data.length; ++i) { + items.push({ + element: data[i], + datasetIndex: datasetIndex, + index: i + }); + } + } + return items; + }, + point: function point(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var axis = options.axis || 'xy'; + return getIntersectItems(chart, position, axis, useFinalPosition); + }, + nearest: function nearest(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var axis = options.axis || 'xy'; + return getNearestItems(chart, position, axis, options.intersect, useFinalPosition); + }, + x: function x(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var items = []; + var intersectsItem = false; + evaluateAllVisibleItems(chart, function (element, datasetIndex, index) { + if (element.inXRange(position.x, useFinalPosition)) { + items.push({ + element: element, + datasetIndex: datasetIndex, + index: index + }); + } + if (element.inRange(position.x, position.y, useFinalPosition)) { + intersectsItem = true; + } + }); + if (options.intersect && !intersectsItem) { + return []; + } + return items; + }, + y: function y(chart, e, options, useFinalPosition) { + var position = getRelativePosition$1(e, chart); + var items = []; + var intersectsItem = false; + evaluateAllVisibleItems(chart, function (element, datasetIndex, index) { + if (element.inYRange(position.y, useFinalPosition)) { + items.push({ + element: element, + datasetIndex: datasetIndex, + index: index + }); + } + if (element.inRange(position.x, position.y, useFinalPosition)) { + intersectsItem = true; + } + }); + if (options.intersect && !intersectsItem) { + return []; + } + return items; + } + } +}; + +var STATIC_POSITIONS = ['left', 'top', 'right', 'bottom']; +function filterByPosition(array, position) { + return array.filter(function (v) { + return v.pos === position; + }); +} +function filterDynamicPositionByAxis(array, axis) { + return array.filter(function (v) { + return STATIC_POSITIONS.indexOf(v.pos) === -1 && v.box.axis === axis; + }); +} +function sortByWeight(array, reverse) { + return array.sort(function (a, b) { + var v0 = reverse ? b : a; + var v1 = reverse ? a : b; + return v0.weight === v1.weight ? v0.index - v1.index : v0.weight - v1.weight; + }); +} +function wrapBoxes(boxes) { + var layoutBoxes = []; + var i, ilen, box; + for (i = 0, ilen = (boxes || []).length; i < ilen; ++i) { + box = boxes[i]; + layoutBoxes.push({ + index: i, + box: box, + pos: box.position, + horizontal: box.isHorizontal(), + weight: box.weight + }); + } + return layoutBoxes; +} +function setLayoutDims(layouts, params) { + var i, ilen, layout; + for (i = 0, ilen = layouts.length; i < ilen; ++i) { + layout = layouts[i]; + layout.width = layout.horizontal ? layout.box.fullWidth && params.availableWidth : params.vBoxMaxWidth; + layout.height = layout.horizontal && params.hBoxMaxHeight; + } +} +function buildLayoutBoxes(boxes) { + var layoutBoxes = wrapBoxes(boxes); + var left = sortByWeight(filterByPosition(layoutBoxes, 'left'), true); + var right = sortByWeight(filterByPosition(layoutBoxes, 'right')); + var top = sortByWeight(filterByPosition(layoutBoxes, 'top'), true); + var bottom = sortByWeight(filterByPosition(layoutBoxes, 'bottom')); + var centerHorizontal = filterDynamicPositionByAxis(layoutBoxes, 'x'); + var centerVertical = filterDynamicPositionByAxis(layoutBoxes, 'y'); + return { + leftAndTop: left.concat(top), + rightAndBottom: right.concat(centerVertical).concat(bottom).concat(centerHorizontal), + chartArea: filterByPosition(layoutBoxes, 'chartArea'), + vertical: left.concat(right).concat(centerVertical), + horizontal: top.concat(bottom).concat(centerHorizontal) + }; +} +function getCombinedMax(maxPadding, chartArea, a, b) { + return Math.max(maxPadding[a], chartArea[a]) + Math.max(maxPadding[b], chartArea[b]); +} +function updateDims(chartArea, params, layout) { + var box = layout.box; + var maxPadding = chartArea.maxPadding; + if (layout.size) { + chartArea[layout.pos] -= layout.size; + } + layout.size = layout.horizontal ? box.height : box.width; + chartArea[layout.pos] += layout.size; + if (box.getPadding) { + var boxPadding = box.getPadding(); + maxPadding.top = Math.max(maxPadding.top, boxPadding.top); + maxPadding.left = Math.max(maxPadding.left, boxPadding.left); + maxPadding.bottom = Math.max(maxPadding.bottom, boxPadding.bottom); + maxPadding.right = Math.max(maxPadding.right, boxPadding.right); + } + var newWidth = params.outerWidth - getCombinedMax(maxPadding, chartArea, 'left', 'right'); + var newHeight = params.outerHeight - getCombinedMax(maxPadding, chartArea, 'top', 'bottom'); + if (newWidth !== chartArea.w || newHeight !== chartArea.h) { + chartArea.w = newWidth; + chartArea.h = newHeight; + return layout.horizontal ? newWidth !== chartArea.w : newHeight !== chartArea.h; + } +} +function handleMaxPadding(chartArea) { + var maxPadding = chartArea.maxPadding; + function updatePos(pos) { + var change = Math.max(maxPadding[pos] - chartArea[pos], 0); + chartArea[pos] += change; + return change; + } + chartArea.y += updatePos('top'); + chartArea.x += updatePos('left'); + updatePos('right'); + updatePos('bottom'); +} +function getMargins(horizontal, chartArea) { + var maxPadding = chartArea.maxPadding; + function marginForPositions(positions) { + var margin = { + left: 0, + top: 0, + right: 0, + bottom: 0 + }; + positions.forEach(function (pos) { + margin[pos] = Math.max(chartArea[pos], maxPadding[pos]); + }); + return margin; + } + return horizontal ? marginForPositions(['left', 'right']) : marginForPositions(['top', 'bottom']); +} +function fitBoxes(boxes, chartArea, params) { + var refitBoxes = []; + var i, ilen, layout, box, refit, changed; + for (i = 0, ilen = boxes.length; i < ilen; ++i) { + layout = boxes[i]; + box = layout.box; + box.update(layout.width || chartArea.w, layout.height || chartArea.h, getMargins(layout.horizontal, chartArea)); + if (updateDims(chartArea, params, layout)) { + changed = true; + if (refitBoxes.length) { + refit = true; + } + } + if (!box.fullWidth) { + refitBoxes.push(layout); + } + } + return refit ? fitBoxes(refitBoxes, chartArea, params) || changed : changed; +} +function placeBoxes(boxes, chartArea, params) { + var userPadding = params.padding; + var x = chartArea.x; + var y = chartArea.y; + var i, ilen, layout, box; + for (i = 0, ilen = boxes.length; i < ilen; ++i) { + layout = boxes[i]; + box = layout.box; + if (layout.horizontal) { + box.left = box.fullWidth ? userPadding.left : chartArea.left; + box.right = box.fullWidth ? params.outerWidth - userPadding.right : chartArea.left + chartArea.w; + box.top = y; + box.bottom = y + box.height; + box.width = box.right - box.left; + y = box.bottom; + } else { + box.left = x; + box.right = x + box.width; + box.top = chartArea.top; + box.bottom = chartArea.top + chartArea.h; + box.height = box.bottom - box.top; + x = box.right; + } + } + chartArea.x = x; + chartArea.y = y; +} +defaults.set('layout', { + padding: { + top: 0, + right: 0, + bottom: 0, + left: 0 + } +}); +var layouts = { + addBox: function addBox(chart, item) { + if (!chart.boxes) { + chart.boxes = []; + } + item.fullWidth = item.fullWidth || false; + item.position = item.position || 'top'; + item.weight = item.weight || 0; + item._layers = item._layers || function () { + return [{ + z: 0, + draw: function draw(chartArea) { + item.draw(chartArea); + } + }]; + }; + chart.boxes.push(item); + }, + removeBox: function removeBox(chart, layoutItem) { + var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1; + if (index !== -1) { + chart.boxes.splice(index, 1); + } + }, + configure: function configure(chart, item, options) { + var props = ['fullWidth', 'position', 'weight']; + var ilen = props.length; + var i = 0; + var prop; + for (; i < ilen; ++i) { + prop = props[i]; + if (Object.prototype.hasOwnProperty.call(options, prop)) { + item[prop] = options[prop]; + } + } + }, + update: function update(chart, width, height) { + if (!chart) { + return; + } + var layoutOptions = chart.options.layout || {}; + var padding = toPadding(layoutOptions.padding); + var availableWidth = width - padding.width; + var availableHeight = height - padding.height; + var boxes = buildLayoutBoxes(chart.boxes); + var verticalBoxes = boxes.vertical; + var horizontalBoxes = boxes.horizontal; + var params = Object.freeze({ + outerWidth: width, + outerHeight: height, + padding: padding, + availableWidth: availableWidth, + vBoxMaxWidth: availableWidth / 2 / verticalBoxes.length, + hBoxMaxHeight: availableHeight / 2 + }); + var chartArea = _extends({ + maxPadding: _extends({}, padding), + w: availableWidth, + h: availableHeight, + x: padding.left, + y: padding.top + }, padding); + setLayoutDims(verticalBoxes.concat(horizontalBoxes), params); + fitBoxes(verticalBoxes, chartArea, params); + if (fitBoxes(horizontalBoxes, chartArea, params)) { + fitBoxes(verticalBoxes, chartArea, params); + } + handleMaxPadding(chartArea); + placeBoxes(boxes.leftAndTop, chartArea, params); + chartArea.x += chartArea.w; + chartArea.y += chartArea.h; + placeBoxes(boxes.rightAndBottom, chartArea, params); + chart.chartArea = { + left: chartArea.left, + top: chartArea.top, + right: chartArea.left + chartArea.w, + bottom: chartArea.top + chartArea.h, + height: chartArea.h, + width: chartArea.w + }; + each(boxes.chartArea, function (layout) { + var box = layout.box; + _extends(box, chart.chartArea); + box.update(chartArea.w, chartArea.h); + }); + } +}; + +var BasicPlatform = function (_BasePlatform) { + _inherits(BasicPlatform, _BasePlatform); + var _super = _createSuper(BasicPlatform); + function BasicPlatform() { + _classCallCheck(this, BasicPlatform); + return _super.apply(this, arguments); + } + _createClass(BasicPlatform, [{ + key: "acquireContext", + value: function acquireContext(item) { + return item && item.getContext && item.getContext('2d') || null; + } + }]); + return BasicPlatform; +}(BasePlatform); + +var platforms = { + BasicPlatform: BasicPlatform, + DomPlatform: DomPlatform, + BasePlatform: BasePlatform +}; + +defaults.set('plugins', {}); +var PluginService = function () { + function PluginService() { + _classCallCheck(this, PluginService); + this._plugins = []; + this._cacheId = 0; + } + _createClass(PluginService, [{ + key: "register", + value: function register(plugins) { + var p = this._plugins; + [].concat(plugins).forEach(function (plugin) { + if (p.indexOf(plugin) === -1) { + p.push(plugin); + } + }); + this._cacheId++; + } + }, { + key: "unregister", + value: function unregister(plugins) { + var p = this._plugins; + [].concat(plugins).forEach(function (plugin) { + var idx = p.indexOf(plugin); + if (idx !== -1) { + p.splice(idx, 1); + } + }); + this._cacheId++; + } + }, { + key: "clear", + value: function clear() { + this._plugins = []; + this._cacheId++; + } + }, { + key: "count", + value: function count() { + return this._plugins.length; + } + }, { + key: "getAll", + value: function getAll() { + return this._plugins; + } + }, { + key: "notify", + value: function notify(chart, hook, args) { + var descriptors = this._descriptors(chart); + var ilen = descriptors.length; + var i, descriptor, plugin, params, method; + for (i = 0; i < ilen; ++i) { + descriptor = descriptors[i]; + plugin = descriptor.plugin; + method = plugin[hook]; + if (typeof method === 'function') { + params = [chart].concat(args || []); + params.push(descriptor.options); + if (method.apply(plugin, params) === false) { + return false; + } + } + } + return true; + } + }, { + key: "_descriptors", + value: function _descriptors(chart) { + var cache = chart.$plugins || (chart.$plugins = {}); + if (cache.id === this._cacheId) { + return cache.descriptors; + } + var plugins = []; + var descriptors = []; + var config = chart && chart.config || {}; + var options = config.options && config.options.plugins || {}; + this._plugins.concat(config.plugins || []).forEach(function (plugin) { + var idx = plugins.indexOf(plugin); + if (idx !== -1) { + return; + } + var id = plugin.id; + var opts = options[id]; + if (opts === false) { + return; + } + if (opts === true) { + opts = clone(defaults.plugins[id]); + } + plugins.push(plugin); + descriptors.push({ + plugin: plugin, + options: opts || {} + }); + }); + cache.descriptors = descriptors; + cache.id = this._cacheId; + return descriptors; + } + }, { + key: "invalidate", + value: function invalidate(chart) { + delete chart.$plugins; + } + }]); + return PluginService; +}(); +var pluginsCore = new PluginService(); + +var scaleService = { + constructors: {}, + defaults: {}, + registerScale: function registerScale(scaleConstructor) { + var me = this; + var type = scaleConstructor.id; + me.constructors[type] = scaleConstructor; + me.defaults[type] = clone(scaleConstructor.defaults); + }, + getScaleConstructor: function getScaleConstructor(type) { + return Object.prototype.hasOwnProperty.call(this.constructors, type) ? this.constructors[type] : undefined; + }, + getScaleDefaults: function getScaleDefaults(type) { + return Object.prototype.hasOwnProperty.call(this.defaults, type) ? merge({}, [defaults.scale, this.defaults[type]]) : {}; + }, + updateScaleDefaults: function updateScaleDefaults(type, additions) { + var me = this; + if (Object.prototype.hasOwnProperty.call(me.defaults, type)) { + me.defaults[type] = _extends(me.defaults[type], additions); + } + }, + addScalesToLayout: function addScalesToLayout(chart) { + each(chart.scales, function (scale) { + scale.fullWidth = scale.options.fullWidth; + scale.position = scale.options.position; + scale.weight = scale.options.weight; + layouts.addBox(chart, scale); + }); + } +}; + +var version = "3.0.0-alpha"; + +var valueOrDefault$1 = helpers.valueOrDefault; +function mergeScaleConfig(config, options) { + options = options || {}; + var chartDefaults = defaults[config.type] || { + scales: {} + }; + var configScales = options.scales || {}; + var firstIDs = {}; + var scales = {}; + Object.keys(configScales).forEach(function (id) { + var axis = id[0]; + firstIDs[axis] = firstIDs[axis] || id; + scales[id] = helpers.mergeIf({}, [configScales[id], chartDefaults.scales[axis]]); + }); + if (options.scale) { + scales[options.scale.id || 'r'] = helpers.mergeIf({}, [options.scale, chartDefaults.scales.r]); + firstIDs.r = firstIDs.r || options.scale.id || 'r'; + } + config.data.datasets.forEach(function (dataset) { + var datasetDefaults = defaults[dataset.type || config.type] || { + scales: {} + }; + var defaultScaleOptions = datasetDefaults.scales || {}; + Object.keys(defaultScaleOptions).forEach(function (defaultID) { + var id = dataset[defaultID + 'AxisID'] || firstIDs[defaultID] || defaultID; + scales[id] = scales[id] || {}; + helpers.mergeIf(scales[id], [configScales[id], defaultScaleOptions[defaultID]]); + }); + }); + Object.keys(scales).forEach(function (key) { + var scale = scales[key]; + helpers.mergeIf(scale, scaleService.getScaleDefaults(scale.type)); + }); + return scales; +} +function mergeConfig() +{ + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + return helpers.merge({}, args, { + merger: function merger(key, target, source, options) { + if (key !== 'scales' && key !== 'scale') { + helpers._merger(key, target, source, options); + } + } + }); +} +function initConfig(config) { + config = config || {}; + var data = config.data = config.data || { + datasets: [], + labels: [] + }; + data.datasets = data.datasets || []; + data.labels = data.labels || []; + var scaleConfig = mergeScaleConfig(config, config.options); + config.options = mergeConfig(defaults, defaults[config.type], config.options || {}); + config.options.scales = scaleConfig; + return config; +} +function isAnimationDisabled(config) { + return !config.animation; +} +function updateConfig(chart) { + var newOptions = chart.options; + helpers.each(chart.scales, function (scale) { + layouts.removeBox(chart, scale); + }); + var scaleConfig = mergeScaleConfig(chart.config, newOptions); + newOptions = mergeConfig(defaults, defaults[chart.config.type], newOptions); + chart.options = chart.config.options = newOptions; + chart.options.scales = scaleConfig; + chart._animationsDisabled = isAnimationDisabled(newOptions); + chart.ensureScalesHaveIDs(); + chart.buildOrUpdateScales(); +} +var KNOWN_POSITIONS = new Set(['top', 'bottom', 'left', 'right', 'chartArea']); +function positionIsHorizontal(position, axis) { + return position === 'top' || position === 'bottom' || !KNOWN_POSITIONS.has(position) && axis === 'x'; +} +function compare2Level(l1, l2) { + return function (a, b) { + return a[l1] === b[l1] ? a[l2] - b[l2] : a[l1] - b[l1]; + }; +} +function onAnimationsComplete(ctx) { + var chart = ctx.chart; + var animationOptions = chart.options.animation; + pluginsCore.notify(chart, 'afterRender'); + helpers.callback(animationOptions && animationOptions.onComplete, [ctx], chart); +} +function onAnimationProgress(ctx) { + var chart = ctx.chart; + var animationOptions = chart.options.animation; + helpers.callback(animationOptions && animationOptions.onProgress, [ctx], chart); +} +function isDomSupported() { + return typeof window !== 'undefined' && typeof document !== 'undefined'; +} +function getCanvas(item) { + if (isDomSupported() && typeof item === 'string') { + item = document.getElementById(item); + } else if (item.length) { + item = item[0]; + } + if (item && item.canvas) { + item = item.canvas; + } + return item; +} +var Chart = function () { + function Chart(item, config) { + _classCallCheck(this, Chart); + var me = this; + config = initConfig(config); + var initialCanvas = getCanvas(item); + this.platform = me._initializePlatform(initialCanvas, config); + var context = me.platform.acquireContext(initialCanvas, config); + var canvas = context && context.canvas; + var height = canvas && canvas.height; + var width = canvas && canvas.width; + this.id = helpers.uid(); + this.ctx = context; + this.canvas = canvas; + this.config = config; + this.width = width; + this.height = height; + this.aspectRatio = height ? width / height : null; + this.options = config.options; + this._bufferedRender = false; + this._layers = []; + this._metasets = []; + this.boxes = []; + this.currentDevicePixelRatio = undefined; + this.chartArea = undefined; + this.data = undefined; + this.active = undefined; + this.lastActive = []; + this._lastEvent = undefined; + this._listeners = {}; + this._sortedMetasets = []; + this._updating = false; + this.scales = {}; + this.scale = undefined; + this.$plugins = undefined; + this.$proxies = {}; + this._hiddenIndices = {}; + Chart.instances[me.id] = me; + Object.defineProperty(me, 'data', { + get: function get() { + return me.config.data; + }, + set: function set(value) { + me.config.data = value; + } + }); + if (!context || !canvas) { + console.error("Failed to create chart: can't acquire context from the given item"); + return; + } + Animator$1.listen(me, 'complete', onAnimationsComplete); + Animator$1.listen(me, 'progress', onAnimationProgress); + me._initialize(); + me.update(); + } + _createClass(Chart, [{ + key: "_initialize", + value: function _initialize() { + var me = this; + pluginsCore.notify(me, 'beforeInit'); + if (me.options.responsive) { + me.resize(true); + } else { + helpers.dom.retinaScale(me, me.options.devicePixelRatio); + } + me.bindEvents(); + pluginsCore.notify(me, 'afterInit'); + return me; + } + }, { + key: "_initializePlatform", + value: function _initializePlatform(canvas, config) { + if (config.platform) { + return new config.platform(); + } else if (!isDomSupported() || typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) { + return new BasicPlatform(); + } + return new DomPlatform(); + } + }, { + key: "clear", + value: function clear() { + helpers.canvas.clear(this); + return this; + } + }, { + key: "stop", + value: function stop() { + Animator$1.stop(this); + return this; + } + }, { + key: "resize", + value: function resize(silent, width, height) { + var me = this; + var options = me.options; + var canvas = me.canvas; + var aspectRatio = options.maintainAspectRatio && me.aspectRatio; + if (width === undefined || height === undefined) { + width = getMaximumWidth(canvas); + height = getMaximumHeight(canvas); + } + var newWidth = Math.max(0, Math.floor(width)); + var newHeight = Math.max(0, Math.floor(aspectRatio ? newWidth / aspectRatio : height)); + var oldRatio = me.currentDevicePixelRatio; + var newRatio = options.devicePixelRatio || me.platform.getDevicePixelRatio(); + if (me.width === newWidth && me.height === newHeight && oldRatio === newRatio) { + return; + } + canvas.width = me.width = newWidth; + canvas.height = me.height = newHeight; + if (canvas.style) { + canvas.style.width = newWidth + 'px'; + canvas.style.height = newHeight + 'px'; + } + helpers.dom.retinaScale(me, newRatio); + if (!silent) { + var newSize = { + width: newWidth, + height: newHeight + }; + pluginsCore.notify(me, 'resize', [newSize]); + if (options.onResize) { + options.onResize(me, newSize); + } + me.update('resize'); + } + } + }, { + key: "ensureScalesHaveIDs", + value: function ensureScalesHaveIDs() { + var options = this.options; + var scalesOptions = options.scales || {}; + var scaleOptions = options.scale; + helpers.each(scalesOptions, function (axisOptions, axisID) { + axisOptions.id = axisID; + }); + if (scaleOptions) { + scaleOptions.id = scaleOptions.id || 'scale'; + } + } + }, { + key: "buildOrUpdateScales", + value: function buildOrUpdateScales() { + var me = this; + var options = me.options; + var scaleOpts = options.scales; + var scales = me.scales || {}; + var updated = Object.keys(scales).reduce(function (obj, id) { + obj[id] = false; + return obj; + }, {}); + var items = []; + if (scaleOpts) { + items = items.concat(Object.keys(scaleOpts).map(function (axisID) { + var axisOptions = scaleOpts[axisID]; + var isRadial = axisID.charAt(0).toLowerCase() === 'r'; + var isHorizontal = axisID.charAt(0).toLowerCase() === 'x'; + return { + options: axisOptions, + dposition: isRadial ? 'chartArea' : isHorizontal ? 'bottom' : 'left', + dtype: isRadial ? 'radialLinear' : isHorizontal ? 'category' : 'linear' + }; + })); + } + helpers.each(items, function (item) { + var scaleOptions = item.options; + var id = scaleOptions.id; + var scaleType = valueOrDefault$1(scaleOptions.type, item.dtype); + if (scaleOptions.position === undefined || positionIsHorizontal(scaleOptions.position, scaleOptions.axis || id[0]) !== positionIsHorizontal(item.dposition)) { + scaleOptions.position = item.dposition; + } + updated[id] = true; + var scale = null; + if (id in scales && scales[id].type === scaleType) { + scale = scales[id]; + scale.options = scaleOptions; + scale.ctx = me.ctx; + scale.chart = me; + } else { + var scaleClass = scaleService.getScaleConstructor(scaleType); + if (!scaleClass) { + return; + } + scale = new scaleClass({ + id: id, + type: scaleType, + options: scaleOptions, + ctx: me.ctx, + chart: me + }); + scales[scale.id] = scale; + } + scale.axis = scale.options.position === 'chartArea' ? 'r' : scale.isHorizontal() ? 'x' : 'y'; + scale._userMin = scale.parse(scale.options.min); + scale._userMax = scale.parse(scale.options.max); + if (item.isDefault) { + me.scale = scale; + } + }); + helpers.each(updated, function (hasUpdated, id) { + if (!hasUpdated) { + delete scales[id]; + } + }); + me.scales = scales; + scaleService.addScalesToLayout(this); + } + }, { + key: "_updateMetasetIndex", + value: function _updateMetasetIndex(meta, index) { + var metasets = this._metasets; + var oldIndex = meta.index; + if (oldIndex !== index) { + metasets[oldIndex] = metasets[index]; + metasets[index] = meta; + meta.index = index; + } + } + }, { + key: "_updateMetasets", + value: function _updateMetasets() { + var me = this; + var metasets = me._metasets; + var numData = me.data.datasets.length; + var numMeta = metasets.length; + if (numMeta > numData) { + for (var i = numData; i < numMeta; ++i) { + me._destroyDatasetMeta(i); + } + metasets.splice(numData, numMeta - numData); + } + me._sortedMetasets = metasets.slice(0).sort(compare2Level('order', 'index')); + } + }, { + key: "buildOrUpdateControllers", + value: function buildOrUpdateControllers() { + var me = this; + var newControllers = []; + var datasets = me.data.datasets; + var i, ilen; + for (i = 0, ilen = datasets.length; i < ilen; i++) { + var dataset = datasets[i]; + var meta = me.getDatasetMeta(i); + var type = dataset.type || me.config.type; + if (meta.type && meta.type !== type) { + me._destroyDatasetMeta(i); + meta = me.getDatasetMeta(i); + } + meta.type = type; + meta.order = dataset.order || 0; + me._updateMetasetIndex(meta, i); + meta.label = '' + dataset.label; + meta.visible = me.isDatasetVisible(i); + if (meta.controller) { + meta.controller.updateIndex(i); + meta.controller.linkScales(); + } else { + var ControllerClass = controllers[meta.type]; + if (ControllerClass === undefined) { + throw new Error('"' + meta.type + '" is not a chart type.'); + } + meta.controller = new ControllerClass(me, i); + newControllers.push(meta.controller); + } + } + me._updateMetasets(); + return newControllers; + } + }, { + key: "_resetElements", + value: function _resetElements() { + var me = this; + helpers.each(me.data.datasets, function (dataset, datasetIndex) { + me.getDatasetMeta(datasetIndex).controller.reset(); + }, me); + } + }, { + key: "reset", + value: function reset() { + this._resetElements(); + pluginsCore.notify(this, 'reset'); + } + }, { + key: "update", + value: function update(mode) { + var me = this; + var i, ilen; + me._updating = true; + updateConfig(me); + pluginsCore.invalidate(me); + if (pluginsCore.notify(me, 'beforeUpdate') === false) { + return; + } + var newControllers = me.buildOrUpdateControllers(); + for (i = 0, ilen = me.data.datasets.length; i < ilen; i++) { + me.getDatasetMeta(i).controller.buildOrUpdateElements(); + } + me._updateLayout(); + if (me.options.animation) { + helpers.each(newControllers, function (controller) { + controller.reset(); + }); + } + me._updateDatasets(mode); + pluginsCore.notify(me, 'afterUpdate'); + me._layers.sort(compare2Level('z', '_idx')); + if (me._lastEvent) { + me._eventHandler(me._lastEvent, true); + } + me.render(); + me._updating = false; + } + }, { + key: "_updateLayout", + value: function _updateLayout() { + var me = this; + if (pluginsCore.notify(me, 'beforeLayout') === false) { + return; + } + layouts.update(me, me.width, me.height); + me._layers = []; + helpers.each(me.boxes, function (box) { + var _me$_layers; + if (box.configure) { + box.configure(); + } + (_me$_layers = me._layers).push.apply(_me$_layers, _toConsumableArray(box._layers())); + }, me); + me._layers.forEach(function (item, index) { + item._idx = index; + }); + pluginsCore.notify(me, 'afterLayout'); + } + }, { + key: "_updateDatasets", + value: function _updateDatasets(mode) { + var me = this; + var isFunction = typeof mode === 'function'; + if (pluginsCore.notify(me, 'beforeDatasetsUpdate') === false) { + return; + } + for (var i = 0, ilen = me.data.datasets.length; i < ilen; ++i) { + me._updateDataset(i, isFunction ? mode({ + datasetIndex: i + }) : mode); + } + pluginsCore.notify(me, 'afterDatasetsUpdate'); + } + }, { + key: "_updateDataset", + value: function _updateDataset(index, mode) { + var me = this; + var meta = me.getDatasetMeta(index); + var args = { + meta: meta, + index: index, + mode: mode + }; + if (pluginsCore.notify(me, 'beforeDatasetUpdate', [args]) === false) { + return; + } + meta.controller._update(mode); + pluginsCore.notify(me, 'afterDatasetUpdate', [args]); + } + }, { + key: "render", + value: function render() { + var me = this; + var animationOptions = me.options.animation; + if (pluginsCore.notify(me, 'beforeRender') === false) { + return; + } + var onComplete = function onComplete() { + pluginsCore.notify(me, 'afterRender'); + helpers.callback(animationOptions && animationOptions.onComplete, [], me); + }; + if (Animator$1.has(me)) { + if (!Animator$1.running(me)) { + Animator$1.start(me); + } + } else { + me.draw(); + onComplete(); + } + } + }, { + key: "draw", + value: function draw() { + var me = this; + var i; + me.clear(); + if (me.width <= 0 || me.height <= 0) { + return; + } + if (pluginsCore.notify(me, 'beforeDraw') === false) { + return; + } + var layers = me._layers; + for (i = 0; i < layers.length && layers[i].z <= 0; ++i) { + layers[i].draw(me.chartArea); + } + me._drawDatasets(); + for (; i < layers.length; ++i) { + layers[i].draw(me.chartArea); + } + pluginsCore.notify(me, 'afterDraw'); + } + }, { + key: "_getSortedDatasetMetas", + value: function _getSortedDatasetMetas(filterVisible) { + var me = this; + var metasets = me._sortedMetasets; + var result = []; + var i, ilen; + for (i = 0, ilen = metasets.length; i < ilen; ++i) { + var meta = metasets[i]; + if (!filterVisible || meta.visible) { + result.push(meta); + } + } + return result; + } + }, { + key: "getSortedVisibleDatasetMetas", + value: function getSortedVisibleDatasetMetas() { + return this._getSortedDatasetMetas(true); + } + }, { + key: "_drawDatasets", + value: function _drawDatasets() { + var me = this; + if (pluginsCore.notify(me, 'beforeDatasetsDraw') === false) { + return; + } + var metasets = me.getSortedVisibleDatasetMetas(); + for (var i = metasets.length - 1; i >= 0; --i) { + me._drawDataset(metasets[i]); + } + pluginsCore.notify(me, 'afterDatasetsDraw'); + } + }, { + key: "_drawDataset", + value: function _drawDataset(meta) { + var me = this; + var ctx = me.ctx; + var clip = meta._clip; + var area = me.chartArea; + var args = { + meta: meta, + index: meta.index + }; + if (pluginsCore.notify(me, 'beforeDatasetDraw', [args]) === false) { + return; + } + helpers.canvas.clipArea(ctx, { + left: clip.left === false ? 0 : area.left - clip.left, + right: clip.right === false ? me.width : area.right + clip.right, + top: clip.top === false ? 0 : area.top - clip.top, + bottom: clip.bottom === false ? me.height : area.bottom + clip.bottom + }); + meta.controller.draw(); + helpers.canvas.unclipArea(ctx); + pluginsCore.notify(me, 'afterDatasetDraw', [args]); + } + }, { + key: "getElementAtEvent", + value: function getElementAtEvent(e) { + return Interaction.modes.nearest(this, e, { + intersect: true + }); + } + }, { + key: "getElementsAtEvent", + value: function getElementsAtEvent(e) { + return Interaction.modes.index(this, e, { + intersect: true + }); + } + }, { + key: "getElementsAtXAxis", + value: function getElementsAtXAxis(e) { + return Interaction.modes.index(this, e, { + intersect: false + }); + } + }, { + key: "getElementsAtEventForMode", + value: function getElementsAtEventForMode(e, mode, options, useFinalPosition) { + var method = Interaction.modes[mode]; + if (typeof method === 'function') { + return method(this, e, options, useFinalPosition); + } + return []; + } + }, { + key: "getDatasetAtEvent", + value: function getDatasetAtEvent(e) { + return Interaction.modes.dataset(this, e, { + intersect: true + }); + } + }, { + key: "getDatasetMeta", + value: function getDatasetMeta(datasetIndex) { + var me = this; + var dataset = me.data.datasets[datasetIndex]; + var metasets = me._metasets; + var meta = metasets.filter(function (x) { + return x._dataset === dataset; + }).pop(); + if (!meta) { + meta = metasets[datasetIndex] = { + type: null, + data: [], + dataset: null, + controller: null, + hidden: null, + xAxisID: null, + yAxisID: null, + order: dataset.order || 0, + index: datasetIndex, + _dataset: dataset, + _parsed: [], + _sorted: false + }; + } + return meta; + } + }, { + key: "getVisibleDatasetCount", + value: function getVisibleDatasetCount() { + return this.getSortedVisibleDatasetMetas().length; + } + }, { + key: "isDatasetVisible", + value: function isDatasetVisible(datasetIndex) { + var meta = this.getDatasetMeta(datasetIndex); + return typeof meta.hidden === 'boolean' ? !meta.hidden : !this.data.datasets[datasetIndex].hidden; + } + }, { + key: "setDatasetVisibility", + value: function setDatasetVisibility(datasetIndex, visible) { + var meta = this.getDatasetMeta(datasetIndex); + meta.hidden = !visible; + } + }, { + key: "toggleDataVisibility", + value: function toggleDataVisibility(index) { + this._hiddenIndices[index] = !this._hiddenIndices[index]; + } + }, { + key: "getDataVisibility", + value: function getDataVisibility(index) { + return !this._hiddenIndices[index]; + } + }, { + key: "_updateDatasetVisibility", + value: function _updateDatasetVisibility(datasetIndex, visible) { + var me = this; + var mode = visible ? 'show' : 'hide'; + var meta = me.getDatasetMeta(datasetIndex); + var anims = meta.controller._resolveAnimations(undefined, mode); + me.setDatasetVisibility(datasetIndex, visible); + anims.update(meta, { + visible: visible + }); + me.update(function (ctx) { + return ctx.datasetIndex === datasetIndex ? mode : undefined; + }); + } + }, { + key: "hide", + value: function hide(datasetIndex) { + this._updateDatasetVisibility(datasetIndex, false); + } + }, { + key: "show", + value: function show(datasetIndex) { + this._updateDatasetVisibility(datasetIndex, true); + } + }, { + key: "_destroyDatasetMeta", + value: function _destroyDatasetMeta(datasetIndex) { + var me = this; + var meta = me._metasets && me._metasets[datasetIndex]; + if (meta) { + meta.controller._destroy(); + delete me._metasets[datasetIndex]; + } + } + }, { + key: "destroy", + value: function destroy() { + var me = this; + var canvas = me.canvas; + var i, ilen; + me.stop(); + Animator$1.remove(me); + for (i = 0, ilen = me.data.datasets.length; i < ilen; ++i) { + me._destroyDatasetMeta(i); + } + if (canvas) { + me.unbindEvents(); + helpers.canvas.clear(me); + me.platform.releaseContext(me.ctx); + me.canvas = null; + me.ctx = null; + } + pluginsCore.notify(me, 'destroy'); + delete Chart.instances[me.id]; + } + }, { + key: "toBase64Image", + value: function toBase64Image() { + var _this$canvas; + return (_this$canvas = this.canvas).toDataURL.apply(_this$canvas, arguments); + } + }, { + key: "bindEvents", + value: function bindEvents() { + var me = this; + var listeners = me._listeners; + var listener = function listener(e) { + me._eventHandler(e); + }; + helpers.each(me.options.events, function (type) { + me.platform.addEventListener(me, type, listener); + listeners[type] = listener; + }); + if (me.options.responsive) { + listener = function listener(width, height) { + if (me.canvas) { + me.resize(false, width, height); + } + }; + me.platform.addEventListener(me, 'resize', listener); + listeners.resize = listener; + } + } + }, { + key: "unbindEvents", + value: function unbindEvents() { + var me = this; + var listeners = me._listeners; + if (!listeners) { + return; + } + delete me._listeners; + helpers.each(listeners, function (listener, type) { + me.platform.removeEventListener(me, type, listener); + }); + } + }, { + key: "updateHoverStyle", + value: function updateHoverStyle(items, mode, enabled) { + var prefix = enabled ? 'set' : 'remove'; + var meta, item, i, ilen; + if (mode === 'dataset') { + meta = this.getDatasetMeta(items[0].datasetIndex); + meta.controller['_' + prefix + 'DatasetHoverStyle'](); + } + for (i = 0, ilen = items.length; i < ilen; ++i) { + item = items[i]; + if (item) { + this.getDatasetMeta(item.datasetIndex).controller[prefix + 'HoverStyle'](item.element, item.datasetIndex, item.index); + } + } + } + }, { + key: "_updateHoverStyles", + value: function _updateHoverStyles() { + var me = this; + var options = me.options || {}; + var hoverOptions = options.hover; + if (me.lastActive.length) { + me.updateHoverStyle(me.lastActive, hoverOptions.mode, false); + } + if (me.active.length && hoverOptions.mode) { + me.updateHoverStyle(me.active, hoverOptions.mode, true); + } + } + }, { + key: "_eventHandler", + value: function _eventHandler(e, replay) { + var me = this; + if (pluginsCore.notify(me, 'beforeEvent', [e, replay]) === false) { + return; + } + me._handleEvent(e, replay); + pluginsCore.notify(me, 'afterEvent', [e, replay]); + me.render(); + return me; + } + }, { + key: "_handleEvent", + value: function _handleEvent(e, replay) { + var me = this; + var options = me.options; + var hoverOptions = options.hover; + var useFinalPosition = replay; + var changed = false; + if (e.type === 'mouseout') { + me.active = []; + me._lastEvent = null; + } else { + me.active = me.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions, useFinalPosition); + me._lastEvent = e.type === 'click' ? me._lastEvent : e; + } + helpers.callback(options.onHover || options.hover.onHover, [e["native"], me.active], me); + if (e.type === 'mouseup' || e.type === 'click') { + if (options.onClick && helpers.canvas._isPointInArea(e, me.chartArea)) { + options.onClick.call(me, e["native"], me.active); + } + } + changed = !helpers._elementsEqual(me.active, me.lastActive); + if (changed || replay) { + me._updateHoverStyles(); + } + me.lastActive = me.active; + return changed; + } + }]); + return Chart; +}(); +_defineProperty(Chart, "version", version); +_defineProperty(Chart, "instances", {}); + +function _abstract() { + throw new Error('This method is not implemented: either no adapter can be found or an incomplete integration was provided.'); +} +var DateAdapter = function () { + function DateAdapter(options) { + _classCallCheck(this, DateAdapter); + this.options = options || {}; + } + _createClass(DateAdapter, [{ + key: "formats", + value: function formats() { + return _abstract(); + } + }, { + key: "parse", + value: function parse(value, format) { + return _abstract(); + } + }, { + key: "format", + value: function format(timestamp, _format) { + return _abstract(); + } + }, { + key: "add", + value: function add(timestamp, amount, unit) { + return _abstract(); + } + }, { + key: "diff", + value: function diff(a, b, unit) { + return _abstract(); + } + }, { + key: "startOf", + value: function startOf(timestamp, unit, weekday) { + return _abstract(); + } + }, { + key: "endOf", + value: function endOf(timestamp, unit) { + return _abstract(); + } + }]); + return DateAdapter; +}(); +DateAdapter.override = function (members) { + _extends(DateAdapter.prototype, members); +}; +var _adapters = { + _date: DateAdapter +}; + +var formatters = { + values: function values(value) { + return isArray(value) ? value : '' + value; + }, + numeric: function numeric(tickValue, index, ticks) { + if (tickValue === 0) { + return '0'; + } + var delta = ticks.length > 3 ? ticks[2].value - ticks[1].value : ticks[1].value - ticks[0].value; + if (Math.abs(delta) > 1 && tickValue !== Math.floor(tickValue)) { + delta = tickValue - Math.floor(tickValue); + } + var logDelta = log10(Math.abs(delta)); + var maxTick = Math.max(Math.abs(ticks[0].value), Math.abs(ticks[ticks.length - 1].value)); + var minTick = Math.min(Math.abs(ticks[0].value), Math.abs(ticks[ticks.length - 1].value)); + var locale = this.chart.options.locale; + if (maxTick < 1e-4 || minTick > 1e+7) { + var logTick = log10(Math.abs(tickValue)); + var numExponential = Math.floor(logTick) - Math.floor(logDelta); + numExponential = Math.max(Math.min(numExponential, 20), 0); + return tickValue.toExponential(numExponential); + } + var numDecimal = -1 * Math.floor(logDelta); + numDecimal = Math.max(Math.min(numDecimal, 20), 0); + return new Intl.NumberFormat(locale, { + minimumFractionDigits: numDecimal, + maximumFractionDigits: numDecimal + }).format(tickValue); + } +}; +formatters.logarithmic = function (tickValue, index, ticks) { + if (tickValue === 0) { + return '0'; + } + var remain = tickValue / Math.pow(10, Math.floor(log10(tickValue))); + if (remain === 1 || remain === 2 || remain === 5) { + return formatters.numeric.call(this, tickValue, index, ticks); + } + return ''; +}; +var Ticks = { + formatters: formatters +}; + +defaults.set('scale', { + display: true, + offset: false, + reverse: false, + beginAtZero: false, + gridLines: { + display: true, + color: 'rgba(0,0,0,0.1)', + lineWidth: 1, + drawBorder: true, + drawOnChartArea: true, + drawTicks: true, + tickMarkLength: 10, + offsetGridLines: false, + borderDash: [], + borderDashOffset: 0.0 + }, + scaleLabel: { + display: false, + labelString: '', + padding: { + top: 4, + bottom: 4 + } + }, + ticks: { + minRotation: 0, + maxRotation: 50, + mirror: false, + lineWidth: 0, + strokeStyle: '', + padding: 0, + display: true, + autoSkip: true, + autoSkipPadding: 0, + labelOffset: 0, + callback: Ticks.formatters.values, + minor: {}, + major: {} + } +}); +function sample(arr, numItems) { + var result = []; + var increment = arr.length / numItems; + var len = arr.length; + var i = 0; + for (; i < len; i += increment) { + result.push(arr[Math.floor(i)]); + } + return result; +} +function getPixelForGridLine(scale, index, offsetGridLines) { + var length = scale.ticks.length; + var validIndex = Math.min(index, length - 1); + var start = scale._startPixel; + var end = scale._endPixel; + var epsilon = 1e-6; + var lineValue = scale.getPixelForTick(validIndex); + var offset; + if (offsetGridLines) { + if (length === 1) { + offset = Math.max(lineValue - start, end - lineValue); + } else if (index === 0) { + offset = (scale.getPixelForTick(1) - lineValue) / 2; + } else { + offset = (lineValue - scale.getPixelForTick(validIndex - 1)) / 2; + } + lineValue += validIndex < index ? offset : -offset; + if (lineValue < start - epsilon || lineValue > end + epsilon) { + return; + } + } + return lineValue; +} +function garbageCollect(caches, length) { + each(caches, function (cache) { + var gc = cache.gc; + var gcLen = gc.length / 2; + var i; + if (gcLen > length) { + for (i = 0; i < gcLen; ++i) { + delete cache.data[gc[i]]; + } + gc.splice(0, gcLen); + } + }); +} +function getTickMarkLength(options) { + return options.drawTicks ? options.tickMarkLength : 0; +} +function getScaleLabelHeight(options) { + if (!options.display) { + return 0; + } + var font = _parseFont(options); + var padding = toPadding(options.padding); + return font.lineHeight + padding.height; +} +function getEvenSpacing(arr) { + var len = arr.length; + var i, diff; + if (len < 2) { + return false; + } + for (diff = arr[0], i = 1; i < len; ++i) { + if (arr[i] - arr[i - 1] !== diff) { + return false; + } + } + return diff; +} +function calculateSpacing(majorIndices, ticks, ticksLimit) { + var evenMajorSpacing = getEvenSpacing(majorIndices); + var spacing = ticks.length / ticksLimit; + if (!evenMajorSpacing) { + return Math.max(spacing, 1); + } + var factors = _factorize(evenMajorSpacing); + for (var i = 0, ilen = factors.length - 1; i < ilen; i++) { + var factor = factors[i]; + if (factor > spacing) { + return factor; + } + } + return Math.max(spacing, 1); +} +function getMajorIndices(ticks) { + var result = []; + var i, ilen; + for (i = 0, ilen = ticks.length; i < ilen; i++) { + if (ticks[i].major) { + result.push(i); + } + } + return result; +} +function skipMajors(ticks, newTicks, majorIndices, spacing) { + var count = 0; + var next = majorIndices[0]; + var i; + spacing = Math.ceil(spacing); + for (i = 0; i < ticks.length; i++) { + if (i === next) { + newTicks.push(ticks[i]); + count++; + next = majorIndices[count * spacing]; + } + } +} +function skip(ticks, newTicks, spacing, majorStart, majorEnd) { + var start = valueOrDefault(majorStart, 0); + var end = Math.min(valueOrDefault(majorEnd, ticks.length), ticks.length); + var count = 0; + var length, i, next; + spacing = Math.ceil(spacing); + if (majorEnd) { + length = majorEnd - majorStart; + spacing = length / Math.floor(length / spacing); + } + next = start; + while (next < 0) { + count++; + next = Math.round(start + count * spacing); + } + for (i = Math.max(start, 0); i < end; i++) { + if (i === next) { + newTicks.push(ticks[i]); + count++; + next = Math.round(start + count * spacing); + } + } +} +var Scale = function (_Element) { + _inherits(Scale, _Element); + var _super = _createSuper(Scale); + function Scale(cfg) { + var _this; + _classCallCheck(this, Scale); + _this = _super.call(this); + _this.id = cfg.id; + _this.type = cfg.type; + _this.options = cfg.options; + _this.ctx = cfg.ctx; + _this.chart = cfg.chart; + _this.top = undefined; + _this.bottom = undefined; + _this.left = undefined; + _this.right = undefined; + _this.width = undefined; + _this.height = undefined; + _this._margins = { + left: 0, + right: 0, + top: 0, + bottom: 0 + }; + _this.maxWidth = undefined; + _this.maxHeight = undefined; + _this.paddingTop = undefined; + _this.paddingBottom = undefined; + _this.paddingLeft = undefined; + _this.paddingRight = undefined; + _this.axis = undefined; + _this.labelRotation = undefined; + _this.min = undefined; + _this.max = undefined; + _this.ticks = []; + _this._gridLineItems = null; + _this._labelItems = null; + _this._labelSizes = null; + _this._length = 0; + _this._longestTextCache = {}; + _this._startPixel = undefined; + _this._endPixel = undefined; + _this._reversePixels = false; + _this._userMax = undefined; + _this._userMin = undefined; + _this._ticksLength = 0; + _this._borderValue = 0; + return _this; + } + _createClass(Scale, [{ + key: "parse", + value: function parse(raw, index) { + return raw; + } + }, { + key: "parseObject", + value: function parseObject(obj, axis, index) { + if (obj[axis] !== undefined) { + return this.parse(obj[axis], index); + } + return null; + } + }, { + key: "getUserBounds", + value: function getUserBounds() { + var min = this._userMin; + var max = this._userMax; + if (isNullOrUndef(min) || isNaN(min)) { + min = Number.POSITIVE_INFINITY; + } + if (isNullOrUndef(max) || isNaN(max)) { + max = Number.NEGATIVE_INFINITY; + } + return { + min: min, + max: max, + minDefined: isNumberFinite(min), + maxDefined: isNumberFinite(max) + }; + } + }, { + key: "getMinMax", + value: function getMinMax(canStack) { + var me = this; + var _me$getUserBounds = me.getUserBounds(), + min = _me$getUserBounds.min, + max = _me$getUserBounds.max, + minDefined = _me$getUserBounds.minDefined, + maxDefined = _me$getUserBounds.maxDefined; + var minmax; + if (minDefined && maxDefined) { + return { + min: min, + max: max + }; + } + var metas = me.getMatchingVisibleMetas(); + for (var i = 0, ilen = metas.length; i < ilen; ++i) { + minmax = metas[i].controller.getMinMax(me, canStack); + if (!minDefined) { + min = Math.min(min, minmax.min); + } + if (!maxDefined) { + max = Math.max(max, minmax.max); + } + } + return { + min: min, + max: max + }; + } + }, { + key: "invalidateCaches", + value: function invalidateCaches() {} + }, { + key: "getPadding", + value: function getPadding() { + var me = this; + return { + left: me.paddingLeft || 0, + top: me.paddingTop || 0, + right: me.paddingRight || 0, + bottom: me.paddingBottom || 0 + }; + } + }, { + key: "getTicks", + value: function getTicks() { + return this.ticks; + } + }, { + key: "getLabels", + value: function getLabels() { + var data = this.chart.data; + return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels || []; + } + }, { + key: "beforeUpdate", + value: function beforeUpdate() { + callback(this.options.beforeUpdate, [this]); + } + }, { + key: "update", + value: function update(maxWidth, maxHeight, margins) { + var me = this; + var tickOpts = me.options.ticks; + var sampleSize = tickOpts.sampleSize; + me.beforeUpdate(); + me.maxWidth = maxWidth; + me.maxHeight = maxHeight; + me._margins = _extends({ + left: 0, + right: 0, + top: 0, + bottom: 0 + }, margins); + me.ticks = null; + me._labelSizes = null; + me._gridLineItems = null; + me._labelItems = null; + me.beforeSetDimensions(); + me.setDimensions(); + me.afterSetDimensions(); + me.beforeDataLimits(); + me.determineDataLimits(); + me.afterDataLimits(); + me.beforeBuildTicks(); + me.ticks = me.buildTicks() || []; + me.afterBuildTicks(); + var samplingEnabled = sampleSize < me.ticks.length; + me._convertTicksToLabels(samplingEnabled ? sample(me.ticks, sampleSize) : me.ticks); + me.configure(); + me.beforeCalculateLabelRotation(); + me.calculateLabelRotation(); + me.afterCalculateLabelRotation(); + me.beforeFit(); + me.fit(); + me.afterFit(); + me.ticks = tickOpts.display && (tickOpts.autoSkip || tickOpts.source === 'auto') ? me._autoSkip(me.ticks) : me.ticks; + if (samplingEnabled) { + me._convertTicksToLabels(me.ticks); + } + me.afterUpdate(); + } + }, { + key: "configure", + value: function configure() { + var me = this; + var reversePixels = me.options.reverse; + var startPixel, endPixel; + if (me.isHorizontal()) { + startPixel = me.left; + endPixel = me.right; + } else { + startPixel = me.top; + endPixel = me.bottom; + reversePixels = !reversePixels; + } + me._startPixel = startPixel; + me._endPixel = endPixel; + me._reversePixels = reversePixels; + me._length = endPixel - startPixel; + } + }, { + key: "afterUpdate", + value: function afterUpdate() { + callback(this.options.afterUpdate, [this]); + } + }, { + key: "beforeSetDimensions", + value: function beforeSetDimensions() { + callback(this.options.beforeSetDimensions, [this]); + } + }, { + key: "setDimensions", + value: function setDimensions() { + var me = this; + if (me.isHorizontal()) { + me.width = me.maxWidth; + me.left = 0; + me.right = me.width; + } else { + me.height = me.maxHeight; + me.top = 0; + me.bottom = me.height; + } + me.paddingLeft = 0; + me.paddingTop = 0; + me.paddingRight = 0; + me.paddingBottom = 0; + } + }, { + key: "afterSetDimensions", + value: function afterSetDimensions() { + callback(this.options.afterSetDimensions, [this]); + } + }, { + key: "beforeDataLimits", + value: function beforeDataLimits() { + callback(this.options.beforeDataLimits, [this]); + } + }, { + key: "determineDataLimits", + value: function determineDataLimits() {} + }, { + key: "afterDataLimits", + value: function afterDataLimits() { + callback(this.options.afterDataLimits, [this]); + } + }, { + key: "beforeBuildTicks", + value: function beforeBuildTicks() { + callback(this.options.beforeBuildTicks, [this]); + } + }, { + key: "buildTicks", + value: function buildTicks() { + return []; + } + }, { + key: "afterBuildTicks", + value: function afterBuildTicks() { + callback(this.options.afterBuildTicks, [this]); + } + }, { + key: "beforeTickToLabelConversion", + value: function beforeTickToLabelConversion() { + callback(this.options.beforeTickToLabelConversion, [this]); + } + }, { + key: "generateTickLabels", + value: function generateTickLabels(ticks) { + var me = this; + var tickOpts = me.options.ticks; + var i, ilen, tick; + for (i = 0, ilen = ticks.length; i < ilen; i++) { + tick = ticks[i]; + tick.label = callback(tickOpts.callback, [tick.value, i, ticks], me); + } + } + }, { + key: "afterTickToLabelConversion", + value: function afterTickToLabelConversion() { + callback(this.options.afterTickToLabelConversion, [this]); + } + }, { + key: "beforeCalculateLabelRotation", + value: function beforeCalculateLabelRotation() { + callback(this.options.beforeCalculateLabelRotation, [this]); + } + }, { + key: "calculateLabelRotation", + value: function calculateLabelRotation() { + var me = this; + var options = me.options; + var tickOpts = options.ticks; + var numTicks = me.ticks.length; + var minRotation = tickOpts.minRotation || 0; + var maxRotation = tickOpts.maxRotation; + var labelRotation = minRotation; + var tickWidth, maxHeight, maxLabelDiagonal; + if (!me._isVisible() || !tickOpts.display || minRotation >= maxRotation || numTicks <= 1 || !me.isHorizontal()) { + me.labelRotation = minRotation; + return; + } + var labelSizes = me._getLabelSizes(); + var maxLabelWidth = labelSizes.widest.width; + var maxLabelHeight = labelSizes.highest.height - labelSizes.highest.offset; + var maxWidth = Math.min(me.maxWidth, me.chart.width - maxLabelWidth); + tickWidth = options.offset ? me.maxWidth / numTicks : maxWidth / (numTicks - 1); + if (maxLabelWidth + 6 > tickWidth) { + tickWidth = maxWidth / (numTicks - (options.offset ? 0.5 : 1)); + maxHeight = me.maxHeight - getTickMarkLength(options.gridLines) - tickOpts.padding - getScaleLabelHeight(options.scaleLabel); + maxLabelDiagonal = Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight); + labelRotation = toDegrees(Math.min(Math.asin(Math.min((labelSizes.highest.height + 6) / tickWidth, 1)), Math.asin(Math.min(maxHeight / maxLabelDiagonal, 1)) - Math.asin(maxLabelHeight / maxLabelDiagonal))); + labelRotation = Math.max(minRotation, Math.min(maxRotation, labelRotation)); + } + me.labelRotation = labelRotation; + } + }, { + key: "afterCalculateLabelRotation", + value: function afterCalculateLabelRotation() { + callback(this.options.afterCalculateLabelRotation, [this]); + } + }, { + key: "beforeFit", + value: function beforeFit() { + callback(this.options.beforeFit, [this]); + } + }, { + key: "fit", + value: function fit() { + var me = this; + var minSize = { + width: 0, + height: 0 + }; + var chart = me.chart; + var opts = me.options; + var tickOpts = opts.ticks; + var scaleLabelOpts = opts.scaleLabel; + var gridLineOpts = opts.gridLines; + var display = me._isVisible(); + var labelsBelowTicks = opts.position !== 'top' && me.axis === 'x'; + var isHorizontal = me.isHorizontal(); + if (isHorizontal) { + minSize.width = me.maxWidth; + } else if (display) { + minSize.width = getTickMarkLength(gridLineOpts) + getScaleLabelHeight(scaleLabelOpts); + } + if (!isHorizontal) { + minSize.height = me.maxHeight; + } else if (display) { + minSize.height = getTickMarkLength(gridLineOpts) + getScaleLabelHeight(scaleLabelOpts); + } + if (tickOpts.display && display && me.ticks.length) { + var labelSizes = me._getLabelSizes(); + var firstLabelSize = labelSizes.first; + var lastLabelSize = labelSizes.last; + var widestLabelSize = labelSizes.widest; + var highestLabelSize = labelSizes.highest; + var lineSpace = highestLabelSize.offset * 0.8; + var tickPadding = tickOpts.padding; + if (isHorizontal) { + var isRotated = me.labelRotation !== 0; + var angleRadians = toRadians(me.labelRotation); + var cosRotation = Math.cos(angleRadians); + var sinRotation = Math.sin(angleRadians); + var labelHeight = sinRotation * widestLabelSize.width + cosRotation * (highestLabelSize.height - (isRotated ? highestLabelSize.offset : 0)) + (isRotated ? 0 : lineSpace); + minSize.height = Math.min(me.maxHeight, minSize.height + labelHeight + tickPadding); + var offsetLeft = me.getPixelForTick(0) - me.left; + var offsetRight = me.right - me.getPixelForTick(me.ticks.length - 1); + var paddingLeft, paddingRight; + if (isRotated) { + paddingLeft = labelsBelowTicks ? cosRotation * firstLabelSize.width + sinRotation * firstLabelSize.offset : sinRotation * (firstLabelSize.height - firstLabelSize.offset); + paddingRight = labelsBelowTicks ? sinRotation * (lastLabelSize.height - lastLabelSize.offset) : cosRotation * lastLabelSize.width + sinRotation * lastLabelSize.offset; + } else { + paddingLeft = firstLabelSize.width / 2; + paddingRight = lastLabelSize.width / 2; + } + me.paddingLeft = Math.max((paddingLeft - offsetLeft) * me.width / (me.width - offsetLeft), 0) + 3; + me.paddingRight = Math.max((paddingRight - offsetRight) * me.width / (me.width - offsetRight), 0) + 3; + } else { + var labelWidth = tickOpts.mirror ? 0 : + widestLabelSize.width + tickPadding + lineSpace; + minSize.width = Math.min(me.maxWidth, minSize.width + labelWidth); + me.paddingTop = firstLabelSize.height / 2; + me.paddingBottom = lastLabelSize.height / 2; + } + } + me._handleMargins(); + if (isHorizontal) { + me.width = me._length = chart.width - me._margins.left - me._margins.right; + me.height = minSize.height; + } else { + me.width = minSize.width; + me.height = me._length = chart.height - me._margins.top - me._margins.bottom; + } + } + }, { + key: "_handleMargins", + value: function _handleMargins() { + var me = this; + if (me._margins) { + me._margins.left = Math.max(me.paddingLeft, me._margins.left); + me._margins.top = Math.max(me.paddingTop, me._margins.top); + me._margins.right = Math.max(me.paddingRight, me._margins.right); + me._margins.bottom = Math.max(me.paddingBottom, me._margins.bottom); + } + } + }, { + key: "afterFit", + value: function afterFit() { + callback(this.options.afterFit, [this]); + } + }, { + key: "isHorizontal", + value: function isHorizontal() { + var _this$options = this.options, + axis = _this$options.axis, + position = _this$options.position; + return position === 'top' || position === 'bottom' || axis === 'x'; + } + }, { + key: "isFullWidth", + value: function isFullWidth() { + return this.options.fullWidth; + } + }, { + key: "_convertTicksToLabels", + value: function _convertTicksToLabels(ticks) { + var me = this; + me.beforeTickToLabelConversion(); + me.generateTickLabels(ticks); + me.afterTickToLabelConversion(); + } + }, { + key: "_getLabelSizes", + value: function _getLabelSizes() { + var me = this; + var labelSizes = me._labelSizes; + if (!labelSizes) { + me._labelSizes = labelSizes = me._computeLabelSizes(); + } + return labelSizes; + } + }, { + key: "_computeLabelSizes", + value: function _computeLabelSizes() { + var me = this; + var ctx = me.ctx; + var caches = me._longestTextCache; + var sampleSize = me.options.ticks.sampleSize; + var widths = []; + var heights = []; + var offsets = []; + var ticks = me.ticks; + if (sampleSize < ticks.length) { + ticks = sample(ticks, sampleSize); + } + var length = ticks.length; + var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, height, nestedLabel; + for (i = 0; i < length; ++i) { + label = ticks[i].label; + tickFont = me._resolveTickFontOptions(i); + ctx.font = fontString = tickFont.string; + cache = caches[fontString] = caches[fontString] || { + data: {}, + gc: [] + }; + lineHeight = tickFont.lineHeight; + width = height = 0; + if (!isNullOrUndef(label) && !isArray(label)) { + width = _measureText(ctx, cache.data, cache.gc, width, label); + height = lineHeight; + } else if (isArray(label)) { + for (j = 0, jlen = label.length; j < jlen; ++j) { + nestedLabel = label[j]; + if (!isNullOrUndef(nestedLabel) && !isArray(nestedLabel)) { + width = _measureText(ctx, cache.data, cache.gc, width, nestedLabel); + height += lineHeight; + } + } + } + widths.push(width); + heights.push(height); + offsets.push(lineHeight / 2); + } + garbageCollect(caches, length); + var widest = widths.indexOf(Math.max.apply(null, widths)); + var highest = heights.indexOf(Math.max.apply(null, heights)); + function valueAt(idx) { + return { + width: widths[idx] || 0, + height: heights[idx] || 0, + offset: offsets[idx] || 0 + }; + } + return { + first: valueAt(0), + last: valueAt(length - 1), + widest: valueAt(widest), + highest: valueAt(highest) + }; + } + }, { + key: "getLabelForValue", + value: function getLabelForValue(value) { + return value; + } + }, { + key: "getPixelForValue", + value: function getPixelForValue(value) { + return NaN; + } + }, { + key: "getValueForPixel", + value: function getValueForPixel(pixel) {} + }, { + key: "getPixelForTick", + value: function getPixelForTick(index) { + var ticks = this.ticks; + if (index < 0 || index > ticks.length - 1) { + return null; + } + return this.getPixelForValue(ticks[index].value); + } + }, { + key: "getPixelForDecimal", + value: function getPixelForDecimal(decimal) { + var me = this; + if (me._reversePixels) { + decimal = 1 - decimal; + } + return me._startPixel + decimal * me._length; + } + }, { + key: "getDecimalForPixel", + value: function getDecimalForPixel(pixel) { + var decimal = (pixel - this._startPixel) / this._length; + return this._reversePixels ? 1 - decimal : decimal; + } + }, { + key: "getBasePixel", + value: function getBasePixel() { + return this.getPixelForValue(this.getBaseValue()); + } + }, { + key: "getBaseValue", + value: function getBaseValue() { + var min = this.min, + max = this.max; + return min < 0 && max < 0 ? max : min > 0 && max > 0 ? min : 0; + } + }, { + key: "_autoSkip", + value: function _autoSkip(ticks) { + var me = this; + var tickOpts = me.options.ticks; + var ticksLimit = tickOpts.maxTicksLimit || me._length / me._tickSize(); + var majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : []; + var numMajorIndices = majorIndices.length; + var first = majorIndices[0]; + var last = majorIndices[numMajorIndices - 1]; + var newTicks = []; + if (numMajorIndices > ticksLimit) { + skipMajors(ticks, newTicks, majorIndices, numMajorIndices / ticksLimit); + return newTicks; + } + var spacing = calculateSpacing(majorIndices, ticks, ticksLimit); + if (numMajorIndices > 0) { + var i, ilen; + var avgMajorSpacing = numMajorIndices > 1 ? Math.round((last - first) / (numMajorIndices - 1)) : null; + skip(ticks, newTicks, spacing, isNullOrUndef(avgMajorSpacing) ? 0 : first - avgMajorSpacing, first); + for (i = 0, ilen = numMajorIndices - 1; i < ilen; i++) { + skip(ticks, newTicks, spacing, majorIndices[i], majorIndices[i + 1]); + } + skip(ticks, newTicks, spacing, last, isNullOrUndef(avgMajorSpacing) ? ticks.length : last + avgMajorSpacing); + return newTicks; + } + skip(ticks, newTicks, spacing); + return newTicks; + } + }, { + key: "_tickSize", + value: function _tickSize() { + var me = this; + var optionTicks = me.options.ticks; + var rot = toRadians(me.labelRotation); + var cos = Math.abs(Math.cos(rot)); + var sin = Math.abs(Math.sin(rot)); + var labelSizes = me._getLabelSizes(); + var padding = optionTicks.autoSkipPadding || 0; + var w = labelSizes ? labelSizes.widest.width + padding : 0; + var h = labelSizes ? labelSizes.highest.height + padding : 0; + return me.isHorizontal() ? h * cos > w * sin ? w / cos : h / sin : h * sin < w * cos ? h / cos : w / sin; + } + }, { + key: "_isVisible", + value: function _isVisible() { + var display = this.options.display; + if (display !== 'auto') { + return !!display; + } + return this.getMatchingVisibleMetas().length > 0; + } + }, { + key: "_computeGridLineItems", + value: function _computeGridLineItems(chartArea) { + var me = this; + var axis = me.axis; + var chart = me.chart; + var options = me.options; + var gridLines = options.gridLines, + position = options.position; + var offsetGridLines = gridLines.offsetGridLines; + var isHorizontal = me.isHorizontal(); + var ticks = me.ticks; + var ticksLength = ticks.length + (offsetGridLines ? 1 : 0); + var tl = getTickMarkLength(gridLines); + var items = []; + var context = { + scale: me, + tick: ticks[0] + }; + var axisWidth = gridLines.drawBorder ? resolve([gridLines.borderWidth, gridLines.lineWidth, 0], context, 0) : 0; + var axisHalfWidth = axisWidth / 2; + var alignBorderValue = function alignBorderValue(pixel) { + return _alignPixel(chart, pixel, axisWidth); + }; + var borderValue, i, lineValue, alignedLineValue; + var tx1, ty1, tx2, ty2, x1, y1, x2, y2; + if (position === 'top') { + borderValue = alignBorderValue(me.bottom); + ty1 = me.bottom - tl; + ty2 = borderValue - axisHalfWidth; + y1 = alignBorderValue(chartArea.top) + axisHalfWidth; + y2 = chartArea.bottom; + } else if (position === 'bottom') { + borderValue = alignBorderValue(me.top); + y1 = chartArea.top; + y2 = alignBorderValue(chartArea.bottom) - axisHalfWidth; + ty1 = borderValue + axisHalfWidth; + ty2 = me.top + tl; + } else if (position === 'left') { + borderValue = alignBorderValue(me.right); + tx1 = me.right - tl; + tx2 = borderValue - axisHalfWidth; + x1 = alignBorderValue(chartArea.left) + axisHalfWidth; + x2 = chartArea.right; + } else if (position === 'right') { + borderValue = alignBorderValue(me.left); + x1 = chartArea.left; + x2 = alignBorderValue(chartArea.right) - axisHalfWidth; + tx1 = borderValue + axisHalfWidth; + tx2 = me.left + tl; + } else if (axis === 'x') { + if (position === 'center') { + borderValue = alignBorderValue((chartArea.top + chartArea.bottom) / 2); + } else if (isObject(position)) { + var positionAxisID = Object.keys(position)[0]; + var value = position[positionAxisID]; + borderValue = alignBorderValue(me.chart.scales[positionAxisID].getPixelForValue(value)); + } + y1 = chartArea.top; + y2 = chartArea.bottom; + ty1 = borderValue + axisHalfWidth; + ty2 = ty1 + tl; + } else if (axis === 'y') { + if (position === 'center') { + borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2); + } else if (isObject(position)) { + var _positionAxisID = Object.keys(position)[0]; + var _value = position[_positionAxisID]; + borderValue = alignBorderValue(me.chart.scales[_positionAxisID].getPixelForValue(_value)); + } + tx1 = borderValue - axisHalfWidth; + tx2 = tx1 - tl; + x1 = chartArea.left; + x2 = chartArea.right; + } + for (i = 0; i < ticksLength; ++i) { + var tick = ticks[i] || {}; + context = { + scale: me, + tick: tick + }; + var lineWidth = resolve([gridLines.lineWidth], context, i); + var lineColor = resolve([gridLines.color], context, i); + var borderDash = gridLines.borderDash || []; + var borderDashOffset = resolve([gridLines.borderDashOffset], context, i); + lineValue = getPixelForGridLine(me, i, offsetGridLines); + if (lineValue === undefined) { + continue; + } + alignedLineValue = _alignPixel(chart, lineValue, lineWidth); + if (isHorizontal) { + tx1 = tx2 = x1 = x2 = alignedLineValue; + } else { + ty1 = ty2 = y1 = y2 = alignedLineValue; + } + items.push({ + tx1: tx1, + ty1: ty1, + tx2: tx2, + ty2: ty2, + x1: x1, + y1: y1, + x2: x2, + y2: y2, + width: lineWidth, + color: lineColor, + borderDash: borderDash, + borderDashOffset: borderDashOffset + }); + } + me._ticksLength = ticksLength; + me._borderValue = borderValue; + return items; + } + }, { + key: "_computeLabelItems", + value: function _computeLabelItems(chartArea) { + var me = this; + var axis = me.axis; + var options = me.options; + var position = options.position, + optionTicks = options.ticks; + var isMirrored = optionTicks.mirror; + var isHorizontal = me.isHorizontal(); + var ticks = me.ticks; + var tickPadding = optionTicks.padding; + var tl = getTickMarkLength(options.gridLines); + var rotation = -toRadians(me.labelRotation); + var items = []; + var i, ilen, tick, label, x, y, textAlign, pixel, font, lineHeight, lineCount, textOffset; + if (position === 'top') { + y = me.bottom - tl - tickPadding; + textAlign = !rotation ? 'center' : 'left'; + } else if (position === 'bottom') { + y = me.top + tl + tickPadding; + textAlign = !rotation ? 'center' : 'right'; + } else if (position === 'left') { + x = me.right - (isMirrored ? 0 : tl) - tickPadding; + textAlign = isMirrored ? 'left' : 'right'; + } else if (position === 'right') { + x = me.left + (isMirrored ? 0 : tl) + tickPadding; + textAlign = isMirrored ? 'right' : 'left'; + } else if (axis === 'x') { + if (position === 'center') { + y = (chartArea.top + chartArea.bottom) / 2 + tl + tickPadding; + } else if (isObject(position)) { + var positionAxisID = Object.keys(position)[0]; + var value = position[positionAxisID]; + y = me.chart.scales[positionAxisID].getPixelForValue(value) + tl + tickPadding; + } + textAlign = !rotation ? 'center' : 'right'; + } else if (axis === 'y') { + if (position === 'center') { + x = (chartArea.left + chartArea.right) / 2 - tl - tickPadding; + } else if (isObject(position)) { + var _positionAxisID2 = Object.keys(position)[0]; + var _value2 = position[_positionAxisID2]; + x = me.chart.scales[_positionAxisID2].getPixelForValue(_value2); + } + textAlign = 'right'; + } + for (i = 0, ilen = ticks.length; i < ilen; ++i) { + tick = ticks[i]; + label = tick.label; + pixel = me.getPixelForTick(i) + optionTicks.labelOffset; + font = me._resolveTickFontOptions(i); + lineHeight = font.lineHeight; + lineCount = isArray(label) ? label.length : 1; + if (isHorizontal) { + x = pixel; + if (position === 'top') { + textOffset = (Math.sin(rotation) * (lineCount / 2) + 0.5) * lineHeight; + textOffset -= (rotation === 0 ? lineCount - 0.5 : Math.cos(rotation) * (lineCount / 2)) * lineHeight; + } else { + textOffset = Math.sin(rotation) * (lineCount / 2) * lineHeight; + textOffset += (rotation === 0 ? 0.5 : Math.cos(rotation) * (lineCount / 2)) * lineHeight; + } + } else { + y = pixel; + textOffset = (1 - lineCount) * lineHeight / 2; + } + items.push({ + x: x, + y: y, + rotation: rotation, + label: label, + font: font, + textOffset: textOffset, + textAlign: textAlign + }); + } + return items; + } + }, { + key: "drawGrid", + value: function drawGrid(chartArea) { + var me = this; + var gridLines = me.options.gridLines; + var ctx = me.ctx; + var chart = me.chart; + var context = { + scale: me, + tick: me.ticks[0] + }; + var axisWidth = gridLines.drawBorder ? resolve([gridLines.borderWidth, gridLines.lineWidth, 0], context, 0) : 0; + var items = me._gridLineItems || (me._gridLineItems = me._computeGridLineItems(chartArea)); + var i, ilen; + if (gridLines.display) { + for (i = 0, ilen = items.length; i < ilen; ++i) { + var item = items[i]; + var width = item.width; + var color = item.color; + if (width && color) { + ctx.save(); + ctx.lineWidth = width; + ctx.strokeStyle = color; + if (ctx.setLineDash) { + ctx.setLineDash(item.borderDash); + ctx.lineDashOffset = item.borderDashOffset; + } + ctx.beginPath(); + if (gridLines.drawTicks) { + ctx.moveTo(item.tx1, item.ty1); + ctx.lineTo(item.tx2, item.ty2); + } + if (gridLines.drawOnChartArea) { + ctx.moveTo(item.x1, item.y1); + ctx.lineTo(item.x2, item.y2); + } + ctx.stroke(); + ctx.restore(); + } + } + } + if (axisWidth) { + var firstLineWidth = axisWidth; + context = { + scale: me, + tick: me.ticks[me._ticksLength - 1] + }; + var lastLineWidth = resolve([gridLines.lineWidth, 1], context, me._ticksLength - 1); + var borderValue = me._borderValue; + var x1, x2, y1, y2; + if (me.isHorizontal()) { + x1 = _alignPixel(chart, me.left, firstLineWidth) - firstLineWidth / 2; + x2 = _alignPixel(chart, me.right, lastLineWidth) + lastLineWidth / 2; + y1 = y2 = borderValue; + } else { + y1 = _alignPixel(chart, me.top, firstLineWidth) - firstLineWidth / 2; + y2 = _alignPixel(chart, me.bottom, lastLineWidth) + lastLineWidth / 2; + x1 = x2 = borderValue; + } + ctx.lineWidth = axisWidth; + ctx.strokeStyle = resolve([gridLines.borderColor, gridLines.color], context, 0); + ctx.beginPath(); + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.stroke(); + } + } + }, { + key: "drawLabels", + value: function drawLabels(chartArea) { + var me = this; + var optionTicks = me.options.ticks; + if (!optionTicks.display) { + return; + } + var ctx = me.ctx; + var items = me._labelItems || (me._labelItems = me._computeLabelItems(chartArea)); + var i, j, ilen, jlen; + for (i = 0, ilen = items.length; i < ilen; ++i) { + var item = items[i]; + var tickFont = item.font; + var useStroke = tickFont.lineWidth > 0 && tickFont.strokeStyle !== ''; + ctx.save(); + ctx.translate(item.x, item.y); + ctx.rotate(item.rotation); + ctx.font = tickFont.string; + ctx.fillStyle = tickFont.color; + ctx.textBaseline = 'middle'; + ctx.textAlign = item.textAlign; + if (useStroke) { + ctx.strokeStyle = tickFont.strokeStyle; + ctx.lineWidth = tickFont.lineWidth; + } + var label = item.label; + var y = item.textOffset; + if (isArray(label)) { + for (j = 0, jlen = label.length; j < jlen; ++j) { + if (useStroke) { + ctx.strokeText('' + label[j], 0, y); + } + ctx.fillText('' + label[j], 0, y); + y += tickFont.lineHeight; + } + } else { + if (useStroke) { + ctx.strokeText(label, 0, y); + } + ctx.fillText(label, 0, y); + } + ctx.restore(); + } + } + }, { + key: "drawTitle", + value: function drawTitle(chartArea) { + var me = this; + var ctx = me.ctx; + var options = me.options; + var scaleLabel = options.scaleLabel; + if (!scaleLabel.display) { + return; + } + var scaleLabelFontColor = valueOrDefault(scaleLabel.fontColor, defaults.fontColor); + var scaleLabelFont = _parseFont(scaleLabel); + var scaleLabelPadding = toPadding(scaleLabel.padding); + var halfLineHeight = scaleLabelFont.lineHeight / 2; + var scaleLabelAlign = scaleLabel.align; + var position = options.position; + var isReverse = me.options.reverse; + var rotation = 0; + var textAlign; + var scaleLabelX, scaleLabelY; + if (me.isHorizontal()) { + switch (scaleLabelAlign) { + case 'start': + scaleLabelX = me.left + (isReverse ? me.width : 0); + textAlign = isReverse ? 'right' : 'left'; + break; + case 'end': + scaleLabelX = me.left + (isReverse ? 0 : me.width); + textAlign = isReverse ? 'left' : 'right'; + break; + default: + scaleLabelX = me.left + me.width / 2; + textAlign = 'center'; + } + scaleLabelY = position === 'top' ? me.top + halfLineHeight + scaleLabelPadding.top : me.bottom - halfLineHeight - scaleLabelPadding.bottom; + } else { + var isLeft = position === 'left'; + scaleLabelX = isLeft ? me.left + halfLineHeight + scaleLabelPadding.top : me.right - halfLineHeight - scaleLabelPadding.top; + switch (scaleLabelAlign) { + case 'start': + scaleLabelY = me.top + (isReverse ? 0 : me.height); + textAlign = isReverse === isLeft ? 'right' : 'left'; + break; + case 'end': + scaleLabelY = me.top + (isReverse ? me.height : 0); + textAlign = isReverse === isLeft ? 'left' : 'right'; + break; + default: + scaleLabelY = me.top + me.height / 2; + textAlign = 'center'; + } + rotation = isLeft ? -0.5 * Math.PI : 0.5 * Math.PI; + } + ctx.save(); + ctx.translate(scaleLabelX, scaleLabelY); + ctx.rotate(rotation); + ctx.textAlign = textAlign; + ctx.textBaseline = 'middle'; + ctx.fillStyle = scaleLabelFontColor; + ctx.font = scaleLabelFont.string; + ctx.fillText(scaleLabel.labelString, 0, 0); + ctx.restore(); + } + }, { + key: "draw", + value: function draw(chartArea) { + var me = this; + if (!me._isVisible()) { + return; + } + me.drawGrid(chartArea); + me.drawTitle(); + me.drawLabels(chartArea); + } + }, { + key: "_layers", + value: function _layers() { + var me = this; + var opts = me.options; + var tz = opts.ticks && opts.ticks.z || 0; + var gz = opts.gridLines && opts.gridLines.z || 0; + if (!me._isVisible() || tz === gz || me.draw !== me._draw) { + return [{ + z: tz, + draw: function draw(chartArea) { + me.draw(chartArea); + } + }]; + } + return [{ + z: gz, + draw: function draw(chartArea) { + me.drawGrid(chartArea); + me.drawTitle(); + } + }, { + z: tz, + draw: function draw(chartArea) { + me.drawLabels(chartArea); + } + }]; + } + }, { + key: "getMatchingVisibleMetas", + value: function getMatchingVisibleMetas(type) { + var me = this; + var metas = me.chart.getSortedVisibleDatasetMetas(); + var axisID = me.axis + 'AxisID'; + var result = []; + var i, ilen; + for (i = 0, ilen = metas.length; i < ilen; ++i) { + var meta = metas[i]; + if (meta[axisID] === me.id && (!type || meta.type === type)) { + result.push(meta); + } + } + return result; + } + }, { + key: "_resolveTickFontOptions", + value: function _resolveTickFontOptions(index) { + var me = this; + var options = me.options.ticks; + var context = { + chart: me.chart, + scale: me, + tick: me.ticks[index], + index: index + }; + return _extends(_parseFont({ + fontFamily: resolve([options.fontFamily], context), + fontSize: resolve([options.fontSize], context), + fontStyle: resolve([options.fontStyle], context), + lineHeight: resolve([options.lineHeight], context) + }), { + color: resolve([options.fontColor, defaults.fontColor], context), + lineWidth: resolve([options.lineWidth], context), + strokeStyle: resolve([options.strokeStyle], context) + }); + } + }]); + return Scale; +}(Element$1); +Scale.prototype._draw = Scale.prototype.draw; + +var defaultConfig = {}; +var CategoryScale = function (_Scale) { + _inherits(CategoryScale, _Scale); + var _super = _createSuper(CategoryScale); + function CategoryScale(cfg) { + var _this; + _classCallCheck(this, CategoryScale); + _this = _super.call(this, cfg); + _this._numLabels = 0; + _this._startValue = undefined; + _this._valueRange = 0; + return _this; + } + _createClass(CategoryScale, [{ + key: "parse", + value: function parse(raw, index) { + var labels = this.getLabels(); + if (labels[index] === raw) { + return index; + } + var first = labels.indexOf(raw); + var last = labels.lastIndexOf(raw); + return first === -1 || first !== last ? index : first; + } + }, { + key: "determineDataLimits", + value: function determineDataLimits() { + var me = this; + var max = me.getLabels().length - 1; + me.min = Math.max(me._userMin || 0, 0); + me.max = Math.min(me._userMax || max, max); + } + }, { + key: "buildTicks", + value: function buildTicks() { + var me = this; + var min = me.min; + var max = me.max; + var offset = me.options.offset; + var labels = me.getLabels(); + labels = min === 0 && max === labels.length - 1 ? labels : labels.slice(min, max + 1); + me._numLabels = labels.length; + me._valueRange = Math.max(labels.length - (offset ? 0 : 1), 1); + me._startValue = me.min - (offset ? 0.5 : 0); + return labels.map(function (l) { + return { + value: l + }; + }); + } + }, { + key: "getLabelForValue", + value: function getLabelForValue(value) { + var me = this; + var labels = me.getLabels(); + if (value >= 0 && value < labels.length) { + return labels[value]; + } + return value; + } + }, { + key: "configure", + value: function configure() { + var me = this; + _get(_getPrototypeOf(CategoryScale.prototype), "configure", this).call(this); + if (!me.isHorizontal()) { + me._reversePixels = !me._reversePixels; + } + } + }, { + key: "getPixelForValue", + value: function getPixelForValue(value) { + var me = this; + if (typeof value !== 'number') { + value = me.parse(value); + } + return me.getPixelForDecimal((value - me._startValue) / me._valueRange); + } + }, { + key: "getPixelForTick", + value: function getPixelForTick(index) { + var me = this; + var ticks = me.ticks; + if (index < 0 || index > ticks.length - 1) { + return null; + } + return me.getPixelForValue(index * me._numLabels / ticks.length + me.min); + } + }, { + key: "getValueForPixel", + value: function getValueForPixel(pixel) { + var me = this; + var value = Math.round(me._startValue + me.getDecimalForPixel(pixel) * me._valueRange); + return Math.min(Math.max(value, 0), me.ticks.length - 1); + } + }, { + key: "getBasePixel", + value: function getBasePixel() { + return this.bottom; + } + }]); + return CategoryScale; +}(Scale); +_defineProperty(CategoryScale, "id", 'category'); +_defineProperty(CategoryScale, "defaults", defaultConfig); + +function niceNum(range, round) { + var exponent = Math.floor(log10(range)); + var fraction = range / Math.pow(10, exponent); + var niceFraction; + if (round) { + if (fraction < 1.5) { + niceFraction = 1; + } else if (fraction < 3) { + niceFraction = 2; + } else if (fraction < 7) { + niceFraction = 5; + } else { + niceFraction = 10; + } + } else if (fraction <= 1.0) { + niceFraction = 1; + } else if (fraction <= 2) { + niceFraction = 2; + } else if (fraction <= 5) { + niceFraction = 5; + } else { + niceFraction = 10; + } + return niceFraction * Math.pow(10, exponent); +} +function generateTicks(generationOptions, dataRange) { + var ticks = []; + var MIN_SPACING = 1e-14; + var stepSize = generationOptions.stepSize, + min = generationOptions.min, + max = generationOptions.max, + precision = generationOptions.precision; + var unit = stepSize || 1; + var maxNumSpaces = generationOptions.maxTicks - 1; + var rmin = dataRange.min, + rmax = dataRange.max; + var spacing = niceNum((rmax - rmin) / maxNumSpaces / unit) * unit; + var factor, niceMin, niceMax, numSpaces; + if (spacing < MIN_SPACING && isNullOrUndef(min) && isNullOrUndef(max)) { + return [{ + value: rmin + }, { + value: rmax + }]; + } + numSpaces = Math.ceil(rmax / spacing) - Math.floor(rmin / spacing); + if (numSpaces > maxNumSpaces) { + spacing = niceNum(numSpaces * spacing / maxNumSpaces / unit) * unit; + } + if (stepSize || isNullOrUndef(precision)) { + factor = Math.pow(10, _decimalPlaces(spacing)); + } else { + factor = Math.pow(10, precision); + spacing = Math.ceil(spacing * factor) / factor; + } + niceMin = Math.floor(rmin / spacing) * spacing; + niceMax = Math.ceil(rmax / spacing) * spacing; + if (stepSize && !isNullOrUndef(min) && !isNullOrUndef(max)) { + if (almostWhole((max - min) / stepSize, spacing / 1000)) { + niceMin = min; + niceMax = max; + } + } + numSpaces = (niceMax - niceMin) / spacing; + if (almostEquals(numSpaces, Math.round(numSpaces), spacing / 1000)) { + numSpaces = Math.round(numSpaces); + } else { + numSpaces = Math.ceil(numSpaces); + } + niceMin = Math.round(niceMin * factor) / factor; + niceMax = Math.round(niceMax * factor) / factor; + ticks.push({ + value: isNullOrUndef(min) ? niceMin : min + }); + for (var j = 1; j < numSpaces; ++j) { + ticks.push({ + value: Math.round((niceMin + j * spacing) * factor) / factor + }); + } + ticks.push({ + value: isNullOrUndef(max) ? niceMax : max + }); + return ticks; +} +var LinearScaleBase = function (_Scale) { + _inherits(LinearScaleBase, _Scale); + var _super = _createSuper(LinearScaleBase); + function LinearScaleBase(cfg) { + var _this; + _classCallCheck(this, LinearScaleBase); + _this = _super.call(this, cfg); + _this.start = undefined; + _this.end = undefined; + _this._startValue = undefined; + _this._endValue = undefined; + _this._valueRange = 0; + return _this; + } + _createClass(LinearScaleBase, [{ + key: "parse", + value: function parse(raw, index) { + if (isNullOrUndef(raw)) { + return NaN; + } + if ((typeof raw === 'number' || raw instanceof Number) && !isFinite(+raw)) { + return NaN; + } + return +raw; + } + }, { + key: "handleTickRangeOptions", + value: function handleTickRangeOptions() { + var me = this; + var opts = me.options; + if (opts.beginAtZero) { + var minSign = sign(me.min); + var maxSign = sign(me.max); + if (minSign < 0 && maxSign < 0) { + me.max = 0; + } else if (minSign > 0 && maxSign > 0) { + me.min = 0; + } + } + var setMin = opts.min !== undefined || opts.suggestedMin !== undefined; + var setMax = opts.max !== undefined || opts.suggestedMax !== undefined; + if (opts.min !== undefined) { + me.min = opts.min; + } else if (opts.suggestedMin !== undefined) { + if (me.min === null) { + me.min = opts.suggestedMin; + } else { + me.min = Math.min(me.min, opts.suggestedMin); + } + } + if (opts.max !== undefined) { + me.max = opts.max; + } else if (opts.suggestedMax !== undefined) { + if (me.max === null) { + me.max = opts.suggestedMax; + } else { + me.max = Math.max(me.max, opts.suggestedMax); + } + } + if (setMin !== setMax) { + if (me.min >= me.max) { + if (setMin) { + me.max = me.min + 1; + } else { + me.min = me.max - 1; + } + } + } + if (me.min === me.max) { + me.max++; + if (!opts.beginAtZero) { + me.min--; + } + } + } + }, { + key: "getTickLimit", + value: function getTickLimit() { + var me = this; + var tickOpts = me.options.ticks; + var maxTicksLimit = tickOpts.maxTicksLimit, + stepSize = tickOpts.stepSize; + var maxTicks; + if (stepSize) { + maxTicks = Math.ceil(me.max / stepSize) - Math.floor(me.min / stepSize) + 1; + } else { + maxTicks = me.computeTickLimit(); + maxTicksLimit = maxTicksLimit || 11; + } + if (maxTicksLimit) { + maxTicks = Math.min(maxTicksLimit, maxTicks); + } + return maxTicks; + } + }, { + key: "computeTickLimit", + value: function computeTickLimit() { + return Number.POSITIVE_INFINITY; + } + }, { + key: "handleDirectionalChanges", + value: function handleDirectionalChanges(ticks) { + return ticks; + } + }, { + key: "buildTicks", + value: function buildTicks() { + var me = this; + var opts = me.options; + var tickOpts = opts.ticks; + var maxTicks = me.getTickLimit(); + maxTicks = Math.max(2, maxTicks); + var numericGeneratorOptions = { + maxTicks: maxTicks, + min: opts.min, + max: opts.max, + precision: tickOpts.precision, + stepSize: valueOrDefault(tickOpts.fixedStepSize, tickOpts.stepSize) + }; + var ticks = generateTicks(numericGeneratorOptions, me); + ticks = me.handleDirectionalChanges(ticks); + _setMinAndMaxByKey(ticks, me, 'value'); + if (opts.reverse) { + ticks.reverse(); + me.start = me.max; + me.end = me.min; + } else { + me.start = me.min; + me.end = me.max; + } + return ticks; + } + }, { + key: "configure", + value: function configure() { + var me = this; + var ticks = me.ticks; + var start = me.min; + var end = me.max; + _get(_getPrototypeOf(LinearScaleBase.prototype), "configure", this).call(this); + if (me.options.offset && ticks.length) { + var offset = (end - start) / Math.max(ticks.length - 1, 1) / 2; + start -= offset; + end += offset; + } + me._startValue = start; + me._endValue = end; + me._valueRange = end - start; + } + }, { + key: "getLabelForValue", + value: function getLabelForValue(value) { + return new Intl.NumberFormat(this.options.locale).format(value); + } + }]); + return LinearScaleBase; +}(Scale); + +var defaultConfig$1 = { + ticks: { + callback: Ticks.formatters.numeric + } +}; +var LinearScale = function (_LinearScaleBase) { + _inherits(LinearScale, _LinearScaleBase); + var _super = _createSuper(LinearScale); + function LinearScale() { + _classCallCheck(this, LinearScale); + return _super.apply(this, arguments); + } + _createClass(LinearScale, [{ + key: "determineDataLimits", + value: function determineDataLimits() { + var me = this; + var options = me.options; + var minmax = me.getMinMax(true); + var min = minmax.min; + var max = minmax.max; + me.min = isNumberFinite(min) ? min : valueOrDefault(options.suggestedMin, 0); + me.max = isNumberFinite(max) ? max : valueOrDefault(options.suggestedMax, 1); + if (options.stacked && min > 0) { + me.min = 0; + } + me.handleTickRangeOptions(); + } + }, { + key: "computeTickLimit", + value: function computeTickLimit() { + var me = this; + if (me.isHorizontal()) { + return Math.ceil(me.width / 40); + } + var tickFont = _parseFont(me.options.ticks); + return Math.ceil(me.height / tickFont.lineHeight); + } + }, { + key: "handleDirectionalChanges", + value: function handleDirectionalChanges(ticks) { + return this.isHorizontal() ? ticks : ticks.reverse(); + } + }, { + key: "getPixelForValue", + value: function getPixelForValue(value) { + var me = this; + return me.getPixelForDecimal((value - me._startValue) / me._valueRange); + } + }, { + key: "getValueForPixel", + value: function getValueForPixel(pixel) { + return this._startValue + this.getDecimalForPixel(pixel) * this._valueRange; + } + }]); + return LinearScale; +}(LinearScaleBase); +_defineProperty(LinearScale, "id", 'linear'); +_defineProperty(LinearScale, "defaults", defaultConfig$1); + +function isMajor(tickVal) { + var remain = tickVal / Math.pow(10, Math.floor(log10(tickVal))); + return remain === 1; +} +function finiteOrDefault(value, def) { + return isNumberFinite(value) ? value : def; +} +function generateTicks$1(generationOptions, dataRange) { + var endExp = Math.floor(log10(dataRange.max)); + var endSignificand = Math.ceil(dataRange.max / Math.pow(10, endExp)); + var ticks = []; + var tickVal = finiteOrDefault(generationOptions.min, Math.pow(10, Math.floor(log10(dataRange.min)))); + var exp = Math.floor(log10(tickVal)); + var significand = Math.floor(tickVal / Math.pow(10, exp)); + var precision = exp < 0 ? Math.pow(10, Math.abs(exp)) : 1; + do { + ticks.push({ + value: tickVal, + major: isMajor(tickVal) + }); + ++significand; + if (significand === 10) { + significand = 1; + ++exp; + precision = exp >= 0 ? 1 : precision; + } + tickVal = Math.round(significand * Math.pow(10, exp) * precision) / precision; + } while (exp < endExp || exp === endExp && significand < endSignificand); + var lastTick = finiteOrDefault(generationOptions.max, tickVal); + ticks.push({ + value: lastTick, + major: isMajor(tickVal) + }); + return ticks; +} +var defaultConfig$2 = { + ticks: { + callback: Ticks.formatters.logarithmic, + major: { + enabled: true + } + } +}; +var LogarithmicScale = function (_Scale) { + _inherits(LogarithmicScale, _Scale); + var _super = _createSuper(LogarithmicScale); + function LogarithmicScale(cfg) { + var _this; + _classCallCheck(this, LogarithmicScale); + _this = _super.call(this, cfg); + _this.start = undefined; + _this.end = undefined; + _this._startValue = undefined; + _this._valueRange = 0; + return _this; + } + _createClass(LogarithmicScale, [{ + key: "parse", + value: function parse(raw, index) { + var value = LinearScaleBase.prototype.parse.apply(this, [raw, index]); + if (value === 0) { + return undefined; + } + return isNumberFinite(value) && value > 0 ? value : NaN; + } + }, { + key: "determineDataLimits", + value: function determineDataLimits() { + var me = this; + var minmax = me.getMinMax(true); + var min = minmax.min; + var max = minmax.max; + me.min = isNumberFinite(min) ? Math.max(0, min) : null; + me.max = isNumberFinite(max) ? Math.max(0, max) : null; + me.handleTickRangeOptions(); + } + }, { + key: "handleTickRangeOptions", + value: function handleTickRangeOptions() { + var me = this; + var DEFAULT_MIN = 1; + var DEFAULT_MAX = 10; + var min = me.min; + var max = me.max; + if (min === max) { + if (min <= 0) { + min = DEFAULT_MIN; + max = DEFAULT_MAX; + } else { + min = Math.pow(10, Math.floor(log10(min)) - 1); + max = Math.pow(10, Math.floor(log10(max)) + 1); + } + } + if (min <= 0) { + min = Math.pow(10, Math.floor(log10(max)) - 1); + } + if (max <= 0) { + max = Math.pow(10, Math.floor(log10(min)) + 1); + } + me.min = min; + me.max = max; + } + }, { + key: "buildTicks", + value: function buildTicks() { + var me = this; + var opts = me.options; + var generationOptions = { + min: me._userMin, + max: me._userMax + }; + var ticks = generateTicks$1(generationOptions, me); + var reverse = !me.isHorizontal(); + _setMinAndMaxByKey(ticks, me, 'value'); + if (opts.reverse) { + reverse = !reverse; + me.start = me.max; + me.end = me.min; + } else { + me.start = me.min; + me.end = me.max; + } + if (reverse) { + ticks.reverse(); + } + return ticks; + } + }, { + key: "getLabelForValue", + value: function getLabelForValue(value) { + return value === undefined ? '0' : new Intl.NumberFormat(this.options.locale).format(value); + } + }, { + key: "configure", + value: function configure() { + var me = this; + var start = me.min; + _get(_getPrototypeOf(LogarithmicScale.prototype), "configure", this).call(this); + me._startValue = log10(start); + me._valueRange = log10(me.max) - log10(start); + } + }, { + key: "getPixelForValue", + value: function getPixelForValue(value) { + var me = this; + if (value === undefined || value === 0) { + value = me.min; + } + return me.getPixelForDecimal(value === me.min ? 0 : (log10(value) - me._startValue) / me._valueRange); + } + }, { + key: "getValueForPixel", + value: function getValueForPixel(pixel) { + var me = this; + var decimal = me.getDecimalForPixel(pixel); + return Math.pow(10, me._startValue + decimal * me._valueRange); + } + }]); + return LogarithmicScale; +}(Scale); +_defineProperty(LogarithmicScale, "id", 'logarithmic'); +_defineProperty(LogarithmicScale, "defaults", defaultConfig$2); + +var valueOrDefault$2 = helpers.valueOrDefault; +var valueAtIndexOrDefault$1 = helpers.valueAtIndexOrDefault; +var resolve$2 = helpers.options.resolve; +var defaultConfig$3 = { + display: true, + animate: true, + position: 'chartArea', + angleLines: { + display: true, + color: 'rgba(0,0,0,0.1)', + lineWidth: 1, + borderDash: [], + borderDashOffset: 0.0 + }, + gridLines: { + circular: false + }, + ticks: { + showLabelBackdrop: true, + backdropColor: 'rgba(255,255,255,0.75)', + backdropPaddingY: 2, + backdropPaddingX: 2, + callback: Ticks.formatters.numeric + }, + pointLabels: { + display: true, + fontSize: 10, + callback: function callback(label) { + return label; + } + } +}; +function getTickBackdropHeight(opts) { + var tickOpts = opts.ticks; + if (tickOpts.display && opts.display) { + return valueOrDefault$2(tickOpts.fontSize, defaults.fontSize) + tickOpts.backdropPaddingY * 2; + } + return 0; +} +function measureLabelSize(ctx, lineHeight, label) { + if (helpers.isArray(label)) { + return { + w: _longestText(ctx, ctx.font, label), + h: label.length * lineHeight + }; + } + return { + w: ctx.measureText(label).width, + h: lineHeight + }; +} +function determineLimits(angle, pos, size, min, max) { + if (angle === min || angle === max) { + return { + start: pos - size / 2, + end: pos + size / 2 + }; + } else if (angle < min || angle > max) { + return { + start: pos - size, + end: pos + }; + } + return { + start: pos, + end: pos + size + }; +} +function fitWithPointLabels(scale) { + var plFont = helpers.options._parseFont(scale.options.pointLabels); + var furthestLimits = { + l: 0, + r: scale.width, + t: 0, + b: scale.height - scale.paddingTop + }; + var furthestAngles = {}; + var i, textSize, pointPosition; + scale.ctx.font = plFont.string; + scale._pointLabelSizes = []; + var valueCount = scale.chart.data.labels.length; + for (i = 0; i < valueCount; i++) { + pointPosition = scale.getPointPosition(i, scale.drawingArea + 5); + textSize = measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointLabels[i]); + scale._pointLabelSizes[i] = textSize; + var angleRadians = scale.getIndexAngle(i); + var angle = toDegrees(angleRadians); + var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180); + var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270); + if (hLimits.start < furthestLimits.l) { + furthestLimits.l = hLimits.start; + furthestAngles.l = angleRadians; + } + if (hLimits.end > furthestLimits.r) { + furthestLimits.r = hLimits.end; + furthestAngles.r = angleRadians; + } + if (vLimits.start < furthestLimits.t) { + furthestLimits.t = vLimits.start; + furthestAngles.t = angleRadians; + } + if (vLimits.end > furthestLimits.b) { + furthestLimits.b = vLimits.end; + furthestAngles.b = angleRadians; + } + } + scale._setReductions(scale.drawingArea, furthestLimits, furthestAngles); +} +function getTextAlignForAngle(angle) { + if (angle === 0 || angle === 180) { + return 'center'; + } else if (angle < 180) { + return 'left'; + } + return 'right'; +} +function fillText(ctx, text, position, lineHeight) { + var y = position.y + lineHeight / 2; + var i, ilen; + if (helpers.isArray(text)) { + for (i = 0, ilen = text.length; i < ilen; ++i) { + ctx.fillText(text[i], position.x, y); + y += lineHeight; + } + } else { + ctx.fillText(text, position.x, y); + } +} +function adjustPointPositionForLabelHeight(angle, textSize, position) { + if (angle === 90 || angle === 270) { + position.y -= textSize.h / 2; + } else if (angle > 270 || angle < 90) { + position.y -= textSize.h; + } +} +function drawPointLabels(scale) { + var ctx = scale.ctx; + var opts = scale.options; + var pointLabelOpts = opts.pointLabels; + var tickBackdropHeight = getTickBackdropHeight(opts); + var outerDistance = scale.getDistanceFromCenterForValue(opts.ticks.reverse ? scale.min : scale.max); + var plFont = helpers.options._parseFont(pointLabelOpts); + ctx.save(); + ctx.font = plFont.string; + ctx.textBaseline = 'middle'; + for (var i = scale.chart.data.labels.length - 1; i >= 0; i--) { + var extra = i === 0 ? tickBackdropHeight / 2 : 0; + var pointLabelPosition = scale.getPointPosition(i, outerDistance + extra + 5); + var pointLabelFontColor = valueAtIndexOrDefault$1(pointLabelOpts.fontColor, i, defaults.fontColor); + ctx.fillStyle = pointLabelFontColor; + var angleRadians = scale.getIndexAngle(i); + var angle = toDegrees(angleRadians); + ctx.textAlign = getTextAlignForAngle(angle); + adjustPointPositionForLabelHeight(angle, scale._pointLabelSizes[i], pointLabelPosition); + fillText(ctx, scale.pointLabels[i], pointLabelPosition, plFont.lineHeight); + } + ctx.restore(); +} +function drawRadiusLine(scale, gridLineOpts, radius, index) { + var ctx = scale.ctx; + var circular = gridLineOpts.circular; + var valueCount = scale.chart.data.labels.length; + var lineColor = valueAtIndexOrDefault$1(gridLineOpts.color, index - 1, undefined); + var lineWidth = valueAtIndexOrDefault$1(gridLineOpts.lineWidth, index - 1, undefined); + var pointPosition; + if (!circular && !valueCount || !lineColor || !lineWidth) { + return; + } + ctx.save(); + ctx.strokeStyle = lineColor; + ctx.lineWidth = lineWidth; + if (ctx.setLineDash) { + ctx.setLineDash(gridLineOpts.borderDash || []); + ctx.lineDashOffset = gridLineOpts.borderDashOffset || 0.0; + } + ctx.beginPath(); + if (circular) { + ctx.arc(scale.xCenter, scale.yCenter, radius, 0, Math.PI * 2); + } else { + pointPosition = scale.getPointPosition(0, radius); + ctx.moveTo(pointPosition.x, pointPosition.y); + for (var i = 1; i < valueCount; i++) { + pointPosition = scale.getPointPosition(i, radius); + ctx.lineTo(pointPosition.x, pointPosition.y); + } + } + ctx.closePath(); + ctx.stroke(); + ctx.restore(); +} +function numberOrZero(param) { + return isNumber(param) ? param : 0; +} +var RadialLinearScale = function (_LinearScaleBase) { + _inherits(RadialLinearScale, _LinearScaleBase); + var _super = _createSuper(RadialLinearScale); + function RadialLinearScale(cfg) { + var _this; + _classCallCheck(this, RadialLinearScale); + _this = _super.call(this, cfg); + _this.xCenter = undefined; + _this.yCenter = undefined; + _this.drawingArea = undefined; + _this.pointLabels = []; + return _this; + } + _createClass(RadialLinearScale, [{ + key: "setDimensions", + value: function setDimensions() { + var me = this; + me.width = me.maxWidth; + me.height = me.maxHeight; + me.paddingTop = getTickBackdropHeight(me.options) / 2; + me.xCenter = Math.floor(me.width / 2); + me.yCenter = Math.floor((me.height - me.paddingTop) / 2); + me.drawingArea = Math.min(me.height - me.paddingTop, me.width) / 2; + } + }, { + key: "determineDataLimits", + value: function determineDataLimits() { + var me = this; + var minmax = me.getMinMax(false); + var min = minmax.min; + var max = minmax.max; + me.min = helpers.isFinite(min) && !isNaN(min) ? min : 0; + me.max = helpers.isFinite(max) && !isNaN(max) ? max : 0; + me.handleTickRangeOptions(); + } + }, { + key: "computeTickLimit", + value: function computeTickLimit() { + return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options)); + } + }, { + key: "generateTickLabels", + value: function generateTickLabels(ticks) { + var me = this; + LinearScaleBase.prototype.generateTickLabels.call(me, ticks); + me.pointLabels = me.chart.data.labels.map(function (value, index) { + var label = helpers.callback(me.options.pointLabels.callback, [value, index], me); + return label || label === 0 ? label : ''; + }); + } + }, { + key: "fit", + value: function fit() { + var me = this; + var opts = me.options; + if (opts.display && opts.pointLabels.display) { + fitWithPointLabels(me); + } else { + me.setCenterPoint(0, 0, 0, 0); + } + } + }, { + key: "_setReductions", + value: function _setReductions(largestPossibleRadius, furthestLimits, furthestAngles) { + var me = this; + var radiusReductionLeft = furthestLimits.l / Math.sin(furthestAngles.l); + var radiusReductionRight = Math.max(furthestLimits.r - me.width, 0) / Math.sin(furthestAngles.r); + var radiusReductionTop = -furthestLimits.t / Math.cos(furthestAngles.t); + var radiusReductionBottom = -Math.max(furthestLimits.b - (me.height - me.paddingTop), 0) / Math.cos(furthestAngles.b); + radiusReductionLeft = numberOrZero(radiusReductionLeft); + radiusReductionRight = numberOrZero(radiusReductionRight); + radiusReductionTop = numberOrZero(radiusReductionTop); + radiusReductionBottom = numberOrZero(radiusReductionBottom); + me.drawingArea = Math.min(Math.floor(largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2), Math.floor(largestPossibleRadius - (radiusReductionTop + radiusReductionBottom) / 2)); + me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReductionTop, radiusReductionBottom); + } + }, { + key: "setCenterPoint", + value: function setCenterPoint(leftMovement, rightMovement, topMovement, bottomMovement) { + var me = this; + var maxRight = me.width - rightMovement - me.drawingArea; + var maxLeft = leftMovement + me.drawingArea; + var maxTop = topMovement + me.drawingArea; + var maxBottom = me.height - me.paddingTop - bottomMovement - me.drawingArea; + me.xCenter = Math.floor((maxLeft + maxRight) / 2 + me.left); + me.yCenter = Math.floor((maxTop + maxBottom) / 2 + me.top + me.paddingTop); + } + }, { + key: "getIndexAngle", + value: function getIndexAngle(index) { + var chart = this.chart; + var angleMultiplier = Math.PI * 2 / chart.data.labels.length; + var options = chart.options || {}; + var startAngle = options.startAngle || 0; + return _normalizeAngle(index * angleMultiplier + toRadians(startAngle)); + } + }, { + key: "getDistanceFromCenterForValue", + value: function getDistanceFromCenterForValue(value) { + var me = this; + if (helpers.isNullOrUndef(value)) { + return NaN; + } + var scalingFactor = me.drawingArea / (me.max - me.min); + if (me.options.reverse) { + return (me.max - value) * scalingFactor; + } + return (value - me.min) * scalingFactor; + } + }, { + key: "getPointPosition", + value: function getPointPosition(index, distanceFromCenter) { + var me = this; + var angle = me.getIndexAngle(index) - Math.PI / 2; + return { + x: Math.cos(angle) * distanceFromCenter + me.xCenter, + y: Math.sin(angle) * distanceFromCenter + me.yCenter, + angle: angle + }; + } + }, { + key: "getPointPositionForValue", + value: function getPointPositionForValue(index, value) { + return this.getPointPosition(index, this.getDistanceFromCenterForValue(value)); + } + }, { + key: "getBasePosition", + value: function getBasePosition(index) { + return this.getPointPositionForValue(index || 0, this.getBaseValue()); + } + }, { + key: "drawGrid", + value: function drawGrid() { + var me = this; + var ctx = me.ctx; + var opts = me.options; + var gridLineOpts = opts.gridLines; + var angleLineOpts = opts.angleLines; + var lineWidth = valueOrDefault$2(angleLineOpts.lineWidth, gridLineOpts.lineWidth); + var lineColor = valueOrDefault$2(angleLineOpts.color, gridLineOpts.color); + var i, offset, position; + if (opts.pointLabels.display) { + drawPointLabels(me); + } + if (gridLineOpts.display) { + me.ticks.forEach(function (tick, index) { + if (index !== 0) { + offset = me.getDistanceFromCenterForValue(me.ticks[index].value); + drawRadiusLine(me, gridLineOpts, offset, index); + } + }); + } + if (angleLineOpts.display && lineWidth && lineColor) { + ctx.save(); + ctx.lineWidth = lineWidth; + ctx.strokeStyle = lineColor; + if (ctx.setLineDash) { + ctx.setLineDash(resolve$2([angleLineOpts.borderDash, gridLineOpts.borderDash, []])); + ctx.lineDashOffset = resolve$2([angleLineOpts.borderDashOffset, gridLineOpts.borderDashOffset, 0.0]); + } + for (i = me.chart.data.labels.length - 1; i >= 0; i--) { + offset = me.getDistanceFromCenterForValue(opts.ticks.reverse ? me.min : me.max); + position = me.getPointPosition(i, offset); + ctx.beginPath(); + ctx.moveTo(me.xCenter, me.yCenter); + ctx.lineTo(position.x, position.y); + ctx.stroke(); + } + ctx.restore(); + } + } + }, { + key: "drawLabels", + value: function drawLabels() { + var me = this; + var ctx = me.ctx; + var opts = me.options; + var tickOpts = opts.ticks; + if (!tickOpts.display) { + return; + } + var startAngle = me.getIndexAngle(0); + var tickFont = helpers.options._parseFont(tickOpts); + var tickFontColor = valueOrDefault$2(tickOpts.fontColor, defaults.fontColor); + var offset, width; + ctx.save(); + ctx.font = tickFont.string; + ctx.translate(me.xCenter, me.yCenter); + ctx.rotate(startAngle); + ctx.textAlign = 'center'; + ctx.textBaseline = 'middle'; + me.ticks.forEach(function (tick, index) { + if (index === 0 && !opts.reverse) { + return; + } + offset = me.getDistanceFromCenterForValue(me.ticks[index].value); + if (tickOpts.showLabelBackdrop) { + width = ctx.measureText(tick.label).width; + ctx.fillStyle = tickOpts.backdropColor; + ctx.fillRect(-width / 2 - tickOpts.backdropPaddingX, -offset - tickFont.size / 2 - tickOpts.backdropPaddingY, width + tickOpts.backdropPaddingX * 2, tickFont.size + tickOpts.backdropPaddingY * 2); + } + ctx.fillStyle = tickFontColor; + ctx.fillText(tick.label, 0, -offset); + }); + ctx.restore(); + } + }, { + key: "drawTitle", + value: function drawTitle() {} + }]); + return RadialLinearScale; +}(LinearScaleBase); +_defineProperty(RadialLinearScale, "id", 'radialLinear'); +_defineProperty(RadialLinearScale, "defaults", defaultConfig$3); + +var MAX_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; +var INTERVALS = { + millisecond: { + common: true, + size: 1, + steps: 1000 + }, + second: { + common: true, + size: 1000, + steps: 60 + }, + minute: { + common: true, + size: 60000, + steps: 60 + }, + hour: { + common: true, + size: 3600000, + steps: 24 + }, + day: { + common: true, + size: 86400000, + steps: 30 + }, + week: { + common: false, + size: 604800000, + steps: 4 + }, + month: { + common: true, + size: 2.628e9, + steps: 12 + }, + quarter: { + common: false, + size: 7.884e9, + steps: 4 + }, + year: { + common: true, + size: 3.154e10 + } +}; +var UNITS = +Object.keys(INTERVALS); +function sorter(a, b) { + return a - b; +} +function arrayUnique(items) { + var set = new Set(); + var i, ilen; + for (i = 0, ilen = items.length; i < ilen; ++i) { + set.add(items[i]); + } + if (set.size === ilen) { + return items; + } + return _toConsumableArray(set); +} +function _parse(scale, input) { + if (isNullOrUndef(input)) { + return null; + } + var adapter = scale._adapter; + var options = scale.options.time; + var parser = options.parser, + round = options.round, + isoWeekday = options.isoWeekday; + var value = input; + if (typeof parser === 'function') { + value = parser(value); + } + if (!isNumberFinite(value)) { + value = typeof parser === 'string' ? adapter.parse(value, parser) : adapter.parse(value); + } + if (value === null) { + return value; + } + if (round) { + value = round === 'week' && isoWeekday ? scale._adapter.startOf(value, 'isoWeek', isoWeekday) : scale._adapter.startOf(value, round); + } + return +value; +} +function getDataTimestamps(scale) { + var isSeries = scale.options.distribution === 'series'; + var timestamps = scale._cache.data || []; + var i, ilen; + if (timestamps.length) { + return timestamps; + } + var metas = scale.getMatchingVisibleMetas(); + if (isSeries && metas.length) { + return metas[0].controller.getAllParsedValues(scale); + } + for (i = 0, ilen = metas.length; i < ilen; ++i) { + timestamps = timestamps.concat(metas[i].controller.getAllParsedValues(scale)); + } + return scale._cache.data = arrayUnique(timestamps.sort(sorter)); +} +function getLabelTimestamps(scale) { + var isSeries = scale.options.distribution === 'series'; + var timestamps = scale._cache.labels || []; + var i, ilen; + if (timestamps.length) { + return timestamps; + } + var labels = scale.getLabels(); + for (i = 0, ilen = labels.length; i < ilen; ++i) { + timestamps.push(_parse(scale, labels[i])); + } + return scale._cache.labels = isSeries ? timestamps : arrayUnique(timestamps.sort(sorter)); +} +function getAllTimestamps(scale) { + var timestamps = scale._cache.all || []; + if (timestamps.length) { + return timestamps; + } + var data = getDataTimestamps(scale); + var label = getLabelTimestamps(scale); + if (data.length && label.length) { + timestamps = arrayUnique(data.concat(label).sort(sorter)); + } else { + timestamps = data.length ? data : label; + } + timestamps = scale._cache.all = timestamps; + return timestamps; +} +function buildLookupTable(timestamps, min, max, distribution) { + if (distribution === 'linear' || !timestamps.length) { + return [{ + time: min, + pos: 0 + }, { + time: max, + pos: 1 + }]; + } + var table = []; + var items = [min]; + var i, ilen, prev, curr, next; + for (i = 0, ilen = timestamps.length; i < ilen; ++i) { + curr = timestamps[i]; + if (curr > min && curr < max) { + items.push(curr); + } + } + items.push(max); + for (i = 0, ilen = items.length; i < ilen; ++i) { + next = items[i + 1]; + prev = items[i - 1]; + curr = items[i]; + if (prev === undefined || next === undefined || Math.round((next + prev) / 2) !== curr) { + table.push({ + time: curr, + pos: i / (ilen - 1) + }); + } + } + return table; +} +function interpolate(table, skey, sval, tkey) { + var _lookupByKey2 = _lookupByKey(table, skey, sval), + lo = _lookupByKey2.lo, + hi = _lookupByKey2.hi; + var prev = table[lo]; + var next = table[hi]; + var span = next[skey] - prev[skey]; + var ratio = span ? (sval - prev[skey]) / span : 0; + var offset = (next[tkey] - prev[tkey]) * ratio; + return prev[tkey] + offset; +} +function determineUnitForAutoTicks(minUnit, min, max, capacity) { + var ilen = UNITS.length; + for (var i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) { + var interval = INTERVALS[UNITS[i]]; + var factor = interval.steps ? interval.steps : MAX_INTEGER; + if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) { + return UNITS[i]; + } + } + return UNITS[ilen - 1]; +} +function determineUnitForFormatting(scale, numTicks, minUnit, min, max) { + for (var i = UNITS.length - 1; i >= UNITS.indexOf(minUnit); i--) { + var unit = UNITS[i]; + if (INTERVALS[unit].common && scale._adapter.diff(max, min, unit) >= numTicks - 1) { + return unit; + } + } + return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0]; +} +function determineMajorUnit(unit) { + for (var i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i) { + if (INTERVALS[UNITS[i]].common) { + return UNITS[i]; + } + } +} +function addTick(timestamps, ticks, time) { + if (!timestamps.length) { + return; + } + var _lookup2 = _lookup(timestamps, time), + lo = _lookup2.lo, + hi = _lookup2.hi; + var timestamp = timestamps[lo] >= time ? timestamps[lo] : timestamps[hi]; + ticks.add(timestamp); +} +function generate(scale) { + var adapter = scale._adapter; + var min = scale.min; + var max = scale.max; + var options = scale.options; + var timeOpts = options.time; + var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, scale._getLabelCapacity(min)); + var stepSize = valueOrDefault(timeOpts.stepSize, 1); + var weekday = minor === 'week' ? timeOpts.isoWeekday : false; + var ticks = new Set(); + var first = min; + var time; + if (weekday) { + first = +adapter.startOf(first, 'isoWeek', weekday); + } + first = +adapter.startOf(first, weekday ? 'day' : minor); + if (adapter.diff(max, min, minor) > 100000 * stepSize) { + throw new Error(min + ' and ' + max + ' are too far apart with stepSize of ' + stepSize + ' ' + minor); + } + if (scale.options.ticks.source === 'data') { + var timestamps = getDataTimestamps(scale); + for (time = first; time < max; time = +adapter.add(time, stepSize, minor)) { + addTick(timestamps, ticks, time); + } + if (time === max || options.bounds === 'ticks') { + addTick(timestamps, ticks, time); + } + } else { + for (time = first; time < max; time = +adapter.add(time, stepSize, minor)) { + ticks.add(time); + } + if (time === max || options.bounds === 'ticks') { + ticks.add(time); + } + } + return _toConsumableArray(ticks); +} +function computeOffsets(table, timestamps, min, max, options) { + var start = 0; + var end = 0; + var first, last; + if (options.offset && timestamps.length) { + first = interpolate(table, 'time', timestamps[0], 'pos'); + if (timestamps.length === 1) { + start = 1 - first; + } else { + start = (interpolate(table, 'time', timestamps[1], 'pos') - first) / 2; + } + last = interpolate(table, 'time', timestamps[timestamps.length - 1], 'pos'); + if (timestamps.length === 1) { + end = last; + } else { + end = (last - interpolate(table, 'time', timestamps[timestamps.length - 2], 'pos')) / 2; + } + } + return { + start: start, + end: end, + factor: 1 / (start + 1 + end) + }; +} +function setMajorTicks(scale, ticks, map, majorUnit) { + var adapter = scale._adapter; + var first = +adapter.startOf(ticks[0].value, majorUnit); + var last = ticks[ticks.length - 1].value; + var major, index; + for (major = first; major <= last; major = +adapter.add(major, 1, majorUnit)) { + index = map[major]; + if (index >= 0) { + ticks[index].major = true; + } + } + return ticks; +} +function ticksFromTimestamps(scale, values, majorUnit) { + var ticks = []; + var map = {}; + var ilen = values.length; + var i, value; + for (i = 0; i < ilen; ++i) { + value = values[i]; + map[value] = i; + ticks.push({ + value: value, + major: false + }); + } + return ilen === 0 || !majorUnit ? ticks : setMajorTicks(scale, ticks, map, majorUnit); +} +function getTimestampsForTicks(scale) { + if (scale.options.ticks.source === 'labels') { + return getLabelTimestamps(scale); + } + return generate(scale); +} +function getTimestampsForTable(scale) { + return scale.options.distribution === 'series' ? getAllTimestamps(scale) : [scale.min, scale.max]; +} +function getLabelBounds(scale) { + var arr = getLabelTimestamps(scale); + var min = Number.POSITIVE_INFINITY; + var max = Number.NEGATIVE_INFINITY; + if (arr.length) { + min = arr[0]; + max = arr[arr.length - 1]; + } + return { + min: min, + max: max + }; +} +var defaultConfig$4 = { + distribution: 'linear', + bounds: 'data', + adapters: {}, + time: { + parser: false, + unit: false, + round: false, + isoWeekday: false, + minUnit: 'millisecond', + displayFormats: {} + }, + ticks: { + autoSkip: false, + source: 'auto', + major: { + enabled: false + } + } +}; +var TimeScale = function (_Scale) { + _inherits(TimeScale, _Scale); + var _super = _createSuper(TimeScale); + function TimeScale(props) { + var _this; + _classCallCheck(this, TimeScale); + _this = _super.call(this, props); + var options = _this.options; + var time = options.time || (options.time = {}); + var adapter = _this._adapter = new _adapters._date(options.adapters.date); + _this._cache = { + data: [], + labels: [], + all: [] + }; + _this._unit = 'day'; + _this._majorUnit = undefined; + _this._offsets = {}; + _this._table = []; + mergeIf(time.displayFormats, adapter.formats()); + return _this; + } + _createClass(TimeScale, [{ + key: "parse", + value: function parse(raw, index) { + if (raw === undefined) { + return NaN; + } + return _parse(this, raw); + } + }, { + key: "parseObject", + value: function parseObject(obj, axis, index) { + if (obj && obj.t) { + return this.parse(obj.t, index); + } + if (obj[axis] !== undefined) { + return this.parse(obj[axis], index); + } + return null; + } + }, { + key: "invalidateCaches", + value: function invalidateCaches() { + this._cache = { + data: [], + labels: [], + all: [] + }; + } + }, { + key: "determineDataLimits", + value: function determineDataLimits() { + var me = this; + var options = me.options; + var adapter = me._adapter; + var unit = options.time.unit || 'day'; + var _me$getUserBounds = me.getUserBounds(), + min = _me$getUserBounds.min, + max = _me$getUserBounds.max, + minDefined = _me$getUserBounds.minDefined, + maxDefined = _me$getUserBounds.maxDefined; + function _applyBounds(bounds) { + if (!minDefined && !isNaN(bounds.min)) { + min = Math.min(min, bounds.min); + } + if (!maxDefined && !isNaN(bounds.max)) { + max = Math.max(max, bounds.max); + } + } + if (!minDefined || !maxDefined) { + _applyBounds(getLabelBounds(me)); + if (options.bounds !== 'ticks' || options.ticks.source !== 'labels') { + _applyBounds(me.getMinMax(false)); + } + } + min = isNumberFinite(min) && !isNaN(min) ? min : +adapter.startOf(Date.now(), unit); + max = isNumberFinite(max) && !isNaN(max) ? max : +adapter.endOf(Date.now(), unit) + 1; + me.min = Math.min(min, max); + me.max = Math.max(min + 1, max); + } + }, { + key: "buildTicks", + value: function buildTicks() { + var me = this; + var options = me.options; + var timeOpts = options.time; + var tickOpts = options.ticks; + var distribution = options.distribution; + var timestamps = getTimestampsForTicks(me); + if (options.bounds === 'ticks' && timestamps.length) { + me.min = me._userMin || timestamps[0]; + me.max = me._userMax || timestamps[timestamps.length - 1]; + } + var min = me.min; + var max = me.max; + var ticks = _filterBetween(timestamps, min, max); + me._unit = timeOpts.unit || (tickOpts.autoSkip ? determineUnitForAutoTicks(timeOpts.minUnit, me.min, me.max, me._getLabelCapacity(min)) : determineUnitForFormatting(me, ticks.length, timeOpts.minUnit, me.min, me.max)); + me._majorUnit = !tickOpts.major.enabled || me._unit === 'year' ? undefined : determineMajorUnit(me._unit); + me._table = buildLookupTable(getTimestampsForTable(me), min, max, distribution); + me._offsets = computeOffsets(me._table, getDataTimestamps(me), min, max, options); + if (options.reverse) { + ticks.reverse(); + } + return ticksFromTimestamps(me, ticks, me._majorUnit); + } + }, { + key: "getLabelForValue", + value: function getLabelForValue(value) { + var me = this; + var adapter = me._adapter; + var timeOpts = me.options.time; + if (timeOpts.tooltipFormat) { + return adapter.format(value, timeOpts.tooltipFormat); + } + return adapter.format(value, timeOpts.displayFormats.datetime); + } + }, { + key: "_tickFormatFunction", + value: function _tickFormatFunction(time, index, ticks, format) { + var me = this; + var options = me.options; + var formats = options.time.displayFormats; + var unit = me._unit; + var majorUnit = me._majorUnit; + var minorFormat = unit && formats[unit]; + var majorFormat = majorUnit && formats[majorUnit]; + var tick = ticks[index]; + var major = majorUnit && majorFormat && tick && tick.major; + var label = me._adapter.format(time, format || (major ? majorFormat : minorFormat)); + var formatter = options.ticks.callback; + return formatter ? formatter(label, index, ticks) : label; + } + }, { + key: "generateTickLabels", + value: function generateTickLabels(ticks) { + var i, ilen, tick; + for (i = 0, ilen = ticks.length; i < ilen; ++i) { + tick = ticks[i]; + tick.label = this._tickFormatFunction(tick.value, i, ticks); + } + } + }, { + key: "getPixelForValue", + value: function getPixelForValue(value) { + var me = this; + var offsets = me._offsets; + var pos = interpolate(me._table, 'time', value, 'pos'); + return me.getPixelForDecimal((offsets.start + pos) * offsets.factor); + } + }, { + key: "getValueForPixel", + value: function getValueForPixel(pixel) { + var me = this; + var offsets = me._offsets; + var pos = me.getDecimalForPixel(pixel) / offsets.factor - offsets.end; + return interpolate(me._table, 'pos', pos, 'time'); + } + }, { + key: "_getLabelSize", + value: function _getLabelSize(label) { + var me = this; + var ticksOpts = me.options.ticks; + var tickLabelWidth = me.ctx.measureText(label).width; + var angle = toRadians(me.isHorizontal() ? ticksOpts.maxRotation : ticksOpts.minRotation); + var cosRotation = Math.cos(angle); + var sinRotation = Math.sin(angle); + var tickFontSize = valueOrDefault(ticksOpts.fontSize, defaults.fontSize); + return { + w: tickLabelWidth * cosRotation + tickFontSize * sinRotation, + h: tickLabelWidth * sinRotation + tickFontSize * cosRotation + }; + } + }, { + key: "_getLabelCapacity", + value: function _getLabelCapacity(exampleTime) { + var me = this; + var timeOpts = me.options.time; + var displayFormats = timeOpts.displayFormats; + var format = displayFormats[timeOpts.unit] || displayFormats.millisecond; + var exampleLabel = me._tickFormatFunction(exampleTime, 0, ticksFromTimestamps(me, [exampleTime], me._majorUnit), format); + var size = me._getLabelSize(exampleLabel); + var capacity = Math.floor(me.isHorizontal() ? me.width / size.w : me.height / size.h) - 1; + return capacity > 0 ? capacity : 1; + } + }]); + return TimeScale; +}(Scale); +_defineProperty(TimeScale, "id", 'time'); +_defineProperty(TimeScale, "defaults", defaultConfig$4); + +var scales = /*#__PURE__*/Object.freeze({ +__proto__: null, +CategoryScale: CategoryScale, +LinearScale: LinearScale, +LogarithmicScale: LogarithmicScale, +RadialLinearScale: RadialLinearScale, +TimeScale: TimeScale +}); + +defaults.set('plugins', { + filler: { + propagate: true + } +}); +function getLineByIndex(chart, index) { + var meta = chart.getDatasetMeta(index); + var visible = meta && chart.isDatasetVisible(index); + return visible ? meta.dataset : null; +} +function parseFillOption(line) { + var options = line.options; + var fillOption = options.fill; + var fill = valueOrDefault(fillOption && fillOption.target, fillOption); + if (fill === undefined) { + fill = !!options.backgroundColor; + } + if (fill === false || fill === null) { + return false; + } + if (fill === true) { + return 'origin'; + } + return fill; +} +function decodeFill(line, index, count) { + var fill = parseFillOption(line); + var target = parseFloat(fill); + if (isNumberFinite(target) && Math.floor(target) === target) { + if (fill[0] === '-' || fill[0] === '+') { + target = index + target; + } + if (target === index || target < 0 || target >= count) { + return false; + } + return target; + } + return ['origin', 'start', 'end'].indexOf(fill) >= 0 ? fill : false; +} +function computeLinearBoundary(source) { + var _source$scale = source.scale, + scale = _source$scale === void 0 ? {} : _source$scale, + fill = source.fill; + var target = null; + var horizontal; + if (fill === 'start') { + target = scale.bottom; + } else if (fill === 'end') { + target = scale.top; + } else if (scale.getBasePixel) { + target = scale.getBasePixel(); + } + if (isNumberFinite(target)) { + horizontal = scale.isHorizontal(); + return { + x: horizontal ? target : null, + y: horizontal ? null : target + }; + } + return null; +} +var simpleArc = function () { + function simpleArc(opts) { + _classCallCheck(this, simpleArc); + this.x = opts.x; + this.y = opts.y; + this.radius = opts.radius; + } + _createClass(simpleArc, [{ + key: "pathSegment", + value: function pathSegment(ctx, bounds, opts) { + var x = this.x, + y = this.y, + radius = this.radius; + bounds = bounds || { + start: 0, + end: Math.PI * 2 + }; + if (opts.reverse) { + ctx.arc(x, y, radius, bounds.end, bounds.start, true); + } else { + ctx.arc(x, y, radius, bounds.start, bounds.end); + } + return !opts.bounds; + } + }, { + key: "interpolate", + value: function interpolate(point, property) { + var x = this.x, + y = this.y, + radius = this.radius; + var angle = point.angle; + if (property === 'angle') { + return { + x: x + Math.cos(angle) * radius, + y: y + Math.sin(angle) * radius, + angle: angle + }; + } + } + }]); + return simpleArc; +}(); +function computeCircularBoundary(source) { + var scale = source.scale, + fill = source.fill; + var options = scale.options; + var length = scale.getLabels().length; + var target = []; + var start = options.reverse ? scale.max : scale.min; + var end = options.reverse ? scale.min : scale.max; + var value = fill === 'start' ? start : fill === 'end' ? end : scale.getBaseValue(); + var i, center; + if (options.gridLines.circular) { + center = scale.getPointPositionForValue(0, start); + return new simpleArc({ + x: center.x, + y: center.y, + radius: scale.getDistanceFromCenterForValue(value) + }); + } + for (i = 0; i < length; ++i) { + target.push(scale.getPointPositionForValue(i, value)); + } + return target; +} +function computeBoundary(source) { + var scale = source.scale || {}; + if (scale.getPointPositionForValue) { + return computeCircularBoundary(source); + } + return computeLinearBoundary(source); +} +function pointsFromSegments(boundary, line) { + var _ref = boundary || {}, + _ref$x = _ref.x, + x = _ref$x === void 0 ? null : _ref$x, + _ref$y = _ref.y, + y = _ref$y === void 0 ? null : _ref$y; + var linePoints = line.points; + var points = []; + line.segments.forEach(function (segment) { + var first = linePoints[segment.start]; + var last = linePoints[segment.end]; + if (y !== null) { + points.push({ + x: first.x, + y: y, + _prop: 'x', + _ref: first + }); + points.push({ + x: last.x, + y: y, + _prop: 'x', + _ref: last + }); + } else if (x !== null) { + points.push({ + x: x, + y: first.y, + _prop: 'y', + _ref: first + }); + points.push({ + x: x, + y: last.y, + _prop: 'y', + _ref: last + }); + } + }); + return points; +} +function getTarget(source) { + var chart = source.chart, + fill = source.fill, + line = source.line; + if (isNumberFinite(fill)) { + return getLineByIndex(chart, fill); + } + var boundary = computeBoundary(source); + var points = []; + var _loop = false; + var _refPoints = false; + if (boundary instanceof simpleArc) { + return boundary; + } + if (isArray(boundary)) { + _loop = true; + points = boundary; + } else { + points = pointsFromSegments(boundary, line); + _refPoints = true; + } + return points.length ? new Line({ + points: points, + options: { + tension: 0 + }, + _loop: _loop, + _fullLoop: _loop, + _refPoints: _refPoints + }) : null; +} +function resolveTarget(sources, index, propagate) { + var source = sources[index]; + var fill = source.fill; + var visited = [index]; + var target; + if (!propagate) { + return fill; + } + while (fill !== false && visited.indexOf(fill) === -1) { + if (!isNumberFinite(fill)) { + return fill; + } + target = sources[fill]; + if (!target) { + return false; + } + if (target.visible) { + return fill; + } + visited.push(fill); + fill = target.fill; + } + return false; +} +function _clip(ctx, target, clipY) { + ctx.beginPath(); + target.path(ctx); + ctx.lineTo(target.last().x, clipY); + ctx.lineTo(target.first().x, clipY); + ctx.closePath(); + ctx.clip(); +} +function getBounds(property, first, last, loop) { + if (loop) { + return; + } + var start = first[property]; + var end = last[property]; + if (property === 'angle') { + start = _normalizeAngle(start); + end = _normalizeAngle(end); + } + return { + property: property, + start: start, + end: end + }; +} +function _getEdge(a, b, prop, fn) { + if (a && b) { + return fn(a[prop], b[prop]); + } + return a ? a[prop] : b ? b[prop] : 0; +} +function _segments(line, target, property) { + var segments = line.segments; + var points = line.points; + var tpoints = target.points; + var parts = []; + if (target._refPoints) { + for (var i = 0, ilen = tpoints.length; i < ilen; ++i) { + var point = tpoints[i]; + var prop = point._prop; + if (prop) { + point[prop] = point._ref[prop]; + } + } + } + for (var _i = 0; _i < segments.length; _i++) { + var segment = segments[_i]; + var bounds = getBounds(property, points[segment.start], points[segment.end], segment.loop); + if (!target.segments) { + parts.push({ + source: segment, + target: bounds, + start: points[segment.start], + end: points[segment.end] + }); + continue; + } + var subs = _boundSegments(target, bounds); + for (var j = 0; j < subs.length; ++j) { + var sub = subs[j]; + var subBounds = getBounds(property, tpoints[sub.start], tpoints[sub.end], sub.loop); + var fillSources = _boundSegment(segment, points, subBounds); + for (var k = 0; k < fillSources.length; k++) { + parts.push({ + source: fillSources[k], + target: sub, + start: _defineProperty({}, property, _getEdge(bounds, subBounds, 'start', Math.max)), + end: _defineProperty({}, property, _getEdge(bounds, subBounds, 'end', Math.min)) + }); + } + } + } + return parts; +} +function clipBounds(ctx, scale, bounds) { + var _scale$chart$chartAre = scale.chart.chartArea, + top = _scale$chart$chartAre.top, + bottom = _scale$chart$chartAre.bottom; + var _ref2 = bounds || {}, + property = _ref2.property, + start = _ref2.start, + end = _ref2.end; + if (property === 'x') { + ctx.beginPath(); + ctx.rect(start, top, end - start, bottom - top); + ctx.clip(); + } +} +function interpolatedLineTo(ctx, target, point, property) { + var interpolatedPoint = target.interpolate(point, property); + if (interpolatedPoint) { + ctx.lineTo(interpolatedPoint.x, interpolatedPoint.y); + } +} +function _fill(ctx, cfg) { + var line = cfg.line, + target = cfg.target, + property = cfg.property, + color = cfg.color, + scale = cfg.scale; + var segments = _segments(cfg.line, cfg.target, property); + ctx.fillStyle = color; + for (var i = 0, ilen = segments.length; i < ilen; ++i) { + var _segments$i = segments[i], + src = _segments$i.source, + tgt = _segments$i.target, + start = _segments$i.start, + end = _segments$i.end; + ctx.save(); + clipBounds(ctx, scale, getBounds(property, start, end)); + ctx.beginPath(); + var lineLoop = !!line.pathSegment(ctx, src); + if (lineLoop) { + ctx.closePath(); + } else { + interpolatedLineTo(ctx, target, end, property); + } + var targetLoop = !!target.pathSegment(ctx, tgt, { + move: lineLoop, + reverse: true + }); + var loop = lineLoop && targetLoop; + if (!loop) { + interpolatedLineTo(ctx, target, start, property); + } + ctx.closePath(); + ctx.fill(loop ? 'evenodd' : 'nonzero'); + ctx.restore(); + } +} +function doFill(ctx, cfg) { + var line = cfg.line, + target = cfg.target, + above = cfg.above, + below = cfg.below, + area = cfg.area, + scale = cfg.scale; + var property = line._loop ? 'angle' : 'x'; + ctx.save(); + if (property === 'x' && below !== above) { + _clip(ctx, target, area.top); + _fill(ctx, { + line: line, + target: target, + color: above, + scale: scale, + property: property + }); + ctx.restore(); + ctx.save(); + _clip(ctx, target, area.bottom); + } + _fill(ctx, { + line: line, + target: target, + color: below, + scale: scale, + property: property + }); + ctx.restore(); +} +var filler = { + id: 'filler', + afterDatasetsUpdate: function afterDatasetsUpdate(chart, options) { + var count = (chart.data.datasets || []).length; + var propagate = options.propagate; + var sources = []; + var meta, i, line, source; + for (i = 0; i < count; ++i) { + meta = chart.getDatasetMeta(i); + line = meta.dataset; + source = null; + if (line && line.options && line instanceof Line) { + source = { + visible: chart.isDatasetVisible(i), + fill: decodeFill(line, i, count), + chart: chart, + scale: meta.vScale, + line: line, + target: undefined + }; + } + meta.$filler = source; + sources.push(source); + } + for (i = 0; i < count; ++i) { + source = sources[i]; + if (!source || source.fill === false) { + continue; + } + source.fill = resolveTarget(sources, i, propagate); + source.target = source.fill !== false && getTarget(source); + } + }, + beforeDatasetsDraw: function beforeDatasetsDraw(chart) { + var metasets = chart.getSortedVisibleDatasetMetas(); + var area = chart.chartArea; + var i, meta; + for (i = metasets.length - 1; i >= 0; --i) { + meta = metasets[i].$filler; + if (meta) { + meta.line.updateControlPoints(area); + } + } + }, + beforeDatasetDraw: function beforeDatasetDraw(chart, args) { + var area = chart.chartArea; + var ctx = chart.ctx; + var meta = args.meta.$filler; + if (!meta || meta.fill === false) { + return; + } + var line = meta.line, + target = meta.target, + scale = meta.scale; + var lineOpts = line.options; + var fillOption = lineOpts.fill; + var color = lineOpts.backgroundColor || defaults.color; + var _ref3 = fillOption || {}, + _ref3$above = _ref3.above, + above = _ref3$above === void 0 ? color : _ref3$above, + _ref3$below = _ref3.below, + below = _ref3$below === void 0 ? color : _ref3$below; + if (target && line.points.length) { + clipArea(ctx, area); + doFill(ctx, { + line: line, + target: target, + above: above, + below: below, + area: area, + scale: scale + }); + unclipArea(ctx); + } + } +}; + +defaults.set('legend', { + display: true, + position: 'top', + align: 'center', + fullWidth: true, + reverse: false, + weight: 1000, + onClick: function onClick(e, legendItem) { + var index = legendItem.datasetIndex; + var ci = this.chart; + if (ci.isDatasetVisible(index)) { + ci.hide(index); + legendItem.hidden = true; + } else { + ci.show(index); + legendItem.hidden = false; + } + }, + onHover: null, + onLeave: null, + labels: { + boxWidth: 40, + padding: 10, + generateLabels: function generateLabels(chart) { + var datasets = chart.data.datasets; + var options = chart.options.legend || {}; + var usePointStyle = options.labels && options.labels.usePointStyle; + return chart._getSortedDatasetMetas().map(function (meta) { + var style = meta.controller.getStyle(usePointStyle ? 0 : undefined); + return { + text: datasets[meta.index].label, + fillStyle: style.backgroundColor, + hidden: !meta.visible, + lineCap: style.borderCapStyle, + lineDash: style.borderDash, + lineDashOffset: style.borderDashOffset, + lineJoin: style.borderJoinStyle, + lineWidth: style.borderWidth, + strokeStyle: style.borderColor, + pointStyle: style.pointStyle, + rotation: style.rotation, + datasetIndex: meta.index + }; + }, this); + } + }, + title: { + display: false, + position: 'center', + text: '' + } +}); +function getBoxWidth(labelOpts, fontSize) { + return labelOpts.usePointStyle && labelOpts.boxWidth > fontSize ? fontSize : labelOpts.boxWidth; +} +var Legend = function (_Element) { + _inherits(Legend, _Element); + var _super = _createSuper(Legend); + function Legend(config) { + var _this; + _classCallCheck(this, Legend); + _this = _super.call(this); + _extends(_assertThisInitialized(_this), config); + _this.legendHitBoxes = []; + _this._hoveredItem = null; + _this.doughnutMode = false; + _this.chart = config.chart; + _this.options = config.options; + _this.ctx = config.ctx; + _this.legendItems = undefined; + _this.columnWidths = undefined; + _this.columnHeights = undefined; + _this.lineWidths = undefined; + _this._minSize = undefined; + _this.maxHeight = undefined; + _this.maxWidth = undefined; + _this.top = undefined; + _this.bottom = undefined; + _this.left = undefined; + _this.right = undefined; + _this.height = undefined; + _this.width = undefined; + _this._margins = undefined; + _this.paddingTop = undefined; + _this.paddingBottom = undefined; + _this.paddingLeft = undefined; + _this.paddingRight = undefined; + _this.position = undefined; + _this.weight = undefined; + _this.fullWidth = undefined; + return _this; + } + _createClass(Legend, [{ + key: "beforeUpdate", + value: function beforeUpdate() {} + }, { + key: "update", + value: function update(maxWidth, maxHeight, margins) { + var me = this; + me.beforeUpdate(); + me.maxWidth = maxWidth; + me.maxHeight = maxHeight; + me._margins = margins; + me.beforeSetDimensions(); + me.setDimensions(); + me.afterSetDimensions(); + me.beforeBuildLabels(); + me.buildLabels(); + me.afterBuildLabels(); + me.beforeFit(); + me.fit(); + me.afterFit(); + me.afterUpdate(); + } + }, { + key: "afterUpdate", + value: function afterUpdate() {} + }, { + key: "beforeSetDimensions", + value: function beforeSetDimensions() {} + }, { + key: "setDimensions", + value: function setDimensions() { + var me = this; + if (me.isHorizontal()) { + me.width = me.maxWidth; + me.left = 0; + me.right = me.width; + } else { + me.height = me.maxHeight; + me.top = 0; + me.bottom = me.height; + } + me.paddingLeft = 0; + me.paddingTop = 0; + me.paddingRight = 0; + me.paddingBottom = 0; + me._minSize = { + width: 0, + height: 0 + }; + } + }, { + key: "afterSetDimensions", + value: function afterSetDimensions() {} + }, { + key: "beforeBuildLabels", + value: function beforeBuildLabels() {} + }, { + key: "buildLabels", + value: function buildLabels() { + var me = this; + var labelOpts = me.options.labels || {}; + var legendItems = callback(labelOpts.generateLabels, [me.chart], me) || []; + if (labelOpts.filter) { + legendItems = legendItems.filter(function (item) { + return labelOpts.filter(item, me.chart.data); + }); + } + if (me.options.reverse) { + legendItems.reverse(); + } + me.legendItems = legendItems; + } + }, { + key: "afterBuildLabels", + value: function afterBuildLabels() {} + }, { + key: "beforeFit", + value: function beforeFit() {} + }, { + key: "fit", + value: function fit() { + var me = this; + var opts = me.options; + var labelOpts = opts.labels; + var display = opts.display; + var ctx = me.ctx; + var labelFont = _parseFont(labelOpts); + var fontSize = labelFont.size; + var hitboxes = me.legendHitBoxes = []; + var minSize = me._minSize; + var isHorizontal = me.isHorizontal(); + var titleHeight = me._computeTitleHeight(); + if (isHorizontal) { + minSize.width = me.maxWidth; + minSize.height = display ? 10 : 0; + } else { + minSize.width = display ? 10 : 0; + minSize.height = me.maxHeight; + } + if (!display) { + me.width = minSize.width = me.height = minSize.height = 0; + return; + } + ctx.font = labelFont.string; + if (isHorizontal) { + var lineWidths = me.lineWidths = [0]; + var totalHeight = titleHeight; + ctx.textAlign = 'left'; + ctx.textBaseline = 'middle'; + me.legendItems.forEach(function (legendItem, i) { + var boxWidth = getBoxWidth(labelOpts, fontSize); + var width = boxWidth + fontSize / 2 + ctx.measureText(legendItem.text).width; + if (i === 0 || lineWidths[lineWidths.length - 1] + width + 2 * labelOpts.padding > minSize.width) { + totalHeight += fontSize + labelOpts.padding; + lineWidths[lineWidths.length - (i > 0 ? 0 : 1)] = 0; + } + hitboxes[i] = { + left: 0, + top: 0, + width: width, + height: fontSize + }; + lineWidths[lineWidths.length - 1] += width + labelOpts.padding; + }); + minSize.height += totalHeight; + } else { + var vPadding = labelOpts.padding; + var columnWidths = me.columnWidths = []; + var columnHeights = me.columnHeights = []; + var totalWidth = labelOpts.padding; + var currentColWidth = 0; + var currentColHeight = 0; + var heightLimit = minSize.height - titleHeight; + me.legendItems.forEach(function (legendItem, i) { + var boxWidth = getBoxWidth(labelOpts, fontSize); + var itemWidth = boxWidth + fontSize / 2 + ctx.measureText(legendItem.text).width; + if (i > 0 && currentColHeight + fontSize + 2 * vPadding > heightLimit) { + totalWidth += currentColWidth + labelOpts.padding; + columnWidths.push(currentColWidth); + columnHeights.push(currentColHeight); + currentColWidth = 0; + currentColHeight = 0; + } + currentColWidth = Math.max(currentColWidth, itemWidth); + currentColHeight += fontSize + vPadding; + hitboxes[i] = { + left: 0, + top: 0, + width: itemWidth, + height: fontSize + }; + }); + totalWidth += currentColWidth; + columnWidths.push(currentColWidth); + columnHeights.push(currentColHeight); + minSize.width += totalWidth; + } + me.width = minSize.width; + me.height = minSize.height; + } + }, { + key: "afterFit", + value: function afterFit() {} + }, { + key: "isHorizontal", + value: function isHorizontal() { + return this.options.position === 'top' || this.options.position === 'bottom'; + } + }, { + key: "draw", + value: function draw() { + var me = this; + var opts = me.options; + var labelOpts = opts.labels; + var defaultColor = defaults.color; + var lineDefault = defaults.elements.line; + var legendHeight = me.height; + var columnHeights = me.columnHeights; + var legendWidth = me.width; + var lineWidths = me.lineWidths; + if (!opts.display) { + return; + } + me.drawTitle(); + var rtlHelper = getRtlAdapter(opts.rtl, me.left, me._minSize.width); + var ctx = me.ctx; + var fontColor = valueOrDefault(labelOpts.fontColor, defaults.fontColor); + var labelFont = _parseFont(labelOpts); + var fontSize = labelFont.size; + var cursor; + ctx.textAlign = rtlHelper.textAlign('left'); + ctx.textBaseline = 'middle'; + ctx.lineWidth = 0.5; + ctx.strokeStyle = fontColor; + ctx.fillStyle = fontColor; + ctx.font = labelFont.string; + var boxWidth = getBoxWidth(labelOpts, fontSize); + var hitboxes = me.legendHitBoxes; + var drawLegendBox = function drawLegendBox(x, y, legendItem) { + if (isNaN(boxWidth) || boxWidth <= 0) { + return; + } + ctx.save(); + var lineWidth = valueOrDefault(legendItem.lineWidth, lineDefault.borderWidth); + ctx.fillStyle = valueOrDefault(legendItem.fillStyle, defaultColor); + ctx.lineCap = valueOrDefault(legendItem.lineCap, lineDefault.borderCapStyle); + ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, lineDefault.borderDashOffset); + ctx.lineJoin = valueOrDefault(legendItem.lineJoin, lineDefault.borderJoinStyle); + ctx.lineWidth = lineWidth; + ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, defaultColor); + if (ctx.setLineDash) { + ctx.setLineDash(valueOrDefault(legendItem.lineDash, lineDefault.borderDash)); + } + if (labelOpts && labelOpts.usePointStyle) { + var drawOptions = { + radius: boxWidth * Math.SQRT2 / 2, + pointStyle: legendItem.pointStyle, + rotation: legendItem.rotation, + borderWidth: lineWidth + }; + var centerX = rtlHelper.xPlus(x, boxWidth / 2); + var centerY = y + fontSize / 2; + drawPoint(ctx, drawOptions, centerX, centerY); + } else { + ctx.fillRect(rtlHelper.leftForLtr(x, boxWidth), y, boxWidth, fontSize); + if (lineWidth !== 0) { + ctx.strokeRect(rtlHelper.leftForLtr(x, boxWidth), y, boxWidth, fontSize); + } + } + ctx.restore(); + }; + var fillText = function fillText(x, y, legendItem, textWidth) { + var halfFontSize = fontSize / 2; + var xLeft = rtlHelper.xPlus(x, boxWidth + halfFontSize); + var yMiddle = y + halfFontSize; + ctx.fillText(legendItem.text, xLeft, yMiddle); + if (legendItem.hidden) { + ctx.beginPath(); + ctx.lineWidth = 2; + ctx.moveTo(xLeft, yMiddle); + ctx.lineTo(rtlHelper.xPlus(xLeft, textWidth), yMiddle); + ctx.stroke(); + } + }; + var alignmentOffset = function alignmentOffset(dimension, blockSize) { + switch (opts.align) { + case 'start': + return labelOpts.padding; + case 'end': + return dimension - blockSize; + default: + return (dimension - blockSize + labelOpts.padding) / 2; + } + }; + var isHorizontal = me.isHorizontal(); + var titleHeight = this._computeTitleHeight(); + if (isHorizontal) { + cursor = { + x: me.left + alignmentOffset(legendWidth, lineWidths[0]), + y: me.top + labelOpts.padding + titleHeight, + line: 0 + }; + } else { + cursor = { + x: me.left + labelOpts.padding, + y: me.top + alignmentOffset(legendHeight, columnHeights[0]) + titleHeight, + line: 0 + }; + } + overrideTextDirection(me.ctx, opts.textDirection); + var itemHeight = fontSize + labelOpts.padding; + me.legendItems.forEach(function (legendItem, i) { + var textWidth = ctx.measureText(legendItem.text).width; + var width = boxWidth + fontSize / 2 + textWidth; + var x = cursor.x; + var y = cursor.y; + rtlHelper.setWidth(me._minSize.width); + if (isHorizontal) { + if (i > 0 && x + width + labelOpts.padding > me.left + me._minSize.width) { + y = cursor.y += itemHeight; + cursor.line++; + x = cursor.x = me.left + alignmentOffset(legendWidth, lineWidths[cursor.line]); + } + } else if (i > 0 && y + itemHeight > me.top + me._minSize.height) { + x = cursor.x = x + me.columnWidths[cursor.line] + labelOpts.padding; + cursor.line++; + y = cursor.y = me.top + alignmentOffset(legendHeight, columnHeights[cursor.line]); + } + var realX = rtlHelper.x(x); + drawLegendBox(realX, y, legendItem); + hitboxes[i].left = rtlHelper.leftForLtr(realX, hitboxes[i].width); + hitboxes[i].top = y; + fillText(realX, y, legendItem, textWidth); + if (isHorizontal) { + cursor.x += width + labelOpts.padding; + } else { + cursor.y += itemHeight; + } + }); + restoreTextDirection(me.ctx, opts.textDirection); + } + }, { + key: "drawTitle", + value: function drawTitle() { + var me = this; + var opts = me.options; + var titleOpts = opts.title; + var titleFont = _parseFont(titleOpts); + var titlePadding = toPadding(titleOpts.padding); + if (!titleOpts.display) { + return; + } + var rtlHelper = getRtlAdapter(opts.rtl, me.left, me._minSize.width); + var ctx = me.ctx; + var fontColor = valueOrDefault(titleOpts.fontColor, defaults.fontColor); + var position = titleOpts.position; + var x, textAlign; + var halfFontSize = titleFont.size / 2; + var y = me.top + titlePadding.top + halfFontSize; + var left = me.left; + var maxWidth = me.width; + if (this.isHorizontal()) { + maxWidth = Math.max.apply(Math, _toConsumableArray(me.lineWidths)); + switch (opts.align) { + case 'start': + break; + case 'end': + left = me.right - maxWidth; + break; + default: + left = (me.left + me.right) / 2 - maxWidth / 2; + break; + } + } else { + var maxHeight = Math.max.apply(Math, _toConsumableArray(me.columnHeights)); + switch (opts.align) { + case 'start': + break; + case 'end': + y += me.height - maxHeight; + break; + default: + y += (me.height - maxHeight) / 2; + break; + } + } + switch (position) { + case 'start': + x = left; + textAlign = 'left'; + break; + case 'end': + x = left + maxWidth; + textAlign = 'right'; + break; + default: + x = left + maxWidth / 2; + textAlign = 'center'; + break; + } + ctx.textAlign = rtlHelper.textAlign(textAlign); + ctx.textBaseline = 'middle'; + ctx.strokeStyle = fontColor; + ctx.fillStyle = fontColor; + ctx.font = titleFont.string; + ctx.fillText(titleOpts.text, x, y); + } + }, { + key: "_computeTitleHeight", + value: function _computeTitleHeight() { + var titleOpts = this.options.title; + var titleFont = _parseFont(titleOpts); + var titlePadding = toPadding(titleOpts.padding); + return titleOpts.display ? titleFont.lineHeight + titlePadding.height : 0; + } + }, { + key: "_getLegendItemAt", + value: function _getLegendItemAt(x, y) { + var me = this; + var i, hitBox, lh; + if (x >= me.left && x <= me.right && y >= me.top && y <= me.bottom) { + lh = me.legendHitBoxes; + for (i = 0; i < lh.length; ++i) { + hitBox = lh[i]; + if (x >= hitBox.left && x <= hitBox.left + hitBox.width && y >= hitBox.top && y <= hitBox.top + hitBox.height) { + return me.legendItems[i]; + } + } + } + return null; + } + }, { + key: "handleEvent", + value: function handleEvent(e) { + var me = this; + var opts = me.options; + var type = e.type === 'mouseup' ? 'click' : e.type; + if (type === 'mousemove') { + if (!opts.onHover && !opts.onLeave) { + return; + } + } else if (type === 'click') { + if (!opts.onClick) { + return; + } + } else { + return; + } + var hoveredItem = me._getLegendItemAt(e.x, e.y); + if (type === 'click') { + if (hoveredItem && opts.onClick) { + opts.onClick.call(me, e["native"], hoveredItem); + } + } else { + if (opts.onLeave && hoveredItem !== me._hoveredItem) { + if (me._hoveredItem) { + opts.onLeave.call(me, e["native"], me._hoveredItem); + } + me._hoveredItem = hoveredItem; + } + if (opts.onHover && hoveredItem) { + opts.onHover.call(me, e["native"], hoveredItem); + } + } + } + }]); + return Legend; +}(Element$1); +function createNewLegendAndAttach(chart, legendOpts) { + var legend = new Legend({ + ctx: chart.ctx, + options: legendOpts, + chart: chart + }); + layouts.configure(chart, legend, legendOpts); + layouts.addBox(chart, legend); + chart.legend = legend; +} +var legend = { + id: 'legend', + _element: Legend, + beforeInit: function beforeInit(chart) { + var legendOpts = chart.options.legend; + if (legendOpts) { + createNewLegendAndAttach(chart, legendOpts); + } + }, + afterUpdate: function afterUpdate(chart) { + var legendOpts = chart.options.legend; + var legend = chart.legend; + if (legendOpts) { + mergeIf(legendOpts, defaults.legend); + if (legend) { + layouts.configure(chart, legend, legendOpts); + legend.options = legendOpts; + legend.buildLabels(); + } else { + createNewLegendAndAttach(chart, legendOpts); + } + } else if (legend) { + layouts.removeBox(chart, legend); + delete chart.legend; + } + }, + afterEvent: function afterEvent(chart, e) { + var legend = chart.legend; + if (legend) { + legend.handleEvent(e); + } + } +}; + +defaults.set('title', { + align: 'center', + display: false, + fontStyle: 'bold', + fullWidth: true, + padding: 10, + position: 'top', + text: '', + weight: 2000 +}); +var Title = function (_Element) { + _inherits(Title, _Element); + var _super = _createSuper(Title); + function Title(config) { + var _this; + _classCallCheck(this, Title); + _this = _super.call(this); + _extends(_assertThisInitialized(_this), config); + _this.chart = config.chart; + _this.options = config.options; + _this.ctx = config.ctx; + _this._margins = undefined; + _this._padding = undefined; + _this.legendHitBoxes = []; + _this.top = undefined; + _this.bottom = undefined; + _this.left = undefined; + _this.right = undefined; + _this.width = undefined; + _this.height = undefined; + _this.maxWidth = undefined; + _this.maxHeight = undefined; + _this.position = undefined; + _this.weight = undefined; + _this.fullWidth = undefined; + return _this; + } + _createClass(Title, [{ + key: "beforeUpdate", + value: function beforeUpdate() {} + }, { + key: "update", + value: function update(maxWidth, maxHeight, margins) { + var me = this; + me.beforeUpdate(); + me.maxWidth = maxWidth; + me.maxHeight = maxHeight; + me._margins = margins; + me.beforeSetDimensions(); + me.setDimensions(); + me.afterSetDimensions(); + me.beforeBuildLabels(); + me.buildLabels(); + me.afterBuildLabels(); + me.beforeFit(); + me.fit(); + me.afterFit(); + me.afterUpdate(); + } + }, { + key: "afterUpdate", + value: function afterUpdate() {} + }, { + key: "beforeSetDimensions", + value: function beforeSetDimensions() {} + }, { + key: "setDimensions", + value: function setDimensions() { + var me = this; + if (me.isHorizontal()) { + me.width = me.maxWidth; + me.left = 0; + me.right = me.width; + } else { + me.height = me.maxHeight; + me.top = 0; + me.bottom = me.height; + } + } + }, { + key: "afterSetDimensions", + value: function afterSetDimensions() {} + }, { + key: "beforeBuildLabels", + value: function beforeBuildLabels() {} + }, { + key: "buildLabels", + value: function buildLabels() {} + }, { + key: "afterBuildLabels", + value: function afterBuildLabels() {} + }, { + key: "beforeFit", + value: function beforeFit() {} + }, { + key: "fit", + value: function fit() { + var me = this; + var opts = me.options; + var minSize = {}; + var isHorizontal = me.isHorizontal(); + if (!opts.display) { + me.width = minSize.width = me.height = minSize.height = 0; + return; + } + var lineCount = helpers.isArray(opts.text) ? opts.text.length : 1; + me._padding = helpers.options.toPadding(opts.padding); + var textSize = lineCount * helpers.options._parseFont(opts).lineHeight + me._padding.height; + me.width = minSize.width = isHorizontal ? me.maxWidth : textSize; + me.height = minSize.height = isHorizontal ? textSize : me.maxHeight; + } + }, { + key: "afterFit", + value: function afterFit() {} + }, { + key: "isHorizontal", + value: function isHorizontal() { + var pos = this.options.position; + return pos === 'top' || pos === 'bottom'; + } + }, { + key: "draw", + value: function draw() { + var me = this; + var ctx = me.ctx; + var opts = me.options; + if (!opts.display) { + return; + } + var fontOpts = helpers.options._parseFont(opts); + var lineHeight = fontOpts.lineHeight; + var offset = lineHeight / 2 + me._padding.top; + var rotation = 0; + var top = me.top; + var left = me.left; + var bottom = me.bottom; + var right = me.right; + var maxWidth, titleX, titleY; + var align; + if (me.isHorizontal()) { + switch (opts.align) { + case 'start': + titleX = left; + align = 'left'; + break; + case 'end': + titleX = right; + align = 'right'; + break; + default: + titleX = left + (right - left) / 2; + align = 'center'; + break; + } + titleY = top + offset; + maxWidth = right - left; + } else { + titleX = opts.position === 'left' ? left + offset : right - offset; + switch (opts.align) { + case 'start': + titleY = opts.position === 'left' ? bottom : top; + align = 'left'; + break; + case 'end': + titleY = opts.position === 'left' ? top : bottom; + align = 'right'; + break; + default: + titleY = top + (bottom - top) / 2; + align = 'center'; + break; + } + maxWidth = bottom - top; + rotation = Math.PI * (opts.position === 'left' ? -0.5 : 0.5); + } + ctx.save(); + ctx.fillStyle = helpers.valueOrDefault(opts.fontColor, defaults.fontColor); + ctx.font = fontOpts.string; + ctx.translate(titleX, titleY); + ctx.rotate(rotation); + ctx.textAlign = align; + ctx.textBaseline = 'middle'; + var text = opts.text; + if (helpers.isArray(text)) { + var y = 0; + for (var i = 0; i < text.length; ++i) { + ctx.fillText(text[i], 0, y, maxWidth); + y += lineHeight; + } + } else { + ctx.fillText(text, 0, 0, maxWidth); + } + ctx.restore(); + } + }]); + return Title; +}(Element$1); +function createNewTitleBlockAndAttach(chart, titleOpts) { + var title = new Title({ + ctx: chart.ctx, + options: titleOpts, + chart: chart + }); + layouts.configure(chart, title, titleOpts); + layouts.addBox(chart, title); + chart.titleBlock = title; +} +var title = { + id: 'title', + _element: Title, + beforeInit: function beforeInit(chart) { + var titleOpts = chart.options.title; + if (titleOpts) { + createNewTitleBlockAndAttach(chart, titleOpts); + } + }, + beforeUpdate: function beforeUpdate(chart) { + var titleOpts = chart.options.title; + var titleBlock = chart.titleBlock; + if (titleOpts) { + helpers.mergeIf(titleOpts, defaults.title); + if (titleBlock) { + layouts.configure(chart, titleBlock, titleOpts); + titleBlock.options = titleOpts; + } else { + createNewTitleBlockAndAttach(chart, titleOpts); + } + } else if (titleBlock) { + layouts.removeBox(chart, titleBlock); + delete chart.titleBlock; + } + } +}; + +var valueOrDefault$3 = helpers.valueOrDefault; +var getRtlHelper = helpers.rtl.getRtlAdapter; +defaults.set('tooltips', { + enabled: true, + custom: null, + mode: 'nearest', + position: 'average', + intersect: true, + backgroundColor: 'rgba(0,0,0,0.8)', + titleFontStyle: 'bold', + titleSpacing: 2, + titleMarginBottom: 6, + titleFontColor: '#fff', + titleAlign: 'left', + bodySpacing: 2, + bodyFontColor: '#fff', + bodyAlign: 'left', + footerFontStyle: 'bold', + footerSpacing: 2, + footerMarginTop: 6, + footerFontColor: '#fff', + footerAlign: 'left', + yPadding: 6, + xPadding: 6, + caretPadding: 2, + caretSize: 5, + cornerRadius: 6, + multiKeyBackground: '#fff', + displayColors: true, + borderColor: 'rgba(0,0,0,0)', + borderWidth: 0, + animation: { + duration: 400, + easing: 'easeOutQuart', + numbers: { + type: 'number', + properties: ['x', 'y', 'width', 'height', 'caretX', 'caretY'] + }, + opacity: { + easing: 'linear', + duration: 200 + } + }, + callbacks: { + beforeTitle: helpers.noop, + title: function title(tooltipItems, data) { + var title = ''; + var labels = data.labels; + var labelCount = labels ? labels.length : 0; + if (tooltipItems.length > 0) { + var item = tooltipItems[0]; + if (item.label) { + title = item.label; + } else if (labelCount > 0 && item.index < labelCount) { + title = labels[item.index]; + } + } + return title; + }, + afterTitle: helpers.noop, + beforeBody: helpers.noop, + beforeLabel: helpers.noop, + label: function label(tooltipItem, data) { + var label = data.datasets[tooltipItem.datasetIndex].label || ''; + if (label) { + label += ': '; + } + var value = tooltipItem.value; + if (!helpers.isNullOrUndef(value)) { + label += value; + } + return label; + }, + labelColor: function labelColor(tooltipItem, chart) { + var meta = chart.getDatasetMeta(tooltipItem.datasetIndex); + var options = meta.controller.getStyle(tooltipItem.index); + return { + borderColor: options.borderColor, + backgroundColor: options.backgroundColor + }; + }, + labelTextColor: function labelTextColor() { + return this.options.bodyFontColor; + }, + afterLabel: helpers.noop, + afterBody: helpers.noop, + beforeFooter: helpers.noop, + footer: helpers.noop, + afterFooter: helpers.noop + } +}); +var positioners = { + average: function average(items) { + if (!items.length) { + return false; + } + var i, len; + var x = 0; + var y = 0; + var count = 0; + for (i = 0, len = items.length; i < len; ++i) { + var el = items[i].element; + if (el && el.hasValue()) { + var pos = el.tooltipPosition(); + x += pos.x; + y += pos.y; + ++count; + } + } + return { + x: x / count, + y: y / count + }; + }, + nearest: function nearest(items, eventPosition) { + var x = eventPosition.x; + var y = eventPosition.y; + var minDistance = Number.POSITIVE_INFINITY; + var i, len, nearestElement; + for (i = 0, len = items.length; i < len; ++i) { + var el = items[i].element; + if (el && el.hasValue()) { + var center = el.getCenterPoint(); + var d = helpers.math.distanceBetweenPoints(eventPosition, center); + if (d < minDistance) { + minDistance = d; + nearestElement = el; + } + } + } + if (nearestElement) { + var tp = nearestElement.tooltipPosition(); + x = tp.x; + y = tp.y; + } + return { + x: x, + y: y + }; + } +}; +function pushOrConcat(base, toPush) { + if (toPush) { + if (helpers.isArray(toPush)) { + Array.prototype.push.apply(base, toPush); + } else { + base.push(toPush); + } + } + return base; +} +function splitNewlines(str) { + if ((typeof str === 'string' || str instanceof String) && str.indexOf('\n') > -1) { + return str.split('\n'); + } + return str; +} +function createTooltipItem(chart, item) { + var datasetIndex = item.datasetIndex, + index = item.index; + var _chart$getDatasetMeta = chart.getDatasetMeta(datasetIndex).controller.getLabelAndValue(index), + label = _chart$getDatasetMeta.label, + value = _chart$getDatasetMeta.value; + return { + label: label, + value: value, + index: index, + datasetIndex: datasetIndex + }; +} +function resolveOptions(options) { + options = _extends({}, defaults.tooltips, options); + options.bodyFontFamily = valueOrDefault$3(options.bodyFontFamily, defaults.fontFamily); + options.bodyFontStyle = valueOrDefault$3(options.bodyFontStyle, defaults.fontStyle); + options.bodyFontSize = valueOrDefault$3(options.bodyFontSize, defaults.fontSize); + options.boxHeight = valueOrDefault$3(options.boxHeight, options.bodyFontSize); + options.boxWidth = valueOrDefault$3(options.boxWidth, options.bodyFontSize); + options.titleFontFamily = valueOrDefault$3(options.titleFontFamily, defaults.fontFamily); + options.titleFontStyle = valueOrDefault$3(options.titleFontStyle, defaults.fontStyle); + options.titleFontSize = valueOrDefault$3(options.titleFontSize, defaults.fontSize); + options.footerFontFamily = valueOrDefault$3(options.footerFontFamily, defaults.fontFamily); + options.footerFontStyle = valueOrDefault$3(options.footerFontStyle, defaults.fontStyle); + options.footerFontSize = valueOrDefault$3(options.footerFontSize, defaults.fontSize); + return options; +} +function getTooltipSize(tooltip) { + var ctx = tooltip._chart.ctx; + var body = tooltip.body, + footer = tooltip.footer, + options = tooltip.options, + title = tooltip.title; + var bodyFontSize = options.bodyFontSize, + footerFontSize = options.footerFontSize, + titleFontSize = options.titleFontSize, + boxWidth = options.boxWidth, + boxHeight = options.boxHeight; + var titleLineCount = title.length; + var footerLineCount = footer.length; + var bodyLineItemCount = body.length; + var height = options.yPadding * 2; + var width = 0; + var combinedBodyLength = body.reduce(function (count, bodyItem) { + return count + bodyItem.before.length + bodyItem.lines.length + bodyItem.after.length; + }, 0); + combinedBodyLength += tooltip.beforeBody.length + tooltip.afterBody.length; + if (titleLineCount) { + height += titleLineCount * titleFontSize + (titleLineCount - 1) * options.titleSpacing + options.titleMarginBottom; + } + if (combinedBodyLength) { + var bodyLineHeight = options.displayColors ? Math.max(boxHeight, bodyFontSize) : bodyFontSize; + height += bodyLineItemCount * bodyLineHeight + (combinedBodyLength - bodyLineItemCount) * bodyFontSize + (combinedBodyLength - 1) * options.bodySpacing; + } + if (footerLineCount) { + height += options.footerMarginTop + footerLineCount * footerFontSize + (footerLineCount - 1) * options.footerSpacing; + } + var widthPadding = 0; + var maxLineWidth = function maxLineWidth(line) { + width = Math.max(width, ctx.measureText(line).width + widthPadding); + }; + ctx.save(); + ctx.font = helpers.fontString(titleFontSize, options.titleFontStyle, options.titleFontFamily); + helpers.each(tooltip.title, maxLineWidth); + ctx.font = helpers.fontString(bodyFontSize, options.bodyFontStyle, options.bodyFontFamily); + helpers.each(tooltip.beforeBody.concat(tooltip.afterBody), maxLineWidth); + widthPadding = options.displayColors ? boxWidth + 2 : 0; + helpers.each(body, function (bodyItem) { + helpers.each(bodyItem.before, maxLineWidth); + helpers.each(bodyItem.lines, maxLineWidth); + helpers.each(bodyItem.after, maxLineWidth); + }); + widthPadding = 0; + ctx.font = helpers.fontString(footerFontSize, options.footerFontStyle, options.footerFontFamily); + helpers.each(tooltip.footer, maxLineWidth); + ctx.restore(); + width += 2 * options.xPadding; + return { + width: width, + height: height + }; +} +function determineAlignment(chart, options, size) { + var x = size.x, + y = size.y, + width = size.width, + height = size.height; + var chartArea = chart.chartArea; + var xAlign = 'center'; + var yAlign = 'center'; + if (y < height) { + yAlign = 'top'; + } else if (y > chart.height - height) { + yAlign = 'bottom'; + } + var lf, rf; + var midX = (chartArea.left + chartArea.right) / 2; + var midY = (chartArea.top + chartArea.bottom) / 2; + if (yAlign === 'center') { + lf = function lf(value) { + return value <= midX; + }; + rf = function rf(value) { + return value > midX; + }; + } else { + lf = function lf(value) { + return value <= width / 2; + }; + rf = function rf(value) { + return value >= chart.width - width / 2; + }; + } + var olf = function olf(value) { + return value + width + options.caretSize + options.caretPadding > chart.width; + }; + var orf = function orf(value) { + return value - width - options.caretSize - options.caretPadding < 0; + }; + var yf = function yf(value) { + return value <= midY ? 'top' : 'bottom'; + }; + if (lf(x)) { + xAlign = 'left'; + if (olf(x)) { + xAlign = 'center'; + yAlign = yf(y); + } + } else if (rf(x)) { + xAlign = 'right'; + if (orf(x)) { + xAlign = 'center'; + yAlign = yf(y); + } + } + return { + xAlign: options.xAlign ? options.xAlign : xAlign, + yAlign: options.yAlign ? options.yAlign : yAlign + }; +} +function alignX(size, xAlign, chartWidth) { + var x = size.x, + width = size.width; + if (xAlign === 'right') { + x -= width; + } else if (xAlign === 'center') { + x -= width / 2; + if (x + width > chartWidth) { + x = chartWidth - width; + } + if (x < 0) { + x = 0; + } + } + return x; +} +function alignY(size, yAlign, paddingAndSize) { + var y = size.y, + height = size.height; + if (yAlign === 'top') { + y += paddingAndSize; + } else if (yAlign === 'bottom') { + y -= height + paddingAndSize; + } else { + y -= height / 2; + } + return y; +} +function getBackgroundPoint(options, size, alignment, chart) { + var caretSize = options.caretSize, + caretPadding = options.caretPadding, + cornerRadius = options.cornerRadius; + var xAlign = alignment.xAlign, + yAlign = alignment.yAlign; + var paddingAndSize = caretSize + caretPadding; + var radiusAndPadding = cornerRadius + caretPadding; + var x = alignX(size, xAlign, chart.width); + var y = alignY(size, yAlign, paddingAndSize); + if (yAlign === 'center') { + if (xAlign === 'left') { + x += paddingAndSize; + } else if (xAlign === 'right') { + x -= paddingAndSize; + } + } else if (xAlign === 'left') { + x -= radiusAndPadding; + } else if (xAlign === 'right') { + x += radiusAndPadding; + } + return { + x: x, + y: y + }; +} +function getAlignedX(tooltip, align) { + var options = tooltip.options; + return align === 'center' ? tooltip.x + tooltip.width / 2 : align === 'right' ? tooltip.x + tooltip.width - options.xPadding : tooltip.x + options.xPadding; +} +function getBeforeAfterBodyLines(callback) { + return pushOrConcat([], splitNewlines(callback)); +} +var Tooltip = function (_Element) { + _inherits(Tooltip, _Element); + var _super = _createSuper(Tooltip); + function Tooltip(config) { + var _this; + _classCallCheck(this, Tooltip); + _this = _super.call(this); + _this.opacity = 0; + _this._active = []; + _this._chart = config._chart; + _this._eventPosition = undefined; + _this._size = undefined; + _this._cachedAnimations = undefined; + _this.$animations = undefined; + _this.options = undefined; + _this.dataPoints = undefined; + _this.title = undefined; + _this.beforeBody = undefined; + _this.body = undefined; + _this.afterBody = undefined; + _this.footer = undefined; + _this.xAlign = undefined; + _this.yAlign = undefined; + _this.x = undefined; + _this.y = undefined; + _this.height = undefined; + _this.width = undefined; + _this.caretX = undefined; + _this.caretY = undefined; + _this.labelColors = undefined; + _this.labelTextColors = undefined; + _this.initialize(); + return _this; + } + _createClass(Tooltip, [{ + key: "initialize", + value: function initialize() { + var me = this; + me.options = resolveOptions(me._chart.options.tooltips); + } + }, { + key: "_resolveAnimations", + value: function _resolveAnimations() { + var me = this; + var cached = me._cachedAnimations; + if (cached) { + return cached; + } + var chart = me._chart; + var opts = chart.options.animation && me.options.animation; + var animations = new Animations(me._chart, opts); + me._cachedAnimations = Object.freeze(animations); + return animations; + } + }, { + key: "getTitle", + value: function getTitle(tooltipitem, data) { + var me = this; + var opts = me.options; + var callbacks = opts.callbacks; + var beforeTitle = callbacks.beforeTitle.apply(me, [tooltipitem, data]); + var title = callbacks.title.apply(me, [tooltipitem, data]); + var afterTitle = callbacks.afterTitle.apply(me, [tooltipitem, data]); + var lines = []; + lines = pushOrConcat(lines, splitNewlines(beforeTitle)); + lines = pushOrConcat(lines, splitNewlines(title)); + lines = pushOrConcat(lines, splitNewlines(afterTitle)); + return lines; + } + }, { + key: "getBeforeBody", + value: function getBeforeBody(tooltipitem, data) { + return getBeforeAfterBodyLines(this.options.callbacks.beforeBody.apply(this, [tooltipitem, data])); + } + }, { + key: "getBody", + value: function getBody(tooltipItems, data) { + var me = this; + var callbacks = me.options.callbacks; + var bodyItems = []; + helpers.each(tooltipItems, function (tooltipItem) { + var bodyItem = { + before: [], + lines: [], + after: [] + }; + pushOrConcat(bodyItem.before, splitNewlines(callbacks.beforeLabel.call(me, tooltipItem, data))); + pushOrConcat(bodyItem.lines, callbacks.label.call(me, tooltipItem, data)); + pushOrConcat(bodyItem.after, splitNewlines(callbacks.afterLabel.call(me, tooltipItem, data))); + bodyItems.push(bodyItem); + }); + return bodyItems; + } + }, { + key: "getAfterBody", + value: function getAfterBody(tooltipitem, data) { + return getBeforeAfterBodyLines(this.options.callbacks.afterBody.apply(this, [tooltipitem, data])); + } + }, { + key: "getFooter", + value: function getFooter(tooltipitem, data) { + var me = this; + var callbacks = me.options.callbacks; + var beforeFooter = callbacks.beforeFooter.apply(me, [tooltipitem, data]); + var footer = callbacks.footer.apply(me, [tooltipitem, data]); + var afterFooter = callbacks.afterFooter.apply(me, [tooltipitem, data]); + var lines = []; + lines = pushOrConcat(lines, splitNewlines(beforeFooter)); + lines = pushOrConcat(lines, splitNewlines(footer)); + lines = pushOrConcat(lines, splitNewlines(afterFooter)); + return lines; + } + }, { + key: "_createItems", + value: function _createItems() { + var me = this; + var active = me._active; + var options = me.options; + var data = me._chart.data; + var labelColors = []; + var labelTextColors = []; + var tooltipItems = []; + var i, len; + for (i = 0, len = active.length; i < len; ++i) { + tooltipItems.push(createTooltipItem(me._chart, active[i])); + } + if (options.filter) { + tooltipItems = tooltipItems.filter(function (a) { + return options.filter(a, data); + }); + } + if (options.itemSort) { + tooltipItems = tooltipItems.sort(function (a, b) { + return options.itemSort(a, b, data); + }); + } + helpers.each(tooltipItems, function (tooltipItem) { + labelColors.push(options.callbacks.labelColor.call(me, tooltipItem, me._chart)); + labelTextColors.push(options.callbacks.labelTextColor.call(me, tooltipItem, me._chart)); + }); + me.labelColors = labelColors; + me.labelTextColors = labelTextColors; + me.dataPoints = tooltipItems; + return tooltipItems; + } + }, { + key: "update", + value: function update(changed) { + var me = this; + var options = me.options; + var active = me._active; + var properties; + if (!active.length) { + if (me.opacity !== 0) { + properties = { + opacity: 0 + }; + } + } else { + var data = me._chart.data; + var position = positioners[options.position].call(me, active, me._eventPosition); + var tooltipItems = me._createItems(); + me.title = me.getTitle(tooltipItems, data); + me.beforeBody = me.getBeforeBody(tooltipItems, data); + me.body = me.getBody(tooltipItems, data); + me.afterBody = me.getAfterBody(tooltipItems, data); + me.footer = me.getFooter(tooltipItems, data); + var size = me._size = getTooltipSize(me); + var positionAndSize = _extends({}, position, size); + var alignment = determineAlignment(me._chart, options, positionAndSize); + var backgroundPoint = getBackgroundPoint(options, positionAndSize, alignment, me._chart); + me.xAlign = alignment.xAlign; + me.yAlign = alignment.yAlign; + properties = { + opacity: 1, + x: backgroundPoint.x, + y: backgroundPoint.y, + width: size.width, + height: size.height, + caretX: position.x, + caretY: position.y + }; + } + if (properties) { + me._resolveAnimations().update(me, properties); + } + if (changed && options.custom) { + options.custom.call(me); + } + } + }, { + key: "drawCaret", + value: function drawCaret(tooltipPoint, ctx, size) { + var caretPosition = this.getCaretPosition(tooltipPoint, size); + ctx.lineTo(caretPosition.x1, caretPosition.y1); + ctx.lineTo(caretPosition.x2, caretPosition.y2); + ctx.lineTo(caretPosition.x3, caretPosition.y3); + } + }, { + key: "getCaretPosition", + value: function getCaretPosition(tooltipPoint, size) { + var xAlign = this.xAlign, + yAlign = this.yAlign, + options = this.options; + var cornerRadius = options.cornerRadius, + caretSize = options.caretSize; + var ptX = tooltipPoint.x, + ptY = tooltipPoint.y; + var width = size.width, + height = size.height; + var x1, x2, x3, y1, y2, y3; + if (yAlign === 'center') { + y2 = ptY + height / 2; + if (xAlign === 'left') { + x1 = ptX; + x2 = x1 - caretSize; + } else { + x1 = ptX + width; + x2 = x1 + caretSize; + } + x3 = x1; + y1 = y2 + caretSize; + y3 = y2 - caretSize; + } else { + if (xAlign === 'left') { + x2 = ptX + cornerRadius + caretSize; + } else if (xAlign === 'right') { + x2 = ptX + width - cornerRadius - caretSize; + } else { + x2 = this.caretX; + } + x1 = x2 - caretSize; + x3 = x2 + caretSize; + if (yAlign === 'top') { + y1 = ptY; + y2 = y1 - caretSize; + } else { + y1 = ptY + height; + y2 = y1 + caretSize; + } + y3 = y1; + } + return { + x1: x1, + x2: x2, + x3: x3, + y1: y1, + y2: y2, + y3: y3 + }; + } + }, { + key: "drawTitle", + value: function drawTitle(pt, ctx) { + var me = this; + var options = me.options; + var title = me.title; + var length = title.length; + var titleFontSize, titleSpacing, i; + if (length) { + var rtlHelper = getRtlHelper(options.rtl, me.x, me.width); + pt.x = getAlignedX(me, options.titleAlign); + ctx.textAlign = rtlHelper.textAlign(options.titleAlign); + ctx.textBaseline = 'middle'; + titleFontSize = options.titleFontSize; + titleSpacing = options.titleSpacing; + ctx.fillStyle = options.titleFontColor; + ctx.font = helpers.fontString(titleFontSize, options.titleFontStyle, options.titleFontFamily); + for (i = 0; i < length; ++i) { + ctx.fillText(title[i], rtlHelper.x(pt.x), pt.y + titleFontSize / 2); + pt.y += titleFontSize + titleSpacing; + if (i + 1 === length) { + pt.y += options.titleMarginBottom - titleSpacing; + } + } + } + } + }, { + key: "_drawColorBox", + value: function _drawColorBox(ctx, pt, i, rtlHelper) { + var me = this; + var options = me.options; + var labelColors = me.labelColors[i]; + var boxHeight = options.boxHeight, + boxWidth = options.boxWidth, + bodyFontSize = options.bodyFontSize; + var colorX = getAlignedX(me, 'left'); + var rtlColorX = rtlHelper.x(colorX); + var yOffSet = boxHeight < bodyFontSize ? (bodyFontSize - boxHeight) / 2 : 0; + var colorY = pt.y + yOffSet; + ctx.fillStyle = options.multiKeyBackground; + ctx.fillRect(rtlHelper.leftForLtr(rtlColorX, boxWidth), colorY, boxWidth, boxHeight); + ctx.lineWidth = 1; + ctx.strokeStyle = labelColors.borderColor; + ctx.strokeRect(rtlHelper.leftForLtr(rtlColorX, boxWidth), colorY, boxWidth, boxHeight); + ctx.fillStyle = labelColors.backgroundColor; + ctx.fillRect(rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - 2), colorY + 1, boxWidth - 2, boxHeight - 2); + ctx.fillStyle = me.labelTextColors[i]; + } + }, { + key: "drawBody", + value: function drawBody(pt, ctx) { + var me = this; + var body = me.body, + options = me.options; + var bodyFontSize = options.bodyFontSize, + bodySpacing = options.bodySpacing, + bodyAlign = options.bodyAlign, + displayColors = options.displayColors, + boxHeight = options.boxHeight, + boxWidth = options.boxWidth; + var bodyLineHeight = bodyFontSize; + var xLinePadding = 0; + var rtlHelper = getRtlHelper(options.rtl, me.x, me.width); + var fillLineOfText = function fillLineOfText(line) { + ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyLineHeight / 2); + pt.y += bodyLineHeight + bodySpacing; + }; + var bodyAlignForCalculation = rtlHelper.textAlign(bodyAlign); + var bodyItem, textColor, lines, i, j, ilen, jlen; + ctx.textAlign = bodyAlign; + ctx.textBaseline = 'middle'; + ctx.font = helpers.fontString(bodyFontSize, options.bodyFontStyle, options.bodyFontFamily); + pt.x = getAlignedX(me, bodyAlignForCalculation); + ctx.fillStyle = options.bodyFontColor; + helpers.each(me.beforeBody, fillLineOfText); + xLinePadding = displayColors && bodyAlignForCalculation !== 'right' ? bodyAlign === 'center' ? boxWidth / 2 + 1 : boxWidth + 2 : 0; + for (i = 0, ilen = body.length; i < ilen; ++i) { + bodyItem = body[i]; + textColor = me.labelTextColors[i]; + ctx.fillStyle = textColor; + helpers.each(bodyItem.before, fillLineOfText); + lines = bodyItem.lines; + if (displayColors && lines.length) { + me._drawColorBox(ctx, pt, i, rtlHelper); + bodyLineHeight = Math.max(bodyFontSize, boxHeight); + } + for (j = 0, jlen = lines.length; j < jlen; ++j) { + fillLineOfText(lines[j]); + bodyLineHeight = bodyFontSize; + } + helpers.each(bodyItem.after, fillLineOfText); + } + xLinePadding = 0; + bodyLineHeight = bodyFontSize; + helpers.each(me.afterBody, fillLineOfText); + pt.y -= bodySpacing; + } + }, { + key: "drawFooter", + value: function drawFooter(pt, ctx) { + var me = this; + var options = me.options; + var footer = me.footer; + var length = footer.length; + var footerFontSize, i; + if (length) { + var rtlHelper = getRtlHelper(options.rtl, me.x, me.width); + pt.x = getAlignedX(me, options.footerAlign); + pt.y += options.footerMarginTop; + ctx.textAlign = rtlHelper.textAlign(options.footerAlign); + ctx.textBaseline = 'middle'; + footerFontSize = options.footerFontSize; + ctx.fillStyle = options.footerFontColor; + ctx.font = helpers.fontString(footerFontSize, options.footerFontStyle, options.footerFontFamily); + for (i = 0; i < length; ++i) { + ctx.fillText(footer[i], rtlHelper.x(pt.x), pt.y + footerFontSize / 2); + pt.y += footerFontSize + options.footerSpacing; + } + } + } + }, { + key: "drawBackground", + value: function drawBackground(pt, ctx, tooltipSize) { + var xAlign = this.xAlign, + yAlign = this.yAlign, + options = this.options; + var x = pt.x, + y = pt.y; + var width = tooltipSize.width, + height = tooltipSize.height; + var radius = options.cornerRadius; + ctx.fillStyle = options.backgroundColor; + ctx.strokeStyle = options.borderColor; + ctx.lineWidth = options.borderWidth; + ctx.beginPath(); + ctx.moveTo(x + radius, y); + if (yAlign === 'top') { + this.drawCaret(pt, ctx, tooltipSize); + } + ctx.lineTo(x + width - radius, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); + if (yAlign === 'center' && xAlign === 'right') { + this.drawCaret(pt, ctx, tooltipSize); + } + ctx.lineTo(x + width, y + height - radius); + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); + if (yAlign === 'bottom') { + this.drawCaret(pt, ctx, tooltipSize); + } + ctx.lineTo(x + radius, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); + if (yAlign === 'center' && xAlign === 'left') { + this.drawCaret(pt, ctx, tooltipSize); + } + ctx.lineTo(x, y + radius); + ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.closePath(); + ctx.fill(); + if (options.borderWidth > 0) { + ctx.stroke(); + } + } + }, { + key: "_updateAnimationTarget", + value: function _updateAnimationTarget() { + var me = this; + var chart = me._chart; + var options = me.options; + var anims = me.$animations; + var animX = anims && anims.x; + var animY = anims && anims.y; + if (animX || animY) { + var position = positioners[options.position].call(me, me._active, me._eventPosition); + if (!position) { + return; + } + var size = me._size = getTooltipSize(me); + var positionAndSize = _extends({}, position, me._size); + var alignment = determineAlignment(chart, options, positionAndSize); + var point = getBackgroundPoint(options, positionAndSize, alignment, chart); + if (animX._to !== point.x || animY._to !== point.y) { + me.xAlign = alignment.xAlign; + me.yAlign = alignment.yAlign; + me.width = size.width; + me.height = size.height; + me.caretX = position.x; + me.caretY = position.y; + me._resolveAnimations().update(me, point); + } + } + } + }, { + key: "draw", + value: function draw(ctx) { + var me = this; + var options = me.options; + var opacity = me.opacity; + if (!opacity) { + return; + } + me._updateAnimationTarget(); + var tooltipSize = { + width: me.width, + height: me.height + }; + var pt = { + x: me.x, + y: me.y + }; + opacity = Math.abs(opacity) < 1e-3 ? 0 : opacity; + var hasTooltipContent = me.title.length || me.beforeBody.length || me.body.length || me.afterBody.length || me.footer.length; + if (options.enabled && hasTooltipContent) { + ctx.save(); + ctx.globalAlpha = opacity; + me.drawBackground(pt, ctx, tooltipSize); + helpers.rtl.overrideTextDirection(ctx, options.textDirection); + pt.y += options.yPadding; + me.drawTitle(pt, ctx); + me.drawBody(pt, ctx); + me.drawFooter(pt, ctx); + helpers.rtl.restoreTextDirection(ctx, options.textDirection); + ctx.restore(); + } + } + }, { + key: "handleEvent", + value: function handleEvent(e, replay) { + var me = this; + var options = me.options; + var lastActive = me._active || []; + var changed = false; + var active = []; + if (e.type !== 'mouseout') { + active = me._chart.getElementsAtEventForMode(e, options.mode, options, replay); + if (options.reverse) { + active.reverse(); + } + } + changed = replay || !helpers._elementsEqual(active, lastActive); + if (changed) { + me._active = active; + if (options.enabled || options.custom) { + me._eventPosition = { + x: e.x, + y: e.y + }; + me.update(true); + } + } + return changed; + } + }]); + return Tooltip; +}(Element$1); +Tooltip.positioners = positioners; +var tooltip = { + id: 'tooltip', + _element: Tooltip, + positioners: positioners, + afterInit: function afterInit(chart) { + var tooltipOpts = chart.options.tooltips; + if (tooltipOpts) { + chart.tooltip = new Tooltip({ + _chart: chart + }); + } + }, + beforeUpdate: function beforeUpdate(chart) { + if (chart.tooltip) { + chart.tooltip.initialize(); + } + }, + reset: function reset(chart) { + if (chart.tooltip) { + chart.tooltip.initialize(); + } + }, + afterDraw: function afterDraw(chart) { + var tooltip = chart.tooltip; + var args = { + tooltip: tooltip + }; + if (pluginsCore.notify(chart, 'beforeTooltipDraw', [args]) === false) { + return; + } + tooltip.draw(chart.ctx); + pluginsCore.notify(chart, 'afterTooltipDraw', [args]); + }, + afterEvent: function afterEvent(chart, e, replay) { + if (chart.tooltip) { + var useFinalPosition = replay; + chart.tooltip.handleEvent(e, useFinalPosition); + } + } +}; + +var plugins = { + filler: filler, + legend: legend, + title: title, + tooltip: tooltip +}; + +Chart.helpers = helpers; +Chart._adapters = _adapters; +Chart.Animation = Animation; +Chart.Animator = Animator$1; +Chart.animationService = Animations; +Chart.controllers = controllers; +Chart.DatasetController = DatasetController; +Chart.defaults = defaults; +Chart.Element = Element$1; +Chart.elements = elements; +Chart.Interaction = Interaction; +Chart.layouts = layouts; +Chart.platforms = platforms; +Chart.plugins = pluginsCore; +Chart.Scale = Scale; +Chart.scaleService = scaleService; +Chart.Ticks = Ticks; +Object.keys(scales).forEach(function (key) { + return Chart.scaleService.registerScale(scales[key]); +}); +for (var k in plugins) { + if (Object.prototype.hasOwnProperty.call(plugins, k)) { + Chart.plugins.register(plugins[k]); + } +} +if (typeof window !== 'undefined') { + window.Chart = Chart; +} + +return Chart; + +}))); diff --git a/dist/next/Chart.min.js b/dist/next/Chart.min.js new file mode 100644 index 0000000000..8cef848026 --- /dev/null +++ b/dist/next/Chart.min.js @@ -0,0 +1,13 @@ +/*! + * Chart.js v3.0.0-alpha + * https://www.chartjs.org + * (c) 2020 Chart.js Contributors + * Released under the MIT License + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Chart=e()}(this,(function(){"use strict";var t=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var i=-1;return t.some((function(t,n){return t[0]===e&&(i=n,!0)})),i}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var i=t(this.__entries__,e),n=this.__entries__[i];return n&&n[1]},e.prototype.set=function(e,i){var n=t(this.__entries__,e);~n?this.__entries__[n][1]=i:this.__entries__.push([e,i])},e.prototype.delete=function(e){var i=this.__entries__,n=t(i,e);~n&&i.splice(n,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var i=0,n=this.__entries__;i0},t.prototype.connect_=function(){e&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),r?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){e&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,i=void 0===e?"":e;a.some((function(t){return!!~i.indexOf(t)}))&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),s=function(t,e){for(var i=0,n=Object.keys(e);i0},e}(),b="undefined"!=typeof WeakMap?new WeakMap:new t,x=function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var i=o.getInstance(),n=new m(e,i,this);b.set(this,n)};["observe","unobserve","disconnect"].forEach((function(t){x.prototype[t]=function(){var e;return(e=b.get(this))[t].apply(e,arguments)}}));void 0!==i.ResizeObserver&&i.ResizeObserver;function _(t){return(_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function k(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function M(t,e){for(var i=0;it.length)&&(e=t.length);for(var i=0,n=new Array(e);i=0;a--)e.call(i,t[a],a);else for(a=0;an&&(n=r),n}function lt(t,e,i,n){var a=(n=n||{}).data=n.data||{},r=n.garbageCollect=n.garbageCollect||[];n.font!==e&&(a=n.data={},r=n.garbageCollect=[],n.font=e),t.save(),t.font=e;var o,s,l,u,c,h=0,d=i.length;for(o=0;oi.length){for(o=0;o0&&t.stroke()}}function ht(t,e){return t.x>e.left-.5&&t.xe.top-.5&&t.y=t}function St(t,e,i){var n,a,r;for(n=0,a=t.length;n0?1:-1};function Dt(t){return t*(yt/180)}function Ot(t){return t*(180/yt)}function At(t){if(Y(t)){for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i}}function Tt(t,e){var i=e.x-t.x,n=e.y-t.y,a=Math.sqrt(i*i+n*n),r=Math.atan2(n,i);return r<-.5*yt&&(r+=mt),{angle:r,distance:a}}function Ct(t,e){return(t-e+bt)%mt-yt}function Et(t){return(t%mt+mt)%mt}function Ft(t,e,i){var n=Et(t),a=Et(e),r=Et(i),o=Et(a-n),s=Et(r-n),l=Et(n-a),u=Et(n-r);return n===a||n===r||o>s&&l0?c[e-1]:null,(a=e0?c[e-1]:null,a=e0&&ht(t[i-1],e)&&(a.controlPointPreviousX=Wt(a.controlPointPreviousX,e.left,e.right),a.controlPointPreviousY=Wt(a.controlPointPreviousY,e.top,e.bottom)),i-1?i*parseInt(e,10)/100:parseInt(e,10)}function $t(t){var e=jt(t);if(!e)return"number"==typeof t.clientWidth?t.clientWidth:t.width;var i=e.clientWidth,n=i-qt(e,"padding-left",i)-qt(e,"padding-right",i),a=function(t){return Ut(t,"max-width","clientWidth")}(t);return isNaN(a)?n:Math.min(n,a)}function Gt(t){var e=jt(t);if(!e)return"number"==typeof t.clientHeight?t.clientHeight:t.height;var i=e.clientHeight,n=i-qt(e,"padding-top",i)-qt(e,"padding-bottom",i),a=function(t){return Ut(t,"max-height","clientHeight")}(t);return isNaN(a)?n:Math.min(n,a)}var Kt=Object.freeze({__proto__:null,_getParentNode:jt,getStyle:Xt,getRelativePosition:function(t,e){var i,n,a=t.originalEvent||t,r=e.canvas,o=r.getBoundingClientRect(),s=a.touches;s&&s.length>0?(i=s[0].clientX,n=s[0].clientY):(i=a.clientX,n=a.clientY);var l=parseFloat(Xt(r,"padding-left")),u=parseFloat(Xt(r,"padding-top")),c=parseFloat(Xt(r,"padding-right")),h=parseFloat(Xt(r,"padding-bottom")),d=o.right-o.left-l-c,f=o.bottom-o.top-u-h;return{x:i=Math.round((i-o.left-l)/d*r.width/e.currentDevicePixelRatio),y:n=Math.round((n-o.top-u)/f*r.height/e.currentDevicePixelRatio)}},getMaximumWidth:$t,getMaximumHeight:Gt,retinaScale:function(t,e){var i=t.currentDevicePixelRatio=e||"undefined"!=typeof window&&window.devicePixelRatio||1,n=t.canvas,a=t.width,r=t.height;n.height=r*i,n.width=a*i,t.ctx.setTransform(i,0,0,i,0,0),!n.style||n.style.height||n.style.width||(n.style.height=r+"px",n.style.width=a+"px")}}),Zt={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return(t-=1)*t*t+1},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-((t-=1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return(t-=1)*t*t*t*t+1},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return 1-Math.cos(t*(Math.PI/2))},easeOutSine:function(t){return Math.sin(t*(Math.PI/2))},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t)-1)},easeInExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},easeOutExpo:function(t){return 1===t?1:1-Math.pow(2,-10*t)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*--t))},easeInCirc:function(t){return t>=1?t:-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math.sqrt(1-(t-=1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var e,i=0;return 0===t?0:1===t?1:(i||(i=.3),e=i/(2*Math.PI)*Math.asin(1),-1*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i))},easeOutElastic:function(t){var e,i=0;return 0===t?0:1===t?1:(i||(i=.3),e=i/(2*Math.PI)*Math.asin(1),1*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/i)+1)},easeInOutElastic:function(t){var e,i=0;return 0===t?0:2==(t/=.5)?1:(i||(i=.45),e=i/(2*Math.PI)*Math.asin(1),t<1?1*Math.pow(2,10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)*-.5:1*Math.pow(2,-10*(t-=1))*Math.sin((t-e)*(2*Math.PI)/i)*.5+1)},easeInBack:function(t){var e=1.70158;return t*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:function(t){return 1-Zt.easeOutBounce(1-t)},easeOutBounce:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInOutBounce:function(t){return t<.5?.5*Zt.easeInBounce(2*t):.5*Zt.easeOutBounce(2*t-1)+.5}},Qt=new(function(){function t(){k(this,t),this.color="rgba(0,0,0,0.1)",this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.fontColor="#666",this.fontFamily="'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",this.fontSize=12,this.fontStyle="normal",this.lineHeight=1.2,this.hover={onHover:null,mode:"nearest",intersect:!0},this.maintainAspectRatio=!0,this.onClick=null,this.responsive=!0,this.showLines=!0,this.plugins=void 0,this.scale=void 0,this.legend=void 0,this.title=void 0,this.tooltips=void 0,this.doughnut=void 0}return w(t,[{key:"set",value:function(t,e){return K(this[t]||(this[t]={}),e)}}]),t}());function Jt(t,e){var i=(""+t).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}function te(t){var e,i,n,a;return j(t)?(e=+t.top||0,i=+t.right||0,n=+t.bottom||0,a=+t.left||0):e=i=n=a=+t||0,{top:e,right:i,bottom:n,left:a,height:e+n,width:a+i}}function ee(t){var e=U(t.fontSize,Qt.fontSize);"string"==typeof e&&(e=parseInt(e,10));var i={family:U(t.fontFamily,Qt.fontFamily),lineHeight:Jt(U(t.lineHeight,Qt.lineHeight),e),size:e,style:U(t.fontStyle,Qt.fontStyle),weight:null,string:""};return i.string=function(t){return!t||N(t.size)||N(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}(i),i}function ie(t,e,i,n){var a,r,o,s=!0;for(a=0,r=t.length;a>4]+ue[15&t]},de=function(t){return(240&t)>>4==(15&t)}; +/*! + * @kurkle/color v0.1.7 + * https://github.com/kurkle/color#readme + * (c) 2020 Jukka Kurkela + * Released under the MIT License + */function fe(t){var e=function(t){return de(t.r)&&de(t.g)&&de(t.b)&&de(t.a)}(t)?ce:he;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function ve(t){return t+.5|0}var pe=function(t,e,i){return Math.max(Math.min(t,i),e)};function ge(t){return pe(ve(2.55*t),0,255)}function ye(t){return pe(ve(255*t),0,255)}function me(t){return pe(ve(t/2.55)/100,0,1)}function be(t){return pe(ve(100*t),0,100)}var xe=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;var _e=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function ke(t,e,i){var n=e*Math.min(i,1-i),a=function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(e+t/30)%12;return i-n*Math.max(Math.min(a-3,9-a,1),-1)};return[a(0),a(8),a(4)]}function Me(t,e,i){var n=function(n){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(n+t/60)%6;return i-i*e*Math.max(Math.min(a,4-a,1),0)};return[n(5),n(3),n(1)]}function we(t,e,i){var n,a=ke(t,1,.5);for(e+i>1&&(e*=n=1/(e+i),i*=n),n=0;n<3;n++)a[n]*=1-e-i,a[n]+=e;return a}function Se(t){var e,i,n,a=t.r/255,r=t.g/255,o=t.b/255,s=Math.max(a,r,o),l=Math.min(a,r,o),u=(s+l)/2;return s!==l&&(n=s-l,i=u>.5?n/(2-s-l):n/(s+l),e=60*(e=s===a?(r-o)/n+(r>16&255,n>>8&255,255&n]}return o}({OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"});function Ee(t,e,i){if(t){var n=Se(t);n[e]=Math.max(0,Math.min(n[e]+n[e]*i,0===e?360:1)),n=De(n),t.r=n[0],t.g=n[1],t.b=n[2]}}function Fe(t,e){return t?P(e||{},t):t}function Ie(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=ye(t[3]))):(e=Fe(t,{r:0,g:0,b:0,a:1})).a=ye(e.a),e}function Le(t){return"r"===t.charAt(0)?function(t){var e,i,n,a=xe.exec(t),r=255;if(a){if(a[7]!==e){var o=+a[7];r=255&(a[8]?ge(o):255*o)}return e=+a[1],i=+a[3],n=+a[5],{r:e=255&(a[2]?ge(e):e),g:i=255&(a[4]?ge(i):i),b:n=255&(a[6]?ge(n):n),a:r}}}(t):Ae(t)}Ce.transparent=[0,0,0,0];var Re=function(){function t(e){if(k(this,t),e instanceof t)return e;var i,n,a,r,o=_(e);"object"===o?i=Ie(e):"string"===o&&(r=(n=e).length,"#"===n[0]&&(4===r||5===r?a={r:255&17*le[n[1]],g:255&17*le[n[2]],b:255&17*le[n[3]],a:5===r?17*le[n[4]]:255}:7!==r&&9!==r||(a={r:le[n[1]]<<4|le[n[2]],g:le[n[3]]<<4|le[n[4]],b:le[n[5]]<<4|le[n[6]],a:9===r?le[n[7]]<<4|le[n[8]]:255})),i=a||function(t){var e=Ce[t];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}(e)||Le(e)),this._rgb=i,this._valid=!!i}return w(t,[{key:"rgbString",value:function(){return(t=this._rgb)&&(t.a<255?"rgba(".concat(t.r,", ").concat(t.g,", ").concat(t.b,", ").concat(me(t.a),")"):"rgb(".concat(t.r,", ").concat(t.g,", ").concat(t.b,")"));var t}},{key:"hexString",value:function(){return fe(this._rgb)}},{key:"hslString",value:function(){return function(t){if(t){var e=Se(t),i=e[0],n=be(e[1]),a=be(e[2]);return t.a<255?"hsla(".concat(i,", ").concat(n,"%, ").concat(a,"%, ").concat(me(t.a),")"):"hsl(".concat(i,", ").concat(n,"%, ").concat(a,"%)")}}(this._rgb)}},{key:"mix",value:function(t,e){if(t){var i,n=this.rgb,a=t.rgb,r=e===i?.5:e,o=2*r-1,s=n.a-a.a,l=((o*s==-1?o:(o+s)/(1+o*s))+1)/2;i=1-l,n.r=255&l*n.r+i*a.r+.5,n.g=255&l*n.g+i*a.g+.5,n.b=255&l*n.b+i*a.b+.5,n.a=r*n.a+(1-r)*a.a,this.rgb=n}return this}},{key:"clone",value:function(){return new t(this.rgb)}},{key:"alpha",value:function(t){return this._rgb.a=ye(t),this}},{key:"clearer",value:function(t){return this._rgb.a*=1-t,this}},{key:"greyscale",value:function(){var t=this._rgb,e=ve(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}},{key:"opaquer",value:function(t){return this._rgb.a*=1+t,this}},{key:"negate",value:function(){var t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}},{key:"lighten",value:function(t){return Ee(this._rgb,2,t),this}},{key:"darken",value:function(t){return Ee(this._rgb,2,-t),this}},{key:"saturate",value:function(t){return Ee(this._rgb,1,t),this}},{key:"desaturate",value:function(t){return Ee(this._rgb,1,-t),this}},{key:"rotate",value:function(t){return function(t,e){var i=Se(t);i[0]=Oe(i[0]+e),i=De(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}},{key:"valid",get:function(){return this._valid}},{key:"rgb",get:function(){var t=Fe(this._rgb);return t&&(t.a=me(t.a)),t},set:function(t){this._rgb=Ie(t)}}]),t}();function ze(t){return new Re(t)}var Be=function(t){return t instanceof CanvasGradient||t instanceof CanvasPattern};var We=function(t){for(var e=1;e=0;--s)(r=o[s])._active?(r.tick(e),l=!0):(o[s]=o[o.length-1],o.pop());l&&a.draw(),a.options.animation.debug&&function(t,e,i,n){var a=1e3/(i-n)|0,r=t.ctx;r.save(),r.clearRect(0,0,50,24),r.fillStyle="black",r.textAlign="right",e&&(r.fillText(e,50,8),r.fillText(a+" fps",50,18)),r.restore()}(a,o.length,e,t._lastDate),t._notify(a,n,e,"progress"),o.length||(n.running=!1,t._notify(a,n,e,"complete")),i+=o.length}})),t._lastDate=e,0===i&&(t._running=!1)}},{key:"_getAnims",value:function(t){var e=this._charts,i=e.get(t);return i||(i={running:!1,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}},{key:"listen",value:function(t,e,i){this._getAnims(t).listeners[e].push(i)}},{key:"add",value:function(t,e){var i;e&&e.length&&(i=this._getAnims(t).items).push.apply(i,R(e))}},{key:"has",value:function(t){return this._getAnims(t).items.length>0}},{key:"start",value:function(t){var e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((function(t,e){return Math.max(t,e._duration)}),0),this._refresh())}},{key:"running",value:function(t){if(!this._running)return!1;var e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}},{key:"stop",value:function(t){var e=this._charts.get(t);if(e&&e.items.length){for(var i=e.items,n=i.length-1;n>=0;--n)i[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}}},{key:"remove",value:function(t){return this._charts.delete(t)}}]),t}()),Qe={boolean:function(t,e,i){return i>.5?e:t},color:function(t,e,i){var n=We.color(t||"transparent"),a=n.valid&&We.color(e||"transparent");return a&&a.valid?a.mix(n,i).hexString():e},number:function(t,e,i){return t+(e-t)*i}},Je=function(){function t(e,i,n,a){k(this,t);var r=i[n];a=ie([e.to,a,r,e.from]);var o=ie([e.from,r,a]);this._active=!0,this._fn=e.fn||Qe[e.type||_(o)],this._easing=Zt[e.easing||"linear"],this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=Math.floor(e.duration),this._loop=!!e.loop,this._target=i,this._prop=n,this._from=o,this._to=a}return w(t,[{key:"active",value:function(){return this._active}},{key:"update",value:function(t,e,i){var n=this;if(n._active){var a=n._target[n._prop],r=i-n._start,o=n._duration-r;n._start=i,n._duration=Math.floor(Math.max(o,t.duration)),n._to=ie([t.to,e,a,t.from]),n._from=ie([t.from,a,e])}}},{key:"cancel",value:function(){this._active&&(this.tick(Date.now()),this._active=!1)}},{key:"tick",value:function(t){var e,i=this,n=t-i._start,a=i._duration,r=i._prop,o=i._from,s=i._loop,l=i._to;i._active=o!==l&&(s||n1?2-e:e,e=i._easing(Math.min(1,Math.max(0,e))),i._target[r]=i._fn(o,l,e)):i._target[r]=l}}]),t}(),ti=["borderColor","backgroundColor"];Qt.set("animation",{duration:1e3,easing:"easeOutQuart",onProgress:B,onComplete:B,colors:{type:"color",properties:ti},numbers:{type:"number",properties:["x","y","borderWidth","radius","tension"]},active:{duration:400},resize:{duration:0},show:{colors:{type:"color",properties:ti,from:"transparent"},visible:{type:"boolean",duration:0}},hide:{colors:{type:"color",properties:ti,to:"transparent"},visible:{type:"boolean",easing:"easeInExpo"}}});var ei=function(){function t(e,i){k(this,t),this._chart=e,this._properties=new Map,this.configure(i)}return w(t,[{key:"configure",value:function(t){if(j(t)){var e=this._properties,i=function(t){var e={};return Object.keys(t).forEach((function(i){var n=t[i];j(n)||(e[i]=n)})),e}(t);Object.keys(t).forEach((function(n){var a=t[n];j(a)&&(a.properties||[n]).forEach((function(t){e.has(t)?t===n&&e.set(t,P({},e.get(t),a)):e.set(t,P({},i,a))}))}))}}},{key:"_animateOptions",value:function(t,e){var i=e.options,n=[];if(!i)return n;var a=t.options;return a?(a.$shared&&(t.options=a=P({},a,{$shared:!1,$animations:{}})),n=this._createAnimations(a,i)):t.options=i,n}},{key:"_createAnimations",value:function(t,e){var i,n=this._properties,a=[],r=t.$animations||(t.$animations={}),o=Object.keys(e),s=Date.now();for(i=o.length-1;i>=0;--i){var l=o[i];if("$"!==l.charAt(0))if("options"!==l){var u=e[l],c=r[l],h=n.get(l);if(c){if(h&&c.active()){c.update(h,u,s);continue}c.cancel()}h&&h.duration?(r[l]=c=new Je(h,t,l,u),a.push(c)):t[l]=u}else a.push.apply(a,R(this._animateOptions(t,e)))}return a}},{key:"update",value:function(t,e){if(0===this._properties.size)return function(t,e){var i=t.options,n=e.options;i&&n&&!n.$shared&&(i.$shared?t.options=P({},i,n,{$shared:!1}):P(i,n),delete e.options)}(t,e),void P(t,e);var i=this._createAnimations(t,e);return i.length?(Ze.add(this._chart,i),!0):void 0}}]),t}(),ii=We.options.resolve,ni=["push","pop","shift","splice","unshift"];function ai(t,e){var i=t&&t.options||{},n=i.reverse,a=void 0===i.min?e:0,r=void 0===i.max?e:0;return{start:n?r:a,end:n?a:r}}function ri(t,e){var i=t._chartjs;if(i){var n=i.listeners,a=n.indexOf(e);-1!==a&&n.splice(a,1),n.length>0||(ni.forEach((function(e){delete t[e]})),delete t._chartjs)}}function oi(t,e){var i,n,a=[],r=t._getSortedDatasetMetas(e);for(i=0,n=r.length;i0&&(f=s._sorted,r=s._parsed[t-1]),!1===o._parsing)s._parsed=l,s._sorted=!0;else{for(n=We.isArray(l[t])?o.parseArrayData(s,l,t,e):We.isObject(l[t])?o.parseObjectData(s,l,t,e):o.parsePrimitiveData(s,l,t,e),i=0;ir||g=0;--i)if(!m()){y();break}return{min:d,max:f}}},{key:"getAllParsedValues",value:function(t){var e,i,n,a=this._cachedMeta._parsed,r=[];for(e=0,i=a.length;e=0;o--)i=r[o],e[i]=n(a[i])}},{key:"getStyle",value:function(t,e){var i=this,n=i._cachedMeta.dataset;i._config||i.configure();var a=n&&void 0===t?i.resolveDatasetElementOptions(e):i.resolveDataElementOptions(t||0,e&&"active");return e&&i._addAutomaticHoverColors(t,a),a}},{key:"_getContext",value:function(t,e){return{chart:this.chart,dataIndex:t,dataset:this.getDataset(),datasetIndex:this.index,active:e}}},{key:"resolveDatasetElementOptions",value:function(t){var e,i,n,a,r,o=this,s=o.chart,l=o._config,u=s.options.elements[o.datasetElementType._type]||{},c=o.datasetElementOptions,h={},d=o._getContext(void 0,t);for(e=0,i=c.length;en?(e._insertElements(n,a-n),t&&n&&e.parse(0,n)):aa?(s=a/e.innerRadius,t.arc(r,o,e.innerRadius-a,n+s,i-s,!0)):t.arc(r,o,a,n+Math.PI/2,i-Math.PI/2),t.closePath(),t.clip()}function gi(t,e,i){var n=e.options,a="inner"===n.borderAlign;a?(t.lineWidth=2*n.borderWidth,t.lineJoin="round"):(t.lineWidth=n.borderWidth,t.lineJoin="bevel"),i.fullCircles&&function(t,e,i,n){var a,r=i.endAngle;for(n&&(i.endAngle=i.startAngle+vi,pi(t,i),i.endAngle=r,i.endAngle===i.startAngle&&i.fullCircles&&(i.endAngle+=vi,i.fullCircles--)),t.beginPath(),t.arc(i.x,i.y,i.innerRadius,i.startAngle+vi,i.startAngle,!0),a=0;a=vi||Ft(a,s,l))&&(r>=u&&r<=c)}},{key:"getCenterPoint",value:function(t){var e=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),i=e.x,n=e.y,a=(e.startAngle+e.endAngle)/2,r=(e.innerRadius+e.outerRadius)/2;return{x:i+Math.cos(a)*r,y:n+Math.sin(a)*r}}},{key:"tooltipPosition",value:function(t){return this.getCenterPoint(t)}},{key:"draw",value:function(t){var e,i=this,n=i.options,a="inner"===n.borderAlign?.33:0,r={x:i.x,y:i.y,innerRadius:i.innerRadius,outerRadius:Math.max(i.outerRadius-a,0),pixelMargin:a,startAngle:i.startAngle,endAngle:i.endAngle,fullCircles:Math.floor(i.circumference/vi)};if(t.save(),t.fillStyle=n.backgroundColor,t.strokeStyle=n.borderColor,r.fullCircles){for(r.endAngle=r.startAngle+vi,t.beginPath(),t.arc(r.x,r.y,r.outerRadius,r.startAngle,r.endAngle),t.arc(r.x,r.y,r.innerRadius,r.endAngle,r.startAngle,!0),t.closePath(),e=0;e0?e.y:t.y}}function xi(t,e,i,n){var a={x:t.controlPointNextX,y:t.controlPointNextY},r={x:e.controlPointPreviousX,y:e.controlPointPreviousY},o=mi(t,a,i),s=mi(a,r,i),l=mi(r,e,i),u=mi(o,s,i),c=mi(s,l,i);return mi(u,c,i)}function _i(t){return"angle"===t?{between:Ft,compare:Ct,normalize:Et}:{between:function(t,e,i){return t>=e&&t<=i},compare:function(t,e){return t-e},normalize:function(t){return t}}}function ki(t,e,i,n){return{start:t%n,end:e%n,loop:i&&(e-t+1)%n==0}}function Mi(t,e,i){if(!i)return[t];var n,a,r,o,s=i.property,l=i.start,u=i.end,c=e.length,h=_i(s),d=h.compare,f=h.between,v=h.normalize,p=function(t,e,i){var n,a,r=i.property,o=i.start,s=i.end,l=_i(r),u=l.between,c=l.normalize,h=e.length,d=t.start,f=t.end,v=t.loop;if(v){for(d+=h,f+=h,n=0,a=h;ng&&d(a,l)>0?o:n),null===_||x&&0!==d(a,u)||(b.push(ki(_,n,m,c)),_=null),o=n);return null!==_&&b.push(ki(_,y,m,c)),b}function wi(t,e){for(var i=[],n=t.segments,a=0;al&&(l=k),b=(x*b+_)/++x):(s!==l&&(t.lineTo(b,l),t.lineTo(b,s),t.lineTo(b,u)),t.lineTo(_,k),o=M,x=0,s=l=k),u=k}}function Ai(t){var e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._loop||e.tension||e.stepped||i)?Oi:Di}Qt.set("elements",{line:{backgroundColor:Si,borderCapStyle:"butt",borderColor:Si,borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,fill:!0,tension:.4}});var Ti=function(t){O(i,t);var e=I(i);function i(t){var n;return k(this,i),(n=e.call(this)).options=void 0,n._loop=void 0,n._fullLoop=void 0,n._controlPointsUpdated=void 0,n._points=void 0,n._segments=void 0,t&&P(E(n),t),n}return w(i,[{key:"updateControlPoints",value:function(t){var e=this;if(!e._controlPointsUpdated){var i=e.options;if(i.tension&&!i.stepped){var n=i.spanGaps?e._loop:e._fullLoop;Vt(e._points,i,t,n)}}}},{key:"first",value:function(){var t=this.segments,e=this.points;return t.length&&e[t[0].start]}},{key:"last",value:function(){var t=this.segments,e=this.points,i=t.length;return i&&e[t[i-1].end]}},{key:"interpolate",value:function(t,e){var i=this.options,n=t[e],a=this.points,r=wi(this,{property:e,start:n,end:n});if(r.length){var o,s,l=[],u=function(t){return t.stepped?bi:t.tension?xi:mi}(i);for(o=0,s=r.length;oa&&t[r%e].skip;)r--;return{start:a,end:r%=e}}(e,n,a,i),o=r.start,s=r.end;return!0===i?[{start:o,end:s,loop:a}]:function(t,e,i,n){var a,r=t.length,o=[],s=e,l=t[e];for(a=e+1;a<=i;++a){var u=t[a%r];u.skip||u.stop?l.skip||(n=!1,o.push({start:e%r,end:(a-1)%r,loop:n}),e=s=u.stop?a:null):(s=a,l.skip&&(e=a)),l=u}return null!==s&&o.push({start:e%r,end:s%r,loop:n}),o}(e,o,st.x&&(e=Li(e,"left","right")):t.base=o.left&&e<=o.right)&&(r||i>=o.top&&i<=o.bottom)}Qt.set("elements",{rectangle:{backgroundColor:Fi,borderColor:Fi,borderSkipped:"bottom",borderWidth:0}});var Wi=function(t){O(i,t);var e=I(i);function i(t){var n;return k(this,i),(n=e.call(this)).options=void 0,n.horizontal=void 0,n.base=void 0,n.width=void 0,n.height=void 0,t&&P(E(n),t),n}return w(i,[{key:"draw",value:function(t){var e,i,n,a,r,o=this.options,s=(i=Ii(e=this),n=i.right-i.left,a=i.bottom-i.top,r=zi(e,n/2,a/2),{outer:{x:i.left,y:i.top,w:n,h:a},inner:{x:i.left+r.l,y:i.top+r.t,w:n-r.l-r.r,h:a-r.t-r.b}}),l=s.inner,u=s.outer;t.save(),u.w===l.w&&u.h===l.h||(t.beginPath(),t.rect(u.x,u.y,u.w,u.h),t.clip(),t.rect(l.x,l.y,l.w,l.h),t.fillStyle=o.borderColor,t.fill("evenodd")),t.fillStyle=o.backgroundColor,t.fillRect(l.x,l.y,l.w,l.h),t.restore()}},{key:"inRange",value:function(t,e,i){return Bi(this,t,e,i)}},{key:"inXRange",value:function(t,e){return Bi(this,t,null,e)}},{key:"inYRange",value:function(t,e){return Bi(this,null,t,e)}},{key:"getCenterPoint",value:function(t){var e=this.getProps(["x","y","base","horizontal"],t),i=e.x,n=e.y,a=e.base,r=e.horizontal;return{x:r?(i+a)/2:i,y:r?n:(n+a)/2}}},{key:"getRange",value:function(t){return"x"===t?this.width/2:this.height/2}}]),i}(fi);S(Wi,"_type","rectangle");var Vi=Object.freeze({__proto__:null,Arc:yi,Line:Ti,Point:Ei,Rectangle:Wi});function Ni(t,e,i,n){var a=i.parse(t[0],n),r=i.parse(t[1],n),o=Math.min(a,r),s=Math.max(a,r),l=o,u=s;Math.abs(o)>Math.abs(s)&&(l=s,u=o),e[i.axis]=u,e._custom={barStart:l,barEnd:u,start:a,end:r,min:o,max:s}}function Hi(t,e,i,n){var a,r,o,s,l=t.iScale,u=t.vScale,c=l.getLabels(),h=l===u,d=[];for(a=i,r=i+n;a0?Math.min(o,Math.abs(n-i)):o,i=n;return o}(n,a),pixels:a,start:n._startPixel,end:n._endPixel,stackCount:this._getStackCount(),scale:n}}},{key:"_calculateBarValuePixels",value:function(t,e){var i,n,a=this._cachedMeta,r=a.vScale,o=e.minBarLength,s=this.getParsed(t),l=s._custom,u=s[r.axis],c=0,h=a._stacked?this.applyStack(r,s):u;h!==u&&(c=h-u,h=u),ji(l)&&(u=l.barStart,h=l.barEnd-l.barStart,0!==u&&Pt(u)!==Pt(l.barEnd)&&(c=0),c+=u);var d=It(r.getPixelForValue(c),r._startPixel-10,r._endPixel+10);return n=(i=r.getPixelForValue(c+h))-d,void 0!==o&&Math.abs(n)0?n[t-1]:null,o=t=0;--t)e=Math.max(e,this.getStyle(t,!0).radius);return e>0&&e}},{key:"getLabelAndValue",value:function(t){var e=this._cachedMeta,i=e.xScale,n=e.yScale,a=this.getParsed(t),r=i.getLabelForValue(a.x),o=n.getLabelForValue(a.y),s=a._custom;return{label:e.label,value:"("+r+", "+o+(s?", "+s:"")+")"}}},{key:"update",value:function(t){var e=this._cachedMeta.data;this.updateElements(e,0,t)}},{key:"updateElements",value:function(t,e,i){for(var n=this,a="reset"===i,r=n._cachedMeta,o=r.xScale,s=r.yScale,l=n.resolveDataElementOptions(e,i),u=n.getSharedOptions(i,t[e],l),c=n.includeOptions(i,u),h=0;h=Xi?-qi:s<-Xi?qi:0)+e,u=Math.cos(s),c=Math.sin(s),h=Math.cos(l),d=Math.sin(l),f=s<=0&&l>=0||l>=qi,v=s<=$i&&l>=$i||l>=qi+$i,p=s<=-$i&&l>=-$i||l>=Xi+$i,g=s===-Xi||l>=Xi?-1:Math.min(u,u*i,h,h*i),y=p?-1:Math.min(c,c*i,d,d*i),m=f?1:Math.max(u,u*i,h,h*i),b=v?1:Math.max(c,c*i,d,d*i);n=(m-g)/2,a=(b-y)/2,r=-(m+g)/2,o=-(b+y)/2}return{ratioX:n,ratioY:a,offsetX:r,offsetY:o}}(a.rotation,a.circumference,s),c=u.ratioX,h=u.ratioY,d=u.offsetX,f=u.offsetY,v=e.getMaxBorderWidth(),p=(n.right-n.left-v)/c,g=(n.bottom-n.top-v)/h,y=Math.max(Math.min(p,g)/2,0),m=(y-Math.max(y*s,0))/e._getVisibleDatasetWeightTotal();e.offsetX=d*y,e.offsetY=f*y,r.total=e.calculateTotal(),e.outerRadius=y-m*e._getRingWeightOffset(e.index),e.innerRadius=Math.max(e.outerRadius-m*l,0),e.updateElements(o,0,t)}},{key:"_circumference",value:function(t,e){var i=this.chart.options,n=this._cachedMeta;return e&&i.animation.animateRotate?0:this.chart.getDataVisibility(t)?this.calculateCircumference(n._parsed[t]*i.circumference/qi):0}},{key:"updateElements",value:function(t,e,i){var n,a=this,r="reset"===i,o=a.chart,s=o.chartArea,l=o.options,u=l.animation,c=(s.left+s.right)/2,h=(s.top+s.bottom)/2,d=r&&u.animateScale,f=d?0:a.innerRadius,v=d?0:a.outerRadius,p=a.resolveDataElementOptions(e,i),g=a.getSharedOptions(i,t[e],p),y=a.includeOptions(i,g),m=l.rotation;for(n=0;n0&&!isNaN(t)?qi*(Math.abs(t)/e):0}},{key:"getMaxBorderWidth",value:function(t){var e,i,n,a,r,o=0,s=this.chart;if(!t)for(e=0,i=s.data.datasets.length;e0&&m.x-n.x>v};d&&(_.options=a.resolveDataElementOptions(g,i)),a.updateElement(y,g,_,i),n=m}a.updateSharedOptions(h,i)}},{key:"resolveDatasetElementOptions",value:function(t){var e=this._config,n=this.chart.options,a=n.elements.line,r=L(A(i.prototype),"resolveDatasetElementOptions",this).call(this,t);return r.spanGaps=U(e.spanGaps,n.spanGaps),r.tension=U(e.lineTension,a.tension),r.stepped=ie([e.stepped,a.stepped]),r}},{key:"getMaxOverflow",value:function(){var t=this._cachedMeta,e=this._showLine&&t.dataset.options.borderWidth||0,i=t.data||[];if(!i.length)return e;var n=i[0].size(),a=i[i.length-1].size();return Math.max(e,n,a)/2}},{key:"draw",value:function(){var t,e,i=this._ctx,n=this.chart,a=this._cachedMeta,r=a.data||[],o=n.chartArea,s=[],l=r.length;for(this._showLine&&a.dataset.draw(i,o),t=0;t1;)t[n=r+a>>1][e]1;)t[n=r+a>>1][e]0){var s=o[0].datasetIndex,l=t.getDatasetMeta(s).data;o=[];for(var u=0;ue){for(var n=e;n=0;--e)this._drawDataset(t[e]);Mn.notify(this,"afterDatasetsDraw")}}},{key:"_drawDataset",value:function(t){var e=this,i=e.ctx,n=t._clip,a=e.chartArea,r={meta:t,index:t.index};!1!==Mn.notify(e,"beforeDatasetDraw",[r])&&(We.canvas.clipArea(i,{left:!1===n.left?0:a.left-n.left,right:!1===n.right?e.width:a.right+n.right,top:!1===n.top?0:a.top-n.top,bottom:!1===n.bottom?e.height:a.bottom+n.bottom}),t.controller.draw(),We.canvas.unclipArea(i),Mn.notify(e,"afterDatasetDraw",[r]))}},{key:"getElementAtEvent",value:function(t){return cn.modes.nearest(this,t,{intersect:!0})}},{key:"getElementsAtEvent",value:function(t){return cn.modes.index(this,t,{intersect:!0})}},{key:"getElementsAtXAxis",value:function(t){return cn.modes.index(this,t,{intersect:!1})}},{key:"getElementsAtEventForMode",value:function(t,e,i,n){var a=cn.modes[e];return"function"==typeof a?a(this,t,i,n):[]}},{key:"getDatasetAtEvent",value:function(t){return cn.modes.dataset(this,t,{intersect:!0})}},{key:"getDatasetMeta",value:function(t){var e=this.data.datasets[t],i=this._metasets,n=i.filter((function(t){return t._dataset===e})).pop();return n||(n=i[t]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1}),n}},{key:"getVisibleDatasetCount",value:function(){return this.getSortedVisibleDatasetMetas().length}},{key:"isDatasetVisible",value:function(t){var e=this.getDatasetMeta(t);return"boolean"==typeof e.hidden?!e.hidden:!this.data.datasets[t].hidden}},{key:"setDatasetVisibility",value:function(t,e){this.getDatasetMeta(t).hidden=!e}},{key:"toggleDataVisibility",value:function(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}},{key:"getDataVisibility",value:function(t){return!this._hiddenIndices[t]}},{key:"_updateDatasetVisibility",value:function(t,e){var i=e?"show":"hide",n=this.getDatasetMeta(t),a=n.controller._resolveAnimations(void 0,i);this.setDatasetVisibility(t,e),a.update(n,{visible:e}),this.update((function(e){return e.datasetIndex===t?i:void 0}))}},{key:"hide",value:function(t){this._updateDatasetVisibility(t,!1)}},{key:"show",value:function(t){this._updateDatasetVisibility(t,!0)}},{key:"_destroyDatasetMeta",value:function(t){var e=this._metasets&&this._metasets[t];e&&(e.controller._destroy(),delete this._metasets[t])}},{key:"destroy",value:function(){var e,i,n=this,a=n.canvas;for(n.stop(),Ze.remove(n),e=0,i=n.data.datasets.length;e3?i[2].value-i[1].value:i[1].value-i[0].value;Math.abs(n)>1&&t!==Math.floor(t)&&(n=t-Math.floor(t));var a=_t(Math.abs(n)),r=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value)),o=Math.min(Math.abs(i[0].value),Math.abs(i[i.length-1].value)),s=this.chart.options.locale;if(r<1e-4||o>1e7){var l=_t(Math.abs(t)),u=Math.floor(l)-Math.floor(a);return u=Math.max(Math.min(u,20),0),t.toExponential(u)}var c=-1*Math.floor(a);return c=Math.max(Math.min(c,20),0),new Intl.NumberFormat(s,{minimumFractionDigits:c,maximumFractionDigits:c}).format(t)},logarithmic:function(t,e,i){if(0===t)return"0";var n=t/Math.pow(10,Math.floor(_t(t)));return 1===n||2===n||5===n?Bn.numeric.call(this,t,e,i):""}},Wn={formatters:Bn};function Vn(t,e){for(var i=[],n=t.length/e,a=t.length,r=0;rs+1e-6)))return l}function Hn(t){return t.drawTicks?t.tickMarkLength:0}function jn(t){if(!t.display)return 0;var e=ee(t),i=te(t.padding);return e.lineHeight+i.height}function Yn(t,e,i,n,a){var r,o,s,l=U(n,0),u=Math.min(U(a,t.length),t.length),c=0;for(i=Math.ceil(i),a&&(i=(r=a-n)/Math.floor(r/i)),s=l;s<0;)c++,s=Math.round(l+c*i);for(o=Math.max(l,0);o=l||o<=1||!n.isHorizontal())n.labelRotation=s;else{var c=n._getLabelSizes(),h=c.widest.width,d=c.highest.height-c.highest.offset,f=Math.min(n.maxWidth,n.chart.width-h);h+6>(t=a.offset?n.maxWidth/o:f/(o-1))&&(t=f/(o-(a.offset?.5:1)),e=n.maxHeight-Hn(a.gridLines)-r.padding-jn(a.scaleLabel),i=Math.sqrt(h*h+d*d),u=Ot(Math.min(Math.asin(Math.min((c.highest.height+6)/t,1)),Math.asin(Math.min(e/i,1))-Math.asin(d/i))),u=Math.max(s,Math.min(l,u))),n.labelRotation=u}}},{key:"afterCalculateLabelRotation",value:function(){X(this.options.afterCalculateLabelRotation,[this])}},{key:"beforeFit",value:function(){X(this.options.beforeFit,[this])}},{key:"fit",value:function(){var t=this,e={width:0,height:0},i=t.chart,n=t.options,a=n.ticks,r=n.scaleLabel,o=n.gridLines,s=t._isVisible(),l="top"!==n.position&&"x"===t.axis,u=t.isHorizontal();if(u?e.width=t.maxWidth:s&&(e.width=Hn(o)+jn(r)),u?s&&(e.height=Hn(o)+jn(r)):e.height=t.maxHeight,a.display&&s&&t.ticks.length){var c=t._getLabelSizes(),h=c.first,d=c.last,f=c.widest,v=c.highest,p=.8*v.offset,g=a.padding;if(u){var y=0!==t.labelRotation,m=Dt(t.labelRotation),b=Math.cos(m),x=Math.sin(m),_=x*f.width+b*(v.height-(y?v.offset:0))+(y?0:p);e.height=Math.min(t.maxHeight,e.height+_+g);var k,M,w=t.getPixelForTick(0)-t.left,S=t.right-t.getPixelForTick(t.ticks.length-1);y?(k=l?b*h.width+x*h.offset:x*(h.height-h.offset),M=l?x*(d.height-d.offset):b*d.width+x*d.offset):(k=h.width/2,M=d.width/2),t.paddingLeft=Math.max((k-w)*t.width/(t.width-w),0)+3,t.paddingRight=Math.max((M-S)*t.width/(t.width-S),0)+3}else{var P=a.mirror?0:f.width+g+p;e.width=Math.min(t.maxWidth,e.width+P),t.paddingTop=h.height/2,t.paddingBottom=d.height/2}}t._handleMargins(),u?(t.width=t._length=i.width-t._margins.left-t._margins.right,t.height=e.height):(t.width=e.width,t.height=t._length=i.height-t._margins.top-t._margins.bottom)}},{key:"_handleMargins",value:function(){var t=this;t._margins&&(t._margins.left=Math.max(t.paddingLeft,t._margins.left),t._margins.top=Math.max(t.paddingTop,t._margins.top),t._margins.right=Math.max(t.paddingRight,t._margins.right),t._margins.bottom=Math.max(t.paddingBottom,t._margins.bottom))}},{key:"afterFit",value:function(){X(this.options.afterFit,[this])}},{key:"isHorizontal",value:function(){var t=this.options,e=t.axis,i=t.position;return"top"===i||"bottom"===i||"x"===e}},{key:"isFullWidth",value:function(){return this.options.fullWidth}},{key:"_convertTicksToLabels",value:function(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t),this.afterTickToLabelConversion()}},{key:"_getLabelSizes",value:function(){var t=this._labelSizes;return t||(this._labelSizes=t=this._computeLabelSizes()),t}},{key:"_computeLabelSizes",value:function(){var t=this,e=t.ctx,i=t._longestTextCache,n=t.options.ticks.sampleSize,a=[],r=[],o=[],s=t.ticks;ne){for(i=0;ie.length-1?null:this.getPixelForValue(e[t].value)}},{key:"getPixelForDecimal",value:function(t){return this._reversePixels&&(t=1-t),this._startPixel+t*this._length}},{key:"getDecimalForPixel",value:function(t){var e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}},{key:"getBasePixel",value:function(){return this.getPixelForValue(this.getBaseValue())}},{key:"getBaseValue",value:function(){var t=this.min,e=this.max;return t<0&&e<0?e:t>0&&e>0?t:0}},{key:"_autoSkip",value:function(t){var e=this.options.ticks,i=e.maxTicksLimit||this._length/this._tickSize(),n=e.major.enabled?function(t){var e,i,n=[];for(e=0,i=t.length;ei)return function(t,e,i,n){var a,r=0,o=i[0];for(n=Math.ceil(n),a=0;aa)return l}return Math.max(a,1)}(n,t,i);if(a>0){var u,c,h=a>1?Math.round((o-r)/(a-1)):null;for(Yn(t,s,l,N(h)?0:r-h,r),u=0,c=a-1;uo*n?o/i:s/n:s*n0}},{key:"_computeGridLineItems",value:function(t){var e,i,n,a,r,o,s,l,u,c,h,d,f=this,v=f.axis,p=f.chart,g=f.options,y=g.gridLines,m=g.position,b=y.offsetGridLines,x=f.isHorizontal(),_=f.ticks,k=_.length+(b?1:0),M=Hn(y),w=[],S={scale:f,tick:_[0]},P=y.drawBorder?ie([y.borderWidth,y.lineWidth,0],S,0):0,D=P/2,O=function(t){return ut(p,t,P)};if("top"===m)e=O(f.bottom),o=f.bottom-M,l=e-D,c=O(t.top)+D,d=t.bottom;else if("bottom"===m)e=O(f.top),c=t.top,d=O(t.bottom)-D,o=e+D,l=f.top+M;else if("left"===m)e=O(f.right),r=f.right-M,s=e-D,u=O(t.left)+D,h=t.right;else if("right"===m)e=O(f.left),u=t.left,h=O(t.right)-D,r=e+D,s=f.left+M;else if("x"===v){if("center"===m)e=O((t.top+t.bottom)/2);else if(j(m)){var A=Object.keys(m)[0],T=m[A];e=O(f.chart.scales[A].getPixelForValue(T))}c=t.top,d=t.bottom,l=(o=e+D)+M}else if("y"===v){if("center"===m)e=O((t.left+t.right)/2);else if(j(m)){var C=Object.keys(m)[0],E=m[C];e=O(f.chart.scales[C].getPixelForValue(E))}s=(r=e-D)-M,u=t.left,h=t.right}for(i=0;i0&&""!==u.strokeStyle;o.save(),o.translate(l.x,l.y),o.rotate(l.rotation),o.font=u.string,o.fillStyle=u.color,o.textBaseline="middle",o.textAlign=l.textAlign,c&&(o.strokeStyle=u.strokeStyle,o.lineWidth=u.lineWidth);var h=l.label,d=l.textOffset;if(H(h))for(n=0,r=h.length;n=0&&te.length-1?null:this.getPixelForValue(t*this._numLabels/e.length+this.min)}},{key:"getValueForPixel",value:function(t){var e=Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange);return Math.min(Math.max(e,0),this.ticks.length-1)}},{key:"getBasePixel",value:function(){return this.bottom}}]),i}(Un);function qn(t,e){var i=Math.floor(_t(t)),n=t/Math.pow(10,i);return(e?n<1.5?1:n<3?2:n<7?5:10:n<=1?1:n<=2?2:n<=5?5:10)*Math.pow(10,i)}S(Xn,"id","category"),S(Xn,"defaults",{});var $n=function(t){O(i,t);var e=I(i);function i(t){var n;return k(this,i),(n=e.call(this,t)).start=void 0,n.end=void 0,n._startValue=void 0,n._endValue=void 0,n._valueRange=0,n}return w(i,[{key:"parse",value:function(t,e){return N(t)||("number"==typeof t||t instanceof Number)&&!isFinite(+t)?NaN:+t}},{key:"handleTickRangeOptions",value:function(){var t=this,e=t.options;if(e.beginAtZero){var i=Pt(t.min),n=Pt(t.max);i<0&&n<0?t.max=0:i>0&&n>0&&(t.min=0)}var a=void 0!==e.min||void 0!==e.suggestedMin,r=void 0!==e.max||void 0!==e.suggestedMax;void 0!==e.min?t.min=e.min:void 0!==e.suggestedMin&&(null===t.min?t.min=e.suggestedMin:t.min=Math.min(t.min,e.suggestedMin)),void 0!==e.max?t.max=e.max:void 0!==e.suggestedMax&&(null===t.max?t.max=e.suggestedMax:t.max=Math.max(t.max,e.suggestedMax)),a!==r&&t.min>=t.max&&(a?t.max=t.min+1:t.min=t.max-1),t.min===t.max&&(t.max++,e.beginAtZero||t.min--)}},{key:"getTickLimit",value:function(){var t,e=this.options.ticks,i=e.maxTicksLimit,n=e.stepSize;return n?t=Math.ceil(this.max/n)-Math.floor(this.min/n)+1:(t=this.computeTickLimit(),i=i||11),i&&(t=Math.min(i,t)),t}},{key:"computeTickLimit",value:function(){return Number.POSITIVE_INFINITY}},{key:"handleDirectionalChanges",value:function(t){return t}},{key:"buildTicks",value:function(){var t=this,e=t.options,i=e.ticks,n=t.getTickLimit(),a=function(t,e){var i,n,a,r,o=[],s=t.stepSize,l=t.min,u=t.max,c=t.precision,h=s||1,d=t.maxTicks-1,f=e.min,v=e.max,p=qn((v-f)/d/h)*h;if(p<1e-14&&N(l)&&N(u))return[{value:f},{value:v}];(r=Math.ceil(v/p)-Math.floor(f/p))>d&&(p=qn(r*p/d/h)*h),s||N(c)?i=Math.pow(10,At(p)):(i=Math.pow(10,c),p=Math.ceil(p*i)/i),n=Math.floor(f/p)*p,a=Math.ceil(v/p)*p,!s||N(l)||N(u)||wt((u-l)/s,p/1e3)&&(n=l,a=u),r=Mt(r=(a-n)/p,Math.round(r),p/1e3)?Math.round(r):Math.ceil(r),n=Math.round(n*i)/i,a=Math.round(a*i)/i,o.push({value:N(l)?n:l});for(var g=1;g0&&(t.min=0),t.handleTickRangeOptions()}},{key:"computeTickLimit",value:function(){if(this.isHorizontal())return Math.ceil(this.width/40);var t=ee(this.options.ticks);return Math.ceil(this.height/t.lineHeight)}},{key:"handleDirectionalChanges",value:function(t){return this.isHorizontal()?t:t.reverse()}},{key:"getPixelForValue",value:function(t){return this.getPixelForDecimal((t-this._startValue)/this._valueRange)}},{key:"getValueForPixel",value:function(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}]),i}($n);function Zn(t){return 1===t/Math.pow(10,Math.floor(_t(t)))}function Qn(t,e){return Y(t)?t:e}S(Kn,"id","linear"),S(Kn,"defaults",Gn);var Jn={ticks:{callback:Wn.formatters.logarithmic,major:{enabled:!0}}},ta=function(t){O(i,t);var e=I(i);function i(t){var n;return k(this,i),(n=e.call(this,t)).start=void 0,n.end=void 0,n._startValue=void 0,n._valueRange=0,n}return w(i,[{key:"parse",value:function(t,e){var i=$n.prototype.parse.apply(this,[t,e]);if(0!==i)return Y(i)&&i>0?i:NaN}},{key:"determineDataLimits",value:function(){var t=this.getMinMax(!0),e=t.min,i=t.max;this.min=Y(e)?Math.max(0,e):null,this.max=Y(i)?Math.max(0,i):null,this.handleTickRangeOptions()}},{key:"handleTickRangeOptions",value:function(){var t=this.min,e=this.max;t===e&&(t<=0?(t=1,e=10):(t=Math.pow(10,Math.floor(_t(t))-1),e=Math.pow(10,Math.floor(_t(e))+1))),t<=0&&(t=Math.pow(10,Math.floor(_t(e))-1)),e<=0&&(e=Math.pow(10,Math.floor(_t(t))+1)),this.min=t,this.max=e}},{key:"buildTicks",value:function(){var t=this,e=t.options,i=function(t,e){var i=Math.floor(_t(e.max)),n=Math.ceil(e.max/Math.pow(10,i)),a=[],r=Qn(t.min,Math.pow(10,Math.floor(_t(e.min)))),o=Math.floor(_t(r)),s=Math.floor(r/Math.pow(10,o)),l=o<0?Math.pow(10,Math.abs(o)):1;do{a.push({value:r,major:Zn(r)}),10===++s&&(s=1,l=++o>=0?1:l),r=Math.round(s*Math.pow(10,o)*l)/l}while(oa?{start:e-i,end:e}:{start:e,end:e+i}}function sa(t){return 0===t||180===t?"center":t<180?"left":"right"}function la(t,e,i,n){var a,r,o=i.y+n/2;if(We.isArray(e))for(a=0,r=e.length;a270||t<90)&&(i.y-=e.h)}function ca(t){return kt(t)?t:0}var ha=function(t){O(i,t);var e=I(i);function i(t){var n;return k(this,i),(n=e.call(this,t)).xCenter=void 0,n.yCenter=void 0,n.drawingArea=void 0,n.pointLabels=[],n}return w(i,[{key:"setDimensions",value:function(){var t=this;t.width=t.maxWidth,t.height=t.maxHeight,t.paddingTop=ra(t.options)/2,t.xCenter=Math.floor(t.width/2),t.yCenter=Math.floor((t.height-t.paddingTop)/2),t.drawingArea=Math.min(t.height-t.paddingTop,t.width)/2}},{key:"determineDataLimits",value:function(){var t=this.getMinMax(!1),e=t.min,i=t.max;this.min=We.isFinite(e)&&!isNaN(e)?e:0,this.max=We.isFinite(i)&&!isNaN(i)?i:0,this.handleTickRangeOptions()}},{key:"computeTickLimit",value:function(){return Math.ceil(this.drawingArea/ra(this.options))}},{key:"generateTickLabels",value:function(t){var e=this;$n.prototype.generateTickLabels.call(e,t),e.pointLabels=e.chart.data.labels.map((function(t,i){var n=We.callback(e.options.pointLabels.callback,[t,i],e);return n||0===n?n:""}))}},{key:"fit",value:function(){var t=this.options;t.display&&t.pointLabels.display?function(t){var e,i,n,a=We.options._parseFont(t.options.pointLabels),r={l:0,r:t.width,t:0,b:t.height-t.paddingTop},o={};t.ctx.font=a.string,t._pointLabelSizes=[];var s,l,u,c=t.chart.data.labels.length;for(e=0;er.r&&(r.r=f.end,o.r=h),v.startr.b&&(r.b=v.end,o.b=h)}t._setReductions(t.drawingArea,r,o)}(this):this.setCenterPoint(0,0,0,0)}},{key:"_setReductions",value:function(t,e,i){var n=this,a=e.l/Math.sin(i.l),r=Math.max(e.r-n.width,0)/Math.sin(i.r),o=-e.t/Math.cos(i.t),s=-Math.max(e.b-(n.height-n.paddingTop),0)/Math.cos(i.b);a=ca(a),r=ca(r),o=ca(o),s=ca(s),n.drawingArea=Math.min(Math.floor(t-(a+r)/2),Math.floor(t-(o+s)/2)),n.setCenterPoint(a,r,o,s)}},{key:"setCenterPoint",value:function(t,e,i,n){var a=this,r=a.width-e-a.drawingArea,o=t+a.drawingArea,s=i+a.drawingArea,l=a.height-a.paddingTop-n-a.drawingArea;a.xCenter=Math.floor((o+r)/2+a.left),a.yCenter=Math.floor((s+l)/2+a.top+a.paddingTop)}},{key:"getIndexAngle",value:function(t){var e=this.chart;return Et(t*(2*Math.PI/e.data.labels.length)+Dt((e.options||{}).startAngle||0))}},{key:"getDistanceFromCenterForValue",value:function(t){var e=this;if(We.isNullOrUndef(t))return NaN;var i=e.drawingArea/(e.max-e.min);return e.options.reverse?(e.max-t)*i:(t-e.min)*i}},{key:"getPointPosition",value:function(t,e){var i=this.getIndexAngle(t)-Math.PI/2;return{x:Math.cos(i)*e+this.xCenter,y:Math.sin(i)*e+this.yCenter,angle:i}}},{key:"getPointPositionForValue",value:function(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))}},{key:"getBasePosition",value:function(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}},{key:"drawGrid",value:function(){var t,e,i,n=this,a=n.ctx,r=n.options,o=r.gridLines,s=r.angleLines,l=ea(s.lineWidth,o.lineWidth),u=ea(s.color,o.color);if(r.pointLabels.display&&function(t){var e=t.ctx,i=t.options,n=i.pointLabels,a=ra(i),r=t.getDistanceFromCenterForValue(i.ticks.reverse?t.min:t.max),o=We.options._parseFont(n);e.save(),e.font=o.string,e.textBaseline="middle";for(var s=t.chart.data.labels.length-1;s>=0;s--){var l=0===s?a/2:0,u=t.getPointPosition(s,r+l+5),c=ia(n.fontColor,s,Qt.fontColor);e.fillStyle=c;var h=Ot(t.getIndexAngle(s));e.textAlign=sa(h),ua(h,t._pointLabelSizes[s],u),la(e,t.pointLabels[s],u,o.lineHeight)}e.restore()}(n),o.display&&n.ticks.forEach((function(t,i){0!==i&&(e=n.getDistanceFromCenterForValue(n.ticks[i].value),function(t,e,i,n){var a,r=t.ctx,o=e.circular,s=t.chart.data.labels.length,l=ia(e.color,n-1,void 0),u=ia(e.lineWidth,n-1,void 0);if((o||s)&&l&&u){if(r.save(),r.strokeStyle=l,r.lineWidth=u,r.setLineDash&&(r.setLineDash(e.borderDash||[]),r.lineDashOffset=e.borderDashOffset||0),r.beginPath(),o)r.arc(t.xCenter,t.yCenter,i,0,2*Math.PI);else{a=t.getPointPosition(0,i),r.moveTo(a.x,a.y);for(var c=1;c=0;t--)e=n.getDistanceFromCenterForValue(r.ticks.reverse?n.min:n.max),i=n.getPointPosition(t,e),a.beginPath(),a.moveTo(n.xCenter,n.yCenter),a.lineTo(i.x,i.y),a.stroke();a.restore()}}},{key:"drawLabels",value:function(){var t=this,e=t.ctx,i=t.options,n=i.ticks;if(n.display){var a,r,o=t.getIndexAngle(0),s=We.options._parseFont(n),l=ea(n.fontColor,Qt.fontColor);e.save(),e.font=s.string,e.translate(t.xCenter,t.yCenter),e.rotate(o),e.textAlign="center",e.textBaseline="middle",t.ticks.forEach((function(o,u){(0!==u||i.reverse)&&(a=t.getDistanceFromCenterForValue(t.ticks[u].value),n.showLabelBackdrop&&(r=e.measureText(o.label).width,e.fillStyle=n.backdropColor,e.fillRect(-r/2-n.backdropPaddingX,-a-s.size/2-n.backdropPaddingY,r+2*n.backdropPaddingX,s.size+2*n.backdropPaddingY)),e.fillStyle=l,e.fillText(o.label,0,-a))})),e.restore()}}},{key:"drawTitle",value:function(){}}]),i}($n);S(ha,"id","radialLinear"),S(ha,"defaults",aa);var da=Number.MAX_SAFE_INTEGER||9007199254740991,fa={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},va=Object.keys(fa);function pa(t,e){return t-e}function ga(t){var e,i,n=new Set;for(e=0,i=t.length;e1;)t[i=a+n>>1]=i?t[a]:t[r];e.add(o)}}function Ma(t,e,i){var n,a,r=[],o={},s=e.length;for(n=0;n=0&&(e[r].major=!0);return e}(t,r,o,i):r}function wa(t){return"labels"===t.options.ticks.source?ba(t):function(t){var e,i=t._adapter,n=t.min,a=t.max,r=t.options,o=r.time,s=o.unit||_a(o.minUnit,n,a,t._getLabelCapacity(n)),l=U(o.stepSize,1),u="week"===s&&o.isoWeekday,c=new Set,h=n;if(u&&(h=+i.startOf(h,"isoWeek",u)),h=+i.startOf(h,u?"day":s),i.diff(a,n,s)>1e5*l)throw new Error(n+" and "+a+" are too far apart with stepSize of "+l+" "+s);if("data"===t.options.ticks.source){var d=ma(t);for(e=h;en&&t[a-1]>i;)a--;return n>0||a=va.indexOf(i);r--){var o=va[r];if(fa[o].common&&t._adapter.diff(a,n,o)>=e-1)return o}return va[i?va.indexOf(i):0]}(t,l.length,i.minUnit,t.min,t.max)),t._majorUnit=n.major.enabled&&"year"!==t._unit?function(t){for(var e=va.indexOf(t)+1,i=va.length;ee&&s0?s:1}}]),i}(Un);S(Pa,"id","time"),S(Pa,"defaults",{distribution:"linear",bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{autoSkip:!1,source:"auto",major:{enabled:!1}}});var Da=Object.freeze({__proto__:null,CategoryScale:Xn,LinearScale:Kn,LogarithmicScale:ta,RadialLinearScale:ha,TimeScale:Pa});function Oa(t,e,i){var n=function(t){var e=t.options,i=e.fill,n=U(i&&i.target,i);return void 0===n&&(n=!!e.backgroundColor),!1!==n&&null!==n&&(!0===n?"origin":n)}(t),a=parseFloat(n);return Y(a)&&Math.floor(a)===a?("-"!==n[0]&&"+"!==n[0]||(a=e+a),!(a===e||a<0||a>=i)&&a):["origin","start","end"].indexOf(n)>=0&&n}Qt.set("plugins",{filler:{propagate:!0}});var Aa=function(){function t(e){k(this,t),this.x=e.x,this.y=e.y,this.radius=e.radius}return w(t,[{key:"pathSegment",value:function(t,e,i){var n=this.x,a=this.y,r=this.radius;return e=e||{start:0,end:2*Math.PI},i.reverse?t.arc(n,a,r,e.end,e.start,!0):t.arc(n,a,r,e.start,e.end),!i.bounds}},{key:"interpolate",value:function(t,e){var i=this.x,n=this.y,a=this.radius,r=t.angle;if("angle"===e)return{x:i+Math.cos(r)*a,y:n+Math.sin(r)*a,angle:r}}}]),t}();function Ta(t){return(t.scale||{}).getPointPositionForValue?function(t){var e,i,n=t.scale,a=t.fill,r=n.options,o=n.getLabels().length,s=[],l=r.reverse?n.max:n.min,u=r.reverse?n.min:n.max,c="start"===a?l:"end"===a?u:n.getBaseValue();if(r.gridLines.circular)return i=n.getPointPositionForValue(0,l),new Aa({x:i.x,y:i.y,radius:n.getDistanceFromCenterForValue(c)});for(e=0;e=0;--e)(i=n[e].$filler)&&i.line.updateControlPoints(a)},beforeDatasetDraw:function(t,e){var i=t.chartArea,n=t.ctx,a=e.meta.$filler;if(a&&!1!==a.fill){var r=a.line,o=a.target,s=a.scale,l=r.options,u=l.fill,c=l.backgroundColor||Qt.color,h=u||{},d=h.above,f=void 0===d?c:d,v=h.below,p=void 0===v?c:v;o&&r.points.length&&(dt(n,i),function(t,e){var i=e.line,n=e.target,a=e.above,r=e.below,o=e.area,s=e.scale,l=i._loop?"angle":"x";t.save(),"x"===l&&r!==a&&(Fa(t,n,o.top),Ba(t,{line:i,target:n,color:a,scale:s,property:l}),t.restore(),t.save(),Fa(t,n,o.bottom)),Ba(t,{line:i,target:n,color:r,scale:s,property:l}),t.restore()}(n,{line:r,target:o,above:f,below:p,area:i,scale:s}),ft(n))}}};function Va(t,e){return t.usePointStyle&&t.boxWidth>e?e:t.boxWidth}Qt.set("legend",{display:!0,position:"top",align:"center",fullWidth:!0,reverse:!1,weight:1e3,onClick:function(t,e){var i=e.datasetIndex,n=this.chart;n.isDatasetVisible(i)?(n.hide(i),e.hidden=!0):(n.show(i),e.hidden=!1)},onHover:null,onLeave:null,labels:{boxWidth:40,padding:10,generateLabels:function(t){var e=t.data.datasets,i=t.options.legend||{},n=i.labels&&i.labels.usePointStyle;return t._getSortedDatasetMetas().map((function(t){var i=t.controller.getStyle(n?0:void 0);return{text:e[t.index].label,fillStyle:i.backgroundColor,hidden:!t.visible,lineCap:i.borderCapStyle,lineDash:i.borderDash,lineDashOffset:i.borderDashOffset,lineJoin:i.borderJoinStyle,lineWidth:i.borderWidth,strokeStyle:i.borderColor,pointStyle:i.pointStyle,rotation:i.rotation,datasetIndex:t.index}}),this)}},title:{display:!1,position:"center",text:""}});var Na=function(t){O(i,t);var e=I(i);function i(t){var n;return k(this,i),P(E(n=e.call(this)),t),n.legendHitBoxes=[],n._hoveredItem=null,n.doughnutMode=!1,n.chart=t.chart,n.options=t.options,n.ctx=t.ctx,n.legendItems=void 0,n.columnWidths=void 0,n.columnHeights=void 0,n.lineWidths=void 0,n._minSize=void 0,n.maxHeight=void 0,n.maxWidth=void 0,n.top=void 0,n.bottom=void 0,n.left=void 0,n.right=void 0,n.height=void 0,n.width=void 0,n._margins=void 0,n.paddingTop=void 0,n.paddingBottom=void 0,n.paddingLeft=void 0,n.paddingRight=void 0,n.position=void 0,n.weight=void 0,n.fullWidth=void 0,n}return w(i,[{key:"beforeUpdate",value:function(){}},{key:"update",value:function(t,e,i){var n=this;n.beforeUpdate(),n.maxWidth=t,n.maxHeight=e,n._margins=i,n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeBuildLabels(),n.buildLabels(),n.afterBuildLabels(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate()}},{key:"afterUpdate",value:function(){}},{key:"beforeSetDimensions",value:function(){}},{key:"setDimensions",value:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t._minSize={width:0,height:0}}},{key:"afterSetDimensions",value:function(){}},{key:"beforeBuildLabels",value:function(){}},{key:"buildLabels",value:function(){var t=this,e=t.options.labels||{},i=X(e.generateLabels,[t.chart],t)||[];e.filter&&(i=i.filter((function(i){return e.filter(i,t.chart.data)}))),t.options.reverse&&i.reverse(),t.legendItems=i}},{key:"afterBuildLabels",value:function(){}},{key:"beforeFit",value:function(){}},{key:"fit",value:function(){var t=this,e=t.options,i=e.labels,n=e.display,a=t.ctx,r=ee(i),o=r.size,s=t.legendHitBoxes=[],l=t._minSize,u=t.isHorizontal(),c=t._computeTitleHeight();if(u?(l.width=t.maxWidth,l.height=n?10:0):(l.width=n?10:0,l.height=t.maxHeight),n){if(a.font=r.string,u){var h=t.lineWidths=[0],d=c;a.textAlign="left",a.textBaseline="middle",t.legendItems.forEach((function(t,e){var n=Va(i,o)+o/2+a.measureText(t.text).width;(0===e||h[h.length-1]+n+2*i.padding>l.width)&&(d+=o+i.padding,h[h.length-(e>0?0:1)]=0),s[e]={left:0,top:0,width:n,height:o},h[h.length-1]+=n+i.padding})),l.height+=d}else{var f=i.padding,v=t.columnWidths=[],p=t.columnHeights=[],g=i.padding,y=0,m=0,b=l.height-c;t.legendItems.forEach((function(t,e){var n=Va(i,o)+o/2+a.measureText(t.text).width;e>0&&m+o+2*f>b&&(g+=y+i.padding,v.push(y),p.push(m),y=0,m=0),y=Math.max(y,n),m+=o+f,s[e]={left:0,top:0,width:n,height:o}})),g+=y,v.push(y),p.push(m),l.width+=g}t.width=l.width,t.height=l.height}else t.width=l.width=t.height=l.height=0}},{key:"afterFit",value:function(){}},{key:"isHorizontal",value:function(){return"top"===this.options.position||"bottom"===this.options.position}},{key:"draw",value:function(){var t=this,e=t.options,i=e.labels,n=Qt.color,a=Qt.elements.line,r=t.height,o=t.columnHeights,s=t.width,l=t.lineWidths;if(e.display){t.drawTitle();var u,c=ae(e.rtl,t.left,t._minSize.width),h=t.ctx,d=U(i.fontColor,Qt.fontColor),f=ee(i),v=f.size;h.textAlign=c.textAlign("left"),h.textBaseline="middle",h.lineWidth=.5,h.strokeStyle=d,h.fillStyle=d,h.font=f.string;var p=Va(i,v),g=t.legendHitBoxes,y=function(t,n){switch(e.align){case"start":return i.padding;case"end":return t-n;default:return(t-n+i.padding)/2}},m=t.isHorizontal(),b=this._computeTitleHeight();u=m?{x:t.left+y(s,l[0]),y:t.top+i.padding+b,line:0}:{x:t.left+i.padding,y:t.top+y(r,o[0])+b,line:0},re(t.ctx,e.textDirection);var x=v+i.padding;t.legendItems.forEach((function(e,d){var f=h.measureText(e.text).width,b=p+v/2+f,_=u.x,k=u.y;c.setWidth(t._minSize.width),m?d>0&&_+b+i.padding>t.left+t._minSize.width&&(k=u.y+=x,u.line++,_=u.x=t.left+y(s,l[u.line])):d>0&&k+x>t.top+t._minSize.height&&(_=u.x=_+t.columnWidths[u.line]+i.padding,u.line++,k=u.y=t.top+y(r,o[u.line]));var M=c.x(_);!function(t,e,r){if(!(isNaN(p)||p<=0)){h.save();var o=U(r.lineWidth,a.borderWidth);if(h.fillStyle=U(r.fillStyle,n),h.lineCap=U(r.lineCap,a.borderCapStyle),h.lineDashOffset=U(r.lineDashOffset,a.borderDashOffset),h.lineJoin=U(r.lineJoin,a.borderJoinStyle),h.lineWidth=o,h.strokeStyle=U(r.strokeStyle,n),h.setLineDash&&h.setLineDash(U(r.lineDash,a.borderDash)),i&&i.usePointStyle){var s={radius:p*Math.SQRT2/2,pointStyle:r.pointStyle,rotation:r.rotation,borderWidth:o},l=c.xPlus(t,p/2);ct(h,s,l,e+v/2)}else h.fillRect(c.leftForLtr(t,p),e,p,v),0!==o&&h.strokeRect(c.leftForLtr(t,p),e,p,v);h.restore()}}(M,k,e),g[d].left=c.leftForLtr(M,g[d].width),g[d].top=k,function(t,e,i,n){var a=v/2,r=c.xPlus(t,p+a),o=e+a;h.fillText(i.text,r,o),i.hidden&&(h.beginPath(),h.lineWidth=2,h.moveTo(r,o),h.lineTo(c.xPlus(r,n),o),h.stroke())}(M,k,e,f),m?u.x+=b+i.padding:u.y+=x})),oe(t.ctx,e.textDirection)}}},{key:"drawTitle",value:function(){var t=this,e=t.options,i=e.title,n=ee(i),a=te(i.padding);if(i.display){var r,o,s=ae(e.rtl,t.left,t._minSize.width),l=t.ctx,u=U(i.fontColor,Qt.fontColor),c=i.position,h=n.size/2,d=t.top+a.top+h,f=t.left,v=t.width;if(this.isHorizontal())switch(v=Math.max.apply(Math,R(t.lineWidths)),e.align){case"start":break;case"end":f=t.right-v;break;default:f=(t.left+t.right)/2-v/2}else{var p=Math.max.apply(Math,R(t.columnHeights));switch(e.align){case"start":break;case"end":d+=t.height-p;break;default:d+=(t.height-p)/2}}switch(c){case"start":r=f,o="left";break;case"end":r=f+v,o="right";break;default:r=f+v/2,o="center"}l.textAlign=s.textAlign(o),l.textBaseline="middle",l.strokeStyle=u,l.fillStyle=u,l.font=n.string,l.fillText(i.text,r,d)}}},{key:"_computeTitleHeight",value:function(){var t=this.options.title,e=ee(t),i=te(t.padding);return t.display?e.lineHeight+i.height:0}},{key:"_getLegendItemAt",value:function(t,e){var i,n,a,r=this;if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom)for(a=r.legendHitBoxes,i=0;i=(n=a[i]).left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height)return r.legendItems[i];return null}},{key:"handleEvent",value:function(t){var e=this,i=e.options,n="mouseup"===t.type?"click":t.type;if("mousemove"===n){if(!i.onHover&&!i.onLeave)return}else{if("click"!==n)return;if(!i.onClick)return}var a=e._getLegendItemAt(t.x,t.y);"click"===n?a&&i.onClick&&i.onClick.call(e,t.native,a):(i.onLeave&&a!==e._hoveredItem&&(e._hoveredItem&&i.onLeave.call(e,t.native,e._hoveredItem),e._hoveredItem=a),i.onHover&&a&&i.onHover.call(e,t.native,a))}}]),i}(fi);function Ha(t,e){var i=new Na({ctx:t.ctx,options:e,chart:t});xn.configure(t,i,e),xn.addBox(t,i),t.legend=i}var ja={id:"legend",_element:Na,beforeInit:function(t){var e=t.options.legend;e&&Ha(t,e)},afterUpdate:function(t){var e=t.options.legend,i=t.legend;e?(Z(e,Qt.legend),i?(xn.configure(t,i,e),i.options=e,i.buildLabels()):Ha(t,e)):i&&(xn.removeBox(t,i),delete t.legend)},afterEvent:function(t,e){var i=t.legend;i&&i.handleEvent(e)}};Qt.set("title",{align:"center",display:!1,fontStyle:"bold",fullWidth:!0,padding:10,position:"top",text:"",weight:2e3});var Ya=function(t){O(i,t);var e=I(i);function i(t){var n;return k(this,i),P(E(n=e.call(this)),t),n.chart=t.chart,n.options=t.options,n.ctx=t.ctx,n._margins=void 0,n._padding=void 0,n.legendHitBoxes=[],n.top=void 0,n.bottom=void 0,n.left=void 0,n.right=void 0,n.width=void 0,n.height=void 0,n.maxWidth=void 0,n.maxHeight=void 0,n.position=void 0,n.weight=void 0,n.fullWidth=void 0,n}return w(i,[{key:"beforeUpdate",value:function(){}},{key:"update",value:function(t,e,i){var n=this;n.beforeUpdate(),n.maxWidth=t,n.maxHeight=e,n._margins=i,n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeBuildLabels(),n.buildLabels(),n.afterBuildLabels(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate()}},{key:"afterUpdate",value:function(){}},{key:"beforeSetDimensions",value:function(){}},{key:"setDimensions",value:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height)}},{key:"afterSetDimensions",value:function(){}},{key:"beforeBuildLabels",value:function(){}},{key:"buildLabels",value:function(){}},{key:"afterBuildLabels",value:function(){}},{key:"beforeFit",value:function(){}},{key:"fit",value:function(){var t=this,e=t.options,i={},n=t.isHorizontal();if(e.display){var a=We.isArray(e.text)?e.text.length:1;t._padding=We.options.toPadding(e.padding);var r=a*We.options._parseFont(e).lineHeight+t._padding.height;t.width=i.width=n?t.maxWidth:r,t.height=i.height=n?r:t.maxHeight}else t.width=i.width=t.height=i.height=0}},{key:"afterFit",value:function(){}},{key:"isHorizontal",value:function(){var t=this.options.position;return"top"===t||"bottom"===t}},{key:"draw",value:function(){var t=this,e=t.ctx,i=t.options;if(i.display){var n,a,r,o,s=We.options._parseFont(i),l=s.lineHeight,u=l/2+t._padding.top,c=0,h=t.top,d=t.left,f=t.bottom,v=t.right;if(t.isHorizontal()){switch(i.align){case"start":a=d,o="left";break;case"end":a=v,o="right";break;default:a=d+(v-d)/2,o="center"}r=h+u,n=v-d}else{switch(a="left"===i.position?d+u:v-u,i.align){case"start":r="left"===i.position?f:h,o="left";break;case"end":r="left"===i.position?h:f,o="right";break;default:r=h+(f-h)/2,o="center"}n=f-h,c=Math.PI*("left"===i.position?-.5:.5)}e.save(),e.fillStyle=We.valueOrDefault(i.fontColor,Qt.fontColor),e.font=s.string,e.translate(a,r),e.rotate(c),e.textAlign=o,e.textBaseline="middle";var p=i.text;if(We.isArray(p))for(var g=0,y=0;y0){var r=t[0];r.label?i=r.label:a>0&&r.index-1?t.split("\n"):t}function Qa(t,e){var i=e.datasetIndex,n=e.index,a=t.getDatasetMeta(i).controller.getLabelAndValue(n);return{label:a.label,value:a.value,index:n,datasetIndex:i}}function Ja(t){var e=t._chart.ctx,i=t.body,n=t.footer,a=t.options,r=t.title,o=a.bodyFontSize,s=a.footerFontSize,l=a.titleFontSize,u=a.boxWidth,c=a.boxHeight,h=r.length,d=n.length,f=i.length,v=2*a.yPadding,p=0,g=i.reduce((function(t,e){return t+e.before.length+e.lines.length+e.after.length}),0);(g+=t.beforeBody.length+t.afterBody.length,h&&(v+=h*l+(h-1)*a.titleSpacing+a.titleMarginBottom),g)&&(v+=f*(a.displayColors?Math.max(c,o):o)+(g-f)*o+(g-1)*a.bodySpacing);d&&(v+=a.footerMarginTop+d*s+(d-1)*a.footerSpacing);var y=0,m=function(t){p=Math.max(p,e.measureText(t).width+y)};return e.save(),e.font=We.fontString(l,a.titleFontStyle,a.titleFontFamily),We.each(t.title,m),e.font=We.fontString(o,a.bodyFontStyle,a.bodyFontFamily),We.each(t.beforeBody.concat(t.afterBody),m),y=a.displayColors?u+2:0,We.each(i,(function(t){We.each(t.before,m),We.each(t.lines,m),We.each(t.after,m)})),y=0,e.font=We.fontString(s,a.footerFontStyle,a.footerFontFamily),We.each(t.footer,m),e.restore(),{width:p+=2*a.xPadding,height:v}}function tr(t,e,i){var n,a,r=i.x,o=i.y,s=i.width,l=i.height,u=t.chartArea,c="center",h="center";ot.height-l&&(h="bottom");var d=(u.left+u.right)/2,f=(u.top+u.bottom)/2;"center"===h?(n=function(t){return t<=d},a=function(t){return t>d}):(n=function(t){return t<=s/2},a=function(e){return e>=t.width-s/2});var v=function(t){return t<=f?"top":"bottom"};return n(r)?(c="left",r+s+e.caretSize+e.caretPadding>t.width&&(c="center",h=v(o))):a(r)&&(c="right",function(t){return t-s-e.caretSize-e.caretPadding<0}(r)&&(c="center",h=v(o))),{xAlign:e.xAlign?e.xAlign:c,yAlign:e.yAlign?e.yAlign:h}}function er(t,e,i,n){var a=t.caretSize,r=t.caretPadding,o=t.cornerRadius,s=i.xAlign,l=i.yAlign,u=a+r,c=o+r,h=function(t,e,i){var n=t.x,a=t.width;return"right"===e?n-=a:"center"===e&&((n-=a/2)+a>i&&(n=i-a),n<0&&(n=0)),n}(e,s,n.width);return"center"===l?"left"===s?h+=u:"right"===s&&(h-=u):"left"===s?h-=c:"right"===s&&(h+=c),{x:h,y:function(t,e,i){var n=t.y,a=t.height;return"top"===e?n+=i:n-="bottom"===e?a+i:a/2,n}(e,l,u)}}function ir(t,e){var i=t.options;return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-i.xPadding:t.x+i.xPadding}function nr(t){return Ka([],Za(t))}var ar=function(t){O(i,t);var e=I(i);function i(t){var n;return k(this,i),(n=e.call(this)).opacity=0,n._active=[],n._chart=t._chart,n._eventPosition=void 0,n._size=void 0,n._cachedAnimations=void 0,n.$animations=void 0,n.options=void 0,n.dataPoints=void 0,n.title=void 0,n.beforeBody=void 0,n.body=void 0,n.afterBody=void 0,n.footer=void 0,n.xAlign=void 0,n.yAlign=void 0,n.x=void 0,n.y=void 0,n.height=void 0,n.width=void 0,n.caretX=void 0,n.caretY=void 0,n.labelColors=void 0,n.labelTextColors=void 0,n.initialize(),n}return w(i,[{key:"initialize",value:function(){this.options=function(t){return(t=P({},Qt.tooltips,t)).bodyFontFamily=qa(t.bodyFontFamily,Qt.fontFamily),t.bodyFontStyle=qa(t.bodyFontStyle,Qt.fontStyle),t.bodyFontSize=qa(t.bodyFontSize,Qt.fontSize),t.boxHeight=qa(t.boxHeight,t.bodyFontSize),t.boxWidth=qa(t.boxWidth,t.bodyFontSize),t.titleFontFamily=qa(t.titleFontFamily,Qt.fontFamily),t.titleFontStyle=qa(t.titleFontStyle,Qt.fontStyle),t.titleFontSize=qa(t.titleFontSize,Qt.fontSize),t.footerFontFamily=qa(t.footerFontFamily,Qt.fontFamily),t.footerFontStyle=qa(t.footerFontStyle,Qt.fontStyle),t.footerFontSize=qa(t.footerFontSize,Qt.fontSize),t}(this._chart.options.tooltips)}},{key:"_resolveAnimations",value:function(){var t=this,e=t._cachedAnimations;if(e)return e;var i=t._chart.options.animation&&t.options.animation,n=new ei(t._chart,i);return t._cachedAnimations=Object.freeze(n),n}},{key:"getTitle",value:function(t,e){var i=this.options.callbacks,n=i.beforeTitle.apply(this,[t,e]),a=i.title.apply(this,[t,e]),r=i.afterTitle.apply(this,[t,e]),o=[];return o=Ka(o,Za(n)),o=Ka(o,Za(a)),o=Ka(o,Za(r))}},{key:"getBeforeBody",value:function(t,e){return nr(this.options.callbacks.beforeBody.apply(this,[t,e]))}},{key:"getBody",value:function(t,e){var i=this,n=i.options.callbacks,a=[];return We.each(t,(function(t){var r={before:[],lines:[],after:[]};Ka(r.before,Za(n.beforeLabel.call(i,t,e))),Ka(r.lines,n.label.call(i,t,e)),Ka(r.after,Za(n.afterLabel.call(i,t,e))),a.push(r)})),a}},{key:"getAfterBody",value:function(t,e){return nr(this.options.callbacks.afterBody.apply(this,[t,e]))}},{key:"getFooter",value:function(t,e){var i=this.options.callbacks,n=i.beforeFooter.apply(this,[t,e]),a=i.footer.apply(this,[t,e]),r=i.afterFooter.apply(this,[t,e]),o=[];return o=Ka(o,Za(n)),o=Ka(o,Za(a)),o=Ka(o,Za(r))}},{key:"_createItems",value:function(){var t,e,i=this,n=i._active,a=i.options,r=i._chart.data,o=[],s=[],l=[];for(t=0,e=n.length;t0&&e.stroke()}},{key:"_updateAnimationTarget",value:function(){var t=this,e=t._chart,i=t.options,n=t.$animations,a=n&&n.x,r=n&&n.y;if(a||r){var o=Ga[i.position].call(t,t._active,t._eventPosition);if(!o)return;var s=t._size=Ja(t),l=P({},o,t._size),u=tr(e,i,l),c=er(i,l,u,e);a._to===c.x&&r._to===c.y||(t.xAlign=u.xAlign,t.yAlign=u.yAlign,t.width=s.width,t.height=s.height,t.caretX=o.x,t.caretY=o.y,t._resolveAnimations().update(t,c))}}},{key:"draw",value:function(t){var e=this,i=e.options,n=e.opacity;if(n){e._updateAnimationTarget();var a={width:e.width,height:e.height},r={x:e.x,y:e.y};n=Math.abs(n)<.001?0:n;var o=e.title.length||e.beforeBody.length||e.body.length||e.afterBody.length||e.footer.length;i.enabled&&o&&(t.save(),t.globalAlpha=n,e.drawBackground(r,t,a),We.rtl.overrideTextDirection(t,i.textDirection),r.y+=i.yPadding,e.drawTitle(r,t),e.drawBody(r,t),e.drawFooter(r,t),We.rtl.restoreTextDirection(t,i.textDirection),t.restore())}}},{key:"handleEvent",value:function(t,e){var i,n=this,a=n.options,r=n._active||[],o=[];return"mouseout"!==t.type&&(o=n._chart.getElementsAtEventForMode(t,a.mode,a,e),a.reverse&&o.reverse()),(i=e||!We._elementsEqual(o,r))&&(n._active=o,(a.enabled||a.custom)&&(n._eventPosition={x:t.x,y:t.y},n.update(!0))),i}}]),i}(fi);ar.positioners=Ga;var rr={filler:Wa,legend:ja,title:Xa,tooltip:{id:"tooltip",_element:ar,positioners:Ga,afterInit:function(t){t.options.tooltips&&(t.tooltip=new ar({_chart:t}))},beforeUpdate:function(t){t.tooltip&&t.tooltip.initialize()},reset:function(t){t.tooltip&&t.tooltip.initialize()},afterDraw:function(t){var e=t.tooltip,i={tooltip:e};!1!==Mn.notify(t,"beforeTooltipDraw",[i])&&(e.draw(t.ctx),Mn.notify(t,"afterTooltipDraw",[i]))},afterEvent:function(t,e,i){if(t.tooltip){var n=i;t.tooltip.handleEvent(e,n)}}}};for(var or in In.helpers=We,In._adapters=zn,In.Animation=Je,In.Animator=Ze,In.animationService=ei,In.controllers=tn,In.DatasetController=di,In.defaults=Qt,In.Element=fi,In.elements=Vi,In.Interaction=cn,In.layouts=xn,In.platforms=kn,In.plugins=Mn,In.Scale=Un,In.scaleService=wn,In.Ticks=Wn,Object.keys(Da).forEach((function(t){return In.scaleService.registerScale(Da[t])})),rr)Object.prototype.hasOwnProperty.call(rr,or)&&In.plugins.register(rr[or]);return"undefined"!=typeof window&&(window.Chart=In),In})); diff --git a/docs/next b/docs/next deleted file mode 120000 index fad0a3463f..0000000000 --- a/docs/next +++ /dev/null @@ -1 +0,0 @@ -3.0.0-dev \ No newline at end of file diff --git a/docs/next/0d14b33b.faaea289.js b/docs/next/0d14b33b.faaea289.js new file mode 100644 index 0000000000..545364d795 --- /dev/null +++ b/docs/next/0d14b33b.faaea289.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{137:function(e,t,a){"use strict";a.r(t),a.d(t,"frontMatter",(function(){return l})),a.d(t,"metadata",(function(){return i})),a.d(t,"rightToc",(function(){return d})),a.d(t,"ExampleChart",(function(){return o})),a.d(t,"default",(function(){return j}));var n=a(1),b=a(9),r=a(0),c=a(200),l={title:"Bubble Chart"},i={id:"charts/bubble",title:"Bubble Chart",description:"A bubble chart is used to display three dimensions of data at the same time. The location of the bubble is determined by the first two dimensions and the corresponding horizontal and vertical axes. The third dimension is represented by the size of the individual bubbles.",source:"@site/docs/charts/bubble.mdx",permalink:"/docs/VERSION/charts/bubble",editUrl:"https://github.com/chartjs/Chart.js/edit/master/docs/docs/charts/bubble.mdx",sidebar:"someSidebar",previous:{title:"Polar Area Chart",permalink:"/docs/VERSION/charts/polar"},next:{title:"Scatter Chart",permalink:"/docs/VERSION/charts/scatter"}},d=[{value:"Example Usage",id:"example-usage",children:[]},{value:"Dataset Properties",id:"dataset-properties",children:[{value:"General",id:"general",children:[]},{value:"Styling",id:"styling",children:[]},{value:"Interactions",id:"interactions",children:[]}]},{value:"Default Options",id:"default-options",children:[]},{value:"Data Structure",id:"data-structure",children:[]},{value:"Internal data format",id:"internal-data-format",children:[]}],o=function(){return Object(r.useEffect)((function(){new Chart(document.getElementById("chartjs-0").getContext("2d"),{type:"bubble",data:{datasets:[{label:"First Dataset",data:[{x:20,y:30,r:15},{x:40,y:10,r:10}],backgroundColor:"rgb(255, 99, 132)"}]}})})),Object(c.b)("div",{className:"chartjs-wrapper"},Object(c.b)("canvas",{id:"chartjs-0",className:"chartjs"}))},O={rightToc:d,ExampleChart:o};function j(e){var t=e.components,a=Object(b.a)(e,["components"]);return Object(c.b)("wrapper",Object(n.a)({},O,a,{components:t,mdxType:"MDXLayout"}),Object(c.b)("p",null,"A bubble chart is used to display three dimensions of data at the same time. The location of the bubble is determined by the first two dimensions and the corresponding horizontal and vertical axes. The third dimension is represented by the size of the individual bubbles."),Object(c.b)(o,{mdxType:"ExampleChart"}),Object(c.b)("h2",{id:"example-usage"},"Example Usage"),Object(c.b)("pre",null,Object(c.b)("code",Object(n.a)({parentName:"pre"},{className:"language-javascript"}),"// For a bubble chart\nvar myBubbleChart = new Chart(ctx, {\n type: 'bubble',\n data: data,\n options: options\n});\n")),Object(c.b)("h2",{id:"dataset-properties"},"Dataset Properties"),Object(c.b)("p",null,"The bubble chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the colour of the bubbles is generally set this way."),Object(c.b)("table",null,Object(c.b)("thead",{parentName:"table"},Object(c.b)("tr",{parentName:"thead"},Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Name"),Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Type"),Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:"center"}),Object(c.b)("a",Object(n.a)({parentName:"th"},{href:"/docs/VERSION/general/options#scriptable-options"}),"Scriptable")),Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:"center"}),Object(c.b)("a",Object(n.a)({parentName:"th"},{href:"/docs/VERSION/general/options#indexable-options"}),"Indexable")),Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Default"))),Object(c.b)("tbody",{parentName:"table"},Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#styling"}),Object(c.b)("inlineCode",{parentName:"a"},"backgroundColor"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"/docs/VERSION/general/colors"}),Object(c.b)("inlineCode",{parentName:"a"},"Color"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"'rgba(0, 0, 0, 0.1)'"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#styling"}),Object(c.b)("inlineCode",{parentName:"a"},"borderColor"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"/docs/VERSION/general/colors"}),Object(c.b)("inlineCode",{parentName:"a"},"Color"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"'rgba(0, 0, 0, 0.1)'"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#styling"}),Object(c.b)("inlineCode",{parentName:"a"},"borderWidth"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"number")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"3"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#general"}),Object(c.b)("inlineCode",{parentName:"a"},"clip"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("code",null,"number","|","object")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"-"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"-"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"undefined"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#data-structure"}),Object(c.b)("inlineCode",{parentName:"a"},"data"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"object[]")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"-"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"-"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("strong",{parentName:"td"},"required"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#interactions"}),Object(c.b)("inlineCode",{parentName:"a"},"hoverBackgroundColor"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"/docs/VERSION/general/colors"}),Object(c.b)("inlineCode",{parentName:"a"},"Color"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"undefined"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#interactions"}),Object(c.b)("inlineCode",{parentName:"a"},"hoverBorderColor"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"/docs/VERSION/general/colors"}),Object(c.b)("inlineCode",{parentName:"a"},"Color"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"undefined"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#interactions"}),Object(c.b)("inlineCode",{parentName:"a"},"hoverBorderWidth"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"number")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"1"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#interactions"}),Object(c.b)("inlineCode",{parentName:"a"},"hoverRadius"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"number")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"4"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#interactions"}),Object(c.b)("inlineCode",{parentName:"a"},"hitRadius"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"number")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"1"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#general"}),Object(c.b)("inlineCode",{parentName:"a"},"label"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"string")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"-"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"-"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"undefined"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#general"}),Object(c.b)("inlineCode",{parentName:"a"},"order"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"number")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"-"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"-"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"0"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#styling"}),Object(c.b)("inlineCode",{parentName:"a"},"pointStyle"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"string")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"'circle'"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#styling"}),Object(c.b)("inlineCode",{parentName:"a"},"rotation"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"number")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"0"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"#styling"}),Object(c.b)("inlineCode",{parentName:"a"},"radius"))),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"number")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:"center"}),"Yes"),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"3"))))),Object(c.b)("h3",{id:"general"},"General"),Object(c.b)("table",null,Object(c.b)("thead",{parentName:"table"},Object(c.b)("tr",{parentName:"thead"},Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Name"),Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Description"))),Object(c.b)("tbody",{parentName:"table"},Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"clip")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. ",Object(c.b)("inlineCode",{parentName:"td"},"0")," = clip at chartArea. Clipping can also be configured per side: ",Object(c.b)("inlineCode",{parentName:"td"},"clip: {left: 5, top: false, right: -2, bottom: 0}"))),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"label")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"The label for the dataset which appears in the legend and tooltips.")),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"order")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"The drawing order of dataset. Also affects order for tooltip and legend.")))),Object(c.b)("h3",{id:"styling"},"Styling"),Object(c.b)("p",null,"The style of each bubble can be controlled with the following properties:"),Object(c.b)("table",null,Object(c.b)("thead",{parentName:"table"},Object(c.b)("tr",{parentName:"thead"},Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Name"),Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Description"))),Object(c.b)("tbody",{parentName:"table"},Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"backgroundColor")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble background color.")),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"borderColor")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble border color.")),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"borderWidth")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble border width (in pixels).")),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"pointStyle")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble ",Object(c.b)("a",Object(n.a)({parentName:"td"},{href:"../configuration/elements#point-styles"}),"shape style"),".")),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"rotation")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble rotation (in degrees).")),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"radius")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble radius (in pixels).")))),Object(c.b)("p",null,"All these values, if ",Object(c.b)("inlineCode",{parentName:"p"},"undefined"),", fallback to the associated ",Object(c.b)("a",Object(n.a)({parentName:"p"},{href:"/docs/VERSION/configuration/elements#point-configuration"}),Object(c.b)("inlineCode",{parentName:"a"},"elements.point.*"))," options."),Object(c.b)("h3",{id:"interactions"},"Interactions"),Object(c.b)("p",null,"The interaction with each bubble can be controlled with the following properties:"),Object(c.b)("table",null,Object(c.b)("thead",{parentName:"table"},Object(c.b)("tr",{parentName:"thead"},Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Name"),Object(c.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Description"))),Object(c.b)("tbody",{parentName:"table"},Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"hoverBackgroundColor")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble background color when hovered.")),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"hoverBorderColor")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble border color when hovered.")),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"hoverBorderWidth")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble border width when hovered (in pixels).")),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"hoverRadius")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble ",Object(c.b)("strong",{parentName:"td"},"additional")," radius when hovered (in pixels).")),Object(c.b)("tr",{parentName:"tbody"},Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(c.b)("inlineCode",{parentName:"td"},"hitRadius")),Object(c.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"bubble ",Object(c.b)("strong",{parentName:"td"},"additional")," radius for hit detection (in pixels).")))),Object(c.b)("p",null,"All these values, if ",Object(c.b)("inlineCode",{parentName:"p"},"undefined"),", fallback to the associated ",Object(c.b)("a",Object(n.a)({parentName:"p"},{href:"/docs/VERSION/configuration/elements#point-configuration"}),Object(c.b)("inlineCode",{parentName:"a"},"elements.point.*"))," options."),Object(c.b)("h2",{id:"default-options"},"Default Options"),Object(c.b)("p",null,"We can also change the default values for the Bubble chart type. Doing so will give all bubble charts created after this point the new defaults. The default configuration for the bubble chart can be accessed at ",Object(c.b)("inlineCode",{parentName:"p"},"Chart.defaults.bubble"),"."),Object(c.b)("h2",{id:"data-structure"},"Data Structure"),Object(c.b)("p",null,"Bubble chart datasets need to contain a ",Object(c.b)("inlineCode",{parentName:"p"},"data")," array of points, each points represented by an object containing the following properties:"),Object(c.b)("pre",null,Object(c.b)("code",Object(n.a)({parentName:"pre"},{className:"language-javascript"}),"{\n // X Value\n x: number,\n\n // Y Value\n y: number,\n\n // Bubble radius in pixels (not scaled).\n r: number\n}\n")),Object(c.b)("p",null,Object(c.b)("strong",{parentName:"p"},"Important:")," the radius property, ",Object(c.b)("inlineCode",{parentName:"p"},"r")," is ",Object(c.b)("strong",{parentName:"p"},"not")," scaled by the chart, it is the raw radius in pixels of the bubble that is drawn on the canvas."),Object(c.b)("h2",{id:"internal-data-format"},"Internal data format"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"{x, y, _custom}")," where ",Object(c.b)("inlineCode",{parentName:"p"},"_custom")," is the radius."))}j.isMDXComponent=!0},200:function(e,t,a){"use strict";a.d(t,"a",(function(){return O})),a.d(t,"b",(function(){return m}));var n=a(0),b=a.n(n);function r(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function c(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function l(e){for(var t=1;t=0||(b[a]=e[a]);return b}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(b[a]=e[a])}return b}var d=b.a.createContext({}),o=function(e){var t=b.a.useContext(d),a=t;return e&&(a="function"==typeof e?e(t):l({},t,{},e)),a},O=function(e){var t=o(e.components);return b.a.createElement(d.Provider,{value:t},e.children)},j={inlineCode:"code",wrapper:function(e){var t=e.children;return b.a.createElement(b.a.Fragment,{},t)}},p=Object(n.forwardRef)((function(e,t){var a=e.components,n=e.mdxType,r=e.originalType,c=e.parentName,d=i(e,["components","mdxType","originalType","parentName"]),O=o(a),p=n,m=O["".concat(c,".").concat(p)]||O[p]||j[p]||r;return a?b.a.createElement(m,l({ref:t},d,{components:a})):b.a.createElement(m,l({ref:t},d))}));function m(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var r=a.length,c=new Array(r);c[0]=p;var l={};for(var i in t)hasOwnProperty.call(t,i)&&(l[i]=t[i]);l.originalType=e,l.mdxType="string"==typeof e?e:n,c[1]=l;for(var d=2;d1?arguments[1]:void 0,e.length)),r=String(t);return a?a.call(e,r,n):e.slice(n,n+r.length)===r}})},205:function(t,e,n){"use strict";function r(t){return!1===/^(https?:|\/\/)/.test(t)}n.d(e,"a",(function(){return r}))},206:function(t,e,n){"use strict";n(52),n(204),n(224);var r=n(0),o=n.n(r),i=n(39),a=n(205),c=n(18),u=n.n(c),s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o0)&&(e.unobserve(n),e.disconnect(),r())}))}))).observe(n))},to:p})):o.a.createElement("a",Object.assign({},c,{href:p}))}},207:function(t,e,n){var r=n(78),o=n(31);t.exports=function(t,e,n){if(r(e))throw TypeError("String#"+n+" doesn't accept regex!");return String(o(t))}},208:function(t,e,n){var r=n(2)("match");t.exports=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[r]=!1,!"/./"[t](e)}catch(o){}}return!0}},210:function(t,e,n){var r=n(83),o=n(58).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return r(t,o)}},212:function(t,e,n){"use strict";var r=n(0),o=n.n(r),i=n(221);e.a=function(t){return o.a.createElement(i.a,t)}},214:function(t,e,n){e.f=n(2)},215:function(t,e,n){var r=n(21);t.exports=Array.isArray||function(t){return"Array"==r(t)}},216:function(t,e,n){var r=n(53),o=n(54),i=n(28),a=n(80),c=n(27),u=n(82),s=Object.getOwnPropertyDescriptor;e.f=n(10)?s:function(t,e){if(t=i(t),e=a(e,!0),u)try{return s(t,e)}catch(n){}if(c(t,e))return o(!r.f.call(t,e),t[e])}},221:function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return ht}));var r,o,i,a,c=n(17),u=n.n(c),s=n(222),f=n.n(s),l=n(223),p=n.n(l),d=n(0),y=n.n(d),h=n(56),b=n.n(h),m="bodyAttributes",v="htmlAttributes",g="titleAttributes",T={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title"},w=(Object.keys(T).map((function(t){return T[t]})),"charset"),O="cssText",S="href",E="http-equiv",A="innerHTML",C="itemprop",j="name",P="property",x="rel",k="src",I="target",L={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},N="defaultTitle",M="defer",R="encodeSpecialCharacters",D="onChangeClientState",F="titleTemplate",_=Object.keys(L).reduce((function(t,e){return t[L[e]]=e,t}),{}),H=[T.NOSCRIPT,T.SCRIPT,T.STYLE],W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Y=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},q=function(){function t(t,e){for(var n=0;n=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},K=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},J=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return!1===e?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")},z=function(t){var e=X(t,T.TITLE),n=X(t,F);if(n&&e)return n.replace(/%s/g,(function(){return Array.isArray(e)?e.join(""):e}));var r=X(t,N);return e||r||void 0},$=function(t){return X(t,D)||function(){}},G=function(t,e){return e.filter((function(e){return void 0!==e[t]})).map((function(e){return e[t]})).reduce((function(t,e){return U({},t,e)}),{})},Q=function(t,e){return e.filter((function(t){return void 0!==t[T.BASE]})).map((function(t){return t[T.BASE]})).reverse().reduce((function(e,n){if(!e.length)for(var r=Object.keys(n),o=0;o=0;n--){var r=t[n];if(r.hasOwnProperty(e))return r[e]}return null},Z=(r=Date.now(),function(t){var e=Date.now();e-r>16?(r=e,t(e)):setTimeout((function(){Z(t)}),0)}),tt=function(t){return clearTimeout(t)},et="undefined"!=typeof window?window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||Z:t.requestAnimationFrame||Z,nt="undefined"!=typeof window?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||tt:t.cancelAnimationFrame||tt,rt=function(t){return console&&"function"==typeof console.warn&&console.warn(t)},ot=null,it=function(t,e){var n=t.baseTag,r=t.bodyAttributes,o=t.htmlAttributes,i=t.linkTags,a=t.metaTags,c=t.noscriptTags,u=t.onChangeClientState,s=t.scriptTags,f=t.styleTags,l=t.title,p=t.titleAttributes;ut(T.BODY,r),ut(T.HTML,o),ct(l,p);var d={baseTag:st(T.BASE,n),linkTags:st(T.LINK,i),metaTags:st(T.META,a),noscriptTags:st(T.NOSCRIPT,c),scriptTags:st(T.SCRIPT,s),styleTags:st(T.STYLE,f)},y={},h={};Object.keys(d).forEach((function(t){var e=d[t],n=e.newTags,r=e.oldTags;n.length&&(y[t]=n),r.length&&(h[t]=d[t].oldTags)})),e&&e(),u(t,y,h)},at=function(t){return Array.isArray(t)?t.join(""):t},ct=function(t,e){void 0!==t&&document.title!==t&&(document.title=at(t)),ut(T.TITLE,e)},ut=function(t,e){var n=document.getElementsByTagName(t)[0];if(n){for(var r=n.getAttribute("data-react-helmet"),o=r?r.split(","):[],i=[].concat(o),a=Object.keys(e),c=0;c=0;l--)n.removeAttribute(i[l]);o.length===i.length?n.removeAttribute("data-react-helmet"):n.getAttribute("data-react-helmet")!==a.join(",")&&n.setAttribute("data-react-helmet",a.join(","))}},st=function(t,e){var n=document.head||document.querySelector(T.HEAD),r=n.querySelectorAll(t+"[data-react-helmet]"),o=Array.prototype.slice.call(r),i=[],a=void 0;return e&&e.length&&e.forEach((function(e){var n=document.createElement(t);for(var r in e)if(e.hasOwnProperty(r))if(r===A)n.innerHTML=e.innerHTML;else if(r===O)n.styleSheet?n.styleSheet.cssText=e.cssText:n.appendChild(document.createTextNode(e.cssText));else{var c=void 0===e[r]?"":e[r];n.setAttribute(r,c)}n.setAttribute("data-react-helmet","true"),o.some((function(t,e){return a=e,n.isEqualNode(t)}))?o.splice(a,1):i.push(n)})),o.forEach((function(t){return t.parentNode.removeChild(t)})),i.forEach((function(t){return n.appendChild(t)})),{oldTags:o,newTags:i}},ft=function(t){return Object.keys(t).reduce((function(e,n){var r=void 0!==t[n]?n+'="'+t[n]+'"':""+n;return e?e+" "+r:r}),"")},lt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(t).reduce((function(e,n){return e[L[n]||n]=t[n],e}),e)},pt=function(t,e,n){switch(t){case T.TITLE:return{toComponent:function(){return t=e.title,n=e.titleAttributes,(r={key:t})["data-react-helmet"]=!0,o=lt(n,r),[y.a.createElement(T.TITLE,o,t)];var t,n,r,o},toString:function(){return function(t,e,n,r){var o=ft(n),i=at(e);return o?"<"+t+' data-react-helmet="true" '+o+">"+J(i,r)+"":"<"+t+' data-react-helmet="true">'+J(i,r)+""}(t,e.title,e.titleAttributes,n)}};case m:case v:return{toComponent:function(){return lt(e)},toString:function(){return ft(e)}};default:return{toComponent:function(){return function(t,e){return e.map((function(e,n){var r,o=((r={key:n})["data-react-helmet"]=!0,r);return Object.keys(e).forEach((function(t){var n=L[t]||t;if(n===A||n===O){var r=e.innerHTML||e.cssText;o.dangerouslySetInnerHTML={__html:r}}else o[n]=e[t]})),y.a.createElement(t,o)}))}(t,e)},toString:function(){return function(t,e,n){return e.reduce((function(e,r){var o=Object.keys(r).filter((function(t){return!(t===A||t===O)})).reduce((function(t,e){var o=void 0===r[e]?e:e+'="'+J(r[e],n)+'"';return t?t+" "+o:o}),""),i=r.innerHTML||r.cssText||"",a=-1===H.indexOf(t);return e+"<"+t+' data-react-helmet="true" '+o+(a?"/>":">"+i+"")}),"")}(t,e,n)}}}},dt=function(t){var e=t.baseTag,n=t.bodyAttributes,r=t.encode,o=t.htmlAttributes,i=t.linkTags,a=t.metaTags,c=t.noscriptTags,u=t.scriptTags,s=t.styleTags,f=t.title,l=void 0===f?"":f,p=t.titleAttributes;return{base:pt(T.BASE,e,r),bodyAttributes:pt(m,n,r),htmlAttributes:pt(v,o,r),link:pt(T.LINK,i,r),meta:pt(T.META,a,r),noscript:pt(T.NOSCRIPT,c,r),script:pt(T.SCRIPT,u,r),style:pt(T.STYLE,s,r),title:pt(T.TITLE,{title:l,titleAttributes:p},r)}},yt=f()((function(t){return{baseTag:Q([S,I],t),bodyAttributes:G(m,t),defer:X(t,M),encode:X(t,R),htmlAttributes:G(v,t),linkTags:V(T.LINK,[x,S],t),metaTags:V(T.META,[j,w,E,P,C],t),noscriptTags:V(T.NOSCRIPT,[A],t),onChangeClientState:$(t),scriptTags:V(T.SCRIPT,[k,A],t),styleTags:V(T.STYLE,[O],t),title:z(t),titleAttributes:G(g,t)}}),(function(t){ot&&nt(ot),t.defer?ot=et((function(){it(t,(function(){ot=null}))})):(it(t),ot=null)}),dt)((function(){return null})),ht=(o=yt,a=i=function(t){function e(){return Y(this,e),K(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.shouldComponentUpdate=function(t){return!p()(this.props,t)},e.prototype.mapNestedChildrenToProps=function(t,e){if(!e)return null;switch(t.type){case T.SCRIPT:case T.NOSCRIPT:return{innerHTML:e};case T.STYLE:return{cssText:e}}throw new Error("<"+t.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")},e.prototype.flattenArrayTypeChildren=function(t){var e,n=t.child,r=t.arrayTypeChildren,o=t.newChildProps,i=t.nestedChildren;return U({},r,((e={})[n.type]=[].concat(r[n.type]||[],[U({},o,this.mapNestedChildrenToProps(n,i))]),e))},e.prototype.mapObjectTypeChildren=function(t){var e,n,r=t.child,o=t.newProps,i=t.newChildProps,a=t.nestedChildren;switch(r.type){case T.TITLE:return U({},o,((e={})[r.type]=a,e.titleAttributes=U({},i),e));case T.BODY:return U({},o,{bodyAttributes:U({},i)});case T.HTML:return U({},o,{htmlAttributes:U({},i)})}return U({},o,((n={})[r.type]=U({},i),n))},e.prototype.mapArrayTypeChildrenToProps=function(t,e){var n=U({},e);return Object.keys(t).forEach((function(e){var r;n=U({},n,((r={})[e]=t[e],r))})),n},e.prototype.warnOnInvalidChildren=function(t,e){return!0},e.prototype.mapChildrenToProps=function(t,e){var n=this,r={};return y.a.Children.forEach(t,(function(t){if(t&&t.props){var o=t.props,i=o.children,a=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(t).reduce((function(e,n){return e[_[n]||n]=t[n],e}),e)}(B(o,["children"]));switch(n.warnOnInvalidChildren(t,i),t.type){case T.LINK:case T.META:case T.NOSCRIPT:case T.SCRIPT:case T.STYLE:r=n.flattenArrayTypeChildren({child:t,arrayTypeChildren:r,newChildProps:a,nestedChildren:i});break;default:e=n.mapObjectTypeChildren({child:t,newProps:e,newChildProps:a,nestedChildren:i})}}})),e=this.mapArrayTypeChildrenToProps(r,e)},e.prototype.render=function(){var t=this.props,e=t.children,n=B(t,["children"]),r=U({},n);return e&&(r=this.mapChildrenToProps(e,r)),y.a.createElement(o,r)},q(e,null,[{key:"canUseDOM",set:function(t){o.canUseDOM=t}}]),e}(y.a.Component),i.propTypes={base:u.a.object,bodyAttributes:u.a.object,children:u.a.oneOfType([u.a.arrayOf(u.a.node),u.a.node]),defaultTitle:u.a.string,defer:u.a.bool,encodeSpecialCharacters:u.a.bool,htmlAttributes:u.a.object,link:u.a.arrayOf(u.a.object),meta:u.a.arrayOf(u.a.object),noscript:u.a.arrayOf(u.a.object),onChangeClientState:u.a.func,script:u.a.arrayOf(u.a.object),style:u.a.arrayOf(u.a.object),title:u.a.string,titleAttributes:u.a.object,titleTemplate:u.a.string},i.defaultProps={defer:!0,encodeSpecialCharacters:!0},i.peek=o.peek,i.rewind=function(){var t=o.rewind();return t||(t=dt({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}})),t},a);ht.renderStatic=ht.rewind}).call(this,n(89))},222:function(t,e,n){"use strict";var r,o=n(0),i=(r=o)&&"object"==typeof r&&"default"in r?r.default:r;function a(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var c=!("undefined"==typeof window||!window.document||!window.document.createElement);t.exports=function(t,e,n){if("function"!=typeof t)throw new Error("Expected reducePropsToState to be a function.");if("function"!=typeof e)throw new Error("Expected handleStateChangeOnClient to be a function.");if(void 0!==n&&"function"!=typeof n)throw new Error("Expected mapStateOnServer to either be undefined or a function.");return function(r){if("function"!=typeof r)throw new Error("Expected WrappedComponent to be a React component.");var u,s=[];function f(){u=t(s.map((function(t){return t.props}))),l.canUseDOM?e(u):n&&(u=n(u))}var l=function(t){var e,n;function o(){return t.apply(this,arguments)||this}n=t,(e=o).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,o.peek=function(){return u},o.rewind=function(){if(o.canUseDOM)throw new Error("You may only call rewind() on the server. Call peek() to read the current state.");var t=u;return u=void 0,s=[],t};var a=o.prototype;return a.UNSAFE_componentWillMount=function(){s.push(this),f()},a.componentDidUpdate=function(){f()},a.componentWillUnmount=function(){var t=s.indexOf(this);s.splice(t,1),f()},a.render=function(){return i.createElement(r,this.props)},o}(o.PureComponent);return a(l,"displayName","SideEffect("+function(t){return t.displayName||t.name||"Component"}(r)+")"),a(l,"canUseDOM",c),l}}},223:function(t,e,n){"use strict";var r=Array.isArray,o=Object.keys,i=Object.prototype.hasOwnProperty,a="undefined"!=typeof Element;t.exports=function(t,e){try{return function t(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){var c,u,s,f=r(e),l=r(n);if(f&&l){if((u=e.length)!=n.length)return!1;for(c=u;0!=c--;)if(!t(e[c],n[c]))return!1;return!0}if(f!=l)return!1;var p=e instanceof Date,d=n instanceof Date;if(p!=d)return!1;if(p&&d)return e.getTime()==n.getTime();var y=e instanceof RegExp,h=n instanceof RegExp;if(y!=h)return!1;if(y&&h)return e.toString()==n.toString();var b=o(e);if((u=b.length)!==o(n).length)return!1;for(c=u;0!=c--;)if(!i.call(n,b[c]))return!1;if(a&&e instanceof Element&&n instanceof Element)return e===n;for(c=u;0!=c--;)if(!("_owner"===(s=b[c])&&e.$$typeof||t(e[s],n[s])))return!1;return!0}return e!=e&&n!=n}(t,e)}catch(n){if(n.message&&n.message.match(/stack|recursion/i)||-2146828260===n.number)return console.warn("Warning: react-fast-compare does not handle circular references.",n.name,n.message),!1;throw n}}},224:function(t,e,n){"use strict";var r=n(5),o=n(27),i=n(10),a=n(12),c=n(15),u=n(225).KEY,s=n(14),f=n(42),l=n(43),p=n(40),d=n(2),y=n(214),h=n(226),b=n(227),m=n(215),v=n(8),g=n(13),T=n(29),w=n(28),O=n(80),S=n(54),E=n(88),A=n(228),C=n(216),j=n(81),P=n(26),x=n(20),k=C.f,I=P.f,L=A.f,N=r.Symbol,M=r.JSON,R=M&&M.stringify,D=d("_hidden"),F=d("toPrimitive"),_={}.propertyIsEnumerable,H=f("symbol-registry"),W=f("symbols"),Y=f("op-symbols"),q=Object.prototype,U="function"==typeof N&&!!j.f,B=r.QObject,K=!B||!B.prototype||!B.prototype.findChild,J=i&&s((function(){return 7!=E(I({},"a",{get:function(){return I(this,"a",{value:7}).a}})).a}))?function(t,e,n){var r=k(q,e);r&&delete q[e],I(t,e,n),r&&t!==q&&I(q,e,r)}:I,z=function(t){var e=W[t]=E(N.prototype);return e._k=t,e},$=U&&"symbol"==typeof N.iterator?function(t){return"symbol"==typeof t}:function(t){return t instanceof N},G=function(t,e,n){return t===q&&G(Y,e,n),v(t),e=O(e,!0),v(n),o(W,e)?(n.enumerable?(o(t,D)&&t[D][e]&&(t[D][e]=!1),n=E(n,{enumerable:S(0,!1)})):(o(t,D)||I(t,D,S(1,{})),t[D][e]=!0),J(t,e,n)):I(t,e,n)},Q=function(t,e){v(t);for(var n,r=b(e=w(e)),o=0,i=r.length;i>o;)G(t,n=r[o++],e[n]);return t},V=function(t){var e=_.call(this,t=O(t,!0));return!(this===q&&o(W,t)&&!o(Y,t))&&(!(e||!o(this,t)||!o(W,t)||o(this,D)&&this[D][t])||e)},X=function(t,e){if(t=w(t),e=O(e,!0),t!==q||!o(W,e)||o(Y,e)){var n=k(t,e);return!n||!o(W,e)||o(t,D)&&t[D][e]||(n.enumerable=!0),n}},Z=function(t){for(var e,n=L(w(t)),r=[],i=0;n.length>i;)o(W,e=n[i++])||e==D||e==u||r.push(e);return r},tt=function(t){for(var e,n=t===q,r=L(n?Y:w(t)),i=[],a=0;r.length>a;)!o(W,e=r[a++])||n&&!o(q,e)||i.push(W[e]);return i};U||(c((N=function(){if(this instanceof N)throw TypeError("Symbol is not a constructor!");var t=p(arguments.length>0?arguments[0]:void 0),e=function(n){this===q&&e.call(Y,n),o(this,D)&&o(this[D],t)&&(this[D][t]=!1),J(this,t,S(1,n))};return i&&K&&J(q,t,{configurable:!0,set:e}),z(t)}).prototype,"toString",(function(){return this._k})),C.f=X,P.f=G,n(210).f=A.f=Z,n(53).f=V,j.f=tt,i&&!n(41)&&c(q,"propertyIsEnumerable",V,!0),y.f=function(t){return z(d(t))}),a(a.G+a.W+a.F*!U,{Symbol:N});for(var et="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),nt=0;et.length>nt;)d(et[nt++]);for(var rt=x(d.store),ot=0;rt.length>ot;)h(rt[ot++]);a(a.S+a.F*!U,"Symbol",{for:function(t){return o(H,t+="")?H[t]:H[t]=N(t)},keyFor:function(t){if(!$(t))throw TypeError(t+" is not a symbol!");for(var e in H)if(H[e]===t)return e},useSetter:function(){K=!0},useSimple:function(){K=!1}}),a(a.S+a.F*!U,"Object",{create:function(t,e){return void 0===e?E(t):Q(E(t),e)},defineProperty:G,defineProperties:Q,getOwnPropertyDescriptor:X,getOwnPropertyNames:Z,getOwnPropertySymbols:tt});var it=s((function(){j.f(1)}));a(a.S+a.F*it,"Object",{getOwnPropertySymbols:function(t){return j.f(T(t))}}),M&&a(a.S+a.F*(!U||s((function(){var t=N();return"[null]"!=R([t])||"{}"!=R({a:t})||"{}"!=R(Object(t))}))),"JSON",{stringify:function(t){for(var e,n,r=[t],o=1;arguments.length>o;)r.push(arguments[o++]);if(n=e=r[1],(g(e)||void 0!==t)&&!$(t))return m(e)||(e=function(t,e){if("function"==typeof n&&(e=n.call(this,t,e)),!$(e))return e}),r[1]=e,R.apply(M,r)}}),N.prototype[F]||n(11)(N.prototype,F,N.prototype.valueOf),l(N,"Symbol"),l(Math,"Math",!0),l(r.JSON,"JSON",!0)},225:function(t,e,n){var r=n(40)("meta"),o=n(13),i=n(27),a=n(26).f,c=0,u=Object.isExtensible||function(){return!0},s=!n(14)((function(){return u(Object.preventExtensions({}))})),f=function(t){a(t,r,{value:{i:"O"+ ++c,w:{}}})},l=t.exports={KEY:r,NEED:!1,fastKey:function(t,e){if(!o(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!i(t,r)){if(!u(t))return"F";if(!e)return"E";f(t)}return t[r].i},getWeak:function(t,e){if(!i(t,r)){if(!u(t))return!0;if(!e)return!1;f(t)}return t[r].w},onFreeze:function(t){return s&&l.NEED&&u(t)&&!i(t,r)&&f(t),t}}},226:function(t,e,n){var r=n(5),o=n(16),i=n(41),a=n(214),c=n(26).f;t.exports=function(t){var e=o.Symbol||(o.Symbol=i?{}:r.Symbol||{});"_"==t.charAt(0)||t in e||c(e,t,{value:a.f(t)})}},227:function(t,e,n){var r=n(20),o=n(81),i=n(53);t.exports=function(t){var e=r(t),n=o.f;if(n)for(var a,c=n(t),u=i.f,s=0;c.length>s;)u.call(t,a=c[s++])&&e.push(a);return e}},228:function(t,e,n){var r=n(28),o=n(210).f,i={}.toString,a="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(t){return a&&"[object Window]"==i.call(t)?function(t){try{return o(t)}catch(e){return a.slice()}}(t):o(r(t))}}}]); \ No newline at end of file diff --git a/docs/next/1.72497a0e.js.LICENSE.txt b/docs/next/1.72497a0e.js.LICENSE.txt new file mode 100644 index 0000000000..bae6dd8e22 --- /dev/null +++ b/docs/next/1.72497a0e.js.LICENSE.txt @@ -0,0 +1,5 @@ +/*! + Copyright (c) 2017 Jed Watson. + Licensed under the MIT License (MIT), see + http://jedwatson.github.io/classnames +*/ diff --git a/docs/next/17896441.650b7739.js b/docs/next/17896441.650b7739.js new file mode 100644 index 0000000000..9fb5139a0b --- /dev/null +++ b/docs/next/17896441.650b7739.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{199:function(e,t,a){"use strict";a.r(t);var n=a(0),l=a.n(n),r=a(212),i=a(205),c=a(201),m=a(203),s=a(206);var o=function(e){var t=e.metadata;return l.a.createElement("nav",{className:"pagination-nav"},l.a.createElement("div",{className:"pagination-nav__item"},t.previous&&l.a.createElement(s.a,{className:"pagination-nav__link",to:t.previous.permalink},l.a.createElement("div",{className:"pagination-nav__link--sublabel"},"Previous"),l.a.createElement("div",{className:"pagination-nav__link--label"},"\xab ",t.previous.title))),l.a.createElement("div",{className:"pagination-nav__item pagination-nav__item--next"},t.next&&l.a.createElement(s.a,{className:"pagination-nav__link",to:t.next.permalink},l.a.createElement("div",{className:"pagination-nav__link--sublabel"},"Next"),l.a.createElement("div",{className:"pagination-nav__link--label"},t.next.title," \xbb"))))};var d=function(e,t,a){var l=Object(n.useState)(void 0),r=l[0],i=l[1];Object(n.useEffect)((function(){var n=[],l=[];function c(){var c=function(){var e=0,t=null;for(n=document.getElementsByClassName("anchor");e=0&&r<=a&&(t=l),e+=1}return t}();if(c){var m=0,s=!1;for(l=document.getElementsByClassName(e);m=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var b=a.a.createContext({}),p=function(e){var t=a.a.useContext(b),n=t;return e&&(n="function"==typeof e?e(t):c({},t,{},e)),n},d=function(e){var t=p(e.components);return a.a.createElement(b.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},O=Object(r.forwardRef)((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,o=e.parentName,b=l(e,["components","mdxType","originalType","parentName"]),d=p(n),O=r,u=d["".concat(o,".").concat(O)]||d[O]||s[O]||i;return n?a.a.createElement(u,c({ref:t},b,{components:n})):a.a.createElement(u,c({ref:t},b))}));function u(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=O;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:r,o[1]=c;for(var b=2;b"," 0 on top.")))),Object(r.b)("p",null,"For function arguments, the function is passed a context object that is of the form:"),Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{className:"language-javscript"}),"{\n scale: // Scale object\n tick: // Tick object\n}\n")),Object(r.b)("h2",{id:"tick-configuration"},"Tick Configuration"),Object(r.b)("p",null,"The tick configuration is nested under the scale configuration in the ",Object(r.b)("inlineCode",{parentName:"p"},"ticks")," key. It defines options for the tick marks that are generated by the axis."),Object(r.b)("table",null,Object(r.b)("thead",{parentName:"table"},Object(r.b)("tr",{parentName:"thead"},Object(r.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Name"),Object(r.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Type"),Object(r.b)("th",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("a",Object(n.a)({parentName:"th"},{href:"/docs/VERSION/general/options#scriptable-options"}),"Scriptable")),Object(r.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Default"))),Object(r.b)("tbody",{parentName:"table"},Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"callback")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"function")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"display")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"boolean")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"true"))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"fontColor")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"Color")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"Yes"),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"'#666'"))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"fontFamily")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"string")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"Yes"),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"\"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif\""))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"fontSize")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"number")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"Yes"),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"12"))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"fontStyle")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"string")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"Yes"),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"'normal'"))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"lineHeight")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("code",null,"number","|","string")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"Yes"),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"1.2"))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"lineWidth")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"number")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"Yes"),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"0"))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"major")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"object")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"{}"))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"padding")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"number")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"0"))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"reverse")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"boolean")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null})),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"false"))),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"strokeStyle")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"string")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"Yes"),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"``")),Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"z")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"number")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"0")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}))))),Object(r.b)("h2",{id:"major-tick-configuration"},"Major Tick Configuration"),Object(r.b)("p",null,"The majorTick configuration is nested under the ticks configuration in the ",Object(r.b)("inlineCode",{parentName:"p"},"major")," key. It defines options for the major tick marks that are generated by the axis."),Object(r.b)("table",null,Object(r.b)("thead",{parentName:"table"},Object(r.b)("tr",{parentName:"thead"},Object(r.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Name"),Object(r.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Type"),Object(r.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Default"),Object(r.b)("th",Object(n.a)({parentName:"tr"},{align:null}),"Description"))),Object(r.b)("tbody",{parentName:"table"},Object(r.b)("tr",{parentName:"tbody"},Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"enabled")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"boolean")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),Object(r.b)("inlineCode",{parentName:"td"},"false")),Object(r.b)("td",Object(n.a)({parentName:"tr"},{align:null}),"If true, major ticks are generated. A major tick will affect autoskipping and ",Object(r.b)("inlineCode",{parentName:"td"},"major")," will be defined on ticks in the scriptable options context.")))))}O.isMDXComponent=!0},200:function(e,t,a){"use strict";a.d(t,"a",(function(){return j})),a.d(t,"b",(function(){return m}));var n=a(0),b=a.n(n);function r(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function l(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function i(e){for(var t=1;t=0||(b[a]=e[a]);return b}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(b[a]=e[a])}return b}var d=b.a.createContext({}),O=function(e){var t=b.a.useContext(d),a=t;return e&&(a="function"==typeof e?e(t):i({},t,{},e)),a},j=function(e){var t=O(e.components);return b.a.createElement(d.Provider,{value:t},e.children)},o={inlineCode:"code",wrapper:function(e){var t=e.children;return b.a.createElement(b.a.Fragment,{},t)}},p=Object(n.forwardRef)((function(e,t){var a=e.components,n=e.mdxType,r=e.originalType,l=e.parentName,d=c(e,["components","mdxType","originalType","parentName"]),j=O(a),p=n,m=j["".concat(l,".").concat(p)]||j[p]||o[p]||r;return a?b.a.createElement(m,i({ref:t},d,{components:a})):b.a.createElement(m,i({ref:t},d))}));function m(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var r=a.length,l=new Array(r);l[0]=p;var i={};for(var c in t)hasOwnProperty.call(t,c)&&(i[c]=t[c]);i.originalType=e,i.mdxType="string"==typeof e?e:n,l[1]=i;for(var d=2;d=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}var s=n.a.createContext({}),p=function(e){var r=n.a.useContext(s),t=r;return e&&(t="function"==typeof e?e(r):c({},r,{},e)),t},u=function(e){var r=p(e.components);return n.a.createElement(s.Provider,{value:r},e.children)},d={inlineCode:"code",wrapper:function(e){var r=e.children;return n.a.createElement(n.a.Fragment,{},r)}},f=Object(a.forwardRef)((function(e,r){var t=e.components,a=e.mdxType,i=e.originalType,o=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),u=p(t),f=a,b=u["".concat(o,".").concat(f)]||u[f]||d[f]||i;return t?n.a.createElement(b,c({ref:r},s,{components:t})):n.a.createElement(b,c({ref:r},s))}));function b(e,r){var t=arguments,a=r&&r.mdxType;if("string"==typeof e||a){var i=t.length,o=new Array(i);o[0]=f;var c={};for(var l in r)hasOwnProperty.call(r,l)&&(c[l]=r[l]);c.originalType=e,c.mdxType="string"==typeof e?e:a,o[1]=c;for(var s=2;s\n')),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-javascript"}),"// Any of the following formats may be used\nvar ctx = document.getElementById('myChart');\nvar ctx = document.getElementById('myChart').getContext('2d');\nvar ctx = $('#myChart');\nvar ctx = 'myChart';\n")),Object(o.b)("p",null,"Once you have the element or context, you're ready to instantiate a pre-defined chart-type or create your own!"),Object(o.b)("p",null,"The following example instantiates a bar chart showing the number of votes for different colors and the y-axis starting at 0."),Object(o.b)("pre",null,Object(o.b)("code",Object(r.a)({parentName:"pre"},{className:"language-html"}),"\n + + + + + + +Page Not Found | Chart.js + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

+
+ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/next/46cc0bae.817a5507.js b/docs/next/46cc0bae.817a5507.js new file mode 100644 index 0000000000..46aac34617 --- /dev/null +++ b/docs/next/46cc0bae.817a5507.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[19],{159:function(e,t,r){"use strict";r.r(t),r.d(t,"frontMatter",(function(){return s})),r.d(t,"metadata",(function(){return l})),r.d(t,"rightToc",(function(){return c})),r.d(t,"default",(function(){return p}));var a=r(1),n=r(9),o=(r(0),r(200)),s={title:"Developers"},l={id:"developers/README",title:"Developers",description:"Developer features allow extending and enhancing Chart.js in many different ways.",source:"@site/docs/developers/README.md",permalink:"/docs/VERSION/developers/README",editUrl:"https://github.com/chartjs/Chart.js/edit/master/docs/docs/developers/README.md",sidebar:"someSidebar",previous:{title:"Styling",permalink:"/docs/VERSION/axes/styling"},next:{title:"API",permalink:"/docs/VERSION/developers/api"}},c=[{value:"Latest resources",id:"latest-resources",children:[]},{value:"Development releases",id:"development-releases",children:[]},{value:"Browser support",id:"browser-support",children:[]},{value:"Previous versions",id:"previous-versions",children:[]}],i={rightToc:c};function p(e){var t=e.components,r=Object(n.a)(e,["components"]);return Object(o.b)("wrapper",Object(a.a)({},i,r,{components:t,mdxType:"MDXLayout"}),Object(o.b)("p",null,"Developer features allow extending and enhancing Chart.js in many different ways."),Object(o.b)("h2",{id:"latest-resources"},"Latest resources"),Object(o.b)("p",null,"Latest documentation and samples, including unreleased features, are available at:"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://www.chartjs.org/docs/master/"}),"https://www.chartjs.org/docs/master/")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://www.chartjs.org/samples/master/"}),"https://www.chartjs.org/samples/master/"))),Object(o.b)("h2",{id:"development-releases"},"Development releases"),Object(o.b)("p",null,"Latest builds are available for testing at:"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://www.chartjs.org/dist/master/Chart.js"}),"https://www.chartjs.org/dist/master/Chart.js")),Object(o.b)("li",{parentName:"ul"},Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://www.chartjs.org/dist/master/Chart.min.js"}),"https://www.chartjs.org/dist/master/Chart.min.js"))),Object(o.b)("blockquote",null,Object(o.b)("p",{parentName:"blockquote"},"Note: Development builds are currently only available via HTTP, so in order to include them in ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://jsfiddle.net"}),"JSFiddle")," or ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://codepen.io"}),"CodePen"),", you need to access these tools via HTTP as well.")),Object(o.b)("p",null,Object(o.b)("strong",{parentName:"p"},"WARNING: Development builds MUST not be used for production purposes or as replacement for CDN.")),Object(o.b)("h2",{id:"browser-support"},"Browser support"),Object(o.b)("p",null,"Chart.js offers support for the following browsers:"),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"Chrome 50+"),Object(o.b)("li",{parentName:"ul"},"Firefox 45+"),Object(o.b)("li",{parentName:"ul"},"Internet Explorer 11"),Object(o.b)("li",{parentName:"ul"},"Edge 14+"),Object(o.b)("li",{parentName:"ul"},"Safari 9+")),Object(o.b)("p",null,"Browser support for the canvas element is available in all modern & major mobile browsers. ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://caniuse.com/#feat=canvas"}),"CanIUse")),Object(o.b)("p",null,"Thanks to ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://browserstack.com"}),"BrowserStack")," for allowing our team to test on thousands of browsers."),Object(o.b)("h2",{id:"previous-versions"},"Previous versions"),Object(o.b)("p",null,"Version 2 has a completely different API than earlier versions."),Object(o.b)("p",null,"Most earlier version options have current equivalents or are the same."),Object(o.b)("p",null,"Please use the documentation that is available on ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"https://www.chartjs.org/docs/"}),"chartjs.org")," for the current version of Chart.js."),Object(o.b)("p",null,"Please note - documentation for previous versions are available on the GitHub repo."),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},Object(o.b)("a",Object(a.a)({parentName:"li"},{href:"https://github.com/chartjs/Chart.js/tree/v1.1.1/docs"}),"1.x Documentation"))))}p.isMDXComponent=!0},200:function(e,t,r){"use strict";r.d(t,"a",(function(){return b})),r.d(t,"b",(function(){return d}));var a=r(0),n=r.n(a);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function l(e){for(var t=1;t=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var i=n.a.createContext({}),p=function(e){var t=n.a.useContext(i),r=t;return e&&(r="function"==typeof e?e(t):l({},t,{},e)),r},b=function(e){var t=p(e.components);return n.a.createElement(i.Provider,{value:t},e.children)},u={inlineCode:"code",wrapper:function(e){var t=e.children;return n.a.createElement(n.a.Fragment,{},t)}},m=Object(a.forwardRef)((function(e,t){var r=e.components,a=e.mdxType,o=e.originalType,s=e.parentName,i=c(e,["components","mdxType","originalType","parentName"]),b=p(r),m=a,d=b["".concat(s,".").concat(m)]||b[m]||u[m]||o;return r?n.a.createElement(d,l({ref:t},i,{components:r})):n.a.createElement(d,l({ref:t},i))}));function d(e,t){var r=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=r.length,s=new Array(o);s[0]=m;var l={};for(var c in t)hasOwnProperty.call(t,c)&&(l[c]=t[c]);l.originalType=e,l.mdxType="string"==typeof e?e:a,s[1]=l;for(var i=2;i=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}var b=r.a.createContext({}),s=function(e){var t=r.a.useContext(b),a=t;return e&&(a="function"==typeof e?e(t):o({},t,{},e)),a},d=function(e){var t=s(e.components);return r.a.createElement(b.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},u=Object(n.forwardRef)((function(e,t){var a=e.components,n=e.mdxType,i=e.originalType,l=e.parentName,b=c(e,["components","mdxType","originalType","parentName"]),d=s(a),u=n,m=d["".concat(l,".").concat(u)]||d[u]||p[u]||i;return a?r.a.createElement(m,o({ref:t},b,{components:a})):r.a.createElement(m,o({ref:t},b))}));function m(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var i=a.length,l=new Array(i);l[0]=u;var o={};for(var c in t)hasOwnProperty.call(t,c)&&(o[c]=t[c]);o.originalType=e,o.mdxType="string"==typeof e?e:n,l[1]=o;for(var b=2;b=0||(i[a]=e[a]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(i[a]=e[a])}return i}var o=i.a.createContext({}),d=function(e){var t=i.a.useContext(o),a=t;return e&&(a="function"==typeof e?e(t):l({},t,{},e)),a},s=function(e){var t=d(e.components);return i.a.createElement(o.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return i.a.createElement(i.a.Fragment,{},t)}},O=Object(n.forwardRef)((function(e,t){var a=e.components,n=e.mdxType,r=e.originalType,b=e.parentName,o=c(e,["components","mdxType","originalType","parentName"]),s=d(a),O=n,j=s["".concat(b,".").concat(O)]||s[O]||p[O]||r;return a?i.a.createElement(j,l({ref:t},o,{components:a})):i.a.createElement(j,l({ref:t},o))}));function j(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var r=a.length,b=new Array(r);b[0]=O;var l={};for(var c in t)hasOwnProperty.call(t,c)&&(l[c]=t[c]);l.originalType=e,l.mdxType="string"==typeof e?e:n,b[1]=l;for(var o=2;o=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}var d=r.a.createContext({}),o=function(e){var t=r.a.useContext(d),a=t;return e&&(a="function"==typeof e?e(t):l({},t,{},e)),a},p=function(e){var t=o(e.components);return r.a.createElement(d.Provider,{value:t},e.children)},m={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},j=Object(n.forwardRef)((function(e,t){var a=e.components,n=e.mdxType,b=e.originalType,i=e.parentName,d=c(e,["components","mdxType","originalType","parentName"]),p=o(a),j=n,O=p["".concat(i,".").concat(j)]||p[j]||m[j]||b;return a?r.a.createElement(O,l({ref:t},d,{components:a})):r.a.createElement(O,l({ref:t},d))}));function O(e,t){var a=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var b=a.length,i=new Array(b);i[0]=j;var l={};for(var c in t)hasOwnProperty.call(t,c)&&(l[c]=t[c]);l.originalType=e,l.mdxType="string"==typeof e?e:n,i[1]=l;for(var d=2;d=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var o=n.a.createContext({}),p=function(e){var t=n.a.useContext(o),a=t;return e&&(a="function"==typeof e?e(t):i({},t,{},e)),a},b=function(e){var t=p(e.components);return n.a.createElement(o.Provider,{value:t},e.children)},j={inlineCode:"code",wrapper:function(e){var t=e.children;return n.a.createElement(n.a.Fragment,{},t)}},d=Object(r.forwardRef)((function(e,t){var a=e.components,r=e.mdxType,c=e.originalType,s=e.parentName,o=l(e,["components","mdxType","originalType","parentName"]),b=p(a),d=r,m=b["".concat(s,".").concat(d)]||b[d]||j[d]||c;return a?n.a.createElement(m,i({ref:t},o,{components:a})):n.a.createElement(m,i({ref:t},o))}));function m(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var c=a.length,s=new Array(c);s[0]=d;var i={};for(var l in t)hasOwnProperty.call(t,l)&&(i[l]=t[l]);i.originalType=e,i.mdxType="string"==typeof e?e:r,s[1]=i;for(var o=2;o0&&o.a.createElement("li",{className:p()("menu__list-item",{"menu__list-item--collapsed":v}),key:f},o.a.createElement("a",Object(s.a)({className:p()("menu__link",{"menu__link--sublist":a,"menu__link--active":a&&!t.collapsed}),href:"#!",onClick:a?j:void 0},i),f),o.a.createElement("ul",{className:"menu__list"},c.map((function(e){return o.a.createElement(b,{tabIndex:v?"-1":"0",key:e.label,item:e,onItemClick:n,collapsible:a})}))));case"link":default:return o.a.createElement("li",{className:"menu__list-item",key:f},o.a.createElement(h.a,Object(s.a)({className:"menu__link",to:l},Object(m.a)(l)?{isNavLink:!0,activeClassName:"menu__link--active",exact:!0,onClick:n}:{target:"_blank",rel:"noreferrer noopener"},i),f))}}var k=function(e){var t=Object(r.useState)(!1),n=t[0],a=t[1],c=Object(i.a)(),l=c.siteConfig,u=(l=void 0===l?{}:l).themeConfig.navbar,f=(u=void 0===u?{}:u).title,m=u.hideOnScroll,v=void 0!==m&&m,k=c.isClient,E=Object(y.a)(),O=E.logoLink,j=E.logoLinkProps,x=E.logoImageUrl,w=E.logoAlt,S=e.docsSidebars,T=e.path,C=e.sidebar,_=e.sidebarCollapsible;if(Object(d.a)(n),!C)return null;var N=S[C];if(!N)throw new Error('Cannot find the sidebar "'+C+'" in the sidebar config!');return _&&N.forEach((function(e){return function e(t,n){var r=t.items,o=t.href;switch(t.type){case"category":var a=r.map((function(t){return e(t,n)})).filter((function(e){return e})).length>0;return t.collapsed=!a,a;case"link":default:return o===n}}(e,T)})),o.a.createElement("div",{className:g.a.sidebar},v&&o.a.createElement(h.a,Object(s.a)({tabIndex:"-1",className:g.a.sidebarLogo,to:O},j),null!=x&&o.a.createElement("img",{key:k,src:x,alt:w}),null!=f&&o.a.createElement("strong",null,f)),o.a.createElement("div",{className:p()("menu","menu--responsive",g.a.menu,{"menu--show":n})},o.a.createElement("button",{"aria-label":n?"Close Menu":"Open Menu","aria-haspopup":"true",className:"button button--secondary button--sm menu__button",type:"button",onClick:function(){a(!n)}},n?o.a.createElement("span",{className:p()(g.a.sidebarMenuIcon,g.a.sidebarMenuCloseIcon)},"\xd7"):o.a.createElement("svg",{"aria-label":"Menu",className:g.a.sidebarMenuIcon,xmlns:"http://www.w3.org/2000/svg",height:24,width:24,viewBox:"0 0 32 32",role:"img",focusable:"false"},o.a.createElement("title",null,"Menu"),o.a.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M4 7h22M4 15h22M4 23h22"}))),o.a.createElement("ul",{className:"menu__list"},N.map((function(e){return o.a.createElement(b,{key:e.label,item:e,onItemClick:function(e){e.target.blur(),a(!1)},collapsible:_})})))))},E=(n(237),n(238),n(86),n(91),n(239),n(240),{plain:{backgroundColor:"#2a2734",color:"#9a86fd"},styles:[{types:["comment","prolog","doctype","cdata","punctuation"],style:{color:"#6c6783"}},{types:["namespace"],style:{opacity:.7}},{types:["tag","operator","number"],style:{color:"#e09142"}},{types:["property","function"],style:{color:"#9a86fd"}},{types:["tag-id","selector","atrule-id"],style:{color:"#eeebff"}},{types:["attr-name"],style:{color:"#c4b9fe"}},{types:["boolean","string","entity","url","attr-value","keyword","control","directive","unit","statement","regex","at-rule","placeholder","variable"],style:{color:"#ffcc99"}},{types:["deleted"],style:{textDecorationLine:"line-through"}},{types:["inserted"],style:{textDecorationLine:"underline"}},{types:["italic"],style:{fontStyle:"italic"}},{types:["important","bold"],style:{fontWeight:"bold"}},{types:["important"],style:{color:"#c4b9fe"}}]}),O={Prism:n(55).a,theme:E};function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(){return(x=Object.assign||function(e){for(var t=1;t0&&e[n-1]===t?e:e.concat(t)},C=function(e,t){var n=e.plain,r=Object.create(null),o=e.styles.reduce((function(e,n){var r=n.languages,o=n.style;return r&&!r.includes(t)||n.types.forEach((function(t){var n=x({},e[t],o);e[t]=n})),e}),r);return o.root=n,o.plain=x({},n,{backgroundColor:null}),o};function _(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&-1===t.indexOf(r)&&(n[r]=e[r]);return n}var N=function(e){function t(){for(var t=this,n=[],r=arguments.length;r--;)n[r]=arguments[r];e.apply(this,n),j(this,"getThemeDict",(function(e){if(void 0!==t.themeDict&&e.theme===t.prevTheme&&e.language===t.prevLanguage)return t.themeDict;t.prevTheme=e.theme,t.prevLanguage=e.language;var n=e.theme?C(e.theme,e.language):void 0;return t.themeDict=n})),j(this,"getLineProps",(function(e){var n=e.key,r=e.className,o=e.style,a=x({},_(e,["key","className","style","line"]),{className:"token-line",style:void 0,key:void 0}),i=t.getThemeDict(t.props);return void 0!==i&&(a.style=i.plain),void 0!==o&&(a.style=void 0!==a.style?x({},a.style,o):o),void 0!==n&&(a.key=n),r&&(a.className+=" "+r),a})),j(this,"getStyleForToken",(function(e){var n=e.types,r=e.empty,o=n.length,a=t.getThemeDict(t.props);if(void 0!==a){if(1===o&&"plain"===n[0])return r?{display:"inline-block"}:void 0;if(1===o&&!r)return a[n[0]];var i=r?{display:"inline-block"}:{},c=n.map((function(e){return a[e]}));return Object.assign.apply(Object,[i].concat(c))}})),j(this,"getTokenProps",(function(e){var n=e.key,r=e.className,o=e.style,a=e.token,i=x({},_(e,["key","className","style","token"]),{className:"token "+a.types.join(" "),children:a.content,style:t.getStyleForToken(a),key:void 0});return void 0!==o&&(i.style=void 0!==i.style?x({},i.style,o):o),void 0!==n&&(i.key=n),r&&(i.className+=" "+r),i}))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){var e=this.props,t=e.Prism,n=e.language,r=e.code,o=e.children,a=this.getThemeDict(this.props),i=t.languages[n];return o({tokens:function(e){for(var t=[[]],n=[e],r=[0],o=[e.length],a=0,i=0,c=[],l=[c];i>-1;){for(;(a=r[i]++)0?u:["plain"],s=f):(u=T(u,f.type),f.alias&&(u=T(u,f.alias)),s=f.content),"string"==typeof s){var p=s.split(w),d=p.length;c.push({types:u,content:p[0]});for(var y=1;y0}))}a&&$.test(a)&&(k=a.match($)[0].split("title=")[1].replace(/"+/g,"")),Object(r.useEffect)((function(){var e;return g.current&&(e=new L.a(g.current,{target:function(){return v.current}})),function(){e&&e.destroy()}}),[g.current,v.current]);var T=n&&n.replace(/language-/,"");!T&&l.defaultLanguage&&(T=l.defaultLanguage);var C=t.replace(/\n$/,"");if(0===b.length&&void 0!==T){for(var _,A="",M=function(e){switch(e){case"js":case"javascript":case"ts":case"typescript":return H(["js","jsBlock"]);case"jsx":case"tsx":return H(["js","jsBlock","jsx"]);case"html":return H(["js","jsBlock","html"]);case"python":case"py":return H(["python"]);default:return H()}}(T),F=t.replace(/\n$/,"").split("\n"),q=0;q=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var s=o.a.createContext({}),u=function(e){var t=o.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):c({},t,{},e)),n},f=function(e){var t=u(e.components);return o.a.createElement(s.Provider,{value:t},e.children)},p={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},d=Object(r.forwardRef)((function(e,t){var n=e.components,r=e.mdxType,a=e.originalType,i=e.parentName,s=l(e,["components","mdxType","originalType","parentName"]),f=u(n),d=r,y=f["".concat(i,".").concat(d)]||f[d]||p[d]||a;return n?o.a.createElement(y,c({ref:t},s,{components:n})):o.a.createElement(y,c({ref:t},s))}));function y(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var a=n.length,i=new Array(a);i[0]=d;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:r,i[1]=c;for(var s=2;s1?arguments[1]:void 0)}}),n(79)("find")},234:function(e,t,n){var r=n(30),o=n(57),a=n(29),i=n(25),c=n(235);e.exports=function(e,t){var n=1==e,l=2==e,s=3==e,u=4==e,f=6==e,p=5==e||f,d=t||c;return function(t,c,y){for(var h,m,v=a(t),g=o(v),b=r(c,y,3),k=i(g.length),E=0,O=n?d(t,k):l?d(t,0):void 0;k>E;E++)if((p||E in g)&&(m=b(h=g[E],E,v),e))if(n)O[E]=m;else if(m)switch(e){case 3:return!0;case 5:return h;case 6:return E;case 2:O.push(h)}else if(u)return!1;return f?-1:s||u?u:O}}},235:function(e,t,n){var r=n(236);e.exports=function(e,t){return new(r(e))(t)}},236:function(e,t,n){var r=n(13),o=n(215),a=n(2)("species");e.exports=function(e){var t;return o(e)&&("function"!=typeof(t=e.constructor)||t!==Array&&!o(t.prototype)||(t=void 0),r(t)&&null===(t=t[a])&&(t=void 0)),void 0===t?Array:t}},237:function(e,t,n){"use strict";var r=n(12),o=n(84)(!0);r(r.P,"Array",{includes:function(e){return o(this,e,arguments.length>1?arguments[1]:void 0)}}),n(79)("includes")},238:function(e,t,n){"use strict";var r=n(12),o=n(207);r(r.P+r.F*n(208)("includes"),"String",{includes:function(e){return!!~o(this,e,"includes").indexOf(e,arguments.length>1?arguments[1]:void 0)}})},239:function(e,t,n){"use strict";var r=n(8),o=n(25),a=n(59),i=n(60);n(61)("match",1,(function(e,t,n,c){return[function(n){var r=e(this),o=null==n?void 0:n[t];return void 0!==o?o.call(n,r):new RegExp(n)[t](String(r))},function(e){var t=c(n,e,this);if(t.done)return t.value;var l=r(e),s=String(this);if(!l.global)return i(l,s);var u=l.unicode;l.lastIndex=0;for(var f,p=[],d=0;null!==(f=i(l,s));){var y=String(f[0]);p[d]=y,""===y&&(l.lastIndex=a(s,o(l.lastIndex),u)),d++}return 0===d?null:p}]}))},240:function(e,t,n){var r=n(5),o=n(241),a=n(26).f,i=n(210).f,c=n(78),l=n(87),s=r.RegExp,u=s,f=s.prototype,p=/a/g,d=/a/g,y=new s(p)!==p;if(n(10)&&(!y||n(14)((function(){return d[n(2)("match")]=!1,s(p)!=p||s(d)==d||"/a/i"!=s(p,"i")})))){s=function(e,t){var n=this instanceof s,r=c(e),a=void 0===t;return!n&&r&&e.constructor===s&&a?e:o(y?new u(r&&!a?e.source:e,t):u((r=e instanceof s)?e.source:e,r&&a?l.call(e):t),n?this:f,s)};for(var h=function(e){e in s||a(s,e,{configurable:!0,get:function(){return u[e]},set:function(t){u[e]=t}})},m=i(u),v=0;m.length>v;)h(m[v++]);f.constructor=s,s.prototype=f,n(15)(r,"RegExp",s)}n(90)("RegExp")},241:function(e,t,n){var r=n(13),o=n(242).set;e.exports=function(e,t,n){var a,i=t.constructor;return i!==n&&"function"==typeof i&&(a=i.prototype)!==n.prototype&&r(a)&&o&&o(e,a),e}},242:function(e,t,n){var r=n(13),o=n(8),a=function(e,t){if(o(e),!r(t)&&null!==t)throw TypeError(t+": can't set as prototype!")};e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t,r){try{(r=n(30)(Function.call,n(216).f(Object.prototype,"__proto__").set,2))(e,[]),t=!(e instanceof Array)}catch(o){t=!0}return function(e,n){return a(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:a}},243:function(e,t,n){var r;r=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t){e.exports=function(e){var t;if("SELECT"===e.nodeName)e.focus(),t=e.value;else if("INPUT"===e.nodeName||"TEXTAREA"===e.nodeName){var n=e.hasAttribute("readonly");n||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),n||e.removeAttribute("readonly"),t=e.value}else{e.hasAttribute("contenteditable")&&e.focus();var r=window.getSelection(),o=document.createRange();o.selectNodeContents(e),r.removeAllRanges(),r.addRange(o),t=r.toString()}return t}},function(e,t){function n(){}n.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function o(){r.off(e,o),t.apply(n,arguments)}return o._=t,this.on(e,o,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,o=n.length;r0&&void 0!==arguments[0]?arguments[0]:{};this.action=e.action,this.container=e.container,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var e=this,t="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[t?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=o()(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=o()(this.target),this.copyText()}},{key:"copyText",value:function(){var e=void 0;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(e){if(void 0!==e){if(!e||"object"!==(void 0===e?"undefined":a(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function(){return this._target}}]),e}(),l=n(1),s=n.n(l),u=n(2),f=n.n(u),p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText,this.container="object"===p(e.container)?e.container:document.body}},{key:"listenClick",value:function(e){var t=this;this.listener=f()(e,"click",(function(e){return t.onClick(e)}))}},{key:"onClick",value:function(e){var t=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new c({action:this.action(t),target:this.target(t),text:this.text(t),container:this.container,trigger:t,emitter:this})}},{key:"defaultAction",value:function(e){return h("action",e)}},{key:"defaultTarget",value:function(e){var t=h("target",e);if(t)return document.querySelector(t)}},{key:"defaultText",value:function(e){return h("text",e)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],t="string"==typeof e?[e]:e,n=!!document.queryCommandSupported;return t.forEach((function(e){n=n&&!!document.queryCommandSupported(e)})),n}}]),t}(s.a);function h(e,t){var n="data-clipboard-"+e;if(t.hasAttribute(n))return t.getAttribute(n)}t.default=y}]).default},e.exports=r()},244:function(e,t){e.exports.parse=function(e){var t=e.split(",").map((function(e){return function(e){if(/^-?\d+$/.test(e))return parseInt(e,10);var t;if(t=e.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)){var n=t[1],r=t[2],o=t[3];if(n&&o){var a=[],i=(n=parseInt(n))<(o=parseInt(o))?1:-1;"-"!=r&&".."!=r&&"\u2025"!=r||(o+=i);for(var c=n;c!=o;c+=i)a.push(c);return a}}return[]}(e)}));return 0===t.length?[]:1===t.length?Array.isArray(t[0])?t[0]:t:t.reduce((function(e,t){return Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),e.concat(t)}))}}}]); \ No newline at end of file diff --git a/docs/next/60.cef636ad.js.LICENSE.txt b/docs/next/60.cef636ad.js.LICENSE.txt new file mode 100644 index 0000000000..73d480c698 --- /dev/null +++ b/docs/next/60.cef636ad.js.LICENSE.txt @@ -0,0 +1,6 @@ +/*! + * clipboard.js v2.0.6 + * https://clipboardjs.com/ + * + * Licensed MIT © Zeno Rocha + */ diff --git a/docs/next/60cfd621.8714873a.js b/docs/next/60cfd621.8714873a.js new file mode 100644 index 0000000000..bb77a54c24 --- /dev/null +++ b/docs/next/60cfd621.8714873a.js @@ -0,0 +1 @@ +(window.webpackJsonp=window.webpackJsonp||[]).push([[24],{164:function(e,t,r){"use strict";r.r(t),r.d(t,"frontMatter",(function(){return o})),r.d(t,"metadata",(function(){return i})),r.d(t,"rightToc",(function(){return s})),r.d(t,"default",(function(){return l}));var a=r(1),n=r(9),c=(r(0),r(200)),o={title:"Scatter Chart"},i={id:"charts/scatter",title:"Scatter Chart",description:"Scatter charts are based on basic line charts with the x axis changed to a linear axis. To use a scatter chart, data must be passed as objects containing X and Y properties. The example below creates a scatter chart with 3 points.",source:"@site/docs/charts/scatter.md",permalink:"/docs/VERSION/charts/scatter",editUrl:"https://github.com/chartjs/Chart.js/edit/master/docs/docs/charts/scatter.md",sidebar:"someSidebar",previous:{title:"Bubble Chart",permalink:"/docs/VERSION/charts/bubble"},next:{title:"Area Chart",permalink:"/docs/VERSION/charts/area"}},s=[{value:"Dataset Properties",id:"dataset-properties",children:[]},{value:"Data Structure",id:"data-structure",children:[]},{value:"Internal data format",id:"internal-data-format",children:[]}],p={rightToc:s};function l(e){var t=e.components,r=Object(n.a)(e,["components"]);return Object(c.b)("wrapper",Object(a.a)({},p,r,{components:t,mdxType:"MDXLayout"}),Object(c.b)("p",null,"Scatter charts are based on basic line charts with the x axis changed to a linear axis. To use a scatter chart, data must be passed as objects containing X and Y properties. The example below creates a scatter chart with 3 points."),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-javascript"}),"var scatterChart = new Chart(ctx, {\n type: 'scatter',\n data: {\n datasets: [{\n label: 'Scatter Dataset',\n data: [{\n x: -10,\n y: 0\n }, {\n x: 0,\n y: 10\n }, {\n x: 10,\n y: 5\n }]\n }]\n },\n options: {\n scales: {\n x: {\n type: 'linear',\n position: 'bottom'\n }\n }\n }\n});\n")),Object(c.b)("h2",{id:"dataset-properties"},"Dataset Properties"),Object(c.b)("p",null,"The scatter chart supports all of the same properties as the ",Object(c.b)("a",Object(a.a)({parentName:"p"},{href:"./line.md#dataset-properties"}),"line chart"),"."),Object(c.b)("h2",{id:"data-structure"},"Data Structure"),Object(c.b)("p",null,"Unlike the line chart where data can be supplied in two different formats, the scatter chart only accepts data in a point format."),Object(c.b)("pre",null,Object(c.b)("code",Object(a.a)({parentName:"pre"},{className:"language-javascript"}),"data: [{\n x: 10,\n y: 20\n }, {\n x: 15,\n y: 10\n }]\n")),Object(c.b)("h2",{id:"internal-data-format"},"Internal data format"),Object(c.b)("p",null,Object(c.b)("inlineCode",{parentName:"p"},"{x, y}")))}l.isMDXComponent=!0},200:function(e,t,r){"use strict";r.d(t,"a",(function(){return u})),r.d(t,"b",(function(){return h}));var a=r(0),n=r.n(a);function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function i(e){for(var t=1;t=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var p=n.a.createContext({}),l=function(e){var t=n.a.useContext(p),r=t;return e&&(r="function"==typeof e?e(t):i({},t,{},e)),r},u=function(e){var t=l(e.components);return n.a.createElement(p.Provider,{value:t},e.children)},b={inlineCode:"code",wrapper:function(e){var t=e.children;return n.a.createElement(n.a.Fragment,{},t)}},d=Object(a.forwardRef)((function(e,t){var r=e.components,a=e.mdxType,c=e.originalType,o=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),u=l(r),d=a,h=u["".concat(o,".").concat(d)]||u[d]||b[d]||c;return r?n.a.createElement(h,i({ref:t},p,{components:r})):n.a.createElement(h,i({ref:t},p))}));function h(e,t){var r=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var c=r.length,o=new Array(c);o[0]=d;var i={};for(var s in t)hasOwnProperty.call(t,s)&&(i[s]=t[s]);i.originalType=e,i.mdxType="string"==typeof e?e:a,o[1]=i;for(var p=2;p {\n dataset.data.push(data);\n });\n chart.update();\n}\n\nfunction removeData(chart) {\n chart.data.labels.pop();\n chart.data.datasets.forEach((dataset) => {\n dataset.data.pop();\n });\n chart.update();\n}\n")),Object(o.b)("h2",{id:"updating-options"},"Updating Options"),Object(o.b)("p",null,"To update the options, mutating the options property in place or passing in a new options object are supported."),Object(o.b)("ul",null,Object(o.b)("li",{parentName:"ul"},"If the options are mutated in place, other option properties would be preserved, including those calculated by Chart.js."),Object(o.b)("li",{parentName:"ul"},"If created as a new object, it would be like creating a new chart with the options - old options would be discarded.")),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-javascript"}),"function updateConfigByMutating(chart) {\n chart.options.title.text = 'new title';\n chart.update();\n}\n\nfunction updateConfigAsNewObject(chart) {\n chart.options = {\n responsive: true,\n title: {\n display: true,\n text: 'Chart.js'\n },\n scales: {\n x: {\n display: true\n },\n y: {\n display: true\n }\n }\n };\n chart.update();\n}\n")),Object(o.b)("p",null,"Scales can be updated separately without changing other options.\nTo update the scales, pass in an object containing all the customization including those unchanged ones."),Object(o.b)("p",null,"Variables referencing any one from ",Object(o.b)("inlineCode",{parentName:"p"},"chart.scales")," would be lost after updating scales with a new ",Object(o.b)("inlineCode",{parentName:"p"},"id")," or the changed ",Object(o.b)("inlineCode",{parentName:"p"},"type"),"."),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-javascript"}),"function updateScales(chart) {\n var xScale = chart.scales.x;\n var yScale = chart.scales.y;\n chart.options.scales = {\n newId: {\n display: true\n },\n y: {\n display: true,\n type: 'logarithmic'\n }\n };\n chart.update();\n // need to update the reference\n xScale = chart.scales.newId;\n yScale = chart.scales.y;\n}\n")),Object(o.b)("p",null,"You can also update a specific scale either by its id."),Object(o.b)("pre",null,Object(o.b)("code",Object(a.a)({parentName:"pre"},{className:"language-javascript"}),"function updateScale(chart) {\n chart.options.scales.y = {\n type: 'logarithmic'\n };\n chart.update();\n}\n")),Object(o.b)("p",null,"Code sample for updating options can be found in ",Object(o.b)("a",Object(a.a)({parentName:"p"},{href:"../../samples/scales/toggle-scale-type.html"}),"toggle-scale-type.html"),"."),Object(o.b)("h2",{id:"preventing-animations"},"Preventing Animations"),Object(o.b)("p",null,"Sometimes when a chart updates, you may not want an animation. To achieve this you can call ",Object(o.b)("inlineCode",{parentName:"p"},"update")," with ",Object(o.b)("inlineCode",{parentName:"p"},"'none'")," as mode."))}l.isMDXComponent=!0},200:function(e,t,n){"use strict";n.d(t,"a",(function(){return d})),n.d(t,"b",(function(){return h}));var a=n(0),r=n.n(a);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=r.a.createContext({}),l=function(e){var t=r.a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):i({},t,{},e)),n},d=function(e){var t=l(e.components);return r.a.createElement(s.Provider,{value:t},e.children)},u={inlineCode:"code",wrapper:function(e){var t=e.children;return r.a.createElement(r.a.Fragment,{},t)}},b=Object(a.forwardRef)((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,c=e.parentName,s=p(e,["components","mdxType","originalType","parentName"]),d=l(n),b=a,h=d["".concat(c,".").concat(b)]||d[b]||u[b]||o;return n?r.a.createElement(h,i({ref:t},s,{components:n})):r.a.createElement(h,i({ref:t},s))}));function h(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,c=new Array(o);c[0]=b;var i={};for(var p in t)hasOwnProperty.call(t,p)&&(i[p]=t[p]);i.originalType=e,i.mdxType="string"==typeof e?e:a,c[1]=i;for(var s=2;s=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var b=a.a.createContext({}),p=function(e){var t=a.a.useContext(b),n=t;return e&&(n="function"==typeof e?e(t):i({},t,{},e)),n},d=function(e){var t=p(e.components);return a.a.createElement(b.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},u=Object(r.forwardRef)((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,c=e.parentName,b=l(e,["components","mdxType","originalType","parentName"]),d=p(n),u=r,O=d["".concat(c,".").concat(u)]||d[u]||s[u]||o;return n?a.a.createElement(O,i({ref:t},b,{components:n})):a.a.createElement(O,i({ref:t},b))}));function O(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,c=new Array(o);c[0]=u;var i={};for(var l in t)hasOwnProperty.call(t,l)&&(i[l]=t[l]);i.originalType=e,i.mdxType="string"==typeof e?e:r,c[1]=i;for(var b=2;b p.id === 'tooltip');\ntooltipPlugin.positioners.custom = function(elements, eventPosition) {\n /** @type {Tooltip} */\n var tooltip = this;\n\n /* ... */\n\n return {\n x: 0,\n y: 0\n };\n};\n")),Object(b.b)("h3",{id:"alignment"},"Alignment"),Object(b.b)("p",null,"The ",Object(b.b)("inlineCode",{parentName:"p"},"titleAlign"),", ",Object(b.b)("inlineCode",{parentName:"p"},"bodyAlign")," and ",Object(b.b)("inlineCode",{parentName:"p"},"footerAlign")," options define the horizontal position of the text lines with respect to the tooltip box. The following values are supported."),Object(b.b)("ul",null,Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"'left'")," (default)"),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"'right'")),Object(b.b)("li",{parentName:"ul"},Object(b.b)("inlineCode",{parentName:"li"},"'center'"))),Object(b.b)("p",null,"These options are only applied to text lines. Color boxes are always aligned to the left edge."),Object(b.b)("h3",{id:"sort-callback"},"Sort Callback"),Object(b.b)("p",null,"Allows sorting of ",Object(b.b)("a",Object(a.a)({parentName:"p"},{href:"#tooltip-item-interface"}),"tooltip items"),". Must implement at minimum a function that can be passed to ",Object(b.b)("a",Object(a.a)({parentName:"p"},{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort"}),"Array.prototype.sort"),". This function can also accept a third parameter that is the data object passed to the chart."),Object(b.b)("h3",{id:"filter-callback"},"Filter Callback"),Object(b.b)("p",null,"Allows filtering of ",Object(b.b)("a",Object(a.a)({parentName:"p"},{href:"#tooltip-item-interface"}),"tooltip items"),". Must implement at minimum a function that can be passed to ",Object(b.b)("a",Object(a.a)({parentName:"p"},{href:"https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter"}),"Array.prototype.filter"),". This function can also accept a second parameter that is the data object passed to the chart."),Object(b.b)("h2",{id:"tooltip-callbacks"},"Tooltip Callbacks"),Object(b.b)("p",null,"The tooltip label configuration is nested below the tooltip configuration using the ",Object(b.b)("inlineCode",{parentName:"p"},"callbacks")," key. The tooltip has the following callbacks for providing text. For all functions, ",Object(b.b)("inlineCode",{parentName:"p"},"this")," will be the tooltip object created from the ",Object(b.b)("inlineCode",{parentName:"p"},"Tooltip")," constructor."),Object(b.b)("p",null,"All functions are called with the same arguments: a ",Object(b.b)("a",Object(a.a)({parentName:"p"},{href:"#tooltip-item-interface"}),"tooltip item")," and the ",Object(b.b)("inlineCode",{parentName:"p"},"data")," object passed to the chart. All functions must return either a string or an array of strings. Arrays of strings are treated as multiple lines of text."),Object(b.b)("table",null,Object(b.b)("thead",{parentName:"table"},Object(b.b)("tr",{parentName:"thead"},Object(b.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Name"),Object(b.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Arguments"),Object(b.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"Description"))),Object(b.b)("tbody",{parentName:"table"},Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"beforeTitle")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem[], object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns the text to render before the title.")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"title")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem[], object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns text to render as the title of the tooltip.")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"afterTitle")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem[], object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns text to render after the title.")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"beforeBody")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem[], object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns text to render before the body section.")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"beforeLabel")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem, object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns text to render before an individual label. This will be called for each item in the tooltip.")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"label")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem, object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns text to render for an individual item in the tooltip. ",Object(b.b)("a",Object(a.a)({parentName:"td"},{href:"#label-callback"}),"more..."))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"labelColor")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem, Chart")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns the colors to render for the tooltip item. ",Object(b.b)("a",Object(a.a)({parentName:"td"},{href:"#label-color-callback"}),"more..."))),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"labelTextColor")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem, Chart")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns the colors for the text of the label for the tooltip item.")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"afterLabel")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem, object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns text to render after an individual label.")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"afterBody")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem[], object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns text to render after the body section.")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"beforeFooter")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem[], object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns text to render before the footer section.")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"footer")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem[], object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Returns text to render as the footer of the tooltip.")),Object(b.b)("tr",{parentName:"tbody"},Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"afterFooter")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(b.b)("inlineCode",{parentName:"td"},"TooltipItem[], object")),Object(b.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Text to render after the footer section.")))),Object(b.b)("h3",{id:"label-callback"},"Label Callback"),Object(b.b)("p",null,"The ",Object(b.b)("inlineCode",{parentName:"p"},"label")," callback can change the text that displays for a given data point. A common example to show a unit. The example below puts a ",Object(b.b)("inlineCode",{parentName:"p"},"'$'")," before every row."),Object(b.b)("pre",null,Object(b.b)("code",Object(a.a)({parentName:"pre"},{className:"language-javascript"}),"var chart = new Chart(ctx, {\n type: 'line',\n data: data,\n options: {\n tooltips: {\n callbacks: {\n label: function(tooltipItem, data) {\n var label = data.datasets[tooltipItem.datasetIndex].label || '';\n\n if (label) {\n label += ': ';\n }\n if (!helpers.isNullOrUndef(tooltipItem.value)) {\n label += '$' + tooltipItem.value;\n }\n return label;\n }\n }\n }\n }\n});\n")),Object(b.b)("h3",{id:"label-color-callback"},"Label Color Callback"),Object(b.b)("p",null,"For example, to return a red box for each item in the tooltip you could do:"),Object(b.b)("pre",null,Object(b.b)("code",Object(a.a)({parentName:"pre"},{className:"language-javascript"}),"var chart = new Chart(ctx, {\n type: 'line',\n data: data,\n options: {\n tooltips: {\n callbacks: {\n labelColor: function(tooltipItem, chart) {\n return {\n borderColor: 'rgb(255, 0, 0)',\n backgroundColor: 'rgb(255, 0, 0)'\n };\n },\n labelTextColor: function(tooltipItem, chart) {\n return '#543453';\n }\n }\n }\n }\n});\n")),Object(b.b)("h3",{id:"tooltip-item-interface"},"Tooltip Item Interface"),Object(b.b)("p",null,"The tooltip items passed to the tooltip callbacks implement the following interface."),Object(b.b)("pre",null,Object(b.b)("code",Object(a.a)({parentName:"pre"},{className:"language-javascript"}),"{\n // Label for the tooltip\n label: string,\n\n // Value for the tooltip\n value: string,\n\n // Index of the dataset the item comes from\n datasetIndex: number,\n\n // Index of this data item in the dataset\n index: number\n}\n")),Object(b.b)("h2",{id:"external-custom-tooltips"},"External (Custom) Tooltips"),Object(b.b)("p",null,"Custom tooltips allow you to hook into the tooltip rendering process so that you can render the tooltip in your own custom way. Generally this is used to create an HTML tooltip instead of an oncanvas one. You can enable custom tooltips in the global or chart configuration like so:"),Object(b.b)("pre",null,Object(b.b)("code",Object(a.a)({parentName:"pre"},{className:"language-javascript"}),"var myPieChart = new Chart(ctx, {\n type: 'pie',\n data: data,\n options: {\n tooltips: {\n // Disable the on-canvas tooltip\n enabled: false,\n\n custom: function(tooltipModel) {\n // Tooltip Element\n var tooltipEl = document.getElementById('chartjs-tooltip');\n\n // Create element on first render\n if (!tooltipEl) {\n tooltipEl = document.createElement('div');\n tooltipEl.id = 'chartjs-tooltip';\n tooltipEl.innerHTML = '
';\n document.body.appendChild(tooltipEl);\n }\n\n // Hide if no tooltip\n if (tooltipModel.opacity === 0) {\n tooltipEl.style.opacity = 0;\n return;\n }\n\n // Set caret Position\n tooltipEl.classList.remove('above', 'below', 'no-transform');\n if (tooltipModel.yAlign) {\n tooltipEl.classList.add(tooltipModel.yAlign);\n } else {\n tooltipEl.classList.add('no-transform');\n }\n\n function getBody(bodyItem) {\n return bodyItem.lines;\n }\n\n // Set Text\n if (tooltipModel.body) {\n var titleLines = tooltipModel.title || [];\n var bodyLines = tooltipModel.body.map(getBody);\n\n var innerHtml = '';\n\n titleLines.forEach(function(title) {\n innerHtml += '' + title + '';\n });\n innerHtml += '';\n\n bodyLines.forEach(function(body, i) {\n var colors = tooltipModel.labelColors[i];\n var style = 'background:' + colors.backgroundColor;\n style += '; border-color:' + colors.borderColor;\n style += '; border-width: 2px';\n var span = '';\n innerHtml += '' + span + body + '';\n });\n innerHtml += '';\n\n var tableRoot = tooltipEl.querySelector('table');\n tableRoot.innerHTML = innerHtml;\n }\n\n // `this` will be the overall tooltip\n var position = this._chart.canvas.getBoundingClientRect();\n\n // Display, position, and set styles for font\n tooltipEl.style.opacity = 1;\n tooltipEl.style.position = 'absolute';\n tooltipEl.style.left = position.left + window.pageXOffset + tooltipModel.caretX + 'px';\n tooltipEl.style.top = position.top + window.pageYOffset + tooltipModel.caretY + 'px';\n tooltipEl.style.fontFamily = tooltipModel._bodyFontFamily;\n tooltipEl.style.fontSize = tooltipModel.bodyFontSize + 'px';\n tooltipEl.style.fontStyle = tooltipModel._bodyFontStyle;\n tooltipEl.style.padding = tooltipModel.yPadding + 'px ' + tooltipModel.xPadding + 'px';\n tooltipEl.style.pointerEvents = 'none';\n }\n }\n }\n});\n")),Object(b.b)("p",null,"See ",Object(b.b)("a",Object(a.a)({parentName:"p"},{href:"https://www.chartjs.org/samples/"}),"samples")," for examples on how to get started with custom tooltips."),Object(b.b)("h2",{id:"tooltip-model"},"Tooltip Model"),Object(b.b)("p",null,"The tooltip model contains parameters that can be used to render the tooltip."),Object(b.b)("pre",null,Object(b.b)("code",Object(a.a)({parentName:"pre"},{className:"language-javascript"}),"{\n // The items that we are rendering in the tooltip. See Tooltip Item Interface section\n dataPoints: TooltipItem[],\n\n // Positioning\n xPadding: number,\n yPadding: number,\n xAlign: string,\n yAlign: string,\n\n // X and Y properties are the top left of the tooltip\n x: number,\n y: number,\n width: number,\n height: number,\n // Where the tooltip points to\n caretX: number,\n caretY: number,\n\n // Body\n // The body lines that need to be rendered\n // Each object contains 3 parameters\n // before: string[] // lines of text before the line with the color square\n // lines: string[], // lines of text to render as the main item with color square\n // after: string[], // lines of text to render after the main lines\n body: object[],\n // lines of text that appear after the title but before the body\n beforeBody: string[],\n // line of text that appear after the body and before the footer\n afterBody: string[],\n bodyFontColor: Color,\n _bodyFontFamily: string,\n _bodyFontStyle: string,\n _bodyAlign: string,\n bodyFontSize: number,\n bodySpacing: number,\n\n // Title\n // lines of text that form the title\n title: string[],\n titleFontColor: Color,\n _titleFontFamily: string,\n _titleFontStyle: string,\n titleFontSize: number,\n _titleAlign: string,\n titleSpacing: number,\n titleMarginBottom: number,\n\n // Footer\n // lines of text that form the footer\n footer: string[],\n footerFontColor: Color,\n _footerFontFamily: string,\n _footerFontStyle: string,\n footerFontSize: number,\n _footerAlign: string,\n footerSpacing: number,\n footerMarginTop: number,\n\n // Appearance\n caretSize: number,\n caretPadding: number,\n cornerRadius: number,\n backgroundColor: Color,\n\n // colors to render for each item in body[]. This is the color of the squares in the tooltip\n labelColors: Color[],\n labelTextColors: Color[],\n\n // 0 opacity is a hidden tooltip\n opacity: number,\n multiKeyBackground: Color,\n displayColors: boolean,\n borderColor: Color,\n borderWidth: number\n}\n")))}d.isMDXComponent=!0},200:function(t,e,n){"use strict";n.d(e,"a",(function(){return p})),n.d(e,"b",(function(){return m}));var a=n(0),l=n.n(a);function b(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,a)}return n}function o(t){for(var e=1;e=0||(l[n]=t[n]);return l}(t,e);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(t);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(l[n]=t[n])}return l}var c=l.a.createContext({}),d=function(t){var e=l.a.useContext(c),n=e;return t&&(n="function"==typeof t?t(e):o({},e,{},t)),n},p=function(t){var e=d(t.components);return l.a.createElement(c.Provider,{value:e},t.children)},j={inlineCode:"code",wrapper:function(t){var e=t.children;return l.a.createElement(l.a.Fragment,{},e)}},O=Object(a.forwardRef)((function(t,e){var n=t.components,a=t.mdxType,b=t.originalType,r=t.parentName,c=i(t,["components","mdxType","originalType","parentName"]),p=d(n),O=a,m=p["".concat(r,".").concat(O)]||p[O]||j[O]||b;return n?l.a.createElement(m,o({ref:e},c,{components:n})):l.a.createElement(m,o({ref:e},c))}));function m(t,e){var n=arguments,a=e&&e.mdxType;if("string"==typeof t||a){var b=n.length,r=new Array(b);r[0]=O;var o={};for(var i in e)hasOwnProperty.call(e,i)&&(o[i]=e[i]);o.originalType=t,o.mdxType="string"==typeof t?t:a,r[1]=o;for(var c=2;c=0||(n[a]=e[a]);return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(n[a]=e[a])}return n}var l=n.a.createContext({}),d=function(e){var t=n.a.useContext(l),a=t;return e&&(a="function"==typeof e?e(t):c({},t,{},e)),a},p=function(e){var t=d(e.components);return n.a.createElement(l.Provider,{value:t},e.children)},b={inlineCode:"code",wrapper:function(e){var t=e.children;return n.a.createElement(n.a.Fragment,{},t)}},u=Object(r.forwardRef)((function(e,t){var a=e.components,r=e.mdxType,o=e.originalType,i=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),p=d(a),u=r,h=p["".concat(i,".").concat(u)]||p[u]||b[u]||o;return a?n.a.createElement(h,c({ref:t},l,{components:a})):n.a.createElement(h,c({ref:t},l))}));function h(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=a.length,i=new Array(o);i[0]=u;var c={};for(var s in t)hasOwnProperty.call(t,s)&&(c[s]=t[s]);c.originalType=e,c.mdxType="string"==typeof e?e:r,i[1]=c;for(var l=2;l