1/*! 2 * Chart.js 3 * http://chartjs.org/ 4 * Version: 1.0.1-beta.4 5 * 6 * Copyright 2014 Nick Downie 7 * Released under the MIT license 8 * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md 9 */ 10 11(function() { 12 "use strict"; 13 var t = this, 14 i = t.Chart, 15 e = function(t) { 16 this.canvas = t.canvas, this.ctx = t; 17 this.width = t.canvas.width, this.height = t.canvas.height; 18 return this.aspectRatio = this.width / this.height, s.retinaScale(this), this 19 }; 20 e.defaults = { 21 global: { 22 animation: !0, 23 animationSteps: 60, 24 animationEasing: "easeOutQuart", 25 showScale: !0, 26 scaleOverride: !1, 27 scaleSteps: null, 28 scaleStepWidth: null, 29 scaleStartValue: null, 30 scaleLineColor: "rgba(0,0,0,.1)", 31 scaleLineWidth: 1, 32 scaleShowLabels: !0, 33 scaleLabel: "<%=value%>", 34 scaleIntegersOnly: !0, 35 scaleBeginAtZero: !1, 36 scaleFontFamily: "'Lato', sans-serif", 37 scaleFontSize: 14, 38 scaleFontStyle: "bold", 39 scaleFontColor: "#000", 40 responsive: !1, 41 maintainAspectRatio: !0, 42 showTooltips: !0, 43 tooltipEvents: ["mousemove", "touchstart", "touchmove", "mouseout"], 44 tooltipFillColor: "rgba(0,0,0,0.8)", 45 tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", 46 tooltipFontSize: 14, 47 tooltipFontStyle: "normal", 48 tooltipFontColor: "#fff", 49 tooltipTitleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", 50 tooltipTitleFontSize: 14, 51 tooltipTitleFontStyle: "bold", 52 tooltipTitleFontColor: "#fff", 53 tooltipYPadding: 6, 54 tooltipXPadding: 6, 55 tooltipCaretSize: 8, 56 tooltipCornerRadius: 6, 57 tooltipXOffset: 10, 58 tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>", 59 multiTooltipTemplate: "<%= value %>", 60 multiTooltipKeyBackground: "#fff", 61 onAnimationProgress: function() {}, 62 onAnimationComplete: function() {} 63 } 64 }, e.types = {}; 65 var s = e.helpers = {}, 66 n = s.each = function(t, i, e) { 67 var s = Array.prototype.slice.call(arguments, 3); 68 if (t) 69 if (t.length === +t.length) { 70 var n; 71 for (n = 0; n < t.length; n++) i.apply(e, [t[n], n].concat(s)) 72 } else 73 for (var o in t) i.apply(e, [t[o], o].concat(s)) 74 }, 75 o = s.clone = function(t) { 76 var i = {}; 77 return n(t, function(e, s) { 78 t.hasOwnProperty(s) && (i[s] = e) 79 }), i 80 }, 81 a = s.extend = function(t) { 82 return n(Array.prototype.slice.call(arguments, 1), function(i) { 83 n(i, function(e, s) { 84 i.hasOwnProperty(s) && (t[s] = e) 85 }) 86 }), t 87 }, 88 h = s.merge = function() { 89 var t = Array.prototype.slice.call(arguments, 0); 90 return t.unshift({}), a.apply(null, t) 91 }, 92 l = s.indexOf = function(t, i) { 93 if (Array.prototype.indexOf) return t.indexOf(i); 94 for (var e = 0; e < t.length; e++) 95 if (t[e] === i) return e; 96 return -1 97 }, 98 r = (s.where = function(t, i) { 99 var e = []; 100 return s.each(t, function(t) { 101 i(t) && e.push(t) 102 }), e 103 }, s.findNextWhere = function(t, i, e) { 104 e || (e = -1); 105 for (var s = e + 1; s < t.length; s++) { 106 var n = t[s]; 107 if (i(n)) return n 108 } 109 }, s.findPreviousWhere = function(t, i, e) { 110 e || (e = t.length); 111 for (var s = e - 1; s >= 0; s--) { 112 var n = t[s]; 113 if (i(n)) return n 114 } 115 }, s.inherits = function(t) { 116 var i = this, 117 e = t && t.hasOwnProperty("constructor") ? t.constructor : function() { 118 return i.apply(this, arguments) 119 }, 120 s = function() { 121 this.constructor = e 122 }; 123 return s.prototype = i.prototype, e.prototype = new s, e.extend = r, t && a(e.prototype, t), e.__super__ = i.prototype, e 124 }), 125 c = s.noop = function() {}, 126 u = s.uid = function() { 127 var t = 0; 128 return function() {
129 return "chart-" + t++ 130 } 131 }(), 132 d = s.warn = function(t) { 133 window.console && "function" == typeof window.console.warn && console.warn(t) 134 }, 135 p = s.amd = "function" == typeof t.define && t.define.amd, 136 f = s.isNumber = function(t) { 137 return !isNaN(parseFloat(t)) && isFinite(t) 138 }, 139 g = s.max = function(t) { 140 return Math.max.apply(Math, t) 141 }, 142 m = s.min = function(t) { 143 return Math.min.apply(Math, t) 144 }, 145 v = (s.cap = function(t, i, e) { 146 if (f(i)) { 147 if (t > i) return i 148 } else if (f(e) && e > t) return e; 149 return t 150 }, s.getDecimalPlaces = function(t) { 151 return t % 1 !== 0 && f(t) ? t.toString().split(".")[1].length : 0 152 }), 153 x = s.radians = function(t) { 154 return t * (Math.PI / 180) 155 }, 156 S = (s.getAngleFromPoint = function(t, i) { 157 var e = i.x - t.x, 158 s = i.y - t.y, 159 n = Math.sqrt(e * e + s * s), 160 o = 2 * Math.PI + Math.atan2(s, e); 161 return 0 > e && 0 > s && (o += 2 * Math.PI), { 162 angle: o, 163 distance: n 164 } 165 }, s.aliasPixel = function(t) { 166 return t % 2 === 0 ? 0 : .5 167 }), 168 y = (s.splineCurve = function(t, i, e, s) { 169 var n = Math.sqrt(Math.pow(i.x - t.x, 2) + Math.pow(i.y - t.y, 2)), 170 o = Math.sqrt(Math.pow(e.x - i.x, 2) + Math.pow(e.y - i.y, 2)), 171 a = s * n / (n + o), 172 h = s * o / (n + o); 173 return { 174 inner: { 175 x: i.x - a * (e.x - t.x), 176 y: i.y - a * (e.y - t.y) 177 }, 178 outer: { 179 x: i.x + h * (e.x - t.x), 180 y: i.y + h * (e.y - t.y) 181 } 182 } 183 }, s.calculateOrderOfMagnitude = function(t) { 184 return Math.floor(Math.log(t) / Math.LN10) 185 }), 186 C = (s.calculateScaleRange = function(t, i, e, s, n) { 187 var o = 2, 188 a = Math.floor(i / (1.5 * e)), 189 h = o >= a, 190 l = g(t), 191 r = m(t); 192 l === r && (l += .5, r >= .5 && !s ? r -= .5 : l += .5); 193 for (var c = Math.abs(l - r), u = y(c), d = Math.ceil(l / (1 * Math.pow(10, u))) * Math.pow(10, u), p = s ? 0 : Math.floor(r / (1 * Math.pow(10, u))) * Math.pow(10, u), f = d - p, v = Math.pow(10, u), x = Math.round(f / v); 194 (x > a || a > 2 * x) && !h;) 195 if (x > a) v *= 2, x = Math.round(f / v), x % 1 !== 0 && (h = !0); 196 else if (n && u >= 0) { 197 if (v / 2 % 1 !== 0) break; 198 v /= 2, x = Math.round(f / v) 199 } else v /= 2, x = Math.round(f / v); 200 return h && (x = o, v = f / x), { 201 steps: x, 202 stepValue: v, 203 min: p, 204 max: p + x * v 205 } 206 }, s.template = function(t, i) { 207 function e(t, i) { 208 var e = /\W/.test(t) ? new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('" + t.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('');") : s[t] = s[t]; 209 return i ? e(i) : e 210 } 211 if (t instanceof Function) return t(i); 212 var s = {}; 213 return e(t, i) 214 }), 215 b = (s.generateLabels = function(t, i, e, s) { 216 var o = new Array(i); 217 return labelTemplateString && n(o, function(i, n) { 218 o[n] = C(t, { 219 value: e + s * (n + 1) 220 }) 221 }), o 222 }, s.easingEffects = { 223 linear: function(t) { 224 return t 225 }, 226 easeInQuad: function(t) { 227 return t * t 228 }, 229 easeOutQuad: function(t) { 230 return -1 * t * (t - 2) 231 }, 232 easeInOutQuad: function(t) { 233 return (t /= .5) < 1 ? .5 * t * t : -0.5 * (--t * (t - 2) - 1) 234 }, 235 easeInCubic: function(t) { 236 return t * t * t 237 }, 238 easeOutCubic: function(t) { 239 return 1 * ((t = t / 1 - 1) * t * t + 1) 240 }, 241 easeInOutCubic: function(t) { 242 return (t /= .5) < 1 ? .5 * t * t * t : .5 * ((t -= 2) * t * t + 2) 243 }, 244 easeInQuart: function(t) { 245 return t * t * t * t 246 }, 247 easeOutQuart: function(t) { 248 return -1 * ((t = t / 1 - 1) * t * t * t - 1) 249 }, 250 easeInOutQuart: function(t) { 251 return (t /= .5) < 1 ? .5 * t * t * t * t : -0.5 * ((t -= 2) * t * t * t - 2) 252 }, 253 easeInQuint: function(t) { 254 return 1 * (t /= 1) * t * t * t * t 255 }, 256 easeOutQuint: function(t) { 257 return 1 * ((t = t / 1 - 1) * t * t * t * t + 1) 258 }, 259 easeInOutQuint: function(t) { 260 return (t /= .5) < 1 ? .5 * t * t * t * t * t : .5 * ((t -= 2) * t * t * t * t + 2) 261 }, 262 easeInSine: function(t) { 263 return -1 * Math.cos(t / 1 * (Math.PI / 2)) + 1 264 }, 265 easeOutSine: function(t) { 266 return 1 * Math.sin(t / 1 * (Math.PI / 2)) 267 }, 268 easeInOutSine: function(t) { 269 return -0.5 * (Math.cos(Math.PI * t / 1) - 1) 270 }, 271 easeInExpo: function(t) { 272 return 0 === t ? 1 : 1 * Math.pow(2, 10 * (t / 1 - 1)) 273 }, 274 easeOutExpo: function(t) { 275 return 1 === t ? 1 : 1 * (-Math.pow(2, -10 * t / 1) + 1) 276 }, 277 easeInOutExpo: function(t) { 278 return 0 === t ? 0 : 1 === t ? 1 : (t /= .5) < 1 ? .5 * Math.pow(2, 10 * (t - 1)) : .5 * (-Math.pow(2, -10 * --t) + 2) 279 }, 280 easeInCirc: function(t) { 281 return t >= 1 ? t : -1 * (Math.sqrt(1 - (t /= 1) * t) - 1) 282 }, 283 easeOutCirc: function(t) { 284 return 1 * Math.sqrt(1 - (t = t / 1 - 1) * t) 285 }, 286 easeInOutCirc: function(t) { 287 return (t /= .5) < 1 ? -0.5 * (Math.sqrt(1 - t * t) - 1) : .5 * (Math.sqrt(1 - (t -= 2) * t) + 1) 288 }, 289 easeInElastic: function(t) { 290 var i = 1.70158, 291 e = 0, 292 s = 1; 293 return 0 === t ? 0 : 1 == (t /= 1) ? 1 : (e || (e = .3), s < Math.abs(1) ? (s = 1, i = e / 4) : i = e / (2 * Math.PI) * Math.asin(1 / s), -(s * Math.pow(2, 10 * (t -= 1)) * Math.sin(2 * (1 * t - i) * Math.PI / e))) 294 }, 295 easeOutElastic: function(t) { 296 var i = 1.70158, 297 e = 0, 298 s = 1; 299 return 0 === t ? 0 : 1 == (t /= 1) ? 1 : (e || (e = .3), s < Math.abs(1) ? (s = 1, i = e / 4) : i = e / (2 * Math.PI) * Math.asin(1 / s), s * Math.pow(2, -10 * t) * Math.sin(2 * (1 * t - i) * Math.PI / e) + 1) 300 }, 301 easeInOutElastic: function(t) { 302 var i = 1.70158, 303 e = 0, 304 s = 1; 305 return 0 === t ? 0 : 2 == (t /= .5) ? 1 : (e || (e = .3 * 1.5), s < Math.abs(1) ? (s = 1, i = e / 4) : i = e / (2 * Math.PI) * Math.asin(1 / s), 1 > t ? -.5 * s * Math.pow(2, 10 * (t -= 1)) * Math.sin(2 * (1 * t - i) * Math.PI / e) : s * Math.pow(2, -10 * (t -= 1)) * Math.sin(2 * (1 * t - i) * Math.PI / e) * .5 + 1) 306 }, 307 easeInBack: function(t) { 308 var i = 1.70158; 309 return 1 * (t /= 1) * t * ((i + 1) * t - i) 310 }, 311 easeOutBack: function(t) { 312 var i = 1.70158; 313 return 1 * ((t = t / 1 - 1) * t * ((i + 1) * t + i) + 1) 314 }, 315 easeInOutBack: function(t) { 316 var i = 1.70158; 317 return (t /= .5) < 1 ? .5 * t * t * (((i *= 1.525) + 1) * t - i) : .5 * ((t -= 2) * t * (((i *= 1.525) + 1) * t + i) + 2) 318 }, 319 easeInBounce: function(t) { 320 return 1 - b.easeOutBounce(1 - t) 321 }, 322 easeOutBounce: function(t) { 323 return (t /= 1) < 1 / 2.75 ? 7.5625 * t * t : 2 / 2.75 > t ? 1 * (7.5625 * (t -= 1.5 / 2.75) * t + .75) : 2.5 / 2.75 > t ? 1 * (7.5625 * (t -= 2.25 / 2.75) * t + .9375) : 1 * (7.5625 * (t -= 2.625 / 2.75) * t + .984375) 324 }, 325 easeInOutBounce: function(t) { 326 return .5 > t ? .5 * b.easeInBounce(2 * t) : .5 * b.easeOutBounce(2 * t - 1) + .5 327 } 328 }), 329 w = s.requestAnimFrame = function() { 330 return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(t) { 331 return window.setTimeout(t, 1e3 / 60) 332 } 333 }(), 334 P = (s.cancelAnimFrame = function() { 335 return window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame || function(t) { 336 return window.clearTimeout(t, 1e3 / 60) 337 } 338 }(), s.animationLoop = function(t, i, e, s, n, o) { 339 var a = 0, 340 h = b[e] || b.linear, 341 l = function() { 342 a++; 343 var e = a / i, 344 r = h(e); 345 t.call(o, r, e, a), s.call(o, r, e), i > a ? o.animationFrame = w(l) : n.apply(o) 346 }; 347 w(l) 348 }, s.getRelativePosition = function(t) { 349 var i, e, s = t.originalEvent || t, 350 n = t.currentTarget || t.srcElement, 351 o = n.getBoundingClientRect(); 352 return s.touches ? (i = s.touches[0].clientX - o.left, e = s.touches[0].clientY - o.top) : (i = s.clientX - o.left, e = s.clientY - o.top), { 353 x: i, 354 y: e 355 } 356 }, s.addEvent = function(t, i, e) { 357 t.addEventListener ? t.addEventListener(i, e) : t.attachEvent ? t.attachEvent("on" + i, e) : t["on" + i] = e 358 }), 359 L = s.removeEvent = function(t, i, e) { 360 t.removeEventListener ? t.removeEventListener(i, e, !1) : t.detachEvent ? t.detachEvent("on" + i, e) : t["on" + i] = c 361 }, 362 k = (s.bindEvents = function(t, i, e) { 363 t.events || (t.events = {}), n(i, function(i) { 364 t.events[i] = function() { 365 e.apply(t, arguments) 366 }, P(t.chart.canvas, i, t.events[i]) 367 }) 368 }, s.unbindEvents = function(t, i) { 369 n(i, function(i, e) { 370 L(t.chart.canvas, e, i) 371 }) 372 }), 373 F = s.getMaximumWidth = function(t) { 374 var i = t.parentNode; 375 return i.clientWidth 376 }, 377 R = s.getMaximumHeight = function(t) { 378 var i = t.parentNode; 379 return i.clientHeight 380 }, 381 A = (s.getMaximumSize = s.getMaximumWidth, s.retinaScale = function(t) { 382 var i = t.ctx, 383 e = t.canvas.width, 384 s = t.canvas.height; 385 window.devicePixelRatio && (i.canvas.style.width = e + "px", i.canvas.style.height = s + "px", i.canvas.height = s * window.devicePixelRatio, i.canvas.width = e * window.devicePixelRatio, i.scale(window.devicePixelRatio, window.devicePixelRatio)) 386 }), 387 T = s.clear = function(t) { 388 t.ctx.clearRect(0, 0, t.width, t.height) 389 }, 390 M = s.fontString = function(t, i, e) { 391 return i + " " + t + "px " + e 392 }, 393 W = s.longestText = function(t, i, e) { 394 t.font = i; 395 var s = 0; 396 return n(e, function(i) { 397 var e = t.measureText(i).width; 398 s = e >
398 s ? e : s 399 }), s 400 }, 401 z = s.drawRoundedRectangle = function(t, i, e, s, n, o) { 402 t.beginPath(), t.moveTo(i + o, e), t.lineTo(i + s - o, e), t.quadraticCurveTo(i + s, e, i + s, e + o), t.lineTo(i + s, e + n - o), t.quadraticCurveTo(i + s, e + n, i + s - o, e + n), t.lineTo(i + o, e + n), t.quadraticCurveTo(i, e + n, i, e + n - o), t.lineTo(i, e + o), t.quadraticCurveTo(i, e, i + o, e), t.closePath() 403 }; 404 e.instances = {}, e.Type = function(t, i, s) { 405 this.options = i, this.chart = s, this.id = u(), e.instances[this.id] = this, i.responsive && this.resize(), this.initialize.call(this, t) 406 }, a(e.Type.prototype, { 407 initialize: function() { 408 return this 409 }, 410 clear: function() { 411 return T(this.chart), this 412 }, 413 stop: function() { 414 return s.cancelAnimFrame.call(t, this.animationFrame), this 415 }, 416 resize: function(t) { 417 this.stop(); 418 var i = this.chart.canvas, 419 e = F(this.chart.canvas), 420 s = this.options.maintainAspectRatio ? e / this.chart.aspectRatio : R(this.chart.canvas); 421 return i.width = this.chart.width = e, i.height = this.chart.height = s, A(this.chart), "function" == typeof t && t.apply(this, Array.prototype.slice.call(arguments, 1)), this 422 }, 423 reflow: c, 424 render: function(t) { 425 return t && this.reflow(), this.options.animation && !t ? s.animationLoop(this.draw, this.options.animationSteps, this.options.animationEasing, this.options.onAnimationProgress, this.options.onAnimationComplete, this) : (this.draw(), this.options.onAnimationComplete.call(this)), this 426 }, 427 generateLegend: function() { 428 return C(this.options.legendTemplate, this) 429 }, 430 destroy: function() { 431 this.clear(), k(this, this.events), delete e.instances[this.id] 432 }, 433 showTooltip: function(t, i) { 434 "undefined" == typeof this.activeElements && (this.activeElements = []); 435 var o = function(t) { 436 var i = !1; 437 return t.length !== this.activeElements.length ? i = !0 : (n(t, function(t, e) { 438 t !== this.activeElements[e] && (i = !0) 439 }, this), i) 440 }.call(this, t); 441 if (o || i) { 442 if (this.activeElements = t, this.draw(), t.length > 0) 443 if (this.datasets && this.datasets.length > 1) { 444 for (var a, h, r = this.datasets.length - 1; r >= 0 && (a = this.datasets[r].points || this.datasets[r].bars || this.datasets[r].segments, h = l(a, t[0]), -1 === h); r--); 445 var c = [], 446 u = [], 447 d = function() { 448 var t, i, e, n, o, a = [], 449 l = [], 450 r = []; 451 return s.each(this.datasets, function(i) { 452 t = i.points || i.bars || i.segments, t[h] && t[h].hasValue() && a.push(t[h]) 453 }), s.each(a, function(t) { 454 l.push(t.x), r.push(t.y), c.push(s.template(this.options.multiTooltipTemplate, t)), u.push({ 455 fill: t._saved.fillColor || t.fillColor, 456 stroke: t._saved.strokeColor || t.strokeColor 457 }) 458 }, this), o = m(r), e = g(r), n = m(l), i = g(l), { 459 x: n > this.chart.width / 2 ? n : i, 460 y: (o + e) / 2 461 } 462 }.call(this, h); 463 new e.MultiTooltip({ 464 x: d.x, 465 y: d.y, 466 xPadding: this.options.tooltipXPadding, 467 yPadding: this.options.tooltipYPadding, 468 xOffset: this.options.tooltipXOffset, 469 fillColor: this.options.tooltipFillColor, 470 textColor: this.options.tooltipFontColor, 471 fontFamily: this.options.tooltipFontFamily, 472 fontStyle: this.options.tooltipFontStyle, 473 fontSize: this.options.tooltipFontSize, 474 titleTextColor: this.options.tooltipTitleFontColor, 475 titleFontFamily: this.options.tooltipTitleFontFamily, 476 titleFontStyle: this.options.tooltipTitleFontStyle, 477 titleFontSize: this.options.tooltipTitleFontSize, 478 cornerRadius: this.options.tooltipCornerRadius, 479 labels: c, 480 legendColors: u,
481 legendColorBackground: this.options.multiTooltipKeyBackground, 482 title: t[0].label, 483 chart: this.chart, 484 ctx: this.chart.ctx 485 }).draw() 486 } else n(t, function(t) { 487 var i = t.tooltipPosition(); 488 new e.Tooltip({ 489 x: Math.round(i.x), 490 y: Math.round(i.y), 491 xPadding: this.options.tooltipXPadding, 492 yPadding: this.options.tooltipYPadding, 493 fillColor: this.options.tooltipFillColor, 494 textColor: this.options.tooltipFontColor, 495 fontFamily: this.options.tooltipFontFamily, 496 fontStyle: this.options.tooltipFontStyle, 497 fontSize: this.options.tooltipFontSize, 498 caretHeight: this.options.tooltipCaretSize, 499 cornerRadius: this.options.tooltipCornerRadius, 500 text: C(this.options.tooltipTemplate, t), 501 chart: this.chart 502 }).draw() 503 }, this); 504 return this 505 } 506 }, 507 toBase64Image: function() { 508 return this.chart.canvas.toDataURL.apply(this.chart.canvas, arguments) 509 } 510 }), e.Type.extend = function(t) { 511 var i = this, 512 s = function() { 513 return i.apply(this, arguments) 514 }; 515 if (s.prototype = o(i.prototype), a(s.prototype, t), s.extend = e.Type.extend, t.name || i.prototype.name) { 516 var n = t.name || i.prototype.name, 517 l = e.defaults[i.prototype.name] ? o(e.defaults[i.prototype.name]) : {}; 518 e.defaults[n] = a(l, t.defaults), e.types[n] = s, e.prototype[n] = function(t, i) { 519 var o = h(e.defaults.global, e.defaults[n], i || {}); 520 return new s(t, o, this) 521 } 522 } else d("Name not provided for this chart, so it hasn't been registered"); 523 return i 524 }, e.Element = function(t) { 525 a(this, t), this.initialize.apply(this, arguments), this.save() 526 }, a(e.Element.prototype, { 527 initialize: function() {}, 528 restore: function(t) { 529 return t ? n(t, function(t) { 530 this[t] = this._saved[t] 531 }, this) : a(this, this._saved), this 532 }, 533 save: function() { 534 return this._saved = o(this), delete this._saved._saved, this 535 }, 536 update: function(t) { 537 return n(t, function(t, i) { 538 this._saved[i] = this[i], this[i] = t 539 }, this), this 540 }, 541 transition: function(t, i) { 542 return n(t, function(t, e) { 543 this[e] = (t - this._saved[e]) * i + this._saved[e] 544 }, this), this 545 }, 546 tooltipPosition: function() { 547 return { 548 x: this.x, 549 y: this.y 550 } 551 }, 552 hasValue: function() { 553 return f(this.value) 554 } 555 }), e.Element.extend = r, e.Point = e.Element.extend({ 556 display: !0, 557 inRange: function(t, i) { 558 var e = this.hitDetectionRadius + this.radius; 559 return Math.pow(t - this.x, 2) + Math.pow(i - this.y, 2) < Math.pow(e, 2) 560 }, 561 draw: function() { 562 if (this.display) { 563 var t = this.ctx; 564 t.beginPath(), t.arc(this.x, this.y, this.radius, 0, 2 * Math.PI), t.closePath(), t.strokeStyle = this.strokeColor, t.lineWidth = this.strokeWidth, t.fillStyle = this.fillColor, t.fill(), t.stroke() 565 } 566 } 567 }), e.Arc = e.Element.extend({ 568 inRange: function(t, i) { 569 var e = s.getAngleFromPoint(this, { 570 x: t, 571 y: i 572 }), 573 n = e.angle >= this.startAngle && e.angle <= this.endAngle, 574 o = e.distance >= this.innerRadius && e.distance <= this.outerRadius; 575 return n && o 576 }, 577 tooltipPosition: function() { 578 var t = this.startAngle + (this.endAngle - this.startAngle) / 2, 579 i = (this.outerRadius - this.innerRadius) / 2 + this.innerRadius; 580 return {
581 x: this.x + Math.cos(t) * i, 582 y: this.y + Math.sin(t) * i 583 } 584 }, 585 draw: function(t) { 586 var i = this.ctx; 587 i.beginPath(), i.arc(this.x, this.y, this.outerRadius, this.startAngle, this.endAngle), i.arc(this.x, this.y, this.innerRadius, this.endAngle, this.startAngle, !0), i.closePath(), i.strokeStyle = this.strokeColor, i.lineWidth = this.strokeWidth, i.fillStyle = this.fillColor, i.fill(), i.lineJoin = "bevel", this.showStroke && i.stroke() 588 } 589 }), e.Rectangle = e.Element.extend({ 590 draw: function() { 591 var t = this.ctx, 592 i = this.width / 2, 593 e = this.x - i, 594 s = this.x + i, 595 n = this.base - (this.base - this.y), 596 o = this.strokeWidth / 2; 597 this.showStroke && (e += o, s -= o, n += o), t.beginPath(), t.fillStyle = this.fillColor, t.strokeStyle = this.strokeColor, t.lineWidth = this.strokeWidth, t.moveTo(e, this.base), t.lineTo(e, n), t.lineTo(s, n), t.lineTo(s, this.base), t.fill(), this.showStroke && t.stroke() 598 }, 599 height: function() { 600 return this.base - this.y 601 }, 602 inRange: function(t, i) { 603 return t >= this.x - this.width / 2 && t <= this.x + this.width / 2 && i >= this.y && i <= this.base 604 } 605 }), e.Tooltip = e.Element.extend({ 606 draw: function() { 607 var t = this.chart.ctx; 608 t.font = M(this.fontSize, this.fontStyle, this.fontFamily), this.xAlign = "center", this.yAlign = "above"; 609 var i = 2, 610 e = t.measureText(this.text).width + 2 * this.xPadding, 611 s = this.fontSize + 2 * this.yPadding, 612 n = s + this.caretHeight + i; 613 this.x + e / 2 > this.chart.width ? this.xAlign = "left" : this.x - e / 2 < 0 && (this.xAlign = "right"), this.y - n < 0 && (this.yAlign = "below"); 614 var o = this.x - e / 2, 615 a = this.y - n; 616 switch (t.fillStyle = this.fillColor, this.yAlign) { 617 case "above": 618 t.beginPath(), t.moveTo(this.x, this.y - i), t.lineTo(this.x + this.caretHeight, this.y - (i + this.caretHeight)), t.lineTo(this.x - this.caretHeight, this.y - (i + this.caretHeight)), t.closePath(), t.fill(); 619 break; 620 case "below": 621 a = this.y + i + this.caretHeight, t.beginPath(), t.moveTo(this.x, this.y + i), t.lineTo(this.x + this.caretHeight, this.y + i + this.caretHeight), t.lineTo(this.x - this.caretHeight, this.y + i + this.caretHeight), t.closePath(), t.fill() 622 } 623 switch (this.xAlign) { 624 case "left": 625 o = this.x - e + (this.cornerRadius + this.caretHeight); 626 break; 627 case "right": 628 o = this.x - (this.cornerRadius + this.caretHeight) 629 } 630 z(t, o, a, e, s, this.cornerRadius), t.fill(), t.fillStyle = this.textColor, t.textAlign = "center", t.textBaseline = "middle", t.fillText(this.text, o + e / 2, a + s / 2) 631 } 632 }), e.MultiTooltip = e.Element.extend({ 633 initialize: function() { 634 this.font = M(this.fontSize, this.fontStyle, this.fontFamily), this.titleFont = M(this.titleFontSize, this.titleFontStyle, this.titleFontFamily), this.height = this.labels.length * this.fontSize + (this.labels.length - 1) * (this.fontSize / 2) + 2 * this.yPadding + 1.5 * this.titleFontSize, this.ctx.font = this.titleFont; 635 var t = this.ctx.measureText(this.title).width, 636 i = W(this.ctx, this.font, this.labels) + this.fontSize + 3, 637 e = g([i, t]); 638 this.width = e + 2 * this.xPadding; 639 var s = this.height / 2; 640 this.y - s < 0 ? this.y = s : this.y + s > this.chart.height && (this.y = this.chart.height - s), this.x > this.chart.width / 2 ? this.x -= this.xOffset + this.width : this.x += this.xOffset 641 }, 642 getLineHeight: function(t) { 643 var i = this.y - this.height / 2 + this.yPadding, 644 e = t - 1; 645 return 0 === t ? i + this.titleFontSize / 2 : i + (1.5 * this.fontSize * e + this.fontSize / 2) + 1.5 * this.titleFontSize 646 }, 647 draw: function() { 648 z(this.ctx, this.x, this.y - this.height / 2, this.width, this.height, this.cornerRadius); 649 var t = this.ctx; 650 t.fillStyle = this.fillColor, t.fill(), t.closePath(), t.textAlign = "left", t.textBaseline = "middle", t.fillStyle = this.titleTextColor, t.font = this.titleFont, t.fillText(this.title, this.x + this.xPadding, this.getLineHeight(0)), t.font = this.font, s.each(this.labels, function(i, e) { 651 t.fillStyle = this.textColor, t.fillText(i, this.x + this.xPadding + this.fontSize + 3, this.getLineHeight(e + 1)), t.fillStyle = this.legendColorBackgroun
651d, t.fillRect(this.x + this.xPadding, this.getLineHeight(e + 1) - this.fontSize / 2, this.fontSize, this.fontSize), t.fillStyle = this.legendColors[e].fill, t.fillRect(this.x + this.xPadding, this.getLineHeight(e + 1) - this.fontSize / 2, this.fontSize, this.fontSize) 652 }, this) 653 } 654 }), e.Scale = e.Element.extend({ 655 initialize: function() { 656 this.fit() 657 }, 658 buildYLabels: function() { 659 this.yLabels = []; 660 for (var t = v(this.stepValue), i = 0; i <= this.steps; i++) this.yLabels.push(C(this.templateString, { 661 value: (this.min + i * this.stepValue).toFixed(t) 662 })); 663 this.yLabelWidth = this.display && this.showLabels ? W(this.ctx, this.font, this.yLabels) : 0 664 }, 665 addXLabel: function(t) { 666 this.xLabels.push(t), this.valuesCount++, this.fit() 667 }, 668 removeXLabel: function() { 669 this.xLabels.shift(), this.valuesCount--, this.fit() 670 }, 671 fit: function() { 672 this.startPoint = this.display ? this.fontSize : 0, this.endPoint = this.display ? this.height - 1.5 * this.fontSize - 5 : this.height, this.startPoint += this.padding, this.endPoint -= this.padding; 673 var t, i = this.endPoint - this.startPoint; 674 for (this.calculateYRange(i), this.buildYLabels(), this.calculateXLabelRotation(); i > this.endPoint - this.startPoint;) i = this.endPoint - this.startPoint, t = this.yLabelWidth, this.calculateYRange(i), this.buildYLabels(), t < this.yLabelWidth && this.calculateXLabelRotation() 675 }, 676 calculateXLabelRotation: function() { 677 this.ctx.font = this.font; 678 var t, i, e = this.ctx.measureText(this.xLabels[0]).width, 679 s = this.ctx.measureText(this.xLabels[this.xLabels.length - 1]).width; 680 if (this.xScalePaddingRight = s / 2 + 3, this.xScalePaddingLeft = e / 2 > this.yLabelWidth + 10 ? e / 2 : this.yLabelWidth + 10, this.xLabelRotation = 0, this.display) { 681 var n, o = W(this.ctx, this.font, this.xLabels); 682 this.xLabelWidth = o; 683 for (var a = Math.floor(this.calculateX(1) - this.calculateX(0)) - 6; this.xLabelWidth > a && 0 === this.xLabelRotation || this.xLabelWidth > a && this.xLabelRotation <= 90 && this.xLabelRotation > 0;) n = Math.cos(x(this.xLabelRotation)), t = n * e, i = n * s, t + this.fontSize / 2 > this.yLabelWidth + 8 && (this.xScalePaddingLeft = t + this.fontSize / 2), this.xScalePaddingRight = this.fontSize / 2, this.xLabelRotation++, this.xLabelWidth = n * o; 684 this.xLabelRotation > 0 && (this.endPoint -= Math.sin(x(this.xLabelRotation)) * o + 3) 685 } else this.xLabelWidth = 0, this.xScalePaddingRight = this.padding, this.xScalePaddingLeft = this.padding 686 }, 687 calculateYRange: c, 688 drawingArea: function() { 689 return this.startPoint - this.endPoint 690 }, 691 calculateY: function(t) { 692 var i = this.drawingArea() / (this.min - this.max); 693 return this.endPoint - i * (t - this.min) 694 }, 695 calculateX: function(t) { 696 var i = (this.xLabelRotation > 0, this.width - (this.xScalePaddingLeft + this.xScalePaddingRight)), 697 e = i / (this.valuesCount - (this.offsetGridLines ? 0 : 1)), 698 s = e * t + this.xScalePaddingLeft; 699 return this.offsetGridLines && (s += e / 2), Math.round(s) 700 }, 701 update: function(t) { 702 s.extend(this, t), this.fit() 703 }, 704 draw: function() { 705 var t = this.ctx, 706 i = (this.endPoint - this.startPoint) / this.steps, 707 e = Math.round(this.xScalePaddingLeft); 708 this.display && (t.fillStyle = this.textColor, t.font = this.font, n(this.yLabels, function(n, o) { 709 var a = this.endPoint - i * o, 710 h = Math.round(a); 711 t.textAlign = "right", t.textBaseline = "middle", this.showLabels && t.fillText(n, e - 10, a), t.beginPath(), o > 0 ? (t.lineWidth = this.gridLineWidth, t.strokeStyle = this.gridLineColor) : (t.lineWidth = this.lineWidth, t.strokeStyle = this.lineColor), h += s.aliasPixel(t.lineWidth), t.moveTo(e, h), t.lineTo(this.width, h), t.stroke(), t.closePath(), t.lineWidth = this.lineWidth, t.strokeStyle = this.lineColor, t.beginPath(), t.moveTo(e - 5, h), t.lineTo(e, h), t.stroke(), t.closePath() 712 }, this), n(this.xLabels, function(i, e) { 713 var s = this.calculateX(e) + S(this.lineWidth), 714 n = this.calculateX(e - (this.offsetGridLines ? .5 : 0)) + S(this.lineWidth), 715 o = this.xLabelRotation > 0;
716 t.beginPath(), e > 0 ? (t.lineWidth = this.gridLineWidth, t.strokeStyle = this.gridLineColor) : (t.lineWidth = this.lineWidth, t.strokeStyle = this.lineColor), t.moveTo(n, this.endPoint), t.lineTo(n, this.startPoint - 3), t.stroke(), t.closePath(), t.lineWidth = this.lineWidth, t.strokeStyle = this.lineColor, t.beginPath(), t.moveTo(n, this.endPoint), t.lineTo(n, this.endPoint + 5), t.stroke(), t.closePath(), t.save(), t.translate(s, o ? this.endPoint + 12 : this.endPoint + 8), t.rotate(-1 * x(this.xLabelRotation)), t.font = this.font, t.textAlign = o ? "right" : "center", t.textBaseline = o ? "middle" : "top", t.fillText(i, 0, 0), t.restore() 717 }, this)) 718 } 719 }), e.RadialScale = e.Element.extend({ 720 initialize: function() { 721 this.size = m([this.height, this.width]), this.drawingArea = this.display ? this.size / 2 - (this.fontSize / 2 + this.backdropPaddingY) : this.size / 2 722 }, 723 calculateCenterOffset: function(t) { 724 var i = this.drawingArea / (this.max - this.min); 725 return (t - this.min) * i 726 }, 727 update: function() { 728 this.lineArc ? this.drawingArea = this.display ? this.size / 2 - (this.fontSize / 2 + this.backdropPaddingY) : this.size / 2 : this.setScaleSize(), this.buildYLabels() 729 }, 730 buildYLabels: function() { 731 this.yLabels = []; 732 for (var t = v(this.stepValue), i = 0; i <= this.steps; i++) this.yLabels.push(C(this.templateString, { 733 value: (this.min + i * this.stepValue).toFixed(t) 734 })) 735 }, 736 getCircumference: function() { 737 return 2 * Math.PI / this.valuesCount 738 }, 739 setScaleSize: function() { 740 var t, i, e, s, n, o, a, h, l, r, c, u, d = m([this.height / 2 - this.pointLabelFontSize - 5, this.width / 2]), 741 p = this.width, 742 g = 0; 743 for (this.ctx.font = M(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily), i = 0; i < this.valuesCount; i++) t = this.getPointPosition(i, d), e = this.ctx.measureText(C(this.templateString, { 744 value: this.labels[i] 745 })).width + 5, 0 === i || i === this.valuesCount / 2 ? (s = e / 2, t.x + s > p && (p = t.x + s, n = i), t.x - s < g && (g = t.x - s, a = i)) : i < this.valuesCount / 2 ? t.x + e > p && (p = t.x + e, n = i) : i > this.valuesCount / 2 && t.x - e < g && (g = t.x - e, a = i); 746 l = g, r = Math.ceil(p - this.width), o = this.getIndexAngle(n), h = this.getIndexAngle(a), c = r / Math.sin(o + Math.PI / 2), u = l / Math.sin(h + Math.PI / 2), c = f(c) ? c : 0, u = f(u) ? u : 0, this.drawingArea = d - (u + c) / 2, this.setCenterPoint(u, c) 747 }, 748 setCenterPoint: function(t, i) { 749 var e = this.width - i - this.drawingArea, 750 s = t + this.drawingArea; 751 this.xCenter = (s + e) / 2, this.yCenter = this.height / 2 752 }, 753 getIndexAngle: function(t) { 754 var i = 2 * Math.PI / this.valuesCount; 755 return t * i - Math.PI / 2 756 }, 757 getPointPosition: function(t, i) { 758 var e = this.getIndexAngle(t); 759 return { 760 x: Math.cos(e) * i + this.xCenter, 761 y: Math.sin(e) * i + this.yCenter 762 } 763 }, 764 draw: function() { 765 if (this.display) { 766 var t = this.ctx; 767 if (n(this.yLabels, function(i, e) { 768 if (e > 0) { 769 var s, n = e * (this.drawingArea / this.steps), 770 o = this.yCenter - n; 771 if (this.lineWidth > 0) 772 if (t.strokeStyle = this.lineColor, t.lineWidth = this.lineWidth, this.lineArc) t.beginPath(), t.arc(this.xCenter, this.yCenter, n, 0, 2 * Math.PI), t.closePath(), t.stroke(); 773 else { 774 t.beginPath(); 775 for (var a = 0; a < this.valuesCount; a++) s = this.getPointPosition(a, this.calculateCenterOffset(this.min + e * this.stepValue)), 0 === a ? t.moveTo(s.x, s.y) : t.lineTo(s.x, s.y); 776 t.closePath(), t.stroke() 777 } 778 if (this.showLabels) { 779 if (t.font = M(this.fontSize, this.fontStyle, this.fontFamily), this.showLabelBackdrop) { 780 var h = t.measureText(i).width; 781 t.fillStyle = this.backdropColor, t.fillRect(this.xCenter - h / 2 - this.backdropPaddingX, o - this.fontSize / 2 - this.backdropPaddingY, h + 2 * this.backdropPaddingX, this.fontSize + 2 * this.backdropPaddingY) 782 } 783 t.textAlign = "center", t.textBaseline = "middle", t.fillStyle = this.fontColor, t.fillText(i, this.xCenter, o) 784 } 785 } 786 }, this), !this.lineArc) { 787 t.lineWidth = this.angleLineWidth, t.strokeStyle = this.angleLineColor; 788 for (var i = this.valuesCount - 1; i >= 0; i--) { 789 if (this.angleLineWidth > 0) { 790 var e = this.getPointPosition(i, this.calculateCenterOffset(this.max)); 791 t.beginPath(), t.moveTo(this.xCenter, this.yCenter), t.lineTo(e.x, e.y), t.stroke(), t.closePath() 792 } 793 var s = this.getPointPosition(i, this.calculateCenterOffset(this.max) + 5); 794 t.font = M(this.pointLabelFontSize, this.pointLabelFontStyle, this.pointLabelFontFamily), t.fillStyle = this.pointLabelFontColor; 795 var o = this.labels.length, 796 a = this.labels.length / 2, 797 h = a / 2, 798 l = h > i || i > o - h, 799 r = i === h || i === o - h; 800 t.textAlign = 0 === i ? "center" : i === a ? "center" : a > i ? "left" : "right", t.textBaseline = r ? "middle" : l ? "bottom" : "top", t.fillText(this.labels[i], s.x, s.y) 801 } 802 } 803 } 804 } 805 }), s.addEvent(window, "resize", function() { 806 var t; 807 return function() { 808 clearTimeout(t), t = setTimeout(function() { 809 n(e.instances, function(t) { 810 t.options.responsive && t.resize(t.render, !0) 811 }) 812 }, 50) 813 } 814 }()), p ? define(function() { 815 return e 816 }) : "object" == typeof module && module.exports && (module.exports = e), t.Chart = e, e.noConflict = function() { 817 return t.Chart = i, e 818 } 819}).call(this), 820 function() { 821 "use strict"; 822 var t = this, 823 i = t.Chart, 824 e = i.helpers, 825 s = { 826 scaleBeginAtZero: !0, 827 scaleShowGridLines: !0, 828 scaleGridLineColor: "rgba(0,0,0,.05)", 829 scaleGridLineWidth: 1, 830 barShowStroke: !0, 831 barStrokeWidth: 2, 832 barValueSpacing: 5, 833 barDatasetSpacing: 1, 834 legendTemplate: '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>' 835 }; 836 i.Type.extend({ 837 name: "Bar", 838 defaults: s, 839 initialize: function(t) { 840 var s = this.options; 841 this.ScaleClass = i.Scale.extend({ 842 offsetGridLines: !0, 843 calculateBarX: function(t, i, e) { 844 var n = this.calculateBaseWidth(), 845 o = this.calculateX(e) - n / 2, 846 a = this.calculateBarWidth(t); 847 return o + a * i + i * s.barDatasetSpacing + a / 2 848 }, 849 calculateBaseWidth: function() { 850 return this.calculateX(1) - this.calculateX(0) - 2 * s.barValueSpacing 851 }, 852 calculateBarWidth: function(t) { 853 var i = this.calculateBaseWidth() - (t - 1) * s.barDatasetSpacing; 854 return i / t 855 } 856 }), this.datasets = [], this.options.showTooltips && e.bindEvents(this, ""/*this.options.tooltipEvents*/, function(t) { 857 var i = "mouseout" !== t.type ? this.getBarsAtEvent(t) : []; 858 this.eachBars(function(t) { 859 t.restore(["fillColor", "strokeColor"]) 860 }), e.each(i, function(t) { 861 t.fillColor = t.highlightFill, t.strokeColor = t.highlightStroke 862 }), this.showTooltip(i) 863 }), this.BarClass = i.Rectangle.extend({ 864 strokeWidth: this.options.barStrokeWidth, 865 showStroke: this.options.barShowStroke, 866 ctx: this.chart.ctx 867 }), e.each(t.datasets, function(i) { 868 var s = { 869 label: i.label || null, 870 fillColor: i.fillColor, 871 strokeColor: i.strokeColor, 872 bars: [] 873 }; 874 this.datasets.push(s), e.each(i.data, function(e, n) { 875 s.bars.push(new this.BarClass({ 876 value: e, 877 label: t.labels[n], 878 datasetLabel: i.label, 879 strokeColor: i.strokeColor, 880 fillColor: i.fillColor, 881 highlightFill: i.highlightFill || i.fillColor, 882 highlightStroke: i.highlightStroke || i.strokeColor 883 })) 884 }, this) 885 }, this), this.buildScale(t.labels), this.BarClass.prototype.base = this.scale.endPoint, this.eachBars(function(t, i, s) { 886 e.extend(t, { 887 width: this.scale.calculateBarWidth(this.datasets.length), 888 x: this.scale.calculateBarX(this.datasets.length, s, i), 889 y: this.scale.endPoint 890 }), t.save() 891 }, this), this.render() 892 }, 893 update: function() {
894 this.scale.update(), e.each(this.activeElements, function(t) { 895 t.restore(["fillColor", "strokeColor"]) 896 }), this.eachBars(function(t) { 897 t.save() 898 }), this.render() 899 }, 900 eachBars: function(t) { 901 e.each(this.datasets, function(i, s) { 902 e.each(i.bars, t, this, s) 903 }, this) 904 }, 905 getBarsAtEvent: function(t) { 906 for (var i, s = [], n = e.getRelativePosition(t), o = function(t) { 907 s.push(t.bars[i]) 908 }, a = 0; a < this.datasets.length; a++) 909 for (i = 0; i < this.datasets[a].bars.length; i++) 910 if (this.datasets[a].bars[i].inRange(n.x, n.y)) return e.each(this.datasets, o), s; 911 return s 912 }, 913 buildScale: function(t) { 914 var i = this, 915 s = function() { 916 var t = []; 917 return i.eachBars(function(i) { 918 t.push(i.value) 919 }), t 920 }, 921 n = { 922 templateString: this.options.scaleLabel, 923 height: this.chart.height, 924 width: this.chart.width, 925 ctx: this.chart.ctx, 926 textColor: this.options.scaleFontColor, 927 fontSize: this.options.scaleFontSize, 928 fontStyle: this.options.scaleFontStyle, 929 fontFamily: this.options.scaleFontFamily, 930 valuesCount: t.length, 931 beginAtZero: this.options.scaleBeginAtZero, 932 integersOnly: this.options.scaleIntegersOnly, 933 calculateYRange: function(t) { 934 var i = e.calculateScaleRange(s(), t, this.fontSize, this.beginAtZero, this.integersOnly); 935 e.extend(this, i) 936 }, 937 xLabels: t, 938 font: e.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), 939 lineWidth: this.options.scaleLineWidth, 940 lineColor: this.options.scaleLineColor, 941 gridLineWidth: this.options.scaleShowGridLines ? this.options.scaleGridLineWidth : 0, 942 gridLineColor: this.options.scaleShowGridLines ? this.options.scaleGridLineColor : "rgba(0,0,0,0)", 943 padding: this.options.showScale ? 0 : this.options.barShowStroke ? this.options.barStrokeWidth : 0, 944 showLabels: this.options.scaleShowLabels, 945 display: this.options.showScale 946 }; 947 this.options.scaleOverride && e.extend(n, { 948 calculateYRange: e.noop, 949 steps: this.options.scaleSteps, 950 stepValue: this.options.scaleStepWidth, 951 min: this.options.scaleStartValue, 952 max: this.options.scaleStartValue + this.options.scaleSteps * this.options.scaleStepWidth 953 }), this.scale = new this.ScaleClass(n) 954 }, 955 addData: function(t, i) { 956 e.each(t, function(t, e) { 957 this.datasets[e].bars.push(new this.BarClass({ 958 value: t, 959 label: i, 960 x: this.scale.calculateBarX(this.datasets.length, e, this.scale.valuesCount + 1), 961 y: this.scale.endPoint, 962 width: this.scale.calculateBarWidth(this.datasets.length), 963 base: this.scale.endPoint, 964 strokeColor: this.datasets[e].strokeColor, 965 fillColor: this.datasets[e].fillColor 966 })) 967 }, this), this.scale.addXLabel(i), this.update() 968 }, 969 removeData: function() { 970 this.scale.removeXLabel(), e.each(this.datasets, function(t) { 971 t.bars.shift() 972 }, this), this.update() 973 }, 974 reflow: function() { 975 e.extend(this.BarClass.prototype, { 976 y: this.scale.endPoint, 977 base: this.scale.endPoint 978 }); 979 var t = e.extend({ 980 height: this.chart.height, 981 width: this.chart.width 982 }); 983 this.scale.update(t) 984 }, 985 draw: function(t) { 986 var i = t || 1; 987 this.clear(); 988 this.chart.ctx; 989 this.scale.draw(i), e.each(this.datasets, function(t, s) { 990 e.each(t.bars, function(t, e) { 991 t.hasValue() && (t.base = this.scale.endPoint, t.transition({ 992 x: this.scale.calculateBarX(this.datasets.length, s, e), 993 y: this.scale.calculateY(t.value), 994 width: this.scale.calculateBarWidth(this.datasets.length) 995 }, i).draw()) 996 }, this) 997 }, this) 998 } 999 }) 1000 }.call(this), 1001 function() { 1002 "use strict"; 1003 var t = this, 1004 i = t.Chart, 1005 e = i.helpers, 1006 s = { 1007 segmentShowStroke: !0, 1008 segmentStrokeColor: "#fff", 1009 segmentStrokeWidth: 2, 1010 percentageInnerCutout: 50, 1011 animationSteps: 100, 1012 animationEasing: "easeOutBounce", 1013 animateRotate: !0, 1014 animateScale: !1, 1015 legendTemplate: '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>' 1016 }; 1017 i.Type.extend({ 1018 name: "Doughnut", 1019 defaults: s, 1020 initialize: function(t) { 1021 this.segments = [], this.outerRadius = (e.min([this.chart.width, this.chart.height]) - this.options.segmentStrokeWidth / 2) / 2, this.SegmentArc = i.Arc.extend({ 1022 ctx: this.chart.ctx, 1023 x: this.chart.width / 2, 1024 y: this.chart.height / 2 1025 }), this.options.showTooltips && e.bindEvents(this, ""/*this.options.tooltipEvents*/, function(t) {
1026 var i = "mouseout" !== t.type ? this.getSegmentsAtEvent(t) : []; 1027 e.each(this.segments, function(t) { 1028 t.restore(["fillColor"]) 1029 }), e.each(i, function(t) { 1030 t.fillColor = t.highlightColor 1031 }), this.showTooltip(i) 1032 }), this.calculateTotal(t), e.each(t, function(t, i) { 1033 this.addData(t, i, !0) 1034 }, this), this.render() 1035 }, 1036 getSegmentsAtEvent: function(t) { 1037 var i = [], 1038 s = e.getRelativePosition(t); 1039 return e.each(this.segments, function(t) { 1040 t.inRange(s.x, s.y) && i.push(t) 1041 }, this), i 1042 }, 1043 addData: function(t, i, e) { 1044 var s = i || this.segments.length; 1045 this.segments.splice(s, 0, new this.SegmentArc({ 1046 value: t.value, 1047 outerRadius: this.options.animateScale ? 0 : this.outerRadius, 1048 innerRadius: this.options.animateScale ? 0 : this.outerRadius / 100 * this.options.percentageInnerCutout, 1049 fillColor: t.color, 1050 highlightColor: t.highlight || t.color, 1051 showStroke: this.options.segmentShowStroke, 1052 strokeWidth: this.options.segmentStrokeWidth, 1053 strokeColor: this.options.segmentStrokeColor, 1054 startAngle: 1.5 * Math.PI, 1055 circumference: this.options.animateRotate ? 0 : this.calculateCircumference(t.value), 1056 label: t.label 1057 })), e || (this.reflow(), this.update()) 1058 }, 1059 calculateCircumference: function(t) { 1060 return 2 * Math.PI * (t / this.total) 1061 }, 1062 calculateTotal: function(t) { 1063 this.total = 0, e.each(t, function(t) { 1064 this.total += t.value 1065 }, this) 1066 }, 1067 update: function() { 1068 this.calculateTotal(this.segments), e.each(this.activeElements, function(t) { 1069 t.restore(["fillColor"]) 1070 }), e.each(this.segments, function(t) { 1071 t.save() 1072 }), this.render() 1073 }, 1074 removeData: function(t) { 1075 var i = e.isNumber(t) ? t : this.segments.length - 1; 1076 this.segments.splice(i, 1), this.reflow(), this.update() 1077 }, 1078 reflow: function() { 1079 e.extend(this.SegmentArc.prototype, { 1080 x: this.chart.width / 2, 1081 y: this.chart.height / 2 1082 }), this.outerRadius = (e.min([this.chart.width, this.chart.height]) - this.options.segmentStrokeWidth / 2) / 2, e.each(this.segments, function(t) { 1083 t.update({ 1084 outerRadius: this.outerRadius, 1085 innerRadius: this.outerRadius / 100 * this.options.percentageInnerCutout 1086 }) 1087 }, this) 1088 }, 1089 draw: function(t) { 1090 var i = t ? t : 1; 1091 this.clear(), e.each(this.segments, function(t, e) { 1092 t.transition({ 1093 circumference: this.calculateCircumference(t.value), 1094 outerRadius: this.outerRadius, 1095 innerRadius: this.outerRadius / 100 * this.options.percentageInnerCutout 1096 }, i), t.endAngle = t.startAngle + t.circumference, t.draw(), 0 === e && (t.startAngle = 1.5 * Math.PI), e < this.segments.length - 1 && (this.segments[e + 1].startAngle = t.endAngle) 1097 }, this) 1098 } 1099 }), i.types.Doughnut.extend({ 1100 name: "Pie", 1101 defaults: e.merge(s, { 1102 percentageInnerCutout: 0 1103 }) 1104 }) 1105 }.call(this), 1106 function() { //begin Curve 1107 "use strict"; 1108 var t = this, 1109 i = t.Chart, 1110 e = i.helpers, 1111 s = { 1112 scaleShowGridLines: !0, 1113 scaleGridLineColor: "rgba(231,232,225,1)", 1114 scaleGridLineWidth: 1, 1115 bezierCurve: !0, 1116 bezierCurveTension: .4, 1117 pointDot: !0, 1118 pointDotRadius: 4, 1119 pointDotStrokeWidth: 1, 1120 pointHitDetectionRadius: 20, 1121 datasetStroke: !0, 1122 datasetStrokeWidth: 2, 1123 datasetFill: !0, 1124 legendTemplate: '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>; "></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>' 1125 }; 1126 i.Type.extend({ 1127 name: "Curve", 1128 defaults: s, 1129 initialize: function(t) { 1130 this.PointClass = i.Point.extend({ 1131 strokeWidth: this.options.pointDotStrokeWidth, 1132 radius: this.options.pointDotRadius, 1133 display: this.options.pointDot, 1134 hitDetectionRadius: this.options.pointHitDetectionRadius, 1135 ctx: this.chart.ctx, 1136 inRange: function(t) { 1137 return Math.pow(t - this.x, 2) < Math.pow(this.radius + this.hitDetectionRadius, 2) 1138 } 1139 }), this.datasets = [], this.options.showTooltips && e.bindEvents(this, this.options.tooltipEvents, function(t) { 1140 var i = "mouseout" !== t.type ? this.getPointsAtEvent(t) : []; 1141 this.eachPoints(function(t) { 1142 t.restore(["fillColor", "strokeColor"]) 1143 }), e.each(i, function(t) { 1144 t.fillColor = t.highlightFill, t.strokeColor = t.highlightStroke 1145 }), this.showTooltip(i) 1146 }), e.each(t.datasets, function(i) { 1147 var s = { 1148 label: i.label || null, 1149 fillColor: i.fillColor, 1150 strokeColor: i.strokeColor, 1151 pointColor: i.pointColor, 1152 pointStrokeColor: i.pointStrokeColor, 1153 points: [] 1154 }; 1155 this.datasets.push(s), e.each(i.data, function(e, n) { 1156 s.points.push(new this.PointClass({ 1157 value: e, 1158 label: t.labels[n], 1159 datasetLabel: i.label, 1160 strokeColor: "#fff", //**** 1161 fillColor: i.pointColor, 1162 highlightFill: i.pointHighlightFill || i.pointColor, 1163 highlightStroke: i.pointHighlightStroke || i.pointStrokeColor 1164 })) 1165 }, this), this.buildScale(t.labels), this.eachPoints(function(t, i) { 1166 e.extend(t, { 1167 x: this.scale.calculateX(i), 1168 y: this.scale.endPoint 1169 }), t.save() 1170 }, this) 1171 }, this), this.render() 1172 }, 1173 update: function() {
1174 this.scale.update(), e.each(this.activeElements, function(t) { 1175 t.restore(["fillColor", "strokeColor"]) 1176 }), this.eachPoints(function(t) { 1177 t.save() 1178 }), this.render() 1179 }, 1180 eachPoints: function(t) { 1181 e.each(this.datasets, function(i) { 1182 e.each(i.points, t, this) 1183 }, this) 1184 }, 1185 getPointsAtEvent: function(t) { 1186 var i = [], 1187 s = e.getRelativePosition(t); 1188 return e.each(this.datasets, function(t) { 1189 e.each(t.points, function(t) { 1190 t.inRange(s.x, s.y) && i.push(t) 1191 }) 1192 }, this), i 1193 }, 1194 buildScale: function(t) { 1195 var s = this, 1196 n = function() { 1197 var t = []; 1198 return s.eachPoints(function(i) { 1199 t.push(i.value) 1200 }), t 1201 }, 1202 o = { 1203 templateString: this.options.scaleLabel, 1204 height: this.chart.height, 1205 width: this.chart.width, 1206 ctx: this.chart.ctx, 1207 textColor: this.options.scaleFontColor, 1208 fontSize: this.options.scaleFontSize, 1209 fontStyle: this.options.scaleFontStyle, 1210 fontFamily: this.options.scaleFontFamily, 1211 valuesCount: t.length, 1212 beginAtZero: this.options.scaleBeginAtZero, 1213 integersOnly: this.options.scaleIntegersOnly, 1214 calculateYRange: function(t) { 1215 var i = e.calculateScaleRange(n(), t, this.fontSize, this.beginAtZero, this.integersOnly); 1216 e.extend(this, i) 1217 }, 1218 xLabels: t, 1219 font: e.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), 1220 lineWidth: this.options.scaleLineWidth, 1221 lineColor: this.options.scaleLineColor, 1222 gridLineWidth: this.options.scaleShowGridLines ? this.options.scaleGridLineWidth : 0, 1223 gridLineColor: this.options.scaleShowGridLines ? this.options.scaleGridLineColor : "rgba(0,0,0,0)", 1224 padding: this.options.showScale ? 0 : this.options.pointDotRadius + this.options.pointDotStrokeWidth, 1225 showLabels: this.options.scaleShowLabels, 1226 display: this.options.showScale 1227 }; 1228 this.options.scaleOverride && e.extend(o, { 1229 calculateYRange: e.noop, 1230 steps: this.options.scaleSteps, 1231 stepValue: this.options.scaleStepWidth, 1232 min: this.options.scaleStartValue, 1233 max: this.options.scaleStartValue + this.options.scaleSteps * this.options.scaleStepWidth 1234 }), this.scale = new i.Scale(o) 1235 }, 1236 addData: function(t, i) { 1237 e.each(t, function(t, e) { 1238 this.datasets[e].points.push(new this.PointClass({ 1239 value: t, 1240 label: i, 1241 x: this.scale.calculateX(this.scale.valuesCount + 1), 1242 y: this.scale.endPoint, 1243 strokeColor: this.datasets[e].pointStrokeColor, 1244 fillColor: this.datasets[e].pointColor 1245 })) 1246 }, this), this.scale.addXLabel(i), this.update() 1247 }, 1248 removeData: function() { 1249 this.scale.removeXLabel(), e.each(this.datasets, function(t) { 1250 t.points.shift() 1251 }, this), this.update() 1252 }, 1253 reflow: function() { 1254 var t = e.extend({ 1255 height: this.chart.height, 1256 width: this.chart.width 1257 }); 1258 this.scale.update(t) 1259 }, 1260 draw: function(t) { 1261 var i = t || 1; 1262 this.clear(); 1263 var s = this.chart.ctx, 1264 n = function(t) { 1265 return null !== t.value 1266 }, 1267 o = function(t, i, s) { 1268 return e.findNextWhere(i, n, s) || t 1269 }, 1270 a = function(t, i, s) { 1271 return e.findPreviousWhere(i, n, s) || t 1272 }; 1273 this.scale.draw(i), e.each(this.datasets, function(t) { 1274 var h = e.where(t.points, n); 1275 e.each(t.points, function(t, e) { 1276 t.hasValue() && t.transition({ 1277 y: this.scale.calculateY(t.value), 1278 x: this.scale.calculateX(e) 1279 }, i) 1280 }, this), this.options.bezierCurve && e.each(h, function(t, i) { 1281 var s = i > 0 && i < h.length - 1 ? this.options.bezierCurveTension : 0; 1282 t.controlPoints = e.splineCurve(a(t, h, i), t, o(t, h, i), s), t.controlPoints.outer.y > this.scale.endPoint ? t.controlPoints.outer.y = this.scale.endPoint : t.controlPoints.outer.y < this.scale.startPoint && (t.controlPoints.outer.y = this.scale.startPoint), t.controlPoints.inner.y > this.scale.endPoint ? t.controlPoints.inner.y = this.scale.endPoint : t.controlPoints.inner.y < this.scale.startPoint && (t.controlPoints.inner.y = this.scale.startPoint) 1283 }, this), s.lineWidth = this.options.datasetStrokeWidth, s.strokeStyle = t.strokeColor, s.beginPath(), e.each(h, function(t, i) { 1284 if (0 === i) s.moveTo(t.x, t.y); 1285 else if (this.options.bezierCurve) { 1286 var e = a(t, h, i); 1287 s.bezierCurveTo(e.controlPoints.outer.x, e.controlPoints.outer.y, t.controlPoints.inner.x, t.controlPoints.inner.y, t.x, t.y) 1288 } else s.lineTo(t.x, t.y) 1289 }, this), s.stroke(), this.options.datasetFill && h.length > 0 && (s.lineTo(h[h.length - 1].x, this.scale.endPoint), s.lineTo(h[0].x, this.scale.endPoint), s.fillStyle = t.fillColor, s.closePath(), s.fill()), e.each(h, function(t) { 1290 t.draw() 1291 }) 1292 }, this) 1293 } 1294 })//ends Curve 1295 }.call(this), 1296 function() { //begin Line 1297 "use strict"; 1298 var t = this, 1299 i = t.Chart, 1300 e = i.helpers, 1301 s = { 1302 scaleShowGridLines: !0, 1303 scaleGridLineColor: "rgba(231,232,225,1)", 1304 scaleGridLineWidth: 1, 1305 bezierCurve: false, 1306 bezierCurveTension: .4, 1307 pointDot: !0, 1308 pointDotRadius: 4, 1309 pointDotStrokeWidth: 1, 1310 pointHitDetectionRadius: 20, 1311 datasetStroke: !0, 1312 datasetStrokeWidth: 2, 1313 datasetFill: !0, 1314 legendTemplate: '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>; "></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>' 1315 }; 1316 i.Type.extend({ 1317 name: "Line", 1318 defaults: s, 1319 initialize: function(t) { 1320 this.PointClass = i.Point.extend({ 1321 strokeWidth: this.options.pointDotStrokeWidth, 1322 radius: this.options.pointDotRadius, 1323 display: this.options.pointDot, 1324 hitDetectionRadius: this.options.pointHitDetectionRadius, 1325 ctx: this.chart.ctx, 1326 inRange: function(t) { 1327 return Math.pow(t - this.x, 2) < Math.pow(this.radius + this.hitDetectionRadius, 2) 1328 } 1329 }), this.datasets = [], this.options.showTooltips && e.bindEvents(this, this.options.tooltipEvents, function(t) { 1330 var i = "mouseout" !== t.type ? this.getPointsAtEvent(t) : []; 1331 this.eachPoints(function(t) { 1332 t.restore(["fillColor", "strokeColor"]) 1333 }), e.each(i, function(t) { 1334 t.fillColor = t.highlightFill, t.strokeColor = t.highlightStroke 1335 }), this.showTooltip(i) 1336 }), e.each(t.datasets, function(i) { 1337 var s = { 1338 label: i.label || null, 1339 fillColor: i.fillColor, 1340 strokeColor: i.strokeColor, 1341 pointColor: i.pointColor, 1342 pointStrokeColor: i.pointStrokeColor, 1343 points: [] 1344 }; 1345 this.datasets.push(s), e.each(i.data, function(e, n) { 1346 s.points.push(new this.PointClass({ 1347 value: e, 1348 label: t.labels[n], 1349 datasetLabel: i.label, 1350 strokeColor: "#fff", //**** 1351 fillColor: i.pointColor, 1352 highlightFill: i.pointHighlightFill || i.pointColor, 1353 highlightStroke: i.pointHighlightStroke || i.pointStrokeColor 1354 })) 1355 }, this), this.buildScale(t.labels), this.eachPoints(function(t, i) { 1356 e.extend(t, { 1357 x: this.scale.calculateX(i), 1358 y: this.scale.endPoint 1359 }), t.save() 1360 }, this) 1361 }, this), this.render() 1362 }, 1363 update: function() {
1364 this.scale.update(), e.each(this.activeElements, function(t) { 1365 t.restore(["fillColor", "strokeColor"]) 1366 }), this.eachPoints(function(t) { 1367 t.save() 1368 }), this.render() 1369 }, 1370 eachPoints: function(t) { 1371 e.each(this.datasets, function(i) { 1372 e.each(i.points, t, this) 1373 }, this) 1374 }, 1375 getPointsAtEvent: function(t) { 1376 var i = [], 1377 s = e.getRelativePosition(t); 1378 return e.each(this.datasets, function(t) { 1379 e.each(t.points, function(t) { 1380 t.inRange(s.x, s.y) && i.push(t) 1381 }) 1382 }, this), i 1383 }, 1384 buildScale: function(t) { 1385 var s = this, 1386 n = function() { 1387 var t = []; 1388 return s.eachPoints(function(i) { 1389 t.push(i.value) 1390 }), t 1391 }, 1392 o = { 1393 templateString: this.options.scaleLabel, 1394 height: this.chart.height, 1395 width: this.chart.width, 1396 ctx: this.chart.ctx, 1397 textColor: this.options.scaleFontColor, 1398 fontSize: this.options.scaleFontSize, 1399 fontStyle: this.options.scaleFontStyle, 1400 fontFamily: this.options.scaleFontFamily, 1401 valuesCount: t.length, 1402 beginAtZero: this.options.scaleBeginAtZero, 1403 integersOnly: this.options.scaleIntegersOnly, 1404 calculateYRange: function(t) { 1405 var i = e.calculateScaleRange(n(), t, this.fontSize, this.beginAtZero, this.integersOnly); 1406 e.extend(this, i) 1407 }, 1408 xLabels: t, 1409 font: e.fontString(this.options.scaleFontSize, this.options.scaleFontStyle, this.options.scaleFontFamily), 1410 lineWidth: this.options.scaleLineWidth, 1411 lineColor: this.options.scaleLineColor, 1412 gridLineWidth: this.options.scaleShowGridLines ? this.options.scaleGridLineWidth : 0, 1413 gridLineColor: this.options.scaleShowGridLines ? this.options.scaleGridLineColor : "rgba(0,0,0,0)", 1414 padding: this.options.showScale ? 0 : this.options.pointDotRadius + this.options.pointDotStrokeWidth, 1415 showLabels: this.options.scaleShowLabels, 1416 display: this.options.showScale 1417 }; 1418 this.options.scaleOverride && e.extend(o, { 1419 calculateYRange: e.noop, 1420 steps: this.options.scaleSteps, 1421 stepValue: this.options.scaleStepWidth, 1422 min: this.options.scaleStartValue, 1423 max: this.options.scaleStartValue + this.options.scaleSteps * this.options.scaleStepWidth 1424 }), this.scale = new i.Scale(o) 1425 }, 1426 addData: function(t, i) { 1427 e.each(t, function(t, e) { 1428 this.datasets[e].points.push(new this.PointClass({ 1429 value: t, 1430 label: i, 1431 x: this.scale.calculateX(this.scale.valuesCount + 1), 1432 y: this.scale.endPoint, 1433 strokeColor: this.datasets[e].pointStrokeColor, 1434 fillColor: this.datasets[e].pointColor 1435 })) 1436 }, this), this.scale.addXLabel(i), this.update() 1437 }, 1438 removeData: function() { 1439 this.scale.removeXLabel(), e.each(this.datasets, function(t) { 1440 t.points.shift() 1441 }, this), this.update() 1442 }, 1443 reflow: function() { 1444 var t = e.extend({ 1445 height: this.chart.height, 1446 width: this.chart.width 1447 }); 1448 this.scale.update(t) 1449 }, 1450 draw: function(t) { 1451 var i = t || 1; 1452 this.clear(); 1453 var s = this.chart.ctx, 1454 n = function(t) { 1455 return null !== t.value 1456 }, 1457 o = function(t, i, s) { 1458 return e.findNextWhere(i, n, s) || t 1459 }, 1460 a = function(t, i, s) { 1461 return e.findPreviousWhere(i, n, s) || t 1462 }; 1463 this.scale.draw(i), e.each(this.datasets, function(t) { 1464 var h = e.where(t.points, n); 1465 e.each(t.points, function(t, e) { 1466 t.hasValue() && t.transition({ 1467 y: this.scale.calculateY(t.value), 1468 x: this.scale.calculateX(e) 1469 }, i) 1470 }, this), this.options.bezierCurve && e.each(h, function(t, i) { 1471 var s = i > 0 && i < h.length - 1 ? this.options.bezierCurveTension : 0; 1472 t.controlPoints = e.splineCurve(a(t, h, i), t, o(t, h, i), s), t.controlPoints.outer.y > this.scale.endPoint ? t.controlPoints.outer.y = this.scale.endPoint : t.controlPoints.outer.y < this.scale.startPoint && (t.controlPoints.outer.y = this.scale.startPoint), t.controlPoints.inner.y > this.scale.endPoint ? t.controlPoints.inner.y = this.scale.endPoint : t.controlPoints.inner.y < this.scale.startPoint && (t.controlPoints.inner.y = this.scale.startPoint) 1473 }, this), s.lineWidth = this.options.datasetStrokeWidth, s.strokeStyle = t.strokeColor, s.beginPath(), e.each(h, function(t, i) { 1474 if (0 === i) s.moveTo(t.x, t.y); 1475 else if (this.options.bezierCurve) { 1476 var e = a(t, h, i); 1477 s.bezierCurveTo(e.controlPoints.outer.x, e.controlPoints.outer.y, t.controlPoints.inner.x, t.controlPoints.inner.y, t.x, t.y) 1478 } else s.lineTo(t.x, t.y) 1479 }, this), s.stroke(), this.options.datasetFill && h.length > 0 && (s.lineTo(h[h.length - 1].x, this.scale.endPoint), s.lineTo(h[0].x, this.scale.endPoint), s.fillStyle = t.fillColor, s.closePath(), s.fill()), e.each(h, function(t) { 1480 t.draw() 1481 }) 1482 }, this) 1483 } 1484 })//******* 1485 }.call(this), 1486 function() { 1487 "use strict"; 1488 var t = this, 1489 i = t.Chart, 1490 e = i.helpers, 1491 s = { 1492 scaleShowLabelBackdrop: !0, 1493 scaleBackdropColor: "rgba(255,255,255,0.75)", 1494 scaleBeginAtZero: !0, 1495 scaleBackdropPaddingY: 2, 1496 scaleBackdropPaddingX: 2, 1497 scaleShowLine: !0, 1498 segmentShowStroke: !0, 1499 segmentStrokeColor: "#fff", 1500 segmentStrokeWidth: 2, 1501 animationSteps: 100, 1502 animationEasing: "easeOutBounce", 1503 animateRotate: !0, 1504 animateScale: !1, 1505 legendTemplate: '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>' 1506 }; 1507 i.Type.extend({ 1508 name: "PolarArea", 1509 defaults: s, 1510 initialize: function(t) { 1511 this.segments = [], this.SegmentArc = i.Arc.extend({ 1512 showStroke: this.options.segmentShowStroke, 1513 strokeWidth: this.options.segmentStrokeWidth, 1514 strokeColor: this.options.segmentStrokeColor, 1515 ctx: this.chart.ctx, 1516 innerRadius: 0, 1517 x: this.chart.width / 2, 1518 y: this.chart.height / 2 1519 }), this.scale = new i.RadialScale({ 1520 display: this.options.showScale, 1521 fontStyle: this.options.scaleFontStyle, 1522 fontSize: this.options.scaleFontSize, 1523 fontFamily: this.options.scaleFontFamily, 1524 fontColor: this.options.scaleFontColor, 1525 showLabels: this.options.scaleShowLabels, 1526 showLabelBackdrop: this.options.scaleShowLabelBackdrop, 1527 backdropColor: this.options.scaleBackdropColor, 1528 backdropPaddingY: this.options.scaleBackdropPaddingY, 1529 backdropPaddingX: this.options.scaleBackdropPaddingX, 1530 lineWidth: this.options.scaleShowLine ? this.options.scaleLineWidth : 0, 1531 lineColor: this.options.scaleLineColor, 1532 lineArc: !0, 1533 width: this.chart.width, 1534 height: this.chart.height, 1535 xCenter: this.chart.width / 2, 1536 yCenter: this.chart.height / 2, 1537 ctx: this.chart.ctx, 1538 templateString: this.options.scaleLabel, 1539 valuesCount: t.length 1540 }
1540), this.updateScaleRange(t), this.scale.update(), e.each(t, function(t, i) { 1541 this.addData(t, i, !0) 1542 }, this), this.options.showTooltips && e.bindEvents(this, ""/*this.options.tooltipEvents*/, function(t) { 1543 var i = "mouseout" !== t.type ? this.getSegmentsAtEvent(t) : []; 1544 e.each(this.segments, function(t) { 1545 t.restore(["fillColor"]) 1546 }), e.each(i, function(t) { 1547 t.fillColor = t.highlightColor 1548 }), this.showTooltip(i) 1549 }), this.render() 1550 }, 1551 getSegmentsAtEvent: function(t) { 1552 var i = [], 1553 s = e.getRelativePosition(t); 1554 return e.each(this.segments, function(t) { 1555 t.inRange(s.x, s.y) && i.push(t) 1556 }, this), i 1557 }, 1558 addData: function(t, i, e) { 1559 var s = i || this.segments.length; 1560 this.segments.splice(s, 0, new this.SegmentArc({ 1561 fillColor: t.color, 1562 highlightColor: t.highlight || t.color, 1563 label: t.label, 1564 value: t.value, 1565 outerRadius: this.options.animateScale ? 0 : this.scale.calculateCenterOffset(t.value), 1566 circumference: this.options.animateRotate ? 0 : this.scale.getCircumference(), 1567 startAngle: 1.5 * Math.PI 1568 })), e || (this.reflow(), this.update()) 1569 }, 1570 removeData: function(t) { 1571 var i = e.isNumber(t) ? t : this.segments.length - 1; 1572 this.segments.splice(i, 1), this.reflow(), this.update() 1573 }, 1574 calculateTotal: function(t) { 1575 this.total = 0, e.each(t, function(t) { 1576 this.total += t.value 1577 }, this), this.scale.valuesCount = this.segments.length 1578 }, 1579 updateScaleRange: function(t) { 1580 var i = []; 1581 e.each(t, function(t) { 1582 i.push(t.value) 1583 }); 1584 var s = this.options.scaleOverride ? { 1585 steps: this.options.scaleSteps, 1586 stepValue: this.options.scaleStepWidth, 1587 min: this.options.scaleStartValue, 1588 max: this.options.scaleStartValue + this.options.scaleSteps * this.options.scaleStepWidth 1589 } : e.calculateScaleRange(i, e.min([this.chart.width, this.chart.height]) / 2, this.options.scaleFontSize, this.options.scaleBeginAtZero, this.options.scaleIntegersOnly); 1590 e.extend(this.scale, s, { 1591 size: e.min([this.chart.width, this.chart.height]), 1592 xCenter: this.chart.width / 2, 1593 yCenter: this.chart.height / 2 1594 }) 1595 }, 1596 update: function() { 1597 this.calculateTotal(this.segments), e.each(this.segments, function(t) { 1598 t.save() 1599 }), this.render() 1600 }, 1601 reflow: function() { 1602 e.extend(this.SegmentArc.prototype, { 1603 x: this.chart.width / 2, 1604 y: this.chart.height / 2 1605 }), this.updateScaleRange(this.segments), this.scale.update(), e.extend(this.scale, { 1606 xCenter: this.chart.width / 2, 1607 yCenter: this.chart.height / 2 1608 }), e.each(this.segments, function(t) { 1609 t.update({ 1610 outerRadius: this.scale.calculateCenterOffset(t.value) 1611 }) 1612 }, this) 1613 }, 1614 draw: function(t) { 1615 var i = t || 1; 1616 this.clear(), e.each(this.segments, function(t, e) { 1617 t.transition({ 1618 circumference: this.scale.getCircumference(), 1619 outerRadius: this.scale.calculateCenterOffset(t.value) 1620 }, i), t.endAngle = t.startAngle + t.circumference, 0 === e && (t.startAngle = 1.5 * Math.PI), e < this.segments.length - 1 && (this.segments[e + 1].startAngle = t.endAngle), t.draw() 1621 }, this), this.scale.draw() 1622 } 1623 }) 1624 }.call(this), 1625 function() { 1626 "use strict"; 1627 var t = this, 1628 i = t.Chart, 1629 e = i.helpers; 1630 i.Type.extend({ 1631 name: "Radar", 1632 defaults: { 1633 scaleShowLine: !0, 1634 angleShowLineOut: !0, 1635 scaleShowLabels: !1, 1636 scaleBeginAtZero: !0, 1637 angleLineColor: "rgba(0,0,0,.1)", 1638 angleLineWidth: 1, 1639 pointLabelFontFamily: "'Arial'", 1640 pointLabelFontStyle: "normal", 1641 pointLabelFontSize: 10, 1642 pointLabelFontColor: "#666", 1643 pointDot: !0, 1644 pointDotRadius: 3, 1645 pointDotStrokeWidth: 1, 1646 pointHitDetectionRadius: 20, 1647 datasetStroke: !0, 1648 datasetStrokeWidth: 2, 1649 datasetFill: !0, 1650 legendTemplate: '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>' 1651 }, 1652 initialize: function(t) { 1653 this.PointClass = i.Point.extend({ 1654 strokeWidth: this.options.pointDotStrokeWidth, 1655 radius: this.options.pointDotRadius, 1656 display: this.options.pointDot, 1657 hitDetectionRadius: this.options.pointHitDetectionRadius, 1658 ctx: this.chart.ctx 1659 }), this.datasets = [], this.buildScale(t), this.options.showTooltips && e.bindEvents(this, ""/*this.options.tooltipEvents*/, function(t) { 1660 var i = "mouseout" !== t.type ? this.getPointsAtEvent(t) : []; 1661 this.eachPoints(function(t) { 1662 t.restore(["fillColor", "strokeColor"]) 1663 }), e.each(i, function(t) { 1664 t.fillColor = t.highlightFill, t.strokeColor = t.highlightStroke 1665 }), this.showTooltip(i) 1666 }), e.each(t.datasets, function(i) { 1667 var s = { 1668 label: i.label || null, 1669 fillColor: i.fillColor, 1670 strokeColor: i.strokeColor, 1671 pointColor: i.pointColor, 1672 pointStrokeColor: i.pointStrokeColor, 1673 points: [] 1674 }; 1675 this.datasets.push(s), e.each(i.data, function(e, n) { 1676 var o; 1677 this.scale.animation || (o = this.scale.getPointPosition(n, this.scale.calculateCenterOffset(e))), s.points.push(new this.PointClass({ 1678 value: e, 1679 label: t.labels[n], 1680 datasetLabel: i.label, 1681 x: this.options.animation ? this.scale.xCenter : o.x, 1682 y: this.options.animation ? this.scale.yCenter : o.y, 1683 strokeColor: i.pointStrokeColor, 1684 fillColor: i.pointColor, 1685 highlightFill: i.pointHighlightFill || i.pointColor, 1686 highlightStroke: i.pointHighlightStroke || i.pointStrokeColor 1687 })) 1688 }, this) 1689 }, this), this.render() 1690 }, 1691 eachPoints: function(t) { 1692 e.each(this.datasets, function(i) { 1693 e.each(i.points, t, this) 1694 }, this) 1695 }, 1696 getPointsAtEvent: function(t) { 1697 var i = e.getRelativePosition(t), 1698 s = e.getAngleFromPoint({ 1699 x: this.scale.xCenter, 1700 y: this.scale.yCenter 1701 }, i), 1702 n = 2 * Math.PI / this.scale.valuesCount, 1703 o = Math.round((s.angle - 1.5 * Math.PI) / n), 1704 a = []; 1705 return (o >= this.scale.valuesCount || 0 > o) && (o = 0), s.distance <= this.scale.drawingArea && e.each(this.datasets, function(t) { 1706 a.push(t.points[o]) 1707 }), a 1708 }, 1709 buildScale: function(t) { 1710 this.scale = new i.RadialScale({ 1711 display: this.options.showScale, 1712 fontStyle: this.options.scaleFontStyle, 1713 fontSize: this.options.scaleFontSize, 1714 fontFamily: this.options.scaleFontFamily, 1715 fontColor: this.options.scaleFontColor, 1716 showLabels: this.options.scaleShowLabels, 1717 showLabelBackdrop: this.options.scaleShowLabelBackdrop, 1718 backdropColor: this.options.scaleBackdropColor, 1719 backdropPaddingY: this.options.scaleBackdropPaddingY, 1720 backdropPaddingX: this.options.scaleBackdropPaddingX, 1721 lineWidth: this.options.scaleShowLine ? this.options.scaleLineWidth : 0, 1722 lineColor: this.options.scaleLineColor, 1723 angleLineColor: this.options.angleLineColor, 1724 angleLineWidth: this.options.angleShowLineOut ? this.options.angleLineWidth : 0, 1725 pointLabelFontColor: this.options.pointLabelFontColor, 1726 pointLabelFontSize: this.options.pointLabelFontSize, 1727 pointLabelFontFamily: this.options.pointLabelFontFamily, 1728 pointLabelFontStyle: this.options.pointLabelFontStyle, 1729 height: this.chart.height, 1730 width: this.chart.width, 1731 xCenter: this.chart.width / 2, 1732 yCenter: this.chart.height / 2, 1733 ctx: this.chart.ctx, 1734 templateString: this.options.scaleLabel, 1735 labels: t.labels, 1736 valuesCount: t.datasets[0].data.length 1737 }), this.scale.setScaleSize(), this.updateScaleRange(t.datasets), this.scale.buildYLabels() 1738 }, 1739 updateScaleRange: function(t) { 1740 var i = function() { 1741 var i = []; 1742 return e.each(t, function(t) { 1743 t.data ? i = i.concat(t.data) : e.each(t.points, function(t) { 1744 i.push(t.value) 1745 }) 1746 }), i 1747 }(), 1748 s = this.options.scaleOverride ? { 1749 steps: this.options.scaleSteps, 1750 stepValue: this.options.scaleStepWidth, 1751 min: this.options.scaleStartValue, 1752 max: this.options.scaleStartValue + this.options.scaleSteps * this.options.scaleStepWidth 1753 } : e.calculateScaleRange(i, e.min([this.chart.width, this.chart.height]) / 2, this.options.scaleFontSize, this.options.scaleBeginAtZero, this.options.scaleIntegersOnly); 1754 e.extend(this.scale, s) 1755 }, 1756 addData: function(t, i) { 1757 this.scale.valuesCount++, e.each(t, function(t, e) { 1758 var s = this.scale.getPointPosition(this.scale.valuesCount, this.scale.calculateCenterOffset(t)); 1759 this.datasets[e].points.push(new this.PointClass({ 1760 value: t, 1761 label: i, 1762 x: s.x, 1763 y: s.y, 1764 strokeColor: this.datasets[e].pointStrokeColor, 1765 fillColor: this.datasets[e].pointColor 1766 })) 1767 }, this), this.scale.labels.push(i), this.reflow(), this.update() 1768 }, 1769 removeData: function() { 1770 this.scale.valuesCount--, this.scale.labels.shift(), e.each(this.datasets, function(t) { 1771 t.points.shift() 1772 }, this), this.reflow(), this.update() 1773 }, 1774 update: function() { 1775 this.eachPoints(function(t) { 1776 t.save() 1777 }), this.reflow(), this.render() 1778 }, 1779 reflow: function() { 1780 e.extend(this.scale, { 1781 width: this.chart.width, 1782 height: this.chart.height, 1783 size: e.min([this.chart.width, this.chart.height]), 1784 xCenter: this.chart.width / 2, 1785 yCenter: this.chart.height / 2 1786 }), this.updateScaleRange(this.datasets), this.scale.setScaleSize(), this.scale.buildYLabels() 1787 }, 1788 draw: function(t) { 1789 var i = t || 1, 1790 s = this.chart.ctx; 1791 this.clear(), this.scale.draw(), e.each(this.datasets, function(t) { 1792 e.each(t.points, function(t, e) { 1793 t.hasValue() && t.transition(this.scale.getPointPosition(e, this.scale.calculateCenterOffset(t.value)), i) 1794 }, this), s.lineWidth = this.options.datasetStrokeWidth, s.strokeStyle = t.strokeColor, s.beginPath(), e.each(t.points, function(t, i) { 1795 0 === i ? s.moveTo(t.x, t.y) : s.lineTo(t.x, t.y) 1796 }, this), s.closePath(), s.stroke(), s.fillStyle = t.fillColor, s.fill(), e.each(t.points, function(t) { 1797 t.hasValue() && t.draw() 1798 }) 1799 }, this) 1800 } 1801 }) 1802 }.call(this); 1803 1804 1805jQuery(document).ready(function(){ 1806 "use strict"; 1807 1808 //graph
1809 if (jQuery('.tw-chart-graph:not(.inited)').length > 0) { 1810 chart_graph_init(jQuery('body').eq(0)); 1811 jQuery(window).scroll(function () { chart_graph_init(jQuery('body').eq(0)); }); 1812 jQuery('.tw-chart-graph:not(.inited)').parents('.sc_tabs').find('.tab_names').click(function () { chart_graph_init(jQuery('body').eq(0)); }); 1813 } 1814 1815 1816}); 1817 1818 1819//graph 1820function chart_graph_init(container) { 1821 1822 if (arguments.length==0) var container = jQuery('body'); 1823 var scrollPosition = jQuery(window).scrollTop() + jQuery(window).height(); 1824 1825 container.find('.tw-chart-graph:not(.inited)').each(function () { 1826 "use strict"; 1827 1828 var item = jQuery(this); 1829 1830 var scrollSkills = item.offset().top + 300; 1831 if (scrollPosition > scrollSkills) { 1832 if (jQuery(this).parents('div:hidden').length > 0) return; 1833 jQuery(this).addClass('inited'); 1834 1835 var $curr = jQuery(this); 1836 var $type = $curr.attr('data-type'); 1837 var $height = $curr.attr('data-item-height'); 1838 var $labels = $curr.attr('data-labels')?$curr.attr('data-labels').split(','):[" "]; 1839 var $beginAtZero = $curr.attr('data-zero')==='true'?true:false; 1840 var $datasets = []; 1841 var $graphWidth = jQuery(this).width(); 1842 $curr.children('canvas').remove(); 1843 $curr.append(jQuery('<canvas />')); 1844 var $canvas = $curr.children('canvas'); 1845 var $listDesc = ''; 1846 jQuery('>ul.data>li',$curr).each(function(){ 1847 var $currData = jQuery(this); 1848 if($currData.attr('data-fill-text')&&$currData.attr('data-fill-color')){$listDesc+='<li><i class="fa-caret-right fa" style="background:'+$currData.attr('data-fill-color')+';"></i>'+$currData.attr('data-fill-text')+'</li>';} 1849 $datasets.push( 1850 { 1851 // Line And Radar 1852 pointColor : $currData.attr('data-fill-color'), 1853 pointStrokeColor : $currData.attr('data-fill-color'), 1854 pointHighlightFill: "#ffffff", 1855 pointHighlightStroke: 'rgba('+hex2rgb($currData.attr('data-fill-color')).red+','+hex2rgb($currData.attr('data-fill-color')).green+','+hex2rgb($currData.attr('data-fill-color')).blue+',1)', 1856 // Bar 1857 highlightFill : 'rgba('+hex2rgb($currData.attr('data-fill-color')).red+','+hex2rgb($currData.attr('data-fill-color')).green+','+hex2rgb($currData.attr('data-fill-color')).blue+',1)', 1858 highlightStroke : 'rgba('+hex2rgb($currData.attr('data-fill-color')).red+','+hex2rgb($currData.attr('data-fill-color')).green+','+hex2rgb($currData.attr('data-fill-color')).blue+',1)', 1859 // All 1860 label : $currData.attr('data-fill-text'), 1861 fillColor : 'rgba('+hex2rgb($currData.attr('data-fill-color')).red+','+hex2rgb($currData.attr('data-fill-color')).green+','+hex2rgb($currData.attr('data-fill-color')).blue+',1)', 1862 strokeColor : $currData.attr('data-fill-color'), 1863 data : $currData.attr('data-datas')?$currData.attr('data-datas').split(','):[" "] 1864 } 1865 ); 1866 }); 1867 if($graphWidth > 0) if($listDesc){$curr.addClass('with-list-desc').before('<div class="graph list-desc" style="width: ' + $graphWidth + 'px; margin: auto;"><ul>'+$listDesc+'</ul></div>');} 1868 else if($listDesc){$curr.addClass('with-list-desc').before('<div class="graph list-desc"><ul>'+$listDesc+'</ul></div>');} 1869 1870 $canvas.attr('width', $curr.width()+'px'); 1871 $canvas.attr('height',$height===''?$curr.height()+'px':$height); 1872 1873 var $data = { 1874 labels : $labels, 1875 datasets : $datasets 1876 }; 1877 1878 if($curr.hasClass('tw-animate')) 1879 { 1880 var $currDelay = parseInt($curr.attr('data-animation-delay'), 10); 1881 if(!($currDelay>0)){$currDelay=0;} 1882 1883 setTimeout(function(){ 1884 $curr.css('opacity',''); 1885 $curr.siblings('.list-desc').animate({opacity: 1},500); 1886 $curr.removeClass('not-drawed'); 1887 $curr.children('canvas').remove(); 1888 $curr.append(jQuery('<canvas />')); 1889 $canvas = $curr.children('canvas'); 1890 $height = ($height==='')?($curr.height()+'px'):$height; 1891 $canvas.attr('width', $curr.width()+'px'); 1892 $canvas.attr('height', 286); //graph height 1893 var $chart = new Chart($canvas.get(0).getContext("2d")); 1894 $chart[$type]($data, {scaleBeginAtZero : $beginAtZero}
1894); 1895 1896 1897 },$currDelay); 1898 1899 } 1900 } 1901 }); 1902} 1903 1904// HEX To RGB 1905function hex2rgb(hex) { 1906 "use strict"; 1907 try{ 1908 if (hex[0]==="#") hex=hex.substr(1); 1909 if (hex.length===3) { 1910 var temp=hex; hex=''; 1911 temp = /^([a-f0-9])([a-f0-9])([a-f0-9])$/i.exec(temp).slice(1); 1912 for (var i=0;i<3;i++) hex+=temp[i]+temp[i]; 1913 } 1914 var triplets = /^([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i.exec(hex).slice(1); 1915 }catch(e){ 1916 return { 1917 red: 0, 1918 green: 0, 1919 blue: 0 1920 }; 1921 } 1922 return { 1923 red: parseInt(triplets[0],16), 1924 green: parseInt(triplets[1],16), 1925 blue: parseInt(triplets[2],16) 1926 }; 1927}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.