var excludeMobileRedirect = ["/fifaworldcup/organisation/ticketing/", "/worldcup/organisation/ticketing/"];define(['frameworks/bundle'],function () {;function roundToWithThousands(e, t, n) { var r = 1 * unFormat(e, t); if (typeof r == "number" && n != "none") { if (n <= 0) { var i = -n; r = +(Math.round(r + "e+" + i) + "e-" + i) } else { var i = n; var s = "1e+" + i; r = +Math.round(r / s) * s } } r = fmtChartJS(e, r, "none"); return r } function unFormat(e, t) { if ((e.decimalSeparator != "." || e.thousandSeparator != "") && typeof t == "string") { var n = "" + t; if (e.thousandSeparator != "") { while (n.indexOf(e.thousandSeparator) >= 0) n = "" + n.replace(e.thousandSeparator, "") } if (e.decimalSeparator != ".") n = "" + n.replace(e.decimalSeparator, "."); return 1 * n } else { return t } } function fmtChartJSPerso(e, t, n) { switch (n) { case "SampleJS_Format": if (typeof t == "number") return_value = "My Format : " + t.toString() + " $"; else return_value = t + "XX"; break; case "Change_Month": if (typeof t == "string") return_value = t.toString() + " 2014"; else return_value = t.toString() + "YY"; break; default: return_value = t; break } return return_value } function fmtChartJS(e, t, n) { var r; if (n == "notformatted") { r = t } else if (n == "none" && typeof t == "number") { if (e.roundNumber != "none") { if (e.roundNumber <= 0) { var i = -e.roundNumber; t = +(Math.round(t + "e+" + i) + "e-" + i) } else { var i = e.roundNumber; var s = "1e+" + i; t = +Math.round(t / s) * s } } if (e.decimalSeparator != "." || e.thousandSeparator != "") { r = t.toString().replace(/\./g, e.decimalSeparator); if (e.thousandSeparator != "") { var o = r; var u = ""; var a = o.indexOf(e.decimalSeparator); if (a >= 0) { u = o.substring(a + 1, o.length); u = u.split("").reverse().join(""); o = o.substring(0, a) } o = o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, e.thousandSeparator); u = u.split("").reverse().join(""); r = o; if (u != "") r = r + e.decimalSeparator + u } } else r = t } else if (n != "none" && n != "notformatted") { r = fmtChartJSPerso(e, t, n) } else { r = t } return r } function addParameters2Function(data, fctName, fctList) { var mathFunctions = { mean: { data: data.data, datasetNr: data.v11 }, varianz: { data: data.data, datasetNr: data.v11 }, stddev: { data: data.data, datasetNr: data.v11 }, cv: { data: data.data, datasetNr: data.v11 }, median: { data: data.data, datasetNr: data.v11 } }; dif = false; if (fctName.substr(-3) == "Dif") { fctName = fctName.substr(0, fctName.length - 3); dif = true } if (typeof eval(fctName) == "function") { var parameter = eval(fctList + "." + fctName); if (dif) { return data.v3 - window[fctName](parameter) } return window[fctName](parameter) } return } function isNumber(e) { return !isNaN(parseFloat(e)) && isFinite(e) } function tmplbis(e, t) { var n = ["mean", "varianz", "stddev", "cv", "median"]; var r = new RegExp("<%=((?:(?:.*?)\\W)??)((?:" + n.join("|") + ")(?:Dif)?)\\(([0-9]*?)\\)(.*?)%>", "g"); while (r.test(e)) { e = e.replace(r, function (e, n, r, i, s) { if (i) { var o = i } else { var o = 2 } var u = addParameters2Function(t, r, "mathFunctions"); if (isNumber(u)) { return "<%=" + n + "" + Math.round(Math.pow(10, o) * u) / Math.pow(10, o) + "" + s + "%>" } return "<%= %>" }) } var i = /^[A-Za-z][-A-Za-z0-9_:.]*$/.test(e) ? cachebis[e] = cachebis[e] || tmplbis(document.getElementById(e).innerHTML) : new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" + "with(obj){p.push('" + e.replace(/[\r\n]/g, "\\n").replace(/[\t]/g, " ").split("<%").join(" ").replace(/((^|%>)[^\t]*)'/g, "$1\r").replace(/\t=(.*?)%>/g, "',$1,'").split(" ").join("');").split("%>").join("p.push('").split("\r").join("\\'") + "');}return p.join('');"); return t ? i(t) : i } function createCursorDiv() { if (cursorDivCreated == false) { var e = document.createElement("divCursor"); e.id = "divCursor"; e.style.position = "absolute"; document.body.appendChild(e); cursorDivCreated = true } } function checkBrowser() { this.ver = navigator.appVersion; this.dom = document.getElementById ? 1 : 0; this.ie5 = this.ver.indexOf("MSIE 5") > -1 && this.dom ? 1 : 0; this.ie4 = document.all && !this.dom ? 1 : 0; this.ns5 = this.dom && parseInt(this.ver) >= 5 ? 1 : 0; this.ns4 = document.layers && !this.dom ? 1 : 0; this.bw = this.ie5 || this.ie4 || this.ns4 || this.ns5; return this } function cursorInit() { scrolled = bw.ns4 || bw.ns5 ? "window.pageYOffset" : "document.body.scrollTop"; if (bw.ns4) document.captureEvents(Event.MOUSEMOVE) } function makeCursorObj(obj, nest) { createCursorDiv(); nest = !nest ? "" : "document." + nest + "."; this.css = bw.dom ? document.getElementById(obj).style : bw.ie4 ? document.all[obj].style : bw.ns4 ? eval(nest + "document.layers." + obj) : 0; this.moveIt = b_moveIt; cursorInit(); return this } function b_moveIt(e, t) { this.x = e; this.y = t; this.css.left = this.x + "px"; this.css.top = this.y + "px" } function isIE() { var e = navigator.userAgent.toLowerCase(); return e.indexOf("msie") != -1 ? parseInt(e.split("msie")[1]) : false } function mergeChartConfig(e, t) { var n = {}; for (var r in e) { n[r] = e[r] } for (var r in t) { n[r] = t[r] } return n } function sleep(e) { var t = new Date; t.setTime(t.getTime() + e); while ((new Date).getTime() < t.getTime()) { } } function saveCanvas(e, t, n, r) { cvSave = e.getImageData(0, 0, e.canvas.width, e.canvas.height); var i = { savePng: false, annotateDisplay: false, animation: false, dynamicDisplay: false }; var s = mergeChartConfig(n, i); s.clearRect = false; switch (r) { case "Bar": (new Chart(e.canvas.getContext("2d"))).Bar(t, s); break; case "Pie": (new Chart(e.canvas.getContext("2d"))).Pie(t, s); break; case "Doughnut": (new Chart(e.canvas.getContext("2d"))).Doughnut(t, s); break; case "Radar": (new Chart(e.canvas.getContext("2d"))).Radar(t, s); break; case "PolarArea": (new Chart(e.canvas.getContext("2d"))).PolarArea(t, s); break; case "HorizontalBar": (new Chart(e.canvas.getContext("2d"))).HorizontalBar(t, s); break; case "StackedBar": (new Chart(e.canvas.getContext("2d"))).StackedBar(t, s); break; case "HorizontalStackedBar": (new Chart(e.canvas.getContext("2d"))).HorizontalStackedBar(t, s); break; case "Line": (new Chart(e.canvas.getContext("2d"))).Line(t, s); break } if (n.savePngOutput == "NewWindow") { var o = e.canvas.toDataURL(); e.putImageData(cvSave, 0, 0); window.open(o, "_blank") } if (n.savePngOutput == "CurrentWindow") { var o = e.canvas.toDataURL(); e.putImageData(cvSave, 0, 0); window.location.href = o } if (n.savePngOutput == "Save") { var o = e.canvas.toDataURL(); var u = document.createElement("a"); u.href = o; u.download = n.savePngName + ".png"; document.body.appendChild(u); u.click(); document.body.removeChild(u) } } function dynamicFunction(e, t, n, r) { if (t.dynamicDisplay) { if (n.canvas.id == "") { var i = new Date; var s = i.getTime(); n.canvas.id = "Canvas_" + s } if (typeof dynamicDisplay[n.canvas.id] == "undefined") { dynamicDisplayList[dynamicDisplayList["length"]] = n.canvas.id; dynamicDisplay[n.canvas.id] = [n.canvas, false, false, e, t, n.canvas, r]; dynamicDisplay[n.canvas.id][1] = isScrolledIntoView(n.canvas); window.onscroll = scrollFunction } if (dynamicDisplay[n.canvas.id][1] == false || dynamicDisplay[n.canvas.id][2] == true) return false; dynamicDisplay[n.canvas.id][2] = true } return true } function isScrolledIntoView(e) { var t = 0; var n = 0; elem = e; while (elem) { t += elem.offsetLeft - elem.scrollLeft + elem.clientLeft; n += elem.offsetTop - elem.scrollTop + elem.clientTop; elem = elem.offsetParent } if (t + e.width / 2 >= window.pageXOffset && t + e.width / 2 <= window.pageXOffset + window.innerWidth && n + e.height / 2 >= window.pageYOffset && n + e.height / 2 <= window.pageYOffset + window.innerHeight) return true; else return false } function scrollFunction() { for (var e = 0; e < dynamicDisplayList["length"]; e++) { if (isScrolledIntoView(dynamicDisplay[dynamicDisplayList[e]][5]) && dynamicDisplay[dynamicDisplayList[e]][2] == false) { dynamicDisplay[dynamicDisplayList[e]][1] = true; switch (dynamicDisplay[dynamicDisplayList[e]][6]) { case "Bar": (new Chart(document.getElementById(dynamicDisplayList[e]).getContext("2d"))).Bar(dynamicDisplay[dynamicDisplayList[e]][3], dynamicDisplay[dynamicDisplayList[e]][4]); break; case "Pie": (new Chart(document.getElementById(dynamicDisplayList[e]).getContext("2d"))).Pie(dynamicDisplay[dynamicDisplayList[e]][3], dynamicDisplay[dynamicDisplayList[e]][4]); break; case "Doughnut": (new Chart(document.getElementById(dynamicDisplayList[e]).getContext("2d"))).Doughnut(dynamicDisplay[dynamicDisplayList[e]][3], dynamicDisplay[dynamicDisplayList[e]][4]); break; case "Radar": (new Chart(document.getElementById(dynamicDisplayList[e]).getContext("2d"))).Radar(dynamicDisplay[dynamicDisplayList[e]][3], dynamicDisplay[dynamicDisplayList[e]][4]); break; case "PolarArea": (new Chart(document.getElementById(dynamicDisplayList[e]).getContext("2d"))).PolarArea(dynamicDisplay[dynamicDisplayList[e]][3], dynamicDisplay[dynamicDisplayList[e]][4]); break; case "HorizontalBar": (new Chart(document.getElementById(dynamicDisplayList[e]).getContext("2d"))).HorizontalBar(dynamicDisplay[dynamicDisplayList[e]][3], dynamicDisplay[dynamicDisplayList[e]][4]); break; case "StackedBar": (new Chart(document.getElementById(dynamicDisplayList[e]).getContext("2d"))).StackedBar(dynamicDisplay[dynamicDisplayList[e]][3], dynamicDisplay[dynamicDisplayList[e]][4]); break; case "HorizontalStackedBar": (new Chart(document.getElementById(dynamicDisplayList[e]).getContext("2d"))).HorizontalStackedBar(dynamicDisplay[dynamicDisplayList[e]][3], dynamicDisplay[dynamicDisplayList[e]][4]); break; case "Line": (new Chart(document.getElementById(dynamicDisplayList[e]).getContext("2d"))).Line(dynamicDisplay[dynamicDisplayList[e]][3], dynamicDisplay[dynamicDisplayList[e]][4]); break } } } } function clearAnnotate(e) { jsGraphAnnotate[e] = [] } function getMousePos(e, t) { var n = e.getBoundingClientRect(); return { x: t.clientX - n.left, y: t.clientY - n.top } } function doMouseAction(config, ctx, event, data, action, funct) { var onData = false; if (action == "annotate") { var annotateDIV = document.getElementById("divCursor"); var show = false; annotateDIV.className = config.annotateClassName ? config.annotateClassName : ""; annotateDIV.style.border = config.annotateClassName ? "" : config.annotateBorder; annotateDIV.style.padding = config.annotateClassName ? "" : config.annotatePadding; annotateDIV.style.borderRadius = config.annotateClassName ? "" : config.annotateBorderRadius; annotateDIV.style.backgroundColor = config.annotateClassName ? "" : config.annotateBackgroundColor; annotateDIV.style.color = config.annotateClassName ? "" : config.annotateFontColor; annotateDIV.style.fontFamily = config.annotateClassName ? "" : config.annotateFontFamily; annotateDIV.style.fontSize = config.annotateClassName ? "" : config.annotateFontSize + "pt"; annotateDIV.style.fontStyle = config.annotateClassName ? "" : config.annotateFontStyle } if (action == "annotate") { show = false; annotateDIV.style.display = show ? "" : "none" } canvas_pos = getMousePos(ctx.canvas, event); for (i = 0; i < jsGraphAnnotate[ctx.ChartNewId]["length"]; i++) { if (jsGraphAnnotate[ctx.ChartNewId][i][0] == "ARC") { distance = Math.sqrt((canvas_pos.x - jsGraphAnnotate[ctx.ChartNewId][i][1]) * (canvas_pos.x - jsGraphAnnotate[ctx.ChartNewId][i][1]) + (canvas_pos.y - jsGraphAnnotate[ctx.ChartNewId][i][2]) * (canvas_pos.y - jsGraphAnnotate[ctx.ChartNewId][i][2])); if (distance > jsGraphAnnotate[ctx.ChartNewId][i][3] && distance < jsGraphAnnotate[ctx.ChartNewId][i][4]) { angle = Math.acos((canvas_pos.x - jsGraphAnnotate[ctx.ChartNewId][i][1]) / distance); if (canvas_pos.y < jsGraphAnnotate[ctx.ChartNewId][i][2]) angle = -angle; while (angle < 0) { angle += 2 * Math.PI } while (angle > 2 * Math.PI) { angle -= 2 * Math.PI } if (angle < config.startAngle * (Math.PI / 360)) angle += 2 * Math.PI; if (angle > jsGraphAnnotate[ctx.ChartNewId][i][5] && angle < jsGraphAnnotate[ctx.ChartNewId][i][6] || angle > jsGraphAnnotate[ctx.ChartNewId][i][5] - 2 * Math.PI && angle < jsGraphAnnotate[ctx.ChartNewId][i][6] - 2 * Math.PI || angle > jsGraphAnnotate[ctx.ChartNewId][i][5] + 2 * Math.PI && angle < jsGraphAnnotate[ctx.ChartNewId][i][6] + 2 * Math.PI) { v1 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][7], config.fmtV1); v2 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][8], config.fmtV2); v3 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][9], config.fmtV3); v4 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][10], config.fmtV4); v5 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][11], config.fmtV5); v6 = fmtChartJS(config, 100 * jsGraphAnnotate[ctx.ChartNewId][i][8] / jsGraphAnnotate[ctx.ChartNewId][i][10], config.fmtV6); v6 = roundToWithThousands(config, v6, config.roundPct); v7 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][1], config.fmtV7); v8 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][2], config.fmtV8); v9 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][3], config.fmtV9); v10 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][4], config.fmtV10); v11 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][5], config.fmtV11); v12 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][6], config.fmtV12); v13 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][12], config.fmtV13); graphPosX = canvas_pos.x; graphPosY = canvas_pos.y; onData = true; if (action == "annotate") { dispString = tmplbis(config.annotateLabel, { config: config, v1: v1, v2: v2, v3: v3, v4: v4, v5: v5, v6: v6, v7: v7, v8: v8, v9: v9, v10: v10, v11: v11, v12: v12, v13: v13, graphPosX: graphPosX, graphPosY: graphPosY }); annotateDIV.innerHTML = dispString; show = true } else { funct(event, ctx, config, data, { v1: v1, v2: v2, v3: v3, v4: v4, v5: v5, v6: v6, v7: v7, v8: v8, v9: v9, v10: v10, v11: v11, v12: v12, v13: v13, graphPosX: graphPosX, graphPosY: graphPosY }) } if (action == "annotate") { x = bw.ns4 || bw.ns5 ? event.pageX : event.x; y = bw.ns4 || bw.ns5 ? event.pageY : event.y; if (bw.ie4 || bw.ie5) y = y + eval(scrolled); oCursor.moveIt(x + fromLeft, y + fromTop) } } } } else if (jsGraphAnnotate[ctx.ChartNewId][i][0] == "RECT") { if (canvas_pos.x > jsGraphAnnotate[ctx.ChartNewId][i][1] && canvas_pos.x < jsGraphAnnotate[ctx.ChartNewId][i][3] && canvas_pos.y < jsGraphAnnotate[ctx.ChartNewId][i][2] && canvas_pos.y > jsGraphAnnotate[ctx.ChartNewId][i][4]) { v1 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][5], config.fmtV1); v2 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][6], config.fmtV2); v3 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][7], config.fmtV3); v4 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][8], config.fmtV4); v5 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][9], config.fmtV5); v6 = fmtChartJS(config, 100 * jsGraphAnnotate[ctx.ChartNewId][i][7] / jsGraphAnnotate[ctx.ChartNewId][i][9], config.fmtV6); v6 = roundToWithThousands(config, v6, config.roundPct); v7 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][1], config.fmtV7); v8 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][2], config.fmtV8); v9 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][3], config.fmtV9); v10 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][4], config.fmtV10); v11 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][10], config.fmtV11); v12 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][11], config.fmtV12); graphPosX = canvas_pos.x; graphPosY = canvas_pos.y; onData = true; if (action == "annotate") { dispString = tmplbis(config.annotateLabel, { config: config, v1: v1, v2: v2, v3: v3, v4: v4, v5: v5, v6: v6, v7: v7, v8: v8, v9: v9, v10: v10, v11: v11, v12: v12, graphPosX: graphPosX, graphPosY: graphPosY, data: data }); annotateDIV.innerHTML = dispString; show = true } else { funct(event, ctx, config, data, { v1: v1, v2: v2, v3: v3, v4: v4, v5: v5, v6: v6, v7: v7, v8: v8, v9: v9, v10: v10, v11: v11, v12: v12, graphPosX: graphPosX, graphPosY: graphPosY }) } if (action == "annotate") { x = bw.ns4 || bw.ns5 ? event.pageX : event.x; y = bw.ns4 || bw.ns5 ? event.pageY : event.y; if (bw.ie4 || bw.ie5) y = y + eval(scrolled); oCursor.moveIt(x + fromLeft, y + fromTop) } } } else if (jsGraphAnnotate[ctx.ChartNewId][i][0] == "POINT") { distance = Math.sqrt((canvas_pos.x - jsGraphAnnotate[ctx.ChartNewId][i][1]) * (canvas_pos.x - jsGraphAnnotate[ctx.ChartNewId][i][1]) + (canvas_pos.y - jsGraphAnnotate[ctx.ChartNewId][i][2]) * (canvas_pos.y - jsGraphAnnotate[ctx.ChartNewId][i][2])); if (distance < 10) { v1 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][3], config.fmtV1); v2 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][4], config.fmtV2); v3 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][5], config.fmtV3); v4 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][6], config.fmtV4); v5 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][7], config.fmtV5); v6 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][8], config.fmtV6); v7 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][9], config.fmtV7); v8 = fmtChartJS(config, 100 * jsGraphAnnotate[ctx.ChartNewId][i][5] / jsGraphAnnotate[ctx.ChartNewId][i][9], config.fmtV8); v8 = roundToWithThousands(config, v8, config.roundPct); v9 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][1], config.fmtV9); v10 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][2], config.fmtV10); v11 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][10], config.fmtV11); v12 = fmtChartJS(config, jsGraphAnnotate[ctx.ChartNewId][i][11], config.fmtV12); graphPosX = canvas_pos.x; graphPosY = canvas_pos.y; onData = true; if (action == "annotate") { dispString = tmplbis(config.annotateLabel, { config: config, v1: v1, v2: v2, v3: v3, v4: v4, v5: v5, v6: v6, v7: v7, v8: v8, v9: v9, v10: v10, v11: v11, v12: v12, graphPosX: graphPosX, graphPosY: graphPosY, data: data }); annotateDIV.innerHTML = dispString; show = true } else { funct(event, ctx, config, data, { v1: v1, v2: v2, v3: v3, v4: v4, v5: v5, v6: v6, v7: v7, v8: v8, v9: v9, v10: v10, v11: v11, v12: v12, graphPosX: graphPosX, graphPosY: graphPosY }) } if (action == "annotate") { x = bw.ns4 || bw.ns5 ? event.pageX : event.x; y = bw.ns4 || bw.ns5 ? event.pageY : event.y; if (bw.ie4 || bw.ie5) y = y + eval(scrolled); oCursor.moveIt(x + fromLeft, y + fromTop) } } } if (action == "annotate") { annotateDIV.style.display = show ? "" : "none" } } if (onData == false && action != "annotate") { funct(event, ctx, config, data, null) } } function animationCorrection(e, t, n, r, i, s) { var o = e; var u = 0; if (i != -1) { if (o < 1 && r < n.animationStartWithDataset - 1 && n.animationStartWithDataset - 1 != -1) { o = 1 } if (o < 1 && i < n.animationStartWithData - 1 && n.animationStartWithData - 1 != -1) { o = 1 } var a = 1; var f = e; if (o < 1 && n.animationByDataset) { o = 0; a = 0; var l = n.animationStartWithDataset - 1; if (n.animationStartWithDataset - 1 == -1) l = 0; var c = n.animationSteps / (t.datasets.length - l); if (e >= (r - l + 1) * c / n.animationSteps) o = 1; else if (e >= (r - l) * c / n.animationSteps) { var h = e - (r - l) * c / n.animationSteps; if (!n.animationLeftToRight) { o = h * (t.datasets.length - l) } else { f = h * (t.datasets.length - l) } a = 1 } } if (a == 1 && o < 1 && n.animationLeftToRight) { o = 0; var p = n.animationStartWithData - 1; if (n.animationStartWithData - 1 == -1) p = 0; var d = n.animationSteps / (t.datasets[r].data.length - p - 1 + s); if (f >= (i - p) * d / n.animationSteps) { o = 1; if (f <= (i + 1 - p) * d / n.animationSteps) { u = (t.datasets[r].data.length - p - 1) * (f - (i - p) * d / n.animationSteps) } } } } else { if (o < 1 && r < n.animationStartWithData - 1) { o = 1 } } return { mainVal: o, subVal: u, animVal: o + u } } function drawLegend(e, t, n, r, i) { if (n.legendBorders == true) { r.save(); r.beginPath(); r.lineWidth = n.legendBordersWidth; r.strokeStyle = n.legendBordersColors; r.moveTo(e.xLegendBorderPos, e.yLegendBorderPos); r.lineTo(e.xLegendBorderPos, e.yLegendBorderPos + e.legendBorderHeight); r.lineTo(e.xLegendBorderPos + e.legendBorderWidth, e.yLegendBorderPos + e.legendBorderHeight); r.lineTo(e.xLegendBorderPos + e.legendBorderWidth, e.yLegendBorderPos); r.lineTo(e.xLegendBorderPos, e.yLegendBorderPos); r.lineTo(e.xLegendBorderPos + e.legendBorderWidth, e.yLegendBorderPos); r.lineTo(e.xLegendBorderPos, e.yLegendBorderPos); r.lineTo(e.xLegendBorderPos, e.yLegendBorderPos + e.legendBorderHeight); r.stroke(); r.closePath(); r.fillStyle = "rgba(0,0,0,0)"; r.fillStyle = n.legendFillColor; r.fill(); r.restore() } nbcols = e.nbLegendCols - 1; ypos = e.yFirstLegendTextPos - (n.legendFontSize + n.legendSpaceBetweenTextVertical); xpos = 0; if (e.drawLegendOnData) fromi = t.datasets.length; else fromi = t.length; for (var s = fromi - 1; s >= 0; s--) { orderi = s; if (e.reverseLegend) { if (e.drawLegendOnData) orderi = t.datasets.length - s - 1; else orderi = t.length - s - 1 } if (e.drawLegendOnData) tpof = typeof t.datasets[orderi].title; else tpof = typeof t[orderi].title; if (tpof == "string") { if (e.drawLegendOnData) lgtxt = fmtChartJS(n, t.datasets[orderi].title, n.fmtLegend).trim(); else lgtxt = fmtChartJS(n, t[orderi].title, n.fmtLegend).trim(); if (lgtxt != "") { nbcols++; if (nbcols == e.nbLegendCols) { nbcols = 0; xpos = e.xFirstLegendTextPos; ypos += n.legendFontSize + n.legendSpaceBetweenTextVertical } else { xpos += e.widestLegend + n.legendSpaceBetweenTextHorizontal } r.save(); r.beginPath(); if (e.drawLegendOnData) { if (typeof t.datasets[orderi].strokeColor == "function") r.strokeStyle = t.datasets[orderi].strokeColor("STROKECOLOR", t, n, orderi, -1, 1, -1, i, r, -1, -1, -1, -1); else if (typeof t.datasets[orderi].strokeColor == "string") r.strokeStyle = t.datasets[orderi].strokeColor; else r.strokeStyle = n.defaultStrokeColor } else { if (typeof t[orderi].color == "function") r.strokeStyle = t[orderi].color("COLOR", t, n, orderi, -1, 1, t[orderi].value, i, r, 1, 1, 1, 1); else if (typeof t[orderi].color == "string") r.strokeStyle = t[orderi].color; else r.strokeStyle = n.defaultStrokeColor } if (e.legendBox) { r.lineWidth = 1; r.moveTo(xpos, ypos); r.lineTo(xpos + n.legendBlockSize, ypos); r.lineTo(xpos + n.legendBlockSize, ypos - n.legendFontSize); r.lineTo(xpos, ypos - n.legendFontSize); r.lineTo(xpos, ypos); r.closePath(); if (e.drawLegendOnData) { if (typeof t.datasets[orderi].fillColor == "function") r.fillStyle = t.datasets[orderi].fillColor("LEGENDFILLCOLOR", t, n, orderi, -1, 1, -1, i, r, xpos, ypos, xpos + n.legendBlockSize, ypos - n.legendFontSize); else if (typeof t.datasets[orderi].fillColor == "string") r.fillStyle = t.datasets[orderi].fillColor; else r.fillStyle = n.defaultFillColor } else { if (typeof t[orderi].color == "function") r.fillStyle = t[orderi].color("LEGENDFILLCOLOR", t, n, orderi, -1, 1, -1, i, r, xpos, ypos - n.legendFontSize, xpos + n.legendBlockSize, ypos); else if (typeof t[orderi].color == "string") r.fillStyle = t[orderi].color; else r.fillStyle = n.defaultFillColor } r.fill() } else { r.lineWidth = n.legendColorIndicatorStrokeWidth ? n.legendColorIndicatorStrokeWidth : n.datasetStrokeWidth; if (n.legendColorIndicatorStrokeWidth && n.legendColorIndicatorStrokeWidth > n.legendFontSize) { r.lineWidth = n.legendFontSize } r.moveTo(xpos + 2, ypos - n.legendFontSize / 2); r.lineTo(xpos + 2 + n.legendBlockSize, ypos - n.legendFontSize / 2) } r.stroke(); r.restore(); r.save(); r.beginPath(); r.font = n.legendFontStyle + " " + n.legendFontSize + "px " + n.legendFontFamily; r.fillStyle = n.legendFontColor; r.textAlign = "left"; r.textBaseline = "bottom"; r.translate(xpos + n.legendBlockSize + n.legendSpaceBetweenBoxAndText, ypos); r.fillText(lgtxt, 0, 0); r.stroke(); r.restore() } } } } if (typeof String.prototype.trim !== "function") { String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, "") } } if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (e) { "use strict"; if (this == null) { throw new TypeError } var t = Object(this); var n = t.length >>> 0; if (n === 0) { return -1 } var r = 0; if (arguments.length > 0) { r = Number(arguments[1]); if (r != r) { r = 0 } else if (r != 0 && r != Infinity && r != -Infinity) { r = (r > 0 || -1) * Math.floor(Math.abs(r)) } } if (r >= n) { return -1 } var i = r >= 0 ? r : Math.max(n - Math.abs(r), 0); for (; i < n; i++) { if (i in t && t[i] === e) { return i } } return -1 } } var charJSPersonalDefaultOptions = {}; var charJSPersonalDefaultOptionsLine = {}; var charJSPersonalDefaultOptionsRadar = {}; var charJSPersonalDefaultOptionsPolarArea = {}; var charJSPersonalDefaultOptionsPie = {}; var charJSPersonalDefaultOptionsDoughnut = {}; var charJSPersonalDefaultOptionsBar = {}; var charJSPersonalDefaultOptionsStackedBar = {}; var charJSPersonalDefaultOptionsHorizontalBar = {}; var charJSPersonalDefaultOptionsHorizontalStackedBar = {}; var cachebis = {}; CanvasRenderingContext2D.prototype.fillTextMultiLine = function (e, t, n, r, i) { var s = ("" + e).split("\n"); if (r == "middle") { n -= (s.length - 1) / 2 * i } else if (r == "bottom") { n -= (s.length - 1) * i } for (var o = 0; o < s.length; o++) { this.fillText(s[o], t, n); n += i } }; CanvasRenderingContext2D.prototype.measureTextMultiLine = function (e, t) { var n = 0; var r; var i = ("" + e).split("\n"); var s = i.length * t; for (var o = 0; o < i.length; o++) { r = this.measureText(i[o]).width; if (r > n) n = r } return { textWidth: n, textHeight: s } }; cursorDivCreated = false; bw = new checkBrowser; fromLeft = 10; fromTop = 10; if (typeof String.prototype.trim !== "function") { String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, "") } } var dynamicDisplay = new Array; var dynamicDisplayList = new Array; var jsGraphAnnotate = new Array; window.Chart = function (context) { function setting_new_chart_vars(e, t) { if (typeof e.ChartNewId === typeof undefined) { var n = new Date; var r = n.getTime(); e.ChartNewId = t + "_" + r; e._eventListeners = {} } } function reverseData(e) { e.labels = e.labels.reverse(); for (var t = 0; t < e.datasets.length; t++) { for (var n in e.datasets[t]) { if (Array.isArray(e.datasets[t][n])) { e.datasets[t][n] = e.datasets[t][n].reverse() } } } return e } function calculateOffset(e, t, n, r) { if (!e) { var i = n.steps * n.stepValue; var s = t - n.graphMin; var o = CapValue(s / i, 1, 0); return r * n.steps * o } else { return CapValue(log10(t) * r - calculateOrderOfMagnitude(n.graphMin) * r, undefined, 0) } } function animationLoop(e, t, n, r, i, s, o, u, a, f, l, c, h) { function E() { var d = e.animation ? CapValue(g(y), null, 0) : 1; if (1 * p >= 1 * CapValue(e.animationSteps, Number.MAX_VALUE, 1) || e.animation == false) d = 1; else if (d >= 1) d = .9999; if (e.animation && !(isIE() < 9 && isIE() != false) && e.clearRect) r.clearRect(i, s, o, u); dispCrossImage(r, e, a, f, l, c, false, h, d, p); dispCrossText(r, e, a, f, l, c, false, h, d, p); if (e.scaleOverlay) { n(d); t() } else { t(); n(d) } dispCrossImage(r, e, a, f, l, c, true, h, d, p); dispCrossText(r, e, a, f, l, c, true, h, d, p) } function S() { p += v; y += v * m; if (p == e.animationSteps || e.animation == false) y = 1; else if (y >= 1) y = .999; E(); if (v == -1 && p <= b) { if (typeof e.onAnimationComplete == "function") e.onAnimationComplete(r, e, h, 0, d + 1); v = 1; requestAnimFrame(S) } else if (y < e.animationStopValue) { requestAnimFrame(S) } else { if (typeof e.onAnimationComplete == "function") e.onAnimationComplete(r, e, h, 1, d + 1); if (d < e.animationCount || e.animationCount == 0) { d++; if (e.animationBackward && v == 1) { y -= m; v = -1 } else { v = 1; p = b - 1; y = w - m } window.setTimeout(S, 2e3) } } } var p = 0; var d = 1; var v = 1; if (e.animationStartValue < 0 || e.animationStartValue > 1) e.animation.StartValue = 0; if (e.animationStopValue < 0 || e.animationStopValue > 1) e.animation.StopValue = 1; if (e.animationStopValue < e.animationStartValue) e.animationStopValue = e.animationStartValue; if (isIE() < 9 && isIE() != false) e.animation = false; var m = e.animation ? 1 / CapValue(e.animationSteps, Number.MAX_VALUE, 1) : 1, g = animationOptions[e.animationEasing], y = e.animation ? 0 : 1; if (e.animation && e.animationStartValue > 0 && e.animationStartValue <= 1) { while (y < e.animationStartValue) { p++; y += m } } var b = p; var w = y; if (typeof t !== "function") t = function () { }; if (e.clearRect) requestAnimFrame(S); else S(); } function calculateScale(e, t, n, r, i, s, o) { var u, a, f, l, c, h, p, d; var v, m; if (e == 2) { v = t.logarithmic2; m = t.yAxisMinimumInterval2 } else { v = t.logarithmic; m = t.yAxisMinimumInterval } if (!v) { h = i - s; p = calculateOrderOfMagnitude(h); u = Math.floor(s / (1 * Math.pow(10, p))) * Math.pow(10, p); a = Math.ceil(i / (1 * Math.pow(10, p))) * Math.pow(10, p); if (typeof m == "number") { u = u - u % m; while (u > s) u = u - m; if (a % m > 1e-7 && a % m < m - 1e-7) { a = roundScale(t, (1 + Math.floor(a / m)) * m) } while (a < i) a = a + m } } else { var g = calculateOrderOfMagnitude(s); var y = calculateOrderOfMagnitude(i) + 1; u = Math.pow(10, g); a = Math.pow(10, y); p = y - g } f = a - u; l = Math.pow(10, p); c = Math.round(f / l); if (!v) { var b = false; while (!b && (c < r || c > n)) { if (c < r) { if (typeof m == "number") { if (l / 2 < m) b = true } if (!b) { l /= 2; c = Math.round(f / l) } } else { l *= 2; c = Math.round(f / l) } } if (typeof m == "number") { if (l < m) { l = m; c = Math.round(f / l) } if (l % m > 1e-7 && l % m < m - 1e-7) { if (2 * l % m < 1e-7 || 2 * l % m > m - 1e-7) { l = 2 * l; c = Math.round(f / l) } else { l = roundScale(t, (1 + Math.floor(l / m)) * m); c = Math.round(f / l) } } } } else { c = p } var w = []; populateLabels(1, t, o, w, c, u, a, l); return { steps: c, stepValue: l, graphMin: u, labels: w, maxValue: i } } function calculateScaleOld(e, t, n, r, i, s) { var o, u, a, f, l, c, h, p; if (!e.logarithmic) { c = r - i; h = calculateOrderOfMagnitude(c); o = Math.floor(i / (1 * Math.pow(10, h))) * Math.pow(10, h); u = Math.ceil(r / (1 * Math.pow(10, h))) * Math.pow(10, h); if (typeof e.yAxisMinimumInterval == "number") { o = o - o % e.yAxisMinimumInterval; while (o > i) o = o - e.yAxisMinimumInterval; if (u % e.yAxisMinimumInterval > 1e-7 && u % e.yAxisMinimumInterval < e.yAxisMinimumInterval - 1e-7) { u = roundScale(e, (1 + Math.floor(u / e.yAxisMinimumInterval)) * e.yAxisMinimumInterval) } while (u < r) u = u + e.yAxisMinimumInterval } } else { var d = calculateOrderOfMagnitude(i); var v = calculateOrderOfMagnitude(r) + 1; o = Math.pow(10, d); u = Math.pow(10, v); h = v - d } a = u - o; f = Math.pow(10, h); l = Math.round(a / f); if (!e.logarithmic) { var m = false; while (!m && (l < n || l > t)) { if (l < n) { if (typeof e.yAxisMinimumInterval == "number") { if (f / 2 < e.yAxisMinimumInterval) m = true } if (!m) { f /= 2; l = Math.round(a / f) } } else { f *= 2; l = Math.round(a / f) } } if (typeof e.yAxisMinimumInterval == "number") { if (f < e.yAxisMinimumInterval) { f = e.yAxisMinimumInterval; l = Math.round(a / f) } if (f % e.yAxisMinimumInterval > 1e-7 && f % e.yAxisMinimumInterval < e.yAxisMinimumInterval - 1e-7) { if (2 * f % e.yAxisMinimumInterval < 1e-7 || 2 * f % e.yAxisMinimumInterval > e.yAxisMinimumInterval - 1e-7) { f = 2 * f; l = Math.round(a / f) } else { f = roundScale(e, (1 + Math.floor(f / e.yAxisMinimumInterval)) * e.yAxisMinimumInterval); l = Math.round(a / f) } } } } else { l = h } var g = []; populateLabels(1, e, s, g, l, o, u, f); return { steps: l, stepValue: f, graphMin: o, labels: g, maxValue: r } } function roundScale(e, t) { var n = 0; var r = "" + e.yAxisMinimumInterval; if (r.indexOf(".") > 0) { n = r.substr(r.indexOf(".")).length } return Math.round(t * Math.pow(10, n)) / Math.pow(10, n) } function calculateOrderOfMagnitude(e) { return Math.floor(Math.log(e) / Math.LN10) } function populateLabels(e, t, n, r, i, s, o, u) { var a; if (e == 2) { a = t.logarithmic2; fmtYLabel = t.fmtYLabel2 } else { a = t.logarithmic; fmtYLabel = t.fmtYLabel } if (n) { if (!a) { for (var f = 0; f < i + 1; f++) { r.push(tmpl(n, { value: fmtChartJS(t, 1 * (s + u * f).toFixed(getDecimalPlaces(u)), fmtYLabel) })) } } else { var l = s; for (var f = 0; f < i + 1; f++) { r.push(tmpl(n, { value: fmtChartJS(t, 1 * l.toFixed(getDecimalPlaces(l)), fmtYLabel) })); l *= 10 } } } } function Max(e) { return Math.max.apply(Math, e) } function Min(e) { return Math.min.apply(Math, e) } function Default(e, t) { if (!e) { return t } else { return e } } function CapValue(e, t, n) { if (isNumber(t)) { if (e > t) { return t } } if (isNumber(n)) { if (e < n) { return n } } return e } function getDecimalPlaces(e) { var t; if (e % 1 != 0) { return e.toString().split(".")[1].length } else { return 0 } } function mergeChartConfig(e, t) { var n = {}; for (var r in e) { n[r] = e[r] } for (var r in t) { n[r] = t[r] } return n } function tmpl(e, t) { var n = !/\W/.test(e) ? cache[e] = cache[e] || tmpl(document.getElementById(e).innerHTML) : new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" + "with(obj){p.push('" + e.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('');"); return t ? n(t) : n } function dispCrossText(e, t, n, r, i, s, o, u, a, f) { var l, c, h, p, d, v; for (l = 0; l < t.crossText.length; l++) { if (t.crossText[l] != "" && t.crossTextOverlay[Min([l, t.crossTextOverlay.length - 1])] == o && (f == 1 && t.crossTextIter[Min([l, t.crossTextIter.length - 1])] == "first" || t.crossTextIter[Min([l, t.crossTextIter.length - 1])] == f || t.crossTextIter[Min([l, t.crossTextIter.length - 1])] == "all" || a == 1 && t.crossTextIter[Min([l, t.crossTextIter.length - 1])] == "last")) { e.save(); e.beginPath(); e.font = t.crossTextFontStyle[Min([l, t.crossTextFontStyle.length - 1])] + " " + t.crossTextFontSize[Min([l, t.crossTextFontSize.length - 1])] + "px " + t.crossTextFontFamily[Min([l, t.crossTextFontFamily.length - 1])]; e.fillStyle = t.crossTextFontColor[Min([l, t.crossTextFontColor.length - 1])]; d = t.crossTextAlign[Min([l, t.crossTextAlign.length - 1])]; v = t.crossTextBaseline[Min([l, t.crossTextBaseline.length - 1])]; h = 1 * t.crossTextPosX[Min([l, t.crossTextPosX.length - 1])]; p = 1 * t.crossTextPosY[Min([l, t.crossTextPosY.length - 1])]; switch (1 * t.crossTextRelativePosX[Min([l, t.crossTextRelativePosX.length - 1])]) { case 0: if (d == "default") d = "left"; break; case 1: h += i; if (d == "default") d = "right"; break; case 2: h += n; if (d == "default") d = "center"; break; case -2: h += context.canvas.width / 2; if (d == "default") d = "center"; break; case 3: h += h + 2 * n - i; if (d == "default") d = "left"; break; case 4: h += context.canvas.width; if (d == "default") d = "right"; break; default: h += n; if (d == "default") d = "center"; break } switch (1 * t.crossTextRelativePosY[Min([l, t.crossTextRelativePosY.length - 1])]) { case 0: if (v == "default") v = "top"; break; case 3: p += s; if (v == "default") v = "top"; break; case 2: p += r; if (v == "default") v = "middle"; break; case -2: p += context.canvas.height / 2; if (v == "default") v = "middle"; break; case 1: p += p + 2 * r - s; if (v == "default") v = "bottom"; break; case 4: p += context.canvas.height; if (v == "default") v = "bottom"; break; default: p += r; if (v == "default") v = "middle"; break } e.textAlign = d; e.textBaseline = v; e.translate(1 * h, 1 * p); e.rotate(Math.PI * t.crossTextAngle[Min([l, t.crossTextAngle.length - 1])] / 180); if (t.crossText[l].substring(0, 1) == "%") { if (typeof t.crossTextFunction == "function") c = t.crossTextFunction(l, t.crossText[l], e, t, n, r, i, s, o, u, a) } else c = t.crossText[l]; e.fillTextMultiLine(c, 0, 0, e.textBaseline, t.crossTextFontSize[Min([l, t.crossTextFontSize.length - 1])]); e.stroke(); e.restore() } } } function dispCrossImage(e, t, n, r, i, s, o, u, a, f) { var l, c, h, p, d, v; for (l = 0; l < t.crossImage.length; l++) { if (typeof t.crossImage[l] != "undefined" && t.crossImageOverlay[Min([l, t.crossImageOverlay.length - 1])] == o && (f == -1 && t.crossImageIter[Min([l, t.crossImageIter.length - 1])] == "background" || f == 1 && t.crossImageIter[Min([l, t.crossImageIter.length - 1])] == "first" || t.crossImageIter[Min([l, t.crossImageIter.length - 1])] == f || f != -1 && t.crossImageIter[Min([l, t.crossImageIter.length - 1])] == "all" || a == 1 && t.crossImageIter[Min([l, t.crossImageIter.length - 1])] == "last")) { e.save(); e.beginPath(); d = t.crossImageAlign[Min([l, t.crossImageAlign.length - 1])]; v = t.crossImageBaseline[Min([l, t.crossImageBaseline.length - 1])]; h = 1 * t.crossImagePosX[Min([l, t.crossImagePosX.length - 1])]; p = 1 * t.crossImagePosY[Min([l, t.crossImagePosY.length - 1])]; switch (1 * t.crossImageRelativePosX[Min([l, t.crossImageRelativePosX.length - 1])]) { case 0: if (d == "default") d = "left"; break; case 1: h += i; if (d == "default") d = "right"; break; case 2: h += n; if (d == "default") d = "center"; break; case -2: h += context.canvas.width / 2; if (d == "default") d = "center"; break; case 3: h += h + 2 * n - i; if (d == "default") d = "left"; break; case 4: h += context.canvas.width; if (d == "default") d = "right"; break; default: h += n; if (d == "default") d = "center"; break } switch (1 * t.crossImageRelativePosY[Min([l, t.crossImageRelativePosY.length - 1])]) { case 0: if (v == "default") v = "top"; break; case 3: p += s; if (v == "default") v = "top"; break; case 2: p += r; if (v == "default") v = "middle"; break; case -2: p += context.canvas.height / 2; if (v == "default") v = "middle"; break; case 1: p += p + 2 * r - s; if (v == "default") v = "bottom"; break; case 4: p += context.canvas.height; if (v == "default") v = "bottom"; break; default: p += r; if (v == "default") v = "middle"; break } var m = t.crossImage[l].width; switch (d) { case "left": break; case "right": h -= m; break; case "center": h -= m / 2; break; default: break } var g = t.crossImage[l].height; switch (v) { case "top": break; case "bottom": p -= g; break; case "middle": p -= g / 2; break; default: break } e.translate(1 * h, 1 * p); e.rotate(Math.PI * t.crossImageAngle[Min([l, t.crossImageAngle.length - 1])] / 180); e.drawImage(t.crossImage[l], 0, 0); e.restore() } } } function setMeasures(e, t, n, r, i, s, o, u, a, f, l, c, h) { if (t.canvasBackgroundColor != "none") n.canvas.style.background = t.canvasBackgroundColor; var p = 0; var d = 0; var v = 0; var m = 0; var g = 0; var y = 0; var b = 0; var w = 0; var E = 0; var S = 0; var x = 0; var T = 0; var N = 0; var C = 0; var k = 0; var L = 0; var A = 0; var O = 0; var M = 0; var _ = 0; var D = 0; var P = 0; var H = 0; var B = 0; var j = 1; var F = 1; var I = 0; var q = 1; var R = 0; var U = 1; var z = 0; var W = 0; var X = 0; var V = 0; var $ = 0; var J = 0; if (t.canvasBorders) p = t.canvasBordersWidth; if (f) { n.font = t.scaleFontStyle + " " + t.scaleFontSize + "px " + t.scaleFontFamily; for (var K = 0; K < e.labels.length; K++) { var Q = n.measureTextMultiLine(fmtChartJS(t, e.labels[K], t.fmtXLabel), t.scaleFontSize); j = Q.textWidth > j ? Q.textWidth : j; F = Q.textHeight > F ? Q.textHeight : F } if (j < t.xScaleLabelsMinimumWidth) { j = t.xScaleLabelsMinimumWidth } } if (f) { I = 1; if (s != null && s != "nihil") { n.font = t.scaleFontStyle + " " + t.scaleFontSize + "px " + t.scaleFontFamily; for (var K = s.length - 1; K >= 0; K--) { if (typeof s[K] == "string") { if (s[K].trim() != "") { var Q = n.measureTextMultiLine(fmtChartJS(t, s[K], t.fmtYLabel), t.scaleFontSize); I = Q.textWidth > I ? Q.textWidth : I; q = Q.textHeight > q ? Q.textHeight : q } } } } if (I < t.yScaleLabelsMinimumWidth) { I = t.yScaleLabelsMinimumWidth } R = 1; if (o != null && t.yAxisRight) { n.font = t.scaleFontStyle + " " + t.scaleFontSize + "px " + t.scaleFontFamily; for (var K = o.length - 1; K >= 0; K--) { if (typeof o[K] == "string") { if (o[K].trim() != "") { var Q = n.measureTextMultiLine(fmtChartJS(t, o[K], t.fmtYLabel2), t.scaleFontSize); R = Q.textWidth > R ? Q.textWidth : R; U = Q.textHeight > U ? Q.textHeight : U } } } } else { R = I } if (R < t.yScaleLabelsMinimumWidth) { R = t.yScaleLabelsMinimumWidth } } z = p + t.spaceLeft; W = p + t.spaceRight; if (f) { if (typeof t.yAxisLabel != "undefined") { if (t.yAxisLabel.trim() != "") { _ = t.yAxisFontSize + t.yAxisLabelSpaceLeft + t.yAxisLabelSpaceRight; D = p + t.spaceLeft + t.yAxisLabelSpaceLeft + t.yAxisFontSize; P = i - p - t.spaceRight - t.yAxisLabelSpaceLeft - t.yAxisFontSize } } if (t.yAxisLeft) { if (a == false) z = p + t.spaceLeft + _ + I + t.yAxisSpaceLeft + t.yAxisSpaceRight; else z = p + t.spaceLeft + _ + j + t.yAxisSpaceLeft + t.yAxisSpaceRight } if (t.yAxisRight) { if (a == false) W = p + t.spaceRight + _ + R + t.yAxisSpaceLeft + t.yAxisSpaceRight; else W = p + t.spaceRight + _ + j + t.yAxisSpaceLeft + t.yAxisSpaceRight } } availableWidth = i - z - W; if (t.graphTitle.trim() != "") { v = t.graphTitleFontSize + t.graphTitleSpaceBefore + t.graphTitleSpaceAfter; m = p + t.spaceTop + v - t.graphTitleSpaceAfter } if (t.graphSubTitle.trim() != "") { g = t.graphSubTitleFontSize + t.graphSubTitleSpaceBefore + t.graphSubTitleSpaceAfter; y = p + t.spaceTop + v + g - t.graphSubTitleSpaceAfter } if (f) { if (t.yAxisUnit.trim() != "") { E = t.yAxisUnitFontSize + t.yAxisUnitSpaceBefore + t.yAxisUnitSpaceAfter; S = p + t.spaceTop + v + g + E - t.yAxisUnitSpaceAfter } } topNotUsableSize = p + t.spaceTop + v + g + E + t.graphSpaceBefore; if (typeof t.footNote != "undefined") { if (t.footNote.trim() != "") { b = t.footNoteFontSize + t.footNoteSpaceBefore + t.footNoteSpaceAfter; w = r - t.spaceBottom - p - t.footNoteSpaceAfter } } if (f) { if (typeof t.xAxisLabel != "undefined") { if (t.xAxisLabel.trim() != "") { H = t.xAxisFontSize + t.xAxisLabelSpaceBefore + t.xAxisLabelSpaceAfter; d = r - p - t.spaceBottom - b - t.xAxisLabelSpaceAfter } } } bottomNotUsableHeightWithoutXLabels = p + t.spaceBottom + b + H + t.graphSpaceAfter; if (typeof t.legend != "undefined") { if (t.legend == true) { n.font = t.legendFontStyle + " " + t.legendFontSize + "px " + t.legendFontFamily; if (l) { for (var K = e.datasets.length - 1; K >= 0; K--) { if (typeof e.datasets[K].title == "string") { if (e.datasets[K].title.trim() != "") { T++; var G = n.measureText(fmtChartJS(t, e.datasets[K].title, t.fmtLegend)).width; x = G > x ? G : x } } } } else { for (var K = e.length - 1; K >= 0; K--) { if (typeof e[K].title == "string") { if (e[K].title.trim() != "") { T++; var G = n.measureText(fmtChartJS(t, e[K].title, t.fmtLegend)).width; x = G > x ? G : x } } } } if (T > 1 || T == 1 && t.showSingleLegend) { x += t.legendBlockSize + t.legendSpaceBetweenBoxAndText; if (t.legendPosY == 1 || t.legendPosY == 2 || t.legendPosY == 3) { availableLegendWidth = availableWidth - t.legendSpaceLeftText - t.legendSpaceRightText } else { availableLegendWidth = i - t.spaceLeft - t.spaceRight - 2 * p - t.legendSpaceLeftText - t.legendSpaceRightText } if (t.legendBorders == true) availableLegendWidth -= 2 * t.legendBordersWidth - t.legendBordersSpaceLeft - t.legendBordersSpaceRight; maxLegendOnLine = Min([Math.floor((availableLegendWidth + t.legendSpaceBetweenTextHorizontal) / (x + t.legendSpaceBetweenTextHorizontal)), t.maxLegendCols]); N = Math.ceil(T / maxLegendOnLine); C = Math.ceil(T / N); var Y = N * (t.legendFontSize + t.legendSpaceBetweenTextVertical) - t.legendSpaceBetweenTextVertical + t.legendSpaceBeforeText + t.legendSpaceAfterText; if (t.legendBorders == true) { } switch (t.legendPosY) { case 0: L = t.spaceLeft + (i - t.spaceLeft - t.spaceRight - C * (x + t.legendSpaceBetweenTextHorizontal) + t.legendSpaceBetweenTextHorizontal) / 2; k = Y; if (t.legendBorders == true) { M = topNotUsableSize + t.legendBordersSpaceBefore + t.legendBordersWidth / 2; A = M + t.legendBordersWidth / 2 + t.legendSpaceBeforeText + t.legendFontSize; k += 2 * t.legendBordersWidth + t.legendBordersSpaceBefore + t.legendBordersSpaceAfter; O = Math.floor(L - t.legendSpaceLeftText - t.legendBordersWidth / 2); J = Math.ceil(k - t.legendBordersWidth) - t.legendBordersSpaceBefore - t.legendBordersSpaceAfter; $ = Math.ceil(C * (x + t.legendSpaceBetweenTextHorizontal)) - t.legendSpaceBetweenTextHorizontal + t.legendBordersWidth + t.legendSpaceRightText + t.legendSpaceLeftText } else { A = topNotUsableSize + t.legendBordersSpaceBefore + t.legendBordersWidth / 2 } if (E > 0) { S += k; if (t.legendBorders == true) M -= E; A -= E } topNotUsableSize += k; break; case 1: k = Y; L = t.spaceLeft + (i - t.spaceLeft - t.spaceRight - C * (x + t.legendSpaceBetweenTextHorizontal) + t.legendSpaceBetweenTextHorizontal) / 2; A = topNotUsableSize + t.legendSpaceBeforeText + t.legendFontSize; if (t.legendBorders == true) { A += t.legendBordersSpaceBefore + t.legendBordersWidth; M = A - t.legendSpaceBeforeText - t.legendFontSize - t.legendBordersWidth / 2; k += 2 * t.legendBordersWidth + t.legendBordersSpaceBefore + t.legendBordersSpaceAfter; O = Math.floor(L - t.legendSpaceLeftText - t.legendBordersWidth / 2); J = Math.ceil(k - t.legendBordersWidth) - t.legendBordersSpaceBefore - t.legendBordersSpaceAfter; $ = Math.ceil(C * (x + t.legendSpaceBetweenTextHorizontal)) - t.legendSpaceBetweenTextHorizontal + t.legendBordersWidth + t.legendSpaceRightText + t.legendSpaceLeftText } break; case 2: k = Y; L = t.spaceLeft + (i - t.spaceLeft - t.spaceRight - C * (x + t.legendSpaceBetweenTextHorizontal) + t.legendSpaceBetweenTextHorizontal) / 2; A = topNotUsableSize + (r - topNotUsableSize - bottomNotUsableHeightWithoutXLabels - k) / 2 + t.legendSpaceBeforeText + t.legendFontSize; if (t.legendBorders == true) { A += t.legendBordersSpaceBefore - t.legendBordersSpaceAfter; M = A - t.legendSpaceBeforeText - t.legendFontSize - t.legendBordersWidth / 2; k += 2 * t.legendBordersWidth + t.legendBordersSpaceBefore + t.legendBordersSpaceAfter; O = Math.floor(L - t.legendSpaceLeftText - t.legendBordersWidth / 2); J = Math.ceil(k - t.legendBordersWidth) - t.legendBordersSpaceBefore - t.legendBordersSpaceAfter; $ = Math.ceil(C * (x + t.legendSpaceBetweenTextHorizontal)) - t.legendSpaceBetweenTextHorizontal + t.legendBordersWidth + t.legendSpaceRightText + t.legendSpaceLeftText } break; case 3: k = Y; L = t.spaceLeft + (i - t.spaceLeft - t.spaceRight - C * (x + t.legendSpaceBetweenTextHorizontal) + t.legendSpaceBetweenTextHorizontal) / 2; availableHeight = r - topNotUsableSize - bottomNotUsableHeightWithoutXLabels; A = topNotUsableSize + availableHeight - k + t.legendSpaceBeforeText + t.legendFontSize; if (t.legendBorders == true) { A -= t.legendBordersSpaceAfter + t.legendBordersWidth; M = A - t.legendSpaceBeforeText - t.legendFontSize - t.legendBordersWidth / 2; k += 2 * t.legendBordersWidth + t.legendBordersSpaceBefore + t.legendBordersSpaceAfter; O = Math.floor(L - t.legendSpaceLeftText - t.legendBordersWidth / 2); J = Math.ceil(k - t.legendBordersWidth) - t.legendBordersSpaceBefore - t.legendBordersSpaceAfter; $ = Math.ceil(C * (x + t.legendSpaceBetweenTextHorizontal)) - t.legendSpaceBetweenTextHorizontal + t.legendBordersWidth + t.legendSpaceRightText + t.legendSpaceLeftText } break; default: k = Y; A = r - p - t.spaceBottom - b - k + t.legendSpaceBeforeText + t.legendFontSize; L = t.spaceLeft + (i - t.spaceLeft - t.spaceRight - C * (x + t.legendSpaceBetweenTextHorizontal) + t.legendSpaceBetweenTextHorizontal) / 2; if (t.legendBorders == true) { k += 2 * t.legendBordersWidth + t.legendBordersSpaceBefore + t.legendBordersSpaceAfter; A -= t.legendBordersWidth + t.legendBordersSpaceAfter; M = Math.floor(r - p - t.spaceBottom - b - k + t.legendBordersWidth / 2 + t.legendBordersSpaceBefore); O = Math.floor(L - t.legendSpaceLeftText - t.legendBordersWidth / 2); J = Math.ceil(k - t.legendBordersWidth) - t.legendBordersSpaceBefore - t.legendBordersSpaceAfter; $ = Math.ceil(C * (x + t.legendSpaceBetweenTextHorizontal)) - t.legendSpaceBetweenTextHorizontal + t.legendBordersWidth + t.legendSpaceRightText + t.legendSpaceLeftText } d -= k; bottomNotUsableHeightWithoutXLabels += k; break } var Z = t.legendSpaceRightText + C * (x + t.legendSpaceBetweenTextHorizontal) - t.legendSpaceBetweenTextHorizontal + t.legendSpaceLeftText; if (t.legendBorders == true) { Z += 2 * t.legendBordersWidth + t.legendBordersSpaceLeft + t.legendBordersSpaceRight } switch (t.legendPosX) { case 0: L = t.spaceLeft + t.canvasBorders * t.canvasBordersWidth + t.legendSpaceLeftText; if (t.legendBorders == true) { L += t.legendBordersWidth + t.legendBordersSpaceLeft; O = t.spaceLeft + t.canvasBorders * t.canvasBordersWidth + t.legendBordersSpaceLeft } if (t.legendPosY >= 1 && t.legendPosY <= 3) { z += Z; D += Z } break; case 1: L = z + t.legendSpaceLeftText; if (t.legendBorders == true) { O = L; L += t.legendBordersWidth + t.legendBordersSpaceLeft } break; case 2: L = z + (i - W - z) / 2 - (t.legendSpaceLeftText - t.legendSpaceRightText) - (C * (x + t.legendSpaceBetweenTextHorizontal) - t.legendSpaceBetweenTextHorizontal) / 2; if (t.legendBorders == true) { L -= t.legendBordersWidth + t.legendBordersSpaceRight; O = L - t.legendBordersWidth / 2 - t.legendSpaceLeftText } break; case 3: L = i - W - t.legendSpaceRightText - C * (x + t.legendSpaceBetweenTextHorizontal) + t.legendSpaceBetweenTextHorizontal / 2; if (t.legendBorders == true) { L -= t.legendBordersWidth + t.legendBordersSpaceRight; O = L - t.legendBordersWidth / 2 - t.legendSpaceLeftText } break; case 4: L = i - t.spaceRight - t.canvasBorders * t.canvasBordersWidth - t.legendSpaceRightText - C * (x + t.legendSpaceBetweenTextHorizontal) + t.legendSpaceBetweenTextHorizontal / 2; if (t.legendBorders == true) { L -= t.legendBordersWidth + t.legendBordersSpaceRight; O = L - t.legendBordersSpaceLeft - t.legendBordersWidth / 2 } if (t.legendPosY >= 1 && t.legendPosY <= 3) { W += Z; P -= Z } break; default: break } if (t.legendBorders == true) { M += t.legendYPadding; O += t.legendXPadding } A += t.legendYPadding; L += t.legendXPadding } } } xLabelWidth = 0; bottomNotUsableHeightWithXLabels = bottomNotUsableHeightWithoutXLabels; if (f && (t.xAxisBottom || t.xAxisTop)) { if (a == false) { var et = j; var tt = F; nblab = e.labels.length } else { var et = I; var tt = q; nblab = s.length } if (t.rotateLabels == "smart") { X = 0; if ((availableWidth + t.xAxisSpaceBetweenLabels) / nblab < et + t.xAxisSpaceBetweenLabels) { X = 45; if (availableWidth / nblab < Math.abs(Math.cos(X * Math.PI / 180) * et)) { X = 90 } } } else { X = t.rotateLabels; if (X < 0) X = 0; if (X > 180) X = 180 } if (X > 90) X += 180; B = Math.abs(Math.sin(X * Math.PI / 180) * et) + Math.abs(Math.sin((X + 90) * Math.PI / 180) * tt) + t.xAxisSpaceBefore + t.xAxisSpaceAfter; V = r - p - t.spaceBottom - b - H - (B - t.xAxisSpaceBefore) - t.graphSpaceAfter; xLabelWidth = Math.abs(Math.cos(X * Math.PI / 180) * et) + Math.abs(Math.cos((X + 90) * Math.PI / 180) * tt); z = Max([z, p + t.spaceLeft + xLabelWidth / 2]); W = Max([W, p + t.spaceRight + xLabelWidth / 2]); availableWidth = i - z - W; if (t.legend && t.xAxisBottom && t.legendPosY == 4) { V -= k } bottomNotUsableHeightWithXLabels = bottomNotUsableHeightWithoutXLabels + B } else { availableWidth = i - z - W } availableHeight = r - topNotUsableSize - bottomNotUsableHeightWithXLabels; dispCrossImage(n, t, i / 2, r / 2, i / 2, r / 2, false, e, -1, -1); if (s != "nihil") { if (p > 0) { n.save(); n.beginPath(); n.lineWidth = 2 * p; n.strokeStyle = t.canvasBordersColor; n.moveTo(0, 0); n.lineTo(0, r); n.lineTo(i, r); n.lineTo(i, 0); n.lineTo(0, 0); n.stroke(); n.restore() } if (v > 0) { n.save(); n.beginPath(); n.font = t.graphTitleFontStyle + " " + t.graphTitleFontSize + "px " + t.graphTitleFontFamily; n.fillStyle = t.graphTitleFontColor; n.textAlign = "center"; n.textBaseline = "bottom"; n.translate(t.spaceLeft + (i - t.spaceLeft - t.spaceRight) / 2, m); n.fillText(t.graphTitle, 0, 0); n.stroke(); n.restore() } if (g > 0) { n.save(); n.beginPath(); n.font = t.graphSubTitleFontStyle + " " + t.graphSubTitleFontSize + "px " + t.graphSubTitleFontFamily; n.fillStyle = t.graphSubTitleFontColor; n.textAlign = "center"; n.textBaseline = "bottom"; n.translate(t.spaceLeft + (i - t.spaceLeft - t.spaceRight) / 2, y); n.fillText(t.graphSubTitle, 0, 0); n.stroke(); n.restore() } if (E > 0) { if (t.yAxisLeft) { n.save(); n.beginPath(); n.font = t.yAxisUnitFontStyle + " " + t.yAxisUnitFontSize + "px " + t.yAxisUnitFontFamily; n.fillStyle = t.yAxisUnitFontColor; n.textAlign = "center"; n.textBaseline = "bottom"; n.translate(z, S); n.fillText(t.yAxisUnit, 0, 0); n.stroke(); n.restore() } if (t.yAxisRight) { if (t.yAxisUnit2 == "") t.yAxisUnit2 = t.yAxisUnit; n.save(); n.beginPath(); n.font = t.yAxisUnitFontStyle + " " + t.yAxisUnitFontSize + "px " + t.yAxisUnitFontFamily; n.fillStyle = t.yAxisUnitFontColor; n.textAlign = "center"; n.textBaseline = "bottom"; n.translate(i - W, S); n.fillText(t.yAxisUnit2, 0, 0); n.stroke(); n.restore() } } if (_ > 0) { if (t.yAxisLeft) { n.save(); n.beginPath(); n.font = t.yAxisFontStyle + " " + t.yAxisFontSize + "px " + t.yAxisFontFamily; n.fillStyle = t.yAxisFontColor; n.textAlign = "center"; n.textBaseline = "bottom"; n.translate(D, topNotUsableSize + availableHeight / 2); n.rotate(-(90 * (Math.PI / 180))); n.fillText(t.yAxisLabel, 0, 0); n.stroke(); n.restore() } if (t.yAxisRight) { if (t.yAxisLabel2 == "") t.yAxisLabel2 = t.yAxisLabel; n.save(); n.beginPath(); n.font = t.yAxisFontStyle + " " + t.yAxisFontSize + "px " + t.yAxisFontFamily; n.fillStyle = t.yAxisFontColor; n.textAlign = "center"; n.textBaseline = "bottom"; n.translate(P, topNotUsableSize + availableHeight / 2); n.rotate(+(90 * (Math.PI / 180))); n.fillText(t.yAxisLabel2, 0, 0); n.stroke(); n.restore() } } if (H > 0) { if (t.xAxisBottom) { n.save(); n.beginPath(); n.font = t.xAxisFontStyle + " " + t.xAxisFontSize + "px " + t.xAxisFontFamily; n.fillStyle = t.xAxisFontColor; n.textAlign = "center"; n.textBaseline = "bottom"; n.translate(z + availableWidth / 2, d); n.fillText(t.xAxisLabel, 0, 0); n.stroke(); n.restore() } } if (T > 1 || T == 1 && t.showSingleLegend) { var nt = { dispLegend: true, xLegendBorderPos: O, yLegendBorderPos: M, legendBorderWidth: $, legendBorderHeight: J, nbLegendCols: C, xFirstLegendTextPos: L, yFirstLegendTextPos: A, drawLegendOnData: l, reverseLegend: u, legendBox: c, widestLegend: x }; if (t.legendPosY == 0 || t.legendPosY == 4) { drawLegend(nt, e, t, n, h); var nt = { dispLegend: false } } } else { var nt = { dispLegend: false } } if (t.footNote.trim() != "") { n.save(); n.font = t.footNoteFontStyle + " " + t.footNoteFontSize + "px " + t.footNoteFontFamily; n.fillStyle = t.footNoteFontColor; n.textAlign = "center"; n.textBaseline = "bottom"; n.translate(z + availableWidth / 2, w); n.fillText(t.footNote, 0, 0); n.stroke(); n.restore() } } clrx = z; clrwidth = availableWidth; clry = topNotUsableSize; clrheight = availableHeight; return { leftNotUsableSize: z, rightNotUsableSize: W, availableWidth: availableWidth, topNotUsableSize: topNotUsableSize, bottomNotUsableHeightWithoutXLabels: bottomNotUsableHeightWithoutXLabels, bottomNotUsableHeightWithXLabels: bottomNotUsableHeightWithXLabels, availableHeight: availableHeight, widestXLabel: j, highestXLabel: F, widestYLabel: I, widestYLabel2: R, highestYLabel: q, rotateLabels: X, xLabelPos: V, clrx: clrx, clry: clry, clrwidth: clrwidth, clrheight: clrheight, legendMsr: nt } } function drawLinesDataset(e, n, r, i, s, o, u) { function P(e, t) { return a - p - m.mainVal * (calculateOffset(v, r.datasets[e].data[t], d, h) - p) } function H(e, t, n) { if (typeof n.datasets[e].xPos == "object") { if (!(typeof n.datasets[e].xPos[Math.floor(t + 1e-4)] == "undefined")) { var r = l * c; var i = typeof n.xBegin != "undefined" ? n.xBegin : 1 * n.labels[0]; var s = typeof n.xEnd != "undefined" ? n.xEnd : 1 * n.labels[n.labels.length - 1]; if (s <= i) s = i + 100; if (1 * n.datasets[e].xPos[Math.floor(t + 1e-4)] >= i && n.datasets[e].xPos[Math.floor(t + 1e-4)] <= s) { var o = f + r * ((1 * n.datasets[e].xPos[Math.floor(t + 1e-4)] - i) / (s - i)); var u = o; if (Math.abs(t - Math.floor(t + 1e-4)) > 1e-4) { var a = t + Math.floor(t + 1e-4); var u = H(e, Math.ceil(t - 1e-4), n) } return o + (t - Math.floor(t + 1e-4)) * (u - o) } } } return f + l * t } var a = u.xAxisPosY; var f = u.yAxisPosX; var l = u.valueHop; var c = u.nbValueHop; var h = u.scaleHop; var p = u.zeroY; var d = u.calculatedScale; var v = u.logarithmic; var m = animationCorrection(n, r, i, 0, 0, 0); var g = new Array; var y = new Array; var b = new Array; var w = new Array; for (var E = 0; E < r.datasets.length; E++) { b[E] = -999999999; w[E] = 999999999; if (e == 2 && r.datasets[E].axis == 2 || e != 2 && r.datasets[E].axis != 2) { for (var S = 0; S < r.datasets[E].data.length; S++) { g[S] = 0; y[S] = -999999999 } } } m.mainVal = 1; for (var E = 0; E < r.datasets.length; E++) { if (e == 2 && r.datasets[E].axis == 2 || e != 2 && r.datasets[E].axis != 2) { for (var S = 0; S < r.datasets[E].data.length; S++) { g[S] += r.datasets[E].data[S]; y[S] = Max([y[S], r.datasets[E].data[S]]); b[E] = Max([b[E], P(E, S)]); w[E] = Min([w[E], P(E, S)]) } } } for (var E = 0; E < r.datasets.length; E++) { if (e == 2 && r.datasets[E].axis == 2 || e != 2 && r.datasets[E].axis != 2) { var x = -1; var T = -1; if (typeof r.datasets[E].strokeColor == "function") { s.strokeStyle = r.datasets[E].strokeColor("STROKECOLOR", r, i, E, -1, n, -1, "Line", s, f, b[E], f + l * (r.datasets[E].data.length - 1), b[E] - (i.animationLeftToRight ? 1 : 1 * m.mainVal) * (b[E] - w[E])) } else if (typeof r.datasets[E].strokeColor == "string") { s.strokeStyle = r.datasets[E].strokeColor } else s.strokeStyle = i.defaultStrokeColor; s.lineWidth = i.datasetStrokeWidth; s.beginPath(); var N; var C; N = 0; prevnotempty = 0; for (var S = 0; S < r.datasets[E].data.length; S++) { var k = H(E, S, r); m = animationCorrection(n, r, i, E, S, 0); if (m.mainVal == 0 && N > 0) { s.stroke(); s.strokeStyle = "rgba(0,0,0,0)"; s.lineTo(C, a - p) } N = m.mainVal; if (m.mainVal >= 1) { if (typeof r.datasets[E].title == "string") lgtxt = r.datasets[E].title.trim(); else lgtxt = "" } if (!(typeof r.datasets[E].data[S] == "undefined")) { C = H(E, S, r); if (x == -1) { s.moveTo(k, P(E, S)); T = S } else { if (i.bezierCurve) { s.bezierCurveTo(H(E, S - (S - x) / 2, r), P(E, x), H(E, S - (S - x) / 2, r), P(E, S), H(E, S, r), P(E, S)) } else { s.lineTo(H(E, S, r), P(E, S)) } } if (typeof r.datasets[E].data[S + 1] !== "undefined" || true == i.extrapolateMissingData) { if (m.subVal > 0) { nxtnotmiss = -1; for (t = S + 1; t < r.datasets[E].data["length"] && nxtnotmiss == -1; t++) { if (!(typeof r.datasets[E].data[t] == "undefined")) nxtnotmiss = t } if (nxtnotmiss != -1) { C = H(E, S + m.subVal, r); if (i.bezierCurve) { s.bezierCurveTo(H(E, S + m.subVal / 2, r), P(E, S), H(E, S + m.subVal / 2, r), P(E, nxtnotmiss), H(E, S + m.subVal, r), P(E, nxtnotmiss)) } else { s.lineTo(H(E, S + m.subVal, r), P(E, S + 1)) } } } x = S; if (n >= 1) { if (E == 0) divprev = r.datasets[E].data[S]; else divprev = r.datasets[E].data[S] - r.datasets[E - 1].data[S]; if (E == r.datasets.length - 1) divnext = r.datasets[E].data[S]; else divnext = r.datasets[E].data[S] - r.datasets[E + 1].data[S]; lgtxt2 = ""; if (typeof r.datasets[E].xPos != "undefined") { if (!(typeof r.datasets[E].xPos[S] == "undefined")) lgtxt2 = r.datasets[E].xPos[S] } if (lgtxt2 == "" && !(typeof r.labels[S] == "undefined")) lgtxt2 = r.labels[S]; if (typeof lgtxt2 == "string") lgtxt2 = lgtxt2.trim(); jsGraphAnnotate[s.ChartNewId][jsGraphAnnotate[s.ChartNewId].length] = ["POINT", H(E, S, r), P(E, S), lgtxt, lgtxt2, 1 * r.datasets[E].data[S], divprev, divnext, y[S], g[S], E, S]; if (i.inGraphDataShow) { s.save(); s.textAlign = i.inGraphDataAlign; s.textBaseline = i.inGraphDataVAlign; s.font = i.inGraphDataFontStyle + " " + i.inGraphDataFontSize + "px " + i.inGraphDataFontFamily; s.fillStyle = i.inGraphDataFontColor; var L = f + l * D, A = a - m.mainVal * calculateOffset(v, r.datasets[E].data[S], d, h), O = i.inGraphDataPaddingX, M = i.inGraphDataPaddingY; var _ = tmplbis(i.inGraphDataTmpl, { config: i, v1: fmtChartJS(i, lgtxt, i.fmtV1), v2: fmtChartJS(i, lgtxt2, i.fmtV2), v3: fmtChartJS(i, 1 * r.datasets[E].data[S], i.fmtV3), v4: fmtChartJS(i, divprev, i.fmtV4), v5: fmtChartJS(i, divnext, i.fmtV5), v6: fmtChartJS(i, y[S], i.fmtV6), v7: fmtChartJS(i, g[S], i.fmtV7), v8: roundToWithThousands(i, fmtChartJS(i, 100 * r.datasets[E].data[S] / g[S], i.fmtV8), i.roundPct), v9: fmtChartJS(i, f + l * D, i.fmtV9), v10: fmtChartJS(i, a - calculateOffset(v, r.datasets[E].data[S], d, h), i.fmtV10), v11: fmtChartJS(i, E, i.fmtV11), v12: fmtChartJS(i, S, i.fmtV12), data: r }); s.translate(H(E, S, r) + O, P(E, S) - M); s.rotate(i.inGraphDataRotate * (Math.PI / 180)); s.fillTextMultiLine(_, 0, 0, s.textBaseline, i.inGraphDataFontSize); s.restore() } } } } else { if (false == i.extrapolateMissingData) { s.stroke(); if (i.datasetFill) { s.lineTo(C, a - p); s.lineTo(H(E, T, r), a - p); s.lineTo(H(E, T, r), P(E, T)); s.closePath(); if (typeof r.datasets[E].fillColor == "function") s.fillStyle = r.datasets[E].fillColor("FILLCOLOR", r, i, E, -1, m.mainVal, -1, "Line", s, f, b[E], f + l * (r.datasets[E].data.length - 1), b[E] - (i.animationLeftToRight ? 1 : 1 * m.mainVal) * (b[E] - w[E])); else if (typeof r.datasets[E].fillColor == "string") s.fillStyle = r.datasets[E].fillColor; else s.fillStyle = i.defaultFillColor; s.fill() } s.beginPath(); x = -1; T = -1; N = 0; prevnotempty = 0 } else { if (m.subVal > 0) { nxtnotmiss = -1; for (t = S + 1; t < r.datasets[E].data["length"] && nxtnotmiss == -1; t++) { if (!(typeof r.datasets[E].data[t] == "undefined")) nxtnotmiss = t } if (typeof r.datasets[E].data[S] !== "undefined" || true == i.extrapolateMissingData) { if (nxtnotmiss != -1) { C = H(E, S + m.subVal, r); if (i.bezierCurve) { s.bezierCurveTo(H(E, x + (S + m.subVal - x) / 2, r), P(E, x), H(E, x + (S + m.subVal - x) / 2, r), P(E, nxtnotmiss), H(E, S + m.subVal, r), P(E, nxtnotmiss)) } else { s.lineTo(H(E, S + m.subVal, r), P(E, S + 1)) } } } } } } } s.stroke(); if (i.datasetFill) { s.lineTo(C, a - p); s.lineTo(H(E, T, r), a - p); s.lineTo(H(E, T, r), P(E, T)); s.closePath(); if (typeof r.datasets[E].fillColor == "function") { s.fillStyle = r.datasets[E].fillColor("FILLCOLOR", r, i, E, -1, m.mainVal, -1, "Line", s, f, b[E], f + l * (r.datasets[E].data.length - 1), b[E] - (i.animationLeftToRight ? 1 : 1 * m.mainVal) * (b[E] - w[E])) } else if (typeof r.datasets[E].fillColor == "string") s.fillStyle = r.datasets[E].fillColor; else s.fillStyle = i.defaultFillColor; s.fill() } else { s.closePath() } if (i.pointDot) { if (typeof r.datasets[E].pointColor == "function") s.fillStyle = r.datasets[E].pointColor("POINTCOLOR", r, i, E, -1, n, -1, "Line", s, f, b[E], f + l * (r.datasets[E].data.length - 1), b[E] - (i.animationLeftToRight ? 1 : 1 * m.mainVal) * (b[E] - w[E])); else s.fillStyle = r.datasets[E].pointColor; if (typeof r.datasets[E].pointStrokeColor == "function") s.strokeStyle = r.datasets[E].pointStrokeColor("POINTSTROKECOLOR", r, i, E, -1, n, -1, "Line", s, f, b[E], f + l * (r.datasets[E].data.length - 1), b[E] - (i.animationLeftToRight ? 1 : 1 * m.mainVal) * (b[E] - w[E])); else s.strokeStyle = r.datasets[E].pointStrokeColor; s.lineWidth = i.pointDotStrokeWidth; for (var D = 0; D < r.datasets[E].data.length; D++) { if (!(typeof r.datasets[E].data[D] == "undefined")) { var m = animationCorrection(n, r, i, E, D, 0); if (m.mainVal > 0 || !i.animationLeftToRight) { s.beginPath(); s.arc(H(E, D, r), P(E, D), i.pointDotRadius, 0, Math.PI * 2, true); s.fill(); s.stroke() } } } } } } } function log10(e) { return Math.log(e) / Math.LN10 } function setRect(e, t) { if (t.clearRect) { if (!t.multiGraph) { clear(e); e.clearRect(0, 0, width, height) } } else { clear(e); e.clearRect(0, 0, width, height); e.fillStyle = t.savePngBackgroundColor; e.strokeStyle = t.savePngBackgroundColor; e.beginPath(); e.moveTo(0, 0); e.lineTo(0, e.canvas.height); e.lineTo(e.canvas.width, e.canvas.height); e.lineTo(e.canvas.width, 0); e.lineTo(0, 0); e.stroke(); e.fill() } } function defMouse(e, t, n, r) { function i(r, i, s) { function o(r) { if (s == null || s(r)) doMouseAction(n, e, r, t, "mouseaction", i) } if (typeof i != "function") return; var u = r + " " + i.name; if (u in e._eventListeners) { if (e.canvas.removeEventListener) e.canvas.removeEventListener(r, e._eventListeners[u]); else if (e.canvas.detachEvent) e.canvas.detachEvent(r, e._eventListeners[u]) } e._eventListeners[u] = o; if (e.canvas.addEventListener) { if (r == "mousewheel") r = "DOMMouseScroll"; e.canvas.addEventListener(r, o, false) } else if (e.canvas.attachEvent) { e.canvas.attachEvent("on" + r, o) } } if (n.annotateDisplay == true) { if (cursorDivCreated == false) oCursor = new makeCursorObj("divCursor"); if (isIE() < 9 && isIE() != false) e.canvas.attachEvent("on" + n.annotateFunction.split(" ")[0], function (r) { if (n.annotateFunction.split(" ")[1] == "left" && r.which == 1 || n.annotateFunction.split(" ")[1] == "middle" && r.which == 2 || n.annotateFunction.split(" ")[1] == "right" && r.which == 3 || typeof n.annotateFunction.split(" ")[1] != "string") doMouseAction(n, e, r, t, "annotate", n.mouseDownRight) }); else e.canvas.addEventListener(n.annotateFunction.split(" ")[0], function (r) { if (n.annotateFunction.split(" ")[1] == "left" && r.which == 1 || n.annotateFunction.split(" ")[1] == "middle" && r.which == 2 || n.annotateFunction.split(" ")[1] == "right" && r.which == 3 || typeof n.annotateFunction.split(" ")[1] != "string") doMouseAction(n, e, r, t, "annotate", n.mouseDownRight) }, false) } if (n.savePng) { if (isIE() < 9 && isIE() != false) e.canvas.attachEvent("on" + n.savePngFunction.split(" ")[0], function (i) { if (n.savePngFunction.split(" ")[1] == "left" && i.which == 1 || n.savePngFunction.split(" ")[1] == "middle" && i.which == 2 || n.savePngFunction.split(" ")[1] == "right" && i.which == 3 || typeof n.savePngFunction.split(" ")[1] != "string") saveCanvas(e, t, n, r) }); else e.canvas.addEventListener(n.savePngFunction.split(" ")[0], function (i) { if (n.savePngFunction.split(" ")[1] == "left" && i.which == 1 || n.savePngFunction.split(" ")[1] == "middle" && i.which == 2 || n.savePngFunction.split(" ")[1] == "right" && i.which == 3 || typeof n.savePngFunction.split(" ")[1] != "string") saveCanvas(e, t, n, r) }, false) } if (isIE() < 9 && isIE() != false) e.canvas.attachEvent("onmousewheel", function (e) { if (cursorDivCreated) document.getElementById("divCursor").style.display = "none" }); else e.canvas.addEventListener("DOMMouseScroll", function (e) { if (cursorDivCreated) document.getElementById("divCursor").style.display = "none" }, false); i("mousedown", n.mouseDownLeft, function (e) { return e.which == 1 }); i("mousedown", n.mouseDownMiddle, function (e) { return e.which == 2 }); i("mousedown", n.mouseDownRight, function (e) { return e.which == 3 }); i("mousemove", n.mouseMove); i("mouseout", n.mouseOut); i("mousewheel", n.mouseWheel) } var chart = this; var animationOptions = { linear: function (e) { return e }, easeInQuad: function (e) { return e * e }, easeOutQuad: function (e) { return -1 * e * (e - 2) }, easeInOutQuad: function (e) { if ((e /= 1 / 2) < 1) return 1 / 2 * e * e; return -1 / 2 * (--e * (e - 2) - 1) }, easeInCubic: function (e) { return e * e * e }, easeOutCubic: function (e) { return 1 * ((e = e / 1 - 1) * e * e + 1) }, easeInOutCubic: function (e) { if ((e /= 1 / 2) < 1) return 1 / 2 * e * e * e; return 1 / 2 * ((e -= 2) * e * e + 2) }, easeInQuart: function (e) { return e * e * e * e }, easeOutQuart: function (e) { return -1 * ((e = e / 1 - 1) * e * e * e - 1) }, easeInOutQuart: function (e) { if ((e /= 1 / 2) < 1) return 1 / 2 * e * e * e * e; return -1 / 2 * ((e -= 2) * e * e * e - 2) }, easeInQuint: function (e) { return 1 * (e /= 1) * e * e * e * e }, easeOutQuint: function (e) { return 1 * ((e = e / 1 - 1) * e * e * e * e + 1) }, easeInOutQuint: function (e) { if ((e /= 1 / 2) < 1) return 1 / 2 * e * e * e * e * e; return 1 / 2 * ((e -= 2) * e * e * e * e + 2) }, easeInSine: function (e) { return -1 * Math.cos(e / 1 * (Math.PI / 2)) + 1 }, easeOutSine: function (e) { return 1 * Math.sin(e / 1 * (Math.PI / 2)) }, easeInOutSine: function (e) { return -1 / 2 * (Math.cos(Math.PI * e / 1) - 1) }, easeInExpo: function (e) { return e == 0 ? 1 : 1 * Math.pow(2, 10 * (e / 1 - 1)) }, easeOutExpo: function (e) { return e == 1 ? 1 : 1 * (-Math.pow(2, -10 * e / 1) + 1) }, easeInOutExpo: function (e) { if (e == 0) return 0; if (e == 1) return 1; if ((e /= 1 / 2) < 1) return 1 / 2 * Math.pow(2, 10 * (e - 1)); return 1 / 2 * (-Math.pow(2, -10 * --e) + 2) }, easeInCirc: function (e) { if (e >= 1) return e; return -1 * (Math.sqrt(1 - (e /= 1) * e) - 1) }, easeOutCirc: function (e) { return 1 * Math.sqrt(1 - (e = e / 1 - 1) * e) }, easeInOutCirc: function (e) { if ((e /= 1 / 2) < 1) return -1 / 2 * (Math.sqrt(1 - e * e) - 1); return 1 / 2 * (Math.sqrt(1 - (e -= 2) * e) + 1) }, easeInElastic: function (e) { var t = 1.70158; var n = 0; var r = 1; if (e == 0) return 0; if ((e /= 1) == 1) return 1; if (!n) n = 1 * .3; if (r < Math.abs(1)) { r = 1; var t = n / 4 } else var t = n / (2 * Math.PI) * Math.asin(1 / r); return -(r * Math.pow(2, 10 * (e -= 1)) * Math.sin((e * 1 - t) * 2 * Math.PI / n)) }, easeOutElastic: function (e) { var t = 1.70158; var n = 0; var r = 1; if (e == 0) return 0; if ((e /= 1) == 1) return 1; if (!n) n = 1 * .3; if (r < Math.abs(1)) { r = 1; var t = n / 4 } else var t = n / (2 * Math.PI) * Math.asin(1 / r); return r * Math.pow(2, -10 * e) * Math.sin((e * 1 - t) * 2 * Math.PI / n) + 1 }, easeInOutElastic: function (e) { var t = 1.70158; var n = 0; var r = 1; if (e == 0) return 0; if ((e /= 1 / 2) == 2) return 1; if (!n) n = 1 * .3 * 1.5; if (r < Math.abs(1)) { r = 1; var t = n / 4 } else var t = n / (2 * Math.PI) * Math.asin(1 / r); if (e < 1) return -.5 * r * Math.pow(2, 10 * (e -= 1)) * Math.sin((e * 1 - t) * 2 * Math.PI / n); return r * Math.pow(2, -10 * (e -= 1)) * Math.sin((e * 1 - t) * 2 * Math.PI / n) * .5 + 1 }, easeInBack: function (e) { var t = 1.70158; return 1 * (e /= 1) * e * ((t + 1) * e - t) }, easeOutBack: function (e) { var t = 1.70158; return 1 * ((e = e / 1 - 1) * e * ((t + 1) * e + t) + 1) }, easeInOutBack: function (e) { var t = 1.70158; if ((e /= 1 / 2) < 1) return 1 / 2 * e * e * (((t *= 1.525) + 1) * e - t); return 1 / 2 * ((e -= 2) * e * (((t *= 1.525) + 1) * e + t) + 2) }, easeInBounce: function (e) { return 1 - animationOptions.easeOutBounce(1 - e) }, easeOutBounce: function (e) { if ((e /= 1) < 1 / 2.75) { return 1 * 7.5625 * e * e } else if (e < 2 / 2.75) { return 1 * (7.5625 * (e -= 1.5 / 2.75) * e + .75) } else if (e < 2.5 / 2.75) { return 1 * (7.5625 * (e -= 2.25 / 2.75) * e + .9375) } else { return 1 * (7.5625 * (e -= 2.625 / 2.75) * e + .984375) } }, easeInOutBounce: function (e) { if (e < 1 / 2) return animationOptions.easeInBounce(e * 2) * .5; return animationOptions.easeOutBounce(e * 2 - 1) * .5 + 1 * .5 } }; var width = context.canvas.width; var height = context.canvas.height; if (window.devicePixelRatio) { context.canvas.style.width = width + "px"; context.canvas.style.height = height + "px"; context.canvas.height = height * window.devicePixelRatio; context.canvas.width = width * window.devicePixelRatio; context.scale(window.devicePixelRatio, window.devicePixelRatio) } this.PolarArea = function (e, t) { chart.PolarArea.defaults = { inGraphDataShow: false, inGraphDataPaddingRadius: 5, inGraphDataPaddingAngle: 0, inGraphDataTmpl: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' + v6 + ' %)'%>", inGraphDataAlign: "off-center", inGraphDataVAlign: "off-center", inGraphDataRotate: 0, inGraphDataFontFamily: "'Arial'", inGraphDataFontSize: 12, inGraphDataFontStyle: "normal", inGraphDataFontColor: "#666", inGraphDataRadiusPosition: 3, inGraphDataAnglePosition: 2, scaleOverlay: true, scaleOverride: false, scaleOverride2: false, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleShowLine: true, scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: true, scaleShowLabels2: true, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowLabelBackdrop: true, scaleBackdropColor: "rgba(255,255,255,0.75)", scaleBackdropPaddingY: 2, scaleBackdropPaddingX: 2, segmentShowStroke: true, segmentStrokeColor: "#fff", segmentStrokeWidth: 2, animation: true, animationSteps: 100, animationEasing: "easeOutBounce", animateRotate: true, animateScale: false, onAnimationComplete: null, annotateLabel: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' + v6 + ' %)'%>", startAngle: 90 }; chart.PolarArea.defaults = mergeChartConfig(chart.defaults.commonOptions, chart.PolarArea.defaults); chart.PolarArea.defaults = mergeChartConfig(chart.PolarArea.defaults, charJSPersonalDefaultOptions); chart.PolarArea.defaults = mergeChartConfig(chart.PolarArea.defaults, charJSPersonalDefaultOptionsPolarArea); var n = t ? mergeChartConfig(chart.PolarArea.defaults, t) : chart.PolarArea.defaults; return new PolarArea(e, n, context) }; this.Radar = function (e, t) { chart.Radar.defaults = { inGraphDataShow: false, inGraphDataPaddingRadius: 5, inGraphDataTmpl: "<%=v3%>", inGraphDataAlign: "off-center", inGraphDataVAlign: "off-center", inGraphDataRotate: 0, inGraphDataFontFamily: "'Arial'", inGraphDataFontSize: 12, inGraphDataFontStyle: "normal", inGraphDataFontColor: "#666", inGraphDataRadiusPosition: 3, yAxisMinimumInterval: "none", scaleOverlay: false, scaleOverride: false, scaleOverride2: false, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleShowLine: true, scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: false, scaleShowLabels2: true, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowLabelBackdrop: true, scaleBackdropColor: "rgba(255,255,255,0.75)", scaleBackdropPaddingY: 2, scaleBackdropPaddingX: 2, angleShowLineOut: true, angleLineColor: "rgba(0,0,0,.1)", angleLineWidth: 1, pointLabelFontFamily: "'Arial'", pointLabelFontStyle: "normal", pointLabelFontSize: 12, pointLabelFontColor: "#666", pointDot: true, pointDotRadius: 3, pointDotStrokeWidth: 1, datasetFill: true, datasetStrokeWidth: 2, animation: true, animationSteps: 60, animationEasing: "easeOutQuart", onAnimationComplete: null, annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2 !='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3%>", startAngle: 90, graphMaximized: false }; chart.Radar.defaults = mergeChartConfig(chart.defaults.commonOptions, chart.Radar.defaults); chart.Radar.defaults = mergeChartConfig(chart.Radar.defaults, charJSPersonalDefaultOptions); chart.Radar.defaults = mergeChartConfig(chart.Radar.defaults, charJSPersonalDefaultOptionsRadar); var n = t ? mergeChartConfig(chart.Radar.defaults, t) : chart.Radar.defaults; return new Radar(e, n, context) }; this.Pie = function (e, t) { chart.Pie.defaults = { inGraphDataShow: false, inGraphDataPaddingRadius: 5, inGraphDataPaddingAngle: 0, inGraphDataTmpl: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' + v6 + ' %)'%>", inGraphDataAlign: "off-center", inGraphDataVAlign: "off-center", inGraphDataRotate: 0, inGraphDataFontFamily: "'Arial'", inGraphDataFontSize: 12, inGraphDataFontStyle: "normal", inGraphDataFontColor: "#666", inGraphDataRadiusPosition: 3, inGraphDataAnglePosition: 2, inGraphDataMinimumAngle: 0, segmentShowStroke: true, segmentStrokeColor: "#fff", segmentStrokeWidth: 2, animation: true, animationSteps: 100, animationEasing: "easeOutBounce", animateRotate: true, animateScale: false, onAnimationComplete: null, annotateLabel: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' + v6 + ' %)'%>", startAngle: 90, radiusScale: 1 }; chart.Pie.defaults = mergeChartConfig(chart.defaults.commonOptions, chart.Pie.defaults); chart.Pie.defaults = mergeChartConfig(chart.Pie.defaults, charJSPersonalDefaultOptions); chart.Pie.defaults = mergeChartConfig(chart.Pie.defaults, charJSPersonalDefaultOptionsPie); var n = t ? mergeChartConfig(chart.Pie.defaults, t) : chart.Pie.defaults; return new Pie(e, n, context) }; this.Doughnut = function (e, t) { chart.Doughnut.defaults = { inGraphDataShow: false, inGraphDataPaddingRadius: 5, inGraphDataPaddingAngle: 0, inGraphDataTmpl: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' + v6 + ' %)'%>", inGraphDataAlign: "off-center", inGraphDataVAlign: "off-center", inGraphDataRotate: 0, inGraphDataFontFamily: "'Arial'", inGraphDataFontSize: 12, inGraphDataFontStyle: "normal", inGraphDataFontColor: "#666", inGraphDataRadiusPosition: 3, inGraphDataAnglePosition: 2, inGraphDataMinimumAngle: 0, segmentShowStroke: true, segmentStrokeColor: "#fff", segmentStrokeWidth: 2, percentageInnerCutout: 50, animation: true, animationSteps: 100, animationEasing: "easeOutBounce", animateRotate: true, animateScale: false, onAnimationComplete: null, annotateLabel: "<%=(v1 == ''? '' : v1+':')+ v2 + ' (' + v6 + ' %)'%>", startAngle: 90, radiusScale: 1 }; chart.Doughnut.defaults = mergeChartConfig(chart.defaults.commonOptions, chart.Doughnut.defaults); chart.Doughnut.defaults = mergeChartConfig(chart.Doughnut.defaults, charJSPersonalDefaultOptions); chart.Doughnut.defaults = mergeChartConfig(chart.Doughnut.defaults, charJSPersonalDefaultOptionsDoughnut); var n = t ? mergeChartConfig(chart.Doughnut.defaults, t) : chart.Doughnut.defaults; return new Doughnut(e, n, context) }; this.Line = function (e, t) { chart.Line.defaults = { inGraphDataShow: false, inGraphDataPaddingX: 3, inGraphDataPaddingY: 3, inGraphDataTmpl: "<%=v3%>", inGraphDataAlign: "left", inGraphDataVAlign: "bottom", inGraphDataRotate: 0, inGraphDataFontFamily: "'Arial'", inGraphDataFontSize: 12, inGraphDataFontStyle: "normal", inGraphDataFontColor: "#666", drawXScaleLine: [{ position: "bottom" }], scaleOverlay: false, scaleOverride: false, scaleOverride2: false, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleSteps2: null, scaleStepWidth2: null, scaleStartValue2: null, scaleLabel2: "<%=value%>", scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: true, scaleShowLabels2: true, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowGridLines: true, scaleXGridLinesStep: 1, scaleYGridLinesStep: 1, scaleGridLineColor: "rgba(0,0,0,.05)", scaleGridLineWidth: 1, showYAxisMin: true, rotateLabels: "smart", logarithmic: false, logarithmic2: false, scaleTickSizeLeft: 5, scaleTickSizeRight: 5, scaleTickSizeBottom: 5, scaleTickSizeTop: 5, bezierCurve: true, pointDot: true, pointDotRadius: 4, pointDotStrokeWidth: 2, datasetStrokeWidth: 2, datasetFill: true, animation: true, animationSteps: 60, animationEasing: "easeOutQuart", extrapolateMissingData: true, onAnimationComplete: null, annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2 !='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3%>" }; chart.Line.defaults = mergeChartConfig(chart.defaults.commonOptions, chart.Line.defaults); chart.Line.defaults = mergeChartConfig(chart.defaults.xyAxisCommonOptions, chart.Line.defaults); chart.Line.defaults = mergeChartConfig(chart.Line.defaults, charJSPersonalDefaultOptions); chart.Line.defaults = mergeChartConfig(chart.Line.defaults, charJSPersonalDefaultOptionsLine); var n = t ? mergeChartConfig(chart.Line.defaults, t) : chart.Line.defaults; return new Line(e, n, context) }; this.StackedBar = function (e, t) { chart.StackedBar.defaults = { inGraphDataShow: false, inGraphDataPaddingX: 0, inGraphDataPaddingY: -3, inGraphDataTmpl: "<%=v3%>", inGraphDataAlign: "center", inGraphDataVAlign: "top", inGraphDataRotate: 0, inGraphDataFontFamily: "'Arial'", inGraphDataFontSize: 12, inGraphDataFontStyle: "normal", inGraphDataFontColor: "#666", inGraphDataXPosition: 2, inGraphDataYPosition: 3, scaleOverlay: false, scaleOverride: false, scaleOverride2: false, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: true, scaleShowLabels2: true, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowGridLines: true, scaleXGridLinesStep: 1, scaleYGridLinesStep: 1, scaleGridLineColor: "rgba(0,0,0,.05)", scaleGridLineWidth: 1, showYAxisMin: true, rotateLabels: "smart", scaleTickSizeLeft: 5, scaleTickSizeRight: 5, scaleTickSizeBottom: 5, scaleTickSizeTop: 5, barShowStroke: true, barStrokeWidth: 2, barValueSpacing: 5, barDatasetSpacing: 1, animation: true, animationSteps: 60, animationEasing: "easeOutQuart", onAnimationComplete: null, annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2 !='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3 + ' (' + v6 + ' %)'%>" }; chart.StackedBar.defaults = mergeChartConfig(chart.defaults.commonOptions, chart.StackedBar.defaults); chart.StackedBar.defaults = mergeChartConfig(chart.defaults.xyAxisCommonOptions, chart.StackedBar.defaults); chart.StackedBar.defaults = mergeChartConfig(chart.StackedBar.defaults, charJSPersonalDefaultOptions); chart.StackedBar.defaults = mergeChartConfig(chart.StackedBar.defaults, charJSPersonalDefaultOptionsStackedBar); var n = t ? mergeChartConfig(chart.StackedBar.defaults, t) : chart.StackedBar.defaults; return new StackedBar(e, n, context) }; this.HorizontalStackedBar = function (e, t) { chart.HorizontalStackedBar.defaults = { inGraphDataShow: false, inGraphDataPaddingX: -3, inGraphDataPaddingY: 0, inGraphDataTmpl: "<%=v3%>", inGraphDataAlign: "right", inGraphDataVAlign: "middle", inGraphDataRotate: 0, inGraphDataFontFamily: "'Arial'", inGraphDataFontSize: 12, inGraphDataFontStyle: "normal", inGraphDataFontColor: "#666", inGraphDataXPosition: 3, inGraphDataYPosition: 2, scaleOverlay: false, scaleOverride: false, scaleOverride2: false, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: true, scaleShowLabels2: true, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowGridLines: true, scaleXGridLinesStep: 1, scaleYGridLinesStep: 1, scaleGridLineColor: "rgba(0,0,0,.05)", scaleGridLineWidth: 1, scaleTickSizeLeft: 5, scaleTickSizeRight: 5, scaleTickSizeBottom: 5, scaleTickSizeTop: 5, showYAxisMin: true, rotateLabels: "smart", barShowStroke: true, barStrokeWidth: 2, barValueSpacing: 5, barDatasetSpacing: 1, animation: true, animationSteps: 60, animationEasing: "easeOutQuart", onAnimationComplete: null, annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2 !='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3 + ' (' + v6 + ' %)'%>", reverseOrder: false }; chart.HorizontalStackedBar.defaults = mergeChartConfig(chart.defaults.commonOptions, chart.HorizontalStackedBar.defaults); chart.HorizontalStackedBar.defaults = mergeChartConfig(chart.defaults.xyAxisCommonOptions, chart.HorizontalStackedBar.defaults); chart.HorizontalStackedBar.defaults = mergeChartConfig(chart.HorizontalStackedBar.defaults, charJSPersonalDefaultOptions); chart.HorizontalStackedBar.defaults = mergeChartConfig(chart.HorizontalStackedBar.defaults, charJSPersonalDefaultOptionsHorizontalStackedBar); var n = t ? mergeChartConfig(chart.HorizontalStackedBar.defaults, t) : chart.HorizontalStackedBar.defaults; return new HorizontalStackedBar(e, n, context) }; this.Bar = function (e, t) { chart.Bar.defaults = { inGraphDataShow: false, inGraphDataPaddingX: 0, inGraphDataPaddingY: 3, inGraphDataTmpl: "<%=v3%>", inGraphDataAlign: "center", inGraphDataVAlign: "bottom", inGraphDataRotate: 0, inGraphDataFontFamily: "'Arial'", inGraphDataFontSize: 12, inGraphDataFontStyle: "normal", inGraphDataFontColor: "#666", inGraphDataXPosition: 2, inGraphDataYPosition: 3, scaleOverlay: false, scaleOverride: false, scaleOverride2: false, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: true, scaleShowLabels2: true, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowGridLines: true, scaleXGridLinesStep: 1, scaleYGridLinesStep: 1, scaleGridLineColor: "rgba(0,0,0,.05)", scaleGridLineWidth: 1, showYAxisMin: true, rotateLabels: "smart", logarithmic: false, logarithmic2: false, scaleTickSizeLeft: 5, scaleTickSizeRight: 5, scaleTickSizeBottom: 5, scaleTickSizeTop: 5, barShowStroke: true, barStrokeWidth: 2, barValueSpacing: 5, barDatasetSpacing: 1, barBorderRadius: 0, animation: true, animationSteps: 60, animationEasing: "easeOutQuart", onAnimationComplete: null, annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2 !='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3 + ' (' + v6 + ' %)'%>" }; chart.Bar.defaults = mergeChartConfig(chart.defaults.commonOptions, chart.Bar.defaults); chart.Bar.defaults = mergeChartConfig(chart.defaults.xyAxisCommonOptions, chart.Bar.defaults); chart.Bar.defaults = mergeChartConfig(chart.Bar.defaults, charJSPersonalDefaultOptions); chart.Bar.defaults = mergeChartConfig(chart.Bar.defaults, charJSPersonalDefaultOptionsBar); var n = t ? mergeChartConfig(chart.Bar.defaults, t) : chart.Bar.defaults; return new Bar(e, n, context) }; this.HorizontalBar = function (e, t) { chart.HorizontalBar.defaults = { inGraphDataShow: false, inGraphDataPaddingX: 3, inGraphDataPaddingY: 0, inGraphDataTmpl: "<%=v3%>", inGraphDataAlign: "left", inGraphDataVAlign: "middle", inGraphDataRotate: 0, inGraphDataFontFamily: "'Arial'", inGraphDataFontSize: 12, inGraphDataFontStyle: "normal", inGraphDataFontColor: "#666", inGraphDataXPosition: 3, inGraphDataYPosition: 2, scaleOverlay: false, scaleOverride: false, scaleOverride2: false, scaleSteps: null, scaleStepWidth: null, scaleStartValue: null, scaleLineColor: "rgba(0,0,0,.1)", scaleLineWidth: 1, scaleShowLabels: true, scaleShowLabels2: true, scaleLabel: "<%=value%>", scaleFontFamily: "'Arial'", scaleFontSize: 12, scaleFontStyle: "normal", scaleFontColor: "#666", scaleShowGridLines: true, scaleXGridLinesStep: 1, scaleYGridLinesStep: 1, scaleGridLineColor: "rgba(0,0,0,.05)", scaleGridLineWidth: 1, scaleTickSizeLeft: 5, scaleTickSizeRight: 5, scaleTickSizeBottom: 5, scaleTickSizeTop: 5, showYAxisMin: true, rotateLabels: "smart", barShowStroke: true, barStrokeWidth: 2, barValueSpacing: 5, barDatasetSpacing: 1, barBorderRadius: 0, animation: true, animationSteps: 60, animationEasing: "easeOutQuart", onAnimationComplete: null, annotateLabel: "<%=(v1 == '' ? '' : v1) + (v1!='' && v2 !='' ? ' - ' : '')+(v2 == '' ? '' : v2)+(v1!='' || v2 !='' ? ':' : '') + v3 + ' (' + v6 + ' %)'%>", reverseOrder: false }; chart.HorizontalBar.defaults = mergeChartConfig(chart.defaults.commonOptions, chart.HorizontalBar.defaults); chart.HorizontalBar.defaults = mergeChartConfig(chart.defaults.xyAxisCommonOptions, chart.HorizontalBar.defaults); chart.HorizontalBar.defaults = mergeChartConfig(chart.HorizontalBar.defaults, charJSPersonalDefaultOptions); chart.HorizontalBar.defaults = mergeChartConfig(chart.HorizontalBar.defaults, charJSPersonalDefaultOptionsHorizontalBar); var n = t ? mergeChartConfig(chart.HorizontalBar.defaults, t) : chart.HorizontalBar.defaults; return new HorizontalBar(e, n, context) }; chart.defaults = {}; chart.defaults.commonOptions = { multiGraph: false, clearRect: true, dynamicDisplay: false, graphSpaceBefore: 5, graphSpaceAfter: 5, canvasBorders: false, canvasBackgroundColor: "none", canvasBordersWidth: 3, canvasBordersColor: "black", graphTitle: "", graphTitleFontFamily: "'Arial'", graphTitleFontSize: 24, graphTitleFontStyle: "bold", graphTitleFontColor: "#666", graphTitleSpaceBefore: 5, graphTitleSpaceAfter: 5, graphSubTitle: "", graphSubTitleFontFamily: "'Arial'", graphSubTitleFontSize: 18, graphSubTitleFontStyle: "normal", graphSubTitleFontColor: "#666", graphSubTitleSpaceBefore: 5, graphSubTitleSpaceAfter: 5, footNote: "", footNoteFontFamily: "'Arial'", footNoteFontSize: 8, footNoteFontStyle: "bold", footNoteFontColor: "#666", footNoteSpaceBefore: 5, footNoteSpaceAfter: 5, legend: false, showSingleLegend: false, maxLegendCols: 999, legendPosY: 4, legendPosX: -2, legendFontFamily: "'Arial'", legendFontSize: 12, legendFontStyle: "normal", legendFontColor: "#666", legendBlockSize: 15, legendBorders: true, legendBordersWidth: 1, legendBordersColors: "#666", legendBordersSpaceBefore: 5, legendBordersSpaceAfter: 5, legendBordersSpaceLeft: 5, legendBordersSpaceRight: 5, legendSpaceBeforeText: 5, legendSpaceAfterText: 5, legendSpaceLeftText: 5, legendSpaceRightText: 5, legendSpaceBetweenTextVertical: 5, legendSpaceBetweenTextHorizontal: 5, legendSpaceBetweenBoxAndText: 5, legendFillColor: "rbga(0,0,0,0)", legendXPadding: 0, legendYPadding: 0, annotateDisplay: false, savePng: false, savePngOutput: "NewWindow", savePngFunction: "mousedown right", savePngBackgroundColor: "WHITE", annotateFunction: "mousemove", annotateFontFamily: "'Arial'", annotateBorder: "none", annotateBorderRadius: "2px", annotateBackgroundColor: "rgba(0,0,0,0.8)", annotateFontSize: 12, annotateFontColor: "white", annotateFontStyle: "normal", annotatePadding: "3px", annotateClassName: "", crossText: [""], crossTextIter: ["all"], crossTextOverlay: [true], crossTextFontFamily: ["'Arial'"], crossTextFontSize: [12], crossTextFontStyle: ["normal"], crossTextFontColor: ["rgba(220,220,220,1)"], crossTextRelativePosX: [2], crossTextRelativePosY: [2], crossTextBaseline: ["middle"], crossTextAlign: ["center"], crossTextPosX: [0], crossTextPosY: [0], crossTextAngle: [0], crossTextFunction: null, crossImage: [undefined], crossImageIter: ["all"], crossImageOverlay: [true], crossImageRelativePosX: [2], crossImageRelativePosY: [2], crossImageBaseline: ["middle"], crossImageAlign: ["center"], crossImagePosX: [0], crossImagePosY: [0], crossImageAngle: [0], spaceTop: 0, spaceBottom: 0, spaceRight: 0, spaceLeft: 0, decimalSeparator: ".", thousandSeparator: "", roundNumber: "none", roundPct: -1, fmtV1: "none", fmtV2: "none", fmtV3: "none", fmtV4: "none", fmtV5: "none", fmtV6: "none", fmtV7: "none", fmtV8: "none", fmtV9: "none", fmtV10: "none", fmtV11: "none", fmtV12: "none", fmtV13: "none", fmtXLabel: "none", fmtYLabel: "none", fmtYLabel2: "none", fmtLegend: "none", animationStartValue: 0, animationStopValue: 1, animationCount: 1, animationPauseTime: 5, animationBackward: false, animationStartWithDataset: 1, animationStartWithData: 1, animationLeftToRight: false, animationByDataset: false, defaultStrokeColor: "rgba(220,220,220,1)", defaultFillColor: "rgba(220,220,220,0.5)", mouseDownRight: null, mouseDownLeft: null, mouseDownMiddle: null, mouseMove: null, mouseOut: null, mouseWheel: null, savePngName: "canvas" }; chart.defaults.xyAxisCommonOptions = { yAxisMinimumInterval: "none", yAxisMinimumInterval2: "none", yScaleLabelsMinimumWidth: 0, xScaleLabelsMinimumWidth: 0, yAxisLeft: true, yAxisRight: false, xAxisBottom: true, xAxisTop: false, xAxisSpaceBetweenLabels: 5, fullWidthGraph: false, yAxisLabel: "", yAxisLabel2: "", yAxisFontFamily: "'Arial'", yAxisFontSize: 16, yAxisFontStyle: "normal", yAxisFontColor: "#666", yAxisLabelSpaceRight: 5, yAxisLabelSpaceLeft: 5, yAxisSpaceRight: 5, yAxisSpaceLeft: 5, xAxisLabel: "", xAxisFontFamily: "'Arial'", xAxisFontSize: 16, xAxisFontStyle: "normal", xAxisFontColor: "#666", xAxisLabelSpaceBefore: 5, xAxisLabelSpaceAfter: 5, xAxisSpaceBefore: 5, xAxisSpaceAfter: 5, yAxisUnit: "", yAxisUnit2: "", yAxisUnitFontFamily: "'Arial'", yAxisUnitFontSize: 8, yAxisUnitFontStyle: "normal", yAxisUnitFontColor: "#666", yAxisUnitSpaceBefore: 5, yAxisUnitSpaceAfter: 5 }; var clear = function (e) { e.clearRect(0, 0, width, height) }; var PolarArea = function (e, t, n) { function d(r) { var o = -t.startAngle * (Math.PI / 180) + 2 * Math.PI, u = 0, a = 0, f = 1, d = 1; a = 0; for (var v = 0; v < e.length; v++) if (!(typeof e[v].value == "undefined")) a++; a = Math.PI * 2 / a; while (o < 0) { o += 2 * Math.PI } while (o > 2 * Math.PI) { o -= 2 * Math.PI } if (t.animation) { if (t.animateScale) { f = r } if (t.animateRotate) { d = r } } if (r >= 1) { totvalue = 0; for (var v = 0; v < e.length; v++) if (!(typeof e[v].value == "undefined")) totvalue += 1 * e[v].value } for (var v = 0; v < e.length; v++) { correctedRotateAnimation = animationCorrection(d, e, t, v, -1, 0).mainVal; if (!(typeof e[v].value == "undefined")) { n.beginPath(); n.arc(c, h, f * calculateOffset(t.logarithmic, 1 * e[v].value, s, i), o, o + correctedRotateAnimation * a, false); n.lineTo(c, h); n.closePath(); if (typeof e[v].color == "function") n.fillStyle = e[v].color("COLOR", e, t, v, -1, r, e[v].value, "PolarArea", n, c, h, 0, f * calculateOffset(t.logarithmic, 1 * e[v].value, s, i)); else n.fillStyle = e[v].color; n.fill(); o += a; if (t.segmentShowStroke) { n.strokeStyle = t.segmentStrokeColor; n.lineWidth = t.segmentStrokeWidth; n.stroke() } } } if (r >= 1) { o -= 2 * Math.PI; for (var v = 0; v < e.length; v++) { if (!(typeof e[v].value == "undefined")) { u += 1 * e[v].value; o += a; if (typeof e[v].title == "string") lgtxt = e[v].title.trim(); else lgtxt = ""; jsGraphAnnotate[n.ChartNewId][jsGraphAnnotate[n.ChartNewId].length] = ["ARC", c, h, 0, calculateOffset(t.logarithmic, 1 * e[v].value, s, i), o - a, o, lgtxt, 1 * e[v].value, u, totvalue, a, v]; if (t.inGraphDataShow) { if (t.inGraphDataAnglePosition == 1) posAngle = p + t.inGraphDataPaddingAngle * (Math.PI / 180); else if (t.inGraphDataAnglePosition == 2) posAngle = p - a / 2 + t.inGraphDataPaddingAngle * (Math.PI / 180); else if (t.inGraphDataAnglePosition == 3) posAngle = p - a + t.inGraphDataPaddingAngle * (Math.PI / 180); if (t.inGraphDataRadiusPosition == 1) labelRadius = 0 + t.inGraphDataPaddingRadius; else if (t.inGraphDataRadiusPosition == 2) labelRadius = calculateOffset(t.logarithmic, 1 * e[v].value, s, i) / 2 + t.inGraphDataPaddingRadius; else if (t.inGraphDataRadiusPosition == 3) labelRadius = calculateOffset(t.logarithmic, 1 * e[v].value, s, i) + t.inGraphDataPaddingRadius; else if (t.inGraphDataRadiusPosition == 4) labelRadius = i * s.steps + t.inGraphDataPaddingRadius; n.save(); if (t.inGraphDataAlign == "off-center") { if (t.inGraphDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) n.textAlign = "left"; else n.textAlign = "right" } else if (t.inGraphDataAlign == "to-center") { if (t.inGraphDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) n.textAlign = "right"; else n.textAlign = "left" } else n.textAlign = t.inGraphDataAlign; if (t.inGraphDataVAlign == "off-center") { if ((posAngle + 2 * Math.PI) % (2 * Math.PI) > Math.PI) n.textBaseline = "top"; else n.textBaseline = "bottom" } else if (t.inGraphDataVAlign == "to-center") { if ((posAngle + 2 * Math.PI) % (2 * Math.PI) > Math.PI) n.textBaseline = "bottom"; else n.textBaseline = "top" } else n.textBaseline = t.inGraphDataVAlign; n.font = t.inGraphDataFontStyle + " " + t.inGraphDataFontSize + "px " + t.inGraphDataFontFamily; n.fillStyle = t.inGraphDataFontColor; var m = tmplbis(t.inGraphDataTmpl, { config: t, v1: fmtChartJS(t, lgtxt, t.fmtV1), v2: fmtChartJS(t, 1 * e[v].value, t.fmtV2), v3: fmtChartJS(t, u, t.fmtV3), v4: fmtChartJS(t, totvalue, t.fmtV4), v5: fmtChartJS(t, a, t.fmtV5), v6: roundToWithThousands(t, fmtChartJS(t, 100 * e[v].value / totvalue, t.fmtV6), t.roundPct), v7: fmtChartJS(t, c, t.fmtV7), v8: fmtChartJS(t, h, t.fmtV8), v9: fmtChartJS(t, 0, t.fmtV9), v10: fmtChartJS(t, calculateOffset(t.logarithmic, 1 * e[v].value, s, i), t.fmtV10), v11: fmtChartJS(t, o - a, t.fmtV11), v12: fmtChartJS(t, a, t.fmtV12), v13: fmtChartJS(t, v, t.fmtV13), data: e }); n.translate(c + labelRadius * Math.cos(posAngle), h - labelRadius * Math.sin(posAngle)); if (t.inGraphDataRotate == "inRadiusAxis") n.rotate(2 * Math.PI - posAngle); else if (t.inGraphDataRotate == "inRadiusAxisRotateLabels") { if ((posAngle + 2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (posAngle + 2 * Math.PI) % (2 * Math.PI) < 3 * Math.PI / 2) n.rotate(3 * Math.PI - posAngle); else n.rotate(2 * Math.PI - posAngle) } else n.rotate(t.inGraphDataRotate * (Math.PI / 180)); n.fillTextMultiLine(m, 0, 0, n.textBaseline, t.inGraphDataFontSize); n.restore() } p -= a } } } if (l.legendMsr.dispLegend) drawLegend(l.legendMsr, e, t, n, "PolarArea") } function v() { for (var e = 0; e < s.steps; e++) { if (t.scaleShowLine) { n.beginPath(); n.arc(c, h, i * (e + 1), 0, Math.PI * 2, true); n.strokeStyle = t.scaleLineColor; n.lineWidth = t.scaleLineWidth; n.stroke() } if (t.scaleShowLabels) { n.textAlign = "center"; n.font = t.scaleFontStyle + " " + t.scaleFontSize + "px " + t.scaleFontFamily; var r = s.labels[e + 1]; if (t.scaleShowLabelBackdrop) { var o = n.measureTextMultiLine(r, t.scaleFontSize).textWidth; n.fillStyle = t.scaleBackdropColor; n.beginPath(); n.rect(Math.round(c - o / 2 - t.scaleBackdropPaddingX), Math.round(h - i * (e + 1) - t.scaleFontSize * .5 - t.scaleBackdropPaddingY), Math.round(o + t.scaleBackdropPaddingX * 2), Math.round(t.scaleFontSize + t.scaleBackdropPaddingY * 2)); n.fill() } n.textBaseline = "middle"; n.fillStyle = t.scaleFontColor; n.fillTextMultiLine(r, c, h - i * (e + 1), n.textBaseline, t.scaleFontSize) } } } function m() { var n = Number.MIN_VALUE; var r = Number.MAX_VALUE; for (var i = 0; i < e.length; i++) { if (1 * e[i].value > n) { n = 1 * e[i].value } if (1 * e[i].value < r) { r = 1 * e[i].value } } if (Math.abs(n - r) < 1e-8) { n = Max([n * 2, 1]); r = 0 } if (!isNaN(t.graphMin)) r = t.graphMin; if (!isNaN(t.graphMax)) n = t.graphMax; var s = Math.floor(u / (o * .66)); var a = Math.floor(u / o * .5); return { maxValue: n, minValue: r, maxSteps: s, minSteps: a } } var r, i, s, o, u, a, f, l, c, h; setting_new_chart_vars(n, "PolarArea"); if (!dynamicFunction(e, t, n, "PolarArea")) return; var p = t.startAngle * (Math.PI / 180) + 2 * Math.PI; while (t.startAngle < 0) { t.startAngle += 360 } while (t.startAngle > 360) { t.startAngle -= 360 } while (p < 0) { p += 2 * Math.PI } while (p > 2 * Math.PI) { p -= 2 * Math.PI } t.logarithmic = false; t.logarithmic2 = false; if (typeof jsGraphAnnotate[n.ChartNewId] == "undefined") jsGraphAnnotate[n.ChartNewId] = new Array; else if (!t.multiGraph) clearAnnotate(n.ChartNewId); defMouse(n, e, t, "PolarArea"); setRect(n, t); a = m(); f = t.scaleShowLabels ? t.scaleLabel : ""; if (!t.scaleOverride) { s = calculateScale(1, t, a.maxSteps, a.minSteps, a.maxValue, a.minValue, f); l = setMeasures(e, t, n, height, width, s.labels, null, true, false, false, false, true, "PolarArea") } else { s = { steps: t.scaleSteps, stepValue: t.scaleStepWidth, graphMin: t.scaleStartValue, graphMax: t.scaleStartValue + t.scaleSteps * t.scaleStepWidth, labels: [] }; populateLabels(1, t, f, s.labels, s.steps, t.scaleStartValue, s.graphMax, t.scaleStepWidth); l = setMeasures(e, t, n, height, width, s.labels, null, true, false, false, false, true, "PolarArea") } c = l.leftNotUsableSize + l.availableWidth / 2; h = l.topNotUsableSize + l.availableHeight / 2; i = Math.floor((Min([l.availableHeight, l.availableWidth]) / 2 - 5) / s.steps); animationLoop(t, v, d, n, l.clrx, l.clry, l.clrwidth, l.clrheight, c, h, c - (Min([l.availableHeight, l.availableWidth]) / 2 - 5), h + (Min([l.availableHeight, l.availableWidth]) / 2 - 5), e); }; var Radar = function (e, t, n) { function p(r) { var o = new Array; var u = new Array; var a = new Array; for (var f = 0; f < e.datasets.length; f++) { a[f] = -999999999; for (var p = 0; p < e.datasets[f].data.length; p++) { o[p] = 0; u[p] = -999999999 } } for (var f = 0; f < e.datasets.length; f++) { for (var p = 0; p < e.datasets[f].data.length; p++) { if (!(typeof e.datasets[f].data[p] == "undefined")) { o[p] += 1 * e.datasets[f].data[p]; u[p] = Max([u[p], 1 * e.datasets[f].data[p]]); a[f] = Max([a[f], 1 * e.datasets[f].data[p]]) } } } var d = 2 * Math.PI / e.datasets[0].data.length; n.save(); for (var f = 0; f < e.datasets.length; f++) { if (r >= 1) { if (typeof e.datasets[f].title == "string") lgtxt = e.datasets[f].title.trim(); else lgtxt = "" } var v = -1; for (var p = 0; p < e.datasets[f].data.length; p++) { var m = animationCorrection(r, e, t, f, p, 1).animVal; if (m > 1) m = m - 1; if (!(typeof e.datasets[f].data[p] == "undefined")) { if (v == -1) { n.beginPath(); n.moveTo(c + m * Math.cos(t.startAngle * Math.PI / 180 - p * d) * calculateOffset(t.logarithmic, e.datasets[f].data[p], s, i), h - m * Math.sin(t.startAngle * Math.PI / 180 - p * d) * calculateOffset(t.logarithmic, e.datasets[f].data[p], s, i)); v = p } else { n.lineTo(c + m * Math.cos(t.startAngle * Math.PI / 180 - p * d) * calculateOffset(t.logarithmic, e.datasets[f].data[p], s, i), h - m * Math.sin(t.startAngle * Math.PI / 180 - p * d) * calculateOffset(t.logarithmic, e.datasets[f].data[p], s, i)) } if (r >= 1) { if (f == 0) divprev = 0; else divprev = e.datasets[f].data[p] - e.datasets[f - 1].data[p]; if (f == e.datasets.length - 1) divnext = 0; else divnext = e.datasets[f + 1].data[p] - e.datasets[f].data[p]; if (typeof e.labels[p] == "string") lgtxt2 = e.labels[p].trim(); else lgtxt2 = ""; jsGraphAnnotate[n.ChartNewId][jsGraphAnnotate[n.ChartNewId].length] = ["POINT", c + Math.cos(t.startAngle * Math.PI / 180 - p * d) * calculateOffset(t.logarithmic, e.datasets[f].data[p], s, i), h - Math.sin(t.startAngle * Math.PI / 180 - p * d) * calculateOffset(t.logarithmic, e.datasets[f].data[p], s, i), lgtxt, lgtxt2, 1 * e.datasets[f].data[p], divprev, divnext, u[p], o[p], f, p] } } } n.closePath(); if (t.datasetFill) { if (typeof e.datasets[f].fillColor == "function") n.fillStyle = e.datasets[f].fillColor("FILLCOLOR", e, t, f, -1, m, -1, "Radar", n, c, h, 0, (t.animationLeftToRight ? 1 : m) * calculateOffset(t.logarithmic, a[f], s, i)); else if (typeof e.datasets[f].fillColor == "string") n.fillStyle = e.datasets[f].fillColor; else n.fillStyle = t.defaultFillColor } else n.fillStyle = "rgba(0,0,0,0)"; if (typeof e.datasets[f].strokeColor == "function") n.strokeStyle = e.datasets[f].strokeColor("STROKECOLOR", e, t, f, -1, m, -1, "Radar", n, c, h, 0, (t.animationLeftToRight ? 1 : m) * calculateOffset(t.logarithmic, a[f], s, i)); else if (typeof e.datasets[f].strokeColor == "string") n.strokeStyle = e.datasets[f].strokeColor; else n.strokeStyle = t.defaultStrokeColor; n.lineWidth = t.datasetStrokeWidth; n.fill(); n.stroke(); if (t.pointDot && (!t.animationLeftToRight || t.animationLeftToRight && r >= 1)) { n.beginPath(); if (typeof e.datasets[f].pointColor == "function") n.fillStyle = e.datasets[f].pointColor("POINTCOLOR", e, t, f, -1, m, -1, "Radar", n, c, h, 0, (t.animationLeftToRight ? 1 : m) * calculateOffset(t.logarithmic, a[f], s, i)); else n.fillStyle = e.datasets[f].pointColor; if (typeof e.datasets[f].pointStrokeColor == "function") n.strokeStyle = e.datasets[f].pointStrokeColor("POINTSTROKECOLOR", e, t, f, -1, m, -1, "Radar", n, c, h, 0, (t.animationLeftToRight ? 1 : m) * calculateOffset(t.logarithmic, a[f], s, i)); else n.strokeStyle = e.datasets[f].pointStrokeColor; n.lineWidth = t.pointDotStrokeWidth; for (var g = 0; g < e.datasets[f].data.length; g++) { if (!(typeof e.datasets[f].data[g] == "undefined")) { n.beginPath(); n.arc(c + m * Math.cos(t.startAngle * Math.PI / 180 - g * d) * calculateOffset(t.logarithmic, e.datasets[f].data[g], s, i), h - m * Math.sin(t.startAngle * Math.PI / 180 - g * d) * calculateOffset(t.logarithmic, e.datasets[f].data[g], s, i), t.pointDotRadius, 2 * Math.PI, false); n.fill(); n.stroke() } } } } n.restore(); if (r >= 1 && t.inGraphDataShow) { for (var f = 0; f < e.datasets.length; f++) { if (typeof e.datasets[f].title == "string") lgtxt = e.datasets[f].title.trim(); else lgtxt = ""; for (var p = 0; p < e.datasets[f].data.length; p++) { if (!(typeof e.datasets[f].data[p] == "undefined")) { if (f == 0) divprev = 0; else divprev = e.datasets[f].data[p] - e.datasets[f - 1].data[p]; if (f == e.datasets.length - 1) divnext = 0; else divnext = e.datasets[f + 1].data[p] - e.datasets[f].data[p]; if (typeof e.labels[p] == "string") lgtxt2 = e.labels[p].trim(); else lgtxt2 = ""; n.save(); n.textAlign = t.inGraphDataAlign; n.textBaseline = t.inGraphDataVAlign; if (t.inGraphDataAlign == "off-center") { if (t.inGraphDataRotate == "inRadiusAxis" || (t.startAngle * Math.PI / 180 - p * d + 4 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (t.startAngle * Math.PI / 180 - p * d + 4 * Math.PI) % (2 * Math.PI) <= Math.PI / 2) n.textAlign = "left"; else n.textAlign = "right" } else if (t.inGraphDataAlign == "to-center") { if (t.inGraphDataRotate == "inRadiusAxis" || (t.startAngle * Math.PI / 180 - p * d + 4 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (t.startAngle * Math.PI / 180 - p * d + 4 * Math.PI) % (2 * Math.PI) < Math.PI / 2) n.textAlign = "right"; else n.textAlign = "left" } else n.textAlign = t.inGraphDataAlign; if (t.inGraphDataVAlign == "off-center") { if ((t.startAngle * Math.PI / 180 - p * d + 4 * Math.PI) % (2 * Math.PI) > Math.PI) n.textBaseline = "bottom"; else n.textBaseline = "top" } else if (t.inGraphDataVAlign == "to-center") { if ((t.startAngle * Math.PI / 180 - p * d + 4 * Math.PI) % (2 * Math.PI) > Math.PI) n.textBaseline = "top"; else n.textBaseline = "bottom" } else n.textBaseline = t.inGraphDataVAlign; n.font = t.inGraphDataFontStyle + " " + t.inGraphDataFontSize + "px " + t.inGraphDataFontFamily; n.fillStyle = t.inGraphDataFontColor; var y; if (t.inGraphDataRadiusPosition == 1) y = 0 + t.inGraphDataPaddingRadius; else if (t.inGraphDataRadiusPosition == 2) y = calculateOffset(t.logarithmic, e.datasets[f].data[p], s, i) / 2 + t.inGraphDataPaddingRadius; else if (t.inGraphDataRadiusPosition == 3) y = calculateOffset(t.logarithmic, e.datasets[f].data[p], s, i) + t.inGraphDataPaddingRadius; n.translate(c + Math.cos(t.startAngle * Math.PI / 180 - p * d) * y, h - Math.sin(t.startAngle * Math.PI / 180 - p * d) * y); if (t.inGraphDataRotate == "inRadiusAxis") n.rotate(p * d); else if (t.inGraphDataRotate == "inRadiusAxisRotateLabels") { if ((p * d + 2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (p * d + 2 * Math.PI) % (2 * Math.PI) < 3 * Math.PI / 2) n.rotate(3 * Math.PI + p * d); else n.rotate(2 * Math.PI + p * d) } else n.rotate(t.inGraphDataRotate * (Math.PI / 180)); var b = tmplbis(t.inGraphDataTmpl, { config: t, v1: fmtChartJS(t, lgtxt, t.fmtV1), v2: fmtChartJS(t, lgtxt2, t.fmtV2), v3: fmtChartJS(t, 1 * e.datasets[f].data[p], t.fmtV3), v4: fmtChartJS(t, divprev, t.fmtV4), v5: fmtChartJS(t, divnext, t.fmtV5), v6: fmtChartJS(t, u[p], t.fmtV6), v7: fmtChartJS(t, o[p], t.fmtV7), v8: roundToWithThousands(t, fmtChartJS(t, 100 * e.datasets[f].data[p] / o[p], t.fmtV8), t.roundPct), v9: fmtChartJS(t, c + Math.cos(t.startAngle * Math.PI / 180 - p * d) * calculateOffset(t.logarithmic, e.datasets[f].data[p], s, i), t.fmtV9), v10: fmtChartJS(t, h - Math.sin(t.startAngle * Math.PI / 180 - p * d) * calculateOffset(t.logarithmic, e.datasets[f].data[p], s, i), t.fmtV10), v11: fmtChartJS(t, f, t.fmtV11), v12: fmtChartJS(t, p, t.fmtV12), data: e }); n.fillTextMultiLine(b, 0, 0, n.textBaseline, t.inGraphDataFontSize); n.restore() } } } } if (l.legendMsr.dispLegend) drawLegend(l.legendMsr, e, t, n, "Radar") } function d() { var o = 2 * Math.PI / e.datasets[0].data.length; n.save(); n.translate(c, h); n.rotate((90 - t.startAngle) * Math.PI / 180); if (t.angleShowLineOut) { n.strokeStyle = t.angleLineColor; n.lineWidth = t.angleLineWidth; for (var u = 0; u < e.datasets[0].data.length; u++) { n.rotate(o); n.beginPath(); n.moveTo(0, 0); n.lineTo(0, -r); n.stroke() } } for (var a = 0; a < s.steps; a++) { n.beginPath(); if (t.scaleShowLine) { n.strokeStyle = t.scaleLineColor; n.lineWidth = t.scaleLineWidth; n.moveTo(0, -i * (a + 1)); for (var f = 0; f < e.datasets[0].data.length; f++) { n.rotate(o); n.lineTo(0, -i * (a + 1)) } n.closePath(); n.stroke() } } n.rotate(-(90 - t.startAngle) * Math.PI / 180); if (t.scaleShowLabels) { for (var a = 0; a < s.steps; a++) { n.textAlign = "center"; n.font = t.scaleFontStyle + " " + t.scaleFontSize + "px " + t.scaleFontFamily; n.textBaseline = "middle"; if (t.scaleShowLabelBackdrop) { var l = n.measureTextMultiLine(s.labels[a + 1], t.scaleFontSize).textWidth; n.fillStyle = t.scaleBackdropColor; n.beginPath(); n.rect(Math.round(Math.cos(t.startAngle * Math.PI / 180) * i * (a + 1) - l / 2 - t.scaleBackdropPaddingX), Math.round(-Math.sin(t.startAngle * Math.PI / 180) * i * (a + 1) - t.scaleFontSize * .5 - t.scaleBackdropPaddingY), Math.round(l + t.scaleBackdropPaddingX * 2), Math.round(t.scaleFontSize + t.scaleBackdropPaddingY * 2)); n.fill() } n.fillStyle = t.scaleFontColor; n.fillTextMultiLine(s.labels[a + 1], Math.cos(t.startAngle * Math.PI / 180) * i * (a + 1), -Math.sin(t.startAngle * Math.PI / 180) * i * (a + 1), n.textBaseline, t.scaleFontSize) } } for (var p = 0; p < e.labels.length; p++) { n.font = t.pointLabelFontStyle + " " + t.pointLabelFontSize + "px " + t.pointLabelFontFamily; n.fillStyle = t.pointLabelFontColor; var d = Math.sin((90 - t.startAngle) * Math.PI / 180 + o * p) * (r + t.pointLabelFontSize); var v = Math.cos((90 - t.startAngle) * Math.PI / 180 + o * p) * (r + t.pointLabelFontSize); var m = (90 - t.startAngle) * Math.PI / 180 + o * p; while (m < 0) m = m + 2 * Math.PI; while (m > 2 * Math.PI) m = m - 2 * Math.PI; if (m == Math.PI || m == 0) { n.textAlign = "center" } else if (m > Math.PI) { n.textAlign = "right" } else { n.textAlign = "left" } n.textBaseline = "middle"; n.fillTextMultiLine(e.labels[p], d, -v, n.textBaseline, t.pointLabelFontSize) } n.restore() } function v() { var i, s, u, a, f, h, p, d; var v = 2 * Math.PI / e.datasets[0].data.length; var m = t.startAngle * Math.PI / 180; n.font = t.pointLabelFontStyle + " " + t.pointLabelFontSize + "px " + t.pointLabelFontFamily; if (!t.graphMaximized) { a = l.availableWidth / 2; u = l.availableWidth / 2; h = 1 } else { a = l.availableWidth / 2; u = l.availableWidth / 2; h = 40; for (var g = 0; g < e.labels.length; g++) { var y = n.measureTextMultiLine(e.labels[g], t.scaleFontSize).textWidth + n.measureTextMultiLine(e.labels[g], t.scaleFontSize).textHeight; s = (l.availableWidth - y) / (1 + Math.abs(Math.cos(m))); if (m < Math.PI / 2 && m > -Math.PI / 2 || m > 3 * Math.PI / 2) { if (s < a) a = s } else if (Math.cos(m) != 0) { if (s < u) u = s } m -= v } } p = 0; d = 0; c = a + l.rightNotUsableSize; for (i = a, f = 0; f < h; ++f, i += (l.availableWidth - u - a) / h) { r = Max([i, l.availableWidth - i]); var m = t.startAngle * Math.PI / 180; s = l.available; for (var g = 0; g < e.labels.length; g++) { var y = n.measureTextMultiLine(e.labels[g], t.scaleFontSize).textWidth + n.measureTextMultiLine(e.labels[g], t.scaleFontSize).textHeight; if (m < Math.PI / 2 && m > -Math.PI / 2 || m > 3 * Math.PI / 2) { s = (l.availableWidth - i - y) / Math.abs(Math.cos(m)) } else if (Math.cos(m != 0)) { s = (i - y) / Math.abs(Math.cos(m)) } if (s < r) r = s; if (Math.sin(m) * l.availableHeight / 2 > l.availableHeight / 2 - t.scaleFontSize * 2) { s = Math.sin(m) * l.availableHeight / 2 - 1.5 * t.scaleFontSize; if (s < r) r = s } m -= v } if (r > p) { p = r; c = i + l.rightNotUsableSize } } r = p - t.scaleFontSize / 2; o = Default(o, 5) } function m() { var n = Number.MIN_VALUE; var r = Number.MAX_VALUE; for (var i = 0; i < e.datasets.length; i++) { for (var s = 0; s < e.datasets[i].data.length; s++) { if (1 * e.datasets[i].data[s] > n) { n = 1 * e.datasets[i].data[s] } if (1 * e.datasets[i].data[s] < r) { r = 1 * e.datasets[i].data[s] } } } if (Math.abs(n - r) < 1e-8) { n = Max([n * 2, 1]); r = 0 } if (!isNaN(t.graphMin)) r = t.graphMin; if (!isNaN(t.graphMax)) n = t.graphMax; var a = Math.floor(u / (o * .66)); var f = Math.floor(u / o * .5); return { maxValue: n, minValue: r, maxSteps: a, minSteps: f } } var r, i, s, o, u, a, f, l, c, h; setting_new_chart_vars(n, "Radar"); if (!dynamicFunction(e, t, n, "Radar")) return; while (t.startAngle < 0) { t.startAngle += 360 } while (t.startAngle > 360) { t.startAngle -= 360 } t.logarithmic = false; t.logarithmic2 = false; if (typeof jsGraphAnnotate[n.ChartNewId] == "undefined") jsGraphAnnotate[n.ChartNewId] = new Array; else if (!t.multiGraph) clearAnnotate(n.ChartNewId); defMouse(n, e, t, "Radar"); if (!e.labels) e.labels = []; setRect(n, t); a = m(); f = t.scaleShowLabels ? t.scaleLabel : ""; if (!t.scaleOverride) { s = calculateScale(1, t, a.maxSteps, a.minSteps, a.maxValue, a.minValue, f); l = setMeasures(e, t, n, height, width, s.labels, null, true, false, false, true, t.datasetFill, "Radar") } else { s = { steps: t.scaleSteps, stepValue: t.scaleStepWidth, graphMin: t.scaleStartValue, graphMax: t.scaleStartValue + t.scaleSteps * t.scaleStepWidth, labels: [] }; populateLabels(1, t, f, s.labels, s.steps, t.scaleStartValue, s.graphMax, t.scaleStepWidth); l = setMeasures(e, t, n, height, width, s.labels, null, true, false, false, true, t.datasetFill, "Radar") } v(); h = l.topNotUsableSize + l.availableHeight / 2; i = r / s.steps; animationLoop(t, d, p, n, l.clrx, l.clry, l.clrwidth, l.clrheight, c, h, c - r, h + r, e); }; var Pie = function (e, t, n) { function f(a) { var f = -t.startAngle * (Math.PI / 180) + 2 * Math.PI, l = 0, c = 1, h = 1; var p = t.startAngle * (Math.PI / 180) + 2 * Math.PI; while (f < 0) { f += 2 * Math.PI } while (f > 2 * Math.PI) { f -= 2 * Math.PI } while (p < 0) { p += 2 * Math.PI } while (p > 2 * Math.PI) { p -= 2 * Math.PI } if (t.animation) { if (t.animateScale) { c = a } if (t.animateRotate) { h = a } } if (a >= 1) { totvalue = 0; for (var d = 0; d < e.length; d++) if (!(typeof e[d].value == "undefined")) totvalue += 1 * e[d].value } for (var d = 0; d < e.length; d++) { correctedRotateAnimation = animationCorrection(h, e, t, d, -1, 0).mainVal; if (!(typeof e[d].value == "undefined")) { var v = correctedRotateAnimation * 1 * e[d].value / r * Math.PI * 2; if (v >= Math.PI * 2) v = Math.PI * 2 - .001; n.beginPath(); n.arc(s, o, c * u, f, f + v); n.lineTo(s, o); n.closePath(); if (typeof e[d].color == "function") n.fillStyle = e[d].color("COLOR", e, t, d, -1, a, e[d].value, "Pie", n, s, o, 0, c * u); else n.fillStyle = e[d].color; n.fill(); f += v; l += 1 * e[d].value; if (t.segmentShowStroke) { n.lineWidth = t.segmentStrokeWidth; n.strokeStyle = t.segmentStrokeColor; n.stroke() } } } if (a >= 1) { f -= 2 * Math.PI; for (var d = 0; d < e.length; d++) { correctedRotateAnimation = animationCorrection(h, e, t, d, -1, 0).mainVal; if (!(typeof e[d].value == "undefined")) { var v = correctedRotateAnimation * 1 * e[d].value / r * Math.PI * 2; if (v >= Math.PI * 2) v = Math.PI * 2 - .001; f += v; l += 1 * e[d].value; if (typeof e[d].title == "string") lgtxt = e[d].title.trim(); else lgtxt = ""; jsGraphAnnotate[n.ChartNewId][jsGraphAnnotate[n.ChartNewId].length] = ["ARC", s, o, 0, u, f - v, f, lgtxt, 1 * e[d].value, l, totvalue, v, d]; if (t.inGraphDataShow && v >= Math.PI / 180 * t.inGraphDataMinimumAngle) { if (t.inGraphDataAnglePosition == 1) posAngle = p + t.inGraphDataPaddingAngle * (Math.PI / 180); else if (t.inGraphDataAnglePosition == 2) posAngle = p - v / 2 + t.inGraphDataPaddingAngle * (Math.PI / 180); else if (t.inGraphDataAnglePosition == 3) posAngle = p - v + t.inGraphDataPaddingAngle * (Math.PI / 180); if (t.inGraphDataRadiusPosition == 1) labelRadius = 0 + t.inGraphDataPaddingRadius; else if (t.inGraphDataRadiusPosition == 2) labelRadius = u / 2 + t.inGraphDataPaddingRadius; else if (t.inGraphDataRadiusPosition == 3) labelRadius = u + t.inGraphDataPaddingRadius; n.save(); if (t.inGraphDataAlign == "off-center") { if (t.inGraphDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) n.textAlign = "left"; else n.textAlign = "right" } else if (t.inGraphDataAlign == "to-center") { if (t.inGraphDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) n.textAlign = "right"; else n.textAlign = "left" } else n.textAlign = t.inGraphDataAlign; if (t.inGraphDataVAlign == "off-center") { if ((posAngle + 2 * Math.PI) % (2 * Math.PI) > Math.PI) n.textBaseline = "top"; else n.textBaseline = "bottom" } else if (t.inGraphDataVAlign == "to-center") { if ((posAngle + 2 * Math.PI) % (2 * Math.PI) > Math.PI) n.textBaseline = "bottom"; else n.textBaseline = "top" } else n.textBaseline = t.inGraphDataVAlign; n.font = t.inGraphDataFontStyle + " " + t.inGraphDataFontSize + "px " + t.inGraphDataFontFamily; n.fillStyle = t.inGraphDataFontColor; var m = tmplbis(t.inGraphDataTmpl, { config: t, v1: fmtChartJS(t, lgtxt, t.fmtV1), v2: fmtChartJS(t, 1 * e[d].value, t.fmtV2), v3: fmtChartJS(t, l, t.fmtV3), v4: fmtChartJS(t, totvalue, t.fmtV4), v5: fmtChartJS(t, v, t.fmtV5), v6: roundToWithThousands(t, fmtChartJS(t, 100 * e[d].value / totvalue, t.fmtV6), t.roundPct), v7: fmtChartJS(t, s, t.fmtV7), v8: fmtChartJS(t, o, t.fmtV8), v9: fmtChartJS(t, 0, t.fmtV9), v10: fmtChartJS(t, u, t.fmtV10), v11: fmtChartJS(t, f - v, t.fmtV11), v12: fmtChartJS(t, f, t.fmtV12), v13: fmtChartJS(t, d, t.fmtV13), data: e }); n.translate(s + labelRadius * Math.cos(posAngle), o - labelRadius * Math.sin(posAngle)); if (t.inGraphDataRotate == "inRadiusAxis") n.rotate(2 * Math.PI - posAngle); else if (t.inGraphDataRotate == "inRadiusAxisRotateLabels") { if ((posAngle + 2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (posAngle + 2 * Math.PI) % (2 * Math.PI) < 3 * Math.PI / 2) n.rotate(3 * Math.PI - posAngle); else n.rotate(2 * Math.PI - posAngle) } else n.rotate(t.inGraphDataRotate * (Math.PI / 180)); n.fillTextMultiLine(m, 0, 0, n.textBaseline, t.inGraphDataFontSize); n.restore() } p -= v } } } if (i.legendMsr.dispLegend) drawLegend(i.legendMsr, e, t, n, "Pie") } function l() { var a; var f = -t.startAngle * (Math.PI / 180) + 2 * Math.PI, l = 0; while (f < 0) { f += 2 * Math.PI } while (f > 2 * Math.PI) { f -= 2 * Math.PI } s = i.leftNotUsableSize + i.availableWidth / 2; o = i.topNotUsableSize + i.availableHeight / 2; u = Min([i.availableHeight / 2, i.availableWidth / 2]) - 5; if (t.inGraphDataShow && t.inGraphDataRadiusPosition == 3 && t.inGraphDataAlign == "off-center" && t.inGraphDataRotate == 0) { u = Min([i.availableHeight / 2, i.availableWidth / 2]) - t.inGraphDataFontSize - t.inGraphDataPaddingRadius - 5; var c = t.startAngle * (Math.PI / 180) + 2 * Math.PI; while (c < 0) { c += 2 * Math.PI } while (c > 2 * Math.PI) { c -= 2 * Math.PI } var h = 0; for (var p = 0; p < e.length; p++) if (!(typeof e[p].value == "undefined")) h += 1 * e[p].value; n.font = t.inGraphDataFontStyle + " " + t.inGraphDataFontSize + "px " + t.inGraphDataFontFamily; var l = 0; var d; for (var p = 0; p < e.length; p++) { if (!(typeof e[p].value == "undefined")) { l += 1 * e[p].value; var v = 1 * e[p].value / r * Math.PI * 2; f += v; if (t.inGraphDataAnglePosition == 1) d = c + t.inGraphDataPaddingAngle * (Math.PI / 180); else if (t.inGraphDataAnglePosition == 2) d = c - v / 2 + t.inGraphDataPaddingAngle * (Math.PI / 180); else if (t.inGraphDataAnglePosition == 3) d = c - v + t.inGraphDataPaddingAngle * (Math.PI / 180); c -= v; if (typeof e[p].title == "string") a = e[p].title.trim(); else a = ""; var m = tmplbis(t.inGraphDataTmpl, { config: t, v1: fmtChartJS(t, a, t.fmtV1), v2: fmtChartJS(t, 1 * e[p].value, t.fmtV2), v3: fmtChartJS(t, l, t.fmtV3), v4: fmtChartJS(t, h, t.fmtV4), v5: fmtChartJS(t, v, t.fmtV5), v6: roundToWithThousands(t, fmtChartJS(t, 100 * e[p].value / h, t.fmtV6), t.roundPct), v7: fmtChartJS(t, s, t.fmtV7), v8: fmtChartJS(t, o, t.fmtV8), v9: fmtChartJS(t, 0, t.fmtV9), v10: fmtChartJS(t, u, t.fmtV10), v11: fmtChartJS(t, f - v, t.fmtV11), v12: fmtChartJS(t, f, t.fmtV12), v13: fmtChartJS(t, p, t.fmtV13), data: e }); var g = n.measureText(m).width; var y = Math.abs((i.availableWidth / 2 - g) / Math.cos(d)) - t.inGraphDataPaddingRadius - 5; if (y < u) u = y } } } u = u * t.radiusScale } var r = 0; var i, s, o, u; setting_new_chart_vars(n, "Pie"); if (!dynamicFunction(e, t, n, "Pie")) return; while (t.startAngle < 0) { t.startAngle += 360 } while (t.startAngle > 360) { t.startAngle -= 360 } t.logarithmic = false; t.logarithmic2 = false; if (typeof jsGraphAnnotate[n.ChartNewId] == "undefined") jsGraphAnnotate[n.ChartNewId] = new Array; else if (!t.multiGraph) clearAnnotate(n.ChartNewId); defMouse(n, e, t, "Pie"); setRect(n, t); i = setMeasures(e, t, n, height, width, "none", null, true, false, false, false, true, "Pie"); for (var a = 0; a < e.length; a++) { if (!(typeof e[a].value == "undefined")) r += 1 * e[a].value } l(); animationLoop(t, null, f, n, i.clrx, i.clry, i.clrwidth, i.clrheight, s, o, s - u, o + u, e); }; var Doughnut = function (e, t, n) { function c(l) { var c = -t.startAngle * (Math.PI / 180) + 2 * Math.PI, h = 0, p = 1, d = 1; while (c < 0) { c += 2 * Math.PI } while (c > 2 * Math.PI) { c -= 2 * Math.PI } if (t.animation) { if (t.animateScale) { p = l } if (t.animateRotate) { d = l } } if (l >= 1) { totvalue = 0; for (var v = 0; v < e.length; v++) if (!(typeof e[v].value == "undefined")) totvalue += 1 * e[v].value } for (var v = 0; v < e.length; v++) { correctedRotateAnimation = animationCorrection(d, e, t, v, -1, 0).mainVal; if (!(typeof e[v].value == "undefined")) { var m = correctedRotateAnimation * 1 * e[v].value / r * Math.PI * 2; if (m >= Math.PI * 2) m = Math.PI * 2 - .001; n.beginPath(); n.arc(s, o, p * u, c, c + m, false); n.arc(s, o, p * f, c + m, c, true); n.closePath(); if (typeof e[v].color == "function") n.fillStyle = e[v].color("COLOR", e, t, v, -1, l, e[v].value, "Doughnut", n, s, o, p * f, p * u); else n.fillStyle = e[v].color; n.fill(); c += m; h += 1 * e[v].value; if (t.segmentShowStroke) { n.lineWidth = t.segmentStrokeWidth; n.strokeStyle = t.segmentStrokeColor; n.stroke() } } } if (l >= 1) { c -= 2 * Math.PI; for (var v = 0; v < e.length; v++) { correctedRotateAnimation = animationCorrection(d, e, t, v, -1, 0).mainVal; if (!(typeof e[v].value == "undefined")) { var m = correctedRotateAnimation * 1 * e[v].value / r * Math.PI * 2; if (m >= Math.PI * 2) m = Math.PI * 2 - .001; c += m; h += 1 * e[v].value; if (typeof e[v].title == "string") lgtxt = e[v].title.trim(); else lgtxt = ""; jsGraphAnnotate[n.ChartNewId][jsGraphAnnotate[n.ChartNewId].length] = ["ARC", s, o, f, u, c - m, c, lgtxt, 1 * e[v].value, h, totvalue, m, v]; if (t.inGraphDataShow && m >= Math.PI / 180 * t.inGraphDataMinimumAngle) { if (t.inGraphDataAnglePosition == 1) posAngle = a + t.inGraphDataPaddingAngle * (Math.PI / 180); else if (t.inGraphDataAnglePosition == 2) posAngle = a - m / 2 + t.inGraphDataPaddingAngle * (Math.PI / 180); else if (t.inGraphDataAnglePosition == 3) posAngle = a - m + t.inGraphDataPaddingAngle * (Math.PI / 180); if (t.inGraphDataRadiusPosition == 1) labelRadius = f + t.inGraphDataPaddingRadius; else if (t.inGraphDataRadiusPosition == 2) labelRadius = f + (u - f) / 2 + t.inGraphDataPaddingRadius; else if (t.inGraphDataRadiusPosition == 3) labelRadius = u + t.inGraphDataPaddingRadius; n.save(); if (t.inGraphDataAlign == "off-center") { if (t.inGraphDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) n.textAlign = "left"; else n.textAlign = "right" } else if (t.inGraphDataAlign == "to-center") { if (t.inGraphDataRotate == "inRadiusAxis" || (posAngle + 2 * Math.PI) % (2 * Math.PI) > 3 * Math.PI / 2 || (posAngle + 2 * Math.PI) % (2 * Math.PI) < Math.PI / 2) n.textAlign = "right"; else n.textAlign = "left" } else n.textAlign = t.inGraphDataAlign; if (t.inGraphDataVAlign == "off-center") { if ((posAngle + 2 * Math.PI) % (2 * Math.PI) > Math.PI) n.textBaseline = "top"; else n.textBaseline = "bottom" } else if (t.inGraphDataVAlign == "to-center") { if ((posAngle + 2 * Math.PI) % (2 * Math.PI) > Math.PI) n.textBaseline = "bottom"; else n.textBaseline = "top" } else n.textBaseline = t.inGraphDataVAlign; n.font = t.inGraphDataFontStyle + " " + t.inGraphDataFontSize + "px " + t.inGraphDataFontFamily; n.fillStyle = t.inGraphDataFontColor; var g = tmplbis(t.inGraphDataTmpl, { config: t, v1: fmtChartJS(t, lgtxt, t.fmtV1), v2: fmtChartJS(t, 1 * e[v].value, t.fmtV2), v3: fmtChartJS(t, h, t.fmtV3), v4: fmtChartJS(t, totvalue, t.fmtV4), v5: fmtChartJS(t, m, t.fmtV5), v6: roundToWithThousands(t, fmtChartJS(t, 100 * e[v].value / totvalue, t.fmtV6), t.roundPct), v7: fmtChartJS(t, s, t.fmtV7), v8: fmtChartJS(t, o, t.fmtV8), v9: fmtChartJS(t, f, t.fmtV9), v10: fmtChartJS(t, u, t.fmtV10), v11: fmtChartJS(t, c - m, t.fmtV11), v12: fmtChartJS(t, c, t.fmtV12), v13: fmtChartJS(t, v, t.fmtV13) }); n.translate(s + labelRadius * Math.cos(posAngle), o - labelRadius * Math.sin(posAngle)); if (t.inGraphDataRotate == "inRadiusAxis") n.rotate(2 * Math.PI - posAngle); else if (t.inGraphDataRotate == "inRadiusAxisRotateLabels") { if ((posAngle + 2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (posAngle + 2 * Math.PI) % (2 * Math.PI) < 3 * Math.PI / 2) n.rotate(3 * Math.PI - posAngle); else n.rotate(2 * Math.PI - posAngle) } else n.rotate(t.inGraphDataRotate * (Math.PI / 180)); n.fillTextMultiLine(g, 0, 0, n.textBaseline, t.inGraphDataFontSize); n.restore() } a -= m } } } if (i.legendMsr.dispLegend) drawLegend(i.legendMsr, e, t, n, "Doughnut") } function h() { var a; var l = -t.startAngle * (Math.PI / 180) + 2 * Math.PI, c = 0; while (l < 0) { l += 2 * Math.PI } while (l > 2 * Math.PI) { l -= 2 * Math.PI } s = i.leftNotUsableSize + i.availableWidth / 2; o = i.topNotUsableSize + i.availableHeight / 2; u = Min([i.availableHeight / 2, i.availableWidth / 2]) - 5; if (t.inGraphDataShow && t.inGraphDataRadiusPosition == 3 && t.inGraphDataAlign == "off-center" && t.inGraphDataRotate == 0) { u = Min([i.availableHeight / 2, i.availableWidth / 2]) - t.inGraphDataFontSize - t.inGraphDataPaddingRadius - 5; var h = t.startAngle * (Math.PI / 180) + 2 * Math.PI; while (h < 0) { h += 2 * Math.PI } while (h > 2 * Math.PI) { h -= 2 * Math.PI } var p = 0; for (var d = 0; d < e.length; d++) if (!(typeof e[d].value == "undefined")) p += 1 * e[d].value; n.font = t.inGraphDataFontStyle + " " + t.inGraphDataFontSize + "px " + t.inGraphDataFontFamily; var v; var l = 0; for (var d = 0; d < e.length; d++) { if (!(typeof e[d].value == "undefined")) { c += 1 * e[d].value; var m = 1 * e[d].value / r * Math.PI * 2; l += m; if (t.inGraphDataAnglePosition == 1) v = h + t.inGraphDataPaddingAngle * (Math.PI / 180); else if (t.inGraphDataAnglePosition == 2) v = h - m / 2 + t.inGraphDataPaddingAngle * (Math.PI / 180); else if (t.inGraphDataAnglePosition == 3) v = h - m + t.inGraphDataPaddingAngle * (Math.PI / 180); h -= m; if (typeof e[d].title == "string") a = e[d].title.trim(); else a = ""; var g = tmplbis(t.inGraphDataTmpl, { config: t, v1: fmtChartJS(t, a, t.fmtV1), v2: fmtChartJS(t, 1 * e[d].value, t.fmtV2), v3: fmtChartJS(t, c, t.fmtV3), v4: fmtChartJS(t, p, t.fmtV4), v5: fmtChartJS(t, m, t.fmtV5), v6: roundToWithThousands(t, fmtChartJS(t, 100 * e[d].value / p, t.fmtV6), t.roundPct), v7: fmtChartJS(t, s, t.fmtV7), v8: fmtChartJS(t, o, t.fmtV8), v9: fmtChartJS(t, f, t.fmtV9), v10: fmtChartJS(t, u, t.fmtV10), v11: fmtChartJS(t, l - m, t.fmtV11), v12: fmtChartJS(t, l, t.fmtV12), v13: fmtChartJS(t, d, t.fmtV13), data: e }); var y = n.measureText(g).width; var b = Math.abs((i.availableWidth / 2 - y) / Math.cos(v)) - t.inGraphDataPaddingRadius - 5; if (b < u) u = b } } } u = u * t.radiusScale } var r = 0; var i, s, o, u; setting_new_chart_vars(n, "Doughnut"); if (!dynamicFunction(e, t, n, "Doughnut")) return; var a = t.startAngle * (Math.PI / 180) + 2 * Math.PI; while (t.startAngle < 0) { t.startAngle += 360 } while (t.startAngle > 360) { t.startAngle -= 360 } while (a < 0) { a += 2 * Math.PI } while (a > 2 * Math.PI) { a -= 2 * Math.PI } t.logarithmic = false; t.logarithmic2 = false; if (typeof jsGraphAnnotate[n.ChartNewId] == "undefined") jsGraphAnnotate[n.ChartNewId] = new Array; else if (!t.multiGraph) clearAnnotate(n.ChartNewId); defMouse(n, e, t, "Doughnut"); setRect(n, t); i = setMeasures(e, t, n, height, width, "none", null, true, false, false, false, true, "Doughnut"); h(); var f = u * (t.percentageInnerCutout / 100); for (var l = 0; l < e.length; l++) { if (!(typeof e[l].value == "undefined")) r += 1 * e[l].value } animationLoop(t, null, c, n, i.clrx, i.clry, i.clrwidth, i.clrheight, s, o, s - u, o + u, e); }; var Line = function (data, config, ctx) { function drawLines(e) { drawLinesDataset(1, e, data, config, ctx, offsets, { xAxisPosY: xAxisPosY, yAxisPosX: yAxisPosX, valueHop: valueHop, nbValueHop: data.labels.length - 1, scaleHop: scaleHop, zeroY: zeroY, calculatedScale: calculatedScale, logarithmic: config.logarithmic }); drawLinesDataset(2, e, data, config, ctx, offsets, { xAxisPosY: xAxisPosY, yAxisPosX: yAxisPosX, valueHop: valueHop, nbValueHop: data.labels.length - 1, scaleHop: scaleHop2, zeroY: zeroY2, calculatedScale: calculatedScale2, logarithmic: config.logarithmic2 }); if (e >= 1) { if (typeof drawMath == "function") { drawMath(ctx, config, data, msr, { xAxisPosY: xAxisPosY, yAxisPosX: yAxisPosX, valueHop: valueHop, scaleHop: scaleHop, zeroY: zeroY, calculatedScale: calculatedScale, calculateOffset: calculateOffset }) } } if (msr.legendMsr.dispLegend) drawLegend(msr.legendMsr, data, config, ctx, "Line") } function drawScale() { if (config.drawXScaleLine !== false) { for (var e = 0; e < config.drawXScaleLine.length; e++) { ctx.lineWidth = config.drawXScaleLine[e].lineWidth ? config.drawXScaleLine[e].lineWidth : config.scaleLineWidth; ctx.strokeStyle = config.drawXScaleLine[e].lineColor ? config.drawXScaleLine[e].lineColor : config.scaleLineColor; ctx.beginPath(); var t; switch (config.drawXScaleLine[e].position) { case "bottom": t = xAxisPosY; break; case "top": t = xAxisPosY - msr.availableHeight - config.scaleTickSizeTop; break; case "0": case 0: if (zeroY != 0) { t = xAxisPosY - zeroY } break } ctx.moveTo(yAxisPosX - config.scaleTickSizeLeft, t); ctx.lineTo(yAxisPosX + msr.availableWidth + config.scaleTickSizeRight, t); ctx.stroke() } } for (var n = 0; n < data.labels.length; n++) { ctx.beginPath(); ctx.moveTo(yAxisPosX + n * valueHop, xAxisPosY + config.scaleTickSizeBottom); ctx.lineWidth = config.scaleGridLineWidth; ctx.strokeStyle = config.scaleGridLineColor; if (config.scaleShowGridLines && n > 0 && n % config.scaleXGridLinesStep == 0) { ctx.lineTo(yAxisPosX + n * valueHop, xAxisPosY - msr.availableHeight - config.scaleTickSizeTop) } else { ctx.lineTo(yAxisPosX + n * valueHop, xAxisPosY) } ctx.stroke() } ctx.lineWidth = config.scaleLineWidth; ctx.strokeStyle = config.scaleLineColor; ctx.beginPath(); ctx.moveTo(yAxisPosX, xAxisPosY + config.scaleTickSizeBottom); ctx.lineTo(yAxisPosX, xAxisPosY - msr.availableHeight - config.scaleTickSizeTop); ctx.stroke(); for (var r = 0; r < calculatedScale.steps; r++) { ctx.beginPath(); ctx.moveTo(yAxisPosX - config.scaleTickSizeLeft, xAxisPosY - (r + 1) * scaleHop); ctx.lineWidth = config.scaleGridLineWidth; ctx.strokeStyle = config.scaleGridLineColor; if (config.scaleShowGridLines && r % config.scaleYGridLinesStep == 0) { ctx.lineTo(yAxisPosX + msr.availableWidth + config.scaleTickSizeRight, xAxisPosY - (r + 1) * scaleHop) } else { ctx.lineTo(yAxisPosX, xAxisPosY - (r + 1) * scaleHop) } ctx.stroke() } } function drawLabels() { ctx.font = config.scaleFontStyle + " " + config.scaleFontSize + "px " + config.scaleFontFamily; if (config.xAxisTop || config.xAxisBottom) { ctx.textBaseline = "top"; if (msr.rotateLabels > 90) { ctx.save(); ctx.textAlign = "left" } else if (msr.rotateLabels > 0) { ctx.save(); ctx.textAlign = "right" } else { ctx.textAlign = "center" } ctx.fillStyle = config.scaleFontColor; if (config.xAxisBottom) { for (var e = 0; e < data.labels.length; e++) { ctx.save(); if (msr.rotateLabels > 0) { ctx.translate(yAxisPosX + e * valueHop - msr.highestXLabel / 2, msr.xLabelPos); ctx.rotate(-(msr.rotateLabels * (Math.PI / 180))); ctx.fillTextMultiLine(fmtChartJS(config, data.labels[e], config.fmtXLabel), 0, 0, ctx.textBaseline, config.scaleFontSize) } else { ctx.fillTextMultiLine(fmtChartJS(config, data.labels[e], config.fmtXLabel), yAxisPosX + e * valueHop, msr.xLabelPos, ctx.textBaseline, config.scaleFontSize) } ctx.restore() } } } ctx.textAlign = "right"; ctx.textBaseline = "middle"; for (var t = config.showYAxisMin ? -1 : 0; t < calculatedScale.steps; t++) { if (config.scaleShowLabels) { if (config.yAxisLeft) { ctx.textAlign = "right"; ctx.fillTextMultiLine(calculatedScale.labels[t + 1], yAxisPosX - (config.scaleTickSizeLeft + config.yAxisSpaceRight), xAxisPosY - (t + 1) * scaleHop, ctx.textBaseline, config.scaleFontSize) } if (config.yAxisRight && !valueBounds.dbAxis) { ctx.textAlign = "left"; ctx.fillTextMultiLine(calculatedScale.labels[t + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRight + config.yAxisSpaceRight), xAxisPosY - (t + 1) * scaleHop, ctx.textBaseline, config.scaleFontSize) } } } if (config.yAxisRight && valueBounds.dbAxis) { for (var t = config.showYAxisMin ? -1 : 0; t < calculatedScale2.steps; t++) { if (config.scaleShowLabels) { ctx.textAlign = "left"; ctx.fillTextMultiLine(calculatedScale2.labels[t + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRight + config.yAxisSpaceRight), xAxisPosY - (t + 1) * scaleHop2, ctx.textBaseline, config.scaleFontSize) } } } } function getValueBounds() { var upperValue = Number.MIN_VALUE; var lowerValue = Number.MAX_VALUE; var upperValue2 = Number.MIN_VALUE; var lowerValue2 = Number.MAX_VALUE; var secondAxis = false; var firstAxis = false; for (var i = 0; i < data.datasets.length; i++) { var mathFctName = data.datasets[i].drawMathDeviation; var mathValueHeight = 0; if (typeof eval(mathFctName) == "function") { var parameter = { data: data, datasetNr: i }; mathValueHeight = window[mathFctName](parameter) } for (var j = 0; j < data.datasets[i].data.length; j++) { if (data.datasets[i].axis == 2) { secondAxis = true; if (1 * data.datasets[i].data[j] + mathValueHeight > upperValue2) { upperValue2 = 1 * data.datasets[i].data[j] + mathValueHeight } if (1 * data.datasets[i].data[j] - mathValueHeight < lowerValue2) { lowerValue2 = 1 * data.datasets[i].data[j] - mathValueHeight } } else { firstAxis = true; if (1 * data.datasets[i].data[j] + mathValueHeight > upperValue) { upperValue = 1 * data.datasets[i].data[j] + mathValueHeight } if (1 * data.datasets[i].data[j] - mathValueHeight < lowerValue) { lowerValue = 1 * data.datasets[i].data[j] - mathValueHeight } } } } if (Math.abs(upperValue - lowerValue) < 1e-8) { upperValue = Max([upperValue * 2, 1]); lowerValue = 0 } if (!isNaN(config.graphMin)) lowerValue = config.graphMin; if (!isNaN(config.graphMax)) upperValue = config.graphMax; if (secondAxis) { if (Math.abs(upperValue2 - lowerValue2) < 1e-8) { upperValue2 = Max([upperValue2 * 2, 1]); lowerValue2 = 0 } if (!isNaN(config.graphMin2)) lowerValue2 = config.graphMin2; if (!isNaN(config.graphMax2)) upperValue2 = config.graphMax2 } if (!firstAxis && secondAxis) { upperValue = upperValue2; lowerValue = lowerValue2 } labelHeight = config.scaleFontSize; scaleHeight = msr.availableHeight; var maxSteps = Math.floor(scaleHeight / (labelHeight * .66)); var minSteps = Math.floor(scaleHeight / labelHeight * .5); return { maxValue: upperValue, minValue: lowerValue, maxValue2: upperValue2, minValue2: lowerValue2, dbAxis: secondAxis, maxSteps: maxSteps, minSteps: minSteps } } var maxSize, scaleHop, scaleHop2, calculatedScale, calculatedScale2, labelHeight, scaleHeight, valueBounds, labelTemplateString, labelTemplateString2; var valueHop, widestXLabel, xAxisLength, yAxisPosX, xAxisPosY, rotateLabels = 0, msr; var zeroY = 0; var zeroY2 = 0; var offsets = []; setting_new_chart_vars(ctx, "Line"); var mxlgt = 0; for (var i = 0; i < data.datasets.length; i++) mxlgt = Max([mxlgt, data.datasets[i].data.length]); if (mxlgt == 1) { if (typeof data.labels[0] == "string") data.labels = ["", data.labels[0], ""]; for (var i = 0; i < data.datasets.length; i++) { if (typeof (data.datasets[i].data[0] != "undefined")) data.datasets[i].data = [undefined, data.datasets[i].data[0], undefined] } } if (!dynamicFunction(data, config, ctx, "Line")) return; if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGraphAnnotate[ctx.ChartNewId] = new Array; else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); defMouse(ctx, data, config, "Line"); setRect(ctx, config); msr = setMeasures(data, config, ctx, height, width, "nihil", [""], false, false, true, true, config.datasetFill, "Line"); valueBounds = getValueBounds(); if (config.logarithmic !== false) { if (valueBounds.minValue <= 0) { config.logarithmic = false } } if (config.logarithmic2 !== false) { if (valueBounds.minValue2 <= 0) { config.logarithmic2 = false } } var OrderOfMagnitude = calculateOrderOfMagnitude(Math.pow(10, calculateOrderOfMagnitude(valueBounds.maxValue) + 1)) - calculateOrderOfMagnitude(Math.pow(10, calculateOrderOfMagnitude(valueBounds.minValue))); if (config.logarithmic == "fuzzy" && OrderOfMagnitude < 4 || config.scaleOverride) { config.logarithmic = false } var OrderOfMagnitude2 = calculateOrderOfMagnitude(Math.pow(10, calculateOrderOfMagnitude(valueBounds.maxValue2) + 1)) - calculateOrderOfMagnitude(Math.pow(10, calculateOrderOfMagnitude(valueBounds.minValue2))); if (config.logarithmic2 == "fuzzy" && OrderOfMagnitude2 < 4 || config.scaleOverride2) { config.logarithmic2 = false } labelTemplateString = config.scaleShowLabels ? config.scaleLabel : ""; labelTemplateString2 = config.scaleShowLabels2 ? config.scaleLabel2 : ""; if (!config.scaleOverride) { calculatedScale = calculateScale(1, config, valueBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minValue, labelTemplateString) } else { calculatedScale = { steps: config.scaleSteps, stepValue: config.scaleStepWidth, graphMin: config.scaleStartValue, graphMax: config.scaleStartValue + config.scaleSteps * config.scaleStepWidth, labels: [] }; populateLabels(1, config, labelTemplateString, calculatedScale.labels, calculatedScale.steps, config.scaleStartValue, calculatedScale.graphMax, config.scaleStepWidth) } if (valueBounds.dbAxis) { if (!config.scaleOverride2) { calculatedScale2 = calculateScale(2, config, valueBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue2, valueBounds.minValue2, labelTemplateString) } else { calculatedScale2 = { steps: config.scaleSteps2, stepValue: config.scaleStepWidth2, graphMin: config.scaleStartValue2, graphMax: config.scaleStartValue2 + config.scaleSteps2 * config.scaleStepWidth2, labels: [] }; populateLabels(2, config, labelTemplateString2, calculatedScale2.labels, calculatedScale2.steps, config.scaleStartValue2, calculatedScale2.graphMax, config.scaleStepWidth2) } } else { calculatedScale2 = { steps: 0, stepValue: 0, graphMin: 0, graphMax: 0, labels: null } } msr = setMeasures(data, config, ctx, height, width, calculatedScale.labels, calculatedScale2.labels, false, false, true, true, config.datasetFill, "Line"); var prevHeight = msr.availableHeight; msr.availableHeight = msr.availableHeight - config.scaleTickSizeBottom - config.scaleTickSizeTop; msr.availableWidth = msr.availableWidth - config.scaleTickSizeLeft - config.scaleTickSizeRight; scaleHop = Math.floor(msr.availableHeight / calculatedScale.steps); scaleHop2 = Math.floor(msr.availableHeight / calculatedScale2.steps); valueHop = Math.floor(msr.availableWidth / (data.labels.length - 1)); if (valueHop == 0 || config.fullWidthGraph) valueHop = msr.availableWidth / (data.labels.length - 1); msr.clrwidth = msr.clrwidth - (msr.availableWidth - (data.labels.length - 1) * valueHop); msr.availableWidth = (data.labels.length - 1) * valueHop; msr.availableHeight = calculatedScale.steps * scaleHop; msr.xLabelPos += config.scaleTickSizeBottom + config.scaleTickSizeTop - (prevHeight - msr.availableHeight); msr.clrheight += config.scaleTickSizeBottom + config.scaleTickSizeTop - (prevHeight - msr.availableHeight); yAxisPosX = msr.leftNotUsableSize + config.scaleTickSizeLeft; xAxisPosY = msr.topNotUsableSize + msr.availableHeight + config.scaleTickSizeTop; drawLabels(); if (valueBounds.minValue < 0) { zeroY = calculateOffset(config.logarithmic, 0, calculatedScale, scaleHop) } if (valueBounds.minValue2 < 0) { zeroY2 = calculateOffset(config.logarithmic2, 0, calculatedScale2, scaleHop2) } for (var i = 0; i < data.datasets.length; i++) { offsets[i] = []; for (var j = 0; j < data.datasets[i].data.length; j++) { if (data.datasets[i].axis == 2) { offsets[i][j] = calculateOffset(config.logarithmic2, data.datasets[i].data[j], calculatedScale2, scaleHop2) - zeroY2 } else { offsets[i][j] = calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop) - zeroY } } } animationLoop(config, drawScale, drawLines, ctx, msr.clrx, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xAxisPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); }; var StackedBar = function (e, t, n) { function w(r) { n.lineWidth = t.barStrokeWidth; var o = new Array(e.datasets.length); var u = new Array(e.datasets.length); var a = new Array; var f = new Array; for (var c = 0; c < e.datasets.length; c++) { for (var h = 0; h < e.datasets[c].data.length; h++) { a[h] = 0; f[h] = 0 } } for (var c = 0; c < e.datasets.length; c++) { for (var h = 0; h < e.datasets[c].data.length; h++) if (!(typeof e.datasets[c].data[h] == "undefined")) { f[h] += 1 * e.datasets[c].data[h] } } for (var c = 0; c < e.datasets.length; c++) { if (r >= 1) { if (typeof e.datasets[c].title == "string") lgtxt = e.datasets[c].title.trim(); else lgtxt = "" } for (var h = 0; h < e.datasets[c].data.length; h++) { var m = animationCorrection(r, e, t, c, h, 1).animVal; if (m > 1) m = m - 1; if (c == 0) { o[h] = 0; u[h] = 0; zeroY = calculateOffset(t.logarithmic, 0, s, i) } var y = p + t.barValueSpacing + l * h; if (!(typeof e.datasets[c].data[h] == "undefined") && 1 * e.datasets[c].data[h] != 0) { if (1 * e.datasets[c].data[h] < 0) { var b = o[h]; var w = o[h] + 1 * e.datasets[c].data[h] } else { var b = u[h]; var w = u[h] + 1 * e.datasets[c].data[h] } if (t.animationByDataset) { var E = d - calculateOffset(t.logarithmic, b, s, i); var S = d - calculateOffset(t.logarithmic, w, s, i); S = E + m * (S - E) } else { var E = d - calculateOffset(t.logarithmic, m * b, s, i); var S = d - calculateOffset(t.logarithmic, m * w, s, i) } n.fillStyle = t.defaultFillColor; if (typeof e.datasets[c].fillColor == "function") n.fillStyle = e.datasets[c].fillColor("FILLCOLOR", e, t, c, h, m, 1 * e.datasets[c].data[h], "StackedBar", n, y, E, y + v, S); else if (typeof e.datasets[c].fillColor == "string") { n.fillStyle = e.datasets[c].fillColor } else if (typeof e.datasets[c].fillColor == "object") { if (typeof e.datasets[c].fillColor[0] == "string") { n.fillStyle = e.datasets[c].fillColor[Min([e.datasets[c].fillColor.length - 1, h])] } } n.strokeStyle = t.defaultStrokeColor; if (typeof e.datasets[c].strokeColor == "function") n.strokeStyle = e.datasets[c].strokeColor("STROKECOLOR", e, t, c, h, m, 1 * e.datasets[c].data[h], "StackedBar", n, y, E, y + barwidth, S); else if (typeof e.datasets[c].strokeColor == "string") { n.strokeStyle = e.datasets[c].strokeColor } else if (typeof e.datasets[c].strokeColor == "object") { if (typeof e.datasets[c].strokeColor[0] == "string") { n.strokeStyle = e.datasets[c].strokeColor[Min([e.datasets[c].strokeColor.length - 1, h])] } } if (m != 0) { n.beginPath(); n.moveTo(y, E); n.lineTo(y, S); n.lineTo(y + v, S); n.lineTo(y + v, E); if (t.barShowStroke) n.stroke(); n.closePath(); n.fill(); a[h] += 1 * e.datasets[c].data[h]; if (r >= 1) { if (typeof e.labels[h] == "string") lgtxt2 = e.labels[h].trim(); else lgtxt2 = ""; if (1 * e.datasets[c].data[h] < 0) { jsGraphAnnotate[n.ChartNewId][jsGraphAnnotate[n.ChartNewId].length] = ["RECT", y, S, y + v, E, lgtxt, lgtxt2, 1 * e.datasets[c].data[h], a[h], f[h], c, h] } else { jsGraphAnnotate[n.ChartNewId][jsGraphAnnotate[n.ChartNewId].length] = ["RECT", y, E, y + v, S, lgtxt, lgtxt2, 1 * e.datasets[c].data[h], a[h], f[h], c, h] } } } if (1 * e.datasets[c].data[h] < 0) { o[h] = o[h] + 1 * e.datasets[c].data[h] } else { u[h] = u[h] + 1 * e.datasets[c].data[h] } } } } if (r >= 1 && t.inGraphDataShow) { var x = 0, T = 0; for (var c = 0; c < e.datasets.length; c++) { for (var h = 0; h < e.datasets[c].data.length; h++) { a[h] = 0 } } for (var c = 0; c < e.datasets.length; c++) { if (typeof e.datasets[c].title == "string") lgtxt = e.datasets[c].title.trim(); else lgtxt = ""; for (var h = 0; h < e.datasets[c].data.length; h++) { if (c == 0) { o[h] = 0; u[h] = 0; zeroY = calculateOffset(t.logarithmic, 0, s, i) } if (!(typeof e.datasets[c].data[h] == "undefined")) { if (1 * e.datasets[c].data[h] < 0) { var b = o[h]; var w = o[h] + 1 * e.datasets[c].data[h] } else { var b = u[h]; var w = u[h] + 1 * e.datasets[c].data[h] } var E = d - calculateOffset(t.logarithmic, b, s, i); var S = d - calculateOffset(t.logarithmic, w, s, i); n.save(); n.textAlign = t.inGraphDataAlign; n.textBaseline = t.inGraphDataVAlign; n.font = t.inGraphDataFontStyle + " " + t.inGraphDataFontSize + "px " + t.inGraphDataFontFamily; n.fillStyle = t.inGraphDataFontColor; if (typeof e.labels[h] == "string") lgtxt2 = e.labels[h].trim(); else lgtxt2 = ""; a[h] += 1 + e.datasets[c].data[h]; var N = tmplbis(t.inGraphDataTmpl, { config: t, v1: fmtChartJS(t, lgtxt, t.fmtV1), v2: fmtChartJS(t, lgtxt2, t.fmtV2), v3: fmtChartJS(t, 1 * e.datasets[c].data[h], t.fmtV3), v4: fmtChartJS(t, a[h], t.fmtV4), v5: fmtChartJS(t, f[h], t.fmtV5), v6: roundToWithThousands(t, fmtChartJS(t, 100 * e.datasets[c].data[h] / f[h], t.fmtV6), t.roundPct), v7: fmtChartJS(t, y, t.fmtV7), v8: fmtChartJS(t, d, t.fmtV8), v9: fmtChartJS(t, y + v, t.fmtV9), v10: fmtChartJS(t, d - calculateOffset(t.logarithmic, e.datasets[c].data[h], s, i) + t.barStrokeWidth / 2, t.fmtV10), v11: fmtChartJS(t, c, t.fmtV11), v12: fmtChartJS(t, h, t.fmtV12), data: e }); var y = p + t.barValueSpacing + l * h; n.beginPath(); n.beginPath(); x = 0; T = 0; if (t.inGraphDataXPosition == 1) { T = y + t.inGraphDataPaddingX } else if (t.inGraphDataXPosition == 2) { T = y + v / 2 + t.inGraphDataPaddingX } else if (t.inGraphDataXPosition == 3) { T = y + v + t.inGraphDataPaddingX } if (t.inGraphDataYPosition == 1) { x = E - t.inGraphDataPaddingY } else if (t.inGraphDataYPosition == 2) { x = S - (botbar - topbar) / 2 - t.inGraphDataPaddingY } else if (t.inGraphDataYPosition == 3) { x = S - t.inGraphDataPaddingY } if (x > g.topNotUsableSize) { n.translate(T, x); n.rotate(t.inGraphDataRotate * (Math.PI / 180)); n.fillTextMultiLine(N, 0, 0, n.textBaseline, t.inGraphDataFontSize) } n.restore(); if (1 * e.datasets[c].data[h] < 0) { o[h] = o[h] + 1 * e.datasets[c].data[h] } else { u[h] = u[h] + 1 * e.datasets[c].data[h] } } } } } if (g.legendMsr.dispLegend) drawLegend(g.legendMsr, e, t, n, "StackedBar") } function E() { n.lineWidth = t.scaleLineWidth; n.strokeStyle = t.scaleLineColor; n.beginPath(); n.moveTo(p - t.scaleTickSizeLeft, d); n.lineTo(p + g.availableWidth + t.scaleTickSizeRight, d); n.stroke(); for (var r = 0; r < e.labels.length; r++) { n.beginPath(); n.moveTo(p + r * l, d + t.scaleTickSizeBottom); n.lineWidth = t.scaleGridLineWidth; n.strokeStyle = t.scaleGridLineColor; if (t.scaleShowGridLines && r > 0 && r % t.scaleXGridLinesStep == 0) { n.lineTo(p + r * l, d - g.availableHeight - t.scaleTickSizeTop) } else { n.lineTo(p + r * l, d) } n.stroke() } n.lineWidth = t.scaleLineWidth; n.strokeStyle = t.scaleLineColor; n.beginPath(); n.moveTo(p, d + t.scaleTickSizeBottom); n.lineTo(p, d - g.availableHeight - t.scaleTickSizeTop); n.stroke(); for (var o = t.showYAxisMin ? -1 : 0; o < s.steps; o++) { n.beginPath(); n.moveTo(p - t.scaleTickSizeLeft, d - (o + 1) * i); n.lineWidth = t.scaleGridLineWidth; n.strokeStyle = t.scaleGridLineColor; if (t.scaleShowGridLines && o % t.scaleYGridLinesStep == 0) { n.lineTo(p + g.availableWidth + t.scaleTickSizeRight, d - (o + 1) * i) } else { n.lineTo(p, d - (o + 1) * i) } n.stroke() } } function S() { n.font = t.scaleFontStyle + " " + t.scaleFontSize + "px " + t.scaleFontFamily; if (t.xAxisTop || t.xAxisBottom) { n.textBaseline = "top"; if (g.rotateLabels > 90) { n.save(); n.textAlign = "left" } else if (g.rotateLabels > 0) { n.save(); n.textAlign = "right" } else { n.textAlign = "center" } n.fillStyle = t.scaleFontColor; if (t.xAxisBottom) { for (var r = 0; r < e.labels.length; r++) { n.save(); if (g.rotateLabels > 0) { n.translate(p + r * l + v / 2 - g.highestXLabel / 2, g.xLabelPos); n.rotate(-(g.rotateLabels * (Math.PI / 180))); n.fillTextMultiLine(fmtChartJS(t, e.labels[r], t.fmtXLabel), 0, 0, n.textBaseline, t.scaleFontSize) } else { n.fillTextMultiLine(fmtChartJS(t, e.labels[r], t.fmtXLabel), p + r * l + v / 2, g.xLabelPos, n.textBaseline, t.scaleFontSize) } n.restore() } } } n.textAlign = "right"; n.textBaseline = "middle"; for (var o = t.showYAxisMin ? -1 : 0; o < s.steps; o++) { if (t.scaleShowLabels) { if (t.yAxisLeft) { n.textAlign = "right"; n.fillTextMultiLine(s.labels[o + 1], p - (t.scaleTickSizeLeft + t.yAxisSpaceRight), d - (o + 1) * i, n.textBaseline, t.scaleFontSize) } if (t.yAxisRight) { n.textAlign = "left"; n.fillTextMultiLine(s.labels[o + 1], p + g.availableWidth + (t.scaleTickSizeRight + t.yAxisSpaceRight), d - (o + 1) * i, n.textBaseline, t.scaleFontSize) } } } } function x() { var n = Number.MIN_VALUE; var r = Number.MAX_VALUE; var i = new Array(e.datasets.length); var s = new Array(e.datasets.length); for (var a = 0; a < e.datasets.length; a++) { for (var f = 0; f < e.datasets[a].data.length; f++) { var l = a; var c = 0; var h = 0; if (!(typeof e.datasets[0].data[f] == "undefined")) { if (1 * e.datasets[0].data[f] > 0) { c += 1 * e.datasets[0].data[f]; if (c > n) { n = c } if (c < r) { r = c } } else { h += 1 * e.datasets[0].data[f]; if (h > n) { n = h } if (h < r) { r = h } } } while (l > 0) { if (!(typeof e.datasets[l].data[f] == "undefined")) { if (1 * e.datasets[l].data[f] > 0) { c += 1 * e.datasets[l].data[f]; if (c > n) { n = c } if (c < r) { r = c } } else { h += 1 * e.datasets[l].data[f]; if (h > n) { n = h } if (h < r) { r = h } } } l-- } } } if (!isNaN(t.graphMin)) r = t.graphMin; if (!isNaN(t.graphMax)) n = t.graphMax; if (Math.abs(n - r) < 1e-8) { n = Max([n * 2, 1]); r = 0 } o = t.scaleFontSize; u = g.availableHeight; var p = Math.floor(u / (o * .66)); var d = Math.floor(u / o * .5); return { maxValue: n, minValue: r, maxSteps: p, minSteps: d } } var r, i, s, o, u, a, f, l, c, h, p, d, v, m = 0, g; setting_new_chart_vars(n, "StackedBar"); if (!dynamicFunction(e, t, n, "StackedBar")) return; t.logarithmic = false; if (typeof jsGraphAnnotate[n.ChartNewId] == "undefined") jsGraphAnnotate[n.ChartNewId] = new Array; else if (!t.multiGraph) clearAnnotate(n.ChartNewId); defMouse(n, e, t, "StackedBar"); setRect(n, t); g = setMeasures(e, t, n, height, width, "nihil", [""], true, false, true, true, true, "StackedBar"); a = x(); f = t.scaleShowLabels ? t.scaleLabel : ""; if (!t.scaleOverride) { s = calculateScale(1, t, a.maxSteps, a.minSteps, a.maxValue, a.minValue, f); g = setMeasures(e, t, n, height, width, s.labels, null, true, false, true, true, true, "StackedBar") } else { s = { steps: t.scaleSteps, stepValue: t.scaleStepWidth, graphMin: t.scaleStartValue, labels: [] }; for (var y = 0; y <= s.steps; y++) { if (f) { s.labels.push(tmpl(f, { value: fmtChartJS(t, 1 * (t.scaleStartValue + t.scaleStepWidth * y).toFixed(getDecimalPlaces(t.scaleStepWidth)), t.fmtYLabel) })) } } g = setMeasures(e, t, n, height, width, s.labels, null, true, false, true, true, true, "StackedBar") } var b = g.availableHeight; g.availableHeight = g.availableHeight - t.scaleTickSizeBottom - t.scaleTickSizeTop; g.availableWidth = g.availableWidth - t.scaleTickSizeLeft - t.scaleTickSizeRight; i = Math.floor(g.availableHeight / s.steps); l = Math.floor(g.availableWidth / e.labels.length); if (l == 0 || t.fullWidthGraph) l = g.availableWidth / e.labels.length; g.clrwidth = g.clrwidth - (g.availableWidth - e.labels.length * l); g.availableWidth = e.labels.length * l; g.availableHeight = s.steps * i; g.xLabelPos += t.scaleTickSizeBottom + t.scaleTickSizeTop - (b - g.availableHeight); g.clrheight += t.scaleTickSizeBottom + t.scaleTickSizeTop - (b - g.availableHeight); p = g.leftNotUsableSize + t.scaleTickSizeLeft; d = g.topNotUsableSize + g.availableHeight + t.scaleTickSizeTop; v = l - t.scaleGridLineWidth * 2 - t.barValueSpacing * 2 - (t.barDatasetSpacing * e.datasets.length - 1) - t.barStrokeWidth / 2 - 1; if (v >= 0 && v <= 1) v = 1; if (v < 0 && v >= -1) v = -1; S(); animationLoop(t, E, w, n, g.clrx, g.clry, g.clrwidth, g.clrheight, p + g.availableWidth / 2, d - g.availableHeight / 2, p, d, e); }; var HorizontalStackedBar = function (e, t, n) { function b(e, t, n) { var r = t.steps * t.stepValue; var i = e - t.graphMin; var s = CapValue(i / r, 1, 0); return n * t.steps * s } function w(r) { n.lineWidth = t.barStrokeWidth; var o = new Array(e.datasets.length); var u = new Array(e.datasets.length); var a = new Array; var f = new Array; for (var c = 0; c < e.datasets.length; c++) { for (var h = 0; h < e.datasets[c].data.length; h++) { a[h] = 0; f[h] = 0 } } for (var c = 0; c < e.datasets.length; c++) { for (var h = 0; h < e.datasets[c].data.length; h++) if (!(typeof e.datasets[c].data[h] == "undefined")) { f[h] += 1 * e.datasets[c].data[h] } } for (var c = 0; c < e.datasets.length; c++) { if (r >= 1) { if (typeof e.datasets[c].title == "string") lgtxt = e.datasets[c].title.trim(); else lgtxt = "" } for (var h = 0; h < e.datasets[c].data.length; h++) { var m = animationCorrection(r, e, t, c, h, 1).animVal; if (m > 1) m = m - 1; if (c == 0) { o[h] = 0; u[h] = 0; zeroY = b(0, s, i) } var y = d + t.barValueSpacing - i * (h + 1); if (!(typeof e.datasets[c].data[h] == "undefined") && 1 * e.datasets[c].data[h] != 0) { if (1 * e.datasets[c].data[h] < 0) { var w = o[h]; var E = o[h] + 1 * e.datasets[c].data[h] } else { var w = u[h]; var E = u[h] + 1 * e.datasets[c].data[h] } if (t.animationByDataset) { var S = p + b(w, s, l); var x = p + b(E, s, l); x = S + m * (x - S) } else { var S = p + b(m * w, s, l); var x = p + b(m * E, s, l) } n.fillStyle = t.defaultFillColor; if (typeof e.datasets[c].fillColor == "function") n.fillStyle = e.datasets[c].fillColor("FILLCOLOR", e, t, c, h, m, 1 * e.datasets[c].data[h], "HorizontalStackedBar", n, S, y, x, y + v); else if (typeof e.datasets[c].fillColor == "string") { n.fillStyle = e.datasets[c].fillColor } else if (typeof e.datasets[c].fillColor == "object") { if (typeof e.datasets[c].fillColor[0] == "string") { n.fillStyle = e.datasets[c].fillColor[Min([e.datasets[c].fillColor.length - 1, h])] } } n.strokeStyle = t.defaultStrokeColor; if (typeof e.datasets[c].strokeColor == "function") n.strokeStyle = e.datasets[c].strokeColor("STROKECOLOR", e, t, c, h, m, 1 * e.datasets[c].data[h], n, "HorizontalStackedBar", n, S, y, x, y + v); else if (typeof e.datasets[c].strokeColor == "string") { n.strokeStyle = e.datasets[c].strokeColor } else if (typeof e.datasets[c].strokeColor == "object") { if (typeof e.datasets[c].strokeColor[0] == "string") { n.strokeStyle = e.datasets[c].strokeColor[Min([e.datasets[c].strokeColor.length - 1, h])] } } if (m != 0) { n.beginPath(); n.moveTo(S, y); n.lineTo(x, y); n.lineTo(x, y + v); n.lineTo(S, y + v); n.lineTo(S, y); if (t.barShowStroke) n.stroke(); n.closePath(); n.fill(); a[h] += 1 * e.datasets[c].data[h]; if (r >= 1) { if (typeof e.labels[h] == "string") lgtxt2 = e.labels[h].trim(); else lgtxt2 = ""; if (1 * e.datasets[c].data[h] < 0) { jsGraphAnnotate[n.ChartNewId][jsGraphAnnotate[n.ChartNewId].length] = ["RECT", x, y + v, S, y, lgtxt, lgtxt2, 1 * e.datasets[c].data[h], a[h], f[h], c, h] } else { jsGraphAnnotate[n.ChartNewId][jsGraphAnnotate[n.ChartNewId].length] = ["RECT", S, y + v, x, y, lgtxt, lgtxt2, 1 * e.datasets[c].data[h], a[h], f[h], c, h] } } } if (1 * e.datasets[c].data[h] < 0) { o[h] = o[h] + 1 * e.datasets[c].data[h] } else { u[h] = u[h] + 1 * e.datasets[c].data[h] } } } } if (r >= 1 && t.inGraphDataShow) { var T = 0, N = 0; for (var c = 0; c < e.datasets.length; c++) { for (var h = 0; h < e.datasets[c].data.length; h++) { a[h] = 0 } } for (var c = 0; c < e.datasets.length; c++) { if (typeof e.datasets[c].title == "string") lgtxt = e.datasets[c].title.trim(); else lgtxt = ""; for (var h = 0; h < e.datasets[c].data.length; h++) { if (c == 0) { o[h] = 0; u[h] = 0; zeroY = b(0, s, i) } if (!(typeof e.datasets[c].data[h] == "undefined")) { if (1 * e.datasets[c].data[h] < 0) { var w = o[h]; var E = o[h] + 1 * e.datasets[c].data[h] } else { var w = u[h]; var E = u[h] + 1 * e.datasets[c].data[h] } var S = p + b(w, s, l); var x = p + b(E, s, l); n.save(); n.textAlign = t.inGraphDataAlign; n.textBaseline = t.inGraphDataVAlign; n.font = t.inGraphDataFontStyle + " " + t.inGraphDataFontSize + "px " + t.inGraphDataFontFamily; n.fillStyle = t.inGraphDataFontColor; if (typeof e.labels[h] == "string") lgtxt2 = e.labels[h].trim(); else lgtxt2 = ""; var y = d + t.barValueSpacing - i * (h + 1); a[h] += e.datasets[c].data[h]; var C = tmplbis(t.inGraphDataTmpl, { config: t, v1: fmtChartJS(t, lgtxt, t.fmtV1), v2: fmtChartJS(t, lgtxt2, t.fmtV2), v3: fmtChartJS(t, 1 * e.datasets[c].data[h], t.fmtV3), v4: fmtChartJS(t, a[h], t.fmtV4), v5: fmtChartJS(t, f[h], t.fmtV5), v6: roundToWithThousands(t, fmtChartJS(t, 100 * e.datasets[c].data[h] / f[h], t.fmtV6), t.roundPct), v7: fmtChartJS(t, p, t.fmtV7), v8: fmtChartJS(t, y + v, t.fmtV8), v9: fmtChartJS(t, p + b(e.datasets[c].data[h], s, l) + t.barStrokeWidth / 2, t.fmtV9), v10: fmtChartJS(t, y, t.fmtV10), v11: fmtChartJS(t, c, t.fmtV11), v12: fmtChartJS(t, h, t.fmtV12), data: e }); n.beginPath(); T = 0; N = 0; if (t.inGraphDataXPosition == 1) { N = S + t.inGraphDataPaddingX } else if (t.inGraphDataXPosition == 2) { N = S + (x - S) / 2 + t.inGraphDataPaddingX } else if (t.inGraphDataXPosition == 3) { N = x + t.inGraphDataPaddingX } if (t.inGraphDataYPosition == 1) { T = y + v - t.inGraphDataPaddingY } else if (t.inGraphDataYPosition == 2) { T = y + v / 2 - t.inGraphDataPaddingY } else if (t.inGraphDataYPosition == 3) { T = y - t.inGraphDataPaddingY } if (N <= g.availableWidth + g.leftNotUsableSize) { n.translate(N, T); n.rotate(t.inGraphDataRotate * (Math.PI / 180)); n.fillTextMultiLine(C, 0, 0, n.textBaseline, t.inGraphDataFontSize); n.restore() } if (1 * e.datasets[c].data[h] < 0) { o[h] = o[h] + 1 * e.datasets[c].data[h] } else { u[h] = u[h] + 1 * e.datasets[c].data[h] } } } } } if (g.legendMsr.dispLegend) drawLegend(g.legendMsr, e, t, n, "HorizontalStackedBar") } function E() { n.lineWidth = t.scaleLineWidth; n.strokeStyle = t.scaleLineColor; n.beginPath(); n.moveTo(p - t.scaleTickSizeLeft, d); n.lineTo(p + g.availableWidth, d); n.stroke(); for (var r = t.showYAxisMin ? -1 : 0; r < s.steps; r++) { if (r >= 0) { n.beginPath(); n.moveTo(p + r * l, d + t.scaleTickSizeBottom); n.lineWidth = t.scaleGridLineWidth; n.strokeStyle = t.scaleGridLineColor; if (t.scaleShowGridLines && r > 0 && r % t.scaleXGridLinesStep == 0) { n.lineTo(p + r * l, d - g.availableHeight - t.scaleTickSizeTop) } else { n.lineTo(p + r * l, d) } n.stroke() } } n.lineWidth = t.scaleLineWidth; n.strokeStyle = t.scaleLineColor; n.beginPath(); n.moveTo(p, d + t.scaleTickSizeBottom); n.lineTo(p, d - g.availableHeight - t.scaleTickSizeTop); n.stroke(); for (var o = 0; o < e.labels.length; o++) { n.beginPath(); n.moveTo(p - t.scaleTickSizeLeft, d - (o + 1) * i); n.lineWidth = t.scaleGridLineWidth; n.strokeStyle = t.scaleGridLineColor; if (t.scaleShowGridLines && o % t.scaleYGridLinesStep == 0) { n.lineTo(p + g.availableWidth, d - (o + 1) * i) } else { n.lineTo(p, d - (o + 1) * i) } n.stroke() } } function S() { n.font = t.scaleFontStyle + " " + t.scaleFontSize + "px " + t.scaleFontFamily; if (t.scaleShowLabels && (t.xAxisTop || t.xAxisBottom)) { n.textBaseline = "top"; if (g.rotateLabels > 90) { n.save(); n.textAlign = "left" } else if (g.rotateLabels > 0) { n.save(); n.textAlign = "right" } else { n.textAlign = "center" } n.fillStyle = t.scaleFontColor; if (t.xAxisBottom) { for (var r = t.showYAxisMin ? -1 : 0; r < s.steps; r++) { n.save(); if (g.rotateLabels > 0) { n.translate(p + (r + 1) * l - g.highestXLabel / 2, g.xLabelPos); n.rotate(-(g.rotateLabels * (Math.PI / 180))); n.fillTextMultiLine(s.labels[r + 1], 0, 0, n.textBaseline, t.scaleFontSize) } else { n.fillTextMultiLine(s.labels[r + 1], p + (r + 1) * l, g.xLabelPos, n.textBaseline, t.scaleFontSize) } n.restore() } } } n.textAlign = "right"; n.textBaseline = "middle"; for (var o = 0; o < e.labels.length; o++) { if (t.yAxisLeft) { n.textAlign = "right"; n.fillTextMultiLine(fmtChartJS(t, e.labels[o], t.fmtXLabel), p - (t.scaleTickSizeLeft + t.yAxisSpaceRight), d - (o + 1) * i + v / 2, n.textBaseline, t.scaleFontSize) } if (t.yAxisRight) { n.textAlign = "left"; n.fillTextMultiLine(fmtChartJS(t, e.labels[o], t.fmtXLabel), p + g.availableWidth + (t.scaleTickSizeRight + t.yAxisSpaceRight), d - (o + 1) * i + v / 2, n.textBaseline, t.scaleFontSize) } } } function x() { var n = Number.MIN_VALUE; var r = Number.MAX_VALUE; var i = new Array(e.datasets.length); var s = new Array(e.datasets.length); for (var a = 0; a < e.datasets.length; a++) { for (var f = 0; f < e.datasets[a].data.length; f++) { var l = a; var c = 0; var h = 0; if (!(typeof e.datasets[0].data[f] == "undefined")) { if (1 * e.datasets[0].data[f] > 0) { c += 1 * e.datasets[0].data[f]; if (c > n) { n = c } if (c < r) { r = c } } else { h += 1 * e.datasets[0].data[f]; if (h > n) { n = h } if (h < r) { r = h } } } while (l > 0) { if (!(typeof e.datasets[l].data[f] == "undefined")) { if (1 * e.datasets[l].data[f] > 0) { c += 1 * e.datasets[l].data[f]; if (c > n) { n = c } if (c < r) { r = c } } else { h += 1 * e.datasets[l].data[f]; if (h > n) { n = h } if (h < r) { r = h } } } l-- } } } if (!isNaN(t.graphMin)) r = t.graphMin; if (!isNaN(t.graphMax)) n = t.graphMax; if (Math.abs(n - r) < 1e-8) { n = Max([n * 2, 1]); r = 0 } var p = Math.floor(u / (o * .66)); var d = Math.floor(u / o * .5); return { maxValue: n, minValue: r, maxSteps: p, minSteps: d } } var r, i, s, o, u, a, f, l, c, h, p, d, v, m = 0, g; if (t.reverseOrder) { e = reverseData(e) } setting_new_chart_vars(n, "HorizontalStackedBar"); if (!dynamicFunction(e, t, n, "HorizontalStackedBar")) return; t.logarithmic = false; if (typeof jsGraphAnnotate[n.ChartNewId] == "undefined") jsGraphAnnotate[n.ChartNewId] = new Array; else if (!t.multiGraph) clearAnnotate(n.ChartNewId); defMouse(n, e, t, "HorizontalStackedBar"); setRect(n, t); a = x(); f = t.scaleShowLabels ? t.scaleLabel : ""; if (!t.scaleOverride) { s = calculateScale(1, t, a.maxSteps, a.minSteps, a.maxValue, a.minValue, f); g = setMeasures(e, t, n, height, width, s.labels, null, true, true, true, true, true, "HorizontalStackedBar") } else { s = { steps: t.scaleSteps, stepValue: t.scaleStepWidth, graphMin: t.scaleStartValue, labels: [] }; for (var y = 0; y <= s.steps; y++) { if (f) { s.labels.push(tmpl(f, { value: fmtChartJS(t, 1 * (t.scaleStartValue + t.scaleStepWidth * y).toFixed(getDecimalPlaces(t.scaleStepWidth)), t.fmtYLabel) })) } } g = setMeasures(e, t, n, height, width, s.labels, null, true, true, true, true, true, "HorizontalStackedBar") } g.availableHeight = g.availableHeight - t.scaleTickSizeBottom - t.scaleTickSizeTop; g.availableWidth = g.availableWidth - t.scaleTickSizeLeft - t.scaleTickSizeRight; i = Math.floor(g.availableHeight / e.labels.length); l = Math.floor(g.availableWidth / s.steps); if (l == 0 || t.fullWidthGraph) l = g.availableWidth / s.steps; g.clrwidth = g.clrwidth - (g.availableWidth - s.steps * l); g.availableWidth = s.steps * l; g.availableHeight = e.labels.length * i; p = g.leftNotUsableSize + t.scaleTickSizeLeft; d = g.topNotUsableSize + g.availableHeight + t.scaleTickSizeTop; v = i - t.scaleGridLineWidth * 2 - t.barValueSpacing * 2 - (t.barDatasetSpacing * e.datasets.length - 1) - t.barStrokeWidth / 2 - 1; if (v >= 0 && v <= 1) v = 1; if (v < 0 && v >= -1) v = -1; S(); animationLoop(t, E, w, n, g.clrx, g.clry, g.clrwidth, g.clrheight, p + g.availableWidth / 2, d - g.availableHeight / 2, p, d, e); }; var Bar = function (data, config, ctx) { function drawBars(e) { var t, n, r; var i = new Array; var s = new Array; for (var o = 0; o < data.datasets.length; o++) { for (var u = 0; u < data.datasets[o].data.length; u++) { i[u] = 0; s[u] = 0 } } for (var o = 0; o < data.datasets.length; o++) { for (var u = 0; u < data.datasets[o].data.length; u++) { if (!(typeof data.datasets[o].data[u] == "undefined")) { s[u] += 1 * data.datasets[o].data[u] } } } ctx.lineWidth = config.barStrokeWidth; for (var o = 0; o < data.datasets.length; o++) { if (data.datasets[o].type == "Line") { var a = { datasets: [], labels: data.labels }; a.datasets.push(data.datasets[o]); lineConfig = mergeChartConfig(config, { datasetFill: data.datasets[o].fill }); drawLinesDataset(1, e, a, lineConfig, ctx, offsets, { xAxisPosY: xAxisPosY, yAxisPosX: yAxisPosX + config.barValueSpacing + (barWidth + config.barDatasetSpacing / 2 + config.barStrokeWidth) * nrOfBars / 2, valueHop: valueHop, scaleHop: scaleHop, nbValueHop: data.labels.length, zeroY: zeroY, calculatedScale: calculatedScale, logarithmic: config.logarithmic }); continue } if (e >= 1) { if (typeof data.datasets[o].title == "string") lgtxt = data.datasets[o].title.trim(); else lgtxt = "" } for (var u = 0; u < data.datasets[o].data.length; u++) { var f = animationCorrection(e, data, config, o, u, 1).animVal; if (f > 1) f = f - 1; var l = yAxisPosX + config.barValueSpacing + valueHop * u + barWidth * o + config.barDatasetSpacing * o + config.barStrokeWidth * o; var c = f * (calculateOffset(config.logarithmic, 1 * data.datasets[o].data[u], calculatedScale, scaleHop) - zeroY) + config.barStrokeWidth / 2; ctx.fillStyle = config.defaultFillColor; if (typeof data.datasets[o].fillColor == "function") { ctx.fillStyle = data.datasets[o].fillColor("FILLCOLOR", data, config, o, u, f, 1 * data.datasets[o].data[u], "Bar", ctx, l, xAxisPosY - zeroY, l + barWidth, xAxisPosY - zeroY - c) } else if (typeof data.datasets[o].fillColor == "string") { ctx.fillStyle = data.datasets[o].fillColor } else if (typeof data.datasets[o].fillColor == "object") { if (typeof data.datasets[o].fillColor[0] == "string") { ctx.fillStyle = data.datasets[o].fillColor[Min([data.datasets[o].fillColor.length - 1, u])] } } ctx.strokeStyle = config.defaultStrokeColor; if (typeof data.datasets[o].strokeColor == "function") { ctx.strokeStyle = data.datasets[o].strokeColor("STROKECOLOR", data, config, o, u, CurrentAnimPc, 1 * data.datasets[o].data[u], "Bar", ctx, l, xAxisPosY - zeroY - c, l + barWidth, xAxisPosY - zeroY) } else if (typeof data.datasets[o].strokeColor == "string") { ctx.strokeStyle = data.datasets[o].strokeColor } else if (typeof data.datasets[o].strokeColor == "object") { if (typeof data.datasets[o].strokeColor[0] == "string") { ctx.strokeStyle = data.datasets[o].strokeColor[Min([data.datasets[o].strokeColor.length - 1, u])] } } if (!(typeof data.datasets[o].data[u] == "undefined")) { roundRect(ctx, l, xAxisPosY - zeroY, barWidth, c, config.barShowStroke, config.barBorderRadius); i[u] += 1 * data.datasets[o].data[u]; if (e >= 1) { if (typeof data.labels[u] == "string") lgtxt2 = data.labels[u].trim(); else lgtxt2 = ""; t = xAxisPosY - zeroY; n = xAxisPosY - calculateOffset(config.logarithmic, 1 * data.datasets[o].data[u], calculatedScale, scaleHop) + config.barStrokeWidth / 2; if (t < n) { r = t; t = n; n = r } jsGraphAnnotate[ctx.ChartNewId][jsGraphAnnotate[ctx.ChartNewId].length] = ["RECT", l, t, l + barWidth, n, lgtxt, lgtxt2, 1 * data.datasets[o].data[u], i[u], s[u], o, u] } } } } if (e >= 1 && config.inGraphDataShow) { for (var o = 0; o < data.datasets.length; o++) { for (var u = 0; u < data.datasets[o].data.length; u++) { i[u] = 0 } } for (var o = 0; o < data.datasets.length; o++) { if (typeof data.datasets[o].title == "string") lgtxt = data.datasets[o].title.trim(); else lgtxt = ""; for (var u = 0; u < data.datasets[o].data.length; u++) { if (data.datasets[o].type == "Line") { continue } if (!(typeof data.datasets[o].data[u] == "undefined")) { if (typeof data.labels[u] == "string") lgtxt2 = data.labels[u].trim(); ctx.save(); ctx.textAlign = config.inGraphDataAlign; ctx.textBaseline = config.inGraphDataVAlign; ctx.font = config.inGraphDataFontStyle + " " + config.inGraphDataFontSize + "px " + config.inGraphDataFontFamily; ctx.fillStyle = config.inGraphDataFontColor; var l = yAxisPosX + config.barValueSpacing + valueHop * u + barWidth * o + config.barDatasetSpacing * o + config.barStrokeWidth * o; t = xAxisPosY - zeroY; n = xAxisPosY - calculateOffset(config.logarithmic, 1 * data.datasets[o].data[u], calculatedScale, scaleHop) + config.barStrokeWidth / 2; ctx.beginPath(); var h = 0, p = 0; if (config.inGraphDataXPosition == 1) { p = l + config.inGraphDataPaddingX } else if (config.inGraphDataXPosition == 2) { p = l + barWidth / 2 + config.inGraphDataPaddingX } else if (config.inGraphDataXPosition == 3) { p = l + barWidth + config.inGraphDataPaddingX } if (config.inGraphDataYPosition == 1) { h = xAxisPosY - zeroY - config.inGraphDataPaddingY } else if (config.inGraphDataYPosition == 2) { h = xAxisPosY - (calculateOffset(config.logarithmic, 1 * data.datasets[o].data[u], calculatedScale, scaleHop) + config.barStrokeWidth / 2) / 2 - config.inGraphDataPaddingY } else if (config.inGraphDataYPosition == 3) { h = xAxisPosY - calculateOffset(config.logarithmic, 1 * data.datasets[o].data[u], calculatedScale, scaleHop) + config.barStrokeWidth / 2 - config.inGraphDataPaddingY } ctx.translate(p, h); i[u] += 1 * data.datasets[o].data[u]; var d = tmplbis(config.inGraphDataTmpl, { config: config, v1: fmtChartJS(config, lgtxt, config.fmtV1), v2: fmtChartJS(config, lgtxt2, config.fmtV2), v3: fmtChartJS(config, 1 * data.datasets[o].data[u], config.fmtV3), v4: fmtChartJS(config, i[u], config.fmtV4), v5: fmtChartJS(config, s[u], config.fmtV5), v6: roundToWithThousands(config, fmtChartJS(config, 100 * data.datasets[o].data[u] / s[u], config.fmtV6), config.roundPct), v7: fmtChartJS(config, l, config.fmtV7), v8: fmtChartJS(config, t, config.fmtV8), v9: fmtChartJS(config, l + barWidth, config.fmtV9), v10: fmtChartJS(config, n, config.fmtV10), v11: fmtChartJS(config, o, config.fmtV11), v12: fmtChartJS(config, u, config.fmtV12), data: data }); ctx.rotate(config.inGraphDataRotate * (Math.PI / 180)); ctx.fillTextMultiLine(d, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); ctx.restore() } } } } if (e >= 1) { if (typeof drawMath == "function") { drawMath(ctx, config, data, msr, { xAxisPosY: xAxisPosY, yAxisPosX: yAxisPosX, valueHop: valueHop, scaleHop: scaleHop, zeroY: zeroY, calculatedScale: calculatedScale, calculateOffset: calculateOffset, barWidth: barWidth }) } } if (msr.legendMsr.dispLegend) drawLegend(msr.legendMsr, data, config, ctx, "Bar") } function roundRect(e, t, n, r, i, s, o) { e.beginPath(); e.moveTo(t + o, n); e.lineTo(t + r - o, n); e.quadraticCurveTo(t + r, n, t + r, n); e.lineTo(t + r, n - i + o); e.quadraticCurveTo(t + r, n - i, t + r - o, n - i); e.lineTo(t + o, n - i); e.quadraticCurveTo(t, n - i, t, n - i + o); e.lineTo(t, n); e.quadraticCurveTo(t, n, t + o, n); if (s) e.stroke(); e.closePath(); e.fill() } function drawScale() { ctx.lineWidth = config.scaleLineWidth; ctx.strokeStyle = config.scaleLineColor; ctx.beginPath(); ctx.moveTo(yAxisPosX - config.scaleTickSizeLeft, xAxisPosY); ctx.lineTo(yAxisPosX + msr.availableWidth + config.scaleTickSizeRight, xAxisPosY); ctx.stroke(); for (var e = 0; e < data.labels.length; e++) { ctx.beginPath(); ctx.moveTo(yAxisPosX + e * valueHop, xAxisPosY + config.scaleTickSizeBottom); ctx.lineWidth = config.scaleGridLineWidth; ctx.strokeStyle = config.scaleGridLineColor; if (config.scaleShowGridLines && e > 0 && e % config.scaleXGridLinesStep == 0) { ctx.lineTo(yAxisPosX + e * valueHop, xAxisPosY - msr.availableHeight - config.scaleTickSizeTop) } else { ctx.lineTo(yAxisPosX + e * valueHop, xAxisPosY) } ctx.stroke() } ctx.lineWidth = config.scaleLineWidth; ctx.strokeStyle = config.scaleLineColor; ctx.beginPath(); ctx.moveTo(yAxisPosX, xAxisPosY + config.scaleTickSizeBottom); ctx.lineTo(yAxisPosX, xAxisPosY - msr.availableHeight - config.scaleTickSizeTop); ctx.stroke(); for (var t = 0; t < calculatedScale.steps; t++) { ctx.beginPath(); ctx.moveTo(yAxisPosX - config.scaleTickSizeLeft, xAxisPosY - (t + 1) * scaleHop); ctx.lineWidth = config.scaleGridLineWidth; ctx.strokeStyle = config.scaleGridLineColor; if (config.scaleShowGridLines && t % config.scaleYGridLinesStep == 0) { ctx.lineTo(yAxisPosX + msr.availableWidth + config.scaleTickSizeRight, xAxisPosY - (t + 1) * scaleHop) } else { ctx.lineTo(yAxisPosX, xAxisPosY - (t + 1) * scaleHop) } ctx.stroke() } } function drawLabels() { ctx.font = config.scaleFontStyle + " " + config.scaleFontSize + "px " + config.scaleFontFamily; if (config.xAxisTop || config.xAxisBottom) { ctx.textBaseline = "top"; if (msr.rotateLabels > 90) { ctx.save(); ctx.textAlign = "left" } else if (msr.rotateLabels > 0) { ctx.save(); ctx.textAlign = "right" } else { ctx.textAlign = "center" } ctx.fillStyle = config.scaleFontColor; if (config.xAxisBottom) { for (var e = 0; e < data.labels.length; e++) { ctx.save(); if (msr.rotateLabels > 0) { ctx.translate(yAxisPosX + e * valueHop + valueHop / 2 - msr.highestXLabel / 2, msr.xLabelPos); ctx.rotate(-(msr.rotateLabels * (Math.PI / 180))); ctx.fillTextMultiLine(fmtChartJS(config, data.labels[e], config.fmtXLabel), 0, 0, ctx.textBaseline, config.scaleFontSize) } else { ctx.fillTextMultiLine(fmtChartJS(config, data.labels[e], config.fmtXLabel), yAxisPosX + e * valueHop + valueHop / 2, msr.xLabelPos, ctx.textBaseline, config.scaleFontSize) } ctx.restore() } } } ctx.textAlign = "right"; ctx.textBaseline = "middle"; for (var t = config.showYAxisMin ? -1 : 0; t < calculatedScale.steps; t++) { if (config.scaleShowLabels) { if (config.yAxisLeft) { ctx.textAlign = "right"; ctx.fillTextMultiLine(calculatedScale.labels[t + 1], yAxisPosX - (config.scaleTickSizeLeft + config.yAxisSpaceRight), xAxisPosY - (t + 1) * scaleHop, ctx.textBaseline, config.scaleFontSize) } if (config.yAxisRight) { ctx.textAlign = "left"; ctx.fillTextMultiLine(calculatedScale.labels[t + 1], yAxisPosX + msr.availableWidth + (config.scaleTickSizeRight + config.yAxisSpaceRight), xAxisPosY - (t + 1) * scaleHop, ctx.textBaseline, config.scaleFontSize) } } } } function getValueBounds() { var upperValue = Number.MIN_VALUE; var lowerValue = Number.MAX_VALUE; for (var i = 0; i < data.datasets.length; i++) { var mathFctName = data.datasets[i].drawMathDeviation; var mathValueHeight = 0; if (typeof eval(mathFctName) == "function") { var parameter = { data: data, datasetNr: i }; mathValueHeight = window[mathFctName](parameter) } for (var j = 0; j < data.datasets[i].data.length; j++) { if (1 * data.datasets[i].data[j] + mathValueHeight > upperValue) { upperValue = 1 * data.datasets[i].data[j] + mathValueHeight } if (1 * data.datasets[i].data[j] - mathValueHeight < lowerValue) { lowerValue = 1 * data.datasets[i].data[j] - mathValueHeight } } } if (Math.abs(upperValue - lowerValue) < 1e-8) { upperValue = Max([upperValue * 2, 1]); lowerValue = 0 } if (!isNaN(config.graphMin)) lowerValue = config.graphMin; if (!isNaN(config.graphMax)) upperValue = config.graphMax; labelHeight = config.scaleFontSize; scaleHeight = msr.availableHeight; var maxSteps = Math.floor(scaleHeight / (labelHeight * .66)); var minSteps = Math.floor(scaleHeight / labelHeight * .5); return { maxValue: upperValue, minValue: lowerValue, maxSteps: maxSteps, minSteps: minSteps } } var maxSize, scaleHop, calculatedScale, labelHeight, scaleHeight, valueBounds, labelTemplateString, valueHop, widestXLabel, xAxisLength, yAxisPosX, xAxisPosY, barWidth, rotateLabels = 0, msr; var offsets = []; setting_new_chart_vars(ctx, "Bar"); var nrOfBars = data.datasets.length; var nrOfLines = 0; var lineDatasets = []; var barDatasets = []; for (var i = 0; i < data.datasets.length; i++) { if (data.datasets[i].type == "Line") { nrOfLines++; lineDatasets.push(i) } else { barDatasets.push(i) } } var bufferDataset, l = 0; for (var i = data.datasets.length - 1; i >= 0; i--) { if (lineDatasets.indexOf(i) >= 0) { l++; for (var b = i; b < data.datasets.length - l; b++) { bufferDataset = data.datasets[b + 1]; data.datasets[b + 1] = data.datasets[b]; data.datasets[b] = bufferDataset } } } nrOfBars -= nrOfLines; if (!dynamicFunction(data, config, ctx, "Bar")) return; if (typeof jsGraphAnnotate[ctx.ChartNewId] == "undefined") jsGraphAnnotate[ctx.ChartNewId] = new Array; else if (!config.multiGraph) clearAnnotate(ctx.ChartNewId); defMouse(ctx, data, config, "Bar"); setRect(ctx, config); msr = setMeasures(data, config, ctx, height, width, "nihil", [""], true, false, true, true, true, "Bar"); valueBounds = getValueBounds(); if (config.logarithmic !== false) { if (valueBounds.minValue <= 0) { config.logarithmic = false } } var OrderOfMagnitude = calculateOrderOfMagnitude(Math.pow(10, calculateOrderOfMagnitude(valueBounds.maxValue) + 1)) - calculateOrderOfMagnitude(Math.pow(10, calculateOrderOfMagnitude(valueBounds.minValue))); if (config.logarithmic == "fuzzy" && OrderOfMagnitude < 4 || config.scaleOverride) { config.logarithmic = false } labelTemplateString = config.scaleShowLabels ? config.scaleLabel : ""; if (!config.scaleOverride) { calculatedScale = calculateScale(1, config, valueBounds.maxSteps, valueBounds.minSteps, valueBounds.maxValue, valueBounds.minValue, labelTemplateString); msr = setMeasures(data, config, ctx, height, width, calculatedScale.labels, null, true, false, true, true, true, "Bar") } else { calculatedScale = { steps: config.scaleSteps, stepValue: config.scaleStepWidth, graphMin: config.scaleStartValue, graphMax: config.scaleStartValue + config.scaleSteps * config.scaleStepWidth, labels: [] }; populateLabels(1, config, labelTemplateString, calculatedScale.labels, calculatedScale.steps, config.scaleStartValue, calculatedScale.graphMax, config.scaleStepWidth); msr = setMeasures(data, config, ctx, height, width, calculatedScale.labels, null, true, false, true, true, true, "Bar") } var prevHeight = msr.availableHeight; msr.availableHeight = msr.availableHeight - config.scaleTickSizeBottom - config.scaleTickSizeTop; msr.availableWidth = msr.availableWidth - config.scaleTickSizeLeft - config.scaleTickSizeRight; scaleHop = Math.floor(msr.availableHeight / calculatedScale.steps); valueHop = Math.floor(msr.availableWidth / data.labels.length); if (valueHop == 0 || config.fullWidthGraph) valueHop = msr.availableWidth / data.labels.length; msr.clrwidth = msr.clrwidth - (msr.availableWidth - data.labels.length * valueHop); msr.availableWidth = data.labels.length * valueHop; msr.availableHeight = calculatedScale.steps * scaleHop; msr.xLabelPos += config.scaleTickSizeBottom + config.scaleTickSizeTop - (prevHeight - msr.availableHeight); msr.clrheight += config.scaleTickSizeBottom + config.scaleTickSizeTop - (prevHeight - msr.availableHeight); yAxisPosX = msr.leftNotUsableSize + config.scaleTickSizeLeft; xAxisPosY = msr.topNotUsableSize + msr.availableHeight + config.scaleTickSizeTop; barWidth = (valueHop - config.scaleGridLineWidth * 2 - config.barValueSpacing * 2 - (config.barDatasetSpacing * nrOfBars - 1) - (config.barStrokeWidth / 2 * nrOfBars - 1)) / nrOfBars; if (barWidth >= 0 && barWidth <= 1) barWidth = 1; if (barWidth < 0 && barWidth >= -1) barWidth = -1; var zeroY = 0; if (valueBounds.minValue < 0) { var zeroY = calculateOffset(config.logarithmic, 0, calculatedScale, scaleHop) } for (var i = 0; i < data.datasets.length; i++) { offsets[i] = []; for (var j = 0; j < data.datasets[i].data.length; j++) { offsets[i][j] = calculateOffset(config.logarithmic, data.datasets[i].data[j], calculatedScale, scaleHop) - zeroY } } drawLabels(); animationLoop(config, drawScale, drawBars, ctx, msr.clrx, msr.clry, msr.clrwidth, msr.clrheight, yAxisPosX + msr.availableWidth / 2, xAxisPosY - msr.availableHeight / 2, yAxisPosX, xAxisPosY, data); }; var HorizontalBar = function (e, t, n) { function b(r) { var o = new Array; var u = new Array; for (var a = 0; a < e.datasets.length; a++) { for (var f = 0; f < e.datasets[a].data.length; f++) { o[f] = 0; u[f] = 0 } } for (var a = 0; a < e.datasets.length; a++) { for (var f = 0; f < e.datasets[a].data.length; f++) if (!(typeof e.datasets[a].data[f] == "undefined")) u[f] += 1 * e.datasets[a].data[f] } n.lineWidth = t.barStrokeWidth; for (var a = 0; a < e.datasets.length; a++) { if (r >= 1) { if (typeof e.datasets[a].title == "string") lgtxt = e.datasets[a].title.trim(); else lgtxt = "" } for (var f = 0; f < e.datasets[a].data.length; f++) { var c = animationCorrection(r, e, t, a, f, 1).animVal; if (c > 1) c = c - 1; var h = d + t.barValueSpacing - i * (f + 1) + v * a + t.barDatasetSpacing * a + t.barStrokeWidth * a; var m = c * (calculateOffset(t.logarithmic, 1 * e.datasets[a].data[f], s, l) - y) + t.barStrokeWidth / 2; n.fillStyle = t.defaultFillColor; if (typeof e.datasets[a].fillColor == "function") n.fillStyle = e.datasets[a].fillColor("FILLCOLOR", e, t, a, f, c, 1 * e.datasets[a].data[f], "HorizontalBar", n, p + y, h, p + y + m, h + v); else if (typeof e.datasets[a].fillColor == "string") { n.fillStyle = e.datasets[a].fillColor } else if (typeof e.datasets[a].fillColor == "object") { if (typeof e.datasets[a].fillColor[0] == "string") { n.fillStyle = e.datasets[a].fillColor[Min([e.datasets[a].fillColor.length - 1, f])] } } n.strokeStyle = t.defaultStrokeColor; if (typeof e.datasets[a].strokeColor == "function") n.strokeStyle = e.datasets[a].strokeColor("STROKECOLOR", e, t, a, f, c, 1 * e.datasets[a].data[f], "HorizontalBar", n, p, h, p + m, h + v); else if (typeof e.datasets[a].strokeColor == "string") { n.strokeStyle = e.datasets[a].strokeColor } else if (typeof e.datasets[a].strokeColor == "object") { if (typeof e.datasets[a].strokeColor[0] == "string") { n.strokeStyle = e.datasets[a].strokeColor[Min([e.datasets[a].strokeColor.length - 1, f])] } } if (!(typeof e.datasets[a].data[f] == "undefined")) { w(n, h, p + y, v, m, t.barShowStroke, t.barBorderRadius, 0); o[f] += 1 * e.datasets[a].data[f]; if (r >= 1) { if (typeof e.labels[f] == "string") lgtxt2 = e.labels[f].trim(); else lgtxt2 = ""; t1 = p + y; t2 = p + calculateOffset(t.logarithmic, 1 * e.datasets[a].data[f], s, l) + t.barStrokeWidth / 2; if (t1 > t2) { t3 = t1; t1 = t2; t2 = t3 } jsGraphAnnotate[n.ChartNewId][jsGraphAnnotate[n.ChartNewId].length] = ["RECT", t1, h + v, t2, h, lgtxt, lgtxt2, 1 * e.datasets[a].data[f], o[f], u[f], a, f] } } } } if (r >= 1 && t.inGraphDataShow) { for (var a = 0; a < e.datasets.length; a++) { for (var f = 0; f < e.datasets[a].data.length; f++) { o[f] = 0 } } for (var a = 0; a < e.datasets.length; a++) { if (typeof e.datasets[a].title == "string") lgtxt = e.datasets[a].title.trim(); else lgtxt = ""; for (var f = 0; f < e.datasets[a].data.length; f++) { if (!(typeof e.datasets[a].data[f] == "undefined")) { if (typeof e.labels[f] == "string") lgtxt2 = e.labels[f].trim(); n.save(); n.textAlign = t.inGraphDataAlign; n.textBaseline = t.inGraphDataVAlign; n.font = t.inGraphDataFontStyle + " " + t.inGraphDataFontSize + "px " + t.inGraphDataFontFamily; n.fillStyle = t.inGraphDataFontColor; var h = d + t.barValueSpacing - i * (f + 1) + v * a + t.barDatasetSpacing * a + t.barStrokeWidth * a; t1 = p + y; t2 = p + calculateOffset(t.logarithmic, 1 * e.datasets[a].data[f], s, l) + t.barStrokeWidth / 2; if (t1 > t2) { t3 = t1; t1 = t2; t2 = t3 } n.beginPath(); var b = 0, E = 0; if (t.inGraphDataYPosition == 1) { b = h - t.inGraphDataPaddingY + v } else if (t.inGraphDataYPosition == 2) { b = h + v / 2 - t.inGraphDataPaddingY } else if (t.inGraphDataYPosition == 3) { b = h - t.inGraphDataPaddingY } if (t.inGraphDataXPosition == 1) { E = p + y + t.inGraphDataPaddingX } else if (t.inGraphDataXPosition == 2) { E = p + (calculateOffset(t.logarithmic, 1 * e.datasets[a].data[f], s, l) + t.barStrokeWidth / 2) / 2 + t.inGraphDataPaddingX } else if (t.inGraphDataXPosition == 3) { E = p + calculateOffset(t.logarithmic, 1 * e.datasets[a].data[f], s, l) + t.barStrokeWidth / 2 + t.inGraphDataPaddingX } n.translate(E, b); o[f] += 1 * e.datasets[a].data[f]; var S = tmplbis(t.inGraphDataTmpl, { config: t, v1: fmtChartJS(t, lgtxt, t.fmtV1), v2: fmtChartJS(t, lgtxt2, t.fmtV2), v3: fmtChartJS(t, 1 * e.datasets[a].data[f], t.fmtV3), v4: fmtChartJS(t, o[f], t.fmtV4), v5: fmtChartJS(t, u[f], t.fmtV5), v6: roundToWithThousands(t, fmtChartJS(t, 100 * e.datasets[a].data[f] / u[f], t.fmtV6), t.roundPct), v7: fmtChartJS(t, t1, t.fmtV7), v8: fmtChartJS(t, h + v, t.fmtV8), v9: fmtChartJS(t, t2, t.fmtV9), v10: fmtChartJS(t, h, t.fmtV10), v11: fmtChartJS(t, a, t.fmtV11), v12: fmtChartJS(t, f, t.fmtV12), data: e }); n.rotate(t.inGraphDataRotate * (Math.PI / 180)); n.fillTextMultiLine(S, 0, 0, n.textBaseline, t.inGraphDataFontSize); n.restore() } } } } if (g.legendMsr.dispLegend) drawLegend(g.legendMsr, e, t, n, "HorizontalBar") } function w(e, t, n, r, i, s, o, u) { e.beginPath(); e.moveTo(n + u, t + o); e.lineTo(n + u, t + r - o); e.quadraticCurveTo(n + u, t + r, n + u, t + r); e.lineTo(n + i - o, t + r); e.quadraticCurveTo(n + i, t + r, n + i, t + r - o); e.lineTo(n + i, t + o); e.quadraticCurveTo(n + i, t, n + i - o, t); e.lineTo(n + u, t); e.quadraticCurveTo(n + u, t, n + u, t + o); if (s) e.stroke(); e.closePath(); e.fill() } function E() { n.lineWidth = t.scaleLineWidth; n.strokeStyle = t.scaleLineColor; n.beginPath(); n.moveTo(p - t.scaleTickSizeLeft, d); n.lineTo(p + g.availableWidth + t.scaleTickSizeRight, d); n.stroke(); for (var r = t.showYAxisMin ? -1 : 0; r < s.steps; r++) { if (r >= 0) { n.beginPath(); n.moveTo(p + r * l, d + t.scaleTickSizeBottom); n.lineWidth = t.scaleGridLineWidth; n.strokeStyle = t.scaleGridLineColor; if (t.scaleShowGridLines && r > 0 && r % t.scaleXGridLinesStep == 0) { n.lineTo(p + r * l, d - g.availableHeight - t.scaleTickSizeTop) } else { n.lineTo(p + r * l, d) } n.stroke() } } n.lineWidth = t.scaleLineWidth; n.strokeStyle = t.scaleLineColor; n.beginPath(); n.moveTo(p, d + t.scaleTickSizeBottom); n.lineTo(p, d - g.availableHeight - t.scaleTickSizeTop); n.stroke(); for (var o = 0; o < e.labels.length; o++) { n.beginPath(); n.moveTo(p - t.scaleTickSizeLeft, d - (o + 1) * i); n.lineWidth = t.scaleGridLineWidth; n.strokeStyle = t.scaleGridLineColor; if (t.scaleShowGridLines && o % t.scaleYGridLinesStep == 0) { n.lineTo(p + g.availableWidth + t.scaleTickSizeRight, d - (o + 1) * i) } else { n.lineTo(p, d - (o + 1) * i) } n.stroke() } } function S() { n.font = t.scaleFontStyle + " " + t.scaleFontSize + "px " + t.scaleFontFamily; if (t.scaleShowLabels && (t.xAxisTop || t.xAxisBottom)) { n.textBaseline = "top"; if (g.rotateLabels > 90) { n.save(); n.textAlign = "left" } else if (g.rotateLabels > 0) { n.save(); n.textAlign = "right" } else { n.textAlign = "center" } n.fillStyle = t.scaleFontColor; if (t.xAxisBottom) { for (var r = t.showYAxisMin ? -1 : 0; r < s.steps; r++) { n.save(); if (g.rotateLabels > 0) { n.translate(p + (r + 1) * l - g.highestXLabel / 2, g.xLabelPos); n.rotate(-(g.rotateLabels * (Math.PI / 180))); n.fillTextMultiLine(s.labels[r + 1], 0, 0, n.textBaseline, t.scaleFontSize) } else { n.fillTextMultiLine(s.labels[r + 1], p + (r + 1) * l, g.xLabelPos, n.textBaseline, t.scaleFontSize) } n.restore() } } } n.textAlign = "right"; n.textBaseline = "middle"; for (var o = 0; o < e.labels.length; o++) { if (t.yAxisLeft) { n.textAlign = "right"; n.fillTextMultiLine(fmtChartJS(t, e.labels[o], t.fmtXLabel), p - (t.scaleTickSizeLeft + t.yAxisSpaceRight), d - o * i - i / 2, n.textBaseline, t.scaleFontSize) } if (t.yAxisRight) { n.textAlign = "left"; n.fillTextMultiLine(fmtChartJS(t, e.labels[o], t.fmtXLabel), p + g.availableWidth + (t.scaleTickSizeRight + t.yAxisSpaceRight), d - o * i - i / 2, n.textBaseline, t.scaleFontSize) } } } function x() { var n = Number.MIN_VALUE; var r = Number.MAX_VALUE; for (var i = 0; i < e.datasets.length; i++) { for (var s = 0; s < e.datasets[i].data.length; s++) { if (1 * e.datasets[i].data[s] > n) { n = 1 * e.datasets[i].data[s] } if (1 * e.datasets[i].data[s] < r) { r = 1 * e.datasets[i].data[s] } } } if (Math.abs(n - r) < 1e-8) { n = Max([n * 2, 1]); r = 0 } if (!isNaN(t.graphMin)) r = t.graphMin; if (!isNaN(t.graphMax)) n = t.graphMax; var a = Math.floor(u / (o * .66)); var f = Math.floor(u / o * .5); return { maxValue: n, minValue: r, maxSteps: a, minSteps: f } } var r, i, s, o, u, a, f, l, c, h, p, d, v, m = 0, g; if (t.reverseOrder) { e = reverseData(e) } setting_new_chart_vars(n, "HorizontalBar"); if (!dynamicFunction(e, t, n, "HorizontalBar")) return; if (typeof jsGraphAnnotate[n.ChartNewId] == "undefined") jsGraphAnnotate[n.ChartNewId] = new Array; else if (!t.multiGraph) clearAnnotate(n.ChartNewId); defMouse(n, e, t, "HorizontalBar"); setRect(n, t); a = x(); f = t.scaleShowLabels ? t.scaleLabel : ""; if (!t.scaleOverride) { s = calculateScale(1, t, a.maxSteps, a.minSteps, a.maxValue, a.minValue, f); g = setMeasures(e, t, n, height, width, s.labels, null, true, true, true, true, true, "HorizontalBar") } else { s = { steps: t.scaleSteps, stepValue: t.scaleStepWidth, graphMin: t.scaleStartValue, graphMax: t.scaleStartValue + t.scaleSteps * t.scaleStepWidth, labels: [] }; populateLabels(1, t, f, s.labels, s.steps, t.scaleStartValue, s.graphMax, t.scaleStepWidth); g = setMeasures(e, t, n, height, width, s.labels, null, true, true, true, true, true, "HorizontalBar") } g.availableHeight = g.availableHeight - t.scaleTickSizeBottom - t.scaleTickSizeTop; g.availableWidth = g.availableWidth - t.scaleTickSizeLeft - t.scaleTickSizeRight; i = Math.floor(g.availableHeight / e.labels.length); l = Math.floor(g.availableWidth / s.steps); if (l == 0 || t.fullWidthGraph) l = g.availableWidth / s.steps; g.clrwidth = g.clrwidth - (g.availableWidth - s.steps * l); g.availableWidth = s.steps * l; g.availableHeight = e.labels.length * i; p = g.leftNotUsableSize + t.scaleTickSizeLeft; d = g.topNotUsableSize + g.availableHeight + t.scaleTickSizeTop; v = (i - t.scaleGridLineWidth * 2 - t.barValueSpacing * 2 - (t.barDatasetSpacing * e.datasets.length - 1) - (t.barStrokeWidth / 2 * e.datasets.length - 1)) / e.datasets.length; if (v >= 0 && v <= 1) v = 1; if (v < 0 && v >= -1) v = -1; var y = 0; if (a.minValue < 0) { var y = calculateOffset(t.logarithmic, 0, s, l) } S(); animationLoop(t, E, b, n, g.clrx, g.clry, g.clrwidth, g.clrheight, p + g.availableWidth / 2, d - g.availableHeight / 2, p, d, e); }; var requestAnimFrame = function () { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (e) { window.setTimeout(e, 1e3 / 60) } }(); var cache = {}; }; ;(function($,w,d) {var chartModel=fifa.model.extend({initialize:function(options) {var _this=this;fifa.model.prototype.initialize.apply(_this,[options]);},onValidateCollection:function() {var _this=this;},name:'chart',view_name:'chart:view'});w.models.chart=new chartModel({bind:['validateCollection']});}(window.jQuery||window.jm,window,document));;(function($,w,d) {var chartView=fifa.view.extend({$contentWrapContainer:null,$data:null,initialize:function(options) {var _this=this;fifa.view.prototype.initialize.apply(_this,[options]);_this.triggerMe('chartInit');},onChartInit:function(idPlayer1,idPlayer2) {var _this=this;$('.chart-item').each(function() {_this.triggerMe('dataInit',$(this),idPlayer1,idPlayer2);});},coreOnReinit:function() {this.onChartInit();},coreOnAjaxDataRequire:function() {this.onChartInit();},onDataInit:function($div,idPlayer1,idPlayer2) {var _this=this,$item=$div.find('script[type="chart-data"]'),itemcontent=$item.length ? $item.html().trim().replace(/[\r\n]+(?=[^\r\n])/g,''):'',classes=$div.attr('data-attrclass').split(','),color=[],bgColor=[];_.each(classes,function(o,i) {var $div_inner=$div.find('.' + o);if(!$div_inner.length) {$div_inner=$('
').attr('class','hidden ' + o);$div.append($div_inner);}var col=$div_inner.css('color');color.push(col);var bgcol=$div_inner.css('background-color');bgColor.push(bgcol);});if(!idPlayer1) {idPlayer1=$div.attr("data-id");}if(!idPlayer2) {idPlayer2=$div.attr("data-id-away");}var itemobj=$.parseJSON(itemcontent||'{}'),ctx=$div.find('#' + $div.data('attr'))[0].getContext("2d");switch ($div.data("charttype")) {case "Radar":{_this.drawRadar(itemobj,ctx,color,bgColor,idPlayer1,idPlayer2);break;}case "Line":if(itemcontent) {_this.triggerMe('drawLines',itemobj,ctx);}break;default:{_this.drawDoughnut(itemobj,ctx,color);}}},onDrawLines:function(itemobj,ctx,options) {new Chart(ctx).Line(itemobj,options);},name:'chart:view',model_name:'chart',drawRadar:function(itemobj,ctx,color,bgColor,idPlayer1,idPlayer2) {var _this=this;if((idPlayer1||idPlayer2)&&itemobj.players) {var first=$.grep(itemobj.players,function(item) {return item.id===idPlayer1;});var second=$.grep(itemobj.players,function(item) {return item.id===idPlayer2;});var dataSets;if(first&&first.length>0) {if(second&&second.length>0) {dataSets=_this.createDataSets([first[0],second[0]],color,bgColor);}else {dataSets=_this.createDataSets([first[0]],color,bgColor);}}else if(second&&second.length>0) {dataSets=_this.createDataSets([first[0],second[0]],color,bgColor);}else {dataSets=[{data:$.map(itemobj.labels,function() { return 0;}),fillColor:"#fff",strokeColor:"#fff",pointColor:"#fff",pointStrokeColor:"#fff"}];}new Chart(ctx).Radar({labels:$.map(itemobj.labels,function(item) { return item.replace(' ','\n');}),datasets:dataSets},{animation:true,angleLineWidth:3,scaleOverlay:true,scaleOverride:true,scaleStartValue:0,scaleStepWidth:10,scaleSteps:10,scaleFactors:itemobj.scaleFactors});}},drawDoughnut:function(itemobj,ctx,color) {_.each(itemobj,function(o,i) {o.color=color[i];});new Chart(ctx).Doughnut(itemobj,{ percentageInnerCutout:80});},createDataSets:function(players,color,bgColor) {return $.map(players,(function(player,index) {if(player) {if(index==0) {return {data:player.datavalues,fillColor:bgColor[index],strokeColor:color[index],pointColor:color[index],pointStrokeColor:"#fff"};}else {return {data:player.datavalues,fillColor:bgColor[index],strokeColor:color[index],pointColor:color[index],pointStrokeColor:"#fff"};}}else {return {data:[0,0,0,0,0,0,0],fillColor:bgColor[index],strokeColor:color[index],pointColor:color[index],pointStrokeColor:"#fff"}}}));}});w.views.chart=new chartView({bind:['core:ajaxDataRequire','chartInit','dataInit','core:reinit','drawLines']});}(window.jQuery||window.jm,window,document)); });