chart.min.js 36 KB

1
  1. window.Chart = function (a, b) { function e(a, b, d, e) { c.tooltips.push(new f(a, b, d, e)) } function i(a) { for (var b = 0, c = 0; a; ) b += a.offsetLeft + a.clientLeft, c += a.offsetTop + a.clientTop, a = a.offsetParent; return window.pageXOffset > 0 || window.pageYOffset > 0 ? (b -= window.pageXOffset, c -= window.pageYOffset) : (document.body.scrollLeft > 0 || document.body.scrollTop > 0) && (b -= document.body.scrollLeft, c -= document.body.scrollTop), { x: b, y: c} } function j(b) { var d, e, f, g, h; if (c.tooltips.length > 0) { c.savedState = null == c.savedState ? a.getImageData(0, 0, a.canvas.width, a.canvas.height) : c.savedState, d = 0; for (e in c.tooltips) f = i(a.canvas), g = b.clientX - f.x, h = b.clientY - f.y, c.tooltips[e].inRange(g, h) && (c.tooltips[e].render(g, h), d++); 0 == d && a.putImageData(c.savedState, 0, 0) } } function r(a, b, c) { var d = b.steps * b.stepValue, e = a - b.graphMin, f = A(e / d, 1, 0); return c * b.steps * f } function s(a, b, c, e) { function i() { var d = a.animation ? A(g(h), null, 0) : 1; k(e), a.scaleOverlay ? (c(d), b()) : (b(), c(d)) } function j() { h += f, i(), 1 >= h ? t(j) : "function" == typeof a.onAnimationComplete && a.onAnimationComplete() } var f = a.animation ? 1 / A(a.animationSteps, Number.MAX_VALUE, 1) : 1, g = d[a.animationEasing], h = a.animation ? 0 : 1; "function" != typeof b && (b = function () { }), t(j) } function u(a, b, c, d, e, f) { function p(a) { return Math.floor(Math.log(a) / Math.LN10) } for (var o, l = d - e, m = p(l), g = Math.floor(e / (1 * Math.pow(10, m))) * Math.pow(10, m), h = Math.ceil(d / (1 * Math.pow(10, m))) * Math.pow(10, m), i = h - g, j = Math.pow(10, m), k = Math.round(i / j); c > k || k > b; ) c > k ? (j /= 2, k = Math.round(i / j)) : (j *= 2, k = Math.round(i / j)); return o = [], v(f, o, k, g, j), { steps: k, stepValue: j, graphMin: g, labels: o} } function v(a, b, c, d, e) { if (a) for (var f = 1; c + 1 > f; f++) b.push(E(a, { value: (d + e * f).toFixed(B(e)) })) } function v(a, b, c, d, e) { if (a) for (var f = 1; c + 1 > f; f++) b.push(E(a, { value: (d + e * f).toFixed(B(e)) })) } function w(a) { return Math.max.apply(Math, a) } function x(a) { return Math.min.apply(Math, a) } function y(a, b) { return a ? a : b } function z(a) { return !isNaN(parseFloat(a)) && isFinite(a) } function A(a, b, c) { return z(b) && a > b ? b : z(c) && c > a ? c : a } function B(a) { return 0 != a % 1 ? a.toString().split(".")[1].length : 0 } function C(a, b) { var d, c = {}; for (d in a) c[d] = a[d]; for (d in b) c[d] = "object" == typeof b[d] && a[d] ? C(a[d], b[d]) : b[d]; return c } function E(a, b) { var c = /\W/.test(a) ? new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('" + a.replace(/[\r\t\n]/g, " ").split("<%").join(" ").replace(/((^|%>)[^\t]*)'/g, "$1\r").replace(/\t=(.*?)%>/g, "',$1,'").split(" ").join("');").split("%>").join("p.push('").split("\r").join("\\'") + "');}return p.join('');") : D[a] = D[a] || E(document.getElementById(a).innerHTML); return b ? c(b) : c } function F(a, b, c) { var e, f, g, h, i, j, k, l, m, n, o, p, q, r, d = document.createElement("div"); return d.style.color = b, document.body.appendChild(d), e = window.getComputedStyle(d).color, d.style.color = c, f = window.getComputedStyle(d).color, g = /rgb *\( *([0-9]{1,3}) *, *([0-9]{1,3}) *, *([0-9]{1,3}) *\)/, h = g.exec(e), i = g.exec(f), j = Math.round(parseFloat(h[1])), k = Math.round(parseFloat(h[2])), l = Math.round(parseFloat(h[3])), m = Math.round(parseFloat(i[1])), n = Math.round(parseFloat(i[2])), o = Math.round(parseFloat(i[3])), p = parseInt((j - m) * a + m), q = parseInt((k - n) * a + n), r = parseInt((l - o) * a + o), d.parentNode.removeChild(d), "rgb(" + p + "," + q + "," + r + ")" } var f, g, h, k, l, m, n, o, p, q, t, D, c = this, d = { linear: function (a) { return a }, easeInQuad: function (a) { return a * a }, easeOutQuad: function (a) { return -1 * a * (a - 2) }, easeInOutQuad: function (a) { return (a /= .5) < 1 ? .5 * a * a : -0.5 * (--a * (a - 2) - 1) }, easeInCubic: function (a) { return a * a * a }, easeOutCubic: function (a) { return 1 * ((a = a / 1 - 1) * a * a + 1) }, easeInOutCubic: function (a) { return (a /= .5) < 1 ? .5 * a * a * a : .5 * ((a -= 2) * a * a + 2) }, easeInQuart: function (a) { return a * a * a * a }, easeOutQuart: function (a) { return -1 * ((a = a / 1 - 1) * a * a * a - 1) }, easeInOutQuart: function (a) { return (a /= .5) < 1 ? .5 * a * a * a * a : -0.5 * ((a -= 2) * a * a * a - 2) }, easeInQuint: function (a) { return 1 * (a /= 1) * a * a * a * a }, easeOutQuint: function (a) { return 1 * ((a = a / 1 - 1) * a * a * a * a + 1) }, easeInOutQuint: function (a) { return (a /= .5) < 1 ? .5 * a * a * a * a * a : .5 * ((a -= 2) * a * a * a * a + 2) }, easeInSine: function (a) { return -1 * Math.cos(a / 1 * (Math.PI / 2)) + 1 }, easeOutSine: function (a) { return 1 * Math.sin(a / 1 * (Math.PI / 2)) }, easeInOutSine: function (a) { return -0.5 * (Math.cos(Math.PI * a / 1) - 1) }, easeInExpo: function (a) { return 0 == a ? 1 : 1 * Math.pow(2, 10 * (a / 1 - 1)) }, easeOutExpo: function (a) { return 1 == a ? 1 : 1 * (-Math.pow(2, -10 * a / 1) + 1) }, easeInOutExpo: function (a) { return 0 == a ? 0 : 1 == a ? 1 : (a /= .5) < 1 ? .5 * Math.pow(2, 10 * (a - 1)) : .5 * (-Math.pow(2, -10 * --a) + 2) }, easeInCirc: function (a) { return a >= 1 ? a : -1 * (Math.sqrt(1 - (a /= 1) * a) - 1) }, easeOutCirc: function (a) { return 1 * Math.sqrt(1 - (a = a / 1 - 1) * a) }, easeInOutCirc: function (a) { return (a /= .5) < 1 ? -0.5 * (Math.sqrt(1 - a * a) - 1) : .5 * (Math.sqrt(1 - (a -= 2) * a) + 1) }, easeInElastic: function (a) { var b = 1.70158, c = 0, d = 1; return 0 == a ? 0 : 1 == (a /= 1) ? 1 : (c || (c = .3), d < Math.abs(1) ? (d = 1, b = c / 4) : b = c / (2 * Math.PI) * Math.asin(1 / d), -(d * Math.pow(2, 10 * (a -= 1)) * Math.sin((1 * a - b) * 2 * Math.PI / c))) }, easeOutElastic: function (a) { var b = 1.70158, c = 0, d = 1; return 0 == a ? 0 : 1 == (a /= 1) ? 1 : (c || (c = .3), d < Math.abs(1) ? (d = 1, b = c / 4) : b = c / (2 * Math.PI) * Math.asin(1 / d), d * Math.pow(2, -10 * a) * Math.sin((1 * a - b) * 2 * Math.PI / c) + 1) }, easeInOutElastic: function (a) { var b = 1.70158, c = 0, d = 1; return 0 == a ? 0 : 2 == (a /= .5) ? 1 : (c || (c = 1 * .3 * 1.5), d < Math.abs(1) ? (d = 1, b = c / 4) : b = c / (2 * Math.PI) * Math.asin(1 / d), 1 > a ? -.5 * d * Math.pow(2, 10 * (a -= 1)) * Math.sin((1 * a - b) * 2 * Math.PI / c) : .5 * d * Math.pow(2, -10 * (a -= 1)) * Math.sin((1 * a - b) * 2 * Math.PI / c) + 1) }, easeInBack: function (a) { var b = 1.70158; return 1 * (a /= 1) * a * ((b + 1) * a - b) }, easeOutBack: function (a) { var b = 1.70158; return 1 * ((a = a / 1 - 1) * a * ((b + 1) * a + b) + 1) }, easeInOutBack: function (a) { var b = 1.70158; return (a /= .5) < 1 ? .5 * a * a * (((b *= 1.525) + 1) * a - b) : .5 * ((a -= 2) * a * (((b *= 1.525) + 1) * a + b) + 2) }, easeInBounce: function (a) { return 1 - d.easeOutBounce(1 - a) }, easeOutBounce: function (a) { return (a /= 1) < 1 / 2.75 ? 1 * 7.5625 * a * a : 2 / 2.75 > a ? 1 * (7.5625 * (a -= 1.5 / 2.75) * a + .75) : 2.5 / 2.75 > a ? 1 * (7.5625 * (a -= 2.25 / 2.75) * a + .9375) : 1 * (7.5625 * (a -= 2.625 / 2.75) * a + .984375) }, easeInOutBounce: function (a) { return .5 > a ? .5 * d.easeInBounce(2 * a) : .5 * d.easeOutBounce(2 * a - 1) + .5 } }; this.tooltips = [], defaults = { tooltips: { background: "black", fontFamily: "'Arial'", fontStyle: "normal", fontColor: "white", fontSize: "12px", labelTemplate: "<%=label%>: <%=value%>", height: 24, padding: { top: 4, right: 8, bottom: 4, left: 8 }, position: "bottom center", offset: { left: 0, top: 0 }, border: { width: 0, color: "black", radius: 4 }, showShadow: !0, shadow: { color: "rgba(0,0,0,0.9)", blur: 8, offsetX: 0, offsetY: 0 }, showHighlight: !0, highlight: { stroke: { width: 1, color: "rgba(230,230,230,0.25)" }, fill: "rgba(255,255,255,0.25)"}} }, b = b ? C(defaults, b) : defaults, f = function (a, d, e) { this.ctx = a, this.areaObj = d, this.data = e, this.savedState = null, this.highlightState = null, this.x = null, this.y = null, this.inRange = function (a, b) { var c, d, e, f, g; if (this.areaObj.type) switch (this.areaObj.type) { case "rect": return a >= this.areaObj.x && a <= this.areaObj.x + this.areaObj.width && b >= this.areaObj.y && b <= this.areaObj.y + this.areaObj.height; case "circle": return Math.pow(a - this.areaObj.x, 2) + Math.pow(b - this.areaObj.y, 2) < Math.pow(this.areaObj.r, 2); case "shape": for (c = this.areaObj.points, d = !1, e = -1, f = c.length, g = f - 1; ++e < f; g = e) (c[e].y <= b && b < c[g].y || c[g].y <= b && b < c[e].y) && a < (c[g].x - c[e].x) * (b - c[e].y) / (c[g].y - c[e].y) + c[e].x && (d = !d); return d } }, this.render = function (d, e) { function m(a) { var b, c; return a = a || document.body, b = document.createElement("div"), b.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em", b.appendChild(document.createTextNode("M")), a.appendChild(b), c = [b.offsetWidth, b.offsetHeight], a.removeChild(b), c[1] } var f, g, h, i, j, k, l, n, o, p; if (this.ctx.shadowColor = void 0, this.ctx.shadowBlur = 0, this.ctx.shadowOffsetX = 0, this.ctx.shadowOffsetY = 0, null == this.savedState && (this.ctx.putImageData(c.savedState, 0, 0), this.savedState = this.ctx.getImageData(0, 0, this.ctx.canvas.width, this.ctx.canvas.height)), this.ctx.putImageData(this.savedState, 0, 0), b.tooltips.showHighlight) if (null == this.highlightState) { switch (this.ctx.strokeStyle = b.tooltips.highlight.stroke.color, this.ctx.lineWidth = b.tooltips.highlight.stroke.width, this.ctx.fillStyle = b.tooltips.highlight.fill, this.areaObj.type) { case "rect": this.ctx.strokeRect(this.areaObj.x, this.areaObj.y, this.areaObj.width, this.areaObj.height), this.ctx.fillStyle = b.tooltips.highlight.fill, this.ctx.fillRect(this.areaObj.x, this.areaObj.y, this.areaObj.width, this.areaObj.height); break; case "circle": this.ctx.beginPath(), this.ctx.arc(this.areaObj.x, this.areaObj.y, this.areaObj.r, 0, 2 * Math.PI, !1), this.ctx.stroke(), this.ctx.fill(); break; case "shape": this.ctx.beginPath(), this.ctx.moveTo(this.areaObj.points[0].x, this.areaObj.points[0].y); for (f in this.areaObj.points) this.ctx.lineTo(this.areaObj.points[f].x, this.areaObj.points[f].y); this.ctx.stroke(), this.ctx.fill() } this.highlightState = this.ctx.getImageData(0, 0, this.ctx.canvas.width, this.ctx.canvas.height) } else this.ctx.putImageData(this.highlightState, 0, 0); g = d + b.tooltips.offset.left, h = e + b.tooltips.offset.top, i = E(b.tooltips.labelTemplate, this.data), j = b.tooltips.padding.left + this.ctx.measureText(i).width + b.tooltips.padding.right, k = b.tooltips.position.split(" "), l = b.tooltips.height, b.tooltips.fontSize.match(/[0-9]+(.[0-9]+)?px/) ? l = parseInt(b.tooltips.fontSize) : b.tooltips.fontSize.match(/[0-9]+(.[0-9]+)?(\%|em)/) && (n = parseFloat(b.tooltips.fontSize), b.tooltips.fontSize.match(/[0-9]+(.[0-9]+)?\%/) && (n /= 100), l = n * m(this.ctx.canvas.parentNode)), l += b.tooltips.padding.top + b.tooltips.padding.bottom; for (o in k) 0 == o && ("bottom" == k[o] ? h -= l : "center" == k[o] && (h -= l / 2, 1 == k.length && (g -= j / 2))), 1 == o && ("right" == k[o] ? g -= j : "center" == k[o] && (g -= j / 2)); g + j > a.canvas.width && (g -= g + j - a.canvas.width), 0 > g && (g = 0), h + l > a.canvas.height && (h -= h + l - a.canvas.height), 0 > h && (h = 0), this.ctx.fillStyle = b.tooltips.background, b.tooltips.showShadow && (this.ctx.shadowColor = b.tooltips.shadow.color, this.ctx.shadowBlur = b.tooltips.shadow.blur, this.ctx.shadowOffsetX = b.tooltips.shadow.offsetX, this.ctx.shadowOffsetY = b.tooltips.shadow.offsetY), b.tooltips.border.radius ? (p = b.tooltips.border.radius > 12 ? 12 : b.tooltips.border.radius, this.ctx.beginPath(), this.ctx.moveTo(g + p, h), this.ctx.lineTo(g + j - p, h), this.ctx.quadraticCurveTo(g + j, h, g + j, h + p), this.ctx.lineTo(g + j, h + l - p), this.ctx.quadraticCurveTo(g + j, h + l, g + j - p, h + l), this.ctx.lineTo(g + p, h + l), this.ctx.quadraticCurveTo(g, h + l, g, h + l - p), this.ctx.lineTo(g, h + p), this.ctx.quadraticCurveTo(g, h, g + p, h), this.ctx.fill(), b.tooltips.border.width > 0 && (this.ctx.strokeStyle = b.tooltips.border.color, this.ctx.lineWidth = b.tooltips.border.width, this.ctx.stroke()), this.ctx.closePath()) : (this.ctx.fillRect(g, h, j, l), b.tooltips.border.width > 0 && (this.ctx.fillStyle = b.tooltips.border.color, this.ctx.lineWidth = b.tooltips.border.width, this.ctx.strokeRect(g, h, j, l))), this.ctx.font = b.tooltips.fontStyle + " " + b.tooltips.fontSize + " " + b.tooltips.fontFamily, this.ctx.fillStyle = b.tooltips.fontColor, this.ctx.textAlign = "center", this.ctx.textBaseline = "middle", this.ctx.fillText(i, g + j / 2, h + l / 2), this.x = d, this.y = e } }, g = a.canvas.width, h = a.canvas.height, this.savedState = null, window.Touch ? (a.canvas.ontouchstart = function (a) { a.clientX = a.targetTouches[0].clientX, a.clientY = a.targetTouches[0].clientY, j(a) }, a.canvas.ontouchmove = function (a) { a.clientX = a.targetTouches[0].clientX, a.clientY = a.targetTouches[0].clientY, j(a) }) : a.canvas.onmousemove = function (a) { j(a) }, a.canvas.onmouseout = function () { null != c.savedState && a.putImageData(c.savedState, 0, 0) }, window.devicePixelRatio && (a.canvas.style.width = g + "px", a.canvas.style.height = h + "px", a.canvas.height = h * window.devicePixelRatio, a.canvas.width = g * window.devicePixelRatio, a.scale(window.devicePixelRatio, window.devicePixelRatio)), this.PolarArea = function (b, d) { c.PolarArea.defaults = { scaleOverlay: !0, scaleOverride: !1, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleShowLine: !0, scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: !0, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowLabelBackdrop: !0, scaleBackdropColor: "rgba(255,255,255,0.75)", scaleBackdropPaddingY: 2, scaleBackdropPaddingX: 2, segmentShowStroke: !0, segmentStrokeColor: "#fff", segmentStrokeWidth: 2, animation: !0, animationSteps: 100, animationEasing: "easeOutBounce", animateRotate: !0, animateScale: !1, onAnimationComplete: null, showTooltips: !1 }; var e = d ? C(c.PolarArea.defaults, d) : c.PolarArea.defaults; return new l(b, e, a) }, this.Radar = function (b, d) { c.Radar.defaults = { scaleOverlay: !1, scaleOverride: !1, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleShowLine: !0, scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: !1, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowLabelBackdrop: !0, scaleBackdropColor: "rgba(255,255,255,0.75)", scaleBackdropPaddingY: 2, scaleBackdropPaddingX: 2, angleShowLineOut: !0, angleLineColor: "rgba(0,0,0,.1)", angleLineWidth: 1, pointLabelFontFamily: "'Arial'", pointLabelFontStyle: "normal", pointLabelFontSize: 12, pointLabelFontColor: "#666", pointDot: !0, pointDotRadius: 3, pointDotStrokeWidth: 1, datasetStroke: !0, datasetStrokeWidth: 2, datasetFill: !0, animation: !0, animationSteps: 60, animationEasing: "easeOutQuart", onAnimationComplete: null, showTooltips: !1 }; var e = d ? C(c.Radar.defaults, d) : c.Radar.defaults; return new m(b, e, a) }, this.Pie = function (b, d) { c.Pie.defaults = { segmentShowStroke: !0, segmentStrokeColor: "#fff", segmentStrokeWidth: 2, animation: !0, animationSteps: 100, animationEasing: "easeOutBounce", animateRotate: !0, animateScale: !1, onAnimationComplete: null, labelFontFamily: "'Arial'", labelFontStyle: "normal", labelFontSize: 12, labelFontColor: "#666", labelAlign: "right", showTooltips: !1 }; var e = d ? C(c.Pie.defaults, d) : c.Pie.defaults; return new n(b, e, a) }, this.Doughnut = function (b, d) { c.Doughnut.defaults = { segmentShowStroke: !0, segmentStrokeColor: "#fff", segmentStrokeWidth: 2, percentageInnerCutout: 50, animation: !0, animationSteps: 100, animationEasing: "easeOutBounce", animateRotate: !0, animateScale: !1, onAnimationComplete: null, showTooltips: !1 }; var e = d ? C(c.Doughnut.defaults, d) : c.Doughnut.defaults; return new o(b, e, a) }, this.Line = function (b, d) { c.Line.defaults = { scaleShowValues: !0, scaleValuePaddingX: 0, scaleValuePaddingY: 13, scaleValueFontColor: "#666", scaleValueFontSize: 10, scaleOverlay: !1, scaleOverride: !1, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: !0, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowGridLines: !0, scaleGridLineColor: "rgba(0,0,0,.05)", scaleGridLineWidth: 1, bezierCurve: !0, pointDot: !0, pointDotRadius: 4, pointDotStrokeWidth: 2, datasetStroke: !0, datasetStrokeWidth: 2, datasetFill: !0, animation: !0, animationSteps: 60, animationEasing: "easeOutQuart", onAnimationComplete: null, showTooltips: !1 }; var e = d ? C(c.Line.defaults, d) : c.Line.defaults; return new p(b, e, a) }, this.Bar = function (b, d) { c.Bar.defaults = { scaleShowValues: !0, scaleValuePaddingX: 0, scaleValuePaddingY: 3, scaleValueFontColor: "#666", scaleValueFontSize: 10, scaleOverlay: !1, scaleOverride: !1, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: !0, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowGridLines: !0, scaleGridLineColor: "rgba(0,0,0,.05)", scaleGridLineWidth: 1, barShowStroke: !0, barStrokeWidth: 2, barValueSpacing: 5, barDatasetSpacing: 1, animation: !0, animationSteps: 60, animationEasing: "easeOutQuart", onAnimationComplete: null, showTooltips: !1 }; var e = d ? C(c.Bar.defaults, d) : c.Bar.defaults; return new q(b, e, a) }, k = function (a) { a.clearRect(0, 0, g, h) }, l = function (a, b, c) { function n() { d = x([g, h]) / 2, d -= w([.5 * b.scaleFontSize, .5 * b.scaleLineWidth]), j = 2 * b.scaleFontSize, b.scaleShowLabelBackdrop && (j += 2 * b.scaleBackdropPaddingY, d -= 1.5 * b.scaleBackdropPaddingY), k = d, j = y(j, 5) } function o() { var a, d, e; for (a = 0; a < i.steps; a++) b.scaleShowLine && (c.beginPath(), c.arc(g / 2, h / 2, f * (a + 1), 0, 2 * Math.PI, !0), c.strokeStyle = b.scaleLineColor, c.lineWidth = b.scaleLineWidth, c.stroke()), b.scaleShowLabels && (c.textAlign = "center", c.font = b.scaleFontStyle + " " + b.scaleFontSize + "px " + b.scaleFontFamily, d = i.labels[a], b.scaleShowLabelBackdrop && (e = c.measureText(d).width, c.fillStyle = b.scaleBackdropColor, c.beginPath(), c.rect(Math.round(g / 2 - e / 2 - b.scaleBackdropPaddingX), Math.round(h / 2 - f * (a + 1) - .5 * b.scaleFontSize - b.scaleBackdropPaddingY), Math.round(e + 2 * b.scaleBackdropPaddingX), Math.round(b.scaleFontSize + 2 * b.scaleBackdropPaddingY)), c.fill()), c.textBaseline = "middle", c.fillStyle = b.scaleFontColor, c.fillText(d, g / 2, h / 2 - f * (a + 1))) } function p(d) { var n, o, p, q, s, j = -Math.PI / 2, k = 2 * Math.PI / a.length, l = 1, m = 1; for (b.animation && (b.animateScale && (l = d), b.animateRotate && (m = d)), n = 0; n < a.length; n++) { if (c.beginPath(), c.arc(g / 2, h / 2, l * r(a[n].value, i, f), j, j + m * k, !1), c.lineTo(g / 2, h / 2), c.closePath(), c.fillStyle = a[n].color, c.fill(), d >= 1 && b.showTooltips) { for (o = [{ x: g / 2, y: h / 2}], p = 50, q = r(a[n].value, i, f), o.push({ x: g / 2 + q * Math.cos(j), y: h / 2 + q * Math.sin(j) }), s = 0; p >= s; s++) o.push({ x: g / 2 + q * Math.cos(j + s / p * m * k), y: h / 2 + q * Math.sin(j + s / p * m * k) }); e(c, { type: "shape", points: o }, { label: a[n].label, value: a[n].value }, "PolarArea") } b.segmentShowStroke && (c.strokeStyle = b.segmentStrokeColor, c.lineWidth = b.segmentStrokeWidth, c.stroke()), j += m * k } } function q() { var d, e, f, b = Number.MIN_VALUE, c = Number.MAX_VALUE; for (d = 0; d < a.length; d++) a[d].value > b && (b = a[d].value), a[d].value < c && (c = a[d].value); return e = Math.floor(k / (.66 * j)), f = Math.floor(.5 * (k / j)), { maxValue: b, minValue: c, maxSteps: e, minSteps: f} } var d, f, i, j, k, l, m; n(), l = q(), m = b.scaleShowLabels ? b.scaleLabel : null, b.scaleOverride ? (i = { steps: b.scaleSteps, stepValue: b.scaleStepWidth, graphMin: b.scaleStartValue, labels: [] }, v(m, i.labels, i.steps, b.scaleStartValue, b.scaleStepWidth)) : i = u(k, l.maxSteps, l.minSteps, l.maxValue, l.minValue, m), f = d / i.steps, s(b, o, p, c) }, m = function (a, b, c) { function n(d) { var k, l, m, n, o, q, s, j = 2 * Math.PI / a.datasets[0].data.length; for (c.save(), c.translate(g / 2, h / 2), k = 0; k < a.datasets.length; k++) { for (l = r(a.datasets[k].data[0], i, f), c.beginPath(), c.moveTo(0, d * -1 * l), d >= 1 && b.showTooltips && (m = g / 2 + l * Math.cos(0 - Math.PI / 2), n = h / 2 + l * Math.sin(0 - Math.PI / 2), o = b.pointDot ? b.pointDotRadius + b.pointDotStrokeWidth : 10, "" != a.labels[0].trim() ? a.labels[0] + ": " + a.datasets[k].data[0] : a.datasets[k].data[0], e(c, { type: "circle", x: m, y: n, r: o }, { label: a.labels[0], value: a.datasets[k].data[0] }, "Radar")), q = 1; q < a.datasets[k].data.length; q++) l = r(a.datasets[k].data[q], i, f), c.rotate(j), c.lineTo(0, d * -1 * l), d >= 1 && b.showTooltips && (m = g / 2 + l * Math.cos(q * j - Math.PI / 2), n = h / 2 + l * Math.sin(q * j - Math.PI / 2), o = b.pointDot ? b.pointDotRadius + b.pointDotStrokeWidth : 10, "" != a.labels[q].trim() ? a.labels[q] + ": " + a.datasets[k].data[q] : a.datasets[k].data[q], e(c, { type: "circle", x: m, y: n, r: o }, { label: a.labels[q], value: a.datasets[k].data[q] }, "Radar")); if (c.closePath(), c.fillStyle = a.datasets[k].fillColor, c.strokeStyle = a.datasets[k].strokeColor, c.lineWidth = b.datasetStrokeWidth, c.fill(), c.stroke(), b.pointDot) for (c.fillStyle = a.datasets[k].pointColor, c.strokeStyle = a.datasets[k].pointStrokeColor, c.lineWidth = b.pointDotStrokeWidth, s = 0; s < a.datasets[k].data.length; s++) c.rotate(j), c.beginPath(), c.arc(0, d * -1 * r(a.datasets[k].data[s], i, f), b.pointDotRadius, 2 * Math.PI, !1), c.fill(), c.stroke(); c.rotate(j) } c.restore() } function o() { var j, k, l, m, n, o, p, e = 2 * Math.PI / a.datasets[0].data.length; if (c.save(), c.translate(g / 2, h / 2), b.angleShowLineOut) for (c.strokeStyle = b.angleLineColor, c.lineWidth = b.angleLineWidth, j = 0; j < a.datasets[0].data.length; j++) c.rotate(e), c.beginPath(), c.moveTo(0, 0), c.lineTo(0, -d), c.stroke(); for (k = 0; k < i.steps; k++) { if (c.beginPath(), b.scaleShowLine) { for (c.strokeStyle = b.scaleLineColor, c.lineWidth = b.scaleLineWidth, c.moveTo(0, -f * (k + 1)), l = 0; l < a.datasets[0].data.length; l++) c.rotate(e), c.lineTo(0, -f * (k + 1)); c.closePath(), c.stroke() } b.scaleShowLabels && (c.textAlign = "center", c.font = b.scaleFontStyle + " " + b.scaleFontSize + "px " + b.scaleFontFamily, c.textBaseline = "middle", b.scaleShowLabelBackdrop && (m = c.measureText(i.labels[k]).width, c.fillStyle = b.scaleBackdropColor, c.beginPath(), c.rect(Math.round(-m / 2 - b.scaleBackdropPaddingX), Math.round(-f * (k + 1) - .5 * b.scaleFontSize - b.scaleBackdropPaddingY), Math.round(m + 2 * b.scaleBackdropPaddingX), Math.round(b.scaleFontSize + 2 * b.scaleBackdropPaddingY)), c.fill()), c.fillStyle = b.scaleFontColor, c.fillText(i.labels[k], 0, -f * (k + 1))) } for (n = 0; n < a.labels.length; n++) c.font = b.pointLabelFontStyle + " " + b.pointLabelFontSize + "px " + b.pointLabelFontFamily, c.fillStyle = b.pointLabelFontColor, o = Math.sin(e * n) * (d + b.pointLabelFontSize), p = Math.cos(e * n) * (d + b.pointLabelFontSize), c.textAlign = e * n == Math.PI || 0 == e * n ? "center" : e * n > Math.PI ? "right" : "left", c.textBaseline = "middle", c.fillText(a.labels[n], o, -p); c.restore() } function p() { var e, f, i; for (d = x([g, h]) / 2, j = 2 * b.scaleFontSize, e = 0, f = 0; f < a.labels.length; f++) c.font = b.pointLabelFontStyle + " " + b.pointLabelFontSize + "px " + b.pointLabelFontFamily, i = c.measureText(a.labels[f]).width, i > e && (e = i); d -= w([e, 1.5 * (b.pointLabelFontSize / 2)]), d -= b.pointLabelFontSize, d = A(d, null, 0), k = d, j = y(j, 5) } function q() { var d, e, f, g, b = Number.MIN_VALUE, c = Number.MAX_VALUE; for (d = 0; d < a.datasets.length; d++) for (e = 0; e < a.datasets[d].data.length; e++) a.datasets[d].data[e] > b && (b = a.datasets[d].data[e]), a.datasets[d].data[e] < c && (c = a.datasets[d].data[e]); return f = Math.floor(k / (.66 * j)), g = Math.floor(.5 * (k / j)), { maxValue: b, minValue: c, maxSteps: f, minSteps: g} } var d, f, i, j, k, l, m; a.labels || (a.labels = []), p(), l = q(), m = b.scaleShowLabels ? b.scaleLabel : null, b.scaleOverride ? (i = { steps: b.scaleSteps, stepValue: b.scaleStepWidth, graphMin: b.scaleStartValue, labels: [] }, v(m, i.labels, i.steps, b.scaleStartValue, b.scaleStepWidth)) : i = u(k, l.maxSteps, l.minSteps, l.maxValue, l.minValue, m), f = d / i.steps, s(b, o, n, c) }, n = function (a, b, c) { function j(i) { function o(a, b) { switch (a) { case "left": return -b + 20; case "center": return -b / 2 } return -10 } function p(a) { switch (a) { case "left": return "right"; case "right": return "left"; case "center": return a } } var m, n, q, r, s, t, u, v, w, j = -Math.PI / 2, k = 1, l = 1; for (b.animation && (b.animateScale && (k = i), b.animateRotate && (l = i)), m = 0; m < a.length; m++) { if (n = l * a[m].value / d * 2 * Math.PI, c.beginPath(), c.arc(g / 2, h / 2, k * f, j, j + n), c.lineTo(g / 2, h / 2), c.closePath(), c.fillStyle = a[m].color, c.fill(), a[m].label && 2 * k * f * n / (2 * Math.PI) > b.labelFontSize && (q = a[m].labelFontSize || b.labelFontSize + "px", null != q.match(/^[0-9]+$/g) && (q += "px"), c.font = b.labelFontStyle + " " + q + " " + b.labelFontFamily, c.fillStyle = F(i, a[m].labelColor || "black", a[m].color), c.textBaseline = "middle", r = -(j + n) + n / 2, s = g / 2 + k * f * Math.cos(r), t = h / 2 - k * f * Math.sin(r), c.textAlign = a[m].labelAlign || b.labelAlign, textX = o(c.textAlign, k * f), r < -Math.PI / 2 && (r -= Math.PI, c.textAlign = p(c.textAlign), textX = -textX), c.translate(s, t), c.rotate(-r), c.fillText(a[m].label, textX, 0), c.rotate(r), c.translate(-s, -t)), i >= 1 && b.showTooltips) { for (u = [{ x: g / 2, y: h / 2}], v = 50, u.push({ x: g / 2 + f * Math.cos(j), y: h / 2 + f * Math.sin(j) }), w = 0; v >= w; w++) u.push({ x: g / 2 + f * Math.cos(j + w / v * n), y: h / 2 + f * Math.sin(j + w / v * n) }); e(c, { type: "shape", points: u }, { label: a[m].label, value: a[m].value }, "Pie") } b.segmentShowStroke && (c.lineWidth = b.segmentStrokeWidth, c.strokeStyle = b.segmentStrokeColor, c.stroke()), j += n } } var i, d = 0, f = x([h / 2, g / 2]) - 5; for (i = 0; i < a.length; i++) d += a[i].value; c.fillStyle = "black", c.textBaseline = "base", s(b, null, j, c) }, o = function (a, b, c) { function k(j) { var n, o, p, q, r, k = -Math.PI / 2, l = 1, m = 1; for (b.animation && (b.animateScale && (l = j), b.animateRotate && (m = j)), n = 0; n < a.length; n++) { if (o = m * a[n].value / d * 2 * Math.PI, c.beginPath(), c.arc(g / 2, h / 2, l * f, k, k + o, !1), c.arc(g / 2, h / 2, l * i, k + o, k, !0), c.closePath(), c.fillStyle = a[n].color, c.fill(), j >= 1 && b.showTooltips) { for (p = [], q = 50, p.push({ x: g / 2 + f * Math.cos(k), y: h / 2 + f * Math.sin(k) }), r = 0; q >= r; r++) p.push({ x: g / 2 + f * Math.cos(k + r / q * o), y: h / 2 + f * Math.sin(k + r / q * o) }); for (p.push({ x: g / 2 + i * Math.cos(k + o), y: h / 2 + i * Math.sin(k + o) }), r = q; r >= 0; r--) p.push({ x: g / 2 + i * Math.cos(k + r / q * o), y: h / 2 + i * Math.sin(k + r / q * o) }); e(c, { type: "shape", points: p }, { label: a[n].label, value: a[n].value }, "Doughnut") } b.segmentShowStroke && (c.lineWidth = b.segmentStrokeWidth, c.strokeStyle = b.segmentStrokeColor, c.stroke()), k += o } } var j, d = 0, f = x([h / 2, g / 2]) - 5, i = f * (b.percentageInnerCutout / 100); for (j = 0; j < a.length; j++) d += a[j].value; s(b, null, k, c) }, p = function (a, b, c) { function x(d) { function s(b, c) { return t - d * r(a.datasets[b].data[c], i, f) } function u(a) { return q + n * a } var g, h, j, k, l, m, o, p; for (g = 0; g < a.datasets.length; g++) { for (c.strokeStyle = a.datasets[g].strokeColor, c.lineWidth = b.datasetStrokeWidth, c.beginPath(), c.moveTo(q, t - d * r(a.datasets[g].data[0], i, f)), h = 1; h < a.datasets[g].data.length; h++) b.bezierCurve ? c.bezierCurveTo(u(h - .5), s(g, h - 1), u(h - .5), s(g, h), u(h), s(g, h)) : c.lineTo(u(h), s(g, h)); for (j = b.pointDot ? b.pointDotRadius + b.pointDotStrokeWidth : 10, h = 0; h < a.datasets[g].data.length; h++) d >= 1 && b.showTooltips && e(c, { type: "circle", x: u(h), y: s(g, h), r: j }, { label: a.labels[h], value: a.datasets[g].data[h] }, "Line"); if (c.stroke(), b.datasetFill ? (c.lineTo(q + n * (a.datasets[g].data.length - 1), t), c.lineTo(q, t), c.closePath(), c.fillStyle = a.datasets[g].fillColor, c.fill()) : c.closePath(), b.pointDot) for (c.fillStyle = a.datasets[g].pointColor, c.strokeStyle = a.datasets[g].pointStrokeColor, c.lineWidth = b.pointDotStrokeWidth, k = 0; k < a.datasets[g].data.length; k++) c.beginPath(), c.arc(q + n * k, t - d * r(a.datasets[g].data[k], i, f), b.pointDotRadius, 0, 2 * Math.PI, !0), c.fill(), c.stroke(), b.scaleShowValues && 0 != a.datasets[g].data[k] && (c.save(), c.textAlign = "center", c.font = b.scaleFontStyle + " " + b.scaleValueFontSize + "px " + b.scaleFontFamily, c.fillStyle = b.scaleValueFontColor, l = q + n * k, m = t - d * r(a.datasets[g].data[k], i, f), o = b.scaleValuePaddingX, p = b.scaleValuePaddingY, c.fillText(a.datasets[g].data[k], l + o, m - p), c.restore()) } } function y() { var d, e; for (c.lineWidth = b.scaleLineWidth, c.strokeStyle = b.scaleLineColor, c.beginPath(), c.moveTo(g - o / 2 + 5, t), c.lineTo(g - o / 2 - p - 5, t), c.stroke(), w > 0 ? (c.save(), c.textAlign = "right") : c.textAlign = "center", c.fillStyle = b.scaleFontColor, d = 0; d < a.labels.length; d++) c.save(), w > 0 ? (c.translate(q + d * n, t + b.scaleFontSize), c.rotate(-(w * (Math.PI / 180))), c.fillText(a.labels[d], 0, 0), c.restore()) : c.fillText(a.labels[d], q + d * n, t + b.scaleFontSize + 3), c.beginPath(), c.moveTo(q + d * n, t + 3), b.scaleShowGridLines && d > 0 ? (c.lineWidth = b.scaleGridLineWidth, c.strokeStyle = b.scaleGridLineColor, c.lineTo(q + d * n, 5)) : c.lineTo(q + d * n, t + 3), c.stroke(); for (c.lineWidth = b.scaleLineWidth, c.strokeStyle = b.scaleLineColor, c.beginPath(), c.moveTo(q, t + 5), c.lineTo(q, 5), c.stroke(), c.textAlign = "right", c.textBaseline = "middle", e = 0; e < i.steps; e++) c.beginPath(), c.moveTo(q - 3, t - (e + 1) * f), b.scaleShowGridLines ? (c.lineWidth = b.scaleGridLineWidth, c.strokeStyle = b.scaleGridLineColor, c.lineTo(q + p + 5, t - (e + 1) * f)) : c.lineTo(q - .5, t - (e + 1) * f), c.stroke(), b.scaleShowLabels && c.fillText(i.labels[e], q - 8, t - (e + 1) * f) } function z() { var e, f, d = 1; if (b.scaleShowLabels) { for (c.font = b.scaleFontStyle + " " + b.scaleFontSize + "px " + b.scaleFontFamily, e = 0; e < i.labels.length; e++) f = c.measureText(i.labels[e]).width, d = f > d ? f : d; d += 10 } p = g - d - o, n = Math.floor(p / (a.labels.length - 1)), q = g - o / 2 - p, t = k + b.scaleFontSize / 2 } function A() { var e, f; for (d = h, c.font = b.scaleFontStyle + " " + b.scaleFontSize + "px " + b.scaleFontFamily, o = 1, e = 0; e < a.labels.length; e++) f = c.measureText(a.labels[e]).width, o = f > o ? f : o; g / a.labels.length < o ? (w = 45, g / a.labels.length < Math.cos(w) * o ? (w = 90, d -= o) : d -= Math.sin(w) * o) : d -= b.scaleFontSize, d -= 5, j = b.scaleFontSize, d -= j, k = d } function B() { var d, e, f, g, b = Number.MIN_VALUE, c = Number.MAX_VALUE; for (d = 0; d < a.datasets.length; d++) for (e = 0; e < a.datasets[d].data.length; e++) a.datasets[d].data[e] > b && (b = a.datasets[d].data[e]), a.datasets[d].data[e] < c && (c = a.datasets[d].data[e]); return f = Math.floor(k / (.66 * j)), g = Math.floor(.5 * (k / j)), { maxValue: b, minValue: c, maxSteps: f, minSteps: g} } var d, f, i, j, k, l, m, n, o, p, q, t, w = 0; A(), l = B(), m = b.scaleShowLabels ? b.scaleLabel : "", b.scaleOverride ? (i = { steps: b.scaleSteps, stepValue: b.scaleStepWidth, graphMin: b.scaleStartValue, labels: [] }, v(m, i.labels, i.steps, b.scaleStartValue, b.scaleStepWidth)) : i = u(k, l.maxSteps, l.minSteps, l.maxValue, l.minValue, m), f = Math.floor(k / i.steps), z(), s(b, y, x, c) }, q = function (a, b, c) { function y(d) { var g, h, j, k, l, m, o, p; for (c.lineWidth = b.barStrokeWidth, g = 0; g < a.datasets.length; g++) for (c.fillStyle = a.datasets[g].fillColor, c.strokeStyle = a.datasets[g].strokeColor, h = 0; h < a.datasets[g].data.length; h++) j = q + b.barValueSpacing + n * h + w * g + b.barDatasetSpacing * g + b.barStrokeWidth * g, c.beginPath(), c.moveTo(j, t), k = t - d * r(a.datasets[g].data[h], i, f) + b.barStrokeWidth / 2, c.lineTo(j, k), c.lineTo(j + w, t - d * r(a.datasets[g].data[h], i, f) + b.barStrokeWidth / 2), c.lineTo(j + w, t), b.barShowStroke && c.stroke(), c.closePath(), c.fill(), b.scaleShowValues && z(c, k - b.scaleValuePaddingY, j + w / 2 + b.scaleValuePaddingX, b.scaleValueFontSize, a.datasets[g].data[h], b.scaleValueFontColor), d >= 1 && b.showTooltips && (l = j, m = r(a.datasets[g].data[h], i, f), o = t - m, p = w, e(c, { type: "rect", x: l, y: o, width: p, height: m }, { label: a.labels[h], value: a.datasets[g].data[h] }, "Bar")) } function z(a, b, c, d, e, f) { var g = a.fillStyle; b = b + d - (d + 6 * d / 10), a.fillStyle = f, a.textAlign = "center", a.font = d + "pt", a.fillText(e, c, b), a.fillStyle = g } function A() { var d, e; for (c.lineWidth = b.scaleLineWidth, c.strokeStyle = b.scaleLineColor, c.beginPath(), c.moveTo(g - o / 2 + 5, t), c.lineTo(g - o / 2 - p - 5, t), c.stroke(), x > 0 ? (c.save(), c.textAlign = "right") : c.textAlign = "center", c.fillStyle = b.scaleFontColor, d = 0; d < a.labels.length; d++) c.save(), x > 0 ? (c.translate(q + d * n, t + b.scaleFontSize), c.rotate(-(x * (Math.PI / 180))), c.fillText(a.labels[d], 0, 0), c.restore()) : c.fillText(a.labels[d], q + d * n + n / 2, t + b.scaleFontSize + 3), c.beginPath(), c.moveTo(q + (d + 1) * n, t + 3), c.lineWidth = b.scaleGridLineWidth, c.strokeStyle = b.scaleGridLineColor, c.lineTo(q + (d + 1) * n, 5), c.stroke(); for (c.lineWidth = b.scaleLineWidth, c.strokeStyle = b.scaleLineColor, c.beginPath(), c.moveTo(q, t + 5), c.lineTo(q, 5), c.stroke(), c.textAlign = "right", c.textBaseline = "middle", e = 0; e < i.steps; e++) c.beginPath(), c.moveTo(q - 3, t - (e + 1) * f), b.scaleShowGridLines ? (c.lineWidth = b.scaleGridLineWidth, c.strokeStyle = b.scaleGridLineColor, c.lineTo(q + p + 5, t - (e + 1) * f)) : c.lineTo(q - .5, t - (e + 1) * f), c.stroke(), b.scaleShowLabels && c.fillText(i.labels[e], q - 8, t - (e + 1) * f) } function B() { var e, f, d = 1; if (b.scaleShowLabels) { for (c.font = b.scaleFontStyle + " " + b.scaleFontSize + "px " + b.scaleFontFamily, e = 0; e < i.labels.length; e++) f = c.measureText(i.labels[e]).width, d = f > d ? f : d; d += 10 } p = g - d - o, n = Math.floor(p / a.labels.length), w = (n - 2 * b.scaleGridLineWidth - 2 * b.barValueSpacing - (b.barDatasetSpacing * a.datasets.length - 1) - (b.barStrokeWidth / 2 * a.datasets.length - 1)) / a.datasets.length, q = g - o / 2 - p, t = k + b.scaleFontSize / 2 } function C() { var e, f; for (d = h, c.font = b.scaleFontStyle + " " + b.scaleFontSize + "px " + b.scaleFontFamily, o = 1, e = 0; e < a.labels.length; e++) f = c.measureText(a.labels[e]).width, o = f > o ? f : o; g / a.labels.length < o ? (x = 45, g / a.labels.length < Math.cos(x) * o ? (x = 90, d -= o) : d -= Math.sin(x) * o) : d -= b.scaleFontSize, d -= 5, j = b.scaleFontSize, d -= j, k = d } function D() { var d, e, f, g, b = Number.MIN_VALUE, c = Number.MAX_VALUE; for (d = 0; d < a.datasets.length; d++) for (e = 0; e < a.datasets[d].data.length; e++) a.datasets[d].data[e] > b && (b = a.datasets[d].data[e]), a.datasets[d].data[e] < c && (c = a.datasets[d].data[e]); return f = Math.floor(k / (.66 * j)), g = Math.floor(.5 * (k / j)), { maxValue: b, minValue: c, maxSteps: f, minSteps: g} } var d, f, i, j, k, l, m, n, o, p, q, t, w, x = 0; C(), l = D(), m = b.scaleShowLabels ? b.scaleLabel : "", b.scaleOverride ? (i = { steps: b.scaleSteps, stepValue: b.scaleStepWidth, graphMin: b.scaleStartValue, labels: [] }, v(m, i.labels, i.steps, b.scaleStartValue, b.scaleStepWidth)) : i = u(k, l.maxSteps, l.minSteps, l.maxValue, l.minValue, m), f = Math.floor(k / i.steps), B(), s(b, A, y, c) }, t = function () { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (a) { window.setTimeout(a, 1e3 / 60) } } (), D = {} };