Return-Path: Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C77F1CDB474 for ; Tue, 17 Oct 2023 01:01:14 +0000 (UTC) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mx.groups.io with SMTP id smtpd.web10.197718.1697504469621130835 for ; Mon, 16 Oct 2023 18:01:09 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eTcD0JAI; spf=pass (domain: gmail.com, ip: 209.85.214.178, mailfrom: ticotimo@gmail.com) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1c87a85332bso43858405ad.2 for ; Mon, 16 Oct 2023 18:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697504469; x=1698109269; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AjEFlcHx7W3IyJOF5BeHcSo/tLQf856Z91hRLejZYMA=; b=eTcD0JAIbkhFadpo9jZrKLsAPvonYkb6g6HQtTP6mfJuisfXY1upSyghsBGELWrZDg b27eTGaUe3xwHb335J70ggecejQ8Ppc2zIEi3oWZkQxSj8+nHywDNxKdY07hCyJXey5Q DRbUxngO7oXIp4uVHKTMLhk5Q9CAIQx5ke/z03BL1dC6AmHtwMLTKPXtRnMudFBqDLZ8 hukbVM6HzGK4OBCs2lrOM7cZzkPnnM2RaNkk2kjsATK9Dd+2gg/3ux43EGx8S5rA93Bz xd6OOA1VkD/ZYvsm+EETxkY01j7Xkr5rj6wTNFGh5RQaA5ps4SPgMJ56pWfyvMVBEKt+ 32GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697504469; x=1698109269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AjEFlcHx7W3IyJOF5BeHcSo/tLQf856Z91hRLejZYMA=; b=g+HISVPpEkot2niQnYMhygxaz4mMK3wo62xSAccQepOIKs7XpV2gBv0nvbNR9sqdOb eTzZ5juto5W7quJRYh7e/jseN3LvdL3zdX07vGRFx/nIO638+aXJzAK6y5H1awdXZLzv ZHG5GM2UIlY4wRdJ3nTsVNXOxbchtDrjIvqjTvleJ93/Vw/OjfnJq7PGtL42u6LUE+/k nk3RMIufc+wmUg0XrBS4Na/bs/VXncivbiWIockxsVcFr867AOvDwZjA/8Zjc091PwCg Pl4l+oz26KVWKT9Y72JWieviFHPMDPDIfHET4uOlHMf9a62LHVyZK9XvbOouAKkL/smk ZdlA== X-Gm-Message-State: AOJu0YzPK6Kivk9W2uZ7Dv9DEPEmJvsF5IH9uTtIARl6OIVzjIyYAhki i5I0PDNIDtV6gXeldLWbHgcXvKd+3UT78A== X-Google-Smtp-Source: AGHT+IGFbEtcHyT8IhjXRiVgSPD2rWR5eTZXa5I9l+uUF4nMNaF/Nra7Iq2qU+RSxZoovM0uMpy+PA== X-Received: by 2002:a17:902:d4d1:b0:1c9:c6f4:e0c3 with SMTP id o17-20020a170902d4d100b001c9c6f4e0c3mr938489plg.62.1697504466904; Mon, 16 Oct 2023 18:01:06 -0700 (PDT) Received: from chiron.hsd1.or.comcast.net ([2601:1c0:ca00:cea0:ab5b:2a7b:aba2:aa8c]) by smtp.gmail.com with ESMTPSA id f6-20020a170902e98600b001c60a548331sm210879plb.304.2023.10.16.18.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 18:01:05 -0700 (PDT) From: Tim Orling X-Google-Original-From: Tim Orling To: yocto@lists.yoctoproject.org Cc: Tim Orling Subject: [layerindex-web][PATCH 4/4] Chart.js: upgrade from 2.9.3 to 2.9.4 Date: Mon, 16 Oct 2023 17:59:26 -0700 Message-Id: <20231017005921.2618459-5-tim.orling@konsulko.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017005921.2618459-1-tim.orling@konsulko.com> References: <20231017005921.2618459-1-tim.orling@konsulko.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 17 Oct 2023 01:01:14 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto/message/61362 https://github.com/chartjs/Chart.js/releases/tag/v2.9.4 CVE: CVE-2020-7746 https://nvd.nist.gov/vuln/detail/CVE-2020-7746 Signed-off-by: Tim Orling --- layerindex/static/js/Chart-2.9.3.min.js | 7 - .../js/{Chart-2.9.3.js =3D> Chart-2.9.4.js} | 27979 ++++++++-------- layerindex/static/js/Chart-2.9.4.min.js | 7 + 3 files changed, 14007 insertions(+), 13986 deletions(-) delete mode 100644 layerindex/static/js/Chart-2.9.3.min.js rename layerindex/static/js/{Chart-2.9.3.js =3D> Chart-2.9.4.js} (96%) create mode 100644 layerindex/static/js/Chart-2.9.4.min.js diff --git a/layerindex/static/js/Chart-2.9.3.min.js b/layerindex/static/js= /Chart-2.9.3.min.js deleted file mode 100644 index 7c16b0d..0000000 --- a/layerindex/static/js/Chart-2.9.3.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * Chart.js v2.9.3 - * https://www.chartjs.org - * (c) 2019 Chart.js Contributors - * Released under the MIT License - */ -!function(t,e){"object"=3D=3Dtypeof exports&&"undefined"!=3Dtypeof module?= module.exports=3De(function(){try{return require("moment")}catch(t){}}()):"= function"=3D=3Dtypeof define&&define.amd?define(["require"],(function(t){re= turn e(function(){try{return t("moment")}catch(t){}}())})):(t=3Dt||self).Ch= art=3De(t.moment)}(this,(function(t){"use strict";t=3Dt&&t.hasOwnProperty("= default")?t.default:t;var e=3D{aliceblue:[240,248,255],antiquewhite:[250,23= 5,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:= [245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,20= 5],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,= 184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,3= 0],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],c= rimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139]= ,darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],dark= grey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkoliv= egreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[= 139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:= [72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise= :[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,19= 1,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],= firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuc= hsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255= ,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyell= ow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,= 180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240= ,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124= ,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,= 128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgr= ay:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink= :[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightsk= yblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,15= 3],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],li= megreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0= ],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,= 211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue= :[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],m= ediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250= ],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],= navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,3= 5],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenr= od:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevi= oletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru= :[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230= ],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[18= 8,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,1= 14],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sie= nna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,9= 0,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],s= pringgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128= ,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],viole= t:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245= ,245],yellow:[255,255,0],yellowgreen:[154,205,50]},n=3Dfunction(t,e){return= t(e=3D{exports:{}},e.exports),e.exports}((function(t){var n=3D{};for(var i= in e)e.hasOwnProperty(i)&&(n[e[i]]=3Di);var a=3Dt.exports=3D{rgb:{channels= :3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"= },hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channe= ls:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lc= h"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]}= ,ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256= "]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","= g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var r in a)if(a.hasOwnP= roperty(r)){if(!("channels"in a[r]))throw new Error("missing channels prope= rty: "+r);if(!("labels"in a[r]))throw new Error("missing channel labels pro= perty: "+r);if(a[r].labels.length!=3D=3Da[r].channels)throw new Error("chan= nel and label counts mismatch: "+r);var o=3Da[r].channels,s=3Da[r].labels;d= elete a[r].channels,delete a[r].labels,Object.defineProperty(a[r],"channels= ",{value:o}),Object.defineProperty(a[r],"labels",{value:s})}a.rgb.hsl=3Dfun= ction(t){var e,n,i=3Dt[0]/255,a=3Dt[1]/255,r=3Dt[2]/255,o=3DMath.min(i,a,r)= ,s=3DMath.max(i,a,r),l=3Ds-o;return s=3D=3D=3Do?e=3D0:i=3D=3D=3Ds?e=3D(a-r)= /l:a=3D=3D=3Ds?e=3D2+(r-i)/l:r=3D=3D=3Ds&&(e=3D4+(i-a)/l),(e=3DMath.min(60*= e,360))<0&&(e+=3D360),n=3D(o+s)/2,[e,100*(s=3D=3D=3Do?0:n<=3D.5?l/(s+o):l/(= 2-s-o)),100*n]},a.rgb.hsv=3Dfunction(t){var e,n,i,a,r,o=3Dt[0]/255,s=3Dt[1]= /255,l=3Dt[2]/255,u=3DMath.max(o,s,l),d=3Du-Math.min(o,s,l),h=3Dfunction(t)= {return(u-t)/6/d+.5};return 0=3D=3D=3Dd?a=3Dr=3D0:(r=3Dd/u,e=3Dh(o),n=3Dh(s= ),i=3Dh(l),o=3D=3D=3Du?a=3Di-n:s=3D=3D=3Du?a=3D1/3+e-i:l=3D=3D=3Du&&(a=3D2/= 3+n-e),a<0?a+=3D1:a>1&&(a-=3D1)),[360*a,100*r,100*u]},a.rgb.hwb=3Dfunction(= t){var e=3Dt[0],n=3Dt[1],i=3Dt[2];return[a.rgb.hsl(t)[0],100*(1/255*Math.mi= n(e,Math.min(n,i))),100*(i=3D1-1/255*Math.max(e,Math.max(n,i)))]},a.rgb.cmy= k=3Dfunction(t){var e,n=3Dt[0]/255,i=3Dt[1]/255,a=3Dt[2]/255;return[100*((1= -n-(e=3DMath.min(1-n,1-i,1-a)))/(1-e)||0),100*((1-i-e)/(1-e)||0),100*((1-a-= e)/(1-e)||0),100*e]},a.rgb.keyword=3Dfunction(t){var i=3Dn[t];if(i)return i= ;var a,r,o,s=3D1/0;for(var l in e)if(e.hasOwnProperty(l)){var u=3De[l],d=3D= (r=3Dt,o=3Du,Math.pow(r[0]-o[0],2)+Math.pow(r[1]-o[1],2)+Math.pow(r[2]-o[2]= ,2));d.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=3Dn>= .04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(i=3Di>.04045?Math.pow((= i+.055)/1.055,2.4):i/12.92)),100*(.2126*e+.7152*n+.0722*i),100*(.0193*e+.11= 92*n+.9505*i)]},a.rgb.lab=3Dfunction(t){var e=3Da.rgb.xyz(t),n=3De[0],i=3De= [1],r=3De[2];return i/=3D100,r/=3D108.883,n=3D(n/=3D95.047)>.008856?Math.po= w(n,1/3):7.787*n+16/116,[116*(i=3Di>.008856?Math.pow(i,1/3):7.787*i+16/116)= -16,500*(n-i),200*(i-(r=3Dr>.008856?Math.pow(r,1/3):7.787*r+16/116))]},a.hs= l.rgb=3Dfunction(t){var e,n,i,a,r,o=3Dt[0]/360,s=3Dt[1]/100,l=3Dt[2]/100;if= (0=3D=3D=3Ds)return[r=3D255*l,r,r];e=3D2*l-(n=3Dl<.5?l*(1+s):l+s-l*s),a=3D[= 0,0,0];for(var u=3D0;u<3;u++)(i=3Do+1/3*-(u-1))<0&&i++,i>1&&i--,r=3D6*i<1?e= +6*(n-e)*i:2*i<1?n:3*i<2?e+(n-e)*(2/3-i)*6:e,a[u]=3D255*r;return a},a.hsl.h= sv=3Dfunction(t){var e=3Dt[0],n=3Dt[1]/100,i=3Dt[2]/100,a=3Dn,r=3DMath.max(= i,.01);return n*=3D(i*=3D2)<=3D1?i:2-i,a*=3Dr<=3D1?r:2-r,[e,100*(0=3D=3D=3D= i?2*a/(r+a):2*n/(i+n)),100*((i+n)/2)]},a.hsv.rgb=3Dfunction(t){var e=3Dt[0]= /60,n=3Dt[1]/100,i=3Dt[2]/100,a=3DMath.floor(e)%6,r=3De-Math.floor(e),o=3D2= 55*i*(1-n),s=3D255*i*(1-n*r),l=3D255*i*(1-n*(1-r));switch(i*=3D255,a){case = 0:return[i,l,o];case 1:return[s,i,o];case 2:return[o,i,l];case 3:return[o,s= ,i];case 4:return[l,o,i];case 5:return[i,o,s]}},a.hsv.hsl=3Dfunction(t){var= e,n,i,a=3Dt[0],r=3Dt[1]/100,o=3Dt[2]/100,s=3DMath.max(o,.01);return i=3D(2= -r)*o,n=3Dr*s,[a,100*(n=3D(n/=3D(e=3D(2-r)*s)<=3D1?e:2-e)||0),100*(i/=3D2)]= },a.hwb.rgb=3Dfunction(t){var e,n,i,a,r,o,s,l=3Dt[0]/360,u=3Dt[1]/100,d=3Dt= [2]/100,h=3Du+d;switch(h>1&&(u/=3Dh,d/=3Dh),i=3D6*l-(e=3DMath.floor(6*l)),0= !=3D(1&e)&&(i=3D1-i),a=3Du+i*((n=3D1-d)-u),e){default:case 6:case 0:r=3Dn,o= =3Da,s=3Du;break;case 1:r=3Da,o=3Dn,s=3Du;break;case 2:r=3Du,o=3Dn,s=3Da;br= eak;case 3:r=3Du,o=3Da,s=3Dn;break;case 4:r=3Da,o=3Du,s=3Dn;break;case 5:r= =3Dn,o=3Du,s=3Da}return[255*r,255*o,255*s]},a.cmyk.rgb=3Dfunction(t){var e= =3Dt[0]/100,n=3Dt[1]/100,i=3Dt[2]/100,a=3Dt[3]/100;return[255*(1-Math.min(1= ,e*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,i*(1-a)+a))]},= a.xyz.rgb=3Dfunction(t){var e,n,i,a=3Dt[0]/100,r=3Dt[1]/100,o=3Dt[2]/100;re= turn n=3D-.9689*a+1.8758*r+.0415*o,i=3D.0557*a+-.204*r+1.057*o,e=3D(e=3D3.2= 406*a+-1.5372*r+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n= =3Dn>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,i=3Di>.0031308?1.055*Mat= h.pow(i,1/2.4)-.055:12.92*i,[255*(e=3DMath.min(Math.max(0,e),1)),255*(n=3DM= ath.min(Math.max(0,n),1)),255*(i=3DMath.min(Math.max(0,i),1))]},a.xyz.lab= =3Dfunction(t){var e=3Dt[0],n=3Dt[1],i=3Dt[2];return n/=3D100,i/=3D108.883,= e=3D(e/=3D95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=3Dn>.00885= 6?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(i=3Di>.008856?Math.p= ow(i,1/3):7.787*i+16/116))]},a.lab.xyz=3Dfunction(t){var e,n,i,a=3Dt[0];e= =3Dt[1]/500+(n=3D(a+16)/116),i=3Dn-t[2]/200;var r=3DMath.pow(n,3),o=3DMath.= pow(e,3),s=3DMath.pow(i,3);return n=3Dr>.008856?r:(n-16/116)/7.787,e=3Do>.0= 08856?o:(e-16/116)/7.787,i=3Ds>.008856?s:(i-16/116)/7.787,[e*=3D95.047,n*= =3D100,i*=3D108.883]},a.lab.lch=3Dfunction(t){var e,n=3Dt[0],i=3Dt[1],a=3Dt= [2];return(e=3D360*Math.atan2(a,i)/2/Math.PI)<0&&(e+=3D360),[n,Math.sqrt(i*= i+a*a),e]},a.lch.lab=3Dfunction(t){var e,n=3Dt[0],i=3Dt[1];return e=3Dt[2]/= 360*2*Math.PI,[n,i*Math.cos(e),i*Math.sin(e)]},a.rgb.ansi16=3Dfunction(t){v= ar e=3Dt[0],n=3Dt[1],i=3Dt[2],r=3D1 in arguments?arguments[1]:a.rgb.hsv(t)[= 2];if(0=3D=3D=3D(r=3DMath.round(r/50)))return 30;var o=3D30+(Math.round(i/2= 55)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2=3D=3D=3Dr&&(o+=3D60= ),o},a.hsv.ansi16=3Dfunction(t){return a.rgb.ansi16(a.hsv.rgb(t),t[2])},a.r= gb.ansi256=3Dfunction(t){var e=3Dt[0],n=3Dt[1],i=3Dt[2];return e=3D=3D=3Dn&= &n=3D=3D=3Di?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round= (e/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5)},a.ansi16.rgb=3Dfunctio= n(t){var e=3Dt%10;if(0=3D=3D=3De||7=3D=3D=3De)return t>50&&(e+=3D3.5),[e=3D= e/10.5*255,e,e];var n=3D.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(= e>>2&1)*n*255]},a.ansi256.rgb=3Dfunction(t){if(t>=3D232){var e=3D10*(t-232)= +8;return[e,e,e]}var n;return t-=3D16,[Math.floor(t/36)/5*255,Math.floor((n= =3Dt%36)/6)/5*255,n%6/5*255]},a.rgb.hex=3Dfunction(t){var e=3D(((255&Math.r= ound(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toStri= ng(16).toUpperCase();return"000000".substring(e.length)+e},a.hex.rgb=3Dfunc= tion(t){var e=3Dt.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)retu= rn[0,0,0];var n=3De[0];3=3D=3D=3De[0].length&&(n=3Dn.split("").map((functio= n(t){return t+t})).join(""));var i=3DparseInt(n,16);return[i>>16&255,i>>8&2= 55,255&i]},a.rgb.hcg=3Dfunction(t){var e,n=3Dt[0]/255,i=3Dt[1]/255,a=3Dt[2]= /255,r=3DMath.max(Math.max(n,i),a),o=3DMath.min(Math.min(n,i),a),s=3Dr-o;re= turn e=3Ds<=3D0?0:r=3D=3D=3Dn?(i-a)/s%6:r=3D=3D=3Di?2+(a-n)/s:4+(n-i)/s+4,e= /=3D6,[360*(e%=3D1),100*s,100*(s<1?o/(1-s):0)]},a.hsl.hcg=3Dfunction(t){var= e=3Dt[1]/100,n=3Dt[2]/100,i=3D1,a=3D0;return(i=3Dn<.5?2*e*n:2*e*(1-n))<1&&= (a=3D(n-.5*i)/(1-i)),[t[0],100*i,100*a]},a.hsv.hcg=3Dfunction(t){var e=3Dt[= 1]/100,n=3Dt[2]/100,i=3De*n,a=3D0;return i<1&&(a=3D(n-i)/(1-i)),[t[0],100*i= ,100*a]},a.hcg.rgb=3Dfunction(t){var e=3Dt[0]/360,n=3Dt[1]/100,i=3Dt[2]/100= ;if(0=3D=3D=3Dn)return[255*i,255*i,255*i];var a,r=3D[0,0,0],o=3De%1*6,s=3Do= %1,l=3D1-s;switch(Math.floor(o)){case 0:r[0]=3D1,r[1]=3Ds,r[2]=3D0;break;ca= se 1:r[0]=3Dl,r[1]=3D1,r[2]=3D0;break;case 2:r[0]=3D0,r[1]=3D1,r[2]=3Ds;bre= ak;case 3:r[0]=3D0,r[1]=3Dl,r[2]=3D1;break;case 4:r[0]=3Ds,r[1]=3D0,r[2]=3D= 1;break;default:r[0]=3D1,r[1]=3D0,r[2]=3Dl}return a=3D(1-n)*i,[255*(n*r[0]+= a),255*(n*r[1]+a),255*(n*r[2]+a)]},a.hcg.hsv=3Dfunction(t){var e=3Dt[1]/100= ,n=3De+t[2]/100*(1-e),i=3D0;return n>0&&(i=3De/n),[t[0],100*i,100*n]},a.hcg= .hsl=3Dfunction(t){var e=3Dt[1]/100,n=3Dt[2]/100*(1-e)+.5*e,i=3D0;return n>= 0&&n<.5?i=3De/(2*n):n>=3D.5&&n<1&&(i=3De/(2*(1-n))),[t[0],100*i,100*n]},a.h= cg.hwb=3Dfunction(t){var e=3Dt[1]/100,n=3De+t[2]/100*(1-e);return[t[0],100*= (n-e),100*(1-n)]},a.hwb.hcg=3Dfunction(t){var e=3Dt[1]/100,n=3D1-t[2]/100,i= =3Dn-e,a=3D0;return i<1&&(a=3D(n-i)/(1-i)),[t[0],100*i,100*a]},a.apple.rgb= =3Dfunction(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},a.rgb.= apple=3Dfunction(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},a= .gray.rgb=3Dfunction(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},a.g= ray.hsl=3Da.gray.hsv=3Dfunction(t){return[0,0,t[0]]},a.gray.hwb=3Dfunction(= t){return[0,100,t[0]]},a.gray.cmyk=3Dfunction(t){return[0,0,0,t[0]]},a.gray= .lab=3Dfunction(t){return[t[0],0,0]},a.gray.hex=3Dfunction(t){var e=3D255&M= ath.round(t[0]/100*255),n=3D((e<<16)+(e<<8)+e).toString(16).toUpperCase();r= eturn"000000".substring(n.length)+n},a.rgb.gray=3Dfunction(t){return[(t[0]+= t[1]+t[2])/3/255*100]}}));n.rgb,n.hsl,n.hsv,n.hwb,n.cmyk,n.xyz,n.lab,n.lch,= n.hex,n.keyword,n.ansi16,n.ansi256,n.hcg,n.apple,n.gray;function i(t){var e= =3Dfunction(){for(var t=3D{},e=3DObject.keys(n),i=3De.length,a=3D0;a1&&(e=3DArray.prototype.slice.call(arguments));var n=3Dt(e);if("object"=3D= =3Dtypeof n)for(var i=3Dn.length,a=3D0;a1&&(e=3DArray.prototype.slice.call(arguments)),t(e))};return"conversion"in= t&&(e.conversion=3Dt.conversion),e}(i)}))}));var s=3Do,l=3D{aliceblue:[240= ,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,2= 12],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0= ,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],bro= wn:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[1= 27,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149= ,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:= [0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169= ,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],da= rkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],dar= korchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagree= n:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslat= egrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:= [255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105= ,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,24= 0],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghos= twhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,= 128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[= 240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],= ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblus= h:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:= [173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenr= odyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lig= htgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],ligh= tseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,1= 53],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[= 255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magen= ta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[= 0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagree= n:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],= mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,= 25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,1= 81],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[1= 28,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],or= chid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],pale= turquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213= ],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,16= 0,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,15= 3],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown= :[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,= 87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:= [135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112= ,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180]= ,tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71= ],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[25= 5,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205= ,50]},u=3D{getRgba:d,getHsla:h,getRgb:function(t){var e=3Dd(t);return e&&e.= slice(0,3)},getHsl:function(t){var e=3Dh(t);return e&&e.slice(0,3)},getHwb:= c,getAlpha:function(t){var e=3Dd(t);if(e)return e[3];if(e=3Dh(t))return e[3= ];if(e=3Dc(t))return e[3]},hexString:function(t,e){e=3Dvoid 0!=3D=3De&&3=3D= =3D=3Dt.length?e:t[3];return"#"+v(t[0])+v(t[1])+v(t[2])+(e>=3D0&&e<1?v(Math= .round(255*e)):"")},rgbString:function(t,e){if(e<1||t[3]&&t[3]<1)return f(t= ,e);return"rgb("+t[0]+", "+t[1]+", "+t[2]+")"},rgbaString:f,percentString:f= unction(t,e){if(e<1||t[3]&&t[3]<1)return g(t,e);var n=3DMath.round(t[0]/255= *100),i=3DMath.round(t[1]/255*100),a=3DMath.round(t[2]/255*100);return"rgb(= "+n+"%, "+i+"%, "+a+"%)"},percentaString:g,hslString:function(t,e){if(e<1||= t[3]&&t[3]<1)return p(t,e);return"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"},hsl= aString:p,hwbString:function(t,e){void 0=3D=3D=3De&&(e=3Dvoid 0!=3D=3Dt[3]?= t[3]:1);return"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!=3D=3De&&1!=3D= =3De?", "+e:"")+")"},keyword:function(t){return b[t.slice(0,3)]}};function = d(t){if(t){var e=3D[0,0,0],n=3D1,i=3Dt.match(/^#([a-fA-F0-9]{3,4})$/i),a=3D= "";if(i){a=3D(i=3Di[1])[3];for(var r=3D0;rn?(e+.05)/(n+.05):(n+.05)/(e+.05= )},level:function(t){var e=3Dthis.contrast(t);return e>=3D7.1?"AAA":e>=3D4.= 5?"AA":""},dark:function(){var t=3Dthis.values.rgb;return(299*t[0]+587*t[1]= +114*t[2])/1e3<128},light:function(){return!this.dark()},negate:function(){= for(var t=3D[],e=3D0;e<3;e++)t[e]=3D255-this.values.rgb[e];return this.setV= alues("rgb",t),this},lighten:function(t){var e=3Dthis.values.hsl;return e[2= ]+=3De[2]*t,this.setValues("hsl",e),this},darken:function(t){var e=3Dthis.v= alues.hsl;return e[2]-=3De[2]*t,this.setValues("hsl",e),this},saturate:func= tion(t){var e=3Dthis.values.hsl;return e[1]+=3De[1]*t,this.setValues("hsl",= e),this},desaturate:function(t){var e=3Dthis.values.hsl;return e[1]-=3De[1]= *t,this.setValues("hsl",e),this},whiten:function(t){var e=3Dthis.values.hwb= ;return e[1]+=3De[1]*t,this.setValues("hwb",e),this},blacken:function(t){va= r e=3Dthis.values.hwb;return e[2]+=3De[2]*t,this.setValues("hwb",e),this},g= reyscale:function(){var t=3Dthis.values.rgb,e=3D.3*t[0]+.59*t[1]+.11*t[2];r= eturn this.setValues("rgb",[e,e,e]),this},clearer:function(t){var e=3Dthis.= values.alpha;return this.setValues("alpha",e-e*t),this},opaquer:function(t)= {var e=3Dthis.values.alpha;return this.setValues("alpha",e+e*t),this},rotat= e:function(t){var e=3Dthis.values.hsl,n=3D(e[0]+t)%360;return e[0]=3Dn<0?36= 0+n:n,this.setValues("hsl",e),this},mix:function(t,e){var n=3Dt,i=3Dvoid 0= =3D=3D=3De?.5:e,a=3D2*i-1,r=3Dthis.alpha()-n.alpha(),o=3D((a*r=3D=3D-1?a:(a= +r)/(1+a*r))+1)/2,s=3D1-o;return this.rgb(o*this.red()+s*n.red(),o*this.gre= en()+s*n.green(),o*this.blue()+s*n.blue()).alpha(this.alpha()*i+n.alpha()*(= 1-i))},toJSON:function(){return this.rgb()},clone:function(){var t,e,n=3Dne= w y,i=3Dthis.values,a=3Dn.values;for(var r in i)i.hasOwnProperty(r)&&(t=3Di= [r],"[object Array]"=3D=3D=3D(e=3D{}.toString.call(t))?a[r]=3Dt.slice(0):"[= object Number]"=3D=3D=3De?a[r]=3Dt:console.error("unexpected color value:",= t));return n}},y.prototype.spaces=3D{rgb:["red","green","blue"],hsl:["hue",= "saturation","lightness"],hsv:["hue","saturation","value"],hwb:["hue","whit= eness","blackness"],cmyk:["cyan","magenta","yellow","black"]},y.prototype.m= axes=3D{rgb:[255,255,255],hsl:[360,100,100],hsv:[360,100,100],hwb:[360,100,= 100],cmyk:[100,100,100,100]},y.prototype.getValues=3Dfunction(t){for(var e= =3Dthis.values,n=3D{},i=3D0;i=3D0;a--)e.call(n,t[a],a);= else for(a=3D0;a=3D1?t:-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math= .sqrt(1-(t-=3D1)*t)},easeInOutCirc:function(t){return(t/=3D.5)<1?-.5*(Math.= sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=3D2)*t)+1)},easeInElastic:function(t){va= r e=3D1.70158,n=3D0,i=3D1;return 0=3D=3D=3Dt?0:1=3D=3D=3Dt?1:(n||(n=3D.3),i= <1?(i=3D1,e=3Dn/4):e=3Dn/(2*Math.PI)*Math.asin(1/i),-i*Math.pow(2,10*(t-=3D= 1))*Math.sin((t-e)*(2*Math.PI)/n))},easeOutElastic:function(t){var e=3D1.70= 158,n=3D0,i=3D1;return 0=3D=3D=3Dt?0:1=3D=3D=3Dt?1:(n||(n=3D.3),i<1?(i=3D1,= e=3Dn/4):e=3Dn/(2*Math.PI)*Math.asin(1/i),i*Math.pow(2,-10*t)*Math.sin((t-e= )*(2*Math.PI)/n)+1)},easeInOutElastic:function(t){var e=3D1.70158,n=3D0,i= =3D1;return 0=3D=3D=3Dt?0:2=3D=3D(t/=3D.5)?1:(n||(n=3D.45),i<1?(i=3D1,e=3Dn= /4):e=3Dn/(2*Math.PI)*Math.asin(1/i),t<1?i*Math.pow(2,10*(t-=3D1))*Math.sin= ((t-e)*(2*Math.PI)/n)*-.5:i*Math.pow(2,-10*(t-=3D1))*Math.sin((t-e)*(2*Math= .PI)/n)*.5+1)},easeInBack:function(t){var e=3D1.70158;return t*t*((e+1)*t-e= )},easeOutBack:function(t){var e=3D1.70158;return(t-=3D1)*t*((e+1)*t+e)+1},= easeInOutBack:function(t){var e=3D1.70158;return(t/=3D.5)<1?t*t*((1+(e*=3D1= .525))*t-e)*.5:.5*((t-=3D2)*t*((1+(e*=3D1.525))*t+e)+2)},easeInBounce:funct= ion(t){return 1-S.easeOutBounce(1-t)},easeOutBounce:function(t){return t<1/= 2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=3D1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-= =3D2.25/2.75)*t+.9375:7.5625*(t-=3D2.625/2.75)*t+.984375},easeInOutBounce:f= unction(t){return t<.5?.5*S.easeInBounce(2*t):.5*S.easeOutBounce(2*t-1)+.5}= },C=3D{effects:S};M.easingEffects=3DS;var P=3DMath.PI,A=3DP/180,D=3D2*P,T= =3DP/2,I=3DP/4,F=3D2*P/3,L=3D{clear:function(t){t.ctx.clearRect(0,0,t.width= ,t.height)},roundedRect:function(t,e,n,i,a,r){if(r){var o=3DMath.min(r,a/2,= i/2),s=3De+o,l=3Dn+o,u=3De+i-o,d=3Dn+a-o;t.moveTo(e,l),se.left-1e-6&&t.xe.top-1e-6&&t.y0&&this.requestAnimationFrame()},advance:function(){for(var t,e,n,i,a=3Dt= his.animations,r=3D0;r=3Dn?(V.callback(t.onAnimationComplete,[t],e),e.animating=3D!1= ,a.splice(r,1)):++r}},J=3DV.options.resolve,Q=3D["push","pop","shift","spli= ce","unshift"];function tt(t,e){var n=3Dt._chartjs;if(n){var i=3Dn.listener= s,a=3Di.indexOf(e);-1!=3D=3Da&&i.splice(a,1),i.length>0||(Q.forEach((functi= on(e){delete t[e]})),delete t._chartjs)}}var et=3Dfunction(t,e){this.initia= lize(t,e)};V.extend(et.prototype,{datasetElementType:null,dataElementType:n= ull,_datasetElementOptions:["backgroundColor","borderCapStyle","borderColor= ","borderDash","borderDashOffset","borderJoinStyle","borderWidth"],_dataEle= mentOptions:["backgroundColor","borderColor","borderWidth","pointStyle"],in= itialize:function(t,e){var n=3Dthis;n.chart=3Dt,n.index=3De,n.linkScales(),= n.addElements(),n._type=3Dn.getMeta().type},updateIndex:function(t){this.in= dex=3Dt},linkScales:function(){var t=3Dthis.getMeta(),e=3Dthis.chart,n=3De.= scales,i=3Dthis.getDataset(),a=3De.options.scales;null!=3D=3Dt.xAxisID&&t.x= AxisID in n&&!i.xAxisID||(t.xAxisID=3Di.xAxisID||a.xAxes[0].id),null!=3D=3D= t.yAxisID&&t.yAxisID in n&&!i.yAxisID||(t.yAxisID=3Di.yAxisID||a.yAxes[0].i= d)},getDataset:function(){return this.chart.data.datasets[this.index]},getM= eta:function(){return this.chart.getDatasetMeta(this.index)},getScaleForId:= function(t){return this.chart.scales[t]},_getValueScaleId:function(){return= this.getMeta().yAxisID},_getIndexScaleId:function(){return this.getMeta().= xAxisID},_getValueScale:function(){return this.getScaleForId(this._getValue= ScaleId())},_getIndexScale:function(){return this.getScaleForId(this._getIn= dexScaleId())},reset:function(){this._update(!0)},destroy:function(){this._= data&&tt(this._data,this)},createMetaDataset:function(){var t=3Dthis.datase= tElementType;return t&&new t({_chart:this.chart,_datasetIndex:this.index})}= ,createMetaData:function(t){var e=3Dthis.dataElementType;return e&&new e({_= chart:this.chart,_datasetIndex:this.index,_index:t})},addElements:function(= ){var t,e,n=3Dthis.getMeta(),i=3Dthis.getDataset().data||[],a=3Dn.data;for(= t=3D0,e=3Di.length;tn&&this.insertElements(n,i-n)},insertElements:function= (t,e){for(var n=3D0;na?(r=3Da/e.innerRadius,t.a= rc(o,s,e.innerRadius-a,i+r,n-r,!0)):t.arc(o,s,a,i+Math.PI/2,n-Math.PI/2),t.= closePath(),t.clip()}function rt(t,e,n){var i=3D"inner"=3D=3D=3De.borderAli= gn;i?(t.lineWidth=3D2*e.borderWidth,t.lineJoin=3D"round"):(t.lineWidth=3De.= borderWidth,t.lineJoin=3D"bevel"),n.fullCircles&&function(t,e,n,i){var a,r= =3Dn.endAngle;for(i&&(n.endAngle=3Dn.startAngle+it,at(t,n),n.endAngle=3Dr,n= .endAngle=3D=3D=3Dn.startAngle&&n.fullCircles&&(n.endAngle+=3Dit,n.fullCirc= les--)),t.beginPath(),t.arc(n.x,n.y,n.innerRadius,n.startAngle+it,n.startAn= gle,!0),a=3D0;as;)a-=3Dit;for(;a=3Do&&a<=3Ds,u=3Dr>= =3Dn.innerRadius&&r<=3Dn.outerRadius;return l&&u}return!1},getCenterPoint:f= unction(){var t=3Dthis._view,e=3D(t.startAngle+t.endAngle)/2,n=3D(t.innerRa= dius+t.outerRadius)/2;return{x:t.x+Math.cos(e)*n,y:t.y+Math.sin(e)*n}},getA= rea:function(){var t=3Dthis._view;return Math.PI*((t.endAngle-t.startAngle)= /(2*Math.PI))*(Math.pow(t.outerRadius,2)-Math.pow(t.innerRadius,2))},toolti= pPosition:function(){var t=3Dthis._view,e=3Dt.startAngle+(t.endAngle-t.star= tAngle)/2,n=3D(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Ma= th.cos(e)*n,y:t.y+Math.sin(e)*n}},draw:function(){var t,e=3Dthis._chart.ctx= ,n=3Dthis._view,i=3D"inner"=3D=3D=3Dn.borderAlign?.33:0,a=3D{x:n.x,y:n.y,in= nerRadius:n.innerRadius,outerRadius:Math.max(n.outerRadius-i,0),pixelMargin= :i,startAngle:n.startAngle,endAngle:n.endAngle,fullCircles:Math.floor(n.cir= cumference/it)};if(e.save(),e.fillStyle=3Dn.backgroundColor,e.strokeStyle= =3Dn.borderColor,a.fullCircles){for(a.endAngle=3Da.startAngle+it,e.beginPat= h(),e.arc(a.x,a.y,a.outerRadius,a.startAngle,a.endAngle),e.arc(a.x,a.y,a.in= nerRadius,a.endAngle,a.startAngle,!0),e.closePath(),t=3D0;tt.x&&(e=3Dvt(e,"left","right")= ):t.basen?n:i,r:l.right||a<0?0:a>e?e:a,b:l.botto= m||r<0?0:r>n?n:r,l:l.left||o<0?0:o>e?e:o}}function xt(t,e,n){var i=3Dnull= =3D=3D=3De,a=3Dnull=3D=3D=3Dn,r=3D!(!t||i&&a)&&mt(t);return r&&(i||e>=3Dr.l= eft&&e<=3Dr.right)&&(a||n>=3Dr.top&&n<=3Dr.bottom)}z._set("global",{element= s:{rectangle:{backgroundColor:gt,borderColor:gt,borderSkipped:"bottom",bord= erWidth:0}}});var yt=3DX.extend({_type:"rectangle",draw:function(){var t=3D= this._chart.ctx,e=3Dthis._view,n=3Dfunction(t){var e=3Dmt(t),n=3De.right-e.= left,i=3De.bottom-e.top,a=3Dbt(t,n/2,i/2);return{outer:{x:e.left,y:e.top,w:= n,h:i},inner:{x:e.left+a.l,y:e.top+a.t,w:n-a.l-a.r,h:i-a.t-a.b}}}(e),i=3Dn.= outer,a=3Dn.inner;t.fillStyle=3De.backgroundColor,t.fillRect(i.x,i.y,i.w,i.= h),i.w=3D=3D=3Da.w&&i.h=3D=3D=3Da.h||(t.save(),t.beginPath(),t.rect(i.x,i.y= ,i.w,i.h),t.clip(),t.fillStyle=3De.borderColor,t.rect(a.x,a.y,a.w,a.h),t.fi= ll("evenodd"),t.restore())},height:function(){var t=3Dthis._view;return t.b= ase-t.y},inRange:function(t,e){return xt(this._view,t,e)},inLabelRange:func= tion(t,e){var n=3Dthis._view;return pt(n)?xt(n,t,null):xt(n,null,e)},inXRan= ge:function(t){return xt(this._view,t,null)},inYRange:function(t){return xt= (this._view,null,t)},getCenterPoint:function(){var t,e,n=3Dthis._view;retur= n pt(n)?(t=3Dn.x,e=3D(n.y+n.base)/2):(t=3D(n.x+n.base)/2,e=3Dn.y),{x:t,y:e}= },getArea:function(){var t=3Dthis._view;return pt(t)?t.width*Math.abs(t.y-t= .base):t.height*Math.abs(t.x-t.base)},tooltipPosition:function(){var t=3Dth= is._view;return{x:t.x,y:t.y}}}),_t=3D{},kt=3Dot,wt=3Dut,Mt=3Dft,St=3Dyt;_t.= Arc=3Dkt,_t.Line=3Dwt,_t.Point=3DMt,_t.Rectangle=3DSt;var Ct=3DV._deprecate= d,Pt=3DV.valueOrDefault;function At(t,e,n){var i,a,r=3Dn.barThickness,o=3De= .stackCount,s=3De.pixels[t],l=3DV.isNullOrUndef(r)?function(t,e){var n,i,a,= r,o=3Dt._length;for(a=3D1,r=3De.length;a0?Math.min(o,Math.abs(i-n)):o,n=3Di;return o}(e.scale,e.pixels):-1;= return V.isNullOrUndef(r)?(i=3Dl*n.categoryPercentage,a=3Dn.barPercentage):= (i=3Dr*o,a=3D1),{chunk:i/o,ratio:a,start:s-i/2}}z._set("bar",{hover:{mode:"= label"},scales:{xAxes:[{type:"category",offset:!0,gridLines:{offsetGridLine= s:!0}}],yAxes:[{type:"linear"}]}}),z._set("global",{datasets:{bar:{category= Percentage:.8,barPercentage:.9}}});var Dt=3Dnt.extend({dataElementType:_t.R= ectangle,_dataElementOptions:["backgroundColor","borderColor","borderSkippe= d","borderWidth","barPercentage","barThickness","categoryPercentage","maxBa= rThickness","minBarLength"],initialize:function(){var t,e,n=3Dthis;nt.proto= type.initialize.apply(n,arguments),(t=3Dn.getMeta()).stack=3Dn.getDataset()= .stack,t.bar=3D!0,e=3Dn._getIndexScale().options,Ct("bar chart",e.barPercen= tage,"scales.[x/y]Axes.barPercentage","dataset.barPercentage"),Ct("bar char= t",e.barThickness,"scales.[x/y]Axes.barThickness","dataset.barThickness"),C= t("bar chart",e.categoryPercentage,"scales.[x/y]Axes.categoryPercentage","d= ataset.categoryPercentage"),Ct("bar chart",n._getValueScale().options.minBa= rLength,"scales.[x/y]Axes.minBarLength","dataset.minBarLength"),Ct("bar cha= rt",e.maxBarThickness,"scales.[x/y]Axes.maxBarThickness","dataset.maxBarThi= ckness")},update:function(t){var e,n,i=3Dthis.getMeta().data;for(this._rule= r=3Dthis.getRuler(),e=3D0,n=3Di.length;e=3D0&&p.min>=3D0?p.min:p.max,y=3Dvoid 0=3D=3D=3Dp.start?p.end:p= .max>=3D0&&p.min>=3D0?p.max-p.min:p.min-p.max,_=3Dg.length;if(v||void 0=3D= =3D=3Dv&&void 0!=3D=3Db)for(i=3D0;i<_&&(a=3Dg[i]).index!=3D=3Dt;++i)a.stack= =3D=3D=3Db&&(r=3Dvoid 0=3D=3D=3D(u=3Dh._parseValue(f[a.index].data[e])).sta= rt?u.end:u.min>=3D0&&u.max>=3D0?u.max:u.min,(p.min<0&&r<0||p.max>=3D0&&r>0)= &&(x+=3Dr));return o=3Dh.getPixelForValue(x),l=3D(s=3Dh.getPixelForValue(x+= y))-o,void 0!=3D=3Dm&&Math.abs(l)=3D0&&!c||y<0&&c?o-m:o+m)= ,{size:l,base:o,head:s,center:s+l/2}},calculateBarIndexPixels:function(t,e,= n,i){var a=3D"flex"=3D=3D=3Di.barThickness?function(t,e,n){var i,a=3De.pixe= ls,r=3Da[t],o=3Dt>0?a[t-1]:null,s=3Dt=3DOt?-Rt:b<-Ot?Rt:0)+m,y=3DMath.cos(b),_=3DMa= th.sin(b),k=3DMath.cos(x),w=3DMath.sin(x),M=3Db<=3D0&&x>=3D0||x>=3DRt,S=3Db= <=3Dzt&&x>=3Dzt||x>=3DRt+zt,C=3Db<=3D-zt&&x>=3D-zt||x>=3DOt+zt,P=3Db=3D=3D= =3D-Ot||x>=3DOt?-1:Math.min(y,y*p,k,k*p),A=3DC?-1:Math.min(_,_*p,w,w*p),D= =3DM?1:Math.max(y,y*p,k,k*p),T=3DS?1:Math.max(_,_*p,w,w*p);u=3D(D-P)/2,d=3D= (T-A)/2,h=3D-(D+P)/2,c=3D-(T+A)/2}for(i=3D0,a=3Dg.length;i0&&!isNaN(t)?Rt*(Math.abs(t)/e):0},getMaxBorderWidth:function(t){var e,= n,i,a,r,o,s,l,u=3D0,d=3Dthis.chart;if(!t)for(e=3D0,n=3Dd.data.datasets.leng= th;e(u=3Ds>u?s:u)?l:u);return u},setHoverStyle:function(= t){var e=3Dt._model,n=3Dt._options,i=3DV.getHoverColor;t.$previousStyle=3D{= backgroundColor:e.backgroundColor,borderColor:e.borderColor,borderWidth:e.b= orderWidth},e.backgroundColor=3DLt(n.hoverBackgroundColor,i(n.backgroundCol= or)),e.borderColor=3DLt(n.hoverBorderColor,i(n.borderColor)),e.borderWidth= =3DLt(n.hoverBorderWidth,n.borderWidth)},_getRingWeightOffset:function(t){f= or(var e=3D0,n=3D0;n0&&Vt(l[t-1]._model,s)&&(n.controlPointPreviousX=3Du(= n.controlPointPreviousX,s.left,s.right),n.controlPointPreviousY=3Du(n.contr= olPointPreviousY,s.top,s.bottom)),t0&&(r=3Dt.getDatasetMeta(r[0]._datase= tIndex).data),r},"x-axis":function(t,e){return ie(t,e,{intersect:!1})},poin= t:function(t,e){return te(t,Jt(e,t))},nearest:function(t,e,n){var i=3DJt(e,= t);n.axis=3Dn.axis||"xy";var a=3Dne(n.axis);return ee(t,i,n.intersect,a)},x= :function(t,e,n){var i=3DJt(e,t),a=3D[],r=3D!1;return Qt(t,(function(t){t.i= nXRange(i.x)&&a.push(t),t.inRange(i.x,i.y)&&(r=3D!0)})),n.intersect&&!r&&(a= =3D[]),a},y:function(t,e,n){var i=3DJt(e,t),a=3D[],r=3D!1;return Qt(t,(func= tion(t){t.inYRange(i.y)&&a.push(t),t.inRange(i.x,i.y)&&(r=3D!0)})),n.inters= ect&&!r&&(a=3D[]),a}}},re=3DV.extend;function oe(t,e){return V.where(t,(fun= ction(t){return t.pos=3D=3D=3De}))}function se(t,e){return t.sort((function= (t,n){var i=3De?n:t,a=3De?t:n;return i.weight=3D=3D=3Da.weight?i.index-a.in= dex:i.weight-a.weight}))}function le(t,e,n,i){return Math.max(t[n],e[n])+Ma= th.max(t[i],e[i])}function ue(t,e,n){var i,a,r=3Dn.box,o=3Dt.maxPadding;if(= n.size&&(t[n.pos]-=3Dn.size),n.size=3Dn.horizontal?r.height:r.width,t[n.pos= ]+=3Dn.size,r.getPadding){var s=3Dr.getPadding();o.top=3DMath.max(o.top,s.t= op),o.left=3DMath.max(o.left,s.left),o.bottom=3DMath.max(o.bottom,s.bottom)= ,o.right=3DMath.max(o.right,s.right)}if(i=3De.outerWidth-le(o,t,"left","rig= ht"),a=3De.outerHeight-le(o,t,"top","bottom"),i!=3D=3Dt.w||a!=3D=3Dt.h)retu= rn t.w=3Di,t.h=3Da,n.horizontal?i!=3D=3Dt.w:a!=3D=3Dt.h}function de(t,e){va= r n=3De.maxPadding;function i(t){var i=3D{left:0,top:0,right:0,bottom:0};re= turn t.forEach((function(t){i[t]=3DMath.max(e[t],n[t])})),i}return i(t?["le= ft","right"]:["top","bottom"])}function he(t,e,n){var i,a,r,o,s,l,u=3D[];fo= r(i=3D0,a=3Dt.length;idiv{position:absolute;width:1000000px;height:100= 0000px;left:0;top:0}.chartjs-size-monitor-shrink>div{position:absolute;widt= h:200%;height:200%;left:0;top:0}"}))&&fe.default||fe,me=3D"$chartjs",ve=3D"= chartjs-size-monitor",be=3D"chartjs-render-monitor",xe=3D"chartjs-render-an= imation",ye=3D["animationstart","webkitAnimationStart"],_e=3D{touchstart:"m= ousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter= ",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",point= erleave:"mouseout",pointerout:"mouseout"};function ke(t,e){var n=3DV.getSty= le(t,e),i=3Dn&&n.match(/^(\d+)(\.\d+)?px$/);return i?Number(i[1]):void 0}va= r we=3D!!function(){var t=3D!1;try{var e=3DObject.defineProperty({},"passiv= e",{get:function(){t=3D!0}});window.addEventListener("e",null,e)}catch(t){}= return t}()&&{passive:!0};function Me(t,e,n){t.addEventListener(e,n,we)}fun= ction Se(t,e,n){t.removeEventListener(e,n,we)}function Ce(t,e,n,i,a){return= {type:t,chart:e,native:a||null,x:void 0!=3D=3Dn?n:null,y:void 0!=3D=3Di?i:n= ull}}function Pe(t){var e=3Ddocument.createElement("div");return e.classNam= e=3Dt||"",e}function Ae(t,e,n){var i,a,r,o,s=3Dt[me]||(t[me]=3D{}),l=3Ds.re= sizer=3Dfunction(t){var e=3DPe(ve),n=3DPe(ve+"-expand"),i=3DPe(ve+"-shrink"= );n.appendChild(Pe()),i.appendChild(Pe()),e.appendChild(n),e.appendChild(i)= ,e._reset=3Dfunction(){n.scrollLeft=3D1e6,n.scrollTop=3D1e6,i.scrollLeft=3D= 1e6,i.scrollTop=3D1e6};var a=3Dfunction(){e._reset(),t()};return Me(n,"scro= ll",a.bind(n,"expand")),Me(i,"scroll",a.bind(i,"shrink")),e}((i=3Dfunction(= ){if(s.resizer){var i=3Dn.options.maintainAspectRatio&&t.parentNode,a=3Di?i= .clientWidth:0;e(Ce("resize",n)),i&&i.clientWidth0){var r= =3Dt[0];r.label?n=3Dr.label:r.xLabel?n=3Dr.xLabel:a>0&&r.index-= 1?t.split("\n"):t}function We(t){var e=3Dz.global;return{xPadding:t.xPaddin= g,yPadding:t.yPadding,xAlign:t.xAlign,yAlign:t.yAlign,rtl:t.rtl,textDirecti= on:t.textDirection,bodyFontColor:t.bodyFontColor,_bodyFontFamily:Re(t.bodyF= ontFamily,e.defaultFontFamily),_bodyFontStyle:Re(t.bodyFontStyle,e.defaultF= ontStyle),_bodyAlign:t.bodyAlign,bodyFontSize:Re(t.bodyFontSize,e.defaultFo= ntSize),bodySpacing:t.bodySpacing,titleFontColor:t.titleFontColor,_titleFon= tFamily:Re(t.titleFontFamily,e.defaultFontFamily),_titleFontStyle:Re(t.titl= eFontStyle,e.defaultFontStyle),titleFontSize:Re(t.titleFontSize,e.defaultFo= ntSize),_titleAlign:t.titleAlign,titleSpacing:t.titleSpacing,titleMarginBot= tom:t.titleMarginBottom,footerFontColor:t.footerFontColor,_footerFontFamily= :Re(t.footerFontFamily,e.defaultFontFamily),_footerFontStyle:Re(t.footerFon= tStyle,e.defaultFontStyle),footerFontSize:Re(t.footerFontSize,e.defaultFont= Size),_footerAlign:t.footerAlign,footerSpacing:t.footerSpacing,footerMargin= Top:t.footerMarginTop,caretSize:t.caretSize,cornerRadius:t.cornerRadius,bac= kgroundColor:t.backgroundColor,opacity:0,legendColorBackground:t.multiKeyBa= ckground,displayColors:t.displayColors,borderColor:t.borderColor,borderWidt= h:t.borderWidth}}function Ve(t,e){return"center"=3D=3D=3De?t.x+t.width/2:"r= ight"=3D=3D=3De?t.x+t.width-t.xPadding:t.x+t.xPadding}function He(t){return= Be([],Ee(t))}var je=3DX.extend({initialize:function(){this._model=3DWe(thi= s._options),this._lastActive=3D[]},getTitle:function(){var t=3Dthis,e=3Dt._= options,n=3De.callbacks,i=3Dn.beforeTitle.apply(t,arguments),a=3Dn.title.ap= ply(t,arguments),r=3Dn.afterTitle.apply(t,arguments),o=3D[];return o=3DBe(o= ,Ee(i)),o=3DBe(o,Ee(a)),o=3DBe(o,Ee(r))},getBeforeBody:function(){return He= (this._options.callbacks.beforeBody.apply(this,arguments))},getBody:functio= n(t,e){var n=3Dthis,i=3Dn._options.callbacks,a=3D[];return V.each(t,(functi= on(t){var r=3D{before:[],lines:[],after:[]};Be(r.before,Ee(i.beforeLabel.ca= ll(n,t,e))),Be(r.lines,i.label.call(n,t,e)),Be(r.after,Ee(i.afterLabel.call= (n,t,e))),a.push(r)})),a},getAfterBody:function(){return He(this._options.c= allbacks.afterBody.apply(this,arguments))},getFooter:function(){var t=3Dthi= s,e=3Dt._options.callbacks,n=3De.beforeFooter.apply(t,arguments),i=3De.foot= er.apply(t,arguments),a=3De.afterFooter.apply(t,arguments),r=3D[];return r= =3DBe(r,Ee(n)),r=3DBe(r,Ee(i)),r=3DBe(r,Ee(a))},update:function(t){var e,n,= i,a,r,o,s,l,u,d,h=3Dthis,c=3Dh._options,f=3Dh._model,g=3Dh._model=3DWe(c),p= =3Dh._active,m=3Dh._data,v=3D{xAlign:f.xAlign,yAlign:f.yAlign},b=3D{x:f.x,y= :f.y},x=3D{width:f.width,height:f.height},y=3D{x:f.caretX,y:f.caretY};if(p.= length){g.opacity=3D1;var _=3D[],k=3D[];y=3DNe[c.position].call(h,p,h._even= tPosition);var w=3D[];for(e=3D0,n=3Dp.length;ei.width&&(a=3Di.width-= e.width),a<0&&(a=3D0)),"top"=3D=3D=3Dd?r+=3Dh:r-=3D"bottom"=3D=3D=3Dd?e.hei= ght+h:e.height/2,"center"=3D=3D=3Dd?"left"=3D=3D=3Du?a+=3Dh:"right"=3D=3D= =3Du&&(a-=3Dh):"left"=3D=3D=3Du?a-=3Dc:"right"=3D=3D=3Du&&(a+=3Dc),{x:a,y:r= }}(g,x,v=3Dfunction(t,e){var n,i,a,r,o,s=3Dt._model,l=3Dt._chart,u=3Dt._cha= rt.chartArea,d=3D"center",h=3D"center";s.yl.height-= e.height&&(h=3D"bottom");var c=3D(u.left+u.right)/2,f=3D(u.top+u.bottom)/2;= "center"=3D=3D=3Dh?(n=3Dfunction(t){return t<=3Dc},i=3Dfunction(t){return t= >c}):(n=3Dfunction(t){return t<=3De.width/2},i=3Dfunction(t){return t>=3Dl.= width-e.width/2}),a=3Dfunction(t){return t+e.width+s.caretSize+s.caretPaddi= ng>l.width},r=3Dfunction(t){return t-e.width-s.caretSize-s.caretPadding<0},= o=3Dfunction(t){return t<=3Df?"top":"bottom"},n(s.x)?(d=3D"left",a(s.x)&&(d= =3D"center",h=3Do(s.y))):i(s.x)&&(d=3D"right",r(s.x)&&(d=3D"center",h=3Do(s= .y)));var g=3Dt._options;return{xAlign:g.xAlign?g.xAlign:d,yAlign:g.yAlign?= g.yAlign:h}}(this,x),h._chart)}else g.opacity=3D0;return g.xAlign=3Dv.xAlig= n,g.yAlign=3Dv.yAlign,g.x=3Db.x,g.y=3Db.y,g.width=3Dx.width,g.height=3Dx.he= ight,g.caretX=3Dy.x,g.caretY=3Dy.y,h._model=3Dg,t&&c.custom&&c.custom.call(= h,g),h},drawCaret:function(t,e){var n=3Dthis._chart.ctx,i=3Dthis._view,a=3D= this.getCaretPosition(t,e,i);n.lineTo(a.x1,a.y1),n.lineTo(a.x2,a.y2),n.line= To(a.x3,a.y3)},getCaretPosition:function(t,e,n){var i,a,r,o,s,l,u=3Dn.caret= Size,d=3Dn.cornerRadius,h=3Dn.xAlign,c=3Dn.yAlign,f=3Dt.x,g=3Dt.y,p=3De.wid= th,m=3De.height;if("center"=3D=3D=3Dc)s=3Dg+m/2,"left"=3D=3D=3Dh?(a=3D(i=3D= f)-u,r=3Di,o=3Ds+u,l=3Ds-u):(a=3D(i=3Df+p)+u,r=3Di,o=3Ds-u,l=3Ds+u);else if= ("left"=3D=3D=3Dh?(i=3D(a=3Df+d+u)-u,r=3Da+u):"right"=3D=3D=3Dh?(i=3D(a=3Df= +p-d-u)-u,r=3Da+u):(i=3D(a=3Dn.caretX)-u,r=3Da+u),"top"=3D=3D=3Dc)s=3D(o=3D= g)-u,l=3Do;else{s=3D(o=3Dg+m)+u,l=3Do;var v=3Dr;r=3Di,i=3Dv}return{x1:i,x2:= a,x3:r,y1:o,y2:s,y3:l}},drawTitle:function(t,e,n){var i,a,r,o=3De.title,s= =3Do.length;if(s){var l=3Dze(e.rtl,e.x,e.width);for(t.x=3DVe(e,e._titleAlig= n),n.textAlign=3Dl.textAlign(e._titleAlign),n.textBaseline=3D"middle",i=3De= .titleFontSize,a=3De.titleSpacing,n.fillStyle=3De.titleFontColor,n.font=3DV= .fontString(i,e._titleFontStyle,e._titleFontFamily),r=3D0;r0&&n.stroke()},draw:function(){var t=3Dthis._chart.ctx,e=3Dthis.= _view;if(0!=3D=3De.opacity){var n=3D{width:e.width,height:e.height},i=3D{x:= e.x,y:e.y},a=3DMath.abs(e.opacity<.001)?0:e.opacity,r=3De.title.length||e.b= eforeBody.length||e.body.length||e.afterBody.length||e.footer.length;this._= options.enabled&&r&&(t.save(),t.globalAlpha=3Da,this.drawBackground(i,e,t,n= ),i.y+=3De.yPadding,V.rtl.overrideTextDirection(t,e.textDirection),this.dra= wTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),V.rtl.restoreText= Direction(t,e.textDirection),t.restore())}},handleEvent:function(t){var e,n= =3Dthis,i=3Dn._options;return n._lastActive=3Dn._lastActive||[],"mouseout"= =3D=3D=3Dt.type?n._active=3D[]:(n._active=3Dn._chart.getElementsAtEventForM= ode(t,i.mode,i),i.reverse&&n._active.reverse()),(e=3D!V.arrayEquals(n._acti= ve,n._lastActive))&&(n._lastActive=3Dn._active,(i.enabled||i.custom)&&(n._e= ventPosition=3D{x:t.x,y:t.y},n.update(!0),n.pivot())),e}}),qe=3DNe,Ue=3Dje;= Ue.positioners=3Dqe;var Ye=3DV.valueOrDefault;function Ge(){return V.merge(= {},[].slice.call(arguments),{merger:function(t,e,n,i){if("xAxes"=3D=3D=3Dt|= |"yAxes"=3D=3D=3Dt){var a,r,o,s=3Dn[t].length;for(e[t]||(e[t]=3D[]),a=3D0;a= = =3De[t].length&&e[t].push({}),!e[t][a].type||o.type&&o.type!=3D=3De[t][a].t= ype?V.merge(e[t][a],[Oe.getScaleDefaults(r),o]):V.merge(e[t][a],o)}else V._= merger(t,e,n,i)}})}function Xe(){return V.merge({},[].slice.call(arguments)= ,{merger:function(t,e,n,i){var a=3De[t]||{},r=3Dn[t];"scales"=3D=3D=3Dt?e[t= ]=3DGe(a,r):"scale"=3D=3D=3Dt?e[t]=3DV.merge(a,[Oe.getScaleDefaults(r.type)= ,r]):V._merger(t,e,n,i)}})}function Ke(t){var e=3Dt.options;V.each(t.scales= ,(function(e){ge.removeBox(t,e)})),e=3DXe(z.global,z[t.config.type],e),t.op= tions=3Dt.config.options=3De,t.ensureScalesHaveIDs(),t.buildOrUpdateScales(= ),t.tooltip._options=3De.tooltips,t.tooltip.initialize()}function Ze(t,e,n)= {var i,a=3Dfunction(t){return t.id=3D=3D=3Di};do{i=3De+n++}while(V.findInde= x(t,a)>=3D0);return i}function $e(t){return"top"=3D=3D=3Dt||"bottom"=3D=3D= =3Dt}function Je(t,e){return function(n,i){return n[t]=3D=3D=3Di[t]?n[e]-i[= e]:n[t]-i[t]}}z._set("global",{elements:{},events:["mousemove","mouseout","= click","touchstart","touchmove"],hover:{onHover:null,mode:"nearest",interse= ct:!0,animationDuration:400},onClick:null,maintainAspectRatio:!0,responsive= :!0,responsiveAnimationDuration:0});var Qe=3Dfunction(t,e){return this.cons= truct(t,e),this};V.extend(Qe.prototype,{construct:function(t,e){var n=3Dthi= s;e=3Dfunction(t){var e=3D(t=3Dt||{}).data=3Dt.data||{};return e.datasets= =3De.datasets||[],e.labels=3De.labels||[],t.options=3DXe(z.global,z[t.type]= ,t.options||{}),t}(e);var i=3DFe.acquireContext(t,e),a=3Di&&i.canvas,r=3Da&= &a.height,o=3Da&&a.width;n.id=3DV.uid(),n.ctx=3Di,n.canvas=3Da,n.config=3De= ,n.width=3Do,n.height=3Dr,n.aspectRatio=3Dr?o/r:null,n.options=3De.options,= n._bufferedRender=3D!1,n._layers=3D[],n.chart=3Dn,n.controller=3Dn,Qe.insta= nces[n.id]=3Dn,Object.defineProperty(n,"data",{get:function(){return n.conf= ig.data},set:function(t){n.config.data=3Dt}}),i&&a?(n.initialize(),n.update= ()):console.error("Failed to create chart: can't acquire context from the g= iven item")},initialize:function(){var t=3Dthis;return Le.notify(t,"beforeI= nit"),V.retinaScale(t,t.options.devicePixelRatio),t.bindEvents(),t.options.= responsive&&t.resize(!0),t.initToolTip(),Le.notify(t,"afterInit"),t},clear:= function(){return V.canvas.clear(this),this},stop:function(){return $.cance= lAnimation(this),this},resize:function(t){var e=3Dthis,n=3De.options,i=3De.= canvas,a=3Dn.maintainAspectRatio&&e.aspectRatio||null,r=3DMath.max(0,Math.f= loor(V.getMaximumWidth(i))),o=3DMath.max(0,Math.floor(a?r/a:V.getMaximumHei= ght(i)));if((e.width!=3D=3Dr||e.height!=3D=3Do)&&(i.width=3De.width=3Dr,i.h= eight=3De.height=3Do,i.style.width=3Dr+"px",i.style.height=3Do+"px",V.retin= aScale(e,n.devicePixelRatio),!t)){var s=3D{width:r,height:o};Le.notify(e,"r= esize",[s]),n.onResize&&n.onResize(e,s),e.stop(),e.update({duration:n.respo= nsiveAnimationDuration})}},ensureScalesHaveIDs:function(){var t=3Dthis.opti= ons,e=3Dt.scales||{},n=3Dt.scale;V.each(e.xAxes,(function(t,n){t.id||(t.id= =3DZe(e.xAxes,"x-axis-",n))})),V.each(e.yAxes,(function(t,n){t.id||(t.id=3D= Ze(e.yAxes,"y-axis-",n))})),n&&(n.id=3Dn.id||"scale")},buildOrUpdateScales:= function(){var t=3Dthis,e=3Dt.options,n=3Dt.scales||{},i=3D[],a=3DObject.ke= ys(n).reduce((function(t,e){return t[e]=3D!1,t}),{});e.scales&&(i=3Di.conca= t((e.scales.xAxes||[]).map((function(t){return{options:t,dtype:"category",d= position:"bottom"}})),(e.scales.yAxes||[]).map((function(t){return{options:= t,dtype:"linear",dposition:"left"}})))),e.scale&&i.push({options:e.scale,dt= ype:"radialLinear",isDefault:!0,dposition:"chartArea"}),V.each(i,(function(= e){var i=3De.options,r=3Di.id,o=3DYe(i.type,e.dtype);$e(i.position)!=3D=3D$= e(e.dposition)&&(i.position=3De.dposition),a[r]=3D!0;var s=3Dnull;if(r in n= &&n[r].type=3D=3D=3Do)(s=3Dn[r]).options=3Di,s.ctx=3Dt.ctx,s.chart=3Dt;else= {var l=3DOe.getScaleConstructor(o);if(!l)return;s=3Dnew l({id:r,type:o,opti= ons:i,ctx:t.ctx,chart:t}),n[s.id]=3Ds}s.mergeTicksOptions(),e.isDefault&&(t= .scale=3Ds)})),V.each(a,(function(t,e){t||delete n[e]})),t.scales=3Dn,Oe.ad= dScalesToLayout(this)},buildOrUpdateControllers:function(){var t,e,n=3Dthis= ,i=3D[],a=3Dn.data.datasets;for(t=3D0,e=3Da.length;t=3D0;--n)this.drawDataset(e[n],t);Le.notify(this,"afterDatasetsDraw"= ,[t])}},drawDataset:function(t,e){var n=3D{meta:t,index:t.index,easingValue= :e};!1!=3D=3DLe.notify(this,"beforeDatasetDraw",[n])&&(t.controller.draw(e)= ,Le.notify(this,"afterDatasetDraw",[n]))},_drawTooltip:function(t){var e=3D= this.tooltip,n=3D{tooltip:e,easingValue:t};!1!=3D=3DLe.notify(this,"beforeT= ooltipDraw",[n])&&(e.draw(),Le.notify(this,"afterTooltipDraw",[n]))},getEle= mentAtEvent:function(t){return ae.modes.single(this,t)},getElementsAtEvent:= function(t){return ae.modes.label(this,t,{intersect:!0})},getElementsAtXAxi= s:function(t){return ae.modes["x-axis"](this,t,{intersect:!0})},getElements= AtEventForMode:function(t,e,n){var i=3Dae.modes[e];return"function"=3D=3Dty= peof i?i(this,t,n):[]},getDatasetAtEvent:function(t){return ae.modes.datase= t(this,t,{intersect:!0})},getDatasetMeta:function(t){var e=3Dthis.data.data= sets[t];e._meta||(e._meta=3D{});var n=3De._meta[this.id];return n||(n=3De._= meta[this.id]=3D{type:null,data:[],dataset:null,controller:null,hidden:null= ,xAxisID:null,yAxisID:null,order:e.order||0,index:t}),n},getVisibleDatasetC= ount:function(){for(var t=3D0,e=3D0,n=3Dthis.data.datasets.length;e3?n[2]-n[1= ]:n[1]-n[0];Math.abs(i)>1&&t!=3D=3DMath.floor(t)&&(i=3Dt-Math.floor(t));var= a=3DV.log10(Math.abs(i)),r=3D"";if(0!=3D=3Dt)if(Math.max(Math.abs(n[0]),Ma= th.abs(n[n.length-1]))<1e-4){var o=3DV.log10(Math.abs(t)),s=3DMath.floor(o)= -Math.floor(a);s=3DMath.max(Math.min(s,20),0),r=3Dt.toExponential(s)}else{v= ar l=3D-1*Math.floor(a);l=3DMath.max(Math.min(l,20),0),r=3Dt.toFixed(l)}els= e r=3D"0";return r},logarithmic:function(t,e,n){var i=3Dt/Math.pow(10,Math.= floor(V.log10(t)));return 0=3D=3D=3Dt?"0":1=3D=3D=3Di||2=3D=3D=3Di||5=3D=3D= =3Di||0=3D=3D=3De||e=3D=3D=3Dn.length-1?t.toExponential():""}}},on=3DV.isAr= ray,sn=3DV.isNullOrUndef,ln=3DV.valueOrDefault,un=3DV.valueAtIndexOrDefault= ;function dn(t,e,n){var i,a=3Dt.getTicks().length,r=3DMath.min(e,a-1),o=3Dt= .getPixelForTick(r),s=3Dt._startPixel,l=3Dt._endPixel;if(!(n&&(i=3D1=3D=3D= =3Da?Math.max(o-s,l-o):0=3D=3D=3De?(t.getPixelForTick(1)-o)/2:(o-t.getPixel= ForTick(r-1))/2,(o+=3Drl+1e-6)))return o}function hn(t,e= ,n,i){var a,r,o,s,l,u,d,h,c,f,g,p,m,v=3Dn.length,b=3D[],x=3D[],y=3D[];for(a= =3D0;ae){for(n=3D0;n=3Dc||d<=3D1||!s.isHo= rizontal()?s.labelRotation=3Dh:(e=3D(t=3Ds._getLabelSizes()).widest.width,n= =3Dt.highest.height-t.highest.offset,i=3DMath.min(s.maxWidth,s.chart.width-= e),e+6>(a=3Dl.offset?s.maxWidth/d:i/(d-1))&&(a=3Di/(d-(l.offset?.5:1)),r=3D= s.maxHeight-cn(l.gridLines)-u.padding-fn(l.scaleLabel),o=3DMath.sqrt(e*e+n*= n),f=3DV.toDegrees(Math.min(Math.asin(Math.min((t.highest.height+6)/a,1)),M= ath.asin(Math.min(r/o,1))-Math.asin(n/o))),f=3DMath.max(h,Math.min(c,f))),s= .labelRotation=3Df)},afterCalculateTickRotation:function(){V.callback(this.= options.afterCalculateTickRotation,[this])},beforeFit:function(){V.callback= (this.options.beforeFit,[this])},fit:function(){var t=3Dthis,e=3Dt.minSize= =3D{width:0,height:0},n=3Dt.chart,i=3Dt.options,a=3Di.ticks,r=3Di.scaleLabe= l,o=3Di.gridLines,s=3Dt._isVisible(),l=3D"bottom"=3D=3D=3Di.position,u=3Dt.= isHorizontal();if(u?e.width=3Dt.maxWidth:s&&(e.width=3Dcn(o)+fn(r)),u?s&&(e= .height=3Dcn(o)+fn(r)):e.height=3Dt.maxHeight,a.display&&s){var d=3Dpn(a),h= =3Dt._getLabelSizes(),c=3Dh.first,f=3Dh.last,g=3Dh.widest,p=3Dh.highest,m= =3D.4*d.minor.lineHeight,v=3Da.padding;if(u){var b=3D0!=3D=3Dt.labelRotatio= n,x=3DV.toRadians(t.labelRotation),y=3DMath.cos(x),_=3DMath.sin(x),k=3D_*g.= width+y*(p.height-(b?p.offset:0))+(b?0:m);e.height=3DMath.min(t.maxHeight,e= .height+k+v);var w,M,S=3Dt.getPixelForTick(0)-t.left,C=3Dt.right-t.getPixel= ForTick(t.getTicks().length-1);b?(w=3Dl?y*c.width+_*c.offset:_*(c.height-c.= offset),M=3Dl?_*(f.height-f.offset):y*f.width+_*f.offset):(w=3Dc.width/2,M= =3Df.width/2),t.paddingLeft=3DMath.max((w-S)*t.width/(t.width-S),0)+3,t.pad= dingRight=3DMath.max((M-C)*t.width/(t.width-C),0)+3}else{var P=3Da.mirror?0= :g.width+v+m;e.width=3DMath.min(t.maxWidth,e.width+P),t.paddingTop=3Dc.heig= ht/2,t.paddingBottom=3Df.height/2}}t.handleMargins(),u?(t.width=3Dt._length= =3Dn.width-t.margins.left-t.margins.right,t.height=3De.height):(t.width=3De= .width,t.height=3Dt._length=3Dn.height-t.margins.top-t.margins.bottom)},han= dleMargins:function(){var t=3Dthis;t.margins&&(t.margins.left=3DMath.max(t.= paddingLeft,t.margins.left),t.margins.top=3DMath.max(t.paddingTop,t.margins= .top),t.margins.right=3DMath.max(t.paddingRight,t.margins.right),t.margins.= bottom=3DMath.max(t.paddingBottom,t.margins.bottom))},afterFit:function(){V= .callback(this.options.afterFit,[this])},isHorizontal:function(){var t=3Dth= is.options.position;return"top"=3D=3D=3Dt||"bottom"=3D=3D=3Dt},isFullWidth:= function(){return this.options.fullWidth},getRightValue:function(t){if(sn(t= ))return NaN;if(("number"=3D=3Dtypeof t||t instanceof Number)&&!isFinite(t)= )return NaN;if(t)if(this.isHorizontal()){if(void 0!=3D=3Dt.x)return this.ge= tRightValue(t.x)}else if(void 0!=3D=3Dt.y)return this.getRightValue(t.y);re= turn t},_convertTicksToLabels:function(t){var e,n,i,a=3Dthis;for(a.ticks=3D= t.map((function(t){return t.value})),a.beforeTickToLabelConversion(),e=3Da.= convertTicksToLabels(t)||a.ticks,a.afterTickToLabelConversion(),n=3D0,i=3Dt= .length;nn-1?null:this.getPixelForDecima= l(t*i+(e?i/2:0))},getPixelForDecimal:function(t){return this._reversePixels= &&(t=3D1-t),this._startPixel+t*this._length},getDecimalForPixel:function(t)= {var e=3D(t-this._startPixel)/this._length;return this._reversePixels?1-e:e= },getBasePixel:function(){return this.getPixelForValue(this.getBaseValue())= },getBaseValue:function(){var t=3Dthis.min,e=3Dthis.max;return this.beginAt= Zero?0:t<0&&e<0?e:t>0&&e>0?t:0},_autoSkip:function(t){var e,n,i,a,r=3Dthis.= options.ticks,o=3Dthis._length,s=3Dr.maxTicksLimit||o/this._tickSize()+1,l= =3Dr.major.enabled?function(t){var e,n,i=3D[];for(e=3D0,n=3Dt.length;es)return function(t,e,n){var i,a,r=3D0,o=3De[0];for(n=3DMath.ceil(n),i= =3D0;iu)return r;return Math.max(u,1)}(l,t,0,s),u>0){for(e=3D0,n=3Du-1;e1?(h-d)/(u-1):null,vn(t,i,V.isNullOrUnd= ef(a)?0:d-a,d),vn(t,i,h,V.isNullOrUndef(a)?t.length:h+a),mn(t)}return vn(t,= i),mn(t)},_tickSize:function(){var t=3Dthis.options.ticks,e=3DV.toRadians(t= his.labelRotation),n=3DMath.abs(Math.cos(e)),i=3DMath.abs(Math.sin(e)),a=3D= this._getLabelSizes(),r=3Dt.autoSkipPadding||0,o=3Da?a.widest.width+r:0,s= =3Da?a.highest.height+r:0;return this.isHorizontal()?s*n>o*i?o/n:s/i:s*i= =3D0&&(o=3Dt),void 0!=3D=3Dr&&(t=3Dn.indexOf(r))>=3D0&&(s=3Dt),e.minIndex= =3Do,e.maxIndex=3Ds,e.min=3Dn[o],e.max=3Dn[s]},buildTicks:function(){var t= =3Dthis._getLabels(),e=3Dthis.minIndex,n=3Dthis.maxIndex;this.ticks=3D0=3D= =3D=3De&&n=3D=3D=3Dt.length-1?t:t.slice(e,n+1)},getLabelForIndex:function(t= ,e){var n=3Dthis.chart;return n.getDatasetMeta(e).controller._getValueScale= Id()=3D=3D=3Dthis.id?this.getRightValue(n.data.datasets[e].data[t]):this._g= etLabels()[t]},_configure:function(){var t=3Dthis,e=3Dt.options.offset,n=3D= t.ticks;xn.prototype._configure.call(t),t.isHorizontal()||(t._reversePixels= =3D!t._reversePixels),n&&(t._startValue=3Dt.minIndex-(e?.5:0),t._valueRange= =3DMath.max(n.length-(e?0:1),1))},getPixelForValue:function(t,e,n){var i,a,= r,o=3Dthis;return yn(e)||yn(n)||(t=3Do.chart.data.datasets[n].data[e]),yn(t= )||(i=3Do.isHorizontal()?t.x:t.y),(void 0!=3D=3Di||void 0!=3D=3Dt&&isNaN(e)= )&&(a=3Do._getLabels(),t=3DV.valueOrDefault(i,t),e=3D-1!=3D=3D(r=3Da.indexO= f(t))?r:e,isNaN(e)&&(e=3Dt)),o.getPixelForDecimal((e-o._startValue)/o._valu= eRange)},getPixelForTick:function(t){var e=3Dthis.ticks;return t<0||t>e.len= gth-1?null:this.getPixelForValue(e[t],t+this.minIndex)},getValueForPixel:fu= nction(t){var e=3DMath.round(this._startValue+this.getDecimalForPixel(t)*th= is._valueRange);return Math.min(Math.max(e,0),this.ticks.length-1)},getBase= Pixel:function(){return this.bottom}}),kn=3D{position:"bottom"};_n._default= s=3Dkn;var wn=3DV.noop,Mn=3DV.isNullOrUndef;var Sn=3Dxn.extend({getRightVal= ue:function(t){return"string"=3D=3Dtypeof t?+t:xn.prototype.getRightValue.c= all(this,t)},handleTickRangeOptions:function(){var t=3Dthis,e=3Dt.options.t= icks;if(e.beginAtZero){var n=3DV.sign(t.min),i=3DV.sign(t.max);n<0&&i<0?t.m= ax=3D0:n>0&&i>0&&(t.min=3D0)}var a=3Dvoid 0!=3D=3De.min||void 0!=3D=3De.sug= gestedMin,r=3Dvoid 0!=3D=3De.max||void 0!=3D=3De.suggestedMax;void 0!=3D=3D= e.min?t.min=3De.min:void 0!=3D=3De.suggestedMin&&(null=3D=3D=3Dt.min?t.min= =3De.suggestedMin:t.min=3DMath.min(t.min,e.suggestedMin)),void 0!=3D=3De.ma= x?t.max=3De.max:void 0!=3D=3De.suggestedMax&&(null=3D=3D=3Dt.max?t.max=3De.= suggestedMax:t.max=3DMath.max(t.max,e.suggestedMax)),a!=3D=3Dr&&t.min>=3Dt.= max&&(a?t.max=3Dt.min+1:t.min=3Dt.max-1),t.min=3D=3D=3Dt.max&&(t.max++,e.be= ginAtZero||t.min--)},getTickLimit:function(){var t,e=3Dthis.options.ticks,n= =3De.stepSize,i=3De.maxTicksLimit;return n?t=3DMath.ceil(this.max/n)-Math.f= loor(this.min/n)+1:(t=3Dthis._computeTickLimit(),i=3Di||11),i&&(t=3DMath.mi= n(i,t)),t},_computeTickLimit:function(){return Number.POSITIVE_INFINITY},ha= ndleDirectionalChanges:wn,buildTicks:function(){var t=3Dthis,e=3Dt.options.= ticks,n=3Dt.getTickLimit(),i=3D{maxTicks:n=3DMath.max(2,n),min:e.min,max:e.= max,precision:e.precision,stepSize:V.valueOrDefault(e.fixedStepSize,e.stepS= ize)},a=3Dt.ticks=3Dfunction(t,e){var n,i,a,r,o=3D[],s=3Dt.stepSize,l=3Ds||= 1,u=3Dt.maxTicks-1,d=3Dt.min,h=3Dt.max,c=3Dt.precision,f=3De.min,g=3De.max,= p=3DV.niceNum((g-f)/u/l)*l;if(p<1e-14&&Mn(d)&&Mn(h))return[f,g];(r=3DMath.c= eil(g/p)-Math.floor(f/p))>u&&(p=3DV.niceNum(r*p/u/l)*l),s||Mn(c)?n=3DMath.p= ow(10,V._decimalPlaces(p)):(n=3DMath.pow(10,c),p=3DMath.ceil(p*n)/n),i=3DMa= th.floor(f/p)*p,a=3DMath.ceil(g/p)*p,s&&(!Mn(d)&&V.almostWhole(d/p,p/1e3)&&= (i=3Dd),!Mn(h)&&V.almostWhole(h/p,p/1e3)&&(a=3Dh)),r=3D(a-i)/p,r=3DV.almost= Equals(r,Math.round(r),p/1e3)?Math.round(r):Math.ceil(r),i=3DMath.round(i*n= )/n,a=3DMath.round(a*n)/n,o.push(Mn(d)?i:d);for(var m=3D1;me.length-1?null:this.getPixelForValue(e[t])}}),= Tn=3DCn;Dn._defaults=3DTn;var In=3DV.valueOrDefault,Fn=3DV.math.log10;var L= n=3D{position:"left",ticks:{callback:rn.formatters.logarithmic}};function O= n(t,e){return V.isFinite(t)&&t>=3D0?t:e}var Rn=3Dxn.extend({determineDataLi= mits:function(){var t,e,n,i,a,r,o=3Dthis,s=3Do.options,l=3Do.chart,u=3Dl.da= ta.datasets,d=3Do.isHorizontal();function h(t){return d?t.xAxisID=3D=3D=3Do= .id:t.yAxisID=3D=3D=3Do.id}o.min=3DNumber.POSITIVE_INFINITY,o.max=3DNumber.= NEGATIVE_INFINITY,o.minNotZero=3DNumber.POSITIVE_INFINITY;var c=3Ds.stacked= ;if(void 0=3D=3D=3Dc)for(t=3D0;t0){var e=3DV.min(= t),n=3DV.max(t);o.min=3DMath.min(o.min,e),o.max=3DMath.max(o.max,n)}}))}els= e for(t=3D0;t0?t.= minNotZero=3Dt.min:t.max<1?t.minNotZero=3DMath.pow(10,Math.floor(Fn(t.max))= ):t.minNotZero=3D1)},buildTicks:function(){var t=3Dthis,e=3Dt.options.ticks= ,n=3D!t.isHorizontal(),i=3D{min:On(e.min),max:On(e.max)},a=3Dt.ticks=3Dfunc= tion(t,e){var n,i,a=3D[],r=3DIn(t.min,Math.pow(10,Math.floor(Fn(e.min)))),o= =3DMath.floor(Fn(e.max)),s=3DMath.ceil(e.max/Math.pow(10,o));0=3D=3D=3Dr?(n= =3DMath.floor(Fn(e.minNotZero)),i=3DMath.floor(e.minNotZero/Math.pow(10,n))= ,a.push(r),r=3Di*Math.pow(10,n)):(n=3DMath.floor(Fn(r)),i=3DMath.floor(r/Ma= th.pow(10,n)));var l=3Dn<0?Math.pow(10,Math.abs(n)):1;do{a.push(r),10=3D=3D= =3D++i&&(i=3D1,l=3D++n>=3D0?1:l),r=3DMath.round(i*Math.pow(10,n)*l)/l}while= (ne.length-1?null:this.getPixelForValue(e[t])},_g= etFirstTickValue:function(t){var e=3DMath.floor(Fn(t));return Math.floor(t/= Math.pow(10,e))*Math.pow(10,e)},_configure:function(){var t=3Dthis,e=3Dt.mi= n,n=3D0;xn.prototype._configure.call(t),0=3D=3D=3De&&(e=3Dt._getFirstTickVa= lue(t.minNotZero),n=3DIn(t.options.ticks.fontSize,z.global.defaultFontSize)= /t._length),t._startValue=3DFn(e),t._valueOffset=3Dn,t._valueRange=3D(Fn(t.= max)-Fn(e))/(1-n)},getPixelForValue:function(t){var e=3Dthis,n=3D0;return(t= =3D+e.getRightValue(t))>e.min&&t>0&&(n=3D(Fn(t)-e._startValue)/e._valueRang= e+e._valueOffset),e.getPixelForDecimal(n)},getValueForPixel:function(t){var= e=3Dthis,n=3De.getDecimalForPixel(t);return 0=3D=3D=3Dn&&0=3D=3D=3De.min?0= :Math.pow(10,e._startValue+(n-e._valueOffset)*e._valueRange)}}),zn=3DLn;Rn.= _defaults=3Dzn;var Nn=3DV.valueOrDefault,Bn=3DV.valueAtIndexOrDefault,En=3D= V.options.resolve,Wn=3D{display:!0,animate:!0,position:"chartArea",angleLin= es:{display:!0,color:"rgba(0,0,0,0.1)",lineWidth:1,borderDash:[],borderDash= Offset:0},gridLines:{circular:!1},ticks:{showLabelBackdrop:!0,backdropColor= :"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:rn= .formatters.linear},pointLabels:{display:!0,fontSize:10,callback:function(t= ){return t}}};function Vn(t){var e=3Dt.ticks;return e.display&&t.display?Nn= (e.fontSize,z.global.defaultFontSize)+2*e.backdropPaddingY:0}function Hn(t,= e,n,i,a){return t=3D=3D=3Di||t=3D=3D=3Da?{start:e-n/2,end:e+n/2}:ta?{= start:e-n,end:e}:{start:e,end:e+n}}function jn(t){return 0=3D=3D=3Dt||180= =3D=3D=3Dt?"center":t<180?"left":"right"}function qn(t,e,n,i){var a,r,o=3Dn= .y+i/2;if(V.isArray(e))for(a=3D0,r=3De.length;a270||t<90)&&(n.y-=3De.h)}function Yn(t){return V.is= Number(t)?t:0}var Gn=3DSn.extend({setDimensions:function(){var t=3Dthis;t.w= idth=3Dt.maxWidth,t.height=3Dt.maxHeight,t.paddingTop=3DVn(t.options)/2,t.x= Center=3DMath.floor(t.width/2),t.yCenter=3DMath.floor((t.height-t.paddingTo= p)/2),t.drawingArea=3DMath.min(t.height-t.paddingTop,t.width)/2},determineD= ataLimits:function(){var t=3Dthis,e=3Dt.chart,n=3DNumber.POSITIVE_INFINITY,= i=3DNumber.NEGATIVE_INFINITY;V.each(e.data.datasets,(function(a,r){if(e.isD= atasetVisible(r)){var o=3De.getDatasetMeta(r);V.each(a.data,(function(e,a){= var r=3D+t.getRightValue(e);isNaN(r)||o.data[a].hidden||(n=3DMath.min(r,n),= i=3DMath.max(r,i))}))}})),t.min=3Dn=3D=3D=3DNumber.POSITIVE_INFINITY?0:n,t.= max=3Di=3D=3D=3DNumber.NEGATIVE_INFINITY?0:i,t.handleTickRangeOptions()},_c= omputeTickLimit:function(){return Math.ceil(this.drawingArea/Vn(this.option= s))},convertTicksToLabels:function(){var t=3Dthis;Sn.prototype.convertTicks= ToLabels.call(t),t.pointLabels=3Dt.chart.data.labels.map((function(){var e= =3DV.callback(t.options.pointLabels.callback,arguments,t);return e||0=3D=3D= =3De?e:""}))},getLabelForIndex:function(t,e){return+this.getRightValue(this= .chart.data.datasets[e].data[t])},fit:function(){var t=3Dthis.options;t.dis= play&&t.pointLabels.display?function(t){var e,n,i,a=3DV.options._parseFont(= t.options.pointLabels),r=3D{l:0,r:t.width,t:0,b:t.height-t.paddingTop},o=3D= {};t.ctx.font=3Da.string,t._pointLabelSizes=3D[];var s,l,u,d=3Dt.chart.data= .labels.length;for(e=3D0;er.r&&(r.r=3Df.end,o.r=3Dh),g.startr.b&&(r.b=3Dg.end,o.b=3Dh)}t.setReductions(t.drawingArea,r,o)}(this):thi= s.setCenterPoint(0,0,0,0)},setReductions:function(t,e,n){var i=3Dthis,a=3De= .l/Math.sin(n.l),r=3DMath.max(e.r-i.width,0)/Math.sin(n.r),o=3D-e.t/Math.co= s(n.t),s=3D-Math.max(e.b-(i.height-i.paddingTop),0)/Math.cos(n.b);a=3DYn(a)= ,r=3DYn(r),o=3DYn(o),s=3DYn(s),i.drawingArea=3DMath.min(Math.floor(t-(a+r)/= 2),Math.floor(t-(o+s)/2)),i.setCenterPoint(a,r,o,s)},setCenterPoint:functio= n(t,e,n,i){var a=3Dthis,r=3Da.width-e-a.drawingArea,o=3Dt+a.drawingArea,s= =3Dn+a.drawingArea,l=3Da.height-a.paddingTop-i-a.drawingArea;a.xCenter=3DMa= th.floor((o+r)/2+a.left),a.yCenter=3DMath.floor((s+l)/2+a.top+a.paddingTop)= },getIndexAngle:function(t){var e=3Dthis.chart,n=3D(t*(360/e.data.labels.le= ngth)+((e.options||{}).startAngle||0))%360;return(n<0?n+360:n)*Math.PI*2/36= 0},getDistanceFromCenterForValue:function(t){var e=3Dthis;if(V.isNullOrUnde= f(t))return NaN;var n=3De.drawingArea/(e.max-e.min);return e.options.ticks.= reverse?(e.max-t)*n:(t-e.min)*n},getPointPosition:function(t,e){var n=3Dthi= s.getIndexAngle(t)-Math.PI/2;return{x:Math.cos(n)*e+this.xCenter,y:Math.sin= (n)*e+this.yCenter}},getPointPositionForValue:function(t,e){return this.get= PointPosition(t,this.getDistanceFromCenterForValue(e))},getBasePosition:fun= ction(t){var e=3Dthis.min,n=3Dthis.max;return this.getPointPositionForValue= (t||0,this.beginAtZero?0:e<0&&n<0?n:e>0&&n>0?e:0)},_drawGrid:function(){var= t,e,n,i=3Dthis,a=3Di.ctx,r=3Di.options,o=3Dr.gridLines,s=3Dr.angleLines,l= =3DNn(s.lineWidth,o.lineWidth),u=3DNn(s.color,o.color);if(r.pointLabels.dis= play&&function(t){var e=3Dt.ctx,n=3Dt.options,i=3Dn.pointLabels,a=3DVn(n),r= =3Dt.getDistanceFromCenterForValue(n.ticks.reverse?t.min:t.max),o=3DV.optio= ns._parseFont(i);e.save(),e.font=3Do.string,e.textBaseline=3D"middle";for(v= ar s=3Dt.chart.data.labels.length-1;s>=3D0;s--){var l=3D0=3D=3D=3Ds?a/2:0,u= =3Dt.getPointPosition(s,r+l+5),d=3DBn(i.fontColor,s,z.global.defaultFontCol= or);e.fillStyle=3Dd;var h=3Dt.getIndexAngle(s),c=3DV.toDegrees(h);e.textAli= gn=3Djn(c),Un(c,t._pointLabelSizes[s],u),qn(e,t.pointLabels[s],u,o.lineHeig= ht)}e.restore()}(i),o.display&&V.each(i.ticks,(function(t,n){0!=3D=3Dn&&(e= =3Di.getDistanceFromCenterForValue(i.ticksAsNumbers[n]),function(t,e,n,i){v= ar a,r=3Dt.ctx,o=3De.circular,s=3Dt.chart.data.labels.length,l=3DBn(e.color= ,i-1),u=3DBn(e.lineWidth,i-1);if((o||s)&&l&&u){if(r.save(),r.strokeStyle=3D= l,r.lineWidth=3Du,r.setLineDash&&(r.setLineDash(e.borderDash||[]),r.lineDas= hOffset=3De.borderDashOffset||0),r.beginPath(),o)r.arc(t.xCenter,t.yCenter,= n,0,2*Math.PI);else{a=3Dt.getPointPosition(0,n),r.moveTo(a.x,a.y);for(var d= =3D1;d=3D0;t--)e=3Di.getDistanceFromCen= terForValue(r.ticks.reverse?i.min:i.max),n=3Di.getPointPosition(t,e),a.begi= nPath(),a.moveTo(i.xCenter,i.yCenter),a.lineTo(n.x,n.y),a.stroke();a.restor= e()}},_drawLabels:function(){var t=3Dthis,e=3Dt.ctx,n=3Dt.options.ticks;if(= n.display){var i,a,r=3Dt.getIndexAngle(0),o=3DV.options._parseFont(n),s=3DN= n(n.fontColor,z.global.defaultFontColor);e.save(),e.font=3Do.string,e.trans= late(t.xCenter,t.yCenter),e.rotate(r),e.textAlign=3D"center",e.textBaseline= =3D"middle",V.each(t.ticks,(function(r,l){(0!=3D=3Dl||n.reverse)&&(i=3Dt.ge= tDistanceFromCenterForValue(t.ticksAsNumbers[l]),n.showLabelBackdrop&&(a=3D= e.measureText(r).width,e.fillStyle=3Dn.backdropColor,e.fillRect(-a/2-n.back= dropPaddingX,-i-o.size/2-n.backdropPaddingY,a+2*n.backdropPaddingX,o.size+2= *n.backdropPaddingY)),e.fillStyle=3Ds,e.fillText(r,0,-i))})),e.restore()}},= _drawTitle:V.noop}),Xn=3DWn;Gn._defaults=3DXn;var Kn=3DV._deprecated,Zn=3DV= .options.resolve,$n=3DV.valueOrDefault,Jn=3DNumber.MIN_SAFE_INTEGER||-90071= 99254740991,Qn=3DNumber.MAX_SAFE_INTEGER||9007199254740991,ti=3D{millisecon= d:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:= {common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{comm= on:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{comm= on:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{c= ommon:!0,size:3154e7}},ei=3DObject.keys(ti);function ni(t,e){return t-e}fun= ction ii(t){return V.valueOrDefault(t.time.min,t.ticks.min)}function ai(t){= return V.valueOrDefault(t.time.max,t.ticks.max)}function ri(t,e,n,i){var a= =3Dfunction(t,e,n){for(var i,a,r,o=3D0,s=3Dt.length-1;o>=3D0&&o<=3Ds;){if(a= =3Dt[(i=3Do+s>>1)-1]||null,r=3Dt[i],!a)return{lo:null,hi:r};if(r[e]n))return{lo:a,hi:r};s=3Di-1}}return{lo:r,hi:null}}(t,e,n= ),r=3Da.lo?a.hi?a.lo:t[t.length-2]:t[0],o=3Da.lo?a.hi?a.hi:t[t.length-1]:t[= 1],s=3Do[e]-r[e],l=3Ds?(n-r[e])/s:0,u=3D(o[i]-r[i])*l;return r[i]+u}functio= n oi(t,e){var n=3Dt._adapter,i=3Dt.options.time,a=3Di.parser,r=3Da||i.forma= t,o=3De;return"function"=3D=3Dtypeof a&&(o=3Da(o)),V.isFinite(o)||(o=3D"str= ing"=3D=3Dtypeof r?n.parse(o,r):n.parse(o)),null!=3D=3Do?+o:(a||"function"!= =3Dtypeof r||(o=3Dr(e),V.isFinite(o)||(o=3Dn.parse(o))),o)}function si(t,e)= {if(V.isNullOrUndef(e))return null;var n=3Dt.options.time,i=3Doi(t,t.getRig= htValue(e));return null=3D=3D=3Di?i:(n.round&&(i=3D+t._adapter.startOf(i,n.= round)),i)}function li(t,e,n,i){var a,r,o,s=3Dei.length;for(a=3Dei.indexOf(= t);a=3D0&&(e[r].major=3D!0);return e}(t,r,o,n):r}var di= =3Dxn.extend({initialize:function(){this.mergeTicksOptions(),xn.prototype.i= nitialize.call(this)},update:function(){var t=3Dthis,e=3Dt.options,n=3De.ti= me||(e.time=3D{}),i=3Dt._adapter=3Dnew an._date(e.adapters.date);return Kn(= "time scale",n.format,"time.format","time.parser"),Kn("time scale",n.min,"t= ime.min","ticks.min"),Kn("time scale",n.max,"time.max","ticks.max"),V.merge= If(n.displayFormats,i.formats()),xn.prototype.update.apply(t,arguments)},ge= tRightValue:function(t){return t&&void 0!=3D=3Dt.t&&(t=3Dt.t),xn.prototype.= getRightValue.call(this,t)},determineDataLimits:function(){var t,e,n,i,a,r,= o,s=3Dthis,l=3Ds.chart,u=3Ds._adapter,d=3Ds.options,h=3Dd.time.unit||"day",= c=3DQn,f=3DJn,g=3D[],p=3D[],m=3D[],v=3Ds._getLabels();for(t=3D0,n=3Dv.lengt= h;t1?function(t){var e,n,i,a=3D{},r=3D[];for(e=3D0,n=3Dt.length;e1e5*u)th= row e+" and "+n+" are too far apart with stepSize of "+u+" "+l;for(a=3Dh;a<= n;a=3D+r.add(a,u,l))c.push(a);return a!=3D=3Dn&&"ticks"!=3D=3Do.bounds||c.p= ush(a),c}(i,a,r,h),"ticks"=3D=3D=3Do.bounds&&u.length&&(a=3Du[0],r=3Du[u.le= ngth-1]),a=3Dsi(i,ii(o))||a,r=3Dsi(i,ai(o))||r,t=3D0,e=3Du.length;t=3Da&&n<=3Dr&&d.push(n);return i.min=3Da,i.max=3Dr,i._unit=3Dl.un= it||(s.autoSkip?li(l.minUnit,i.min,i.max,h):function(t,e,n,i,a){var r,o;for= (r=3Dei.length-1;r>=3Dei.indexOf(n);r--)if(o=3Dei[r],ti[o].common&&t._adapt= er.diff(a,i,o)>=3De-1)return o;return ei[n?ei.indexOf(n):0]}(i,d.length,l.m= inUnit,i.min,i.max)),i._majorUnit=3Ds.major.enabled&&"year"!=3D=3Di._unit?f= unction(t){for(var e=3Dei.indexOf(t)+1,n=3Dei.length;ee&&s=3D0&&t0?s:1}}),hi=3D{position:"bottom",distribut= ion:"linear",bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,dis= playFormat:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:= {autoSkip:!1,source:"auto",major:{enabled:!1}}};di._defaults=3Dhi;var ci=3D= {category:_n,linear:Dn,logarithmic:Rn,radialLinear:Gn,time:di},fi=3D{dateti= me:"MMM D, YYYY, h:mm:ss a",millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",= minute:"h:mm a",hour:"hA",day:"MMM D",week:"ll",month:"MMM YYYY",quarter:"[= Q]Q - YYYY",year:"YYYY"};an._date.override("function"=3D=3Dtypeof t?{_id:"m= oment",formats:function(){return fi},parse:function(e,n){return"string"=3D= =3Dtypeof e&&"string"=3D=3Dtypeof n?e=3Dt(e,n):e instanceof t||(e=3Dt(e)),e= .isValid()?e.valueOf():null},format:function(e,n){return t(e).format(n)},ad= d:function(e,n,i){return t(e).add(n,i).valueOf()},diff:function(e,n,i){retu= rn t(e).diff(t(n),i)},startOf:function(e,n,i){return e=3Dt(e),"isoWeek"=3D= =3D=3Dn?e.isoWeekday(i).valueOf():e.startOf(n).valueOf()},endOf:function(e,= n){return t(e).endOf(n).valueOf()},_create:function(e){return t(e)}}:{}),z.= _set("global",{plugins:{filler:{propagate:!0}}});var gi=3D{dataset:function= (t){var e=3Dt.fill,n=3Dt.chart,i=3Dn.getDatasetMeta(e),a=3Di&&n.isDatasetVi= sible(e)&&i.dataset._children||[],r=3Da.length||0;return r?function(t,e){re= turn e=3Dn)= &&i;switch(r){case"bottom":return"start";case"top":return"end";case"zero":r= eturn"origin";case"origin":case"start":case"end":return r;default:return!1}= }function mi(t){return(t.el._scale||{}).getPointPositionForValue?function(t= ){var e,n,i,a,r,o=3Dt.el._scale,s=3Do.options,l=3Do.chart.data.labels.lengt= h,u=3Dt.fill,d=3D[];if(!l)return null;for(e=3Ds.ticks.reverse?o.max:o.min,n= =3Ds.ticks.reverse?o.min:o.max,i=3Do.getPointPositionForValue(0,e),a=3D0;a<= l;++a)r=3D"start"=3D=3D=3Du||"end"=3D=3D=3Du?o.getPointPositionForValue(a,"= start"=3D=3D=3Du?e:n):o.getBasePosition(a),s.gridLines.circular&&(r.cx=3Di.= x,r.cy=3Di.y,r.angle=3Do.getIndexAngle(a)-Math.PI/2),d.push(r);return d}(t)= :function(t){var e,n=3Dt.el._model||{},i=3Dt.el._scale||{},a=3Dt.fill,r=3Dn= ull;if(isFinite(a))return null;if("start"=3D=3D=3Da?r=3Dvoid 0=3D=3D=3Dn.sc= aleBottom?i.bottom:n.scaleBottom:"end"=3D=3D=3Da?r=3Dvoid 0=3D=3D=3Dn.scale= Top?i.top:n.scaleTop:void 0!=3D=3Dn.scaleZero?r=3Dn.scaleZero:i.getBasePixe= l&&(r=3Di.getBasePixel()),null!=3Dr){if(void 0!=3D=3Dr.x&&void 0!=3D=3Dr.y)= return r;if(V.isFinite(r))return{x:(e=3Di.isHorizontal())?r:null,y:e?null:r= }}return null}(t)}function vi(t,e,n){var i,a=3Dt[e].fill,r=3D[e];if(!n)retu= rn a;for(;!1!=3D=3Da&&-1=3D=3D=3Dr.indexOf(a);){if(!isFinite(a))return a;if= (!(i=3Dt[a]))return!1;if(i.visible)return a;r.push(a),a=3Di.fill}return!1}f= unction bi(t){var e=3Dt.fill,n=3D"dataset";return!1=3D=3D=3De?null:(isFinit= e(e)||(n=3D"boundary"),gi[n](t))}function xi(t){return t&&!t.skip}function = yi(t,e,n,i,a){var r,o,s,l;if(i&&a){for(t.moveTo(e[0].x,e[0].y),r=3D1;r0;--r)V.canvas.lineTo(t,n[r],n[r-1],!0);else f= or(o=3Dn[0].cx,s=3Dn[0].cy,l=3DMath.sqrt(Math.pow(n[0].x-o,2)+Math.pow(n[0]= .y-s,2)),r=3Da-1;r>0;--r)t.arc(o,s,l,n[r].angle,n[r-1].angle,!0)}}function = _i(t,e,n,i,a,r){var o,s,l,u,d,h,c,f,g=3De.length,p=3Di.spanGaps,m=3D[],v=3D= [],b=3D0,x=3D0;for(t.beginPath(),o=3D0,s=3Dg;o=3D0;--n)(e=3Dl[n].$filler)&&e.visible&&(a=3D(i=3De.el)._view,r=3D= i._children||[],o=3De.mapper,s=3Da.backgroundColor||z.global.defaultColor,o= &&s&&r.length&&(V.canvas.clipArea(u,t.chartArea),_i(u,r,o,a,s,i._loop),V.ca= nvas.unclipArea(u)))}},wi=3DV.rtl.getRtlAdapter,Mi=3DV.noop,Si=3DV.valueOrD= efault;function Ci(t,e){return t.usePointStyle&&t.boxWidth>e?e:t.boxWidth}z= ._set("global",{legend:{display:!0,position:"top",align:"center",fullWidth:= !0,reverse:!1,weight:1e3,onClick:function(t,e){var n=3De.datasetIndex,i=3Dt= his.chart,a=3Di.getDatasetMeta(n);a.hidden=3Dnull=3D=3D=3Da.hidden?!i.data.= datasets[n].hidden:null,i.update()},onHover:null,onLeave:null,labels:{boxWi= dth:40,padding:10,generateLabels:function(t){var e=3Dt.data.datasets,n=3Dt.= options.legend||{},i=3Dn.labels&&n.labels.usePointStyle;return t._getSorted= DatasetMetas().map((function(n){var a=3Dn.controller.getStyle(i?0:void 0);r= eturn{text:e[n.index].label,fillStyle:a.backgroundColor,hidden:!t.isDataset= Visible(n.index),lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOff= set:a.borderDashOffset,lineJoin:a.borderJoinStyle,lineWidth:a.borderWidth,s= trokeStyle:a.borderColor,pointStyle:a.pointStyle,rotation:a.rotation,datase= tIndex:n.index}}),this)}}},legendCallback:function(t){var e,n,i,a=3Ddocumen= t.createElement("ul"),r=3Dt.data.datasets;for(a.setAttribute("class",t.id+"= -legend"),e=3D0,n=3Dr.length;el.width)&&(h+=3Do+n.padding,d[d.length-(e>0?0:1)]=3D0),s[e= ]=3D{left:0,top:0,width:i,height:o},d[d.length-1]+=3Di+n.padding})),l.heigh= t+=3Dh}else{var c=3Dn.padding,f=3Dt.columnWidths=3D[],g=3Dt.columnHeights= =3D[],p=3Dn.padding,m=3D0,v=3D0;V.each(t.legendItems,(function(t,e){var i= =3DCi(n,o)+o/2+a.measureText(t.text).width;e>0&&v+o+2*c>l.height&&(p+=3Dm+n= .padding,f.push(m),g.push(v),m=3D0,v=3D0),m=3DMath.max(m,i),v+=3Do+c,s[e]= =3D{left:0,top:0,width:i,height:o}})),p+=3Dm,f.push(m),g.push(v),l.width+= =3Dp}t.width=3Dl.width,t.height=3Dl.height}else t.width=3Dl.width=3Dt.heigh= t=3Dl.height=3D0},afterFit:Mi,isHorizontal:function(){return"top"=3D=3D=3Dt= his.options.position||"bottom"=3D=3D=3Dthis.options.position},draw:function= (){var t=3Dthis,e=3Dt.options,n=3De.labels,i=3Dz.global,a=3Di.defaultColor,= r=3Di.elements.line,o=3Dt.height,s=3Dt.columnHeights,l=3Dt.width,u=3Dt.line= Widths;if(e.display){var d,h=3Dwi(e.rtl,t.left,t.minSize.width),c=3Dt.ctx,f= =3DSi(n.fontColor,i.defaultFontColor),g=3DV.options._parseFont(n),p=3Dg.siz= e;c.textAlign=3Dh.textAlign("left"),c.textBaseline=3D"middle",c.lineWidth= =3D.5,c.strokeStyle=3Df,c.fillStyle=3Df,c.font=3Dg.string;var m=3DCi(n,p),v= =3Dt.legendHitBoxes,b=3Dfunction(t,i){switch(e.align){case"start":return n.= padding;case"end":return t-i;default:return(t-i+n.padding)/2}},x=3Dt.isHori= zontal();d=3Dx?{x:t.left+b(l,u[0]),y:t.top+n.padding,line:0}:{x:t.left+n.pa= dding,y:t.top+b(o,s[0]),line:0},V.rtl.overrideTextDirection(t.ctx,e.textDir= ection);var y=3Dp+n.padding;V.each(t.legendItems,(function(e,i){var f=3Dc.m= easureText(e.text).width,g=3Dm+p/2+f,_=3Dd.x,k=3Dd.y;h.setWidth(t.minSize.w= idth),x?i>0&&_+g+n.padding>t.left+t.minSize.width&&(k=3Dd.y+=3Dy,d.line++,_= =3Dd.x=3Dt.left+b(l,u[d.line])):i>0&&k+y>t.top+t.minSize.height&&(_=3Dd.x= =3D_+t.columnWidths[d.line]+n.padding,d.line++,k=3Dd.y=3Dt.top+b(o,s[d.line= ]));var w=3Dh.x(_);!function(t,e,i){if(!(isNaN(m)||m<=3D0)){c.save();var o= =3DSi(i.lineWidth,r.borderWidth);if(c.fillStyle=3DSi(i.fillStyle,a),c.lineC= ap=3DSi(i.lineCap,r.borderCapStyle),c.lineDashOffset=3DSi(i.lineDashOffset,= r.borderDashOffset),c.lineJoin=3DSi(i.lineJoin,r.borderJoinStyle),c.lineWid= th=3Do,c.strokeStyle=3DSi(i.strokeStyle,a),c.setLineDash&&c.setLineDash(Si(= i.lineDash,r.borderDash)),n&&n.usePointStyle){var s=3Dm*Math.SQRT2/2,l=3Dh.= xPlus(t,m/2),u=3De+p/2;V.canvas.drawPoint(c,i.pointStyle,s,l,u,i.rotation)}= else c.fillRect(h.leftForLtr(t,m),e,m,p),0!=3D=3Do&&c.strokeRect(h.leftForL= tr(t,m),e,m,p);c.restore()}}(w,k,e),v[i].left=3Dh.leftForLtr(w,v[i].width),= v[i].top=3Dk,function(t,e,n,i){var a=3Dp/2,r=3Dh.xPlus(t,m+a),o=3De+a;c.fil= lText(n.text,r,o),n.hidden&&(c.beginPath(),c.lineWidth=3D2,c.moveTo(r,o),c.= lineTo(h.xPlus(r,i),o),c.stroke())}(w,k,e,f),x?d.x+=3Dg+n.padding:d.y+=3Dy}= )),V.rtl.restoreTextDirection(t.ctx,e.textDirection)}},_getLegendItemAt:fun= ction(t,e){var n,i,a,r=3Dthis;if(t>=3Dr.left&&t<=3Dr.right&&e>=3Dr.top&&e<= =3Dr.bottom)for(a=3Dr.legendHitBoxes,n=3D0;n=3D(i=3Da[n]= ).left&&t<=3Di.left+i.width&&e>=3Di.top&&e<=3Di.top+i.height)return r.legen= dItems[n];return null},handleEvent:function(t){var e,n=3Dthis,i=3Dn.options= ,a=3D"mouseup"=3D=3D=3Dt.type?"click":t.type;if("mousemove"=3D=3D=3Da){if(!= i.onHover&&!i.onLeave)return}else{if("click"!=3D=3Da)return;if(!i.onClick)r= eturn}e=3Dn._getLegendItemAt(t.x,t.y),"click"=3D=3D=3Da?e&&i.onClick&&i.onC= lick.call(n,t.native,e):(i.onLeave&&e!=3D=3Dn._hoveredItem&&(n._hoveredItem= &&i.onLeave.call(n,t.native,n._hoveredItem),n._hoveredItem=3De),i.onHover&&= e&&i.onHover.call(n,t.native,e))}});function Ai(t,e){var n=3Dnew Pi({ctx:t.= ctx,options:e,chart:t});ge.configure(t,n,e),ge.addBox(t,n),t.legend=3Dn}var= Di=3D{id:"legend",_element:Pi,beforeInit:function(t){var e=3Dt.options.leg= end;e&&Ai(t,e)},beforeUpdate:function(t){var e=3Dt.options.legend,n=3Dt.leg= end;e?(V.mergeIf(e,z.global.legend),n?(ge.configure(t,n,e),n.options=3De):A= i(t,e)):n&&(ge.removeBox(t,n),delete t.legend)},afterEvent:function(t,e){va= r n=3Dt.legend;n&&n.handleEvent(e)}},Ti=3DV.noop;z._set("global",{title:{di= splay:!1,fontStyle:"bold",fullWidth:!0,padding:10,position:"top",text:"",we= ight:2e3}});var Ii=3DX.extend({initialize:function(t){V.extend(this,t),this= .legendHitBoxes=3D[]},beforeUpdate:Ti,update:function(t,e,n){var i=3Dthis;r= eturn i.beforeUpdate(),i.maxWidth=3Dt,i.maxHeight=3De,i.margins=3Dn,i.befor= eSetDimensions(),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabe= ls(),i.buildLabels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(= ),i.afterUpdate(),i.minSize},afterUpdate:Ti,beforeSetDimensions:Ti,setDimen= sions:function(){var t=3Dthis;t.isHorizontal()?(t.width=3Dt.maxWidth,t.left= =3D0,t.right=3Dt.width):(t.height=3Dt.maxHeight,t.top=3D0,t.bottom=3Dt.heig= ht),t.paddingLeft=3D0,t.paddingTop=3D0,t.paddingRight=3D0,t.paddingBottom= =3D0,t.minSize=3D{width:0,height:0}},afterSetDimensions:Ti,beforeBuildLabel= s:Ti,buildLabels:Ti,afterBuildLabels:Ti,beforeFit:Ti,fit:function(){var t,e= =3Dthis,n=3De.options,i=3De.minSize=3D{},a=3De.isHorizontal();n.display?(t= =3D(V.isArray(n.text)?n.text.length:1)*V.options._parseFont(n).lineHeight+2= *n.padding,e.width=3Di.width=3Da?e.maxWidth:t,e.height=3Di.height=3Da?t:e.m= axHeight):e.width=3Di.width=3De.height=3Di.height=3D0},afterFit:Ti,isHorizo= ntal:function(){var t=3Dthis.options.position;return"top"=3D=3D=3Dt||"botto= m"=3D=3D=3Dt},draw:function(){var t=3Dthis,e=3Dt.ctx,n=3Dt.options;if(n.dis= play){var i,a,r,o=3DV.options._parseFont(n),s=3Do.lineHeight,l=3Ds/2+n.padd= ing,u=3D0,d=3Dt.top,h=3Dt.left,c=3Dt.bottom,f=3Dt.right;e.fillStyle=3DV.val= ueOrDefault(n.fontColor,z.global.defaultFontColor),e.font=3Do.string,t.isHo= rizontal()?(a=3Dh+(f-h)/2,r=3Dd+l,i=3Df-h):(a=3D"left"=3D=3D=3Dn.position?h= +l:f-l,r=3Dd+(c-d)/2,i=3Dc-d,u=3DMath.PI*("left"=3D=3D=3Dn.position?-.5:.5)= ),e.save(),e.translate(a,r),e.rotate(u),e.textAlign=3D"center",e.textBaseli= ne=3D"middle";var g=3Dn.text;if(V.isArray(g))for(var p=3D0,m=3D0;m=3D0;i--){var a=3Dt[i= ];if(e(a))return a}},V.isNumber=3Dfunction(t){return!isNaN(parseFloat(t))&&= isFinite(t)},V.almostEquals=3Dfunction(t,e,n){return Math.abs(t-e)=3Dt},V= .max=3Dfunction(t){return t.reduce((function(t,e){return isNaN(e)?t:Math.ma= x(t,e)}),Number.NEGATIVE_INFINITY)},V.min=3Dfunction(t){return t.reduce((fu= nction(t,e){return isNaN(e)?t:Math.min(t,e)}),Number.POSITIVE_INFINITY)},V.= sign=3DMath.sign?function(t){return Math.sign(t)}:function(t){return 0=3D= =3D=3D(t=3D+t)||isNaN(t)?t:t>0?1:-1},V.toRadians=3Dfunction(t){return t*(Ma= th.PI/180)},V.toDegrees=3Dfunction(t){return t*(180/Math.PI)},V._decimalPla= ces=3Dfunction(t){if(V.isFinite(t)){for(var e=3D1,n=3D0;Math.round(t*e)/e!= =3D=3Dt;)e*=3D10,n++;return n}},V.getAngleFromPoint=3Dfunction(t,e){var n= =3De.x-t.x,i=3De.y-t.y,a=3DMath.sqrt(n*n+i*i),r=3DMath.atan2(i,n);return r<= -.5*Math.PI&&(r+=3D2*Math.PI),{angle:r,distance:a}},V.distanceBetweenPoints= =3Dfunction(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}= ,V.aliasPixel=3Dfunction(t){return t%2=3D=3D0?0:.5},V._alignPixel=3Dfunctio= n(t,e,n){var i=3Dt.currentDevicePixelRatio,a=3Dn/2;return Math.round((e-a)*= i)/i+a},V.splineCurve=3Dfunction(t,e,n,i){var a=3Dt.skip?e:t,r=3De,o=3Dn.sk= ip?e:n,s=3DMath.sqrt(Math.pow(r.x-a.x,2)+Math.pow(r.y-a.y,2)),l=3DMath.sqrt= (Math.pow(o.x-r.x,2)+Math.pow(o.y-r.y,2)),u=3Ds/(s+l),d=3Dl/(s+l),h=3Di*(u= =3DisNaN(u)?0:u),c=3Di*(d=3DisNaN(d)?0:d);return{previous:{x:r.x-h*(o.x-a.x= ),y:r.y-h*(o.y-a.y)},next:{x:r.x+c*(o.x-a.x),y:r.y+c*(o.y-a.y)}}},V.EPSILON= =3DNumber.EPSILON||1e-14,V.splineCurveMonotone=3Dfunction(t){var e,n,i,a,r,= o,s,l,u,d=3D(t||[]).map((function(t){return{model:t._model,deltaK:0,mK:0}})= ),h=3Dd.length;for(e=3D0;e0?d[e-= 1]:null,(a=3De0?d[e-1]:null,= a=3De=3Dt.length-1?t[0]:t[e+1]:e>=3Dt.leng= th-1?t[t.length-1]:t[e+1]},V.previousItem=3Dfunction(t,e,n){return n?e<=3D0= ?t[t.length-1]:t[e-1]:e<=3D0?t[0]:t[e-1]},V.niceNum=3Dfunction(t,e){var n= =3DMath.floor(V.log10(t)),i=3Dt/Math.pow(10,n);return(e?i<1.5?1:i<3?2:i<7?5= :10:i<=3D1?1:i<=3D2?2:i<=3D5?5:10)*Math.pow(10,n)},V.requestAnimFrame=3D"un= defined"=3D=3Dtypeof window?function(t){t()}:window.requestAnimationFrame||= window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window= .oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return= window.setTimeout(t,1e3/60)},V.getRelativePosition=3Dfunction(t,e){var n,i= ,a=3Dt.originalEvent||t,r=3Dt.target||t.srcElement,o=3Dr.getBoundingClientR= ect(),s=3Da.touches;s&&s.length>0?(n=3Ds[0].clientX,i=3Ds[0].clientY):(n=3D= a.clientX,i=3Da.clientY);var l=3DparseFloat(V.getStyle(r,"padding-left")),u= =3DparseFloat(V.getStyle(r,"padding-top")),d=3DparseFloat(V.getStyle(r,"pad= ding-right")),h=3DparseFloat(V.getStyle(r,"padding-bottom")),c=3Do.right-o.= left-l-d,f=3Do.bottom-o.top-u-h;return{x:n=3DMath.round((n-o.left-l)/c*r.wi= dth/e.currentDevicePixelRatio),y:i=3DMath.round((i-o.top-u)/f*r.height/e.cu= rrentDevicePixelRatio)}},V.getConstraintWidth=3Dfunction(t){return n(t,"max= -width","clientWidth")},V.getConstraintHeight=3Dfunction(t){return n(t,"max= -height","clientHeight")},V._calculatePadding=3Dfunction(t,e,n){return(e=3D= V.getStyle(t,e)).indexOf("%")>-1?n*parseInt(e,10)/100:parseInt(e,10)},V._ge= tParentNode=3Dfunction(t){var e=3Dt.parentNode;return e&&"[object ShadowRoo= t]"=3D=3D=3De.toString()&&(e=3De.host),e},V.getMaximumWidth=3Dfunction(t){v= ar e=3DV._getParentNode(t);if(!e)return t.clientWidth;var n=3De.clientWidth= ,i=3Dn-V._calculatePadding(e,"padding-left",n)-V._calculatePadding(e,"paddi= ng-right",n),a=3DV.getConstraintWidth(t);return isNaN(a)?i:Math.min(i,a)},V= .getMaximumHeight=3Dfunction(t){var e=3DV._getParentNode(t);if(!e)return t.= clientHeight;var n=3De.clientHeight,i=3Dn-V._calculatePadding(e,"padding-to= p",n)-V._calculatePadding(e,"padding-bottom",n),a=3DV.getConstraintHeight(t= );return isNaN(a)?i:Math.min(i,a)},V.getStyle=3Dfunction(t,e){return t.curr= entStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).ge= tPropertyValue(e)},V.retinaScale=3Dfunction(t,e){var n=3Dt.currentDevicePix= elRatio=3De||"undefined"!=3Dtypeof window&&window.devicePixelRatio||1;if(1!= =3D=3Dn){var i=3Dt.canvas,a=3Dt.height,r=3Dt.width;i.height=3Da*n,i.width= =3Dr*n,t.ctx.scale(n,n),i.style.height||i.style.width||(i.style.height=3Da+= "px",i.style.width=3Dr+"px")}},V.fontString=3Dfunction(t,e,n){return e+" "+= t+"px "+n},V.longestText=3Dfunction(t,e,n,i){var a=3D(i=3Di||{}).data=3Di.d= ata||{},r=3Di.garbageCollect=3Di.garbageCollect||[];i.font!=3D=3De&&(a=3Di.= data=3D{},r=3Di.garbageCollect=3D[],i.font=3De),t.font=3De;var o,s,l,u,d,h= =3D0,c=3Dn.length;for(o=3D0;on.length){for(o=3D0;oi&&(i=3Dr),i},V.numberO= fLabelLines=3Dfunction(t){var e=3D1;return V.each(t,(function(t){V.isArray(= t)&&t.length>e&&(e=3Dt.length)})),e},V.color=3Dk?function(t){return t insta= nceof CanvasGradient&&(t=3Dz.global.defaultColor),k(t)}:function(t){return = console.error("Color.js not found!"),t},V.getHoverColor=3Dfunction(t){retur= n t instanceof CanvasPattern||t instanceof CanvasGradient?t:V.color(t).satu= rate(.5).darken(.1).rgbString()}}(),tn._adapters=3Dan,tn.Animation=3DZ,tn.a= nimationService=3D$,tn.controllers=3D$t,tn.DatasetController=3Dnt,tn.defaul= ts=3Dz,tn.Element=3DX,tn.elements=3D_t,tn.Interaction=3Dae,tn.layouts=3Dge,= tn.platform=3DFe,tn.plugins=3DLe,tn.Scale=3Dxn,tn.scaleService=3DOe,tn.Tick= s=3Drn,tn.Tooltip=3DUe,tn.helpers.each(ci,(function(t,e){tn.scaleService.re= gisterScaleType(e,t,t._defaults)})),Li)Li.hasOwnProperty(Ni)&&tn.plugins.re= gister(Li[Ni]);tn.platform.initialize();var Bi=3Dtn;return"undefined"!=3Dty= peof window&&(window.Chart=3Dtn),tn.Chart=3Dtn,tn.Legend=3DLi.legend._eleme= nt,tn.Title=3DLi.title._element,tn.pluginService=3Dtn.plugins,tn.PluginBase= =3Dtn.Element.extend({}),tn.canvasHelpers=3Dtn.helpers.canvas,tn.layoutServ= ice=3Dtn.layouts,tn.LinearScaleBase=3DSn,tn.helpers.each(["Bar","Bubble","D= oughnut","Line","PolarArea","Radar","Scatter"],(function(t){tn[t]=3Dfunctio= n(e,n){return new tn(e,tn.helpers.merge(n||{},{type:t.charAt(0).toLowerCase= ()+t.slice(1)}))}})),Bi})); diff --git a/layerindex/static/js/Chart-2.9.3.js b/layerindex/static/js/Cha= rt-2.9.4.js similarity index 96% rename from layerindex/static/js/Chart-2.9.3.js rename to layerindex/static/js/Chart-2.9.4.js index e8d937c..7a1a28d 100644 --- a/layerindex/static/js/Chart-2.9.3.js +++ b/layerindex/static/js/Chart-2.9.4.js @@ -1,7 +1,7 @@ /*! - * Chart.js v2.9.3 + * Chart.js v2.9.4 * https://www.chartjs.org - * (c) 2019 Chart.js Contributors + * (c) 2020 Chart.js Contributors * Released under the MIT License */ (function (global, factory) { @@ -2103,14047 +2103,14068 @@ if (typeof window !=3D=3D 'undefined') { =20 var chartjsColor =3D Color; =20 -/** - * @namespace Chart.helpers - */ -var helpers =3D { - /** - * An empty function that can be used, for example, for optional callback. - */ - noop: function() {}, - - /** - * Returns a unique id, sequentially generated from a global variable. - * @returns {number} - * @function - */ - uid: (function() { - var id =3D 0; - return function() { - return id++; - }; - }()), - - /** - * Returns true if `value` is neither null nor undefined, else returns fa= lse. - * @param {*} value - The value to test. - * @returns {boolean} - * @since 2.7.0 - */ - isNullOrUndef: function(value) { - return value =3D=3D=3D null || typeof value =3D=3D=3D 'undefined'; - }, - - /** - * Returns true if `value` is an array (including typed arrays), else ret= urns false. - * @param {*} value - The value to test. - * @returns {boolean} - * @function - */ - isArray: function(value) { - if (Array.isArray && Array.isArray(value)) { - return true; - } - var type =3D Object.prototype.toString.call(value); - if (type.substr(0, 7) =3D=3D=3D '[object' && type.substr(-6) =3D=3D=3D '= Array]') { - return true; - } - return false; - }, - - /** - * Returns true if `value` is an object (excluding null), else returns fa= lse. - * @param {*} value - The value to test. - * @returns {boolean} - * @since 2.7.0 - */ - isObject: function(value) { - return value !=3D=3D null && Object.prototype.toString.call(value) =3D= =3D=3D '[object Object]'; - }, - - /** - * Returns true if `value` is a finite number, else returns false - * @param {*} value - The value to test. - * @returns {boolean} - */ - isFinite: function(value) { - return (typeof value =3D=3D=3D 'number' || value instanceof Number) && i= sFinite(value); - }, - - /** - * Returns `value` if defined, else returns `defaultValue`. - * @param {*} value - The value to return if defined. - * @param {*} defaultValue - The value to return if `value` is undefined. - * @returns {*} - */ - valueOrDefault: function(value, defaultValue) { - return typeof value =3D=3D=3D 'undefined' ? defaultValue : value; - }, - - /** - * Returns value at the given `index` in array if defined, else returns `= defaultValue`. - * @param {Array} value - The array to lookup for value at `index`. - * @param {number} index - The index in `value` to lookup for value. - * @param {*} defaultValue - The value to return if `value[index]` is und= efined. - * @returns {*} - */ - valueAtIndexOrDefault: function(value, index, defaultValue) { - return helpers.valueOrDefault(helpers.isArray(value) ? value[index] : va= lue, defaultValue); - }, - - /** - * Calls `fn` with the given `args` in the scope defined by `thisArg` and= returns the - * value returned by `fn`. If `fn` is not a function, this method returns= undefined. - * @param {function} fn - The function to call. - * @param {Array|undefined|null} args - The arguments with which `fn` sho= uld be called. - * @param {object} [thisArg] - The value of `this` provided for the call = to `fn`. - * @returns {*} - */ - callback: function(fn, args, thisArg) { - if (fn && typeof fn.call =3D=3D=3D 'function') { - return fn.apply(thisArg, args); - } - }, - - /** - * Note(SB) for performance sake, this method should only be used when lo= opable type - * is unknown or in none intensive code (not called often and small loopa= ble). Else - * it's preferable to use a regular for() loop and save extra function ca= lls. - * @param {object|Array} loopable - The object or array to be iterated. - * @param {function} fn - The function to call for each item. - * @param {object} [thisArg] - The value of `this` provided for the call = to `fn`. - * @param {boolean} [reverse] - If true, iterates backward on the loopabl= e. - */ - each: function(loopable, fn, thisArg, reverse) { - var i, len, keys; - if (helpers.isArray(loopable)) { - len =3D loopable.length; - if (reverse) { - for (i =3D len - 1; i >=3D 0; i--) { - fn.call(thisArg, loopable[i], i); - } - } else { - for (i =3D 0; i < len; i++) { - fn.call(thisArg, loopable[i], i); - } - } - } else if (helpers.isObject(loopable)) { - keys =3D Object.keys(loopable); - len =3D keys.length; - for (i =3D 0; i < len; i++) { - fn.call(thisArg, loopable[keys[i]], keys[i]); - } - } - }, - - /** - * Returns true if the `a0` and `a1` arrays have the same content, else r= eturns false. - * @see https://stackoverflow.com/a/14853974 - * @param {Array} a0 - The array to compare - * @param {Array} a1 - The array to compare - * @returns {boolean} - */ - arrayEquals: function(a0, a1) { - var i, ilen, v0, v1; - - if (!a0 || !a1 || a0.length !=3D=3D a1.length) { - return false; - } - - for (i =3D 0, ilen =3D a0.length; i < ilen; ++i) { - v0 =3D a0[i]; - v1 =3D a1[i]; - - if (v0 instanceof Array && v1 instanceof Array) { - if (!helpers.arrayEquals(v0, v1)) { - return false; - } - } else if (v0 !=3D=3D v1) { - // NOTE: two different object instances will never be equal: {x:20} != =3D {x:20} - return false; - } - } - - return true; - }, - - /** - * Returns a deep copy of `source` without keeping references on objects = and arrays. - * @param {*} source - The value to clone. - * @returns {*} - */ - clone: function(source) { - if (helpers.isArray(source)) { - return source.map(helpers.clone); - } - - if (helpers.isObject(source)) { - var target =3D {}; - var keys =3D Object.keys(source); - var klen =3D keys.length; - var k =3D 0; - - for (; k < klen; ++k) { - target[keys[k]] =3D helpers.clone(source[keys[k]]); - } - - return target; - } - - return source; - }, - - /** - * The default merger when Chart.helpers.merge is called without merger o= ption. - * Note(SB): also used by mergeConfig and mergeScaleConfig as fallback. - * @private - */ - _merger: function(key, target, source, options) { - var tval =3D target[key]; - var sval =3D source[key]; - - if (helpers.isObject(tval) && helpers.isObject(sval)) { - helpers.merge(tval, sval, options); - } else { - target[key] =3D helpers.clone(sval); - } - }, - - /** - * Merges source[key] in target[key] only if target[key] is undefined. - * @private - */ - _mergerIf: function(key, target, source) { - var tval =3D target[key]; - var sval =3D source[key]; - - if (helpers.isObject(tval) && helpers.isObject(sval)) { - helpers.mergeIf(tval, sval); - } else if (!target.hasOwnProperty(key)) { - target[key] =3D helpers.clone(sval); - } - }, - - /** - * Recursively deep copies `source` properties into `target` with the giv= en `options`. - * IMPORTANT: `target` is not cloned and will be updated with `source` pr= operties. - * @param {object} target - The target object in which all sources are me= rged into. - * @param {object|object[]} source - Object(s) to merge into `target`. - * @param {object} [options] - Merging options: - * @param {function} [options.merger] - The merge method (key, target, so= urce, options) - * @returns {object} The `target` object. - */ - merge: function(target, source, options) { - var sources =3D helpers.isArray(source) ? source : [source]; - var ilen =3D sources.length; - var merge, i, keys, klen, k; - - if (!helpers.isObject(target)) { - return target; - } - - options =3D options || {}; - merge =3D options.merger || helpers._merger; - - for (i =3D 0; i < ilen; ++i) { - source =3D sources[i]; - if (!helpers.isObject(source)) { - continue; - } - - keys =3D Object.keys(source); - for (k =3D 0, klen =3D keys.length; k < klen; ++k) { - merge(keys[k], target, source, options); - } - } - - return target; - }, - - /** - * Recursively deep copies `source` properties into `target` *only* if no= t defined in target. - * IMPORTANT: `target` is not cloned and will be updated with `source` pr= operties. - * @param {object} target - The target object in which all sources are me= rged into. - * @param {object|object[]} source - Object(s) to merge into `target`. - * @returns {object} The `target` object. - */ - mergeIf: function(target, source) { - return helpers.merge(target, source, {merger: helpers._mergerIf}); - }, - - /** - * Applies the contents of two or more objects together into the first ob= ject. - * @param {object} target - The target object in which all objects are me= rged into. - * @param {object} arg1 - Object containing additional properties to merg= e in target. - * @param {object} argN - Additional objects containing properties to mer= ge in target. - * @returns {object} The `target` object. - */ - extend: Object.assign || function(target) { - return helpers.merge(target, [].slice.call(arguments, 1), { - merger: function(key, dst, src) { - dst[key] =3D src[key]; - } - }); - }, - - /** - * Basic javascript inheritance based on the model created in Backbone.js - */ - inherits: function(extensions) { - var me =3D this; - var ChartElement =3D (extensions && extensions.hasOwnProperty('construct= or')) ? extensions.constructor : function() { - return me.apply(this, arguments); - }; - - var Surrogate =3D function() { - this.constructor =3D ChartElement; - }; - - Surrogate.prototype =3D me.prototype; - ChartElement.prototype =3D new Surrogate(); - ChartElement.extend =3D helpers.inherits; - - if (extensions) { - helpers.extend(ChartElement.prototype, extensions); - } - - ChartElement.__super__ =3D me.prototype; - return ChartElement; - }, - - _deprecated: function(scope, value, previous, current) { - if (value !=3D=3D undefined) { - console.warn(scope + ': "' + previous + - '" is deprecated. Please use "' + current + '" instead'); - } - } -}; - -var helpers_core =3D helpers; - -// DEPRECATIONS - -/** - * Provided for backward compatibility, use Chart.helpers.callback instead. - * @function Chart.helpers.callCallback - * @deprecated since version 2.6.0 - * @todo remove at version 3 - * @private - */ -helpers.callCallback =3D helpers.callback; - -/** - * Provided for backward compatibility, use Array.prototype.indexOf instea= d. - * Array.prototype.indexOf compatibility: Chrome, Opera, Safari, FF1.5+, I= E9+ - * @function Chart.helpers.indexOf - * @deprecated since version 2.7.0 - * @todo remove at version 3 - * @private - */ -helpers.indexOf =3D function(array, item, fromIndex) { - return Array.prototype.indexOf.call(array, item, fromIndex); -}; - -/** - * Provided for backward compatibility, use Chart.helpers.valueOrDefault i= nstead. - * @function Chart.helpers.getValueOrDefault - * @deprecated since version 2.7.0 - * @todo remove at version 3 - * @private - */ -helpers.getValueOrDefault =3D helpers.valueOrDefault; - -/** - * Provided for backward compatibility, use Chart.helpers.valueAtIndexOrDe= fault instead. - * @function Chart.helpers.getValueAtIndexOrDefault - * @deprecated since version 2.7.0 - * @todo remove at version 3 - * @private - */ -helpers.getValueAtIndexOrDefault =3D helpers.valueAtIndexOrDefault; - -/** - * Easing functions adapted from Robert Penner's easing equations. - * @namespace Chart.helpers.easingEffects - * @see http://www.robertpenner.com/easing/ - */ -var effects =3D { - linear: function(t) { - return t; - }, - - easeInQuad: function(t) { - return t * t; - }, - - easeOutQuad: function(t) { - return -t * (t - 2); - }, - - easeInOutQuad: function(t) { - if ((t /=3D 0.5) < 1) { - return 0.5 * t * t; - } - return -0.5 * ((--t) * (t - 2) - 1); - }, - - easeInCubic: function(t) { - return t * t * t; - }, - - easeOutCubic: function(t) { - return (t =3D t - 1) * t * t + 1; - }, - - easeInOutCubic: function(t) { - if ((t /=3D 0.5) < 1) { - return 0.5 * t * t * t; - } - return 0.5 * ((t -=3D 2) * t * t + 2); - }, - - easeInQuart: function(t) { - return t * t * t * t; - }, - - easeOutQuart: function(t) { - return -((t =3D t - 1) * t * t * t - 1); - }, - - easeInOutQuart: function(t) { - if ((t /=3D 0.5) < 1) { - return 0.5 * t * t * t * t; - } - return -0.5 * ((t -=3D 2) * t * t * t - 2); - }, - - easeInQuint: function(t) { - return t * t * t * t * t; - }, - - easeOutQuint: function(t) { - return (t =3D t - 1) * t * t * t * t + 1; - }, - - easeInOutQuint: function(t) { - if ((t /=3D 0.5) < 1) { - return 0.5 * t * t * t * t * t; - } - return 0.5 * ((t -=3D 2) * t * t * t * t + 2); - }, - - easeInSine: function(t) { - return -Math.cos(t * (Math.PI / 2)) + 1; - }, - - easeOutSine: function(t) { - return Math.sin(t * (Math.PI / 2)); - }, - - easeInOutSine: function(t) { - return -0.5 * (Math.cos(Math.PI * t) - 1); - }, - - easeInExpo: function(t) { - return (t =3D=3D=3D 0) ? 0 : Math.pow(2, 10 * (t - 1)); - }, - - easeOutExpo: function(t) { - return (t =3D=3D=3D 1) ? 1 : -Math.pow(2, -10 * t) + 1; - }, - - easeInOutExpo: function(t) { - if (t =3D=3D=3D 0) { - return 0; - } - if (t =3D=3D=3D 1) { - return 1; - } - if ((t /=3D 0.5) < 1) { - return 0.5 * Math.pow(2, 10 * (t - 1)); - } - return 0.5 * (-Math.pow(2, -10 * --t) + 2); - }, - - easeInCirc: function(t) { - if (t >=3D 1) { - return t; - } - return -(Math.sqrt(1 - t * t) - 1); - }, - - easeOutCirc: function(t) { - return Math.sqrt(1 - (t =3D t - 1) * t); - }, - - easeInOutCirc: function(t) { - if ((t /=3D 0.5) < 1) { - return -0.5 * (Math.sqrt(1 - t * t) - 1); - } - return 0.5 * (Math.sqrt(1 - (t -=3D 2) * t) + 1); - }, - - easeInElastic: function(t) { - var s =3D 1.70158; - var p =3D 0; - var a =3D 1; - if (t =3D=3D=3D 0) { - return 0; - } - if (t =3D=3D=3D 1) { - return 1; - } - if (!p) { - p =3D 0.3; - } - if (a < 1) { - a =3D 1; - s =3D p / 4; - } else { - s =3D p / (2 * Math.PI) * Math.asin(1 / a); - } - return -(a * Math.pow(2, 10 * (t -=3D 1)) * Math.sin((t - s) * (2 * Math= .PI) / p)); - }, - - easeOutElastic: function(t) { - var s =3D 1.70158; - var p =3D 0; - var a =3D 1; - if (t =3D=3D=3D 0) { - return 0; - } - if (t =3D=3D=3D 1) { - return 1; - } - if (!p) { - p =3D 0.3; - } - if (a < 1) { - a =3D 1; - s =3D p / 4; - } else { - s =3D p / (2 * Math.PI) * Math.asin(1 / a); - } - return a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p) = + 1; - }, - - easeInOutElastic: function(t) { - var s =3D 1.70158; - var p =3D 0; - var a =3D 1; - if (t =3D=3D=3D 0) { - return 0; - } - if ((t /=3D 0.5) =3D=3D=3D 2) { - return 1; - } - if (!p) { - p =3D 0.45; - } - if (a < 1) { - a =3D 1; - s =3D p / 4; - } else { - s =3D p / (2 * Math.PI) * Math.asin(1 / a); - } - if (t < 1) { - return -0.5 * (a * Math.pow(2, 10 * (t -=3D 1)) * Math.sin((t - s) * (2= * Math.PI) / p)); - } - return a * Math.pow(2, -10 * (t -=3D 1)) * Math.sin((t - s) * (2 * Math.= PI) / p) * 0.5 + 1; - }, - easeInBack: function(t) { - var s =3D 1.70158; - return t * t * ((s + 1) * t - s); - }, - - easeOutBack: function(t) { - var s =3D 1.70158; - return (t =3D t - 1) * t * ((s + 1) * t + s) + 1; - }, - - easeInOutBack: function(t) { - var s =3D 1.70158; - if ((t /=3D 0.5) < 1) { - return 0.5 * (t * t * (((s *=3D (1.525)) + 1) * t - s)); - } - return 0.5 * ((t -=3D 2) * t * (((s *=3D (1.525)) + 1) * t + s) + 2); - }, - - easeInBounce: function(t) { - return 1 - effects.easeOutBounce(1 - t); - }, - - easeOutBounce: function(t) { - if (t < (1 / 2.75)) { - return 7.5625 * t * t; - } - if (t < (2 / 2.75)) { - return 7.5625 * (t -=3D (1.5 / 2.75)) * t + 0.75; - } - if (t < (2.5 / 2.75)) { - return 7.5625 * (t -=3D (2.25 / 2.75)) * t + 0.9375; - } - return 7.5625 * (t -=3D (2.625 / 2.75)) * t + 0.984375; - }, - - easeInOutBounce: function(t) { - if (t < 0.5) { - return effects.easeInBounce(t * 2) * 0.5; - } - return effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5; - } -}; - -var helpers_easing =3D { - effects: effects -}; - -// DEPRECATIONS - -/** - * Provided for backward compatibility, use Chart.helpers.easing.effects i= nstead. - * @function Chart.helpers.easingEffects - * @deprecated since version 2.7.0 - * @todo remove at version 3 - * @private - */ -helpers_core.easingEffects =3D effects; - -var PI =3D Math.PI; -var RAD_PER_DEG =3D PI / 180; -var DOUBLE_PI =3D PI * 2; -var HALF_PI =3D PI / 2; -var QUARTER_PI =3D PI / 4; -var TWO_THIRDS_PI =3D PI * 2 / 3; - -/** - * @namespace Chart.helpers.canvas - */ -var exports$1 =3D { - /** - * Clears the entire canvas associated to the given `chart`. - * @param {Chart} chart - The chart for which to clear the canvas. - */ - clear: function(chart) { - chart.ctx.clearRect(0, 0, chart.width, chart.height); - }, - - /** - * Creates a "path" for a rectangle with rounded corners at position (x, = y) with a - * given size (width, height) and the same `radius` for all corners. - * @param {CanvasRenderingContext2D} ctx - The canvas 2D Context. - * @param {number} x - The x axis of the coordinate for the rectangle sta= rting point. - * @param {number} y - The y axis of the coordinate for the rectangle sta= rting point. - * @param {number} width - The rectangle's width. - * @param {number} height - The rectangle's height. - * @param {number} radius - The rounded amount (in pixels) for the four c= orners. - * @todo handle `radius` as top-left, top-right, bottom-right, bottom-lef= t array/object? - */ - roundedRect: function(ctx, x, y, width, height, radius) { - if (radius) { - var r =3D Math.min(radius, height / 2, width / 2); - var left =3D x + r; - var top =3D y + r; - var right =3D x + width - r; - var bottom =3D y + height - r; - - ctx.moveTo(x, top); - if (left < right && top < bottom) { - ctx.arc(left, top, r, -PI, -HALF_PI); - ctx.arc(right, top, r, -HALF_PI, 0); - ctx.arc(right, bottom, r, 0, HALF_PI); - ctx.arc(left, bottom, r, HALF_PI, PI); - } else if (left < right) { - ctx.moveTo(left, y); - ctx.arc(right, top, r, -HALF_PI, HALF_PI); - ctx.arc(left, top, r, HALF_PI, PI + HALF_PI); - } else if (top < bottom) { - ctx.arc(left, top, r, -PI, 0); - ctx.arc(left, bottom, r, 0, PI); - } else { - ctx.arc(left, top, r, -PI, PI); - } - ctx.closePath(); - ctx.moveTo(x, y); - } else { - ctx.rect(x, y, width, height); - } - }, - - drawPoint: function(ctx, style, radius, x, y, rotation) { - var type, xOffset, yOffset, size, cornerRadius; - var rad =3D (rotation || 0) * RAD_PER_DEG; - - if (style && typeof style =3D=3D=3D 'object') { - type =3D style.toString(); - if (type =3D=3D=3D '[object HTMLImageElement]' || type =3D=3D=3D '[obje= ct HTMLCanvasElement]') { - ctx.save(); - ctx.translate(x, y); - ctx.rotate(rad); - ctx.drawImage(style, -style.width / 2, -style.height / 2, style.width,= style.height); - ctx.restore(); - return; - } - } - - if (isNaN(radius) || radius <=3D 0) { - return; - } - - ctx.beginPath(); - - switch (style) { - // Default includes circle - default: - ctx.arc(x, y, radius, 0, DOUBLE_PI); - ctx.closePath(); - break; - case 'triangle': - ctx.moveTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); - rad +=3D TWO_THIRDS_PI; - ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); - rad +=3D TWO_THIRDS_PI; - ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius); - ctx.closePath(); - break; - case 'rectRounded': - // NOTE: the rounded rect implementation changed to use `arc` instead of - // `quadraticCurveTo` since it generates better results when rect is - // almost a circle. 0.516 (instead of 0.5) produces results with visual= ly - // closer proportion to the previous impl and it is inscribed in the - // circle with `radius`. For more details, see the following PRs: - // https://github.com/chartjs/Chart.js/issues/5597 - // https://github.com/chartjs/Chart.js/issues/5858 - cornerRadius =3D radius * 0.516; - size =3D radius - cornerRadius; - xOffset =3D Math.cos(rad + QUARTER_PI) * size; - yOffset =3D Math.sin(rad + QUARTER_PI) * size; - ctx.arc(x - xOffset, y - yOffset, cornerRadius, rad - PI, rad - HALF_PI= ); - ctx.arc(x + yOffset, y - xOffset, cornerRadius, rad - HALF_PI, rad); - ctx.arc(x + xOffset, y + yOffset, cornerRadius, rad, rad + HALF_PI); - ctx.arc(x - yOffset, y + xOffset, cornerRadius, rad + HALF_PI, rad + PI= ); - ctx.closePath(); - break; - case 'rect': - if (!rotation) { - size =3D Math.SQRT1_2 * radius; - ctx.rect(x - size, y - size, 2 * size, 2 * size); - break; - } - rad +=3D QUARTER_PI; - /* falls through */ - case 'rectRot': - xOffset =3D Math.cos(rad) * radius; - yOffset =3D Math.sin(rad) * radius; - ctx.moveTo(x - xOffset, y - yOffset); - ctx.lineTo(x + yOffset, y - xOffset); - ctx.lineTo(x + xOffset, y + yOffset); - ctx.lineTo(x - yOffset, y + xOffset); - ctx.closePath(); - break; - case 'crossRot': - rad +=3D QUARTER_PI; - /* falls through */ - case 'cross': - xOffset =3D Math.cos(rad) * radius; - yOffset =3D Math.sin(rad) * radius; - ctx.moveTo(x - xOffset, y - yOffset); - ctx.lineTo(x + xOffset, y + yOffset); - ctx.moveTo(x + yOffset, y - xOffset); - ctx.lineTo(x - yOffset, y + xOffset); - break; - case 'star': - xOffset =3D Math.cos(rad) * radius; - yOffset =3D Math.sin(rad) * radius; - ctx.moveTo(x - xOffset, y - yOffset); - ctx.lineTo(x + xOffset, y + yOffset); - ctx.moveTo(x + yOffset, y - xOffset); - ctx.lineTo(x - yOffset, y + xOffset); - rad +=3D QUARTER_PI; - xOffset =3D Math.cos(rad) * radius; - yOffset =3D Math.sin(rad) * radius; - ctx.moveTo(x - xOffset, y - yOffset); - ctx.lineTo(x + xOffset, y + yOffset); - ctx.moveTo(x + yOffset, y - xOffset); - ctx.lineTo(x - yOffset, y + xOffset); - break; - case 'line': - xOffset =3D Math.cos(rad) * radius; - yOffset =3D Math.sin(rad) * radius; - ctx.moveTo(x - xOffset, y - yOffset); - ctx.lineTo(x + xOffset, y + yOffset); - break; - case 'dash': - ctx.moveTo(x, y); - ctx.lineTo(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius); - break; - } - - ctx.fill(); - ctx.stroke(); - }, - - /** - * Returns true if the point is inside the rectangle - * @param {object} point - The point to test - * @param {object} area - The rectangle - * @returns {boolean} - * @private - */ - _isPointInArea: function(point, area) { - var epsilon =3D 1e-6; // 1e-6 is margin in pixels for accumulated error. - - return point.x > area.left - epsilon && point.x < area.right + epsilon && - point.y > area.top - epsilon && point.y < area.bottom + epsilon; - }, - - clipArea: function(ctx, area) { - ctx.save(); - ctx.beginPath(); - ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area= .top); - ctx.clip(); - }, - - unclipArea: function(ctx) { - ctx.restore(); - }, - - lineTo: function(ctx, previous, target, flip) { - var stepped =3D target.steppedLine; - if (stepped) { - if (stepped =3D=3D=3D 'middle') { - var midpoint =3D (previous.x + target.x) / 2.0; - ctx.lineTo(midpoint, flip ? target.y : previous.y); - ctx.lineTo(midpoint, flip ? previous.y : target.y); - } else if ((stepped =3D=3D=3D 'after' && !flip) || (stepped !=3D=3D 'af= ter' && flip)) { - ctx.lineTo(previous.x, target.y); - } else { - ctx.lineTo(target.x, previous.y); - } - ctx.lineTo(target.x, target.y); - return; - } - - if (!target.tension) { - ctx.lineTo(target.x, target.y); - return; - } - - ctx.bezierCurveTo( - flip ? previous.controlPointPreviousX : previous.controlPointNextX, - flip ? previous.controlPointPreviousY : previous.controlPointNextY, - flip ? target.controlPointNextX : target.controlPointPreviousX, - flip ? target.controlPointNextY : target.controlPointPreviousY, - target.x, - target.y); - } -}; - -var helpers_canvas =3D exports$1; - -// DEPRECATIONS - -/** - * Provided for backward compatibility, use Chart.helpers.canvas.clear ins= tead. - * @namespace Chart.helpers.clear - * @deprecated since version 2.7.0 - * @todo remove at version 3 - * @private - */ -helpers_core.clear =3D exports$1.clear; - -/** - * Provided for backward compatibility, use Chart.helpers.canvas.roundedRe= ct instead. - * @namespace Chart.helpers.drawRoundedRectangle - * @deprecated since version 2.7.0 - * @todo remove at version 3 - * @private - */ -helpers_core.drawRoundedRectangle =3D function(ctx) { - ctx.beginPath(); - exports$1.roundedRect.apply(exports$1, arguments); -}; - -var defaults =3D { - /** - * @private - */ - _set: function(scope, values) { - return helpers_core.merge(this[scope] || (this[scope] =3D {}), values); - } -}; - -// TODO(v3): remove 'global' from namespace. all default are global and -// there's inconsistency around which options are under 'global' -defaults._set('global', { - defaultColor: 'rgba(0,0,0,0.1)', - defaultFontColor: '#666', - defaultFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", - defaultFontSize: 12, - defaultFontStyle: 'normal', - defaultLineHeight: 1.2, - showLines: true -}); - -var core_defaults =3D defaults; - -var valueOrDefault =3D helpers_core.valueOrDefault; - -/** - * Converts the given font object into a CSS font string. - * @param {object} font - A font object. - * @return {string} The CSS font string. See https://developer.mozilla.org= /en-US/docs/Web/CSS/font - * @private - */ -function toFontString(font) { - if (!font || helpers_core.isNullOrUndef(font.size) || helpers_core.isNull= OrUndef(font.family)) { - return null; - } - - return (font.style ? font.style + ' ' : '') - + (font.weight ? font.weight + ' ' : '') - + font.size + 'px ' - + font.family; -} - -/** - * @alias Chart.helpers.options - * @namespace - */ -var helpers_options =3D { - /** - * Converts the given line height `value` in pixels for a specific font `= size`. - * @param {number|string} value - The lineHeight to parse (eg. 1.6, '14px= ', '75%', '1.6em'). - * @param {number} size - The font size (in pixels) used to resolve relat= ive `value`. - * @returns {number} The effective line height in pixels (size * 1.2 if v= alue is invalid). - * @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height - * @since 2.7.0 - */ - toLineHeight: function(value, size) { - var matches =3D ('' + value).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$= /); - if (!matches || matches[1] =3D=3D=3D 'normal') { - return size * 1.2; - } - - value =3D +matches[2]; - - switch (matches[3]) { - case 'px': - return value; - case '%': - value /=3D 100; - break; - } - - return size * value; - }, - - /** - * Converts the given value into a padding object with pre-computed width= /height. - * @param {number|object} value - If a number, set the value to all TRBL = component, - * else, if and object, use defined properties and sets undefined ones t= o 0. - * @returns {object} The padding values (top, right, bottom, left, width,= height) - * @since 2.7.0 - */ - toPadding: function(value) { - var t, r, b, l; - - if (helpers_core.isObject(value)) { - t =3D +value.top || 0; - r =3D +value.right || 0; - b =3D +value.bottom || 0; - l =3D +value.left || 0; - } else { - t =3D r =3D b =3D l =3D +value || 0; - } - - return { - top: t, - right: r, - bottom: b, - left: l, - height: t + b, - width: l + r - }; - }, - - /** - * Parses font options and returns the font object. - * @param {object} options - A object that contains font options to be pa= rsed. - * @return {object} The font object. - * @todo Support font.* options and renamed to toFont(). - * @private - */ - _parseFont: function(options) { - var globalDefaults =3D core_defaults.global; - var size =3D valueOrDefault(options.fontSize, globalDefaults.defaultFont= Size); - var font =3D { - family: valueOrDefault(options.fontFamily, globalDefaults.defaultFontFa= mily), - lineHeight: helpers_core.options.toLineHeight(valueOrDefault(options.li= neHeight, globalDefaults.defaultLineHeight), size), - size: size, - style: valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyl= e), - weight: null, - string: '' - }; - - font.string =3D toFontString(font); - return font; - }, - - /** - * Evaluates the given `inputs` sequentially and returns the first define= d value. - * @param {Array} inputs - An array of values, falling back to the last v= alue. - * @param {object} [context] - If defined and the current value is a func= tion, the value - * is called with `context` as first argument and the result becomes the = new input. - * @param {number} [index] - If defined and the current value is an array= , the value - * at `index` become the new input. - * @param {object} [info] - object to return information about resolution= in - * @param {boolean} [info.cacheable] - Will be set to `false` if option i= s not cacheable. - * @since 2.7.0 - */ - resolve: function(inputs, context, index, info) { - var cacheable =3D true; - var i, ilen, value; - - for (i =3D 0, ilen =3D inputs.length; i < ilen; ++i) { - value =3D inputs[i]; - if (value =3D=3D=3D undefined) { - continue; - } - if (context !=3D=3D undefined && typeof value =3D=3D=3D 'function') { - value =3D value(context); - cacheable =3D false; - } - if (index !=3D=3D undefined && helpers_core.isArray(value)) { - value =3D value[index]; - cacheable =3D false; - } - if (value !=3D=3D undefined) { - if (info && !cacheable) { - info.cacheable =3D false; - } - return value; - } - } - } -}; - -/** - * @alias Chart.helpers.math - * @namespace - */ -var exports$2 =3D { - /** - * Returns an array of factors sorted from 1 to sqrt(value) - * @private - */ - _factorize: function(value) { - var result =3D []; - var sqrt =3D Math.sqrt(value); - var i; - - for (i =3D 1; i < sqrt; i++) { - if (value % i =3D=3D=3D 0) { - result.push(i); - result.push(value / i); - } - } - if (sqrt =3D=3D=3D (sqrt | 0)) { // if value is a square number - result.push(sqrt); - } - - result.sort(function(a, b) { - return a - b; - }).pop(); - return result; - }, - - log10: Math.log10 || function(x) { - var exponent =3D Math.log(x) * Math.LOG10E; // Math.LOG10E =3D 1 / Math.= LN10. - // Check for whole powers of 10, - // which due to floating point rounding error should be corrected. - var powerOf10 =3D Math.round(exponent); - var isPowerOf10 =3D x =3D=3D=3D Math.pow(10, powerOf10); - - return isPowerOf10 ? powerOf10 : exponent; - } -}; - -var helpers_math =3D exports$2; - -// DEPRECATIONS - -/** - * Provided for backward compatibility, use Chart.helpers.math.log10 inste= ad. - * @namespace Chart.helpers.log10 - * @deprecated since version 2.9.0 - * @todo remove at version 3 - * @private - */ -helpers_core.log10 =3D exports$2.log10; - -var getRtlAdapter =3D function(rectX, width) { - return { - x: function(x) { - return rectX + rectX + width - x; - }, - setWidth: function(w) { - width =3D w; - }, - textAlign: function(align) { - if (align =3D=3D=3D 'center') { - return align; - } - return align =3D=3D=3D 'right' ? 'left' : 'right'; - }, - xPlus: function(x, value) { - return x - value; - }, - leftForLtr: function(x, itemWidth) { - return x - itemWidth; - }, - }; -}; - -var getLtrAdapter =3D function() { - return { - x: function(x) { - return x; - }, - setWidth: function(w) { // eslint-disable-line no-unused-vars - }, - textAlign: function(align) { - return align; - }, - xPlus: function(x, value) { - return x + value; - }, - leftForLtr: function(x, _itemWidth) { // eslint-disable-line no-unused-v= ars - return x; - }, - }; -}; - -var getAdapter =3D function(rtl, rectX, width) { - return rtl ? getRtlAdapter(rectX, width) : getLtrAdapter(); -}; - -var overrideTextDirection =3D function(ctx, direction) { - var style, original; - if (direction =3D=3D=3D 'ltr' || direction =3D=3D=3D 'rtl') { - style =3D ctx.canvas.style; - original =3D [ - style.getPropertyValue('direction'), - style.getPropertyPriority('direction'), - ]; - - style.setProperty('direction', direction, 'important'); - ctx.prevTextDirection =3D original; - } -}; - -var restoreTextDirection =3D function(ctx) { - var original =3D ctx.prevTextDirection; - if (original !=3D=3D undefined) { - delete ctx.prevTextDirection; - ctx.canvas.style.setProperty('direction', original[0], original[1]); - } -}; - -var helpers_rtl =3D { - getRtlAdapter: getAdapter, - overrideTextDirection: overrideTextDirection, - restoreTextDirection: restoreTextDirection, -}; - -var helpers$1 =3D helpers_core; -var easing =3D helpers_easing; -var canvas =3D helpers_canvas; -var options =3D helpers_options; -var math =3D helpers_math; -var rtl =3D helpers_rtl; -helpers$1.easing =3D easing; -helpers$1.canvas =3D canvas; -helpers$1.options =3D options; -helpers$1.math =3D math; -helpers$1.rtl =3D rtl; - -function interpolate(start, view, model, ease) { - var keys =3D Object.keys(model); - var i, ilen, key, actual, origin, target, type, c0, c1; - - for (i =3D 0, ilen =3D keys.length; i < ilen; ++i) { - key =3D keys[i]; - - target =3D model[key]; - - // if a value is added to the model after pivot() has been called, the v= iew - // doesn't contain it, so let's initialize the view to the target value. - if (!view.hasOwnProperty(key)) { - view[key] =3D target; - } - - actual =3D view[key]; - - if (actual =3D=3D=3D target || key[0] =3D=3D=3D '_') { - continue; - } - - if (!start.hasOwnProperty(key)) { - start[key] =3D actual; - } - - origin =3D start[key]; - - type =3D typeof target; - - if (type =3D=3D=3D typeof origin) { - if (type =3D=3D=3D 'string') { - c0 =3D chartjsColor(origin); - if (c0.valid) { - c1 =3D chartjsColor(target); - if (c1.valid) { - view[key] =3D c1.mix(c0, ease).rgbString(); - continue; - } - } - } else if (helpers$1.isFinite(origin) && helpers$1.isFinite(target)) { - view[key] =3D origin + (target - origin) * ease; - continue; - } - } - - view[key] =3D target; - } -} - -var Element =3D function(configuration) { - helpers$1.extend(this, configuration); - this.initialize.apply(this, arguments); -}; - -helpers$1.extend(Element.prototype, { - _type: undefined, - - initialize: function() { - this.hidden =3D false; - }, - - pivot: function() { - var me =3D this; - if (!me._view) { - me._view =3D helpers$1.extend({}, me._model); - } - me._start =3D {}; - return me; - }, - - transition: function(ease) { - var me =3D this; - var model =3D me._model; - var start =3D me._start; - var view =3D me._view; - - // No animation -> No Transition - if (!model || ease =3D=3D=3D 1) { - me._view =3D helpers$1.extend({}, model); - me._start =3D null; - return me; - } - - if (!view) { - view =3D me._view =3D {}; - } - - if (!start) { - start =3D me._start =3D {}; - } - - interpolate(start, view, model, ease); - - return me; - }, - - tooltipPosition: function() { - return { - x: this._model.x, - y: this._model.y - }; - }, - - hasValue: function() { - return helpers$1.isNumber(this._model.x) && helpers$1.isNumber(this._mod= el.y); - } -}); - -Element.extend =3D helpers$1.inherits; - -var core_element =3D Element; - -var exports$3 =3D core_element.extend({ - chart: null, // the animation associated chart instance - currentStep: 0, // the current animation step - numSteps: 60, // default number of steps - easing: '', // the easing to use for this animation - render: null, // render function used by the animation service - - onAnimationProgress: null, // user specified callback to fire on each ste= p of the animation - onAnimationComplete: null, // user specified callback to fire when the an= imation finishes -}); - -var core_animation =3D exports$3; - -// DEPRECATIONS - -/** - * Provided for backward compatibility, use Chart.Animation instead - * @prop Chart.Animation#animationObject - * @deprecated since version 2.6.0 - * @todo remove at version 3 - */ -Object.defineProperty(exports$3.prototype, 'animationObject', { - get: function() { - return this; - } -}); - -/** - * Provided for backward compatibility, use Chart.Animation#chart instead - * @prop Chart.Animation#chartInstance - * @deprecated since version 2.6.0 - * @todo remove at version 3 - */ -Object.defineProperty(exports$3.prototype, 'chartInstance', { - get: function() { - return this.chart; - }, - set: function(value) { - this.chart =3D value; - } -}); - -core_defaults._set('global', { - animation: { - duration: 1000, - easing: 'easeOutQuart', - onProgress: helpers$1.noop, - onComplete: helpers$1.noop - } -}); - -var core_animations =3D { - animations: [], - request: null, - - /** - * @param {Chart} chart - The chart to animate. - * @param {Chart.Animation} animation - The animation that we will animat= e. - * @param {number} duration - The animation duration in ms. - * @param {boolean} lazy - if true, the chart is not marked as animating = to enable more responsive interactions - */ - addAnimation: function(chart, animation, duration, lazy) { - var animations =3D this.animations; - var i, ilen; - - animation.chart =3D chart; - animation.startTime =3D Date.now(); - animation.duration =3D duration; - - if (!lazy) { - chart.animating =3D true; - } - - for (i =3D 0, ilen =3D animations.length; i < ilen; ++i) { - if (animations[i].chart =3D=3D=3D chart) { - animations[i] =3D animation; - return; - } - } - - animations.push(animation); - - // If there are no animations queued, manually kickstart a digest, for l= ack of a better word - if (animations.length =3D=3D=3D 1) { - this.requestAnimationFrame(); - } - }, - - cancelAnimation: function(chart) { - var index =3D helpers$1.findIndex(this.animations, function(animation) { - return animation.chart =3D=3D=3D chart; - }); - - if (index !=3D=3D -1) { - this.animations.splice(index, 1); - chart.animating =3D false; - } - }, - - requestAnimationFrame: function() { - var me =3D this; - if (me.request =3D=3D=3D null) { - // Skip animation frame requests until the active one is executed. - // This can happen when processing mouse events, e.g. 'mousemove' - // and 'mouseout' events will trigger multiple renders. - me.request =3D helpers$1.requestAnimFrame.call(window, function() { - me.request =3D null; - me.startDigest(); - }); - } - }, - - /** - * @private - */ - startDigest: function() { - var me =3D this; - - me.advance(); - - // Do we have more stuff to animate? - if (me.animations.length > 0) { - me.requestAnimationFrame(); - } - }, - - /** - * @private - */ - advance: function() { - var animations =3D this.animations; - var animation, chart, numSteps, nextStep; - var i =3D 0; - - // 1 animation per chart, so we are looping charts here - while (i < animations.length) { - animation =3D animations[i]; - chart =3D animation.chart; - numSteps =3D animation.numSteps; - - // Make sure that currentStep starts at 1 - // https://github.com/chartjs/Chart.js/issues/6104 - nextStep =3D Math.floor((Date.now() - animation.startTime) / animation.= duration * numSteps) + 1; - animation.currentStep =3D Math.min(nextStep, numSteps); - - helpers$1.callback(animation.render, [chart, animation], chart); - helpers$1.callback(animation.onAnimationProgress, [animation], chart); - - if (animation.currentStep >=3D numSteps) { - helpers$1.callback(animation.onAnimationComplete, [animation], chart); - chart.animating =3D false; - animations.splice(i, 1); - } else { - ++i; - } - } - } -}; - -var resolve =3D helpers$1.options.resolve; - -var arrayEvents =3D ['push', 'pop', 'shift', 'splice', 'unshift']; - -/** - * Hooks the array methods that add or remove values ('push', pop', 'shift= ', 'splice', - * 'unshift') and notify the listener AFTER the array has been altered. Li= steners are - * called on the 'onData*' callbacks (e.g. onDataPush, etc.) with same arg= uments. - */ -function listenArrayEvents(array, listener) { - if (array._chartjs) { - array._chartjs.listeners.push(listener); - return; - } - - Object.defineProperty(array, '_chartjs', { - configurable: true, - enumerable: false, - value: { - listeners: [listener] - } - }); - - arrayEvents.forEach(function(key) { - var method =3D 'onData' + key.charAt(0).toUpperCase() + key.slice(1); - var base =3D array[key]; - - Object.defineProperty(array, key, { - configurable: true, - enumerable: false, - value: function() { - var args =3D Array.prototype.slice.call(arguments); - var res =3D base.apply(this, args); - - helpers$1.each(array._chartjs.listeners, function(object) { - if (typeof object[method] =3D=3D=3D 'function') { - object[method].apply(object, args); - } - }); - - return res; - } - }); - }); -} - -/** - * Removes the given array event listener and cleanup extra attached prope= rties (such as - * the _chartjs stub and overridden methods) if array doesn't have any mor= e listeners. - */ -function unlistenArrayEvents(array, listener) { - var stub =3D array._chartjs; - if (!stub) { - return; - } - - var listeners =3D stub.listeners; - var index =3D listeners.indexOf(listener); - if (index !=3D=3D -1) { - listeners.splice(index, 1); - } - - if (listeners.length > 0) { - return; - } - - arrayEvents.forEach(function(key) { - delete array[key]; - }); - - delete array._chartjs; -} - -// Base class for all dataset controllers (line, bar, etc) -var DatasetController =3D function(chart, datasetIndex) { - this.initialize(chart, datasetIndex); -}; - -helpers$1.extend(DatasetController.prototype, { - - /** - * Element type used to generate a meta dataset (e.g. Chart.element.Line). - * @type {Chart.core.element} - */ - datasetElementType: null, - - /** - * Element type used to generate a meta data (e.g. Chart.element.Point). - * @type {Chart.core.element} - */ - dataElementType: null, - - /** - * Dataset element option keys to be resolved in _resolveDatasetElementOp= tions. - * A derived controller may override this to resolve controller-specific = options. - * The keys defined here are for backward compatibility for legend styles. - * @private - */ - _datasetElementOptions: [ - 'backgroundColor', - 'borderCapStyle', - 'borderColor', - 'borderDash', - 'borderDashOffset', - 'borderJoinStyle', - 'borderWidth' - ], - - /** - * Data element option keys to be resolved in _resolveDataElementOptions. - * A derived controller may override this to resolve controller-specific = options. - * The keys defined here are for backward compatibility for legend styles. - * @private - */ - _dataElementOptions: [ - 'backgroundColor', - 'borderColor', - 'borderWidth', - 'pointStyle' - ], - - initialize: function(chart, datasetIndex) { - var me =3D this; - me.chart =3D chart; - me.index =3D datasetIndex; - me.linkScales(); - me.addElements(); - me._type =3D me.getMeta().type; - }, - - updateIndex: function(datasetIndex) { - this.index =3D datasetIndex; - }, - - linkScales: function() { - var me =3D this; - var meta =3D me.getMeta(); - var chart =3D me.chart; - var scales =3D chart.scales; - var dataset =3D me.getDataset(); - var scalesOpts =3D chart.options.scales; - - if (meta.xAxisID =3D=3D=3D null || !(meta.xAxisID in scales) || dataset.= xAxisID) { - meta.xAxisID =3D dataset.xAxisID || scalesOpts.xAxes[0].id; - } - if (meta.yAxisID =3D=3D=3D null || !(meta.yAxisID in scales) || dataset.= yAxisID) { - meta.yAxisID =3D dataset.yAxisID || scalesOpts.yAxes[0].id; - } - }, - - getDataset: function() { - return this.chart.data.datasets[this.index]; - }, - - getMeta: function() { - return this.chart.getDatasetMeta(this.index); - }, - - getScaleForId: function(scaleID) { - return this.chart.scales[scaleID]; - }, - - /** - * @private - */ - _getValueScaleId: function() { - return this.getMeta().yAxisID; - }, - - /** - * @private - */ - _getIndexScaleId: function() { - return this.getMeta().xAxisID; - }, - - /** - * @private - */ - _getValueScale: function() { - return this.getScaleForId(this._getValueScaleId()); - }, - - /** - * @private - */ - _getIndexScale: function() { - return this.getScaleForId(this._getIndexScaleId()); - }, - - reset: function() { - this._update(true); - }, - - /** - * @private - */ - destroy: function() { - if (this._data) { - unlistenArrayEvents(this._data, this); - } - }, - - createMetaDataset: function() { - var me =3D this; - var type =3D me.datasetElementType; - return type && new type({ - _chart: me.chart, - _datasetIndex: me.index - }); - }, - - createMetaData: function(index) { - var me =3D this; - var type =3D me.dataElementType; - return type && new type({ - _chart: me.chart, - _datasetIndex: me.index, - _index: index - }); - }, - - addElements: function() { - var me =3D this; - var meta =3D me.getMeta(); - var data =3D me.getDataset().data || []; - var metaData =3D meta.data; - var i, ilen; - - for (i =3D 0, ilen =3D data.length; i < ilen; ++i) { - metaData[i] =3D metaData[i] || me.createMetaData(i); - } - - meta.dataset =3D meta.dataset || me.createMetaDataset(); - }, - - addElementAndReset: function(index) { - var element =3D this.createMetaData(index); - this.getMeta().data.splice(index, 0, element); - this.updateElement(element, index, true); - }, - - buildOrUpdateElements: function() { - var me =3D this; - var dataset =3D me.getDataset(); - var data =3D dataset.data || (dataset.data =3D []); - - // In order to correctly handle data addition/deletion animation (an thu= s simulate - // real-time charts), we need to monitor these data modifications and sy= nchronize - // the internal meta data accordingly. - if (me._data !=3D=3D data) { - if (me._data) { - // This case happens when the user replaced the data array instance. - unlistenArrayEvents(me._data, me); - } - - if (data && Object.isExtensible(data)) { - listenArrayEvents(data, me); - } - me._data =3D data; - } - - // Re-sync meta data in case the user replaced the data array or if we m= issed - // any updates and so make sure that we handle number of datapoints chan= ging. - me.resyncElements(); - }, - - /** - * Returns the merged user-supplied and default dataset-level options - * @private - */ - _configure: function() { - var me =3D this; - me._config =3D helpers$1.merge({}, [ - me.chart.options.datasets[me._type], - me.getDataset(), - ], { - merger: function(key, target, source) { - if (key !=3D=3D '_meta' && key !=3D=3D 'data') { - helpers$1._merger(key, target, source); - } - } - }); - }, - - _update: function(reset) { - var me =3D this; - me._configure(); - me._cachedDataOpts =3D null; - me.update(reset); - }, - - update: helpers$1.noop, - - transition: function(easingValue) { - var meta =3D this.getMeta(); - var elements =3D meta.data || []; - var ilen =3D elements.length; - var i =3D 0; - - for (; i < ilen; ++i) { - elements[i].transition(easingValue); - } - - if (meta.dataset) { - meta.dataset.transition(easingValue); - } - }, - - draw: function() { - var meta =3D this.getMeta(); - var elements =3D meta.data || []; - var ilen =3D elements.length; - var i =3D 0; - - if (meta.dataset) { - meta.dataset.draw(); - } - - for (; i < ilen; ++i) { - elements[i].draw(); - } - }, - - /** - * Returns a set of predefined style properties that should be used to re= present the dataset - * or the data if the index is specified - * @param {number} index - data index - * @return {IStyleInterface} style object - */ - getStyle: function(index) { - var me =3D this; - var meta =3D me.getMeta(); - var dataset =3D meta.dataset; - var style; - - me._configure(); - if (dataset && index =3D=3D=3D undefined) { - style =3D me._resolveDatasetElementOptions(dataset || {}); - } else { - index =3D index || 0; - style =3D me._resolveDataElementOptions(meta.data[index] || {}, index); - } - - if (style.fill =3D=3D=3D false || style.fill =3D=3D=3D null) { - style.backgroundColor =3D style.borderColor; - } - - return style; - }, - - /** - * @private - */ - _resolveDatasetElementOptions: function(element, hover) { - var me =3D this; - var chart =3D me.chart; - var datasetOpts =3D me._config; - var custom =3D element.custom || {}; - var options =3D chart.options.elements[me.datasetElementType.prototype._= type] || {}; - var elementOptions =3D me._datasetElementOptions; - var values =3D {}; - var i, ilen, key, readKey; - - // Scriptable options - var context =3D { - chart: chart, - dataset: me.getDataset(), - datasetIndex: me.index, - hover: hover - }; - - for (i =3D 0, ilen =3D elementOptions.length; i < ilen; ++i) { - key =3D elementOptions[i]; - readKey =3D hover ? 'hover' + key.charAt(0).toUpperCase() + key.slice(1= ) : key; - values[key] =3D resolve([ - custom[readKey], - datasetOpts[readKey], - options[readKey] - ], context); - } - - return values; - }, - - /** - * @private - */ - _resolveDataElementOptions: function(element, index) { - var me =3D this; - var custom =3D element && element.custom; - var cached =3D me._cachedDataOpts; - if (cached && !custom) { - return cached; - } - var chart =3D me.chart; - var datasetOpts =3D me._config; - var options =3D chart.options.elements[me.dataElementType.prototype._typ= e] || {}; - var elementOptions =3D me._dataElementOptions; - var values =3D {}; - - // Scriptable options - var context =3D { - chart: chart, - dataIndex: index, - dataset: me.getDataset(), - datasetIndex: me.index - }; - - // `resolve` sets cacheable to `false` if any option is indexed or scrip= ted - var info =3D {cacheable: !custom}; - - var keys, i, ilen, key; - - custom =3D custom || {}; - - if (helpers$1.isArray(elementOptions)) { - for (i =3D 0, ilen =3D elementOptions.length; i < ilen; ++i) { - key =3D elementOptions[i]; - values[key] =3D resolve([ - custom[key], - datasetOpts[key], - options[key] - ], context, index, info); - } - } else { - keys =3D Object.keys(elementOptions); - for (i =3D 0, ilen =3D keys.length; i < ilen; ++i) { - key =3D keys[i]; - values[key] =3D resolve([ - custom[key], - datasetOpts[elementOptions[key]], - datasetOpts[key], - options[key] - ], context, index, info); - } - } - - if (info.cacheable) { - me._cachedDataOpts =3D Object.freeze(values); - } - - return values; - }, - - removeHoverStyle: function(element) { - helpers$1.merge(element._model, element.$previousStyle || {}); - delete element.$previousStyle; - }, - - setHoverStyle: function(element) { - var dataset =3D this.chart.data.datasets[element._datasetIndex]; - var index =3D element._index; - var custom =3D element.custom || {}; - var model =3D element._model; - var getHoverColor =3D helpers$1.getHoverColor; - - element.$previousStyle =3D { - backgroundColor: model.backgroundColor, - borderColor: model.borderColor, - borderWidth: model.borderWidth - }; - - model.backgroundColor =3D resolve([custom.hoverBackgroundColor, dataset.= hoverBackgroundColor, getHoverColor(model.backgroundColor)], undefined, ind= ex); - model.borderColor =3D resolve([custom.hoverBorderColor, dataset.hoverBor= derColor, getHoverColor(model.borderColor)], undefined, index); - model.borderWidth =3D resolve([custom.hoverBorderWidth, dataset.hoverBor= derWidth, model.borderWidth], undefined, index); - }, - - /** - * @private - */ - _removeDatasetHoverStyle: function() { - var element =3D this.getMeta().dataset; - - if (element) { - this.removeHoverStyle(element); - } - }, - - /** - * @private - */ - _setDatasetHoverStyle: function() { - var element =3D this.getMeta().dataset; - var prev =3D {}; - var i, ilen, key, keys, hoverOptions, model; - - if (!element) { - return; - } - - model =3D element._model; - hoverOptions =3D this._resolveDatasetElementOptions(element, true); - - keys =3D Object.keys(hoverOptions); - for (i =3D 0, ilen =3D keys.length; i < ilen; ++i) { - key =3D keys[i]; - prev[key] =3D model[key]; - model[key] =3D hoverOptions[key]; - } - - element.$previousStyle =3D prev; - }, - - /** - * @private - */ - resyncElements: function() { - var me =3D this; - var meta =3D me.getMeta(); - var data =3D me.getDataset().data; - var numMeta =3D meta.data.length; - var numData =3D data.length; - - if (numData < numMeta) { - meta.data.splice(numData, numMeta - numData); - } else if (numData > numMeta) { - me.insertElements(numMeta, numData - numMeta); - } - }, - - /** - * @private - */ - insertElements: function(start, count) { - for (var i =3D 0; i < count; ++i) { - this.addElementAndReset(start + i); - } - }, - - /** - * @private - */ - onDataPush: function() { - var count =3D arguments.length; - this.insertElements(this.getDataset().data.length - count, count); - }, - - /** - * @private - */ - onDataPop: function() { - this.getMeta().data.pop(); - }, - - /** - * @private - */ - onDataShift: function() { - this.getMeta().data.shift(); - }, - - /** - * @private - */ - onDataSplice: function(start, count) { - this.getMeta().data.splice(start, count); - this.insertElements(start, arguments.length - 2); - }, - - /** - * @private - */ - onDataUnshift: function() { - this.insertElements(0, arguments.length); - } -}); - -DatasetController.extend =3D helpers$1.inherits; - -var core_datasetController =3D DatasetController; - -var TAU =3D Math.PI * 2; - -core_defaults._set('global', { - elements: { - arc: { - backgroundColor: core_defaults.global.defaultColor, - borderColor: '#fff', - borderWidth: 2, - borderAlign: 'center' - } - } -}); - -function clipArc(ctx, arc) { - var startAngle =3D arc.startAngle; - var endAngle =3D arc.endAngle; - var pixelMargin =3D arc.pixelMargin; - var angleMargin =3D pixelMargin / arc.outerRadius; - var x =3D arc.x; - var y =3D arc.y; - - // Draw an inner border by cliping the arc and drawing a double-width bor= der - // Enlarge the clipping arc by 0.33 pixels to eliminate glitches between = borders - ctx.beginPath(); - ctx.arc(x, y, arc.outerRadius, startAngle - angleMargin, endAngle + angle= Margin); - if (arc.innerRadius > pixelMargin) { - angleMargin =3D pixelMargin / arc.innerRadius; - ctx.arc(x, y, arc.innerRadius - pixelMargin, endAngle + angleMargin, sta= rtAngle - angleMargin, true); - } else { - ctx.arc(x, y, pixelMargin, endAngle + Math.PI / 2, startAngle - Math.PI = / 2); - } - ctx.closePath(); - ctx.clip(); -} - -function drawFullCircleBorders(ctx, vm, arc, inner) { - var endAngle =3D arc.endAngle; - var i; - - if (inner) { - arc.endAngle =3D arc.startAngle + TAU; - clipArc(ctx, arc); - arc.endAngle =3D endAngle; - if (arc.endAngle =3D=3D=3D arc.startAngle && arc.fullCircles) { - arc.endAngle +=3D TAU; - arc.fullCircles--; - } - } - - ctx.beginPath(); - ctx.arc(arc.x, arc.y, arc.innerRadius, arc.startAngle + TAU, arc.startAng= le, true); - for (i =3D 0; i < arc.fullCircles; ++i) { - ctx.stroke(); - } - - ctx.beginPath(); - ctx.arc(arc.x, arc.y, vm.outerRadius, arc.startAngle, arc.startAngle + TA= U); - for (i =3D 0; i < arc.fullCircles; ++i) { - ctx.stroke(); - } -} - -function drawBorder(ctx, vm, arc) { - var inner =3D vm.borderAlign =3D=3D=3D 'inner'; - - if (inner) { - ctx.lineWidth =3D vm.borderWidth * 2; - ctx.lineJoin =3D 'round'; - } else { - ctx.lineWidth =3D vm.borderWidth; - ctx.lineJoin =3D 'bevel'; - } - - if (arc.fullCircles) { - drawFullCircleBorders(ctx, vm, arc, inner); - } - - if (inner) { - clipArc(ctx, arc); - } - - ctx.beginPath(); - ctx.arc(arc.x, arc.y, vm.outerRadius, arc.startAngle, arc.endAngle); - ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true= ); - ctx.closePath(); - ctx.stroke(); -} - -var element_arc =3D core_element.extend({ - _type: 'arc', - - inLabelRange: function(mouseX) { - var vm =3D this._view; - - if (vm) { - return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadiu= s, 2)); - } - return false; - }, - - inRange: function(chartX, chartY) { - var vm =3D this._view; - - if (vm) { - var pointRelativePosition =3D helpers$1.getAngleFromPoint(vm, {x: chart= X, y: chartY}); - var angle =3D pointRelativePosition.angle; - var distance =3D pointRelativePosition.distance; - - // Sanitise angle range - var startAngle =3D vm.startAngle; - var endAngle =3D vm.endAngle; - while (endAngle < startAngle) { - endAngle +=3D TAU; - } - while (angle > endAngle) { - angle -=3D TAU; - } - while (angle < startAngle) { - angle +=3D TAU; - } - - // Check if within the range of the open/close angle - var betweenAngles =3D (angle >=3D startAngle && angle <=3D endAngle); - var withinRadius =3D (distance >=3D vm.innerRadius && distance <=3D vm.= outerRadius); - - return (betweenAngles && withinRadius); - } - return false; - }, - - getCenterPoint: function() { - var vm =3D this._view; - var halfAngle =3D (vm.startAngle + vm.endAngle) / 2; - var halfRadius =3D (vm.innerRadius + vm.outerRadius) / 2; - return { - x: vm.x + Math.cos(halfAngle) * halfRadius, - y: vm.y + Math.sin(halfAngle) * halfRadius - }; - }, - - getArea: function() { - var vm =3D this._view; - return Math.PI * ((vm.endAngle - vm.startAngle) / (2 * Math.PI)) * (Math= .pow(vm.outerRadius, 2) - Math.pow(vm.innerRadius, 2)); - }, - - tooltipPosition: function() { - var vm =3D this._view; - var centreAngle =3D vm.startAngle + ((vm.endAngle - vm.startAngle) / 2); - var rangeFromCentre =3D (vm.outerRadius - vm.innerRadius) / 2 + vm.inner= Radius; - - return { - x: vm.x + (Math.cos(centreAngle) * rangeFromCentre), - y: vm.y + (Math.sin(centreAngle) * rangeFromCentre) - }; - }, - - draw: function() { - var ctx =3D this._chart.ctx; - var vm =3D this._view; - var pixelMargin =3D (vm.borderAlign =3D=3D=3D 'inner') ? 0.33 : 0; - var arc =3D { - x: vm.x, - y: vm.y, - innerRadius: vm.innerRadius, - outerRadius: Math.max(vm.outerRadius - pixelMargin, 0), - pixelMargin: pixelMargin, - startAngle: vm.startAngle, - endAngle: vm.endAngle, - fullCircles: Math.floor(vm.circumference / TAU) - }; - var i; - - ctx.save(); - - ctx.fillStyle =3D vm.backgroundColor; - ctx.strokeStyle =3D vm.borderColor; - - if (arc.fullCircles) { - arc.endAngle =3D arc.startAngle + TAU; - ctx.beginPath(); - ctx.arc(arc.x, arc.y, arc.outerRadius, arc.startAngle, arc.endAngle); - ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, tr= ue); - ctx.closePath(); - for (i =3D 0; i < arc.fullCircles; ++i) { - ctx.fill(); - } - arc.endAngle =3D arc.startAngle + vm.circumference % TAU; - } - - ctx.beginPath(); - ctx.arc(arc.x, arc.y, arc.outerRadius, arc.startAngle, arc.endAngle); - ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, tru= e); - ctx.closePath(); - ctx.fill(); - - if (vm.borderWidth) { - drawBorder(ctx, vm, arc); - } - - ctx.restore(); - } -}); - -var valueOrDefault$1 =3D helpers$1.valueOrDefault; - -var defaultColor =3D core_defaults.global.defaultColor; - -core_defaults._set('global', { - elements: { - line: { - tension: 0.4, - backgroundColor: defaultColor, - borderWidth: 3, - borderColor: defaultColor, - borderCapStyle: 'butt', - borderDash: [], - borderDashOffset: 0.0, - borderJoinStyle: 'miter', - capBezierPoints: true, - fill: true, // do we fill in the area between the line and its base axis - } - } -}); - -var element_line =3D core_element.extend({ - _type: 'line', - - draw: function() { - var me =3D this; - var vm =3D me._view; - var ctx =3D me._chart.ctx; - var spanGaps =3D vm.spanGaps; - var points =3D me._children.slice(); // clone array - var globalDefaults =3D core_defaults.global; - var globalOptionLineElements =3D globalDefaults.elements.line; - var lastDrawnIndex =3D -1; - var closePath =3D me._loop; - var index, previous, currentVM; - - if (!points.length) { - return; - } - - if (me._loop) { - for (index =3D 0; index < points.length; ++index) { - previous =3D helpers$1.previousItem(points, index); - // If the line has an open path, shift the point array - if (!points[index]._view.skip && previous._view.skip) { - points =3D points.slice(index).concat(points.slice(0, index)); - closePath =3D spanGaps; - break; - } - } - // If the line has a close path, add the first point again - if (closePath) { - points.push(points[0]); - } - } - - ctx.save(); - - // Stroke Line Options - ctx.lineCap =3D vm.borderCapStyle || globalOptionLineElements.borderCapS= tyle; - - // IE 9 and 10 do not support line dash - if (ctx.setLineDash) { - ctx.setLineDash(vm.borderDash || globalOptionLineElements.borderDash); - } - - ctx.lineDashOffset =3D valueOrDefault$1(vm.borderDashOffset, globalOptio= nLineElements.borderDashOffset); - ctx.lineJoin =3D vm.borderJoinStyle || globalOptionLineElements.borderJo= inStyle; - ctx.lineWidth =3D valueOrDefault$1(vm.borderWidth, globalOptionLineEleme= nts.borderWidth); - ctx.strokeStyle =3D vm.borderColor || globalDefaults.defaultColor; - - // Stroke Line - ctx.beginPath(); - - // First point moves to it's starting position no matter what - currentVM =3D points[0]._view; - if (!currentVM.skip) { - ctx.moveTo(currentVM.x, currentVM.y); - lastDrawnIndex =3D 0; - } - - for (index =3D 1; index < points.length; ++index) { - currentVM =3D points[index]._view; - previous =3D lastDrawnIndex =3D=3D=3D -1 ? helpers$1.previousItem(point= s, index) : points[lastDrawnIndex]; - - if (!currentVM.skip) { - if ((lastDrawnIndex !=3D=3D (index - 1) && !spanGaps) || lastDrawnInde= x =3D=3D=3D -1) { - // There was a gap and this is the first point after the gap - ctx.moveTo(currentVM.x, currentVM.y); - } else { - // Line to next point - helpers$1.canvas.lineTo(ctx, previous._view, currentVM); - } - lastDrawnIndex =3D index; - } - } - - if (closePath) { - ctx.closePath(); - } - - ctx.stroke(); - ctx.restore(); - } -}); - -var valueOrDefault$2 =3D helpers$1.valueOrDefault; - -var defaultColor$1 =3D core_defaults.global.defaultColor; - -core_defaults._set('global', { - elements: { - point: { - radius: 3, - pointStyle: 'circle', - backgroundColor: defaultColor$1, - borderColor: defaultColor$1, - borderWidth: 1, - // Hover - hitRadius: 1, - hoverRadius: 4, - hoverBorderWidth: 1 - } - } -}); - -function xRange(mouseX) { - var vm =3D this._view; - return vm ? (Math.abs(mouseX - vm.x) < vm.radius + vm.hitRadius) : false; -} - -function yRange(mouseY) { - var vm =3D this._view; - return vm ? (Math.abs(mouseY - vm.y) < vm.radius + vm.hitRadius) : false; -} - -var element_point =3D core_element.extend({ - _type: 'point', - - inRange: function(mouseX, mouseY) { - var vm =3D this._view; - return vm ? ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) <= Math.pow(vm.hitRadius + vm.radius, 2)) : false; - }, - - inLabelRange: xRange, - inXRange: xRange, - inYRange: yRange, - - getCenterPoint: function() { - var vm =3D this._view; - return { - x: vm.x, - y: vm.y - }; - }, - - getArea: function() { - return Math.PI * Math.pow(this._view.radius, 2); - }, - - tooltipPosition: function() { - var vm =3D this._view; - return { - x: vm.x, - y: vm.y, - padding: vm.radius + vm.borderWidth - }; - }, - - draw: function(chartArea) { - var vm =3D this._view; - var ctx =3D this._chart.ctx; - var pointStyle =3D vm.pointStyle; - var rotation =3D vm.rotation; - var radius =3D vm.radius; - var x =3D vm.x; - var y =3D vm.y; - var globalDefaults =3D core_defaults.global; - var defaultColor =3D globalDefaults.defaultColor; // eslint-disable-line= no-shadow - - if (vm.skip) { - return; - } - - // Clipping for Points. - if (chartArea =3D=3D=3D undefined || helpers$1.canvas._isPointInArea(vm,= chartArea)) { - ctx.strokeStyle =3D vm.borderColor || defaultColor; - ctx.lineWidth =3D valueOrDefault$2(vm.borderWidth, globalDefaults.eleme= nts.point.borderWidth); - ctx.fillStyle =3D vm.backgroundColor || defaultColor; - helpers$1.canvas.drawPoint(ctx, pointStyle, radius, x, y, rotation); - } - } -}); - -var defaultColor$2 =3D core_defaults.global.defaultColor; - -core_defaults._set('global', { - elements: { - rectangle: { - backgroundColor: defaultColor$2, - borderColor: defaultColor$2, - borderSkipped: 'bottom', - borderWidth: 0 - } - } -}); - -function isVertical(vm) { - return vm && vm.width !=3D=3D undefined; -} - -/** - * Helper function to get the bounds of the bar regardless of the orientat= ion - * @param bar {Chart.Element.Rectangle} the bar - * @return {Bounds} bounds of the bar - * @private - */ -function getBarBounds(vm) { - var x1, x2, y1, y2, half; - - if (isVertical(vm)) { - half =3D vm.width / 2; - x1 =3D vm.x - half; - x2 =3D vm.x + half; - y1 =3D Math.min(vm.y, vm.base); - y2 =3D Math.max(vm.y, vm.base); - } else { - half =3D vm.height / 2; - x1 =3D Math.min(vm.x, vm.base); - x2 =3D Math.max(vm.x, vm.base); - y1 =3D vm.y - half; - y2 =3D vm.y + half; - } - - return { - left: x1, - top: y1, - right: x2, - bottom: y2 - }; -} - -function swap(orig, v1, v2) { - return orig =3D=3D=3D v1 ? v2 : orig =3D=3D=3D v2 ? v1 : orig; -} - -function parseBorderSkipped(vm) { - var edge =3D vm.borderSkipped; - var res =3D {}; - - if (!edge) { - return res; - } - - if (vm.horizontal) { - if (vm.base > vm.x) { - edge =3D swap(edge, 'left', 'right'); - } - } else if (vm.base < vm.y) { - edge =3D swap(edge, 'bottom', 'top'); - } - - res[edge] =3D true; - return res; -} - -function parseBorderWidth(vm, maxW, maxH) { - var value =3D vm.borderWidth; - var skip =3D parseBorderSkipped(vm); - var t, r, b, l; - - if (helpers$1.isObject(value)) { - t =3D +value.top || 0; - r =3D +value.right || 0; - b =3D +value.bottom || 0; - l =3D +value.left || 0; - } else { - t =3D r =3D b =3D l =3D +value || 0; - } - - return { - t: skip.top || (t < 0) ? 0 : t > maxH ? maxH : t, - r: skip.right || (r < 0) ? 0 : r > maxW ? maxW : r, - b: skip.bottom || (b < 0) ? 0 : b > maxH ? maxH : b, - l: skip.left || (l < 0) ? 0 : l > maxW ? maxW : l - }; -} - -function boundingRects(vm) { - var bounds =3D getBarBounds(vm); - var width =3D bounds.right - bounds.left; - var height =3D bounds.bottom - bounds.top; - var border =3D parseBorderWidth(vm, width / 2, height / 2); - - return { - outer: { - x: bounds.left, - y: bounds.top, - w: width, - h: height - }, - inner: { - x: bounds.left + border.l, - y: bounds.top + border.t, - w: width - border.l - border.r, - h: height - border.t - border.b - } - }; -} - -function inRange(vm, x, y) { - var skipX =3D x =3D=3D=3D null; - var skipY =3D y =3D=3D=3D null; - var bounds =3D !vm || (skipX && skipY) ? false : getBarBounds(vm); - - return bounds - && (skipX || x >=3D bounds.left && x <=3D bounds.right) - && (skipY || y >=3D bounds.top && y <=3D bounds.bottom); -} - -var element_rectangle =3D core_element.extend({ - _type: 'rectangle', - - draw: function() { - var ctx =3D this._chart.ctx; - var vm =3D this._view; - var rects =3D boundingRects(vm); - var outer =3D rects.outer; - var inner =3D rects.inner; - - ctx.fillStyle =3D vm.backgroundColor; - ctx.fillRect(outer.x, outer.y, outer.w, outer.h); - - if (outer.w =3D=3D=3D inner.w && outer.h =3D=3D=3D inner.h) { - return; - } - - ctx.save(); - ctx.beginPath(); - ctx.rect(outer.x, outer.y, outer.w, outer.h); - ctx.clip(); - ctx.fillStyle =3D vm.borderColor; - ctx.rect(inner.x, inner.y, inner.w, inner.h); - ctx.fill('evenodd'); - ctx.restore(); - }, - - height: function() { - var vm =3D this._view; - return vm.base - vm.y; - }, - - inRange: function(mouseX, mouseY) { - return inRange(this._view, mouseX, mouseY); - }, - - inLabelRange: function(mouseX, mouseY) { - var vm =3D this._view; - return isVertical(vm) - ? inRange(vm, mouseX, null) - : inRange(vm, null, mouseY); - }, - - inXRange: function(mouseX) { - return inRange(this._view, mouseX, null); - }, - - inYRange: function(mouseY) { - return inRange(this._view, null, mouseY); - }, - - getCenterPoint: function() { - var vm =3D this._view; - var x, y; - if (isVertical(vm)) { - x =3D vm.x; - y =3D (vm.y + vm.base) / 2; - } else { - x =3D (vm.x + vm.base) / 2; - y =3D vm.y; - } - - return {x: x, y: y}; - }, - - getArea: function() { - var vm =3D this._view; - - return isVertical(vm) - ? vm.width * Math.abs(vm.y - vm.base) - : vm.height * Math.abs(vm.x - vm.base); - }, - - tooltipPosition: function() { - var vm =3D this._view; - return { - x: vm.x, - y: vm.y - }; - } -}); - -var elements =3D {}; -var Arc =3D element_arc; -var Line =3D element_line; -var Point =3D element_point; -var Rectangle =3D element_rectangle; -elements.Arc =3D Arc; -elements.Line =3D Line; -elements.Point =3D Point; -elements.Rectangle =3D Rectangle; - -var deprecated =3D helpers$1._deprecated; -var valueOrDefault$3 =3D helpers$1.valueOrDefault; - -core_defaults._set('bar', { - hover: { - mode: 'label' - }, - - scales: { - xAxes: [{ - type: 'category', - offset: true, - gridLines: { - offsetGridLines: true - } - }], - - yAxes: [{ - type: 'linear' - }] - } -}); - -core_defaults._set('global', { - datasets: { - bar: { - categoryPercentage: 0.8, - barPercentage: 0.9 - } - } -}); - -/** - * Computes the "optimal" sample size to maintain bars equally sized while= preventing overlap. - * @private - */ -function computeMinSampleSize(scale, pixels) { - var min =3D scale._length; - var prev, curr, i, ilen; - - for (i =3D 1, ilen =3D pixels.length; i < ilen; ++i) { - min =3D Math.min(min, Math.abs(pixels[i] - pixels[i - 1])); - } - - for (i =3D 0, ilen =3D scale.getTicks().length; i < ilen; ++i) { - curr =3D scale.getPixelForTick(i); - min =3D i > 0 ? Math.min(min, Math.abs(curr - prev)) : min; - prev =3D curr; - } - - return min; -} - -/** - * Computes an "ideal" category based on the absolute bar thickness or, if= undefined or null, - * uses the smallest interval (see computeMinSampleSize) that prevents bar= overlapping. This - * mode currently always generates bars equally sized (until we introduce = scriptable options?). - * @private - */ -function computeFitCategoryTraits(index, ruler, options) { - var thickness =3D options.barThickness; - var count =3D ruler.stackCount; - var curr =3D ruler.pixels[index]; - var min =3D helpers$1.isNullOrUndef(thickness) - ? computeMinSampleSize(ruler.scale, ruler.pixels) - : -1; - var size, ratio; - - if (helpers$1.isNullOrUndef(thickness)) { - size =3D min * options.categoryPercentage; - ratio =3D options.barPercentage; - } else { - // When bar thickness is enforced, category and bar percentages are igno= red. - // Note(SB): we could add support for relative bar thickness (e.g. barTh= ickness: '50%') - // and deprecate barPercentage since this value is ignored when thicknes= s is absolute. - size =3D thickness * count; - ratio =3D 1; - } - - return { - chunk: size / count, - ratio: ratio, - start: curr - (size / 2) - }; -} - -/** - * Computes an "optimal" category that globally arranges bars side by side= (no gap when - * percentage options are 1), based on the previous and following categori= es. This mode - * generates bars with different widths when data are not evenly spaced. - * @private - */ -function computeFlexCategoryTraits(index, ruler, options) { - var pixels =3D ruler.pixels; - var curr =3D pixels[index]; - var prev =3D index > 0 ? pixels[index - 1] : null; - var next =3D index < pixels.length - 1 ? pixels[index + 1] : null; - var percent =3D options.categoryPercentage; - var start, size; - - if (prev =3D=3D=3D null) { - // first data: its size is double based on the next point or, - // if it's also the last data, we use the scale size. - prev =3D curr - (next =3D=3D=3D null ? ruler.end - ruler.start : next - = curr); - } - - if (next =3D=3D=3D null) { - // last data: its size is also double based on the previous point. - next =3D curr + curr - prev; - } - - start =3D curr - (curr - Math.min(prev, next)) / 2 * percent; - size =3D Math.abs(next - prev) / 2 * percent; - - return { - chunk: size / ruler.stackCount, - ratio: options.barPercentage, - start: start - }; -} - -var controller_bar =3D core_datasetController.extend({ - - dataElementType: elements.Rectangle, - - /** - * @private - */ - _dataElementOptions: [ - 'backgroundColor', - 'borderColor', - 'borderSkipped', - 'borderWidth', - 'barPercentage', - 'barThickness', - 'categoryPercentage', - 'maxBarThickness', - 'minBarLength' - ], - - initialize: function() { - var me =3D this; - var meta, scaleOpts; - - core_datasetController.prototype.initialize.apply(me, arguments); - - meta =3D me.getMeta(); - meta.stack =3D me.getDataset().stack; - meta.bar =3D true; - - scaleOpts =3D me._getIndexScale().options; - deprecated('bar chart', scaleOpts.barPercentage, 'scales.[x/y]Axes.barPe= rcentage', 'dataset.barPercentage'); - deprecated('bar chart', scaleOpts.barThickness, 'scales.[x/y]Axes.barThi= ckness', 'dataset.barThickness'); - deprecated('bar chart', scaleOpts.categoryPercentage, 'scales.[x/y]Axes.= categoryPercentage', 'dataset.categoryPercentage'); - deprecated('bar chart', me._getValueScale().options.minBarLength, 'scale= s.[x/y]Axes.minBarLength', 'dataset.minBarLength'); - deprecated('bar chart', scaleOpts.maxBarThickness, 'scales.[x/y]Axes.max= BarThickness', 'dataset.maxBarThickness'); - }, - - update: function(reset) { - var me =3D this; - var rects =3D me.getMeta().data; - var i, ilen; - - me._ruler =3D me.getRuler(); - - for (i =3D 0, ilen =3D rects.length; i < ilen; ++i) { - me.updateElement(rects[i], i, reset); - } - }, - - updateElement: function(rectangle, index, reset) { - var me =3D this; - var meta =3D me.getMeta(); - var dataset =3D me.getDataset(); - var options =3D me._resolveDataElementOptions(rectangle, index); - - rectangle._xScale =3D me.getScaleForId(meta.xAxisID); - rectangle._yScale =3D me.getScaleForId(meta.yAxisID); - rectangle._datasetIndex =3D me.index; - rectangle._index =3D index; - rectangle._model =3D { - backgroundColor: options.backgroundColor, - borderColor: options.borderColor, - borderSkipped: options.borderSkipped, - borderWidth: options.borderWidth, - datasetLabel: dataset.label, - label: me.chart.data.labels[index] - }; - - if (helpers$1.isArray(dataset.data[index])) { - rectangle._model.borderSkipped =3D null; - } - - me._updateElementGeometry(rectangle, index, reset, options); - - rectangle.pivot(); - }, - - /** - * @private - */ - _updateElementGeometry: function(rectangle, index, reset, options) { - var me =3D this; - var model =3D rectangle._model; - var vscale =3D me._getValueScale(); - var base =3D vscale.getBasePixel(); - var horizontal =3D vscale.isHorizontal(); - var ruler =3D me._ruler || me.getRuler(); - var vpixels =3D me.calculateBarValuePixels(me.index, index, options); - var ipixels =3D me.calculateBarIndexPixels(me.index, index, ruler, optio= ns); - - model.horizontal =3D horizontal; - model.base =3D reset ? base : vpixels.base; - model.x =3D horizontal ? reset ? base : vpixels.head : ipixels.center; - model.y =3D horizontal ? ipixels.center : reset ? base : vpixels.head; - model.height =3D horizontal ? ipixels.size : undefined; - model.width =3D horizontal ? undefined : ipixels.size; - }, - - /** - * Returns the stacks based on groups and bar visibility. - * @param {number} [last] - The dataset index - * @returns {string[]} The list of stack IDs - * @private - */ - _getStacks: function(last) { - var me =3D this; - var scale =3D me._getIndexScale(); - var metasets =3D scale._getMatchingVisibleMetas(me._type); - var stacked =3D scale.options.stacked; - var ilen =3D metasets.length; - var stacks =3D []; - var i, meta; - - for (i =3D 0; i < ilen; ++i) { - meta =3D metasets[i]; - // stacked | meta.stack - // | found | not found | undefined - // false | x | x | x - // true | | x | - // undefined | | x | x - if (stacked =3D=3D=3D false || stacks.indexOf(meta.stack) =3D=3D=3D -1 = || - (stacked =3D=3D=3D undefined && meta.stack =3D=3D=3D undefined)) { - stacks.push(meta.stack); - } - if (meta.index =3D=3D=3D last) { - break; - } - } - - return stacks; - }, - - /** - * Returns the effective number of stacks based on groups and bar visibil= ity. - * @private - */ - getStackCount: function() { - return this._getStacks().length; - }, - - /** - * Returns the stack index for the given dataset based on groups and bar = visibility. - * @param {number} [datasetIndex] - The dataset index - * @param {string} [name] - The stack name to find - * @returns {number} The stack index - * @private - */ - getStackIndex: function(datasetIndex, name) { - var stacks =3D this._getStacks(datasetIndex); - var index =3D (name !=3D=3D undefined) - ? stacks.indexOf(name) - : -1; // indexOf returns -1 if element is not present - - return (index =3D=3D=3D -1) - ? stacks.length - 1 - : index; - }, - - /** - * @private - */ - getRuler: function() { - var me =3D this; - var scale =3D me._getIndexScale(); - var pixels =3D []; - var i, ilen; - - for (i =3D 0, ilen =3D me.getMeta().data.length; i < ilen; ++i) { - pixels.push(scale.getPixelForValue(null, i, me.index)); - } - - return { - pixels: pixels, - start: scale._startPixel, - end: scale._endPixel, - stackCount: me.getStackCount(), - scale: scale - }; - }, - - /** - * Note: pixel values are not clamped to the scale area. - * @private - */ - calculateBarValuePixels: function(datasetIndex, index, options) { - var me =3D this; - var chart =3D me.chart; - var scale =3D me._getValueScale(); - var isHorizontal =3D scale.isHorizontal(); - var datasets =3D chart.data.datasets; - var metasets =3D scale._getMatchingVisibleMetas(me._type); - var value =3D scale._parseValue(datasets[datasetIndex].data[index]); - var minBarLength =3D options.minBarLength; - var stacked =3D scale.options.stacked; - var stack =3D me.getMeta().stack; - var start =3D value.start =3D=3D=3D undefined ? 0 : value.max >=3D 0 && = value.min >=3D 0 ? value.min : value.max; - var length =3D value.start =3D=3D=3D undefined ? value.end : value.max >= =3D 0 && value.min >=3D 0 ? value.max - value.min : value.min - value.max; - var ilen =3D metasets.length; - var i, imeta, ivalue, base, head, size, stackLength; - - if (stacked || (stacked =3D=3D=3D undefined && stack !=3D=3D undefined))= { - for (i =3D 0; i < ilen; ++i) { - imeta =3D metasets[i]; - - if (imeta.index =3D=3D=3D datasetIndex) { - break; - } - - if (imeta.stack =3D=3D=3D stack) { - stackLength =3D scale._parseValue(datasets[imeta.index].data[index]); - ivalue =3D stackLength.start =3D=3D=3D undefined ? stackLength.end : = stackLength.min >=3D 0 && stackLength.max >=3D 0 ? stackLength.max : stackL= ength.min; - - if ((value.min < 0 && ivalue < 0) || (value.max >=3D 0 && ivalue > 0)= ) { - start +=3D ivalue; - } - } - } - } - - base =3D scale.getPixelForValue(start); - head =3D scale.getPixelForValue(start + length); - size =3D head - base; - - if (minBarLength !=3D=3D undefined && Math.abs(size) < minBarLength) { - size =3D minBarLength; - if (length >=3D 0 && !isHorizontal || length < 0 && isHorizontal) { - head =3D base - minBarLength; - } else { - head =3D base + minBarLength; - } - } - - return { - size: size, - base: base, - head: head, - center: head + size / 2 - }; - }, - - /** - * @private - */ - calculateBarIndexPixels: function(datasetIndex, index, ruler, options) { - var me =3D this; - var range =3D options.barThickness =3D=3D=3D 'flex' - ? computeFlexCategoryTraits(index, ruler, options) - : computeFitCategoryTraits(index, ruler, options); - - var stackIndex =3D me.getStackIndex(datasetIndex, me.getMeta().stack); - var center =3D range.start + (range.chunk * stackIndex) + (range.chunk /= 2); - var size =3D Math.min( - valueOrDefault$3(options.maxBarThickness, Infinity), - range.chunk * range.ratio); - - return { - base: center - size / 2, - head: center + size / 2, - center: center, - size: size - }; - }, - - draw: function() { - var me =3D this; - var chart =3D me.chart; - var scale =3D me._getValueScale(); - var rects =3D me.getMeta().data; - var dataset =3D me.getDataset(); - var ilen =3D rects.length; - var i =3D 0; - - helpers$1.canvas.clipArea(chart.ctx, chart.chartArea); - - for (; i < ilen; ++i) { - var val =3D scale._parseValue(dataset.data[i]); - if (!isNaN(val.min) && !isNaN(val.max)) { - rects[i].draw(); - } - } - - helpers$1.canvas.unclipArea(chart.ctx); - }, - - /** - * @private - */ - _resolveDataElementOptions: function() { - var me =3D this; - var values =3D helpers$1.extend({}, core_datasetController.prototype._re= solveDataElementOptions.apply(me, arguments)); - var indexOpts =3D me._getIndexScale().options; - var valueOpts =3D me._getValueScale().options; - - values.barPercentage =3D valueOrDefault$3(indexOpts.barPercentage, value= s.barPercentage); - values.barThickness =3D valueOrDefault$3(indexOpts.barThickness, values.= barThickness); - values.categoryPercentage =3D valueOrDefault$3(indexOpts.categoryPercent= age, values.categoryPercentage); - values.maxBarThickness =3D valueOrDefault$3(indexOpts.maxBarThickness, v= alues.maxBarThickness); - values.minBarLength =3D valueOrDefault$3(valueOpts.minBarLength, values.= minBarLength); - - return values; - } - -}); - -var valueOrDefault$4 =3D helpers$1.valueOrDefault; -var resolve$1 =3D helpers$1.options.resolve; - -core_defaults._set('bubble', { - hover: { - mode: 'single' - }, - - scales: { - xAxes: [{ - type: 'linear', // bubble should probably use a linear scale by default - position: 'bottom', - id: 'x-axis-0' // need an ID so datasets can reference the scale - }], - yAxes: [{ - type: 'linear', - position: 'left', - id: 'y-axis-0' - }] - }, - - tooltips: { - callbacks: { - title: function() { - // Title doesn't make sense for scatter since we format the data as a = point - return ''; - }, - label: function(item, data) { - var datasetLabel =3D data.datasets[item.datasetIndex].label || ''; - var dataPoint =3D data.datasets[item.datasetIndex].data[item.index]; - return datasetLabel + ': (' + item.xLabel + ', ' + item.yLabel + ', ' = + dataPoint.r + ')'; - } - } - } -}); - -var controller_bubble =3D core_datasetController.extend({ - /** - * @protected - */ - dataElementType: elements.Point, - - /** - * @private - */ - _dataElementOptions: [ - 'backgroundColor', - 'borderColor', - 'borderWidth', - 'hoverBackgroundColor', - 'hoverBorderColor', - 'hoverBorderWidth', - 'hoverRadius', - 'hitRadius', - 'pointStyle', - 'rotation' - ], - - /** - * @protected - */ - update: function(reset) { - var me =3D this; - var meta =3D me.getMeta(); - var points =3D meta.data; - - // Update Points - helpers$1.each(points, function(point, index) { - me.updateElement(point, index, reset); - }); - }, - - /** - * @protected - */ - updateElement: function(point, index, reset) { - var me =3D this; - var meta =3D me.getMeta(); - var custom =3D point.custom || {}; - var xScale =3D me.getScaleForId(meta.xAxisID); - var yScale =3D me.getScaleForId(meta.yAxisID); - var options =3D me._resolveDataElementOptions(point, index); - var data =3D me.getDataset().data[index]; - var dsIndex =3D me.index; - - var x =3D reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForVal= ue(typeof data =3D=3D=3D 'object' ? data : NaN, index, dsIndex); - var y =3D reset ? yScale.getBasePixel() : yScale.getPixelForValue(data, = index, dsIndex); - - point._xScale =3D xScale; - point._yScale =3D yScale; - point._options =3D options; - point._datasetIndex =3D dsIndex; - point._index =3D index; - point._model =3D { - backgroundColor: options.backgroundColor, - borderColor: options.borderColor, - borderWidth: options.borderWidth, - hitRadius: options.hitRadius, - pointStyle: options.pointStyle, - rotation: options.rotation, - radius: reset ? 0 : options.radius, - skip: custom.skip || isNaN(x) || isNaN(y), - x: x, - y: y, - }; - - point.pivot(); - }, - - /** - * @protected - */ - setHoverStyle: function(point) { - var model =3D point._model; - var options =3D point._options; - var getHoverColor =3D helpers$1.getHoverColor; - - point.$previousStyle =3D { - backgroundColor: model.backgroundColor, - borderColor: model.borderColor, - borderWidth: model.borderWidth, - radius: model.radius - }; - - model.backgroundColor =3D valueOrDefault$4(options.hoverBackgroundColor,= getHoverColor(options.backgroundColor)); - model.borderColor =3D valueOrDefault$4(options.hoverBorderColor, getHove= rColor(options.borderColor)); - model.borderWidth =3D valueOrDefault$4(options.hoverBorderWidth, options= .borderWidth); - model.radius =3D options.radius + options.hoverRadius; - }, - - /** - * @private - */ - _resolveDataElementOptions: function(point, index) { - var me =3D this; - var chart =3D me.chart; - var dataset =3D me.getDataset(); - var custom =3D point.custom || {}; - var data =3D dataset.data[index] || {}; - var values =3D core_datasetController.prototype._resolveDataElementOptio= ns.apply(me, arguments); - - // Scriptable options - var context =3D { - chart: chart, - dataIndex: index, - dataset: dataset, - datasetIndex: me.index - }; - - // In case values were cached (and thus frozen), we need to clone the va= lues - if (me._cachedDataOpts =3D=3D=3D values) { - values =3D helpers$1.extend({}, values); - } - - // Custom radius resolution - values.radius =3D resolve$1([ - custom.radius, - data.r, - me._config.radius, - chart.options.elements.point.radius - ], context, index); - - return values; - } -}); - -var valueOrDefault$5 =3D helpers$1.valueOrDefault; - -var PI$1 =3D Math.PI; -var DOUBLE_PI$1 =3D PI$1 * 2; -var HALF_PI$1 =3D PI$1 / 2; - -core_defaults._set('doughnut', { - animation: { - // Boolean - Whether we animate the rotation of the Doughnut - animateRotate: true, - // Boolean - Whether we animate scaling the Doughnut from the centre - animateScale: false - }, - hover: { - mode: 'single' - }, - legendCallback: function(chart) { - var list =3D document.createElement('ul'); - var data =3D chart.data; - var datasets =3D data.datasets; - var labels =3D data.labels; - var i, ilen, listItem, listItemSpan; - - list.setAttribute('class', chart.id + '-legend'); - if (datasets.length) { - for (i =3D 0, ilen =3D datasets[0].data.length; i < ilen; ++i) { - listItem =3D list.appendChild(document.createElement('li')); - listItemSpan =3D listItem.appendChild(document.createElement('span')); - listItemSpan.style.backgroundColor =3D datasets[0].backgroundColor[i]; - if (labels[i]) { - listItem.appendChild(document.createTextNode(labels[i])); - } - } - } - - return list.outerHTML; - }, - legend: { - labels: { - generateLabels: function(chart) { - var data =3D chart.data; - if (data.labels.length && data.datasets.length) { - return data.labels.map(function(label, i) { - var meta =3D chart.getDatasetMeta(0); - var style =3D meta.controller.getStyle(i); - - return { - text: label, - fillStyle: style.backgroundColor, - strokeStyle: style.borderColor, - lineWidth: style.borderWidth, - hidden: isNaN(data.datasets[0].data[i]) || meta.data[i].hidden, - - // Extra data used for toggling the correct item - index: i - }; - }); - } - return []; - } - }, - - onClick: function(e, legendItem) { - var index =3D legendItem.index; - var chart =3D this.chart; - var i, ilen, meta; - - for (i =3D 0, ilen =3D (chart.data.datasets || []).length; i < ilen; ++= i) { - meta =3D chart.getDatasetMeta(i); - // toggle visibility of index if exists - if (meta.data[index]) { - meta.data[index].hidden =3D !meta.data[index].hidden; - } - } - - chart.update(); - } - }, - - // The percentage of the chart that we cut out of the middle. - cutoutPercentage: 50, - - // The rotation of the chart, where the first data arc begins. - rotation: -HALF_PI$1, - - // The total circumference of the chart. - circumference: DOUBLE_PI$1, - - // Need to override these to give a nice default - tooltips: { - callbacks: { - title: function() { - return ''; - }, - label: function(tooltipItem, data) { - var dataLabel =3D data.labels[tooltipItem.index]; - var value =3D ': ' + data.datasets[tooltipItem.datasetIndex].data[tool= tipItem.index]; - - if (helpers$1.isArray(dataLabel)) { - // show value on first line of multiline label - // need to clone because we are changing the value - dataLabel =3D dataLabel.slice(); - dataLabel[0] +=3D value; - } else { - dataLabel +=3D value; - } - - return dataLabel; - } - } - } -}); - -var controller_doughnut =3D core_datasetController.extend({ - - dataElementType: elements.Arc, - - linkScales: helpers$1.noop, - - /** - * @private - */ - _dataElementOptions: [ - 'backgroundColor', - 'borderColor', - 'borderWidth', - 'borderAlign', - 'hoverBackgroundColor', - 'hoverBorderColor', - 'hoverBorderWidth', - ], - - // Get index of the dataset in relation to the visible datasets. This all= ows determining the inner and outer radius correctly - getRingIndex: function(datasetIndex) { - var ringIndex =3D 0; - - for (var j =3D 0; j < datasetIndex; ++j) { - if (this.chart.isDatasetVisible(j)) { - ++ringIndex; - } - } - - return ringIndex; - }, - - update: function(reset) { - var me =3D this; - var chart =3D me.chart; - var chartArea =3D chart.chartArea; - var opts =3D chart.options; - var ratioX =3D 1; - var ratioY =3D 1; - var offsetX =3D 0; - var offsetY =3D 0; - var meta =3D me.getMeta(); - var arcs =3D meta.data; - var cutout =3D opts.cutoutPercentage / 100 || 0; - var circumference =3D opts.circumference; - var chartWeight =3D me._getRingWeight(me.index); - var maxWidth, maxHeight, i, ilen; - - // If the chart's circumference isn't a full circle, calculate size as a= ratio of the width/height of the arc - if (circumference < DOUBLE_PI$1) { - var startAngle =3D opts.rotation % DOUBLE_PI$1; - startAngle +=3D startAngle >=3D PI$1 ? -DOUBLE_PI$1 : startAngle < -PI$= 1 ? DOUBLE_PI$1 : 0; - var endAngle =3D startAngle + circumference; - var startX =3D Math.cos(startAngle); - var startY =3D Math.sin(startAngle); - var endX =3D Math.cos(endAngle); - var endY =3D Math.sin(endAngle); - var contains0 =3D (startAngle <=3D 0 && endAngle >=3D 0) || endAngle >= =3D DOUBLE_PI$1; - var contains90 =3D (startAngle <=3D HALF_PI$1 && endAngle >=3D HALF_PI$= 1) || endAngle >=3D DOUBLE_PI$1 + HALF_PI$1; - var contains180 =3D startAngle =3D=3D=3D -PI$1 || endAngle >=3D PI$1; - var contains270 =3D (startAngle <=3D -HALF_PI$1 && endAngle >=3D -HALF_= PI$1) || endAngle >=3D PI$1 + HALF_PI$1; - var minX =3D contains180 ? -1 : Math.min(startX, startX * cutout, endX,= endX * cutout); - var minY =3D contains270 ? -1 : Math.min(startY, startY * cutout, endY,= endY * cutout); - var maxX =3D contains0 ? 1 : Math.max(startX, startX * cutout, endX, en= dX * cutout); - var maxY =3D contains90 ? 1 : Math.max(startY, startY * cutout, endY, e= ndY * cutout); - ratioX =3D (maxX - minX) / 2; - ratioY =3D (maxY - minY) / 2; - offsetX =3D -(maxX + minX) / 2; - offsetY =3D -(maxY + minY) / 2; - } - - for (i =3D 0, ilen =3D arcs.length; i < ilen; ++i) { - arcs[i]._options =3D me._resolveDataElementOptions(arcs[i], i); - } - - chart.borderWidth =3D me.getMaxBorderWidth(); - maxWidth =3D (chartArea.right - chartArea.left - chart.borderWidth) / ra= tioX; - maxHeight =3D (chartArea.bottom - chartArea.top - chart.borderWidth) / r= atioY; - chart.outerRadius =3D Math.max(Math.min(maxWidth, maxHeight) / 2, 0); - chart.innerRadius =3D Math.max(chart.outerRadius * cutout, 0); - chart.radiusLength =3D (chart.outerRadius - chart.innerRadius) / (me._ge= tVisibleDatasetWeightTotal() || 1); - chart.offsetX =3D offsetX * chart.outerRadius; - chart.offsetY =3D offsetY * chart.outerRadius; - - meta.total =3D me.calculateTotal(); - - me.outerRadius =3D chart.outerRadius - chart.radiusLength * me._getRingW= eightOffset(me.index); - me.innerRadius =3D Math.max(me.outerRadius - chart.radiusLength * chartW= eight, 0); - - for (i =3D 0, ilen =3D arcs.length; i < ilen; ++i) { - me.updateElement(arcs[i], i, reset); - } - }, - - updateElement: function(arc, index, reset) { - var me =3D this; - var chart =3D me.chart; - var chartArea =3D chart.chartArea; - var opts =3D chart.options; - var animationOpts =3D opts.animation; - var centerX =3D (chartArea.left + chartArea.right) / 2; - var centerY =3D (chartArea.top + chartArea.bottom) / 2; - var startAngle =3D opts.rotation; // non reset case handled later - var endAngle =3D opts.rotation; // non reset case handled later - var dataset =3D me.getDataset(); - var circumference =3D reset && animationOpts.animateRotate ? 0 : arc.hid= den ? 0 : me.calculateCircumference(dataset.data[index]) * (opts.circumfere= nce / DOUBLE_PI$1); - var innerRadius =3D reset && animationOpts.animateScale ? 0 : me.innerRa= dius; - var outerRadius =3D reset && animationOpts.animateScale ? 0 : me.outerRa= dius; - var options =3D arc._options || {}; - - helpers$1.extend(arc, { - // Utility - _datasetIndex: me.index, - _index: index, - - // Desired view properties - _model: { - backgroundColor: options.backgroundColor, - borderColor: options.borderColor, - borderWidth: options.borderWidth, - borderAlign: options.borderAlign, - x: centerX + chart.offsetX, - y: centerY + chart.offsetY, - startAngle: startAngle, - endAngle: endAngle, - circumference: circumference, - outerRadius: outerRadius, - innerRadius: innerRadius, - label: helpers$1.valueAtIndexOrDefault(dataset.label, index, chart.dat= a.labels[index]) - } - }); - - var model =3D arc._model; - - // Set correct angles if not resetting - if (!reset || !animationOpts.animateRotate) { - if (index =3D=3D=3D 0) { - model.startAngle =3D opts.rotation; - } else { - model.startAngle =3D me.getMeta().data[index - 1]._model.endAngle; - } - - model.endAngle =3D model.startAngle + model.circumference; - } - - arc.pivot(); - }, - - calculateTotal: function() { - var dataset =3D this.getDataset(); - var meta =3D this.getMeta(); - var total =3D 0; - var value; - - helpers$1.each(meta.data, function(element, index) { - value =3D dataset.data[index]; - if (!isNaN(value) && !element.hidden) { - total +=3D Math.abs(value); - } - }); - - /* if (total =3D=3D=3D 0) { - total =3D NaN; - }*/ - - return total; - }, - - calculateCircumference: function(value) { - var total =3D this.getMeta().total; - if (total > 0 && !isNaN(value)) { - return DOUBLE_PI$1 * (Math.abs(value) / total); - } - return 0; - }, - - // gets the max border or hover width to properly scale pie charts - getMaxBorderWidth: function(arcs) { - var me =3D this; - var max =3D 0; - var chart =3D me.chart; - var i, ilen, meta, arc, controller, options, borderWidth, hoverWidth; - - if (!arcs) { - // Find the outmost visible dataset - for (i =3D 0, ilen =3D chart.data.datasets.length; i < ilen; ++i) { - if (chart.isDatasetVisible(i)) { - meta =3D chart.getDatasetMeta(i); - arcs =3D meta.data; - if (i !=3D=3D me.index) { - controller =3D meta.controller; - } - break; - } - } - } - - if (!arcs) { - return 0; - } - - for (i =3D 0, ilen =3D arcs.length; i < ilen; ++i) { - arc =3D arcs[i]; - if (controller) { - controller._configure(); - options =3D controller._resolveDataElementOptions(arc, i); - } else { - options =3D arc._options; - } - if (options.borderAlign !=3D=3D 'inner') { - borderWidth =3D options.borderWidth; - hoverWidth =3D options.hoverBorderWidth; - - max =3D borderWidth > max ? borderWidth : max; - max =3D hoverWidth > max ? hoverWidth : max; - } - } - return max; - }, - - /** - * @protected - */ - setHoverStyle: function(arc) { - var model =3D arc._model; - var options =3D arc._options; - var getHoverColor =3D helpers$1.getHoverColor; - - arc.$previousStyle =3D { - backgroundColor: model.backgroundColor, - borderColor: model.borderColor, - borderWidth: model.borderWidth, - }; - - model.backgroundColor =3D valueOrDefault$5(options.hoverBackgroundColor,= getHoverColor(options.backgroundColor)); - model.borderColor =3D valueOrDefault$5(options.hoverBorderColor, getHove= rColor(options.borderColor)); - model.borderWidth =3D valueOrDefault$5(options.hoverBorderWidth, options= .borderWidth); - }, - - /** - * Get radius length offset of the dataset in relation to the visible dat= asets weights. This allows determining the inner and outer radius correctly - * @private - */ - _getRingWeightOffset: function(datasetIndex) { - var ringWeightOffset =3D 0; - - for (var i =3D 0; i < datasetIndex; ++i) { - if (this.chart.isDatasetVisible(i)) { - ringWeightOffset +=3D this._getRingWeight(i); - } - } - - return ringWeightOffset; - }, - - /** - * @private - */ - _getRingWeight: function(dataSetIndex) { - return Math.max(valueOrDefault$5(this.chart.data.datasets[dataSetIndex].= weight, 1), 0); - }, - - /** - * Returns the sum of all visibile data set weights. This value can be 0. - * @private - */ - _getVisibleDatasetWeightTotal: function() { - return this._getRingWeightOffset(this.chart.data.datasets.length); - } -}); - -core_defaults._set('horizontalBar', { - hover: { - mode: 'index', - axis: 'y' - }, - - scales: { - xAxes: [{ - type: 'linear', - position: 'bottom' - }], - - yAxes: [{ - type: 'category', - position: 'left', - offset: true, - gridLines: { - offsetGridLines: true - } - }] - }, - - elements: { - rectangle: { - borderSkipped: 'left' - } - }, - - tooltips: { - mode: 'index', - axis: 'y' - } -}); - -core_defaults._set('global', { - datasets: { - horizontalBar: { - categoryPercentage: 0.8, - barPercentage: 0.9 - } - } -}); - -var controller_horizontalBar =3D controller_bar.extend({ - /** - * @private - */ - _getValueScaleId: function() { - return this.getMeta().xAxisID; - }, - - /** - * @private - */ - _getIndexScaleId: function() { - return this.getMeta().yAxisID; - } -}); - -var valueOrDefault$6 =3D helpers$1.valueOrDefault; -var resolve$2 =3D helpers$1.options.resolve; -var isPointInArea =3D helpers$1.canvas._isPointInArea; - -core_defaults._set('line', { - showLines: true, - spanGaps: false, - - hover: { - mode: 'label' - }, - - scales: { - xAxes: [{ - type: 'category', - id: 'x-axis-0' - }], - yAxes: [{ - type: 'linear', - id: 'y-axis-0' - }] - } -}); - -function scaleClip(scale, halfBorderWidth) { - var tickOpts =3D scale && scale.options.ticks || {}; - var reverse =3D tickOpts.reverse; - var min =3D tickOpts.min =3D=3D=3D undefined ? halfBorderWidth : 0; - var max =3D tickOpts.max =3D=3D=3D undefined ? halfBorderWidth : 0; - return { - start: reverse ? max : min, - end: reverse ? min : max - }; -} - -function defaultClip(xScale, yScale, borderWidth) { - var halfBorderWidth =3D borderWidth / 2; - var x =3D scaleClip(xScale, halfBorderWidth); - var y =3D scaleClip(yScale, halfBorderWidth); - - return { - top: y.end, - right: x.end, - bottom: y.start, - left: x.start - }; -} - -function toClip(value) { - var t, r, b, l; - - if (helpers$1.isObject(value)) { - t =3D value.top; - r =3D value.right; - b =3D value.bottom; - l =3D value.left; - } else { - t =3D r =3D b =3D l =3D value; - } - - return { - top: t, - right: r, - bottom: b, - left: l - }; -} - - -var controller_line =3D core_datasetController.extend({ - - datasetElementType: elements.Line, - - dataElementType: elements.Point, - - /** - * @private - */ - _datasetElementOptions: [ - 'backgroundColor', - 'borderCapStyle', - 'borderColor', - 'borderDash', - 'borderDashOffset', - 'borderJoinStyle', - 'borderWidth', - 'cubicInterpolationMode', - 'fill' - ], - - /** - * @private - */ - _dataElementOptions: { - backgroundColor: 'pointBackgroundColor', - borderColor: 'pointBorderColor', - borderWidth: 'pointBorderWidth', - hitRadius: 'pointHitRadius', - hoverBackgroundColor: 'pointHoverBackgroundColor', - hoverBorderColor: 'pointHoverBorderColor', - hoverBorderWidth: 'pointHoverBorderWidth', - hoverRadius: 'pointHoverRadius', - pointStyle: 'pointStyle', - radius: 'pointRadius', - rotation: 'pointRotation' - }, - - update: function(reset) { - var me =3D this; - var meta =3D me.getMeta(); - var line =3D meta.dataset; - var points =3D meta.data || []; - var options =3D me.chart.options; - var config =3D me._config; - var showLine =3D me._showLine =3D valueOrDefault$6(config.showLine, opti= ons.showLines); - var i, ilen; - - me._xScale =3D me.getScaleForId(meta.xAxisID); - me._yScale =3D me.getScaleForId(meta.yAxisID); - - // Update Line - if (showLine) { - // Compatibility: If the properties are defined with only the old name,= use those values - if (config.tension !=3D=3D undefined && config.lineTension =3D=3D=3D un= defined) { - config.lineTension =3D config.tension; - } - - // Utility - line._scale =3D me._yScale; - line._datasetIndex =3D me.index; - // Data - line._children =3D points; - // Model - line._model =3D me._resolveDatasetElementOptions(line); - - line.pivot(); - } - - // Update Points - for (i =3D 0, ilen =3D points.length; i < ilen; ++i) { - me.updateElement(points[i], i, reset); - } - - if (showLine && line._model.tension !=3D=3D 0) { - me.updateBezierControlPoints(); - } - - // Now pivot the point for animation - for (i =3D 0, ilen =3D points.length; i < ilen; ++i) { - points[i].pivot(); - } - }, - - updateElement: function(point, index, reset) { - var me =3D this; - var meta =3D me.getMeta(); - var custom =3D point.custom || {}; - var dataset =3D me.getDataset(); - var datasetIndex =3D me.index; - var value =3D dataset.data[index]; - var xScale =3D me._xScale; - var yScale =3D me._yScale; - var lineModel =3D meta.dataset._model; - var x, y; - - var options =3D me._resolveDataElementOptions(point, index); - - x =3D xScale.getPixelForValue(typeof value =3D=3D=3D 'object' ? value : = NaN, index, datasetIndex); - y =3D reset ? yScale.getBasePixel() : me.calculatePointY(value, index, d= atasetIndex); - - // Utility - point._xScale =3D xScale; - point._yScale =3D yScale; - point._options =3D options; - point._datasetIndex =3D datasetIndex; - point._index =3D index; - - // Desired view properties - point._model =3D { - x: x, - y: y, - skip: custom.skip || isNaN(x) || isNaN(y), - // Appearance - radius: options.radius, - pointStyle: options.pointStyle, - rotation: options.rotation, - backgroundColor: options.backgroundColor, - borderColor: options.borderColor, - borderWidth: options.borderWidth, - tension: valueOrDefault$6(custom.tension, lineModel ? lineModel.tension= : 0), - steppedLine: lineModel ? lineModel.steppedLine : false, - // Tooltip - hitRadius: options.hitRadius - }; - }, - - /** - * @private - */ - _resolveDatasetElementOptions: function(element) { - var me =3D this; - var config =3D me._config; - var custom =3D element.custom || {}; - var options =3D me.chart.options; - var lineOptions =3D options.elements.line; - var values =3D core_datasetController.prototype._resolveDatasetElementOp= tions.apply(me, arguments); - - // The default behavior of lines is to break at null values, according - // to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-21671= 8158 - // This option gives lines the ability to span gaps - values.spanGaps =3D valueOrDefault$6(config.spanGaps, options.spanGaps); - values.tension =3D valueOrDefault$6(config.lineTension, lineOptions.tens= ion); - values.steppedLine =3D resolve$2([custom.steppedLine, config.steppedLine= , lineOptions.stepped]); - values.clip =3D toClip(valueOrDefault$6(config.clip, defaultClip(me._xSc= ale, me._yScale, values.borderWidth))); - - return values; - }, - - calculatePointY: function(value, index, datasetIndex) { - var me =3D this; - var chart =3D me.chart; - var yScale =3D me._yScale; - var sumPos =3D 0; - var sumNeg =3D 0; - var i, ds, dsMeta, stackedRightValue, rightValue, metasets, ilen; - - if (yScale.options.stacked) { - rightValue =3D +yScale.getRightValue(value); - metasets =3D chart._getSortedVisibleDatasetMetas(); - ilen =3D metasets.length; - - for (i =3D 0; i < ilen; ++i) { - dsMeta =3D metasets[i]; - if (dsMeta.index =3D=3D=3D datasetIndex) { - break; - } - - ds =3D chart.data.datasets[dsMeta.index]; - if (dsMeta.type =3D=3D=3D 'line' && dsMeta.yAxisID =3D=3D=3D yScale.id= ) { - stackedRightValue =3D +yScale.getRightValue(ds.data[index]); - if (stackedRightValue < 0) { - sumNeg +=3D stackedRightValue || 0; - } else { - sumPos +=3D stackedRightValue || 0; - } - } - } - - if (rightValue < 0) { - return yScale.getPixelForValue(sumNeg + rightValue); - } - return yScale.getPixelForValue(sumPos + rightValue); - } - return yScale.getPixelForValue(value); - }, - - updateBezierControlPoints: function() { - var me =3D this; - var chart =3D me.chart; - var meta =3D me.getMeta(); - var lineModel =3D meta.dataset._model; - var area =3D chart.chartArea; - var points =3D meta.data || []; - var i, ilen, model, controlPoints; - - // Only consider points that are drawn in case the spanGaps option is us= ed - if (lineModel.spanGaps) { - points =3D points.filter(function(pt) { - return !pt._model.skip; - }); - } - - function capControlPoint(pt, min, max) { - return Math.max(Math.min(pt, max), min); - } - - if (lineModel.cubicInterpolationMode =3D=3D=3D 'monotone') { - helpers$1.splineCurveMonotone(points); - } else { - for (i =3D 0, ilen =3D points.length; i < ilen; ++i) { - model =3D points[i]._model; - controlPoints =3D helpers$1.splineCurve( - helpers$1.previousItem(points, i)._model, - model, - helpers$1.nextItem(points, i)._model, - lineModel.tension - ); - model.controlPointPreviousX =3D controlPoints.previous.x; - model.controlPointPreviousY =3D controlPoints.previous.y; - model.controlPointNextX =3D controlPoints.next.x; - model.controlPointNextY =3D controlPoints.next.y; - } - } - - if (chart.options.elements.line.capBezierPoints) { - for (i =3D 0, ilen =3D points.length; i < ilen; ++i) { - model =3D points[i]._model; - if (isPointInArea(model, area)) { - if (i > 0 && isPointInArea(points[i - 1]._model, area)) { - model.controlPointPreviousX =3D capControlPoint(model.controlPointPr= eviousX, area.left, area.right); - model.controlPointPreviousY =3D capControlPoint(model.controlPointPr= eviousY, area.top, area.bottom); - } - if (i < points.length - 1 && isPointInArea(points[i + 1]._model, area= )) { - model.controlPointNextX =3D capControlPoint(model.controlPointNextX,= area.left, area.right); - model.controlPointNextY =3D capControlPoint(model.controlPointNextY,= area.top, area.bottom); - } - } - } - } - }, - - draw: function() { - var me =3D this; - var chart =3D me.chart; - var meta =3D me.getMeta(); - var points =3D meta.data || []; - var area =3D chart.chartArea; - var canvas =3D chart.canvas; - var i =3D 0; - var ilen =3D points.length; - var clip; - - if (me._showLine) { - clip =3D meta.dataset._model.clip; - - helpers$1.canvas.clipArea(chart.ctx, { - left: clip.left =3D=3D=3D false ? 0 : area.left - clip.left, - right: clip.right =3D=3D=3D false ? canvas.width : area.right + clip.r= ight, - top: clip.top =3D=3D=3D false ? 0 : area.top - clip.top, - bottom: clip.bottom =3D=3D=3D false ? canvas.height : area.bottom + cl= ip.bottom - }); - - meta.dataset.draw(); - - helpers$1.canvas.unclipArea(chart.ctx); - } - - // Draw the points - for (; i < ilen; ++i) { - points[i].draw(area); - } - }, - - /** - * @protected - */ - setHoverStyle: function(point) { - var model =3D point._model; - var options =3D point._options; - var getHoverColor =3D helpers$1.getHoverColor; - - point.$previousStyle =3D { - backgroundColor: model.backgroundColor, - borderColor: model.borderColor, - borderWidth: model.borderWidth, - radius: model.radius - }; - - model.backgroundColor =3D valueOrDefault$6(options.hoverBackgroundColor,= getHoverColor(options.backgroundColor)); - model.borderColor =3D valueOrDefault$6(options.hoverBorderColor, getHove= rColor(options.borderColor)); - model.borderWidth =3D valueOrDefault$6(options.hoverBorderWidth, options= .borderWidth); - model.radius =3D valueOrDefault$6(options.hoverRadius, options.radius); - }, -}); - -var resolve$3 =3D helpers$1.options.resolve; - -core_defaults._set('polarArea', { - scale: { - type: 'radialLinear', - angleLines: { - display: false - }, - gridLines: { - circular: true - }, - pointLabels: { - display: false - }, - ticks: { - beginAtZero: true - } - }, - - // Boolean - Whether to animate the rotation of the chart - animation: { - animateRotate: true, - animateScale: true - }, - - startAngle: -0.5 * Math.PI, - legendCallback: function(chart) { - var list =3D document.createElement('ul'); - var data =3D chart.data; - var datasets =3D data.datasets; - var labels =3D data.labels; - var i, ilen, listItem, listItemSpan; - - list.setAttribute('class', chart.id + '-legend'); - if (datasets.length) { - for (i =3D 0, ilen =3D datasets[0].data.length; i < ilen; ++i) { - listItem =3D list.appendChild(document.createElement('li')); - listItemSpan =3D listItem.appendChild(document.createElement('span')); - listItemSpan.style.backgroundColor =3D datasets[0].backgroundColor[i]; - if (labels[i]) { - listItem.appendChild(document.createTextNode(labels[i])); - } - } - } - - return list.outerHTML; - }, - legend: { - labels: { - generateLabels: function(chart) { - var data =3D chart.data; - if (data.labels.length && data.datasets.length) { - return data.labels.map(function(label, i) { - var meta =3D chart.getDatasetMeta(0); - var style =3D meta.controller.getStyle(i); - - return { - text: label, - fillStyle: style.backgroundColor, - strokeStyle: style.borderColor, - lineWidth: style.borderWidth, - hidden: isNaN(data.datasets[0].data[i]) || meta.data[i].hidden, - - // Extra data used for toggling the correct item - index: i - }; - }); - } - return []; - } - }, - - onClick: function(e, legendItem) { - var index =3D legendItem.index; - var chart =3D this.chart; - var i, ilen, meta; - - for (i =3D 0, ilen =3D (chart.data.datasets || []).length; i < ilen; ++= i) { - meta =3D chart.getDatasetMeta(i); - meta.data[index].hidden =3D !meta.data[index].hidden; - } - - chart.update(); - } - }, - - // Need to override these to give a nice default - tooltips: { - callbacks: { - title: function() { - return ''; - }, - label: function(item, data) { - return data.labels[item.index] + ': ' + item.yLabel; - } - } - } -}); - -var controller_polarArea =3D core_datasetController.extend({ - - dataElementType: elements.Arc, - - linkScales: helpers$1.noop, - - /** - * @private - */ - _dataElementOptions: [ - 'backgroundColor', - 'borderColor', - 'borderWidth', - 'borderAlign', - 'hoverBackgroundColor', - 'hoverBorderColor', - 'hoverBorderWidth', - ], - - /** - * @private - */ - _getIndexScaleId: function() { - return this.chart.scale.id; - }, - - /** - * @private - */ - _getValueScaleId: function() { - return this.chart.scale.id; - }, - - update: function(reset) { - var me =3D this; - var dataset =3D me.getDataset(); - var meta =3D me.getMeta(); - var start =3D me.chart.options.startAngle || 0; - var starts =3D me._starts =3D []; - var angles =3D me._angles =3D []; - var arcs =3D meta.data; - var i, ilen, angle; - - me._updateRadius(); - - meta.count =3D me.countVisibleElements(); - - for (i =3D 0, ilen =3D dataset.data.length; i < ilen; i++) { - starts[i] =3D start; - angle =3D me._computeAngle(i); - angles[i] =3D angle; - start +=3D angle; - } - - for (i =3D 0, ilen =3D arcs.length; i < ilen; ++i) { - arcs[i]._options =3D me._resolveDataElementOptions(arcs[i], i); - me.updateElement(arcs[i], i, reset); - } - }, - - /** - * @private - */ - _updateRadius: function() { - var me =3D this; - var chart =3D me.chart; - var chartArea =3D chart.chartArea; - var opts =3D chart.options; - var minSize =3D Math.min(chartArea.right - chartArea.left, chartArea.bot= tom - chartArea.top); - - chart.outerRadius =3D Math.max(minSize / 2, 0); - chart.innerRadius =3D Math.max(opts.cutoutPercentage ? (chart.outerRadiu= s / 100) * (opts.cutoutPercentage) : 1, 0); - chart.radiusLength =3D (chart.outerRadius - chart.innerRadius) / chart.g= etVisibleDatasetCount(); - - me.outerRadius =3D chart.outerRadius - (chart.radiusLength * me.index); - me.innerRadius =3D me.outerRadius - chart.radiusLength; - }, - - updateElement: function(arc, index, reset) { - var me =3D this; - var chart =3D me.chart; - var dataset =3D me.getDataset(); - var opts =3D chart.options; - var animationOpts =3D opts.animation; - var scale =3D chart.scale; - var labels =3D chart.data.labels; - - var centerX =3D scale.xCenter; - var centerY =3D scale.yCenter; - - // var negHalfPI =3D -0.5 * Math.PI; - var datasetStartAngle =3D opts.startAngle; - var distance =3D arc.hidden ? 0 : scale.getDistanceFromCenterForValue(da= taset.data[index]); - var startAngle =3D me._starts[index]; - var endAngle =3D startAngle + (arc.hidden ? 0 : me._angles[index]); - - var resetRadius =3D animationOpts.animateScale ? 0 : scale.getDistanceFr= omCenterForValue(dataset.data[index]); - var options =3D arc._options || {}; - - helpers$1.extend(arc, { - // Utility - _datasetIndex: me.index, - _index: index, - _scale: scale, - - // Desired view properties - _model: { - backgroundColor: options.backgroundColor, - borderColor: options.borderColor, - borderWidth: options.borderWidth, - borderAlign: options.borderAlign, - x: centerX, - y: centerY, - innerRadius: 0, - outerRadius: reset ? resetRadius : distance, - startAngle: reset && animationOpts.animateRotate ? datasetStartAngle := startAngle, - endAngle: reset && animationOpts.animateRotate ? datasetStartAngle : e= ndAngle, - label: helpers$1.valueAtIndexOrDefault(labels, index, labels[index]) - } - }); - - arc.pivot(); - }, - - countVisibleElements: function() { - var dataset =3D this.getDataset(); - var meta =3D this.getMeta(); - var count =3D 0; - - helpers$1.each(meta.data, function(element, index) { - if (!isNaN(dataset.data[index]) && !element.hidden) { - count++; - } - }); - - return count; - }, - - /** - * @protected - */ - setHoverStyle: function(arc) { - var model =3D arc._model; - var options =3D arc._options; - var getHoverColor =3D helpers$1.getHoverColor; - var valueOrDefault =3D helpers$1.valueOrDefault; - - arc.$previousStyle =3D { - backgroundColor: model.backgroundColor, - borderColor: model.borderColor, - borderWidth: model.borderWidth, - }; - - model.backgroundColor =3D valueOrDefault(options.hoverBackgroundColor, g= etHoverColor(options.backgroundColor)); - model.borderColor =3D valueOrDefault(options.hoverBorderColor, getHoverC= olor(options.borderColor)); - model.borderWidth =3D valueOrDefault(options.hoverBorderWidth, options.b= orderWidth); - }, - - /** - * @private - */ - _computeAngle: function(index) { - var me =3D this; - var count =3D this.getMeta().count; - var dataset =3D me.getDataset(); - var meta =3D me.getMeta(); - - if (isNaN(dataset.data[index]) || meta.data[index].hidden) { - return 0; - } - - // Scriptable options - var context =3D { - chart: me.chart, - dataIndex: index, - dataset: dataset, - datasetIndex: me.index - }; - - return resolve$3([ - me.chart.options.elements.arc.angle, - (2 * Math.PI) / count - ], context, index); - } -}); - -core_defaults._set('pie', helpers$1.clone(core_defaults.doughnut)); -core_defaults._set('pie', { - cutoutPercentage: 0 -}); - -// Pie charts are Doughnut chart with different defaults -var controller_pie =3D controller_doughnut; - -var valueOrDefault$7 =3D helpers$1.valueOrDefault; - -core_defaults._set('radar', { - spanGaps: false, - scale: { - type: 'radialLinear' - }, - elements: { - line: { - fill: 'start', - tension: 0 // no bezier in radar - } - } -}); - -var controller_radar =3D core_datasetController.extend({ - datasetElementType: elements.Line, - - dataElementType: elements.Point, - - linkScales: helpers$1.noop, - - /** - * @private - */ - _datasetElementOptions: [ - 'backgroundColor', - 'borderWidth', - 'borderColor', - 'borderCapStyle', - 'borderDash', - 'borderDashOffset', - 'borderJoinStyle', - 'fill' - ], - - /** - * @private - */ - _dataElementOptions: { - backgroundColor: 'pointBackgroundColor', - borderColor: 'pointBorderColor', - borderWidth: 'pointBorderWidth', - hitRadius: 'pointHitRadius', - hoverBackgroundColor: 'pointHoverBackgroundColor', - hoverBorderColor: 'pointHoverBorderColor', - hoverBorderWidth: 'pointHoverBorderWidth', - hoverRadius: 'pointHoverRadius', - pointStyle: 'pointStyle', - radius: 'pointRadius', - rotation: 'pointRotation' - }, - - /** - * @private - */ - _getIndexScaleId: function() { - return this.chart.scale.id; - }, - - /** - * @private - */ - _getValueScaleId: function() { - return this.chart.scale.id; - }, - - update: function(reset) { - var me =3D this; - var meta =3D me.getMeta(); - var line =3D meta.dataset; - var points =3D meta.data || []; - var scale =3D me.chart.scale; - var config =3D me._config; - var i, ilen; - - // Compatibility: If the properties are defined with only the old name, = use those values - if (config.tension !=3D=3D undefined && config.lineTension =3D=3D=3D und= efined) { - config.lineTension =3D config.tension; - } - - // Utility - line._scale =3D scale; - line._datasetIndex =3D me.index; - // Data - line._children =3D points; - line._loop =3D true; - // Model - line._model =3D me._resolveDatasetElementOptions(line); - - line.pivot(); - - // Update Points - for (i =3D 0, ilen =3D points.length; i < ilen; ++i) { - me.updateElement(points[i], i, reset); - } - - // Update bezier control points - me.updateBezierControlPoints(); - - // Now pivot the point for animation - for (i =3D 0, ilen =3D points.length; i < ilen; ++i) { - points[i].pivot(); - } - }, - - updateElement: function(point, index, reset) { - var me =3D this; - var custom =3D point.custom || {}; - var dataset =3D me.getDataset(); - var scale =3D me.chart.scale; - var pointPosition =3D scale.getPointPositionForValue(index, dataset.data= [index]); - var options =3D me._resolveDataElementOptions(point, index); - var lineModel =3D me.getMeta().dataset._model; - var x =3D reset ? scale.xCenter : pointPosition.x; - var y =3D reset ? scale.yCenter : pointPosition.y; - - // Utility - point._scale =3D scale; - point._options =3D options; - point._datasetIndex =3D me.index; - point._index =3D index; - - // Desired view properties - point._model =3D { - x: x, // value not used in dataset scale, but we want a consistent API = between scales - y: y, - skip: custom.skip || isNaN(x) || isNaN(y), - // Appearance - radius: options.radius, - pointStyle: options.pointStyle, - rotation: options.rotation, - backgroundColor: options.backgroundColor, - borderColor: options.borderColor, - borderWidth: options.borderWidth, - tension: valueOrDefault$7(custom.tension, lineModel ? lineModel.tension= : 0), - - // Tooltip - hitRadius: options.hitRadius - }; - }, - - /** - * @private - */ - _resolveDatasetElementOptions: function() { - var me =3D this; - var config =3D me._config; - var options =3D me.chart.options; - var values =3D core_datasetController.prototype._resolveDatasetElementOp= tions.apply(me, arguments); - - values.spanGaps =3D valueOrDefault$7(config.spanGaps, options.spanGaps); - values.tension =3D valueOrDefault$7(config.lineTension, options.elements= .line.tension); - - return values; - }, - - updateBezierControlPoints: function() { - var me =3D this; - var meta =3D me.getMeta(); - var area =3D me.chart.chartArea; - var points =3D meta.data || []; - var i, ilen, model, controlPoints; - - // Only consider points that are drawn in case the spanGaps option is us= ed - if (meta.dataset._model.spanGaps) { - points =3D points.filter(function(pt) { - return !pt._model.skip; - }); - } - - function capControlPoint(pt, min, max) { - return Math.max(Math.min(pt, max), min); - } - - for (i =3D 0, ilen =3D points.length; i < ilen; ++i) { - model =3D points[i]._model; - controlPoints =3D helpers$1.splineCurve( - helpers$1.previousItem(points, i, true)._model, - model, - helpers$1.nextItem(points, i, true)._model, - model.tension - ); - - // Prevent the bezier going outside of the bounds of the graph - model.controlPointPreviousX =3D capControlPoint(controlPoints.previous.= x, area.left, area.right); - model.controlPointPreviousY =3D capControlPoint(controlPoints.previous.= y, area.top, area.bottom); - model.controlPointNextX =3D capControlPoint(controlPoints.next.x, area.= left, area.right); - model.controlPointNextY =3D capControlPoint(controlPoints.next.y, area.= top, area.bottom); - } - }, - - setHoverStyle: function(point) { - var model =3D point._model; - var options =3D point._options; - var getHoverColor =3D helpers$1.getHoverColor; - - point.$previousStyle =3D { - backgroundColor: model.backgroundColor, - borderColor: model.borderColor, - borderWidth: model.borderWidth, - radius: model.radius - }; - - model.backgroundColor =3D valueOrDefault$7(options.hoverBackgroundColor,= getHoverColor(options.backgroundColor)); - model.borderColor =3D valueOrDefault$7(options.hoverBorderColor, getHove= rColor(options.borderColor)); - model.borderWidth =3D valueOrDefault$7(options.hoverBorderWidth, options= .borderWidth); - model.radius =3D valueOrDefault$7(options.hoverRadius, options.radius); - } -}); - -core_defaults._set('scatter', { - hover: { - mode: 'single' - }, - - scales: { - xAxes: [{ - id: 'x-axis-1', // need an ID so datasets can reference the scale - type: 'linear', // scatter should not use a category axis - position: 'bottom' - }], - yAxes: [{ - id: 'y-axis-1', - type: 'linear', - position: 'left' - }] - }, - - tooltips: { - callbacks: { - title: function() { - return ''; // doesn't make sense for scatter since data are format= ted as a point - }, - label: function(item) { - return '(' + item.xLabel + ', ' + item.yLabel + ')'; - } - } - } -}); - -core_defaults._set('global', { - datasets: { - scatter: { - showLine: false - } - } -}); - -// Scatter charts use line controllers -var controller_scatter =3D controller_line; - -// NOTE export a map in which the key represents the controller type, not -// the class, and so must be CamelCase in order to be correctly retrieved -// by the controller in core.controller.js (`controllers[meta.type]`). - -var controllers =3D { - bar: controller_bar, - bubble: controller_bubble, - doughnut: controller_doughnut, - horizontalBar: controller_horizontalBar, - line: controller_line, - polarArea: controller_polarArea, - pie: controller_pie, - radar: controller_radar, - scatter: controller_scatter -}; - -/** - * Helper function to get relative position for an event - * @param {Event|IEvent} event - The event to get the position for - * @param {Chart} chart - The chart - * @returns {object} the event position - */ -function getRelativePosition(e, chart) { - if (e.native) { - return { - x: e.x, - y: e.y - }; - } - - return helpers$1.getRelativePosition(e, chart); -} - -/** - * Helper function to traverse all of the visible elements in the chart - * @param {Chart} chart - the chart - * @param {function} handler - the callback to execute for each visible it= em - */ -function parseVisibleItems(chart, handler) { - var metasets =3D chart._getSortedVisibleDatasetMetas(); - var metadata, i, j, ilen, jlen, element; - - for (i =3D 0, ilen =3D metasets.length; i < ilen; ++i) { - metadata =3D metasets[i].data; - for (j =3D 0, jlen =3D metadata.length; j < jlen; ++j) { - element =3D metadata[j]; - if (!element._view.skip) { - handler(element); - } - } - } -} - -/** - * Helper function to get the items that intersect the event position - * @param {ChartElement[]} items - elements to filter - * @param {object} position - the point to be nearest to - * @return {ChartElement[]} the nearest items - */ -function getIntersectItems(chart, position) { - var elements =3D []; - - parseVisibleItems(chart, function(element) { - if (element.inRange(position.x, position.y)) { - elements.push(element); - } - }); - - return elements; -} - -/** - * Helper function to get the items nearest to the event position consider= ing all visible items in teh chart - * @param {Chart} chart - the chart to look at elements from - * @param {object} position - the point to be nearest to - * @param {boolean} intersect - if true, only consider items that intersec= t the position - * @param {function} distanceMetric - function to provide the distance bet= ween points - * @return {ChartElement[]} the nearest items - */ -function getNearestItems(chart, position, intersect, distanceMetric) { - var minDistance =3D Number.POSITIVE_INFINITY; - var nearestItems =3D []; - - parseVisibleItems(chart, function(element) { - if (intersect && !element.inRange(position.x, position.y)) { - return; - } - - var center =3D element.getCenterPoint(); - var distance =3D distanceMetric(position, center); - if (distance < minDistance) { - nearestItems =3D [element]; - minDistance =3D distance; - } else if (distance =3D=3D=3D minDistance) { - // Can have multiple items at the same distance in which case we sort b= y size - nearestItems.push(element); - } - }); - - return nearestItems; -} - -/** - * Get a distance metric function for two points based on the - * axis mode setting - * @param {string} axis - the axis mode. x|y|xy - */ -function getDistanceMetricForAxis(axis) { - var useX =3D axis.indexOf('x') !=3D=3D -1; - var useY =3D axis.indexOf('y') !=3D=3D -1; - - return function(pt1, pt2) { - var deltaX =3D useX ? Math.abs(pt1.x - pt2.x) : 0; - var deltaY =3D useY ? Math.abs(pt1.y - pt2.y) : 0; - return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)); - }; -} - -function indexMode(chart, e, options) { - var position =3D getRelativePosition(e, chart); - // Default axis for index mode is 'x' to match old behaviour - options.axis =3D options.axis || 'x'; - var distanceMetric =3D getDistanceMetricForAxis(options.axis); - var items =3D options.intersect ? getIntersectItems(chart, position) : ge= tNearestItems(chart, position, false, distanceMetric); - var elements =3D []; - - if (!items.length) { - return []; - } - - chart._getSortedVisibleDatasetMetas().forEach(function(meta) { - var element =3D meta.data[items[0]._index]; - - // don't count items that are skipped (null data) - if (element && !element._view.skip) { - elements.push(element); - } - }); - - return elements; -} - -/** - * @interface IInteractionOptions - */ -/** - * If true, only consider items that intersect the point - * @name IInterfaceOptions#boolean - * @type Boolean - */ - -/** - * Contains interaction related functions - * @namespace Chart.Interaction - */ -var core_interaction =3D { - // Helper function for different modes - modes: { - single: function(chart, e) { - var position =3D getRelativePosition(e, chart); - var elements =3D []; - - parseVisibleItems(chart, function(element) { - if (element.inRange(position.x, position.y)) { - elements.push(element); - return elements; - } - }); - - return elements.slice(0, 1); - }, - - /** - * @function Chart.Interaction.modes.label - * @deprecated since version 2.4.0 - * @todo remove at version 3 - * @private - */ - label: indexMode, - - /** - * Returns items at the same index. If the options.intersect parameter i= s true, we only return items if we intersect something - * If the options.intersect mode is false, we find the nearest item and = return the items at the same index as that item - * @function Chart.Interaction.modes.index - * @since v2.4.0 - * @param {Chart} chart - the chart we are returning items from - * @param {Event} e - the event we are find things at - * @param {IInteractionOptions} options - options to use during interact= ion - * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned - */ - index: indexMode, - - /** - * Returns items in the same dataset. If the options.intersect parameter= is true, we only return items if we intersect something - * If the options.intersect is false, we find the nearest item and retur= n the items in that dataset - * @function Chart.Interaction.modes.dataset - * @param {Chart} chart - the chart we are returning items from - * @param {Event} e - the event we are find things at - * @param {IInteractionOptions} options - options to use during interact= ion - * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned - */ - dataset: function(chart, e, options) { - var position =3D getRelativePosition(e, chart); - options.axis =3D options.axis || 'xy'; - var distanceMetric =3D getDistanceMetricForAxis(options.axis); - var items =3D options.intersect ? getIntersectItems(chart, position) : = getNearestItems(chart, position, false, distanceMetric); - - if (items.length > 0) { - items =3D chart.getDatasetMeta(items[0]._datasetIndex).data; - } - - return items; - }, - - /** - * @function Chart.Interaction.modes.x-axis - * @deprecated since version 2.4.0. Use index mode and intersect =3D=3D = true - * @todo remove at version 3 - * @private - */ - 'x-axis': function(chart, e) { - return indexMode(chart, e, {intersect: false}); - }, - - /** - * Point mode returns all elements that hit test based on the event posi= tion - * of the event - * @function Chart.Interaction.modes.intersect - * @param {Chart} chart - the chart we are returning items from - * @param {Event} e - the event we are find things at - * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned - */ - point: function(chart, e) { - var position =3D getRelativePosition(e, chart); - return getIntersectItems(chart, position); - }, - - /** - * nearest mode returns the element closest to the point - * @function Chart.Interaction.modes.intersect - * @param {Chart} chart - the chart we are returning items from - * @param {Event} e - the event we are find things at - * @param {IInteractionOptions} options - options to use - * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned - */ - nearest: function(chart, e, options) { - var position =3D getRelativePosition(e, chart); - options.axis =3D options.axis || 'xy'; - var distanceMetric =3D getDistanceMetricForAxis(options.axis); - return getNearestItems(chart, position, options.intersect, distanceMetr= ic); - }, - - /** - * x mode returns the elements that hit-test at the current x coordinate - * @function Chart.Interaction.modes.x - * @param {Chart} chart - the chart we are returning items from - * @param {Event} e - the event we are find things at - * @param {IInteractionOptions} options - options to use - * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned - */ - x: function(chart, e, options) { - var position =3D getRelativePosition(e, chart); - var items =3D []; - var intersectsItem =3D false; - - parseVisibleItems(chart, function(element) { - if (element.inXRange(position.x)) { - items.push(element); - } - - if (element.inRange(position.x, position.y)) { - intersectsItem =3D true; - } - }); - - // If we want to trigger on an intersect and we don't have any items - // that intersect the position, return nothing - if (options.intersect && !intersectsItem) { - items =3D []; - } - return items; - }, - - /** - * y mode returns the elements that hit-test at the current y coordinate - * @function Chart.Interaction.modes.y - * @param {Chart} chart - the chart we are returning items from - * @param {Event} e - the event we are find things at - * @param {IInteractionOptions} options - options to use - * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned - */ - y: function(chart, e, options) { - var position =3D getRelativePosition(e, chart); - var items =3D []; - var intersectsItem =3D false; - - parseVisibleItems(chart, function(element) { - if (element.inYRange(position.y)) { - items.push(element); - } - - if (element.inRange(position.x, position.y)) { - intersectsItem =3D true; - } - }); - - // If we want to trigger on an intersect and we don't have any items - // that intersect the position, return nothing - if (options.intersect && !intersectsItem) { - items =3D []; - } - return items; - } - } -}; - -var extend =3D helpers$1.extend; - -function filterByPosition(array, position) { - return helpers$1.where(array, function(v) { - return v.pos =3D=3D=3D position; - }); -} - -function sortByWeight(array, reverse) { - return array.sort(function(a, b) { - var v0 =3D reverse ? b : a; - var v1 =3D reverse ? a : b; - return v0.weight =3D=3D=3D v1.weight ? - v0.index - v1.index : - v0.weight - v1.weight; - }); -} - -function wrapBoxes(boxes) { - var layoutBoxes =3D []; - var i, ilen, box; - - for (i =3D 0, ilen =3D (boxes || []).length; i < ilen; ++i) { - box =3D boxes[i]; - layoutBoxes.push({ - index: i, - box: box, - pos: box.position, - horizontal: box.isHorizontal(), - weight: box.weight - }); - } - return layoutBoxes; -} - -function setLayoutDims(layouts, params) { - var i, ilen, layout; - for (i =3D 0, ilen =3D layouts.length; i < ilen; ++i) { - layout =3D layouts[i]; - // store width used instead of chartArea.w in fitBoxes - layout.width =3D layout.horizontal - ? layout.box.fullWidth && params.availableWidth - : params.vBoxMaxWidth; - // store height used instead of chartArea.h in fitBoxes - layout.height =3D layout.horizontal && params.hBoxMaxHeight; - } -} - -function buildLayoutBoxes(boxes) { - var layoutBoxes =3D wrapBoxes(boxes); - var left =3D sortByWeight(filterByPosition(layoutBoxes, 'left'), true); - var right =3D sortByWeight(filterByPosition(layoutBoxes, 'right')); - var top =3D sortByWeight(filterByPosition(layoutBoxes, 'top'), true); - var bottom =3D sortByWeight(filterByPosition(layoutBoxes, 'bottom')); - - return { - leftAndTop: left.concat(top), - rightAndBottom: right.concat(bottom), - chartArea: filterByPosition(layoutBoxes, 'chartArea'), - vertical: left.concat(right), - horizontal: top.concat(bottom) - }; -} - -function getCombinedMax(maxPadding, chartArea, a, b) { - return Math.max(maxPadding[a], chartArea[a]) + Math.max(maxPadding[b], ch= artArea[b]); -} - -function updateDims(chartArea, params, layout) { - var box =3D layout.box; - var maxPadding =3D chartArea.maxPadding; - var newWidth, newHeight; - - if (layout.size) { - // this layout was already counted for, lets first reduce old size - chartArea[layout.pos] -=3D layout.size; - } - layout.size =3D layout.horizontal ? box.height : box.width; - chartArea[layout.pos] +=3D layout.size; - - if (box.getPadding) { - var boxPadding =3D box.getPadding(); - maxPadding.top =3D Math.max(maxPadding.top, boxPadding.top); - maxPadding.left =3D Math.max(maxPadding.left, boxPadding.left); - maxPadding.bottom =3D Math.max(maxPadding.bottom, boxPadding.bottom); - maxPadding.right =3D Math.max(maxPadding.right, boxPadding.right); - } - - newWidth =3D params.outerWidth - getCombinedMax(maxPadding, chartArea, 'l= eft', 'right'); - newHeight =3D params.outerHeight - getCombinedMax(maxPadding, chartArea, = 'top', 'bottom'); - - if (newWidth !=3D=3D chartArea.w || newHeight !=3D=3D chartArea.h) { - chartArea.w =3D newWidth; - chartArea.h =3D newHeight; - - // return true if chart area changed in layout's direction - return layout.horizontal ? newWidth !=3D=3D chartArea.w : newHeight !=3D= =3D chartArea.h; - } -} - -function handleMaxPadding(chartArea) { - var maxPadding =3D chartArea.maxPadding; - - function updatePos(pos) { - var change =3D Math.max(maxPadding[pos] - chartArea[pos], 0); - chartArea[pos] +=3D change; - return change; - } - chartArea.y +=3D updatePos('top'); - chartArea.x +=3D updatePos('left'); - updatePos('right'); - updatePos('bottom'); -} - -function getMargins(horizontal, chartArea) { - var maxPadding =3D chartArea.maxPadding; - - function marginForPositions(positions) { - var margin =3D {left: 0, top: 0, right: 0, bottom: 0}; - positions.forEach(function(pos) { - margin[pos] =3D Math.max(chartArea[pos], maxPadding[pos]); - }); - return margin; - } - - return horizontal - ? marginForPositions(['left', 'right']) - : marginForPositions(['top', 'bottom']); -} - -function fitBoxes(boxes, chartArea, params) { - var refitBoxes =3D []; - var i, ilen, layout, box, refit, changed; - - for (i =3D 0, ilen =3D boxes.length; i < ilen; ++i) { - layout =3D boxes[i]; - box =3D layout.box; - - box.update( - layout.width || chartArea.w, - layout.height || chartArea.h, - getMargins(layout.horizontal, chartArea) - ); - if (updateDims(chartArea, params, layout)) { - changed =3D true; - if (refitBoxes.length) { - // Dimensions changed and there were non full width boxes before this - // -> we have to refit those - refit =3D true; - } - } - if (!box.fullWidth) { // fullWidth boxes don't need to be re-fitted in a= ny case - refitBoxes.push(layout); - } - } - - return refit ? fitBoxes(refitBoxes, chartArea, params) || changed : chang= ed; -} - -function placeBoxes(boxes, chartArea, params) { - var userPadding =3D params.padding; - var x =3D chartArea.x; - var y =3D chartArea.y; - var i, ilen, layout, box; - - for (i =3D 0, ilen =3D boxes.length; i < ilen; ++i) { - layout =3D boxes[i]; - box =3D layout.box; - if (layout.horizontal) { - box.left =3D box.fullWidth ? userPadding.left : chartArea.left; - box.right =3D box.fullWidth ? params.outerWidth - userPadding.right : c= hartArea.left + chartArea.w; - box.top =3D y; - box.bottom =3D y + box.height; - box.width =3D box.right - box.left; - y =3D box.bottom; - } else { - box.left =3D x; - box.right =3D x + box.width; - box.top =3D chartArea.top; - box.bottom =3D chartArea.top + chartArea.h; - box.height =3D box.bottom - box.top; - x =3D box.right; - } - } - - chartArea.x =3D x; - chartArea.y =3D y; -} - -core_defaults._set('global', { - layout: { - padding: { - top: 0, - right: 0, - bottom: 0, - left: 0 - } - } -}); - -/** - * @interface ILayoutItem - * @prop {string} position - The position of the item in the chart layout.= Possible values are - * 'left', 'top', 'right', 'bottom', and 'chartArea' - * @prop {number} weight - The weight used to sort the item. Higher weight= s are further away from the chart area - * @prop {boolean} fullWidth - if true, and the item is horizontal, then p= ush vertical boxes down - * @prop {function} isHorizontal - returns true if the layout item is hori= zontal (ie. top or bottom) - * @prop {function} update - Takes two parameters: width and height. Retur= ns size of item - * @prop {function} getPadding - Returns an object with padding on the ed= ges - * @prop {number} width - Width of item. Must be valid after update() - * @prop {number} height - Height of item. Must be valid after update() - * @prop {number} left - Left edge of the item. Set by layout system and c= annot be used in update - * @prop {number} top - Top edge of the item. Set by layout system and can= not be used in update - * @prop {number} right - Right edge of the item. Set by layout system and= cannot be used in update - * @prop {number} bottom - Bottom edge of the item. Set by layout system a= nd cannot be used in update - */ - -// The layout service is very self explanatory. It's responsible for the = layout within a chart. -// Scales, Legends and Plugins all rely on the layout service and can easi= ly register to be placed anywhere they need -// It is this service's responsibility of carrying out that layout. -var core_layouts =3D { - defaults: {}, - - /** - * Register a box to a chart. - * A box is simply a reference to an object that requires layout. eg. Sca= les, Legend, Title. - * @param {Chart} chart - the chart to use - * @param {ILayoutItem} item - the item to add to be layed out - */ - addBox: function(chart, item) { - if (!chart.boxes) { - chart.boxes =3D []; - } - - // initialize item with default values - item.fullWidth =3D item.fullWidth || false; - item.position =3D item.position || 'top'; - item.weight =3D item.weight || 0; - item._layers =3D item._layers || function() { - return [{ - z: 0, - draw: function() { - item.draw.apply(item, arguments); - } - }]; - }; - - chart.boxes.push(item); - }, - - /** - * Remove a layoutItem from a chart - * @param {Chart} chart - the chart to remove the box from - * @param {ILayoutItem} layoutItem - the item to remove from the layout - */ - removeBox: function(chart, layoutItem) { - var index =3D chart.boxes ? chart.boxes.indexOf(layoutItem) : -1; - if (index !=3D=3D -1) { - chart.boxes.splice(index, 1); - } - }, - - /** - * Sets (or updates) options on the given `item`. - * @param {Chart} chart - the chart in which the item lives (or will be a= dded to) - * @param {ILayoutItem} item - the item to configure with the given optio= ns - * @param {object} options - the new item options. - */ - configure: function(chart, item, options) { - var props =3D ['fullWidth', 'position', 'weight']; - var ilen =3D props.length; - var i =3D 0; - var prop; - - for (; i < ilen; ++i) { - prop =3D props[i]; - if (options.hasOwnProperty(prop)) { - item[prop] =3D options[prop]; - } - } - }, - - /** - * Fits boxes of the given chart into the given size by having each box m= easure itself - * then running a fitting algorithm - * @param {Chart} chart - the chart - * @param {number} width - the width to fit into - * @param {number} height - the height to fit into - */ - update: function(chart, width, height) { - if (!chart) { - return; - } - - var layoutOptions =3D chart.options.layout || {}; - var padding =3D helpers$1.options.toPadding(layoutOptions.padding); - - var availableWidth =3D width - padding.width; - var availableHeight =3D height - padding.height; - var boxes =3D buildLayoutBoxes(chart.boxes); - var verticalBoxes =3D boxes.vertical; - var horizontalBoxes =3D boxes.horizontal; - - // Essentially we now have any number of boxes on each of the 4 sides. - // Our canvas looks like the following. - // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is th= e top axis and - // B1 is the bottom axis - // There are also 4 quadrant-like locations (left to right instead of cl= ockwise) reserved for chart overlays - // These locations are single-box locations only, when trying to registe= r a chartArea location that is already taken, - // an error will be thrown. - // - // |----------------------------------------------------| - // | T1 (Full Width) | - // |----------------------------------------------------| - // | | | T2 | | - // | |----|-------------------------------------|----| - // | | | C1 | | C2 | | - // | | |----| |----| | - // | | | | | - // | L1 | L2 | ChartArea (C0) | R1 | - // | | | | | - // | | |----| |----| | - // | | | C3 | | C4 | | - // | |----|-------------------------------------|----| - // | | | B1 | | - // |----------------------------------------------------| - // | B2 (Full Width) | - // |----------------------------------------------------| - // - - var params =3D Object.freeze({ - outerWidth: width, - outerHeight: height, - padding: padding, - availableWidth: availableWidth, - vBoxMaxWidth: availableWidth / 2 / verticalBoxes.length, - hBoxMaxHeight: availableHeight / 2 - }); - var chartArea =3D extend({ - maxPadding: extend({}, padding), - w: availableWidth, - h: availableHeight, - x: padding.left, - y: padding.top - }, padding); - - setLayoutDims(verticalBoxes.concat(horizontalBoxes), params); - - // First fit vertical boxes - fitBoxes(verticalBoxes, chartArea, params); - - // Then fit horizontal boxes - if (fitBoxes(horizontalBoxes, chartArea, params)) { - // if the area changed, re-fit vertical boxes - fitBoxes(verticalBoxes, chartArea, params); - } - - handleMaxPadding(chartArea); - - // Finally place the boxes to correct coordinates - placeBoxes(boxes.leftAndTop, chartArea, params); - - // Move to opposite side of chart - chartArea.x +=3D chartArea.w; - chartArea.y +=3D chartArea.h; - - placeBoxes(boxes.rightAndBottom, chartArea, params); - - chart.chartArea =3D { - left: chartArea.left, - top: chartArea.top, - right: chartArea.left + chartArea.w, - bottom: chartArea.top + chartArea.h - }; - - // Finally update boxes in chartArea (radial scale for example) - helpers$1.each(boxes.chartArea, function(layout) { - var box =3D layout.box; - extend(box, chart.chartArea); - box.update(chartArea.w, chartArea.h); - }); - } -}; - -/** - * Platform fallback implementation (minimal). - * @see https://github.com/chartjs/Chart.js/pull/4591#issuecomment-3195759= 39 - */ - -var platform_basic =3D { - acquireContext: function(item) { - if (item && item.canvas) { - // Support for any object associated to a canvas (including a context2d) - item =3D item.canvas; - } - - return item && item.getContext('2d') || null; - } -}; - -var platform_dom =3D "/*\n * DOM element rendering detection\n * https://d= avidwalsh.name/detect-node-insertion\n */\n@keyframes chartjs-render-animat= ion {\n\tfrom { opacity: 0.99; }\n\tto { opacity: 1; }\n}\n\n.chartjs-rende= r-monitor {\n\tanimation: chartjs-render-animation 0.001s;\n}\n\n/*\n * DOM= element resizing detection\n * https://github.com/marcj/css-element-querie= s\n */\n.chartjs-size-monitor,\n.chartjs-size-monitor-expand,\n.chartjs-siz= e-monitor-shrink {\n\tposition: absolute;\n\tdirection: ltr;\n\tleft: 0;\n\= ttop: 0;\n\tright: 0;\n\tbottom: 0;\n\toverflow: hidden;\n\tpointer-events:= none;\n\tvisibility: hidden;\n\tz-index: -1;\n}\n\n.chartjs-size-monitor-e= xpand > div {\n\tposition: absolute;\n\twidth: 1000000px;\n\theight: 100000= 0px;\n\tleft: 0;\n\ttop: 0;\n}\n\n.chartjs-size-monitor-shrink > div {\n\tp= osition: absolute;\n\twidth: 200%;\n\theight: 200%;\n\tleft: 0;\n\ttop: 0;\= n}\n"; - -var platform_dom$1 =3D /*#__PURE__*/Object.freeze({ -__proto__: null, -'default': platform_dom -}); - -var stylesheet =3D getCjsExportFromNamespace(platform_dom$1); - -var EXPANDO_KEY =3D '$chartjs'; -var CSS_PREFIX =3D 'chartjs-'; -var CSS_SIZE_MONITOR =3D CSS_PREFIX + 'size-monitor'; -var CSS_RENDER_MONITOR =3D CSS_PREFIX + 'render-monitor'; -var CSS_RENDER_ANIMATION =3D CSS_PREFIX + 'render-animation'; -var ANIMATION_START_EVENTS =3D ['animationstart', 'webkitAnimationStart']; - -/** - * DOM event types -> Chart.js event types. - * Note: only events with different types are mapped. - * @see https://developer.mozilla.org/en-US/docs/Web/Events - */ -var EVENT_TYPES =3D { - touchstart: 'mousedown', - touchmove: 'mousemove', - touchend: 'mouseup', - pointerenter: 'mouseenter', - pointerdown: 'mousedown', - pointermove: 'mousemove', - pointerup: 'mouseup', - pointerleave: 'mouseout', - pointerout: 'mouseout' -}; - -/** - * The "used" size is the final value of a dimension property after all ca= lculations have - * been performed. This method uses the computed style of `element` but re= turns undefined - * if the computed style is not expressed in pixels. That can happen in so= me cases where - * `element` has a size relative to its parent and this last one is not ye= t displayed, - * for example because of `display: none` on a parent node. - * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value - * @returns {number} Size in pixels or undefined if unknown. - */ -function readUsedSize(element, property) { - var value =3D helpers$1.getStyle(element, property); - var matches =3D value && value.match(/^(\d+)(\.\d+)?px$/); - return matches ? Number(matches[1]) : undefined; -} - -/** - * Initializes the canvas style and render size without modifying the canv= as display size, - * since responsiveness is handled by the controller.resize() method. The = config is used - * to determine the aspect ratio to apply in case no explicit height has b= een specified. - */ -function initCanvas(canvas, config) { - var style =3D canvas.style; - - // NOTE(SB) canvas.getAttribute('width') !=3D=3D canvas.width: in the fir= st case it - // returns null or '' if no explicit value has been set to the canvas att= ribute. - var renderHeight =3D canvas.getAttribute('height'); - var renderWidth =3D canvas.getAttribute('width'); - - // Chart.js modifies some canvas values that we want to restore on destroy - canvas[EXPANDO_KEY] =3D { - initial: { - height: renderHeight, - width: renderWidth, - style: { - display: style.display, - height: style.height, - width: style.width - } - } - }; - - // Force canvas to display as block to avoid extra space caused by inline - // elements, which would interfere with the responsive resize process. - // https://github.com/chartjs/Chart.js/issues/2538 - style.display =3D style.display || 'block'; - - if (renderWidth =3D=3D=3D null || renderWidth =3D=3D=3D '') { - var displayWidth =3D readUsedSize(canvas, 'width'); - if (displayWidth !=3D=3D undefined) { - canvas.width =3D displayWidth; - } - } - - if (renderHeight =3D=3D=3D null || renderHeight =3D=3D=3D '') { - if (canvas.style.height =3D=3D=3D '') { - // If no explicit render height and style height, let's apply the aspec= t ratio, - // which one can be specified by the user but also by charts as default= option - // (i.e. options.aspectRatio). If not specified, use canvas aspect rati= o of 2. - canvas.height =3D canvas.width / (config.options.aspectRatio || 2); - } else { - var displayHeight =3D readUsedSize(canvas, 'height'); - if (displayWidth !=3D=3D undefined) { - canvas.height =3D displayHeight; - } - } - } - - return canvas; -} - -/** - * Detects support for options object argument in addEventListener. - * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventLi= stener#Safely_detecting_option_support - * @private - */ -var supportsEventListenerOptions =3D (function() { - var supports =3D false; - try { - var options =3D Object.defineProperty({}, 'passive', { - // eslint-disable-next-line getter-return - get: function() { - supports =3D true; - } - }); - window.addEventListener('e', null, options); - } catch (e) { - // continue regardless of error - } - return supports; -}()); - -// Default passive to true as expected by Chrome for 'touchstart' and 'tou= chend' events. -// https://github.com/chartjs/Chart.js/issues/4287 -var eventListenerOptions =3D supportsEventListenerOptions ? {passive: true= } : false; - -function addListener(node, type, listener) { - node.addEventListener(type, listener, eventListenerOptions); -} - -function removeListener(node, type, listener) { - node.removeEventListener(type, listener, eventListenerOptions); -} - -function createEvent(type, chart, x, y, nativeEvent) { - return { - type: type, - chart: chart, - native: nativeEvent || null, - x: x !=3D=3D undefined ? x : null, - y: y !=3D=3D undefined ? y : null, - }; -} - -function fromNativeEvent(event, chart) { - var type =3D EVENT_TYPES[event.type] || event.type; - var pos =3D helpers$1.getRelativePosition(event, chart); - return createEvent(type, chart, pos.x, pos.y, event); -} - -function throttled(fn, thisArg) { - var ticking =3D false; - var args =3D []; - - return function() { - args =3D Array.prototype.slice.call(arguments); - thisArg =3D thisArg || this; - - if (!ticking) { - ticking =3D true; - helpers$1.requestAnimFrame.call(window, function() { - ticking =3D false; - fn.apply(thisArg, args); - }); - } - }; -} - -function createDiv(cls) { - var el =3D document.createElement('div'); - el.className =3D cls || ''; - return el; -} - -// Implementation based on https://github.com/marcj/css-element-queries -function createResizer(handler) { - var maxSize =3D 1000000; - - // NOTE(SB) Don't use innerHTML because it could be considered unsafe. - // https://github.com/chartjs/Chart.js/issues/5902 - var resizer =3D createDiv(CSS_SIZE_MONITOR); - var expand =3D createDiv(CSS_SIZE_MONITOR + '-expand'); - var shrink =3D createDiv(CSS_SIZE_MONITOR + '-shrink'); - - expand.appendChild(createDiv()); - shrink.appendChild(createDiv()); - - resizer.appendChild(expand); - resizer.appendChild(shrink); - resizer._reset =3D function() { - expand.scrollLeft =3D maxSize; - expand.scrollTop =3D maxSize; - shrink.scrollLeft =3D maxSize; - shrink.scrollTop =3D maxSize; - }; - - var onScroll =3D function() { - resizer._reset(); - handler(); - }; - - addListener(expand, 'scroll', onScroll.bind(expand, 'expand')); - addListener(shrink, 'scroll', onScroll.bind(shrink, 'shrink')); - - return resizer; -} - -// https://davidwalsh.name/detect-node-insertion -function watchForRender(node, handler) { - var expando =3D node[EXPANDO_KEY] || (node[EXPANDO_KEY] =3D {}); - var proxy =3D expando.renderProxy =3D function(e) { - if (e.animationName =3D=3D=3D CSS_RENDER_ANIMATION) { - handler(); - } - }; - - helpers$1.each(ANIMATION_START_EVENTS, function(type) { - addListener(node, type, proxy); - }); - - // #4737: Chrome might skip the CSS animation when the CSS_RENDER_MONITOR= class - // is removed then added back immediately (same animation frame?). Access= ing the - // `offsetParent` property will force a reflow and re-evaluate the CSS an= imation. - // https://gist.github.com/paulirish/5d52fb081b3570c81e3a#box-metrics - // https://github.com/chartjs/Chart.js/issues/4737 - expando.reflow =3D !!node.offsetParent; - - node.classList.add(CSS_RENDER_MONITOR); -} - -function unwatchForRender(node) { - var expando =3D node[EXPANDO_KEY] || {}; - var proxy =3D expando.renderProxy; - - if (proxy) { - helpers$1.each(ANIMATION_START_EVENTS, function(type) { - removeListener(node, type, proxy); - }); - - delete expando.renderProxy; - } - - node.classList.remove(CSS_RENDER_MONITOR); -} - -function addResizeListener(node, listener, chart) { - var expando =3D node[EXPANDO_KEY] || (node[EXPANDO_KEY] =3D {}); - - // Let's keep track of this added resizer and thus avoid DOM query when r= emoving it. - var resizer =3D expando.resizer =3D createResizer(throttled(function() { - if (expando.resizer) { - var container =3D chart.options.maintainAspectRatio && node.parentNode; - var w =3D container ? container.clientWidth : 0; - listener(createEvent('resize', chart)); - if (container && container.clientWidth < w && chart.canvas) { - // If the container size shrank during chart resize, let's assume - // scrollbar appeared. So we resize again with the scrollbar visible - - // effectively making chart smaller and the scrollbar hidden again. - // Because we are inside `throttled`, and currently `ticking`, scroll - // events are ignored during this whole 2 resize process. - // If we assumed wrong and something else happened, we are resizing - // twice in a frame (potential performance issue) - listener(createEvent('resize', chart)); - } - } - })); - - // The resizer needs to be attached to the node parent, so we first need = to be - // sure that `node` is attached to the DOM before injecting the resizer e= lement. - watchForRender(node, function() { - if (expando.resizer) { - var container =3D node.parentNode; - if (container && container !=3D=3D resizer.parentNode) { - container.insertBefore(resizer, container.firstChild); - } - - // The container size might have changed, let's reset the resizer state. - resizer._reset(); - } - }); -} - -function removeResizeListener(node) { - var expando =3D node[EXPANDO_KEY] || {}; - var resizer =3D expando.resizer; - - delete expando.resizer; - unwatchForRender(node); - - if (resizer && resizer.parentNode) { - resizer.parentNode.removeChild(resizer); - } -} - -/** - * Injects CSS styles inline if the styles are not already present. - * @param {HTMLDocument|ShadowRoot} rootNode - the node to contain the . - * @param {string} css - the CSS to be injected. - */ -function injectCSS(rootNode, css) { - // https://stackoverflow.com/q/3922139 - var expando =3D rootNode[EXPANDO_KEY] || (rootNode[EXPANDO_KEY] =3D {}); - if (!expando.containsStyles) { - expando.containsStyles =3D true; - css =3D '/* Chart.js */\n' + css; - var style =3D document.createElement('style'); - style.setAttribute('type', 'text/css'); - style.appendChild(document.createTextNode(css)); - rootNode.appendChild(style); - } -} - -var platform_dom$2 =3D { - /** - * When `true`, prevents the automatic injection of the stylesheet requir= ed to - * correctly detect when the chart is added to the DOM and then resized. = This - * switch has been added to allow external stylesheet (`dist/Chart(.min)?= .js`) - * to be manually imported to make this library compatible with any CSP. - * See https://github.com/chartjs/Chart.js/issues/5208 - */ - disableCSSInjection: false, - - /** - * This property holds whether this platform is enabled for the current e= nvironment. - * Currently used by platform.js to select the proper implementation. - * @private - */ - _enabled: typeof window !=3D=3D 'undefined' && typeof document !=3D=3D 'u= ndefined', - - /** - * Initializes resources that depend on platform options. - * @param {HTMLCanvasElement} canvas - The Canvas element. - * @private - */ - _ensureLoaded: function(canvas) { - if (!this.disableCSSInjection) { - // If the canvas is in a shadow DOM, then the styles must also be inser= ted - // into the same shadow DOM. - // https://github.com/chartjs/Chart.js/issues/5763 - var root =3D canvas.getRootNode ? canvas.getRootNode() : document; - var targetNode =3D root.host ? root : document.head; - injectCSS(targetNode, stylesheet); - } - }, - - acquireContext: function(item, config) { - if (typeof item =3D=3D=3D 'string') { - item =3D document.getElementById(item); - } else if (item.length) { - // Support for array based queries (such as jQuery) - item =3D item[0]; - } - - if (item && item.canvas) { - // Support for any object associated to a canvas (including a context2d) - item =3D item.canvas; - } - - // To prevent canvas fingerprinting, some add-ons undefine the getContext - // method, for example: https://github.com/kkapsner/CanvasBlocker - // https://github.com/chartjs/Chart.js/issues/2807 - var context =3D item && item.getContext && item.getContext('2d'); - - // `instanceof HTMLCanvasElement/CanvasRenderingContext2D` fails when th= e item is - // inside an iframe or when running in a protected environment. We could= guess the - // types from their toString() value but let's keep things flexible and = assume it's - // a sufficient condition if the item has a context2D which has item as = `canvas`. - // https://github.com/chartjs/Chart.js/issues/3887 - // https://github.com/chartjs/Chart.js/issues/4102 - // https://github.com/chartjs/Chart.js/issues/4152 - if (context && context.canvas =3D=3D=3D item) { - // Load platform resources on first chart creation, to make it possible= to - // import the library before setting platform options. - this._ensureLoaded(item); - initCanvas(item, config); - return context; - } - - return null; - }, - - releaseContext: function(context) { - var canvas =3D context.canvas; - if (!canvas[EXPANDO_KEY]) { - return; - } - - var initial =3D canvas[EXPANDO_KEY].initial; - ['height', 'width'].forEach(function(prop) { - var value =3D initial[prop]; - if (helpers$1.isNullOrUndef(value)) { - canvas.removeAttribute(prop); - } else { - canvas.setAttribute(prop, value); - } - }); - - helpers$1.each(initial.style || {}, function(value, key) { - canvas.style[key] =3D value; - }); - - // The canvas render size might have been changed (and thus the state st= ack discarded), - // we can't use save() and restore() to restore the initial state. So ma= ke sure that at - // least the canvas context is reset to the default state by setting the= canvas width. - // https://www.w3.org/TR/2011/WD-html5-20110525/the-canvas-element.html - // eslint-disable-next-line no-self-assign - canvas.width =3D canvas.width; - - delete canvas[EXPANDO_KEY]; - }, - - addEventListener: function(chart, type, listener) { - var canvas =3D chart.canvas; - if (type =3D=3D=3D 'resize') { - // Note: the resize event is not supported on all browsers. - addResizeListener(canvas, listener, chart); - return; - } - - var expando =3D listener[EXPANDO_KEY] || (listener[EXPANDO_KEY] =3D {}); - var proxies =3D expando.proxies || (expando.proxies =3D {}); - var proxy =3D proxies[chart.id + '_' + type] =3D function(event) { - listener(fromNativeEvent(event, chart)); - }; - - addListener(canvas, type, proxy); - }, - - removeEventListener: function(chart, type, listener) { - var canvas =3D chart.canvas; - if (type =3D=3D=3D 'resize') { - // Note: the resize event is not supported on all browsers. - removeResizeListener(canvas); - return; - } - - var expando =3D listener[EXPANDO_KEY] || {}; - var proxies =3D expando.proxies || {}; - var proxy =3D proxies[chart.id + '_' + type]; - if (!proxy) { - return; - } - - removeListener(canvas, type, proxy); - } -}; - -// DEPRECATIONS - -/** - * Provided for backward compatibility, use EventTarget.addEventListener i= nstead. - * EventTarget.addEventListener compatibility: Chrome, Opera 7, Safari, FF= 1.5+, IE9+ - * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEv= entListener - * @function Chart.helpers.addEvent - * @deprecated since version 2.7.0 - * @todo remove at version 3 - * @private - */ -helpers$1.addEvent =3D addListener; - -/** - * Provided for backward compatibility, use EventTarget.removeEventListene= r instead. - * EventTarget.removeEventListener compatibility: Chrome, Opera 7, Safari,= FF1.5+, IE9+ - * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/remov= eEventListener - * @function Chart.helpers.removeEvent - * @deprecated since version 2.7.0 - * @todo remove at version 3 - * @private - */ -helpers$1.removeEvent =3D removeListener; - -// @TODO Make possible to select another platform at build time. -var implementation =3D platform_dom$2._enabled ? platform_dom$2 : platform= _basic; - -/** - * @namespace Chart.platform - * @see https://chartjs.gitbooks.io/proposals/content/Platform.html - * @since 2.4.0 - */ -var platform =3D helpers$1.extend({ - /** - * @since 2.7.0 - */ - initialize: function() {}, - - /** - * Called at chart construction time, returns a context2d instance implem= enting - * the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2= dcontext/}. - * @param {*} item - The native item from which to acquire context (platf= orm specific) - * @param {object} options - The chart options - * @returns {CanvasRenderingContext2D} context2d instance - */ - acquireContext: function() {}, - - /** - * Called at chart destruction time, releases any resources associated to= the context - * previously returned by the acquireContext() method. - * @param {CanvasRenderingContext2D} context - The context2d instance - * @returns {boolean} true if the method succeeded, else false - */ - releaseContext: function() {}, - - /** - * Registers the specified listener on the given chart. - * @param {Chart} chart - Chart from which to listen for event - * @param {string} type - The ({@link IEvent}) type to listen for - * @param {function} listener - Receives a notification (an object that i= mplements - * the {@link IEvent} interface) when an event of the specified type occu= rs. - */ - addEventListener: function() {}, - - /** - * Removes the specified listener previously registered with addEventList= ener. - * @param {Chart} chart - Chart from which to remove the listener - * @param {string} type - The ({@link IEvent}) type to remove - * @param {function} listener - The listener function to remove from the = event target. - */ - removeEventListener: function() {} - -}, implementation); - -core_defaults._set('global', { - plugins: {} -}); - -/** - * The plugin service singleton - * @namespace Chart.plugins - * @since 2.1.0 - */ -var core_plugins =3D { - /** - * Globally registered plugins. - * @private - */ - _plugins: [], - - /** - * This identifier is used to invalidate the descriptors cache attached t= o each chart - * when a global plugin is registered or unregistered. In this case, the = cache ID is - * incremented and descriptors are regenerated during following API calls. - * @private - */ - _cacheId: 0, - - /** - * Registers the given plugin(s) if not already registered. - * @param {IPlugin[]|IPlugin} plugins plugin instance(s). - */ - register: function(plugins) { - var p =3D this._plugins; - ([]).concat(plugins).forEach(function(plugin) { - if (p.indexOf(plugin) =3D=3D=3D -1) { - p.push(plugin); - } - }); - - this._cacheId++; - }, - - /** - * Unregisters the given plugin(s) only if registered. - * @param {IPlugin[]|IPlugin} plugins plugin instance(s). - */ - unregister: function(plugins) { - var p =3D this._plugins; - ([]).concat(plugins).forEach(function(plugin) { - var idx =3D p.indexOf(plugin); - if (idx !=3D=3D -1) { - p.splice(idx, 1); - } - }); - - this._cacheId++; - }, - - /** - * Remove all registered plugins. - * @since 2.1.5 - */ - clear: function() { - this._plugins =3D []; - this._cacheId++; - }, - - /** - * Returns the number of registered plugins? - * @returns {number} - * @since 2.1.5 - */ - count: function() { - return this._plugins.length; - }, - - /** - * Returns all registered plugin instances. - * @returns {IPlugin[]} array of plugin objects. - * @since 2.1.5 - */ - getAll: function() { - return this._plugins; - }, - - /** - * Calls enabled plugins for `chart` on the specified hook and with the g= iven args. - * This method immediately returns as soon as a plugin explicitly returns= false. The - * returned value can be used, for instance, to interrupt the current act= ion. - * @param {Chart} chart - The chart instance for which plugins should be = called. - * @param {string} hook - The name of the plugin method to call (e.g. 'be= foreUpdate'). - * @param {Array} [args] - Extra arguments to apply to the hook call. - * @returns {boolean} false if any of the plugins return false, else retu= rns true. - */ - notify: function(chart, hook, args) { - var descriptors =3D this.descriptors(chart); - var ilen =3D descriptors.length; - var i, descriptor, plugin, params, method; - - for (i =3D 0; i < ilen; ++i) { - descriptor =3D descriptors[i]; - plugin =3D descriptor.plugin; - method =3D plugin[hook]; - if (typeof method =3D=3D=3D 'function') { - params =3D [chart].concat(args || []); - params.push(descriptor.options); - if (method.apply(plugin, params) =3D=3D=3D false) { - return false; - } - } - } - - return true; - }, - - /** - * Returns descriptors of enabled plugins for the given chart. - * @returns {object[]} [{ plugin, options }] - * @private - */ - descriptors: function(chart) { - var cache =3D chart.$plugins || (chart.$plugins =3D {}); - if (cache.id =3D=3D=3D this._cacheId) { - return cache.descriptors; - } - - var plugins =3D []; - var descriptors =3D []; - var config =3D (chart && chart.config) || {}; - var options =3D (config.options && config.options.plugins) || {}; - - this._plugins.concat(config.plugins || []).forEach(function(plugin) { - var idx =3D plugins.indexOf(plugin); - if (idx !=3D=3D -1) { - return; - } - - var id =3D plugin.id; - var opts =3D options[id]; - if (opts =3D=3D=3D false) { - return; - } - - if (opts =3D=3D=3D true) { - opts =3D helpers$1.clone(core_defaults.global.plugins[id]); - } - - plugins.push(plugin); - descriptors.push({ - plugin: plugin, - options: opts || {} - }); - }); - - cache.descriptors =3D descriptors; - cache.id =3D this._cacheId; - return descriptors; - }, - - /** - * Invalidates cache for the given chart: descriptors hold a reference on= plugin option, - * but in some cases, this reference can be changed by the user when upda= ting options. - * https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167 - * @private - */ - _invalidate: function(chart) { - delete chart.$plugins; - } -}; - -var core_scaleService =3D { - // Scale registration object. Extensions can register new scale types (su= ch as log or DB scales) and then - // use the new chart options to grab the correct scale - constructors: {}, - // Use a registration function so that we can move to an ES6 map when we = no longer need to support - // old browsers - - // Scale config defaults - defaults: {}, - registerScaleType: function(type, scaleConstructor, scaleDefaults) { - this.constructors[type] =3D scaleConstructor; - this.defaults[type] =3D helpers$1.clone(scaleDefaults); - }, - getScaleConstructor: function(type) { - return this.constructors.hasOwnProperty(type) ? this.constructors[type] = : undefined; - }, - getScaleDefaults: function(type) { - // Return the scale defaults merged with the global settings so that we = always use the latest ones - return this.defaults.hasOwnProperty(type) ? helpers$1.merge({}, [core_de= faults.scale, this.defaults[type]]) : {}; - }, - updateScaleDefaults: function(type, additions) { - var me =3D this; - if (me.defaults.hasOwnProperty(type)) { - me.defaults[type] =3D helpers$1.extend(me.defaults[type], additions); - } - }, - addScalesToLayout: function(chart) { - // Adds each scale to the chart.boxes array to be sized accordingly - helpers$1.each(chart.scales, function(scale) { - // Set ILayoutItem parameters for backwards compatibility - scale.fullWidth =3D scale.options.fullWidth; - scale.position =3D scale.options.position; - scale.weight =3D scale.options.weight; - core_layouts.addBox(chart, scale); - }); - } -}; - -var valueOrDefault$8 =3D helpers$1.valueOrDefault; -var getRtlHelper =3D helpers$1.rtl.getRtlAdapter; - -core_defaults._set('global', { - tooltips: { - enabled: true, - custom: null, - mode: 'nearest', - position: 'average', - intersect: true, - backgroundColor: 'rgba(0,0,0,0.8)', - titleFontStyle: 'bold', - titleSpacing: 2, - titleMarginBottom: 6, - titleFontColor: '#fff', - titleAlign: 'left', - bodySpacing: 2, - bodyFontColor: '#fff', - bodyAlign: 'left', - footerFontStyle: 'bold', - footerSpacing: 2, - footerMarginTop: 6, - footerFontColor: '#fff', - footerAlign: 'left', - yPadding: 6, - xPadding: 6, - caretPadding: 2, - caretSize: 5, - cornerRadius: 6, - multiKeyBackground: '#fff', - displayColors: true, - borderColor: 'rgba(0,0,0,0)', - borderWidth: 0, - callbacks: { - // Args are: (tooltipItems, data) - beforeTitle: helpers$1.noop, - title: function(tooltipItems, data) { - var title =3D ''; - var labels =3D data.labels; - var labelCount =3D labels ? labels.length : 0; - - if (tooltipItems.length > 0) { - var item =3D tooltipItems[0]; - if (item.label) { - title =3D item.label; - } else if (item.xLabel) { - title =3D item.xLabel; - } else if (labelCount > 0 && item.index < labelCount) { - title =3D labels[item.index]; - } - } - - return title; - }, - afterTitle: helpers$1.noop, - - // Args are: (tooltipItems, data) - beforeBody: helpers$1.noop, - - // Args are: (tooltipItem, data) - beforeLabel: helpers$1.noop, - label: function(tooltipItem, data) { - var label =3D data.datasets[tooltipItem.datasetIndex].label || ''; - - if (label) { - label +=3D ': '; - } - if (!helpers$1.isNullOrUndef(tooltipItem.value)) { - label +=3D tooltipItem.value; - } else { - label +=3D tooltipItem.yLabel; - } - return label; - }, - labelColor: function(tooltipItem, chart) { - var meta =3D chart.getDatasetMeta(tooltipItem.datasetIndex); - var activeElement =3D meta.data[tooltipItem.index]; - var view =3D activeElement._view; - return { - borderColor: view.borderColor, - backgroundColor: view.backgroundColor - }; - }, - labelTextColor: function() { - return this._options.bodyFontColor; - }, - afterLabel: helpers$1.noop, - - // Args are: (tooltipItems, data) - afterBody: helpers$1.noop, - - // Args are: (tooltipItems, data) - beforeFooter: helpers$1.noop, - footer: helpers$1.noop, - afterFooter: helpers$1.noop - } - } -}); - -var positioners =3D { - /** - * Average mode places the tooltip at the average position of the element= s shown - * @function Chart.Tooltip.positioners.average - * @param elements {ChartElement[]} the elements being displayed in the t= ooltip - * @returns {object} tooltip position - */ - average: function(elements) { - if (!elements.length) { - return false; - } - - var i, len; - var x =3D 0; - var y =3D 0; - var count =3D 0; - - for (i =3D 0, len =3D elements.length; i < len; ++i) { - var el =3D elements[i]; - if (el && el.hasValue()) { - var pos =3D el.tooltipPosition(); - x +=3D pos.x; - y +=3D pos.y; - ++count; - } - } - - return { - x: x / count, - y: y / count - }; - }, - - /** - * Gets the tooltip position nearest of the item nearest to the event pos= ition - * @function Chart.Tooltip.positioners.nearest - * @param elements {Chart.Element[]} the tooltip elements - * @param eventPosition {object} the position of the event in canvas coor= dinates - * @returns {object} the tooltip position - */ - nearest: function(elements, eventPosition) { - var x =3D eventPosition.x; - var y =3D eventPosition.y; - var minDistance =3D Number.POSITIVE_INFINITY; - var i, len, nearestElement; - - for (i =3D 0, len =3D elements.length; i < len; ++i) { - var el =3D elements[i]; - if (el && el.hasValue()) { - var center =3D el.getCenterPoint(); - var d =3D helpers$1.distanceBetweenPoints(eventPosition, center); - - if (d < minDistance) { - minDistance =3D d; - nearestElement =3D el; - } - } - } - - if (nearestElement) { - var tp =3D nearestElement.tooltipPosition(); - x =3D tp.x; - y =3D tp.y; - } - - return { - x: x, - y: y - }; - } -}; - -// Helper to push or concat based on if the 2nd parameter is an array or n= ot -function pushOrConcat(base, toPush) { - if (toPush) { - if (helpers$1.isArray(toPush)) { - // base =3D base.concat(toPush); - Array.prototype.push.apply(base, toPush); - } else { - base.push(toPush); - } - } - - return base; -} - -/** - * Returns array of strings split by newline - * @param {string} value - The value to split by newline. - * @returns {string[]} value if newline present - Returned from String spl= it() method - * @function - */ -function splitNewlines(str) { - if ((typeof str =3D=3D=3D 'string' || str instanceof String) && str.index= Of('\n') > -1) { - return str.split('\n'); - } - return str; -} - - -/** - * Private helper to create a tooltip item model - * @param element - the chart element (point, arc, bar) to create the tool= tip item for - * @return new tooltip item - */ -function createTooltipItem(element) { - var xScale =3D element._xScale; - var yScale =3D element._yScale || element._scale; // handle radar || pola= rArea charts - var index =3D element._index; - var datasetIndex =3D element._datasetIndex; - var controller =3D element._chart.getDatasetMeta(datasetIndex).controller; - var indexScale =3D controller._getIndexScale(); - var valueScale =3D controller._getValueScale(); - - return { - xLabel: xScale ? xScale.getLabelForIndex(index, datasetIndex) : '', - yLabel: yScale ? yScale.getLabelForIndex(index, datasetIndex) : '', - label: indexScale ? '' + indexScale.getLabelForIndex(index, datasetIndex= ) : '', - value: valueScale ? '' + valueScale.getLabelForIndex(index, datasetIndex= ) : '', - index: index, - datasetIndex: datasetIndex, - x: element._model.x, - y: element._model.y - }; -} - -/** - * Helper to get the reset model for the tooltip - * @param tooltipOpts {object} the tooltip options - */ -function getBaseModel(tooltipOpts) { - var globalDefaults =3D core_defaults.global; - - return { - // Positioning - xPadding: tooltipOpts.xPadding, - yPadding: tooltipOpts.yPadding, - xAlign: tooltipOpts.xAlign, - yAlign: tooltipOpts.yAlign, - - // Drawing direction and text direction - rtl: tooltipOpts.rtl, - textDirection: tooltipOpts.textDirection, - - // Body - bodyFontColor: tooltipOpts.bodyFontColor, - _bodyFontFamily: valueOrDefault$8(tooltipOpts.bodyFontFamily, globalDefa= ults.defaultFontFamily), - _bodyFontStyle: valueOrDefault$8(tooltipOpts.bodyFontStyle, globalDefaul= ts.defaultFontStyle), - _bodyAlign: tooltipOpts.bodyAlign, - bodyFontSize: valueOrDefault$8(tooltipOpts.bodyFontSize, globalDefaults.= defaultFontSize), - bodySpacing: tooltipOpts.bodySpacing, - - // Title - titleFontColor: tooltipOpts.titleFontColor, - _titleFontFamily: valueOrDefault$8(tooltipOpts.titleFontFamily, globalDe= faults.defaultFontFamily), - _titleFontStyle: valueOrDefault$8(tooltipOpts.titleFontStyle, globalDefa= ults.defaultFontStyle), - titleFontSize: valueOrDefault$8(tooltipOpts.titleFontSize, globalDefault= s.defaultFontSize), - _titleAlign: tooltipOpts.titleAlign, - titleSpacing: tooltipOpts.titleSpacing, - titleMarginBottom: tooltipOpts.titleMarginBottom, - - // Footer - footerFontColor: tooltipOpts.footerFontColor, - _footerFontFamily: valueOrDefault$8(tooltipOpts.footerFontFamily, global= Defaults.defaultFontFamily), - _footerFontStyle: valueOrDefault$8(tooltipOpts.footerFontStyle, globalDe= faults.defaultFontStyle), - footerFontSize: valueOrDefault$8(tooltipOpts.footerFontSize, globalDefau= lts.defaultFontSize), - _footerAlign: tooltipOpts.footerAlign, - footerSpacing: tooltipOpts.footerSpacing, - footerMarginTop: tooltipOpts.footerMarginTop, - - // Appearance - caretSize: tooltipOpts.caretSize, - cornerRadius: tooltipOpts.cornerRadius, - backgroundColor: tooltipOpts.backgroundColor, - opacity: 0, - legendColorBackground: tooltipOpts.multiKeyBackground, - displayColors: tooltipOpts.displayColors, - borderColor: tooltipOpts.borderColor, - borderWidth: tooltipOpts.borderWidth - }; -} - -/** - * Get the size of the tooltip - */ -function getTooltipSize(tooltip, model) { - var ctx =3D tooltip._chart.ctx; - - var height =3D model.yPadding * 2; // Tooltip Padding - var width =3D 0; - - // Count of all lines in the body - var body =3D model.body; - var combinedBodyLength =3D body.reduce(function(count, bodyItem) { - return count + bodyItem.before.length + bodyItem.lines.length + bodyItem= .after.length; - }, 0); - combinedBodyLength +=3D model.beforeBody.length + model.afterBody.length; - - var titleLineCount =3D model.title.length; - var footerLineCount =3D model.footer.length; - var titleFontSize =3D model.titleFontSize; - var bodyFontSize =3D model.bodyFontSize; - var footerFontSize =3D model.footerFontSize; - - height +=3D titleLineCount * titleFontSize; // Title Lines - height +=3D titleLineCount ? (titleLineCount - 1) * model.titleSpacing : = 0; // Title Line Spacing - height +=3D titleLineCount ? model.titleMarginBottom : 0; // Title's bott= om Margin - height +=3D combinedBodyLength * bodyFontSize; // Body Lines - height +=3D combinedBodyLength ? (combinedBodyLength - 1) * model.bodySpa= cing : 0; // Body Line Spacing - height +=3D footerLineCount ? model.footerMarginTop : 0; // Footer Margin - height +=3D footerLineCount * (footerFontSize); // Footer Lines - height +=3D footerLineCount ? (footerLineCount - 1) * model.footerSpacing= : 0; // Footer Line Spacing - - // Title width - var widthPadding =3D 0; - var maxLineWidth =3D function(line) { - width =3D Math.max(width, ctx.measureText(line).width + widthPadding); - }; - - ctx.font =3D helpers$1.fontString(titleFontSize, model._titleFontStyle, m= odel._titleFontFamily); - helpers$1.each(model.title, maxLineWidth); - - // Body width - ctx.font =3D helpers$1.fontString(bodyFontSize, model._bodyFontStyle, mod= el._bodyFontFamily); - helpers$1.each(model.beforeBody.concat(model.afterBody), maxLineWidth); - - // Body lines may include some extra width due to the color box - widthPadding =3D model.displayColors ? (bodyFontSize + 2) : 0; - helpers$1.each(body, function(bodyItem) { - helpers$1.each(bodyItem.before, maxLineWidth); - helpers$1.each(bodyItem.lines, maxLineWidth); - helpers$1.each(bodyItem.after, maxLineWidth); - }); - - // Reset back to 0 - widthPadding =3D 0; - - // Footer width - ctx.font =3D helpers$1.fontString(footerFontSize, model._footerFontStyle,= model._footerFontFamily); - helpers$1.each(model.footer, maxLineWidth); - - // Add padding - width +=3D 2 * model.xPadding; - - return { - width: width, - height: height - }; -} - -/** - * Helper to get the alignment of a tooltip given the size - */ -function determineAlignment(tooltip, size) { - var model =3D tooltip._model; - var chart =3D tooltip._chart; - var chartArea =3D tooltip._chart.chartArea; - var xAlign =3D 'center'; - var yAlign =3D 'center'; - - if (model.y < size.height) { - yAlign =3D 'top'; - } else if (model.y > (chart.height - size.height)) { - yAlign =3D 'bottom'; - } - - var lf, rf; // functions to determine left, right alignment - var olf, orf; // functions to determine if left/right alignment causes to= oltip to go outside chart - var yf; // function to get the y alignment if the tooltip goes outside of= the left or right edges - var midX =3D (chartArea.left + chartArea.right) / 2; - var midY =3D (chartArea.top + chartArea.bottom) / 2; - - if (yAlign =3D=3D=3D 'center') { - lf =3D function(x) { - return x <=3D midX; - }; - rf =3D function(x) { - return x > midX; - }; - } else { - lf =3D function(x) { - return x <=3D (size.width / 2); - }; - rf =3D function(x) { - return x >=3D (chart.width - (size.width / 2)); - }; - } - - olf =3D function(x) { - return x + size.width + model.caretSize + model.caretPadding > chart.wid= th; - }; - orf =3D function(x) { - return x - size.width - model.caretSize - model.caretPadding < 0; - }; - yf =3D function(y) { - return y <=3D midY ? 'top' : 'bottom'; - }; - - if (lf(model.x)) { - xAlign =3D 'left'; - - // Is tooltip too wide and goes over the right side of the chart.? - if (olf(model.x)) { - xAlign =3D 'center'; - yAlign =3D yf(model.y); - } - } else if (rf(model.x)) { - xAlign =3D 'right'; - - // Is tooltip too wide and goes outside left edge of canvas? - if (orf(model.x)) { - xAlign =3D 'center'; - yAlign =3D yf(model.y); - } - } - - var opts =3D tooltip._options; - return { - xAlign: opts.xAlign ? opts.xAlign : xAlign, - yAlign: opts.yAlign ? opts.yAlign : yAlign - }; -} - -/** - * Helper to get the location a tooltip needs to be placed at given the in= itial position (via the vm) and the size and alignment - */ -function getBackgroundPoint(vm, size, alignment, chart) { - // Background Position - var x =3D vm.x; - var y =3D vm.y; - - var caretSize =3D vm.caretSize; - var caretPadding =3D vm.caretPadding; - var cornerRadius =3D vm.cornerRadius; - var xAlign =3D alignment.xAlign; - var yAlign =3D alignment.yAlign; - var paddingAndSize =3D caretSize + caretPadding; - var radiusAndPadding =3D cornerRadius + caretPadding; - - if (xAlign =3D=3D=3D 'right') { - x -=3D size.width; - } else if (xAlign =3D=3D=3D 'center') { - x -=3D (size.width / 2); - if (x + size.width > chart.width) { - x =3D chart.width - size.width; - } - if (x < 0) { - x =3D 0; - } - } - - if (yAlign =3D=3D=3D 'top') { - y +=3D paddingAndSize; - } else if (yAlign =3D=3D=3D 'bottom') { - y -=3D size.height + paddingAndSize; - } else { - y -=3D (size.height / 2); - } - - if (yAlign =3D=3D=3D 'center') { - if (xAlign =3D=3D=3D 'left') { - x +=3D paddingAndSize; - } else if (xAlign =3D=3D=3D 'right') { - x -=3D paddingAndSize; - } - } else if (xAlign =3D=3D=3D 'left') { - x -=3D radiusAndPadding; - } else if (xAlign =3D=3D=3D 'right') { - x +=3D radiusAndPadding; - } - - return { - x: x, - y: y - }; -} - -function getAlignedX(vm, align) { - return align =3D=3D=3D 'center' - ? vm.x + vm.width / 2 - : align =3D=3D=3D 'right' - ? vm.x + vm.width - vm.xPadding - : vm.x + vm.xPadding; -} - -/** - * Helper to build before and after body lines - */ -function getBeforeAfterBodyLines(callback) { - return pushOrConcat([], splitNewlines(callback)); -} - -var exports$4 =3D core_element.extend({ - initialize: function() { - this._model =3D getBaseModel(this._options); - this._lastActive =3D []; - }, - - // Get the title - // Args are: (tooltipItem, data) - getTitle: function() { - var me =3D this; - var opts =3D me._options; - var callbacks =3D opts.callbacks; - - var beforeTitle =3D callbacks.beforeTitle.apply(me, arguments); - var title =3D callbacks.title.apply(me, arguments); - var afterTitle =3D callbacks.afterTitle.apply(me, arguments); - - var lines =3D []; - lines =3D pushOrConcat(lines, splitNewlines(beforeTitle)); - lines =3D pushOrConcat(lines, splitNewlines(title)); - lines =3D pushOrConcat(lines, splitNewlines(afterTitle)); - - return lines; - }, - - // Args are: (tooltipItem, data) - getBeforeBody: function() { - return getBeforeAfterBodyLines(this._options.callbacks.beforeBody.apply(= this, arguments)); - }, - - // Args are: (tooltipItem, data) - getBody: function(tooltipItems, data) { - var me =3D this; - var callbacks =3D me._options.callbacks; - var bodyItems =3D []; - - helpers$1.each(tooltipItems, function(tooltipItem) { - var bodyItem =3D { - before: [], - lines: [], - after: [] - }; - pushOrConcat(bodyItem.before, splitNewlines(callbacks.beforeLabel.call(= me, tooltipItem, data))); - pushOrConcat(bodyItem.lines, callbacks.label.call(me, tooltipItem, data= )); - pushOrConcat(bodyItem.after, splitNewlines(callbacks.afterLabel.call(me= , tooltipItem, data))); - - bodyItems.push(bodyItem); - }); - - return bodyItems; - }, - - // Args are: (tooltipItem, data) - getAfterBody: function() { - return getBeforeAfterBodyLines(this._options.callbacks.afterBody.apply(t= his, arguments)); - }, - - // Get the footer and beforeFooter and afterFooter lines - // Args are: (tooltipItem, data) - getFooter: function() { - var me =3D this; - var callbacks =3D me._options.callbacks; - - var beforeFooter =3D callbacks.beforeFooter.apply(me, arguments); - var footer =3D callbacks.footer.apply(me, arguments); - var afterFooter =3D callbacks.afterFooter.apply(me, arguments); - - var lines =3D []; - lines =3D pushOrConcat(lines, splitNewlines(beforeFooter)); - lines =3D pushOrConcat(lines, splitNewlines(footer)); - lines =3D pushOrConcat(lines, splitNewlines(afterFooter)); - - return lines; - }, - - update: function(changed) { - var me =3D this; - var opts =3D me._options; - - // Need to regenerate the model because its faster than using extend and= it is necessary due to the optimization in Chart.Element.transition - // that does _view =3D _model if ease =3D=3D=3D 1. This causes the 2nd t= ooltip update to set properties in both the view and model at the same time - // which breaks any animations. - var existingModel =3D me._model; - var model =3D me._model =3D getBaseModel(opts); - var active =3D me._active; - - var data =3D me._data; - - // In the case where active.length =3D=3D=3D 0 we need to keep these at = existing values for good animations - var alignment =3D { - xAlign: existingModel.xAlign, - yAlign: existingModel.yAlign - }; - var backgroundPoint =3D { - x: existingModel.x, - y: existingModel.y - }; - var tooltipSize =3D { - width: existingModel.width, - height: existingModel.height - }; - var tooltipPosition =3D { - x: existingModel.caretX, - y: existingModel.caretY - }; - - var i, len; - - if (active.length) { - model.opacity =3D 1; - - var labelColors =3D []; - var labelTextColors =3D []; - tooltipPosition =3D positioners[opts.position].call(me, active, me._eve= ntPosition); - - var tooltipItems =3D []; - for (i =3D 0, len =3D active.length; i < len; ++i) { - tooltipItems.push(createTooltipItem(active[i])); - } - - // If the user provided a filter function, use it to modify the tooltip= items - if (opts.filter) { - tooltipItems =3D tooltipItems.filter(function(a) { - return opts.filter(a, data); - }); - } - - // If the user provided a sorting function, use it to modify the toolti= p items - if (opts.itemSort) { - tooltipItems =3D tooltipItems.sort(function(a, b) { - return opts.itemSort(a, b, data); - }); - } - - // Determine colors for boxes - helpers$1.each(tooltipItems, function(tooltipItem) { - labelColors.push(opts.callbacks.labelColor.call(me, tooltipItem, me._c= hart)); - labelTextColors.push(opts.callbacks.labelTextColor.call(me, tooltipIte= m, me._chart)); - }); - - - // Build the Text Lines - model.title =3D me.getTitle(tooltipItems, data); - model.beforeBody =3D me.getBeforeBody(tooltipItems, data); - model.body =3D me.getBody(tooltipItems, data); - model.afterBody =3D me.getAfterBody(tooltipItems, data); - model.footer =3D me.getFooter(tooltipItems, data); - - // Initial positioning and colors - model.x =3D tooltipPosition.x; - model.y =3D tooltipPosition.y; - model.caretPadding =3D opts.caretPadding; - model.labelColors =3D labelColors; - model.labelTextColors =3D labelTextColors; - - // data points - model.dataPoints =3D tooltipItems; - - // We need to determine alignment of the tooltip - tooltipSize =3D getTooltipSize(this, model); - alignment =3D determineAlignment(this, tooltipSize); - // Final Size and Position - backgroundPoint =3D getBackgroundPoint(model, tooltipSize, alignment, m= e._chart); - } else { - model.opacity =3D 0; - } - - model.xAlign =3D alignment.xAlign; - model.yAlign =3D alignment.yAlign; - model.x =3D backgroundPoint.x; - model.y =3D backgroundPoint.y; - model.width =3D tooltipSize.width; - model.height =3D tooltipSize.height; - - // Point where the caret on the tooltip points to - model.caretX =3D tooltipPosition.x; - model.caretY =3D tooltipPosition.y; - - me._model =3D model; - - if (changed && opts.custom) { - opts.custom.call(me, model); - } - - return me; - }, - - drawCaret: function(tooltipPoint, size) { - var ctx =3D this._chart.ctx; - var vm =3D this._view; - var caretPosition =3D this.getCaretPosition(tooltipPoint, size, vm); - - ctx.lineTo(caretPosition.x1, caretPosition.y1); - ctx.lineTo(caretPosition.x2, caretPosition.y2); - ctx.lineTo(caretPosition.x3, caretPosition.y3); - }, - getCaretPosition: function(tooltipPoint, size, vm) { - var x1, x2, x3, y1, y2, y3; - var caretSize =3D vm.caretSize; - var cornerRadius =3D vm.cornerRadius; - var xAlign =3D vm.xAlign; - var yAlign =3D vm.yAlign; - var ptX =3D tooltipPoint.x; - var ptY =3D tooltipPoint.y; - var width =3D size.width; - var height =3D size.height; - - if (yAlign =3D=3D=3D 'center') { - y2 =3D ptY + (height / 2); - - if (xAlign =3D=3D=3D 'left') { - x1 =3D ptX; - x2 =3D x1 - caretSize; - x3 =3D x1; - - y1 =3D y2 + caretSize; - y3 =3D y2 - caretSize; - } else { - x1 =3D ptX + width; - x2 =3D x1 + caretSize; - x3 =3D x1; - - y1 =3D y2 - caretSize; - y3 =3D y2 + caretSize; - } - } else { - if (xAlign =3D=3D=3D 'left') { - x2 =3D ptX + cornerRadius + (caretSize); - x1 =3D x2 - caretSize; - x3 =3D x2 + caretSize; - } else if (xAlign =3D=3D=3D 'right') { - x2 =3D ptX + width - cornerRadius - caretSize; - x1 =3D x2 - caretSize; - x3 =3D x2 + caretSize; - } else { - x2 =3D vm.caretX; - x1 =3D x2 - caretSize; - x3 =3D x2 + caretSize; - } - if (yAlign =3D=3D=3D 'top') { - y1 =3D ptY; - y2 =3D y1 - caretSize; - y3 =3D y1; - } else { - y1 =3D ptY + height; - y2 =3D y1 + caretSize; - y3 =3D y1; - // invert drawing order - var tmp =3D x3; - x3 =3D x1; - x1 =3D tmp; - } - } - return {x1: x1, x2: x2, x3: x3, y1: y1, y2: y2, y3: y3}; - }, - - drawTitle: function(pt, vm, ctx) { - var title =3D vm.title; - var length =3D title.length; - var titleFontSize, titleSpacing, i; - - if (length) { - var rtlHelper =3D getRtlHelper(vm.rtl, vm.x, vm.width); - - pt.x =3D getAlignedX(vm, vm._titleAlign); - - ctx.textAlign =3D rtlHelper.textAlign(vm._titleAlign); - ctx.textBaseline =3D 'middle'; - - titleFontSize =3D vm.titleFontSize; - titleSpacing =3D vm.titleSpacing; - - ctx.fillStyle =3D vm.titleFontColor; - ctx.font =3D helpers$1.fontString(titleFontSize, vm._titleFontStyle, vm= ._titleFontFamily); - - for (i =3D 0; i < length; ++i) { - ctx.fillText(title[i], rtlHelper.x(pt.x), pt.y + titleFontSize / 2); - pt.y +=3D titleFontSize + titleSpacing; // Line Height and spacing - - if (i + 1 =3D=3D=3D length) { - pt.y +=3D vm.titleMarginBottom - titleSpacing; // If Last, add margin= , remove spacing - } - } - } - }, - - drawBody: function(pt, vm, ctx) { - var bodyFontSize =3D vm.bodyFontSize; - var bodySpacing =3D vm.bodySpacing; - var bodyAlign =3D vm._bodyAlign; - var body =3D vm.body; - var drawColorBoxes =3D vm.displayColors; - var xLinePadding =3D 0; - var colorX =3D drawColorBoxes ? getAlignedX(vm, 'left') : 0; - - var rtlHelper =3D getRtlHelper(vm.rtl, vm.x, vm.width); - - var fillLineOfText =3D function(line) { - ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyFontSiz= e / 2); - pt.y +=3D bodyFontSize + bodySpacing; - }; - - var bodyItem, textColor, labelColors, lines, i, j, ilen, jlen; - var bodyAlignForCalculation =3D rtlHelper.textAlign(bodyAlign); - - ctx.textAlign =3D bodyAlign; - ctx.textBaseline =3D 'middle'; - ctx.font =3D helpers$1.fontString(bodyFontSize, vm._bodyFontStyle, vm._b= odyFontFamily); - - pt.x =3D getAlignedX(vm, bodyAlignForCalculation); - - // Before body lines - ctx.fillStyle =3D vm.bodyFontColor; - helpers$1.each(vm.beforeBody, fillLineOfText); - - xLinePadding =3D drawColorBoxes && bodyAlignForCalculation !=3D=3D 'righ= t' - ? bodyAlign =3D=3D=3D 'center' ? (bodyFontSize / 2 + 1) : (bodyFontSize= + 2) - : 0; - - // Draw body lines now - for (i =3D 0, ilen =3D body.length; i < ilen; ++i) { - bodyItem =3D body[i]; - textColor =3D vm.labelTextColors[i]; - labelColors =3D vm.labelColors[i]; - - ctx.fillStyle =3D textColor; - helpers$1.each(bodyItem.before, fillLineOfText); - - lines =3D bodyItem.lines; - for (j =3D 0, jlen =3D lines.length; j < jlen; ++j) { - // Draw Legend-like boxes if needed - if (drawColorBoxes) { - var rtlColorX =3D rtlHelper.x(colorX); - - // Fill a white rect so that colours merge nicely if the opacity is <= 1 - ctx.fillStyle =3D vm.legendColorBackground; - ctx.fillRect(rtlHelper.leftForLtr(rtlColorX, bodyFontSize), pt.y, bod= yFontSize, bodyFontSize); - - // Border - ctx.lineWidth =3D 1; - ctx.strokeStyle =3D labelColors.borderColor; - ctx.strokeRect(rtlHelper.leftForLtr(rtlColorX, bodyFontSize), pt.y, b= odyFontSize, bodyFontSize); - - // Inner square - ctx.fillStyle =3D labelColors.backgroundColor; - ctx.fillRect(rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), body= FontSize - 2), pt.y + 1, bodyFontSize - 2, bodyFontSize - 2); - ctx.fillStyle =3D textColor; - } - - fillLineOfText(lines[j]); - } - - helpers$1.each(bodyItem.after, fillLineOfText); - } - - // Reset back to 0 for after body - xLinePadding =3D 0; - - // After body lines - helpers$1.each(vm.afterBody, fillLineOfText); - pt.y -=3D bodySpacing; // Remove last body spacing - }, - - drawFooter: function(pt, vm, ctx) { - var footer =3D vm.footer; - var length =3D footer.length; - var footerFontSize, i; - - if (length) { - var rtlHelper =3D getRtlHelper(vm.rtl, vm.x, vm.width); - - pt.x =3D getAlignedX(vm, vm._footerAlign); - pt.y +=3D vm.footerMarginTop; - - ctx.textAlign =3D rtlHelper.textAlign(vm._footerAlign); - ctx.textBaseline =3D 'middle'; - - footerFontSize =3D vm.footerFontSize; - - ctx.fillStyle =3D vm.footerFontColor; - ctx.font =3D helpers$1.fontString(footerFontSize, vm._footerFontStyle, = vm._footerFontFamily); - - for (i =3D 0; i < length; ++i) { - ctx.fillText(footer[i], rtlHelper.x(pt.x), pt.y + footerFontSize / 2); - pt.y +=3D footerFontSize + vm.footerSpacing; - } - } - }, - - drawBackground: function(pt, vm, ctx, tooltipSize) { - ctx.fillStyle =3D vm.backgroundColor; - ctx.strokeStyle =3D vm.borderColor; - ctx.lineWidth =3D vm.borderWidth; - var xAlign =3D vm.xAlign; - var yAlign =3D vm.yAlign; - var x =3D pt.x; - var y =3D pt.y; - var width =3D tooltipSize.width; - var height =3D tooltipSize.height; - var radius =3D vm.cornerRadius; - - ctx.beginPath(); - ctx.moveTo(x + radius, y); - if (yAlign =3D=3D=3D 'top') { - this.drawCaret(pt, tooltipSize); - } - ctx.lineTo(x + width - radius, y); - ctx.quadraticCurveTo(x + width, y, x + width, y + radius); - if (yAlign =3D=3D=3D 'center' && xAlign =3D=3D=3D 'right') { - this.drawCaret(pt, tooltipSize); - } - ctx.lineTo(x + width, y + height - radius); - ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + heig= ht); - if (yAlign =3D=3D=3D 'bottom') { - this.drawCaret(pt, tooltipSize); - } - ctx.lineTo(x + radius, y + height); - ctx.quadraticCurveTo(x, y + height, x, y + height - radius); - if (yAlign =3D=3D=3D 'center' && xAlign =3D=3D=3D 'left') { - this.drawCaret(pt, tooltipSize); - } - ctx.lineTo(x, y + radius); - ctx.quadraticCurveTo(x, y, x + radius, y); - ctx.closePath(); - - ctx.fill(); - - if (vm.borderWidth > 0) { - ctx.stroke(); - } - }, - - draw: function() { - var ctx =3D this._chart.ctx; - var vm =3D this._view; - - if (vm.opacity =3D=3D=3D 0) { - return; - } - - var tooltipSize =3D { - width: vm.width, - height: vm.height - }; - var pt =3D { - x: vm.x, - y: vm.y - }; - - // IE11/Edge does not like very small opacities, so snap to 0 - var opacity =3D Math.abs(vm.opacity < 1e-3) ? 0 : vm.opacity; - - // Truthy/falsey value for empty tooltip - var hasTooltipContent =3D vm.title.length || vm.beforeBody.length || vm.= body.length || vm.afterBody.length || vm.footer.length; - - if (this._options.enabled && hasTooltipContent) { - ctx.save(); - ctx.globalAlpha =3D opacity; - - // Draw Background - this.drawBackground(pt, vm, ctx, tooltipSize); - - // Draw Title, Body, and Footer - pt.y +=3D vm.yPadding; - - helpers$1.rtl.overrideTextDirection(ctx, vm.textDirection); - - // Titles - this.drawTitle(pt, vm, ctx); - - // Body - this.drawBody(pt, vm, ctx); - - // Footer - this.drawFooter(pt, vm, ctx); - - helpers$1.rtl.restoreTextDirection(ctx, vm.textDirection); - - ctx.restore(); - } - }, - - /** - * Handle an event - * @private - * @param {IEvent} event - The event to handle - * @returns {boolean} true if the tooltip changed - */ - handleEvent: function(e) { - var me =3D this; - var options =3D me._options; - var changed =3D false; - - me._lastActive =3D me._lastActive || []; - - // Find Active Elements for tooltips - if (e.type =3D=3D=3D 'mouseout') { - me._active =3D []; - } else { - me._active =3D me._chart.getElementsAtEventForMode(e, options.mode, opt= ions); - if (options.reverse) { - me._active.reverse(); - } - } - - // Remember Last Actives - changed =3D !helpers$1.arrayEquals(me._active, me._lastActive); - - // Only handle target event on tooltip change - if (changed) { - me._lastActive =3D me._active; - - if (options.enabled || options.custom) { - me._eventPosition =3D { - x: e.x, - y: e.y - }; - - me.update(true); - me.pivot(); - } - } - - return changed; - } -}); - -/** - * @namespace Chart.Tooltip.positioners - */ -var positioners_1 =3D positioners; - -var core_tooltip =3D exports$4; -core_tooltip.positioners =3D positioners_1; - -var valueOrDefault$9 =3D helpers$1.valueOrDefault; - -core_defaults._set('global', { - elements: {}, - events: [ - 'mousemove', - 'mouseout', - 'click', - 'touchstart', - 'touchmove' - ], - hover: { - onHover: null, - mode: 'nearest', - intersect: true, - animationDuration: 400 - }, - onClick: null, - maintainAspectRatio: true, - responsive: true, - responsiveAnimationDuration: 0 -}); - -/** - * Recursively merge the given config objects representing the `scales` op= tion - * by incorporating scale defaults in `xAxes` and `yAxes` array items, then - * returns a deep copy of the result, thus doesn't alter inputs. - */ -function mergeScaleConfig(/* config objects ... */) { - return helpers$1.merge({}, [].slice.call(arguments), { - merger: function(key, target, source, options) { - if (key =3D=3D=3D 'xAxes' || key =3D=3D=3D 'yAxes') { - var slen =3D source[key].length; - var i, type, scale; - - if (!target[key]) { - target[key] =3D []; - } - - for (i =3D 0; i < slen; ++i) { - scale =3D source[key][i]; - type =3D valueOrDefault$9(scale.type, key =3D=3D=3D 'xAxes' ? 'catego= ry' : 'linear'); - - if (i >=3D target[key].length) { - target[key].push({}); - } - - if (!target[key][i].type || (scale.type && scale.type !=3D=3D target[= key][i].type)) { - // new/untyped scale or type changed: let's apply the new defaults - // then merge source scale to correctly overwrite the defaults. - helpers$1.merge(target[key][i], [core_scaleService.getScaleDefaults(= type), scale]); - } else { - // scales type are the same - helpers$1.merge(target[key][i], scale); - } - } - } else { - helpers$1._merger(key, target, source, options); - } - } - }); -} - -/** - * Recursively merge the given config objects as the root options by handl= ing - * default scale options for the `scales` and `scale` properties, then ret= urns - * a deep copy of the result, thus doesn't alter inputs. - */ -function mergeConfig(/* config objects ... */) { - return helpers$1.merge({}, [].slice.call(arguments), { - merger: function(key, target, source, options) { - var tval =3D target[key] || {}; - var sval =3D source[key]; - - if (key =3D=3D=3D 'scales') { - // scale config merging is complex. Add our own function here for that - target[key] =3D mergeScaleConfig(tval, sval); - } else if (key =3D=3D=3D 'scale') { - // used in polar area & radar charts since there is only one scale - target[key] =3D helpers$1.merge(tval, [core_scaleService.getScaleDefau= lts(sval.type), sval]); - } else { - helpers$1._merger(key, target, source, options); - } - } - }); -} - -function initConfig(config) { - config =3D config || {}; - - // Do NOT use mergeConfig for the data object because this method merges = arrays - // and so would change references to labels and datasets, preventing data= updates. - var data =3D config.data =3D config.data || {}; - data.datasets =3D data.datasets || []; - data.labels =3D data.labels || []; - - config.options =3D mergeConfig( - core_defaults.global, - core_defaults[config.type], - config.options || {}); - - return config; -} - -function updateConfig(chart) { - var newOptions =3D chart.options; - - helpers$1.each(chart.scales, function(scale) { - core_layouts.removeBox(chart, scale); - }); - - newOptions =3D mergeConfig( - core_defaults.global, - core_defaults[chart.config.type], - newOptions); - - chart.options =3D chart.config.options =3D newOptions; - chart.ensureScalesHaveIDs(); - chart.buildOrUpdateScales(); - - // Tooltip - chart.tooltip._options =3D newOptions.tooltips; - chart.tooltip.initialize(); -} - -function nextAvailableScaleId(axesOpts, prefix, index) { - var id; - var hasId =3D function(obj) { - return obj.id =3D=3D=3D id; - }; - - do { - id =3D prefix + index++; - } while (helpers$1.findIndex(axesOpts, hasId) >=3D 0); - - return id; -} - -function positionIsHorizontal(position) { - return position =3D=3D=3D 'top' || position =3D=3D=3D 'bottom'; -} - -function compare2Level(l1, l2) { - return function(a, b) { - return a[l1] =3D=3D=3D b[l1] - ? a[l2] - b[l2] - : a[l1] - b[l1]; - }; -} - -var Chart =3D function(item, config) { - this.construct(item, config); - return this; -}; - -helpers$1.extend(Chart.prototype, /** @lends Chart */ { - /** - * @private - */ - construct: function(item, config) { - var me =3D this; - - config =3D initConfig(config); - - var context =3D platform.acquireContext(item, config); - var canvas =3D context && context.canvas; - var height =3D canvas && canvas.height; - var width =3D canvas && canvas.width; - - me.id =3D helpers$1.uid(); - me.ctx =3D context; - me.canvas =3D canvas; - me.config =3D config; - me.width =3D width; - me.height =3D height; - me.aspectRatio =3D height ? width / height : null; - me.options =3D config.options; - me._bufferedRender =3D false; - me._layers =3D []; - - /** - * Provided for backward compatibility, Chart and Chart.Controller have = been merged, - * the "instance" still need to be defined since it might be called from= plugins. - * @prop Chart#chart - * @deprecated since version 2.6.0 - * @todo remove at version 3 - * @private - */ - me.chart =3D me; - me.controller =3D me; // chart.chart.controller #inception - - // Add the chart instance to the global namespace - Chart.instances[me.id] =3D me; - - // Define alias to the config data: `chart.data =3D=3D=3D chart.config.d= ata` - Object.defineProperty(me, 'data', { - get: function() { - return me.config.data; - }, - set: function(value) { - me.config.data =3D value; - } - }); - - if (!context || !canvas) { - // The given item is not a compatible context2d element, let's return b= efore finalizing - // the chart initialization but after setting basic chart / controller = properties that - // can help to figure out that the chart is not valid (e.g chart.canvas= !=3D=3D null); - // https://github.com/chartjs/Chart.js/issues/2807 - console.error("Failed to create chart: can't acquire context from the g= iven item"); - return; - } - - me.initialize(); - me.update(); - }, - - /** - * @private - */ - initialize: function() { - var me =3D this; - - // Before init plugin notification - core_plugins.notify(me, 'beforeInit'); - - helpers$1.retinaScale(me, me.options.devicePixelRatio); - - me.bindEvents(); - - if (me.options.responsive) { - // Initial resize before chart draws (must be silent to preserve initia= l animations). - me.resize(true); - } - - me.initToolTip(); - - // After init plugin notification - core_plugins.notify(me, 'afterInit'); - - return me; - }, - - clear: function() { - helpers$1.canvas.clear(this); - return this; - }, - - stop: function() { - // Stops any current animation loop occurring - core_animations.cancelAnimation(this); - return this; - }, - - resize: function(silent) { - var me =3D this; - var options =3D me.options; - var canvas =3D me.canvas; - var aspectRatio =3D (options.maintainAspectRatio && me.aspectRatio) || n= ull; - - // the canvas render width and height will be casted to integers so make= sure that - // the canvas display style uses the same integer values to avoid blurri= ng effect. - - // Set to 0 instead of canvas.size because the size defaults to 300x150 = if the element is collapsed - var newWidth =3D Math.max(0, Math.floor(helpers$1.getMaximumWidth(canvas= ))); - var newHeight =3D Math.max(0, Math.floor(aspectRatio ? newWidth / aspect= Ratio : helpers$1.getMaximumHeight(canvas))); - - if (me.width =3D=3D=3D newWidth && me.height =3D=3D=3D newHeight) { - return; - } - - canvas.width =3D me.width =3D newWidth; - canvas.height =3D me.height =3D newHeight; - canvas.style.width =3D newWidth + 'px'; - canvas.style.height =3D newHeight + 'px'; - - helpers$1.retinaScale(me, options.devicePixelRatio); - - if (!silent) { - // Notify any plugins about the resize - var newSize =3D {width: newWidth, height: newHeight}; - core_plugins.notify(me, 'resize', [newSize]); - - // Notify of resize - if (options.onResize) { - options.onResize(me, newSize); - } - - me.stop(); - me.update({ - duration: options.responsiveAnimationDuration - }); - } - }, - - ensureScalesHaveIDs: function() { - var options =3D this.options; - var scalesOptions =3D options.scales || {}; - var scaleOptions =3D options.scale; - - helpers$1.each(scalesOptions.xAxes, function(xAxisOptions, index) { - if (!xAxisOptions.id) { - xAxisOptions.id =3D nextAvailableScaleId(scalesOptions.xAxes, 'x-axis-= ', index); - } - }); - - helpers$1.each(scalesOptions.yAxes, function(yAxisOptions, index) { - if (!yAxisOptions.id) { - yAxisOptions.id =3D nextAvailableScaleId(scalesOptions.yAxes, 'y-axis-= ', index); - } - }); - - if (scaleOptions) { - scaleOptions.id =3D scaleOptions.id || 'scale'; - } - }, - - /** - * Builds a map of scale ID to scale object for future lookup. - */ - buildOrUpdateScales: function() { - var me =3D this; - var options =3D me.options; - var scales =3D me.scales || {}; - var items =3D []; - var updated =3D Object.keys(scales).reduce(function(obj, id) { - obj[id] =3D false; - return obj; - }, {}); - - if (options.scales) { - items =3D items.concat( - (options.scales.xAxes || []).map(function(xAxisOptions) { - return {options: xAxisOptions, dtype: 'category', dposition: 'bottom'= }; - }), - (options.scales.yAxes || []).map(function(yAxisOptions) { - return {options: yAxisOptions, dtype: 'linear', dposition: 'left'}; - }) - ); - } - - if (options.scale) { - items.push({ - options: options.scale, - dtype: 'radialLinear', - isDefault: true, - dposition: 'chartArea' - }); - } - - helpers$1.each(items, function(item) { - var scaleOptions =3D item.options; - var id =3D scaleOptions.id; - var scaleType =3D valueOrDefault$9(scaleOptions.type, item.dtype); - - if (positionIsHorizontal(scaleOptions.position) !=3D=3D positionIsHoriz= ontal(item.dposition)) { - scaleOptions.position =3D item.dposition; - } - - updated[id] =3D true; - var scale =3D null; - if (id in scales && scales[id].type =3D=3D=3D scaleType) { - scale =3D scales[id]; - scale.options =3D scaleOptions; - scale.ctx =3D me.ctx; - scale.chart =3D me; - } else { - var scaleClass =3D core_scaleService.getScaleConstructor(scaleType); - if (!scaleClass) { - return; - } - scale =3D new scaleClass({ - id: id, - type: scaleType, - options: scaleOptions, - ctx: me.ctx, - chart: me - }); - scales[scale.id] =3D scale; - } - - scale.mergeTicksOptions(); - - // TODO(SB): I think we should be able to remove this custom case (opti= ons.scale) - // and consider it as a regular scale part of the "scales"" map only! T= his would - // make the logic easier and remove some useless? custom code. - if (item.isDefault) { - me.scale =3D scale; - } - }); - // clear up discarded scales - helpers$1.each(updated, function(hasUpdated, id) { - if (!hasUpdated) { - delete scales[id]; - } - }); - - me.scales =3D scales; - - core_scaleService.addScalesToLayout(this); - }, - - buildOrUpdateControllers: function() { - var me =3D this; - var newControllers =3D []; - var datasets =3D me.data.datasets; - var i, ilen; - - for (i =3D 0, ilen =3D datasets.length; i < ilen; i++) { - var dataset =3D datasets[i]; - var meta =3D me.getDatasetMeta(i); - var type =3D dataset.type || me.config.type; - - if (meta.type && meta.type !=3D=3D type) { - me.destroyDatasetMeta(i); - meta =3D me.getDatasetMeta(i); - } - meta.type =3D type; - meta.order =3D dataset.order || 0; - meta.index =3D i; - - if (meta.controller) { - meta.controller.updateIndex(i); - meta.controller.linkScales(); - } else { - var ControllerClass =3D controllers[meta.type]; - if (ControllerClass =3D=3D=3D undefined) { - throw new Error('"' + meta.type + '" is not a chart type.'); - } - - meta.controller =3D new ControllerClass(me, i); - newControllers.push(meta.controller); - } - } - - return newControllers; - }, - - /** - * Reset the elements of all datasets - * @private - */ - resetElements: function() { - var me =3D this; - helpers$1.each(me.data.datasets, function(dataset, datasetIndex) { - me.getDatasetMeta(datasetIndex).controller.reset(); - }, me); - }, - - /** - * Resets the chart back to it's state before the initial animation - */ - reset: function() { - this.resetElements(); - this.tooltip.initialize(); - }, - - update: function(config) { - var me =3D this; - var i, ilen; - - if (!config || typeof config !=3D=3D 'object') { - // backwards compatibility - config =3D { - duration: config, - lazy: arguments[1] - }; - } - - updateConfig(me); - - // plugins options references might have change, let's invalidate the ca= che - // https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167 - core_plugins._invalidate(me); - - if (core_plugins.notify(me, 'beforeUpdate') =3D=3D=3D false) { - return; - } - - // In case the entire data object changed - me.tooltip._data =3D me.data; - - // Make sure dataset controllers are updated and new controllers are res= et - var newControllers =3D me.buildOrUpdateControllers(); - - // Make sure all dataset controllers have correct meta data counts - for (i =3D 0, ilen =3D me.data.datasets.length; i < ilen; i++) { - me.getDatasetMeta(i).controller.buildOrUpdateElements(); - } - - me.updateLayout(); - - // Can only reset the new controllers after the scales have been updated - if (me.options.animation && me.options.animation.duration) { - helpers$1.each(newControllers, function(controller) { - controller.reset(); - }); - } - - me.updateDatasets(); - - // Need to reset tooltip in case it is displayed with elements that are = removed - // after update. - me.tooltip.initialize(); - - // Last active contains items that were previously in the tooltip. - // When we reset the tooltip, we need to clear it - me.lastActive =3D []; - - // Do this before render so that any plugins that need final scale updat= es can use it - core_plugins.notify(me, 'afterUpdate'); - - me._layers.sort(compare2Level('z', '_idx')); - - if (me._bufferedRender) { - me._bufferedRequest =3D { - duration: config.duration, - easing: config.easing, - lazy: config.lazy - }; - } else { - me.render(config); - } - }, - - /** - * Updates the chart layout unless a plugin returns `false` to the `befor= eLayout` - * hook, in which case, plugins will not be called on `afterLayout`. - * @private - */ - updateLayout: function() { - var me =3D this; - - if (core_plugins.notify(me, 'beforeLayout') =3D=3D=3D false) { - return; - } - - core_layouts.update(this, this.width, this.height); - - me._layers =3D []; - helpers$1.each(me.boxes, function(box) { - // _configure is called twice, once in core.scale.update and once here. - // Here the boxes are fully updated and at their final positions. - if (box._configure) { - box._configure(); - } - me._layers.push.apply(me._layers, box._layers()); - }, me); - - me._layers.forEach(function(item, index) { - item._idx =3D index; - }); - - /** - * Provided for backward compatibility, use `afterLayout` instead. - * @method IPlugin#afterScaleUpdate - * @deprecated since version 2.5.0 - * @todo remove at version 3 - * @private - */ - core_plugins.notify(me, 'afterScaleUpdate'); - core_plugins.notify(me, 'afterLayout'); - }, - - /** - * Updates all datasets unless a plugin returns `false` to the `beforeDat= asetsUpdate` - * hook, in which case, plugins will not be called on `afterDatasetsUpdat= e`. - * @private - */ - updateDatasets: function() { - var me =3D this; - - if (core_plugins.notify(me, 'beforeDatasetsUpdate') =3D=3D=3D false) { - return; - } - - for (var i =3D 0, ilen =3D me.data.datasets.length; i < ilen; ++i) { - me.updateDataset(i); - } - - core_plugins.notify(me, 'afterDatasetsUpdate'); - }, - - /** - * Updates dataset at index unless a plugin returns `false` to the `befor= eDatasetUpdate` - * hook, in which case, plugins will not be called on `afterDatasetUpdate= `. - * @private - */ - updateDataset: function(index) { - var me =3D this; - var meta =3D me.getDatasetMeta(index); - var args =3D { - meta: meta, - index: index - }; - - if (core_plugins.notify(me, 'beforeDatasetUpdate', [args]) =3D=3D=3D fal= se) { - return; - } - - meta.controller._update(); - - core_plugins.notify(me, 'afterDatasetUpdate', [args]); - }, - - render: function(config) { - var me =3D this; - - if (!config || typeof config !=3D=3D 'object') { - // backwards compatibility - config =3D { - duration: config, - lazy: arguments[1] - }; - } - - var animationOptions =3D me.options.animation; - var duration =3D valueOrDefault$9(config.duration, animationOptions && a= nimationOptions.duration); - var lazy =3D config.lazy; - - if (core_plugins.notify(me, 'beforeRender') =3D=3D=3D false) { - return; - } - - var onComplete =3D function(animation) { - core_plugins.notify(me, 'afterRender'); - helpers$1.callback(animationOptions && animationOptions.onComplete, [an= imation], me); - }; - - if (animationOptions && duration) { - var animation =3D new core_animation({ - numSteps: duration / 16.66, // 60 fps - easing: config.easing || animationOptions.easing, - - render: function(chart, animationObject) { - var easingFunction =3D helpers$1.easing.effects[animationObject.easin= g]; - var currentStep =3D animationObject.currentStep; - var stepDecimal =3D currentStep / animationObject.numSteps; - - chart.draw(easingFunction(stepDecimal), stepDecimal, currentStep); - }, - - onAnimationProgress: animationOptions.onProgress, - onAnimationComplete: onComplete - }); - - core_animations.addAnimation(me, animation, duration, lazy); - } else { - me.draw(); - - // See https://github.com/chartjs/Chart.js/issues/3781 - onComplete(new core_animation({numSteps: 0, chart: me})); - } - - return me; - }, - - draw: function(easingValue) { - var me =3D this; - var i, layers; - - me.clear(); - - if (helpers$1.isNullOrUndef(easingValue)) { - easingValue =3D 1; - } - - me.transition(easingValue); - - if (me.width <=3D 0 || me.height <=3D 0) { - return; - } - - if (core_plugins.notify(me, 'beforeDraw', [easingValue]) =3D=3D=3D false= ) { - return; - } - - // Because of plugin hooks (before/afterDatasetsDraw), datasets can't - // currently be part of layers. Instead, we draw - // layers <=3D 0 before(default, backward compat), and the rest after - layers =3D me._layers; - for (i =3D 0; i < layers.length && layers[i].z <=3D 0; ++i) { - layers[i].draw(me.chartArea); - } - - me.drawDatasets(easingValue); - - // Rest of layers - for (; i < layers.length; ++i) { - layers[i].draw(me.chartArea); - } - - me._drawTooltip(easingValue); - - core_plugins.notify(me, 'afterDraw', [easingValue]); - }, - - /** - * @private - */ - transition: function(easingValue) { - var me =3D this; - - for (var i =3D 0, ilen =3D (me.data.datasets || []).length; i < ilen; ++= i) { - if (me.isDatasetVisible(i)) { - me.getDatasetMeta(i).controller.transition(easingValue); - } - } - - me.tooltip.transition(easingValue); - }, - - /** - * @private - */ - _getSortedDatasetMetas: function(filterVisible) { - var me =3D this; - var datasets =3D me.data.datasets || []; - var result =3D []; - var i, ilen; - - for (i =3D 0, ilen =3D datasets.length; i < ilen; ++i) { - if (!filterVisible || me.isDatasetVisible(i)) { - result.push(me.getDatasetMeta(i)); - } - } - - result.sort(compare2Level('order', 'index')); - - return result; - }, - - /** - * @private - */ - _getSortedVisibleDatasetMetas: function() { - return this._getSortedDatasetMetas(true); - }, - - /** - * Draws all datasets unless a plugin returns `false` to the `beforeDatas= etsDraw` - * hook, in which case, plugins will not be called on `afterDatasetsDraw`. - * @private - */ - drawDatasets: function(easingValue) { - var me =3D this; - var metasets, i; - - if (core_plugins.notify(me, 'beforeDatasetsDraw', [easingValue]) =3D=3D= =3D false) { - return; - } - - metasets =3D me._getSortedVisibleDatasetMetas(); - for (i =3D metasets.length - 1; i >=3D 0; --i) { - me.drawDataset(metasets[i], easingValue); - } - - core_plugins.notify(me, 'afterDatasetsDraw', [easingValue]); - }, - - /** - * Draws dataset at index unless a plugin returns `false` to the `beforeD= atasetDraw` - * hook, in which case, plugins will not be called on `afterDatasetDraw`. - * @private - */ - drawDataset: function(meta, easingValue) { - var me =3D this; - var args =3D { - meta: meta, - index: meta.index, - easingValue: easingValue - }; - - if (core_plugins.notify(me, 'beforeDatasetDraw', [args]) =3D=3D=3D false= ) { - return; - } - - meta.controller.draw(easingValue); - - core_plugins.notify(me, 'afterDatasetDraw', [args]); - }, - - /** - * Draws tooltip unless a plugin returns `false` to the `beforeTooltipDra= w` - * hook, in which case, plugins will not be called on `afterTooltipDraw`. - * @private - */ - _drawTooltip: function(easingValue) { - var me =3D this; - var tooltip =3D me.tooltip; - var args =3D { - tooltip: tooltip, - easingValue: easingValue - }; - - if (core_plugins.notify(me, 'beforeTooltipDraw', [args]) =3D=3D=3D false= ) { - return; - } - - tooltip.draw(); - - core_plugins.notify(me, 'afterTooltipDraw', [args]); - }, - - /** - * Get the single element that was clicked on - * @return An object containing the dataset index and element index of th= e matching element. Also contains the rectangle that was draw - */ - getElementAtEvent: function(e) { - return core_interaction.modes.single(this, e); - }, - - getElementsAtEvent: function(e) { - return core_interaction.modes.label(this, e, {intersect: true}); - }, - - getElementsAtXAxis: function(e) { - return core_interaction.modes['x-axis'](this, e, {intersect: true}); - }, - - getElementsAtEventForMode: function(e, mode, options) { - var method =3D core_interaction.modes[mode]; - if (typeof method =3D=3D=3D 'function') { - return method(this, e, options); - } - - return []; - }, - - getDatasetAtEvent: function(e) { - return core_interaction.modes.dataset(this, e, {intersect: true}); - }, - - getDatasetMeta: function(datasetIndex) { - var me =3D this; - var dataset =3D me.data.datasets[datasetIndex]; - if (!dataset._meta) { - dataset._meta =3D {}; - } - - var meta =3D dataset._meta[me.id]; - if (!meta) { - meta =3D dataset._meta[me.id] =3D { - type: null, - data: [], - dataset: null, - controller: null, - hidden: null, // See isDatasetVisible() comment - xAxisID: null, - yAxisID: null, - order: dataset.order || 0, - index: datasetIndex - }; - } - - return meta; - }, - - getVisibleDatasetCount: function() { - var count =3D 0; - for (var i =3D 0, ilen =3D this.data.datasets.length; i < ilen; ++i) { - if (this.isDatasetVisible(i)) { - count++; - } - } - return count; - }, - - isDatasetVisible: function(datasetIndex) { - var meta =3D this.getDatasetMeta(datasetIndex); - - // meta.hidden is a per chart dataset hidden flag override with 3 states= : if true or false, - // the dataset.hidden value is ignored, else if null, the dataset hidden= state is returned. - return typeof meta.hidden =3D=3D=3D 'boolean' ? !meta.hidden : !this.dat= a.datasets[datasetIndex].hidden; - }, - - generateLegend: function() { - return this.options.legendCallback(this); - }, - - /** - * @private - */ - destroyDatasetMeta: function(datasetIndex) { - var id =3D this.id; - var dataset =3D this.data.datasets[datasetIndex]; - var meta =3D dataset._meta && dataset._meta[id]; - - if (meta) { - meta.controller.destroy(); - delete dataset._meta[id]; - } - }, - - destroy: function() { - var me =3D this; - var canvas =3D me.canvas; - var i, ilen; - - me.stop(); - - // dataset controllers need to cleanup associated data - for (i =3D 0, ilen =3D me.data.datasets.length; i < ilen; ++i) { - me.destroyDatasetMeta(i); - } - - if (canvas) { - me.unbindEvents(); - helpers$1.canvas.clear(me); - platform.releaseContext(me.ctx); - me.canvas =3D null; - me.ctx =3D null; - } - - core_plugins.notify(me, 'destroy'); - - delete Chart.instances[me.id]; - }, - - toBase64Image: function() { - return this.canvas.toDataURL.apply(this.canvas, arguments); - }, - - initToolTip: function() { - var me =3D this; - me.tooltip =3D new core_tooltip({ - _chart: me, - _chartInstance: me, // deprecated, backward compatibility - _data: me.data, - _options: me.options.tooltips - }, me); - }, - - /** - * @private - */ - bindEvents: function() { - var me =3D this; - var listeners =3D me._listeners =3D {}; - var listener =3D function() { - me.eventHandler.apply(me, arguments); - }; - - helpers$1.each(me.options.events, function(type) { - platform.addEventListener(me, type, listener); - listeners[type] =3D listener; - }); - - // Elements used to detect size change should not be injected for non re= sponsive charts. - // See https://github.com/chartjs/Chart.js/issues/2210 - if (me.options.responsive) { - listener =3D function() { - me.resize(); - }; - - platform.addEventListener(me, 'resize', listener); - listeners.resize =3D listener; - } - }, - - /** - * @private - */ - unbindEvents: function() { - var me =3D this; - var listeners =3D me._listeners; - if (!listeners) { - return; - } - - delete me._listeners; - helpers$1.each(listeners, function(listener, type) { - platform.removeEventListener(me, type, listener); - }); - }, - - updateHoverStyle: function(elements, mode, enabled) { - var prefix =3D enabled ? 'set' : 'remove'; - var element, i, ilen; - - for (i =3D 0, ilen =3D elements.length; i < ilen; ++i) { - element =3D elements[i]; - if (element) { - this.getDatasetMeta(element._datasetIndex).controller[prefix + 'HoverS= tyle'](element); - } - } - - if (mode =3D=3D=3D 'dataset') { - this.getDatasetMeta(elements[0]._datasetIndex).controller['_' + prefix = + 'DatasetHoverStyle'](); - } - }, - - /** - * @private - */ - eventHandler: function(e) { - var me =3D this; - var tooltip =3D me.tooltip; - - if (core_plugins.notify(me, 'beforeEvent', [e]) =3D=3D=3D false) { - return; - } - - // Buffer any update calls so that renders do not occur - me._bufferedRender =3D true; - me._bufferedRequest =3D null; - - var changed =3D me.handleEvent(e); - // for smooth tooltip animations issue #4989 - // the tooltip should be the source of change - // Animation check workaround: - // tooltip._start will be null when tooltip isn't animating - if (tooltip) { - changed =3D tooltip._start - ? tooltip.handleEvent(e) - : changed | tooltip.handleEvent(e); - } - - core_plugins.notify(me, 'afterEvent', [e]); - - var bufferedRequest =3D me._bufferedRequest; - if (bufferedRequest) { - // If we have an update that was triggered, we need to do a normal rend= er - me.render(bufferedRequest); - } else if (changed && !me.animating) { - // If entering, leaving, or changing elements, animate the change via p= ivot - me.stop(); - - // We only need to render at this point. Updating will cause scales to = be - // recomputed generating flicker & using more memory than necessary. - me.render({ - duration: me.options.hover.animationDuration, - lazy: true - }); - } - - me._bufferedRender =3D false; - me._bufferedRequest =3D null; - - return me; - }, - - /** - * Handle an event - * @private - * @param {IEvent} event the event to handle - * @return {boolean} true if the chart needs to re-render - */ - handleEvent: function(e) { - var me =3D this; - var options =3D me.options || {}; - var hoverOptions =3D options.hover; - var changed =3D false; - - me.lastActive =3D me.lastActive || []; - - // Find Active Elements for hover and tooltips - if (e.type =3D=3D=3D 'mouseout') { - me.active =3D []; - } else { - me.active =3D me.getElementsAtEventForMode(e, hoverOptions.mode, hoverO= ptions); - } - - // Invoke onHover hook - // Need to call with native event here to not break backwards compatibil= ity - helpers$1.callback(options.onHover || options.hover.onHover, [e.native, = me.active], me); - - if (e.type =3D=3D=3D 'mouseup' || e.type =3D=3D=3D 'click') { - if (options.onClick) { - // Use e.native here for backwards compatibility - options.onClick.call(me, e.native, me.active); - } - } - - // Remove styling for last active (even if it may still be active) - if (me.lastActive.length) { - me.updateHoverStyle(me.lastActive, hoverOptions.mode, false); - } - - // Built in hover styling - if (me.active.length && hoverOptions.mode) { - me.updateHoverStyle(me.active, hoverOptions.mode, true); - } - - changed =3D !helpers$1.arrayEquals(me.active, me.lastActive); - - // Remember Last Actives - me.lastActive =3D me.active; - - return changed; - } -}); - -/** - * NOTE(SB) We actually don't use this container anymore but we need to ke= ep it - * for backward compatibility. Though, it can still be useful for plugins = that - * would need to work on multiple charts?! - */ -Chart.instances =3D {}; - -var core_controller =3D Chart; - -// DEPRECATIONS - -/** - * Provided for backward compatibility, use Chart instead. - * @class Chart.Controller - * @deprecated since version 2.6 - * @todo remove at version 3 - * @private - */ -Chart.Controller =3D Chart; - -/** - * Provided for backward compatibility, not available anymore. - * @namespace Chart - * @deprecated since version 2.8 - * @todo remove at version 3 - * @private - */ -Chart.types =3D {}; - -/** - * Provided for backward compatibility, not available anymore. - * @namespace Chart.helpers.configMerge - * @deprecated since version 2.8.0 - * @todo remove at version 3 - * @private - */ -helpers$1.configMerge =3D mergeConfig; - -/** - * Provided for backward compatibility, not available anymore. - * @namespace Chart.helpers.scaleMerge - * @deprecated since version 2.8.0 - * @todo remove at version 3 - * @private - */ -helpers$1.scaleMerge =3D mergeScaleConfig; - -var core_helpers =3D function() { - - // -- Basic js utility methods - - helpers$1.where =3D function(collection, filterCallback) { - if (helpers$1.isArray(collection) && Array.prototype.filter) { - return collection.filter(filterCallback); - } - var filtered =3D []; - - helpers$1.each(collection, function(item) { - if (filterCallback(item)) { - filtered.push(item); - } - }); - - return filtered; - }; - helpers$1.findIndex =3D Array.prototype.findIndex ? - function(array, callback, scope) { - return array.findIndex(callback, scope); - } : - function(array, callback, scope) { - scope =3D scope =3D=3D=3D undefined ? array : scope; - for (var i =3D 0, ilen =3D array.length; i < ilen; ++i) { - if (callback.call(scope, array[i], i, array)) { - return i; - } - } - return -1; - }; - helpers$1.findNextWhere =3D function(arrayToSearch, filterCallback, start= Index) { - // Default to start of the array - if (helpers$1.isNullOrUndef(startIndex)) { - startIndex =3D -1; - } - for (var i =3D startIndex + 1; i < arrayToSearch.length; i++) { - var currentItem =3D arrayToSearch[i]; - if (filterCallback(currentItem)) { - return currentItem; - } - } - }; - helpers$1.findPreviousWhere =3D function(arrayToSearch, filterCallback, s= tartIndex) { - // Default to end of the array - if (helpers$1.isNullOrUndef(startIndex)) { - startIndex =3D arrayToSearch.length; - } - for (var i =3D startIndex - 1; i >=3D 0; i--) { - var currentItem =3D arrayToSearch[i]; - if (filterCallback(currentItem)) { - return currentItem; - } - } - }; - - // -- Math methods - helpers$1.isNumber =3D function(n) { - return !isNaN(parseFloat(n)) && isFinite(n); - }; - helpers$1.almostEquals =3D function(x, y, epsilon) { - return Math.abs(x - y) < epsilon; - }; - helpers$1.almostWhole =3D function(x, epsilon) { - var rounded =3D Math.round(x); - return ((rounded - epsilon) <=3D x) && ((rounded + epsilon) >=3D x); - }; - helpers$1.max =3D function(array) { - return array.reduce(function(max, value) { - if (!isNaN(value)) { - return Math.max(max, value); - } - return max; - }, Number.NEGATIVE_INFINITY); - }; - helpers$1.min =3D function(array) { - return array.reduce(function(min, value) { - if (!isNaN(value)) { - return Math.min(min, value); - } - return min; - }, Number.POSITIVE_INFINITY); - }; - helpers$1.sign =3D Math.sign ? - function(x) { - return Math.sign(x); - } : - function(x) { - x =3D +x; // convert to a number - if (x =3D=3D=3D 0 || isNaN(x)) { - return x; - } - return x > 0 ? 1 : -1; - }; - helpers$1.toRadians =3D function(degrees) { - return degrees * (Math.PI / 180); - }; - helpers$1.toDegrees =3D function(radians) { - return radians * (180 / Math.PI); - }; - - /** - * Returns the number of decimal places - * i.e. the number of digits after the decimal point, of the value of thi= s Number. - * @param {number} x - A number. - * @returns {number} The number of decimal places. - * @private - */ - helpers$1._decimalPlaces =3D function(x) { - if (!helpers$1.isFinite(x)) { - return; - } - var e =3D 1; - var p =3D 0; - while (Math.round(x * e) / e !=3D=3D x) { - e *=3D 10; - p++; - } - return p; - }; - - // Gets the angle from vertical upright to the point about a centre. - helpers$1.getAngleFromPoint =3D function(centrePoint, anglePoint) { - var distanceFromXCenter =3D anglePoint.x - centrePoint.x; - var distanceFromYCenter =3D anglePoint.y - centrePoint.y; - var radialDistanceFromCenter =3D Math.sqrt(distanceFromXCenter * distanc= eFromXCenter + distanceFromYCenter * distanceFromYCenter); - - var angle =3D Math.atan2(distanceFromYCenter, distanceFromXCenter); - - if (angle < (-0.5 * Math.PI)) { - angle +=3D 2.0 * Math.PI; // make sure the returned angle is in the ran= ge of (-PI/2, 3PI/2] - } - - return { - angle: angle, - distance: radialDistanceFromCenter - }; - }; - helpers$1.distanceBetweenPoints =3D function(pt1, pt2) { - return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2)= ); - }; - - /** - * Provided for backward compatibility, not available anymore - * @function Chart.helpers.aliasPixel - * @deprecated since version 2.8.0 - * @todo remove at version 3 - */ - helpers$1.aliasPixel =3D function(pixelWidth) { - return (pixelWidth % 2 =3D=3D=3D 0) ? 0 : 0.5; - }; - - /** - * Returns the aligned pixel value to avoid anti-aliasing blur - * @param {Chart} chart - The chart instance. - * @param {number} pixel - A pixel value. - * @param {number} width - The width of the element. - * @returns {number} The aligned pixel value. - * @private - */ - helpers$1._alignPixel =3D function(chart, pixel, width) { - var devicePixelRatio =3D chart.currentDevicePixelRatio; - var halfWidth =3D width / 2; - return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelR= atio + halfWidth; - }; - - helpers$1.splineCurve =3D function(firstPoint, middlePoint, afterPoint, t= ) { - // Props to Rob Spencer at scaled innovation for his post on splining be= tween points - // http://scaledinnovation.com/analytics/splines/aboutSplines.html - - // This function must also respect "skipped" points - - var previous =3D firstPoint.skip ? middlePoint : firstPoint; - var current =3D middlePoint; - var next =3D afterPoint.skip ? middlePoint : afterPoint; - - var d01 =3D Math.sqrt(Math.pow(current.x - previous.x, 2) + Math.pow(cur= rent.y - previous.y, 2)); - var d12 =3D Math.sqrt(Math.pow(next.x - current.x, 2) + Math.pow(next.y = - current.y, 2)); - - var s01 =3D d01 / (d01 + d12); - var s12 =3D d12 / (d01 + d12); - - // If all points are the same, s01 & s02 will be inf - s01 =3D isNaN(s01) ? 0 : s01; - s12 =3D isNaN(s12) ? 0 : s12; - - var fa =3D t * s01; // scaling factor for triangle Ta - var fb =3D t * s12; - - return { - previous: { - x: current.x - fa * (next.x - previous.x), - y: current.y - fa * (next.y - previous.y) - }, - next: { - x: current.x + fb * (next.x - previous.x), - y: current.y + fb * (next.y - previous.y) - } - }; - }; - helpers$1.EPSILON =3D Number.EPSILON || 1e-14; - helpers$1.splineCurveMonotone =3D function(points) { - // This function calculates B=C3=A9zier control points in a similar way = than |splineCurve|, - // but preserves monotonicity of the provided data and ensures no local = extremums are added - // between the dataset discrete points due to the interpolation. - // See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation - - var pointsWithTangents =3D (points || []).map(function(point) { - return { - model: point._model, - deltaK: 0, - mK: 0 - }; - }); - - // Calculate slopes (deltaK) and initialize tangents (mK) - var pointsLen =3D pointsWithTangents.length; - var i, pointBefore, pointCurrent, pointAfter; - for (i =3D 0; i < pointsLen; ++i) { - pointCurrent =3D pointsWithTangents[i]; - if (pointCurrent.model.skip) { - continue; - } - - pointBefore =3D i > 0 ? pointsWithTangents[i - 1] : null; - pointAfter =3D i < pointsLen - 1 ? pointsWithTangents[i + 1] : null; - if (pointAfter && !pointAfter.model.skip) { - var slopeDeltaX =3D (pointAfter.model.x - pointCurrent.model.x); - - // In the case of two points that appear at the same x pixel, slopeDel= taX is 0 - pointCurrent.deltaK =3D slopeDeltaX !=3D=3D 0 ? (pointAfter.model.y - = pointCurrent.model.y) / slopeDeltaX : 0; - } - - if (!pointBefore || pointBefore.model.skip) { - pointCurrent.mK =3D pointCurrent.deltaK; - } else if (!pointAfter || pointAfter.model.skip) { - pointCurrent.mK =3D pointBefore.deltaK; - } else if (this.sign(pointBefore.deltaK) !=3D=3D this.sign(pointCurrent= .deltaK)) { - pointCurrent.mK =3D 0; - } else { - pointCurrent.mK =3D (pointBefore.deltaK + pointCurrent.deltaK) / 2; - } - } - - // Adjust tangents to ensure monotonic properties - var alphaK, betaK, tauK, squaredMagnitude; - for (i =3D 0; i < pointsLen - 1; ++i) { - pointCurrent =3D pointsWithTangents[i]; - pointAfter =3D pointsWithTangents[i + 1]; - if (pointCurrent.model.skip || pointAfter.model.skip) { - continue; - } - - if (helpers$1.almostEquals(pointCurrent.deltaK, 0, this.EPSILON)) { - pointCurrent.mK =3D pointAfter.mK =3D 0; - continue; - } - - alphaK =3D pointCurrent.mK / pointCurrent.deltaK; - betaK =3D pointAfter.mK / pointCurrent.deltaK; - squaredMagnitude =3D Math.pow(alphaK, 2) + Math.pow(betaK, 2); - if (squaredMagnitude <=3D 9) { - continue; - } - - tauK =3D 3 / Math.sqrt(squaredMagnitude); - pointCurrent.mK =3D alphaK * tauK * pointCurrent.deltaK; - pointAfter.mK =3D betaK * tauK * pointCurrent.deltaK; - } - - // Compute control points - var deltaX; - for (i =3D 0; i < pointsLen; ++i) { - pointCurrent =3D pointsWithTangents[i]; - if (pointCurrent.model.skip) { - continue; - } - - pointBefore =3D i > 0 ? pointsWithTangents[i - 1] : null; - pointAfter =3D i < pointsLen - 1 ? pointsWithTangents[i + 1] : null; - if (pointBefore && !pointBefore.model.skip) { - deltaX =3D (pointCurrent.model.x - pointBefore.model.x) / 3; - pointCurrent.model.controlPointPreviousX =3D pointCurrent.model.x - de= ltaX; - pointCurrent.model.controlPointPreviousY =3D pointCurrent.model.y - de= ltaX * pointCurrent.mK; - } - if (pointAfter && !pointAfter.model.skip) { - deltaX =3D (pointAfter.model.x - pointCurrent.model.x) / 3; - pointCurrent.model.controlPointNextX =3D pointCurrent.model.x + deltaX; - pointCurrent.model.controlPointNextY =3D pointCurrent.model.y + deltaX= * pointCurrent.mK; - } - } - }; - helpers$1.nextItem =3D function(collection, index, loop) { - if (loop) { - return index >=3D collection.length - 1 ? collection[0] : collection[in= dex + 1]; - } - return index >=3D collection.length - 1 ? collection[collection.length -= 1] : collection[index + 1]; - }; - helpers$1.previousItem =3D function(collection, index, loop) { - if (loop) { - return index <=3D 0 ? collection[collection.length - 1] : collection[in= dex - 1]; - } - return index <=3D 0 ? collection[0] : collection[index - 1]; - }; - // Implementation of the nice number algorithm used in determining where = axis labels will go - helpers$1.niceNum =3D function(range, round) { - var exponent =3D Math.floor(helpers$1.log10(range)); - var fraction =3D range / Math.pow(10, exponent); - var niceFraction; - - if (round) { - if (fraction < 1.5) { - niceFraction =3D 1; - } else if (fraction < 3) { - niceFraction =3D 2; - } else if (fraction < 7) { - niceFraction =3D 5; - } else { - niceFraction =3D 10; - } - } else if (fraction <=3D 1.0) { - niceFraction =3D 1; - } else if (fraction <=3D 2) { - niceFraction =3D 2; - } else if (fraction <=3D 5) { - niceFraction =3D 5; - } else { - niceFraction =3D 10; - } - - return niceFraction * Math.pow(10, exponent); - }; - // Request animation polyfill - https://www.paulirish.com/2011/requestani= mationframe-for-smart-animating/ - helpers$1.requestAnimFrame =3D (function() { - if (typeof window =3D=3D=3D 'undefined') { - return function(callback) { - callback(); - }; - } - return window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(callback) { - return window.setTimeout(callback, 1000 / 60); - }; - }()); - // -- DOM methods - helpers$1.getRelativePosition =3D function(evt, chart) { - var mouseX, mouseY; - var e =3D evt.originalEvent || evt; - var canvas =3D evt.target || evt.srcElement; - var boundingRect =3D canvas.getBoundingClientRect(); - - var touches =3D e.touches; - if (touches && touches.length > 0) { - mouseX =3D touches[0].clientX; - mouseY =3D touches[0].clientY; - - } else { - mouseX =3D e.clientX; - mouseY =3D e.clientY; - } - - // Scale mouse coordinates into canvas coordinates - // by following the pattern laid out by 'jerryj' in the comments of - // https://www.html5canvastutorials.com/advanced/html5-canvas-mouse-coor= dinates/ - var paddingLeft =3D parseFloat(helpers$1.getStyle(canvas, 'padding-left'= )); - var paddingTop =3D parseFloat(helpers$1.getStyle(canvas, 'padding-top')); - var paddingRight =3D parseFloat(helpers$1.getStyle(canvas, 'padding-righ= t')); - var paddingBottom =3D parseFloat(helpers$1.getStyle(canvas, 'padding-bot= tom')); - var width =3D boundingRect.right - boundingRect.left - paddingLeft - pad= dingRight; - var height =3D boundingRect.bottom - boundingRect.top - paddingTop - pad= dingBottom; - - // We divide by the current device pixel ratio, because the canvas is sc= aled up by that amount in each direction. However - // the backend model is in unscaled coordinates. Since we are going to d= eal with our model coordinates, we go back here - mouseX =3D Math.round((mouseX - boundingRect.left - paddingLeft) / (widt= h) * canvas.width / chart.currentDevicePixelRatio); - mouseY =3D Math.round((mouseY - boundingRect.top - paddingTop) / (height= ) * canvas.height / chart.currentDevicePixelRatio); - - return { - x: mouseX, - y: mouseY - }; - - }; - - // Private helper function to convert max-width/max-height values that ma= y be percentages into a number - function parseMaxStyle(styleValue, node, parentProperty) { - var valueInPixels; - if (typeof styleValue =3D=3D=3D 'string') { - valueInPixels =3D parseInt(styleValue, 10); - - if (styleValue.indexOf('%') !=3D=3D -1) { - // percentage * size in dimension - valueInPixels =3D valueInPixels / 100 * node.parentNode[parentProperty= ]; - } - } else { - valueInPixels =3D styleValue; - } - - return valueInPixels; - } - - /** - * Returns if the given value contains an effective constraint. - * @private - */ - function isConstrainedValue(value) { - return value !=3D=3D undefined && value !=3D=3D null && value !=3D=3D 'n= one'; - } - - /** - * Returns the max width or height of the given DOM node in a cross-brows= er compatible fashion - * @param {HTMLElement} domNode - the node to check the constraint on - * @param {string} maxStyle - the style that defines the maximum for the = direction we are using ('max-width' / 'max-height') - * @param {string} percentageProperty - property of parent to use when ca= lculating width as a percentage - * @see {@link https://www.nathanaeljones.com/blog/2013/reading-max-width= -cross-browser} - */ - function getConstraintDimension(domNode, maxStyle, percentageProperty) { - var view =3D document.defaultView; - var parentNode =3D helpers$1._getParentNode(domNode); - var constrainedNode =3D view.getComputedStyle(domNode)[maxStyle]; - var constrainedContainer =3D view.getComputedStyle(parentNode)[maxStyle]; - var hasCNode =3D isConstrainedValue(constrainedNode); - var hasCContainer =3D isConstrainedValue(constrainedContainer); - var infinity =3D Number.POSITIVE_INFINITY; - - if (hasCNode || hasCContainer) { - return Math.min( - hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty)= : infinity, - hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percen= tageProperty) : infinity); - } - - return 'none'; - } - // returns Number or undefined if no constraint - helpers$1.getConstraintWidth =3D function(domNode) { - return getConstraintDimension(domNode, 'max-width', 'clientWidth'); - }; - // returns Number or undefined if no constraint - helpers$1.getConstraintHeight =3D function(domNode) { - return getConstraintDimension(domNode, 'max-height', 'clientHeight'); - }; - /** - * @private - */ - helpers$1._calculatePadding =3D function(container, padding, parentDimens= ion) { - padding =3D helpers$1.getStyle(container, padding); - - return padding.indexOf('%') > -1 ? parentDimension * parseInt(padding, 1= 0) / 100 : parseInt(padding, 10); - }; - /** - * @private - */ - helpers$1._getParentNode =3D function(domNode) { - var parent =3D domNode.parentNode; - if (parent && parent.toString() =3D=3D=3D '[object ShadowRoot]') { - parent =3D parent.host; - } - return parent; - }; - helpers$1.getMaximumWidth =3D function(domNode) { - var container =3D helpers$1._getParentNode(domNode); - if (!container) { - return domNode.clientWidth; - } - - var clientWidth =3D container.clientWidth; - var paddingLeft =3D helpers$1._calculatePadding(container, 'padding-left= ', clientWidth); - var paddingRight =3D helpers$1._calculatePadding(container, 'padding-rig= ht', clientWidth); - - var w =3D clientWidth - paddingLeft - paddingRight; - var cw =3D helpers$1.getConstraintWidth(domNode); - return isNaN(cw) ? w : Math.min(w, cw); - }; - helpers$1.getMaximumHeight =3D function(domNode) { - var container =3D helpers$1._getParentNode(domNode); - if (!container) { - return domNode.clientHeight; - } - - var clientHeight =3D container.clientHeight; - var paddingTop =3D helpers$1._calculatePadding(container, 'padding-top',= clientHeight); - var paddingBottom =3D helpers$1._calculatePadding(container, 'padding-bo= ttom', clientHeight); - - var h =3D clientHeight - paddingTop - paddingBottom; - var ch =3D helpers$1.getConstraintHeight(domNode); - return isNaN(ch) ? h : Math.min(h, ch); - }; - helpers$1.getStyle =3D function(el, property) { - return el.currentStyle ? - el.currentStyle[property] : - document.defaultView.getComputedStyle(el, null).getPropertyValue(proper= ty); - }; - helpers$1.retinaScale =3D function(chart, forceRatio) { - var pixelRatio =3D chart.currentDevicePixelRatio =3D forceRatio || (type= of window !=3D=3D 'undefined' && window.devicePixelRatio) || 1; - if (pixelRatio =3D=3D=3D 1) { - return; - } - - var canvas =3D chart.canvas; - var height =3D chart.height; - var width =3D chart.width; - - canvas.height =3D height * pixelRatio; - canvas.width =3D width * pixelRatio; - chart.ctx.scale(pixelRatio, pixelRatio); - - // If no style has been set on the canvas, the render size is used as di= splay size, - // making the chart visually bigger, so let's enforce it to the "correct= " values. - // See https://github.com/chartjs/Chart.js/issues/3575 - if (!canvas.style.height && !canvas.style.width) { - canvas.style.height =3D height + 'px'; - canvas.style.width =3D width + 'px'; - } - }; - // -- Canvas methods - helpers$1.fontString =3D function(pixelSize, fontStyle, fontFamily) { - return fontStyle + ' ' + pixelSize + 'px ' + fontFamily; - }; - helpers$1.longestText =3D function(ctx, font, arrayOfThings, cache) { - cache =3D cache || {}; - var data =3D cache.data =3D cache.data || {}; - var gc =3D cache.garbageCollect =3D cache.garbageCollect || []; - - if (cache.font !=3D=3D font) { - data =3D cache.data =3D {}; - gc =3D cache.garbageCollect =3D []; - cache.font =3D font; - } - - ctx.font =3D font; - var longest =3D 0; - var ilen =3D arrayOfThings.length; - var i, j, jlen, thing, nestedThing; - for (i =3D 0; i < ilen; i++) { - thing =3D arrayOfThings[i]; - - // Undefined strings and arrays should not be measured - if (thing !=3D=3D undefined && thing !=3D=3D null && helpers$1.isArray(= thing) !=3D=3D true) { - longest =3D helpers$1.measureText(ctx, data, gc, longest, thing); - } else if (helpers$1.isArray(thing)) { - // if it is an array lets measure each element - // to do maybe simplify this function a bit so we can do this more rec= ursively? - for (j =3D 0, jlen =3D thing.length; j < jlen; j++) { - nestedThing =3D thing[j]; - // Undefined strings and arrays should not be measured - if (nestedThing !=3D=3D undefined && nestedThing !=3D=3D null && !hel= pers$1.isArray(nestedThing)) { - longest =3D helpers$1.measureText(ctx, data, gc, longest, nestedThin= g); - } - } - } - } - - var gcLen =3D gc.length / 2; - if (gcLen > arrayOfThings.length) { - for (i =3D 0; i < gcLen; i++) { - delete data[gc[i]]; - } - gc.splice(0, gcLen); - } - return longest; - }; - helpers$1.measureText =3D function(ctx, data, gc, longest, string) { - var textWidth =3D data[string]; - if (!textWidth) { - textWidth =3D data[string] =3D ctx.measureText(string).width; - gc.push(string); - } - if (textWidth > longest) { - longest =3D textWidth; - } - return longest; - }; - - /** - * @deprecated - */ - helpers$1.numberOfLabelLines =3D function(arrayOfThings) { - var numberOfLines =3D 1; - helpers$1.each(arrayOfThings, function(thing) { - if (helpers$1.isArray(thing)) { - if (thing.length > numberOfLines) { - numberOfLines =3D thing.length; - } - } - }); - return numberOfLines; - }; - - helpers$1.color =3D !chartjsColor ? - function(value) { - console.error('Color.js not found!'); - return value; - } : - function(value) { - /* global CanvasGradient */ - if (value instanceof CanvasGradient) { - value =3D core_defaults.global.defaultColor; - } - - return chartjsColor(value); - }; - - helpers$1.getHoverColor =3D function(colorValue) { - /* global CanvasPattern */ - return (colorValue instanceof CanvasPattern || colorValue instanceof Can= vasGradient) ? - colorValue : - helpers$1.color(colorValue).saturate(0.5).darken(0.1).rgbString(); - }; -}; - -function abstract() { - throw new Error( - 'This method is not implemented: either no adapter can ' + - 'be found or an incomplete integration was provided.' - ); -} - -/** - * Date adapter (current used by the time scale) - * @namespace Chart._adapters._date - * @memberof Chart._adapters - * @private - */ - -/** - * Currently supported unit string values. - * @typedef {('millisecond'|'second'|'minute'|'hour'|'day'|'week'|'month'|= 'quarter'|'year')} - * @memberof Chart._adapters._date - * @name Unit - */ - -/** - * @class - */ -function DateAdapter(options) { - this.options =3D options || {}; -} - -helpers$1.extend(DateAdapter.prototype, /** @lends DateAdapter */ { - /** - * Returns a map of time formats for the supported formatting units defin= ed - * in Unit as well as 'datetime' representing a detailed date/time string. - * @returns {{string: string}} - */ - formats: abstract, - - /** - * Parses the given `value` and return the associated timestamp. - * @param {any} value - the value to parse (usually comes from the data) - * @param {string} [format] - the expected data format - * @returns {(number|null)} - * @function - */ - parse: abstract, - - /** - * Returns the formatted date in the specified `format` for a given `time= stamp`. - * @param {number} timestamp - the timestamp to format - * @param {string} format - the date/time token - * @return {string} - * @function - */ - format: abstract, - - /** - * Adds the specified `amount` of `unit` to the given `timestamp`. - * @param {number} timestamp - the input timestamp - * @param {number} amount - the amount to add - * @param {Unit} unit - the unit as string - * @return {number} - * @function - */ - add: abstract, - - /** - * Returns the number of `unit` between the given timestamps. - * @param {number} max - the input timestamp (reference) - * @param {number} min - the timestamp to substract - * @param {Unit} unit - the unit as string - * @return {number} - * @function - */ - diff: abstract, - - /** - * Returns start of `unit` for the given `timestamp`. - * @param {number} timestamp - the input timestamp - * @param {Unit} unit - the unit as string - * @param {number} [weekday] - the ISO day of the week with 1 being Monday - * and 7 being Sunday (only needed if param *unit* is `isoWeek`). - * @function - */ - startOf: abstract, - - /** - * Returns end of `unit` for the given `timestamp`. - * @param {number} timestamp - the input timestamp - * @param {Unit} unit - the unit as string - * @function - */ - endOf: abstract, - - // DEPRECATIONS - - /** - * Provided for backward compatibility for scale.getValueForPixel(), - * this method should be overridden only by the moment adapter. - * @deprecated since version 2.8.0 - * @todo remove at version 3 - * @private - */ - _create: function(value) { - return value; - } -}); - -DateAdapter.override =3D function(members) { - helpers$1.extend(DateAdapter.prototype, members); -}; - -var _date =3D DateAdapter; - -var core_adapters =3D { - _date: _date -}; - -/** - * Namespace to hold static tick generation functions - * @namespace Chart.Ticks - */ -var core_ticks =3D { - /** - * Namespace to hold formatters for different types of ticks - * @namespace Chart.Ticks.formatters - */ - formatters: { - /** - * Formatter for value labels - * @method Chart.Ticks.formatters.values - * @param value the value to display - * @return {string|string[]} the label to display - */ - values: function(value) { - return helpers$1.isArray(value) ? value : '' + value; - }, - - /** - * Formatter for linear numeric ticks - * @method Chart.Ticks.formatters.linear - * @param tickValue {number} the value to be formatted - * @param index {number} the position of the tickValue parameter in the = ticks array - * @param ticks {number[]} the list of ticks being converted - * @return {string} string representation of the tickValue parameter - */ - linear: function(tickValue, index, ticks) { - // If we have lots of ticks, don't use the ones - var delta =3D ticks.length > 3 ? ticks[2] - ticks[1] : ticks[1] - ticks= [0]; - - // If we have a number like 2.5 as the delta, figure out how many decim= al places we need - if (Math.abs(delta) > 1) { - if (tickValue !=3D=3D Math.floor(tickValue)) { - // not an integer - delta =3D tickValue - Math.floor(tickValue); - } - } - - var logDelta =3D helpers$1.log10(Math.abs(delta)); - var tickString =3D ''; - - if (tickValue !=3D=3D 0) { - var maxTick =3D Math.max(Math.abs(ticks[0]), Math.abs(ticks[ticks.leng= th - 1])); - if (maxTick < 1e-4) { // all ticks are small numbers; use scientific n= otation - var logTick =3D helpers$1.log10(Math.abs(tickValue)); - var numExponential =3D Math.floor(logTick) - Math.floor(logDelta); - numExponential =3D Math.max(Math.min(numExponential, 20), 0); - tickString =3D tickValue.toExponential(numExponential); - } else { - var numDecimal =3D -1 * Math.floor(logDelta); - numDecimal =3D Math.max(Math.min(numDecimal, 20), 0); // toFixed has = a max of 20 decimal places - tickString =3D tickValue.toFixed(numDecimal); - } - } else { - tickString =3D '0'; // never show decimal places for 0 - } - - return tickString; - }, - - logarithmic: function(tickValue, index, ticks) { - var remain =3D tickValue / (Math.pow(10, Math.floor(helpers$1.log10(tic= kValue)))); - - if (tickValue =3D=3D=3D 0) { - return '0'; - } else if (remain =3D=3D=3D 1 || remain =3D=3D=3D 2 || remain =3D=3D=3D= 5 || index =3D=3D=3D 0 || index =3D=3D=3D ticks.length - 1) { - return tickValue.toExponential(); - } - return ''; - } - } -}; - -var isArray =3D helpers$1.isArray; -var isNullOrUndef =3D helpers$1.isNullOrUndef; -var valueOrDefault$a =3D helpers$1.valueOrDefault; -var valueAtIndexOrDefault =3D helpers$1.valueAtIndexOrDefault; - -core_defaults._set('scale', { - display: true, - position: 'left', - offset: false, - - // grid line settings - gridLines: { - display: true, - color: 'rgba(0,0,0,0.1)', - lineWidth: 1, - drawBorder: true, - drawOnChartArea: true, - drawTicks: true, - tickMarkLength: 10, - zeroLineWidth: 1, - zeroLineColor: 'rgba(0,0,0,0.25)', - zeroLineBorderDash: [], - zeroLineBorderDashOffset: 0.0, - offsetGridLines: false, - borderDash: [], - borderDashOffset: 0.0 - }, - - // scale label - scaleLabel: { - // display property - display: false, - - // actual label - labelString: '', - - // top/bottom padding - padding: { - top: 4, - bottom: 4 - } - }, - - // label settings - ticks: { - beginAtZero: false, - minRotation: 0, - maxRotation: 50, - mirror: false, - padding: 0, - reverse: false, - display: true, - autoSkip: true, - autoSkipPadding: 0, - labelOffset: 0, - // We pass through arrays to be rendered as multiline labels, we convert= Others to strings here. - callback: core_ticks.formatters.values, - minor: {}, - major: {} - } -}); - -/** Returns a new array containing numItems from arr */ -function sample(arr, numItems) { - var result =3D []; - var increment =3D arr.length / numItems; - var i =3D 0; - var len =3D arr.length; - - for (; i < len; i +=3D increment) { - result.push(arr[Math.floor(i)]); - } - return result; -} - -function getPixelForGridLine(scale, index, offsetGridLines) { - var length =3D scale.getTicks().length; - var validIndex =3D Math.min(index, length - 1); - var lineValue =3D scale.getPixelForTick(validIndex); - var start =3D scale._startPixel; - var end =3D scale._endPixel; - var epsilon =3D 1e-6; // 1e-6 is margin in pixels for accumulated error. - var offset; - - if (offsetGridLines) { - if (length =3D=3D=3D 1) { - offset =3D Math.max(lineValue - start, end - lineValue); - } else if (index =3D=3D=3D 0) { - offset =3D (scale.getPixelForTick(1) - lineValue) / 2; - } else { - offset =3D (lineValue - scale.getPixelForTick(validIndex - 1)) / 2; - } - lineValue +=3D validIndex < index ? offset : -offset; - - // Return undefined if the pixel is out of the range - if (lineValue < start - epsilon || lineValue > end + epsilon) { - return; - } - } - return lineValue; -} - -function garbageCollect(caches, length) { - helpers$1.each(caches, function(cache) { - var gc =3D cache.gc; - var gcLen =3D gc.length / 2; - var i; - if (gcLen > length) { - for (i =3D 0; i < gcLen; ++i) { - delete cache.data[gc[i]]; - } - gc.splice(0, gcLen); - } - }); -} - -/** - * Returns {width, height, offset} objects for the first, last, widest, hi= ghest tick - * labels where offset indicates the anchor point offset from the top in p= ixels. - */ -function computeLabelSizes(ctx, tickFonts, ticks, caches) { - var length =3D ticks.length; - var widths =3D []; - var heights =3D []; - var offsets =3D []; - var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, he= ight, nestedLabel, widest, highest; - - for (i =3D 0; i < length; ++i) { - label =3D ticks[i].label; - tickFont =3D ticks[i].major ? tickFonts.major : tickFonts.minor; - ctx.font =3D fontString =3D tickFont.string; - cache =3D caches[fontString] =3D caches[fontString] || {data: {}, gc: []= }; - lineHeight =3D tickFont.lineHeight; - width =3D height =3D 0; - // Undefined labels and arrays should not be measured - if (!isNullOrUndef(label) && !isArray(label)) { - width =3D helpers$1.measureText(ctx, cache.data, cache.gc, width, label= ); - height =3D lineHeight; - } else if (isArray(label)) { - // if it is an array let's measure each element - for (j =3D 0, jlen =3D label.length; j < jlen; ++j) { - nestedLabel =3D label[j]; - // Undefined labels and arrays should not be measured - if (!isNullOrUndef(nestedLabel) && !isArray(nestedLabel)) { - width =3D helpers$1.measureText(ctx, cache.data, cache.gc, width, nes= tedLabel); - height +=3D lineHeight; - } - } - } - widths.push(width); - heights.push(height); - offsets.push(lineHeight / 2); - } - garbageCollect(caches, length); - - widest =3D widths.indexOf(Math.max.apply(null, widths)); - highest =3D heights.indexOf(Math.max.apply(null, heights)); - - function valueAt(idx) { - return { - width: widths[idx] || 0, - height: heights[idx] || 0, - offset: offsets[idx] || 0 - }; - } - - return { - first: valueAt(0), - last: valueAt(length - 1), - widest: valueAt(widest), - highest: valueAt(highest) - }; -} - -function getTickMarkLength(options) { - return options.drawTicks ? options.tickMarkLength : 0; -} - -function getScaleLabelHeight(options) { - var font, padding; - - if (!options.display) { - return 0; - } - - font =3D helpers$1.options._parseFont(options); - padding =3D helpers$1.options.toPadding(options.padding); - - return font.lineHeight + padding.height; -} - -function parseFontOptions(options, nestedOpts) { - return helpers$1.extend(helpers$1.options._parseFont({ - fontFamily: valueOrDefault$a(nestedOpts.fontFamily, options.fontFamily), - fontSize: valueOrDefault$a(nestedOpts.fontSize, options.fontSize), - fontStyle: valueOrDefault$a(nestedOpts.fontStyle, options.fontStyle), - lineHeight: valueOrDefault$a(nestedOpts.lineHeight, options.lineHeight) - }), { - color: helpers$1.options.resolve([nestedOpts.fontColor, options.fontColo= r, core_defaults.global.defaultFontColor]) - }); -} - -function parseTickFontOptions(options) { - var minor =3D parseFontOptions(options, options.minor); - var major =3D options.major.enabled ? parseFontOptions(options, options.m= ajor) : minor; - - return {minor: minor, major: major}; -} - -function nonSkipped(ticksToFilter) { - var filtered =3D []; - var item, index, len; - for (index =3D 0, len =3D ticksToFilter.length; index < len; ++index) { - item =3D ticksToFilter[index]; - if (typeof item._index !=3D=3D 'undefined') { - filtered.push(item); - } - } - return filtered; -} - -function getEvenSpacing(arr) { - var len =3D arr.length; - var i, diff; - - if (len < 2) { - return false; - } - - for (diff =3D arr[0], i =3D 1; i < len; ++i) { - if (arr[i] - arr[i - 1] !=3D=3D diff) { - return false; - } - } - return diff; -} - -function calculateSpacing(majorIndices, ticks, axisLength, ticksLimit) { - var evenMajorSpacing =3D getEvenSpacing(majorIndices); - var spacing =3D (ticks.length - 1) / ticksLimit; - var factors, factor, i, ilen; - - // If the major ticks are evenly spaced apart, place the minor ticks - // so that they divide the major ticks into even chunks - if (!evenMajorSpacing) { - return Math.max(spacing, 1); - } - - factors =3D helpers$1.math._factorize(evenMajorSpacing); - for (i =3D 0, ilen =3D factors.length - 1; i < ilen; i++) { - factor =3D factors[i]; - if (factor > spacing) { - return factor; - } - } - return Math.max(spacing, 1); -} - -function getMajorIndices(ticks) { - var result =3D []; - var i, ilen; - for (i =3D 0, ilen =3D ticks.length; i < ilen; i++) { - if (ticks[i].major) { - result.push(i); - } - } - return result; -} - -function skipMajors(ticks, majorIndices, spacing) { - var count =3D 0; - var next =3D majorIndices[0]; - var i, tick; - - spacing =3D Math.ceil(spacing); - for (i =3D 0; i < ticks.length; i++) { - tick =3D ticks[i]; - if (i =3D=3D=3D next) { - tick._index =3D i; - count++; - next =3D majorIndices[count * spacing]; - } else { - delete tick.label; - } - } -} - -function skip(ticks, spacing, majorStart, majorEnd) { - var start =3D valueOrDefault$a(majorStart, 0); - var end =3D Math.min(valueOrDefault$a(majorEnd, ticks.length), ticks.leng= th); - var count =3D 0; - var length, i, tick, next; - - spacing =3D Math.ceil(spacing); - if (majorEnd) { - length =3D majorEnd - majorStart; - spacing =3D length / Math.floor(length / spacing); - } - - next =3D start; - - while (next < 0) { - count++; - next =3D Math.round(start + count * spacing); - } - - for (i =3D Math.max(start, 0); i < end; i++) { - tick =3D ticks[i]; - if (i =3D=3D=3D next) { - tick._index =3D i; - count++; - next =3D Math.round(start + count * spacing); - } else { - delete tick.label; - } - } -} - -var Scale =3D core_element.extend({ - - zeroLineIndex: 0, - - /** - * Get the padding needed for the scale - * @method getPadding - * @private - * @returns {Padding} the necessary padding - */ - getPadding: function() { - var me =3D this; - return { - left: me.paddingLeft || 0, - top: me.paddingTop || 0, - right: me.paddingRight || 0, - bottom: me.paddingBottom || 0 - }; - }, - - /** - * Returns the scale tick objects ({label, major}) - * @since 2.7 - */ - getTicks: function() { - return this._ticks; - }, - - /** - * @private - */ - _getLabels: function() { - var data =3D this.chart.data; - return this.options.labels || (this.isHorizontal() ? data.xLabels : data= .yLabels) || data.labels || []; - }, - - // These methods are ordered by lifecyle. Utilities then follow. - // Any function defined here is inherited by all scale types. - // Any function can be extended by the scale type - - /** - * Provided for backward compatibility, not available anymore - * @function Chart.Scale.mergeTicksOptions - * @deprecated since version 2.8.0 - * @todo remove at version 3 - */ - mergeTicksOptions: function() { - // noop - }, - - beforeUpdate: function() { - helpers$1.callback(this.options.beforeUpdate, [this]); - }, - - /** - * @param {number} maxWidth - the max width in pixels - * @param {number} maxHeight - the max height in pixels - * @param {object} margins - the space between the edge of the other scal= es and edge of the chart - * This space comes from two sources: - * - padding - space that's required to show the labels at the edges = of the scale - * - thickness of scales or legends in another orientation - */ - update: function(maxWidth, maxHeight, margins) { - var me =3D this; - var tickOpts =3D me.options.ticks; - var sampleSize =3D tickOpts.sampleSize; - var i, ilen, labels, ticks, samplingEnabled; - - // Update Lifecycle - Probably don't want to ever extend or overwrite th= is function ;) - me.beforeUpdate(); - - // Absorb the master measurements - me.maxWidth =3D maxWidth; - me.maxHeight =3D maxHeight; - me.margins =3D helpers$1.extend({ - left: 0, - right: 0, - top: 0, - bottom: 0 - }, margins); - - me._ticks =3D null; - me.ticks =3D null; - me._labelSizes =3D null; - me._maxLabelLines =3D 0; - me.longestLabelWidth =3D 0; - me.longestTextCache =3D me.longestTextCache || {}; - me._gridLineItems =3D null; - me._labelItems =3D null; - - // Dimensions - me.beforeSetDimensions(); - me.setDimensions(); - me.afterSetDimensions(); - - // Data min/max - me.beforeDataLimits(); - me.determineDataLimits(); - me.afterDataLimits(); - - // Ticks - `this.ticks` is now DEPRECATED! - // Internal ticks are now stored as objects in the PRIVATE `this._ticks`= member - // and must not be accessed directly from outside this class. `this.tick= s` being - // around for long time and not marked as private, we can't change its s= tructure - // without unexpected breaking changes. If you need to access the scale = ticks, - // use scale.getTicks() instead. - - me.beforeBuildTicks(); - - // New implementations should return an array of objects but for BACKWAR= D COMPAT, - // we still support no return (`this.ticks` internally set by calling th= is method). - ticks =3D me.buildTicks() || []; - - // Allow modification of ticks in callback. - ticks =3D me.afterBuildTicks(ticks) || ticks; - - // Ensure ticks contains ticks in new tick format - if ((!ticks || !ticks.length) && me.ticks) { - ticks =3D []; - for (i =3D 0, ilen =3D me.ticks.length; i < ilen; ++i) { - ticks.push({ - value: me.ticks[i], - major: false - }); - } - } - - me._ticks =3D ticks; - - // Compute tick rotation and fit using a sampled subset of labels - // We generally don't need to compute the size of every single label for= determining scale size - samplingEnabled =3D sampleSize < ticks.length; - labels =3D me._convertTicksToLabels(samplingEnabled ? sample(ticks, samp= leSize) : ticks); - - // _configure is called twice, once here, once from core.controller.upda= teLayout. - // Here we haven't been positioned yet, but dimensions are correct. - // Variables set in _configure are needed for calculateTickRotation, and - // it's ok that coordinates are not correct there, only dimensions matte= r. - me._configure(); - - // Tick Rotation - me.beforeCalculateTickRotation(); - me.calculateTickRotation(); - me.afterCalculateTickRotation(); - - me.beforeFit(); - me.fit(); - me.afterFit(); - - // Auto-skip - me._ticksToDraw =3D tickOpts.display && (tickOpts.autoSkip || tickOpts.s= ource =3D=3D=3D 'auto') ? me._autoSkip(ticks) : ticks; - - if (samplingEnabled) { - // Generate labels using all non-skipped ticks - labels =3D me._convertTicksToLabels(me._ticksToDraw); - } - - me.ticks =3D labels; // BACKWARD COMPATIBILITY - - // IMPORTANT: after this point, we consider that `this.ticks` will NEVER= change! - - me.afterUpdate(); - - // TODO(v3): remove minSize as a public property and return value from a= ll layout boxes. It is unused - // make maxWidth and maxHeight private - return me.minSize; - }, - - /** - * @private - */ - _configure: function() { - var me =3D this; - var reversePixels =3D me.options.ticks.reverse; - var startPixel, endPixel; - - if (me.isHorizontal()) { - startPixel =3D me.left; - endPixel =3D me.right; - } else { - startPixel =3D me.top; - endPixel =3D me.bottom; - // by default vertical scales are from bottom to top, so pixels are rev= ersed - reversePixels =3D !reversePixels; - } - me._startPixel =3D startPixel; - me._endPixel =3D endPixel; - me._reversePixels =3D reversePixels; - me._length =3D endPixel - startPixel; - }, - - afterUpdate: function() { - helpers$1.callback(this.options.afterUpdate, [this]); - }, - - // - - beforeSetDimensions: function() { - helpers$1.callback(this.options.beforeSetDimensions, [this]); - }, - setDimensions: function() { - var me =3D this; - // Set the unconstrained dimension before label rotation - if (me.isHorizontal()) { - // Reset position before calculating rotation - me.width =3D me.maxWidth; - me.left =3D 0; - me.right =3D me.width; - } else { - me.height =3D me.maxHeight; - - // Reset position before calculating rotation - me.top =3D 0; - me.bottom =3D me.height; - } - - // Reset padding - me.paddingLeft =3D 0; - me.paddingTop =3D 0; - me.paddingRight =3D 0; - me.paddingBottom =3D 0; - }, - afterSetDimensions: function() { - helpers$1.callback(this.options.afterSetDimensions, [this]); - }, - - // Data limits - beforeDataLimits: function() { - helpers$1.callback(this.options.beforeDataLimits, [this]); - }, - determineDataLimits: helpers$1.noop, - afterDataLimits: function() { - helpers$1.callback(this.options.afterDataLimits, [this]); - }, - - // - beforeBuildTicks: function() { - helpers$1.callback(this.options.beforeBuildTicks, [this]); - }, - buildTicks: helpers$1.noop, - afterBuildTicks: function(ticks) { - var me =3D this; - // ticks is empty for old axis implementations here - if (isArray(ticks) && ticks.length) { - return helpers$1.callback(me.options.afterBuildTicks, [me, ticks]); - } - // Support old implementations (that modified `this.ticks` directly in b= uildTicks) - me.ticks =3D helpers$1.callback(me.options.afterBuildTicks, [me, me.tick= s]) || me.ticks; - return ticks; - }, - - beforeTickToLabelConversion: function() { - helpers$1.callback(this.options.beforeTickToLabelConversion, [this]); - }, - convertTicksToLabels: function() { - var me =3D this; - // Convert ticks to strings - var tickOpts =3D me.options.ticks; - me.ticks =3D me.ticks.map(tickOpts.userCallback || tickOpts.callback, th= is); - }, - afterTickToLabelConversion: function() { - helpers$1.callback(this.options.afterTickToLabelConversion, [this]); - }, - - // - - beforeCalculateTickRotation: function() { - helpers$1.callback(this.options.beforeCalculateTickRotation, [this]); - }, - calculateTickRotation: function() { - var me =3D this; - var options =3D me.options; - var tickOpts =3D options.ticks; - var numTicks =3D me.getTicks().length; - var minRotation =3D tickOpts.minRotation || 0; - var maxRotation =3D tickOpts.maxRotation; - var labelRotation =3D minRotation; - var labelSizes, maxLabelWidth, maxLabelHeight, maxWidth, tickWidth, maxH= eight, maxLabelDiagonal; - - if (!me._isVisible() || !tickOpts.display || minRotation >=3D maxRotatio= n || numTicks <=3D 1 || !me.isHorizontal()) { - me.labelRotation =3D minRotation; - return; - } - - labelSizes =3D me._getLabelSizes(); - maxLabelWidth =3D labelSizes.widest.width; - maxLabelHeight =3D labelSizes.highest.height - labelSizes.highest.offset; - - // Estimate the width of each grid based on the canvas width, the maximum - // label width and the number of tick intervals - maxWidth =3D Math.min(me.maxWidth, me.chart.width - maxLabelWidth); - tickWidth =3D options.offset ? me.maxWidth / numTicks : maxWidth / (numT= icks - 1); - - // Allow 3 pixels x2 padding either side for label readability - if (maxLabelWidth + 6 > tickWidth) { - tickWidth =3D maxWidth / (numTicks - (options.offset ? 0.5 : 1)); - maxHeight =3D me.maxHeight - getTickMarkLength(options.gridLines) - - tickOpts.padding - getScaleLabelHeight(options.scaleLabel); - maxLabelDiagonal =3D Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabel= Height * maxLabelHeight); - labelRotation =3D helpers$1.toDegrees(Math.min( - Math.asin(Math.min((labelSizes.highest.height + 6) / tickWidth, 1)), - Math.asin(Math.min(maxHeight / maxLabelDiagonal, 1)) - Math.asin(maxLa= belHeight / maxLabelDiagonal) - )); - labelRotation =3D Math.max(minRotation, Math.min(maxRotation, labelRota= tion)); - } - - me.labelRotation =3D labelRotation; - }, - afterCalculateTickRotation: function() { - helpers$1.callback(this.options.afterCalculateTickRotation, [this]); - }, - - // - - beforeFit: function() { - helpers$1.callback(this.options.beforeFit, [this]); - }, - fit: function() { - var me =3D this; - // Reset - var minSize =3D me.minSize =3D { - width: 0, - height: 0 - }; - - var chart =3D me.chart; - var opts =3D me.options; - var tickOpts =3D opts.ticks; - var scaleLabelOpts =3D opts.scaleLabel; - var gridLineOpts =3D opts.gridLines; - var display =3D me._isVisible(); - var isBottom =3D opts.position =3D=3D=3D 'bottom'; - var isHorizontal =3D me.isHorizontal(); - - // Width - if (isHorizontal) { - minSize.width =3D me.maxWidth; - } else if (display) { - minSize.width =3D getTickMarkLength(gridLineOpts) + getScaleLabelHeight= (scaleLabelOpts); - } - - // height - if (!isHorizontal) { - minSize.height =3D me.maxHeight; // fill all the height - } else if (display) { - minSize.height =3D getTickMarkLength(gridLineOpts) + getScaleLabelHeigh= t(scaleLabelOpts); - } - - // Don't bother fitting the ticks if we are not showing the labels - if (tickOpts.display && display) { - var tickFonts =3D parseTickFontOptions(tickOpts); - var labelSizes =3D me._getLabelSizes(); - var firstLabelSize =3D labelSizes.first; - var lastLabelSize =3D labelSizes.last; - var widestLabelSize =3D labelSizes.widest; - var highestLabelSize =3D labelSizes.highest; - var lineSpace =3D tickFonts.minor.lineHeight * 0.4; - var tickPadding =3D tickOpts.padding; - - if (isHorizontal) { - // A horizontal axis is more constrained by the height. - var isRotated =3D me.labelRotation !=3D=3D 0; - var angleRadians =3D helpers$1.toRadians(me.labelRotation); - var cosRotation =3D Math.cos(angleRadians); - var sinRotation =3D Math.sin(angleRadians); - - var labelHeight =3D sinRotation * widestLabelSize.width - + cosRotation * (highestLabelSize.height - (isRotated ? highestLabelS= ize.offset : 0)) - + (isRotated ? 0 : lineSpace); // padding - - minSize.height =3D Math.min(me.maxHeight, minSize.height + labelHeight= + tickPadding); - - var offsetLeft =3D me.getPixelForTick(0) - me.left; - var offsetRight =3D me.right - me.getPixelForTick(me.getTicks().length= - 1); - var paddingLeft, paddingRight; - - // Ensure that our ticks are always inside the canvas. When rotated, t= icks are right aligned - // which means that the right padding is dominated by the font height - if (isRotated) { - paddingLeft =3D isBottom ? - cosRotation * firstLabelSize.width + sinRotation * firstLabelSize.of= fset : - sinRotation * (firstLabelSize.height - firstLabelSize.offset); - paddingRight =3D isBottom ? - sinRotation * (lastLabelSize.height - lastLabelSize.offset) : - cosRotation * lastLabelSize.width + sinRotation * lastLabelSize.offs= et; - } else { - paddingLeft =3D firstLabelSize.width / 2; - paddingRight =3D lastLabelSize.width / 2; - } - - // Adjust padding taking into account changes in offsets - // and add 3 px to move away from canvas edges - me.paddingLeft =3D Math.max((paddingLeft - offsetLeft) * me.width / (m= e.width - offsetLeft), 0) + 3; - me.paddingRight =3D Math.max((paddingRight - offsetRight) * me.width /= (me.width - offsetRight), 0) + 3; - } else { - // A vertical axis is more constrained by the width. Labels are the - // dominant factor here, so get that length first and account for padd= ing - var labelWidth =3D tickOpts.mirror ? 0 : - // use lineSpace for consistency with horizontal axis - // tickPadding is not implemented for horizontal - widestLabelSize.width + tickPadding + lineSpace; - - minSize.width =3D Math.min(me.maxWidth, minSize.width + labelWidth); - - me.paddingTop =3D firstLabelSize.height / 2; - me.paddingBottom =3D lastLabelSize.height / 2; - } - } - - me.handleMargins(); - - if (isHorizontal) { - me.width =3D me._length =3D chart.width - me.margins.left - me.margins.= right; - me.height =3D minSize.height; - } else { - me.width =3D minSize.width; - me.height =3D me._length =3D chart.height - me.margins.top - me.margins= .bottom; - } - }, - - /** - * Handle margins and padding interactions - * @private - */ - handleMargins: function() { - var me =3D this; - if (me.margins) { - me.margins.left =3D Math.max(me.paddingLeft, me.margins.left); - me.margins.top =3D Math.max(me.paddingTop, me.margins.top); - me.margins.right =3D Math.max(me.paddingRight, me.margins.right); - me.margins.bottom =3D Math.max(me.paddingBottom, me.margins.bottom); - } - }, - - afterFit: function() { - helpers$1.callback(this.options.afterFit, [this]); - }, - - // Shared Methods - isHorizontal: function() { - var pos =3D this.options.position; - return pos =3D=3D=3D 'top' || pos =3D=3D=3D 'bottom'; - }, - isFullWidth: function() { - return this.options.fullWidth; - }, - - // Get the correct value. NaN bad inputs, If the value type is object get= the x or y based on whether we are horizontal or not - getRightValue: function(rawValue) { - // Null and undefined values first - if (isNullOrUndef(rawValue)) { - return NaN; - } - // isNaN(object) returns true, so make sure NaN is checking for a number= ; Discard Infinite values - if ((typeof rawValue =3D=3D=3D 'number' || rawValue instanceof Number) &= & !isFinite(rawValue)) { - return NaN; - } - - // If it is in fact an object, dive in one more level - if (rawValue) { - if (this.isHorizontal()) { - if (rawValue.x !=3D=3D undefined) { - return this.getRightValue(rawValue.x); - } - } else if (rawValue.y !=3D=3D undefined) { - return this.getRightValue(rawValue.y); - } - } - - // Value is good, return it - return rawValue; - }, - - _convertTicksToLabels: function(ticks) { - var me =3D this; - var labels, i, ilen; - - me.ticks =3D ticks.map(function(tick) { - return tick.value; - }); - - me.beforeTickToLabelConversion(); - - // New implementations should return the formatted tick labels but for B= ACKWARD - // COMPAT, we still support no return (`this.ticks` internally changed b= y calling - // this method and supposed to contain only string values). - labels =3D me.convertTicksToLabels(ticks) || me.ticks; - - me.afterTickToLabelConversion(); - - // BACKWARD COMPAT: synchronize `_ticks` with labels (so potentially `th= is.ticks`) - for (i =3D 0, ilen =3D ticks.length; i < ilen; ++i) { - ticks[i].label =3D labels[i]; - } - - return labels; - }, - - /** - * @private - */ - _getLabelSizes: function() { - var me =3D this; - var labelSizes =3D me._labelSizes; - - if (!labelSizes) { - me._labelSizes =3D labelSizes =3D computeLabelSizes(me.ctx, parseTickFo= ntOptions(me.options.ticks), me.getTicks(), me.longestTextCache); - me.longestLabelWidth =3D labelSizes.widest.width; - } - - return labelSizes; - }, - - /** - * @private - */ - _parseValue: function(value) { - var start, end, min, max; - - if (isArray(value)) { - start =3D +this.getRightValue(value[0]); - end =3D +this.getRightValue(value[1]); - min =3D Math.min(start, end); - max =3D Math.max(start, end); - } else { - value =3D +this.getRightValue(value); - start =3D undefined; - end =3D value; - min =3D value; - max =3D value; - } - - return { - min: min, - max: max, - start: start, - end: end - }; - }, - - /** - * @private - */ - _getScaleLabel: function(rawValue) { - var v =3D this._parseValue(rawValue); - if (v.start !=3D=3D undefined) { - return '[' + v.start + ', ' + v.end + ']'; - } - - return +this.getRightValue(rawValue); - }, - - /** - * Used to get the value to display in the tooltip for the data at the gi= ven index - * @param index - * @param datasetIndex - */ - getLabelForIndex: helpers$1.noop, - - /** - * Returns the location of the given data point. Value can either be an i= ndex or a numerical value - * The coordinate (0, 0) is at the upper-left corner of the canvas - * @param value - * @param index - * @param datasetIndex - */ - getPixelForValue: helpers$1.noop, - - /** - * Used to get the data value from a given pixel. This is the inverse of = getPixelForValue - * The coordinate (0, 0) is at the upper-left corner of the canvas - * @param pixel - */ - getValueForPixel: helpers$1.noop, - - /** - * Returns the location of the tick at the given index - * The coordinate (0, 0) is at the upper-left corner of the canvas - */ - getPixelForTick: function(index) { - var me =3D this; - var offset =3D me.options.offset; - var numTicks =3D me._ticks.length; - var tickWidth =3D 1 / Math.max(numTicks - (offset ? 0 : 1), 1); - - return index < 0 || index > numTicks - 1 - ? null - : me.getPixelForDecimal(index * tickWidth + (offset ? tickWidth / 2 : 0= )); - }, - - /** - * Utility for getting the pixel location of a percentage of scale - * The coordinate (0, 0) is at the upper-left corner of the canvas - */ - getPixelForDecimal: function(decimal) { - var me =3D this; - - if (me._reversePixels) { - decimal =3D 1 - decimal; - } - - return me._startPixel + decimal * me._length; - }, - - getDecimalForPixel: function(pixel) { - var decimal =3D (pixel - this._startPixel) / this._length; - return this._reversePixels ? 1 - decimal : decimal; - }, - - /** - * Returns the pixel for the minimum chart value - * The coordinate (0, 0) is at the upper-left corner of the canvas - */ - getBasePixel: function() { - return this.getPixelForValue(this.getBaseValue()); - }, - - getBaseValue: function() { - var me =3D this; - var min =3D me.min; - var max =3D me.max; - - return me.beginAtZero ? 0 : - min < 0 && max < 0 ? max : - min > 0 && max > 0 ? min : - 0; - }, - - /** - * Returns a subset of ticks to be plotted to avoid overlapping labels. - * @private - */ - _autoSkip: function(ticks) { - var me =3D this; - var tickOpts =3D me.options.ticks; - var axisLength =3D me._length; - var ticksLimit =3D tickOpts.maxTicksLimit || axisLength / me._tickSize()= + 1; - var majorIndices =3D tickOpts.major.enabled ? getMajorIndices(ticks) : [= ]; - var numMajorIndices =3D majorIndices.length; - var first =3D majorIndices[0]; - var last =3D majorIndices[numMajorIndices - 1]; - var i, ilen, spacing, avgMajorSpacing; - - // If there are too many major ticks to display them all - if (numMajorIndices > ticksLimit) { - skipMajors(ticks, majorIndices, numMajorIndices / ticksLimit); - return nonSkipped(ticks); - } - - spacing =3D calculateSpacing(majorIndices, ticks, axisLength, ticksLimit= ); - - if (numMajorIndices > 0) { - for (i =3D 0, ilen =3D numMajorIndices - 1; i < ilen; i++) { - skip(ticks, spacing, majorIndices[i], majorIndices[i + 1]); - } - avgMajorSpacing =3D numMajorIndices > 1 ? (last - first) / (numMajorInd= ices - 1) : null; - skip(ticks, spacing, helpers$1.isNullOrUndef(avgMajorSpacing) ? 0 : fir= st - avgMajorSpacing, first); - skip(ticks, spacing, last, helpers$1.isNullOrUndef(avgMajorSpacing) ? t= icks.length : last + avgMajorSpacing); - return nonSkipped(ticks); - } - skip(ticks, spacing); - return nonSkipped(ticks); - }, - - /** - * @private - */ - _tickSize: function() { - var me =3D this; - var optionTicks =3D me.options.ticks; - - // Calculate space needed by label in axis direction. - var rot =3D helpers$1.toRadians(me.labelRotation); - var cos =3D Math.abs(Math.cos(rot)); - var sin =3D Math.abs(Math.sin(rot)); - - var labelSizes =3D me._getLabelSizes(); - var padding =3D optionTicks.autoSkipPadding || 0; - var w =3D labelSizes ? labelSizes.widest.width + padding : 0; - var h =3D labelSizes ? labelSizes.highest.height + padding : 0; - - // Calculate space needed for 1 tick in axis direction. - return me.isHorizontal() - ? h * cos > w * sin ? w / cos : h / sin - : h * sin < w * cos ? h / cos : w / sin; - }, - - /** - * @private - */ - _isVisible: function() { - var me =3D this; - var chart =3D me.chart; - var display =3D me.options.display; - var i, ilen, meta; - - if (display !=3D=3D 'auto') { - return !!display; - } - - // When 'auto', the scale is visible if at least one associated dataset = is visible. - for (i =3D 0, ilen =3D chart.data.datasets.length; i < ilen; ++i) { - if (chart.isDatasetVisible(i)) { - meta =3D chart.getDatasetMeta(i); - if (meta.xAxisID =3D=3D=3D me.id || meta.yAxisID =3D=3D=3D me.id) { - return true; - } - } - } - - return false; - }, - - /** - * @private - */ - _computeGridLineItems: function(chartArea) { - var me =3D this; - var chart =3D me.chart; - var options =3D me.options; - var gridLines =3D options.gridLines; - var position =3D options.position; - var offsetGridLines =3D gridLines.offsetGridLines; - var isHorizontal =3D me.isHorizontal(); - var ticks =3D me._ticksToDraw; - var ticksLength =3D ticks.length + (offsetGridLines ? 1 : 0); - - var tl =3D getTickMarkLength(gridLines); - var items =3D []; - var axisWidth =3D gridLines.drawBorder ? valueAtIndexOrDefault(gridLines= .lineWidth, 0, 0) : 0; - var axisHalfWidth =3D axisWidth / 2; - var alignPixel =3D helpers$1._alignPixel; - var alignBorderValue =3D function(pixel) { - return alignPixel(chart, pixel, axisWidth); - }; - var borderValue, i, tick, lineValue, alignedLineValue; - var tx1, ty1, tx2, ty2, x1, y1, x2, y2, lineWidth, lineColor, borderDash= , borderDashOffset; - - if (position =3D=3D=3D 'top') { - borderValue =3D alignBorderValue(me.bottom); - ty1 =3D me.bottom - tl; - ty2 =3D borderValue - axisHalfWidth; - y1 =3D alignBorderValue(chartArea.top) + axisHalfWidth; - y2 =3D chartArea.bottom; - } else if (position =3D=3D=3D 'bottom') { - borderValue =3D alignBorderValue(me.top); - y1 =3D chartArea.top; - y2 =3D alignBorderValue(chartArea.bottom) - axisHalfWidth; - ty1 =3D borderValue + axisHalfWidth; - ty2 =3D me.top + tl; - } else if (position =3D=3D=3D 'left') { - borderValue =3D alignBorderValue(me.right); - tx1 =3D me.right - tl; - tx2 =3D borderValue - axisHalfWidth; - x1 =3D alignBorderValue(chartArea.left) + axisHalfWidth; - x2 =3D chartArea.right; - } else { - borderValue =3D alignBorderValue(me.left); - x1 =3D chartArea.left; - x2 =3D alignBorderValue(chartArea.right) - axisHalfWidth; - tx1 =3D borderValue + axisHalfWidth; - tx2 =3D me.left + tl; - } - - for (i =3D 0; i < ticksLength; ++i) { - tick =3D ticks[i] || {}; - - // autoskipper skipped this tick (#4635) - if (isNullOrUndef(tick.label) && i < ticks.length) { - continue; - } - - if (i =3D=3D=3D me.zeroLineIndex && options.offset =3D=3D=3D offsetGrid= Lines) { - // Draw the first index specially - lineWidth =3D gridLines.zeroLineWidth; - lineColor =3D gridLines.zeroLineColor; - borderDash =3D gridLines.zeroLineBorderDash || []; - borderDashOffset =3D gridLines.zeroLineBorderDashOffset || 0.0; - } else { - lineWidth =3D valueAtIndexOrDefault(gridLines.lineWidth, i, 1); - lineColor =3D valueAtIndexOrDefault(gridLines.color, i, 'rgba(0,0,0,0.= 1)'); - borderDash =3D gridLines.borderDash || []; - borderDashOffset =3D gridLines.borderDashOffset || 0.0; - } - - lineValue =3D getPixelForGridLine(me, tick._index || i, offsetGridLines= ); - - // Skip if the pixel is out of the range - if (lineValue =3D=3D=3D undefined) { - continue; - } - - alignedLineValue =3D alignPixel(chart, lineValue, lineWidth); - - if (isHorizontal) { - tx1 =3D tx2 =3D x1 =3D x2 =3D alignedLineValue; - } else { - ty1 =3D ty2 =3D y1 =3D y2 =3D alignedLineValue; - } - - items.push({ - tx1: tx1, - ty1: ty1, - tx2: tx2, - ty2: ty2, - x1: x1, - y1: y1, - x2: x2, - y2: y2, - width: lineWidth, - color: lineColor, - borderDash: borderDash, - borderDashOffset: borderDashOffset, - }); - } - - items.ticksLength =3D ticksLength; - items.borderValue =3D borderValue; - - return items; - }, - - /** - * @private - */ - _computeLabelItems: function() { - var me =3D this; - var options =3D me.options; - var optionTicks =3D options.ticks; - var position =3D options.position; - var isMirrored =3D optionTicks.mirror; - var isHorizontal =3D me.isHorizontal(); - var ticks =3D me._ticksToDraw; - var fonts =3D parseTickFontOptions(optionTicks); - var tickPadding =3D optionTicks.padding; - var tl =3D getTickMarkLength(options.gridLines); - var rotation =3D -helpers$1.toRadians(me.labelRotation); - var items =3D []; - var i, ilen, tick, label, x, y, textAlign, pixel, font, lineHeight, line= Count, textOffset; - - if (position =3D=3D=3D 'top') { - y =3D me.bottom - tl - tickPadding; - textAlign =3D !rotation ? 'center' : 'left'; - } else if (position =3D=3D=3D 'bottom') { - y =3D me.top + tl + tickPadding; - textAlign =3D !rotation ? 'center' : 'right'; - } else if (position =3D=3D=3D 'left') { - x =3D me.right - (isMirrored ? 0 : tl) - tickPadding; - textAlign =3D isMirrored ? 'left' : 'right'; - } else { - x =3D me.left + (isMirrored ? 0 : tl) + tickPadding; - textAlign =3D isMirrored ? 'right' : 'left'; - } - - for (i =3D 0, ilen =3D ticks.length; i < ilen; ++i) { - tick =3D ticks[i]; - label =3D tick.label; - - // autoskipper skipped this tick (#4635) - if (isNullOrUndef(label)) { - continue; - } - - pixel =3D me.getPixelForTick(tick._index || i) + optionTicks.labelOffse= t; - font =3D tick.major ? fonts.major : fonts.minor; - lineHeight =3D font.lineHeight; - lineCount =3D isArray(label) ? label.length : 1; - - if (isHorizontal) { - x =3D pixel; - textOffset =3D position =3D=3D=3D 'top' - ? ((!rotation ? 0.5 : 1) - lineCount) * lineHeight - : (!rotation ? 0.5 : 0) * lineHeight; - } else { - y =3D pixel; - textOffset =3D (1 - lineCount) * lineHeight / 2; - } - - items.push({ - x: x, - y: y, - rotation: rotation, - label: label, - font: font, - textOffset: textOffset, - textAlign: textAlign - }); - } - - return items; - }, - - /** - * @private - */ - _drawGrid: function(chartArea) { - var me =3D this; - var gridLines =3D me.options.gridLines; - - if (!gridLines.display) { - return; - } - - var ctx =3D me.ctx; - var chart =3D me.chart; - var alignPixel =3D helpers$1._alignPixel; - var axisWidth =3D gridLines.drawBorder ? valueAtIndexOrDefault(gridLines= .lineWidth, 0, 0) : 0; - var items =3D me._gridLineItems || (me._gridLineItems =3D me._computeGri= dLineItems(chartArea)); - var width, color, i, ilen, item; - - for (i =3D 0, ilen =3D items.length; i < ilen; ++i) { - item =3D items[i]; - width =3D item.width; - color =3D item.color; - - if (width && color) { - ctx.save(); - ctx.lineWidth =3D width; - ctx.strokeStyle =3D color; - if (ctx.setLineDash) { - ctx.setLineDash(item.borderDash); - ctx.lineDashOffset =3D item.borderDashOffset; - } - - ctx.beginPath(); - - if (gridLines.drawTicks) { - ctx.moveTo(item.tx1, item.ty1); - ctx.lineTo(item.tx2, item.ty2); - } - - if (gridLines.drawOnChartArea) { - ctx.moveTo(item.x1, item.y1); - ctx.lineTo(item.x2, item.y2); - } - - ctx.stroke(); - ctx.restore(); - } - } - - if (axisWidth) { - // Draw the line at the edge of the axis - var firstLineWidth =3D axisWidth; - var lastLineWidth =3D valueAtIndexOrDefault(gridLines.lineWidth, items.= ticksLength - 1, 1); - var borderValue =3D items.borderValue; - var x1, x2, y1, y2; - - if (me.isHorizontal()) { - x1 =3D alignPixel(chart, me.left, firstLineWidth) - firstLineWidth / 2; - x2 =3D alignPixel(chart, me.right, lastLineWidth) + lastLineWidth / 2; - y1 =3D y2 =3D borderValue; - } else { - y1 =3D alignPixel(chart, me.top, firstLineWidth) - firstLineWidth / 2; - y2 =3D alignPixel(chart, me.bottom, lastLineWidth) + lastLineWidth / 2; - x1 =3D x2 =3D borderValue; - } - - ctx.lineWidth =3D axisWidth; - ctx.strokeStyle =3D valueAtIndexOrDefault(gridLines.color, 0); - ctx.beginPath(); - ctx.moveTo(x1, y1); - ctx.lineTo(x2, y2); - ctx.stroke(); - } - }, - - /** - * @private - */ - _drawLabels: function() { - var me =3D this; - var optionTicks =3D me.options.ticks; - - if (!optionTicks.display) { - return; - } - - var ctx =3D me.ctx; - var items =3D me._labelItems || (me._labelItems =3D me._computeLabelItem= s()); - var i, j, ilen, jlen, item, tickFont, label, y; - - for (i =3D 0, ilen =3D items.length; i < ilen; ++i) { - item =3D items[i]; - tickFont =3D item.font; - - // Make sure we draw text in the correct color and font - ctx.save(); - ctx.translate(item.x, item.y); - ctx.rotate(item.rotation); - ctx.font =3D tickFont.string; - ctx.fillStyle =3D tickFont.color; - ctx.textBaseline =3D 'middle'; - ctx.textAlign =3D item.textAlign; - - label =3D item.label; - y =3D item.textOffset; - if (isArray(label)) { - for (j =3D 0, jlen =3D label.length; j < jlen; ++j) { - // We just make sure the multiline element is a string here.. - ctx.fillText('' + label[j], 0, y); - y +=3D tickFont.lineHeight; - } - } else { - ctx.fillText(label, 0, y); - } - ctx.restore(); - } - }, - - /** - * @private - */ - _drawTitle: function() { - var me =3D this; - var ctx =3D me.ctx; - var options =3D me.options; - var scaleLabel =3D options.scaleLabel; - - if (!scaleLabel.display) { - return; - } - - var scaleLabelFontColor =3D valueOrDefault$a(scaleLabel.fontColor, core_= defaults.global.defaultFontColor); - var scaleLabelFont =3D helpers$1.options._parseFont(scaleLabel); - var scaleLabelPadding =3D helpers$1.options.toPadding(scaleLabel.padding= ); - var halfLineHeight =3D scaleLabelFont.lineHeight / 2; - var position =3D options.position; - var rotation =3D 0; - var scaleLabelX, scaleLabelY; - - if (me.isHorizontal()) { - scaleLabelX =3D me.left + me.width / 2; // midpoint of the width - scaleLabelY =3D position =3D=3D=3D 'bottom' - ? me.bottom - halfLineHeight - scaleLabelPadding.bottom - : me.top + halfLineHeight + scaleLabelPadding.top; - } else { - var isLeft =3D position =3D=3D=3D 'left'; - scaleLabelX =3D isLeft - ? me.left + halfLineHeight + scaleLabelPadding.top - : me.right - halfLineHeight - scaleLabelPadding.top; - scaleLabelY =3D me.top + me.height / 2; - rotation =3D isLeft ? -0.5 * Math.PI : 0.5 * Math.PI; - } - - ctx.save(); - ctx.translate(scaleLabelX, scaleLabelY); - ctx.rotate(rotation); - ctx.textAlign =3D 'center'; - ctx.textBaseline =3D 'middle'; - ctx.fillStyle =3D scaleLabelFontColor; // render in correct colour - ctx.font =3D scaleLabelFont.string; - ctx.fillText(scaleLabel.labelString, 0, 0); - ctx.restore(); - }, - - draw: function(chartArea) { - var me =3D this; - - if (!me._isVisible()) { - return; - } - - me._drawGrid(chartArea); - me._drawTitle(); - me._drawLabels(); - }, - - /** - * @private - */ - _layers: function() { - var me =3D this; - var opts =3D me.options; - var tz =3D opts.ticks && opts.ticks.z || 0; - var gz =3D opts.gridLines && opts.gridLines.z || 0; - - if (!me._isVisible() || tz =3D=3D=3D gz || me.draw !=3D=3D me._draw) { - // backward compatibility: draw has been overridden by custom scale - return [{ - z: tz, - draw: function() { - me.draw.apply(me, arguments); - } - }]; - } - - return [{ - z: gz, - draw: function() { - me._drawGrid.apply(me, arguments); - me._drawTitle.apply(me, arguments); - } - }, { - z: tz, - draw: function() { - me._drawLabels.apply(me, arguments); - } - }]; - }, - - /** - * @private - */ - _getMatchingVisibleMetas: function(type) { - var me =3D this; - var isHorizontal =3D me.isHorizontal(); - return me.chart._getSortedVisibleDatasetMetas() - .filter(function(meta) { - return (!type || meta.type =3D=3D=3D type) - && (isHorizontal ? meta.xAxisID =3D=3D=3D me.id : meta.yAxisID =3D=3D= =3D me.id); - }); - } -}); - -Scale.prototype._draw =3D Scale.prototype.draw; - -var core_scale =3D Scale; - -var isNullOrUndef$1 =3D helpers$1.isNullOrUndef; - -var defaultConfig =3D { - position: 'bottom' -}; - -var scale_category =3D core_scale.extend({ - determineDataLimits: function() { - var me =3D this; - var labels =3D me._getLabels(); - var ticksOpts =3D me.options.ticks; - var min =3D ticksOpts.min; - var max =3D ticksOpts.max; - var minIndex =3D 0; - var maxIndex =3D labels.length - 1; - var findIndex; - - if (min !=3D=3D undefined) { - // user specified min value - findIndex =3D labels.indexOf(min); - if (findIndex >=3D 0) { - minIndex =3D findIndex; - } - } - - if (max !=3D=3D undefined) { - // user specified max value - findIndex =3D labels.indexOf(max); - if (findIndex >=3D 0) { - maxIndex =3D findIndex; - } - } - - me.minIndex =3D minIndex; - me.maxIndex =3D maxIndex; - me.min =3D labels[minIndex]; - me.max =3D labels[maxIndex]; - }, - - buildTicks: function() { - var me =3D this; - var labels =3D me._getLabels(); - var minIndex =3D me.minIndex; - var maxIndex =3D me.maxIndex; - - // If we are viewing some subset of labels, slice the original array - me.ticks =3D (minIndex =3D=3D=3D 0 && maxIndex =3D=3D=3D labels.length -= 1) ? labels : labels.slice(minIndex, maxIndex + 1); - }, - - getLabelForIndex: function(index, datasetIndex) { - var me =3D this; - var chart =3D me.chart; - - if (chart.getDatasetMeta(datasetIndex).controller._getValueScaleId() =3D= =3D=3D me.id) { - return me.getRightValue(chart.data.datasets[datasetIndex].data[index]); - } - - return me._getLabels()[index]; - }, - - _configure: function() { - var me =3D this; - var offset =3D me.options.offset; - var ticks =3D me.ticks; - - core_scale.prototype._configure.call(me); - - if (!me.isHorizontal()) { - // For backward compatibility, vertical category scale reverse is inver= ted. - me._reversePixels =3D !me._reversePixels; - } - - if (!ticks) { - return; - } - - me._startValue =3D me.minIndex - (offset ? 0.5 : 0); - me._valueRange =3D Math.max(ticks.length - (offset ? 0 : 1), 1); - }, - - // Used to get data value locations. Value can either be an index or a n= umerical value - getPixelForValue: function(value, index, datasetIndex) { - var me =3D this; - var valueCategory, labels, idx; - - if (!isNullOrUndef$1(index) && !isNullOrUndef$1(datasetIndex)) { - value =3D me.chart.data.datasets[datasetIndex].data[index]; - } - - // If value is a data object, then index is the index in the data array, - // not the index of the scale. We need to change that. - if (!isNullOrUndef$1(value)) { - valueCategory =3D me.isHorizontal() ? value.x : value.y; - } - if (valueCategory !=3D=3D undefined || (value !=3D=3D undefined && isNaN= (index))) { - labels =3D me._getLabels(); - value =3D helpers$1.valueOrDefault(valueCategory, value); - idx =3D labels.indexOf(value); - index =3D idx !=3D=3D -1 ? idx : index; - if (isNaN(index)) { - index =3D value; - } - } - return me.getPixelForDecimal((index - me._startValue) / me._valueRange); - }, - - getPixelForTick: function(index) { - var ticks =3D this.ticks; - return index < 0 || index > ticks.length - 1 - ? null - : this.getPixelForValue(ticks[index], index + this.minIndex); - }, - - getValueForPixel: function(pixel) { - var me =3D this; - var value =3D Math.round(me._startValue + me.getDecimalForPixel(pixel) *= me._valueRange); - return Math.min(Math.max(value, 0), me.ticks.length - 1); - }, - - getBasePixel: function() { - return this.bottom; - } -}); - -// INTERNAL: static default options, registered in src/index.js -var _defaults =3D defaultConfig; -scale_category._defaults =3D _defaults; - -var noop =3D helpers$1.noop; -var isNullOrUndef$2 =3D helpers$1.isNullOrUndef; - -/** - * Generate a set of linear ticks - * @param generationOptions the options used to generate the ticks - * @param dataRange the range of the data - * @returns {number[]} array of tick values - */ -function generateTicks(generationOptions, dataRange) { - var ticks =3D []; - // To get a "nice" value for the tick spacing, we will use the appropriat= ely named - // "nice number" algorithm. See https://stackoverflow.com/questions/85068= 81/nice-label-algorithm-for-charts-with-minimum-ticks - // for details. - - var MIN_SPACING =3D 1e-14; - var stepSize =3D generationOptions.stepSize; - var unit =3D stepSize || 1; - var maxNumSpaces =3D generationOptions.maxTicks - 1; - var min =3D generationOptions.min; - var max =3D generationOptions.max; - var precision =3D generationOptions.precision; - var rmin =3D dataRange.min; - var rmax =3D dataRange.max; - var spacing =3D helpers$1.niceNum((rmax - rmin) / maxNumSpaces / unit) * = unit; - var factor, niceMin, niceMax, numSpaces; - - // Beyond MIN_SPACING floating point numbers being to lose precision - // such that we can't do the math necessary to generate ticks - if (spacing < MIN_SPACING && isNullOrUndef$2(min) && isNullOrUndef$2(max)= ) { - return [rmin, rmax]; - } - - numSpaces =3D Math.ceil(rmax / spacing) - Math.floor(rmin / spacing); - if (numSpaces > maxNumSpaces) { - // If the calculated num of spaces exceeds maxNumSpaces, recalculate it - spacing =3D helpers$1.niceNum(numSpaces * spacing / maxNumSpaces / unit)= * unit; - } - - if (stepSize || isNullOrUndef$2(precision)) { - // If a precision is not specified, calculate factor based on spacing - factor =3D Math.pow(10, helpers$1._decimalPlaces(spacing)); - } else { - // If the user specified a precision, round to that number of decimal pl= aces - factor =3D Math.pow(10, precision); - spacing =3D Math.ceil(spacing * factor) / factor; - } - - niceMin =3D Math.floor(rmin / spacing) * spacing; - niceMax =3D Math.ceil(rmax / spacing) * spacing; - - // If min, max and stepSize is set and they make an evenly spaced scale u= se it. - if (stepSize) { - // If very close to our whole number, use it. - if (!isNullOrUndef$2(min) && helpers$1.almostWhole(min / spacing, spacin= g / 1000)) { - niceMin =3D min; - } - if (!isNullOrUndef$2(max) && helpers$1.almostWhole(max / spacing, spacin= g / 1000)) { - niceMax =3D max; - } - } - - numSpaces =3D (niceMax - niceMin) / spacing; - // If very close to our rounded value, use it. - if (helpers$1.almostEquals(numSpaces, Math.round(numSpaces), spacing / 10= 00)) { - numSpaces =3D Math.round(numSpaces); - } else { - numSpaces =3D Math.ceil(numSpaces); - } - - niceMin =3D Math.round(niceMin * factor) / factor; - niceMax =3D Math.round(niceMax * factor) / factor; - ticks.push(isNullOrUndef$2(min) ? niceMin : min); - for (var j =3D 1; j < numSpaces; ++j) { - ticks.push(Math.round((niceMin + j * spacing) * factor) / factor); - } - ticks.push(isNullOrUndef$2(max) ? niceMax : max); - - return ticks; -} - -var scale_linearbase =3D core_scale.extend({ - getRightValue: function(value) { - if (typeof value =3D=3D=3D 'string') { - return +value; - } - return core_scale.prototype.getRightValue.call(this, value); - }, - - handleTickRangeOptions: function() { - var me =3D this; - var opts =3D me.options; - var tickOpts =3D opts.ticks; - - // If we are forcing it to begin at 0, but 0 will already be rendered on= the chart, - // do nothing since that would make the chart weird. If the user really = wants a weird chart - // axis, they can manually override it - if (tickOpts.beginAtZero) { - var minSign =3D helpers$1.sign(me.min); - var maxSign =3D helpers$1.sign(me.max); - - if (minSign < 0 && maxSign < 0) { - // move the top up to 0 - me.max =3D 0; - } else if (minSign > 0 && maxSign > 0) { - // move the bottom down to 0 - me.min =3D 0; - } - } - - var setMin =3D tickOpts.min !=3D=3D undefined || tickOpts.suggestedMin != =3D=3D undefined; - var setMax =3D tickOpts.max !=3D=3D undefined || tickOpts.suggestedMax != =3D=3D undefined; - - if (tickOpts.min !=3D=3D undefined) { - me.min =3D tickOpts.min; - } else if (tickOpts.suggestedMin !=3D=3D undefined) { - if (me.min =3D=3D=3D null) { - me.min =3D tickOpts.suggestedMin; - } else { - me.min =3D Math.min(me.min, tickOpts.suggestedMin); - } - } - - if (tickOpts.max !=3D=3D undefined) { - me.max =3D tickOpts.max; - } else if (tickOpts.suggestedMax !=3D=3D undefined) { - if (me.max =3D=3D=3D null) { - me.max =3D tickOpts.suggestedMax; - } else { - me.max =3D Math.max(me.max, tickOpts.suggestedMax); - } - } - - if (setMin !=3D=3D setMax) { - // We set the min or the max but not both. - // So ensure that our range is good - // Inverted or 0 length range can happen when - // ticks.min is set, and no datasets are visible - if (me.min >=3D me.max) { - if (setMin) { - me.max =3D me.min + 1; - } else { - me.min =3D me.max - 1; - } - } - } - - if (me.min =3D=3D=3D me.max) { - me.max++; - - if (!tickOpts.beginAtZero) { - me.min--; - } - } - }, - - getTickLimit: function() { - var me =3D this; - var tickOpts =3D me.options.ticks; - var stepSize =3D tickOpts.stepSize; - var maxTicksLimit =3D tickOpts.maxTicksLimit; - var maxTicks; - - if (stepSize) { - maxTicks =3D Math.ceil(me.max / stepSize) - Math.floor(me.min / stepSiz= e) + 1; - } else { - maxTicks =3D me._computeTickLimit(); - maxTicksLimit =3D maxTicksLimit || 11; - } - - if (maxTicksLimit) { - maxTicks =3D Math.min(maxTicksLimit, maxTicks); - } - - return maxTicks; - }, - - _computeTickLimit: function() { - return Number.POSITIVE_INFINITY; - }, - - handleDirectionalChanges: noop, - - buildTicks: function() { - var me =3D this; - var opts =3D me.options; - var tickOpts =3D opts.ticks; - - // Figure out what the max number of ticks we can support it is based on= the size of - // the axis area. For now, we say that the minimum tick spacing in pixel= s must be 40 - // We also limit the maximum number of ticks to 11 which gives a nice 10= squares on - // the graph. Make sure we always have at least 2 ticks - var maxTicks =3D me.getTickLimit(); - maxTicks =3D Math.max(2, maxTicks); - - var numericGeneratorOptions =3D { - maxTicks: maxTicks, - min: tickOpts.min, - max: tickOpts.max, - precision: tickOpts.precision, - stepSize: helpers$1.valueOrDefault(tickOpts.fixedStepSize, tickOpts.ste= pSize) - }; - var ticks =3D me.ticks =3D generateTicks(numericGeneratorOptions, me); - - me.handleDirectionalChanges(); - - // At this point, we need to update our max and min given the tick value= s since we have expanded the - // range of the scale - me.max =3D helpers$1.max(ticks); - me.min =3D helpers$1.min(ticks); - - if (tickOpts.reverse) { - ticks.reverse(); - - me.start =3D me.max; - me.end =3D me.min; - } else { - me.start =3D me.min; - me.end =3D me.max; - } - }, - - convertTicksToLabels: function() { - var me =3D this; - me.ticksAsNumbers =3D me.ticks.slice(); - me.zeroLineIndex =3D me.ticks.indexOf(0); - - core_scale.prototype.convertTicksToLabels.call(me); - }, - - _configure: function() { - var me =3D this; - var ticks =3D me.getTicks(); - var start =3D me.min; - var end =3D me.max; - var offset; - - core_scale.prototype._configure.call(me); - - if (me.options.offset && ticks.length) { - offset =3D (end - start) / Math.max(ticks.length - 1, 1) / 2; - start -=3D offset; - end +=3D offset; - } - me._startValue =3D start; - me._endValue =3D end; - me._valueRange =3D end - start; - } -}); - -var defaultConfig$1 =3D { - position: 'left', - ticks: { - callback: core_ticks.formatters.linear - } -}; - -var DEFAULT_MIN =3D 0; -var DEFAULT_MAX =3D 1; - -function getOrCreateStack(stacks, stacked, meta) { - var key =3D [ - meta.type, - // we have a separate stack for stack=3Dundefined datasets when the opts= .stacked is undefined - stacked =3D=3D=3D undefined && meta.stack =3D=3D=3D undefined ? meta.ind= ex : '', - meta.stack - ].join('.'); - - if (stacks[key] =3D=3D=3D undefined) { - stacks[key] =3D { - pos: [], - neg: [] - }; - } - - return stacks[key]; -} - -function stackData(scale, stacks, meta, data) { - var opts =3D scale.options; - var stacked =3D opts.stacked; - var stack =3D getOrCreateStack(stacks, stacked, meta); - var pos =3D stack.pos; - var neg =3D stack.neg; - var ilen =3D data.length; - var i, value; - - for (i =3D 0; i < ilen; ++i) { - value =3D scale._parseValue(data[i]); - if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden) { - continue; - } - - pos[i] =3D pos[i] || 0; - neg[i] =3D neg[i] || 0; - - if (opts.relativePoints) { - pos[i] =3D 100; - } else if (value.min < 0 || value.max < 0) { - neg[i] +=3D value.min; - } else { - pos[i] +=3D value.max; - } - } -} - -function updateMinMax(scale, meta, data) { - var ilen =3D data.length; - var i, value; - - for (i =3D 0; i < ilen; ++i) { - value =3D scale._parseValue(data[i]); - if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden) { - continue; - } - - scale.min =3D Math.min(scale.min, value.min); - scale.max =3D Math.max(scale.max, value.max); - } -} - -var scale_linear =3D scale_linearbase.extend({ - determineDataLimits: function() { - var me =3D this; - var opts =3D me.options; - var chart =3D me.chart; - var datasets =3D chart.data.datasets; - var metasets =3D me._getMatchingVisibleMetas(); - var hasStacks =3D opts.stacked; - var stacks =3D {}; - var ilen =3D metasets.length; - var i, meta, data, values; - - me.min =3D Number.POSITIVE_INFINITY; - me.max =3D Number.NEGATIVE_INFINITY; - - if (hasStacks =3D=3D=3D undefined) { - for (i =3D 0; !hasStacks && i < ilen; ++i) { - meta =3D metasets[i]; - hasStacks =3D meta.stack !=3D=3D undefined; - } - } - - for (i =3D 0; i < ilen; ++i) { - meta =3D metasets[i]; - data =3D datasets[meta.index].data; - if (hasStacks) { - stackData(me, stacks, meta, data); - } else { - updateMinMax(me, meta, data); - } - } - - helpers$1.each(stacks, function(stackValues) { - values =3D stackValues.pos.concat(stackValues.neg); - me.min =3D Math.min(me.min, helpers$1.min(values)); - me.max =3D Math.max(me.max, helpers$1.max(values)); - }); - - me.min =3D helpers$1.isFinite(me.min) && !isNaN(me.min) ? me.min : DEFAU= LT_MIN; - me.max =3D helpers$1.isFinite(me.max) && !isNaN(me.max) ? me.max : DEFAU= LT_MAX; - - // Common base implementation to handle ticks.min, ticks.max, ticks.begi= nAtZero - me.handleTickRangeOptions(); - }, - - // Returns the maximum number of ticks based on the scale dimension - _computeTickLimit: function() { - var me =3D this; - var tickFont; - - if (me.isHorizontal()) { - return Math.ceil(me.width / 40); - } - tickFont =3D helpers$1.options._parseFont(me.options.ticks); - return Math.ceil(me.height / tickFont.lineHeight); - }, - - // Called after the ticks are built. We need - handleDirectionalChanges: function() { - if (!this.isHorizontal()) { - // We are in a vertical orientation. The top value is the highest. So r= everse the array - this.ticks.reverse(); - } - }, - - getLabelForIndex: function(index, datasetIndex) { - return this._getScaleLabel(this.chart.data.datasets[datasetIndex].data[i= ndex]); - }, - - // Utils - getPixelForValue: function(value) { - var me =3D this; - return me.getPixelForDecimal((+me.getRightValue(value) - me._startValue)= / me._valueRange); - }, - - getValueForPixel: function(pixel) { - return this._startValue + this.getDecimalForPixel(pixel) * this._valueRa= nge; - }, - - getPixelForTick: function(index) { - var ticks =3D this.ticksAsNumbers; - if (index < 0 || index > ticks.length - 1) { - return null; - } - return this.getPixelForValue(ticks[index]); - } -}); - -// INTERNAL: static default options, registered in src/index.js -var _defaults$1 =3D defaultConfig$1; -scale_linear._defaults =3D _defaults$1; - -var valueOrDefault$b =3D helpers$1.valueOrDefault; -var log10 =3D helpers$1.math.log10; - -/** - * Generate a set of logarithmic ticks - * @param generationOptions the options used to generate the ticks - * @param dataRange the range of the data - * @returns {number[]} array of tick values - */ -function generateTicks$1(generationOptions, dataRange) { - var ticks =3D []; - - var tickVal =3D valueOrDefault$b(generationOptions.min, Math.pow(10, Math= .floor(log10(dataRange.min)))); - - var endExp =3D Math.floor(log10(dataRange.max)); - var endSignificand =3D Math.ceil(dataRange.max / Math.pow(10, endExp)); - var exp, significand; - - if (tickVal =3D=3D=3D 0) { - exp =3D Math.floor(log10(dataRange.minNotZero)); - significand =3D Math.floor(dataRange.minNotZero / Math.pow(10, exp)); - - ticks.push(tickVal); - tickVal =3D significand * Math.pow(10, exp); - } else { - exp =3D Math.floor(log10(tickVal)); - significand =3D Math.floor(tickVal / Math.pow(10, exp)); - } - var precision =3D exp < 0 ? Math.pow(10, Math.abs(exp)) : 1; - - do { - ticks.push(tickVal); - - ++significand; - if (significand =3D=3D=3D 10) { - significand =3D 1; - ++exp; - precision =3D exp >=3D 0 ? 1 : precision; - } - - tickVal =3D Math.round(significand * Math.pow(10, exp) * precision) / pr= ecision; - } while (exp < endExp || (exp =3D=3D=3D endExp && significand < endSignif= icand)); - - var lastTick =3D valueOrDefault$b(generationOptions.max, tickVal); - ticks.push(lastTick); - - return ticks; -} - -var defaultConfig$2 =3D { - position: 'left', - - // label settings - ticks: { - callback: core_ticks.formatters.logarithmic - } -}; - -// TODO(v3): change this to positiveOrDefault -function nonNegativeOrDefault(value, defaultValue) { - return helpers$1.isFinite(value) && value >=3D 0 ? value : defaultValue; -} - -var scale_logarithmic =3D core_scale.extend({ - determineDataLimits: function() { - var me =3D this; - var opts =3D me.options; - var chart =3D me.chart; - var datasets =3D chart.data.datasets; - var isHorizontal =3D me.isHorizontal(); - function IDMatches(meta) { - return isHorizontal ? meta.xAxisID =3D=3D=3D me.id : meta.yAxisID =3D= =3D=3D me.id; - } - var datasetIndex, meta, value, data, i, ilen; - - // Calculate Range - me.min =3D Number.POSITIVE_INFINITY; - me.max =3D Number.NEGATIVE_INFINITY; - me.minNotZero =3D Number.POSITIVE_INFINITY; - - var hasStacks =3D opts.stacked; - if (hasStacks =3D=3D=3D undefined) { - for (datasetIndex =3D 0; datasetIndex < datasets.length; datasetIndex++= ) { - meta =3D chart.getDatasetMeta(datasetIndex); - if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta) && - meta.stack !=3D=3D undefined) { - hasStacks =3D true; - break; - } - } - } - - if (opts.stacked || hasStacks) { - var valuesPerStack =3D {}; - - for (datasetIndex =3D 0; datasetIndex < datasets.length; datasetIndex++= ) { - meta =3D chart.getDatasetMeta(datasetIndex); - var key =3D [ - meta.type, - // we have a separate stack for stack=3Dundefined datasets when the o= pts.stacked is undefined - ((opts.stacked =3D=3D=3D undefined && meta.stack =3D=3D=3D undefined)= ? datasetIndex : ''), - meta.stack - ].join('.'); - - if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) { - if (valuesPerStack[key] =3D=3D=3D undefined) { - valuesPerStack[key] =3D []; - } - - data =3D datasets[datasetIndex].data; - for (i =3D 0, ilen =3D data.length; i < ilen; i++) { - var values =3D valuesPerStack[key]; - value =3D me._parseValue(data[i]); - // invalid, hidden and negative values are ignored - if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden || v= alue.min < 0 || value.max < 0) { - continue; - } - values[i] =3D values[i] || 0; - values[i] +=3D value.max; - } - } - } - - helpers$1.each(valuesPerStack, function(valuesForType) { - if (valuesForType.length > 0) { - var minVal =3D helpers$1.min(valuesForType); - var maxVal =3D helpers$1.max(valuesForType); - me.min =3D Math.min(me.min, minVal); - me.max =3D Math.max(me.max, maxVal); - } - }); - - } else { - for (datasetIndex =3D 0; datasetIndex < datasets.length; datasetIndex++= ) { - meta =3D chart.getDatasetMeta(datasetIndex); - if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) { - data =3D datasets[datasetIndex].data; - for (i =3D 0, ilen =3D data.length; i < ilen; i++) { - value =3D me._parseValue(data[i]); - // invalid, hidden and negative values are ignored - if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden || v= alue.min < 0 || value.max < 0) { - continue; - } - - me.min =3D Math.min(value.min, me.min); - me.max =3D Math.max(value.max, me.max); - - if (value.min !=3D=3D 0) { - me.minNotZero =3D Math.min(value.min, me.minNotZero); - } - } - } - } - } - - me.min =3D helpers$1.isFinite(me.min) ? me.min : null; - me.max =3D helpers$1.isFinite(me.max) ? me.max : null; - me.minNotZero =3D helpers$1.isFinite(me.minNotZero) ? me.minNotZero : nu= ll; - - // Common base implementation to handle ticks.min, ticks.max - this.handleTickRangeOptions(); - }, - - handleTickRangeOptions: function() { - var me =3D this; - var tickOpts =3D me.options.ticks; - var DEFAULT_MIN =3D 1; - var DEFAULT_MAX =3D 10; - - me.min =3D nonNegativeOrDefault(tickOpts.min, me.min); - me.max =3D nonNegativeOrDefault(tickOpts.max, me.max); - - if (me.min =3D=3D=3D me.max) { - if (me.min !=3D=3D 0 && me.min !=3D=3D null) { - me.min =3D Math.pow(10, Math.floor(log10(me.min)) - 1); - me.max =3D Math.pow(10, Math.floor(log10(me.max)) + 1); - } else { - me.min =3D DEFAULT_MIN; - me.max =3D DEFAULT_MAX; - } - } - if (me.min =3D=3D=3D null) { - me.min =3D Math.pow(10, Math.floor(log10(me.max)) - 1); - } - if (me.max =3D=3D=3D null) { - me.max =3D me.min !=3D=3D 0 - ? Math.pow(10, Math.floor(log10(me.min)) + 1) - : DEFAULT_MAX; - } - if (me.minNotZero =3D=3D=3D null) { - if (me.min > 0) { - me.minNotZero =3D me.min; - } else if (me.max < 1) { - me.minNotZero =3D Math.pow(10, Math.floor(log10(me.max))); - } else { - me.minNotZero =3D DEFAULT_MIN; - } - } - }, - - buildTicks: function() { - var me =3D this; - var tickOpts =3D me.options.ticks; - var reverse =3D !me.isHorizontal(); - - var generationOptions =3D { - min: nonNegativeOrDefault(tickOpts.min), - max: nonNegativeOrDefault(tickOpts.max) - }; - var ticks =3D me.ticks =3D generateTicks$1(generationOptions, me); - - // At this point, we need to update our max and min given the tick value= s since we have expanded the - // range of the scale - me.max =3D helpers$1.max(ticks); - me.min =3D helpers$1.min(ticks); - - if (tickOpts.reverse) { - reverse =3D !reverse; - me.start =3D me.max; - me.end =3D me.min; - } else { - me.start =3D me.min; - me.end =3D me.max; - } - if (reverse) { - ticks.reverse(); - } - }, - - convertTicksToLabels: function() { - this.tickValues =3D this.ticks.slice(); - - core_scale.prototype.convertTicksToLabels.call(this); - }, - - // Get the correct tooltip label - getLabelForIndex: function(index, datasetIndex) { - return this._getScaleLabel(this.chart.data.datasets[datasetIndex].data[i= ndex]); - }, - - getPixelForTick: function(index) { - var ticks =3D this.tickValues; - if (index < 0 || index > ticks.length - 1) { - return null; - } - return this.getPixelForValue(ticks[index]); - }, - - /** - * Returns the value of the first tick. - * @param {number} value - The minimum not zero value. - * @return {number} The first tick value. - * @private - */ - _getFirstTickValue: function(value) { - var exp =3D Math.floor(log10(value)); - var significand =3D Math.floor(value / Math.pow(10, exp)); - - return significand * Math.pow(10, exp); - }, - - _configure: function() { - var me =3D this; - var start =3D me.min; - var offset =3D 0; - - core_scale.prototype._configure.call(me); - - if (start =3D=3D=3D 0) { - start =3D me._getFirstTickValue(me.minNotZero); - offset =3D valueOrDefault$b(me.options.ticks.fontSize, core_defaults.gl= obal.defaultFontSize) / me._length; - } - - me._startValue =3D log10(start); - me._valueOffset =3D offset; - me._valueRange =3D (log10(me.max) - log10(start)) / (1 - offset); - }, - - getPixelForValue: function(value) { - var me =3D this; - var decimal =3D 0; - - value =3D +me.getRightValue(value); - - if (value > me.min && value > 0) { - decimal =3D (log10(value) - me._startValue) / me._valueRange + me._valu= eOffset; - } - return me.getPixelForDecimal(decimal); - }, - - getValueForPixel: function(pixel) { - var me =3D this; - var decimal =3D me.getDecimalForPixel(pixel); - return decimal =3D=3D=3D 0 && me.min =3D=3D=3D 0 - ? 0 - : Math.pow(10, me._startValue + (decimal - me._valueOffset) * me._value= Range); - } -}); - -// INTERNAL: static default options, registered in src/index.js -var _defaults$2 =3D defaultConfig$2; -scale_logarithmic._defaults =3D _defaults$2; - -var valueOrDefault$c =3D helpers$1.valueOrDefault; -var valueAtIndexOrDefault$1 =3D helpers$1.valueAtIndexOrDefault; -var resolve$4 =3D helpers$1.options.resolve; - -var defaultConfig$3 =3D { - display: true, - - // Boolean - Whether to animate scaling the chart from the centre - animate: true, - position: 'chartArea', - - angleLines: { - display: true, - color: 'rgba(0,0,0,0.1)', - lineWidth: 1, - borderDash: [], - borderDashOffset: 0.0 - }, - - gridLines: { - circular: false - }, - - // label settings - ticks: { - // Boolean - Show a backdrop to the scale label - showLabelBackdrop: true, - - // String - The colour of the label backdrop - backdropColor: 'rgba(255,255,255,0.75)', - - // Number - The backdrop padding above & below the label in pixels - backdropPaddingY: 2, - - // Number - The backdrop padding to the side of the label in pixels - backdropPaddingX: 2, - - callback: core_ticks.formatters.linear - }, - - pointLabels: { - // Boolean - if true, show point labels - display: true, - - // Number - Point label font size in pixels - fontSize: 10, - - // Function - Used to convert point labels - callback: function(label) { - return label; - } - } -}; - -function getTickBackdropHeight(opts) { - var tickOpts =3D opts.ticks; - - if (tickOpts.display && opts.display) { - return valueOrDefault$c(tickOpts.fontSize, core_defaults.global.defaultF= ontSize) + tickOpts.backdropPaddingY * 2; - } - return 0; -} - -function measureLabelSize(ctx, lineHeight, label) { - if (helpers$1.isArray(label)) { - return { - w: helpers$1.longestText(ctx, ctx.font, label), - h: label.length * lineHeight - }; - } - - return { - w: ctx.measureText(label).width, - h: lineHeight - }; -} - -function determineLimits(angle, pos, size, min, max) { - if (angle =3D=3D=3D min || angle =3D=3D=3D max) { - return { - start: pos - (size / 2), - end: pos + (size / 2) - }; - } else if (angle < min || angle > max) { - return { - start: pos - size, - end: pos - }; - } - - return { - start: pos, - end: pos + size - }; -} - -/** - * Helper function to fit a radial linear scale with point labels - */ -function fitWithPointLabels(scale) { - - // Right, this is really confusing and there is a lot of maths going on h= ere - // The gist of the problem is here: https://gist.github.com/nnnick/696cc9= c55f4b0beb8fe9 - // - // Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.= gif - // - // Solution: - // - // We assume the radius of the polygon is half the size of the canvas at = first - // at each index we check if the text overlaps. - // - // Where it does, we store that angle and that index. - // - // After finding the largest index and angle we calculate how much we nee= d to remove - // from the shape radius to move the point inwards by that x. - // - // We average the left and right distances to get the maximum shape radiu= s that can fit in the box - // along with labels. - // - // Once we have that, we can find the centre point for the chart, by taki= ng the x text protrusion - // on each side, removing that from the size, halving it and adding the l= eft x protrusion width. - // - // This will mean we have a shape fitted to the canvas, as large as it ca= n be with the labels - // and position it in the most space efficient manner - // - // https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif - - var plFont =3D helpers$1.options._parseFont(scale.options.pointLabels); - - // Get maximum radius of the polygon. Either half the height (minus the t= ext width) or half the width. - // Use this to calculate the offset + change. - Make sure L/R protrusion = is at least 0 to stop issues with centre points - var furthestLimits =3D { - l: 0, - r: scale.width, - t: 0, - b: scale.height - scale.paddingTop - }; - var furthestAngles =3D {}; - var i, textSize, pointPosition; - - scale.ctx.font =3D plFont.string; - scale._pointLabelSizes =3D []; - - var valueCount =3D scale.chart.data.labels.length; - for (i =3D 0; i < valueCount; i++) { - pointPosition =3D scale.getPointPosition(i, scale.drawingArea + 5); - textSize =3D measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointL= abels[i]); - scale._pointLabelSizes[i] =3D textSize; - - // Add quarter circle to make degree 0 mean top of circle - var angleRadians =3D scale.getIndexAngle(i); - var angle =3D helpers$1.toDegrees(angleRadians) % 360; - var hLimits =3D determineLimits(angle, pointPosition.x, textSize.w, 0, 1= 80); - var vLimits =3D determineLimits(angle, pointPosition.y, textSize.h, 90, = 270); - - if (hLimits.start < furthestLimits.l) { - furthestLimits.l =3D hLimits.start; - furthestAngles.l =3D angleRadians; - } - - if (hLimits.end > furthestLimits.r) { - furthestLimits.r =3D hLimits.end; - furthestAngles.r =3D angleRadians; - } - - if (vLimits.start < furthestLimits.t) { - furthestLimits.t =3D vLimits.start; - furthestAngles.t =3D angleRadians; - } - - if (vLimits.end > furthestLimits.b) { - furthestLimits.b =3D vLimits.end; - furthestAngles.b =3D angleRadians; - } - } - - scale.setReductions(scale.drawingArea, furthestLimits, furthestAngles); -} - -function getTextAlignForAngle(angle) { - if (angle =3D=3D=3D 0 || angle =3D=3D=3D 180) { - return 'center'; - } else if (angle < 180) { - return 'left'; - } - - return 'right'; -} - -function fillText(ctx, text, position, lineHeight) { - var y =3D position.y + lineHeight / 2; - var i, ilen; - - if (helpers$1.isArray(text)) { - for (i =3D 0, ilen =3D text.length; i < ilen; ++i) { - ctx.fillText(text[i], position.x, y); - y +=3D lineHeight; - } - } else { - ctx.fillText(text, position.x, y); - } -} - -function adjustPointPositionForLabelHeight(angle, textSize, position) { - if (angle =3D=3D=3D 90 || angle =3D=3D=3D 270) { - position.y -=3D (textSize.h / 2); - } else if (angle > 270 || angle < 90) { - position.y -=3D textSize.h; - } -} - -function drawPointLabels(scale) { - var ctx =3D scale.ctx; - var opts =3D scale.options; - var pointLabelOpts =3D opts.pointLabels; - var tickBackdropHeight =3D getTickBackdropHeight(opts); - var outerDistance =3D scale.getDistanceFromCenterForValue(opts.ticks.reve= rse ? scale.min : scale.max); - var plFont =3D helpers$1.options._parseFont(pointLabelOpts); - - ctx.save(); - - ctx.font =3D plFont.string; - ctx.textBaseline =3D 'middle'; - - for (var i =3D scale.chart.data.labels.length - 1; i >=3D 0; i--) { - // Extra pixels out for some label spacing - var extra =3D (i =3D=3D=3D 0 ? tickBackdropHeight / 2 : 0); - var pointLabelPosition =3D scale.getPointPosition(i, outerDistance + ext= ra + 5); - - // Keep this in loop since we may support array properties here - var pointLabelFontColor =3D valueAtIndexOrDefault$1(pointLabelOpts.fontC= olor, i, core_defaults.global.defaultFontColor); - ctx.fillStyle =3D pointLabelFontColor; - - var angleRadians =3D scale.getIndexAngle(i); - var angle =3D helpers$1.toDegrees(angleRadians); - ctx.textAlign =3D getTextAlignForAngle(angle); - adjustPointPositionForLabelHeight(angle, scale._pointLabelSizes[i], poin= tLabelPosition); - fillText(ctx, scale.pointLabels[i], pointLabelPosition, plFont.lineHeigh= t); - } - ctx.restore(); -} - -function drawRadiusLine(scale, gridLineOpts, radius, index) { - var ctx =3D scale.ctx; - var circular =3D gridLineOpts.circular; - var valueCount =3D scale.chart.data.labels.length; - var lineColor =3D valueAtIndexOrDefault$1(gridLineOpts.color, index - 1); - var lineWidth =3D valueAtIndexOrDefault$1(gridLineOpts.lineWidth, index -= 1); - var pointPosition; - - if ((!circular && !valueCount) || !lineColor || !lineWidth) { - return; - } - - ctx.save(); - ctx.strokeStyle =3D lineColor; - ctx.lineWidth =3D lineWidth; - if (ctx.setLineDash) { - ctx.setLineDash(gridLineOpts.borderDash || []); - ctx.lineDashOffset =3D gridLineOpts.borderDashOffset || 0.0; - } - - ctx.beginPath(); - if (circular) { - // Draw circular arcs between the points - ctx.arc(scale.xCenter, scale.yCenter, radius, 0, Math.PI * 2); - } else { - // Draw straight lines connecting each index - pointPosition =3D scale.getPointPosition(0, radius); - ctx.moveTo(pointPosition.x, pointPosition.y); - - for (var i =3D 1; i < valueCount; i++) { - pointPosition =3D scale.getPointPosition(i, radius); - ctx.lineTo(pointPosition.x, pointPosition.y); - } - } - ctx.closePath(); - ctx.stroke(); - ctx.restore(); -} - -function numberOrZero(param) { - return helpers$1.isNumber(param) ? param : 0; -} - -var scale_radialLinear =3D scale_linearbase.extend({ - setDimensions: function() { - var me =3D this; - - // Set the unconstrained dimension before label rotation - me.width =3D me.maxWidth; - me.height =3D me.maxHeight; - me.paddingTop =3D getTickBackdropHeight(me.options) / 2; - me.xCenter =3D Math.floor(me.width / 2); - me.yCenter =3D Math.floor((me.height - me.paddingTop) / 2); - me.drawingArea =3D Math.min(me.height - me.paddingTop, me.width) / 2; - }, - - determineDataLimits: function() { - var me =3D this; - var chart =3D me.chart; - var min =3D Number.POSITIVE_INFINITY; - var max =3D Number.NEGATIVE_INFINITY; - - helpers$1.each(chart.data.datasets, function(dataset, datasetIndex) { - if (chart.isDatasetVisible(datasetIndex)) { - var meta =3D chart.getDatasetMeta(datasetIndex); - - helpers$1.each(dataset.data, function(rawValue, index) { - var value =3D +me.getRightValue(rawValue); - if (isNaN(value) || meta.data[index].hidden) { - return; - } - - min =3D Math.min(value, min); - max =3D Math.max(value, max); - }); - } - }); - - me.min =3D (min =3D=3D=3D Number.POSITIVE_INFINITY ? 0 : min); - me.max =3D (max =3D=3D=3D Number.NEGATIVE_INFINITY ? 0 : max); - - // Common base implementation to handle ticks.min, ticks.max, ticks.begi= nAtZero - me.handleTickRangeOptions(); - }, - - // Returns the maximum number of ticks based on the scale dimension - _computeTickLimit: function() { - return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options)); - }, - - convertTicksToLabels: function() { - var me =3D this; - - scale_linearbase.prototype.convertTicksToLabels.call(me); - - // Point labels - me.pointLabels =3D me.chart.data.labels.map(function() { - var label =3D helpers$1.callback(me.options.pointLabels.callback, argum= ents, me); - return label || label =3D=3D=3D 0 ? label : ''; - }); - }, - - getLabelForIndex: function(index, datasetIndex) { - return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[i= ndex]); - }, - - fit: function() { - var me =3D this; - var opts =3D me.options; - - if (opts.display && opts.pointLabels.display) { - fitWithPointLabels(me); - } else { - me.setCenterPoint(0, 0, 0, 0); - } - }, - - /** - * Set radius reductions and determine new radius and center point - * @private - */ - setReductions: function(largestPossibleRadius, furthestLimits, furthestAn= gles) { - var me =3D this; - var radiusReductionLeft =3D furthestLimits.l / Math.sin(furthestAngles.l= ); - var radiusReductionRight =3D Math.max(furthestLimits.r - me.width, 0) / = Math.sin(furthestAngles.r); - var radiusReductionTop =3D -furthestLimits.t / Math.cos(furthestAngles.t= ); - var radiusReductionBottom =3D -Math.max(furthestLimits.b - (me.height - = me.paddingTop), 0) / Math.cos(furthestAngles.b); - - radiusReductionLeft =3D numberOrZero(radiusReductionLeft); - radiusReductionRight =3D numberOrZero(radiusReductionRight); - radiusReductionTop =3D numberOrZero(radiusReductionTop); - radiusReductionBottom =3D numberOrZero(radiusReductionBottom); - - me.drawingArea =3D Math.min( - Math.floor(largestPossibleRadius - (radiusReductionLeft + radiusReducti= onRight) / 2), - Math.floor(largestPossibleRadius - (radiusReductionTop + radiusReductio= nBottom) / 2)); - me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReduc= tionTop, radiusReductionBottom); - }, - - setCenterPoint: function(leftMovement, rightMovement, topMovement, bottom= Movement) { - var me =3D this; - var maxRight =3D me.width - rightMovement - me.drawingArea; - var maxLeft =3D leftMovement + me.drawingArea; - var maxTop =3D topMovement + me.drawingArea; - var maxBottom =3D (me.height - me.paddingTop) - bottomMovement - me.draw= ingArea; - - me.xCenter =3D Math.floor(((maxLeft + maxRight) / 2) + me.left); - me.yCenter =3D Math.floor(((maxTop + maxBottom) / 2) + me.top + me.paddi= ngTop); - }, - - getIndexAngle: function(index) { - var chart =3D this.chart; - var angleMultiplier =3D 360 / chart.data.labels.length; - var options =3D chart.options || {}; - var startAngle =3D options.startAngle || 0; - - // Start from the top instead of right, so remove a quarter of the circle - var angle =3D (index * angleMultiplier + startAngle) % 360; - - return (angle < 0 ? angle + 360 : angle) * Math.PI * 2 / 360; - }, - - getDistanceFromCenterForValue: function(value) { - var me =3D this; - - if (helpers$1.isNullOrUndef(value)) { - return NaN; - } - - // Take into account half font size + the yPadding of the top value - var scalingFactor =3D me.drawingArea / (me.max - me.min); - if (me.options.ticks.reverse) { - return (me.max - value) * scalingFactor; - } - return (value - me.min) * scalingFactor; - }, - - getPointPosition: function(index, distanceFromCenter) { - var me =3D this; - var thisAngle =3D me.getIndexAngle(index) - (Math.PI / 2); - return { - x: Math.cos(thisAngle) * distanceFromCenter + me.xCenter, - y: Math.sin(thisAngle) * distanceFromCenter + me.yCenter - }; - }, - - getPointPositionForValue: function(index, value) { - return this.getPointPosition(index, this.getDistanceFromCenterForValue(v= alue)); - }, - - getBasePosition: function(index) { - var me =3D this; - var min =3D me.min; - var max =3D me.max; - - return me.getPointPositionForValue(index || 0, - me.beginAtZero ? 0 : - min < 0 && max < 0 ? max : - min > 0 && max > 0 ? min : - 0); - }, - - /** - * @private - */ - _drawGrid: function() { - var me =3D this; - var ctx =3D me.ctx; - var opts =3D me.options; - var gridLineOpts =3D opts.gridLines; - var angleLineOpts =3D opts.angleLines; - var lineWidth =3D valueOrDefault$c(angleLineOpts.lineWidth, gridLineOpts= .lineWidth); - var lineColor =3D valueOrDefault$c(angleLineOpts.color, gridLineOpts.col= or); - var i, offset, position; - - if (opts.pointLabels.display) { - drawPointLabels(me); - } - - if (gridLineOpts.display) { - helpers$1.each(me.ticks, function(label, index) { - if (index !=3D=3D 0) { - offset =3D me.getDistanceFromCenterForValue(me.ticksAsNumbers[index]); - drawRadiusLine(me, gridLineOpts, offset, index); - } - }); - } - - if (angleLineOpts.display && lineWidth && lineColor) { - ctx.save(); - ctx.lineWidth =3D lineWidth; - ctx.strokeStyle =3D lineColor; - if (ctx.setLineDash) { - ctx.setLineDash(resolve$4([angleLineOpts.borderDash, gridLineOpts.bord= erDash, []])); - ctx.lineDashOffset =3D resolve$4([angleLineOpts.borderDashOffset, grid= LineOpts.borderDashOffset, 0.0]); - } - - for (i =3D me.chart.data.labels.length - 1; i >=3D 0; i--) { - offset =3D me.getDistanceFromCenterForValue(opts.ticks.reverse ? me.mi= n : me.max); - position =3D me.getPointPosition(i, offset); - ctx.beginPath(); - ctx.moveTo(me.xCenter, me.yCenter); - ctx.lineTo(position.x, position.y); - ctx.stroke(); - } - - ctx.restore(); - } - }, - - /** - * @private - */ - _drawLabels: function() { - var me =3D this; - var ctx =3D me.ctx; - var opts =3D me.options; - var tickOpts =3D opts.ticks; - - if (!tickOpts.display) { - return; - } - - var startAngle =3D me.getIndexAngle(0); - var tickFont =3D helpers$1.options._parseFont(tickOpts); - var tickFontColor =3D valueOrDefault$c(tickOpts.fontColor, core_defaults= .global.defaultFontColor); - var offset, width; - - ctx.save(); - ctx.font =3D tickFont.string; - ctx.translate(me.xCenter, me.yCenter); - ctx.rotate(startAngle); - ctx.textAlign =3D 'center'; - ctx.textBaseline =3D 'middle'; - - helpers$1.each(me.ticks, function(label, index) { - if (index =3D=3D=3D 0 && !tickOpts.reverse) { - return; - } - - offset =3D me.getDistanceFromCenterForValue(me.ticksAsNumbers[index]); - - if (tickOpts.showLabelBackdrop) { - width =3D ctx.measureText(label).width; - ctx.fillStyle =3D tickOpts.backdropColor; - - ctx.fillRect( - -width / 2 - tickOpts.backdropPaddingX, - -offset - tickFont.size / 2 - tickOpts.backdropPaddingY, - width + tickOpts.backdropPaddingX * 2, - tickFont.size + tickOpts.backdropPaddingY * 2 - ); - } - - ctx.fillStyle =3D tickFontColor; - ctx.fillText(label, 0, -offset); - }); - - ctx.restore(); - }, - - /** - * @private - */ - _drawTitle: helpers$1.noop -}); - -// INTERNAL: static default options, registered in src/index.js -var _defaults$3 =3D defaultConfig$3; -scale_radialLinear._defaults =3D _defaults$3; - -var deprecated$1 =3D helpers$1._deprecated; -var resolve$5 =3D helpers$1.options.resolve; -var valueOrDefault$d =3D helpers$1.valueOrDefault; - -// Integer constants are from the ES6 spec. -var MIN_INTEGER =3D Number.MIN_SAFE_INTEGER || -9007199254740991; -var MAX_INTEGER =3D Number.MAX_SAFE_INTEGER || 9007199254740991; - -var INTERVALS =3D { - millisecond: { - common: true, - size: 1, - steps: 1000 - }, - second: { - common: true, - size: 1000, - steps: 60 - }, - minute: { - common: true, - size: 60000, - steps: 60 - }, - hour: { - common: true, - size: 3600000, - steps: 24 - }, - day: { - common: true, - size: 86400000, - steps: 30 - }, - week: { - common: false, - size: 604800000, - steps: 4 - }, - month: { - common: true, - size: 2.628e9, - steps: 12 - }, - quarter: { - common: false, - size: 7.884e9, - steps: 4 - }, - year: { - common: true, - size: 3.154e10 - } -}; - -var UNITS =3D Object.keys(INTERVALS); - -function sorter(a, b) { - return a - b; -} - -function arrayUnique(items) { - var hash =3D {}; - var out =3D []; - var i, ilen, item; - - for (i =3D 0, ilen =3D items.length; i < ilen; ++i) { - item =3D items[i]; - if (!hash[item]) { - hash[item] =3D true; - out.push(item); - } - } - - return out; -} - -function getMin(options) { - return helpers$1.valueOrDefault(options.time.min, options.ticks.min); -} - -function getMax(options) { - return helpers$1.valueOrDefault(options.time.max, options.ticks.max); -} - -/** - * Returns an array of {time, pos} objects used to interpolate a specific = `time` or position - * (`pos`) on the scale, by searching entries before and after the request= ed value. `pos` is - * a decimal between 0 and 1: 0 being the start of the scale (left or top)= and 1 the other - * extremity (left + width or top + height). Note that it would be more op= timized to directly - * store pre-computed pixels, but the scale dimensions are not guaranteed = at the time we need - * to create the lookup table. The table ALWAYS contains at least two item= s: min and max. - * - * @param {number[]} timestamps - timestamps sorted from lowest to highest. - * @param {string} distribution - If 'linear', timestamps will be spread l= inearly along the min - * and max range, so basically, the table will contains only two items: {m= in, 0} and {max, 1}. - * If 'series', timestamps will be positioned at the same distance from ea= ch other. In this - * case, only timestamps that break the time linearity are registered, mea= ning that in the - * best case, all timestamps are linear, the table contains only min and m= ax. - */ -function buildLookupTable(timestamps, min, max, distribution) { - if (distribution =3D=3D=3D 'linear' || !timestamps.length) { - return [ - {time: min, pos: 0}, - {time: max, pos: 1} - ]; - } - - var table =3D []; - var items =3D [min]; - var i, ilen, prev, curr, next; - - for (i =3D 0, ilen =3D timestamps.length; i < ilen; ++i) { - curr =3D timestamps[i]; - if (curr > min && curr < max) { - items.push(curr); - } - } - - items.push(max); - - for (i =3D 0, ilen =3D items.length; i < ilen; ++i) { - next =3D items[i + 1]; - prev =3D items[i - 1]; - curr =3D items[i]; - - // only add points that breaks the scale linearity - if (prev =3D=3D=3D undefined || next =3D=3D=3D undefined || Math.round((= next + prev) / 2) !=3D=3D curr) { - table.push({time: curr, pos: i / (ilen - 1)}); - } - } - - return table; -} - -// @see adapted from https://www.anujgakhar.com/2014/03/01/binary-search-i= n-javascript/ -function lookup(table, key, value) { - var lo =3D 0; - var hi =3D table.length - 1; - var mid, i0, i1; - - while (lo >=3D 0 && lo <=3D hi) { - mid =3D (lo + hi) >> 1; - i0 =3D table[mid - 1] || null; - i1 =3D table[mid]; - - if (!i0) { - // given value is outside table (before first item) - return {lo: null, hi: i1}; - } else if (i1[key] < value) { - lo =3D mid + 1; - } else if (i0[key] > value) { - hi =3D mid - 1; - } else { - return {lo: i0, hi: i1}; - } - } - - // given value is outside table (after last item) - return {lo: i1, hi: null}; -} - -/** - * Linearly interpolates the given source `value` using the table items `s= key` values and - * returns the associated `tkey` value. For example, interpolate(table, 't= ime', 42, 'pos') - * returns the position for a timestamp equal to 42. If value is out of bo= unds, values at - * index [0, 1] or [n - 1, n] are used for the interpolation. - */ -function interpolate$1(table, skey, sval, tkey) { - var range =3D lookup(table, skey, sval); - - // Note: the lookup table ALWAYS contains at least 2 items (min and max) - var prev =3D !range.lo ? table[0] : !range.hi ? table[table.length - 2] := range.lo; - var next =3D !range.lo ? table[1] : !range.hi ? table[table.length - 1] := range.hi; - - var span =3D next[skey] - prev[skey]; - var ratio =3D span ? (sval - prev[skey]) / span : 0; - var offset =3D (next[tkey] - prev[tkey]) * ratio; - - return prev[tkey] + offset; -} - -function toTimestamp(scale, input) { - var adapter =3D scale._adapter; - var options =3D scale.options.time; - var parser =3D options.parser; - var format =3D parser || options.format; - var value =3D input; - - if (typeof parser =3D=3D=3D 'function') { - value =3D parser(value); - } - - // Only parse if its not a timestamp already - if (!helpers$1.isFinite(value)) { - value =3D typeof format =3D=3D=3D 'string' - ? adapter.parse(value, format) - : adapter.parse(value); - } - - if (value !=3D=3D null) { - return +value; - } - - // Labels are in an incompatible format and no `parser` has been provided. - // The user might still use the deprecated `format` option for parsing. - if (!parser && typeof format =3D=3D=3D 'function') { - value =3D format(input); - - // `format` could return something else than a timestamp, if so, parse it - if (!helpers$1.isFinite(value)) { - value =3D adapter.parse(value); - } - } - - return value; -} - -function parse(scale, input) { - if (helpers$1.isNullOrUndef(input)) { - return null; - } - - var options =3D scale.options.time; - var value =3D toTimestamp(scale, scale.getRightValue(input)); - if (value =3D=3D=3D null) { - return value; - } - - if (options.round) { - value =3D +scale._adapter.startOf(value, options.round); - } - - return value; -} - -/** - * Figures out what unit results in an appropriate number of auto-generate= d ticks - */ -function determineUnitForAutoTicks(minUnit, min, max, capacity) { - var ilen =3D UNITS.length; - var i, interval, factor; - - for (i =3D UNITS.indexOf(minUnit); i < ilen - 1; ++i) { - interval =3D INTERVALS[UNITS[i]]; - factor =3D interval.steps ? interval.steps : MAX_INTEGER; - - if (interval.common && Math.ceil((max - min) / (factor * interval.size))= <=3D capacity) { - return UNITS[i]; - } - } - - return UNITS[ilen - 1]; -} - -/** - * Figures out what unit to format a set of ticks with - */ -function determineUnitForFormatting(scale, numTicks, minUnit, min, max) { - var i, unit; - - for (i =3D UNITS.length - 1; i >=3D UNITS.indexOf(minUnit); i--) { - unit =3D UNITS[i]; - if (INTERVALS[unit].common && scale._adapter.diff(max, min, unit) >=3D n= umTicks - 1) { - return unit; - } - } - - return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0]; -} - -function determineMajorUnit(unit) { - for (var i =3D UNITS.indexOf(unit) + 1, ilen =3D UNITS.length; i < ilen; = ++i) { - if (INTERVALS[UNITS[i]].common) { - return UNITS[i]; - } - } -} - -/** - * Generates a maximum of `capacity` timestamps between min and max, round= ed to the - * `minor` unit using the given scale time `options`. - * Important: this method can return ticks outside the min and max range, = it's the - * responsibility of the calling code to clamp values if needed. - */ -function generate(scale, min, max, capacity) { - var adapter =3D scale._adapter; - var options =3D scale.options; - var timeOpts =3D options.time; - var minor =3D timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit= , min, max, capacity); - var stepSize =3D resolve$5([timeOpts.stepSize, timeOpts.unitStepSize, 1]); - var weekday =3D minor =3D=3D=3D 'week' ? timeOpts.isoWeekday : false; - var first =3D min; - var ticks =3D []; - var time; - - // For 'week' unit, handle the first day of week option - if (weekday) { - first =3D +adapter.startOf(first, 'isoWeek', weekday); - } - - // Align first ticks on unit - first =3D +adapter.startOf(first, weekday ? 'day' : minor); - - // Prevent browser from freezing in case user options request millions of= milliseconds - if (adapter.diff(max, min, minor) > 100000 * stepSize) { - throw min + ' and ' + max + ' are too far apart with stepSize of ' + ste= pSize + ' ' + minor; - } - - for (time =3D first; time < max; time =3D +adapter.add(time, stepSize, mi= nor)) { - ticks.push(time); - } - - if (time =3D=3D=3D max || options.bounds =3D=3D=3D 'ticks') { - ticks.push(time); - } - - return ticks; -} - -/** - * Returns the start and end offsets from edges in the form of {start, end} - * where each value is a relative width to the scale and ranges between 0 = and 1. - * They add extra margins on the both sides by scaling down the original s= cale. - * Offsets are added when the `offset` option is true. - */ -function computeOffsets(table, ticks, min, max, options) { - var start =3D 0; - var end =3D 0; - var first, last; - - if (options.offset && ticks.length) { - first =3D interpolate$1(table, 'time', ticks[0], 'pos'); - if (ticks.length =3D=3D=3D 1) { - start =3D 1 - first; - } else { - start =3D (interpolate$1(table, 'time', ticks[1], 'pos') - first) / 2; - } - last =3D interpolate$1(table, 'time', ticks[ticks.length - 1], 'pos'); - if (ticks.length =3D=3D=3D 1) { - end =3D last; - } else { - end =3D (last - interpolate$1(table, 'time', ticks[ticks.length - 2], '= pos')) / 2; - } - } - - return {start: start, end: end, factor: 1 / (start + 1 + end)}; -} - -function setMajorTicks(scale, ticks, map, majorUnit) { - var adapter =3D scale._adapter; - var first =3D +adapter.startOf(ticks[0].value, majorUnit); - var last =3D ticks[ticks.length - 1].value; - var major, index; - - for (major =3D first; major <=3D last; major =3D +adapter.add(major, 1, m= ajorUnit)) { - index =3D map[major]; - if (index >=3D 0) { - ticks[index].major =3D true; - } - } - return ticks; -} - -function ticksFromTimestamps(scale, values, majorUnit) { - var ticks =3D []; - var map =3D {}; - var ilen =3D values.length; - var i, value; - - for (i =3D 0; i < ilen; ++i) { - value =3D values[i]; - map[value] =3D i; - - ticks.push({ - value: value, - major: false - }); - } - - // We set the major ticks separately from the above loop because calling = startOf for every tick - // is expensive when there is a large number of ticks - return (ilen =3D=3D=3D 0 || !majorUnit) ? ticks : setMajorTicks(scale, ti= cks, map, majorUnit); -} - -var defaultConfig$4 =3D { - position: 'bottom', - - /** - * Data distribution along the scale: - * - 'linear': data are spread according to their time (distances can var= y), - * - 'series': data are spread at the same distance from each other. - * @see https://github.com/chartjs/Chart.js/pull/4507 - * @since 2.7.0 - */ - distribution: 'linear', - - /** - * Scale boundary strategy (bypassed by min/max time options) - * - `data`: make sure data are fully visible, ticks outside are removed - * - `ticks`: make sure ticks are fully visible, data outside are truncat= ed - * @see https://github.com/chartjs/Chart.js/pull/4556 - * @since 2.7.0 - */ - bounds: 'data', - - adapters: {}, - time: { - parser: false, // false =3D=3D a pattern string from https://momentjs.co= m/docs/#/parsing/string-format/ or a custom callback that converts its argu= ment to a moment - unit: false, // false =3D=3D automatic or override with week, month, yea= r, etc. - round: false, // none, or override with week, month, year, etc. - displayFormat: false, // DEPRECATED - isoWeekday: false, // override week start day - see https://momentjs.com= /docs/#/get-set/iso-weekday/ - minUnit: 'millisecond', - displayFormats: {} - }, - ticks: { - autoSkip: false, - - /** - * Ticks generation input values: - * - 'auto': generates "optimal" ticks based on scale size and time opti= ons. - * - 'data': generates ticks from data (including labels from data {t|x|= y} objects). - * - 'labels': generates ticks from user given `data.labels` values ONLY. - * @see https://github.com/chartjs/Chart.js/pull/4507 - * @since 2.7.0 - */ - source: 'auto', - - major: { - enabled: false - } - } -}; - -var scale_time =3D core_scale.extend({ - initialize: function() { - this.mergeTicksOptions(); - core_scale.prototype.initialize.call(this); - }, - - update: function() { - var me =3D this; - var options =3D me.options; - var time =3D options.time || (options.time =3D {}); - var adapter =3D me._adapter =3D new core_adapters._date(options.adapters= .date); - - // DEPRECATIONS: output a message only one time per update - deprecated$1('time scale', time.format, 'time.format', 'time.parser'); - deprecated$1('time scale', time.min, 'time.min', 'ticks.min'); - deprecated$1('time scale', time.max, 'time.max', 'ticks.max'); - - // Backward compatibility: before introducing adapter, `displayFormats` = was - // supposed to contain *all* unit/string pairs but this can't be resolved - // when loading the scale (adapters are loaded afterward), so let's popu= late - // missing formats on update - helpers$1.mergeIf(time.displayFormats, adapter.formats()); - - return core_scale.prototype.update.apply(me, arguments); - }, - - /** - * Allows data to be referenced via 't' attribute - */ - getRightValue: function(rawValue) { - if (rawValue && rawValue.t !=3D=3D undefined) { - rawValue =3D rawValue.t; - } - return core_scale.prototype.getRightValue.call(this, rawValue); - }, - - determineDataLimits: function() { - var me =3D this; - var chart =3D me.chart; - var adapter =3D me._adapter; - var options =3D me.options; - var unit =3D options.time.unit || 'day'; - var min =3D MAX_INTEGER; - var max =3D MIN_INTEGER; - var timestamps =3D []; - var datasets =3D []; - var labels =3D []; - var i, j, ilen, jlen, data, timestamp, labelsAdded; - var dataLabels =3D me._getLabels(); - - for (i =3D 0, ilen =3D dataLabels.length; i < ilen; ++i) { - labels.push(parse(me, dataLabels[i])); - } - - for (i =3D 0, ilen =3D (chart.data.datasets || []).length; i < ilen; ++i= ) { - if (chart.isDatasetVisible(i)) { - data =3D chart.data.datasets[i].data; - - // Let's consider that all data have the same format. - if (helpers$1.isObject(data[0])) { - datasets[i] =3D []; - - for (j =3D 0, jlen =3D data.length; j < jlen; ++j) { - timestamp =3D parse(me, data[j]); - timestamps.push(timestamp); - datasets[i][j] =3D timestamp; - } - } else { - datasets[i] =3D labels.slice(0); - if (!labelsAdded) { - timestamps =3D timestamps.concat(labels); - labelsAdded =3D true; - } - } - } else { - datasets[i] =3D []; - } - } - - if (labels.length) { - min =3D Math.min(min, labels[0]); - max =3D Math.max(max, labels[labels.length - 1]); - } - - if (timestamps.length) { - timestamps =3D ilen > 1 ? arrayUnique(timestamps).sort(sorter) : timest= amps.sort(sorter); - min =3D Math.min(min, timestamps[0]); - max =3D Math.max(max, timestamps[timestamps.length - 1]); - } - - min =3D parse(me, getMin(options)) || min; - max =3D parse(me, getMax(options)) || max; - - // In case there is no valid min/max, set limits based on unit time opti= on - min =3D min =3D=3D=3D MAX_INTEGER ? +adapter.startOf(Date.now(), unit) := min; - max =3D max =3D=3D=3D MIN_INTEGER ? +adapter.endOf(Date.now(), unit) + 1= : max; - - // Make sure that max is strictly higher than min (required by the looku= p table) - me.min =3D Math.min(min, max); - me.max =3D Math.max(min + 1, max); - - // PRIVATE - me._table =3D []; - me._timestamps =3D { - data: timestamps, - datasets: datasets, - labels: labels - }; - }, - - buildTicks: function() { - var me =3D this; - var min =3D me.min; - var max =3D me.max; - var options =3D me.options; - var tickOpts =3D options.ticks; - var timeOpts =3D options.time; - var timestamps =3D me._timestamps; - var ticks =3D []; - var capacity =3D me.getLabelCapacity(min); - var source =3D tickOpts.source; - var distribution =3D options.distribution; - var i, ilen, timestamp; - - if (source =3D=3D=3D 'data' || (source =3D=3D=3D 'auto' && distribution = =3D=3D=3D 'series')) { - timestamps =3D timestamps.data; - } else if (source =3D=3D=3D 'labels') { - timestamps =3D timestamps.labels; - } else { - timestamps =3D generate(me, min, max, capacity); - } - - if (options.bounds =3D=3D=3D 'ticks' && timestamps.length) { - min =3D timestamps[0]; - max =3D timestamps[timestamps.length - 1]; - } - - // Enforce limits with user min/max options - min =3D parse(me, getMin(options)) || min; - max =3D parse(me, getMax(options)) || max; - - // Remove ticks outside the min/max range - for (i =3D 0, ilen =3D timestamps.length; i < ilen; ++i) { - timestamp =3D timestamps[i]; - if (timestamp >=3D min && timestamp <=3D max) { - ticks.push(timestamp); - } - } - - me.min =3D min; - me.max =3D max; - - // PRIVATE - // determineUnitForFormatting relies on the number of ticks so we don't = use it when - // autoSkip is enabled because we don't yet know what the final number o= f ticks will be - me._unit =3D timeOpts.unit || (tickOpts.autoSkip - ? determineUnitForAutoTicks(timeOpts.minUnit, me.min, me.max, capacity) - : determineUnitForFormatting(me, ticks.length, timeOpts.minUnit, me.min= , me.max)); - me._majorUnit =3D !tickOpts.major.enabled || me._unit =3D=3D=3D 'year' ?= undefined - : determineMajorUnit(me._unit); - me._table =3D buildLookupTable(me._timestamps.data, min, max, distributi= on); - me._offsets =3D computeOffsets(me._table, ticks, min, max, options); - - if (tickOpts.reverse) { - ticks.reverse(); - } - - return ticksFromTimestamps(me, ticks, me._majorUnit); - }, - - getLabelForIndex: function(index, datasetIndex) { - var me =3D this; - var adapter =3D me._adapter; - var data =3D me.chart.data; - var timeOpts =3D me.options.time; - var label =3D data.labels && index < data.labels.length ? data.labels[in= dex] : ''; - var value =3D data.datasets[datasetIndex].data[index]; - - if (helpers$1.isObject(value)) { - label =3D me.getRightValue(value); - } - if (timeOpts.tooltipFormat) { - return adapter.format(toTimestamp(me, label), timeOpts.tooltipFormat); - } - if (typeof label =3D=3D=3D 'string') { - return label; - } - return adapter.format(toTimestamp(me, label), timeOpts.displayFormats.da= tetime); - }, - - /** - * Function to format an individual tick mark - * @private - */ - tickFormatFunction: function(time, index, ticks, format) { - var me =3D this; - var adapter =3D me._adapter; - var options =3D me.options; - var formats =3D options.time.displayFormats; - var minorFormat =3D formats[me._unit]; - var majorUnit =3D me._majorUnit; - var majorFormat =3D formats[majorUnit]; - var tick =3D ticks[index]; - var tickOpts =3D options.ticks; - var major =3D majorUnit && majorFormat && tick && tick.major; - var label =3D adapter.format(time, format ? format : major ? majorFormat= : minorFormat); - var nestedTickOpts =3D major ? tickOpts.major : tickOpts.minor; - var formatter =3D resolve$5([ - nestedTickOpts.callback, - nestedTickOpts.userCallback, - tickOpts.callback, - tickOpts.userCallback - ]); - - return formatter ? formatter(label, index, ticks) : label; - }, - - convertTicksToLabels: function(ticks) { - var labels =3D []; - var i, ilen; - - for (i =3D 0, ilen =3D ticks.length; i < ilen; ++i) { - labels.push(this.tickFormatFunction(ticks[i].value, i, ticks)); - } - - return labels; - }, - - /** - * @private - */ - getPixelForOffset: function(time) { - var me =3D this; - var offsets =3D me._offsets; - var pos =3D interpolate$1(me._table, 'time', time, 'pos'); - return me.getPixelForDecimal((offsets.start + pos) * offsets.factor); - }, - - getPixelForValue: function(value, index, datasetIndex) { - var me =3D this; - var time =3D null; - - if (index !=3D=3D undefined && datasetIndex !=3D=3D undefined) { - time =3D me._timestamps.datasets[datasetIndex][index]; - } - - if (time =3D=3D=3D null) { - time =3D parse(me, value); - } - - if (time !=3D=3D null) { - return me.getPixelForOffset(time); - } - }, - - getPixelForTick: function(index) { - var ticks =3D this.getTicks(); - return index >=3D 0 && index < ticks.length ? - this.getPixelForOffset(ticks[index].value) : - null; - }, - - getValueForPixel: function(pixel) { - var me =3D this; - var offsets =3D me._offsets; - var pos =3D me.getDecimalForPixel(pixel) / offsets.factor - offsets.end; - var time =3D interpolate$1(me._table, 'pos', pos, 'time'); - - // DEPRECATION, we should return time directly - return me._adapter._create(time); - }, - - /** - * @private - */ - _getLabelSize: function(label) { - var me =3D this; - var ticksOpts =3D me.options.ticks; - var tickLabelWidth =3D me.ctx.measureText(label).width; - var angle =3D helpers$1.toRadians(me.isHorizontal() ? ticksOpts.maxRotat= ion : ticksOpts.minRotation); - var cosRotation =3D Math.cos(angle); - var sinRotation =3D Math.sin(angle); - var tickFontSize =3D valueOrDefault$d(ticksOpts.fontSize, core_defaults.= global.defaultFontSize); - - return { - w: (tickLabelWidth * cosRotation) + (tickFontSize * sinRotation), - h: (tickLabelWidth * sinRotation) + (tickFontSize * cosRotation) - }; - }, - - /** - * Crude approximation of what the label width might be - * @private - */ - getLabelWidth: function(label) { - return this._getLabelSize(label).w; - }, - - /** - * @private - */ - getLabelCapacity: function(exampleTime) { - var me =3D this; - var timeOpts =3D me.options.time; - var displayFormats =3D timeOpts.displayFormats; - - // pick the longest format (milliseconds) for guestimation - var format =3D displayFormats[timeOpts.unit] || displayFormats.milliseco= nd; - var exampleLabel =3D me.tickFormatFunction(exampleTime, 0, ticksFromTime= stamps(me, [exampleTime], me._majorUnit), format); - var size =3D me._getLabelSize(exampleLabel); - var capacity =3D Math.floor(me.isHorizontal() ? me.width / size.w : me.h= eight / size.h); - - if (me.options.offset) { - capacity--; - } - - return capacity > 0 ? capacity : 1; - } -}); - -// INTERNAL: static default options, registered in src/index.js -var _defaults$4 =3D defaultConfig$4; -scale_time._defaults =3D _defaults$4; - -var scales =3D { - category: scale_category, - linear: scale_linear, - logarithmic: scale_logarithmic, - radialLinear: scale_radialLinear, - time: scale_time -}; - -var FORMATS =3D { - datetime: 'MMM D, YYYY, h:mm:ss a', - millisecond: 'h:mm:ss.SSS a', - second: 'h:mm:ss a', - minute: 'h:mm a', - hour: 'hA', - day: 'MMM D', - week: 'll', - month: 'MMM YYYY', - quarter: '[Q]Q - YYYY', - year: 'YYYY' -}; - -core_adapters._date.override(typeof moment =3D=3D=3D 'function' ? { - _id: 'moment', // DEBUG ONLY - - formats: function() { - return FORMATS; - }, - - parse: function(value, format) { - if (typeof value =3D=3D=3D 'string' && typeof format =3D=3D=3D 'string')= { - value =3D moment(value, format); - } else if (!(value instanceof moment)) { - value =3D moment(value); - } - return value.isValid() ? value.valueOf() : null; - }, - - format: function(time, format) { - return moment(time).format(format); - }, - - add: function(time, amount, unit) { - return moment(time).add(amount, unit).valueOf(); - }, - - diff: function(max, min, unit) { - return moment(max).diff(moment(min), unit); - }, - - startOf: function(time, unit, weekday) { - time =3D moment(time); - if (unit =3D=3D=3D 'isoWeek') { - return time.isoWeekday(weekday).valueOf(); - } - return time.startOf(unit).valueOf(); - }, - - endOf: function(time, unit) { - return moment(time).endOf(unit).valueOf(); - }, - - // DEPRECATIONS - - /** - * Provided for backward compatibility with scale.getValueForPixel(). - * @deprecated since version 2.8.0 - * @todo remove at version 3 - * @private - */ - _create: function(time) { - return moment(time); - }, -} : {}); - -core_defaults._set('global', { - plugins: { - filler: { - propagate: true - } - } -}); - -var mappers =3D { - dataset: function(source) { - var index =3D source.fill; - var chart =3D source.chart; - var meta =3D chart.getDatasetMeta(index); - var visible =3D meta && chart.isDatasetVisible(index); - var points =3D (visible && meta.dataset._children) || []; - var length =3D points.length || 0; - - return !length ? null : function(point, i) { - return (i < length && points[i]._view) || null; - }; - }, - - boundary: function(source) { - var boundary =3D source.boundary; - var x =3D boundary ? boundary.x : null; - var y =3D boundary ? boundary.y : null; - - if (helpers$1.isArray(boundary)) { - return function(point, i) { - return boundary[i]; - }; - } - - return function(point) { - return { - x: x =3D=3D=3D null ? point.x : x, - y: y =3D=3D=3D null ? point.y : y, - }; - }; - } -}; - -// @todo if (fill[0] =3D=3D=3D '#') -function decodeFill(el, index, count) { - var model =3D el._model || {}; - var fill =3D model.fill; - var target; - - if (fill =3D=3D=3D undefined) { - fill =3D !!model.backgroundColor; - } - - if (fill =3D=3D=3D false || fill =3D=3D=3D null) { - return false; - } - - if (fill =3D=3D=3D true) { - return 'origin'; - } - - target =3D parseFloat(fill, 10); - if (isFinite(target) && Math.floor(target) =3D=3D=3D target) { - if (fill[0] =3D=3D=3D '-' || fill[0] =3D=3D=3D '+') { - target =3D index + target; - } - - if (target =3D=3D=3D index || target < 0 || target >=3D count) { - return false; - } - - return target; - } - - switch (fill) { - // compatibility - case 'bottom': - return 'start'; - case 'top': - return 'end'; - case 'zero': - return 'origin'; - // supported boundaries - case 'origin': - case 'start': - case 'end': - return fill; - // invalid fill values - default: - return false; - } -} - -function computeLinearBoundary(source) { - var model =3D source.el._model || {}; - var scale =3D source.el._scale || {}; - var fill =3D source.fill; - var target =3D null; - var horizontal; - - if (isFinite(fill)) { - return null; - } - - // Backward compatibility: until v3, we still need to support boundary va= lues set on - // the model (scaleTop, scaleBottom and scaleZero) because some external = plugins and - // controllers might still use it (e.g. the Smith chart). - - if (fill =3D=3D=3D 'start') { - target =3D model.scaleBottom =3D=3D=3D undefined ? scale.bottom : model.= scaleBottom; - } else if (fill =3D=3D=3D 'end') { - target =3D model.scaleTop =3D=3D=3D undefined ? scale.top : model.scaleT= op; - } else if (model.scaleZero !=3D=3D undefined) { - target =3D model.scaleZero; - } else if (scale.getBasePixel) { - target =3D scale.getBasePixel(); - } - - if (target !=3D=3D undefined && target !=3D=3D null) { - if (target.x !=3D=3D undefined && target.y !=3D=3D undefined) { - return target; - } - - if (helpers$1.isFinite(target)) { - horizontal =3D scale.isHorizontal(); - return { - x: horizontal ? target : null, - y: horizontal ? null : target - }; - } - } - - return null; -} - -function computeCircularBoundary(source) { - var scale =3D source.el._scale; - var options =3D scale.options; - var length =3D scale.chart.data.labels.length; - var fill =3D source.fill; - var target =3D []; - var start, end, center, i, point; - - if (!length) { - return null; - } - - start =3D options.ticks.reverse ? scale.max : scale.min; - end =3D options.ticks.reverse ? scale.min : scale.max; - center =3D scale.getPointPositionForValue(0, start); - for (i =3D 0; i < length; ++i) { - point =3D fill =3D=3D=3D 'start' || fill =3D=3D=3D 'end' - ? scale.getPointPositionForValue(i, fill =3D=3D=3D 'start' ? start : en= d) - : scale.getBasePosition(i); - if (options.gridLines.circular) { - point.cx =3D center.x; - point.cy =3D center.y; - point.angle =3D scale.getIndexAngle(i) - Math.PI / 2; - } - target.push(point); - } - return target; -} - -function computeBoundary(source) { - var scale =3D source.el._scale || {}; - - if (scale.getPointPositionForValue) { - return computeCircularBoundary(source); - } - return computeLinearBoundary(source); -} - -function resolveTarget(sources, index, propagate) { - var source =3D sources[index]; - var fill =3D source.fill; - var visited =3D [index]; - var target; - - if (!propagate) { - return fill; - } - - while (fill !=3D=3D false && visited.indexOf(fill) =3D=3D=3D -1) { - if (!isFinite(fill)) { - return fill; - } - - target =3D sources[fill]; - if (!target) { - return false; - } - - if (target.visible) { - return fill; - } - - visited.push(fill); - fill =3D target.fill; - } - - return false; -} - -function createMapper(source) { - var fill =3D source.fill; - var type =3D 'dataset'; - - if (fill =3D=3D=3D false) { - return null; - } - - if (!isFinite(fill)) { - type =3D 'boundary'; - } - - return mappers[type](source); -} - -function isDrawable(point) { - return point && !point.skip; -} - -function drawArea(ctx, curve0, curve1, len0, len1) { - var i, cx, cy, r; - - if (!len0 || !len1) { - return; - } - - // building first area curve (normal) - ctx.moveTo(curve0[0].x, curve0[0].y); - for (i =3D 1; i < len0; ++i) { - helpers$1.canvas.lineTo(ctx, curve0[i - 1], curve0[i]); - } - - if (curve1[0].angle !=3D=3D undefined) { - cx =3D curve1[0].cx; - cy =3D curve1[0].cy; - r =3D Math.sqrt(Math.pow(curve1[0].x - cx, 2) + Math.pow(curve1[0].y - c= y, 2)); - for (i =3D len1 - 1; i > 0; --i) { - ctx.arc(cx, cy, r, curve1[i].angle, curve1[i - 1].angle, true); - } - return; - } - - // joining the two area curves - ctx.lineTo(curve1[len1 - 1].x, curve1[len1 - 1].y); - - // building opposite area curve (reverse) - for (i =3D len1 - 1; i > 0; --i) { - helpers$1.canvas.lineTo(ctx, curve1[i], curve1[i - 1], true); - } -} - -function doFill(ctx, points, mapper, view, color, loop) { - var count =3D points.length; - var span =3D view.spanGaps; - var curve0 =3D []; - var curve1 =3D []; - var len0 =3D 0; - var len1 =3D 0; - var i, ilen, index, p0, p1, d0, d1, loopOffset; - - ctx.beginPath(); - - for (i =3D 0, ilen =3D count; i < ilen; ++i) { - index =3D i % count; - p0 =3D points[index]._view; - p1 =3D mapper(p0, index, view); - d0 =3D isDrawable(p0); - d1 =3D isDrawable(p1); - - if (loop && loopOffset =3D=3D=3D undefined && d0) { - loopOffset =3D i + 1; - ilen =3D count + loopOffset; - } - - if (d0 && d1) { - len0 =3D curve0.push(p0); - len1 =3D curve1.push(p1); - } else if (len0 && len1) { - if (!span) { - drawArea(ctx, curve0, curve1, len0, len1); - len0 =3D len1 =3D 0; - curve0 =3D []; - curve1 =3D []; - } else { - if (d0) { - curve0.push(p0); - } - if (d1) { - curve1.push(p1); - } - } - } - } - - drawArea(ctx, curve0, curve1, len0, len1); - - ctx.closePath(); - ctx.fillStyle =3D color; - ctx.fill(); -} - -var plugin_filler =3D { - id: 'filler', - - afterDatasetsUpdate: function(chart, options) { - var count =3D (chart.data.datasets || []).length; - var propagate =3D options.propagate; - var sources =3D []; - var meta, i, el, source; - - for (i =3D 0; i < count; ++i) { - meta =3D chart.getDatasetMeta(i); - el =3D meta.dataset; - source =3D null; - - if (el && el._model && el instanceof elements.Line) { - source =3D { - visible: chart.isDatasetVisible(i), - fill: decodeFill(el, i, count), - chart: chart, - el: el - }; - } - - meta.$filler =3D source; - sources.push(source); - } - - for (i =3D 0; i < count; ++i) { - source =3D sources[i]; - if (!source) { - continue; - } - - source.fill =3D resolveTarget(sources, i, propagate); - source.boundary =3D computeBoundary(source); - source.mapper =3D createMapper(source); - } - }, - - beforeDatasetsDraw: function(chart) { - var metasets =3D chart._getSortedVisibleDatasetMetas(); - var ctx =3D chart.ctx; - var meta, i, el, view, points, mapper, color; - - for (i =3D metasets.length - 1; i >=3D 0; --i) { - meta =3D metasets[i].$filler; - - if (!meta || !meta.visible) { - continue; - } - - el =3D meta.el; - view =3D el._view; - points =3D el._children || []; - mapper =3D meta.mapper; - color =3D view.backgroundColor || core_defaults.global.defaultColor; - - if (mapper && color && points.length) { - helpers$1.canvas.clipArea(ctx, chart.chartArea); - doFill(ctx, points, mapper, view, color, el._loop); - helpers$1.canvas.unclipArea(ctx); - } - } - } -}; - -var getRtlHelper$1 =3D helpers$1.rtl.getRtlAdapter; -var noop$1 =3D helpers$1.noop; -var valueOrDefault$e =3D helpers$1.valueOrDefault; - -core_defaults._set('global', { - legend: { - display: true, - position: 'top', - align: 'center', - fullWidth: true, - reverse: false, - weight: 1000, - - // a callback that will handle - onClick: function(e, legendItem) { - var index =3D legendItem.datasetIndex; - var ci =3D this.chart; - var meta =3D ci.getDatasetMeta(index); - - // See controller.isDatasetVisible comment - meta.hidden =3D meta.hidden =3D=3D=3D null ? !ci.data.datasets[index].h= idden : null; - - // We hid a dataset ... rerender the chart - ci.update(); - }, - - onHover: null, - onLeave: null, - - labels: { - boxWidth: 40, - padding: 10, - // Generates labels shown in the legend - // Valid properties to return: - // text : text to display - // fillStyle : fill of coloured box - // strokeStyle: stroke of coloured box - // hidden : if this legend item refers to a hidden item - // lineCap : cap style for line - // lineDash - // lineDashOffset : - // lineJoin : - // lineWidth : - generateLabels: function(chart) { - var datasets =3D chart.data.datasets; - var options =3D chart.options.legend || {}; - var usePointStyle =3D options.labels && options.labels.usePointStyle; - - return chart._getSortedDatasetMetas().map(function(meta) { - var style =3D meta.controller.getStyle(usePointStyle ? 0 : undefined); - - return { - text: datasets[meta.index].label, - fillStyle: style.backgroundColor, - hidden: !chart.isDatasetVisible(meta.index), - lineCap: style.borderCapStyle, - lineDash: style.borderDash, - lineDashOffset: style.borderDashOffset, - lineJoin: style.borderJoinStyle, - lineWidth: style.borderWidth, - strokeStyle: style.borderColor, - pointStyle: style.pointStyle, - rotation: style.rotation, - - // Below is extra data used for toggling the datasets - datasetIndex: meta.index - }; - }, this); - } - } - }, - - legendCallback: function(chart) { - var list =3D document.createElement('ul'); - var datasets =3D chart.data.datasets; - var i, ilen, listItem, listItemSpan; - - list.setAttribute('class', chart.id + '-legend'); - - for (i =3D 0, ilen =3D datasets.length; i < ilen; i++) { - listItem =3D list.appendChild(document.createElement('li')); - listItemSpan =3D listItem.appendChild(document.createElement('span')); - listItemSpan.style.backgroundColor =3D datasets[i].backgroundColor; - if (datasets[i].label) { - listItem.appendChild(document.createTextNode(datasets[i].label)); - } - } - - return list.outerHTML; - } -}); - -/** - * Helper function to get the box width based on the usePointStyle option - * @param {object} labelopts - the label options on the legend - * @param {number} fontSize - the label font size - * @return {number} width of the color box area - */ -function getBoxWidth(labelOpts, fontSize) { - return labelOpts.usePointStyle && labelOpts.boxWidth > fontSize ? - fontSize : - labelOpts.boxWidth; -} - -/** - * IMPORTANT: this class is exposed publicly as Chart.Legend, backward com= patibility required! - */ -var Legend =3D core_element.extend({ - - initialize: function(config) { - var me =3D this; - helpers$1.extend(me, config); - - // Contains hit boxes for each dataset (in dataset order) - me.legendHitBoxes =3D []; - - /** - * @private - */ - me._hoveredItem =3D null; - - // Are we in doughnut mode which has a different data type - me.doughnutMode =3D false; - }, - - // These methods are ordered by lifecycle. Utilities then follow. - // Any function defined here is inherited by all legend types. - // Any function can be extended by the legend type - - beforeUpdate: noop$1, - update: function(maxWidth, maxHeight, margins) { - var me =3D this; - - // Update Lifecycle - Probably don't want to ever extend or overwrite th= is function ;) - me.beforeUpdate(); - - // Absorb the master measurements - me.maxWidth =3D maxWidth; - me.maxHeight =3D maxHeight; - me.margins =3D margins; - - // Dimensions - me.beforeSetDimensions(); - me.setDimensions(); - me.afterSetDimensions(); - // Labels - me.beforeBuildLabels(); - me.buildLabels(); - me.afterBuildLabels(); - - // Fit - me.beforeFit(); - me.fit(); - me.afterFit(); - // - me.afterUpdate(); - - return me.minSize; - }, - afterUpdate: noop$1, - - // - - beforeSetDimensions: noop$1, - setDimensions: function() { - var me =3D this; - // Set the unconstrained dimension before label rotation - if (me.isHorizontal()) { - // Reset position before calculating rotation - me.width =3D me.maxWidth; - me.left =3D 0; - me.right =3D me.width; - } else { - me.height =3D me.maxHeight; - - // Reset position before calculating rotation - me.top =3D 0; - me.bottom =3D me.height; - } - - // Reset padding - me.paddingLeft =3D 0; - me.paddingTop =3D 0; - me.paddingRight =3D 0; - me.paddingBottom =3D 0; - - // Reset minSize - me.minSize =3D { - width: 0, - height: 0 - }; - }, - afterSetDimensions: noop$1, - - // - - beforeBuildLabels: noop$1, - buildLabels: function() { - var me =3D this; - var labelOpts =3D me.options.labels || {}; - var legendItems =3D helpers$1.callback(labelOpts.generateLabels, [me.cha= rt], me) || []; - - if (labelOpts.filter) { - legendItems =3D legendItems.filter(function(item) { - return labelOpts.filter(item, me.chart.data); - }); - } - - if (me.options.reverse) { - legendItems.reverse(); - } - - me.legendItems =3D legendItems; - }, - afterBuildLabels: noop$1, - - // - - beforeFit: noop$1, - fit: function() { - var me =3D this; - var opts =3D me.options; - var labelOpts =3D opts.labels; - var display =3D opts.display; - - var ctx =3D me.ctx; - - var labelFont =3D helpers$1.options._parseFont(labelOpts); - var fontSize =3D labelFont.size; - - // Reset hit boxes - var hitboxes =3D me.legendHitBoxes =3D []; - - var minSize =3D me.minSize; - var isHorizontal =3D me.isHorizontal(); - - if (isHorizontal) { - minSize.width =3D me.maxWidth; // fill all the width - minSize.height =3D display ? 10 : 0; - } else { - minSize.width =3D display ? 10 : 0; - minSize.height =3D me.maxHeight; // fill all the height - } - - // Increase sizes here - if (!display) { - me.width =3D minSize.width =3D me.height =3D minSize.height =3D 0; - return; - } - ctx.font =3D labelFont.string; - - if (isHorizontal) { - // Labels - - // Width of each line of legend boxes. Labels wrap onto multiple lines = when there are too many to fit on one - var lineWidths =3D me.lineWidths =3D [0]; - var totalHeight =3D 0; - - ctx.textAlign =3D 'left'; - ctx.textBaseline =3D 'middle'; - - helpers$1.each(me.legendItems, function(legendItem, i) { - var boxWidth =3D getBoxWidth(labelOpts, fontSize); - var width =3D boxWidth + (fontSize / 2) + ctx.measureText(legendItem.t= ext).width; - - if (i =3D=3D=3D 0 || lineWidths[lineWidths.length - 1] + width + 2 * l= abelOpts.padding > minSize.width) { - totalHeight +=3D fontSize + labelOpts.padding; - lineWidths[lineWidths.length - (i > 0 ? 0 : 1)] =3D 0; - } - - // Store the hitbox width and height here. Final position will be upda= ted in `draw` - hitboxes[i] =3D { - left: 0, - top: 0, - width: width, - height: fontSize - }; - - lineWidths[lineWidths.length - 1] +=3D width + labelOpts.padding; - }); - - minSize.height +=3D totalHeight; - - } else { - var vPadding =3D labelOpts.padding; - var columnWidths =3D me.columnWidths =3D []; - var columnHeights =3D me.columnHeights =3D []; - var totalWidth =3D labelOpts.padding; - var currentColWidth =3D 0; - var currentColHeight =3D 0; - - helpers$1.each(me.legendItems, function(legendItem, i) { - var boxWidth =3D getBoxWidth(labelOpts, fontSize); - var itemWidth =3D boxWidth + (fontSize / 2) + ctx.measureText(legendIt= em.text).width; - - // If too tall, go to new column - if (i > 0 && currentColHeight + fontSize + 2 * vPadding > minSize.heig= ht) { - totalWidth +=3D currentColWidth + labelOpts.padding; - columnWidths.push(currentColWidth); // previous column width - columnHeights.push(currentColHeight); - currentColWidth =3D 0; - currentColHeight =3D 0; - } - - // Get max width - currentColWidth =3D Math.max(currentColWidth, itemWidth); - currentColHeight +=3D fontSize + vPadding; - - // Store the hitbox width and height here. Final position will be upda= ted in `draw` - hitboxes[i] =3D { - left: 0, - top: 0, - width: itemWidth, - height: fontSize - }; - }); - - totalWidth +=3D currentColWidth; - columnWidths.push(currentColWidth); - columnHeights.push(currentColHeight); - minSize.width +=3D totalWidth; - } - - me.width =3D minSize.width; - me.height =3D minSize.height; - }, - afterFit: noop$1, - - // Shared Methods - isHorizontal: function() { - return this.options.position =3D=3D=3D 'top' || this.options.position = =3D=3D=3D 'bottom'; - }, - - // Actually draw the legend on the canvas - draw: function() { - var me =3D this; - var opts =3D me.options; - var labelOpts =3D opts.labels; - var globalDefaults =3D core_defaults.global; - var defaultColor =3D globalDefaults.defaultColor; - var lineDefault =3D globalDefaults.elements.line; - var legendHeight =3D me.height; - var columnHeights =3D me.columnHeights; - var legendWidth =3D me.width; - var lineWidths =3D me.lineWidths; - - if (!opts.display) { - return; - } - - var rtlHelper =3D getRtlHelper$1(opts.rtl, me.left, me.minSize.width); - var ctx =3D me.ctx; - var fontColor =3D valueOrDefault$e(labelOpts.fontColor, globalDefaults.d= efaultFontColor); - var labelFont =3D helpers$1.options._parseFont(labelOpts); - var fontSize =3D labelFont.size; - var cursor; - - // Canvas setup - ctx.textAlign =3D rtlHelper.textAlign('left'); - ctx.textBaseline =3D 'middle'; - ctx.lineWidth =3D 0.5; - ctx.strokeStyle =3D fontColor; // for strikethrough effect - ctx.fillStyle =3D fontColor; // render in correct colour - ctx.font =3D labelFont.string; - - var boxWidth =3D getBoxWidth(labelOpts, fontSize); - var hitboxes =3D me.legendHitBoxes; - - // current position - var drawLegendBox =3D function(x, y, legendItem) { - if (isNaN(boxWidth) || boxWidth <=3D 0) { - return; - } - - // Set the ctx for the box - ctx.save(); - - var lineWidth =3D valueOrDefault$e(legendItem.lineWidth, lineDefault.bo= rderWidth); - ctx.fillStyle =3D valueOrDefault$e(legendItem.fillStyle, defaultColor); - ctx.lineCap =3D valueOrDefault$e(legendItem.lineCap, lineDefault.border= CapStyle); - ctx.lineDashOffset =3D valueOrDefault$e(legendItem.lineDashOffset, line= Default.borderDashOffset); - ctx.lineJoin =3D valueOrDefault$e(legendItem.lineJoin, lineDefault.bord= erJoinStyle); - ctx.lineWidth =3D lineWidth; - ctx.strokeStyle =3D valueOrDefault$e(legendItem.strokeStyle, defaultCol= or); - - if (ctx.setLineDash) { - // IE 9 and 10 do not support line dash - ctx.setLineDash(valueOrDefault$e(legendItem.lineDash, lineDefault.bord= erDash)); - } - - if (labelOpts && labelOpts.usePointStyle) { - // Recalculate x and y for drawPoint() because its expecting - // x and y to be center of figure (instead of top left) - var radius =3D boxWidth * Math.SQRT2 / 2; - var centerX =3D rtlHelper.xPlus(x, boxWidth / 2); - var centerY =3D y + fontSize / 2; - - // Draw pointStyle as legend symbol - helpers$1.canvas.drawPoint(ctx, legendItem.pointStyle, radius, centerX= , centerY, legendItem.rotation); - } else { - // Draw box as legend symbol - ctx.fillRect(rtlHelper.leftForLtr(x, boxWidth), y, boxWidth, fontSize); - if (lineWidth !=3D=3D 0) { - ctx.strokeRect(rtlHelper.leftForLtr(x, boxWidth), y, boxWidth, fontSi= ze); - } - } - - ctx.restore(); - }; - - var fillText =3D function(x, y, legendItem, textWidth) { - var halfFontSize =3D fontSize / 2; - var xLeft =3D rtlHelper.xPlus(x, boxWidth + halfFontSize); - var yMiddle =3D y + halfFontSize; - - ctx.fillText(legendItem.text, xLeft, yMiddle); - - if (legendItem.hidden) { - // Strikethrough the text if hidden - ctx.beginPath(); - ctx.lineWidth =3D 2; - ctx.moveTo(xLeft, yMiddle); - ctx.lineTo(rtlHelper.xPlus(xLeft, textWidth), yMiddle); - ctx.stroke(); - } - }; - - var alignmentOffset =3D function(dimension, blockSize) { - switch (opts.align) { - case 'start': - return labelOpts.padding; - case 'end': - return dimension - blockSize; - default: // center - return (dimension - blockSize + labelOpts.padding) / 2; - } - }; - - // Horizontal - var isHorizontal =3D me.isHorizontal(); - if (isHorizontal) { - cursor =3D { - x: me.left + alignmentOffset(legendWidth, lineWidths[0]), - y: me.top + labelOpts.padding, - line: 0 - }; - } else { - cursor =3D { - x: me.left + labelOpts.padding, - y: me.top + alignmentOffset(legendHeight, columnHeights[0]), - line: 0 - }; - } - - helpers$1.rtl.overrideTextDirection(me.ctx, opts.textDirection); - - var itemHeight =3D fontSize + labelOpts.padding; - helpers$1.each(me.legendItems, function(legendItem, i) { - var textWidth =3D ctx.measureText(legendItem.text).width; - var width =3D boxWidth + (fontSize / 2) + textWidth; - var x =3D cursor.x; - var y =3D cursor.y; - - rtlHelper.setWidth(me.minSize.width); - - // Use (me.left + me.minSize.width) and (me.top + me.minSize.height) - // instead of me.right and me.bottom because me.width and me.height - // may have been changed since me.minSize was calculated - if (isHorizontal) { - if (i > 0 && x + width + labelOpts.padding > me.left + me.minSize.widt= h) { - y =3D cursor.y +=3D itemHeight; - cursor.line++; - x =3D cursor.x =3D me.left + alignmentOffset(legendWidth, lineWidths[= cursor.line]); - } - } else if (i > 0 && y + itemHeight > me.top + me.minSize.height) { - x =3D cursor.x =3D x + me.columnWidths[cursor.line] + labelOpts.paddin= g; - cursor.line++; - y =3D cursor.y =3D me.top + alignmentOffset(legendHeight, columnHeight= s[cursor.line]); - } - - var realX =3D rtlHelper.x(x); - - drawLegendBox(realX, y, legendItem); - - hitboxes[i].left =3D rtlHelper.leftForLtr(realX, hitboxes[i].width); - hitboxes[i].top =3D y; +function isValidKey(key) {=0D + return ['__proto__', 'prototype', 'constructor'].indexOf(key) =3D=3D=3D -= 1;=0D +}=0D +=0D +/**=0D + * @namespace Chart.helpers=0D + */=0D +var helpers =3D {=0D + /**=0D + * An empty function that can be used, for example, for optional callback= .=0D + */=0D + noop: function() {},=0D +=0D + /**=0D + * Returns a unique id, sequentially generated from a global variable.=0D + * @returns {number}=0D + * @function=0D + */=0D + uid: (function() {=0D + var id =3D 0;=0D + return function() {=0D + return id++;=0D + };=0D + }()),=0D +=0D + /**=0D + * Returns true if `value` is neither null nor undefined, else returns fa= lse.=0D + * @param {*} value - The value to test.=0D + * @returns {boolean}=0D + * @since 2.7.0=0D + */=0D + isNullOrUndef: function(value) {=0D + return value =3D=3D=3D null || typeof value =3D=3D=3D 'undefined';=0D + },=0D +=0D + /**=0D + * Returns true if `value` is an array (including typed arrays), else ret= urns false.=0D + * @param {*} value - The value to test.=0D + * @returns {boolean}=0D + * @function=0D + */=0D + isArray: function(value) {=0D + if (Array.isArray && Array.isArray(value)) {=0D + return true;=0D + }=0D + var type =3D Object.prototype.toString.call(value);=0D + if (type.substr(0, 7) =3D=3D=3D '[object' && type.substr(-6) =3D=3D=3D '= Array]') {=0D + return true;=0D + }=0D + return false;=0D + },=0D +=0D + /**=0D + * Returns true if `value` is an object (excluding null), else returns fa= lse.=0D + * @param {*} value - The value to test.=0D + * @returns {boolean}=0D + * @since 2.7.0=0D + */=0D + isObject: function(value) {=0D + return value !=3D=3D null && Object.prototype.toString.call(value) =3D= =3D=3D '[object Object]';=0D + },=0D +=0D + /**=0D + * Returns true if `value` is a finite number, else returns false=0D + * @param {*} value - The value to test.=0D + * @returns {boolean}=0D + */=0D + isFinite: function(value) {=0D + return (typeof value =3D=3D=3D 'number' || value instanceof Number) && i= sFinite(value);=0D + },=0D +=0D + /**=0D + * Returns `value` if defined, else returns `defaultValue`.=0D + * @param {*} value - The value to return if defined.=0D + * @param {*} defaultValue - The value to return if `value` is undefined.= =0D + * @returns {*}=0D + */=0D + valueOrDefault: function(value, defaultValue) {=0D + return typeof value =3D=3D=3D 'undefined' ? defaultValue : value;=0D + },=0D +=0D + /**=0D + * Returns value at the given `index` in array if defined, else returns `= defaultValue`.=0D + * @param {Array} value - The array to lookup for value at `index`.=0D + * @param {number} index - The index in `value` to lookup for value.=0D + * @param {*} defaultValue - The value to return if `value[index]` is und= efined.=0D + * @returns {*}=0D + */=0D + valueAtIndexOrDefault: function(value, index, defaultValue) {=0D + return helpers.valueOrDefault(helpers.isArray(value) ? value[index] : va= lue, defaultValue);=0D + },=0D +=0D + /**=0D + * Calls `fn` with the given `args` in the scope defined by `thisArg` and= returns the=0D + * value returned by `fn`. If `fn` is not a function, this method returns= undefined.=0D + * @param {function} fn - The function to call.=0D + * @param {Array|undefined|null} args - The arguments with which `fn` sho= uld be called.=0D + * @param {object} [thisArg] - The value of `this` provided for the call = to `fn`.=0D + * @returns {*}=0D + */=0D + callback: function(fn, args, thisArg) {=0D + if (fn && typeof fn.call =3D=3D=3D 'function') {=0D + return fn.apply(thisArg, args);=0D + }=0D + },=0D +=0D + /**=0D + * Note(SB) for performance sake, this method should only be used when lo= opable type=0D + * is unknown or in none intensive code (not called often and small loopa= ble). Else=0D + * it's preferable to use a regular for() loop and save extra function ca= lls.=0D + * @param {object|Array} loopable - The object or array to be iterated.=0D + * @param {function} fn - The function to call for each item.=0D + * @param {object} [thisArg] - The value of `this` provided for the call = to `fn`.=0D + * @param {boolean} [reverse] - If true, iterates backward on the loopabl= e.=0D + */=0D + each: function(loopable, fn, thisArg, reverse) {=0D + var i, len, keys;=0D + if (helpers.isArray(loopable)) {=0D + len =3D loopable.length;=0D + if (reverse) {=0D + for (i =3D len - 1; i >=3D 0; i--) {=0D + fn.call(thisArg, loopable[i], i);=0D + }=0D + } else {=0D + for (i =3D 0; i < len; i++) {=0D + fn.call(thisArg, loopable[i], i);=0D + }=0D + }=0D + } else if (helpers.isObject(loopable)) {=0D + keys =3D Object.keys(loopable);=0D + len =3D keys.length;=0D + for (i =3D 0; i < len; i++) {=0D + fn.call(thisArg, loopable[keys[i]], keys[i]);=0D + }=0D + }=0D + },=0D +=0D + /**=0D + * Returns true if the `a0` and `a1` arrays have the same content, else r= eturns false.=0D + * @see https://stackoverflow.com/a/14853974=0D + * @param {Array} a0 - The array to compare=0D + * @param {Array} a1 - The array to compare=0D + * @returns {boolean}=0D + */=0D + arrayEquals: function(a0, a1) {=0D + var i, ilen, v0, v1;=0D +=0D + if (!a0 || !a1 || a0.length !=3D=3D a1.length) {=0D + return false;=0D + }=0D +=0D + for (i =3D 0, ilen =3D a0.length; i < ilen; ++i) {=0D + v0 =3D a0[i];=0D + v1 =3D a1[i];=0D +=0D + if (v0 instanceof Array && v1 instanceof Array) {=0D + if (!helpers.arrayEquals(v0, v1)) {=0D + return false;=0D + }=0D + } else if (v0 !=3D=3D v1) {=0D + // NOTE: two different object instances will never be equal: {x:20} != =3D {x:20}=0D + return false;=0D + }=0D + }=0D +=0D + return true;=0D + },=0D +=0D + /**=0D + * Returns a deep copy of `source` without keeping references on objects = and arrays.=0D + * @param {*} source - The value to clone.=0D + * @returns {*}=0D + */=0D + clone: function(source) {=0D + if (helpers.isArray(source)) {=0D + return source.map(helpers.clone);=0D + }=0D +=0D + if (helpers.isObject(source)) {=0D + var target =3D Object.create(source);=0D + var keys =3D Object.keys(source);=0D + var klen =3D keys.length;=0D + var k =3D 0;=0D +=0D + for (; k < klen; ++k) {=0D + target[keys[k]] =3D helpers.clone(source[keys[k]]);=0D + }=0D +=0D + return target;=0D + }=0D +=0D + return source;=0D + },=0D +=0D + /**=0D + * The default merger when Chart.helpers.merge is called without merger o= ption.=0D + * Note(SB): also used by mergeConfig and mergeScaleConfig as fallback.=0D + * @private=0D + */=0D + _merger: function(key, target, source, options) {=0D + if (!isValidKey(key)) {=0D + // We want to ensure we do not copy prototypes over=0D + // as this can pollute global namespaces=0D + return;=0D + }=0D +=0D + var tval =3D target[key];=0D + var sval =3D source[key];=0D +=0D + if (helpers.isObject(tval) && helpers.isObject(sval)) {=0D + helpers.merge(tval, sval, options);=0D + } else {=0D + target[key] =3D helpers.clone(sval);=0D + }=0D + },=0D +=0D + /**=0D + * Merges source[key] in target[key] only if target[key] is undefined.=0D + * @private=0D + */=0D + _mergerIf: function(key, target, source) {=0D + if (!isValidKey(key)) {=0D + // We want to ensure we do not copy prototypes over=0D + // as this can pollute global namespaces=0D + return;=0D + }=0D +=0D + var tval =3D target[key];=0D + var sval =3D source[key];=0D +=0D + if (helpers.isObject(tval) && helpers.isObject(sval)) {=0D + helpers.mergeIf(tval, sval);=0D + } else if (!target.hasOwnProperty(key)) {=0D + target[key] =3D helpers.clone(sval);=0D + }=0D + },=0D +=0D + /**=0D + * Recursively deep copies `source` properties into `target` with the giv= en `options`.=0D + * IMPORTANT: `target` is not cloned and will be updated with `source` pr= operties.=0D + * @param {object} target - The target object in which all sources are me= rged into.=0D + * @param {object|object[]} source - Object(s) to merge into `target`.=0D + * @param {object} [options] - Merging options:=0D + * @param {function} [options.merger] - The merge method (key, target, so= urce, options)=0D + * @returns {object} The `target` object.=0D + */=0D + merge: function(target, source, options) {=0D + var sources =3D helpers.isArray(source) ? source : [source];=0D + var ilen =3D sources.length;=0D + var merge, i, keys, klen, k;=0D +=0D + if (!helpers.isObject(target)) {=0D + return target;=0D + }=0D +=0D + options =3D options || {};=0D + merge =3D options.merger || helpers._merger;=0D +=0D + for (i =3D 0; i < ilen; ++i) {=0D + source =3D sources[i];=0D + if (!helpers.isObject(source)) {=0D + continue;=0D + }=0D +=0D + keys =3D Object.keys(source);=0D + for (k =3D 0, klen =3D keys.length; k < klen; ++k) {=0D + merge(keys[k], target, source, options);=0D + }=0D + }=0D +=0D + return target;=0D + },=0D +=0D + /**=0D + * Recursively deep copies `source` properties into `target` *only* if no= t defined in target.=0D + * IMPORTANT: `target` is not cloned and will be updated with `source` pr= operties.=0D + * @param {object} target - The target object in which all sources are me= rged into.=0D + * @param {object|object[]} source - Object(s) to merge into `target`.=0D + * @returns {object} The `target` object.=0D + */=0D + mergeIf: function(target, source) {=0D + return helpers.merge(target, source, {merger: helpers._mergerIf});=0D + },=0D +=0D + /**=0D + * Applies the contents of two or more objects together into the first ob= ject.=0D + * @param {object} target - The target object in which all objects are me= rged into.=0D + * @param {object} arg1 - Object containing additional properties to merg= e in target.=0D + * @param {object} argN - Additional objects containing properties to mer= ge in target.=0D + * @returns {object} The `target` object.=0D + */=0D + extend: Object.assign || function(target) {=0D + return helpers.merge(target, [].slice.call(arguments, 1), {=0D + merger: function(key, dst, src) {=0D + dst[key] =3D src[key];=0D + }=0D + });=0D + },=0D +=0D + /**=0D + * Basic javascript inheritance based on the model created in Backbone.js= =0D + */=0D + inherits: function(extensions) {=0D + var me =3D this;=0D + var ChartElement =3D (extensions && extensions.hasOwnProperty('construct= or')) ? extensions.constructor : function() {=0D + return me.apply(this, arguments);=0D + };=0D +=0D + var Surrogate =3D function() {=0D + this.constructor =3D ChartElement;=0D + };=0D +=0D + Surrogate.prototype =3D me.prototype;=0D + ChartElement.prototype =3D new Surrogate();=0D + ChartElement.extend =3D helpers.inherits;=0D +=0D + if (extensions) {=0D + helpers.extend(ChartElement.prototype, extensions);=0D + }=0D +=0D + ChartElement.__super__ =3D me.prototype;=0D + return ChartElement;=0D + },=0D +=0D + _deprecated: function(scope, value, previous, current) {=0D + if (value !=3D=3D undefined) {=0D + console.warn(scope + ': "' + previous +=0D + '" is deprecated. Please use "' + current + '" instead');=0D + }=0D + }=0D +};=0D +=0D +var helpers_core =3D helpers;=0D +=0D +// DEPRECATIONS=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.helpers.callback instead= .=0D + * @function Chart.helpers.callCallback=0D + * @deprecated since version 2.6.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers.callCallback =3D helpers.callback;=0D +=0D +/**=0D + * Provided for backward compatibility, use Array.prototype.indexOf instea= d.=0D + * Array.prototype.indexOf compatibility: Chrome, Opera, Safari, FF1.5+, I= E9+=0D + * @function Chart.helpers.indexOf=0D + * @deprecated since version 2.7.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers.indexOf =3D function(array, item, fromIndex) {=0D + return Array.prototype.indexOf.call(array, item, fromIndex);=0D +};=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.helpers.valueOrDefault i= nstead.=0D + * @function Chart.helpers.getValueOrDefault=0D + * @deprecated since version 2.7.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers.getValueOrDefault =3D helpers.valueOrDefault;=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.helpers.valueAtIndexOrDe= fault instead.=0D + * @function Chart.helpers.getValueAtIndexOrDefault=0D + * @deprecated since version 2.7.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers.getValueAtIndexOrDefault =3D helpers.valueAtIndexOrDefault; =20 - // Fill the actual label - fillText(realX, y, legendItem, textWidth); +/**=0D + * Easing functions adapted from Robert Penner's easing equations.=0D + * @namespace Chart.helpers.easingEffects=0D + * @see http://www.robertpenner.com/easing/=0D + */=0D +var effects =3D {=0D + linear: function(t) {=0D + return t;=0D + },=0D +=0D + easeInQuad: function(t) {=0D + return t * t;=0D + },=0D +=0D + easeOutQuad: function(t) {=0D + return -t * (t - 2);=0D + },=0D +=0D + easeInOutQuad: function(t) {=0D + if ((t /=3D 0.5) < 1) {=0D + return 0.5 * t * t;=0D + }=0D + return -0.5 * ((--t) * (t - 2) - 1);=0D + },=0D +=0D + easeInCubic: function(t) {=0D + return t * t * t;=0D + },=0D +=0D + easeOutCubic: function(t) {=0D + return (t =3D t - 1) * t * t + 1;=0D + },=0D +=0D + easeInOutCubic: function(t) {=0D + if ((t /=3D 0.5) < 1) {=0D + return 0.5 * t * t * t;=0D + }=0D + return 0.5 * ((t -=3D 2) * t * t + 2);=0D + },=0D +=0D + easeInQuart: function(t) {=0D + return t * t * t * t;=0D + },=0D +=0D + easeOutQuart: function(t) {=0D + return -((t =3D t - 1) * t * t * t - 1);=0D + },=0D +=0D + easeInOutQuart: function(t) {=0D + if ((t /=3D 0.5) < 1) {=0D + return 0.5 * t * t * t * t;=0D + }=0D + return -0.5 * ((t -=3D 2) * t * t * t - 2);=0D + },=0D +=0D + easeInQuint: function(t) {=0D + return t * t * t * t * t;=0D + },=0D +=0D + easeOutQuint: function(t) {=0D + return (t =3D t - 1) * t * t * t * t + 1;=0D + },=0D +=0D + easeInOutQuint: function(t) {=0D + if ((t /=3D 0.5) < 1) {=0D + return 0.5 * t * t * t * t * t;=0D + }=0D + return 0.5 * ((t -=3D 2) * t * t * t * t + 2);=0D + },=0D +=0D + easeInSine: function(t) {=0D + return -Math.cos(t * (Math.PI / 2)) + 1;=0D + },=0D +=0D + easeOutSine: function(t) {=0D + return Math.sin(t * (Math.PI / 2));=0D + },=0D +=0D + easeInOutSine: function(t) {=0D + return -0.5 * (Math.cos(Math.PI * t) - 1);=0D + },=0D +=0D + easeInExpo: function(t) {=0D + return (t =3D=3D=3D 0) ? 0 : Math.pow(2, 10 * (t - 1));=0D + },=0D +=0D + easeOutExpo: function(t) {=0D + return (t =3D=3D=3D 1) ? 1 : -Math.pow(2, -10 * t) + 1;=0D + },=0D +=0D + easeInOutExpo: function(t) {=0D + if (t =3D=3D=3D 0) {=0D + return 0;=0D + }=0D + if (t =3D=3D=3D 1) {=0D + return 1;=0D + }=0D + if ((t /=3D 0.5) < 1) {=0D + return 0.5 * Math.pow(2, 10 * (t - 1));=0D + }=0D + return 0.5 * (-Math.pow(2, -10 * --t) + 2);=0D + },=0D +=0D + easeInCirc: function(t) {=0D + if (t >=3D 1) {=0D + return t;=0D + }=0D + return -(Math.sqrt(1 - t * t) - 1);=0D + },=0D +=0D + easeOutCirc: function(t) {=0D + return Math.sqrt(1 - (t =3D t - 1) * t);=0D + },=0D +=0D + easeInOutCirc: function(t) {=0D + if ((t /=3D 0.5) < 1) {=0D + return -0.5 * (Math.sqrt(1 - t * t) - 1);=0D + }=0D + return 0.5 * (Math.sqrt(1 - (t -=3D 2) * t) + 1);=0D + },=0D +=0D + easeInElastic: function(t) {=0D + var s =3D 1.70158;=0D + var p =3D 0;=0D + var a =3D 1;=0D + if (t =3D=3D=3D 0) {=0D + return 0;=0D + }=0D + if (t =3D=3D=3D 1) {=0D + return 1;=0D + }=0D + if (!p) {=0D + p =3D 0.3;=0D + }=0D + if (a < 1) {=0D + a =3D 1;=0D + s =3D p / 4;=0D + } else {=0D + s =3D p / (2 * Math.PI) * Math.asin(1 / a);=0D + }=0D + return -(a * Math.pow(2, 10 * (t -=3D 1)) * Math.sin((t - s) * (2 * Math= .PI) / p));=0D + },=0D +=0D + easeOutElastic: function(t) {=0D + var s =3D 1.70158;=0D + var p =3D 0;=0D + var a =3D 1;=0D + if (t =3D=3D=3D 0) {=0D + return 0;=0D + }=0D + if (t =3D=3D=3D 1) {=0D + return 1;=0D + }=0D + if (!p) {=0D + p =3D 0.3;=0D + }=0D + if (a < 1) {=0D + a =3D 1;=0D + s =3D p / 4;=0D + } else {=0D + s =3D p / (2 * Math.PI) * Math.asin(1 / a);=0D + }=0D + return a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p) = + 1;=0D + },=0D +=0D + easeInOutElastic: function(t) {=0D + var s =3D 1.70158;=0D + var p =3D 0;=0D + var a =3D 1;=0D + if (t =3D=3D=3D 0) {=0D + return 0;=0D + }=0D + if ((t /=3D 0.5) =3D=3D=3D 2) {=0D + return 1;=0D + }=0D + if (!p) {=0D + p =3D 0.45;=0D + }=0D + if (a < 1) {=0D + a =3D 1;=0D + s =3D p / 4;=0D + } else {=0D + s =3D p / (2 * Math.PI) * Math.asin(1 / a);=0D + }=0D + if (t < 1) {=0D + return -0.5 * (a * Math.pow(2, 10 * (t -=3D 1)) * Math.sin((t - s) * (2= * Math.PI) / p));=0D + }=0D + return a * Math.pow(2, -10 * (t -=3D 1)) * Math.sin((t - s) * (2 * Math.= PI) / p) * 0.5 + 1;=0D + },=0D + easeInBack: function(t) {=0D + var s =3D 1.70158;=0D + return t * t * ((s + 1) * t - s);=0D + },=0D +=0D + easeOutBack: function(t) {=0D + var s =3D 1.70158;=0D + return (t =3D t - 1) * t * ((s + 1) * t + s) + 1;=0D + },=0D +=0D + easeInOutBack: function(t) {=0D + var s =3D 1.70158;=0D + if ((t /=3D 0.5) < 1) {=0D + return 0.5 * (t * t * (((s *=3D (1.525)) + 1) * t - s));=0D + }=0D + return 0.5 * ((t -=3D 2) * t * (((s *=3D (1.525)) + 1) * t + s) + 2);=0D + },=0D +=0D + easeInBounce: function(t) {=0D + return 1 - effects.easeOutBounce(1 - t);=0D + },=0D +=0D + easeOutBounce: function(t) {=0D + if (t < (1 / 2.75)) {=0D + return 7.5625 * t * t;=0D + }=0D + if (t < (2 / 2.75)) {=0D + return 7.5625 * (t -=3D (1.5 / 2.75)) * t + 0.75;=0D + }=0D + if (t < (2.5 / 2.75)) {=0D + return 7.5625 * (t -=3D (2.25 / 2.75)) * t + 0.9375;=0D + }=0D + return 7.5625 * (t -=3D (2.625 / 2.75)) * t + 0.984375;=0D + },=0D +=0D + easeInOutBounce: function(t) {=0D + if (t < 0.5) {=0D + return effects.easeInBounce(t * 2) * 0.5;=0D + }=0D + return effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5;=0D + }=0D +};=0D +=0D +var helpers_easing =3D {=0D + effects: effects=0D +};=0D +=0D +// DEPRECATIONS=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.helpers.easing.effects i= nstead.=0D + * @function Chart.helpers.easingEffects=0D + * @deprecated since version 2.7.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers_core.easingEffects =3D effects; =20 - if (isHorizontal) { - cursor.x +=3D width + labelOpts.padding; - } else { - cursor.y +=3D itemHeight; - } - }); +var PI =3D Math.PI;=0D +var RAD_PER_DEG =3D PI / 180;=0D +var DOUBLE_PI =3D PI * 2;=0D +var HALF_PI =3D PI / 2;=0D +var QUARTER_PI =3D PI / 4;=0D +var TWO_THIRDS_PI =3D PI * 2 / 3;=0D +=0D +/**=0D + * @namespace Chart.helpers.canvas=0D + */=0D +var exports$1 =3D {=0D + /**=0D + * Clears the entire canvas associated to the given `chart`.=0D + * @param {Chart} chart - The chart for which to clear the canvas.=0D + */=0D + clear: function(chart) {=0D + chart.ctx.clearRect(0, 0, chart.width, chart.height);=0D + },=0D +=0D + /**=0D + * Creates a "path" for a rectangle with rounded corners at position (x, = y) with a=0D + * given size (width, height) and the same `radius` for all corners.=0D + * @param {CanvasRenderingContext2D} ctx - The canvas 2D Context.=0D + * @param {number} x - The x axis of the coordinate for the rectangle sta= rting point.=0D + * @param {number} y - The y axis of the coordinate for the rectangle sta= rting point.=0D + * @param {number} width - The rectangle's width.=0D + * @param {number} height - The rectangle's height.=0D + * @param {number} radius - The rounded amount (in pixels) for the four c= orners.=0D + * @todo handle `radius` as top-left, top-right, bottom-right, bottom-lef= t array/object?=0D + */=0D + roundedRect: function(ctx, x, y, width, height, radius) {=0D + if (radius) {=0D + var r =3D Math.min(radius, height / 2, width / 2);=0D + var left =3D x + r;=0D + var top =3D y + r;=0D + var right =3D x + width - r;=0D + var bottom =3D y + height - r;=0D +=0D + ctx.moveTo(x, top);=0D + if (left < right && top < bottom) {=0D + ctx.arc(left, top, r, -PI, -HALF_PI);=0D + ctx.arc(right, top, r, -HALF_PI, 0);=0D + ctx.arc(right, bottom, r, 0, HALF_PI);=0D + ctx.arc(left, bottom, r, HALF_PI, PI);=0D + } else if (left < right) {=0D + ctx.moveTo(left, y);=0D + ctx.arc(right, top, r, -HALF_PI, HALF_PI);=0D + ctx.arc(left, top, r, HALF_PI, PI + HALF_PI);=0D + } else if (top < bottom) {=0D + ctx.arc(left, top, r, -PI, 0);=0D + ctx.arc(left, bottom, r, 0, PI);=0D + } else {=0D + ctx.arc(left, top, r, -PI, PI);=0D + }=0D + ctx.closePath();=0D + ctx.moveTo(x, y);=0D + } else {=0D + ctx.rect(x, y, width, height);=0D + }=0D + },=0D +=0D + drawPoint: function(ctx, style, radius, x, y, rotation) {=0D + var type, xOffset, yOffset, size, cornerRadius;=0D + var rad =3D (rotation || 0) * RAD_PER_DEG;=0D +=0D + if (style && typeof style =3D=3D=3D 'object') {=0D + type =3D style.toString();=0D + if (type =3D=3D=3D '[object HTMLImageElement]' || type =3D=3D=3D '[obje= ct HTMLCanvasElement]') {=0D + ctx.save();=0D + ctx.translate(x, y);=0D + ctx.rotate(rad);=0D + ctx.drawImage(style, -style.width / 2, -style.height / 2, style.width,= style.height);=0D + ctx.restore();=0D + return;=0D + }=0D + }=0D +=0D + if (isNaN(radius) || radius <=3D 0) {=0D + return;=0D + }=0D +=0D + ctx.beginPath();=0D +=0D + switch (style) {=0D + // Default includes circle=0D + default:=0D + ctx.arc(x, y, radius, 0, DOUBLE_PI);=0D + ctx.closePath();=0D + break;=0D + case 'triangle':=0D + ctx.moveTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius);=0D + rad +=3D TWO_THIRDS_PI;=0D + ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius);=0D + rad +=3D TWO_THIRDS_PI;=0D + ctx.lineTo(x + Math.sin(rad) * radius, y - Math.cos(rad) * radius);=0D + ctx.closePath();=0D + break;=0D + case 'rectRounded':=0D + // NOTE: the rounded rect implementation changed to use `arc` instead o= f=0D + // `quadraticCurveTo` since it generates better results when rect is=0D + // almost a circle. 0.516 (instead of 0.5) produces results with visual= ly=0D + // closer proportion to the previous impl and it is inscribed in the=0D + // circle with `radius`. For more details, see the following PRs:=0D + // https://github.com/chartjs/Chart.js/issues/5597=0D + // https://github.com/chartjs/Chart.js/issues/5858=0D + cornerRadius =3D radius * 0.516;=0D + size =3D radius - cornerRadius;=0D + xOffset =3D Math.cos(rad + QUARTER_PI) * size;=0D + yOffset =3D Math.sin(rad + QUARTER_PI) * size;=0D + ctx.arc(x - xOffset, y - yOffset, cornerRadius, rad - PI, rad - HALF_PI= );=0D + ctx.arc(x + yOffset, y - xOffset, cornerRadius, rad - HALF_PI, rad);=0D + ctx.arc(x + xOffset, y + yOffset, cornerRadius, rad, rad + HALF_PI);=0D + ctx.arc(x - yOffset, y + xOffset, cornerRadius, rad + HALF_PI, rad + PI= );=0D + ctx.closePath();=0D + break;=0D + case 'rect':=0D + if (!rotation) {=0D + size =3D Math.SQRT1_2 * radius;=0D + ctx.rect(x - size, y - size, 2 * size, 2 * size);=0D + break;=0D + }=0D + rad +=3D QUARTER_PI;=0D + /* falls through */=0D + case 'rectRot':=0D + xOffset =3D Math.cos(rad) * radius;=0D + yOffset =3D Math.sin(rad) * radius;=0D + ctx.moveTo(x - xOffset, y - yOffset);=0D + ctx.lineTo(x + yOffset, y - xOffset);=0D + ctx.lineTo(x + xOffset, y + yOffset);=0D + ctx.lineTo(x - yOffset, y + xOffset);=0D + ctx.closePath();=0D + break;=0D + case 'crossRot':=0D + rad +=3D QUARTER_PI;=0D + /* falls through */=0D + case 'cross':=0D + xOffset =3D Math.cos(rad) * radius;=0D + yOffset =3D Math.sin(rad) * radius;=0D + ctx.moveTo(x - xOffset, y - yOffset);=0D + ctx.lineTo(x + xOffset, y + yOffset);=0D + ctx.moveTo(x + yOffset, y - xOffset);=0D + ctx.lineTo(x - yOffset, y + xOffset);=0D + break;=0D + case 'star':=0D + xOffset =3D Math.cos(rad) * radius;=0D + yOffset =3D Math.sin(rad) * radius;=0D + ctx.moveTo(x - xOffset, y - yOffset);=0D + ctx.lineTo(x + xOffset, y + yOffset);=0D + ctx.moveTo(x + yOffset, y - xOffset);=0D + ctx.lineTo(x - yOffset, y + xOffset);=0D + rad +=3D QUARTER_PI;=0D + xOffset =3D Math.cos(rad) * radius;=0D + yOffset =3D Math.sin(rad) * radius;=0D + ctx.moveTo(x - xOffset, y - yOffset);=0D + ctx.lineTo(x + xOffset, y + yOffset);=0D + ctx.moveTo(x + yOffset, y - xOffset);=0D + ctx.lineTo(x - yOffset, y + xOffset);=0D + break;=0D + case 'line':=0D + xOffset =3D Math.cos(rad) * radius;=0D + yOffset =3D Math.sin(rad) * radius;=0D + ctx.moveTo(x - xOffset, y - yOffset);=0D + ctx.lineTo(x + xOffset, y + yOffset);=0D + break;=0D + case 'dash':=0D + ctx.moveTo(x, y);=0D + ctx.lineTo(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius);=0D + break;=0D + }=0D +=0D + ctx.fill();=0D + ctx.stroke();=0D + },=0D +=0D + /**=0D + * Returns true if the point is inside the rectangle=0D + * @param {object} point - The point to test=0D + * @param {object} area - The rectangle=0D + * @returns {boolean}=0D + * @private=0D + */=0D + _isPointInArea: function(point, area) {=0D + var epsilon =3D 1e-6; // 1e-6 is margin in pixels for accumulated error.= =0D +=0D + return point.x > area.left - epsilon && point.x < area.right + epsilon &= &=0D + point.y > area.top - epsilon && point.y < area.bottom + epsilon;=0D + },=0D +=0D + clipArea: function(ctx, area) {=0D + ctx.save();=0D + ctx.beginPath();=0D + ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area= .top);=0D + ctx.clip();=0D + },=0D +=0D + unclipArea: function(ctx) {=0D + ctx.restore();=0D + },=0D +=0D + lineTo: function(ctx, previous, target, flip) {=0D + var stepped =3D target.steppedLine;=0D + if (stepped) {=0D + if (stepped =3D=3D=3D 'middle') {=0D + var midpoint =3D (previous.x + target.x) / 2.0;=0D + ctx.lineTo(midpoint, flip ? target.y : previous.y);=0D + ctx.lineTo(midpoint, flip ? previous.y : target.y);=0D + } else if ((stepped =3D=3D=3D 'after' && !flip) || (stepped !=3D=3D 'af= ter' && flip)) {=0D + ctx.lineTo(previous.x, target.y);=0D + } else {=0D + ctx.lineTo(target.x, previous.y);=0D + }=0D + ctx.lineTo(target.x, target.y);=0D + return;=0D + }=0D +=0D + if (!target.tension) {=0D + ctx.lineTo(target.x, target.y);=0D + return;=0D + }=0D +=0D + ctx.bezierCurveTo(=0D + flip ? previous.controlPointPreviousX : previous.controlPointNextX,=0D + flip ? previous.controlPointPreviousY : previous.controlPointNextY,=0D + flip ? target.controlPointNextX : target.controlPointPreviousX,=0D + flip ? target.controlPointNextY : target.controlPointPreviousY,=0D + target.x,=0D + target.y);=0D + }=0D +};=0D +=0D +var helpers_canvas =3D exports$1;=0D +=0D +// DEPRECATIONS=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.helpers.canvas.clear ins= tead.=0D + * @namespace Chart.helpers.clear=0D + * @deprecated since version 2.7.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers_core.clear =3D exports$1.clear;=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.helpers.canvas.roundedRe= ct instead.=0D + * @namespace Chart.helpers.drawRoundedRectangle=0D + * @deprecated since version 2.7.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers_core.drawRoundedRectangle =3D function(ctx) {=0D + ctx.beginPath();=0D + exports$1.roundedRect.apply(exports$1, arguments);=0D +}; =20 - helpers$1.rtl.restoreTextDirection(me.ctx, opts.textDirection); - }, +var defaults =3D {=0D + /**=0D + * @private=0D + */=0D + _set: function(scope, values) {=0D + return helpers_core.merge(this[scope] || (this[scope] =3D {}), values);= =0D + }=0D +};=0D +=0D +// TODO(v3): remove 'global' from namespace. all default are global and=0D +// there's inconsistency around which options are under 'global'=0D +defaults._set('global', {=0D + defaultColor: 'rgba(0,0,0,0.1)',=0D + defaultFontColor: '#666',=0D + defaultFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",= =0D + defaultFontSize: 12,=0D + defaultFontStyle: 'normal',=0D + defaultLineHeight: 1.2,=0D + showLines: true=0D +});=0D +=0D +var core_defaults =3D defaults; =20 - /** - * @private - */ - _getLegendItemAt: function(x, y) { - var me =3D this; - var i, hitBox, lh; - - if (x >=3D me.left && x <=3D me.right && y >=3D me.top && y <=3D me.bott= om) { - // See if we are touching one of the dataset boxes - lh =3D me.legendHitBoxes; - for (i =3D 0; i < lh.length; ++i) { - hitBox =3D lh[i]; - - if (x >=3D hitBox.left && x <=3D hitBox.left + hitBox.width && y >=3D = hitBox.top && y <=3D hitBox.top + hitBox.height) { - // Touching an element - return me.legendItems[i]; - } - } - } +var valueOrDefault =3D helpers_core.valueOrDefault;=0D +=0D +/**=0D + * Converts the given font object into a CSS font string.=0D + * @param {object} font - A font object.=0D + * @return {string} The CSS font string. See https://developer.mozilla.org= /en-US/docs/Web/CSS/font=0D + * @private=0D + */=0D +function toFontString(font) {=0D + if (!font || helpers_core.isNullOrUndef(font.size) || helpers_core.isNull= OrUndef(font.family)) {=0D + return null;=0D + }=0D +=0D + return (font.style ? font.style + ' ' : '')=0D + + (font.weight ? font.weight + ' ' : '')=0D + + font.size + 'px '=0D + + font.family;=0D +}=0D +=0D +/**=0D + * @alias Chart.helpers.options=0D + * @namespace=0D + */=0D +var helpers_options =3D {=0D + /**=0D + * Converts the given line height `value` in pixels for a specific font `= size`.=0D + * @param {number|string} value - The lineHeight to parse (eg. 1.6, '14px= ', '75%', '1.6em').=0D + * @param {number} size - The font size (in pixels) used to resolve relat= ive `value`.=0D + * @returns {number} The effective line height in pixels (size * 1.2 if v= alue is invalid).=0D + * @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height=0D + * @since 2.7.0=0D + */=0D + toLineHeight: function(value, size) {=0D + var matches =3D ('' + value).match(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$= /);=0D + if (!matches || matches[1] =3D=3D=3D 'normal') {=0D + return size * 1.2;=0D + }=0D +=0D + value =3D +matches[2];=0D +=0D + switch (matches[3]) {=0D + case 'px':=0D + return value;=0D + case '%':=0D + value /=3D 100;=0D + break;=0D + }=0D +=0D + return size * value;=0D + },=0D +=0D + /**=0D + * Converts the given value into a padding object with pre-computed width= /height.=0D + * @param {number|object} value - If a number, set the value to all TRBL = component,=0D + * else, if and object, use defined properties and sets undefined ones t= o 0.=0D + * @returns {object} The padding values (top, right, bottom, left, width,= height)=0D + * @since 2.7.0=0D + */=0D + toPadding: function(value) {=0D + var t, r, b, l;=0D +=0D + if (helpers_core.isObject(value)) {=0D + t =3D +value.top || 0;=0D + r =3D +value.right || 0;=0D + b =3D +value.bottom || 0;=0D + l =3D +value.left || 0;=0D + } else {=0D + t =3D r =3D b =3D l =3D +value || 0;=0D + }=0D +=0D + return {=0D + top: t,=0D + right: r,=0D + bottom: b,=0D + left: l,=0D + height: t + b,=0D + width: l + r=0D + };=0D + },=0D +=0D + /**=0D + * Parses font options and returns the font object.=0D + * @param {object} options - A object that contains font options to be pa= rsed.=0D + * @return {object} The font object.=0D + * @todo Support font.* options and renamed to toFont().=0D + * @private=0D + */=0D + _parseFont: function(options) {=0D + var globalDefaults =3D core_defaults.global;=0D + var size =3D valueOrDefault(options.fontSize, globalDefaults.defaultFont= Size);=0D + var font =3D {=0D + family: valueOrDefault(options.fontFamily, globalDefaults.defaultFontFa= mily),=0D + lineHeight: helpers_core.options.toLineHeight(valueOrDefault(options.li= neHeight, globalDefaults.defaultLineHeight), size),=0D + size: size,=0D + style: valueOrDefault(options.fontStyle, globalDefaults.defaultFontStyl= e),=0D + weight: null,=0D + string: ''=0D + };=0D +=0D + font.string =3D toFontString(font);=0D + return font;=0D + },=0D +=0D + /**=0D + * Evaluates the given `inputs` sequentially and returns the first define= d value.=0D + * @param {Array} inputs - An array of values, falling back to the last v= alue.=0D + * @param {object} [context] - If defined and the current value is a func= tion, the value=0D + * is called with `context` as first argument and the result becomes the = new input.=0D + * @param {number} [index] - If defined and the current value is an array= , the value=0D + * at `index` become the new input.=0D + * @param {object} [info] - object to return information about resolution= in=0D + * @param {boolean} [info.cacheable] - Will be set to `false` if option i= s not cacheable.=0D + * @since 2.7.0=0D + */=0D + resolve: function(inputs, context, index, info) {=0D + var cacheable =3D true;=0D + var i, ilen, value;=0D +=0D + for (i =3D 0, ilen =3D inputs.length; i < ilen; ++i) {=0D + value =3D inputs[i];=0D + if (value =3D=3D=3D undefined) {=0D + continue;=0D + }=0D + if (context !=3D=3D undefined && typeof value =3D=3D=3D 'function') {=0D + value =3D value(context);=0D + cacheable =3D false;=0D + }=0D + if (index !=3D=3D undefined && helpers_core.isArray(value)) {=0D + value =3D value[index];=0D + cacheable =3D false;=0D + }=0D + if (value !=3D=3D undefined) {=0D + if (info && !cacheable) {=0D + info.cacheable =3D false;=0D + }=0D + return value;=0D + }=0D + }=0D + }=0D +}; =20 - return null; - }, +/**=0D + * @alias Chart.helpers.math=0D + * @namespace=0D + */=0D +var exports$2 =3D {=0D + /**=0D + * Returns an array of factors sorted from 1 to sqrt(value)=0D + * @private=0D + */=0D + _factorize: function(value) {=0D + var result =3D [];=0D + var sqrt =3D Math.sqrt(value);=0D + var i;=0D +=0D + for (i =3D 1; i < sqrt; i++) {=0D + if (value % i =3D=3D=3D 0) {=0D + result.push(i);=0D + result.push(value / i);=0D + }=0D + }=0D + if (sqrt =3D=3D=3D (sqrt | 0)) { // if value is a square number=0D + result.push(sqrt);=0D + }=0D +=0D + result.sort(function(a, b) {=0D + return a - b;=0D + }).pop();=0D + return result;=0D + },=0D +=0D + log10: Math.log10 || function(x) {=0D + var exponent =3D Math.log(x) * Math.LOG10E; // Math.LOG10E =3D 1 / Math.= LN10.=0D + // Check for whole powers of 10,=0D + // which due to floating point rounding error should be corrected.=0D + var powerOf10 =3D Math.round(exponent);=0D + var isPowerOf10 =3D x =3D=3D=3D Math.pow(10, powerOf10);=0D +=0D + return isPowerOf10 ? powerOf10 : exponent;=0D + }=0D +};=0D +=0D +var helpers_math =3D exports$2;=0D +=0D +// DEPRECATIONS=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.helpers.math.log10 inste= ad.=0D + * @namespace Chart.helpers.log10=0D + * @deprecated since version 2.9.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers_core.log10 =3D exports$2.log10; =20 - /** - * Handle an event - * @private - * @param {IEvent} event - The event to handle - */ - handleEvent: function(e) { - var me =3D this; - var opts =3D me.options; - var type =3D e.type =3D=3D=3D 'mouseup' ? 'click' : e.type; - var hoveredItem; - - if (type =3D=3D=3D 'mousemove') { - if (!opts.onHover && !opts.onLeave) { - return; - } - } else if (type =3D=3D=3D 'click') { - if (!opts.onClick) { - return; - } - } else { - return; - } +var getRtlAdapter =3D function(rectX, width) {=0D + return {=0D + x: function(x) {=0D + return rectX + rectX + width - x;=0D + },=0D + setWidth: function(w) {=0D + width =3D w;=0D + },=0D + textAlign: function(align) {=0D + if (align =3D=3D=3D 'center') {=0D + return align;=0D + }=0D + return align =3D=3D=3D 'right' ? 'left' : 'right';=0D + },=0D + xPlus: function(x, value) {=0D + return x - value;=0D + },=0D + leftForLtr: function(x, itemWidth) {=0D + return x - itemWidth;=0D + },=0D + };=0D +};=0D +=0D +var getLtrAdapter =3D function() {=0D + return {=0D + x: function(x) {=0D + return x;=0D + },=0D + setWidth: function(w) { // eslint-disable-line no-unused-vars=0D + },=0D + textAlign: function(align) {=0D + return align;=0D + },=0D + xPlus: function(x, value) {=0D + return x + value;=0D + },=0D + leftForLtr: function(x, _itemWidth) { // eslint-disable-line no-unused-v= ars=0D + return x;=0D + },=0D + };=0D +};=0D +=0D +var getAdapter =3D function(rtl, rectX, width) {=0D + return rtl ? getRtlAdapter(rectX, width) : getLtrAdapter();=0D +};=0D +=0D +var overrideTextDirection =3D function(ctx, direction) {=0D + var style, original;=0D + if (direction =3D=3D=3D 'ltr' || direction =3D=3D=3D 'rtl') {=0D + style =3D ctx.canvas.style;=0D + original =3D [=0D + style.getPropertyValue('direction'),=0D + style.getPropertyPriority('direction'),=0D + ];=0D +=0D + style.setProperty('direction', direction, 'important');=0D + ctx.prevTextDirection =3D original;=0D + }=0D +};=0D +=0D +var restoreTextDirection =3D function(ctx) {=0D + var original =3D ctx.prevTextDirection;=0D + if (original !=3D=3D undefined) {=0D + delete ctx.prevTextDirection;=0D + ctx.canvas.style.setProperty('direction', original[0], original[1]);=0D + }=0D +};=0D +=0D +var helpers_rtl =3D {=0D + getRtlAdapter: getAdapter,=0D + overrideTextDirection: overrideTextDirection,=0D + restoreTextDirection: restoreTextDirection,=0D +}; =20 - // Chart event already has relative position in it - hoveredItem =3D me._getLegendItemAt(e.x, e.y); +var helpers$1 =3D helpers_core;=0D +var easing =3D helpers_easing;=0D +var canvas =3D helpers_canvas;=0D +var options =3D helpers_options;=0D +var math =3D helpers_math;=0D +var rtl =3D helpers_rtl; +helpers$1.easing =3D easing; +helpers$1.canvas =3D canvas; +helpers$1.options =3D options; +helpers$1.math =3D math; +helpers$1.rtl =3D rtl; =20 - if (type =3D=3D=3D 'click') { - if (hoveredItem && opts.onClick) { - // use e.native for backwards compatibility - opts.onClick.call(me, e.native, hoveredItem); - } - } else { - if (opts.onLeave && hoveredItem !=3D=3D me._hoveredItem) { - if (me._hoveredItem) { - opts.onLeave.call(me, e.native, me._hoveredItem); - } - me._hoveredItem =3D hoveredItem; - } +function interpolate(start, view, model, ease) {=0D + var keys =3D Object.keys(model);=0D + var i, ilen, key, actual, origin, target, type, c0, c1;=0D +=0D + for (i =3D 0, ilen =3D keys.length; i < ilen; ++i) {=0D + key =3D keys[i];=0D +=0D + target =3D model[key];=0D +=0D + // if a value is added to the model after pivot() has been called, the v= iew=0D + // doesn't contain it, so let's initialize the view to the target value.= =0D + if (!view.hasOwnProperty(key)) {=0D + view[key] =3D target;=0D + }=0D +=0D + actual =3D view[key];=0D +=0D + if (actual =3D=3D=3D target || key[0] =3D=3D=3D '_') {=0D + continue;=0D + }=0D +=0D + if (!start.hasOwnProperty(key)) {=0D + start[key] =3D actual;=0D + }=0D +=0D + origin =3D start[key];=0D +=0D + type =3D typeof target;=0D +=0D + if (type =3D=3D=3D typeof origin) {=0D + if (type =3D=3D=3D 'string') {=0D + c0 =3D chartjsColor(origin);=0D + if (c0.valid) {=0D + c1 =3D chartjsColor(target);=0D + if (c1.valid) {=0D + view[key] =3D c1.mix(c0, ease).rgbString();=0D + continue;=0D + }=0D + }=0D + } else if (helpers$1.isFinite(origin) && helpers$1.isFinite(target)) {= =0D + view[key] =3D origin + (target - origin) * ease;=0D + continue;=0D + }=0D + }=0D +=0D + view[key] =3D target;=0D + }=0D +}=0D +=0D +var Element =3D function(configuration) {=0D + helpers$1.extend(this, configuration);=0D + this.initialize.apply(this, arguments);=0D +};=0D +=0D +helpers$1.extend(Element.prototype, {=0D + _type: undefined,=0D +=0D + initialize: function() {=0D + this.hidden =3D false;=0D + },=0D +=0D + pivot: function() {=0D + var me =3D this;=0D + if (!me._view) {=0D + me._view =3D helpers$1.extend({}, me._model);=0D + }=0D + me._start =3D {};=0D + return me;=0D + },=0D +=0D + transition: function(ease) {=0D + var me =3D this;=0D + var model =3D me._model;=0D + var start =3D me._start;=0D + var view =3D me._view;=0D +=0D + // No animation -> No Transition=0D + if (!model || ease =3D=3D=3D 1) {=0D + me._view =3D helpers$1.extend({}, model);=0D + me._start =3D null;=0D + return me;=0D + }=0D +=0D + if (!view) {=0D + view =3D me._view =3D {};=0D + }=0D +=0D + if (!start) {=0D + start =3D me._start =3D {};=0D + }=0D +=0D + interpolate(start, view, model, ease);=0D +=0D + return me;=0D + },=0D +=0D + tooltipPosition: function() {=0D + return {=0D + x: this._model.x,=0D + y: this._model.y=0D + };=0D + },=0D +=0D + hasValue: function() {=0D + return helpers$1.isNumber(this._model.x) && helpers$1.isNumber(this._mod= el.y);=0D + }=0D +});=0D +=0D +Element.extend =3D helpers$1.inherits;=0D +=0D +var core_element =3D Element; =20 - if (opts.onHover && hoveredItem) { - // use e.native for backwards compatibility - opts.onHover.call(me, e.native, hoveredItem); - } - } - } +var exports$3 =3D core_element.extend({=0D + chart: null, // the animation associated chart instance=0D + currentStep: 0, // the current animation step=0D + numSteps: 60, // default number of steps=0D + easing: '', // the easing to use for this animation=0D + render: null, // render function used by the animation service=0D +=0D + onAnimationProgress: null, // user specified callback to fire on each ste= p of the animation=0D + onAnimationComplete: null, // user specified callback to fire when the an= imation finishes=0D +});=0D +=0D +var core_animation =3D exports$3;=0D +=0D +// DEPRECATIONS=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.Animation instead=0D + * @prop Chart.Animation#animationObject=0D + * @deprecated since version 2.6.0=0D + * @todo remove at version 3=0D + */=0D +Object.defineProperty(exports$3.prototype, 'animationObject', {=0D + get: function() {=0D + return this;=0D + }=0D +});=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.Animation#chart instead= =0D + * @prop Chart.Animation#chartInstance=0D + * @deprecated since version 2.6.0=0D + * @todo remove at version 3=0D + */=0D +Object.defineProperty(exports$3.prototype, 'chartInstance', {=0D + get: function() {=0D + return this.chart;=0D + },=0D + set: function(value) {=0D + this.chart =3D value;=0D + }=0D }); =20 -function createNewLegendAndAttach(chart, legendOpts) { - var legend =3D new Legend({ - ctx: chart.ctx, - options: legendOpts, - chart: chart - }); - - core_layouts.configure(chart, legend, legendOpts); - core_layouts.addBox(chart, legend); - chart.legend =3D legend; -} +core_defaults._set('global', {=0D + animation: {=0D + duration: 1000,=0D + easing: 'easeOutQuart',=0D + onProgress: helpers$1.noop,=0D + onComplete: helpers$1.noop=0D + }=0D +});=0D +=0D +var core_animations =3D {=0D + animations: [],=0D + request: null,=0D +=0D + /**=0D + * @param {Chart} chart - The chart to animate.=0D + * @param {Chart.Animation} animation - The animation that we will animat= e.=0D + * @param {number} duration - The animation duration in ms.=0D + * @param {boolean} lazy - if true, the chart is not marked as animating = to enable more responsive interactions=0D + */=0D + addAnimation: function(chart, animation, duration, lazy) {=0D + var animations =3D this.animations;=0D + var i, ilen;=0D +=0D + animation.chart =3D chart;=0D + animation.startTime =3D Date.now();=0D + animation.duration =3D duration;=0D +=0D + if (!lazy) {=0D + chart.animating =3D true;=0D + }=0D +=0D + for (i =3D 0, ilen =3D animations.length; i < ilen; ++i) {=0D + if (animations[i].chart =3D=3D=3D chart) {=0D + animations[i] =3D animation;=0D + return;=0D + }=0D + }=0D +=0D + animations.push(animation);=0D +=0D + // If there are no animations queued, manually kickstart a digest, for l= ack of a better word=0D + if (animations.length =3D=3D=3D 1) {=0D + this.requestAnimationFrame();=0D + }=0D + },=0D +=0D + cancelAnimation: function(chart) {=0D + var index =3D helpers$1.findIndex(this.animations, function(animation) {= =0D + return animation.chart =3D=3D=3D chart;=0D + });=0D +=0D + if (index !=3D=3D -1) {=0D + this.animations.splice(index, 1);=0D + chart.animating =3D false;=0D + }=0D + },=0D +=0D + requestAnimationFrame: function() {=0D + var me =3D this;=0D + if (me.request =3D=3D=3D null) {=0D + // Skip animation frame requests until the active one is executed.=0D + // This can happen when processing mouse events, e.g. 'mousemove'=0D + // and 'mouseout' events will trigger multiple renders.=0D + me.request =3D helpers$1.requestAnimFrame.call(window, function() {=0D + me.request =3D null;=0D + me.startDigest();=0D + });=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + startDigest: function() {=0D + var me =3D this;=0D +=0D + me.advance();=0D +=0D + // Do we have more stuff to animate?=0D + if (me.animations.length > 0) {=0D + me.requestAnimationFrame();=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + advance: function() {=0D + var animations =3D this.animations;=0D + var animation, chart, numSteps, nextStep;=0D + var i =3D 0;=0D +=0D + // 1 animation per chart, so we are looping charts here=0D + while (i < animations.length) {=0D + animation =3D animations[i];=0D + chart =3D animation.chart;=0D + numSteps =3D animation.numSteps;=0D +=0D + // Make sure that currentStep starts at 1=0D + // https://github.com/chartjs/Chart.js/issues/6104=0D + nextStep =3D Math.floor((Date.now() - animation.startTime) / animation.= duration * numSteps) + 1;=0D + animation.currentStep =3D Math.min(nextStep, numSteps);=0D +=0D + helpers$1.callback(animation.render, [chart, animation], chart);=0D + helpers$1.callback(animation.onAnimationProgress, [animation], chart);= =0D +=0D + if (animation.currentStep >=3D numSteps) {=0D + helpers$1.callback(animation.onAnimationComplete, [animation], chart);= =0D + chart.animating =3D false;=0D + animations.splice(i, 1);=0D + } else {=0D + ++i;=0D + }=0D + }=0D + }=0D +}; =20 -var plugin_legend =3D { - id: 'legend', +var resolve =3D helpers$1.options.resolve;=0D +=0D +var arrayEvents =3D ['push', 'pop', 'shift', 'splice', 'unshift'];=0D +=0D +/**=0D + * Hooks the array methods that add or remove values ('push', pop', 'shift= ', 'splice',=0D + * 'unshift') and notify the listener AFTER the array has been altered. Li= steners are=0D + * called on the 'onData*' callbacks (e.g. onDataPush, etc.) with same arg= uments.=0D + */=0D +function listenArrayEvents(array, listener) {=0D + if (array._chartjs) {=0D + array._chartjs.listeners.push(listener);=0D + return;=0D + }=0D +=0D + Object.defineProperty(array, '_chartjs', {=0D + configurable: true,=0D + enumerable: false,=0D + value: {=0D + listeners: [listener]=0D + }=0D + });=0D +=0D + arrayEvents.forEach(function(key) {=0D + var method =3D 'onData' + key.charAt(0).toUpperCase() + key.slice(1);=0D + var base =3D array[key];=0D +=0D + Object.defineProperty(array, key, {=0D + configurable: true,=0D + enumerable: false,=0D + value: function() {=0D + var args =3D Array.prototype.slice.call(arguments);=0D + var res =3D base.apply(this, args);=0D +=0D + helpers$1.each(array._chartjs.listeners, function(object) {=0D + if (typeof object[method] =3D=3D=3D 'function') {=0D + object[method].apply(object, args);=0D + }=0D + });=0D +=0D + return res;=0D + }=0D + });=0D + });=0D +}=0D +=0D +/**=0D + * Removes the given array event listener and cleanup extra attached prope= rties (such as=0D + * the _chartjs stub and overridden methods) if array doesn't have any mor= e listeners.=0D + */=0D +function unlistenArrayEvents(array, listener) {=0D + var stub =3D array._chartjs;=0D + if (!stub) {=0D + return;=0D + }=0D +=0D + var listeners =3D stub.listeners;=0D + var index =3D listeners.indexOf(listener);=0D + if (index !=3D=3D -1) {=0D + listeners.splice(index, 1);=0D + }=0D +=0D + if (listeners.length > 0) {=0D + return;=0D + }=0D +=0D + arrayEvents.forEach(function(key) {=0D + delete array[key];=0D + });=0D +=0D + delete array._chartjs;=0D +}=0D +=0D +// Base class for all dataset controllers (line, bar, etc)=0D +var DatasetController =3D function(chart, datasetIndex) {=0D + this.initialize(chart, datasetIndex);=0D +};=0D +=0D +helpers$1.extend(DatasetController.prototype, {=0D +=0D + /**=0D + * Element type used to generate a meta dataset (e.g. Chart.element.Line)= .=0D + * @type {Chart.core.element}=0D + */=0D + datasetElementType: null,=0D +=0D + /**=0D + * Element type used to generate a meta data (e.g. Chart.element.Point).= =0D + * @type {Chart.core.element}=0D + */=0D + dataElementType: null,=0D +=0D + /**=0D + * Dataset element option keys to be resolved in _resolveDatasetElementOp= tions.=0D + * A derived controller may override this to resolve controller-specific = options.=0D + * The keys defined here are for backward compatibility for legend styles= .=0D + * @private=0D + */=0D + _datasetElementOptions: [=0D + 'backgroundColor',=0D + 'borderCapStyle',=0D + 'borderColor',=0D + 'borderDash',=0D + 'borderDashOffset',=0D + 'borderJoinStyle',=0D + 'borderWidth'=0D + ],=0D +=0D + /**=0D + * Data element option keys to be resolved in _resolveDataElementOptions.= =0D + * A derived controller may override this to resolve controller-specific = options.=0D + * The keys defined here are for backward compatibility for legend styles= .=0D + * @private=0D + */=0D + _dataElementOptions: [=0D + 'backgroundColor',=0D + 'borderColor',=0D + 'borderWidth',=0D + 'pointStyle'=0D + ],=0D +=0D + initialize: function(chart, datasetIndex) {=0D + var me =3D this;=0D + me.chart =3D chart;=0D + me.index =3D datasetIndex;=0D + me.linkScales();=0D + me.addElements();=0D + me._type =3D me.getMeta().type;=0D + },=0D +=0D + updateIndex: function(datasetIndex) {=0D + this.index =3D datasetIndex;=0D + },=0D +=0D + linkScales: function() {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var chart =3D me.chart;=0D + var scales =3D chart.scales;=0D + var dataset =3D me.getDataset();=0D + var scalesOpts =3D chart.options.scales;=0D +=0D + if (meta.xAxisID =3D=3D=3D null || !(meta.xAxisID in scales) || dataset.= xAxisID) {=0D + meta.xAxisID =3D dataset.xAxisID || scalesOpts.xAxes[0].id;=0D + }=0D + if (meta.yAxisID =3D=3D=3D null || !(meta.yAxisID in scales) || dataset.= yAxisID) {=0D + meta.yAxisID =3D dataset.yAxisID || scalesOpts.yAxes[0].id;=0D + }=0D + },=0D +=0D + getDataset: function() {=0D + return this.chart.data.datasets[this.index];=0D + },=0D +=0D + getMeta: function() {=0D + return this.chart.getDatasetMeta(this.index);=0D + },=0D +=0D + getScaleForId: function(scaleID) {=0D + return this.chart.scales[scaleID];=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getValueScaleId: function() {=0D + return this.getMeta().yAxisID;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getIndexScaleId: function() {=0D + return this.getMeta().xAxisID;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getValueScale: function() {=0D + return this.getScaleForId(this._getValueScaleId());=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getIndexScale: function() {=0D + return this.getScaleForId(this._getIndexScaleId());=0D + },=0D +=0D + reset: function() {=0D + this._update(true);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + destroy: function() {=0D + if (this._data) {=0D + unlistenArrayEvents(this._data, this);=0D + }=0D + },=0D +=0D + createMetaDataset: function() {=0D + var me =3D this;=0D + var type =3D me.datasetElementType;=0D + return type && new type({=0D + _chart: me.chart,=0D + _datasetIndex: me.index=0D + });=0D + },=0D +=0D + createMetaData: function(index) {=0D + var me =3D this;=0D + var type =3D me.dataElementType;=0D + return type && new type({=0D + _chart: me.chart,=0D + _datasetIndex: me.index,=0D + _index: index=0D + });=0D + },=0D +=0D + addElements: function() {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var data =3D me.getDataset().data || [];=0D + var metaData =3D meta.data;=0D + var i, ilen;=0D +=0D + for (i =3D 0, ilen =3D data.length; i < ilen; ++i) {=0D + metaData[i] =3D metaData[i] || me.createMetaData(i);=0D + }=0D +=0D + meta.dataset =3D meta.dataset || me.createMetaDataset();=0D + },=0D +=0D + addElementAndReset: function(index) {=0D + var element =3D this.createMetaData(index);=0D + this.getMeta().data.splice(index, 0, element);=0D + this.updateElement(element, index, true);=0D + },=0D +=0D + buildOrUpdateElements: function() {=0D + var me =3D this;=0D + var dataset =3D me.getDataset();=0D + var data =3D dataset.data || (dataset.data =3D []);=0D +=0D + // In order to correctly handle data addition/deletion animation (an thu= s simulate=0D + // real-time charts), we need to monitor these data modifications and sy= nchronize=0D + // the internal meta data accordingly.=0D + if (me._data !=3D=3D data) {=0D + if (me._data) {=0D + // This case happens when the user replaced the data array instance.=0D + unlistenArrayEvents(me._data, me);=0D + }=0D +=0D + if (data && Object.isExtensible(data)) {=0D + listenArrayEvents(data, me);=0D + }=0D + me._data =3D data;=0D + }=0D +=0D + // Re-sync meta data in case the user replaced the data array or if we m= issed=0D + // any updates and so make sure that we handle number of datapoints chan= ging.=0D + me.resyncElements();=0D + },=0D +=0D + /**=0D + * Returns the merged user-supplied and default dataset-level options=0D + * @private=0D + */=0D + _configure: function() {=0D + var me =3D this;=0D + me._config =3D helpers$1.merge(Object.create(null), [=0D + me.chart.options.datasets[me._type],=0D + me.getDataset(),=0D + ], {=0D + merger: function(key, target, source) {=0D + if (key !=3D=3D '_meta' && key !=3D=3D 'data') {=0D + helpers$1._merger(key, target, source);=0D + }=0D + }=0D + });=0D + },=0D +=0D + _update: function(reset) {=0D + var me =3D this;=0D + me._configure();=0D + me._cachedDataOpts =3D null;=0D + me.update(reset);=0D + },=0D +=0D + update: helpers$1.noop,=0D +=0D + transition: function(easingValue) {=0D + var meta =3D this.getMeta();=0D + var elements =3D meta.data || [];=0D + var ilen =3D elements.length;=0D + var i =3D 0;=0D +=0D + for (; i < ilen; ++i) {=0D + elements[i].transition(easingValue);=0D + }=0D +=0D + if (meta.dataset) {=0D + meta.dataset.transition(easingValue);=0D + }=0D + },=0D +=0D + draw: function() {=0D + var meta =3D this.getMeta();=0D + var elements =3D meta.data || [];=0D + var ilen =3D elements.length;=0D + var i =3D 0;=0D +=0D + if (meta.dataset) {=0D + meta.dataset.draw();=0D + }=0D +=0D + for (; i < ilen; ++i) {=0D + elements[i].draw();=0D + }=0D + },=0D +=0D + /**=0D + * Returns a set of predefined style properties that should be used to re= present the dataset=0D + * or the data if the index is specified=0D + * @param {number} index - data index=0D + * @return {IStyleInterface} style object=0D + */=0D + getStyle: function(index) {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var dataset =3D meta.dataset;=0D + var style;=0D +=0D + me._configure();=0D + if (dataset && index =3D=3D=3D undefined) {=0D + style =3D me._resolveDatasetElementOptions(dataset || {});=0D + } else {=0D + index =3D index || 0;=0D + style =3D me._resolveDataElementOptions(meta.data[index] || {}, index);= =0D + }=0D +=0D + if (style.fill =3D=3D=3D false || style.fill =3D=3D=3D null) {=0D + style.backgroundColor =3D style.borderColor;=0D + }=0D +=0D + return style;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _resolveDatasetElementOptions: function(element, hover) {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var datasetOpts =3D me._config;=0D + var custom =3D element.custom || {};=0D + var options =3D chart.options.elements[me.datasetElementType.prototype._= type] || {};=0D + var elementOptions =3D me._datasetElementOptions;=0D + var values =3D {};=0D + var i, ilen, key, readKey;=0D +=0D + // Scriptable options=0D + var context =3D {=0D + chart: chart,=0D + dataset: me.getDataset(),=0D + datasetIndex: me.index,=0D + hover: hover=0D + };=0D +=0D + for (i =3D 0, ilen =3D elementOptions.length; i < ilen; ++i) {=0D + key =3D elementOptions[i];=0D + readKey =3D hover ? 'hover' + key.charAt(0).toUpperCase() + key.slice(1= ) : key;=0D + values[key] =3D resolve([=0D + custom[readKey],=0D + datasetOpts[readKey],=0D + options[readKey]=0D + ], context);=0D + }=0D +=0D + return values;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _resolveDataElementOptions: function(element, index) {=0D + var me =3D this;=0D + var custom =3D element && element.custom;=0D + var cached =3D me._cachedDataOpts;=0D + if (cached && !custom) {=0D + return cached;=0D + }=0D + var chart =3D me.chart;=0D + var datasetOpts =3D me._config;=0D + var options =3D chart.options.elements[me.dataElementType.prototype._typ= e] || {};=0D + var elementOptions =3D me._dataElementOptions;=0D + var values =3D {};=0D +=0D + // Scriptable options=0D + var context =3D {=0D + chart: chart,=0D + dataIndex: index,=0D + dataset: me.getDataset(),=0D + datasetIndex: me.index=0D + };=0D +=0D + // `resolve` sets cacheable to `false` if any option is indexed or scrip= ted=0D + var info =3D {cacheable: !custom};=0D +=0D + var keys, i, ilen, key;=0D +=0D + custom =3D custom || {};=0D +=0D + if (helpers$1.isArray(elementOptions)) {=0D + for (i =3D 0, ilen =3D elementOptions.length; i < ilen; ++i) {=0D + key =3D elementOptions[i];=0D + values[key] =3D resolve([=0D + custom[key],=0D + datasetOpts[key],=0D + options[key]=0D + ], context, index, info);=0D + }=0D + } else {=0D + keys =3D Object.keys(elementOptions);=0D + for (i =3D 0, ilen =3D keys.length; i < ilen; ++i) {=0D + key =3D keys[i];=0D + values[key] =3D resolve([=0D + custom[key],=0D + datasetOpts[elementOptions[key]],=0D + datasetOpts[key],=0D + options[key]=0D + ], context, index, info);=0D + }=0D + }=0D +=0D + if (info.cacheable) {=0D + me._cachedDataOpts =3D Object.freeze(values);=0D + }=0D +=0D + return values;=0D + },=0D +=0D + removeHoverStyle: function(element) {=0D + helpers$1.merge(element._model, element.$previousStyle || {});=0D + delete element.$previousStyle;=0D + },=0D +=0D + setHoverStyle: function(element) {=0D + var dataset =3D this.chart.data.datasets[element._datasetIndex];=0D + var index =3D element._index;=0D + var custom =3D element.custom || {};=0D + var model =3D element._model;=0D + var getHoverColor =3D helpers$1.getHoverColor;=0D +=0D + element.$previousStyle =3D {=0D + backgroundColor: model.backgroundColor,=0D + borderColor: model.borderColor,=0D + borderWidth: model.borderWidth=0D + };=0D +=0D + model.backgroundColor =3D resolve([custom.hoverBackgroundColor, dataset.= hoverBackgroundColor, getHoverColor(model.backgroundColor)], undefined, ind= ex);=0D + model.borderColor =3D resolve([custom.hoverBorderColor, dataset.hoverBor= derColor, getHoverColor(model.borderColor)], undefined, index);=0D + model.borderWidth =3D resolve([custom.hoverBorderWidth, dataset.hoverBor= derWidth, model.borderWidth], undefined, index);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _removeDatasetHoverStyle: function() {=0D + var element =3D this.getMeta().dataset;=0D +=0D + if (element) {=0D + this.removeHoverStyle(element);=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _setDatasetHoverStyle: function() {=0D + var element =3D this.getMeta().dataset;=0D + var prev =3D {};=0D + var i, ilen, key, keys, hoverOptions, model;=0D +=0D + if (!element) {=0D + return;=0D + }=0D +=0D + model =3D element._model;=0D + hoverOptions =3D this._resolveDatasetElementOptions(element, true);=0D +=0D + keys =3D Object.keys(hoverOptions);=0D + for (i =3D 0, ilen =3D keys.length; i < ilen; ++i) {=0D + key =3D keys[i];=0D + prev[key] =3D model[key];=0D + model[key] =3D hoverOptions[key];=0D + }=0D +=0D + element.$previousStyle =3D prev;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + resyncElements: function() {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var data =3D me.getDataset().data;=0D + var numMeta =3D meta.data.length;=0D + var numData =3D data.length;=0D +=0D + if (numData < numMeta) {=0D + meta.data.splice(numData, numMeta - numData);=0D + } else if (numData > numMeta) {=0D + me.insertElements(numMeta, numData - numMeta);=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + insertElements: function(start, count) {=0D + for (var i =3D 0; i < count; ++i) {=0D + this.addElementAndReset(start + i);=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + onDataPush: function() {=0D + var count =3D arguments.length;=0D + this.insertElements(this.getDataset().data.length - count, count);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + onDataPop: function() {=0D + this.getMeta().data.pop();=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + onDataShift: function() {=0D + this.getMeta().data.shift();=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + onDataSplice: function(start, count) {=0D + this.getMeta().data.splice(start, count);=0D + this.insertElements(start, arguments.length - 2);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + onDataUnshift: function() {=0D + this.insertElements(0, arguments.length);=0D + }=0D +});=0D +=0D +DatasetController.extend =3D helpers$1.inherits;=0D +=0D +var core_datasetController =3D DatasetController; =20 - /** - * Backward compatibility: since 2.1.5, the legend is registered as a plu= gin, making - * Chart.Legend obsolete. To avoid a breaking change, we export the Legen= d as part of - * the plugin, which one will be re-exposed in the chart.js file. - * https://github.com/chartjs/Chart.js/pull/2640 - * @private - */ - _element: Legend, +var TAU =3D Math.PI * 2;=0D +=0D +core_defaults._set('global', {=0D + elements: {=0D + arc: {=0D + backgroundColor: core_defaults.global.defaultColor,=0D + borderColor: '#fff',=0D + borderWidth: 2,=0D + borderAlign: 'center'=0D + }=0D + }=0D +});=0D +=0D +function clipArc(ctx, arc) {=0D + var startAngle =3D arc.startAngle;=0D + var endAngle =3D arc.endAngle;=0D + var pixelMargin =3D arc.pixelMargin;=0D + var angleMargin =3D pixelMargin / arc.outerRadius;=0D + var x =3D arc.x;=0D + var y =3D arc.y;=0D +=0D + // Draw an inner border by cliping the arc and drawing a double-width bor= der=0D + // Enlarge the clipping arc by 0.33 pixels to eliminate glitches between = borders=0D + ctx.beginPath();=0D + ctx.arc(x, y, arc.outerRadius, startAngle - angleMargin, endAngle + angle= Margin);=0D + if (arc.innerRadius > pixelMargin) {=0D + angleMargin =3D pixelMargin / arc.innerRadius;=0D + ctx.arc(x, y, arc.innerRadius - pixelMargin, endAngle + angleMargin, sta= rtAngle - angleMargin, true);=0D + } else {=0D + ctx.arc(x, y, pixelMargin, endAngle + Math.PI / 2, startAngle - Math.PI = / 2);=0D + }=0D + ctx.closePath();=0D + ctx.clip();=0D +}=0D +=0D +function drawFullCircleBorders(ctx, vm, arc, inner) {=0D + var endAngle =3D arc.endAngle;=0D + var i;=0D +=0D + if (inner) {=0D + arc.endAngle =3D arc.startAngle + TAU;=0D + clipArc(ctx, arc);=0D + arc.endAngle =3D endAngle;=0D + if (arc.endAngle =3D=3D=3D arc.startAngle && arc.fullCircles) {=0D + arc.endAngle +=3D TAU;=0D + arc.fullCircles--;=0D + }=0D + }=0D +=0D + ctx.beginPath();=0D + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.startAngle + TAU, arc.startAng= le, true);=0D + for (i =3D 0; i < arc.fullCircles; ++i) {=0D + ctx.stroke();=0D + }=0D +=0D + ctx.beginPath();=0D + ctx.arc(arc.x, arc.y, vm.outerRadius, arc.startAngle, arc.startAngle + TA= U);=0D + for (i =3D 0; i < arc.fullCircles; ++i) {=0D + ctx.stroke();=0D + }=0D +}=0D +=0D +function drawBorder(ctx, vm, arc) {=0D + var inner =3D vm.borderAlign =3D=3D=3D 'inner';=0D +=0D + if (inner) {=0D + ctx.lineWidth =3D vm.borderWidth * 2;=0D + ctx.lineJoin =3D 'round';=0D + } else {=0D + ctx.lineWidth =3D vm.borderWidth;=0D + ctx.lineJoin =3D 'bevel';=0D + }=0D +=0D + if (arc.fullCircles) {=0D + drawFullCircleBorders(ctx, vm, arc, inner);=0D + }=0D +=0D + if (inner) {=0D + clipArc(ctx, arc);=0D + }=0D +=0D + ctx.beginPath();=0D + ctx.arc(arc.x, arc.y, vm.outerRadius, arc.startAngle, arc.endAngle);=0D + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, true= );=0D + ctx.closePath();=0D + ctx.stroke();=0D +}=0D +=0D +var element_arc =3D core_element.extend({=0D + _type: 'arc',=0D +=0D + inLabelRange: function(mouseX) {=0D + var vm =3D this._view;=0D +=0D + if (vm) {=0D + return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadiu= s, 2));=0D + }=0D + return false;=0D + },=0D +=0D + inRange: function(chartX, chartY) {=0D + var vm =3D this._view;=0D +=0D + if (vm) {=0D + var pointRelativePosition =3D helpers$1.getAngleFromPoint(vm, {x: chart= X, y: chartY});=0D + var angle =3D pointRelativePosition.angle;=0D + var distance =3D pointRelativePosition.distance;=0D +=0D + // Sanitise angle range=0D + var startAngle =3D vm.startAngle;=0D + var endAngle =3D vm.endAngle;=0D + while (endAngle < startAngle) {=0D + endAngle +=3D TAU;=0D + }=0D + while (angle > endAngle) {=0D + angle -=3D TAU;=0D + }=0D + while (angle < startAngle) {=0D + angle +=3D TAU;=0D + }=0D +=0D + // Check if within the range of the open/close angle=0D + var betweenAngles =3D (angle >=3D startAngle && angle <=3D endAngle);=0D + var withinRadius =3D (distance >=3D vm.innerRadius && distance <=3D vm.= outerRadius);=0D +=0D + return (betweenAngles && withinRadius);=0D + }=0D + return false;=0D + },=0D +=0D + getCenterPoint: function() {=0D + var vm =3D this._view;=0D + var halfAngle =3D (vm.startAngle + vm.endAngle) / 2;=0D + var halfRadius =3D (vm.innerRadius + vm.outerRadius) / 2;=0D + return {=0D + x: vm.x + Math.cos(halfAngle) * halfRadius,=0D + y: vm.y + Math.sin(halfAngle) * halfRadius=0D + };=0D + },=0D +=0D + getArea: function() {=0D + var vm =3D this._view;=0D + return Math.PI * ((vm.endAngle - vm.startAngle) / (2 * Math.PI)) * (Math= .pow(vm.outerRadius, 2) - Math.pow(vm.innerRadius, 2));=0D + },=0D +=0D + tooltipPosition: function() {=0D + var vm =3D this._view;=0D + var centreAngle =3D vm.startAngle + ((vm.endAngle - vm.startAngle) / 2);= =0D + var rangeFromCentre =3D (vm.outerRadius - vm.innerRadius) / 2 + vm.inner= Radius;=0D +=0D + return {=0D + x: vm.x + (Math.cos(centreAngle) * rangeFromCentre),=0D + y: vm.y + (Math.sin(centreAngle) * rangeFromCentre)=0D + };=0D + },=0D +=0D + draw: function() {=0D + var ctx =3D this._chart.ctx;=0D + var vm =3D this._view;=0D + var pixelMargin =3D (vm.borderAlign =3D=3D=3D 'inner') ? 0.33 : 0;=0D + var arc =3D {=0D + x: vm.x,=0D + y: vm.y,=0D + innerRadius: vm.innerRadius,=0D + outerRadius: Math.max(vm.outerRadius - pixelMargin, 0),=0D + pixelMargin: pixelMargin,=0D + startAngle: vm.startAngle,=0D + endAngle: vm.endAngle,=0D + fullCircles: Math.floor(vm.circumference / TAU)=0D + };=0D + var i;=0D +=0D + ctx.save();=0D +=0D + ctx.fillStyle =3D vm.backgroundColor;=0D + ctx.strokeStyle =3D vm.borderColor;=0D +=0D + if (arc.fullCircles) {=0D + arc.endAngle =3D arc.startAngle + TAU;=0D + ctx.beginPath();=0D + ctx.arc(arc.x, arc.y, arc.outerRadius, arc.startAngle, arc.endAngle);=0D + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, tr= ue);=0D + ctx.closePath();=0D + for (i =3D 0; i < arc.fullCircles; ++i) {=0D + ctx.fill();=0D + }=0D + arc.endAngle =3D arc.startAngle + vm.circumference % TAU;=0D + }=0D +=0D + ctx.beginPath();=0D + ctx.arc(arc.x, arc.y, arc.outerRadius, arc.startAngle, arc.endAngle);=0D + ctx.arc(arc.x, arc.y, arc.innerRadius, arc.endAngle, arc.startAngle, tru= e);=0D + ctx.closePath();=0D + ctx.fill();=0D +=0D + if (vm.borderWidth) {=0D + drawBorder(ctx, vm, arc);=0D + }=0D +=0D + ctx.restore();=0D + }=0D +}); =20 - beforeInit: function(chart) { - var legendOpts =3D chart.options.legend; +var valueOrDefault$1 =3D helpers$1.valueOrDefault;=0D +=0D +var defaultColor =3D core_defaults.global.defaultColor;=0D +=0D +core_defaults._set('global', {=0D + elements: {=0D + line: {=0D + tension: 0.4,=0D + backgroundColor: defaultColor,=0D + borderWidth: 3,=0D + borderColor: defaultColor,=0D + borderCapStyle: 'butt',=0D + borderDash: [],=0D + borderDashOffset: 0.0,=0D + borderJoinStyle: 'miter',=0D + capBezierPoints: true,=0D + fill: true, // do we fill in the area between the line and its base axi= s=0D + }=0D + }=0D +});=0D +=0D +var element_line =3D core_element.extend({=0D + _type: 'line',=0D +=0D + draw: function() {=0D + var me =3D this;=0D + var vm =3D me._view;=0D + var ctx =3D me._chart.ctx;=0D + var spanGaps =3D vm.spanGaps;=0D + var points =3D me._children.slice(); // clone array=0D + var globalDefaults =3D core_defaults.global;=0D + var globalOptionLineElements =3D globalDefaults.elements.line;=0D + var lastDrawnIndex =3D -1;=0D + var closePath =3D me._loop;=0D + var index, previous, currentVM;=0D +=0D + if (!points.length) {=0D + return;=0D + }=0D +=0D + if (me._loop) {=0D + for (index =3D 0; index < points.length; ++index) {=0D + previous =3D helpers$1.previousItem(points, index);=0D + // If the line has an open path, shift the point array=0D + if (!points[index]._view.skip && previous._view.skip) {=0D + points =3D points.slice(index).concat(points.slice(0, index));=0D + closePath =3D spanGaps;=0D + break;=0D + }=0D + }=0D + // If the line has a close path, add the first point again=0D + if (closePath) {=0D + points.push(points[0]);=0D + }=0D + }=0D +=0D + ctx.save();=0D +=0D + // Stroke Line Options=0D + ctx.lineCap =3D vm.borderCapStyle || globalOptionLineElements.borderCapS= tyle;=0D +=0D + // IE 9 and 10 do not support line dash=0D + if (ctx.setLineDash) {=0D + ctx.setLineDash(vm.borderDash || globalOptionLineElements.borderDash);= =0D + }=0D +=0D + ctx.lineDashOffset =3D valueOrDefault$1(vm.borderDashOffset, globalOptio= nLineElements.borderDashOffset);=0D + ctx.lineJoin =3D vm.borderJoinStyle || globalOptionLineElements.borderJo= inStyle;=0D + ctx.lineWidth =3D valueOrDefault$1(vm.borderWidth, globalOptionLineEleme= nts.borderWidth);=0D + ctx.strokeStyle =3D vm.borderColor || globalDefaults.defaultColor;=0D +=0D + // Stroke Line=0D + ctx.beginPath();=0D +=0D + // First point moves to it's starting position no matter what=0D + currentVM =3D points[0]._view;=0D + if (!currentVM.skip) {=0D + ctx.moveTo(currentVM.x, currentVM.y);=0D + lastDrawnIndex =3D 0;=0D + }=0D +=0D + for (index =3D 1; index < points.length; ++index) {=0D + currentVM =3D points[index]._view;=0D + previous =3D lastDrawnIndex =3D=3D=3D -1 ? helpers$1.previousItem(point= s, index) : points[lastDrawnIndex];=0D +=0D + if (!currentVM.skip) {=0D + if ((lastDrawnIndex !=3D=3D (index - 1) && !spanGaps) || lastDrawnInde= x =3D=3D=3D -1) {=0D + // There was a gap and this is the first point after the gap=0D + ctx.moveTo(currentVM.x, currentVM.y);=0D + } else {=0D + // Line to next point=0D + helpers$1.canvas.lineTo(ctx, previous._view, currentVM);=0D + }=0D + lastDrawnIndex =3D index;=0D + }=0D + }=0D +=0D + if (closePath) {=0D + ctx.closePath();=0D + }=0D +=0D + ctx.stroke();=0D + ctx.restore();=0D + }=0D +}); =20 - if (legendOpts) { - createNewLegendAndAttach(chart, legendOpts); - } - }, +var valueOrDefault$2 =3D helpers$1.valueOrDefault;=0D +=0D +var defaultColor$1 =3D core_defaults.global.defaultColor;=0D +=0D +core_defaults._set('global', {=0D + elements: {=0D + point: {=0D + radius: 3,=0D + pointStyle: 'circle',=0D + backgroundColor: defaultColor$1,=0D + borderColor: defaultColor$1,=0D + borderWidth: 1,=0D + // Hover=0D + hitRadius: 1,=0D + hoverRadius: 4,=0D + hoverBorderWidth: 1=0D + }=0D + }=0D +});=0D +=0D +function xRange(mouseX) {=0D + var vm =3D this._view;=0D + return vm ? (Math.abs(mouseX - vm.x) < vm.radius + vm.hitRadius) : false;= =0D +}=0D +=0D +function yRange(mouseY) {=0D + var vm =3D this._view;=0D + return vm ? (Math.abs(mouseY - vm.y) < vm.radius + vm.hitRadius) : false;= =0D +}=0D +=0D +var element_point =3D core_element.extend({=0D + _type: 'point',=0D +=0D + inRange: function(mouseX, mouseY) {=0D + var vm =3D this._view;=0D + return vm ? ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) <= Math.pow(vm.hitRadius + vm.radius, 2)) : false;=0D + },=0D +=0D + inLabelRange: xRange,=0D + inXRange: xRange,=0D + inYRange: yRange,=0D +=0D + getCenterPoint: function() {=0D + var vm =3D this._view;=0D + return {=0D + x: vm.x,=0D + y: vm.y=0D + };=0D + },=0D +=0D + getArea: function() {=0D + return Math.PI * Math.pow(this._view.radius, 2);=0D + },=0D +=0D + tooltipPosition: function() {=0D + var vm =3D this._view;=0D + return {=0D + x: vm.x,=0D + y: vm.y,=0D + padding: vm.radius + vm.borderWidth=0D + };=0D + },=0D +=0D + draw: function(chartArea) {=0D + var vm =3D this._view;=0D + var ctx =3D this._chart.ctx;=0D + var pointStyle =3D vm.pointStyle;=0D + var rotation =3D vm.rotation;=0D + var radius =3D vm.radius;=0D + var x =3D vm.x;=0D + var y =3D vm.y;=0D + var globalDefaults =3D core_defaults.global;=0D + var defaultColor =3D globalDefaults.defaultColor; // eslint-disable-line= no-shadow=0D +=0D + if (vm.skip) {=0D + return;=0D + }=0D +=0D + // Clipping for Points.=0D + if (chartArea =3D=3D=3D undefined || helpers$1.canvas._isPointInArea(vm,= chartArea)) {=0D + ctx.strokeStyle =3D vm.borderColor || defaultColor;=0D + ctx.lineWidth =3D valueOrDefault$2(vm.borderWidth, globalDefaults.eleme= nts.point.borderWidth);=0D + ctx.fillStyle =3D vm.backgroundColor || defaultColor;=0D + helpers$1.canvas.drawPoint(ctx, pointStyle, radius, x, y, rotation);=0D + }=0D + }=0D +}); =20 - beforeUpdate: function(chart) { - var legendOpts =3D chart.options.legend; - var legend =3D chart.legend; +var defaultColor$2 =3D core_defaults.global.defaultColor;=0D +=0D +core_defaults._set('global', {=0D + elements: {=0D + rectangle: {=0D + backgroundColor: defaultColor$2,=0D + borderColor: defaultColor$2,=0D + borderSkipped: 'bottom',=0D + borderWidth: 0=0D + }=0D + }=0D +});=0D +=0D +function isVertical(vm) {=0D + return vm && vm.width !=3D=3D undefined;=0D +}=0D +=0D +/**=0D + * Helper function to get the bounds of the bar regardless of the orientat= ion=0D + * @param bar {Chart.Element.Rectangle} the bar=0D + * @return {Bounds} bounds of the bar=0D + * @private=0D + */=0D +function getBarBounds(vm) {=0D + var x1, x2, y1, y2, half;=0D +=0D + if (isVertical(vm)) {=0D + half =3D vm.width / 2;=0D + x1 =3D vm.x - half;=0D + x2 =3D vm.x + half;=0D + y1 =3D Math.min(vm.y, vm.base);=0D + y2 =3D Math.max(vm.y, vm.base);=0D + } else {=0D + half =3D vm.height / 2;=0D + x1 =3D Math.min(vm.x, vm.base);=0D + x2 =3D Math.max(vm.x, vm.base);=0D + y1 =3D vm.y - half;=0D + y2 =3D vm.y + half;=0D + }=0D +=0D + return {=0D + left: x1,=0D + top: y1,=0D + right: x2,=0D + bottom: y2=0D + };=0D +}=0D +=0D +function swap(orig, v1, v2) {=0D + return orig =3D=3D=3D v1 ? v2 : orig =3D=3D=3D v2 ? v1 : orig;=0D +}=0D +=0D +function parseBorderSkipped(vm) {=0D + var edge =3D vm.borderSkipped;=0D + var res =3D {};=0D +=0D + if (!edge) {=0D + return res;=0D + }=0D +=0D + if (vm.horizontal) {=0D + if (vm.base > vm.x) {=0D + edge =3D swap(edge, 'left', 'right');=0D + }=0D + } else if (vm.base < vm.y) {=0D + edge =3D swap(edge, 'bottom', 'top');=0D + }=0D +=0D + res[edge] =3D true;=0D + return res;=0D +}=0D +=0D +function parseBorderWidth(vm, maxW, maxH) {=0D + var value =3D vm.borderWidth;=0D + var skip =3D parseBorderSkipped(vm);=0D + var t, r, b, l;=0D +=0D + if (helpers$1.isObject(value)) {=0D + t =3D +value.top || 0;=0D + r =3D +value.right || 0;=0D + b =3D +value.bottom || 0;=0D + l =3D +value.left || 0;=0D + } else {=0D + t =3D r =3D b =3D l =3D +value || 0;=0D + }=0D +=0D + return {=0D + t: skip.top || (t < 0) ? 0 : t > maxH ? maxH : t,=0D + r: skip.right || (r < 0) ? 0 : r > maxW ? maxW : r,=0D + b: skip.bottom || (b < 0) ? 0 : b > maxH ? maxH : b,=0D + l: skip.left || (l < 0) ? 0 : l > maxW ? maxW : l=0D + };=0D +}=0D +=0D +function boundingRects(vm) {=0D + var bounds =3D getBarBounds(vm);=0D + var width =3D bounds.right - bounds.left;=0D + var height =3D bounds.bottom - bounds.top;=0D + var border =3D parseBorderWidth(vm, width / 2, height / 2);=0D +=0D + return {=0D + outer: {=0D + x: bounds.left,=0D + y: bounds.top,=0D + w: width,=0D + h: height=0D + },=0D + inner: {=0D + x: bounds.left + border.l,=0D + y: bounds.top + border.t,=0D + w: width - border.l - border.r,=0D + h: height - border.t - border.b=0D + }=0D + };=0D +}=0D +=0D +function inRange(vm, x, y) {=0D + var skipX =3D x =3D=3D=3D null;=0D + var skipY =3D y =3D=3D=3D null;=0D + var bounds =3D !vm || (skipX && skipY) ? false : getBarBounds(vm);=0D +=0D + return bounds=0D + && (skipX || x >=3D bounds.left && x <=3D bounds.right)=0D + && (skipY || y >=3D bounds.top && y <=3D bounds.bottom);=0D +}=0D +=0D +var element_rectangle =3D core_element.extend({=0D + _type: 'rectangle',=0D +=0D + draw: function() {=0D + var ctx =3D this._chart.ctx;=0D + var vm =3D this._view;=0D + var rects =3D boundingRects(vm);=0D + var outer =3D rects.outer;=0D + var inner =3D rects.inner;=0D +=0D + ctx.fillStyle =3D vm.backgroundColor;=0D + ctx.fillRect(outer.x, outer.y, outer.w, outer.h);=0D +=0D + if (outer.w =3D=3D=3D inner.w && outer.h =3D=3D=3D inner.h) {=0D + return;=0D + }=0D +=0D + ctx.save();=0D + ctx.beginPath();=0D + ctx.rect(outer.x, outer.y, outer.w, outer.h);=0D + ctx.clip();=0D + ctx.fillStyle =3D vm.borderColor;=0D + ctx.rect(inner.x, inner.y, inner.w, inner.h);=0D + ctx.fill('evenodd');=0D + ctx.restore();=0D + },=0D +=0D + height: function() {=0D + var vm =3D this._view;=0D + return vm.base - vm.y;=0D + },=0D +=0D + inRange: function(mouseX, mouseY) {=0D + return inRange(this._view, mouseX, mouseY);=0D + },=0D +=0D + inLabelRange: function(mouseX, mouseY) {=0D + var vm =3D this._view;=0D + return isVertical(vm)=0D + ? inRange(vm, mouseX, null)=0D + : inRange(vm, null, mouseY);=0D + },=0D +=0D + inXRange: function(mouseX) {=0D + return inRange(this._view, mouseX, null);=0D + },=0D +=0D + inYRange: function(mouseY) {=0D + return inRange(this._view, null, mouseY);=0D + },=0D +=0D + getCenterPoint: function() {=0D + var vm =3D this._view;=0D + var x, y;=0D + if (isVertical(vm)) {=0D + x =3D vm.x;=0D + y =3D (vm.y + vm.base) / 2;=0D + } else {=0D + x =3D (vm.x + vm.base) / 2;=0D + y =3D vm.y;=0D + }=0D +=0D + return {x: x, y: y};=0D + },=0D +=0D + getArea: function() {=0D + var vm =3D this._view;=0D +=0D + return isVertical(vm)=0D + ? vm.width * Math.abs(vm.y - vm.base)=0D + : vm.height * Math.abs(vm.x - vm.base);=0D + },=0D +=0D + tooltipPosition: function() {=0D + var vm =3D this._view;=0D + return {=0D + x: vm.x,=0D + y: vm.y=0D + };=0D + }=0D +}); =20 - if (legendOpts) { - helpers$1.mergeIf(legendOpts, core_defaults.global.legend); +var elements =3D {};=0D +var Arc =3D element_arc;=0D +var Line =3D element_line;=0D +var Point =3D element_point;=0D +var Rectangle =3D element_rectangle; +elements.Arc =3D Arc; +elements.Line =3D Line; +elements.Point =3D Point; +elements.Rectangle =3D Rectangle; =20 - if (legend) { - core_layouts.configure(chart, legend, legendOpts); - legend.options =3D legendOpts; - } else { - createNewLegendAndAttach(chart, legendOpts); - } - } else if (legend) { - core_layouts.removeBox(chart, legend); - delete chart.legend; - } - }, +var deprecated =3D helpers$1._deprecated;=0D +var valueOrDefault$3 =3D helpers$1.valueOrDefault;=0D +=0D +core_defaults._set('bar', {=0D + hover: {=0D + mode: 'label'=0D + },=0D +=0D + scales: {=0D + xAxes: [{=0D + type: 'category',=0D + offset: true,=0D + gridLines: {=0D + offsetGridLines: true=0D + }=0D + }],=0D +=0D + yAxes: [{=0D + type: 'linear'=0D + }]=0D + }=0D +});=0D +=0D +core_defaults._set('global', {=0D + datasets: {=0D + bar: {=0D + categoryPercentage: 0.8,=0D + barPercentage: 0.9=0D + }=0D + }=0D +});=0D +=0D +/**=0D + * Computes the "optimal" sample size to maintain bars equally sized while= preventing overlap.=0D + * @private=0D + */=0D +function computeMinSampleSize(scale, pixels) {=0D + var min =3D scale._length;=0D + var prev, curr, i, ilen;=0D +=0D + for (i =3D 1, ilen =3D pixels.length; i < ilen; ++i) {=0D + min =3D Math.min(min, Math.abs(pixels[i] - pixels[i - 1]));=0D + }=0D +=0D + for (i =3D 0, ilen =3D scale.getTicks().length; i < ilen; ++i) {=0D + curr =3D scale.getPixelForTick(i);=0D + min =3D i > 0 ? Math.min(min, Math.abs(curr - prev)) : min;=0D + prev =3D curr;=0D + }=0D +=0D + return min;=0D +}=0D +=0D +/**=0D + * Computes an "ideal" category based on the absolute bar thickness or, if= undefined or null,=0D + * uses the smallest interval (see computeMinSampleSize) that prevents bar= overlapping. This=0D + * mode currently always generates bars equally sized (until we introduce = scriptable options?).=0D + * @private=0D + */=0D +function computeFitCategoryTraits(index, ruler, options) {=0D + var thickness =3D options.barThickness;=0D + var count =3D ruler.stackCount;=0D + var curr =3D ruler.pixels[index];=0D + var min =3D helpers$1.isNullOrUndef(thickness)=0D + ? computeMinSampleSize(ruler.scale, ruler.pixels)=0D + : -1;=0D + var size, ratio;=0D +=0D + if (helpers$1.isNullOrUndef(thickness)) {=0D + size =3D min * options.categoryPercentage;=0D + ratio =3D options.barPercentage;=0D + } else {=0D + // When bar thickness is enforced, category and bar percentages are igno= red.=0D + // Note(SB): we could add support for relative bar thickness (e.g. barTh= ickness: '50%')=0D + // and deprecate barPercentage since this value is ignored when thicknes= s is absolute.=0D + size =3D thickness * count;=0D + ratio =3D 1;=0D + }=0D +=0D + return {=0D + chunk: size / count,=0D + ratio: ratio,=0D + start: curr - (size / 2)=0D + };=0D +}=0D +=0D +/**=0D + * Computes an "optimal" category that globally arranges bars side by side= (no gap when=0D + * percentage options are 1), based on the previous and following categori= es. This mode=0D + * generates bars with different widths when data are not evenly spaced.=0D + * @private=0D + */=0D +function computeFlexCategoryTraits(index, ruler, options) {=0D + var pixels =3D ruler.pixels;=0D + var curr =3D pixels[index];=0D + var prev =3D index > 0 ? pixels[index - 1] : null;=0D + var next =3D index < pixels.length - 1 ? pixels[index + 1] : null;=0D + var percent =3D options.categoryPercentage;=0D + var start, size;=0D +=0D + if (prev =3D=3D=3D null) {=0D + // first data: its size is double based on the next point or,=0D + // if it's also the last data, we use the scale size.=0D + prev =3D curr - (next =3D=3D=3D null ? ruler.end - ruler.start : next - = curr);=0D + }=0D +=0D + if (next =3D=3D=3D null) {=0D + // last data: its size is also double based on the previous point.=0D + next =3D curr + curr - prev;=0D + }=0D +=0D + start =3D curr - (curr - Math.min(prev, next)) / 2 * percent;=0D + size =3D Math.abs(next - prev) / 2 * percent;=0D +=0D + return {=0D + chunk: size / ruler.stackCount,=0D + ratio: options.barPercentage,=0D + start: start=0D + };=0D +}=0D +=0D +var controller_bar =3D core_datasetController.extend({=0D +=0D + dataElementType: elements.Rectangle,=0D +=0D + /**=0D + * @private=0D + */=0D + _dataElementOptions: [=0D + 'backgroundColor',=0D + 'borderColor',=0D + 'borderSkipped',=0D + 'borderWidth',=0D + 'barPercentage',=0D + 'barThickness',=0D + 'categoryPercentage',=0D + 'maxBarThickness',=0D + 'minBarLength'=0D + ],=0D +=0D + initialize: function() {=0D + var me =3D this;=0D + var meta, scaleOpts;=0D +=0D + core_datasetController.prototype.initialize.apply(me, arguments);=0D +=0D + meta =3D me.getMeta();=0D + meta.stack =3D me.getDataset().stack;=0D + meta.bar =3D true;=0D +=0D + scaleOpts =3D me._getIndexScale().options;=0D + deprecated('bar chart', scaleOpts.barPercentage, 'scales.[x/y]Axes.barPe= rcentage', 'dataset.barPercentage');=0D + deprecated('bar chart', scaleOpts.barThickness, 'scales.[x/y]Axes.barThi= ckness', 'dataset.barThickness');=0D + deprecated('bar chart', scaleOpts.categoryPercentage, 'scales.[x/y]Axes.= categoryPercentage', 'dataset.categoryPercentage');=0D + deprecated('bar chart', me._getValueScale().options.minBarLength, 'scale= s.[x/y]Axes.minBarLength', 'dataset.minBarLength');=0D + deprecated('bar chart', scaleOpts.maxBarThickness, 'scales.[x/y]Axes.max= BarThickness', 'dataset.maxBarThickness');=0D + },=0D +=0D + update: function(reset) {=0D + var me =3D this;=0D + var rects =3D me.getMeta().data;=0D + var i, ilen;=0D +=0D + me._ruler =3D me.getRuler();=0D +=0D + for (i =3D 0, ilen =3D rects.length; i < ilen; ++i) {=0D + me.updateElement(rects[i], i, reset);=0D + }=0D + },=0D +=0D + updateElement: function(rectangle, index, reset) {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var dataset =3D me.getDataset();=0D + var options =3D me._resolveDataElementOptions(rectangle, index);=0D +=0D + rectangle._xScale =3D me.getScaleForId(meta.xAxisID);=0D + rectangle._yScale =3D me.getScaleForId(meta.yAxisID);=0D + rectangle._datasetIndex =3D me.index;=0D + rectangle._index =3D index;=0D + rectangle._model =3D {=0D + backgroundColor: options.backgroundColor,=0D + borderColor: options.borderColor,=0D + borderSkipped: options.borderSkipped,=0D + borderWidth: options.borderWidth,=0D + datasetLabel: dataset.label,=0D + label: me.chart.data.labels[index]=0D + };=0D +=0D + if (helpers$1.isArray(dataset.data[index])) {=0D + rectangle._model.borderSkipped =3D null;=0D + }=0D +=0D + me._updateElementGeometry(rectangle, index, reset, options);=0D +=0D + rectangle.pivot();=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _updateElementGeometry: function(rectangle, index, reset, options) {=0D + var me =3D this;=0D + var model =3D rectangle._model;=0D + var vscale =3D me._getValueScale();=0D + var base =3D vscale.getBasePixel();=0D + var horizontal =3D vscale.isHorizontal();=0D + var ruler =3D me._ruler || me.getRuler();=0D + var vpixels =3D me.calculateBarValuePixels(me.index, index, options);=0D + var ipixels =3D me.calculateBarIndexPixels(me.index, index, ruler, optio= ns);=0D +=0D + model.horizontal =3D horizontal;=0D + model.base =3D reset ? base : vpixels.base;=0D + model.x =3D horizontal ? reset ? base : vpixels.head : ipixels.center;=0D + model.y =3D horizontal ? ipixels.center : reset ? base : vpixels.head;=0D + model.height =3D horizontal ? ipixels.size : undefined;=0D + model.width =3D horizontal ? undefined : ipixels.size;=0D + },=0D +=0D + /**=0D + * Returns the stacks based on groups and bar visibility.=0D + * @param {number} [last] - The dataset index=0D + * @returns {string[]} The list of stack IDs=0D + * @private=0D + */=0D + _getStacks: function(last) {=0D + var me =3D this;=0D + var scale =3D me._getIndexScale();=0D + var metasets =3D scale._getMatchingVisibleMetas(me._type);=0D + var stacked =3D scale.options.stacked;=0D + var ilen =3D metasets.length;=0D + var stacks =3D [];=0D + var i, meta;=0D +=0D + for (i =3D 0; i < ilen; ++i) {=0D + meta =3D metasets[i];=0D + // stacked | meta.stack=0D + // | found | not found | undefined=0D + // false | x | x | x=0D + // true | | x |=0D + // undefined | | x | x=0D + if (stacked =3D=3D=3D false || stacks.indexOf(meta.stack) =3D=3D=3D -1 = ||=0D + (stacked =3D=3D=3D undefined && meta.stack =3D=3D=3D undefined)) {=0D + stacks.push(meta.stack);=0D + }=0D + if (meta.index =3D=3D=3D last) {=0D + break;=0D + }=0D + }=0D +=0D + return stacks;=0D + },=0D +=0D + /**=0D + * Returns the effective number of stacks based on groups and bar visibil= ity.=0D + * @private=0D + */=0D + getStackCount: function() {=0D + return this._getStacks().length;=0D + },=0D +=0D + /**=0D + * Returns the stack index for the given dataset based on groups and bar = visibility.=0D + * @param {number} [datasetIndex] - The dataset index=0D + * @param {string} [name] - The stack name to find=0D + * @returns {number} The stack index=0D + * @private=0D + */=0D + getStackIndex: function(datasetIndex, name) {=0D + var stacks =3D this._getStacks(datasetIndex);=0D + var index =3D (name !=3D=3D undefined)=0D + ? stacks.indexOf(name)=0D + : -1; // indexOf returns -1 if element is not present=0D +=0D + return (index =3D=3D=3D -1)=0D + ? stacks.length - 1=0D + : index;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + getRuler: function() {=0D + var me =3D this;=0D + var scale =3D me._getIndexScale();=0D + var pixels =3D [];=0D + var i, ilen;=0D +=0D + for (i =3D 0, ilen =3D me.getMeta().data.length; i < ilen; ++i) {=0D + pixels.push(scale.getPixelForValue(null, i, me.index));=0D + }=0D +=0D + return {=0D + pixels: pixels,=0D + start: scale._startPixel,=0D + end: scale._endPixel,=0D + stackCount: me.getStackCount(),=0D + scale: scale=0D + };=0D + },=0D +=0D + /**=0D + * Note: pixel values are not clamped to the scale area.=0D + * @private=0D + */=0D + calculateBarValuePixels: function(datasetIndex, index, options) {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var scale =3D me._getValueScale();=0D + var isHorizontal =3D scale.isHorizontal();=0D + var datasets =3D chart.data.datasets;=0D + var metasets =3D scale._getMatchingVisibleMetas(me._type);=0D + var value =3D scale._parseValue(datasets[datasetIndex].data[index]);=0D + var minBarLength =3D options.minBarLength;=0D + var stacked =3D scale.options.stacked;=0D + var stack =3D me.getMeta().stack;=0D + var start =3D value.start =3D=3D=3D undefined ? 0 : value.max >=3D 0 && = value.min >=3D 0 ? value.min : value.max;=0D + var length =3D value.start =3D=3D=3D undefined ? value.end : value.max >= =3D 0 && value.min >=3D 0 ? value.max - value.min : value.min - value.max;= =0D + var ilen =3D metasets.length;=0D + var i, imeta, ivalue, base, head, size, stackLength;=0D +=0D + if (stacked || (stacked =3D=3D=3D undefined && stack !=3D=3D undefined))= {=0D + for (i =3D 0; i < ilen; ++i) {=0D + imeta =3D metasets[i];=0D +=0D + if (imeta.index =3D=3D=3D datasetIndex) {=0D + break;=0D + }=0D +=0D + if (imeta.stack =3D=3D=3D stack) {=0D + stackLength =3D scale._parseValue(datasets[imeta.index].data[index]);= =0D + ivalue =3D stackLength.start =3D=3D=3D undefined ? stackLength.end : = stackLength.min >=3D 0 && stackLength.max >=3D 0 ? stackLength.max : stackL= ength.min;=0D +=0D + if ((value.min < 0 && ivalue < 0) || (value.max >=3D 0 && ivalue > 0)= ) {=0D + start +=3D ivalue;=0D + }=0D + }=0D + }=0D + }=0D +=0D + base =3D scale.getPixelForValue(start);=0D + head =3D scale.getPixelForValue(start + length);=0D + size =3D head - base;=0D +=0D + if (minBarLength !=3D=3D undefined && Math.abs(size) < minBarLength) {=0D + size =3D minBarLength;=0D + if (length >=3D 0 && !isHorizontal || length < 0 && isHorizontal) {=0D + head =3D base - minBarLength;=0D + } else {=0D + head =3D base + minBarLength;=0D + }=0D + }=0D +=0D + return {=0D + size: size,=0D + base: base,=0D + head: head,=0D + center: head + size / 2=0D + };=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + calculateBarIndexPixels: function(datasetIndex, index, ruler, options) {= =0D + var me =3D this;=0D + var range =3D options.barThickness =3D=3D=3D 'flex'=0D + ? computeFlexCategoryTraits(index, ruler, options)=0D + : computeFitCategoryTraits(index, ruler, options);=0D +=0D + var stackIndex =3D me.getStackIndex(datasetIndex, me.getMeta().stack);=0D + var center =3D range.start + (range.chunk * stackIndex) + (range.chunk /= 2);=0D + var size =3D Math.min(=0D + valueOrDefault$3(options.maxBarThickness, Infinity),=0D + range.chunk * range.ratio);=0D +=0D + return {=0D + base: center - size / 2,=0D + head: center + size / 2,=0D + center: center,=0D + size: size=0D + };=0D + },=0D +=0D + draw: function() {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var scale =3D me._getValueScale();=0D + var rects =3D me.getMeta().data;=0D + var dataset =3D me.getDataset();=0D + var ilen =3D rects.length;=0D + var i =3D 0;=0D +=0D + helpers$1.canvas.clipArea(chart.ctx, chart.chartArea);=0D +=0D + for (; i < ilen; ++i) {=0D + var val =3D scale._parseValue(dataset.data[i]);=0D + if (!isNaN(val.min) && !isNaN(val.max)) {=0D + rects[i].draw();=0D + }=0D + }=0D +=0D + helpers$1.canvas.unclipArea(chart.ctx);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _resolveDataElementOptions: function() {=0D + var me =3D this;=0D + var values =3D helpers$1.extend({}, core_datasetController.prototype._re= solveDataElementOptions.apply(me, arguments));=0D + var indexOpts =3D me._getIndexScale().options;=0D + var valueOpts =3D me._getValueScale().options;=0D +=0D + values.barPercentage =3D valueOrDefault$3(indexOpts.barPercentage, value= s.barPercentage);=0D + values.barThickness =3D valueOrDefault$3(indexOpts.barThickness, values.= barThickness);=0D + values.categoryPercentage =3D valueOrDefault$3(indexOpts.categoryPercent= age, values.categoryPercentage);=0D + values.maxBarThickness =3D valueOrDefault$3(indexOpts.maxBarThickness, v= alues.maxBarThickness);=0D + values.minBarLength =3D valueOrDefault$3(valueOpts.minBarLength, values.= minBarLength);=0D +=0D + return values;=0D + }=0D +=0D +}); =20 - afterEvent: function(chart, e) { - var legend =3D chart.legend; - if (legend) { - legend.handleEvent(e); - } - } -}; +var valueOrDefault$4 =3D helpers$1.valueOrDefault;=0D +var resolve$1 =3D helpers$1.options.resolve;=0D +=0D +core_defaults._set('bubble', {=0D + hover: {=0D + mode: 'single'=0D + },=0D +=0D + scales: {=0D + xAxes: [{=0D + type: 'linear', // bubble should probably use a linear scale by default= =0D + position: 'bottom',=0D + id: 'x-axis-0' // need an ID so datasets can reference the scale=0D + }],=0D + yAxes: [{=0D + type: 'linear',=0D + position: 'left',=0D + id: 'y-axis-0'=0D + }]=0D + },=0D +=0D + tooltips: {=0D + callbacks: {=0D + title: function() {=0D + // Title doesn't make sense for scatter since we format the data as a = point=0D + return '';=0D + },=0D + label: function(item, data) {=0D + var datasetLabel =3D data.datasets[item.datasetIndex].label || '';=0D + var dataPoint =3D data.datasets[item.datasetIndex].data[item.index];=0D + return datasetLabel + ': (' + item.xLabel + ', ' + item.yLabel + ', ' = + dataPoint.r + ')';=0D + }=0D + }=0D + }=0D +});=0D +=0D +var controller_bubble =3D core_datasetController.extend({=0D + /**=0D + * @protected=0D + */=0D + dataElementType: elements.Point,=0D +=0D + /**=0D + * @private=0D + */=0D + _dataElementOptions: [=0D + 'backgroundColor',=0D + 'borderColor',=0D + 'borderWidth',=0D + 'hoverBackgroundColor',=0D + 'hoverBorderColor',=0D + 'hoverBorderWidth',=0D + 'hoverRadius',=0D + 'hitRadius',=0D + 'pointStyle',=0D + 'rotation'=0D + ],=0D +=0D + /**=0D + * @protected=0D + */=0D + update: function(reset) {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var points =3D meta.data;=0D +=0D + // Update Points=0D + helpers$1.each(points, function(point, index) {=0D + me.updateElement(point, index, reset);=0D + });=0D + },=0D +=0D + /**=0D + * @protected=0D + */=0D + updateElement: function(point, index, reset) {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var custom =3D point.custom || {};=0D + var xScale =3D me.getScaleForId(meta.xAxisID);=0D + var yScale =3D me.getScaleForId(meta.yAxisID);=0D + var options =3D me._resolveDataElementOptions(point, index);=0D + var data =3D me.getDataset().data[index];=0D + var dsIndex =3D me.index;=0D +=0D + var x =3D reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForVal= ue(typeof data =3D=3D=3D 'object' ? data : NaN, index, dsIndex);=0D + var y =3D reset ? yScale.getBasePixel() : yScale.getPixelForValue(data, = index, dsIndex);=0D +=0D + point._xScale =3D xScale;=0D + point._yScale =3D yScale;=0D + point._options =3D options;=0D + point._datasetIndex =3D dsIndex;=0D + point._index =3D index;=0D + point._model =3D {=0D + backgroundColor: options.backgroundColor,=0D + borderColor: options.borderColor,=0D + borderWidth: options.borderWidth,=0D + hitRadius: options.hitRadius,=0D + pointStyle: options.pointStyle,=0D + rotation: options.rotation,=0D + radius: reset ? 0 : options.radius,=0D + skip: custom.skip || isNaN(x) || isNaN(y),=0D + x: x,=0D + y: y,=0D + };=0D +=0D + point.pivot();=0D + },=0D +=0D + /**=0D + * @protected=0D + */=0D + setHoverStyle: function(point) {=0D + var model =3D point._model;=0D + var options =3D point._options;=0D + var getHoverColor =3D helpers$1.getHoverColor;=0D +=0D + point.$previousStyle =3D {=0D + backgroundColor: model.backgroundColor,=0D + borderColor: model.borderColor,=0D + borderWidth: model.borderWidth,=0D + radius: model.radius=0D + };=0D +=0D + model.backgroundColor =3D valueOrDefault$4(options.hoverBackgroundColor,= getHoverColor(options.backgroundColor));=0D + model.borderColor =3D valueOrDefault$4(options.hoverBorderColor, getHove= rColor(options.borderColor));=0D + model.borderWidth =3D valueOrDefault$4(options.hoverBorderWidth, options= .borderWidth);=0D + model.radius =3D options.radius + options.hoverRadius;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _resolveDataElementOptions: function(point, index) {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var dataset =3D me.getDataset();=0D + var custom =3D point.custom || {};=0D + var data =3D dataset.data[index] || {};=0D + var values =3D core_datasetController.prototype._resolveDataElementOptio= ns.apply(me, arguments);=0D +=0D + // Scriptable options=0D + var context =3D {=0D + chart: chart,=0D + dataIndex: index,=0D + dataset: dataset,=0D + datasetIndex: me.index=0D + };=0D +=0D + // In case values were cached (and thus frozen), we need to clone the va= lues=0D + if (me._cachedDataOpts =3D=3D=3D values) {=0D + values =3D helpers$1.extend({}, values);=0D + }=0D +=0D + // Custom radius resolution=0D + values.radius =3D resolve$1([=0D + custom.radius,=0D + data.r,=0D + me._config.radius,=0D + chart.options.elements.point.radius=0D + ], context, index);=0D +=0D + return values;=0D + }=0D +}); =20 -var noop$2 =3D helpers$1.noop; - -core_defaults._set('global', { - title: { - display: false, - fontStyle: 'bold', - fullWidth: true, - padding: 10, - position: 'top', - text: '', - weight: 2000 // by default greater than legend (1000) to be above - } +var valueOrDefault$5 =3D helpers$1.valueOrDefault;=0D +=0D +var PI$1 =3D Math.PI;=0D +var DOUBLE_PI$1 =3D PI$1 * 2;=0D +var HALF_PI$1 =3D PI$1 / 2;=0D +=0D +core_defaults._set('doughnut', {=0D + animation: {=0D + // Boolean - Whether we animate the rotation of the Doughnut=0D + animateRotate: true,=0D + // Boolean - Whether we animate scaling the Doughnut from the centre=0D + animateScale: false=0D + },=0D + hover: {=0D + mode: 'single'=0D + },=0D + legendCallback: function(chart) {=0D + var list =3D document.createElement('ul');=0D + var data =3D chart.data;=0D + var datasets =3D data.datasets;=0D + var labels =3D data.labels;=0D + var i, ilen, listItem, listItemSpan;=0D +=0D + list.setAttribute('class', chart.id + '-legend');=0D + if (datasets.length) {=0D + for (i =3D 0, ilen =3D datasets[0].data.length; i < ilen; ++i) {=0D + listItem =3D list.appendChild(document.createElement('li'));=0D + listItemSpan =3D listItem.appendChild(document.createElement('span'));= =0D + listItemSpan.style.backgroundColor =3D datasets[0].backgroundColor[i];= =0D + if (labels[i]) {=0D + listItem.appendChild(document.createTextNode(labels[i]));=0D + }=0D + }=0D + }=0D +=0D + return list.outerHTML;=0D + },=0D + legend: {=0D + labels: {=0D + generateLabels: function(chart) {=0D + var data =3D chart.data;=0D + if (data.labels.length && data.datasets.length) {=0D + return data.labels.map(function(label, i) {=0D + var meta =3D chart.getDatasetMeta(0);=0D + var style =3D meta.controller.getStyle(i);=0D +=0D + return {=0D + text: label,=0D + fillStyle: style.backgroundColor,=0D + strokeStyle: style.borderColor,=0D + lineWidth: style.borderWidth,=0D + hidden: isNaN(data.datasets[0].data[i]) || meta.data[i].hidden,=0D +=0D + // Extra data used for toggling the correct item=0D + index: i=0D + };=0D + });=0D + }=0D + return [];=0D + }=0D + },=0D +=0D + onClick: function(e, legendItem) {=0D + var index =3D legendItem.index;=0D + var chart =3D this.chart;=0D + var i, ilen, meta;=0D +=0D + for (i =3D 0, ilen =3D (chart.data.datasets || []).length; i < ilen; ++= i) {=0D + meta =3D chart.getDatasetMeta(i);=0D + // toggle visibility of index if exists=0D + if (meta.data[index]) {=0D + meta.data[index].hidden =3D !meta.data[index].hidden;=0D + }=0D + }=0D +=0D + chart.update();=0D + }=0D + },=0D +=0D + // The percentage of the chart that we cut out of the middle.=0D + cutoutPercentage: 50,=0D +=0D + // The rotation of the chart, where the first data arc begins.=0D + rotation: -HALF_PI$1,=0D +=0D + // The total circumference of the chart.=0D + circumference: DOUBLE_PI$1,=0D +=0D + // Need to override these to give a nice default=0D + tooltips: {=0D + callbacks: {=0D + title: function() {=0D + return '';=0D + },=0D + label: function(tooltipItem, data) {=0D + var dataLabel =3D data.labels[tooltipItem.index];=0D + var value =3D ': ' + data.datasets[tooltipItem.datasetIndex].data[tool= tipItem.index];=0D +=0D + if (helpers$1.isArray(dataLabel)) {=0D + // show value on first line of multiline label=0D + // need to clone because we are changing the value=0D + dataLabel =3D dataLabel.slice();=0D + dataLabel[0] +=3D value;=0D + } else {=0D + dataLabel +=3D value;=0D + }=0D +=0D + return dataLabel;=0D + }=0D + }=0D + }=0D +});=0D +=0D +var controller_doughnut =3D core_datasetController.extend({=0D +=0D + dataElementType: elements.Arc,=0D +=0D + linkScales: helpers$1.noop,=0D +=0D + /**=0D + * @private=0D + */=0D + _dataElementOptions: [=0D + 'backgroundColor',=0D + 'borderColor',=0D + 'borderWidth',=0D + 'borderAlign',=0D + 'hoverBackgroundColor',=0D + 'hoverBorderColor',=0D + 'hoverBorderWidth',=0D + ],=0D +=0D + // Get index of the dataset in relation to the visible datasets. This all= ows determining the inner and outer radius correctly=0D + getRingIndex: function(datasetIndex) {=0D + var ringIndex =3D 0;=0D +=0D + for (var j =3D 0; j < datasetIndex; ++j) {=0D + if (this.chart.isDatasetVisible(j)) {=0D + ++ringIndex;=0D + }=0D + }=0D +=0D + return ringIndex;=0D + },=0D +=0D + update: function(reset) {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var chartArea =3D chart.chartArea;=0D + var opts =3D chart.options;=0D + var ratioX =3D 1;=0D + var ratioY =3D 1;=0D + var offsetX =3D 0;=0D + var offsetY =3D 0;=0D + var meta =3D me.getMeta();=0D + var arcs =3D meta.data;=0D + var cutout =3D opts.cutoutPercentage / 100 || 0;=0D + var circumference =3D opts.circumference;=0D + var chartWeight =3D me._getRingWeight(me.index);=0D + var maxWidth, maxHeight, i, ilen;=0D +=0D + // If the chart's circumference isn't a full circle, calculate size as a= ratio of the width/height of the arc=0D + if (circumference < DOUBLE_PI$1) {=0D + var startAngle =3D opts.rotation % DOUBLE_PI$1;=0D + startAngle +=3D startAngle >=3D PI$1 ? -DOUBLE_PI$1 : startAngle < -PI$= 1 ? DOUBLE_PI$1 : 0;=0D + var endAngle =3D startAngle + circumference;=0D + var startX =3D Math.cos(startAngle);=0D + var startY =3D Math.sin(startAngle);=0D + var endX =3D Math.cos(endAngle);=0D + var endY =3D Math.sin(endAngle);=0D + var contains0 =3D (startAngle <=3D 0 && endAngle >=3D 0) || endAngle >= =3D DOUBLE_PI$1;=0D + var contains90 =3D (startAngle <=3D HALF_PI$1 && endAngle >=3D HALF_PI$= 1) || endAngle >=3D DOUBLE_PI$1 + HALF_PI$1;=0D + var contains180 =3D startAngle =3D=3D=3D -PI$1 || endAngle >=3D PI$1;=0D + var contains270 =3D (startAngle <=3D -HALF_PI$1 && endAngle >=3D -HALF_= PI$1) || endAngle >=3D PI$1 + HALF_PI$1;=0D + var minX =3D contains180 ? -1 : Math.min(startX, startX * cutout, endX,= endX * cutout);=0D + var minY =3D contains270 ? -1 : Math.min(startY, startY * cutout, endY,= endY * cutout);=0D + var maxX =3D contains0 ? 1 : Math.max(startX, startX * cutout, endX, en= dX * cutout);=0D + var maxY =3D contains90 ? 1 : Math.max(startY, startY * cutout, endY, e= ndY * cutout);=0D + ratioX =3D (maxX - minX) / 2;=0D + ratioY =3D (maxY - minY) / 2;=0D + offsetX =3D -(maxX + minX) / 2;=0D + offsetY =3D -(maxY + minY) / 2;=0D + }=0D +=0D + for (i =3D 0, ilen =3D arcs.length; i < ilen; ++i) {=0D + arcs[i]._options =3D me._resolveDataElementOptions(arcs[i], i);=0D + }=0D +=0D + chart.borderWidth =3D me.getMaxBorderWidth();=0D + maxWidth =3D (chartArea.right - chartArea.left - chart.borderWidth) / ra= tioX;=0D + maxHeight =3D (chartArea.bottom - chartArea.top - chart.borderWidth) / r= atioY;=0D + chart.outerRadius =3D Math.max(Math.min(maxWidth, maxHeight) / 2, 0);=0D + chart.innerRadius =3D Math.max(chart.outerRadius * cutout, 0);=0D + chart.radiusLength =3D (chart.outerRadius - chart.innerRadius) / (me._ge= tVisibleDatasetWeightTotal() || 1);=0D + chart.offsetX =3D offsetX * chart.outerRadius;=0D + chart.offsetY =3D offsetY * chart.outerRadius;=0D +=0D + meta.total =3D me.calculateTotal();=0D +=0D + me.outerRadius =3D chart.outerRadius - chart.radiusLength * me._getRingW= eightOffset(me.index);=0D + me.innerRadius =3D Math.max(me.outerRadius - chart.radiusLength * chartW= eight, 0);=0D +=0D + for (i =3D 0, ilen =3D arcs.length; i < ilen; ++i) {=0D + me.updateElement(arcs[i], i, reset);=0D + }=0D + },=0D +=0D + updateElement: function(arc, index, reset) {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var chartArea =3D chart.chartArea;=0D + var opts =3D chart.options;=0D + var animationOpts =3D opts.animation;=0D + var centerX =3D (chartArea.left + chartArea.right) / 2;=0D + var centerY =3D (chartArea.top + chartArea.bottom) / 2;=0D + var startAngle =3D opts.rotation; // non reset case handled later=0D + var endAngle =3D opts.rotation; // non reset case handled later=0D + var dataset =3D me.getDataset();=0D + var circumference =3D reset && animationOpts.animateRotate ? 0 : arc.hid= den ? 0 : me.calculateCircumference(dataset.data[index]) * (opts.circumfere= nce / DOUBLE_PI$1);=0D + var innerRadius =3D reset && animationOpts.animateScale ? 0 : me.innerRa= dius;=0D + var outerRadius =3D reset && animationOpts.animateScale ? 0 : me.outerRa= dius;=0D + var options =3D arc._options || {};=0D +=0D + helpers$1.extend(arc, {=0D + // Utility=0D + _datasetIndex: me.index,=0D + _index: index,=0D +=0D + // Desired view properties=0D + _model: {=0D + backgroundColor: options.backgroundColor,=0D + borderColor: options.borderColor,=0D + borderWidth: options.borderWidth,=0D + borderAlign: options.borderAlign,=0D + x: centerX + chart.offsetX,=0D + y: centerY + chart.offsetY,=0D + startAngle: startAngle,=0D + endAngle: endAngle,=0D + circumference: circumference,=0D + outerRadius: outerRadius,=0D + innerRadius: innerRadius,=0D + label: helpers$1.valueAtIndexOrDefault(dataset.label, index, chart.dat= a.labels[index])=0D + }=0D + });=0D +=0D + var model =3D arc._model;=0D +=0D + // Set correct angles if not resetting=0D + if (!reset || !animationOpts.animateRotate) {=0D + if (index =3D=3D=3D 0) {=0D + model.startAngle =3D opts.rotation;=0D + } else {=0D + model.startAngle =3D me.getMeta().data[index - 1]._model.endAngle;=0D + }=0D +=0D + model.endAngle =3D model.startAngle + model.circumference;=0D + }=0D +=0D + arc.pivot();=0D + },=0D +=0D + calculateTotal: function() {=0D + var dataset =3D this.getDataset();=0D + var meta =3D this.getMeta();=0D + var total =3D 0;=0D + var value;=0D +=0D + helpers$1.each(meta.data, function(element, index) {=0D + value =3D dataset.data[index];=0D + if (!isNaN(value) && !element.hidden) {=0D + total +=3D Math.abs(value);=0D + }=0D + });=0D +=0D + /* if (total =3D=3D=3D 0) {=0D + total =3D NaN;=0D + }*/=0D +=0D + return total;=0D + },=0D +=0D + calculateCircumference: function(value) {=0D + var total =3D this.getMeta().total;=0D + if (total > 0 && !isNaN(value)) {=0D + return DOUBLE_PI$1 * (Math.abs(value) / total);=0D + }=0D + return 0;=0D + },=0D +=0D + // gets the max border or hover width to properly scale pie charts=0D + getMaxBorderWidth: function(arcs) {=0D + var me =3D this;=0D + var max =3D 0;=0D + var chart =3D me.chart;=0D + var i, ilen, meta, arc, controller, options, borderWidth, hoverWidth;=0D +=0D + if (!arcs) {=0D + // Find the outmost visible dataset=0D + for (i =3D 0, ilen =3D chart.data.datasets.length; i < ilen; ++i) {=0D + if (chart.isDatasetVisible(i)) {=0D + meta =3D chart.getDatasetMeta(i);=0D + arcs =3D meta.data;=0D + if (i !=3D=3D me.index) {=0D + controller =3D meta.controller;=0D + }=0D + break;=0D + }=0D + }=0D + }=0D +=0D + if (!arcs) {=0D + return 0;=0D + }=0D +=0D + for (i =3D 0, ilen =3D arcs.length; i < ilen; ++i) {=0D + arc =3D arcs[i];=0D + if (controller) {=0D + controller._configure();=0D + options =3D controller._resolveDataElementOptions(arc, i);=0D + } else {=0D + options =3D arc._options;=0D + }=0D + if (options.borderAlign !=3D=3D 'inner') {=0D + borderWidth =3D options.borderWidth;=0D + hoverWidth =3D options.hoverBorderWidth;=0D +=0D + max =3D borderWidth > max ? borderWidth : max;=0D + max =3D hoverWidth > max ? hoverWidth : max;=0D + }=0D + }=0D + return max;=0D + },=0D +=0D + /**=0D + * @protected=0D + */=0D + setHoverStyle: function(arc) {=0D + var model =3D arc._model;=0D + var options =3D arc._options;=0D + var getHoverColor =3D helpers$1.getHoverColor;=0D +=0D + arc.$previousStyle =3D {=0D + backgroundColor: model.backgroundColor,=0D + borderColor: model.borderColor,=0D + borderWidth: model.borderWidth,=0D + };=0D +=0D + model.backgroundColor =3D valueOrDefault$5(options.hoverBackgroundColor,= getHoverColor(options.backgroundColor));=0D + model.borderColor =3D valueOrDefault$5(options.hoverBorderColor, getHove= rColor(options.borderColor));=0D + model.borderWidth =3D valueOrDefault$5(options.hoverBorderWidth, options= .borderWidth);=0D + },=0D +=0D + /**=0D + * Get radius length offset of the dataset in relation to the visible dat= asets weights. This allows determining the inner and outer radius correctly= =0D + * @private=0D + */=0D + _getRingWeightOffset: function(datasetIndex) {=0D + var ringWeightOffset =3D 0;=0D +=0D + for (var i =3D 0; i < datasetIndex; ++i) {=0D + if (this.chart.isDatasetVisible(i)) {=0D + ringWeightOffset +=3D this._getRingWeight(i);=0D + }=0D + }=0D +=0D + return ringWeightOffset;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getRingWeight: function(dataSetIndex) {=0D + return Math.max(valueOrDefault$5(this.chart.data.datasets[dataSetIndex].= weight, 1), 0);=0D + },=0D +=0D + /**=0D + * Returns the sum of all visibile data set weights. This value can be 0= .=0D + * @private=0D + */=0D + _getVisibleDatasetWeightTotal: function() {=0D + return this._getRingWeightOffset(this.chart.data.datasets.length);=0D + }=0D }); =20 -/** - * IMPORTANT: this class is exposed publicly as Chart.Legend, backward com= patibility required! - */ -var Title =3D core_element.extend({ - initialize: function(config) { - var me =3D this; - helpers$1.extend(me, config); +core_defaults._set('horizontalBar', {=0D + hover: {=0D + mode: 'index',=0D + axis: 'y'=0D + },=0D +=0D + scales: {=0D + xAxes: [{=0D + type: 'linear',=0D + position: 'bottom'=0D + }],=0D +=0D + yAxes: [{=0D + type: 'category',=0D + position: 'left',=0D + offset: true,=0D + gridLines: {=0D + offsetGridLines: true=0D + }=0D + }]=0D + },=0D +=0D + elements: {=0D + rectangle: {=0D + borderSkipped: 'left'=0D + }=0D + },=0D +=0D + tooltips: {=0D + mode: 'index',=0D + axis: 'y'=0D + }=0D +});=0D +=0D +core_defaults._set('global', {=0D + datasets: {=0D + horizontalBar: {=0D + categoryPercentage: 0.8,=0D + barPercentage: 0.9=0D + }=0D + }=0D +});=0D +=0D +var controller_horizontalBar =3D controller_bar.extend({=0D + /**=0D + * @private=0D + */=0D + _getValueScaleId: function() {=0D + return this.getMeta().xAxisID;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getIndexScaleId: function() {=0D + return this.getMeta().yAxisID;=0D + }=0D +}); =20 - // Contains hit boxes for each dataset (in dataset order) - me.legendHitBoxes =3D []; - }, +var valueOrDefault$6 =3D helpers$1.valueOrDefault;=0D +var resolve$2 =3D helpers$1.options.resolve;=0D +var isPointInArea =3D helpers$1.canvas._isPointInArea;=0D +=0D +core_defaults._set('line', {=0D + showLines: true,=0D + spanGaps: false,=0D +=0D + hover: {=0D + mode: 'label'=0D + },=0D +=0D + scales: {=0D + xAxes: [{=0D + type: 'category',=0D + id: 'x-axis-0'=0D + }],=0D + yAxes: [{=0D + type: 'linear',=0D + id: 'y-axis-0'=0D + }]=0D + }=0D +});=0D +=0D +function scaleClip(scale, halfBorderWidth) {=0D + var tickOpts =3D scale && scale.options.ticks || {};=0D + var reverse =3D tickOpts.reverse;=0D + var min =3D tickOpts.min =3D=3D=3D undefined ? halfBorderWidth : 0;=0D + var max =3D tickOpts.max =3D=3D=3D undefined ? halfBorderWidth : 0;=0D + return {=0D + start: reverse ? max : min,=0D + end: reverse ? min : max=0D + };=0D +}=0D +=0D +function defaultClip(xScale, yScale, borderWidth) {=0D + var halfBorderWidth =3D borderWidth / 2;=0D + var x =3D scaleClip(xScale, halfBorderWidth);=0D + var y =3D scaleClip(yScale, halfBorderWidth);=0D +=0D + return {=0D + top: y.end,=0D + right: x.end,=0D + bottom: y.start,=0D + left: x.start=0D + };=0D +}=0D +=0D +function toClip(value) {=0D + var t, r, b, l;=0D +=0D + if (helpers$1.isObject(value)) {=0D + t =3D value.top;=0D + r =3D value.right;=0D + b =3D value.bottom;=0D + l =3D value.left;=0D + } else {=0D + t =3D r =3D b =3D l =3D value;=0D + }=0D +=0D + return {=0D + top: t,=0D + right: r,=0D + bottom: b,=0D + left: l=0D + };=0D +}=0D +=0D +=0D +var controller_line =3D core_datasetController.extend({=0D +=0D + datasetElementType: elements.Line,=0D +=0D + dataElementType: elements.Point,=0D +=0D + /**=0D + * @private=0D + */=0D + _datasetElementOptions: [=0D + 'backgroundColor',=0D + 'borderCapStyle',=0D + 'borderColor',=0D + 'borderDash',=0D + 'borderDashOffset',=0D + 'borderJoinStyle',=0D + 'borderWidth',=0D + 'cubicInterpolationMode',=0D + 'fill'=0D + ],=0D +=0D + /**=0D + * @private=0D + */=0D + _dataElementOptions: {=0D + backgroundColor: 'pointBackgroundColor',=0D + borderColor: 'pointBorderColor',=0D + borderWidth: 'pointBorderWidth',=0D + hitRadius: 'pointHitRadius',=0D + hoverBackgroundColor: 'pointHoverBackgroundColor',=0D + hoverBorderColor: 'pointHoverBorderColor',=0D + hoverBorderWidth: 'pointHoverBorderWidth',=0D + hoverRadius: 'pointHoverRadius',=0D + pointStyle: 'pointStyle',=0D + radius: 'pointRadius',=0D + rotation: 'pointRotation'=0D + },=0D +=0D + update: function(reset) {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var line =3D meta.dataset;=0D + var points =3D meta.data || [];=0D + var options =3D me.chart.options;=0D + var config =3D me._config;=0D + var showLine =3D me._showLine =3D valueOrDefault$6(config.showLine, opti= ons.showLines);=0D + var i, ilen;=0D +=0D + me._xScale =3D me.getScaleForId(meta.xAxisID);=0D + me._yScale =3D me.getScaleForId(meta.yAxisID);=0D +=0D + // Update Line=0D + if (showLine) {=0D + // Compatibility: If the properties are defined with only the old name,= use those values=0D + if (config.tension !=3D=3D undefined && config.lineTension =3D=3D=3D un= defined) {=0D + config.lineTension =3D config.tension;=0D + }=0D +=0D + // Utility=0D + line._scale =3D me._yScale;=0D + line._datasetIndex =3D me.index;=0D + // Data=0D + line._children =3D points;=0D + // Model=0D + line._model =3D me._resolveDatasetElementOptions(line);=0D +=0D + line.pivot();=0D + }=0D +=0D + // Update Points=0D + for (i =3D 0, ilen =3D points.length; i < ilen; ++i) {=0D + me.updateElement(points[i], i, reset);=0D + }=0D +=0D + if (showLine && line._model.tension !=3D=3D 0) {=0D + me.updateBezierControlPoints();=0D + }=0D +=0D + // Now pivot the point for animation=0D + for (i =3D 0, ilen =3D points.length; i < ilen; ++i) {=0D + points[i].pivot();=0D + }=0D + },=0D +=0D + updateElement: function(point, index, reset) {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var custom =3D point.custom || {};=0D + var dataset =3D me.getDataset();=0D + var datasetIndex =3D me.index;=0D + var value =3D dataset.data[index];=0D + var xScale =3D me._xScale;=0D + var yScale =3D me._yScale;=0D + var lineModel =3D meta.dataset._model;=0D + var x, y;=0D +=0D + var options =3D me._resolveDataElementOptions(point, index);=0D +=0D + x =3D xScale.getPixelForValue(typeof value =3D=3D=3D 'object' ? value : = NaN, index, datasetIndex);=0D + y =3D reset ? yScale.getBasePixel() : me.calculatePointY(value, index, d= atasetIndex);=0D +=0D + // Utility=0D + point._xScale =3D xScale;=0D + point._yScale =3D yScale;=0D + point._options =3D options;=0D + point._datasetIndex =3D datasetIndex;=0D + point._index =3D index;=0D +=0D + // Desired view properties=0D + point._model =3D {=0D + x: x,=0D + y: y,=0D + skip: custom.skip || isNaN(x) || isNaN(y),=0D + // Appearance=0D + radius: options.radius,=0D + pointStyle: options.pointStyle,=0D + rotation: options.rotation,=0D + backgroundColor: options.backgroundColor,=0D + borderColor: options.borderColor,=0D + borderWidth: options.borderWidth,=0D + tension: valueOrDefault$6(custom.tension, lineModel ? lineModel.tension= : 0),=0D + steppedLine: lineModel ? lineModel.steppedLine : false,=0D + // Tooltip=0D + hitRadius: options.hitRadius=0D + };=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _resolveDatasetElementOptions: function(element) {=0D + var me =3D this;=0D + var config =3D me._config;=0D + var custom =3D element.custom || {};=0D + var options =3D me.chart.options;=0D + var lineOptions =3D options.elements.line;=0D + var values =3D core_datasetController.prototype._resolveDatasetElementOp= tions.apply(me, arguments);=0D +=0D + // The default behavior of lines is to break at null values, according=0D + // to https://github.com/chartjs/Chart.js/issues/2435#issuecomment-21671= 8158=0D + // This option gives lines the ability to span gaps=0D + values.spanGaps =3D valueOrDefault$6(config.spanGaps, options.spanGaps);= =0D + values.tension =3D valueOrDefault$6(config.lineTension, lineOptions.tens= ion);=0D + values.steppedLine =3D resolve$2([custom.steppedLine, config.steppedLine= , lineOptions.stepped]);=0D + values.clip =3D toClip(valueOrDefault$6(config.clip, defaultClip(me._xSc= ale, me._yScale, values.borderWidth)));=0D +=0D + return values;=0D + },=0D +=0D + calculatePointY: function(value, index, datasetIndex) {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var yScale =3D me._yScale;=0D + var sumPos =3D 0;=0D + var sumNeg =3D 0;=0D + var i, ds, dsMeta, stackedRightValue, rightValue, metasets, ilen;=0D +=0D + if (yScale.options.stacked) {=0D + rightValue =3D +yScale.getRightValue(value);=0D + metasets =3D chart._getSortedVisibleDatasetMetas();=0D + ilen =3D metasets.length;=0D +=0D + for (i =3D 0; i < ilen; ++i) {=0D + dsMeta =3D metasets[i];=0D + if (dsMeta.index =3D=3D=3D datasetIndex) {=0D + break;=0D + }=0D +=0D + ds =3D chart.data.datasets[dsMeta.index];=0D + if (dsMeta.type =3D=3D=3D 'line' && dsMeta.yAxisID =3D=3D=3D yScale.id= ) {=0D + stackedRightValue =3D +yScale.getRightValue(ds.data[index]);=0D + if (stackedRightValue < 0) {=0D + sumNeg +=3D stackedRightValue || 0;=0D + } else {=0D + sumPos +=3D stackedRightValue || 0;=0D + }=0D + }=0D + }=0D +=0D + if (rightValue < 0) {=0D + return yScale.getPixelForValue(sumNeg + rightValue);=0D + }=0D + return yScale.getPixelForValue(sumPos + rightValue);=0D + }=0D + return yScale.getPixelForValue(value);=0D + },=0D +=0D + updateBezierControlPoints: function() {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var meta =3D me.getMeta();=0D + var lineModel =3D meta.dataset._model;=0D + var area =3D chart.chartArea;=0D + var points =3D meta.data || [];=0D + var i, ilen, model, controlPoints;=0D +=0D + // Only consider points that are drawn in case the spanGaps option is us= ed=0D + if (lineModel.spanGaps) {=0D + points =3D points.filter(function(pt) {=0D + return !pt._model.skip;=0D + });=0D + }=0D +=0D + function capControlPoint(pt, min, max) {=0D + return Math.max(Math.min(pt, max), min);=0D + }=0D +=0D + if (lineModel.cubicInterpolationMode =3D=3D=3D 'monotone') {=0D + helpers$1.splineCurveMonotone(points);=0D + } else {=0D + for (i =3D 0, ilen =3D points.length; i < ilen; ++i) {=0D + model =3D points[i]._model;=0D + controlPoints =3D helpers$1.splineCurve(=0D + helpers$1.previousItem(points, i)._model,=0D + model,=0D + helpers$1.nextItem(points, i)._model,=0D + lineModel.tension=0D + );=0D + model.controlPointPreviousX =3D controlPoints.previous.x;=0D + model.controlPointPreviousY =3D controlPoints.previous.y;=0D + model.controlPointNextX =3D controlPoints.next.x;=0D + model.controlPointNextY =3D controlPoints.next.y;=0D + }=0D + }=0D +=0D + if (chart.options.elements.line.capBezierPoints) {=0D + for (i =3D 0, ilen =3D points.length; i < ilen; ++i) {=0D + model =3D points[i]._model;=0D + if (isPointInArea(model, area)) {=0D + if (i > 0 && isPointInArea(points[i - 1]._model, area)) {=0D + model.controlPointPreviousX =3D capControlPoint(model.controlPointPr= eviousX, area.left, area.right);=0D + model.controlPointPreviousY =3D capControlPoint(model.controlPointPr= eviousY, area.top, area.bottom);=0D + }=0D + if (i < points.length - 1 && isPointInArea(points[i + 1]._model, area= )) {=0D + model.controlPointNextX =3D capControlPoint(model.controlPointNextX,= area.left, area.right);=0D + model.controlPointNextY =3D capControlPoint(model.controlPointNextY,= area.top, area.bottom);=0D + }=0D + }=0D + }=0D + }=0D + },=0D +=0D + draw: function() {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var meta =3D me.getMeta();=0D + var points =3D meta.data || [];=0D + var area =3D chart.chartArea;=0D + var canvas =3D chart.canvas;=0D + var i =3D 0;=0D + var ilen =3D points.length;=0D + var clip;=0D +=0D + if (me._showLine) {=0D + clip =3D meta.dataset._model.clip;=0D +=0D + helpers$1.canvas.clipArea(chart.ctx, {=0D + left: clip.left =3D=3D=3D false ? 0 : area.left - clip.left,=0D + right: clip.right =3D=3D=3D false ? canvas.width : area.right + clip.r= ight,=0D + top: clip.top =3D=3D=3D false ? 0 : area.top - clip.top,=0D + bottom: clip.bottom =3D=3D=3D false ? canvas.height : area.bottom + cl= ip.bottom=0D + });=0D +=0D + meta.dataset.draw();=0D +=0D + helpers$1.canvas.unclipArea(chart.ctx);=0D + }=0D +=0D + // Draw the points=0D + for (; i < ilen; ++i) {=0D + points[i].draw(area);=0D + }=0D + },=0D +=0D + /**=0D + * @protected=0D + */=0D + setHoverStyle: function(point) {=0D + var model =3D point._model;=0D + var options =3D point._options;=0D + var getHoverColor =3D helpers$1.getHoverColor;=0D +=0D + point.$previousStyle =3D {=0D + backgroundColor: model.backgroundColor,=0D + borderColor: model.borderColor,=0D + borderWidth: model.borderWidth,=0D + radius: model.radius=0D + };=0D +=0D + model.backgroundColor =3D valueOrDefault$6(options.hoverBackgroundColor,= getHoverColor(options.backgroundColor));=0D + model.borderColor =3D valueOrDefault$6(options.hoverBorderColor, getHove= rColor(options.borderColor));=0D + model.borderWidth =3D valueOrDefault$6(options.hoverBorderWidth, options= .borderWidth);=0D + model.radius =3D valueOrDefault$6(options.hoverRadius, options.radius);= =0D + },=0D +}); =20 - // These methods are ordered by lifecycle. Utilities then follow. +var resolve$3 =3D helpers$1.options.resolve;=0D +=0D +core_defaults._set('polarArea', {=0D + scale: {=0D + type: 'radialLinear',=0D + angleLines: {=0D + display: false=0D + },=0D + gridLines: {=0D + circular: true=0D + },=0D + pointLabels: {=0D + display: false=0D + },=0D + ticks: {=0D + beginAtZero: true=0D + }=0D + },=0D +=0D + // Boolean - Whether to animate the rotation of the chart=0D + animation: {=0D + animateRotate: true,=0D + animateScale: true=0D + },=0D +=0D + startAngle: -0.5 * Math.PI,=0D + legendCallback: function(chart) {=0D + var list =3D document.createElement('ul');=0D + var data =3D chart.data;=0D + var datasets =3D data.datasets;=0D + var labels =3D data.labels;=0D + var i, ilen, listItem, listItemSpan;=0D +=0D + list.setAttribute('class', chart.id + '-legend');=0D + if (datasets.length) {=0D + for (i =3D 0, ilen =3D datasets[0].data.length; i < ilen; ++i) {=0D + listItem =3D list.appendChild(document.createElement('li'));=0D + listItemSpan =3D listItem.appendChild(document.createElement('span'));= =0D + listItemSpan.style.backgroundColor =3D datasets[0].backgroundColor[i];= =0D + if (labels[i]) {=0D + listItem.appendChild(document.createTextNode(labels[i]));=0D + }=0D + }=0D + }=0D +=0D + return list.outerHTML;=0D + },=0D + legend: {=0D + labels: {=0D + generateLabels: function(chart) {=0D + var data =3D chart.data;=0D + if (data.labels.length && data.datasets.length) {=0D + return data.labels.map(function(label, i) {=0D + var meta =3D chart.getDatasetMeta(0);=0D + var style =3D meta.controller.getStyle(i);=0D +=0D + return {=0D + text: label,=0D + fillStyle: style.backgroundColor,=0D + strokeStyle: style.borderColor,=0D + lineWidth: style.borderWidth,=0D + hidden: isNaN(data.datasets[0].data[i]) || meta.data[i].hidden,=0D +=0D + // Extra data used for toggling the correct item=0D + index: i=0D + };=0D + });=0D + }=0D + return [];=0D + }=0D + },=0D +=0D + onClick: function(e, legendItem) {=0D + var index =3D legendItem.index;=0D + var chart =3D this.chart;=0D + var i, ilen, meta;=0D +=0D + for (i =3D 0, ilen =3D (chart.data.datasets || []).length; i < ilen; ++= i) {=0D + meta =3D chart.getDatasetMeta(i);=0D + meta.data[index].hidden =3D !meta.data[index].hidden;=0D + }=0D +=0D + chart.update();=0D + }=0D + },=0D +=0D + // Need to override these to give a nice default=0D + tooltips: {=0D + callbacks: {=0D + title: function() {=0D + return '';=0D + },=0D + label: function(item, data) {=0D + return data.labels[item.index] + ': ' + item.yLabel;=0D + }=0D + }=0D + }=0D +});=0D +=0D +var controller_polarArea =3D core_datasetController.extend({=0D +=0D + dataElementType: elements.Arc,=0D +=0D + linkScales: helpers$1.noop,=0D +=0D + /**=0D + * @private=0D + */=0D + _dataElementOptions: [=0D + 'backgroundColor',=0D + 'borderColor',=0D + 'borderWidth',=0D + 'borderAlign',=0D + 'hoverBackgroundColor',=0D + 'hoverBorderColor',=0D + 'hoverBorderWidth',=0D + ],=0D +=0D + /**=0D + * @private=0D + */=0D + _getIndexScaleId: function() {=0D + return this.chart.scale.id;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getValueScaleId: function() {=0D + return this.chart.scale.id;=0D + },=0D +=0D + update: function(reset) {=0D + var me =3D this;=0D + var dataset =3D me.getDataset();=0D + var meta =3D me.getMeta();=0D + var start =3D me.chart.options.startAngle || 0;=0D + var starts =3D me._starts =3D [];=0D + var angles =3D me._angles =3D [];=0D + var arcs =3D meta.data;=0D + var i, ilen, angle;=0D +=0D + me._updateRadius();=0D +=0D + meta.count =3D me.countVisibleElements();=0D +=0D + for (i =3D 0, ilen =3D dataset.data.length; i < ilen; i++) {=0D + starts[i] =3D start;=0D + angle =3D me._computeAngle(i);=0D + angles[i] =3D angle;=0D + start +=3D angle;=0D + }=0D +=0D + for (i =3D 0, ilen =3D arcs.length; i < ilen; ++i) {=0D + arcs[i]._options =3D me._resolveDataElementOptions(arcs[i], i);=0D + me.updateElement(arcs[i], i, reset);=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _updateRadius: function() {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var chartArea =3D chart.chartArea;=0D + var opts =3D chart.options;=0D + var minSize =3D Math.min(chartArea.right - chartArea.left, chartArea.bot= tom - chartArea.top);=0D +=0D + chart.outerRadius =3D Math.max(minSize / 2, 0);=0D + chart.innerRadius =3D Math.max(opts.cutoutPercentage ? (chart.outerRadiu= s / 100) * (opts.cutoutPercentage) : 1, 0);=0D + chart.radiusLength =3D (chart.outerRadius - chart.innerRadius) / chart.g= etVisibleDatasetCount();=0D +=0D + me.outerRadius =3D chart.outerRadius - (chart.radiusLength * me.index);= =0D + me.innerRadius =3D me.outerRadius - chart.radiusLength;=0D + },=0D +=0D + updateElement: function(arc, index, reset) {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var dataset =3D me.getDataset();=0D + var opts =3D chart.options;=0D + var animationOpts =3D opts.animation;=0D + var scale =3D chart.scale;=0D + var labels =3D chart.data.labels;=0D +=0D + var centerX =3D scale.xCenter;=0D + var centerY =3D scale.yCenter;=0D +=0D + // var negHalfPI =3D -0.5 * Math.PI;=0D + var datasetStartAngle =3D opts.startAngle;=0D + var distance =3D arc.hidden ? 0 : scale.getDistanceFromCenterForValue(da= taset.data[index]);=0D + var startAngle =3D me._starts[index];=0D + var endAngle =3D startAngle + (arc.hidden ? 0 : me._angles[index]);=0D +=0D + var resetRadius =3D animationOpts.animateScale ? 0 : scale.getDistanceFr= omCenterForValue(dataset.data[index]);=0D + var options =3D arc._options || {};=0D +=0D + helpers$1.extend(arc, {=0D + // Utility=0D + _datasetIndex: me.index,=0D + _index: index,=0D + _scale: scale,=0D +=0D + // Desired view properties=0D + _model: {=0D + backgroundColor: options.backgroundColor,=0D + borderColor: options.borderColor,=0D + borderWidth: options.borderWidth,=0D + borderAlign: options.borderAlign,=0D + x: centerX,=0D + y: centerY,=0D + innerRadius: 0,=0D + outerRadius: reset ? resetRadius : distance,=0D + startAngle: reset && animationOpts.animateRotate ? datasetStartAngle := startAngle,=0D + endAngle: reset && animationOpts.animateRotate ? datasetStartAngle : e= ndAngle,=0D + label: helpers$1.valueAtIndexOrDefault(labels, index, labels[index])=0D + }=0D + });=0D +=0D + arc.pivot();=0D + },=0D +=0D + countVisibleElements: function() {=0D + var dataset =3D this.getDataset();=0D + var meta =3D this.getMeta();=0D + var count =3D 0;=0D +=0D + helpers$1.each(meta.data, function(element, index) {=0D + if (!isNaN(dataset.data[index]) && !element.hidden) {=0D + count++;=0D + }=0D + });=0D +=0D + return count;=0D + },=0D +=0D + /**=0D + * @protected=0D + */=0D + setHoverStyle: function(arc) {=0D + var model =3D arc._model;=0D + var options =3D arc._options;=0D + var getHoverColor =3D helpers$1.getHoverColor;=0D + var valueOrDefault =3D helpers$1.valueOrDefault;=0D +=0D + arc.$previousStyle =3D {=0D + backgroundColor: model.backgroundColor,=0D + borderColor: model.borderColor,=0D + borderWidth: model.borderWidth,=0D + };=0D +=0D + model.backgroundColor =3D valueOrDefault(options.hoverBackgroundColor, g= etHoverColor(options.backgroundColor));=0D + model.borderColor =3D valueOrDefault(options.hoverBorderColor, getHoverC= olor(options.borderColor));=0D + model.borderWidth =3D valueOrDefault(options.hoverBorderWidth, options.b= orderWidth);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _computeAngle: function(index) {=0D + var me =3D this;=0D + var count =3D this.getMeta().count;=0D + var dataset =3D me.getDataset();=0D + var meta =3D me.getMeta();=0D +=0D + if (isNaN(dataset.data[index]) || meta.data[index].hidden) {=0D + return 0;=0D + }=0D +=0D + // Scriptable options=0D + var context =3D {=0D + chart: me.chart,=0D + dataIndex: index,=0D + dataset: dataset,=0D + datasetIndex: me.index=0D + };=0D +=0D + return resolve$3([=0D + me.chart.options.elements.arc.angle,=0D + (2 * Math.PI) / count=0D + ], context, index);=0D + }=0D +}); =20 - beforeUpdate: noop$2, - update: function(maxWidth, maxHeight, margins) { - var me =3D this; +core_defaults._set('pie', helpers$1.clone(core_defaults.doughnut));=0D +core_defaults._set('pie', {=0D + cutoutPercentage: 0=0D +});=0D +=0D +// Pie charts are Doughnut chart with different defaults=0D +var controller_pie =3D controller_doughnut; =20 - // Update Lifecycle - Probably don't want to ever extend or overwrite th= is function ;) - me.beforeUpdate(); +var valueOrDefault$7 =3D helpers$1.valueOrDefault;=0D +=0D +core_defaults._set('radar', {=0D + spanGaps: false,=0D + scale: {=0D + type: 'radialLinear'=0D + },=0D + elements: {=0D + line: {=0D + fill: 'start',=0D + tension: 0 // no bezier in radar=0D + }=0D + }=0D +});=0D +=0D +var controller_radar =3D core_datasetController.extend({=0D + datasetElementType: elements.Line,=0D +=0D + dataElementType: elements.Point,=0D +=0D + linkScales: helpers$1.noop,=0D +=0D + /**=0D + * @private=0D + */=0D + _datasetElementOptions: [=0D + 'backgroundColor',=0D + 'borderWidth',=0D + 'borderColor',=0D + 'borderCapStyle',=0D + 'borderDash',=0D + 'borderDashOffset',=0D + 'borderJoinStyle',=0D + 'fill'=0D + ],=0D +=0D + /**=0D + * @private=0D + */=0D + _dataElementOptions: {=0D + backgroundColor: 'pointBackgroundColor',=0D + borderColor: 'pointBorderColor',=0D + borderWidth: 'pointBorderWidth',=0D + hitRadius: 'pointHitRadius',=0D + hoverBackgroundColor: 'pointHoverBackgroundColor',=0D + hoverBorderColor: 'pointHoverBorderColor',=0D + hoverBorderWidth: 'pointHoverBorderWidth',=0D + hoverRadius: 'pointHoverRadius',=0D + pointStyle: 'pointStyle',=0D + radius: 'pointRadius',=0D + rotation: 'pointRotation'=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getIndexScaleId: function() {=0D + return this.chart.scale.id;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getValueScaleId: function() {=0D + return this.chart.scale.id;=0D + },=0D +=0D + update: function(reset) {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var line =3D meta.dataset;=0D + var points =3D meta.data || [];=0D + var scale =3D me.chart.scale;=0D + var config =3D me._config;=0D + var i, ilen;=0D +=0D + // Compatibility: If the properties are defined with only the old name, = use those values=0D + if (config.tension !=3D=3D undefined && config.lineTension =3D=3D=3D und= efined) {=0D + config.lineTension =3D config.tension;=0D + }=0D +=0D + // Utility=0D + line._scale =3D scale;=0D + line._datasetIndex =3D me.index;=0D + // Data=0D + line._children =3D points;=0D + line._loop =3D true;=0D + // Model=0D + line._model =3D me._resolveDatasetElementOptions(line);=0D +=0D + line.pivot();=0D +=0D + // Update Points=0D + for (i =3D 0, ilen =3D points.length; i < ilen; ++i) {=0D + me.updateElement(points[i], i, reset);=0D + }=0D +=0D + // Update bezier control points=0D + me.updateBezierControlPoints();=0D +=0D + // Now pivot the point for animation=0D + for (i =3D 0, ilen =3D points.length; i < ilen; ++i) {=0D + points[i].pivot();=0D + }=0D + },=0D +=0D + updateElement: function(point, index, reset) {=0D + var me =3D this;=0D + var custom =3D point.custom || {};=0D + var dataset =3D me.getDataset();=0D + var scale =3D me.chart.scale;=0D + var pointPosition =3D scale.getPointPositionForValue(index, dataset.data= [index]);=0D + var options =3D me._resolveDataElementOptions(point, index);=0D + var lineModel =3D me.getMeta().dataset._model;=0D + var x =3D reset ? scale.xCenter : pointPosition.x;=0D + var y =3D reset ? scale.yCenter : pointPosition.y;=0D +=0D + // Utility=0D + point._scale =3D scale;=0D + point._options =3D options;=0D + point._datasetIndex =3D me.index;=0D + point._index =3D index;=0D +=0D + // Desired view properties=0D + point._model =3D {=0D + x: x, // value not used in dataset scale, but we want a consistent API = between scales=0D + y: y,=0D + skip: custom.skip || isNaN(x) || isNaN(y),=0D + // Appearance=0D + radius: options.radius,=0D + pointStyle: options.pointStyle,=0D + rotation: options.rotation,=0D + backgroundColor: options.backgroundColor,=0D + borderColor: options.borderColor,=0D + borderWidth: options.borderWidth,=0D + tension: valueOrDefault$7(custom.tension, lineModel ? lineModel.tension= : 0),=0D +=0D + // Tooltip=0D + hitRadius: options.hitRadius=0D + };=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _resolveDatasetElementOptions: function() {=0D + var me =3D this;=0D + var config =3D me._config;=0D + var options =3D me.chart.options;=0D + var values =3D core_datasetController.prototype._resolveDatasetElementOp= tions.apply(me, arguments);=0D +=0D + values.spanGaps =3D valueOrDefault$7(config.spanGaps, options.spanGaps);= =0D + values.tension =3D valueOrDefault$7(config.lineTension, options.elements= .line.tension);=0D +=0D + return values;=0D + },=0D +=0D + updateBezierControlPoints: function() {=0D + var me =3D this;=0D + var meta =3D me.getMeta();=0D + var area =3D me.chart.chartArea;=0D + var points =3D meta.data || [];=0D + var i, ilen, model, controlPoints;=0D +=0D + // Only consider points that are drawn in case the spanGaps option is us= ed=0D + if (meta.dataset._model.spanGaps) {=0D + points =3D points.filter(function(pt) {=0D + return !pt._model.skip;=0D + });=0D + }=0D +=0D + function capControlPoint(pt, min, max) {=0D + return Math.max(Math.min(pt, max), min);=0D + }=0D +=0D + for (i =3D 0, ilen =3D points.length; i < ilen; ++i) {=0D + model =3D points[i]._model;=0D + controlPoints =3D helpers$1.splineCurve(=0D + helpers$1.previousItem(points, i, true)._model,=0D + model,=0D + helpers$1.nextItem(points, i, true)._model,=0D + model.tension=0D + );=0D +=0D + // Prevent the bezier going outside of the bounds of the graph=0D + model.controlPointPreviousX =3D capControlPoint(controlPoints.previous.= x, area.left, area.right);=0D + model.controlPointPreviousY =3D capControlPoint(controlPoints.previous.= y, area.top, area.bottom);=0D + model.controlPointNextX =3D capControlPoint(controlPoints.next.x, area.= left, area.right);=0D + model.controlPointNextY =3D capControlPoint(controlPoints.next.y, area.= top, area.bottom);=0D + }=0D + },=0D +=0D + setHoverStyle: function(point) {=0D + var model =3D point._model;=0D + var options =3D point._options;=0D + var getHoverColor =3D helpers$1.getHoverColor;=0D +=0D + point.$previousStyle =3D {=0D + backgroundColor: model.backgroundColor,=0D + borderColor: model.borderColor,=0D + borderWidth: model.borderWidth,=0D + radius: model.radius=0D + };=0D +=0D + model.backgroundColor =3D valueOrDefault$7(options.hoverBackgroundColor,= getHoverColor(options.backgroundColor));=0D + model.borderColor =3D valueOrDefault$7(options.hoverBorderColor, getHove= rColor(options.borderColor));=0D + model.borderWidth =3D valueOrDefault$7(options.hoverBorderWidth, options= .borderWidth);=0D + model.radius =3D valueOrDefault$7(options.hoverRadius, options.radius);= =0D + }=0D +}); =20 - // Absorb the master measurements - me.maxWidth =3D maxWidth; - me.maxHeight =3D maxHeight; - me.margins =3D margins; +core_defaults._set('scatter', {=0D + hover: {=0D + mode: 'single'=0D + },=0D +=0D + scales: {=0D + xAxes: [{=0D + id: 'x-axis-1', // need an ID so datasets can reference the scale=0D + type: 'linear', // scatter should not use a category axis=0D + position: 'bottom'=0D + }],=0D + yAxes: [{=0D + id: 'y-axis-1',=0D + type: 'linear',=0D + position: 'left'=0D + }]=0D + },=0D +=0D + tooltips: {=0D + callbacks: {=0D + title: function() {=0D + return ''; // doesn't make sense for scatter since data are format= ted as a point=0D + },=0D + label: function(item) {=0D + return '(' + item.xLabel + ', ' + item.yLabel + ')';=0D + }=0D + }=0D + }=0D +});=0D +=0D +core_defaults._set('global', {=0D + datasets: {=0D + scatter: {=0D + showLine: false=0D + }=0D + }=0D +});=0D +=0D +// Scatter charts use line controllers=0D +var controller_scatter =3D controller_line; =20 - // Dimensions - me.beforeSetDimensions(); - me.setDimensions(); - me.afterSetDimensions(); - // Labels - me.beforeBuildLabels(); - me.buildLabels(); - me.afterBuildLabels(); +// NOTE export a map in which the key represents the controller type, not= =0D +// the class, and so must be CamelCase in order to be correctly retrieved= =0D +// by the controller in core.controller.js (`controllers[meta.type]`).=0D +=0D +var controllers =3D {=0D + bar: controller_bar,=0D + bubble: controller_bubble,=0D + doughnut: controller_doughnut,=0D + horizontalBar: controller_horizontalBar,=0D + line: controller_line,=0D + polarArea: controller_polarArea,=0D + pie: controller_pie,=0D + radar: controller_radar,=0D + scatter: controller_scatter=0D +}; =20 - // Fit - me.beforeFit(); - me.fit(); - me.afterFit(); - // - me.afterUpdate(); +/**=0D + * Helper function to get relative position for an event=0D + * @param {Event|IEvent} event - The event to get the position for=0D + * @param {Chart} chart - The chart=0D + * @returns {object} the event position=0D + */=0D +function getRelativePosition(e, chart) {=0D + if (e.native) {=0D + return {=0D + x: e.x,=0D + y: e.y=0D + };=0D + }=0D +=0D + return helpers$1.getRelativePosition(e, chart);=0D +}=0D +=0D +/**=0D + * Helper function to traverse all of the visible elements in the chart=0D + * @param {Chart} chart - the chart=0D + * @param {function} handler - the callback to execute for each visible it= em=0D + */=0D +function parseVisibleItems(chart, handler) {=0D + var metasets =3D chart._getSortedVisibleDatasetMetas();=0D + var metadata, i, j, ilen, jlen, element;=0D +=0D + for (i =3D 0, ilen =3D metasets.length; i < ilen; ++i) {=0D + metadata =3D metasets[i].data;=0D + for (j =3D 0, jlen =3D metadata.length; j < jlen; ++j) {=0D + element =3D metadata[j];=0D + if (!element._view.skip) {=0D + handler(element);=0D + }=0D + }=0D + }=0D +}=0D +=0D +/**=0D + * Helper function to get the items that intersect the event position=0D + * @param {ChartElement[]} items - elements to filter=0D + * @param {object} position - the point to be nearest to=0D + * @return {ChartElement[]} the nearest items=0D + */=0D +function getIntersectItems(chart, position) {=0D + var elements =3D [];=0D +=0D + parseVisibleItems(chart, function(element) {=0D + if (element.inRange(position.x, position.y)) {=0D + elements.push(element);=0D + }=0D + });=0D +=0D + return elements;=0D +}=0D +=0D +/**=0D + * Helper function to get the items nearest to the event position consider= ing all visible items in teh chart=0D + * @param {Chart} chart - the chart to look at elements from=0D + * @param {object} position - the point to be nearest to=0D + * @param {boolean} intersect - if true, only consider items that intersec= t the position=0D + * @param {function} distanceMetric - function to provide the distance bet= ween points=0D + * @return {ChartElement[]} the nearest items=0D + */=0D +function getNearestItems(chart, position, intersect, distanceMetric) {=0D + var minDistance =3D Number.POSITIVE_INFINITY;=0D + var nearestItems =3D [];=0D +=0D + parseVisibleItems(chart, function(element) {=0D + if (intersect && !element.inRange(position.x, position.y)) {=0D + return;=0D + }=0D +=0D + var center =3D element.getCenterPoint();=0D + var distance =3D distanceMetric(position, center);=0D + if (distance < minDistance) {=0D + nearestItems =3D [element];=0D + minDistance =3D distance;=0D + } else if (distance =3D=3D=3D minDistance) {=0D + // Can have multiple items at the same distance in which case we sort b= y size=0D + nearestItems.push(element);=0D + }=0D + });=0D +=0D + return nearestItems;=0D +}=0D +=0D +/**=0D + * Get a distance metric function for two points based on the=0D + * axis mode setting=0D + * @param {string} axis - the axis mode. x|y|xy=0D + */=0D +function getDistanceMetricForAxis(axis) {=0D + var useX =3D axis.indexOf('x') !=3D=3D -1;=0D + var useY =3D axis.indexOf('y') !=3D=3D -1;=0D +=0D + return function(pt1, pt2) {=0D + var deltaX =3D useX ? Math.abs(pt1.x - pt2.x) : 0;=0D + var deltaY =3D useY ? Math.abs(pt1.y - pt2.y) : 0;=0D + return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));=0D + };=0D +}=0D +=0D +function indexMode(chart, e, options) {=0D + var position =3D getRelativePosition(e, chart);=0D + // Default axis for index mode is 'x' to match old behaviour=0D + options.axis =3D options.axis || 'x';=0D + var distanceMetric =3D getDistanceMetricForAxis(options.axis);=0D + var items =3D options.intersect ? getIntersectItems(chart, position) : ge= tNearestItems(chart, position, false, distanceMetric);=0D + var elements =3D [];=0D +=0D + if (!items.length) {=0D + return [];=0D + }=0D +=0D + chart._getSortedVisibleDatasetMetas().forEach(function(meta) {=0D + var element =3D meta.data[items[0]._index];=0D +=0D + // don't count items that are skipped (null data)=0D + if (element && !element._view.skip) {=0D + elements.push(element);=0D + }=0D + });=0D +=0D + return elements;=0D +}=0D +=0D +/**=0D + * @interface IInteractionOptions=0D + */=0D +/**=0D + * If true, only consider items that intersect the point=0D + * @name IInterfaceOptions#boolean=0D + * @type Boolean=0D + */=0D +=0D +/**=0D + * Contains interaction related functions=0D + * @namespace Chart.Interaction=0D + */=0D +var core_interaction =3D {=0D + // Helper function for different modes=0D + modes: {=0D + single: function(chart, e) {=0D + var position =3D getRelativePosition(e, chart);=0D + var elements =3D [];=0D +=0D + parseVisibleItems(chart, function(element) {=0D + if (element.inRange(position.x, position.y)) {=0D + elements.push(element);=0D + return elements;=0D + }=0D + });=0D +=0D + return elements.slice(0, 1);=0D + },=0D +=0D + /**=0D + * @function Chart.Interaction.modes.label=0D + * @deprecated since version 2.4.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D + label: indexMode,=0D +=0D + /**=0D + * Returns items at the same index. If the options.intersect parameter i= s true, we only return items if we intersect something=0D + * If the options.intersect mode is false, we find the nearest item and = return the items at the same index as that item=0D + * @function Chart.Interaction.modes.index=0D + * @since v2.4.0=0D + * @param {Chart} chart - the chart we are returning items from=0D + * @param {Event} e - the event we are find things at=0D + * @param {IInteractionOptions} options - options to use during interact= ion=0D + * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned=0D + */=0D + index: indexMode,=0D +=0D + /**=0D + * Returns items in the same dataset. If the options.intersect parameter= is true, we only return items if we intersect something=0D + * If the options.intersect is false, we find the nearest item and retur= n the items in that dataset=0D + * @function Chart.Interaction.modes.dataset=0D + * @param {Chart} chart - the chart we are returning items from=0D + * @param {Event} e - the event we are find things at=0D + * @param {IInteractionOptions} options - options to use during interact= ion=0D + * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned=0D + */=0D + dataset: function(chart, e, options) {=0D + var position =3D getRelativePosition(e, chart);=0D + options.axis =3D options.axis || 'xy';=0D + var distanceMetric =3D getDistanceMetricForAxis(options.axis);=0D + var items =3D options.intersect ? getIntersectItems(chart, position) : = getNearestItems(chart, position, false, distanceMetric);=0D +=0D + if (items.length > 0) {=0D + items =3D chart.getDatasetMeta(items[0]._datasetIndex).data;=0D + }=0D +=0D + return items;=0D + },=0D +=0D + /**=0D + * @function Chart.Interaction.modes.x-axis=0D + * @deprecated since version 2.4.0. Use index mode and intersect =3D=3D = true=0D + * @todo remove at version 3=0D + * @private=0D + */=0D + 'x-axis': function(chart, e) {=0D + return indexMode(chart, e, {intersect: false});=0D + },=0D +=0D + /**=0D + * Point mode returns all elements that hit test based on the event posi= tion=0D + * of the event=0D + * @function Chart.Interaction.modes.intersect=0D + * @param {Chart} chart - the chart we are returning items from=0D + * @param {Event} e - the event we are find things at=0D + * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned=0D + */=0D + point: function(chart, e) {=0D + var position =3D getRelativePosition(e, chart);=0D + return getIntersectItems(chart, position);=0D + },=0D +=0D + /**=0D + * nearest mode returns the element closest to the point=0D + * @function Chart.Interaction.modes.intersect=0D + * @param {Chart} chart - the chart we are returning items from=0D + * @param {Event} e - the event we are find things at=0D + * @param {IInteractionOptions} options - options to use=0D + * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned=0D + */=0D + nearest: function(chart, e, options) {=0D + var position =3D getRelativePosition(e, chart);=0D + options.axis =3D options.axis || 'xy';=0D + var distanceMetric =3D getDistanceMetricForAxis(options.axis);=0D + return getNearestItems(chart, position, options.intersect, distanceMetr= ic);=0D + },=0D +=0D + /**=0D + * x mode returns the elements that hit-test at the current x coordinate= =0D + * @function Chart.Interaction.modes.x=0D + * @param {Chart} chart - the chart we are returning items from=0D + * @param {Event} e - the event we are find things at=0D + * @param {IInteractionOptions} options - options to use=0D + * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned=0D + */=0D + x: function(chart, e, options) {=0D + var position =3D getRelativePosition(e, chart);=0D + var items =3D [];=0D + var intersectsItem =3D false;=0D +=0D + parseVisibleItems(chart, function(element) {=0D + if (element.inXRange(position.x)) {=0D + items.push(element);=0D + }=0D +=0D + if (element.inRange(position.x, position.y)) {=0D + intersectsItem =3D true;=0D + }=0D + });=0D +=0D + // If we want to trigger on an intersect and we don't have any items=0D + // that intersect the position, return nothing=0D + if (options.intersect && !intersectsItem) {=0D + items =3D [];=0D + }=0D + return items;=0D + },=0D +=0D + /**=0D + * y mode returns the elements that hit-test at the current y coordinate= =0D + * @function Chart.Interaction.modes.y=0D + * @param {Chart} chart - the chart we are returning items from=0D + * @param {Event} e - the event we are find things at=0D + * @param {IInteractionOptions} options - options to use=0D + * @return {Chart.Element[]} Array of elements that are under the point.= If none are found, an empty array is returned=0D + */=0D + y: function(chart, e, options) {=0D + var position =3D getRelativePosition(e, chart);=0D + var items =3D [];=0D + var intersectsItem =3D false;=0D +=0D + parseVisibleItems(chart, function(element) {=0D + if (element.inYRange(position.y)) {=0D + items.push(element);=0D + }=0D +=0D + if (element.inRange(position.x, position.y)) {=0D + intersectsItem =3D true;=0D + }=0D + });=0D +=0D + // If we want to trigger on an intersect and we don't have any items=0D + // that intersect the position, return nothing=0D + if (options.intersect && !intersectsItem) {=0D + items =3D [];=0D + }=0D + return items;=0D + }=0D + }=0D +}; =20 - return me.minSize; +var extend =3D helpers$1.extend;=0D +=0D +function filterByPosition(array, position) {=0D + return helpers$1.where(array, function(v) {=0D + return v.pos =3D=3D=3D position;=0D + });=0D +}=0D +=0D +function sortByWeight(array, reverse) {=0D + return array.sort(function(a, b) {=0D + var v0 =3D reverse ? b : a;=0D + var v1 =3D reverse ? a : b;=0D + return v0.weight =3D=3D=3D v1.weight ?=0D + v0.index - v1.index :=0D + v0.weight - v1.weight;=0D + });=0D +}=0D +=0D +function wrapBoxes(boxes) {=0D + var layoutBoxes =3D [];=0D + var i, ilen, box;=0D +=0D + for (i =3D 0, ilen =3D (boxes || []).length; i < ilen; ++i) {=0D + box =3D boxes[i];=0D + layoutBoxes.push({=0D + index: i,=0D + box: box,=0D + pos: box.position,=0D + horizontal: box.isHorizontal(),=0D + weight: box.weight=0D + });=0D + }=0D + return layoutBoxes;=0D +}=0D +=0D +function setLayoutDims(layouts, params) {=0D + var i, ilen, layout;=0D + for (i =3D 0, ilen =3D layouts.length; i < ilen; ++i) {=0D + layout =3D layouts[i];=0D + // store width used instead of chartArea.w in fitBoxes=0D + layout.width =3D layout.horizontal=0D + ? layout.box.fullWidth && params.availableWidth=0D + : params.vBoxMaxWidth;=0D + // store height used instead of chartArea.h in fitBoxes=0D + layout.height =3D layout.horizontal && params.hBoxMaxHeight;=0D + }=0D +}=0D +=0D +function buildLayoutBoxes(boxes) {=0D + var layoutBoxes =3D wrapBoxes(boxes);=0D + var left =3D sortByWeight(filterByPosition(layoutBoxes, 'left'), true);=0D + var right =3D sortByWeight(filterByPosition(layoutBoxes, 'right'));=0D + var top =3D sortByWeight(filterByPosition(layoutBoxes, 'top'), true);=0D + var bottom =3D sortByWeight(filterByPosition(layoutBoxes, 'bottom'));=0D +=0D + return {=0D + leftAndTop: left.concat(top),=0D + rightAndBottom: right.concat(bottom),=0D + chartArea: filterByPosition(layoutBoxes, 'chartArea'),=0D + vertical: left.concat(right),=0D + horizontal: top.concat(bottom)=0D + };=0D +}=0D +=0D +function getCombinedMax(maxPadding, chartArea, a, b) {=0D + return Math.max(maxPadding[a], chartArea[a]) + Math.max(maxPadding[b], ch= artArea[b]);=0D +}=0D +=0D +function updateDims(chartArea, params, layout) {=0D + var box =3D layout.box;=0D + var maxPadding =3D chartArea.maxPadding;=0D + var newWidth, newHeight;=0D +=0D + if (layout.size) {=0D + // this layout was already counted for, lets first reduce old size=0D + chartArea[layout.pos] -=3D layout.size;=0D + }=0D + layout.size =3D layout.horizontal ? box.height : box.width;=0D + chartArea[layout.pos] +=3D layout.size;=0D +=0D + if (box.getPadding) {=0D + var boxPadding =3D box.getPadding();=0D + maxPadding.top =3D Math.max(maxPadding.top, boxPadding.top);=0D + maxPadding.left =3D Math.max(maxPadding.left, boxPadding.left);=0D + maxPadding.bottom =3D Math.max(maxPadding.bottom, boxPadding.bottom);=0D + maxPadding.right =3D Math.max(maxPadding.right, boxPadding.right);=0D + }=0D +=0D + newWidth =3D params.outerWidth - getCombinedMax(maxPadding, chartArea, 'l= eft', 'right');=0D + newHeight =3D params.outerHeight - getCombinedMax(maxPadding, chartArea, = 'top', 'bottom');=0D +=0D + if (newWidth !=3D=3D chartArea.w || newHeight !=3D=3D chartArea.h) {=0D + chartArea.w =3D newWidth;=0D + chartArea.h =3D newHeight;=0D +=0D + // return true if chart area changed in layout's direction=0D + var sizes =3D layout.horizontal ? [newWidth, chartArea.w] : [newHeight, = chartArea.h];=0D + return sizes[0] !=3D=3D sizes[1] && (!isNaN(sizes[0]) || !isNaN(sizes[1]= ));=0D + }=0D +}=0D +=0D +function handleMaxPadding(chartArea) {=0D + var maxPadding =3D chartArea.maxPadding;=0D +=0D + function updatePos(pos) {=0D + var change =3D Math.max(maxPadding[pos] - chartArea[pos], 0);=0D + chartArea[pos] +=3D change;=0D + return change;=0D + }=0D + chartArea.y +=3D updatePos('top');=0D + chartArea.x +=3D updatePos('left');=0D + updatePos('right');=0D + updatePos('bottom');=0D +}=0D +=0D +function getMargins(horizontal, chartArea) {=0D + var maxPadding =3D chartArea.maxPadding;=0D +=0D + function marginForPositions(positions) {=0D + var margin =3D {left: 0, top: 0, right: 0, bottom: 0};=0D + positions.forEach(function(pos) {=0D + margin[pos] =3D Math.max(chartArea[pos], maxPadding[pos]);=0D + });=0D + return margin;=0D + }=0D +=0D + return horizontal=0D + ? marginForPositions(['left', 'right'])=0D + : marginForPositions(['top', 'bottom']);=0D +}=0D +=0D +function fitBoxes(boxes, chartArea, params) {=0D + var refitBoxes =3D [];=0D + var i, ilen, layout, box, refit, changed;=0D +=0D + for (i =3D 0, ilen =3D boxes.length; i < ilen; ++i) {=0D + layout =3D boxes[i];=0D + box =3D layout.box;=0D +=0D + box.update(=0D + layout.width || chartArea.w,=0D + layout.height || chartArea.h,=0D + getMargins(layout.horizontal, chartArea)=0D + );=0D + if (updateDims(chartArea, params, layout)) {=0D + changed =3D true;=0D + if (refitBoxes.length) {=0D + // Dimensions changed and there were non full width boxes before this= =0D + // -> we have to refit those=0D + refit =3D true;=0D + }=0D + }=0D + if (!box.fullWidth) { // fullWidth boxes don't need to be re-fitted in a= ny case=0D + refitBoxes.push(layout);=0D + }=0D + }=0D +=0D + return refit ? fitBoxes(refitBoxes, chartArea, params) || changed : chang= ed;=0D +}=0D +=0D +function placeBoxes(boxes, chartArea, params) {=0D + var userPadding =3D params.padding;=0D + var x =3D chartArea.x;=0D + var y =3D chartArea.y;=0D + var i, ilen, layout, box;=0D +=0D + for (i =3D 0, ilen =3D boxes.length; i < ilen; ++i) {=0D + layout =3D boxes[i];=0D + box =3D layout.box;=0D + if (layout.horizontal) {=0D + box.left =3D box.fullWidth ? userPadding.left : chartArea.left;=0D + box.right =3D box.fullWidth ? params.outerWidth - userPadding.right : c= hartArea.left + chartArea.w;=0D + box.top =3D y;=0D + box.bottom =3D y + box.height;=0D + box.width =3D box.right - box.left;=0D + y =3D box.bottom;=0D + } else {=0D + box.left =3D x;=0D + box.right =3D x + box.width;=0D + box.top =3D chartArea.top;=0D + box.bottom =3D chartArea.top + chartArea.h;=0D + box.height =3D box.bottom - box.top;=0D + x =3D box.right;=0D + }=0D + }=0D +=0D + chartArea.x =3D x;=0D + chartArea.y =3D y;=0D +}=0D +=0D +core_defaults._set('global', {=0D + layout: {=0D + padding: {=0D + top: 0,=0D + right: 0,=0D + bottom: 0,=0D + left: 0=0D + }=0D + }=0D +});=0D +=0D +/**=0D + * @interface ILayoutItem=0D + * @prop {string} position - The position of the item in the chart layout.= Possible values are=0D + * 'left', 'top', 'right', 'bottom', and 'chartArea'=0D + * @prop {number} weight - The weight used to sort the item. Higher weight= s are further away from the chart area=0D + * @prop {boolean} fullWidth - if true, and the item is horizontal, then p= ush vertical boxes down=0D + * @prop {function} isHorizontal - returns true if the layout item is hori= zontal (ie. top or bottom)=0D + * @prop {function} update - Takes two parameters: width and height. Retur= ns size of item=0D + * @prop {function} getPadding - Returns an object with padding on the ed= ges=0D + * @prop {number} width - Width of item. Must be valid after update()=0D + * @prop {number} height - Height of item. Must be valid after update()=0D + * @prop {number} left - Left edge of the item. Set by layout system and c= annot be used in update=0D + * @prop {number} top - Top edge of the item. Set by layout system and can= not be used in update=0D + * @prop {number} right - Right edge of the item. Set by layout system and= cannot be used in update=0D + * @prop {number} bottom - Bottom edge of the item. Set by layout system a= nd cannot be used in update=0D + */=0D +=0D +// The layout service is very self explanatory. It's responsible for the = layout within a chart.=0D +// Scales, Legends and Plugins all rely on the layout service and can easi= ly register to be placed anywhere they need=0D +// It is this service's responsibility of carrying out that layout.=0D +var core_layouts =3D {=0D + defaults: {},=0D +=0D + /**=0D + * Register a box to a chart.=0D + * A box is simply a reference to an object that requires layout. eg. Sca= les, Legend, Title.=0D + * @param {Chart} chart - the chart to use=0D + * @param {ILayoutItem} item - the item to add to be layed out=0D + */=0D + addBox: function(chart, item) {=0D + if (!chart.boxes) {=0D + chart.boxes =3D [];=0D + }=0D +=0D + // initialize item with default values=0D + item.fullWidth =3D item.fullWidth || false;=0D + item.position =3D item.position || 'top';=0D + item.weight =3D item.weight || 0;=0D + item._layers =3D item._layers || function() {=0D + return [{=0D + z: 0,=0D + draw: function() {=0D + item.draw.apply(item, arguments);=0D + }=0D + }];=0D + };=0D +=0D + chart.boxes.push(item);=0D + },=0D +=0D + /**=0D + * Remove a layoutItem from a chart=0D + * @param {Chart} chart - the chart to remove the box from=0D + * @param {ILayoutItem} layoutItem - the item to remove from the layout=0D + */=0D + removeBox: function(chart, layoutItem) {=0D + var index =3D chart.boxes ? chart.boxes.indexOf(layoutItem) : -1;=0D + if (index !=3D=3D -1) {=0D + chart.boxes.splice(index, 1);=0D + }=0D + },=0D +=0D + /**=0D + * Sets (or updates) options on the given `item`.=0D + * @param {Chart} chart - the chart in which the item lives (or will be a= dded to)=0D + * @param {ILayoutItem} item - the item to configure with the given optio= ns=0D + * @param {object} options - the new item options.=0D + */=0D + configure: function(chart, item, options) {=0D + var props =3D ['fullWidth', 'position', 'weight'];=0D + var ilen =3D props.length;=0D + var i =3D 0;=0D + var prop;=0D +=0D + for (; i < ilen; ++i) {=0D + prop =3D props[i];=0D + if (options.hasOwnProperty(prop)) {=0D + item[prop] =3D options[prop];=0D + }=0D + }=0D + },=0D +=0D + /**=0D + * Fits boxes of the given chart into the given size by having each box m= easure itself=0D + * then running a fitting algorithm=0D + * @param {Chart} chart - the chart=0D + * @param {number} width - the width to fit into=0D + * @param {number} height - the height to fit into=0D + */=0D + update: function(chart, width, height) {=0D + if (!chart) {=0D + return;=0D + }=0D +=0D + var layoutOptions =3D chart.options.layout || {};=0D + var padding =3D helpers$1.options.toPadding(layoutOptions.padding);=0D +=0D + var availableWidth =3D width - padding.width;=0D + var availableHeight =3D height - padding.height;=0D + var boxes =3D buildLayoutBoxes(chart.boxes);=0D + var verticalBoxes =3D boxes.vertical;=0D + var horizontalBoxes =3D boxes.horizontal;=0D +=0D + // Essentially we now have any number of boxes on each of the 4 sides.=0D + // Our canvas looks like the following.=0D + // The areas L1 and L2 are the left axes. R1 is the right axis, T1 is th= e top axis and=0D + // B1 is the bottom axis=0D + // There are also 4 quadrant-like locations (left to right instead of cl= ockwise) reserved for chart overlays=0D + // These locations are single-box locations only, when trying to registe= r a chartArea location that is already taken,=0D + // an error will be thrown.=0D + //=0D + // |----------------------------------------------------|=0D + // | T1 (Full Width) |=0D + // |----------------------------------------------------|=0D + // | | | T2 | |=0D + // | |----|-------------------------------------|----|=0D + // | | | C1 | | C2 | |=0D + // | | |----| |----| |=0D + // | | | | |=0D + // | L1 | L2 | ChartArea (C0) | R1 |=0D + // | | | | |=0D + // | | |----| |----| |=0D + // | | | C3 | | C4 | |=0D + // | |----|-------------------------------------|----|=0D + // | | | B1 | |=0D + // |----------------------------------------------------|=0D + // | B2 (Full Width) |=0D + // |----------------------------------------------------|=0D + //=0D +=0D + var params =3D Object.freeze({=0D + outerWidth: width,=0D + outerHeight: height,=0D + padding: padding,=0D + availableWidth: availableWidth,=0D + vBoxMaxWidth: availableWidth / 2 / verticalBoxes.length,=0D + hBoxMaxHeight: availableHeight / 2=0D + });=0D + var chartArea =3D extend({=0D + maxPadding: extend({}, padding),=0D + w: availableWidth,=0D + h: availableHeight,=0D + x: padding.left,=0D + y: padding.top=0D + }, padding);=0D +=0D + setLayoutDims(verticalBoxes.concat(horizontalBoxes), params);=0D +=0D + // First fit vertical boxes=0D + fitBoxes(verticalBoxes, chartArea, params);=0D +=0D + // Then fit horizontal boxes=0D + if (fitBoxes(horizontalBoxes, chartArea, params)) {=0D + // if the area changed, re-fit vertical boxes=0D + fitBoxes(verticalBoxes, chartArea, params);=0D + }=0D +=0D + handleMaxPadding(chartArea);=0D +=0D + // Finally place the boxes to correct coordinates=0D + placeBoxes(boxes.leftAndTop, chartArea, params);=0D +=0D + // Move to opposite side of chart=0D + chartArea.x +=3D chartArea.w;=0D + chartArea.y +=3D chartArea.h;=0D +=0D + placeBoxes(boxes.rightAndBottom, chartArea, params);=0D +=0D + chart.chartArea =3D {=0D + left: chartArea.left,=0D + top: chartArea.top,=0D + right: chartArea.left + chartArea.w,=0D + bottom: chartArea.top + chartArea.h=0D + };=0D +=0D + // Finally update boxes in chartArea (radial scale for example)=0D + helpers$1.each(boxes.chartArea, function(layout) {=0D + var box =3D layout.box;=0D + extend(box, chart.chartArea);=0D + box.update(chartArea.w, chartArea.h);=0D + });=0D + }=0D +}; =20 - }, - afterUpdate: noop$2, - - // - - beforeSetDimensions: noop$2, - setDimensions: function() { - var me =3D this; - // Set the unconstrained dimension before label rotation - if (me.isHorizontal()) { - // Reset position before calculating rotation - me.width =3D me.maxWidth; - me.left =3D 0; - me.right =3D me.width; - } else { - me.height =3D me.maxHeight; +/**=0D + * Platform fallback implementation (minimal).=0D + * @see https://github.com/chartjs/Chart.js/pull/4591#issuecomment-3195759= 39=0D + */=0D +=0D +var platform_basic =3D {=0D + acquireContext: function(item) {=0D + if (item && item.canvas) {=0D + // Support for any object associated to a canvas (including a context2d= )=0D + item =3D item.canvas;=0D + }=0D +=0D + return item && item.getContext('2d') || null;=0D + }=0D +}; =20 - // Reset position before calculating rotation - me.top =3D 0; - me.bottom =3D me.height; - } +var platform_dom =3D "/*\r\n * DOM element rendering detection\r\n * https= ://davidwalsh.name/detect-node-insertion\r\n */\r\n@keyframes chartjs-rende= r-animation {\r\n\tfrom { opacity: 0.99; }\r\n\tto { opacity: 1; }\r\n}\r\n= \r\n.chartjs-render-monitor {\r\n\tanimation: chartjs-render-animation 0.00= 1s;\r\n}\r\n\r\n/*\r\n * DOM element resizing detection\r\n * https://githu= b.com/marcj/css-element-queries\r\n */\r\n.chartjs-size-monitor,\r\n.chartj= s-size-monitor-expand,\r\n.chartjs-size-monitor-shrink {\r\n\tposition: abs= olute;\r\n\tdirection: ltr;\r\n\tleft: 0;\r\n\ttop: 0;\r\n\tright: 0;\r\n\t= bottom: 0;\r\n\toverflow: hidden;\r\n\tpointer-events: none;\r\n\tvisibilit= y: hidden;\r\n\tz-index: -1;\r\n}\r\n\r\n.chartjs-size-monitor-expand > div= {\r\n\tposition: absolute;\r\n\twidth: 1000000px;\r\n\theight: 1000000px;\= r\n\tleft: 0;\r\n\ttop: 0;\r\n}\r\n\r\n.chartjs-size-monitor-shrink > div {= \r\n\tposition: absolute;\r\n\twidth: 200%;\r\n\theight: 200%;\r\n\tleft: 0= ;\r\n\ttop: 0;\r\n}\r\n"; =20 - // Reset padding - me.paddingLeft =3D 0; - me.paddingTop =3D 0; - me.paddingRight =3D 0; - me.paddingBottom =3D 0; +var platform_dom$1 =3D /*#__PURE__*/Object.freeze({ +__proto__: null, +'default': platform_dom +}); =20 - // Reset minSize - me.minSize =3D { - width: 0, - height: 0 - }; - }, - afterSetDimensions: noop$2, +var stylesheet =3D getCjsExportFromNamespace(platform_dom$1); =20 - // +var EXPANDO_KEY =3D '$chartjs';=0D +var CSS_PREFIX =3D 'chartjs-';=0D +var CSS_SIZE_MONITOR =3D CSS_PREFIX + 'size-monitor';=0D +var CSS_RENDER_MONITOR =3D CSS_PREFIX + 'render-monitor';=0D +var CSS_RENDER_ANIMATION =3D CSS_PREFIX + 'render-animation';=0D +var ANIMATION_START_EVENTS =3D ['animationstart', 'webkitAnimationStart'];= =0D +=0D +/**=0D + * DOM event types -> Chart.js event types.=0D + * Note: only events with different types are mapped.=0D + * @see https://developer.mozilla.org/en-US/docs/Web/Events=0D + */=0D +var EVENT_TYPES =3D {=0D + touchstart: 'mousedown',=0D + touchmove: 'mousemove',=0D + touchend: 'mouseup',=0D + pointerenter: 'mouseenter',=0D + pointerdown: 'mousedown',=0D + pointermove: 'mousemove',=0D + pointerup: 'mouseup',=0D + pointerleave: 'mouseout',=0D + pointerout: 'mouseout'=0D +};=0D +=0D +/**=0D + * The "used" size is the final value of a dimension property after all ca= lculations have=0D + * been performed. This method uses the computed style of `element` but re= turns undefined=0D + * if the computed style is not expressed in pixels. That can happen in so= me cases where=0D + * `element` has a size relative to its parent and this last one is not ye= t displayed,=0D + * for example because of `display: none` on a parent node.=0D + * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value=0D + * @returns {number} Size in pixels or undefined if unknown.=0D + */=0D +function readUsedSize(element, property) {=0D + var value =3D helpers$1.getStyle(element, property);=0D + var matches =3D value && value.match(/^(\d+)(\.\d+)?px$/);=0D + return matches ? Number(matches[1]) : undefined;=0D +}=0D +=0D +/**=0D + * Initializes the canvas style and render size without modifying the canv= as display size,=0D + * since responsiveness is handled by the controller.resize() method. The = config is used=0D + * to determine the aspect ratio to apply in case no explicit height has b= een specified.=0D + */=0D +function initCanvas(canvas, config) {=0D + var style =3D canvas.style;=0D +=0D + // NOTE(SB) canvas.getAttribute('width') !=3D=3D canvas.width: in the fir= st case it=0D + // returns null or '' if no explicit value has been set to the canvas att= ribute.=0D + var renderHeight =3D canvas.getAttribute('height');=0D + var renderWidth =3D canvas.getAttribute('width');=0D +=0D + // Chart.js modifies some canvas values that we want to restore on destro= y=0D + canvas[EXPANDO_KEY] =3D {=0D + initial: {=0D + height: renderHeight,=0D + width: renderWidth,=0D + style: {=0D + display: style.display,=0D + height: style.height,=0D + width: style.width=0D + }=0D + }=0D + };=0D +=0D + // Force canvas to display as block to avoid extra space caused by inline= =0D + // elements, which would interfere with the responsive resize process.=0D + // https://github.com/chartjs/Chart.js/issues/2538=0D + style.display =3D style.display || 'block';=0D +=0D + if (renderWidth =3D=3D=3D null || renderWidth =3D=3D=3D '') {=0D + var displayWidth =3D readUsedSize(canvas, 'width');=0D + if (displayWidth !=3D=3D undefined) {=0D + canvas.width =3D displayWidth;=0D + }=0D + }=0D +=0D + if (renderHeight =3D=3D=3D null || renderHeight =3D=3D=3D '') {=0D + if (canvas.style.height =3D=3D=3D '') {=0D + // If no explicit render height and style height, let's apply the aspec= t ratio,=0D + // which one can be specified by the user but also by charts as default= option=0D + // (i.e. options.aspectRatio). If not specified, use canvas aspect rati= o of 2.=0D + canvas.height =3D canvas.width / (config.options.aspectRatio || 2);=0D + } else {=0D + var displayHeight =3D readUsedSize(canvas, 'height');=0D + if (displayWidth !=3D=3D undefined) {=0D + canvas.height =3D displayHeight;=0D + }=0D + }=0D + }=0D +=0D + return canvas;=0D +}=0D +=0D +/**=0D + * Detects support for options object argument in addEventListener.=0D + * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventLi= stener#Safely_detecting_option_support=0D + * @private=0D + */=0D +var supportsEventListenerOptions =3D (function() {=0D + var supports =3D false;=0D + try {=0D + var options =3D Object.defineProperty({}, 'passive', {=0D + // eslint-disable-next-line getter-return=0D + get: function() {=0D + supports =3D true;=0D + }=0D + });=0D + window.addEventListener('e', null, options);=0D + } catch (e) {=0D + // continue regardless of error=0D + }=0D + return supports;=0D +}());=0D +=0D +// Default passive to true as expected by Chrome for 'touchstart' and 'tou= chend' events.=0D +// https://github.com/chartjs/Chart.js/issues/4287=0D +var eventListenerOptions =3D supportsEventListenerOptions ? {passive: true= } : false;=0D +=0D +function addListener(node, type, listener) {=0D + node.addEventListener(type, listener, eventListenerOptions);=0D +}=0D +=0D +function removeListener(node, type, listener) {=0D + node.removeEventListener(type, listener, eventListenerOptions);=0D +}=0D +=0D +function createEvent(type, chart, x, y, nativeEvent) {=0D + return {=0D + type: type,=0D + chart: chart,=0D + native: nativeEvent || null,=0D + x: x !=3D=3D undefined ? x : null,=0D + y: y !=3D=3D undefined ? y : null,=0D + };=0D +}=0D +=0D +function fromNativeEvent(event, chart) {=0D + var type =3D EVENT_TYPES[event.type] || event.type;=0D + var pos =3D helpers$1.getRelativePosition(event, chart);=0D + return createEvent(type, chart, pos.x, pos.y, event);=0D +}=0D +=0D +function throttled(fn, thisArg) {=0D + var ticking =3D false;=0D + var args =3D [];=0D +=0D + return function() {=0D + args =3D Array.prototype.slice.call(arguments);=0D + thisArg =3D thisArg || this;=0D +=0D + if (!ticking) {=0D + ticking =3D true;=0D + helpers$1.requestAnimFrame.call(window, function() {=0D + ticking =3D false;=0D + fn.apply(thisArg, args);=0D + });=0D + }=0D + };=0D +}=0D +=0D +function createDiv(cls) {=0D + var el =3D document.createElement('div');=0D + el.className =3D cls || '';=0D + return el;=0D +}=0D +=0D +// Implementation based on https://github.com/marcj/css-element-queries=0D +function createResizer(handler) {=0D + var maxSize =3D 1000000;=0D +=0D + // NOTE(SB) Don't use innerHTML because it could be considered unsafe.=0D + // https://github.com/chartjs/Chart.js/issues/5902=0D + var resizer =3D createDiv(CSS_SIZE_MONITOR);=0D + var expand =3D createDiv(CSS_SIZE_MONITOR + '-expand');=0D + var shrink =3D createDiv(CSS_SIZE_MONITOR + '-shrink');=0D +=0D + expand.appendChild(createDiv());=0D + shrink.appendChild(createDiv());=0D +=0D + resizer.appendChild(expand);=0D + resizer.appendChild(shrink);=0D + resizer._reset =3D function() {=0D + expand.scrollLeft =3D maxSize;=0D + expand.scrollTop =3D maxSize;=0D + shrink.scrollLeft =3D maxSize;=0D + shrink.scrollTop =3D maxSize;=0D + };=0D +=0D + var onScroll =3D function() {=0D + resizer._reset();=0D + handler();=0D + };=0D +=0D + addListener(expand, 'scroll', onScroll.bind(expand, 'expand'));=0D + addListener(shrink, 'scroll', onScroll.bind(shrink, 'shrink'));=0D +=0D + return resizer;=0D +}=0D +=0D +// https://davidwalsh.name/detect-node-insertion=0D +function watchForRender(node, handler) {=0D + var expando =3D node[EXPANDO_KEY] || (node[EXPANDO_KEY] =3D {});=0D + var proxy =3D expando.renderProxy =3D function(e) {=0D + if (e.animationName =3D=3D=3D CSS_RENDER_ANIMATION) {=0D + handler();=0D + }=0D + };=0D +=0D + helpers$1.each(ANIMATION_START_EVENTS, function(type) {=0D + addListener(node, type, proxy);=0D + });=0D +=0D + // #4737: Chrome might skip the CSS animation when the CSS_RENDER_MONITOR= class=0D + // is removed then added back immediately (same animation frame?). Access= ing the=0D + // `offsetParent` property will force a reflow and re-evaluate the CSS an= imation.=0D + // https://gist.github.com/paulirish/5d52fb081b3570c81e3a#box-metrics=0D + // https://github.com/chartjs/Chart.js/issues/4737=0D + expando.reflow =3D !!node.offsetParent;=0D +=0D + node.classList.add(CSS_RENDER_MONITOR);=0D +}=0D +=0D +function unwatchForRender(node) {=0D + var expando =3D node[EXPANDO_KEY] || {};=0D + var proxy =3D expando.renderProxy;=0D +=0D + if (proxy) {=0D + helpers$1.each(ANIMATION_START_EVENTS, function(type) {=0D + removeListener(node, type, proxy);=0D + });=0D +=0D + delete expando.renderProxy;=0D + }=0D +=0D + node.classList.remove(CSS_RENDER_MONITOR);=0D +}=0D +=0D +function addResizeListener(node, listener, chart) {=0D + var expando =3D node[EXPANDO_KEY] || (node[EXPANDO_KEY] =3D {});=0D +=0D + // Let's keep track of this added resizer and thus avoid DOM query when r= emoving it.=0D + var resizer =3D expando.resizer =3D createResizer(throttled(function() {= =0D + if (expando.resizer) {=0D + var container =3D chart.options.maintainAspectRatio && node.parentNode;= =0D + var w =3D container ? container.clientWidth : 0;=0D + listener(createEvent('resize', chart));=0D + if (container && container.clientWidth < w && chart.canvas) {=0D + // If the container size shrank during chart resize, let's assume=0D + // scrollbar appeared. So we resize again with the scrollbar visible -= =0D + // effectively making chart smaller and the scrollbar hidden again.=0D + // Because we are inside `throttled`, and currently `ticking`, scroll= =0D + // events are ignored during this whole 2 resize process.=0D + // If we assumed wrong and something else happened, we are resizing=0D + // twice in a frame (potential performance issue)=0D + listener(createEvent('resize', chart));=0D + }=0D + }=0D + }));=0D +=0D + // The resizer needs to be attached to the node parent, so we first need = to be=0D + // sure that `node` is attached to the DOM before injecting the resizer e= lement.=0D + watchForRender(node, function() {=0D + if (expando.resizer) {=0D + var container =3D node.parentNode;=0D + if (container && container !=3D=3D resizer.parentNode) {=0D + container.insertBefore(resizer, container.firstChild);=0D + }=0D +=0D + // The container size might have changed, let's reset the resizer state= .=0D + resizer._reset();=0D + }=0D + });=0D +}=0D +=0D +function removeResizeListener(node) {=0D + var expando =3D node[EXPANDO_KEY] || {};=0D + var resizer =3D expando.resizer;=0D +=0D + delete expando.resizer;=0D + unwatchForRender(node);=0D +=0D + if (resizer && resizer.parentNode) {=0D + resizer.parentNode.removeChild(resizer);=0D + }=0D +}=0D +=0D +/**=0D + * Injects CSS styles inline if the styles are not already present.=0D + * @param {HTMLDocument|ShadowRoot} rootNode - the node to contain the .=0D + * @param {string} css - the CSS to be injected.=0D + */=0D +function injectCSS(rootNode, css) {=0D + // https://stackoverflow.com/q/3922139=0D + var expando =3D rootNode[EXPANDO_KEY] || (rootNode[EXPANDO_KEY] =3D {});= =0D + if (!expando.containsStyles) {=0D + expando.containsStyles =3D true;=0D + css =3D '/* Chart.js */\n' + css;=0D + var style =3D document.createElement('style');=0D + style.setAttribute('type', 'text/css');=0D + style.appendChild(document.createTextNode(css));=0D + rootNode.appendChild(style);=0D + }=0D +}=0D +=0D +var platform_dom$2 =3D {=0D + /**=0D + * When `true`, prevents the automatic injection of the stylesheet requir= ed to=0D + * correctly detect when the chart is added to the DOM and then resized. = This=0D + * switch has been added to allow external stylesheet (`dist/Chart(.min)?= .js`)=0D + * to be manually imported to make this library compatible with any CSP.= =0D + * See https://github.com/chartjs/Chart.js/issues/5208=0D + */=0D + disableCSSInjection: false,=0D +=0D + /**=0D + * This property holds whether this platform is enabled for the current e= nvironment.=0D + * Currently used by platform.js to select the proper implementation.=0D + * @private=0D + */=0D + _enabled: typeof window !=3D=3D 'undefined' && typeof document !=3D=3D 'u= ndefined',=0D +=0D + /**=0D + * Initializes resources that depend on platform options.=0D + * @param {HTMLCanvasElement} canvas - The Canvas element.=0D + * @private=0D + */=0D + _ensureLoaded: function(canvas) {=0D + if (!this.disableCSSInjection) {=0D + // If the canvas is in a shadow DOM, then the styles must also be inser= ted=0D + // into the same shadow DOM.=0D + // https://github.com/chartjs/Chart.js/issues/5763=0D + var root =3D canvas.getRootNode ? canvas.getRootNode() : document;=0D + var targetNode =3D root.host ? root : document.head;=0D + injectCSS(targetNode, stylesheet);=0D + }=0D + },=0D +=0D + acquireContext: function(item, config) {=0D + if (typeof item =3D=3D=3D 'string') {=0D + item =3D document.getElementById(item);=0D + } else if (item.length) {=0D + // Support for array based queries (such as jQuery)=0D + item =3D item[0];=0D + }=0D +=0D + if (item && item.canvas) {=0D + // Support for any object associated to a canvas (including a context2d= )=0D + item =3D item.canvas;=0D + }=0D +=0D + // To prevent canvas fingerprinting, some add-ons undefine the getContex= t=0D + // method, for example: https://github.com/kkapsner/CanvasBlocker=0D + // https://github.com/chartjs/Chart.js/issues/2807=0D + var context =3D item && item.getContext && item.getContext('2d');=0D +=0D + // `instanceof HTMLCanvasElement/CanvasRenderingContext2D` fails when th= e item is=0D + // inside an iframe or when running in a protected environment. We could= guess the=0D + // types from their toString() value but let's keep things flexible and = assume it's=0D + // a sufficient condition if the item has a context2D which has item as = `canvas`.=0D + // https://github.com/chartjs/Chart.js/issues/3887=0D + // https://github.com/chartjs/Chart.js/issues/4102=0D + // https://github.com/chartjs/Chart.js/issues/4152=0D + if (context && context.canvas =3D=3D=3D item) {=0D + // Load platform resources on first chart creation, to make it possible= to=0D + // import the library before setting platform options.=0D + this._ensureLoaded(item);=0D + initCanvas(item, config);=0D + return context;=0D + }=0D +=0D + return null;=0D + },=0D +=0D + releaseContext: function(context) {=0D + var canvas =3D context.canvas;=0D + if (!canvas[EXPANDO_KEY]) {=0D + return;=0D + }=0D +=0D + var initial =3D canvas[EXPANDO_KEY].initial;=0D + ['height', 'width'].forEach(function(prop) {=0D + var value =3D initial[prop];=0D + if (helpers$1.isNullOrUndef(value)) {=0D + canvas.removeAttribute(prop);=0D + } else {=0D + canvas.setAttribute(prop, value);=0D + }=0D + });=0D +=0D + helpers$1.each(initial.style || {}, function(value, key) {=0D + canvas.style[key] =3D value;=0D + });=0D +=0D + // The canvas render size might have been changed (and thus the state st= ack discarded),=0D + // we can't use save() and restore() to restore the initial state. So ma= ke sure that at=0D + // least the canvas context is reset to the default state by setting the= canvas width.=0D + // https://www.w3.org/TR/2011/WD-html5-20110525/the-canvas-element.html= =0D + // eslint-disable-next-line no-self-assign=0D + canvas.width =3D canvas.width;=0D +=0D + delete canvas[EXPANDO_KEY];=0D + },=0D +=0D + addEventListener: function(chart, type, listener) {=0D + var canvas =3D chart.canvas;=0D + if (type =3D=3D=3D 'resize') {=0D + // Note: the resize event is not supported on all browsers.=0D + addResizeListener(canvas, listener, chart);=0D + return;=0D + }=0D +=0D + var expando =3D listener[EXPANDO_KEY] || (listener[EXPANDO_KEY] =3D {});= =0D + var proxies =3D expando.proxies || (expando.proxies =3D {});=0D + var proxy =3D proxies[chart.id + '_' + type] =3D function(event) {=0D + listener(fromNativeEvent(event, chart));=0D + };=0D +=0D + addListener(canvas, type, proxy);=0D + },=0D +=0D + removeEventListener: function(chart, type, listener) {=0D + var canvas =3D chart.canvas;=0D + if (type =3D=3D=3D 'resize') {=0D + // Note: the resize event is not supported on all browsers.=0D + removeResizeListener(canvas);=0D + return;=0D + }=0D +=0D + var expando =3D listener[EXPANDO_KEY] || {};=0D + var proxies =3D expando.proxies || {};=0D + var proxy =3D proxies[chart.id + '_' + type];=0D + if (!proxy) {=0D + return;=0D + }=0D +=0D + removeListener(canvas, type, proxy);=0D + }=0D +};=0D +=0D +// DEPRECATIONS=0D +=0D +/**=0D + * Provided for backward compatibility, use EventTarget.addEventListener i= nstead.=0D + * EventTarget.addEventListener compatibility: Chrome, Opera 7, Safari, FF= 1.5+, IE9+=0D + * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEv= entListener=0D + * @function Chart.helpers.addEvent=0D + * @deprecated since version 2.7.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers$1.addEvent =3D addListener;=0D +=0D +/**=0D + * Provided for backward compatibility, use EventTarget.removeEventListene= r instead.=0D + * EventTarget.removeEventListener compatibility: Chrome, Opera 7, Safari,= FF1.5+, IE9+=0D + * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/remov= eEventListener=0D + * @function Chart.helpers.removeEvent=0D + * @deprecated since version 2.7.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers$1.removeEvent =3D removeListener; =20 - beforeBuildLabels: noop$2, - buildLabels: noop$2, - afterBuildLabels: noop$2, +// @TODO Make possible to select another platform at build time.=0D +var implementation =3D platform_dom$2._enabled ? platform_dom$2 : platform= _basic;=0D +=0D +/**=0D + * @namespace Chart.platform=0D + * @see https://chartjs.gitbooks.io/proposals/content/Platform.html=0D + * @since 2.4.0=0D + */=0D +var platform =3D helpers$1.extend({=0D + /**=0D + * @since 2.7.0=0D + */=0D + initialize: function() {},=0D +=0D + /**=0D + * Called at chart construction time, returns a context2d instance implem= enting=0D + * the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2= dcontext/}.=0D + * @param {*} item - The native item from which to acquire context (platf= orm specific)=0D + * @param {object} options - The chart options=0D + * @returns {CanvasRenderingContext2D} context2d instance=0D + */=0D + acquireContext: function() {},=0D +=0D + /**=0D + * Called at chart destruction time, releases any resources associated to= the context=0D + * previously returned by the acquireContext() method.=0D + * @param {CanvasRenderingContext2D} context - The context2d instance=0D + * @returns {boolean} true if the method succeeded, else false=0D + */=0D + releaseContext: function() {},=0D +=0D + /**=0D + * Registers the specified listener on the given chart.=0D + * @param {Chart} chart - Chart from which to listen for event=0D + * @param {string} type - The ({@link IEvent}) type to listen for=0D + * @param {function} listener - Receives a notification (an object that i= mplements=0D + * the {@link IEvent} interface) when an event of the specified type occu= rs.=0D + */=0D + addEventListener: function() {},=0D +=0D + /**=0D + * Removes the specified listener previously registered with addEventList= ener.=0D + * @param {Chart} chart - Chart from which to remove the listener=0D + * @param {string} type - The ({@link IEvent}) type to remove=0D + * @param {function} listener - The listener function to remove from the = event target.=0D + */=0D + removeEventListener: function() {}=0D +=0D +}, implementation); =20 - // +core_defaults._set('global', {=0D + plugins: {}=0D +});=0D +=0D +/**=0D + * The plugin service singleton=0D + * @namespace Chart.plugins=0D + * @since 2.1.0=0D + */=0D +var core_plugins =3D {=0D + /**=0D + * Globally registered plugins.=0D + * @private=0D + */=0D + _plugins: [],=0D +=0D + /**=0D + * This identifier is used to invalidate the descriptors cache attached t= o each chart=0D + * when a global plugin is registered or unregistered. In this case, the = cache ID is=0D + * incremented and descriptors are regenerated during following API calls= .=0D + * @private=0D + */=0D + _cacheId: 0,=0D +=0D + /**=0D + * Registers the given plugin(s) if not already registered.=0D + * @param {IPlugin[]|IPlugin} plugins plugin instance(s).=0D + */=0D + register: function(plugins) {=0D + var p =3D this._plugins;=0D + ([]).concat(plugins).forEach(function(plugin) {=0D + if (p.indexOf(plugin) =3D=3D=3D -1) {=0D + p.push(plugin);=0D + }=0D + });=0D +=0D + this._cacheId++;=0D + },=0D +=0D + /**=0D + * Unregisters the given plugin(s) only if registered.=0D + * @param {IPlugin[]|IPlugin} plugins plugin instance(s).=0D + */=0D + unregister: function(plugins) {=0D + var p =3D this._plugins;=0D + ([]).concat(plugins).forEach(function(plugin) {=0D + var idx =3D p.indexOf(plugin);=0D + if (idx !=3D=3D -1) {=0D + p.splice(idx, 1);=0D + }=0D + });=0D +=0D + this._cacheId++;=0D + },=0D +=0D + /**=0D + * Remove all registered plugins.=0D + * @since 2.1.5=0D + */=0D + clear: function() {=0D + this._plugins =3D [];=0D + this._cacheId++;=0D + },=0D +=0D + /**=0D + * Returns the number of registered plugins?=0D + * @returns {number}=0D + * @since 2.1.5=0D + */=0D + count: function() {=0D + return this._plugins.length;=0D + },=0D +=0D + /**=0D + * Returns all registered plugin instances.=0D + * @returns {IPlugin[]} array of plugin objects.=0D + * @since 2.1.5=0D + */=0D + getAll: function() {=0D + return this._plugins;=0D + },=0D +=0D + /**=0D + * Calls enabled plugins for `chart` on the specified hook and with the g= iven args.=0D + * This method immediately returns as soon as a plugin explicitly returns= false. The=0D + * returned value can be used, for instance, to interrupt the current act= ion.=0D + * @param {Chart} chart - The chart instance for which plugins should be = called.=0D + * @param {string} hook - The name of the plugin method to call (e.g. 'be= foreUpdate').=0D + * @param {Array} [args] - Extra arguments to apply to the hook call.=0D + * @returns {boolean} false if any of the plugins return false, else retu= rns true.=0D + */=0D + notify: function(chart, hook, args) {=0D + var descriptors =3D this.descriptors(chart);=0D + var ilen =3D descriptors.length;=0D + var i, descriptor, plugin, params, method;=0D +=0D + for (i =3D 0; i < ilen; ++i) {=0D + descriptor =3D descriptors[i];=0D + plugin =3D descriptor.plugin;=0D + method =3D plugin[hook];=0D + if (typeof method =3D=3D=3D 'function') {=0D + params =3D [chart].concat(args || []);=0D + params.push(descriptor.options);=0D + if (method.apply(plugin, params) =3D=3D=3D false) {=0D + return false;=0D + }=0D + }=0D + }=0D +=0D + return true;=0D + },=0D +=0D + /**=0D + * Returns descriptors of enabled plugins for the given chart.=0D + * @returns {object[]} [{ plugin, options }]=0D + * @private=0D + */=0D + descriptors: function(chart) {=0D + var cache =3D chart.$plugins || (chart.$plugins =3D {});=0D + if (cache.id =3D=3D=3D this._cacheId) {=0D + return cache.descriptors;=0D + }=0D +=0D + var plugins =3D [];=0D + var descriptors =3D [];=0D + var config =3D (chart && chart.config) || {};=0D + var options =3D (config.options && config.options.plugins) || {};=0D +=0D + this._plugins.concat(config.plugins || []).forEach(function(plugin) {=0D + var idx =3D plugins.indexOf(plugin);=0D + if (idx !=3D=3D -1) {=0D + return;=0D + }=0D +=0D + var id =3D plugin.id;=0D + var opts =3D options[id];=0D + if (opts =3D=3D=3D false) {=0D + return;=0D + }=0D +=0D + if (opts =3D=3D=3D true) {=0D + opts =3D helpers$1.clone(core_defaults.global.plugins[id]);=0D + }=0D +=0D + plugins.push(plugin);=0D + descriptors.push({=0D + plugin: plugin,=0D + options: opts || {}=0D + });=0D + });=0D +=0D + cache.descriptors =3D descriptors;=0D + cache.id =3D this._cacheId;=0D + return descriptors;=0D + },=0D +=0D + /**=0D + * Invalidates cache for the given chart: descriptors hold a reference on= plugin option,=0D + * but in some cases, this reference can be changed by the user when upda= ting options.=0D + * https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167= =0D + * @private=0D + */=0D + _invalidate: function(chart) {=0D + delete chart.$plugins;=0D + }=0D +}; =20 - beforeFit: noop$2, - fit: function() { - var me =3D this; - var opts =3D me.options; - var minSize =3D me.minSize =3D {}; - var isHorizontal =3D me.isHorizontal(); - var lineCount, textSize; +var core_scaleService =3D {=0D + // Scale registration object. Extensions can register new scale types (su= ch as log or DB scales) and then=0D + // use the new chart options to grab the correct scale=0D + constructors: {},=0D + // Use a registration function so that we can move to an ES6 map when we = no longer need to support=0D + // old browsers=0D +=0D + // Scale config defaults=0D + defaults: {},=0D + registerScaleType: function(type, scaleConstructor, scaleDefaults) {=0D + this.constructors[type] =3D scaleConstructor;=0D + this.defaults[type] =3D helpers$1.clone(scaleDefaults);=0D + },=0D + getScaleConstructor: function(type) {=0D + return this.constructors.hasOwnProperty(type) ? this.constructors[type] = : undefined;=0D + },=0D + getScaleDefaults: function(type) {=0D + // Return the scale defaults merged with the global settings so that we = always use the latest ones=0D + return this.defaults.hasOwnProperty(type) ? helpers$1.merge(Object.creat= e(null), [core_defaults.scale, this.defaults[type]]) : {};=0D + },=0D + updateScaleDefaults: function(type, additions) {=0D + var me =3D this;=0D + if (me.defaults.hasOwnProperty(type)) {=0D + me.defaults[type] =3D helpers$1.extend(me.defaults[type], additions);=0D + }=0D + },=0D + addScalesToLayout: function(chart) {=0D + // Adds each scale to the chart.boxes array to be sized accordingly=0D + helpers$1.each(chart.scales, function(scale) {=0D + // Set ILayoutItem parameters for backwards compatibility=0D + scale.fullWidth =3D scale.options.fullWidth;=0D + scale.position =3D scale.options.position;=0D + scale.weight =3D scale.options.weight;=0D + core_layouts.addBox(chart, scale);=0D + });=0D + }=0D +}; =20 - if (!opts.display) { - me.width =3D minSize.width =3D me.height =3D minSize.height =3D 0; - return; - } +var valueOrDefault$8 =3D helpers$1.valueOrDefault;=0D +var getRtlHelper =3D helpers$1.rtl.getRtlAdapter;=0D +=0D +core_defaults._set('global', {=0D + tooltips: {=0D + enabled: true,=0D + custom: null,=0D + mode: 'nearest',=0D + position: 'average',=0D + intersect: true,=0D + backgroundColor: 'rgba(0,0,0,0.8)',=0D + titleFontStyle: 'bold',=0D + titleSpacing: 2,=0D + titleMarginBottom: 6,=0D + titleFontColor: '#fff',=0D + titleAlign: 'left',=0D + bodySpacing: 2,=0D + bodyFontColor: '#fff',=0D + bodyAlign: 'left',=0D + footerFontStyle: 'bold',=0D + footerSpacing: 2,=0D + footerMarginTop: 6,=0D + footerFontColor: '#fff',=0D + footerAlign: 'left',=0D + yPadding: 6,=0D + xPadding: 6,=0D + caretPadding: 2,=0D + caretSize: 5,=0D + cornerRadius: 6,=0D + multiKeyBackground: '#fff',=0D + displayColors: true,=0D + borderColor: 'rgba(0,0,0,0)',=0D + borderWidth: 0,=0D + callbacks: {=0D + // Args are: (tooltipItems, data)=0D + beforeTitle: helpers$1.noop,=0D + title: function(tooltipItems, data) {=0D + var title =3D '';=0D + var labels =3D data.labels;=0D + var labelCount =3D labels ? labels.length : 0;=0D +=0D + if (tooltipItems.length > 0) {=0D + var item =3D tooltipItems[0];=0D + if (item.label) {=0D + title =3D item.label;=0D + } else if (item.xLabel) {=0D + title =3D item.xLabel;=0D + } else if (labelCount > 0 && item.index < labelCount) {=0D + title =3D labels[item.index];=0D + }=0D + }=0D +=0D + return title;=0D + },=0D + afterTitle: helpers$1.noop,=0D +=0D + // Args are: (tooltipItems, data)=0D + beforeBody: helpers$1.noop,=0D +=0D + // Args are: (tooltipItem, data)=0D + beforeLabel: helpers$1.noop,=0D + label: function(tooltipItem, data) {=0D + var label =3D data.datasets[tooltipItem.datasetIndex].label || '';=0D +=0D + if (label) {=0D + label +=3D ': ';=0D + }=0D + if (!helpers$1.isNullOrUndef(tooltipItem.value)) {=0D + label +=3D tooltipItem.value;=0D + } else {=0D + label +=3D tooltipItem.yLabel;=0D + }=0D + return label;=0D + },=0D + labelColor: function(tooltipItem, chart) {=0D + var meta =3D chart.getDatasetMeta(tooltipItem.datasetIndex);=0D + var activeElement =3D meta.data[tooltipItem.index];=0D + var view =3D activeElement._view;=0D + return {=0D + borderColor: view.borderColor,=0D + backgroundColor: view.backgroundColor=0D + };=0D + },=0D + labelTextColor: function() {=0D + return this._options.bodyFontColor;=0D + },=0D + afterLabel: helpers$1.noop,=0D +=0D + // Args are: (tooltipItems, data)=0D + afterBody: helpers$1.noop,=0D +=0D + // Args are: (tooltipItems, data)=0D + beforeFooter: helpers$1.noop,=0D + footer: helpers$1.noop,=0D + afterFooter: helpers$1.noop=0D + }=0D + }=0D +});=0D +=0D +var positioners =3D {=0D + /**=0D + * Average mode places the tooltip at the average position of the element= s shown=0D + * @function Chart.Tooltip.positioners.average=0D + * @param elements {ChartElement[]} the elements being displayed in the t= ooltip=0D + * @returns {object} tooltip position=0D + */=0D + average: function(elements) {=0D + if (!elements.length) {=0D + return false;=0D + }=0D +=0D + var i, len;=0D + var x =3D 0;=0D + var y =3D 0;=0D + var count =3D 0;=0D +=0D + for (i =3D 0, len =3D elements.length; i < len; ++i) {=0D + var el =3D elements[i];=0D + if (el && el.hasValue()) {=0D + var pos =3D el.tooltipPosition();=0D + x +=3D pos.x;=0D + y +=3D pos.y;=0D + ++count;=0D + }=0D + }=0D +=0D + return {=0D + x: x / count,=0D + y: y / count=0D + };=0D + },=0D +=0D + /**=0D + * Gets the tooltip position nearest of the item nearest to the event pos= ition=0D + * @function Chart.Tooltip.positioners.nearest=0D + * @param elements {Chart.Element[]} the tooltip elements=0D + * @param eventPosition {object} the position of the event in canvas coor= dinates=0D + * @returns {object} the tooltip position=0D + */=0D + nearest: function(elements, eventPosition) {=0D + var x =3D eventPosition.x;=0D + var y =3D eventPosition.y;=0D + var minDistance =3D Number.POSITIVE_INFINITY;=0D + var i, len, nearestElement;=0D +=0D + for (i =3D 0, len =3D elements.length; i < len; ++i) {=0D + var el =3D elements[i];=0D + if (el && el.hasValue()) {=0D + var center =3D el.getCenterPoint();=0D + var d =3D helpers$1.distanceBetweenPoints(eventPosition, center);=0D +=0D + if (d < minDistance) {=0D + minDistance =3D d;=0D + nearestElement =3D el;=0D + }=0D + }=0D + }=0D +=0D + if (nearestElement) {=0D + var tp =3D nearestElement.tooltipPosition();=0D + x =3D tp.x;=0D + y =3D tp.y;=0D + }=0D +=0D + return {=0D + x: x,=0D + y: y=0D + };=0D + }=0D +};=0D +=0D +// Helper to push or concat based on if the 2nd parameter is an array or n= ot=0D +function pushOrConcat(base, toPush) {=0D + if (toPush) {=0D + if (helpers$1.isArray(toPush)) {=0D + // base =3D base.concat(toPush);=0D + Array.prototype.push.apply(base, toPush);=0D + } else {=0D + base.push(toPush);=0D + }=0D + }=0D +=0D + return base;=0D +}=0D +=0D +/**=0D + * Returns array of strings split by newline=0D + * @param {string} value - The value to split by newline.=0D + * @returns {string[]} value if newline present - Returned from String spl= it() method=0D + * @function=0D + */=0D +function splitNewlines(str) {=0D + if ((typeof str =3D=3D=3D 'string' || str instanceof String) && str.index= Of('\n') > -1) {=0D + return str.split('\n');=0D + }=0D + return str;=0D +}=0D +=0D +=0D +/**=0D + * Private helper to create a tooltip item model=0D + * @param element - the chart element (point, arc, bar) to create the tool= tip item for=0D + * @return new tooltip item=0D + */=0D +function createTooltipItem(element) {=0D + var xScale =3D element._xScale;=0D + var yScale =3D element._yScale || element._scale; // handle radar || pola= rArea charts=0D + var index =3D element._index;=0D + var datasetIndex =3D element._datasetIndex;=0D + var controller =3D element._chart.getDatasetMeta(datasetIndex).controller= ;=0D + var indexScale =3D controller._getIndexScale();=0D + var valueScale =3D controller._getValueScale();=0D +=0D + return {=0D + xLabel: xScale ? xScale.getLabelForIndex(index, datasetIndex) : '',=0D + yLabel: yScale ? yScale.getLabelForIndex(index, datasetIndex) : '',=0D + label: indexScale ? '' + indexScale.getLabelForIndex(index, datasetIndex= ) : '',=0D + value: valueScale ? '' + valueScale.getLabelForIndex(index, datasetIndex= ) : '',=0D + index: index,=0D + datasetIndex: datasetIndex,=0D + x: element._model.x,=0D + y: element._model.y=0D + };=0D +}=0D +=0D +/**=0D + * Helper to get the reset model for the tooltip=0D + * @param tooltipOpts {object} the tooltip options=0D + */=0D +function getBaseModel(tooltipOpts) {=0D + var globalDefaults =3D core_defaults.global;=0D +=0D + return {=0D + // Positioning=0D + xPadding: tooltipOpts.xPadding,=0D + yPadding: tooltipOpts.yPadding,=0D + xAlign: tooltipOpts.xAlign,=0D + yAlign: tooltipOpts.yAlign,=0D +=0D + // Drawing direction and text direction=0D + rtl: tooltipOpts.rtl,=0D + textDirection: tooltipOpts.textDirection,=0D +=0D + // Body=0D + bodyFontColor: tooltipOpts.bodyFontColor,=0D + _bodyFontFamily: valueOrDefault$8(tooltipOpts.bodyFontFamily, globalDefa= ults.defaultFontFamily),=0D + _bodyFontStyle: valueOrDefault$8(tooltipOpts.bodyFontStyle, globalDefaul= ts.defaultFontStyle),=0D + _bodyAlign: tooltipOpts.bodyAlign,=0D + bodyFontSize: valueOrDefault$8(tooltipOpts.bodyFontSize, globalDefaults.= defaultFontSize),=0D + bodySpacing: tooltipOpts.bodySpacing,=0D +=0D + // Title=0D + titleFontColor: tooltipOpts.titleFontColor,=0D + _titleFontFamily: valueOrDefault$8(tooltipOpts.titleFontFamily, globalDe= faults.defaultFontFamily),=0D + _titleFontStyle: valueOrDefault$8(tooltipOpts.titleFontStyle, globalDefa= ults.defaultFontStyle),=0D + titleFontSize: valueOrDefault$8(tooltipOpts.titleFontSize, globalDefault= s.defaultFontSize),=0D + _titleAlign: tooltipOpts.titleAlign,=0D + titleSpacing: tooltipOpts.titleSpacing,=0D + titleMarginBottom: tooltipOpts.titleMarginBottom,=0D +=0D + // Footer=0D + footerFontColor: tooltipOpts.footerFontColor,=0D + _footerFontFamily: valueOrDefault$8(tooltipOpts.footerFontFamily, global= Defaults.defaultFontFamily),=0D + _footerFontStyle: valueOrDefault$8(tooltipOpts.footerFontStyle, globalDe= faults.defaultFontStyle),=0D + footerFontSize: valueOrDefault$8(tooltipOpts.footerFontSize, globalDefau= lts.defaultFontSize),=0D + _footerAlign: tooltipOpts.footerAlign,=0D + footerSpacing: tooltipOpts.footerSpacing,=0D + footerMarginTop: tooltipOpts.footerMarginTop,=0D +=0D + // Appearance=0D + caretSize: tooltipOpts.caretSize,=0D + cornerRadius: tooltipOpts.cornerRadius,=0D + backgroundColor: tooltipOpts.backgroundColor,=0D + opacity: 0,=0D + legendColorBackground: tooltipOpts.multiKeyBackground,=0D + displayColors: tooltipOpts.displayColors,=0D + borderColor: tooltipOpts.borderColor,=0D + borderWidth: tooltipOpts.borderWidth=0D + };=0D +}=0D +=0D +/**=0D + * Get the size of the tooltip=0D + */=0D +function getTooltipSize(tooltip, model) {=0D + var ctx =3D tooltip._chart.ctx;=0D +=0D + var height =3D model.yPadding * 2; // Tooltip Padding=0D + var width =3D 0;=0D +=0D + // Count of all lines in the body=0D + var body =3D model.body;=0D + var combinedBodyLength =3D body.reduce(function(count, bodyItem) {=0D + return count + bodyItem.before.length + bodyItem.lines.length + bodyItem= .after.length;=0D + }, 0);=0D + combinedBodyLength +=3D model.beforeBody.length + model.afterBody.length;= =0D +=0D + var titleLineCount =3D model.title.length;=0D + var footerLineCount =3D model.footer.length;=0D + var titleFontSize =3D model.titleFontSize;=0D + var bodyFontSize =3D model.bodyFontSize;=0D + var footerFontSize =3D model.footerFontSize;=0D +=0D + height +=3D titleLineCount * titleFontSize; // Title Lines=0D + height +=3D titleLineCount ? (titleLineCount - 1) * model.titleSpacing : = 0; // Title Line Spacing=0D + height +=3D titleLineCount ? model.titleMarginBottom : 0; // Title's bott= om Margin=0D + height +=3D combinedBodyLength * bodyFontSize; // Body Lines=0D + height +=3D combinedBodyLength ? (combinedBodyLength - 1) * model.bodySpa= cing : 0; // Body Line Spacing=0D + height +=3D footerLineCount ? model.footerMarginTop : 0; // Footer Margin= =0D + height +=3D footerLineCount * (footerFontSize); // Footer Lines=0D + height +=3D footerLineCount ? (footerLineCount - 1) * model.footerSpacing= : 0; // Footer Line Spacing=0D +=0D + // Title width=0D + var widthPadding =3D 0;=0D + var maxLineWidth =3D function(line) {=0D + width =3D Math.max(width, ctx.measureText(line).width + widthPadding);=0D + };=0D +=0D + ctx.font =3D helpers$1.fontString(titleFontSize, model._titleFontStyle, m= odel._titleFontFamily);=0D + helpers$1.each(model.title, maxLineWidth);=0D +=0D + // Body width=0D + ctx.font =3D helpers$1.fontString(bodyFontSize, model._bodyFontStyle, mod= el._bodyFontFamily);=0D + helpers$1.each(model.beforeBody.concat(model.afterBody), maxLineWidth);=0D +=0D + // Body lines may include some extra width due to the color box=0D + widthPadding =3D model.displayColors ? (bodyFontSize + 2) : 0;=0D + helpers$1.each(body, function(bodyItem) {=0D + helpers$1.each(bodyItem.before, maxLineWidth);=0D + helpers$1.each(bodyItem.lines, maxLineWidth);=0D + helpers$1.each(bodyItem.after, maxLineWidth);=0D + });=0D +=0D + // Reset back to 0=0D + widthPadding =3D 0;=0D +=0D + // Footer width=0D + ctx.font =3D helpers$1.fontString(footerFontSize, model._footerFontStyle,= model._footerFontFamily);=0D + helpers$1.each(model.footer, maxLineWidth);=0D +=0D + // Add padding=0D + width +=3D 2 * model.xPadding;=0D +=0D + return {=0D + width: width,=0D + height: height=0D + };=0D +}=0D +=0D +/**=0D + * Helper to get the alignment of a tooltip given the size=0D + */=0D +function determineAlignment(tooltip, size) {=0D + var model =3D tooltip._model;=0D + var chart =3D tooltip._chart;=0D + var chartArea =3D tooltip._chart.chartArea;=0D + var xAlign =3D 'center';=0D + var yAlign =3D 'center';=0D +=0D + if (model.y < size.height) {=0D + yAlign =3D 'top';=0D + } else if (model.y > (chart.height - size.height)) {=0D + yAlign =3D 'bottom';=0D + }=0D +=0D + var lf, rf; // functions to determine left, right alignment=0D + var olf, orf; // functions to determine if left/right alignment causes to= oltip to go outside chart=0D + var yf; // function to get the y alignment if the tooltip goes outside of= the left or right edges=0D + var midX =3D (chartArea.left + chartArea.right) / 2;=0D + var midY =3D (chartArea.top + chartArea.bottom) / 2;=0D +=0D + if (yAlign =3D=3D=3D 'center') {=0D + lf =3D function(x) {=0D + return x <=3D midX;=0D + };=0D + rf =3D function(x) {=0D + return x > midX;=0D + };=0D + } else {=0D + lf =3D function(x) {=0D + return x <=3D (size.width / 2);=0D + };=0D + rf =3D function(x) {=0D + return x >=3D (chart.width - (size.width / 2));=0D + };=0D + }=0D +=0D + olf =3D function(x) {=0D + return x + size.width + model.caretSize + model.caretPadding > chart.wid= th;=0D + };=0D + orf =3D function(x) {=0D + return x - size.width - model.caretSize - model.caretPadding < 0;=0D + };=0D + yf =3D function(y) {=0D + return y <=3D midY ? 'top' : 'bottom';=0D + };=0D +=0D + if (lf(model.x)) {=0D + xAlign =3D 'left';=0D +=0D + // Is tooltip too wide and goes over the right side of the chart.?=0D + if (olf(model.x)) {=0D + xAlign =3D 'center';=0D + yAlign =3D yf(model.y);=0D + }=0D + } else if (rf(model.x)) {=0D + xAlign =3D 'right';=0D +=0D + // Is tooltip too wide and goes outside left edge of canvas?=0D + if (orf(model.x)) {=0D + xAlign =3D 'center';=0D + yAlign =3D yf(model.y);=0D + }=0D + }=0D +=0D + var opts =3D tooltip._options;=0D + return {=0D + xAlign: opts.xAlign ? opts.xAlign : xAlign,=0D + yAlign: opts.yAlign ? opts.yAlign : yAlign=0D + };=0D +}=0D +=0D +/**=0D + * Helper to get the location a tooltip needs to be placed at given the in= itial position (via the vm) and the size and alignment=0D + */=0D +function getBackgroundPoint(vm, size, alignment, chart) {=0D + // Background Position=0D + var x =3D vm.x;=0D + var y =3D vm.y;=0D +=0D + var caretSize =3D vm.caretSize;=0D + var caretPadding =3D vm.caretPadding;=0D + var cornerRadius =3D vm.cornerRadius;=0D + var xAlign =3D alignment.xAlign;=0D + var yAlign =3D alignment.yAlign;=0D + var paddingAndSize =3D caretSize + caretPadding;=0D + var radiusAndPadding =3D cornerRadius + caretPadding;=0D +=0D + if (xAlign =3D=3D=3D 'right') {=0D + x -=3D size.width;=0D + } else if (xAlign =3D=3D=3D 'center') {=0D + x -=3D (size.width / 2);=0D + if (x + size.width > chart.width) {=0D + x =3D chart.width - size.width;=0D + }=0D + if (x < 0) {=0D + x =3D 0;=0D + }=0D + }=0D +=0D + if (yAlign =3D=3D=3D 'top') {=0D + y +=3D paddingAndSize;=0D + } else if (yAlign =3D=3D=3D 'bottom') {=0D + y -=3D size.height + paddingAndSize;=0D + } else {=0D + y -=3D (size.height / 2);=0D + }=0D +=0D + if (yAlign =3D=3D=3D 'center') {=0D + if (xAlign =3D=3D=3D 'left') {=0D + x +=3D paddingAndSize;=0D + } else if (xAlign =3D=3D=3D 'right') {=0D + x -=3D paddingAndSize;=0D + }=0D + } else if (xAlign =3D=3D=3D 'left') {=0D + x -=3D radiusAndPadding;=0D + } else if (xAlign =3D=3D=3D 'right') {=0D + x +=3D radiusAndPadding;=0D + }=0D +=0D + return {=0D + x: x,=0D + y: y=0D + };=0D +}=0D +=0D +function getAlignedX(vm, align) {=0D + return align =3D=3D=3D 'center'=0D + ? vm.x + vm.width / 2=0D + : align =3D=3D=3D 'right'=0D + ? vm.x + vm.width - vm.xPadding=0D + : vm.x + vm.xPadding;=0D +}=0D +=0D +/**=0D + * Helper to build before and after body lines=0D + */=0D +function getBeforeAfterBodyLines(callback) {=0D + return pushOrConcat([], splitNewlines(callback));=0D +}=0D +=0D +var exports$4 =3D core_element.extend({=0D + initialize: function() {=0D + this._model =3D getBaseModel(this._options);=0D + this._lastActive =3D [];=0D + },=0D +=0D + // Get the title=0D + // Args are: (tooltipItem, data)=0D + getTitle: function() {=0D + var me =3D this;=0D + var opts =3D me._options;=0D + var callbacks =3D opts.callbacks;=0D +=0D + var beforeTitle =3D callbacks.beforeTitle.apply(me, arguments);=0D + var title =3D callbacks.title.apply(me, arguments);=0D + var afterTitle =3D callbacks.afterTitle.apply(me, arguments);=0D +=0D + var lines =3D [];=0D + lines =3D pushOrConcat(lines, splitNewlines(beforeTitle));=0D + lines =3D pushOrConcat(lines, splitNewlines(title));=0D + lines =3D pushOrConcat(lines, splitNewlines(afterTitle));=0D +=0D + return lines;=0D + },=0D +=0D + // Args are: (tooltipItem, data)=0D + getBeforeBody: function() {=0D + return getBeforeAfterBodyLines(this._options.callbacks.beforeBody.apply(= this, arguments));=0D + },=0D +=0D + // Args are: (tooltipItem, data)=0D + getBody: function(tooltipItems, data) {=0D + var me =3D this;=0D + var callbacks =3D me._options.callbacks;=0D + var bodyItems =3D [];=0D +=0D + helpers$1.each(tooltipItems, function(tooltipItem) {=0D + var bodyItem =3D {=0D + before: [],=0D + lines: [],=0D + after: []=0D + };=0D + pushOrConcat(bodyItem.before, splitNewlines(callbacks.beforeLabel.call(= me, tooltipItem, data)));=0D + pushOrConcat(bodyItem.lines, callbacks.label.call(me, tooltipItem, data= ));=0D + pushOrConcat(bodyItem.after, splitNewlines(callbacks.afterLabel.call(me= , tooltipItem, data)));=0D +=0D + bodyItems.push(bodyItem);=0D + });=0D +=0D + return bodyItems;=0D + },=0D +=0D + // Args are: (tooltipItem, data)=0D + getAfterBody: function() {=0D + return getBeforeAfterBodyLines(this._options.callbacks.afterBody.apply(t= his, arguments));=0D + },=0D +=0D + // Get the footer and beforeFooter and afterFooter lines=0D + // Args are: (tooltipItem, data)=0D + getFooter: function() {=0D + var me =3D this;=0D + var callbacks =3D me._options.callbacks;=0D +=0D + var beforeFooter =3D callbacks.beforeFooter.apply(me, arguments);=0D + var footer =3D callbacks.footer.apply(me, arguments);=0D + var afterFooter =3D callbacks.afterFooter.apply(me, arguments);=0D +=0D + var lines =3D [];=0D + lines =3D pushOrConcat(lines, splitNewlines(beforeFooter));=0D + lines =3D pushOrConcat(lines, splitNewlines(footer));=0D + lines =3D pushOrConcat(lines, splitNewlines(afterFooter));=0D +=0D + return lines;=0D + },=0D +=0D + update: function(changed) {=0D + var me =3D this;=0D + var opts =3D me._options;=0D +=0D + // Need to regenerate the model because its faster than using extend and= it is necessary due to the optimization in Chart.Element.transition=0D + // that does _view =3D _model if ease =3D=3D=3D 1. This causes the 2nd t= ooltip update to set properties in both the view and model at the same time= =0D + // which breaks any animations.=0D + var existingModel =3D me._model;=0D + var model =3D me._model =3D getBaseModel(opts);=0D + var active =3D me._active;=0D +=0D + var data =3D me._data;=0D +=0D + // In the case where active.length =3D=3D=3D 0 we need to keep these at = existing values for good animations=0D + var alignment =3D {=0D + xAlign: existingModel.xAlign,=0D + yAlign: existingModel.yAlign=0D + };=0D + var backgroundPoint =3D {=0D + x: existingModel.x,=0D + y: existingModel.y=0D + };=0D + var tooltipSize =3D {=0D + width: existingModel.width,=0D + height: existingModel.height=0D + };=0D + var tooltipPosition =3D {=0D + x: existingModel.caretX,=0D + y: existingModel.caretY=0D + };=0D +=0D + var i, len;=0D +=0D + if (active.length) {=0D + model.opacity =3D 1;=0D +=0D + var labelColors =3D [];=0D + var labelTextColors =3D [];=0D + tooltipPosition =3D positioners[opts.position].call(me, active, me._eve= ntPosition);=0D +=0D + var tooltipItems =3D [];=0D + for (i =3D 0, len =3D active.length; i < len; ++i) {=0D + tooltipItems.push(createTooltipItem(active[i]));=0D + }=0D +=0D + // If the user provided a filter function, use it to modify the tooltip= items=0D + if (opts.filter) {=0D + tooltipItems =3D tooltipItems.filter(function(a) {=0D + return opts.filter(a, data);=0D + });=0D + }=0D +=0D + // If the user provided a sorting function, use it to modify the toolti= p items=0D + if (opts.itemSort) {=0D + tooltipItems =3D tooltipItems.sort(function(a, b) {=0D + return opts.itemSort(a, b, data);=0D + });=0D + }=0D +=0D + // Determine colors for boxes=0D + helpers$1.each(tooltipItems, function(tooltipItem) {=0D + labelColors.push(opts.callbacks.labelColor.call(me, tooltipItem, me._c= hart));=0D + labelTextColors.push(opts.callbacks.labelTextColor.call(me, tooltipIte= m, me._chart));=0D + });=0D +=0D +=0D + // Build the Text Lines=0D + model.title =3D me.getTitle(tooltipItems, data);=0D + model.beforeBody =3D me.getBeforeBody(tooltipItems, data);=0D + model.body =3D me.getBody(tooltipItems, data);=0D + model.afterBody =3D me.getAfterBody(tooltipItems, data);=0D + model.footer =3D me.getFooter(tooltipItems, data);=0D +=0D + // Initial positioning and colors=0D + model.x =3D tooltipPosition.x;=0D + model.y =3D tooltipPosition.y;=0D + model.caretPadding =3D opts.caretPadding;=0D + model.labelColors =3D labelColors;=0D + model.labelTextColors =3D labelTextColors;=0D +=0D + // data points=0D + model.dataPoints =3D tooltipItems;=0D +=0D + // We need to determine alignment of the tooltip=0D + tooltipSize =3D getTooltipSize(this, model);=0D + alignment =3D determineAlignment(this, tooltipSize);=0D + // Final Size and Position=0D + backgroundPoint =3D getBackgroundPoint(model, tooltipSize, alignment, m= e._chart);=0D + } else {=0D + model.opacity =3D 0;=0D + }=0D +=0D + model.xAlign =3D alignment.xAlign;=0D + model.yAlign =3D alignment.yAlign;=0D + model.x =3D backgroundPoint.x;=0D + model.y =3D backgroundPoint.y;=0D + model.width =3D tooltipSize.width;=0D + model.height =3D tooltipSize.height;=0D +=0D + // Point where the caret on the tooltip points to=0D + model.caretX =3D tooltipPosition.x;=0D + model.caretY =3D tooltipPosition.y;=0D +=0D + me._model =3D model;=0D +=0D + if (changed && opts.custom) {=0D + opts.custom.call(me, model);=0D + }=0D +=0D + return me;=0D + },=0D +=0D + drawCaret: function(tooltipPoint, size) {=0D + var ctx =3D this._chart.ctx;=0D + var vm =3D this._view;=0D + var caretPosition =3D this.getCaretPosition(tooltipPoint, size, vm);=0D +=0D + ctx.lineTo(caretPosition.x1, caretPosition.y1);=0D + ctx.lineTo(caretPosition.x2, caretPosition.y2);=0D + ctx.lineTo(caretPosition.x3, caretPosition.y3);=0D + },=0D + getCaretPosition: function(tooltipPoint, size, vm) {=0D + var x1, x2, x3, y1, y2, y3;=0D + var caretSize =3D vm.caretSize;=0D + var cornerRadius =3D vm.cornerRadius;=0D + var xAlign =3D vm.xAlign;=0D + var yAlign =3D vm.yAlign;=0D + var ptX =3D tooltipPoint.x;=0D + var ptY =3D tooltipPoint.y;=0D + var width =3D size.width;=0D + var height =3D size.height;=0D +=0D + if (yAlign =3D=3D=3D 'center') {=0D + y2 =3D ptY + (height / 2);=0D +=0D + if (xAlign =3D=3D=3D 'left') {=0D + x1 =3D ptX;=0D + x2 =3D x1 - caretSize;=0D + x3 =3D x1;=0D +=0D + y1 =3D y2 + caretSize;=0D + y3 =3D y2 - caretSize;=0D + } else {=0D + x1 =3D ptX + width;=0D + x2 =3D x1 + caretSize;=0D + x3 =3D x1;=0D +=0D + y1 =3D y2 - caretSize;=0D + y3 =3D y2 + caretSize;=0D + }=0D + } else {=0D + if (xAlign =3D=3D=3D 'left') {=0D + x2 =3D ptX + cornerRadius + (caretSize);=0D + x1 =3D x2 - caretSize;=0D + x3 =3D x2 + caretSize;=0D + } else if (xAlign =3D=3D=3D 'right') {=0D + x2 =3D ptX + width - cornerRadius - caretSize;=0D + x1 =3D x2 - caretSize;=0D + x3 =3D x2 + caretSize;=0D + } else {=0D + x2 =3D vm.caretX;=0D + x1 =3D x2 - caretSize;=0D + x3 =3D x2 + caretSize;=0D + }=0D + if (yAlign =3D=3D=3D 'top') {=0D + y1 =3D ptY;=0D + y2 =3D y1 - caretSize;=0D + y3 =3D y1;=0D + } else {=0D + y1 =3D ptY + height;=0D + y2 =3D y1 + caretSize;=0D + y3 =3D y1;=0D + // invert drawing order=0D + var tmp =3D x3;=0D + x3 =3D x1;=0D + x1 =3D tmp;=0D + }=0D + }=0D + return {x1: x1, x2: x2, x3: x3, y1: y1, y2: y2, y3: y3};=0D + },=0D +=0D + drawTitle: function(pt, vm, ctx) {=0D + var title =3D vm.title;=0D + var length =3D title.length;=0D + var titleFontSize, titleSpacing, i;=0D +=0D + if (length) {=0D + var rtlHelper =3D getRtlHelper(vm.rtl, vm.x, vm.width);=0D +=0D + pt.x =3D getAlignedX(vm, vm._titleAlign);=0D +=0D + ctx.textAlign =3D rtlHelper.textAlign(vm._titleAlign);=0D + ctx.textBaseline =3D 'middle';=0D +=0D + titleFontSize =3D vm.titleFontSize;=0D + titleSpacing =3D vm.titleSpacing;=0D +=0D + ctx.fillStyle =3D vm.titleFontColor;=0D + ctx.font =3D helpers$1.fontString(titleFontSize, vm._titleFontStyle, vm= ._titleFontFamily);=0D +=0D + for (i =3D 0; i < length; ++i) {=0D + ctx.fillText(title[i], rtlHelper.x(pt.x), pt.y + titleFontSize / 2);=0D + pt.y +=3D titleFontSize + titleSpacing; // Line Height and spacing=0D +=0D + if (i + 1 =3D=3D=3D length) {=0D + pt.y +=3D vm.titleMarginBottom - titleSpacing; // If Last, add margin= , remove spacing=0D + }=0D + }=0D + }=0D + },=0D +=0D + drawBody: function(pt, vm, ctx) {=0D + var bodyFontSize =3D vm.bodyFontSize;=0D + var bodySpacing =3D vm.bodySpacing;=0D + var bodyAlign =3D vm._bodyAlign;=0D + var body =3D vm.body;=0D + var drawColorBoxes =3D vm.displayColors;=0D + var xLinePadding =3D 0;=0D + var colorX =3D drawColorBoxes ? getAlignedX(vm, 'left') : 0;=0D +=0D + var rtlHelper =3D getRtlHelper(vm.rtl, vm.x, vm.width);=0D +=0D + var fillLineOfText =3D function(line) {=0D + ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyFontSiz= e / 2);=0D + pt.y +=3D bodyFontSize + bodySpacing;=0D + };=0D +=0D + var bodyItem, textColor, labelColors, lines, i, j, ilen, jlen;=0D + var bodyAlignForCalculation =3D rtlHelper.textAlign(bodyAlign);=0D +=0D + ctx.textAlign =3D bodyAlign;=0D + ctx.textBaseline =3D 'middle';=0D + ctx.font =3D helpers$1.fontString(bodyFontSize, vm._bodyFontStyle, vm._b= odyFontFamily);=0D +=0D + pt.x =3D getAlignedX(vm, bodyAlignForCalculation);=0D +=0D + // Before body lines=0D + ctx.fillStyle =3D vm.bodyFontColor;=0D + helpers$1.each(vm.beforeBody, fillLineOfText);=0D +=0D + xLinePadding =3D drawColorBoxes && bodyAlignForCalculation !=3D=3D 'righ= t'=0D + ? bodyAlign =3D=3D=3D 'center' ? (bodyFontSize / 2 + 1) : (bodyFontSize= + 2)=0D + : 0;=0D +=0D + // Draw body lines now=0D + for (i =3D 0, ilen =3D body.length; i < ilen; ++i) {=0D + bodyItem =3D body[i];=0D + textColor =3D vm.labelTextColors[i];=0D + labelColors =3D vm.labelColors[i];=0D +=0D + ctx.fillStyle =3D textColor;=0D + helpers$1.each(bodyItem.before, fillLineOfText);=0D +=0D + lines =3D bodyItem.lines;=0D + for (j =3D 0, jlen =3D lines.length; j < jlen; ++j) {=0D + // Draw Legend-like boxes if needed=0D + if (drawColorBoxes) {=0D + var rtlColorX =3D rtlHelper.x(colorX);=0D +=0D + // Fill a white rect so that colours merge nicely if the opacity is <= 1=0D + ctx.fillStyle =3D vm.legendColorBackground;=0D + ctx.fillRect(rtlHelper.leftForLtr(rtlColorX, bodyFontSize), pt.y, bod= yFontSize, bodyFontSize);=0D +=0D + // Border=0D + ctx.lineWidth =3D 1;=0D + ctx.strokeStyle =3D labelColors.borderColor;=0D + ctx.strokeRect(rtlHelper.leftForLtr(rtlColorX, bodyFontSize), pt.y, b= odyFontSize, bodyFontSize);=0D +=0D + // Inner square=0D + ctx.fillStyle =3D labelColors.backgroundColor;=0D + ctx.fillRect(rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), body= FontSize - 2), pt.y + 1, bodyFontSize - 2, bodyFontSize - 2);=0D + ctx.fillStyle =3D textColor;=0D + }=0D +=0D + fillLineOfText(lines[j]);=0D + }=0D +=0D + helpers$1.each(bodyItem.after, fillLineOfText);=0D + }=0D +=0D + // Reset back to 0 for after body=0D + xLinePadding =3D 0;=0D +=0D + // After body lines=0D + helpers$1.each(vm.afterBody, fillLineOfText);=0D + pt.y -=3D bodySpacing; // Remove last body spacing=0D + },=0D +=0D + drawFooter: function(pt, vm, ctx) {=0D + var footer =3D vm.footer;=0D + var length =3D footer.length;=0D + var footerFontSize, i;=0D +=0D + if (length) {=0D + var rtlHelper =3D getRtlHelper(vm.rtl, vm.x, vm.width);=0D +=0D + pt.x =3D getAlignedX(vm, vm._footerAlign);=0D + pt.y +=3D vm.footerMarginTop;=0D +=0D + ctx.textAlign =3D rtlHelper.textAlign(vm._footerAlign);=0D + ctx.textBaseline =3D 'middle';=0D +=0D + footerFontSize =3D vm.footerFontSize;=0D +=0D + ctx.fillStyle =3D vm.footerFontColor;=0D + ctx.font =3D helpers$1.fontString(footerFontSize, vm._footerFontStyle, = vm._footerFontFamily);=0D +=0D + for (i =3D 0; i < length; ++i) {=0D + ctx.fillText(footer[i], rtlHelper.x(pt.x), pt.y + footerFontSize / 2);= =0D + pt.y +=3D footerFontSize + vm.footerSpacing;=0D + }=0D + }=0D + },=0D +=0D + drawBackground: function(pt, vm, ctx, tooltipSize) {=0D + ctx.fillStyle =3D vm.backgroundColor;=0D + ctx.strokeStyle =3D vm.borderColor;=0D + ctx.lineWidth =3D vm.borderWidth;=0D + var xAlign =3D vm.xAlign;=0D + var yAlign =3D vm.yAlign;=0D + var x =3D pt.x;=0D + var y =3D pt.y;=0D + var width =3D tooltipSize.width;=0D + var height =3D tooltipSize.height;=0D + var radius =3D vm.cornerRadius;=0D +=0D + ctx.beginPath();=0D + ctx.moveTo(x + radius, y);=0D + if (yAlign =3D=3D=3D 'top') {=0D + this.drawCaret(pt, tooltipSize);=0D + }=0D + ctx.lineTo(x + width - radius, y);=0D + ctx.quadraticCurveTo(x + width, y, x + width, y + radius);=0D + if (yAlign =3D=3D=3D 'center' && xAlign =3D=3D=3D 'right') {=0D + this.drawCaret(pt, tooltipSize);=0D + }=0D + ctx.lineTo(x + width, y + height - radius);=0D + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + heig= ht);=0D + if (yAlign =3D=3D=3D 'bottom') {=0D + this.drawCaret(pt, tooltipSize);=0D + }=0D + ctx.lineTo(x + radius, y + height);=0D + ctx.quadraticCurveTo(x, y + height, x, y + height - radius);=0D + if (yAlign =3D=3D=3D 'center' && xAlign =3D=3D=3D 'left') {=0D + this.drawCaret(pt, tooltipSize);=0D + }=0D + ctx.lineTo(x, y + radius);=0D + ctx.quadraticCurveTo(x, y, x + radius, y);=0D + ctx.closePath();=0D +=0D + ctx.fill();=0D +=0D + if (vm.borderWidth > 0) {=0D + ctx.stroke();=0D + }=0D + },=0D +=0D + draw: function() {=0D + var ctx =3D this._chart.ctx;=0D + var vm =3D this._view;=0D +=0D + if (vm.opacity =3D=3D=3D 0) {=0D + return;=0D + }=0D +=0D + var tooltipSize =3D {=0D + width: vm.width,=0D + height: vm.height=0D + };=0D + var pt =3D {=0D + x: vm.x,=0D + y: vm.y=0D + };=0D +=0D + // IE11/Edge does not like very small opacities, so snap to 0=0D + var opacity =3D Math.abs(vm.opacity < 1e-3) ? 0 : vm.opacity;=0D +=0D + // Truthy/falsey value for empty tooltip=0D + var hasTooltipContent =3D vm.title.length || vm.beforeBody.length || vm.= body.length || vm.afterBody.length || vm.footer.length;=0D +=0D + if (this._options.enabled && hasTooltipContent) {=0D + ctx.save();=0D + ctx.globalAlpha =3D opacity;=0D +=0D + // Draw Background=0D + this.drawBackground(pt, vm, ctx, tooltipSize);=0D +=0D + // Draw Title, Body, and Footer=0D + pt.y +=3D vm.yPadding;=0D +=0D + helpers$1.rtl.overrideTextDirection(ctx, vm.textDirection);=0D +=0D + // Titles=0D + this.drawTitle(pt, vm, ctx);=0D +=0D + // Body=0D + this.drawBody(pt, vm, ctx);=0D +=0D + // Footer=0D + this.drawFooter(pt, vm, ctx);=0D +=0D + helpers$1.rtl.restoreTextDirection(ctx, vm.textDirection);=0D +=0D + ctx.restore();=0D + }=0D + },=0D +=0D + /**=0D + * Handle an event=0D + * @private=0D + * @param {IEvent} event - The event to handle=0D + * @returns {boolean} true if the tooltip changed=0D + */=0D + handleEvent: function(e) {=0D + var me =3D this;=0D + var options =3D me._options;=0D + var changed =3D false;=0D +=0D + me._lastActive =3D me._lastActive || [];=0D +=0D + // Find Active Elements for tooltips=0D + if (e.type =3D=3D=3D 'mouseout') {=0D + me._active =3D [];=0D + } else {=0D + me._active =3D me._chart.getElementsAtEventForMode(e, options.mode, opt= ions);=0D + if (options.reverse) {=0D + me._active.reverse();=0D + }=0D + }=0D +=0D + // Remember Last Actives=0D + changed =3D !helpers$1.arrayEquals(me._active, me._lastActive);=0D +=0D + // Only handle target event on tooltip change=0D + if (changed) {=0D + me._lastActive =3D me._active;=0D +=0D + if (options.enabled || options.custom) {=0D + me._eventPosition =3D {=0D + x: e.x,=0D + y: e.y=0D + };=0D +=0D + me.update(true);=0D + me.pivot();=0D + }=0D + }=0D +=0D + return changed;=0D + }=0D +});=0D +=0D +/**=0D + * @namespace Chart.Tooltip.positioners=0D + */=0D +var positioners_1 =3D positioners;=0D +=0D +var core_tooltip =3D exports$4; +core_tooltip.positioners =3D positioners_1; =20 - lineCount =3D helpers$1.isArray(opts.text) ? opts.text.length : 1; - textSize =3D lineCount * helpers$1.options._parseFont(opts).lineHeight += opts.padding * 2; +var valueOrDefault$9 =3D helpers$1.valueOrDefault;=0D +=0D +core_defaults._set('global', {=0D + elements: {},=0D + events: [=0D + 'mousemove',=0D + 'mouseout',=0D + 'click',=0D + 'touchstart',=0D + 'touchmove'=0D + ],=0D + hover: {=0D + onHover: null,=0D + mode: 'nearest',=0D + intersect: true,=0D + animationDuration: 400=0D + },=0D + onClick: null,=0D + maintainAspectRatio: true,=0D + responsive: true,=0D + responsiveAnimationDuration: 0=0D +});=0D +=0D +/**=0D + * Recursively merge the given config objects representing the `scales` op= tion=0D + * by incorporating scale defaults in `xAxes` and `yAxes` array items, the= n=0D + * returns a deep copy of the result, thus doesn't alter inputs.=0D + */=0D +function mergeScaleConfig(/* config objects ... */) {=0D + return helpers$1.merge(Object.create(null), [].slice.call(arguments), {=0D + merger: function(key, target, source, options) {=0D + if (key =3D=3D=3D 'xAxes' || key =3D=3D=3D 'yAxes') {=0D + var slen =3D source[key].length;=0D + var i, type, scale;=0D +=0D + if (!target[key]) {=0D + target[key] =3D [];=0D + }=0D +=0D + for (i =3D 0; i < slen; ++i) {=0D + scale =3D source[key][i];=0D + type =3D valueOrDefault$9(scale.type, key =3D=3D=3D 'xAxes' ? 'catego= ry' : 'linear');=0D +=0D + if (i >=3D target[key].length) {=0D + target[key].push({});=0D + }=0D +=0D + if (!target[key][i].type || (scale.type && scale.type !=3D=3D target[= key][i].type)) {=0D + // new/untyped scale or type changed: let's apply the new defaults=0D + // then merge source scale to correctly overwrite the defaults.=0D + helpers$1.merge(target[key][i], [core_scaleService.getScaleDefaults(= type), scale]);=0D + } else {=0D + // scales type are the same=0D + helpers$1.merge(target[key][i], scale);=0D + }=0D + }=0D + } else {=0D + helpers$1._merger(key, target, source, options);=0D + }=0D + }=0D + });=0D +}=0D +=0D +/**=0D + * Recursively merge the given config objects as the root options by handl= ing=0D + * default scale options for the `scales` and `scale` properties, then ret= urns=0D + * a deep copy of the result, thus doesn't alter inputs.=0D + */=0D +function mergeConfig(/* config objects ... */) {=0D + return helpers$1.merge(Object.create(null), [].slice.call(arguments), {=0D + merger: function(key, target, source, options) {=0D + var tval =3D target[key] || Object.create(null);=0D + var sval =3D source[key];=0D +=0D + if (key =3D=3D=3D 'scales') {=0D + // scale config merging is complex. Add our own function here for that= =0D + target[key] =3D mergeScaleConfig(tval, sval);=0D + } else if (key =3D=3D=3D 'scale') {=0D + // used in polar area & radar charts since there is only one scale=0D + target[key] =3D helpers$1.merge(tval, [core_scaleService.getScaleDefau= lts(sval.type), sval]);=0D + } else {=0D + helpers$1._merger(key, target, source, options);=0D + }=0D + }=0D + });=0D +}=0D +=0D +function initConfig(config) {=0D + config =3D config || Object.create(null);=0D +=0D + // Do NOT use mergeConfig for the data object because this method merges = arrays=0D + // and so would change references to labels and datasets, preventing data= updates.=0D + var data =3D config.data =3D config.data || {};=0D + data.datasets =3D data.datasets || [];=0D + data.labels =3D data.labels || [];=0D +=0D + config.options =3D mergeConfig(=0D + core_defaults.global,=0D + core_defaults[config.type],=0D + config.options || {});=0D +=0D + return config;=0D +}=0D +=0D +function updateConfig(chart) {=0D + var newOptions =3D chart.options;=0D +=0D + helpers$1.each(chart.scales, function(scale) {=0D + core_layouts.removeBox(chart, scale);=0D + });=0D +=0D + newOptions =3D mergeConfig(=0D + core_defaults.global,=0D + core_defaults[chart.config.type],=0D + newOptions);=0D +=0D + chart.options =3D chart.config.options =3D newOptions;=0D + chart.ensureScalesHaveIDs();=0D + chart.buildOrUpdateScales();=0D +=0D + // Tooltip=0D + chart.tooltip._options =3D newOptions.tooltips;=0D + chart.tooltip.initialize();=0D +}=0D +=0D +function nextAvailableScaleId(axesOpts, prefix, index) {=0D + var id;=0D + var hasId =3D function(obj) {=0D + return obj.id =3D=3D=3D id;=0D + };=0D +=0D + do {=0D + id =3D prefix + index++;=0D + } while (helpers$1.findIndex(axesOpts, hasId) >=3D 0);=0D +=0D + return id;=0D +}=0D +=0D +function positionIsHorizontal(position) {=0D + return position =3D=3D=3D 'top' || position =3D=3D=3D 'bottom';=0D +}=0D +=0D +function compare2Level(l1, l2) {=0D + return function(a, b) {=0D + return a[l1] =3D=3D=3D b[l1]=0D + ? a[l2] - b[l2]=0D + : a[l1] - b[l1];=0D + };=0D +}=0D +=0D +var Chart =3D function(item, config) {=0D + this.construct(item, config);=0D + return this;=0D +};=0D +=0D +helpers$1.extend(Chart.prototype, /** @lends Chart */ {=0D + /**=0D + * @private=0D + */=0D + construct: function(item, config) {=0D + var me =3D this;=0D +=0D + config =3D initConfig(config);=0D +=0D + var context =3D platform.acquireContext(item, config);=0D + var canvas =3D context && context.canvas;=0D + var height =3D canvas && canvas.height;=0D + var width =3D canvas && canvas.width;=0D +=0D + me.id =3D helpers$1.uid();=0D + me.ctx =3D context;=0D + me.canvas =3D canvas;=0D + me.config =3D config;=0D + me.width =3D width;=0D + me.height =3D height;=0D + me.aspectRatio =3D height ? width / height : null;=0D + me.options =3D config.options;=0D + me._bufferedRender =3D false;=0D + me._layers =3D [];=0D +=0D + /**=0D + * Provided for backward compatibility, Chart and Chart.Controller have = been merged,=0D + * the "instance" still need to be defined since it might be called from= plugins.=0D + * @prop Chart#chart=0D + * @deprecated since version 2.6.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D + me.chart =3D me;=0D + me.controller =3D me; // chart.chart.controller #inception=0D +=0D + // Add the chart instance to the global namespace=0D + Chart.instances[me.id] =3D me;=0D +=0D + // Define alias to the config data: `chart.data =3D=3D=3D chart.config.d= ata`=0D + Object.defineProperty(me, 'data', {=0D + get: function() {=0D + return me.config.data;=0D + },=0D + set: function(value) {=0D + me.config.data =3D value;=0D + }=0D + });=0D +=0D + if (!context || !canvas) {=0D + // The given item is not a compatible context2d element, let's return b= efore finalizing=0D + // the chart initialization but after setting basic chart / controller = properties that=0D + // can help to figure out that the chart is not valid (e.g chart.canvas= !=3D=3D null);=0D + // https://github.com/chartjs/Chart.js/issues/2807=0D + console.error("Failed to create chart: can't acquire context from the g= iven item");=0D + return;=0D + }=0D +=0D + me.initialize();=0D + me.update();=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + initialize: function() {=0D + var me =3D this;=0D +=0D + // Before init plugin notification=0D + core_plugins.notify(me, 'beforeInit');=0D +=0D + helpers$1.retinaScale(me, me.options.devicePixelRatio);=0D +=0D + me.bindEvents();=0D +=0D + if (me.options.responsive) {=0D + // Initial resize before chart draws (must be silent to preserve initia= l animations).=0D + me.resize(true);=0D + }=0D +=0D + me.initToolTip();=0D +=0D + // After init plugin notification=0D + core_plugins.notify(me, 'afterInit');=0D +=0D + return me;=0D + },=0D +=0D + clear: function() {=0D + helpers$1.canvas.clear(this);=0D + return this;=0D + },=0D +=0D + stop: function() {=0D + // Stops any current animation loop occurring=0D + core_animations.cancelAnimation(this);=0D + return this;=0D + },=0D +=0D + resize: function(silent) {=0D + var me =3D this;=0D + var options =3D me.options;=0D + var canvas =3D me.canvas;=0D + var aspectRatio =3D (options.maintainAspectRatio && me.aspectRatio) || n= ull;=0D +=0D + // the canvas render width and height will be casted to integers so make= sure that=0D + // the canvas display style uses the same integer values to avoid blurri= ng effect.=0D +=0D + // Set to 0 instead of canvas.size because the size defaults to 300x150 = if the element is collapsed=0D + var newWidth =3D Math.max(0, Math.floor(helpers$1.getMaximumWidth(canvas= )));=0D + var newHeight =3D Math.max(0, Math.floor(aspectRatio ? newWidth / aspect= Ratio : helpers$1.getMaximumHeight(canvas)));=0D +=0D + if (me.width =3D=3D=3D newWidth && me.height =3D=3D=3D newHeight) {=0D + return;=0D + }=0D +=0D + canvas.width =3D me.width =3D newWidth;=0D + canvas.height =3D me.height =3D newHeight;=0D + canvas.style.width =3D newWidth + 'px';=0D + canvas.style.height =3D newHeight + 'px';=0D +=0D + helpers$1.retinaScale(me, options.devicePixelRatio);=0D +=0D + if (!silent) {=0D + // Notify any plugins about the resize=0D + var newSize =3D {width: newWidth, height: newHeight};=0D + core_plugins.notify(me, 'resize', [newSize]);=0D +=0D + // Notify of resize=0D + if (options.onResize) {=0D + options.onResize(me, newSize);=0D + }=0D +=0D + me.stop();=0D + me.update({=0D + duration: options.responsiveAnimationDuration=0D + });=0D + }=0D + },=0D +=0D + ensureScalesHaveIDs: function() {=0D + var options =3D this.options;=0D + var scalesOptions =3D options.scales || {};=0D + var scaleOptions =3D options.scale;=0D +=0D + helpers$1.each(scalesOptions.xAxes, function(xAxisOptions, index) {=0D + if (!xAxisOptions.id) {=0D + xAxisOptions.id =3D nextAvailableScaleId(scalesOptions.xAxes, 'x-axis-= ', index);=0D + }=0D + });=0D +=0D + helpers$1.each(scalesOptions.yAxes, function(yAxisOptions, index) {=0D + if (!yAxisOptions.id) {=0D + yAxisOptions.id =3D nextAvailableScaleId(scalesOptions.yAxes, 'y-axis-= ', index);=0D + }=0D + });=0D +=0D + if (scaleOptions) {=0D + scaleOptions.id =3D scaleOptions.id || 'scale';=0D + }=0D + },=0D +=0D + /**=0D + * Builds a map of scale ID to scale object for future lookup.=0D + */=0D + buildOrUpdateScales: function() {=0D + var me =3D this;=0D + var options =3D me.options;=0D + var scales =3D me.scales || {};=0D + var items =3D [];=0D + var updated =3D Object.keys(scales).reduce(function(obj, id) {=0D + obj[id] =3D false;=0D + return obj;=0D + }, {});=0D +=0D + if (options.scales) {=0D + items =3D items.concat(=0D + (options.scales.xAxes || []).map(function(xAxisOptions) {=0D + return {options: xAxisOptions, dtype: 'category', dposition: 'bottom'= };=0D + }),=0D + (options.scales.yAxes || []).map(function(yAxisOptions) {=0D + return {options: yAxisOptions, dtype: 'linear', dposition: 'left'};=0D + })=0D + );=0D + }=0D +=0D + if (options.scale) {=0D + items.push({=0D + options: options.scale,=0D + dtype: 'radialLinear',=0D + isDefault: true,=0D + dposition: 'chartArea'=0D + });=0D + }=0D +=0D + helpers$1.each(items, function(item) {=0D + var scaleOptions =3D item.options;=0D + var id =3D scaleOptions.id;=0D + var scaleType =3D valueOrDefault$9(scaleOptions.type, item.dtype);=0D +=0D + if (positionIsHorizontal(scaleOptions.position) !=3D=3D positionIsHoriz= ontal(item.dposition)) {=0D + scaleOptions.position =3D item.dposition;=0D + }=0D +=0D + updated[id] =3D true;=0D + var scale =3D null;=0D + if (id in scales && scales[id].type =3D=3D=3D scaleType) {=0D + scale =3D scales[id];=0D + scale.options =3D scaleOptions;=0D + scale.ctx =3D me.ctx;=0D + scale.chart =3D me;=0D + } else {=0D + var scaleClass =3D core_scaleService.getScaleConstructor(scaleType);=0D + if (!scaleClass) {=0D + return;=0D + }=0D + scale =3D new scaleClass({=0D + id: id,=0D + type: scaleType,=0D + options: scaleOptions,=0D + ctx: me.ctx,=0D + chart: me=0D + });=0D + scales[scale.id] =3D scale;=0D + }=0D +=0D + scale.mergeTicksOptions();=0D +=0D + // TODO(SB): I think we should be able to remove this custom case (opti= ons.scale)=0D + // and consider it as a regular scale part of the "scales"" map only! T= his would=0D + // make the logic easier and remove some useless? custom code.=0D + if (item.isDefault) {=0D + me.scale =3D scale;=0D + }=0D + });=0D + // clear up discarded scales=0D + helpers$1.each(updated, function(hasUpdated, id) {=0D + if (!hasUpdated) {=0D + delete scales[id];=0D + }=0D + });=0D +=0D + me.scales =3D scales;=0D +=0D + core_scaleService.addScalesToLayout(this);=0D + },=0D +=0D + buildOrUpdateControllers: function() {=0D + var me =3D this;=0D + var newControllers =3D [];=0D + var datasets =3D me.data.datasets;=0D + var i, ilen;=0D +=0D + for (i =3D 0, ilen =3D datasets.length; i < ilen; i++) {=0D + var dataset =3D datasets[i];=0D + var meta =3D me.getDatasetMeta(i);=0D + var type =3D dataset.type || me.config.type;=0D +=0D + if (meta.type && meta.type !=3D=3D type) {=0D + me.destroyDatasetMeta(i);=0D + meta =3D me.getDatasetMeta(i);=0D + }=0D + meta.type =3D type;=0D + meta.order =3D dataset.order || 0;=0D + meta.index =3D i;=0D +=0D + if (meta.controller) {=0D + meta.controller.updateIndex(i);=0D + meta.controller.linkScales();=0D + } else {=0D + var ControllerClass =3D controllers[meta.type];=0D + if (ControllerClass =3D=3D=3D undefined) {=0D + throw new Error('"' + meta.type + '" is not a chart type.');=0D + }=0D +=0D + meta.controller =3D new ControllerClass(me, i);=0D + newControllers.push(meta.controller);=0D + }=0D + }=0D +=0D + return newControllers;=0D + },=0D +=0D + /**=0D + * Reset the elements of all datasets=0D + * @private=0D + */=0D + resetElements: function() {=0D + var me =3D this;=0D + helpers$1.each(me.data.datasets, function(dataset, datasetIndex) {=0D + me.getDatasetMeta(datasetIndex).controller.reset();=0D + }, me);=0D + },=0D +=0D + /**=0D + * Resets the chart back to it's state before the initial animation=0D + */=0D + reset: function() {=0D + this.resetElements();=0D + this.tooltip.initialize();=0D + },=0D +=0D + update: function(config) {=0D + var me =3D this;=0D + var i, ilen;=0D +=0D + if (!config || typeof config !=3D=3D 'object') {=0D + // backwards compatibility=0D + config =3D {=0D + duration: config,=0D + lazy: arguments[1]=0D + };=0D + }=0D +=0D + updateConfig(me);=0D +=0D + // plugins options references might have change, let's invalidate the ca= che=0D + // https://github.com/chartjs/Chart.js/issues/5111#issuecomment-35593416= 7=0D + core_plugins._invalidate(me);=0D +=0D + if (core_plugins.notify(me, 'beforeUpdate') =3D=3D=3D false) {=0D + return;=0D + }=0D +=0D + // In case the entire data object changed=0D + me.tooltip._data =3D me.data;=0D +=0D + // Make sure dataset controllers are updated and new controllers are res= et=0D + var newControllers =3D me.buildOrUpdateControllers();=0D +=0D + // Make sure all dataset controllers have correct meta data counts=0D + for (i =3D 0, ilen =3D me.data.datasets.length; i < ilen; i++) {=0D + me.getDatasetMeta(i).controller.buildOrUpdateElements();=0D + }=0D +=0D + me.updateLayout();=0D +=0D + // Can only reset the new controllers after the scales have been updated= =0D + if (me.options.animation && me.options.animation.duration) {=0D + helpers$1.each(newControllers, function(controller) {=0D + controller.reset();=0D + });=0D + }=0D +=0D + me.updateDatasets();=0D +=0D + // Need to reset tooltip in case it is displayed with elements that are = removed=0D + // after update.=0D + me.tooltip.initialize();=0D +=0D + // Last active contains items that were previously in the tooltip.=0D + // When we reset the tooltip, we need to clear it=0D + me.lastActive =3D [];=0D +=0D + // Do this before render so that any plugins that need final scale updat= es can use it=0D + core_plugins.notify(me, 'afterUpdate');=0D +=0D + me._layers.sort(compare2Level('z', '_idx'));=0D +=0D + if (me._bufferedRender) {=0D + me._bufferedRequest =3D {=0D + duration: config.duration,=0D + easing: config.easing,=0D + lazy: config.lazy=0D + };=0D + } else {=0D + me.render(config);=0D + }=0D + },=0D +=0D + /**=0D + * Updates the chart layout unless a plugin returns `false` to the `befor= eLayout`=0D + * hook, in which case, plugins will not be called on `afterLayout`.=0D + * @private=0D + */=0D + updateLayout: function() {=0D + var me =3D this;=0D +=0D + if (core_plugins.notify(me, 'beforeLayout') =3D=3D=3D false) {=0D + return;=0D + }=0D +=0D + core_layouts.update(this, this.width, this.height);=0D +=0D + me._layers =3D [];=0D + helpers$1.each(me.boxes, function(box) {=0D + // _configure is called twice, once in core.scale.update and once here.= =0D + // Here the boxes are fully updated and at their final positions.=0D + if (box._configure) {=0D + box._configure();=0D + }=0D + me._layers.push.apply(me._layers, box._layers());=0D + }, me);=0D +=0D + me._layers.forEach(function(item, index) {=0D + item._idx =3D index;=0D + });=0D +=0D + /**=0D + * Provided for backward compatibility, use `afterLayout` instead.=0D + * @method IPlugin#afterScaleUpdate=0D + * @deprecated since version 2.5.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D + core_plugins.notify(me, 'afterScaleUpdate');=0D + core_plugins.notify(me, 'afterLayout');=0D + },=0D +=0D + /**=0D + * Updates all datasets unless a plugin returns `false` to the `beforeDat= asetsUpdate`=0D + * hook, in which case, plugins will not be called on `afterDatasetsUpdat= e`.=0D + * @private=0D + */=0D + updateDatasets: function() {=0D + var me =3D this;=0D +=0D + if (core_plugins.notify(me, 'beforeDatasetsUpdate') =3D=3D=3D false) {=0D + return;=0D + }=0D +=0D + for (var i =3D 0, ilen =3D me.data.datasets.length; i < ilen; ++i) {=0D + me.updateDataset(i);=0D + }=0D +=0D + core_plugins.notify(me, 'afterDatasetsUpdate');=0D + },=0D +=0D + /**=0D + * Updates dataset at index unless a plugin returns `false` to the `befor= eDatasetUpdate`=0D + * hook, in which case, plugins will not be called on `afterDatasetUpdate= `.=0D + * @private=0D + */=0D + updateDataset: function(index) {=0D + var me =3D this;=0D + var meta =3D me.getDatasetMeta(index);=0D + var args =3D {=0D + meta: meta,=0D + index: index=0D + };=0D +=0D + if (core_plugins.notify(me, 'beforeDatasetUpdate', [args]) =3D=3D=3D fal= se) {=0D + return;=0D + }=0D +=0D + meta.controller._update();=0D +=0D + core_plugins.notify(me, 'afterDatasetUpdate', [args]);=0D + },=0D +=0D + render: function(config) {=0D + var me =3D this;=0D +=0D + if (!config || typeof config !=3D=3D 'object') {=0D + // backwards compatibility=0D + config =3D {=0D + duration: config,=0D + lazy: arguments[1]=0D + };=0D + }=0D +=0D + var animationOptions =3D me.options.animation;=0D + var duration =3D valueOrDefault$9(config.duration, animationOptions && a= nimationOptions.duration);=0D + var lazy =3D config.lazy;=0D +=0D + if (core_plugins.notify(me, 'beforeRender') =3D=3D=3D false) {=0D + return;=0D + }=0D +=0D + var onComplete =3D function(animation) {=0D + core_plugins.notify(me, 'afterRender');=0D + helpers$1.callback(animationOptions && animationOptions.onComplete, [an= imation], me);=0D + };=0D +=0D + if (animationOptions && duration) {=0D + var animation =3D new core_animation({=0D + numSteps: duration / 16.66, // 60 fps=0D + easing: config.easing || animationOptions.easing,=0D +=0D + render: function(chart, animationObject) {=0D + var easingFunction =3D helpers$1.easing.effects[animationObject.easin= g];=0D + var currentStep =3D animationObject.currentStep;=0D + var stepDecimal =3D currentStep / animationObject.numSteps;=0D +=0D + chart.draw(easingFunction(stepDecimal), stepDecimal, currentStep);=0D + },=0D +=0D + onAnimationProgress: animationOptions.onProgress,=0D + onAnimationComplete: onComplete=0D + });=0D +=0D + core_animations.addAnimation(me, animation, duration, lazy);=0D + } else {=0D + me.draw();=0D +=0D + // See https://github.com/chartjs/Chart.js/issues/3781=0D + onComplete(new core_animation({numSteps: 0, chart: me}));=0D + }=0D +=0D + return me;=0D + },=0D +=0D + draw: function(easingValue) {=0D + var me =3D this;=0D + var i, layers;=0D +=0D + me.clear();=0D +=0D + if (helpers$1.isNullOrUndef(easingValue)) {=0D + easingValue =3D 1;=0D + }=0D +=0D + me.transition(easingValue);=0D +=0D + if (me.width <=3D 0 || me.height <=3D 0) {=0D + return;=0D + }=0D +=0D + if (core_plugins.notify(me, 'beforeDraw', [easingValue]) =3D=3D=3D false= ) {=0D + return;=0D + }=0D +=0D + // Because of plugin hooks (before/afterDatasetsDraw), datasets can't=0D + // currently be part of layers. Instead, we draw=0D + // layers <=3D 0 before(default, backward compat), and the rest after=0D + layers =3D me._layers;=0D + for (i =3D 0; i < layers.length && layers[i].z <=3D 0; ++i) {=0D + layers[i].draw(me.chartArea);=0D + }=0D +=0D + me.drawDatasets(easingValue);=0D +=0D + // Rest of layers=0D + for (; i < layers.length; ++i) {=0D + layers[i].draw(me.chartArea);=0D + }=0D +=0D + me._drawTooltip(easingValue);=0D +=0D + core_plugins.notify(me, 'afterDraw', [easingValue]);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + transition: function(easingValue) {=0D + var me =3D this;=0D +=0D + for (var i =3D 0, ilen =3D (me.data.datasets || []).length; i < ilen; ++= i) {=0D + if (me.isDatasetVisible(i)) {=0D + me.getDatasetMeta(i).controller.transition(easingValue);=0D + }=0D + }=0D +=0D + me.tooltip.transition(easingValue);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getSortedDatasetMetas: function(filterVisible) {=0D + var me =3D this;=0D + var datasets =3D me.data.datasets || [];=0D + var result =3D [];=0D + var i, ilen;=0D +=0D + for (i =3D 0, ilen =3D datasets.length; i < ilen; ++i) {=0D + if (!filterVisible || me.isDatasetVisible(i)) {=0D + result.push(me.getDatasetMeta(i));=0D + }=0D + }=0D +=0D + result.sort(compare2Level('order', 'index'));=0D +=0D + return result;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getSortedVisibleDatasetMetas: function() {=0D + return this._getSortedDatasetMetas(true);=0D + },=0D +=0D + /**=0D + * Draws all datasets unless a plugin returns `false` to the `beforeDatas= etsDraw`=0D + * hook, in which case, plugins will not be called on `afterDatasetsDraw`= .=0D + * @private=0D + */=0D + drawDatasets: function(easingValue) {=0D + var me =3D this;=0D + var metasets, i;=0D +=0D + if (core_plugins.notify(me, 'beforeDatasetsDraw', [easingValue]) =3D=3D= =3D false) {=0D + return;=0D + }=0D +=0D + metasets =3D me._getSortedVisibleDatasetMetas();=0D + for (i =3D metasets.length - 1; i >=3D 0; --i) {=0D + me.drawDataset(metasets[i], easingValue);=0D + }=0D +=0D + core_plugins.notify(me, 'afterDatasetsDraw', [easingValue]);=0D + },=0D +=0D + /**=0D + * Draws dataset at index unless a plugin returns `false` to the `beforeD= atasetDraw`=0D + * hook, in which case, plugins will not be called on `afterDatasetDraw`.= =0D + * @private=0D + */=0D + drawDataset: function(meta, easingValue) {=0D + var me =3D this;=0D + var args =3D {=0D + meta: meta,=0D + index: meta.index,=0D + easingValue: easingValue=0D + };=0D +=0D + if (core_plugins.notify(me, 'beforeDatasetDraw', [args]) =3D=3D=3D false= ) {=0D + return;=0D + }=0D +=0D + meta.controller.draw(easingValue);=0D +=0D + core_plugins.notify(me, 'afterDatasetDraw', [args]);=0D + },=0D +=0D + /**=0D + * Draws tooltip unless a plugin returns `false` to the `beforeTooltipDra= w`=0D + * hook, in which case, plugins will not be called on `afterTooltipDraw`.= =0D + * @private=0D + */=0D + _drawTooltip: function(easingValue) {=0D + var me =3D this;=0D + var tooltip =3D me.tooltip;=0D + var args =3D {=0D + tooltip: tooltip,=0D + easingValue: easingValue=0D + };=0D +=0D + if (core_plugins.notify(me, 'beforeTooltipDraw', [args]) =3D=3D=3D false= ) {=0D + return;=0D + }=0D +=0D + tooltip.draw();=0D +=0D + core_plugins.notify(me, 'afterTooltipDraw', [args]);=0D + },=0D +=0D + /**=0D + * Get the single element that was clicked on=0D + * @return An object containing the dataset index and element index of th= e matching element. Also contains the rectangle that was draw=0D + */=0D + getElementAtEvent: function(e) {=0D + return core_interaction.modes.single(this, e);=0D + },=0D +=0D + getElementsAtEvent: function(e) {=0D + return core_interaction.modes.label(this, e, {intersect: true});=0D + },=0D +=0D + getElementsAtXAxis: function(e) {=0D + return core_interaction.modes['x-axis'](this, e, {intersect: true});=0D + },=0D +=0D + getElementsAtEventForMode: function(e, mode, options) {=0D + var method =3D core_interaction.modes[mode];=0D + if (typeof method =3D=3D=3D 'function') {=0D + return method(this, e, options);=0D + }=0D +=0D + return [];=0D + },=0D +=0D + getDatasetAtEvent: function(e) {=0D + return core_interaction.modes.dataset(this, e, {intersect: true});=0D + },=0D +=0D + getDatasetMeta: function(datasetIndex) {=0D + var me =3D this;=0D + var dataset =3D me.data.datasets[datasetIndex];=0D + if (!dataset._meta) {=0D + dataset._meta =3D {};=0D + }=0D +=0D + var meta =3D dataset._meta[me.id];=0D + if (!meta) {=0D + meta =3D dataset._meta[me.id] =3D {=0D + type: null,=0D + data: [],=0D + dataset: null,=0D + controller: null,=0D + hidden: null, // See isDatasetVisible() comment=0D + xAxisID: null,=0D + yAxisID: null,=0D + order: dataset.order || 0,=0D + index: datasetIndex=0D + };=0D + }=0D +=0D + return meta;=0D + },=0D +=0D + getVisibleDatasetCount: function() {=0D + var count =3D 0;=0D + for (var i =3D 0, ilen =3D this.data.datasets.length; i < ilen; ++i) {=0D + if (this.isDatasetVisible(i)) {=0D + count++;=0D + }=0D + }=0D + return count;=0D + },=0D +=0D + isDatasetVisible: function(datasetIndex) {=0D + var meta =3D this.getDatasetMeta(datasetIndex);=0D +=0D + // meta.hidden is a per chart dataset hidden flag override with 3 states= : if true or false,=0D + // the dataset.hidden value is ignored, else if null, the dataset hidden= state is returned.=0D + return typeof meta.hidden =3D=3D=3D 'boolean' ? !meta.hidden : !this.dat= a.datasets[datasetIndex].hidden;=0D + },=0D +=0D + generateLegend: function() {=0D + return this.options.legendCallback(this);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + destroyDatasetMeta: function(datasetIndex) {=0D + var id =3D this.id;=0D + var dataset =3D this.data.datasets[datasetIndex];=0D + var meta =3D dataset._meta && dataset._meta[id];=0D +=0D + if (meta) {=0D + meta.controller.destroy();=0D + delete dataset._meta[id];=0D + }=0D + },=0D +=0D + destroy: function() {=0D + var me =3D this;=0D + var canvas =3D me.canvas;=0D + var i, ilen;=0D +=0D + me.stop();=0D +=0D + // dataset controllers need to cleanup associated data=0D + for (i =3D 0, ilen =3D me.data.datasets.length; i < ilen; ++i) {=0D + me.destroyDatasetMeta(i);=0D + }=0D +=0D + if (canvas) {=0D + me.unbindEvents();=0D + helpers$1.canvas.clear(me);=0D + platform.releaseContext(me.ctx);=0D + me.canvas =3D null;=0D + me.ctx =3D null;=0D + }=0D +=0D + core_plugins.notify(me, 'destroy');=0D +=0D + delete Chart.instances[me.id];=0D + },=0D +=0D + toBase64Image: function() {=0D + return this.canvas.toDataURL.apply(this.canvas, arguments);=0D + },=0D +=0D + initToolTip: function() {=0D + var me =3D this;=0D + me.tooltip =3D new core_tooltip({=0D + _chart: me,=0D + _chartInstance: me, // deprecated, backward compatibility=0D + _data: me.data,=0D + _options: me.options.tooltips=0D + }, me);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + bindEvents: function() {=0D + var me =3D this;=0D + var listeners =3D me._listeners =3D {};=0D + var listener =3D function() {=0D + me.eventHandler.apply(me, arguments);=0D + };=0D +=0D + helpers$1.each(me.options.events, function(type) {=0D + platform.addEventListener(me, type, listener);=0D + listeners[type] =3D listener;=0D + });=0D +=0D + // Elements used to detect size change should not be injected for non re= sponsive charts.=0D + // See https://github.com/chartjs/Chart.js/issues/2210=0D + if (me.options.responsive) {=0D + listener =3D function() {=0D + me.resize();=0D + };=0D +=0D + platform.addEventListener(me, 'resize', listener);=0D + listeners.resize =3D listener;=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + unbindEvents: function() {=0D + var me =3D this;=0D + var listeners =3D me._listeners;=0D + if (!listeners) {=0D + return;=0D + }=0D +=0D + delete me._listeners;=0D + helpers$1.each(listeners, function(listener, type) {=0D + platform.removeEventListener(me, type, listener);=0D + });=0D + },=0D +=0D + updateHoverStyle: function(elements, mode, enabled) {=0D + var prefix =3D enabled ? 'set' : 'remove';=0D + var element, i, ilen;=0D +=0D + for (i =3D 0, ilen =3D elements.length; i < ilen; ++i) {=0D + element =3D elements[i];=0D + if (element) {=0D + this.getDatasetMeta(element._datasetIndex).controller[prefix + 'HoverS= tyle'](element);=0D + }=0D + }=0D +=0D + if (mode =3D=3D=3D 'dataset') {=0D + this.getDatasetMeta(elements[0]._datasetIndex).controller['_' + prefix = + 'DatasetHoverStyle']();=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + eventHandler: function(e) {=0D + var me =3D this;=0D + var tooltip =3D me.tooltip;=0D +=0D + if (core_plugins.notify(me, 'beforeEvent', [e]) =3D=3D=3D false) {=0D + return;=0D + }=0D +=0D + // Buffer any update calls so that renders do not occur=0D + me._bufferedRender =3D true;=0D + me._bufferedRequest =3D null;=0D +=0D + var changed =3D me.handleEvent(e);=0D + // for smooth tooltip animations issue #4989=0D + // the tooltip should be the source of change=0D + // Animation check workaround:=0D + // tooltip._start will be null when tooltip isn't animating=0D + if (tooltip) {=0D + changed =3D tooltip._start=0D + ? tooltip.handleEvent(e)=0D + : changed | tooltip.handleEvent(e);=0D + }=0D +=0D + core_plugins.notify(me, 'afterEvent', [e]);=0D +=0D + var bufferedRequest =3D me._bufferedRequest;=0D + if (bufferedRequest) {=0D + // If we have an update that was triggered, we need to do a normal rend= er=0D + me.render(bufferedRequest);=0D + } else if (changed && !me.animating) {=0D + // If entering, leaving, or changing elements, animate the change via p= ivot=0D + me.stop();=0D +=0D + // We only need to render at this point. Updating will cause scales to = be=0D + // recomputed generating flicker & using more memory than necessary.=0D + me.render({=0D + duration: me.options.hover.animationDuration,=0D + lazy: true=0D + });=0D + }=0D +=0D + me._bufferedRender =3D false;=0D + me._bufferedRequest =3D null;=0D +=0D + return me;=0D + },=0D +=0D + /**=0D + * Handle an event=0D + * @private=0D + * @param {IEvent} event the event to handle=0D + * @return {boolean} true if the chart needs to re-render=0D + */=0D + handleEvent: function(e) {=0D + var me =3D this;=0D + var options =3D me.options || {};=0D + var hoverOptions =3D options.hover;=0D + var changed =3D false;=0D +=0D + me.lastActive =3D me.lastActive || [];=0D +=0D + // Find Active Elements for hover and tooltips=0D + if (e.type =3D=3D=3D 'mouseout') {=0D + me.active =3D [];=0D + } else {=0D + me.active =3D me.getElementsAtEventForMode(e, hoverOptions.mode, hoverO= ptions);=0D + }=0D +=0D + // Invoke onHover hook=0D + // Need to call with native event here to not break backwards compatibil= ity=0D + helpers$1.callback(options.onHover || options.hover.onHover, [e.native, = me.active], me);=0D +=0D + if (e.type =3D=3D=3D 'mouseup' || e.type =3D=3D=3D 'click') {=0D + if (options.onClick) {=0D + // Use e.native here for backwards compatibility=0D + options.onClick.call(me, e.native, me.active);=0D + }=0D + }=0D +=0D + // Remove styling for last active (even if it may still be active)=0D + if (me.lastActive.length) {=0D + me.updateHoverStyle(me.lastActive, hoverOptions.mode, false);=0D + }=0D +=0D + // Built in hover styling=0D + if (me.active.length && hoverOptions.mode) {=0D + me.updateHoverStyle(me.active, hoverOptions.mode, true);=0D + }=0D +=0D + changed =3D !helpers$1.arrayEquals(me.active, me.lastActive);=0D +=0D + // Remember Last Actives=0D + me.lastActive =3D me.active;=0D +=0D + return changed;=0D + }=0D +});=0D +=0D +/**=0D + * NOTE(SB) We actually don't use this container anymore but we need to ke= ep it=0D + * for backward compatibility. Though, it can still be useful for plugins = that=0D + * would need to work on multiple charts?!=0D + */=0D +Chart.instances =3D {};=0D +=0D +var core_controller =3D Chart;=0D +=0D +// DEPRECATIONS=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart instead.=0D + * @class Chart.Controller=0D + * @deprecated since version 2.6=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +Chart.Controller =3D Chart;=0D +=0D +/**=0D + * Provided for backward compatibility, not available anymore.=0D + * @namespace Chart=0D + * @deprecated since version 2.8=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +Chart.types =3D {};=0D +=0D +/**=0D + * Provided for backward compatibility, not available anymore.=0D + * @namespace Chart.helpers.configMerge=0D + * @deprecated since version 2.8.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers$1.configMerge =3D mergeConfig;=0D +=0D +/**=0D + * Provided for backward compatibility, not available anymore.=0D + * @namespace Chart.helpers.scaleMerge=0D + * @deprecated since version 2.8.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +helpers$1.scaleMerge =3D mergeScaleConfig; =20 - me.width =3D minSize.width =3D isHorizontal ? me.maxWidth : textSize; - me.height =3D minSize.height =3D isHorizontal ? textSize : me.maxHeight; - }, - afterFit: noop$2, +var core_helpers =3D function() {=0D +=0D + // -- Basic js utility methods=0D +=0D + helpers$1.where =3D function(collection, filterCallback) {=0D + if (helpers$1.isArray(collection) && Array.prototype.filter) {=0D + return collection.filter(filterCallback);=0D + }=0D + var filtered =3D [];=0D +=0D + helpers$1.each(collection, function(item) {=0D + if (filterCallback(item)) {=0D + filtered.push(item);=0D + }=0D + });=0D +=0D + return filtered;=0D + };=0D + helpers$1.findIndex =3D Array.prototype.findIndex ?=0D + function(array, callback, scope) {=0D + return array.findIndex(callback, scope);=0D + } :=0D + function(array, callback, scope) {=0D + scope =3D scope =3D=3D=3D undefined ? array : scope;=0D + for (var i =3D 0, ilen =3D array.length; i < ilen; ++i) {=0D + if (callback.call(scope, array[i], i, array)) {=0D + return i;=0D + }=0D + }=0D + return -1;=0D + };=0D + helpers$1.findNextWhere =3D function(arrayToSearch, filterCallback, start= Index) {=0D + // Default to start of the array=0D + if (helpers$1.isNullOrUndef(startIndex)) {=0D + startIndex =3D -1;=0D + }=0D + for (var i =3D startIndex + 1; i < arrayToSearch.length; i++) {=0D + var currentItem =3D arrayToSearch[i];=0D + if (filterCallback(currentItem)) {=0D + return currentItem;=0D + }=0D + }=0D + };=0D + helpers$1.findPreviousWhere =3D function(arrayToSearch, filterCallback, s= tartIndex) {=0D + // Default to end of the array=0D + if (helpers$1.isNullOrUndef(startIndex)) {=0D + startIndex =3D arrayToSearch.length;=0D + }=0D + for (var i =3D startIndex - 1; i >=3D 0; i--) {=0D + var currentItem =3D arrayToSearch[i];=0D + if (filterCallback(currentItem)) {=0D + return currentItem;=0D + }=0D + }=0D + };=0D +=0D + // -- Math methods=0D + helpers$1.isNumber =3D function(n) {=0D + return !isNaN(parseFloat(n)) && isFinite(n);=0D + };=0D + helpers$1.almostEquals =3D function(x, y, epsilon) {=0D + return Math.abs(x - y) < epsilon;=0D + };=0D + helpers$1.almostWhole =3D function(x, epsilon) {=0D + var rounded =3D Math.round(x);=0D + return ((rounded - epsilon) <=3D x) && ((rounded + epsilon) >=3D x);=0D + };=0D + helpers$1.max =3D function(array) {=0D + return array.reduce(function(max, value) {=0D + if (!isNaN(value)) {=0D + return Math.max(max, value);=0D + }=0D + return max;=0D + }, Number.NEGATIVE_INFINITY);=0D + };=0D + helpers$1.min =3D function(array) {=0D + return array.reduce(function(min, value) {=0D + if (!isNaN(value)) {=0D + return Math.min(min, value);=0D + }=0D + return min;=0D + }, Number.POSITIVE_INFINITY);=0D + };=0D + helpers$1.sign =3D Math.sign ?=0D + function(x) {=0D + return Math.sign(x);=0D + } :=0D + function(x) {=0D + x =3D +x; // convert to a number=0D + if (x =3D=3D=3D 0 || isNaN(x)) {=0D + return x;=0D + }=0D + return x > 0 ? 1 : -1;=0D + };=0D + helpers$1.toRadians =3D function(degrees) {=0D + return degrees * (Math.PI / 180);=0D + };=0D + helpers$1.toDegrees =3D function(radians) {=0D + return radians * (180 / Math.PI);=0D + };=0D +=0D + /**=0D + * Returns the number of decimal places=0D + * i.e. the number of digits after the decimal point, of the value of thi= s Number.=0D + * @param {number} x - A number.=0D + * @returns {number} The number of decimal places.=0D + * @private=0D + */=0D + helpers$1._decimalPlaces =3D function(x) {=0D + if (!helpers$1.isFinite(x)) {=0D + return;=0D + }=0D + var e =3D 1;=0D + var p =3D 0;=0D + while (Math.round(x * e) / e !=3D=3D x) {=0D + e *=3D 10;=0D + p++;=0D + }=0D + return p;=0D + };=0D +=0D + // Gets the angle from vertical upright to the point about a centre.=0D + helpers$1.getAngleFromPoint =3D function(centrePoint, anglePoint) {=0D + var distanceFromXCenter =3D anglePoint.x - centrePoint.x;=0D + var distanceFromYCenter =3D anglePoint.y - centrePoint.y;=0D + var radialDistanceFromCenter =3D Math.sqrt(distanceFromXCenter * distanc= eFromXCenter + distanceFromYCenter * distanceFromYCenter);=0D +=0D + var angle =3D Math.atan2(distanceFromYCenter, distanceFromXCenter);=0D +=0D + if (angle < (-0.5 * Math.PI)) {=0D + angle +=3D 2.0 * Math.PI; // make sure the returned angle is in the ran= ge of (-PI/2, 3PI/2]=0D + }=0D +=0D + return {=0D + angle: angle,=0D + distance: radialDistanceFromCenter=0D + };=0D + };=0D + helpers$1.distanceBetweenPoints =3D function(pt1, pt2) {=0D + return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2)= );=0D + };=0D +=0D + /**=0D + * Provided for backward compatibility, not available anymore=0D + * @function Chart.helpers.aliasPixel=0D + * @deprecated since version 2.8.0=0D + * @todo remove at version 3=0D + */=0D + helpers$1.aliasPixel =3D function(pixelWidth) {=0D + return (pixelWidth % 2 =3D=3D=3D 0) ? 0 : 0.5;=0D + };=0D +=0D + /**=0D + * Returns the aligned pixel value to avoid anti-aliasing blur=0D + * @param {Chart} chart - The chart instance.=0D + * @param {number} pixel - A pixel value.=0D + * @param {number} width - The width of the element.=0D + * @returns {number} The aligned pixel value.=0D + * @private=0D + */=0D + helpers$1._alignPixel =3D function(chart, pixel, width) {=0D + var devicePixelRatio =3D chart.currentDevicePixelRatio;=0D + var halfWidth =3D width / 2;=0D + return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelR= atio + halfWidth;=0D + };=0D +=0D + helpers$1.splineCurve =3D function(firstPoint, middlePoint, afterPoint, t= ) {=0D + // Props to Rob Spencer at scaled innovation for his post on splining be= tween points=0D + // http://scaledinnovation.com/analytics/splines/aboutSplines.html=0D +=0D + // This function must also respect "skipped" points=0D +=0D + var previous =3D firstPoint.skip ? middlePoint : firstPoint;=0D + var current =3D middlePoint;=0D + var next =3D afterPoint.skip ? middlePoint : afterPoint;=0D +=0D + var d01 =3D Math.sqrt(Math.pow(current.x - previous.x, 2) + Math.pow(cur= rent.y - previous.y, 2));=0D + var d12 =3D Math.sqrt(Math.pow(next.x - current.x, 2) + Math.pow(next.y = - current.y, 2));=0D +=0D + var s01 =3D d01 / (d01 + d12);=0D + var s12 =3D d12 / (d01 + d12);=0D +=0D + // If all points are the same, s01 & s02 will be inf=0D + s01 =3D isNaN(s01) ? 0 : s01;=0D + s12 =3D isNaN(s12) ? 0 : s12;=0D +=0D + var fa =3D t * s01; // scaling factor for triangle Ta=0D + var fb =3D t * s12;=0D +=0D + return {=0D + previous: {=0D + x: current.x - fa * (next.x - previous.x),=0D + y: current.y - fa * (next.y - previous.y)=0D + },=0D + next: {=0D + x: current.x + fb * (next.x - previous.x),=0D + y: current.y + fb * (next.y - previous.y)=0D + }=0D + };=0D + };=0D + helpers$1.EPSILON =3D Number.EPSILON || 1e-14;=0D + helpers$1.splineCurveMonotone =3D function(points) {=0D + // This function calculates B=C3=A9zier control points in a similar way = than |splineCurve|,=0D + // but preserves monotonicity of the provided data and ensures no local = extremums are added=0D + // between the dataset discrete points due to the interpolation.=0D + // See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation=0D +=0D + var pointsWithTangents =3D (points || []).map(function(point) {=0D + return {=0D + model: point._model,=0D + deltaK: 0,=0D + mK: 0=0D + };=0D + });=0D +=0D + // Calculate slopes (deltaK) and initialize tangents (mK)=0D + var pointsLen =3D pointsWithTangents.length;=0D + var i, pointBefore, pointCurrent, pointAfter;=0D + for (i =3D 0; i < pointsLen; ++i) {=0D + pointCurrent =3D pointsWithTangents[i];=0D + if (pointCurrent.model.skip) {=0D + continue;=0D + }=0D +=0D + pointBefore =3D i > 0 ? pointsWithTangents[i - 1] : null;=0D + pointAfter =3D i < pointsLen - 1 ? pointsWithTangents[i + 1] : null;=0D + if (pointAfter && !pointAfter.model.skip) {=0D + var slopeDeltaX =3D (pointAfter.model.x - pointCurrent.model.x);=0D +=0D + // In the case of two points that appear at the same x pixel, slopeDel= taX is 0=0D + pointCurrent.deltaK =3D slopeDeltaX !=3D=3D 0 ? (pointAfter.model.y - = pointCurrent.model.y) / slopeDeltaX : 0;=0D + }=0D +=0D + if (!pointBefore || pointBefore.model.skip) {=0D + pointCurrent.mK =3D pointCurrent.deltaK;=0D + } else if (!pointAfter || pointAfter.model.skip) {=0D + pointCurrent.mK =3D pointBefore.deltaK;=0D + } else if (this.sign(pointBefore.deltaK) !=3D=3D this.sign(pointCurrent= .deltaK)) {=0D + pointCurrent.mK =3D 0;=0D + } else {=0D + pointCurrent.mK =3D (pointBefore.deltaK + pointCurrent.deltaK) / 2;=0D + }=0D + }=0D +=0D + // Adjust tangents to ensure monotonic properties=0D + var alphaK, betaK, tauK, squaredMagnitude;=0D + for (i =3D 0; i < pointsLen - 1; ++i) {=0D + pointCurrent =3D pointsWithTangents[i];=0D + pointAfter =3D pointsWithTangents[i + 1];=0D + if (pointCurrent.model.skip || pointAfter.model.skip) {=0D + continue;=0D + }=0D +=0D + if (helpers$1.almostEquals(pointCurrent.deltaK, 0, this.EPSILON)) {=0D + pointCurrent.mK =3D pointAfter.mK =3D 0;=0D + continue;=0D + }=0D +=0D + alphaK =3D pointCurrent.mK / pointCurrent.deltaK;=0D + betaK =3D pointAfter.mK / pointCurrent.deltaK;=0D + squaredMagnitude =3D Math.pow(alphaK, 2) + Math.pow(betaK, 2);=0D + if (squaredMagnitude <=3D 9) {=0D + continue;=0D + }=0D +=0D + tauK =3D 3 / Math.sqrt(squaredMagnitude);=0D + pointCurrent.mK =3D alphaK * tauK * pointCurrent.deltaK;=0D + pointAfter.mK =3D betaK * tauK * pointCurrent.deltaK;=0D + }=0D +=0D + // Compute control points=0D + var deltaX;=0D + for (i =3D 0; i < pointsLen; ++i) {=0D + pointCurrent =3D pointsWithTangents[i];=0D + if (pointCurrent.model.skip) {=0D + continue;=0D + }=0D +=0D + pointBefore =3D i > 0 ? pointsWithTangents[i - 1] : null;=0D + pointAfter =3D i < pointsLen - 1 ? pointsWithTangents[i + 1] : null;=0D + if (pointBefore && !pointBefore.model.skip) {=0D + deltaX =3D (pointCurrent.model.x - pointBefore.model.x) / 3;=0D + pointCurrent.model.controlPointPreviousX =3D pointCurrent.model.x - de= ltaX;=0D + pointCurrent.model.controlPointPreviousY =3D pointCurrent.model.y - de= ltaX * pointCurrent.mK;=0D + }=0D + if (pointAfter && !pointAfter.model.skip) {=0D + deltaX =3D (pointAfter.model.x - pointCurrent.model.x) / 3;=0D + pointCurrent.model.controlPointNextX =3D pointCurrent.model.x + deltaX= ;=0D + pointCurrent.model.controlPointNextY =3D pointCurrent.model.y + deltaX= * pointCurrent.mK;=0D + }=0D + }=0D + };=0D + helpers$1.nextItem =3D function(collection, index, loop) {=0D + if (loop) {=0D + return index >=3D collection.length - 1 ? collection[0] : collection[in= dex + 1];=0D + }=0D + return index >=3D collection.length - 1 ? collection[collection.length -= 1] : collection[index + 1];=0D + };=0D + helpers$1.previousItem =3D function(collection, index, loop) {=0D + if (loop) {=0D + return index <=3D 0 ? collection[collection.length - 1] : collection[in= dex - 1];=0D + }=0D + return index <=3D 0 ? collection[0] : collection[index - 1];=0D + };=0D + // Implementation of the nice number algorithm used in determining where = axis labels will go=0D + helpers$1.niceNum =3D function(range, round) {=0D + var exponent =3D Math.floor(helpers$1.log10(range));=0D + var fraction =3D range / Math.pow(10, exponent);=0D + var niceFraction;=0D +=0D + if (round) {=0D + if (fraction < 1.5) {=0D + niceFraction =3D 1;=0D + } else if (fraction < 3) {=0D + niceFraction =3D 2;=0D + } else if (fraction < 7) {=0D + niceFraction =3D 5;=0D + } else {=0D + niceFraction =3D 10;=0D + }=0D + } else if (fraction <=3D 1.0) {=0D + niceFraction =3D 1;=0D + } else if (fraction <=3D 2) {=0D + niceFraction =3D 2;=0D + } else if (fraction <=3D 5) {=0D + niceFraction =3D 5;=0D + } else {=0D + niceFraction =3D 10;=0D + }=0D +=0D + return niceFraction * Math.pow(10, exponent);=0D + };=0D + // Request animation polyfill - https://www.paulirish.com/2011/requestani= mationframe-for-smart-animating/=0D + helpers$1.requestAnimFrame =3D (function() {=0D + if (typeof window =3D=3D=3D 'undefined') {=0D + return function(callback) {=0D + callback();=0D + };=0D + }=0D + return window.requestAnimationFrame ||=0D + window.webkitRequestAnimationFrame ||=0D + window.mozRequestAnimationFrame ||=0D + window.oRequestAnimationFrame ||=0D + window.msRequestAnimationFrame ||=0D + function(callback) {=0D + return window.setTimeout(callback, 1000 / 60);=0D + };=0D + }());=0D + // -- DOM methods=0D + helpers$1.getRelativePosition =3D function(evt, chart) {=0D + var mouseX, mouseY;=0D + var e =3D evt.originalEvent || evt;=0D + var canvas =3D evt.target || evt.srcElement;=0D + var boundingRect =3D canvas.getBoundingClientRect();=0D +=0D + var touches =3D e.touches;=0D + if (touches && touches.length > 0) {=0D + mouseX =3D touches[0].clientX;=0D + mouseY =3D touches[0].clientY;=0D +=0D + } else {=0D + mouseX =3D e.clientX;=0D + mouseY =3D e.clientY;=0D + }=0D +=0D + // Scale mouse coordinates into canvas coordinates=0D + // by following the pattern laid out by 'jerryj' in the comments of=0D + // https://www.html5canvastutorials.com/advanced/html5-canvas-mouse-coor= dinates/=0D + var paddingLeft =3D parseFloat(helpers$1.getStyle(canvas, 'padding-left'= ));=0D + var paddingTop =3D parseFloat(helpers$1.getStyle(canvas, 'padding-top'))= ;=0D + var paddingRight =3D parseFloat(helpers$1.getStyle(canvas, 'padding-righ= t'));=0D + var paddingBottom =3D parseFloat(helpers$1.getStyle(canvas, 'padding-bot= tom'));=0D + var width =3D boundingRect.right - boundingRect.left - paddingLeft - pad= dingRight;=0D + var height =3D boundingRect.bottom - boundingRect.top - paddingTop - pad= dingBottom;=0D +=0D + // We divide by the current device pixel ratio, because the canvas is sc= aled up by that amount in each direction. However=0D + // the backend model is in unscaled coordinates. Since we are going to d= eal with our model coordinates, we go back here=0D + mouseX =3D Math.round((mouseX - boundingRect.left - paddingLeft) / (widt= h) * canvas.width / chart.currentDevicePixelRatio);=0D + mouseY =3D Math.round((mouseY - boundingRect.top - paddingTop) / (height= ) * canvas.height / chart.currentDevicePixelRatio);=0D +=0D + return {=0D + x: mouseX,=0D + y: mouseY=0D + };=0D +=0D + };=0D +=0D + // Private helper function to convert max-width/max-height values that ma= y be percentages into a number=0D + function parseMaxStyle(styleValue, node, parentProperty) {=0D + var valueInPixels;=0D + if (typeof styleValue =3D=3D=3D 'string') {=0D + valueInPixels =3D parseInt(styleValue, 10);=0D +=0D + if (styleValue.indexOf('%') !=3D=3D -1) {=0D + // percentage * size in dimension=0D + valueInPixels =3D valueInPixels / 100 * node.parentNode[parentProperty= ];=0D + }=0D + } else {=0D + valueInPixels =3D styleValue;=0D + }=0D +=0D + return valueInPixels;=0D + }=0D +=0D + /**=0D + * Returns if the given value contains an effective constraint.=0D + * @private=0D + */=0D + function isConstrainedValue(value) {=0D + return value !=3D=3D undefined && value !=3D=3D null && value !=3D=3D 'n= one';=0D + }=0D +=0D + /**=0D + * Returns the max width or height of the given DOM node in a cross-brows= er compatible fashion=0D + * @param {HTMLElement} domNode - the node to check the constraint on=0D + * @param {string} maxStyle - the style that defines the maximum for the = direction we are using ('max-width' / 'max-height')=0D + * @param {string} percentageProperty - property of parent to use when ca= lculating width as a percentage=0D + * @see {@link https://www.nathanaeljones.com/blog/2013/reading-max-width= -cross-browser}=0D + */=0D + function getConstraintDimension(domNode, maxStyle, percentageProperty) {= =0D + var view =3D document.defaultView;=0D + var parentNode =3D helpers$1._getParentNode(domNode);=0D + var constrainedNode =3D view.getComputedStyle(domNode)[maxStyle];=0D + var constrainedContainer =3D view.getComputedStyle(parentNode)[maxStyle]= ;=0D + var hasCNode =3D isConstrainedValue(constrainedNode);=0D + var hasCContainer =3D isConstrainedValue(constrainedContainer);=0D + var infinity =3D Number.POSITIVE_INFINITY;=0D +=0D + if (hasCNode || hasCContainer) {=0D + return Math.min(=0D + hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty)= : infinity,=0D + hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percen= tageProperty) : infinity);=0D + }=0D +=0D + return 'none';=0D + }=0D + // returns Number or undefined if no constraint=0D + helpers$1.getConstraintWidth =3D function(domNode) {=0D + return getConstraintDimension(domNode, 'max-width', 'clientWidth');=0D + };=0D + // returns Number or undefined if no constraint=0D + helpers$1.getConstraintHeight =3D function(domNode) {=0D + return getConstraintDimension(domNode, 'max-height', 'clientHeight');=0D + };=0D + /**=0D + * @private=0D + */=0D + helpers$1._calculatePadding =3D function(container, padding, parentDimens= ion) {=0D + padding =3D helpers$1.getStyle(container, padding);=0D +=0D + return padding.indexOf('%') > -1 ? parentDimension * parseInt(padding, 1= 0) / 100 : parseInt(padding, 10);=0D + };=0D + /**=0D + * @private=0D + */=0D + helpers$1._getParentNode =3D function(domNode) {=0D + var parent =3D domNode.parentNode;=0D + if (parent && parent.toString() =3D=3D=3D '[object ShadowRoot]') {=0D + parent =3D parent.host;=0D + }=0D + return parent;=0D + };=0D + helpers$1.getMaximumWidth =3D function(domNode) {=0D + var container =3D helpers$1._getParentNode(domNode);=0D + if (!container) {=0D + return domNode.clientWidth;=0D + }=0D +=0D + var clientWidth =3D container.clientWidth;=0D + var paddingLeft =3D helpers$1._calculatePadding(container, 'padding-left= ', clientWidth);=0D + var paddingRight =3D helpers$1._calculatePadding(container, 'padding-rig= ht', clientWidth);=0D +=0D + var w =3D clientWidth - paddingLeft - paddingRight;=0D + var cw =3D helpers$1.getConstraintWidth(domNode);=0D + return isNaN(cw) ? w : Math.min(w, cw);=0D + };=0D + helpers$1.getMaximumHeight =3D function(domNode) {=0D + var container =3D helpers$1._getParentNode(domNode);=0D + if (!container) {=0D + return domNode.clientHeight;=0D + }=0D +=0D + var clientHeight =3D container.clientHeight;=0D + var paddingTop =3D helpers$1._calculatePadding(container, 'padding-top',= clientHeight);=0D + var paddingBottom =3D helpers$1._calculatePadding(container, 'padding-bo= ttom', clientHeight);=0D +=0D + var h =3D clientHeight - paddingTop - paddingBottom;=0D + var ch =3D helpers$1.getConstraintHeight(domNode);=0D + return isNaN(ch) ? h : Math.min(h, ch);=0D + };=0D + helpers$1.getStyle =3D function(el, property) {=0D + return el.currentStyle ?=0D + el.currentStyle[property] :=0D + document.defaultView.getComputedStyle(el, null).getPropertyValue(proper= ty);=0D + };=0D + helpers$1.retinaScale =3D function(chart, forceRatio) {=0D + var pixelRatio =3D chart.currentDevicePixelRatio =3D forceRatio || (type= of window !=3D=3D 'undefined' && window.devicePixelRatio) || 1;=0D + if (pixelRatio =3D=3D=3D 1) {=0D + return;=0D + }=0D +=0D + var canvas =3D chart.canvas;=0D + var height =3D chart.height;=0D + var width =3D chart.width;=0D +=0D + canvas.height =3D height * pixelRatio;=0D + canvas.width =3D width * pixelRatio;=0D + chart.ctx.scale(pixelRatio, pixelRatio);=0D +=0D + // If no style has been set on the canvas, the render size is used as di= splay size,=0D + // making the chart visually bigger, so let's enforce it to the "correct= " values.=0D + // See https://github.com/chartjs/Chart.js/issues/3575=0D + if (!canvas.style.height && !canvas.style.width) {=0D + canvas.style.height =3D height + 'px';=0D + canvas.style.width =3D width + 'px';=0D + }=0D + };=0D + // -- Canvas methods=0D + helpers$1.fontString =3D function(pixelSize, fontStyle, fontFamily) {=0D + return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;=0D + };=0D + helpers$1.longestText =3D function(ctx, font, arrayOfThings, cache) {=0D + cache =3D cache || {};=0D + var data =3D cache.data =3D cache.data || {};=0D + var gc =3D cache.garbageCollect =3D cache.garbageCollect || [];=0D +=0D + if (cache.font !=3D=3D font) {=0D + data =3D cache.data =3D {};=0D + gc =3D cache.garbageCollect =3D [];=0D + cache.font =3D font;=0D + }=0D +=0D + ctx.font =3D font;=0D + var longest =3D 0;=0D + var ilen =3D arrayOfThings.length;=0D + var i, j, jlen, thing, nestedThing;=0D + for (i =3D 0; i < ilen; i++) {=0D + thing =3D arrayOfThings[i];=0D +=0D + // Undefined strings and arrays should not be measured=0D + if (thing !=3D=3D undefined && thing !=3D=3D null && helpers$1.isArray(= thing) !=3D=3D true) {=0D + longest =3D helpers$1.measureText(ctx, data, gc, longest, thing);=0D + } else if (helpers$1.isArray(thing)) {=0D + // if it is an array lets measure each element=0D + // to do maybe simplify this function a bit so we can do this more rec= ursively?=0D + for (j =3D 0, jlen =3D thing.length; j < jlen; j++) {=0D + nestedThing =3D thing[j];=0D + // Undefined strings and arrays should not be measured=0D + if (nestedThing !=3D=3D undefined && nestedThing !=3D=3D null && !hel= pers$1.isArray(nestedThing)) {=0D + longest =3D helpers$1.measureText(ctx, data, gc, longest, nestedThin= g);=0D + }=0D + }=0D + }=0D + }=0D +=0D + var gcLen =3D gc.length / 2;=0D + if (gcLen > arrayOfThings.length) {=0D + for (i =3D 0; i < gcLen; i++) {=0D + delete data[gc[i]];=0D + }=0D + gc.splice(0, gcLen);=0D + }=0D + return longest;=0D + };=0D + helpers$1.measureText =3D function(ctx, data, gc, longest, string) {=0D + var textWidth =3D data[string];=0D + if (!textWidth) {=0D + textWidth =3D data[string] =3D ctx.measureText(string).width;=0D + gc.push(string);=0D + }=0D + if (textWidth > longest) {=0D + longest =3D textWidth;=0D + }=0D + return longest;=0D + };=0D +=0D + /**=0D + * @deprecated=0D + */=0D + helpers$1.numberOfLabelLines =3D function(arrayOfThings) {=0D + var numberOfLines =3D 1;=0D + helpers$1.each(arrayOfThings, function(thing) {=0D + if (helpers$1.isArray(thing)) {=0D + if (thing.length > numberOfLines) {=0D + numberOfLines =3D thing.length;=0D + }=0D + }=0D + });=0D + return numberOfLines;=0D + };=0D +=0D + helpers$1.color =3D !chartjsColor ?=0D + function(value) {=0D + console.error('Color.js not found!');=0D + return value;=0D + } :=0D + function(value) {=0D + /* global CanvasGradient */=0D + if (value instanceof CanvasGradient) {=0D + value =3D core_defaults.global.defaultColor;=0D + }=0D +=0D + return chartjsColor(value);=0D + };=0D +=0D + helpers$1.getHoverColor =3D function(colorValue) {=0D + /* global CanvasPattern */=0D + return (colorValue instanceof CanvasPattern || colorValue instanceof Can= vasGradient) ?=0D + colorValue :=0D + helpers$1.color(colorValue).saturate(0.5).darken(0.1).rgbString();=0D + };=0D +}; =20 - // Shared Methods - isHorizontal: function() { - var pos =3D this.options.position; - return pos =3D=3D=3D 'top' || pos =3D=3D=3D 'bottom'; - }, +function abstract() {=0D + throw new Error(=0D + 'This method is not implemented: either no adapter can ' +=0D + 'be found or an incomplete integration was provided.'=0D + );=0D +}=0D +=0D +/**=0D + * Date adapter (current used by the time scale)=0D + * @namespace Chart._adapters._date=0D + * @memberof Chart._adapters=0D + * @private=0D + */=0D +=0D +/**=0D + * Currently supported unit string values.=0D + * @typedef {('millisecond'|'second'|'minute'|'hour'|'day'|'week'|'month'|= 'quarter'|'year')}=0D + * @memberof Chart._adapters._date=0D + * @name Unit=0D + */=0D +=0D +/**=0D + * @class=0D + */=0D +function DateAdapter(options) {=0D + this.options =3D options || {};=0D +}=0D +=0D +helpers$1.extend(DateAdapter.prototype, /** @lends DateAdapter */ {=0D + /**=0D + * Returns a map of time formats for the supported formatting units defin= ed=0D + * in Unit as well as 'datetime' representing a detailed date/time string= .=0D + * @returns {{string: string}}=0D + */=0D + formats: abstract,=0D +=0D + /**=0D + * Parses the given `value` and return the associated timestamp.=0D + * @param {any} value - the value to parse (usually comes from the data)= =0D + * @param {string} [format] - the expected data format=0D + * @returns {(number|null)}=0D + * @function=0D + */=0D + parse: abstract,=0D +=0D + /**=0D + * Returns the formatted date in the specified `format` for a given `time= stamp`.=0D + * @param {number} timestamp - the timestamp to format=0D + * @param {string} format - the date/time token=0D + * @return {string}=0D + * @function=0D + */=0D + format: abstract,=0D +=0D + /**=0D + * Adds the specified `amount` of `unit` to the given `timestamp`.=0D + * @param {number} timestamp - the input timestamp=0D + * @param {number} amount - the amount to add=0D + * @param {Unit} unit - the unit as string=0D + * @return {number}=0D + * @function=0D + */=0D + add: abstract,=0D +=0D + /**=0D + * Returns the number of `unit` between the given timestamps.=0D + * @param {number} max - the input timestamp (reference)=0D + * @param {number} min - the timestamp to substract=0D + * @param {Unit} unit - the unit as string=0D + * @return {number}=0D + * @function=0D + */=0D + diff: abstract,=0D +=0D + /**=0D + * Returns start of `unit` for the given `timestamp`.=0D + * @param {number} timestamp - the input timestamp=0D + * @param {Unit} unit - the unit as string=0D + * @param {number} [weekday] - the ISO day of the week with 1 being Monda= y=0D + * and 7 being Sunday (only needed if param *unit* is `isoWeek`).=0D + * @function=0D + */=0D + startOf: abstract,=0D +=0D + /**=0D + * Returns end of `unit` for the given `timestamp`.=0D + * @param {number} timestamp - the input timestamp=0D + * @param {Unit} unit - the unit as string=0D + * @function=0D + */=0D + endOf: abstract,=0D +=0D + // DEPRECATIONS=0D +=0D + /**=0D + * Provided for backward compatibility for scale.getValueForPixel(),=0D + * this method should be overridden only by the moment adapter.=0D + * @deprecated since version 2.8.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D + _create: function(value) {=0D + return value;=0D + }=0D +});=0D +=0D +DateAdapter.override =3D function(members) {=0D + helpers$1.extend(DateAdapter.prototype, members);=0D +};=0D +=0D +var _date =3D DateAdapter; =20 - // Actually draw the title block on the canvas - draw: function() { - var me =3D this; - var ctx =3D me.ctx; - var opts =3D me.options; +var core_adapters =3D { + _date: _date +}; =20 - if (!opts.display) { - return; - } +/**=0D + * Namespace to hold static tick generation functions=0D + * @namespace Chart.Ticks=0D + */=0D +var core_ticks =3D {=0D + /**=0D + * Namespace to hold formatters for different types of ticks=0D + * @namespace Chart.Ticks.formatters=0D + */=0D + formatters: {=0D + /**=0D + * Formatter for value labels=0D + * @method Chart.Ticks.formatters.values=0D + * @param value the value to display=0D + * @return {string|string[]} the label to display=0D + */=0D + values: function(value) {=0D + return helpers$1.isArray(value) ? value : '' + value;=0D + },=0D +=0D + /**=0D + * Formatter for linear numeric ticks=0D + * @method Chart.Ticks.formatters.linear=0D + * @param tickValue {number} the value to be formatted=0D + * @param index {number} the position of the tickValue parameter in the = ticks array=0D + * @param ticks {number[]} the list of ticks being converted=0D + * @return {string} string representation of the tickValue parameter=0D + */=0D + linear: function(tickValue, index, ticks) {=0D + // If we have lots of ticks, don't use the ones=0D + var delta =3D ticks.length > 3 ? ticks[2] - ticks[1] : ticks[1] - ticks= [0];=0D +=0D + // If we have a number like 2.5 as the delta, figure out how many decim= al places we need=0D + if (Math.abs(delta) > 1) {=0D + if (tickValue !=3D=3D Math.floor(tickValue)) {=0D + // not an integer=0D + delta =3D tickValue - Math.floor(tickValue);=0D + }=0D + }=0D +=0D + var logDelta =3D helpers$1.log10(Math.abs(delta));=0D + var tickString =3D '';=0D +=0D + if (tickValue !=3D=3D 0) {=0D + var maxTick =3D Math.max(Math.abs(ticks[0]), Math.abs(ticks[ticks.leng= th - 1]));=0D + if (maxTick < 1e-4) { // all ticks are small numbers; use scientific n= otation=0D + var logTick =3D helpers$1.log10(Math.abs(tickValue));=0D + var numExponential =3D Math.floor(logTick) - Math.floor(logDelta);=0D + numExponential =3D Math.max(Math.min(numExponential, 20), 0);=0D + tickString =3D tickValue.toExponential(numExponential);=0D + } else {=0D + var numDecimal =3D -1 * Math.floor(logDelta);=0D + numDecimal =3D Math.max(Math.min(numDecimal, 20), 0); // toFixed has = a max of 20 decimal places=0D + tickString =3D tickValue.toFixed(numDecimal);=0D + }=0D + } else {=0D + tickString =3D '0'; // never show decimal places for 0=0D + }=0D +=0D + return tickString;=0D + },=0D +=0D + logarithmic: function(tickValue, index, ticks) {=0D + var remain =3D tickValue / (Math.pow(10, Math.floor(helpers$1.log10(tic= kValue))));=0D +=0D + if (tickValue =3D=3D=3D 0) {=0D + return '0';=0D + } else if (remain =3D=3D=3D 1 || remain =3D=3D=3D 2 || remain =3D=3D=3D= 5 || index =3D=3D=3D 0 || index =3D=3D=3D ticks.length - 1) {=0D + return tickValue.toExponential();=0D + }=0D + return '';=0D + }=0D + }=0D +}; =20 - var fontOpts =3D helpers$1.options._parseFont(opts); - var lineHeight =3D fontOpts.lineHeight; - var offset =3D lineHeight / 2 + opts.padding; - var rotation =3D 0; - var top =3D me.top; - var left =3D me.left; - var bottom =3D me.bottom; - var right =3D me.right; - var maxWidth, titleX, titleY; - - ctx.fillStyle =3D helpers$1.valueOrDefault(opts.fontColor, core_defaults= .global.defaultFontColor); // render in correct colour - ctx.font =3D fontOpts.string; - - // Horizontal - if (me.isHorizontal()) { - titleX =3D left + ((right - left) / 2); // midpoint of the width - titleY =3D top + offset; - maxWidth =3D right - left; - } else { - titleX =3D opts.position =3D=3D=3D 'left' ? left + offset : right - off= set; - titleY =3D top + ((bottom - top) / 2); - maxWidth =3D bottom - top; - rotation =3D Math.PI * (opts.position =3D=3D=3D 'left' ? -0.5 : 0.5); - } +var isArray =3D helpers$1.isArray;=0D +var isNullOrUndef =3D helpers$1.isNullOrUndef;=0D +var valueOrDefault$a =3D helpers$1.valueOrDefault;=0D +var valueAtIndexOrDefault =3D helpers$1.valueAtIndexOrDefault;=0D +=0D +core_defaults._set('scale', {=0D + display: true,=0D + position: 'left',=0D + offset: false,=0D +=0D + // grid line settings=0D + gridLines: {=0D + display: true,=0D + color: 'rgba(0,0,0,0.1)',=0D + lineWidth: 1,=0D + drawBorder: true,=0D + drawOnChartArea: true,=0D + drawTicks: true,=0D + tickMarkLength: 10,=0D + zeroLineWidth: 1,=0D + zeroLineColor: 'rgba(0,0,0,0.25)',=0D + zeroLineBorderDash: [],=0D + zeroLineBorderDashOffset: 0.0,=0D + offsetGridLines: false,=0D + borderDash: [],=0D + borderDashOffset: 0.0=0D + },=0D +=0D + // scale label=0D + scaleLabel: {=0D + // display property=0D + display: false,=0D +=0D + // actual label=0D + labelString: '',=0D +=0D + // top/bottom padding=0D + padding: {=0D + top: 4,=0D + bottom: 4=0D + }=0D + },=0D +=0D + // label settings=0D + ticks: {=0D + beginAtZero: false,=0D + minRotation: 0,=0D + maxRotation: 50,=0D + mirror: false,=0D + padding: 0,=0D + reverse: false,=0D + display: true,=0D + autoSkip: true,=0D + autoSkipPadding: 0,=0D + labelOffset: 0,=0D + // We pass through arrays to be rendered as multiline labels, we convert= Others to strings here.=0D + callback: core_ticks.formatters.values,=0D + minor: {},=0D + major: {}=0D + }=0D +});=0D +=0D +/** Returns a new array containing numItems from arr */=0D +function sample(arr, numItems) {=0D + var result =3D [];=0D + var increment =3D arr.length / numItems;=0D + var i =3D 0;=0D + var len =3D arr.length;=0D +=0D + for (; i < len; i +=3D increment) {=0D + result.push(arr[Math.floor(i)]);=0D + }=0D + return result;=0D +}=0D +=0D +function getPixelForGridLine(scale, index, offsetGridLines) {=0D + var length =3D scale.getTicks().length;=0D + var validIndex =3D Math.min(index, length - 1);=0D + var lineValue =3D scale.getPixelForTick(validIndex);=0D + var start =3D scale._startPixel;=0D + var end =3D scale._endPixel;=0D + var epsilon =3D 1e-6; // 1e-6 is margin in pixels for accumulated error.= =0D + var offset;=0D +=0D + if (offsetGridLines) {=0D + if (length =3D=3D=3D 1) {=0D + offset =3D Math.max(lineValue - start, end - lineValue);=0D + } else if (index =3D=3D=3D 0) {=0D + offset =3D (scale.getPixelForTick(1) - lineValue) / 2;=0D + } else {=0D + offset =3D (lineValue - scale.getPixelForTick(validIndex - 1)) / 2;=0D + }=0D + lineValue +=3D validIndex < index ? offset : -offset;=0D +=0D + // Return undefined if the pixel is out of the range=0D + if (lineValue < start - epsilon || lineValue > end + epsilon) {=0D + return;=0D + }=0D + }=0D + return lineValue;=0D +}=0D +=0D +function garbageCollect(caches, length) {=0D + helpers$1.each(caches, function(cache) {=0D + var gc =3D cache.gc;=0D + var gcLen =3D gc.length / 2;=0D + var i;=0D + if (gcLen > length) {=0D + for (i =3D 0; i < gcLen; ++i) {=0D + delete cache.data[gc[i]];=0D + }=0D + gc.splice(0, gcLen);=0D + }=0D + });=0D +}=0D +=0D +/**=0D + * Returns {width, height, offset} objects for the first, last, widest, hi= ghest tick=0D + * labels where offset indicates the anchor point offset from the top in p= ixels.=0D + */=0D +function computeLabelSizes(ctx, tickFonts, ticks, caches) {=0D + var length =3D ticks.length;=0D + var widths =3D [];=0D + var heights =3D [];=0D + var offsets =3D [];=0D + var widestLabelSize =3D 0;=0D + var highestLabelSize =3D 0;=0D + var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, he= ight, nestedLabel, widest, highest;=0D +=0D + for (i =3D 0; i < length; ++i) {=0D + label =3D ticks[i].label;=0D + tickFont =3D ticks[i].major ? tickFonts.major : tickFonts.minor;=0D + ctx.font =3D fontString =3D tickFont.string;=0D + cache =3D caches[fontString] =3D caches[fontString] || {data: {}, gc: []= };=0D + lineHeight =3D tickFont.lineHeight;=0D + width =3D height =3D 0;=0D + // Undefined labels and arrays should not be measured=0D + if (!isNullOrUndef(label) && !isArray(label)) {=0D + width =3D helpers$1.measureText(ctx, cache.data, cache.gc, width, label= );=0D + height =3D lineHeight;=0D + } else if (isArray(label)) {=0D + // if it is an array let's measure each element=0D + for (j =3D 0, jlen =3D label.length; j < jlen; ++j) {=0D + nestedLabel =3D label[j];=0D + // Undefined labels and arrays should not be measured=0D + if (!isNullOrUndef(nestedLabel) && !isArray(nestedLabel)) {=0D + width =3D helpers$1.measureText(ctx, cache.data, cache.gc, width, nes= tedLabel);=0D + height +=3D lineHeight;=0D + }=0D + }=0D + }=0D + widths.push(width);=0D + heights.push(height);=0D + offsets.push(lineHeight / 2);=0D + widestLabelSize =3D Math.max(width, widestLabelSize);=0D + highestLabelSize =3D Math.max(height, highestLabelSize);=0D + }=0D + garbageCollect(caches, length);=0D +=0D + widest =3D widths.indexOf(widestLabelSize);=0D + highest =3D heights.indexOf(highestLabelSize);=0D +=0D + function valueAt(idx) {=0D + return {=0D + width: widths[idx] || 0,=0D + height: heights[idx] || 0,=0D + offset: offsets[idx] || 0=0D + };=0D + }=0D +=0D + return {=0D + first: valueAt(0),=0D + last: valueAt(length - 1),=0D + widest: valueAt(widest),=0D + highest: valueAt(highest)=0D + };=0D +}=0D +=0D +function getTickMarkLength(options) {=0D + return options.drawTicks ? options.tickMarkLength : 0;=0D +}=0D +=0D +function getScaleLabelHeight(options) {=0D + var font, padding;=0D +=0D + if (!options.display) {=0D + return 0;=0D + }=0D +=0D + font =3D helpers$1.options._parseFont(options);=0D + padding =3D helpers$1.options.toPadding(options.padding);=0D +=0D + return font.lineHeight + padding.height;=0D +}=0D +=0D +function parseFontOptions(options, nestedOpts) {=0D + return helpers$1.extend(helpers$1.options._parseFont({=0D + fontFamily: valueOrDefault$a(nestedOpts.fontFamily, options.fontFamily),= =0D + fontSize: valueOrDefault$a(nestedOpts.fontSize, options.fontSize),=0D + fontStyle: valueOrDefault$a(nestedOpts.fontStyle, options.fontStyle),=0D + lineHeight: valueOrDefault$a(nestedOpts.lineHeight, options.lineHeight)= =0D + }), {=0D + color: helpers$1.options.resolve([nestedOpts.fontColor, options.fontColo= r, core_defaults.global.defaultFontColor])=0D + });=0D +}=0D +=0D +function parseTickFontOptions(options) {=0D + var minor =3D parseFontOptions(options, options.minor);=0D + var major =3D options.major.enabled ? parseFontOptions(options, options.m= ajor) : minor;=0D +=0D + return {minor: minor, major: major};=0D +}=0D +=0D +function nonSkipped(ticksToFilter) {=0D + var filtered =3D [];=0D + var item, index, len;=0D + for (index =3D 0, len =3D ticksToFilter.length; index < len; ++index) {=0D + item =3D ticksToFilter[index];=0D + if (typeof item._index !=3D=3D 'undefined') {=0D + filtered.push(item);=0D + }=0D + }=0D + return filtered;=0D +}=0D +=0D +function getEvenSpacing(arr) {=0D + var len =3D arr.length;=0D + var i, diff;=0D +=0D + if (len < 2) {=0D + return false;=0D + }=0D +=0D + for (diff =3D arr[0], i =3D 1; i < len; ++i) {=0D + if (arr[i] - arr[i - 1] !=3D=3D diff) {=0D + return false;=0D + }=0D + }=0D + return diff;=0D +}=0D +=0D +function calculateSpacing(majorIndices, ticks, axisLength, ticksLimit) {=0D + var evenMajorSpacing =3D getEvenSpacing(majorIndices);=0D + var spacing =3D (ticks.length - 1) / ticksLimit;=0D + var factors, factor, i, ilen;=0D +=0D + // If the major ticks are evenly spaced apart, place the minor ticks=0D + // so that they divide the major ticks into even chunks=0D + if (!evenMajorSpacing) {=0D + return Math.max(spacing, 1);=0D + }=0D +=0D + factors =3D helpers$1.math._factorize(evenMajorSpacing);=0D + for (i =3D 0, ilen =3D factors.length - 1; i < ilen; i++) {=0D + factor =3D factors[i];=0D + if (factor > spacing) {=0D + return factor;=0D + }=0D + }=0D + return Math.max(spacing, 1);=0D +}=0D +=0D +function getMajorIndices(ticks) {=0D + var result =3D [];=0D + var i, ilen;=0D + for (i =3D 0, ilen =3D ticks.length; i < ilen; i++) {=0D + if (ticks[i].major) {=0D + result.push(i);=0D + }=0D + }=0D + return result;=0D +}=0D +=0D +function skipMajors(ticks, majorIndices, spacing) {=0D + var count =3D 0;=0D + var next =3D majorIndices[0];=0D + var i, tick;=0D +=0D + spacing =3D Math.ceil(spacing);=0D + for (i =3D 0; i < ticks.length; i++) {=0D + tick =3D ticks[i];=0D + if (i =3D=3D=3D next) {=0D + tick._index =3D i;=0D + count++;=0D + next =3D majorIndices[count * spacing];=0D + } else {=0D + delete tick.label;=0D + }=0D + }=0D +}=0D +=0D +function skip(ticks, spacing, majorStart, majorEnd) {=0D + var start =3D valueOrDefault$a(majorStart, 0);=0D + var end =3D Math.min(valueOrDefault$a(majorEnd, ticks.length), ticks.leng= th);=0D + var count =3D 0;=0D + var length, i, tick, next;=0D +=0D + spacing =3D Math.ceil(spacing);=0D + if (majorEnd) {=0D + length =3D majorEnd - majorStart;=0D + spacing =3D length / Math.floor(length / spacing);=0D + }=0D +=0D + next =3D start;=0D +=0D + while (next < 0) {=0D + count++;=0D + next =3D Math.round(start + count * spacing);=0D + }=0D +=0D + for (i =3D Math.max(start, 0); i < end; i++) {=0D + tick =3D ticks[i];=0D + if (i =3D=3D=3D next) {=0D + tick._index =3D i;=0D + count++;=0D + next =3D Math.round(start + count * spacing);=0D + } else {=0D + delete tick.label;=0D + }=0D + }=0D +}=0D +=0D +var Scale =3D core_element.extend({=0D +=0D + zeroLineIndex: 0,=0D +=0D + /**=0D + * Get the padding needed for the scale=0D + * @method getPadding=0D + * @private=0D + * @returns {Padding} the necessary padding=0D + */=0D + getPadding: function() {=0D + var me =3D this;=0D + return {=0D + left: me.paddingLeft || 0,=0D + top: me.paddingTop || 0,=0D + right: me.paddingRight || 0,=0D + bottom: me.paddingBottom || 0=0D + };=0D + },=0D +=0D + /**=0D + * Returns the scale tick objects ({label, major})=0D + * @since 2.7=0D + */=0D + getTicks: function() {=0D + return this._ticks;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getLabels: function() {=0D + var data =3D this.chart.data;=0D + return this.options.labels || (this.isHorizontal() ? data.xLabels : data= .yLabels) || data.labels || [];=0D + },=0D +=0D + // These methods are ordered by lifecyle. Utilities then follow.=0D + // Any function defined here is inherited by all scale types.=0D + // Any function can be extended by the scale type=0D +=0D + /**=0D + * Provided for backward compatibility, not available anymore=0D + * @function Chart.Scale.mergeTicksOptions=0D + * @deprecated since version 2.8.0=0D + * @todo remove at version 3=0D + */=0D + mergeTicksOptions: function() {=0D + // noop=0D + },=0D +=0D + beforeUpdate: function() {=0D + helpers$1.callback(this.options.beforeUpdate, [this]);=0D + },=0D +=0D + /**=0D + * @param {number} maxWidth - the max width in pixels=0D + * @param {number} maxHeight - the max height in pixels=0D + * @param {object} margins - the space between the edge of the other scal= es and edge of the chart=0D + * This space comes from two sources:=0D + * - padding - space that's required to show the labels at the edges = of the scale=0D + * - thickness of scales or legends in another orientation=0D + */=0D + update: function(maxWidth, maxHeight, margins) {=0D + var me =3D this;=0D + var tickOpts =3D me.options.ticks;=0D + var sampleSize =3D tickOpts.sampleSize;=0D + var i, ilen, labels, ticks, samplingEnabled;=0D +=0D + // Update Lifecycle - Probably don't want to ever extend or overwrite th= is function ;)=0D + me.beforeUpdate();=0D +=0D + // Absorb the master measurements=0D + me.maxWidth =3D maxWidth;=0D + me.maxHeight =3D maxHeight;=0D + me.margins =3D helpers$1.extend({=0D + left: 0,=0D + right: 0,=0D + top: 0,=0D + bottom: 0=0D + }, margins);=0D +=0D + me._ticks =3D null;=0D + me.ticks =3D null;=0D + me._labelSizes =3D null;=0D + me._maxLabelLines =3D 0;=0D + me.longestLabelWidth =3D 0;=0D + me.longestTextCache =3D me.longestTextCache || {};=0D + me._gridLineItems =3D null;=0D + me._labelItems =3D null;=0D +=0D + // Dimensions=0D + me.beforeSetDimensions();=0D + me.setDimensions();=0D + me.afterSetDimensions();=0D +=0D + // Data min/max=0D + me.beforeDataLimits();=0D + me.determineDataLimits();=0D + me.afterDataLimits();=0D +=0D + // Ticks - `this.ticks` is now DEPRECATED!=0D + // Internal ticks are now stored as objects in the PRIVATE `this._ticks`= member=0D + // and must not be accessed directly from outside this class. `this.tick= s` being=0D + // around for long time and not marked as private, we can't change its s= tructure=0D + // without unexpected breaking changes. If you need to access the scale = ticks,=0D + // use scale.getTicks() instead.=0D +=0D + me.beforeBuildTicks();=0D +=0D + // New implementations should return an array of objects but for BACKWAR= D COMPAT,=0D + // we still support no return (`this.ticks` internally set by calling th= is method).=0D + ticks =3D me.buildTicks() || [];=0D +=0D + // Allow modification of ticks in callback.=0D + ticks =3D me.afterBuildTicks(ticks) || ticks;=0D +=0D + // Ensure ticks contains ticks in new tick format=0D + if ((!ticks || !ticks.length) && me.ticks) {=0D + ticks =3D [];=0D + for (i =3D 0, ilen =3D me.ticks.length; i < ilen; ++i) {=0D + ticks.push({=0D + value: me.ticks[i],=0D + major: false=0D + });=0D + }=0D + }=0D +=0D + me._ticks =3D ticks;=0D +=0D + // Compute tick rotation and fit using a sampled subset of labels=0D + // We generally don't need to compute the size of every single label for= determining scale size=0D + samplingEnabled =3D sampleSize < ticks.length;=0D + labels =3D me._convertTicksToLabels(samplingEnabled ? sample(ticks, samp= leSize) : ticks);=0D +=0D + // _configure is called twice, once here, once from core.controller.upda= teLayout.=0D + // Here we haven't been positioned yet, but dimensions are correct.=0D + // Variables set in _configure are needed for calculateTickRotation, and= =0D + // it's ok that coordinates are not correct there, only dimensions matte= r.=0D + me._configure();=0D +=0D + // Tick Rotation=0D + me.beforeCalculateTickRotation();=0D + me.calculateTickRotation();=0D + me.afterCalculateTickRotation();=0D +=0D + me.beforeFit();=0D + me.fit();=0D + me.afterFit();=0D +=0D + // Auto-skip=0D + me._ticksToDraw =3D tickOpts.display && (tickOpts.autoSkip || tickOpts.s= ource =3D=3D=3D 'auto') ? me._autoSkip(ticks) : ticks;=0D +=0D + if (samplingEnabled) {=0D + // Generate labels using all non-skipped ticks=0D + labels =3D me._convertTicksToLabels(me._ticksToDraw);=0D + }=0D +=0D + me.ticks =3D labels; // BACKWARD COMPATIBILITY=0D +=0D + // IMPORTANT: after this point, we consider that `this.ticks` will NEVER= change!=0D +=0D + me.afterUpdate();=0D +=0D + // TODO(v3): remove minSize as a public property and return value from a= ll layout boxes. It is unused=0D + // make maxWidth and maxHeight private=0D + return me.minSize;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _configure: function() {=0D + var me =3D this;=0D + var reversePixels =3D me.options.ticks.reverse;=0D + var startPixel, endPixel;=0D +=0D + if (me.isHorizontal()) {=0D + startPixel =3D me.left;=0D + endPixel =3D me.right;=0D + } else {=0D + startPixel =3D me.top;=0D + endPixel =3D me.bottom;=0D + // by default vertical scales are from bottom to top, so pixels are rev= ersed=0D + reversePixels =3D !reversePixels;=0D + }=0D + me._startPixel =3D startPixel;=0D + me._endPixel =3D endPixel;=0D + me._reversePixels =3D reversePixels;=0D + me._length =3D endPixel - startPixel;=0D + },=0D +=0D + afterUpdate: function() {=0D + helpers$1.callback(this.options.afterUpdate, [this]);=0D + },=0D +=0D + //=0D +=0D + beforeSetDimensions: function() {=0D + helpers$1.callback(this.options.beforeSetDimensions, [this]);=0D + },=0D + setDimensions: function() {=0D + var me =3D this;=0D + // Set the unconstrained dimension before label rotation=0D + if (me.isHorizontal()) {=0D + // Reset position before calculating rotation=0D + me.width =3D me.maxWidth;=0D + me.left =3D 0;=0D + me.right =3D me.width;=0D + } else {=0D + me.height =3D me.maxHeight;=0D +=0D + // Reset position before calculating rotation=0D + me.top =3D 0;=0D + me.bottom =3D me.height;=0D + }=0D +=0D + // Reset padding=0D + me.paddingLeft =3D 0;=0D + me.paddingTop =3D 0;=0D + me.paddingRight =3D 0;=0D + me.paddingBottom =3D 0;=0D + },=0D + afterSetDimensions: function() {=0D + helpers$1.callback(this.options.afterSetDimensions, [this]);=0D + },=0D +=0D + // Data limits=0D + beforeDataLimits: function() {=0D + helpers$1.callback(this.options.beforeDataLimits, [this]);=0D + },=0D + determineDataLimits: helpers$1.noop,=0D + afterDataLimits: function() {=0D + helpers$1.callback(this.options.afterDataLimits, [this]);=0D + },=0D +=0D + //=0D + beforeBuildTicks: function() {=0D + helpers$1.callback(this.options.beforeBuildTicks, [this]);=0D + },=0D + buildTicks: helpers$1.noop,=0D + afterBuildTicks: function(ticks) {=0D + var me =3D this;=0D + // ticks is empty for old axis implementations here=0D + if (isArray(ticks) && ticks.length) {=0D + return helpers$1.callback(me.options.afterBuildTicks, [me, ticks]);=0D + }=0D + // Support old implementations (that modified `this.ticks` directly in b= uildTicks)=0D + me.ticks =3D helpers$1.callback(me.options.afterBuildTicks, [me, me.tick= s]) || me.ticks;=0D + return ticks;=0D + },=0D +=0D + beforeTickToLabelConversion: function() {=0D + helpers$1.callback(this.options.beforeTickToLabelConversion, [this]);=0D + },=0D + convertTicksToLabels: function() {=0D + var me =3D this;=0D + // Convert ticks to strings=0D + var tickOpts =3D me.options.ticks;=0D + me.ticks =3D me.ticks.map(tickOpts.userCallback || tickOpts.callback, th= is);=0D + },=0D + afterTickToLabelConversion: function() {=0D + helpers$1.callback(this.options.afterTickToLabelConversion, [this]);=0D + },=0D +=0D + //=0D +=0D + beforeCalculateTickRotation: function() {=0D + helpers$1.callback(this.options.beforeCalculateTickRotation, [this]);=0D + },=0D + calculateTickRotation: function() {=0D + var me =3D this;=0D + var options =3D me.options;=0D + var tickOpts =3D options.ticks;=0D + var numTicks =3D me.getTicks().length;=0D + var minRotation =3D tickOpts.minRotation || 0;=0D + var maxRotation =3D tickOpts.maxRotation;=0D + var labelRotation =3D minRotation;=0D + var labelSizes, maxLabelWidth, maxLabelHeight, maxWidth, tickWidth, maxH= eight, maxLabelDiagonal;=0D +=0D + if (!me._isVisible() || !tickOpts.display || minRotation >=3D maxRotatio= n || numTicks <=3D 1 || !me.isHorizontal()) {=0D + me.labelRotation =3D minRotation;=0D + return;=0D + }=0D +=0D + labelSizes =3D me._getLabelSizes();=0D + maxLabelWidth =3D labelSizes.widest.width;=0D + maxLabelHeight =3D labelSizes.highest.height - labelSizes.highest.offset= ;=0D +=0D + // Estimate the width of each grid based on the canvas width, the maximu= m=0D + // label width and the number of tick intervals=0D + maxWidth =3D Math.min(me.maxWidth, me.chart.width - maxLabelWidth);=0D + tickWidth =3D options.offset ? me.maxWidth / numTicks : maxWidth / (numT= icks - 1);=0D +=0D + // Allow 3 pixels x2 padding either side for label readability=0D + if (maxLabelWidth + 6 > tickWidth) {=0D + tickWidth =3D maxWidth / (numTicks - (options.offset ? 0.5 : 1));=0D + maxHeight =3D me.maxHeight - getTickMarkLength(options.gridLines)=0D + - tickOpts.padding - getScaleLabelHeight(options.scaleLabel);=0D + maxLabelDiagonal =3D Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabel= Height * maxLabelHeight);=0D + labelRotation =3D helpers$1.toDegrees(Math.min(=0D + Math.asin(Math.min((labelSizes.highest.height + 6) / tickWidth, 1)),=0D + Math.asin(Math.min(maxHeight / maxLabelDiagonal, 1)) - Math.asin(maxLa= belHeight / maxLabelDiagonal)=0D + ));=0D + labelRotation =3D Math.max(minRotation, Math.min(maxRotation, labelRota= tion));=0D + }=0D +=0D + me.labelRotation =3D labelRotation;=0D + },=0D + afterCalculateTickRotation: function() {=0D + helpers$1.callback(this.options.afterCalculateTickRotation, [this]);=0D + },=0D +=0D + //=0D +=0D + beforeFit: function() {=0D + helpers$1.callback(this.options.beforeFit, [this]);=0D + },=0D + fit: function() {=0D + var me =3D this;=0D + // Reset=0D + var minSize =3D me.minSize =3D {=0D + width: 0,=0D + height: 0=0D + };=0D +=0D + var chart =3D me.chart;=0D + var opts =3D me.options;=0D + var tickOpts =3D opts.ticks;=0D + var scaleLabelOpts =3D opts.scaleLabel;=0D + var gridLineOpts =3D opts.gridLines;=0D + var display =3D me._isVisible();=0D + var isBottom =3D opts.position =3D=3D=3D 'bottom';=0D + var isHorizontal =3D me.isHorizontal();=0D +=0D + // Width=0D + if (isHorizontal) {=0D + minSize.width =3D me.maxWidth;=0D + } else if (display) {=0D + minSize.width =3D getTickMarkLength(gridLineOpts) + getScaleLabelHeight= (scaleLabelOpts);=0D + }=0D +=0D + // height=0D + if (!isHorizontal) {=0D + minSize.height =3D me.maxHeight; // fill all the height=0D + } else if (display) {=0D + minSize.height =3D getTickMarkLength(gridLineOpts) + getScaleLabelHeigh= t(scaleLabelOpts);=0D + }=0D +=0D + // Don't bother fitting the ticks if we are not showing the labels=0D + if (tickOpts.display && display) {=0D + var tickFonts =3D parseTickFontOptions(tickOpts);=0D + var labelSizes =3D me._getLabelSizes();=0D + var firstLabelSize =3D labelSizes.first;=0D + var lastLabelSize =3D labelSizes.last;=0D + var widestLabelSize =3D labelSizes.widest;=0D + var highestLabelSize =3D labelSizes.highest;=0D + var lineSpace =3D tickFonts.minor.lineHeight * 0.4;=0D + var tickPadding =3D tickOpts.padding;=0D +=0D + if (isHorizontal) {=0D + // A horizontal axis is more constrained by the height.=0D + var isRotated =3D me.labelRotation !=3D=3D 0;=0D + var angleRadians =3D helpers$1.toRadians(me.labelRotation);=0D + var cosRotation =3D Math.cos(angleRadians);=0D + var sinRotation =3D Math.sin(angleRadians);=0D +=0D + var labelHeight =3D sinRotation * widestLabelSize.width=0D + + cosRotation * (highestLabelSize.height - (isRotated ? highestLabelS= ize.offset : 0))=0D + + (isRotated ? 0 : lineSpace); // padding=0D +=0D + minSize.height =3D Math.min(me.maxHeight, minSize.height + labelHeight= + tickPadding);=0D +=0D + var offsetLeft =3D me.getPixelForTick(0) - me.left;=0D + var offsetRight =3D me.right - me.getPixelForTick(me.getTicks().length= - 1);=0D + var paddingLeft, paddingRight;=0D +=0D + // Ensure that our ticks are always inside the canvas. When rotated, t= icks are right aligned=0D + // which means that the right padding is dominated by the font height= =0D + if (isRotated) {=0D + paddingLeft =3D isBottom ?=0D + cosRotation * firstLabelSize.width + sinRotation * firstLabelSize.of= fset :=0D + sinRotation * (firstLabelSize.height - firstLabelSize.offset);=0D + paddingRight =3D isBottom ?=0D + sinRotation * (lastLabelSize.height - lastLabelSize.offset) :=0D + cosRotation * lastLabelSize.width + sinRotation * lastLabelSize.offs= et;=0D + } else {=0D + paddingLeft =3D firstLabelSize.width / 2;=0D + paddingRight =3D lastLabelSize.width / 2;=0D + }=0D +=0D + // Adjust padding taking into account changes in offsets=0D + // and add 3 px to move away from canvas edges=0D + me.paddingLeft =3D Math.max((paddingLeft - offsetLeft) * me.width / (m= e.width - offsetLeft), 0) + 3;=0D + me.paddingRight =3D Math.max((paddingRight - offsetRight) * me.width /= (me.width - offsetRight), 0) + 3;=0D + } else {=0D + // A vertical axis is more constrained by the width. Labels are the=0D + // dominant factor here, so get that length first and account for padd= ing=0D + var labelWidth =3D tickOpts.mirror ? 0 :=0D + // use lineSpace for consistency with horizontal axis=0D + // tickPadding is not implemented for horizontal=0D + widestLabelSize.width + tickPadding + lineSpace;=0D +=0D + minSize.width =3D Math.min(me.maxWidth, minSize.width + labelWidth);=0D +=0D + me.paddingTop =3D firstLabelSize.height / 2;=0D + me.paddingBottom =3D lastLabelSize.height / 2;=0D + }=0D + }=0D +=0D + me.handleMargins();=0D +=0D + if (isHorizontal) {=0D + me.width =3D me._length =3D chart.width - me.margins.left - me.margins.= right;=0D + me.height =3D minSize.height;=0D + } else {=0D + me.width =3D minSize.width;=0D + me.height =3D me._length =3D chart.height - me.margins.top - me.margins= .bottom;=0D + }=0D + },=0D +=0D + /**=0D + * Handle margins and padding interactions=0D + * @private=0D + */=0D + handleMargins: function() {=0D + var me =3D this;=0D + if (me.margins) {=0D + me.margins.left =3D Math.max(me.paddingLeft, me.margins.left);=0D + me.margins.top =3D Math.max(me.paddingTop, me.margins.top);=0D + me.margins.right =3D Math.max(me.paddingRight, me.margins.right);=0D + me.margins.bottom =3D Math.max(me.paddingBottom, me.margins.bottom);=0D + }=0D + },=0D +=0D + afterFit: function() {=0D + helpers$1.callback(this.options.afterFit, [this]);=0D + },=0D +=0D + // Shared Methods=0D + isHorizontal: function() {=0D + var pos =3D this.options.position;=0D + return pos =3D=3D=3D 'top' || pos =3D=3D=3D 'bottom';=0D + },=0D + isFullWidth: function() {=0D + return this.options.fullWidth;=0D + },=0D +=0D + // Get the correct value. NaN bad inputs, If the value type is object get= the x or y based on whether we are horizontal or not=0D + getRightValue: function(rawValue) {=0D + // Null and undefined values first=0D + if (isNullOrUndef(rawValue)) {=0D + return NaN;=0D + }=0D + // isNaN(object) returns true, so make sure NaN is checking for a number= ; Discard Infinite values=0D + if ((typeof rawValue =3D=3D=3D 'number' || rawValue instanceof Number) &= & !isFinite(rawValue)) {=0D + return NaN;=0D + }=0D +=0D + // If it is in fact an object, dive in one more level=0D + if (rawValue) {=0D + if (this.isHorizontal()) {=0D + if (rawValue.x !=3D=3D undefined) {=0D + return this.getRightValue(rawValue.x);=0D + }=0D + } else if (rawValue.y !=3D=3D undefined) {=0D + return this.getRightValue(rawValue.y);=0D + }=0D + }=0D +=0D + // Value is good, return it=0D + return rawValue;=0D + },=0D +=0D + _convertTicksToLabels: function(ticks) {=0D + var me =3D this;=0D + var labels, i, ilen;=0D +=0D + me.ticks =3D ticks.map(function(tick) {=0D + return tick.value;=0D + });=0D +=0D + me.beforeTickToLabelConversion();=0D +=0D + // New implementations should return the formatted tick labels but for B= ACKWARD=0D + // COMPAT, we still support no return (`this.ticks` internally changed b= y calling=0D + // this method and supposed to contain only string values).=0D + labels =3D me.convertTicksToLabels(ticks) || me.ticks;=0D +=0D + me.afterTickToLabelConversion();=0D +=0D + // BACKWARD COMPAT: synchronize `_ticks` with labels (so potentially `th= is.ticks`)=0D + for (i =3D 0, ilen =3D ticks.length; i < ilen; ++i) {=0D + ticks[i].label =3D labels[i];=0D + }=0D +=0D + return labels;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getLabelSizes: function() {=0D + var me =3D this;=0D + var labelSizes =3D me._labelSizes;=0D +=0D + if (!labelSizes) {=0D + me._labelSizes =3D labelSizes =3D computeLabelSizes(me.ctx, parseTickFo= ntOptions(me.options.ticks), me.getTicks(), me.longestTextCache);=0D + me.longestLabelWidth =3D labelSizes.widest.width;=0D + }=0D +=0D + return labelSizes;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _parseValue: function(value) {=0D + var start, end, min, max;=0D +=0D + if (isArray(value)) {=0D + start =3D +this.getRightValue(value[0]);=0D + end =3D +this.getRightValue(value[1]);=0D + min =3D Math.min(start, end);=0D + max =3D Math.max(start, end);=0D + } else {=0D + value =3D +this.getRightValue(value);=0D + start =3D undefined;=0D + end =3D value;=0D + min =3D value;=0D + max =3D value;=0D + }=0D +=0D + return {=0D + min: min,=0D + max: max,=0D + start: start,=0D + end: end=0D + };=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getScaleLabel: function(rawValue) {=0D + var v =3D this._parseValue(rawValue);=0D + if (v.start !=3D=3D undefined) {=0D + return '[' + v.start + ', ' + v.end + ']';=0D + }=0D +=0D + return +this.getRightValue(rawValue);=0D + },=0D +=0D + /**=0D + * Used to get the value to display in the tooltip for the data at the gi= ven index=0D + * @param index=0D + * @param datasetIndex=0D + */=0D + getLabelForIndex: helpers$1.noop,=0D +=0D + /**=0D + * Returns the location of the given data point. Value can either be an i= ndex or a numerical value=0D + * The coordinate (0, 0) is at the upper-left corner of the canvas=0D + * @param value=0D + * @param index=0D + * @param datasetIndex=0D + */=0D + getPixelForValue: helpers$1.noop,=0D +=0D + /**=0D + * Used to get the data value from a given pixel. This is the inverse of = getPixelForValue=0D + * The coordinate (0, 0) is at the upper-left corner of the canvas=0D + * @param pixel=0D + */=0D + getValueForPixel: helpers$1.noop,=0D +=0D + /**=0D + * Returns the location of the tick at the given index=0D + * The coordinate (0, 0) is at the upper-left corner of the canvas=0D + */=0D + getPixelForTick: function(index) {=0D + var me =3D this;=0D + var offset =3D me.options.offset;=0D + var numTicks =3D me._ticks.length;=0D + var tickWidth =3D 1 / Math.max(numTicks - (offset ? 0 : 1), 1);=0D +=0D + return index < 0 || index > numTicks - 1=0D + ? null=0D + : me.getPixelForDecimal(index * tickWidth + (offset ? tickWidth / 2 : 0= ));=0D + },=0D +=0D + /**=0D + * Utility for getting the pixel location of a percentage of scale=0D + * The coordinate (0, 0) is at the upper-left corner of the canvas=0D + */=0D + getPixelForDecimal: function(decimal) {=0D + var me =3D this;=0D +=0D + if (me._reversePixels) {=0D + decimal =3D 1 - decimal;=0D + }=0D +=0D + return me._startPixel + decimal * me._length;=0D + },=0D +=0D + getDecimalForPixel: function(pixel) {=0D + var decimal =3D (pixel - this._startPixel) / this._length;=0D + return this._reversePixels ? 1 - decimal : decimal;=0D + },=0D +=0D + /**=0D + * Returns the pixel for the minimum chart value=0D + * The coordinate (0, 0) is at the upper-left corner of the canvas=0D + */=0D + getBasePixel: function() {=0D + return this.getPixelForValue(this.getBaseValue());=0D + },=0D +=0D + getBaseValue: function() {=0D + var me =3D this;=0D + var min =3D me.min;=0D + var max =3D me.max;=0D +=0D + return me.beginAtZero ? 0 :=0D + min < 0 && max < 0 ? max :=0D + min > 0 && max > 0 ? min :=0D + 0;=0D + },=0D +=0D + /**=0D + * Returns a subset of ticks to be plotted to avoid overlapping labels.=0D + * @private=0D + */=0D + _autoSkip: function(ticks) {=0D + var me =3D this;=0D + var tickOpts =3D me.options.ticks;=0D + var axisLength =3D me._length;=0D + var ticksLimit =3D tickOpts.maxTicksLimit || axisLength / me._tickSize()= + 1;=0D + var majorIndices =3D tickOpts.major.enabled ? getMajorIndices(ticks) : [= ];=0D + var numMajorIndices =3D majorIndices.length;=0D + var first =3D majorIndices[0];=0D + var last =3D majorIndices[numMajorIndices - 1];=0D + var i, ilen, spacing, avgMajorSpacing;=0D +=0D + // If there are too many major ticks to display them all=0D + if (numMajorIndices > ticksLimit) {=0D + skipMajors(ticks, majorIndices, numMajorIndices / ticksLimit);=0D + return nonSkipped(ticks);=0D + }=0D +=0D + spacing =3D calculateSpacing(majorIndices, ticks, axisLength, ticksLimit= );=0D +=0D + if (numMajorIndices > 0) {=0D + for (i =3D 0, ilen =3D numMajorIndices - 1; i < ilen; i++) {=0D + skip(ticks, spacing, majorIndices[i], majorIndices[i + 1]);=0D + }=0D + avgMajorSpacing =3D numMajorIndices > 1 ? (last - first) / (numMajorInd= ices - 1) : null;=0D + skip(ticks, spacing, helpers$1.isNullOrUndef(avgMajorSpacing) ? 0 : fir= st - avgMajorSpacing, first);=0D + skip(ticks, spacing, last, helpers$1.isNullOrUndef(avgMajorSpacing) ? t= icks.length : last + avgMajorSpacing);=0D + return nonSkipped(ticks);=0D + }=0D + skip(ticks, spacing);=0D + return nonSkipped(ticks);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _tickSize: function() {=0D + var me =3D this;=0D + var optionTicks =3D me.options.ticks;=0D +=0D + // Calculate space needed by label in axis direction.=0D + var rot =3D helpers$1.toRadians(me.labelRotation);=0D + var cos =3D Math.abs(Math.cos(rot));=0D + var sin =3D Math.abs(Math.sin(rot));=0D +=0D + var labelSizes =3D me._getLabelSizes();=0D + var padding =3D optionTicks.autoSkipPadding || 0;=0D + var w =3D labelSizes ? labelSizes.widest.width + padding : 0;=0D + var h =3D labelSizes ? labelSizes.highest.height + padding : 0;=0D +=0D + // Calculate space needed for 1 tick in axis direction.=0D + return me.isHorizontal()=0D + ? h * cos > w * sin ? w / cos : h / sin=0D + : h * sin < w * cos ? h / cos : w / sin;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _isVisible: function() {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var display =3D me.options.display;=0D + var i, ilen, meta;=0D +=0D + if (display !=3D=3D 'auto') {=0D + return !!display;=0D + }=0D +=0D + // When 'auto', the scale is visible if at least one associated dataset = is visible.=0D + for (i =3D 0, ilen =3D chart.data.datasets.length; i < ilen; ++i) {=0D + if (chart.isDatasetVisible(i)) {=0D + meta =3D chart.getDatasetMeta(i);=0D + if (meta.xAxisID =3D=3D=3D me.id || meta.yAxisID =3D=3D=3D me.id) {=0D + return true;=0D + }=0D + }=0D + }=0D +=0D + return false;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _computeGridLineItems: function(chartArea) {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var options =3D me.options;=0D + var gridLines =3D options.gridLines;=0D + var position =3D options.position;=0D + var offsetGridLines =3D gridLines.offsetGridLines;=0D + var isHorizontal =3D me.isHorizontal();=0D + var ticks =3D me._ticksToDraw;=0D + var ticksLength =3D ticks.length + (offsetGridLines ? 1 : 0);=0D +=0D + var tl =3D getTickMarkLength(gridLines);=0D + var items =3D [];=0D + var axisWidth =3D gridLines.drawBorder ? valueAtIndexOrDefault(gridLines= .lineWidth, 0, 0) : 0;=0D + var axisHalfWidth =3D axisWidth / 2;=0D + var alignPixel =3D helpers$1._alignPixel;=0D + var alignBorderValue =3D function(pixel) {=0D + return alignPixel(chart, pixel, axisWidth);=0D + };=0D + var borderValue, i, tick, lineValue, alignedLineValue;=0D + var tx1, ty1, tx2, ty2, x1, y1, x2, y2, lineWidth, lineColor, borderDash= , borderDashOffset;=0D +=0D + if (position =3D=3D=3D 'top') {=0D + borderValue =3D alignBorderValue(me.bottom);=0D + ty1 =3D me.bottom - tl;=0D + ty2 =3D borderValue - axisHalfWidth;=0D + y1 =3D alignBorderValue(chartArea.top) + axisHalfWidth;=0D + y2 =3D chartArea.bottom;=0D + } else if (position =3D=3D=3D 'bottom') {=0D + borderValue =3D alignBorderValue(me.top);=0D + y1 =3D chartArea.top;=0D + y2 =3D alignBorderValue(chartArea.bottom) - axisHalfWidth;=0D + ty1 =3D borderValue + axisHalfWidth;=0D + ty2 =3D me.top + tl;=0D + } else if (position =3D=3D=3D 'left') {=0D + borderValue =3D alignBorderValue(me.right);=0D + tx1 =3D me.right - tl;=0D + tx2 =3D borderValue - axisHalfWidth;=0D + x1 =3D alignBorderValue(chartArea.left) + axisHalfWidth;=0D + x2 =3D chartArea.right;=0D + } else {=0D + borderValue =3D alignBorderValue(me.left);=0D + x1 =3D chartArea.left;=0D + x2 =3D alignBorderValue(chartArea.right) - axisHalfWidth;=0D + tx1 =3D borderValue + axisHalfWidth;=0D + tx2 =3D me.left + tl;=0D + }=0D +=0D + for (i =3D 0; i < ticksLength; ++i) {=0D + tick =3D ticks[i] || {};=0D +=0D + // autoskipper skipped this tick (#4635)=0D + if (isNullOrUndef(tick.label) && i < ticks.length) {=0D + continue;=0D + }=0D +=0D + if (i =3D=3D=3D me.zeroLineIndex && options.offset =3D=3D=3D offsetGrid= Lines) {=0D + // Draw the first index specially=0D + lineWidth =3D gridLines.zeroLineWidth;=0D + lineColor =3D gridLines.zeroLineColor;=0D + borderDash =3D gridLines.zeroLineBorderDash || [];=0D + borderDashOffset =3D gridLines.zeroLineBorderDashOffset || 0.0;=0D + } else {=0D + lineWidth =3D valueAtIndexOrDefault(gridLines.lineWidth, i, 1);=0D + lineColor =3D valueAtIndexOrDefault(gridLines.color, i, 'rgba(0,0,0,0.= 1)');=0D + borderDash =3D gridLines.borderDash || [];=0D + borderDashOffset =3D gridLines.borderDashOffset || 0.0;=0D + }=0D +=0D + lineValue =3D getPixelForGridLine(me, tick._index || i, offsetGridLines= );=0D +=0D + // Skip if the pixel is out of the range=0D + if (lineValue =3D=3D=3D undefined) {=0D + continue;=0D + }=0D +=0D + alignedLineValue =3D alignPixel(chart, lineValue, lineWidth);=0D +=0D + if (isHorizontal) {=0D + tx1 =3D tx2 =3D x1 =3D x2 =3D alignedLineValue;=0D + } else {=0D + ty1 =3D ty2 =3D y1 =3D y2 =3D alignedLineValue;=0D + }=0D +=0D + items.push({=0D + tx1: tx1,=0D + ty1: ty1,=0D + tx2: tx2,=0D + ty2: ty2,=0D + x1: x1,=0D + y1: y1,=0D + x2: x2,=0D + y2: y2,=0D + width: lineWidth,=0D + color: lineColor,=0D + borderDash: borderDash,=0D + borderDashOffset: borderDashOffset,=0D + });=0D + }=0D +=0D + items.ticksLength =3D ticksLength;=0D + items.borderValue =3D borderValue;=0D +=0D + return items;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _computeLabelItems: function() {=0D + var me =3D this;=0D + var options =3D me.options;=0D + var optionTicks =3D options.ticks;=0D + var position =3D options.position;=0D + var isMirrored =3D optionTicks.mirror;=0D + var isHorizontal =3D me.isHorizontal();=0D + var ticks =3D me._ticksToDraw;=0D + var fonts =3D parseTickFontOptions(optionTicks);=0D + var tickPadding =3D optionTicks.padding;=0D + var tl =3D getTickMarkLength(options.gridLines);=0D + var rotation =3D -helpers$1.toRadians(me.labelRotation);=0D + var items =3D [];=0D + var i, ilen, tick, label, x, y, textAlign, pixel, font, lineHeight, line= Count, textOffset;=0D +=0D + if (position =3D=3D=3D 'top') {=0D + y =3D me.bottom - tl - tickPadding;=0D + textAlign =3D !rotation ? 'center' : 'left';=0D + } else if (position =3D=3D=3D 'bottom') {=0D + y =3D me.top + tl + tickPadding;=0D + textAlign =3D !rotation ? 'center' : 'right';=0D + } else if (position =3D=3D=3D 'left') {=0D + x =3D me.right - (isMirrored ? 0 : tl) - tickPadding;=0D + textAlign =3D isMirrored ? 'left' : 'right';=0D + } else {=0D + x =3D me.left + (isMirrored ? 0 : tl) + tickPadding;=0D + textAlign =3D isMirrored ? 'right' : 'left';=0D + }=0D +=0D + for (i =3D 0, ilen =3D ticks.length; i < ilen; ++i) {=0D + tick =3D ticks[i];=0D + label =3D tick.label;=0D +=0D + // autoskipper skipped this tick (#4635)=0D + if (isNullOrUndef(label)) {=0D + continue;=0D + }=0D +=0D + pixel =3D me.getPixelForTick(tick._index || i) + optionTicks.labelOffse= t;=0D + font =3D tick.major ? fonts.major : fonts.minor;=0D + lineHeight =3D font.lineHeight;=0D + lineCount =3D isArray(label) ? label.length : 1;=0D +=0D + if (isHorizontal) {=0D + x =3D pixel;=0D + textOffset =3D position =3D=3D=3D 'top'=0D + ? ((!rotation ? 0.5 : 1) - lineCount) * lineHeight=0D + : (!rotation ? 0.5 : 0) * lineHeight;=0D + } else {=0D + y =3D pixel;=0D + textOffset =3D (1 - lineCount) * lineHeight / 2;=0D + }=0D +=0D + items.push({=0D + x: x,=0D + y: y,=0D + rotation: rotation,=0D + label: label,=0D + font: font,=0D + textOffset: textOffset,=0D + textAlign: textAlign=0D + });=0D + }=0D +=0D + return items;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _drawGrid: function(chartArea) {=0D + var me =3D this;=0D + var gridLines =3D me.options.gridLines;=0D +=0D + if (!gridLines.display) {=0D + return;=0D + }=0D +=0D + var ctx =3D me.ctx;=0D + var chart =3D me.chart;=0D + var alignPixel =3D helpers$1._alignPixel;=0D + var axisWidth =3D gridLines.drawBorder ? valueAtIndexOrDefault(gridLines= .lineWidth, 0, 0) : 0;=0D + var items =3D me._gridLineItems || (me._gridLineItems =3D me._computeGri= dLineItems(chartArea));=0D + var width, color, i, ilen, item;=0D +=0D + for (i =3D 0, ilen =3D items.length; i < ilen; ++i) {=0D + item =3D items[i];=0D + width =3D item.width;=0D + color =3D item.color;=0D +=0D + if (width && color) {=0D + ctx.save();=0D + ctx.lineWidth =3D width;=0D + ctx.strokeStyle =3D color;=0D + if (ctx.setLineDash) {=0D + ctx.setLineDash(item.borderDash);=0D + ctx.lineDashOffset =3D item.borderDashOffset;=0D + }=0D +=0D + ctx.beginPath();=0D +=0D + if (gridLines.drawTicks) {=0D + ctx.moveTo(item.tx1, item.ty1);=0D + ctx.lineTo(item.tx2, item.ty2);=0D + }=0D +=0D + if (gridLines.drawOnChartArea) {=0D + ctx.moveTo(item.x1, item.y1);=0D + ctx.lineTo(item.x2, item.y2);=0D + }=0D +=0D + ctx.stroke();=0D + ctx.restore();=0D + }=0D + }=0D +=0D + if (axisWidth) {=0D + // Draw the line at the edge of the axis=0D + var firstLineWidth =3D axisWidth;=0D + var lastLineWidth =3D valueAtIndexOrDefault(gridLines.lineWidth, items.= ticksLength - 1, 1);=0D + var borderValue =3D items.borderValue;=0D + var x1, x2, y1, y2;=0D +=0D + if (me.isHorizontal()) {=0D + x1 =3D alignPixel(chart, me.left, firstLineWidth) - firstLineWidth / 2= ;=0D + x2 =3D alignPixel(chart, me.right, lastLineWidth) + lastLineWidth / 2;= =0D + y1 =3D y2 =3D borderValue;=0D + } else {=0D + y1 =3D alignPixel(chart, me.top, firstLineWidth) - firstLineWidth / 2;= =0D + y2 =3D alignPixel(chart, me.bottom, lastLineWidth) + lastLineWidth / 2= ;=0D + x1 =3D x2 =3D borderValue;=0D + }=0D +=0D + ctx.lineWidth =3D axisWidth;=0D + ctx.strokeStyle =3D valueAtIndexOrDefault(gridLines.color, 0);=0D + ctx.beginPath();=0D + ctx.moveTo(x1, y1);=0D + ctx.lineTo(x2, y2);=0D + ctx.stroke();=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _drawLabels: function() {=0D + var me =3D this;=0D + var optionTicks =3D me.options.ticks;=0D +=0D + if (!optionTicks.display) {=0D + return;=0D + }=0D +=0D + var ctx =3D me.ctx;=0D + var items =3D me._labelItems || (me._labelItems =3D me._computeLabelItem= s());=0D + var i, j, ilen, jlen, item, tickFont, label, y;=0D +=0D + for (i =3D 0, ilen =3D items.length; i < ilen; ++i) {=0D + item =3D items[i];=0D + tickFont =3D item.font;=0D +=0D + // Make sure we draw text in the correct color and font=0D + ctx.save();=0D + ctx.translate(item.x, item.y);=0D + ctx.rotate(item.rotation);=0D + ctx.font =3D tickFont.string;=0D + ctx.fillStyle =3D tickFont.color;=0D + ctx.textBaseline =3D 'middle';=0D + ctx.textAlign =3D item.textAlign;=0D +=0D + label =3D item.label;=0D + y =3D item.textOffset;=0D + if (isArray(label)) {=0D + for (j =3D 0, jlen =3D label.length; j < jlen; ++j) {=0D + // We just make sure the multiline element is a string here..=0D + ctx.fillText('' + label[j], 0, y);=0D + y +=3D tickFont.lineHeight;=0D + }=0D + } else {=0D + ctx.fillText(label, 0, y);=0D + }=0D + ctx.restore();=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _drawTitle: function() {=0D + var me =3D this;=0D + var ctx =3D me.ctx;=0D + var options =3D me.options;=0D + var scaleLabel =3D options.scaleLabel;=0D +=0D + if (!scaleLabel.display) {=0D + return;=0D + }=0D +=0D + var scaleLabelFontColor =3D valueOrDefault$a(scaleLabel.fontColor, core_= defaults.global.defaultFontColor);=0D + var scaleLabelFont =3D helpers$1.options._parseFont(scaleLabel);=0D + var scaleLabelPadding =3D helpers$1.options.toPadding(scaleLabel.padding= );=0D + var halfLineHeight =3D scaleLabelFont.lineHeight / 2;=0D + var position =3D options.position;=0D + var rotation =3D 0;=0D + var scaleLabelX, scaleLabelY;=0D +=0D + if (me.isHorizontal()) {=0D + scaleLabelX =3D me.left + me.width / 2; // midpoint of the width=0D + scaleLabelY =3D position =3D=3D=3D 'bottom'=0D + ? me.bottom - halfLineHeight - scaleLabelPadding.bottom=0D + : me.top + halfLineHeight + scaleLabelPadding.top;=0D + } else {=0D + var isLeft =3D position =3D=3D=3D 'left';=0D + scaleLabelX =3D isLeft=0D + ? me.left + halfLineHeight + scaleLabelPadding.top=0D + : me.right - halfLineHeight - scaleLabelPadding.top;=0D + scaleLabelY =3D me.top + me.height / 2;=0D + rotation =3D isLeft ? -0.5 * Math.PI : 0.5 * Math.PI;=0D + }=0D +=0D + ctx.save();=0D + ctx.translate(scaleLabelX, scaleLabelY);=0D + ctx.rotate(rotation);=0D + ctx.textAlign =3D 'center';=0D + ctx.textBaseline =3D 'middle';=0D + ctx.fillStyle =3D scaleLabelFontColor; // render in correct colour=0D + ctx.font =3D scaleLabelFont.string;=0D + ctx.fillText(scaleLabel.labelString, 0, 0);=0D + ctx.restore();=0D + },=0D +=0D + draw: function(chartArea) {=0D + var me =3D this;=0D +=0D + if (!me._isVisible()) {=0D + return;=0D + }=0D +=0D + me._drawGrid(chartArea);=0D + me._drawTitle();=0D + me._drawLabels();=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _layers: function() {=0D + var me =3D this;=0D + var opts =3D me.options;=0D + var tz =3D opts.ticks && opts.ticks.z || 0;=0D + var gz =3D opts.gridLines && opts.gridLines.z || 0;=0D +=0D + if (!me._isVisible() || tz =3D=3D=3D gz || me.draw !=3D=3D me._draw) {=0D + // backward compatibility: draw has been overridden by custom scale=0D + return [{=0D + z: tz,=0D + draw: function() {=0D + me.draw.apply(me, arguments);=0D + }=0D + }];=0D + }=0D +=0D + return [{=0D + z: gz,=0D + draw: function() {=0D + me._drawGrid.apply(me, arguments);=0D + me._drawTitle.apply(me, arguments);=0D + }=0D + }, {=0D + z: tz,=0D + draw: function() {=0D + me._drawLabels.apply(me, arguments);=0D + }=0D + }];=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getMatchingVisibleMetas: function(type) {=0D + var me =3D this;=0D + var isHorizontal =3D me.isHorizontal();=0D + return me.chart._getSortedVisibleDatasetMetas()=0D + .filter(function(meta) {=0D + return (!type || meta.type =3D=3D=3D type)=0D + && (isHorizontal ? meta.xAxisID =3D=3D=3D me.id : meta.yAxisID =3D=3D= =3D me.id);=0D + });=0D + }=0D +});=0D +=0D +Scale.prototype._draw =3D Scale.prototype.draw;=0D +=0D +var core_scale =3D Scale; =20 - ctx.save(); - ctx.translate(titleX, titleY); - ctx.rotate(rotation); - ctx.textAlign =3D 'center'; - ctx.textBaseline =3D 'middle'; - - var text =3D opts.text; - if (helpers$1.isArray(text)) { - var y =3D 0; - for (var i =3D 0; i < text.length; ++i) { - ctx.fillText(text[i], 0, y, maxWidth); - y +=3D lineHeight; - } - } else { - ctx.fillText(text, 0, 0, maxWidth); - } +var isNullOrUndef$1 =3D helpers$1.isNullOrUndef;=0D +=0D +var defaultConfig =3D {=0D + position: 'bottom'=0D +};=0D +=0D +var scale_category =3D core_scale.extend({=0D + determineDataLimits: function() {=0D + var me =3D this;=0D + var labels =3D me._getLabels();=0D + var ticksOpts =3D me.options.ticks;=0D + var min =3D ticksOpts.min;=0D + var max =3D ticksOpts.max;=0D + var minIndex =3D 0;=0D + var maxIndex =3D labels.length - 1;=0D + var findIndex;=0D +=0D + if (min !=3D=3D undefined) {=0D + // user specified min value=0D + findIndex =3D labels.indexOf(min);=0D + if (findIndex >=3D 0) {=0D + minIndex =3D findIndex;=0D + }=0D + }=0D +=0D + if (max !=3D=3D undefined) {=0D + // user specified max value=0D + findIndex =3D labels.indexOf(max);=0D + if (findIndex >=3D 0) {=0D + maxIndex =3D findIndex;=0D + }=0D + }=0D +=0D + me.minIndex =3D minIndex;=0D + me.maxIndex =3D maxIndex;=0D + me.min =3D labels[minIndex];=0D + me.max =3D labels[maxIndex];=0D + },=0D +=0D + buildTicks: function() {=0D + var me =3D this;=0D + var labels =3D me._getLabels();=0D + var minIndex =3D me.minIndex;=0D + var maxIndex =3D me.maxIndex;=0D +=0D + // If we are viewing some subset of labels, slice the original array=0D + me.ticks =3D (minIndex =3D=3D=3D 0 && maxIndex =3D=3D=3D labels.length -= 1) ? labels : labels.slice(minIndex, maxIndex + 1);=0D + },=0D +=0D + getLabelForIndex: function(index, datasetIndex) {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D +=0D + if (chart.getDatasetMeta(datasetIndex).controller._getValueScaleId() =3D= =3D=3D me.id) {=0D + return me.getRightValue(chart.data.datasets[datasetIndex].data[index]);= =0D + }=0D +=0D + return me._getLabels()[index];=0D + },=0D +=0D + _configure: function() {=0D + var me =3D this;=0D + var offset =3D me.options.offset;=0D + var ticks =3D me.ticks;=0D +=0D + core_scale.prototype._configure.call(me);=0D +=0D + if (!me.isHorizontal()) {=0D + // For backward compatibility, vertical category scale reverse is inver= ted.=0D + me._reversePixels =3D !me._reversePixels;=0D + }=0D +=0D + if (!ticks) {=0D + return;=0D + }=0D +=0D + me._startValue =3D me.minIndex - (offset ? 0.5 : 0);=0D + me._valueRange =3D Math.max(ticks.length - (offset ? 0 : 1), 1);=0D + },=0D +=0D + // Used to get data value locations. Value can either be an index or a n= umerical value=0D + getPixelForValue: function(value, index, datasetIndex) {=0D + var me =3D this;=0D + var valueCategory, labels, idx;=0D +=0D + if (!isNullOrUndef$1(index) && !isNullOrUndef$1(datasetIndex)) {=0D + value =3D me.chart.data.datasets[datasetIndex].data[index];=0D + }=0D +=0D + // If value is a data object, then index is the index in the data array,= =0D + // not the index of the scale. We need to change that.=0D + if (!isNullOrUndef$1(value)) {=0D + valueCategory =3D me.isHorizontal() ? value.x : value.y;=0D + }=0D + if (valueCategory !=3D=3D undefined || (value !=3D=3D undefined && isNaN= (index))) {=0D + labels =3D me._getLabels();=0D + value =3D helpers$1.valueOrDefault(valueCategory, value);=0D + idx =3D labels.indexOf(value);=0D + index =3D idx !=3D=3D -1 ? idx : index;=0D + if (isNaN(index)) {=0D + index =3D value;=0D + }=0D + }=0D + return me.getPixelForDecimal((index - me._startValue) / me._valueRange);= =0D + },=0D +=0D + getPixelForTick: function(index) {=0D + var ticks =3D this.ticks;=0D + return index < 0 || index > ticks.length - 1=0D + ? null=0D + : this.getPixelForValue(ticks[index], index + this.minIndex);=0D + },=0D +=0D + getValueForPixel: function(pixel) {=0D + var me =3D this;=0D + var value =3D Math.round(me._startValue + me.getDecimalForPixel(pixel) *= me._valueRange);=0D + return Math.min(Math.max(value, 0), me.ticks.length - 1);=0D + },=0D +=0D + getBasePixel: function() {=0D + return this.bottom;=0D + }=0D +});=0D +=0D +// INTERNAL: static default options, registered in src/index.js=0D +var _defaults =3D defaultConfig; +scale_category._defaults =3D _defaults; =20 - ctx.restore(); - } +var noop =3D helpers$1.noop;=0D +var isNullOrUndef$2 =3D helpers$1.isNullOrUndef;=0D +=0D +/**=0D + * Generate a set of linear ticks=0D + * @param generationOptions the options used to generate the ticks=0D + * @param dataRange the range of the data=0D + * @returns {number[]} array of tick values=0D + */=0D +function generateTicks(generationOptions, dataRange) {=0D + var ticks =3D [];=0D + // To get a "nice" value for the tick spacing, we will use the appropriat= ely named=0D + // "nice number" algorithm. See https://stackoverflow.com/questions/85068= 81/nice-label-algorithm-for-charts-with-minimum-ticks=0D + // for details.=0D +=0D + var MIN_SPACING =3D 1e-14;=0D + var stepSize =3D generationOptions.stepSize;=0D + var unit =3D stepSize || 1;=0D + var maxNumSpaces =3D generationOptions.maxTicks - 1;=0D + var min =3D generationOptions.min;=0D + var max =3D generationOptions.max;=0D + var precision =3D generationOptions.precision;=0D + var rmin =3D dataRange.min;=0D + var rmax =3D dataRange.max;=0D + var spacing =3D helpers$1.niceNum((rmax - rmin) / maxNumSpaces / unit) * = unit;=0D + var factor, niceMin, niceMax, numSpaces;=0D +=0D + // Beyond MIN_SPACING floating point numbers being to lose precision=0D + // such that we can't do the math necessary to generate ticks=0D + if (spacing < MIN_SPACING && isNullOrUndef$2(min) && isNullOrUndef$2(max)= ) {=0D + return [rmin, rmax];=0D + }=0D +=0D + numSpaces =3D Math.ceil(rmax / spacing) - Math.floor(rmin / spacing);=0D + if (numSpaces > maxNumSpaces) {=0D + // If the calculated num of spaces exceeds maxNumSpaces, recalculate it= =0D + spacing =3D helpers$1.niceNum(numSpaces * spacing / maxNumSpaces / unit)= * unit;=0D + }=0D +=0D + if (stepSize || isNullOrUndef$2(precision)) {=0D + // If a precision is not specified, calculate factor based on spacing=0D + factor =3D Math.pow(10, helpers$1._decimalPlaces(spacing));=0D + } else {=0D + // If the user specified a precision, round to that number of decimal pl= aces=0D + factor =3D Math.pow(10, precision);=0D + spacing =3D Math.ceil(spacing * factor) / factor;=0D + }=0D +=0D + niceMin =3D Math.floor(rmin / spacing) * spacing;=0D + niceMax =3D Math.ceil(rmax / spacing) * spacing;=0D +=0D + // If min, max and stepSize is set and they make an evenly spaced scale u= se it.=0D + if (stepSize) {=0D + // If very close to our whole number, use it.=0D + if (!isNullOrUndef$2(min) && helpers$1.almostWhole(min / spacing, spacin= g / 1000)) {=0D + niceMin =3D min;=0D + }=0D + if (!isNullOrUndef$2(max) && helpers$1.almostWhole(max / spacing, spacin= g / 1000)) {=0D + niceMax =3D max;=0D + }=0D + }=0D +=0D + numSpaces =3D (niceMax - niceMin) / spacing;=0D + // If very close to our rounded value, use it.=0D + if (helpers$1.almostEquals(numSpaces, Math.round(numSpaces), spacing / 10= 00)) {=0D + numSpaces =3D Math.round(numSpaces);=0D + } else {=0D + numSpaces =3D Math.ceil(numSpaces);=0D + }=0D +=0D + niceMin =3D Math.round(niceMin * factor) / factor;=0D + niceMax =3D Math.round(niceMax * factor) / factor;=0D + ticks.push(isNullOrUndef$2(min) ? niceMin : min);=0D + for (var j =3D 1; j < numSpaces; ++j) {=0D + ticks.push(Math.round((niceMin + j * spacing) * factor) / factor);=0D + }=0D + ticks.push(isNullOrUndef$2(max) ? niceMax : max);=0D +=0D + return ticks;=0D +}=0D +=0D +var scale_linearbase =3D core_scale.extend({=0D + getRightValue: function(value) {=0D + if (typeof value =3D=3D=3D 'string') {=0D + return +value;=0D + }=0D + return core_scale.prototype.getRightValue.call(this, value);=0D + },=0D +=0D + handleTickRangeOptions: function() {=0D + var me =3D this;=0D + var opts =3D me.options;=0D + var tickOpts =3D opts.ticks;=0D +=0D + // If we are forcing it to begin at 0, but 0 will already be rendered on= the chart,=0D + // do nothing since that would make the chart weird. If the user really = wants a weird chart=0D + // axis, they can manually override it=0D + if (tickOpts.beginAtZero) {=0D + var minSign =3D helpers$1.sign(me.min);=0D + var maxSign =3D helpers$1.sign(me.max);=0D +=0D + if (minSign < 0 && maxSign < 0) {=0D + // move the top up to 0=0D + me.max =3D 0;=0D + } else if (minSign > 0 && maxSign > 0) {=0D + // move the bottom down to 0=0D + me.min =3D 0;=0D + }=0D + }=0D +=0D + var setMin =3D tickOpts.min !=3D=3D undefined || tickOpts.suggestedMin != =3D=3D undefined;=0D + var setMax =3D tickOpts.max !=3D=3D undefined || tickOpts.suggestedMax != =3D=3D undefined;=0D +=0D + if (tickOpts.min !=3D=3D undefined) {=0D + me.min =3D tickOpts.min;=0D + } else if (tickOpts.suggestedMin !=3D=3D undefined) {=0D + if (me.min =3D=3D=3D null) {=0D + me.min =3D tickOpts.suggestedMin;=0D + } else {=0D + me.min =3D Math.min(me.min, tickOpts.suggestedMin);=0D + }=0D + }=0D +=0D + if (tickOpts.max !=3D=3D undefined) {=0D + me.max =3D tickOpts.max;=0D + } else if (tickOpts.suggestedMax !=3D=3D undefined) {=0D + if (me.max =3D=3D=3D null) {=0D + me.max =3D tickOpts.suggestedMax;=0D + } else {=0D + me.max =3D Math.max(me.max, tickOpts.suggestedMax);=0D + }=0D + }=0D +=0D + if (setMin !=3D=3D setMax) {=0D + // We set the min or the max but not both.=0D + // So ensure that our range is good=0D + // Inverted or 0 length range can happen when=0D + // ticks.min is set, and no datasets are visible=0D + if (me.min >=3D me.max) {=0D + if (setMin) {=0D + me.max =3D me.min + 1;=0D + } else {=0D + me.min =3D me.max - 1;=0D + }=0D + }=0D + }=0D +=0D + if (me.min =3D=3D=3D me.max) {=0D + me.max++;=0D +=0D + if (!tickOpts.beginAtZero) {=0D + me.min--;=0D + }=0D + }=0D + },=0D +=0D + getTickLimit: function() {=0D + var me =3D this;=0D + var tickOpts =3D me.options.ticks;=0D + var stepSize =3D tickOpts.stepSize;=0D + var maxTicksLimit =3D tickOpts.maxTicksLimit;=0D + var maxTicks;=0D +=0D + if (stepSize) {=0D + maxTicks =3D Math.ceil(me.max / stepSize) - Math.floor(me.min / stepSiz= e) + 1;=0D + } else {=0D + maxTicks =3D me._computeTickLimit();=0D + maxTicksLimit =3D maxTicksLimit || 11;=0D + }=0D +=0D + if (maxTicksLimit) {=0D + maxTicks =3D Math.min(maxTicksLimit, maxTicks);=0D + }=0D +=0D + return maxTicks;=0D + },=0D +=0D + _computeTickLimit: function() {=0D + return Number.POSITIVE_INFINITY;=0D + },=0D +=0D + handleDirectionalChanges: noop,=0D +=0D + buildTicks: function() {=0D + var me =3D this;=0D + var opts =3D me.options;=0D + var tickOpts =3D opts.ticks;=0D +=0D + // Figure out what the max number of ticks we can support it is based on= the size of=0D + // the axis area. For now, we say that the minimum tick spacing in pixel= s must be 40=0D + // We also limit the maximum number of ticks to 11 which gives a nice 10= squares on=0D + // the graph. Make sure we always have at least 2 ticks=0D + var maxTicks =3D me.getTickLimit();=0D + maxTicks =3D Math.max(2, maxTicks);=0D +=0D + var numericGeneratorOptions =3D {=0D + maxTicks: maxTicks,=0D + min: tickOpts.min,=0D + max: tickOpts.max,=0D + precision: tickOpts.precision,=0D + stepSize: helpers$1.valueOrDefault(tickOpts.fixedStepSize, tickOpts.ste= pSize)=0D + };=0D + var ticks =3D me.ticks =3D generateTicks(numericGeneratorOptions, me);=0D +=0D + me.handleDirectionalChanges();=0D +=0D + // At this point, we need to update our max and min given the tick value= s since we have expanded the=0D + // range of the scale=0D + me.max =3D helpers$1.max(ticks);=0D + me.min =3D helpers$1.min(ticks);=0D +=0D + if (tickOpts.reverse) {=0D + ticks.reverse();=0D +=0D + me.start =3D me.max;=0D + me.end =3D me.min;=0D + } else {=0D + me.start =3D me.min;=0D + me.end =3D me.max;=0D + }=0D + },=0D +=0D + convertTicksToLabels: function() {=0D + var me =3D this;=0D + me.ticksAsNumbers =3D me.ticks.slice();=0D + me.zeroLineIndex =3D me.ticks.indexOf(0);=0D +=0D + core_scale.prototype.convertTicksToLabels.call(me);=0D + },=0D +=0D + _configure: function() {=0D + var me =3D this;=0D + var ticks =3D me.getTicks();=0D + var start =3D me.min;=0D + var end =3D me.max;=0D + var offset;=0D +=0D + core_scale.prototype._configure.call(me);=0D +=0D + if (me.options.offset && ticks.length) {=0D + offset =3D (end - start) / Math.max(ticks.length - 1, 1) / 2;=0D + start -=3D offset;=0D + end +=3D offset;=0D + }=0D + me._startValue =3D start;=0D + me._endValue =3D end;=0D + me._valueRange =3D end - start;=0D + }=0D }); =20 -function createNewTitleBlockAndAttach(chart, titleOpts) { - var title =3D new Title({ - ctx: chart.ctx, - options: titleOpts, - chart: chart - }); +var defaultConfig$1 =3D {=0D + position: 'left',=0D + ticks: {=0D + callback: core_ticks.formatters.linear=0D + }=0D +};=0D +=0D +var DEFAULT_MIN =3D 0;=0D +var DEFAULT_MAX =3D 1;=0D +=0D +function getOrCreateStack(stacks, stacked, meta) {=0D + var key =3D [=0D + meta.type,=0D + // we have a separate stack for stack=3Dundefined datasets when the opts= .stacked is undefined=0D + stacked =3D=3D=3D undefined && meta.stack =3D=3D=3D undefined ? meta.ind= ex : '',=0D + meta.stack=0D + ].join('.');=0D +=0D + if (stacks[key] =3D=3D=3D undefined) {=0D + stacks[key] =3D {=0D + pos: [],=0D + neg: []=0D + };=0D + }=0D +=0D + return stacks[key];=0D +}=0D +=0D +function stackData(scale, stacks, meta, data) {=0D + var opts =3D scale.options;=0D + var stacked =3D opts.stacked;=0D + var stack =3D getOrCreateStack(stacks, stacked, meta);=0D + var pos =3D stack.pos;=0D + var neg =3D stack.neg;=0D + var ilen =3D data.length;=0D + var i, value;=0D +=0D + for (i =3D 0; i < ilen; ++i) {=0D + value =3D scale._parseValue(data[i]);=0D + if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden) {=0D + continue;=0D + }=0D +=0D + pos[i] =3D pos[i] || 0;=0D + neg[i] =3D neg[i] || 0;=0D +=0D + if (opts.relativePoints) {=0D + pos[i] =3D 100;=0D + } else if (value.min < 0 || value.max < 0) {=0D + neg[i] +=3D value.min;=0D + } else {=0D + pos[i] +=3D value.max;=0D + }=0D + }=0D +}=0D +=0D +function updateMinMax(scale, meta, data) {=0D + var ilen =3D data.length;=0D + var i, value;=0D +=0D + for (i =3D 0; i < ilen; ++i) {=0D + value =3D scale._parseValue(data[i]);=0D + if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden) {=0D + continue;=0D + }=0D +=0D + scale.min =3D Math.min(scale.min, value.min);=0D + scale.max =3D Math.max(scale.max, value.max);=0D + }=0D +}=0D +=0D +var scale_linear =3D scale_linearbase.extend({=0D + determineDataLimits: function() {=0D + var me =3D this;=0D + var opts =3D me.options;=0D + var chart =3D me.chart;=0D + var datasets =3D chart.data.datasets;=0D + var metasets =3D me._getMatchingVisibleMetas();=0D + var hasStacks =3D opts.stacked;=0D + var stacks =3D {};=0D + var ilen =3D metasets.length;=0D + var i, meta, data, values;=0D +=0D + me.min =3D Number.POSITIVE_INFINITY;=0D + me.max =3D Number.NEGATIVE_INFINITY;=0D +=0D + if (hasStacks =3D=3D=3D undefined) {=0D + for (i =3D 0; !hasStacks && i < ilen; ++i) {=0D + meta =3D metasets[i];=0D + hasStacks =3D meta.stack !=3D=3D undefined;=0D + }=0D + }=0D +=0D + for (i =3D 0; i < ilen; ++i) {=0D + meta =3D metasets[i];=0D + data =3D datasets[meta.index].data;=0D + if (hasStacks) {=0D + stackData(me, stacks, meta, data);=0D + } else {=0D + updateMinMax(me, meta, data);=0D + }=0D + }=0D +=0D + helpers$1.each(stacks, function(stackValues) {=0D + values =3D stackValues.pos.concat(stackValues.neg);=0D + me.min =3D Math.min(me.min, helpers$1.min(values));=0D + me.max =3D Math.max(me.max, helpers$1.max(values));=0D + });=0D +=0D + me.min =3D helpers$1.isFinite(me.min) && !isNaN(me.min) ? me.min : DEFAU= LT_MIN;=0D + me.max =3D helpers$1.isFinite(me.max) && !isNaN(me.max) ? me.max : DEFAU= LT_MAX;=0D +=0D + // Common base implementation to handle ticks.min, ticks.max, ticks.begi= nAtZero=0D + me.handleTickRangeOptions();=0D + },=0D +=0D + // Returns the maximum number of ticks based on the scale dimension=0D + _computeTickLimit: function() {=0D + var me =3D this;=0D + var tickFont;=0D +=0D + if (me.isHorizontal()) {=0D + return Math.ceil(me.width / 40);=0D + }=0D + tickFont =3D helpers$1.options._parseFont(me.options.ticks);=0D + return Math.ceil(me.height / tickFont.lineHeight);=0D + },=0D +=0D + // Called after the ticks are built. We need=0D + handleDirectionalChanges: function() {=0D + if (!this.isHorizontal()) {=0D + // We are in a vertical orientation. The top value is the highest. So r= everse the array=0D + this.ticks.reverse();=0D + }=0D + },=0D +=0D + getLabelForIndex: function(index, datasetIndex) {=0D + return this._getScaleLabel(this.chart.data.datasets[datasetIndex].data[i= ndex]);=0D + },=0D +=0D + // Utils=0D + getPixelForValue: function(value) {=0D + var me =3D this;=0D + return me.getPixelForDecimal((+me.getRightValue(value) - me._startValue)= / me._valueRange);=0D + },=0D +=0D + getValueForPixel: function(pixel) {=0D + return this._startValue + this.getDecimalForPixel(pixel) * this._valueRa= nge;=0D + },=0D +=0D + getPixelForTick: function(index) {=0D + var ticks =3D this.ticksAsNumbers;=0D + if (index < 0 || index > ticks.length - 1) {=0D + return null;=0D + }=0D + return this.getPixelForValue(ticks[index]);=0D + }=0D +});=0D +=0D +// INTERNAL: static default options, registered in src/index.js=0D +var _defaults$1 =3D defaultConfig$1; +scale_linear._defaults =3D _defaults$1; =20 - core_layouts.configure(chart, title, titleOpts); - core_layouts.addBox(chart, title); - chart.titleBlock =3D title; -} +var valueOrDefault$b =3D helpers$1.valueOrDefault;=0D +var log10 =3D helpers$1.math.log10;=0D +=0D +/**=0D + * Generate a set of logarithmic ticks=0D + * @param generationOptions the options used to generate the ticks=0D + * @param dataRange the range of the data=0D + * @returns {number[]} array of tick values=0D + */=0D +function generateTicks$1(generationOptions, dataRange) {=0D + var ticks =3D [];=0D +=0D + var tickVal =3D valueOrDefault$b(generationOptions.min, Math.pow(10, Math= .floor(log10(dataRange.min))));=0D +=0D + var endExp =3D Math.floor(log10(dataRange.max));=0D + var endSignificand =3D Math.ceil(dataRange.max / Math.pow(10, endExp));=0D + var exp, significand;=0D +=0D + if (tickVal =3D=3D=3D 0) {=0D + exp =3D Math.floor(log10(dataRange.minNotZero));=0D + significand =3D Math.floor(dataRange.minNotZero / Math.pow(10, exp));=0D +=0D + ticks.push(tickVal);=0D + tickVal =3D significand * Math.pow(10, exp);=0D + } else {=0D + exp =3D Math.floor(log10(tickVal));=0D + significand =3D Math.floor(tickVal / Math.pow(10, exp));=0D + }=0D + var precision =3D exp < 0 ? Math.pow(10, Math.abs(exp)) : 1;=0D +=0D + do {=0D + ticks.push(tickVal);=0D +=0D + ++significand;=0D + if (significand =3D=3D=3D 10) {=0D + significand =3D 1;=0D + ++exp;=0D + precision =3D exp >=3D 0 ? 1 : precision;=0D + }=0D +=0D + tickVal =3D Math.round(significand * Math.pow(10, exp) * precision) / pr= ecision;=0D + } while (exp < endExp || (exp =3D=3D=3D endExp && significand < endSignif= icand));=0D +=0D + var lastTick =3D valueOrDefault$b(generationOptions.max, tickVal);=0D + ticks.push(lastTick);=0D +=0D + return ticks;=0D +}=0D +=0D +var defaultConfig$2 =3D {=0D + position: 'left',=0D +=0D + // label settings=0D + ticks: {=0D + callback: core_ticks.formatters.logarithmic=0D + }=0D +};=0D +=0D +// TODO(v3): change this to positiveOrDefault=0D +function nonNegativeOrDefault(value, defaultValue) {=0D + return helpers$1.isFinite(value) && value >=3D 0 ? value : defaultValue;= =0D +}=0D +=0D +var scale_logarithmic =3D core_scale.extend({=0D + determineDataLimits: function() {=0D + var me =3D this;=0D + var opts =3D me.options;=0D + var chart =3D me.chart;=0D + var datasets =3D chart.data.datasets;=0D + var isHorizontal =3D me.isHorizontal();=0D + function IDMatches(meta) {=0D + return isHorizontal ? meta.xAxisID =3D=3D=3D me.id : meta.yAxisID =3D= =3D=3D me.id;=0D + }=0D + var datasetIndex, meta, value, data, i, ilen;=0D +=0D + // Calculate Range=0D + me.min =3D Number.POSITIVE_INFINITY;=0D + me.max =3D Number.NEGATIVE_INFINITY;=0D + me.minNotZero =3D Number.POSITIVE_INFINITY;=0D +=0D + var hasStacks =3D opts.stacked;=0D + if (hasStacks =3D=3D=3D undefined) {=0D + for (datasetIndex =3D 0; datasetIndex < datasets.length; datasetIndex++= ) {=0D + meta =3D chart.getDatasetMeta(datasetIndex);=0D + if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta) &&=0D + meta.stack !=3D=3D undefined) {=0D + hasStacks =3D true;=0D + break;=0D + }=0D + }=0D + }=0D +=0D + if (opts.stacked || hasStacks) {=0D + var valuesPerStack =3D {};=0D +=0D + for (datasetIndex =3D 0; datasetIndex < datasets.length; datasetIndex++= ) {=0D + meta =3D chart.getDatasetMeta(datasetIndex);=0D + var key =3D [=0D + meta.type,=0D + // we have a separate stack for stack=3Dundefined datasets when the o= pts.stacked is undefined=0D + ((opts.stacked =3D=3D=3D undefined && meta.stack =3D=3D=3D undefined)= ? datasetIndex : ''),=0D + meta.stack=0D + ].join('.');=0D +=0D + if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {=0D + if (valuesPerStack[key] =3D=3D=3D undefined) {=0D + valuesPerStack[key] =3D [];=0D + }=0D +=0D + data =3D datasets[datasetIndex].data;=0D + for (i =3D 0, ilen =3D data.length; i < ilen; i++) {=0D + var values =3D valuesPerStack[key];=0D + value =3D me._parseValue(data[i]);=0D + // invalid, hidden and negative values are ignored=0D + if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden || v= alue.min < 0 || value.max < 0) {=0D + continue;=0D + }=0D + values[i] =3D values[i] || 0;=0D + values[i] +=3D value.max;=0D + }=0D + }=0D + }=0D +=0D + helpers$1.each(valuesPerStack, function(valuesForType) {=0D + if (valuesForType.length > 0) {=0D + var minVal =3D helpers$1.min(valuesForType);=0D + var maxVal =3D helpers$1.max(valuesForType);=0D + me.min =3D Math.min(me.min, minVal);=0D + me.max =3D Math.max(me.max, maxVal);=0D + }=0D + });=0D +=0D + } else {=0D + for (datasetIndex =3D 0; datasetIndex < datasets.length; datasetIndex++= ) {=0D + meta =3D chart.getDatasetMeta(datasetIndex);=0D + if (chart.isDatasetVisible(datasetIndex) && IDMatches(meta)) {=0D + data =3D datasets[datasetIndex].data;=0D + for (i =3D 0, ilen =3D data.length; i < ilen; i++) {=0D + value =3D me._parseValue(data[i]);=0D + // invalid, hidden and negative values are ignored=0D + if (isNaN(value.min) || isNaN(value.max) || meta.data[i].hidden || v= alue.min < 0 || value.max < 0) {=0D + continue;=0D + }=0D +=0D + me.min =3D Math.min(value.min, me.min);=0D + me.max =3D Math.max(value.max, me.max);=0D +=0D + if (value.min !=3D=3D 0) {=0D + me.minNotZero =3D Math.min(value.min, me.minNotZero);=0D + }=0D + }=0D + }=0D + }=0D + }=0D +=0D + me.min =3D helpers$1.isFinite(me.min) ? me.min : null;=0D + me.max =3D helpers$1.isFinite(me.max) ? me.max : null;=0D + me.minNotZero =3D helpers$1.isFinite(me.minNotZero) ? me.minNotZero : nu= ll;=0D +=0D + // Common base implementation to handle ticks.min, ticks.max=0D + this.handleTickRangeOptions();=0D + },=0D +=0D + handleTickRangeOptions: function() {=0D + var me =3D this;=0D + var tickOpts =3D me.options.ticks;=0D + var DEFAULT_MIN =3D 1;=0D + var DEFAULT_MAX =3D 10;=0D +=0D + me.min =3D nonNegativeOrDefault(tickOpts.min, me.min);=0D + me.max =3D nonNegativeOrDefault(tickOpts.max, me.max);=0D +=0D + if (me.min =3D=3D=3D me.max) {=0D + if (me.min !=3D=3D 0 && me.min !=3D=3D null) {=0D + me.min =3D Math.pow(10, Math.floor(log10(me.min)) - 1);=0D + me.max =3D Math.pow(10, Math.floor(log10(me.max)) + 1);=0D + } else {=0D + me.min =3D DEFAULT_MIN;=0D + me.max =3D DEFAULT_MAX;=0D + }=0D + }=0D + if (me.min =3D=3D=3D null) {=0D + me.min =3D Math.pow(10, Math.floor(log10(me.max)) - 1);=0D + }=0D + if (me.max =3D=3D=3D null) {=0D + me.max =3D me.min !=3D=3D 0=0D + ? Math.pow(10, Math.floor(log10(me.min)) + 1)=0D + : DEFAULT_MAX;=0D + }=0D + if (me.minNotZero =3D=3D=3D null) {=0D + if (me.min > 0) {=0D + me.minNotZero =3D me.min;=0D + } else if (me.max < 1) {=0D + me.minNotZero =3D Math.pow(10, Math.floor(log10(me.max)));=0D + } else {=0D + me.minNotZero =3D DEFAULT_MIN;=0D + }=0D + }=0D + },=0D +=0D + buildTicks: function() {=0D + var me =3D this;=0D + var tickOpts =3D me.options.ticks;=0D + var reverse =3D !me.isHorizontal();=0D +=0D + var generationOptions =3D {=0D + min: nonNegativeOrDefault(tickOpts.min),=0D + max: nonNegativeOrDefault(tickOpts.max)=0D + };=0D + var ticks =3D me.ticks =3D generateTicks$1(generationOptions, me);=0D +=0D + // At this point, we need to update our max and min given the tick value= s since we have expanded the=0D + // range of the scale=0D + me.max =3D helpers$1.max(ticks);=0D + me.min =3D helpers$1.min(ticks);=0D +=0D + if (tickOpts.reverse) {=0D + reverse =3D !reverse;=0D + me.start =3D me.max;=0D + me.end =3D me.min;=0D + } else {=0D + me.start =3D me.min;=0D + me.end =3D me.max;=0D + }=0D + if (reverse) {=0D + ticks.reverse();=0D + }=0D + },=0D +=0D + convertTicksToLabels: function() {=0D + this.tickValues =3D this.ticks.slice();=0D +=0D + core_scale.prototype.convertTicksToLabels.call(this);=0D + },=0D +=0D + // Get the correct tooltip label=0D + getLabelForIndex: function(index, datasetIndex) {=0D + return this._getScaleLabel(this.chart.data.datasets[datasetIndex].data[i= ndex]);=0D + },=0D +=0D + getPixelForTick: function(index) {=0D + var ticks =3D this.tickValues;=0D + if (index < 0 || index > ticks.length - 1) {=0D + return null;=0D + }=0D + return this.getPixelForValue(ticks[index]);=0D + },=0D +=0D + /**=0D + * Returns the value of the first tick.=0D + * @param {number} value - The minimum not zero value.=0D + * @return {number} The first tick value.=0D + * @private=0D + */=0D + _getFirstTickValue: function(value) {=0D + var exp =3D Math.floor(log10(value));=0D + var significand =3D Math.floor(value / Math.pow(10, exp));=0D +=0D + return significand * Math.pow(10, exp);=0D + },=0D +=0D + _configure: function() {=0D + var me =3D this;=0D + var start =3D me.min;=0D + var offset =3D 0;=0D +=0D + core_scale.prototype._configure.call(me);=0D +=0D + if (start =3D=3D=3D 0) {=0D + start =3D me._getFirstTickValue(me.minNotZero);=0D + offset =3D valueOrDefault$b(me.options.ticks.fontSize, core_defaults.gl= obal.defaultFontSize) / me._length;=0D + }=0D +=0D + me._startValue =3D log10(start);=0D + me._valueOffset =3D offset;=0D + me._valueRange =3D (log10(me.max) - log10(start)) / (1 - offset);=0D + },=0D +=0D + getPixelForValue: function(value) {=0D + var me =3D this;=0D + var decimal =3D 0;=0D +=0D + value =3D +me.getRightValue(value);=0D +=0D + if (value > me.min && value > 0) {=0D + decimal =3D (log10(value) - me._startValue) / me._valueRange + me._valu= eOffset;=0D + }=0D + return me.getPixelForDecimal(decimal);=0D + },=0D +=0D + getValueForPixel: function(pixel) {=0D + var me =3D this;=0D + var decimal =3D me.getDecimalForPixel(pixel);=0D + return decimal =3D=3D=3D 0 && me.min =3D=3D=3D 0=0D + ? 0=0D + : Math.pow(10, me._startValue + (decimal - me._valueOffset) * me._value= Range);=0D + }=0D +});=0D +=0D +// INTERNAL: static default options, registered in src/index.js=0D +var _defaults$2 =3D defaultConfig$2; +scale_logarithmic._defaults =3D _defaults$2; =20 -var plugin_title =3D { - id: 'title', +var valueOrDefault$c =3D helpers$1.valueOrDefault;=0D +var valueAtIndexOrDefault$1 =3D helpers$1.valueAtIndexOrDefault;=0D +var resolve$4 =3D helpers$1.options.resolve;=0D +=0D +var defaultConfig$3 =3D {=0D + display: true,=0D +=0D + // Boolean - Whether to animate scaling the chart from the centre=0D + animate: true,=0D + position: 'chartArea',=0D +=0D + angleLines: {=0D + display: true,=0D + color: 'rgba(0,0,0,0.1)',=0D + lineWidth: 1,=0D + borderDash: [],=0D + borderDashOffset: 0.0=0D + },=0D +=0D + gridLines: {=0D + circular: false=0D + },=0D +=0D + // label settings=0D + ticks: {=0D + // Boolean - Show a backdrop to the scale label=0D + showLabelBackdrop: true,=0D +=0D + // String - The colour of the label backdrop=0D + backdropColor: 'rgba(255,255,255,0.75)',=0D +=0D + // Number - The backdrop padding above & below the label in pixels=0D + backdropPaddingY: 2,=0D +=0D + // Number - The backdrop padding to the side of the label in pixels=0D + backdropPaddingX: 2,=0D +=0D + callback: core_ticks.formatters.linear=0D + },=0D +=0D + pointLabels: {=0D + // Boolean - if true, show point labels=0D + display: true,=0D +=0D + // Number - Point label font size in pixels=0D + fontSize: 10,=0D +=0D + // Function - Used to convert point labels=0D + callback: function(label) {=0D + return label;=0D + }=0D + }=0D +};=0D +=0D +function getTickBackdropHeight(opts) {=0D + var tickOpts =3D opts.ticks;=0D +=0D + if (tickOpts.display && opts.display) {=0D + return valueOrDefault$c(tickOpts.fontSize, core_defaults.global.defaultF= ontSize) + tickOpts.backdropPaddingY * 2;=0D + }=0D + return 0;=0D +}=0D +=0D +function measureLabelSize(ctx, lineHeight, label) {=0D + if (helpers$1.isArray(label)) {=0D + return {=0D + w: helpers$1.longestText(ctx, ctx.font, label),=0D + h: label.length * lineHeight=0D + };=0D + }=0D +=0D + return {=0D + w: ctx.measureText(label).width,=0D + h: lineHeight=0D + };=0D +}=0D +=0D +function determineLimits(angle, pos, size, min, max) {=0D + if (angle =3D=3D=3D min || angle =3D=3D=3D max) {=0D + return {=0D + start: pos - (size / 2),=0D + end: pos + (size / 2)=0D + };=0D + } else if (angle < min || angle > max) {=0D + return {=0D + start: pos - size,=0D + end: pos=0D + };=0D + }=0D +=0D + return {=0D + start: pos,=0D + end: pos + size=0D + };=0D +}=0D +=0D +/**=0D + * Helper function to fit a radial linear scale with point labels=0D + */=0D +function fitWithPointLabels(scale) {=0D +=0D + // Right, this is really confusing and there is a lot of maths going on h= ere=0D + // The gist of the problem is here: https://gist.github.com/nnnick/696cc9= c55f4b0beb8fe9=0D + //=0D + // Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.= gif=0D + //=0D + // Solution:=0D + //=0D + // We assume the radius of the polygon is half the size of the canvas at = first=0D + // at each index we check if the text overlaps.=0D + //=0D + // Where it does, we store that angle and that index.=0D + //=0D + // After finding the largest index and angle we calculate how much we nee= d to remove=0D + // from the shape radius to move the point inwards by that x.=0D + //=0D + // We average the left and right distances to get the maximum shape radiu= s that can fit in the box=0D + // along with labels.=0D + //=0D + // Once we have that, we can find the centre point for the chart, by taki= ng the x text protrusion=0D + // on each side, removing that from the size, halving it and adding the l= eft x protrusion width.=0D + //=0D + // This will mean we have a shape fitted to the canvas, as large as it ca= n be with the labels=0D + // and position it in the most space efficient manner=0D + //=0D + // https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif=0D +=0D + var plFont =3D helpers$1.options._parseFont(scale.options.pointLabels);=0D +=0D + // Get maximum radius of the polygon. Either half the height (minus the t= ext width) or half the width.=0D + // Use this to calculate the offset + change. - Make sure L/R protrusion = is at least 0 to stop issues with centre points=0D + var furthestLimits =3D {=0D + l: 0,=0D + r: scale.width,=0D + t: 0,=0D + b: scale.height - scale.paddingTop=0D + };=0D + var furthestAngles =3D {};=0D + var i, textSize, pointPosition;=0D +=0D + scale.ctx.font =3D plFont.string;=0D + scale._pointLabelSizes =3D [];=0D +=0D + var valueCount =3D scale.chart.data.labels.length;=0D + for (i =3D 0; i < valueCount; i++) {=0D + pointPosition =3D scale.getPointPosition(i, scale.drawingArea + 5);=0D + textSize =3D measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointL= abels[i]);=0D + scale._pointLabelSizes[i] =3D textSize;=0D +=0D + // Add quarter circle to make degree 0 mean top of circle=0D + var angleRadians =3D scale.getIndexAngle(i);=0D + var angle =3D helpers$1.toDegrees(angleRadians) % 360;=0D + var hLimits =3D determineLimits(angle, pointPosition.x, textSize.w, 0, 1= 80);=0D + var vLimits =3D determineLimits(angle, pointPosition.y, textSize.h, 90, = 270);=0D +=0D + if (hLimits.start < furthestLimits.l) {=0D + furthestLimits.l =3D hLimits.start;=0D + furthestAngles.l =3D angleRadians;=0D + }=0D +=0D + if (hLimits.end > furthestLimits.r) {=0D + furthestLimits.r =3D hLimits.end;=0D + furthestAngles.r =3D angleRadians;=0D + }=0D +=0D + if (vLimits.start < furthestLimits.t) {=0D + furthestLimits.t =3D vLimits.start;=0D + furthestAngles.t =3D angleRadians;=0D + }=0D +=0D + if (vLimits.end > furthestLimits.b) {=0D + furthestLimits.b =3D vLimits.end;=0D + furthestAngles.b =3D angleRadians;=0D + }=0D + }=0D +=0D + scale.setReductions(scale.drawingArea, furthestLimits, furthestAngles);=0D +}=0D +=0D +function getTextAlignForAngle(angle) {=0D + if (angle =3D=3D=3D 0 || angle =3D=3D=3D 180) {=0D + return 'center';=0D + } else if (angle < 180) {=0D + return 'left';=0D + }=0D +=0D + return 'right';=0D +}=0D +=0D +function fillText(ctx, text, position, lineHeight) {=0D + var y =3D position.y + lineHeight / 2;=0D + var i, ilen;=0D +=0D + if (helpers$1.isArray(text)) {=0D + for (i =3D 0, ilen =3D text.length; i < ilen; ++i) {=0D + ctx.fillText(text[i], position.x, y);=0D + y +=3D lineHeight;=0D + }=0D + } else {=0D + ctx.fillText(text, position.x, y);=0D + }=0D +}=0D +=0D +function adjustPointPositionForLabelHeight(angle, textSize, position) {=0D + if (angle =3D=3D=3D 90 || angle =3D=3D=3D 270) {=0D + position.y -=3D (textSize.h / 2);=0D + } else if (angle > 270 || angle < 90) {=0D + position.y -=3D textSize.h;=0D + }=0D +}=0D +=0D +function drawPointLabels(scale) {=0D + var ctx =3D scale.ctx;=0D + var opts =3D scale.options;=0D + var pointLabelOpts =3D opts.pointLabels;=0D + var tickBackdropHeight =3D getTickBackdropHeight(opts);=0D + var outerDistance =3D scale.getDistanceFromCenterForValue(opts.ticks.reve= rse ? scale.min : scale.max);=0D + var plFont =3D helpers$1.options._parseFont(pointLabelOpts);=0D +=0D + ctx.save();=0D +=0D + ctx.font =3D plFont.string;=0D + ctx.textBaseline =3D 'middle';=0D +=0D + for (var i =3D scale.chart.data.labels.length - 1; i >=3D 0; i--) {=0D + // Extra pixels out for some label spacing=0D + var extra =3D (i =3D=3D=3D 0 ? tickBackdropHeight / 2 : 0);=0D + var pointLabelPosition =3D scale.getPointPosition(i, outerDistance + ext= ra + 5);=0D +=0D + // Keep this in loop since we may support array properties here=0D + var pointLabelFontColor =3D valueAtIndexOrDefault$1(pointLabelOpts.fontC= olor, i, core_defaults.global.defaultFontColor);=0D + ctx.fillStyle =3D pointLabelFontColor;=0D +=0D + var angleRadians =3D scale.getIndexAngle(i);=0D + var angle =3D helpers$1.toDegrees(angleRadians);=0D + ctx.textAlign =3D getTextAlignForAngle(angle);=0D + adjustPointPositionForLabelHeight(angle, scale._pointLabelSizes[i], poin= tLabelPosition);=0D + fillText(ctx, scale.pointLabels[i], pointLabelPosition, plFont.lineHeigh= t);=0D + }=0D + ctx.restore();=0D +}=0D +=0D +function drawRadiusLine(scale, gridLineOpts, radius, index) {=0D + var ctx =3D scale.ctx;=0D + var circular =3D gridLineOpts.circular;=0D + var valueCount =3D scale.chart.data.labels.length;=0D + var lineColor =3D valueAtIndexOrDefault$1(gridLineOpts.color, index - 1);= =0D + var lineWidth =3D valueAtIndexOrDefault$1(gridLineOpts.lineWidth, index -= 1);=0D + var pointPosition;=0D +=0D + if ((!circular && !valueCount) || !lineColor || !lineWidth) {=0D + return;=0D + }=0D +=0D + ctx.save();=0D + ctx.strokeStyle =3D lineColor;=0D + ctx.lineWidth =3D lineWidth;=0D + if (ctx.setLineDash) {=0D + ctx.setLineDash(gridLineOpts.borderDash || []);=0D + ctx.lineDashOffset =3D gridLineOpts.borderDashOffset || 0.0;=0D + }=0D +=0D + ctx.beginPath();=0D + if (circular) {=0D + // Draw circular arcs between the points=0D + ctx.arc(scale.xCenter, scale.yCenter, radius, 0, Math.PI * 2);=0D + } else {=0D + // Draw straight lines connecting each index=0D + pointPosition =3D scale.getPointPosition(0, radius);=0D + ctx.moveTo(pointPosition.x, pointPosition.y);=0D +=0D + for (var i =3D 1; i < valueCount; i++) {=0D + pointPosition =3D scale.getPointPosition(i, radius);=0D + ctx.lineTo(pointPosition.x, pointPosition.y);=0D + }=0D + }=0D + ctx.closePath();=0D + ctx.stroke();=0D + ctx.restore();=0D +}=0D +=0D +function numberOrZero(param) {=0D + return helpers$1.isNumber(param) ? param : 0;=0D +}=0D +=0D +var scale_radialLinear =3D scale_linearbase.extend({=0D + setDimensions: function() {=0D + var me =3D this;=0D +=0D + // Set the unconstrained dimension before label rotation=0D + me.width =3D me.maxWidth;=0D + me.height =3D me.maxHeight;=0D + me.paddingTop =3D getTickBackdropHeight(me.options) / 2;=0D + me.xCenter =3D Math.floor(me.width / 2);=0D + me.yCenter =3D Math.floor((me.height - me.paddingTop) / 2);=0D + me.drawingArea =3D Math.min(me.height - me.paddingTop, me.width) / 2;=0D + },=0D +=0D + determineDataLimits: function() {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var min =3D Number.POSITIVE_INFINITY;=0D + var max =3D Number.NEGATIVE_INFINITY;=0D +=0D + helpers$1.each(chart.data.datasets, function(dataset, datasetIndex) {=0D + if (chart.isDatasetVisible(datasetIndex)) {=0D + var meta =3D chart.getDatasetMeta(datasetIndex);=0D +=0D + helpers$1.each(dataset.data, function(rawValue, index) {=0D + var value =3D +me.getRightValue(rawValue);=0D + if (isNaN(value) || meta.data[index].hidden) {=0D + return;=0D + }=0D +=0D + min =3D Math.min(value, min);=0D + max =3D Math.max(value, max);=0D + });=0D + }=0D + });=0D +=0D + me.min =3D (min =3D=3D=3D Number.POSITIVE_INFINITY ? 0 : min);=0D + me.max =3D (max =3D=3D=3D Number.NEGATIVE_INFINITY ? 0 : max);=0D +=0D + // Common base implementation to handle ticks.min, ticks.max, ticks.begi= nAtZero=0D + me.handleTickRangeOptions();=0D + },=0D +=0D + // Returns the maximum number of ticks based on the scale dimension=0D + _computeTickLimit: function() {=0D + return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options))= ;=0D + },=0D +=0D + convertTicksToLabels: function() {=0D + var me =3D this;=0D +=0D + scale_linearbase.prototype.convertTicksToLabels.call(me);=0D +=0D + // Point labels=0D + me.pointLabels =3D me.chart.data.labels.map(function() {=0D + var label =3D helpers$1.callback(me.options.pointLabels.callback, argum= ents, me);=0D + return label || label =3D=3D=3D 0 ? label : '';=0D + });=0D + },=0D +=0D + getLabelForIndex: function(index, datasetIndex) {=0D + return +this.getRightValue(this.chart.data.datasets[datasetIndex].data[i= ndex]);=0D + },=0D +=0D + fit: function() {=0D + var me =3D this;=0D + var opts =3D me.options;=0D +=0D + if (opts.display && opts.pointLabels.display) {=0D + fitWithPointLabels(me);=0D + } else {=0D + me.setCenterPoint(0, 0, 0, 0);=0D + }=0D + },=0D +=0D + /**=0D + * Set radius reductions and determine new radius and center point=0D + * @private=0D + */=0D + setReductions: function(largestPossibleRadius, furthestLimits, furthestAn= gles) {=0D + var me =3D this;=0D + var radiusReductionLeft =3D furthestLimits.l / Math.sin(furthestAngles.l= );=0D + var radiusReductionRight =3D Math.max(furthestLimits.r - me.width, 0) / = Math.sin(furthestAngles.r);=0D + var radiusReductionTop =3D -furthestLimits.t / Math.cos(furthestAngles.t= );=0D + var radiusReductionBottom =3D -Math.max(furthestLimits.b - (me.height - = me.paddingTop), 0) / Math.cos(furthestAngles.b);=0D +=0D + radiusReductionLeft =3D numberOrZero(radiusReductionLeft);=0D + radiusReductionRight =3D numberOrZero(radiusReductionRight);=0D + radiusReductionTop =3D numberOrZero(radiusReductionTop);=0D + radiusReductionBottom =3D numberOrZero(radiusReductionBottom);=0D +=0D + me.drawingArea =3D Math.min(=0D + Math.floor(largestPossibleRadius - (radiusReductionLeft + radiusReducti= onRight) / 2),=0D + Math.floor(largestPossibleRadius - (radiusReductionTop + radiusReductio= nBottom) / 2));=0D + me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReduc= tionTop, radiusReductionBottom);=0D + },=0D +=0D + setCenterPoint: function(leftMovement, rightMovement, topMovement, bottom= Movement) {=0D + var me =3D this;=0D + var maxRight =3D me.width - rightMovement - me.drawingArea;=0D + var maxLeft =3D leftMovement + me.drawingArea;=0D + var maxTop =3D topMovement + me.drawingArea;=0D + var maxBottom =3D (me.height - me.paddingTop) - bottomMovement - me.draw= ingArea;=0D +=0D + me.xCenter =3D Math.floor(((maxLeft + maxRight) / 2) + me.left);=0D + me.yCenter =3D Math.floor(((maxTop + maxBottom) / 2) + me.top + me.paddi= ngTop);=0D + },=0D +=0D + getIndexAngle: function(index) {=0D + var chart =3D this.chart;=0D + var angleMultiplier =3D 360 / chart.data.labels.length;=0D + var options =3D chart.options || {};=0D + var startAngle =3D options.startAngle || 0;=0D +=0D + // Start from the top instead of right, so remove a quarter of the circl= e=0D + var angle =3D (index * angleMultiplier + startAngle) % 360;=0D +=0D + return (angle < 0 ? angle + 360 : angle) * Math.PI * 2 / 360;=0D + },=0D +=0D + getDistanceFromCenterForValue: function(value) {=0D + var me =3D this;=0D +=0D + if (helpers$1.isNullOrUndef(value)) {=0D + return NaN;=0D + }=0D +=0D + // Take into account half font size + the yPadding of the top value=0D + var scalingFactor =3D me.drawingArea / (me.max - me.min);=0D + if (me.options.ticks.reverse) {=0D + return (me.max - value) * scalingFactor;=0D + }=0D + return (value - me.min) * scalingFactor;=0D + },=0D +=0D + getPointPosition: function(index, distanceFromCenter) {=0D + var me =3D this;=0D + var thisAngle =3D me.getIndexAngle(index) - (Math.PI / 2);=0D + return {=0D + x: Math.cos(thisAngle) * distanceFromCenter + me.xCenter,=0D + y: Math.sin(thisAngle) * distanceFromCenter + me.yCenter=0D + };=0D + },=0D +=0D + getPointPositionForValue: function(index, value) {=0D + return this.getPointPosition(index, this.getDistanceFromCenterForValue(v= alue));=0D + },=0D +=0D + getBasePosition: function(index) {=0D + var me =3D this;=0D + var min =3D me.min;=0D + var max =3D me.max;=0D +=0D + return me.getPointPositionForValue(index || 0,=0D + me.beginAtZero ? 0 :=0D + min < 0 && max < 0 ? max :=0D + min > 0 && max > 0 ? min :=0D + 0);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _drawGrid: function() {=0D + var me =3D this;=0D + var ctx =3D me.ctx;=0D + var opts =3D me.options;=0D + var gridLineOpts =3D opts.gridLines;=0D + var angleLineOpts =3D opts.angleLines;=0D + var lineWidth =3D valueOrDefault$c(angleLineOpts.lineWidth, gridLineOpts= .lineWidth);=0D + var lineColor =3D valueOrDefault$c(angleLineOpts.color, gridLineOpts.col= or);=0D + var i, offset, position;=0D +=0D + if (opts.pointLabels.display) {=0D + drawPointLabels(me);=0D + }=0D +=0D + if (gridLineOpts.display) {=0D + helpers$1.each(me.ticks, function(label, index) {=0D + if (index !=3D=3D 0) {=0D + offset =3D me.getDistanceFromCenterForValue(me.ticksAsNumbers[index])= ;=0D + drawRadiusLine(me, gridLineOpts, offset, index);=0D + }=0D + });=0D + }=0D +=0D + if (angleLineOpts.display && lineWidth && lineColor) {=0D + ctx.save();=0D + ctx.lineWidth =3D lineWidth;=0D + ctx.strokeStyle =3D lineColor;=0D + if (ctx.setLineDash) {=0D + ctx.setLineDash(resolve$4([angleLineOpts.borderDash, gridLineOpts.bord= erDash, []]));=0D + ctx.lineDashOffset =3D resolve$4([angleLineOpts.borderDashOffset, grid= LineOpts.borderDashOffset, 0.0]);=0D + }=0D +=0D + for (i =3D me.chart.data.labels.length - 1; i >=3D 0; i--) {=0D + offset =3D me.getDistanceFromCenterForValue(opts.ticks.reverse ? me.mi= n : me.max);=0D + position =3D me.getPointPosition(i, offset);=0D + ctx.beginPath();=0D + ctx.moveTo(me.xCenter, me.yCenter);=0D + ctx.lineTo(position.x, position.y);=0D + ctx.stroke();=0D + }=0D +=0D + ctx.restore();=0D + }=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _drawLabels: function() {=0D + var me =3D this;=0D + var ctx =3D me.ctx;=0D + var opts =3D me.options;=0D + var tickOpts =3D opts.ticks;=0D +=0D + if (!tickOpts.display) {=0D + return;=0D + }=0D +=0D + var startAngle =3D me.getIndexAngle(0);=0D + var tickFont =3D helpers$1.options._parseFont(tickOpts);=0D + var tickFontColor =3D valueOrDefault$c(tickOpts.fontColor, core_defaults= .global.defaultFontColor);=0D + var offset, width;=0D +=0D + ctx.save();=0D + ctx.font =3D tickFont.string;=0D + ctx.translate(me.xCenter, me.yCenter);=0D + ctx.rotate(startAngle);=0D + ctx.textAlign =3D 'center';=0D + ctx.textBaseline =3D 'middle';=0D +=0D + helpers$1.each(me.ticks, function(label, index) {=0D + if (index =3D=3D=3D 0 && !tickOpts.reverse) {=0D + return;=0D + }=0D +=0D + offset =3D me.getDistanceFromCenterForValue(me.ticksAsNumbers[index]);= =0D +=0D + if (tickOpts.showLabelBackdrop) {=0D + width =3D ctx.measureText(label).width;=0D + ctx.fillStyle =3D tickOpts.backdropColor;=0D +=0D + ctx.fillRect(=0D + -width / 2 - tickOpts.backdropPaddingX,=0D + -offset - tickFont.size / 2 - tickOpts.backdropPaddingY,=0D + width + tickOpts.backdropPaddingX * 2,=0D + tickFont.size + tickOpts.backdropPaddingY * 2=0D + );=0D + }=0D +=0D + ctx.fillStyle =3D tickFontColor;=0D + ctx.fillText(label, 0, -offset);=0D + });=0D +=0D + ctx.restore();=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _drawTitle: helpers$1.noop=0D +});=0D +=0D +// INTERNAL: static default options, registered in src/index.js=0D +var _defaults$3 =3D defaultConfig$3; +scale_radialLinear._defaults =3D _defaults$3; =20 - /** - * Backward compatibility: since 2.1.5, the title is registered as a plug= in, making - * Chart.Title obsolete. To avoid a breaking change, we export the Title = as part of - * the plugin, which one will be re-exposed in the chart.js file. - * https://github.com/chartjs/Chart.js/pull/2640 - * @private - */ - _element: Title, +var deprecated$1 =3D helpers$1._deprecated;=0D +var resolve$5 =3D helpers$1.options.resolve;=0D +var valueOrDefault$d =3D helpers$1.valueOrDefault;=0D +=0D +// Integer constants are from the ES6 spec.=0D +var MIN_INTEGER =3D Number.MIN_SAFE_INTEGER || -9007199254740991;=0D +var MAX_INTEGER =3D Number.MAX_SAFE_INTEGER || 9007199254740991;=0D +=0D +var INTERVALS =3D {=0D + millisecond: {=0D + common: true,=0D + size: 1,=0D + steps: 1000=0D + },=0D + second: {=0D + common: true,=0D + size: 1000,=0D + steps: 60=0D + },=0D + minute: {=0D + common: true,=0D + size: 60000,=0D + steps: 60=0D + },=0D + hour: {=0D + common: true,=0D + size: 3600000,=0D + steps: 24=0D + },=0D + day: {=0D + common: true,=0D + size: 86400000,=0D + steps: 30=0D + },=0D + week: {=0D + common: false,=0D + size: 604800000,=0D + steps: 4=0D + },=0D + month: {=0D + common: true,=0D + size: 2.628e9,=0D + steps: 12=0D + },=0D + quarter: {=0D + common: false,=0D + size: 7.884e9,=0D + steps: 4=0D + },=0D + year: {=0D + common: true,=0D + size: 3.154e10=0D + }=0D +};=0D +=0D +var UNITS =3D Object.keys(INTERVALS);=0D +=0D +function sorter(a, b) {=0D + return a - b;=0D +}=0D +=0D +function arrayUnique(items) {=0D + var hash =3D {};=0D + var out =3D [];=0D + var i, ilen, item;=0D +=0D + for (i =3D 0, ilen =3D items.length; i < ilen; ++i) {=0D + item =3D items[i];=0D + if (!hash[item]) {=0D + hash[item] =3D true;=0D + out.push(item);=0D + }=0D + }=0D +=0D + return out;=0D +}=0D +=0D +function getMin(options) {=0D + return helpers$1.valueOrDefault(options.time.min, options.ticks.min);=0D +}=0D +=0D +function getMax(options) {=0D + return helpers$1.valueOrDefault(options.time.max, options.ticks.max);=0D +}=0D +=0D +/**=0D + * Returns an array of {time, pos} objects used to interpolate a specific = `time` or position=0D + * (`pos`) on the scale, by searching entries before and after the request= ed value. `pos` is=0D + * a decimal between 0 and 1: 0 being the start of the scale (left or top)= and 1 the other=0D + * extremity (left + width or top + height). Note that it would be more op= timized to directly=0D + * store pre-computed pixels, but the scale dimensions are not guaranteed = at the time we need=0D + * to create the lookup table. The table ALWAYS contains at least two item= s: min and max.=0D + *=0D + * @param {number[]} timestamps - timestamps sorted from lowest to highest= .=0D + * @param {string} distribution - If 'linear', timestamps will be spread l= inearly along the min=0D + * and max range, so basically, the table will contains only two items: {m= in, 0} and {max, 1}.=0D + * If 'series', timestamps will be positioned at the same distance from ea= ch other. In this=0D + * case, only timestamps that break the time linearity are registered, mea= ning that in the=0D + * best case, all timestamps are linear, the table contains only min and m= ax.=0D + */=0D +function buildLookupTable(timestamps, min, max, distribution) {=0D + if (distribution =3D=3D=3D 'linear' || !timestamps.length) {=0D + return [=0D + {time: min, pos: 0},=0D + {time: max, pos: 1}=0D + ];=0D + }=0D +=0D + var table =3D [];=0D + var items =3D [min];=0D + var i, ilen, prev, curr, next;=0D +=0D + for (i =3D 0, ilen =3D timestamps.length; i < ilen; ++i) {=0D + curr =3D timestamps[i];=0D + if (curr > min && curr < max) {=0D + items.push(curr);=0D + }=0D + }=0D +=0D + items.push(max);=0D +=0D + for (i =3D 0, ilen =3D items.length; i < ilen; ++i) {=0D + next =3D items[i + 1];=0D + prev =3D items[i - 1];=0D + curr =3D items[i];=0D +=0D + // only add points that breaks the scale linearity=0D + if (prev =3D=3D=3D undefined || next =3D=3D=3D undefined || Math.round((= next + prev) / 2) !=3D=3D curr) {=0D + table.push({time: curr, pos: i / (ilen - 1)});=0D + }=0D + }=0D +=0D + return table;=0D +}=0D +=0D +// @see adapted from https://www.anujgakhar.com/2014/03/01/binary-search-i= n-javascript/=0D +function lookup(table, key, value) {=0D + var lo =3D 0;=0D + var hi =3D table.length - 1;=0D + var mid, i0, i1;=0D +=0D + while (lo >=3D 0 && lo <=3D hi) {=0D + mid =3D (lo + hi) >> 1;=0D + i0 =3D table[mid - 1] || null;=0D + i1 =3D table[mid];=0D +=0D + if (!i0) {=0D + // given value is outside table (before first item)=0D + return {lo: null, hi: i1};=0D + } else if (i1[key] < value) {=0D + lo =3D mid + 1;=0D + } else if (i0[key] > value) {=0D + hi =3D mid - 1;=0D + } else {=0D + return {lo: i0, hi: i1};=0D + }=0D + }=0D +=0D + // given value is outside table (after last item)=0D + return {lo: i1, hi: null};=0D +}=0D +=0D +/**=0D + * Linearly interpolates the given source `value` using the table items `s= key` values and=0D + * returns the associated `tkey` value. For example, interpolate(table, 't= ime', 42, 'pos')=0D + * returns the position for a timestamp equal to 42. If value is out of bo= unds, values at=0D + * index [0, 1] or [n - 1, n] are used for the interpolation.=0D + */=0D +function interpolate$1(table, skey, sval, tkey) {=0D + var range =3D lookup(table, skey, sval);=0D +=0D + // Note: the lookup table ALWAYS contains at least 2 items (min and max)= =0D + var prev =3D !range.lo ? table[0] : !range.hi ? table[table.length - 2] := range.lo;=0D + var next =3D !range.lo ? table[1] : !range.hi ? table[table.length - 1] := range.hi;=0D +=0D + var span =3D next[skey] - prev[skey];=0D + var ratio =3D span ? (sval - prev[skey]) / span : 0;=0D + var offset =3D (next[tkey] - prev[tkey]) * ratio;=0D +=0D + return prev[tkey] + offset;=0D +}=0D +=0D +function toTimestamp(scale, input) {=0D + var adapter =3D scale._adapter;=0D + var options =3D scale.options.time;=0D + var parser =3D options.parser;=0D + var format =3D parser || options.format;=0D + var value =3D input;=0D +=0D + if (typeof parser =3D=3D=3D 'function') {=0D + value =3D parser(value);=0D + }=0D +=0D + // Only parse if its not a timestamp already=0D + if (!helpers$1.isFinite(value)) {=0D + value =3D typeof format =3D=3D=3D 'string'=0D + ? adapter.parse(value, format)=0D + : adapter.parse(value);=0D + }=0D +=0D + if (value !=3D=3D null) {=0D + return +value;=0D + }=0D +=0D + // Labels are in an incompatible format and no `parser` has been provided= .=0D + // The user might still use the deprecated `format` option for parsing.=0D + if (!parser && typeof format =3D=3D=3D 'function') {=0D + value =3D format(input);=0D +=0D + // `format` could return something else than a timestamp, if so, parse i= t=0D + if (!helpers$1.isFinite(value)) {=0D + value =3D adapter.parse(value);=0D + }=0D + }=0D +=0D + return value;=0D +}=0D +=0D +function parse(scale, input) {=0D + if (helpers$1.isNullOrUndef(input)) {=0D + return null;=0D + }=0D +=0D + var options =3D scale.options.time;=0D + var value =3D toTimestamp(scale, scale.getRightValue(input));=0D + if (value =3D=3D=3D null) {=0D + return value;=0D + }=0D +=0D + if (options.round) {=0D + value =3D +scale._adapter.startOf(value, options.round);=0D + }=0D +=0D + return value;=0D +}=0D +=0D +/**=0D + * Figures out what unit results in an appropriate number of auto-generate= d ticks=0D + */=0D +function determineUnitForAutoTicks(minUnit, min, max, capacity) {=0D + var ilen =3D UNITS.length;=0D + var i, interval, factor;=0D +=0D + for (i =3D UNITS.indexOf(minUnit); i < ilen - 1; ++i) {=0D + interval =3D INTERVALS[UNITS[i]];=0D + factor =3D interval.steps ? interval.steps : MAX_INTEGER;=0D +=0D + if (interval.common && Math.ceil((max - min) / (factor * interval.size))= <=3D capacity) {=0D + return UNITS[i];=0D + }=0D + }=0D +=0D + return UNITS[ilen - 1];=0D +}=0D +=0D +/**=0D + * Figures out what unit to format a set of ticks with=0D + */=0D +function determineUnitForFormatting(scale, numTicks, minUnit, min, max) {= =0D + var i, unit;=0D +=0D + for (i =3D UNITS.length - 1; i >=3D UNITS.indexOf(minUnit); i--) {=0D + unit =3D UNITS[i];=0D + if (INTERVALS[unit].common && scale._adapter.diff(max, min, unit) >=3D n= umTicks - 1) {=0D + return unit;=0D + }=0D + }=0D +=0D + return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0];=0D +}=0D +=0D +function determineMajorUnit(unit) {=0D + for (var i =3D UNITS.indexOf(unit) + 1, ilen =3D UNITS.length; i < ilen; = ++i) {=0D + if (INTERVALS[UNITS[i]].common) {=0D + return UNITS[i];=0D + }=0D + }=0D +}=0D +=0D +/**=0D + * Generates a maximum of `capacity` timestamps between min and max, round= ed to the=0D + * `minor` unit using the given scale time `options`.=0D + * Important: this method can return ticks outside the min and max range, = it's the=0D + * responsibility of the calling code to clamp values if needed.=0D + */=0D +function generate(scale, min, max, capacity) {=0D + var adapter =3D scale._adapter;=0D + var options =3D scale.options;=0D + var timeOpts =3D options.time;=0D + var minor =3D timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit= , min, max, capacity);=0D + var stepSize =3D resolve$5([timeOpts.stepSize, timeOpts.unitStepSize, 1])= ;=0D + var weekday =3D minor =3D=3D=3D 'week' ? timeOpts.isoWeekday : false;=0D + var first =3D min;=0D + var ticks =3D [];=0D + var time;=0D +=0D + // For 'week' unit, handle the first day of week option=0D + if (weekday) {=0D + first =3D +adapter.startOf(first, 'isoWeek', weekday);=0D + }=0D +=0D + // Align first ticks on unit=0D + first =3D +adapter.startOf(first, weekday ? 'day' : minor);=0D +=0D + // Prevent browser from freezing in case user options request millions of= milliseconds=0D + if (adapter.diff(max, min, minor) > 100000 * stepSize) {=0D + throw min + ' and ' + max + ' are too far apart with stepSize of ' + ste= pSize + ' ' + minor;=0D + }=0D +=0D + for (time =3D first; time < max; time =3D +adapter.add(time, stepSize, mi= nor)) {=0D + ticks.push(time);=0D + }=0D +=0D + if (time =3D=3D=3D max || options.bounds =3D=3D=3D 'ticks') {=0D + ticks.push(time);=0D + }=0D +=0D + return ticks;=0D +}=0D +=0D +/**=0D + * Returns the start and end offsets from edges in the form of {start, end= }=0D + * where each value is a relative width to the scale and ranges between 0 = and 1.=0D + * They add extra margins on the both sides by scaling down the original s= cale.=0D + * Offsets are added when the `offset` option is true.=0D + */=0D +function computeOffsets(table, ticks, min, max, options) {=0D + var start =3D 0;=0D + var end =3D 0;=0D + var first, last;=0D +=0D + if (options.offset && ticks.length) {=0D + first =3D interpolate$1(table, 'time', ticks[0], 'pos');=0D + if (ticks.length =3D=3D=3D 1) {=0D + start =3D 1 - first;=0D + } else {=0D + start =3D (interpolate$1(table, 'time', ticks[1], 'pos') - first) / 2;= =0D + }=0D + last =3D interpolate$1(table, 'time', ticks[ticks.length - 1], 'pos');=0D + if (ticks.length =3D=3D=3D 1) {=0D + end =3D last;=0D + } else {=0D + end =3D (last - interpolate$1(table, 'time', ticks[ticks.length - 2], '= pos')) / 2;=0D + }=0D + }=0D +=0D + return {start: start, end: end, factor: 1 / (start + 1 + end)};=0D +}=0D +=0D +function setMajorTicks(scale, ticks, map, majorUnit) {=0D + var adapter =3D scale._adapter;=0D + var first =3D +adapter.startOf(ticks[0].value, majorUnit);=0D + var last =3D ticks[ticks.length - 1].value;=0D + var major, index;=0D +=0D + for (major =3D first; major <=3D last; major =3D +adapter.add(major, 1, m= ajorUnit)) {=0D + index =3D map[major];=0D + if (index >=3D 0) {=0D + ticks[index].major =3D true;=0D + }=0D + }=0D + return ticks;=0D +}=0D +=0D +function ticksFromTimestamps(scale, values, majorUnit) {=0D + var ticks =3D [];=0D + var map =3D {};=0D + var ilen =3D values.length;=0D + var i, value;=0D +=0D + for (i =3D 0; i < ilen; ++i) {=0D + value =3D values[i];=0D + map[value] =3D i;=0D +=0D + ticks.push({=0D + value: value,=0D + major: false=0D + });=0D + }=0D +=0D + // We set the major ticks separately from the above loop because calling = startOf for every tick=0D + // is expensive when there is a large number of ticks=0D + return (ilen =3D=3D=3D 0 || !majorUnit) ? ticks : setMajorTicks(scale, ti= cks, map, majorUnit);=0D +}=0D +=0D +var defaultConfig$4 =3D {=0D + position: 'bottom',=0D +=0D + /**=0D + * Data distribution along the scale:=0D + * - 'linear': data are spread according to their time (distances can var= y),=0D + * - 'series': data are spread at the same distance from each other.=0D + * @see https://github.com/chartjs/Chart.js/pull/4507=0D + * @since 2.7.0=0D + */=0D + distribution: 'linear',=0D +=0D + /**=0D + * Scale boundary strategy (bypassed by min/max time options)=0D + * - `data`: make sure data are fully visible, ticks outside are removed= =0D + * - `ticks`: make sure ticks are fully visible, data outside are truncat= ed=0D + * @see https://github.com/chartjs/Chart.js/pull/4556=0D + * @since 2.7.0=0D + */=0D + bounds: 'data',=0D +=0D + adapters: {},=0D + time: {=0D + parser: false, // false =3D=3D a pattern string from https://momentjs.co= m/docs/#/parsing/string-format/ or a custom callback that converts its argu= ment to a moment=0D + unit: false, // false =3D=3D automatic or override with week, month, yea= r, etc.=0D + round: false, // none, or override with week, month, year, etc.=0D + displayFormat: false, // DEPRECATED=0D + isoWeekday: false, // override week start day - see https://momentjs.com= /docs/#/get-set/iso-weekday/=0D + minUnit: 'millisecond',=0D + displayFormats: {}=0D + },=0D + ticks: {=0D + autoSkip: false,=0D +=0D + /**=0D + * Ticks generation input values:=0D + * - 'auto': generates "optimal" ticks based on scale size and time opti= ons.=0D + * - 'data': generates ticks from data (including labels from data {t|x|= y} objects).=0D + * - 'labels': generates ticks from user given `data.labels` values ONLY= .=0D + * @see https://github.com/chartjs/Chart.js/pull/4507=0D + * @since 2.7.0=0D + */=0D + source: 'auto',=0D +=0D + major: {=0D + enabled: false=0D + }=0D + }=0D +};=0D +=0D +var scale_time =3D core_scale.extend({=0D + initialize: function() {=0D + this.mergeTicksOptions();=0D + core_scale.prototype.initialize.call(this);=0D + },=0D +=0D + update: function() {=0D + var me =3D this;=0D + var options =3D me.options;=0D + var time =3D options.time || (options.time =3D {});=0D + var adapter =3D me._adapter =3D new core_adapters._date(options.adapters= .date);=0D +=0D + // DEPRECATIONS: output a message only one time per update=0D + deprecated$1('time scale', time.format, 'time.format', 'time.parser');=0D + deprecated$1('time scale', time.min, 'time.min', 'ticks.min');=0D + deprecated$1('time scale', time.max, 'time.max', 'ticks.max');=0D +=0D + // Backward compatibility: before introducing adapter, `displayFormats` = was=0D + // supposed to contain *all* unit/string pairs but this can't be resolve= d=0D + // when loading the scale (adapters are loaded afterward), so let's popu= late=0D + // missing formats on update=0D + helpers$1.mergeIf(time.displayFormats, adapter.formats());=0D +=0D + return core_scale.prototype.update.apply(me, arguments);=0D + },=0D +=0D + /**=0D + * Allows data to be referenced via 't' attribute=0D + */=0D + getRightValue: function(rawValue) {=0D + if (rawValue && rawValue.t !=3D=3D undefined) {=0D + rawValue =3D rawValue.t;=0D + }=0D + return core_scale.prototype.getRightValue.call(this, rawValue);=0D + },=0D +=0D + determineDataLimits: function() {=0D + var me =3D this;=0D + var chart =3D me.chart;=0D + var adapter =3D me._adapter;=0D + var options =3D me.options;=0D + var unit =3D options.time.unit || 'day';=0D + var min =3D MAX_INTEGER;=0D + var max =3D MIN_INTEGER;=0D + var timestamps =3D [];=0D + var datasets =3D [];=0D + var labels =3D [];=0D + var i, j, ilen, jlen, data, timestamp, labelsAdded;=0D + var dataLabels =3D me._getLabels();=0D +=0D + for (i =3D 0, ilen =3D dataLabels.length; i < ilen; ++i) {=0D + labels.push(parse(me, dataLabels[i]));=0D + }=0D +=0D + for (i =3D 0, ilen =3D (chart.data.datasets || []).length; i < ilen; ++i= ) {=0D + if (chart.isDatasetVisible(i)) {=0D + data =3D chart.data.datasets[i].data;=0D +=0D + // Let's consider that all data have the same format.=0D + if (helpers$1.isObject(data[0])) {=0D + datasets[i] =3D [];=0D +=0D + for (j =3D 0, jlen =3D data.length; j < jlen; ++j) {=0D + timestamp =3D parse(me, data[j]);=0D + timestamps.push(timestamp);=0D + datasets[i][j] =3D timestamp;=0D + }=0D + } else {=0D + datasets[i] =3D labels.slice(0);=0D + if (!labelsAdded) {=0D + timestamps =3D timestamps.concat(labels);=0D + labelsAdded =3D true;=0D + }=0D + }=0D + } else {=0D + datasets[i] =3D [];=0D + }=0D + }=0D +=0D + if (labels.length) {=0D + min =3D Math.min(min, labels[0]);=0D + max =3D Math.max(max, labels[labels.length - 1]);=0D + }=0D +=0D + if (timestamps.length) {=0D + timestamps =3D ilen > 1 ? arrayUnique(timestamps).sort(sorter) : timest= amps.sort(sorter);=0D + min =3D Math.min(min, timestamps[0]);=0D + max =3D Math.max(max, timestamps[timestamps.length - 1]);=0D + }=0D +=0D + min =3D parse(me, getMin(options)) || min;=0D + max =3D parse(me, getMax(options)) || max;=0D +=0D + // In case there is no valid min/max, set limits based on unit time opti= on=0D + min =3D min =3D=3D=3D MAX_INTEGER ? +adapter.startOf(Date.now(), unit) := min;=0D + max =3D max =3D=3D=3D MIN_INTEGER ? +adapter.endOf(Date.now(), unit) + 1= : max;=0D +=0D + // Make sure that max is strictly higher than min (required by the looku= p table)=0D + me.min =3D Math.min(min, max);=0D + me.max =3D Math.max(min + 1, max);=0D +=0D + // PRIVATE=0D + me._table =3D [];=0D + me._timestamps =3D {=0D + data: timestamps,=0D + datasets: datasets,=0D + labels: labels=0D + };=0D + },=0D +=0D + buildTicks: function() {=0D + var me =3D this;=0D + var min =3D me.min;=0D + var max =3D me.max;=0D + var options =3D me.options;=0D + var tickOpts =3D options.ticks;=0D + var timeOpts =3D options.time;=0D + var timestamps =3D me._timestamps;=0D + var ticks =3D [];=0D + var capacity =3D me.getLabelCapacity(min);=0D + var source =3D tickOpts.source;=0D + var distribution =3D options.distribution;=0D + var i, ilen, timestamp;=0D +=0D + if (source =3D=3D=3D 'data' || (source =3D=3D=3D 'auto' && distribution = =3D=3D=3D 'series')) {=0D + timestamps =3D timestamps.data;=0D + } else if (source =3D=3D=3D 'labels') {=0D + timestamps =3D timestamps.labels;=0D + } else {=0D + timestamps =3D generate(me, min, max, capacity);=0D + }=0D +=0D + if (options.bounds =3D=3D=3D 'ticks' && timestamps.length) {=0D + min =3D timestamps[0];=0D + max =3D timestamps[timestamps.length - 1];=0D + }=0D +=0D + // Enforce limits with user min/max options=0D + min =3D parse(me, getMin(options)) || min;=0D + max =3D parse(me, getMax(options)) || max;=0D +=0D + // Remove ticks outside the min/max range=0D + for (i =3D 0, ilen =3D timestamps.length; i < ilen; ++i) {=0D + timestamp =3D timestamps[i];=0D + if (timestamp >=3D min && timestamp <=3D max) {=0D + ticks.push(timestamp);=0D + }=0D + }=0D +=0D + me.min =3D min;=0D + me.max =3D max;=0D +=0D + // PRIVATE=0D + // determineUnitForFormatting relies on the number of ticks so we don't = use it when=0D + // autoSkip is enabled because we don't yet know what the final number o= f ticks will be=0D + me._unit =3D timeOpts.unit || (tickOpts.autoSkip=0D + ? determineUnitForAutoTicks(timeOpts.minUnit, me.min, me.max, capacity)= =0D + : determineUnitForFormatting(me, ticks.length, timeOpts.minUnit, me.min= , me.max));=0D + me._majorUnit =3D !tickOpts.major.enabled || me._unit =3D=3D=3D 'year' ?= undefined=0D + : determineMajorUnit(me._unit);=0D + me._table =3D buildLookupTable(me._timestamps.data, min, max, distributi= on);=0D + me._offsets =3D computeOffsets(me._table, ticks, min, max, options);=0D +=0D + if (tickOpts.reverse) {=0D + ticks.reverse();=0D + }=0D +=0D + return ticksFromTimestamps(me, ticks, me._majorUnit);=0D + },=0D +=0D + getLabelForIndex: function(index, datasetIndex) {=0D + var me =3D this;=0D + var adapter =3D me._adapter;=0D + var data =3D me.chart.data;=0D + var timeOpts =3D me.options.time;=0D + var label =3D data.labels && index < data.labels.length ? data.labels[in= dex] : '';=0D + var value =3D data.datasets[datasetIndex].data[index];=0D +=0D + if (helpers$1.isObject(value)) {=0D + label =3D me.getRightValue(value);=0D + }=0D + if (timeOpts.tooltipFormat) {=0D + return adapter.format(toTimestamp(me, label), timeOpts.tooltipFormat);= =0D + }=0D + if (typeof label =3D=3D=3D 'string') {=0D + return label;=0D + }=0D + return adapter.format(toTimestamp(me, label), timeOpts.displayFormats.da= tetime);=0D + },=0D +=0D + /**=0D + * Function to format an individual tick mark=0D + * @private=0D + */=0D + tickFormatFunction: function(time, index, ticks, format) {=0D + var me =3D this;=0D + var adapter =3D me._adapter;=0D + var options =3D me.options;=0D + var formats =3D options.time.displayFormats;=0D + var minorFormat =3D formats[me._unit];=0D + var majorUnit =3D me._majorUnit;=0D + var majorFormat =3D formats[majorUnit];=0D + var tick =3D ticks[index];=0D + var tickOpts =3D options.ticks;=0D + var major =3D majorUnit && majorFormat && tick && tick.major;=0D + var label =3D adapter.format(time, format ? format : major ? majorFormat= : minorFormat);=0D + var nestedTickOpts =3D major ? tickOpts.major : tickOpts.minor;=0D + var formatter =3D resolve$5([=0D + nestedTickOpts.callback,=0D + nestedTickOpts.userCallback,=0D + tickOpts.callback,=0D + tickOpts.userCallback=0D + ]);=0D +=0D + return formatter ? formatter(label, index, ticks) : label;=0D + },=0D +=0D + convertTicksToLabels: function(ticks) {=0D + var labels =3D [];=0D + var i, ilen;=0D +=0D + for (i =3D 0, ilen =3D ticks.length; i < ilen; ++i) {=0D + labels.push(this.tickFormatFunction(ticks[i].value, i, ticks));=0D + }=0D +=0D + return labels;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + getPixelForOffset: function(time) {=0D + var me =3D this;=0D + var offsets =3D me._offsets;=0D + var pos =3D interpolate$1(me._table, 'time', time, 'pos');=0D + return me.getPixelForDecimal((offsets.start + pos) * offsets.factor);=0D + },=0D +=0D + getPixelForValue: function(value, index, datasetIndex) {=0D + var me =3D this;=0D + var time =3D null;=0D +=0D + if (index !=3D=3D undefined && datasetIndex !=3D=3D undefined) {=0D + time =3D me._timestamps.datasets[datasetIndex][index];=0D + }=0D +=0D + if (time =3D=3D=3D null) {=0D + time =3D parse(me, value);=0D + }=0D +=0D + if (time !=3D=3D null) {=0D + return me.getPixelForOffset(time);=0D + }=0D + },=0D +=0D + getPixelForTick: function(index) {=0D + var ticks =3D this.getTicks();=0D + return index >=3D 0 && index < ticks.length ?=0D + this.getPixelForOffset(ticks[index].value) :=0D + null;=0D + },=0D +=0D + getValueForPixel: function(pixel) {=0D + var me =3D this;=0D + var offsets =3D me._offsets;=0D + var pos =3D me.getDecimalForPixel(pixel) / offsets.factor - offsets.end;= =0D + var time =3D interpolate$1(me._table, 'pos', pos, 'time');=0D +=0D + // DEPRECATION, we should return time directly=0D + return me._adapter._create(time);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getLabelSize: function(label) {=0D + var me =3D this;=0D + var ticksOpts =3D me.options.ticks;=0D + var tickLabelWidth =3D me.ctx.measureText(label).width;=0D + var angle =3D helpers$1.toRadians(me.isHorizontal() ? ticksOpts.maxRotat= ion : ticksOpts.minRotation);=0D + var cosRotation =3D Math.cos(angle);=0D + var sinRotation =3D Math.sin(angle);=0D + var tickFontSize =3D valueOrDefault$d(ticksOpts.fontSize, core_defaults.= global.defaultFontSize);=0D +=0D + return {=0D + w: (tickLabelWidth * cosRotation) + (tickFontSize * sinRotation),=0D + h: (tickLabelWidth * sinRotation) + (tickFontSize * cosRotation)=0D + };=0D + },=0D +=0D + /**=0D + * Crude approximation of what the label width might be=0D + * @private=0D + */=0D + getLabelWidth: function(label) {=0D + return this._getLabelSize(label).w;=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + getLabelCapacity: function(exampleTime) {=0D + var me =3D this;=0D + var timeOpts =3D me.options.time;=0D + var displayFormats =3D timeOpts.displayFormats;=0D +=0D + // pick the longest format (milliseconds) for guestimation=0D + var format =3D displayFormats[timeOpts.unit] || displayFormats.milliseco= nd;=0D + var exampleLabel =3D me.tickFormatFunction(exampleTime, 0, ticksFromTime= stamps(me, [exampleTime], me._majorUnit), format);=0D + var size =3D me._getLabelSize(exampleLabel);=0D + var capacity =3D Math.floor(me.isHorizontal() ? me.width / size.w : me.h= eight / size.h);=0D +=0D + if (me.options.offset) {=0D + capacity--;=0D + }=0D +=0D + return capacity > 0 ? capacity : 1;=0D + }=0D +});=0D +=0D +// INTERNAL: static default options, registered in src/index.js=0D +var _defaults$4 =3D defaultConfig$4; +scale_time._defaults =3D _defaults$4; =20 - beforeInit: function(chart) { - var titleOpts =3D chart.options.title; +var scales =3D {=0D + category: scale_category,=0D + linear: scale_linear,=0D + logarithmic: scale_logarithmic,=0D + radialLinear: scale_radialLinear,=0D + time: scale_time=0D +}; =20 - if (titleOpts) { - createNewTitleBlockAndAttach(chart, titleOpts); - } - }, +var FORMATS =3D {=0D + datetime: 'MMM D, YYYY, h:mm:ss a',=0D + millisecond: 'h:mm:ss.SSS a',=0D + second: 'h:mm:ss a',=0D + minute: 'h:mm a',=0D + hour: 'hA',=0D + day: 'MMM D',=0D + week: 'll',=0D + month: 'MMM YYYY',=0D + quarter: '[Q]Q - YYYY',=0D + year: 'YYYY'=0D +};=0D +=0D +core_adapters._date.override(typeof moment =3D=3D=3D 'function' ? {=0D + _id: 'moment', // DEBUG ONLY=0D +=0D + formats: function() {=0D + return FORMATS;=0D + },=0D +=0D + parse: function(value, format) {=0D + if (typeof value =3D=3D=3D 'string' && typeof format =3D=3D=3D 'string')= {=0D + value =3D moment(value, format);=0D + } else if (!(value instanceof moment)) {=0D + value =3D moment(value);=0D + }=0D + return value.isValid() ? value.valueOf() : null;=0D + },=0D +=0D + format: function(time, format) {=0D + return moment(time).format(format);=0D + },=0D +=0D + add: function(time, amount, unit) {=0D + return moment(time).add(amount, unit).valueOf();=0D + },=0D +=0D + diff: function(max, min, unit) {=0D + return moment(max).diff(moment(min), unit);=0D + },=0D +=0D + startOf: function(time, unit, weekday) {=0D + time =3D moment(time);=0D + if (unit =3D=3D=3D 'isoWeek') {=0D + return time.isoWeekday(weekday).valueOf();=0D + }=0D + return time.startOf(unit).valueOf();=0D + },=0D +=0D + endOf: function(time, unit) {=0D + return moment(time).endOf(unit).valueOf();=0D + },=0D +=0D + // DEPRECATIONS=0D +=0D + /**=0D + * Provided for backward compatibility with scale.getValueForPixel().=0D + * @deprecated since version 2.8.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D + _create: function(time) {=0D + return moment(time);=0D + },=0D +} : {}); =20 - beforeUpdate: function(chart) { - var titleOpts =3D chart.options.title; - var titleBlock =3D chart.titleBlock; +core_defaults._set('global', {=0D + plugins: {=0D + filler: {=0D + propagate: true=0D + }=0D + }=0D +});=0D +=0D +var mappers =3D {=0D + dataset: function(source) {=0D + var index =3D source.fill;=0D + var chart =3D source.chart;=0D + var meta =3D chart.getDatasetMeta(index);=0D + var visible =3D meta && chart.isDatasetVisible(index);=0D + var points =3D (visible && meta.dataset._children) || [];=0D + var length =3D points.length || 0;=0D +=0D + return !length ? null : function(point, i) {=0D + return (i < length && points[i]._view) || null;=0D + };=0D + },=0D +=0D + boundary: function(source) {=0D + var boundary =3D source.boundary;=0D + var x =3D boundary ? boundary.x : null;=0D + var y =3D boundary ? boundary.y : null;=0D +=0D + if (helpers$1.isArray(boundary)) {=0D + return function(point, i) {=0D + return boundary[i];=0D + };=0D + }=0D +=0D + return function(point) {=0D + return {=0D + x: x =3D=3D=3D null ? point.x : x,=0D + y: y =3D=3D=3D null ? point.y : y,=0D + };=0D + };=0D + }=0D +};=0D +=0D +// @todo if (fill[0] =3D=3D=3D '#')=0D +function decodeFill(el, index, count) {=0D + var model =3D el._model || {};=0D + var fill =3D model.fill;=0D + var target;=0D +=0D + if (fill =3D=3D=3D undefined) {=0D + fill =3D !!model.backgroundColor;=0D + }=0D +=0D + if (fill =3D=3D=3D false || fill =3D=3D=3D null) {=0D + return false;=0D + }=0D +=0D + if (fill =3D=3D=3D true) {=0D + return 'origin';=0D + }=0D +=0D + target =3D parseFloat(fill, 10);=0D + if (isFinite(target) && Math.floor(target) =3D=3D=3D target) {=0D + if (fill[0] =3D=3D=3D '-' || fill[0] =3D=3D=3D '+') {=0D + target =3D index + target;=0D + }=0D +=0D + if (target =3D=3D=3D index || target < 0 || target >=3D count) {=0D + return false;=0D + }=0D +=0D + return target;=0D + }=0D +=0D + switch (fill) {=0D + // compatibility=0D + case 'bottom':=0D + return 'start';=0D + case 'top':=0D + return 'end';=0D + case 'zero':=0D + return 'origin';=0D + // supported boundaries=0D + case 'origin':=0D + case 'start':=0D + case 'end':=0D + return fill;=0D + // invalid fill values=0D + default:=0D + return false;=0D + }=0D +}=0D +=0D +function computeLinearBoundary(source) {=0D + var model =3D source.el._model || {};=0D + var scale =3D source.el._scale || {};=0D + var fill =3D source.fill;=0D + var target =3D null;=0D + var horizontal;=0D +=0D + if (isFinite(fill)) {=0D + return null;=0D + }=0D +=0D + // Backward compatibility: until v3, we still need to support boundary va= lues set on=0D + // the model (scaleTop, scaleBottom and scaleZero) because some external = plugins and=0D + // controllers might still use it (e.g. the Smith chart).=0D +=0D + if (fill =3D=3D=3D 'start') {=0D + target =3D model.scaleBottom =3D=3D=3D undefined ? scale.bottom : model.= scaleBottom;=0D + } else if (fill =3D=3D=3D 'end') {=0D + target =3D model.scaleTop =3D=3D=3D undefined ? scale.top : model.scaleT= op;=0D + } else if (model.scaleZero !=3D=3D undefined) {=0D + target =3D model.scaleZero;=0D + } else if (scale.getBasePixel) {=0D + target =3D scale.getBasePixel();=0D + }=0D +=0D + if (target !=3D=3D undefined && target !=3D=3D null) {=0D + if (target.x !=3D=3D undefined && target.y !=3D=3D undefined) {=0D + return target;=0D + }=0D +=0D + if (helpers$1.isFinite(target)) {=0D + horizontal =3D scale.isHorizontal();=0D + return {=0D + x: horizontal ? target : null,=0D + y: horizontal ? null : target=0D + };=0D + }=0D + }=0D +=0D + return null;=0D +}=0D +=0D +function computeCircularBoundary(source) {=0D + var scale =3D source.el._scale;=0D + var options =3D scale.options;=0D + var length =3D scale.chart.data.labels.length;=0D + var fill =3D source.fill;=0D + var target =3D [];=0D + var start, end, center, i, point;=0D +=0D + if (!length) {=0D + return null;=0D + }=0D +=0D + start =3D options.ticks.reverse ? scale.max : scale.min;=0D + end =3D options.ticks.reverse ? scale.min : scale.max;=0D + center =3D scale.getPointPositionForValue(0, start);=0D + for (i =3D 0; i < length; ++i) {=0D + point =3D fill =3D=3D=3D 'start' || fill =3D=3D=3D 'end'=0D + ? scale.getPointPositionForValue(i, fill =3D=3D=3D 'start' ? start : en= d)=0D + : scale.getBasePosition(i);=0D + if (options.gridLines.circular) {=0D + point.cx =3D center.x;=0D + point.cy =3D center.y;=0D + point.angle =3D scale.getIndexAngle(i) - Math.PI / 2;=0D + }=0D + target.push(point);=0D + }=0D + return target;=0D +}=0D +=0D +function computeBoundary(source) {=0D + var scale =3D source.el._scale || {};=0D +=0D + if (scale.getPointPositionForValue) {=0D + return computeCircularBoundary(source);=0D + }=0D + return computeLinearBoundary(source);=0D +}=0D +=0D +function resolveTarget(sources, index, propagate) {=0D + var source =3D sources[index];=0D + var fill =3D source.fill;=0D + var visited =3D [index];=0D + var target;=0D +=0D + if (!propagate) {=0D + return fill;=0D + }=0D +=0D + while (fill !=3D=3D false && visited.indexOf(fill) =3D=3D=3D -1) {=0D + if (!isFinite(fill)) {=0D + return fill;=0D + }=0D +=0D + target =3D sources[fill];=0D + if (!target) {=0D + return false;=0D + }=0D +=0D + if (target.visible) {=0D + return fill;=0D + }=0D +=0D + visited.push(fill);=0D + fill =3D target.fill;=0D + }=0D +=0D + return false;=0D +}=0D +=0D +function createMapper(source) {=0D + var fill =3D source.fill;=0D + var type =3D 'dataset';=0D +=0D + if (fill =3D=3D=3D false) {=0D + return null;=0D + }=0D +=0D + if (!isFinite(fill)) {=0D + type =3D 'boundary';=0D + }=0D +=0D + return mappers[type](source);=0D +}=0D +=0D +function isDrawable(point) {=0D + return point && !point.skip;=0D +}=0D +=0D +function drawArea(ctx, curve0, curve1, len0, len1) {=0D + var i, cx, cy, r;=0D +=0D + if (!len0 || !len1) {=0D + return;=0D + }=0D +=0D + // building first area curve (normal)=0D + ctx.moveTo(curve0[0].x, curve0[0].y);=0D + for (i =3D 1; i < len0; ++i) {=0D + helpers$1.canvas.lineTo(ctx, curve0[i - 1], curve0[i]);=0D + }=0D +=0D + if (curve1[0].angle !=3D=3D undefined) {=0D + cx =3D curve1[0].cx;=0D + cy =3D curve1[0].cy;=0D + r =3D Math.sqrt(Math.pow(curve1[0].x - cx, 2) + Math.pow(curve1[0].y - c= y, 2));=0D + for (i =3D len1 - 1; i > 0; --i) {=0D + ctx.arc(cx, cy, r, curve1[i].angle, curve1[i - 1].angle, true);=0D + }=0D + return;=0D + }=0D +=0D + // joining the two area curves=0D + ctx.lineTo(curve1[len1 - 1].x, curve1[len1 - 1].y);=0D +=0D + // building opposite area curve (reverse)=0D + for (i =3D len1 - 1; i > 0; --i) {=0D + helpers$1.canvas.lineTo(ctx, curve1[i], curve1[i - 1], true);=0D + }=0D +}=0D +=0D +function doFill(ctx, points, mapper, view, color, loop) {=0D + var count =3D points.length;=0D + var span =3D view.spanGaps;=0D + var curve0 =3D [];=0D + var curve1 =3D [];=0D + var len0 =3D 0;=0D + var len1 =3D 0;=0D + var i, ilen, index, p0, p1, d0, d1, loopOffset;=0D +=0D + ctx.beginPath();=0D +=0D + for (i =3D 0, ilen =3D count; i < ilen; ++i) {=0D + index =3D i % count;=0D + p0 =3D points[index]._view;=0D + p1 =3D mapper(p0, index, view);=0D + d0 =3D isDrawable(p0);=0D + d1 =3D isDrawable(p1);=0D +=0D + if (loop && loopOffset =3D=3D=3D undefined && d0) {=0D + loopOffset =3D i + 1;=0D + ilen =3D count + loopOffset;=0D + }=0D +=0D + if (d0 && d1) {=0D + len0 =3D curve0.push(p0);=0D + len1 =3D curve1.push(p1);=0D + } else if (len0 && len1) {=0D + if (!span) {=0D + drawArea(ctx, curve0, curve1, len0, len1);=0D + len0 =3D len1 =3D 0;=0D + curve0 =3D [];=0D + curve1 =3D [];=0D + } else {=0D + if (d0) {=0D + curve0.push(p0);=0D + }=0D + if (d1) {=0D + curve1.push(p1);=0D + }=0D + }=0D + }=0D + }=0D +=0D + drawArea(ctx, curve0, curve1, len0, len1);=0D +=0D + ctx.closePath();=0D + ctx.fillStyle =3D color;=0D + ctx.fill();=0D +}=0D +=0D +var plugin_filler =3D {=0D + id: 'filler',=0D +=0D + afterDatasetsUpdate: function(chart, options) {=0D + var count =3D (chart.data.datasets || []).length;=0D + var propagate =3D options.propagate;=0D + var sources =3D [];=0D + var meta, i, el, source;=0D +=0D + for (i =3D 0; i < count; ++i) {=0D + meta =3D chart.getDatasetMeta(i);=0D + el =3D meta.dataset;=0D + source =3D null;=0D +=0D + if (el && el._model && el instanceof elements.Line) {=0D + source =3D {=0D + visible: chart.isDatasetVisible(i),=0D + fill: decodeFill(el, i, count),=0D + chart: chart,=0D + el: el=0D + };=0D + }=0D +=0D + meta.$filler =3D source;=0D + sources.push(source);=0D + }=0D +=0D + for (i =3D 0; i < count; ++i) {=0D + source =3D sources[i];=0D + if (!source) {=0D + continue;=0D + }=0D +=0D + source.fill =3D resolveTarget(sources, i, propagate);=0D + source.boundary =3D computeBoundary(source);=0D + source.mapper =3D createMapper(source);=0D + }=0D + },=0D +=0D + beforeDatasetsDraw: function(chart) {=0D + var metasets =3D chart._getSortedVisibleDatasetMetas();=0D + var ctx =3D chart.ctx;=0D + var meta, i, el, view, points, mapper, color;=0D +=0D + for (i =3D metasets.length - 1; i >=3D 0; --i) {=0D + meta =3D metasets[i].$filler;=0D +=0D + if (!meta || !meta.visible) {=0D + continue;=0D + }=0D +=0D + el =3D meta.el;=0D + view =3D el._view;=0D + points =3D el._children || [];=0D + mapper =3D meta.mapper;=0D + color =3D view.backgroundColor || core_defaults.global.defaultColor;=0D +=0D + if (mapper && color && points.length) {=0D + helpers$1.canvas.clipArea(ctx, chart.chartArea);=0D + doFill(ctx, points, mapper, view, color, el._loop);=0D + helpers$1.canvas.unclipArea(ctx);=0D + }=0D + }=0D + }=0D +}; =20 - if (titleOpts) { - helpers$1.mergeIf(titleOpts, core_defaults.global.title); +var getRtlHelper$1 =3D helpers$1.rtl.getRtlAdapter;=0D +var noop$1 =3D helpers$1.noop;=0D +var valueOrDefault$e =3D helpers$1.valueOrDefault;=0D +=0D +core_defaults._set('global', {=0D + legend: {=0D + display: true,=0D + position: 'top',=0D + align: 'center',=0D + fullWidth: true,=0D + reverse: false,=0D + weight: 1000,=0D +=0D + // a callback that will handle=0D + onClick: function(e, legendItem) {=0D + var index =3D legendItem.datasetIndex;=0D + var ci =3D this.chart;=0D + var meta =3D ci.getDatasetMeta(index);=0D +=0D + // See controller.isDatasetVisible comment=0D + meta.hidden =3D meta.hidden =3D=3D=3D null ? !ci.data.datasets[index].h= idden : null;=0D +=0D + // We hid a dataset ... rerender the chart=0D + ci.update();=0D + },=0D +=0D + onHover: null,=0D + onLeave: null,=0D +=0D + labels: {=0D + boxWidth: 40,=0D + padding: 10,=0D + // Generates labels shown in the legend=0D + // Valid properties to return:=0D + // text : text to display=0D + // fillStyle : fill of coloured box=0D + // strokeStyle: stroke of coloured box=0D + // hidden : if this legend item refers to a hidden item=0D + // lineCap : cap style for line=0D + // lineDash=0D + // lineDashOffset :=0D + // lineJoin :=0D + // lineWidth :=0D + generateLabels: function(chart) {=0D + var datasets =3D chart.data.datasets;=0D + var options =3D chart.options.legend || {};=0D + var usePointStyle =3D options.labels && options.labels.usePointStyle;= =0D +=0D + return chart._getSortedDatasetMetas().map(function(meta) {=0D + var style =3D meta.controller.getStyle(usePointStyle ? 0 : undefined)= ;=0D +=0D + return {=0D + text: datasets[meta.index].label,=0D + fillStyle: style.backgroundColor,=0D + hidden: !chart.isDatasetVisible(meta.index),=0D + lineCap: style.borderCapStyle,=0D + lineDash: style.borderDash,=0D + lineDashOffset: style.borderDashOffset,=0D + lineJoin: style.borderJoinStyle,=0D + lineWidth: style.borderWidth,=0D + strokeStyle: style.borderColor,=0D + pointStyle: style.pointStyle,=0D + rotation: style.rotation,=0D +=0D + // Below is extra data used for toggling the datasets=0D + datasetIndex: meta.index=0D + };=0D + }, this);=0D + }=0D + }=0D + },=0D +=0D + legendCallback: function(chart) {=0D + var list =3D document.createElement('ul');=0D + var datasets =3D chart.data.datasets;=0D + var i, ilen, listItem, listItemSpan;=0D +=0D + list.setAttribute('class', chart.id + '-legend');=0D +=0D + for (i =3D 0, ilen =3D datasets.length; i < ilen; i++) {=0D + listItem =3D list.appendChild(document.createElement('li'));=0D + listItemSpan =3D listItem.appendChild(document.createElement('span'));= =0D + listItemSpan.style.backgroundColor =3D datasets[i].backgroundColor;=0D + if (datasets[i].label) {=0D + listItem.appendChild(document.createTextNode(datasets[i].label));=0D + }=0D + }=0D +=0D + return list.outerHTML;=0D + }=0D +});=0D +=0D +/**=0D + * Helper function to get the box width based on the usePointStyle option= =0D + * @param {object} labelopts - the label options on the legend=0D + * @param {number} fontSize - the label font size=0D + * @return {number} width of the color box area=0D + */=0D +function getBoxWidth(labelOpts, fontSize) {=0D + return labelOpts.usePointStyle && labelOpts.boxWidth > fontSize ?=0D + fontSize :=0D + labelOpts.boxWidth;=0D +}=0D +=0D +/**=0D + * IMPORTANT: this class is exposed publicly as Chart.Legend, backward com= patibility required!=0D + */=0D +var Legend =3D core_element.extend({=0D +=0D + initialize: function(config) {=0D + var me =3D this;=0D + helpers$1.extend(me, config);=0D +=0D + // Contains hit boxes for each dataset (in dataset order)=0D + me.legendHitBoxes =3D [];=0D +=0D + /**=0D + * @private=0D + */=0D + me._hoveredItem =3D null;=0D +=0D + // Are we in doughnut mode which has a different data type=0D + me.doughnutMode =3D false;=0D + },=0D +=0D + // These methods are ordered by lifecycle. Utilities then follow.=0D + // Any function defined here is inherited by all legend types.=0D + // Any function can be extended by the legend type=0D +=0D + beforeUpdate: noop$1,=0D + update: function(maxWidth, maxHeight, margins) {=0D + var me =3D this;=0D +=0D + // Update Lifecycle - Probably don't want to ever extend or overwrite th= is function ;)=0D + me.beforeUpdate();=0D +=0D + // Absorb the master measurements=0D + me.maxWidth =3D maxWidth;=0D + me.maxHeight =3D maxHeight;=0D + me.margins =3D margins;=0D +=0D + // Dimensions=0D + me.beforeSetDimensions();=0D + me.setDimensions();=0D + me.afterSetDimensions();=0D + // Labels=0D + me.beforeBuildLabels();=0D + me.buildLabels();=0D + me.afterBuildLabels();=0D +=0D + // Fit=0D + me.beforeFit();=0D + me.fit();=0D + me.afterFit();=0D + //=0D + me.afterUpdate();=0D +=0D + return me.minSize;=0D + },=0D + afterUpdate: noop$1,=0D +=0D + //=0D +=0D + beforeSetDimensions: noop$1,=0D + setDimensions: function() {=0D + var me =3D this;=0D + // Set the unconstrained dimension before label rotation=0D + if (me.isHorizontal()) {=0D + // Reset position before calculating rotation=0D + me.width =3D me.maxWidth;=0D + me.left =3D 0;=0D + me.right =3D me.width;=0D + } else {=0D + me.height =3D me.maxHeight;=0D +=0D + // Reset position before calculating rotation=0D + me.top =3D 0;=0D + me.bottom =3D me.height;=0D + }=0D +=0D + // Reset padding=0D + me.paddingLeft =3D 0;=0D + me.paddingTop =3D 0;=0D + me.paddingRight =3D 0;=0D + me.paddingBottom =3D 0;=0D +=0D + // Reset minSize=0D + me.minSize =3D {=0D + width: 0,=0D + height: 0=0D + };=0D + },=0D + afterSetDimensions: noop$1,=0D +=0D + //=0D +=0D + beforeBuildLabels: noop$1,=0D + buildLabels: function() {=0D + var me =3D this;=0D + var labelOpts =3D me.options.labels || {};=0D + var legendItems =3D helpers$1.callback(labelOpts.generateLabels, [me.cha= rt], me) || [];=0D +=0D + if (labelOpts.filter) {=0D + legendItems =3D legendItems.filter(function(item) {=0D + return labelOpts.filter(item, me.chart.data);=0D + });=0D + }=0D +=0D + if (me.options.reverse) {=0D + legendItems.reverse();=0D + }=0D +=0D + me.legendItems =3D legendItems;=0D + },=0D + afterBuildLabels: noop$1,=0D +=0D + //=0D +=0D + beforeFit: noop$1,=0D + fit: function() {=0D + var me =3D this;=0D + var opts =3D me.options;=0D + var labelOpts =3D opts.labels;=0D + var display =3D opts.display;=0D +=0D + var ctx =3D me.ctx;=0D +=0D + var labelFont =3D helpers$1.options._parseFont(labelOpts);=0D + var fontSize =3D labelFont.size;=0D +=0D + // Reset hit boxes=0D + var hitboxes =3D me.legendHitBoxes =3D [];=0D +=0D + var minSize =3D me.minSize;=0D + var isHorizontal =3D me.isHorizontal();=0D +=0D + if (isHorizontal) {=0D + minSize.width =3D me.maxWidth; // fill all the width=0D + minSize.height =3D display ? 10 : 0;=0D + } else {=0D + minSize.width =3D display ? 10 : 0;=0D + minSize.height =3D me.maxHeight; // fill all the height=0D + }=0D +=0D + // Increase sizes here=0D + if (!display) {=0D + me.width =3D minSize.width =3D me.height =3D minSize.height =3D 0;=0D + return;=0D + }=0D + ctx.font =3D labelFont.string;=0D +=0D + if (isHorizontal) {=0D + // Labels=0D +=0D + // Width of each line of legend boxes. Labels wrap onto multiple lines = when there are too many to fit on one=0D + var lineWidths =3D me.lineWidths =3D [0];=0D + var totalHeight =3D 0;=0D +=0D + ctx.textAlign =3D 'left';=0D + ctx.textBaseline =3D 'middle';=0D +=0D + helpers$1.each(me.legendItems, function(legendItem, i) {=0D + var boxWidth =3D getBoxWidth(labelOpts, fontSize);=0D + var width =3D boxWidth + (fontSize / 2) + ctx.measureText(legendItem.t= ext).width;=0D +=0D + if (i =3D=3D=3D 0 || lineWidths[lineWidths.length - 1] + width + 2 * l= abelOpts.padding > minSize.width) {=0D + totalHeight +=3D fontSize + labelOpts.padding;=0D + lineWidths[lineWidths.length - (i > 0 ? 0 : 1)] =3D 0;=0D + }=0D +=0D + // Store the hitbox width and height here. Final position will be upda= ted in `draw`=0D + hitboxes[i] =3D {=0D + left: 0,=0D + top: 0,=0D + width: width,=0D + height: fontSize=0D + };=0D +=0D + lineWidths[lineWidths.length - 1] +=3D width + labelOpts.padding;=0D + });=0D +=0D + minSize.height +=3D totalHeight;=0D +=0D + } else {=0D + var vPadding =3D labelOpts.padding;=0D + var columnWidths =3D me.columnWidths =3D [];=0D + var columnHeights =3D me.columnHeights =3D [];=0D + var totalWidth =3D labelOpts.padding;=0D + var currentColWidth =3D 0;=0D + var currentColHeight =3D 0;=0D +=0D + helpers$1.each(me.legendItems, function(legendItem, i) {=0D + var boxWidth =3D getBoxWidth(labelOpts, fontSize);=0D + var itemWidth =3D boxWidth + (fontSize / 2) + ctx.measureText(legendIt= em.text).width;=0D +=0D + // If too tall, go to new column=0D + if (i > 0 && currentColHeight + fontSize + 2 * vPadding > minSize.heig= ht) {=0D + totalWidth +=3D currentColWidth + labelOpts.padding;=0D + columnWidths.push(currentColWidth); // previous column width=0D + columnHeights.push(currentColHeight);=0D + currentColWidth =3D 0;=0D + currentColHeight =3D 0;=0D + }=0D +=0D + // Get max width=0D + currentColWidth =3D Math.max(currentColWidth, itemWidth);=0D + currentColHeight +=3D fontSize + vPadding;=0D +=0D + // Store the hitbox width and height here. Final position will be upda= ted in `draw`=0D + hitboxes[i] =3D {=0D + left: 0,=0D + top: 0,=0D + width: itemWidth,=0D + height: fontSize=0D + };=0D + });=0D +=0D + totalWidth +=3D currentColWidth;=0D + columnWidths.push(currentColWidth);=0D + columnHeights.push(currentColHeight);=0D + minSize.width +=3D totalWidth;=0D + }=0D +=0D + me.width =3D minSize.width;=0D + me.height =3D minSize.height;=0D + },=0D + afterFit: noop$1,=0D +=0D + // Shared Methods=0D + isHorizontal: function() {=0D + return this.options.position =3D=3D=3D 'top' || this.options.position = =3D=3D=3D 'bottom';=0D + },=0D +=0D + // Actually draw the legend on the canvas=0D + draw: function() {=0D + var me =3D this;=0D + var opts =3D me.options;=0D + var labelOpts =3D opts.labels;=0D + var globalDefaults =3D core_defaults.global;=0D + var defaultColor =3D globalDefaults.defaultColor;=0D + var lineDefault =3D globalDefaults.elements.line;=0D + var legendHeight =3D me.height;=0D + var columnHeights =3D me.columnHeights;=0D + var legendWidth =3D me.width;=0D + var lineWidths =3D me.lineWidths;=0D +=0D + if (!opts.display) {=0D + return;=0D + }=0D +=0D + var rtlHelper =3D getRtlHelper$1(opts.rtl, me.left, me.minSize.width);=0D + var ctx =3D me.ctx;=0D + var fontColor =3D valueOrDefault$e(labelOpts.fontColor, globalDefaults.d= efaultFontColor);=0D + var labelFont =3D helpers$1.options._parseFont(labelOpts);=0D + var fontSize =3D labelFont.size;=0D + var cursor;=0D +=0D + // Canvas setup=0D + ctx.textAlign =3D rtlHelper.textAlign('left');=0D + ctx.textBaseline =3D 'middle';=0D + ctx.lineWidth =3D 0.5;=0D + ctx.strokeStyle =3D fontColor; // for strikethrough effect=0D + ctx.fillStyle =3D fontColor; // render in correct colour=0D + ctx.font =3D labelFont.string;=0D +=0D + var boxWidth =3D getBoxWidth(labelOpts, fontSize);=0D + var hitboxes =3D me.legendHitBoxes;=0D +=0D + // current position=0D + var drawLegendBox =3D function(x, y, legendItem) {=0D + if (isNaN(boxWidth) || boxWidth <=3D 0) {=0D + return;=0D + }=0D +=0D + // Set the ctx for the box=0D + ctx.save();=0D +=0D + var lineWidth =3D valueOrDefault$e(legendItem.lineWidth, lineDefault.bo= rderWidth);=0D + ctx.fillStyle =3D valueOrDefault$e(legendItem.fillStyle, defaultColor);= =0D + ctx.lineCap =3D valueOrDefault$e(legendItem.lineCap, lineDefault.border= CapStyle);=0D + ctx.lineDashOffset =3D valueOrDefault$e(legendItem.lineDashOffset, line= Default.borderDashOffset);=0D + ctx.lineJoin =3D valueOrDefault$e(legendItem.lineJoin, lineDefault.bord= erJoinStyle);=0D + ctx.lineWidth =3D lineWidth;=0D + ctx.strokeStyle =3D valueOrDefault$e(legendItem.strokeStyle, defaultCol= or);=0D +=0D + if (ctx.setLineDash) {=0D + // IE 9 and 10 do not support line dash=0D + ctx.setLineDash(valueOrDefault$e(legendItem.lineDash, lineDefault.bord= erDash));=0D + }=0D +=0D + if (labelOpts && labelOpts.usePointStyle) {=0D + // Recalculate x and y for drawPoint() because its expecting=0D + // x and y to be center of figure (instead of top left)=0D + var radius =3D boxWidth * Math.SQRT2 / 2;=0D + var centerX =3D rtlHelper.xPlus(x, boxWidth / 2);=0D + var centerY =3D y + fontSize / 2;=0D +=0D + // Draw pointStyle as legend symbol=0D + helpers$1.canvas.drawPoint(ctx, legendItem.pointStyle, radius, centerX= , centerY, legendItem.rotation);=0D + } else {=0D + // Draw box as legend symbol=0D + ctx.fillRect(rtlHelper.leftForLtr(x, boxWidth), y, boxWidth, fontSize)= ;=0D + if (lineWidth !=3D=3D 0) {=0D + ctx.strokeRect(rtlHelper.leftForLtr(x, boxWidth), y, boxWidth, fontSi= ze);=0D + }=0D + }=0D +=0D + ctx.restore();=0D + };=0D +=0D + var fillText =3D function(x, y, legendItem, textWidth) {=0D + var halfFontSize =3D fontSize / 2;=0D + var xLeft =3D rtlHelper.xPlus(x, boxWidth + halfFontSize);=0D + var yMiddle =3D y + halfFontSize;=0D +=0D + ctx.fillText(legendItem.text, xLeft, yMiddle);=0D +=0D + if (legendItem.hidden) {=0D + // Strikethrough the text if hidden=0D + ctx.beginPath();=0D + ctx.lineWidth =3D 2;=0D + ctx.moveTo(xLeft, yMiddle);=0D + ctx.lineTo(rtlHelper.xPlus(xLeft, textWidth), yMiddle);=0D + ctx.stroke();=0D + }=0D + };=0D +=0D + var alignmentOffset =3D function(dimension, blockSize) {=0D + switch (opts.align) {=0D + case 'start':=0D + return labelOpts.padding;=0D + case 'end':=0D + return dimension - blockSize;=0D + default: // center=0D + return (dimension - blockSize + labelOpts.padding) / 2;=0D + }=0D + };=0D +=0D + // Horizontal=0D + var isHorizontal =3D me.isHorizontal();=0D + if (isHorizontal) {=0D + cursor =3D {=0D + x: me.left + alignmentOffset(legendWidth, lineWidths[0]),=0D + y: me.top + labelOpts.padding,=0D + line: 0=0D + };=0D + } else {=0D + cursor =3D {=0D + x: me.left + labelOpts.padding,=0D + y: me.top + alignmentOffset(legendHeight, columnHeights[0]),=0D + line: 0=0D + };=0D + }=0D +=0D + helpers$1.rtl.overrideTextDirection(me.ctx, opts.textDirection);=0D +=0D + var itemHeight =3D fontSize + labelOpts.padding;=0D + helpers$1.each(me.legendItems, function(legendItem, i) {=0D + var textWidth =3D ctx.measureText(legendItem.text).width;=0D + var width =3D boxWidth + (fontSize / 2) + textWidth;=0D + var x =3D cursor.x;=0D + var y =3D cursor.y;=0D +=0D + rtlHelper.setWidth(me.minSize.width);=0D +=0D + // Use (me.left + me.minSize.width) and (me.top + me.minSize.height)=0D + // instead of me.right and me.bottom because me.width and me.height=0D + // may have been changed since me.minSize was calculated=0D + if (isHorizontal) {=0D + if (i > 0 && x + width + labelOpts.padding > me.left + me.minSize.widt= h) {=0D + y =3D cursor.y +=3D itemHeight;=0D + cursor.line++;=0D + x =3D cursor.x =3D me.left + alignmentOffset(legendWidth, lineWidths[= cursor.line]);=0D + }=0D + } else if (i > 0 && y + itemHeight > me.top + me.minSize.height) {=0D + x =3D cursor.x =3D x + me.columnWidths[cursor.line] + labelOpts.paddin= g;=0D + cursor.line++;=0D + y =3D cursor.y =3D me.top + alignmentOffset(legendHeight, columnHeight= s[cursor.line]);=0D + }=0D +=0D + var realX =3D rtlHelper.x(x);=0D +=0D + drawLegendBox(realX, y, legendItem);=0D +=0D + hitboxes[i].left =3D rtlHelper.leftForLtr(realX, hitboxes[i].width);=0D + hitboxes[i].top =3D y;=0D +=0D + // Fill the actual label=0D + fillText(realX, y, legendItem, textWidth);=0D +=0D + if (isHorizontal) {=0D + cursor.x +=3D width + labelOpts.padding;=0D + } else {=0D + cursor.y +=3D itemHeight;=0D + }=0D + });=0D +=0D + helpers$1.rtl.restoreTextDirection(me.ctx, opts.textDirection);=0D + },=0D +=0D + /**=0D + * @private=0D + */=0D + _getLegendItemAt: function(x, y) {=0D + var me =3D this;=0D + var i, hitBox, lh;=0D +=0D + if (x >=3D me.left && x <=3D me.right && y >=3D me.top && y <=3D me.bott= om) {=0D + // See if we are touching one of the dataset boxes=0D + lh =3D me.legendHitBoxes;=0D + for (i =3D 0; i < lh.length; ++i) {=0D + hitBox =3D lh[i];=0D +=0D + if (x >=3D hitBox.left && x <=3D hitBox.left + hitBox.width && y >=3D = hitBox.top && y <=3D hitBox.top + hitBox.height) {=0D + // Touching an element=0D + return me.legendItems[i];=0D + }=0D + }=0D + }=0D +=0D + return null;=0D + },=0D +=0D + /**=0D + * Handle an event=0D + * @private=0D + * @param {IEvent} event - The event to handle=0D + */=0D + handleEvent: function(e) {=0D + var me =3D this;=0D + var opts =3D me.options;=0D + var type =3D e.type =3D=3D=3D 'mouseup' ? 'click' : e.type;=0D + var hoveredItem;=0D +=0D + if (type =3D=3D=3D 'mousemove') {=0D + if (!opts.onHover && !opts.onLeave) {=0D + return;=0D + }=0D + } else if (type =3D=3D=3D 'click') {=0D + if (!opts.onClick) {=0D + return;=0D + }=0D + } else {=0D + return;=0D + }=0D +=0D + // Chart event already has relative position in it=0D + hoveredItem =3D me._getLegendItemAt(e.x, e.y);=0D +=0D + if (type =3D=3D=3D 'click') {=0D + if (hoveredItem && opts.onClick) {=0D + // use e.native for backwards compatibility=0D + opts.onClick.call(me, e.native, hoveredItem);=0D + }=0D + } else {=0D + if (opts.onLeave && hoveredItem !=3D=3D me._hoveredItem) {=0D + if (me._hoveredItem) {=0D + opts.onLeave.call(me, e.native, me._hoveredItem);=0D + }=0D + me._hoveredItem =3D hoveredItem;=0D + }=0D +=0D + if (opts.onHover && hoveredItem) {=0D + // use e.native for backwards compatibility=0D + opts.onHover.call(me, e.native, hoveredItem);=0D + }=0D + }=0D + }=0D +});=0D +=0D +function createNewLegendAndAttach(chart, legendOpts) {=0D + var legend =3D new Legend({=0D + ctx: chart.ctx,=0D + options: legendOpts,=0D + chart: chart=0D + });=0D +=0D + core_layouts.configure(chart, legend, legendOpts);=0D + core_layouts.addBox(chart, legend);=0D + chart.legend =3D legend;=0D +}=0D +=0D +var plugin_legend =3D {=0D + id: 'legend',=0D +=0D + /**=0D + * Backward compatibility: since 2.1.5, the legend is registered as a plu= gin, making=0D + * Chart.Legend obsolete. To avoid a breaking change, we export the Legen= d as part of=0D + * the plugin, which one will be re-exposed in the chart.js file.=0D + * https://github.com/chartjs/Chart.js/pull/2640=0D + * @private=0D + */=0D + _element: Legend,=0D +=0D + beforeInit: function(chart) {=0D + var legendOpts =3D chart.options.legend;=0D +=0D + if (legendOpts) {=0D + createNewLegendAndAttach(chart, legendOpts);=0D + }=0D + },=0D +=0D + beforeUpdate: function(chart) {=0D + var legendOpts =3D chart.options.legend;=0D + var legend =3D chart.legend;=0D +=0D + if (legendOpts) {=0D + helpers$1.mergeIf(legendOpts, core_defaults.global.legend);=0D +=0D + if (legend) {=0D + core_layouts.configure(chart, legend, legendOpts);=0D + legend.options =3D legendOpts;=0D + } else {=0D + createNewLegendAndAttach(chart, legendOpts);=0D + }=0D + } else if (legend) {=0D + core_layouts.removeBox(chart, legend);=0D + delete chart.legend;=0D + }=0D + },=0D +=0D + afterEvent: function(chart, e) {=0D + var legend =3D chart.legend;=0D + if (legend) {=0D + legend.handleEvent(e);=0D + }=0D + }=0D +}; =20 - if (titleBlock) { - core_layouts.configure(chart, titleBlock, titleOpts); - titleBlock.options =3D titleOpts; - } else { - createNewTitleBlockAndAttach(chart, titleOpts); - } - } else if (titleBlock) { - core_layouts.removeBox(chart, titleBlock); - delete chart.titleBlock; - } - } +var noop$2 =3D helpers$1.noop;=0D +=0D +core_defaults._set('global', {=0D + title: {=0D + display: false,=0D + fontStyle: 'bold',=0D + fullWidth: true,=0D + padding: 10,=0D + position: 'top',=0D + text: '',=0D + weight: 2000 // by default greater than legend (1000) to be abov= e=0D + }=0D +});=0D +=0D +/**=0D + * IMPORTANT: this class is exposed publicly as Chart.Legend, backward com= patibility required!=0D + */=0D +var Title =3D core_element.extend({=0D + initialize: function(config) {=0D + var me =3D this;=0D + helpers$1.extend(me, config);=0D +=0D + // Contains hit boxes for each dataset (in dataset order)=0D + me.legendHitBoxes =3D [];=0D + },=0D +=0D + // These methods are ordered by lifecycle. Utilities then follow.=0D +=0D + beforeUpdate: noop$2,=0D + update: function(maxWidth, maxHeight, margins) {=0D + var me =3D this;=0D +=0D + // Update Lifecycle - Probably don't want to ever extend or overwrite th= is function ;)=0D + me.beforeUpdate();=0D +=0D + // Absorb the master measurements=0D + me.maxWidth =3D maxWidth;=0D + me.maxHeight =3D maxHeight;=0D + me.margins =3D margins;=0D +=0D + // Dimensions=0D + me.beforeSetDimensions();=0D + me.setDimensions();=0D + me.afterSetDimensions();=0D + // Labels=0D + me.beforeBuildLabels();=0D + me.buildLabels();=0D + me.afterBuildLabels();=0D +=0D + // Fit=0D + me.beforeFit();=0D + me.fit();=0D + me.afterFit();=0D + //=0D + me.afterUpdate();=0D +=0D + return me.minSize;=0D +=0D + },=0D + afterUpdate: noop$2,=0D +=0D + //=0D +=0D + beforeSetDimensions: noop$2,=0D + setDimensions: function() {=0D + var me =3D this;=0D + // Set the unconstrained dimension before label rotation=0D + if (me.isHorizontal()) {=0D + // Reset position before calculating rotation=0D + me.width =3D me.maxWidth;=0D + me.left =3D 0;=0D + me.right =3D me.width;=0D + } else {=0D + me.height =3D me.maxHeight;=0D +=0D + // Reset position before calculating rotation=0D + me.top =3D 0;=0D + me.bottom =3D me.height;=0D + }=0D +=0D + // Reset padding=0D + me.paddingLeft =3D 0;=0D + me.paddingTop =3D 0;=0D + me.paddingRight =3D 0;=0D + me.paddingBottom =3D 0;=0D +=0D + // Reset minSize=0D + me.minSize =3D {=0D + width: 0,=0D + height: 0=0D + };=0D + },=0D + afterSetDimensions: noop$2,=0D +=0D + //=0D +=0D + beforeBuildLabels: noop$2,=0D + buildLabels: noop$2,=0D + afterBuildLabels: noop$2,=0D +=0D + //=0D +=0D + beforeFit: noop$2,=0D + fit: function() {=0D + var me =3D this;=0D + var opts =3D me.options;=0D + var minSize =3D me.minSize =3D {};=0D + var isHorizontal =3D me.isHorizontal();=0D + var lineCount, textSize;=0D +=0D + if (!opts.display) {=0D + me.width =3D minSize.width =3D me.height =3D minSize.height =3D 0;=0D + return;=0D + }=0D +=0D + lineCount =3D helpers$1.isArray(opts.text) ? opts.text.length : 1;=0D + textSize =3D lineCount * helpers$1.options._parseFont(opts).lineHeight += opts.padding * 2;=0D +=0D + me.width =3D minSize.width =3D isHorizontal ? me.maxWidth : textSize;=0D + me.height =3D minSize.height =3D isHorizontal ? textSize : me.maxHeight;= =0D + },=0D + afterFit: noop$2,=0D +=0D + // Shared Methods=0D + isHorizontal: function() {=0D + var pos =3D this.options.position;=0D + return pos =3D=3D=3D 'top' || pos =3D=3D=3D 'bottom';=0D + },=0D +=0D + // Actually draw the title block on the canvas=0D + draw: function() {=0D + var me =3D this;=0D + var ctx =3D me.ctx;=0D + var opts =3D me.options;=0D +=0D + if (!opts.display) {=0D + return;=0D + }=0D +=0D + var fontOpts =3D helpers$1.options._parseFont(opts);=0D + var lineHeight =3D fontOpts.lineHeight;=0D + var offset =3D lineHeight / 2 + opts.padding;=0D + var rotation =3D 0;=0D + var top =3D me.top;=0D + var left =3D me.left;=0D + var bottom =3D me.bottom;=0D + var right =3D me.right;=0D + var maxWidth, titleX, titleY;=0D +=0D + ctx.fillStyle =3D helpers$1.valueOrDefault(opts.fontColor, core_defaults= .global.defaultFontColor); // render in correct colour=0D + ctx.font =3D fontOpts.string;=0D +=0D + // Horizontal=0D + if (me.isHorizontal()) {=0D + titleX =3D left + ((right - left) / 2); // midpoint of the width=0D + titleY =3D top + offset;=0D + maxWidth =3D right - left;=0D + } else {=0D + titleX =3D opts.position =3D=3D=3D 'left' ? left + offset : right - off= set;=0D + titleY =3D top + ((bottom - top) / 2);=0D + maxWidth =3D bottom - top;=0D + rotation =3D Math.PI * (opts.position =3D=3D=3D 'left' ? -0.5 : 0.5);=0D + }=0D +=0D + ctx.save();=0D + ctx.translate(titleX, titleY);=0D + ctx.rotate(rotation);=0D + ctx.textAlign =3D 'center';=0D + ctx.textBaseline =3D 'middle';=0D +=0D + var text =3D opts.text;=0D + if (helpers$1.isArray(text)) {=0D + var y =3D 0;=0D + for (var i =3D 0; i < text.length; ++i) {=0D + ctx.fillText(text[i], 0, y, maxWidth);=0D + y +=3D lineHeight;=0D + }=0D + } else {=0D + ctx.fillText(text, 0, 0, maxWidth);=0D + }=0D +=0D + ctx.restore();=0D + }=0D +});=0D +=0D +function createNewTitleBlockAndAttach(chart, titleOpts) {=0D + var title =3D new Title({=0D + ctx: chart.ctx,=0D + options: titleOpts,=0D + chart: chart=0D + });=0D +=0D + core_layouts.configure(chart, title, titleOpts);=0D + core_layouts.addBox(chart, title);=0D + chart.titleBlock =3D title;=0D +}=0D +=0D +var plugin_title =3D {=0D + id: 'title',=0D +=0D + /**=0D + * Backward compatibility: since 2.1.5, the title is registered as a plug= in, making=0D + * Chart.Title obsolete. To avoid a breaking change, we export the Title = as part of=0D + * the plugin, which one will be re-exposed in the chart.js file.=0D + * https://github.com/chartjs/Chart.js/pull/2640=0D + * @private=0D + */=0D + _element: Title,=0D +=0D + beforeInit: function(chart) {=0D + var titleOpts =3D chart.options.title;=0D +=0D + if (titleOpts) {=0D + createNewTitleBlockAndAttach(chart, titleOpts);=0D + }=0D + },=0D +=0D + beforeUpdate: function(chart) {=0D + var titleOpts =3D chart.options.title;=0D + var titleBlock =3D chart.titleBlock;=0D +=0D + if (titleOpts) {=0D + helpers$1.mergeIf(titleOpts, core_defaults.global.title);=0D +=0D + if (titleBlock) {=0D + core_layouts.configure(chart, titleBlock, titleOpts);=0D + titleBlock.options =3D titleOpts;=0D + } else {=0D + createNewTitleBlockAndAttach(chart, titleOpts);=0D + }=0D + } else if (titleBlock) {=0D + core_layouts.removeBox(chart, titleBlock);=0D + delete chart.titleBlock;=0D + }=0D + }=0D }; =20 -var plugins =3D {}; -var filler =3D plugin_filler; -var legend =3D plugin_legend; +var plugins =3D {};=0D +var filler =3D plugin_filler;=0D +var legend =3D plugin_legend;=0D var title =3D plugin_title; plugins.filler =3D filler; plugins.legend =3D legend; plugins.title =3D title; =20 -/** - * @namespace Chart - */ - - -core_controller.helpers =3D helpers$1; - -// @todo dispatch these helpers into appropriated helpers/helpers.* file a= nd write unit tests! -core_helpers(); - -core_controller._adapters =3D core_adapters; -core_controller.Animation =3D core_animation; -core_controller.animationService =3D core_animations; -core_controller.controllers =3D controllers; -core_controller.DatasetController =3D core_datasetController; -core_controller.defaults =3D core_defaults; -core_controller.Element =3D core_element; -core_controller.elements =3D elements; -core_controller.Interaction =3D core_interaction; -core_controller.layouts =3D core_layouts; -core_controller.platform =3D platform; -core_controller.plugins =3D core_plugins; -core_controller.Scale =3D core_scale; -core_controller.scaleService =3D core_scaleService; -core_controller.Ticks =3D core_ticks; -core_controller.Tooltip =3D core_tooltip; - -// Register built-in scales - -core_controller.helpers.each(scales, function(scale, type) { - core_controller.scaleService.registerScaleType(type, scale, scale._defaul= ts); -}); - -// Load to register built-in adapters (as side effects) - - -// Loading built-in plugins - -for (var k in plugins) { - if (plugins.hasOwnProperty(k)) { - core_controller.plugins.register(plugins[k]); - } -} - -core_controller.platform.initialize(); - -var src =3D core_controller; -if (typeof window !=3D=3D 'undefined') { - window.Chart =3D core_controller; -} - -// DEPRECATIONS - -/** - * Provided for backward compatibility, not available anymore - * @namespace Chart.Chart - * @deprecated since version 2.8.0 - * @todo remove at version 3 - * @private - */ -core_controller.Chart =3D core_controller; - -/** - * Provided for backward compatibility, not available anymore - * @namespace Chart.Legend - * @deprecated since version 2.1.5 - * @todo remove at version 3 - * @private - */ -core_controller.Legend =3D plugins.legend._element; - -/** - * Provided for backward compatibility, not available anymore - * @namespace Chart.Title - * @deprecated since version 2.1.5 - * @todo remove at version 3 - * @private - */ -core_controller.Title =3D plugins.title._element; - -/** - * Provided for backward compatibility, use Chart.plugins instead - * @namespace Chart.pluginService - * @deprecated since version 2.1.5 - * @todo remove at version 3 - * @private - */ -core_controller.pluginService =3D core_controller.plugins; - -/** - * Provided for backward compatibility, inheriting from Chart.PlugingBase = has no - * effect, instead simply create/register plugins via plain JavaScript obj= ects. - * @interface Chart.PluginBase - * @deprecated since version 2.5.0 - * @todo remove at version 3 - * @private - */ -core_controller.PluginBase =3D core_controller.Element.extend({}); - -/** - * Provided for backward compatibility, use Chart.helpers.canvas instead. - * @namespace Chart.canvasHelpers - * @deprecated since version 2.6.0 - * @todo remove at version 3 - * @private - */ -core_controller.canvasHelpers =3D core_controller.helpers.canvas; - -/** - * Provided for backward compatibility, use Chart.layouts instead. - * @namespace Chart.layoutService - * @deprecated since version 2.7.3 - * @todo remove at version 3 - * @private - */ -core_controller.layoutService =3D core_controller.layouts; - -/** - * Provided for backward compatibility, not available anymore. - * @namespace Chart.LinearScaleBase - * @deprecated since version 2.8 - * @todo remove at version 3 - * @private - */ -core_controller.LinearScaleBase =3D scale_linearbase; - -/** - * Provided for backward compatibility, instead we should create a new Cha= rt - * by setting the type in the config (`new Chart(id, {type: '{chart-type}'= }`). - * @deprecated since version 2.8.0 - * @todo remove at version 3 - */ -core_controller.helpers.each( - [ - 'Bar', - 'Bubble', - 'Doughnut', - 'Line', - 'PolarArea', - 'Radar', - 'Scatter' - ], - function(klass) { - core_controller[klass] =3D function(ctx, cfg) { - return new core_controller(ctx, core_controller.helpers.merge(cfg || {}= , { - type: klass.charAt(0).toLowerCase() + klass.slice(1) - })); - }; - } +/**=0D + * @namespace Chart=0D + */=0D +=0D +=0D +core_controller.helpers =3D helpers$1;=0D +=0D +// @todo dispatch these helpers into appropriated helpers/helpers.* file a= nd write unit tests!=0D +core_helpers();=0D +=0D +core_controller._adapters =3D core_adapters;=0D +core_controller.Animation =3D core_animation;=0D +core_controller.animationService =3D core_animations;=0D +core_controller.controllers =3D controllers;=0D +core_controller.DatasetController =3D core_datasetController;=0D +core_controller.defaults =3D core_defaults;=0D +core_controller.Element =3D core_element;=0D +core_controller.elements =3D elements;=0D +core_controller.Interaction =3D core_interaction;=0D +core_controller.layouts =3D core_layouts;=0D +core_controller.platform =3D platform;=0D +core_controller.plugins =3D core_plugins;=0D +core_controller.Scale =3D core_scale;=0D +core_controller.scaleService =3D core_scaleService;=0D +core_controller.Ticks =3D core_ticks;=0D +core_controller.Tooltip =3D core_tooltip;=0D +=0D +// Register built-in scales=0D +=0D +core_controller.helpers.each(scales, function(scale, type) {=0D + core_controller.scaleService.registerScaleType(type, scale, scale._defaul= ts);=0D +});=0D +=0D +// Load to register built-in adapters (as side effects)=0D +=0D +=0D +// Loading built-in plugins=0D +=0D +for (var k in plugins) {=0D + if (plugins.hasOwnProperty(k)) {=0D + core_controller.plugins.register(plugins[k]);=0D + }=0D +}=0D +=0D +core_controller.platform.initialize();=0D +=0D +var src =3D core_controller;=0D +if (typeof window !=3D=3D 'undefined') {=0D + window.Chart =3D core_controller;=0D +}=0D +=0D +// DEPRECATIONS=0D +=0D +/**=0D + * Provided for backward compatibility, not available anymore=0D + * @namespace Chart.Chart=0D + * @deprecated since version 2.8.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +core_controller.Chart =3D core_controller;=0D +=0D +/**=0D + * Provided for backward compatibility, not available anymore=0D + * @namespace Chart.Legend=0D + * @deprecated since version 2.1.5=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +core_controller.Legend =3D plugins.legend._element;=0D +=0D +/**=0D + * Provided for backward compatibility, not available anymore=0D + * @namespace Chart.Title=0D + * @deprecated since version 2.1.5=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +core_controller.Title =3D plugins.title._element;=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.plugins instead=0D + * @namespace Chart.pluginService=0D + * @deprecated since version 2.1.5=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +core_controller.pluginService =3D core_controller.plugins;=0D +=0D +/**=0D + * Provided for backward compatibility, inheriting from Chart.PlugingBase = has no=0D + * effect, instead simply create/register plugins via plain JavaScript obj= ects.=0D + * @interface Chart.PluginBase=0D + * @deprecated since version 2.5.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +core_controller.PluginBase =3D core_controller.Element.extend({});=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.helpers.canvas instead.= =0D + * @namespace Chart.canvasHelpers=0D + * @deprecated since version 2.6.0=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +core_controller.canvasHelpers =3D core_controller.helpers.canvas;=0D +=0D +/**=0D + * Provided for backward compatibility, use Chart.layouts instead.=0D + * @namespace Chart.layoutService=0D + * @deprecated since version 2.7.3=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +core_controller.layoutService =3D core_controller.layouts;=0D +=0D +/**=0D + * Provided for backward compatibility, not available anymore.=0D + * @namespace Chart.LinearScaleBase=0D + * @deprecated since version 2.8=0D + * @todo remove at version 3=0D + * @private=0D + */=0D +core_controller.LinearScaleBase =3D scale_linearbase;=0D +=0D +/**=0D + * Provided for backward compatibility, instead we should create a new Cha= rt=0D + * by setting the type in the config (`new Chart(id, {type: '{chart-type}'= }`).=0D + * @deprecated since version 2.8.0=0D + * @todo remove at version 3=0D + */=0D +core_controller.helpers.each(=0D + [=0D + 'Bar',=0D + 'Bubble',=0D + 'Doughnut',=0D + 'Line',=0D + 'PolarArea',=0D + 'Radar',=0D + 'Scatter'=0D + ],=0D + function(klass) {=0D + core_controller[klass] =3D function(ctx, cfg) {=0D + return new core_controller(ctx, core_controller.helpers.merge(cfg || {}= , {=0D + type: klass.charAt(0).toLowerCase() + klass.slice(1)=0D + }));=0D + };=0D + }=0D ); =20 return src; diff --git a/layerindex/static/js/Chart-2.9.4.min.js b/layerindex/static/js= /Chart-2.9.4.min.js new file mode 100644 index 0000000..a87f614 --- /dev/null +++ b/layerindex/static/js/Chart-2.9.4.min.js @@ -0,0 +1,7 @@ +/*! + * Chart.js v2.9.4 + * https://www.chartjs.org + * (c) 2020 Chart.js Contributors + * Released under the MIT License + */ +!function(t,e){"object"=3D=3Dtypeof exports&&"undefined"!=3Dtypeof module?= module.exports=3De(function(){try{return require("moment")}catch(t){}}()):"= function"=3D=3Dtypeof define&&define.amd?define(["require"],(function(t){re= turn e(function(){try{return t("moment")}catch(t){}}())})):(t=3Dt||self).Ch= art=3De(t.moment)}(this,(function(t){"use strict";t=3Dt&&t.hasOwnProperty("= default")?t.default:t;var e=3D{aliceblue:[240,248,255],antiquewhite:[250,23= 5,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:= [245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,20= 5],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,= 184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,3= 0],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],c= rimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139]= ,darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],dark= grey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkoliv= egreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[= 139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:= [72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise= :[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,19= 1,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],= firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuc= hsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255= ,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyell= ow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,= 180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240= ,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124= ,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,= 128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgr= ay:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink= :[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightsk= yblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,15= 3],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],li= megreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0= ],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,= 211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue= :[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],m= ediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250= ],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],= navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,3= 5],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenr= od:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevi= oletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru= :[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230= ],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[18= 8,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,1= 14],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sie= nna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,9= 0,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],s= pringgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128= ,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],viole= t:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245= ,245],yellow:[255,255,0],yellowgreen:[154,205,50]},n=3Dfunction(t,e){return= t(e=3D{exports:{}},e.exports),e.exports}((function(t){var n=3D{};for(var i= in e)e.hasOwnProperty(i)&&(n[e[i]]=3Di);var a=3Dt.exports=3D{rgb:{channels= :3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"= },hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channe= ls:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lc= h"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]}= ,ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256= "]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","= g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var r in a)if(a.hasOwnP= roperty(r)){if(!("channels"in a[r]))throw new Error("missing channels prope= rty: "+r);if(!("labels"in a[r]))throw new Error("missing channel labels pro= perty: "+r);if(a[r].labels.length!=3D=3Da[r].channels)throw new Error("chan= nel and label counts mismatch: "+r);var o=3Da[r].channels,s=3Da[r].labels;d= elete a[r].channels,delete a[r].labels,Object.defineProperty(a[r],"channels= ",{value:o}),Object.defineProperty(a[r],"labels",{value:s})}a.rgb.hsl=3Dfun= ction(t){var e,n,i=3Dt[0]/255,a=3Dt[1]/255,r=3Dt[2]/255,o=3DMath.min(i,a,r)= ,s=3DMath.max(i,a,r),l=3Ds-o;return s=3D=3D=3Do?e=3D0:i=3D=3D=3Ds?e=3D(a-r)= /l:a=3D=3D=3Ds?e=3D2+(r-i)/l:r=3D=3D=3Ds&&(e=3D4+(i-a)/l),(e=3DMath.min(60*= e,360))<0&&(e+=3D360),n=3D(o+s)/2,[e,100*(s=3D=3D=3Do?0:n<=3D.5?l/(s+o):l/(= 2-s-o)),100*n]},a.rgb.hsv=3Dfunction(t){var e,n,i,a,r,o=3Dt[0]/255,s=3Dt[1]= /255,l=3Dt[2]/255,u=3DMath.max(o,s,l),d=3Du-Math.min(o,s,l),h=3Dfunction(t)= {return(u-t)/6/d+.5};return 0=3D=3D=3Dd?a=3Dr=3D0:(r=3Dd/u,e=3Dh(o),n=3Dh(s= ),i=3Dh(l),o=3D=3D=3Du?a=3Di-n:s=3D=3D=3Du?a=3D1/3+e-i:l=3D=3D=3Du&&(a=3D2/= 3+n-e),a<0?a+=3D1:a>1&&(a-=3D1)),[360*a,100*r,100*u]},a.rgb.hwb=3Dfunction(= t){var e=3Dt[0],n=3Dt[1],i=3Dt[2];return[a.rgb.hsl(t)[0],100*(1/255*Math.mi= n(e,Math.min(n,i))),100*(i=3D1-1/255*Math.max(e,Math.max(n,i)))]},a.rgb.cmy= k=3Dfunction(t){var e,n=3Dt[0]/255,i=3Dt[1]/255,a=3Dt[2]/255;return[100*((1= -n-(e=3DMath.min(1-n,1-i,1-a)))/(1-e)||0),100*((1-i-e)/(1-e)||0),100*((1-a-= e)/(1-e)||0),100*e]},a.rgb.keyword=3Dfunction(t){var i=3Dn[t];if(i)return i= ;var a,r,o,s=3D1/0;for(var l in e)if(e.hasOwnProperty(l)){var u=3De[l],d=3D= (r=3Dt,o=3Du,Math.pow(r[0]-o[0],2)+Math.pow(r[1]-o[1],2)+Math.pow(r[2]-o[2]= ,2));d.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=3Dn>= .04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(i=3Di>.04045?Math.pow((= i+.055)/1.055,2.4):i/12.92)),100*(.2126*e+.7152*n+.0722*i),100*(.0193*e+.11= 92*n+.9505*i)]},a.rgb.lab=3Dfunction(t){var e=3Da.rgb.xyz(t),n=3De[0],i=3De= [1],r=3De[2];return i/=3D100,r/=3D108.883,n=3D(n/=3D95.047)>.008856?Math.po= w(n,1/3):7.787*n+16/116,[116*(i=3Di>.008856?Math.pow(i,1/3):7.787*i+16/116)= -16,500*(n-i),200*(i-(r=3Dr>.008856?Math.pow(r,1/3):7.787*r+16/116))]},a.hs= l.rgb=3Dfunction(t){var e,n,i,a,r,o=3Dt[0]/360,s=3Dt[1]/100,l=3Dt[2]/100;if= (0=3D=3D=3Ds)return[r=3D255*l,r,r];e=3D2*l-(n=3Dl<.5?l*(1+s):l+s-l*s),a=3D[= 0,0,0];for(var u=3D0;u<3;u++)(i=3Do+1/3*-(u-1))<0&&i++,i>1&&i--,r=3D6*i<1?e= +6*(n-e)*i:2*i<1?n:3*i<2?e+(n-e)*(2/3-i)*6:e,a[u]=3D255*r;return a},a.hsl.h= sv=3Dfunction(t){var e=3Dt[0],n=3Dt[1]/100,i=3Dt[2]/100,a=3Dn,r=3DMath.max(= i,.01);return n*=3D(i*=3D2)<=3D1?i:2-i,a*=3Dr<=3D1?r:2-r,[e,100*(0=3D=3D=3D= i?2*a/(r+a):2*n/(i+n)),100*((i+n)/2)]},a.hsv.rgb=3Dfunction(t){var e=3Dt[0]= /60,n=3Dt[1]/100,i=3Dt[2]/100,a=3DMath.floor(e)%6,r=3De-Math.floor(e),o=3D2= 55*i*(1-n),s=3D255*i*(1-n*r),l=3D255*i*(1-n*(1-r));switch(i*=3D255,a){case = 0:return[i,l,o];case 1:return[s,i,o];case 2:return[o,i,l];case 3:return[o,s= ,i];case 4:return[l,o,i];case 5:return[i,o,s]}},a.hsv.hsl=3Dfunction(t){var= e,n,i,a=3Dt[0],r=3Dt[1]/100,o=3Dt[2]/100,s=3DMath.max(o,.01);return i=3D(2= -r)*o,n=3Dr*s,[a,100*(n=3D(n/=3D(e=3D(2-r)*s)<=3D1?e:2-e)||0),100*(i/=3D2)]= },a.hwb.rgb=3Dfunction(t){var e,n,i,a,r,o,s,l=3Dt[0]/360,u=3Dt[1]/100,d=3Dt= [2]/100,h=3Du+d;switch(h>1&&(u/=3Dh,d/=3Dh),i=3D6*l-(e=3DMath.floor(6*l)),0= !=3D(1&e)&&(i=3D1-i),a=3Du+i*((n=3D1-d)-u),e){default:case 6:case 0:r=3Dn,o= =3Da,s=3Du;break;case 1:r=3Da,o=3Dn,s=3Du;break;case 2:r=3Du,o=3Dn,s=3Da;br= eak;case 3:r=3Du,o=3Da,s=3Dn;break;case 4:r=3Da,o=3Du,s=3Dn;break;case 5:r= =3Dn,o=3Du,s=3Da}return[255*r,255*o,255*s]},a.cmyk.rgb=3Dfunction(t){var e= =3Dt[0]/100,n=3Dt[1]/100,i=3Dt[2]/100,a=3Dt[3]/100;return[255*(1-Math.min(1= ,e*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,i*(1-a)+a))]},= a.xyz.rgb=3Dfunction(t){var e,n,i,a=3Dt[0]/100,r=3Dt[1]/100,o=3Dt[2]/100;re= turn n=3D-.9689*a+1.8758*r+.0415*o,i=3D.0557*a+-.204*r+1.057*o,e=3D(e=3D3.2= 406*a+-1.5372*r+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n= =3Dn>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,i=3Di>.0031308?1.055*Mat= h.pow(i,1/2.4)-.055:12.92*i,[255*(e=3DMath.min(Math.max(0,e),1)),255*(n=3DM= ath.min(Math.max(0,n),1)),255*(i=3DMath.min(Math.max(0,i),1))]},a.xyz.lab= =3Dfunction(t){var e=3Dt[0],n=3Dt[1],i=3Dt[2];return n/=3D100,i/=3D108.883,= e=3D(e/=3D95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=3Dn>.00885= 6?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(i=3Di>.008856?Math.p= ow(i,1/3):7.787*i+16/116))]},a.lab.xyz=3Dfunction(t){var e,n,i,a=3Dt[0];e= =3Dt[1]/500+(n=3D(a+16)/116),i=3Dn-t[2]/200;var r=3DMath.pow(n,3),o=3DMath.= pow(e,3),s=3DMath.pow(i,3);return n=3Dr>.008856?r:(n-16/116)/7.787,e=3Do>.0= 08856?o:(e-16/116)/7.787,i=3Ds>.008856?s:(i-16/116)/7.787,[e*=3D95.047,n*= =3D100,i*=3D108.883]},a.lab.lch=3Dfunction(t){var e,n=3Dt[0],i=3Dt[1],a=3Dt= [2];return(e=3D360*Math.atan2(a,i)/2/Math.PI)<0&&(e+=3D360),[n,Math.sqrt(i*= i+a*a),e]},a.lch.lab=3Dfunction(t){var e,n=3Dt[0],i=3Dt[1];return e=3Dt[2]/= 360*2*Math.PI,[n,i*Math.cos(e),i*Math.sin(e)]},a.rgb.ansi16=3Dfunction(t){v= ar e=3Dt[0],n=3Dt[1],i=3Dt[2],r=3D1 in arguments?arguments[1]:a.rgb.hsv(t)[= 2];if(0=3D=3D=3D(r=3DMath.round(r/50)))return 30;var o=3D30+(Math.round(i/2= 55)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2=3D=3D=3Dr&&(o+=3D60= ),o},a.hsv.ansi16=3Dfunction(t){return a.rgb.ansi16(a.hsv.rgb(t),t[2])},a.r= gb.ansi256=3Dfunction(t){var e=3Dt[0],n=3Dt[1],i=3Dt[2];return e=3D=3D=3Dn&= &n=3D=3D=3Di?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round= (e/255*5)+6*Math.round(n/255*5)+Math.round(i/255*5)},a.ansi16.rgb=3Dfunctio= n(t){var e=3Dt%10;if(0=3D=3D=3De||7=3D=3D=3De)return t>50&&(e+=3D3.5),[e=3D= e/10.5*255,e,e];var n=3D.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(= e>>2&1)*n*255]},a.ansi256.rgb=3Dfunction(t){if(t>=3D232){var e=3D10*(t-232)= +8;return[e,e,e]}var n;return t-=3D16,[Math.floor(t/36)/5*255,Math.floor((n= =3Dt%36)/6)/5*255,n%6/5*255]},a.rgb.hex=3Dfunction(t){var e=3D(((255&Math.r= ound(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toStri= ng(16).toUpperCase();return"000000".substring(e.length)+e},a.hex.rgb=3Dfunc= tion(t){var e=3Dt.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)retu= rn[0,0,0];var n=3De[0];3=3D=3D=3De[0].length&&(n=3Dn.split("").map((functio= n(t){return t+t})).join(""));var i=3DparseInt(n,16);return[i>>16&255,i>>8&2= 55,255&i]},a.rgb.hcg=3Dfunction(t){var e,n=3Dt[0]/255,i=3Dt[1]/255,a=3Dt[2]= /255,r=3DMath.max(Math.max(n,i),a),o=3DMath.min(Math.min(n,i),a),s=3Dr-o;re= turn e=3Ds<=3D0?0:r=3D=3D=3Dn?(i-a)/s%6:r=3D=3D=3Di?2+(a-n)/s:4+(n-i)/s+4,e= /=3D6,[360*(e%=3D1),100*s,100*(s<1?o/(1-s):0)]},a.hsl.hcg=3Dfunction(t){var= e=3Dt[1]/100,n=3Dt[2]/100,i=3D1,a=3D0;return(i=3Dn<.5?2*e*n:2*e*(1-n))<1&&= (a=3D(n-.5*i)/(1-i)),[t[0],100*i,100*a]},a.hsv.hcg=3Dfunction(t){var e=3Dt[= 1]/100,n=3Dt[2]/100,i=3De*n,a=3D0;return i<1&&(a=3D(n-i)/(1-i)),[t[0],100*i= ,100*a]},a.hcg.rgb=3Dfunction(t){var e=3Dt[0]/360,n=3Dt[1]/100,i=3Dt[2]/100= ;if(0=3D=3D=3Dn)return[255*i,255*i,255*i];var a,r=3D[0,0,0],o=3De%1*6,s=3Do= %1,l=3D1-s;switch(Math.floor(o)){case 0:r[0]=3D1,r[1]=3Ds,r[2]=3D0;break;ca= se 1:r[0]=3Dl,r[1]=3D1,r[2]=3D0;break;case 2:r[0]=3D0,r[1]=3D1,r[2]=3Ds;bre= ak;case 3:r[0]=3D0,r[1]=3Dl,r[2]=3D1;break;case 4:r[0]=3Ds,r[1]=3D0,r[2]=3D= 1;break;default:r[0]=3D1,r[1]=3D0,r[2]=3Dl}return a=3D(1-n)*i,[255*(n*r[0]+= a),255*(n*r[1]+a),255*(n*r[2]+a)]},a.hcg.hsv=3Dfunction(t){var e=3Dt[1]/100= ,n=3De+t[2]/100*(1-e),i=3D0;return n>0&&(i=3De/n),[t[0],100*i,100*n]},a.hcg= .hsl=3Dfunction(t){var e=3Dt[1]/100,n=3Dt[2]/100*(1-e)+.5*e,i=3D0;return n>= 0&&n<.5?i=3De/(2*n):n>=3D.5&&n<1&&(i=3De/(2*(1-n))),[t[0],100*i,100*n]},a.h= cg.hwb=3Dfunction(t){var e=3Dt[1]/100,n=3De+t[2]/100*(1-e);return[t[0],100*= (n-e),100*(1-n)]},a.hwb.hcg=3Dfunction(t){var e=3Dt[1]/100,n=3D1-t[2]/100,i= =3Dn-e,a=3D0;return i<1&&(a=3D(n-i)/(1-i)),[t[0],100*i,100*a]},a.apple.rgb= =3Dfunction(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},a.rgb.= apple=3Dfunction(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},a= .gray.rgb=3Dfunction(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},a.g= ray.hsl=3Da.gray.hsv=3Dfunction(t){return[0,0,t[0]]},a.gray.hwb=3Dfunction(= t){return[0,100,t[0]]},a.gray.cmyk=3Dfunction(t){return[0,0,0,t[0]]},a.gray= .lab=3Dfunction(t){return[t[0],0,0]},a.gray.hex=3Dfunction(t){var e=3D255&M= ath.round(t[0]/100*255),n=3D((e<<16)+(e<<8)+e).toString(16).toUpperCase();r= eturn"000000".substring(n.length)+n},a.rgb.gray=3Dfunction(t){return[(t[0]+= t[1]+t[2])/3/255*100]}}));n.rgb,n.hsl,n.hsv,n.hwb,n.cmyk,n.xyz,n.lab,n.lch,= n.hex,n.keyword,n.ansi16,n.ansi256,n.hcg,n.apple,n.gray;function i(t){var e= =3Dfunction(){for(var t=3D{},e=3DObject.keys(n),i=3De.length,a=3D0;a1&&(e=3DArray.prototype.slice.call(arguments));var n=3Dt(e);if("object"=3D= =3Dtypeof n)for(var i=3Dn.length,a=3D0;a1&&(e=3DArray.prototype.slice.call(arguments)),t(e))};return"conversion"in= t&&(e.conversion=3Dt.conversion),e}(i)}))}));var s=3Do,l=3D{aliceblue:[240= ,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,2= 12],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0= ,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],bro= wn:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[1= 27,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149= ,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:= [0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169= ,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],da= rkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],dar= korchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagree= n:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslat= egrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:= [255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105= ,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,24= 0],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghos= twhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,= 128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[= 240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],= ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblus= h:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:= [173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenr= odyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lig= htgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],ligh= tseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,1= 53],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[= 255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magen= ta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[= 0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagree= n:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],= mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,= 25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,1= 81],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[1= 28,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],or= chid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],pale= turquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213= ],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,16= 0,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,15= 3],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown= :[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,= 87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:= [135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112= ,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180]= ,tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71= ],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[25= 5,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205= ,50]},u=3D{getRgba:d,getHsla:h,getRgb:function(t){var e=3Dd(t);return e&&e.= slice(0,3)},getHsl:function(t){var e=3Dh(t);return e&&e.slice(0,3)},getHwb:= c,getAlpha:function(t){var e=3Dd(t);if(e)return e[3];if(e=3Dh(t))return e[3= ];if(e=3Dc(t))return e[3]},hexString:function(t,e){e=3Dvoid 0!=3D=3De&&3=3D= =3D=3Dt.length?e:t[3];return"#"+v(t[0])+v(t[1])+v(t[2])+(e>=3D0&&e<1?v(Math= .round(255*e)):"")},rgbString:function(t,e){if(e<1||t[3]&&t[3]<1)return f(t= ,e);return"rgb("+t[0]+", "+t[1]+", "+t[2]+")"},rgbaString:f,percentString:f= unction(t,e){if(e<1||t[3]&&t[3]<1)return g(t,e);var n=3DMath.round(t[0]/255= *100),i=3DMath.round(t[1]/255*100),a=3DMath.round(t[2]/255*100);return"rgb(= "+n+"%, "+i+"%, "+a+"%)"},percentaString:g,hslString:function(t,e){if(e<1||= t[3]&&t[3]<1)return p(t,e);return"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"},hsl= aString:p,hwbString:function(t,e){void 0=3D=3D=3De&&(e=3Dvoid 0!=3D=3Dt[3]?= t[3]:1);return"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!=3D=3De&&1!=3D= =3De?", "+e:"")+")"},keyword:function(t){return b[t.slice(0,3)]}};function = d(t){if(t){var e=3D[0,0,0],n=3D1,i=3Dt.match(/^#([a-fA-F0-9]{3,4})$/i),a=3D= "";if(i){a=3D(i=3Di[1])[3];for(var r=3D0;rn?(e+.05)/(n+.05):(n+.05)/(e+.05= )},level:function(t){var e=3Dthis.contrast(t);return e>=3D7.1?"AAA":e>=3D4.= 5?"AA":""},dark:function(){var t=3Dthis.values.rgb;return(299*t[0]+587*t[1]= +114*t[2])/1e3<128},light:function(){return!this.dark()},negate:function(){= for(var t=3D[],e=3D0;e<3;e++)t[e]=3D255-this.values.rgb[e];return this.setV= alues("rgb",t),this},lighten:function(t){var e=3Dthis.values.hsl;return e[2= ]+=3De[2]*t,this.setValues("hsl",e),this},darken:function(t){var e=3Dthis.v= alues.hsl;return e[2]-=3De[2]*t,this.setValues("hsl",e),this},saturate:func= tion(t){var e=3Dthis.values.hsl;return e[1]+=3De[1]*t,this.setValues("hsl",= e),this},desaturate:function(t){var e=3Dthis.values.hsl;return e[1]-=3De[1]= *t,this.setValues("hsl",e),this},whiten:function(t){var e=3Dthis.values.hwb= ;return e[1]+=3De[1]*t,this.setValues("hwb",e),this},blacken:function(t){va= r e=3Dthis.values.hwb;return e[2]+=3De[2]*t,this.setValues("hwb",e),this},g= reyscale:function(){var t=3Dthis.values.rgb,e=3D.3*t[0]+.59*t[1]+.11*t[2];r= eturn this.setValues("rgb",[e,e,e]),this},clearer:function(t){var e=3Dthis.= values.alpha;return this.setValues("alpha",e-e*t),this},opaquer:function(t)= {var e=3Dthis.values.alpha;return this.setValues("alpha",e+e*t),this},rotat= e:function(t){var e=3Dthis.values.hsl,n=3D(e[0]+t)%360;return e[0]=3Dn<0?36= 0+n:n,this.setValues("hsl",e),this},mix:function(t,e){var n=3Dt,i=3Dvoid 0= =3D=3D=3De?.5:e,a=3D2*i-1,r=3Dthis.alpha()-n.alpha(),o=3D((a*r=3D=3D-1?a:(a= +r)/(1+a*r))+1)/2,s=3D1-o;return this.rgb(o*this.red()+s*n.red(),o*this.gre= en()+s*n.green(),o*this.blue()+s*n.blue()).alpha(this.alpha()*i+n.alpha()*(= 1-i))},toJSON:function(){return this.rgb()},clone:function(){var t,e,n=3Dne= w y,i=3Dthis.values,a=3Dn.values;for(var r in i)i.hasOwnProperty(r)&&(t=3Di= [r],"[object Array]"=3D=3D=3D(e=3D{}.toString.call(t))?a[r]=3Dt.slice(0):"[= object Number]"=3D=3D=3De?a[r]=3Dt:console.error("unexpected color value:",= t));return n}},y.prototype.spaces=3D{rgb:["red","green","blue"],hsl:["hue",= "saturation","lightness"],hsv:["hue","saturation","value"],hwb:["hue","whit= eness","blackness"],cmyk:["cyan","magenta","yellow","black"]},y.prototype.m= axes=3D{rgb:[255,255,255],hsl:[360,100,100],hsv:[360,100,100],hwb:[360,100,= 100],cmyk:[100,100,100,100]},y.prototype.getValues=3Dfunction(t){for(var e= =3Dthis.values,n=3D{},i=3D0;i=3D0;a--)e.call= (n,t[a],a);else for(a=3D0;a=3D1?t:-(Math.sqrt(1-t*t= )-1)},easeOutCirc:function(t){return Math.sqrt(1-(t-=3D1)*t)},easeInOutCirc= :function(t){return(t/=3D.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-= =3D2)*t)+1)},easeInElastic:function(t){var e=3D1.70158,n=3D0,i=3D1;return 0= =3D=3D=3Dt?0:1=3D=3D=3Dt?1:(n||(n=3D.3),i<1?(i=3D1,e=3Dn/4):e=3Dn/(2*Math.P= I)*Math.asin(1/i),-i*Math.pow(2,10*(t-=3D1))*Math.sin((t-e)*(2*Math.PI)/n))= },easeOutElastic:function(t){var e=3D1.70158,n=3D0,i=3D1;return 0=3D=3D=3Dt= ?0:1=3D=3D=3Dt?1:(n||(n=3D.3),i<1?(i=3D1,e=3Dn/4):e=3Dn/(2*Math.PI)*Math.as= in(1/i),i*Math.pow(2,-10*t)*Math.sin((t-e)*(2*Math.PI)/n)+1)},easeInOutElas= tic:function(t){var e=3D1.70158,n=3D0,i=3D1;return 0=3D=3D=3Dt?0:2=3D=3D(t/= =3D.5)?1:(n||(n=3D.45),i<1?(i=3D1,e=3Dn/4):e=3Dn/(2*Math.PI)*Math.asin(1/i)= ,t<1?i*Math.pow(2,10*(t-=3D1))*Math.sin((t-e)*(2*Math.PI)/n)*-.5:i*Math.pow= (2,-10*(t-=3D1))*Math.sin((t-e)*(2*Math.PI)/n)*.5+1)},easeInBack:function(t= ){var e=3D1.70158;return t*t*((e+1)*t-e)},easeOutBack:function(t){var e=3D1= .70158;return(t-=3D1)*t*((e+1)*t+e)+1},easeInOutBack:function(t){var e=3D1.= 70158;return(t/=3D.5)<1?t*t*((1+(e*=3D1.525))*t-e)*.5:.5*((t-=3D2)*t*((1+(e= *=3D1.525))*t+e)+2)},easeInBounce:function(t){return 1-C.easeOutBounce(1-t)= },easeOutBounce:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-= =3D1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=3D2.25/2.75)*t+.9375:7.5625*(t-=3D= 2.625/2.75)*t+.984375},easeInOutBounce:function(t){return t<.5?.5*C.easeInB= ounce(2*t):.5*C.easeOutBounce(2*t-1)+.5}},P=3D{effects:C};S.easingEffects= =3DC;var A=3DMath.PI,D=3DA/180,T=3D2*A,I=3DA/2,F=3DA/4,O=3D2*A/3,L=3D{clear= :function(t){t.ctx.clearRect(0,0,t.width,t.height)},roundedRect:function(t,= e,n,i,a,r){if(r){var o=3DMath.min(r,a/2,i/2),s=3De+o,l=3Dn+o,u=3De+i-o,d=3D= n+a-o;t.moveTo(e,l),se.left-1e-6&&t.x<= e.right+1e-6&&t.y>e.top-1e-6&&t.y0&&this.requestAnimationFrame(= )},advance:function(){for(var t,e,n,i,a=3Dthis.animations,r=3D0;r=3Dn?(H.callback(t.= onAnimationComplete,[t],e),e.animating=3D!1,a.splice(r,1)):++r}},Q=3DH.opti= ons.resolve,tt=3D["push","pop","shift","splice","unshift"];function et(t,e)= {var n=3Dt._chartjs;if(n){var i=3Dn.listeners,a=3Di.indexOf(e);-1!=3D=3Da&&= i.splice(a,1),i.length>0||(tt.forEach((function(e){delete t[e]})),delete t.= _chartjs)}}var nt=3Dfunction(t,e){this.initialize(t,e)};H.extend(nt.prototy= pe,{datasetElementType:null,dataElementType:null,_datasetElementOptions:["b= ackgroundColor","borderCapStyle","borderColor","borderDash","borderDashOffs= et","borderJoinStyle","borderWidth"],_dataElementOptions:["backgroundColor"= ,"borderColor","borderWidth","pointStyle"],initialize:function(t,e){var n= =3Dthis;n.chart=3Dt,n.index=3De,n.linkScales(),n.addElements(),n._type=3Dn.= getMeta().type},updateIndex:function(t){this.index=3Dt},linkScales:function= (){var t=3Dthis.getMeta(),e=3Dthis.chart,n=3De.scales,i=3Dthis.getDataset()= ,a=3De.options.scales;null!=3D=3Dt.xAxisID&&t.xAxisID in n&&!i.xAxisID||(t.= xAxisID=3Di.xAxisID||a.xAxes[0].id),null!=3D=3Dt.yAxisID&&t.yAxisID in n&&!= i.yAxisID||(t.yAxisID=3Di.yAxisID||a.yAxes[0].id)},getDataset:function(){re= turn this.chart.data.datasets[this.index]},getMeta:function(){return this.c= hart.getDatasetMeta(this.index)},getScaleForId:function(t){return this.char= t.scales[t]},_getValueScaleId:function(){return this.getMeta().yAxisID},_ge= tIndexScaleId:function(){return this.getMeta().xAxisID},_getValueScale:func= tion(){return this.getScaleForId(this._getValueScaleId())},_getIndexScale:f= unction(){return this.getScaleForId(this._getIndexScaleId())},reset:functio= n(){this._update(!0)},destroy:function(){this._data&&et(this._data,this)},c= reateMetaDataset:function(){var t=3Dthis.datasetElementType;return t&&new t= ({_chart:this.chart,_datasetIndex:this.index})},createMetaData:function(t){= var e=3Dthis.dataElementType;return e&&new e({_chart:this.chart,_datasetInd= ex:this.index,_index:t})},addElements:function(){var t,e,n=3Dthis.getMeta()= ,i=3Dthis.getDataset().data||[],a=3Dn.data;for(t=3D0,e=3Di.length;tn&&this.insertElements(n,i-n)},insertElements:function(t,e)= {for(var n=3D0;na?(r=3Da/e.innerRadius,t.arc(o,= s,e.innerRadius-a,i+r,n-r,!0)):t.arc(o,s,a,i+Math.PI/2,n-Math.PI/2),t.close= Path(),t.clip()}function ot(t,e,n){var i=3D"inner"=3D=3D=3De.borderAlign;i?= (t.lineWidth=3D2*e.borderWidth,t.lineJoin=3D"round"):(t.lineWidth=3De.borde= rWidth,t.lineJoin=3D"bevel"),n.fullCircles&&function(t,e,n,i){var a,r=3Dn.e= ndAngle;for(i&&(n.endAngle=3Dn.startAngle+at,rt(t,n),n.endAngle=3Dr,n.endAn= gle=3D=3D=3Dn.startAngle&&n.fullCircles&&(n.endAngle+=3Dat,n.fullCircles--)= ),t.beginPath(),t.arc(n.x,n.y,n.innerRadius,n.startAngle+at,n.startAngle,!0= ),a=3D0;as;)a-=3Dat;for(;a=3Do&&a<=3Ds,u=3Dr>=3Dn.in= nerRadius&&r<=3Dn.outerRadius;return l&&u}return!1},getCenterPoint:function= (){var t=3Dthis._view,e=3D(t.startAngle+t.endAngle)/2,n=3D(t.innerRadius+t.= outerRadius)/2;return{x:t.x+Math.cos(e)*n,y:t.y+Math.sin(e)*n}},getArea:fun= ction(){var t=3Dthis._view;return Math.PI*((t.endAngle-t.startAngle)/(2*Mat= h.PI))*(Math.pow(t.outerRadius,2)-Math.pow(t.innerRadius,2))},tooltipPositi= on:function(){var t=3Dthis._view,e=3Dt.startAngle+(t.endAngle-t.startAngle)= /2,n=3D(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(= e)*n,y:t.y+Math.sin(e)*n}},draw:function(){var t,e=3Dthis._chart.ctx,n=3Dth= is._view,i=3D"inner"=3D=3D=3Dn.borderAlign?.33:0,a=3D{x:n.x,y:n.y,innerRadi= us:n.innerRadius,outerRadius:Math.max(n.outerRadius-i,0),pixelMargin:i,star= tAngle:n.startAngle,endAngle:n.endAngle,fullCircles:Math.floor(n.circumfere= nce/at)};if(e.save(),e.fillStyle=3Dn.backgroundColor,e.strokeStyle=3Dn.bord= erColor,a.fullCircles){for(a.endAngle=3Da.startAngle+at,e.beginPath(),e.arc= (a.x,a.y,a.outerRadius,a.startAngle,a.endAngle),e.arc(a.x,a.y,a.innerRadius= ,a.endAngle,a.startAngle,!0),e.closePath(),t=3D0;tt.x&&(e=3Dbt(e,"left","right")):t.base= n?n:i,r:l.right||a<0?0:a>e?e:a,b:l.bottom||r<0?0= :r>n?n:r,l:l.left||o<0?0:o>e?e:o}}function yt(t,e,n){var i=3Dnull=3D=3D=3De= ,a=3Dnull=3D=3D=3Dn,r=3D!(!t||i&&a)&&vt(t);return r&&(i||e>=3Dr.left&&e<=3D= r.right)&&(a||n>=3Dr.top&&n<=3Dr.bottom)}N._set("global",{elements:{rectang= le:{backgroundColor:pt,borderColor:pt,borderSkipped:"bottom",borderWidth:0}= }});var _t=3DK.extend({_type:"rectangle",draw:function(){var t=3Dthis._char= t.ctx,e=3Dthis._view,n=3Dfunction(t){var e=3Dvt(t),n=3De.right-e.left,i=3De= .bottom-e.top,a=3Dxt(t,n/2,i/2);return{outer:{x:e.left,y:e.top,w:n,h:i},inn= er:{x:e.left+a.l,y:e.top+a.t,w:n-a.l-a.r,h:i-a.t-a.b}}}(e),i=3Dn.outer,a=3D= n.inner;t.fillStyle=3De.backgroundColor,t.fillRect(i.x,i.y,i.w,i.h),i.w=3D= =3D=3Da.w&&i.h=3D=3D=3Da.h||(t.save(),t.beginPath(),t.rect(i.x,i.y,i.w,i.h)= ,t.clip(),t.fillStyle=3De.borderColor,t.rect(a.x,a.y,a.w,a.h),t.fill("eveno= dd"),t.restore())},height:function(){var t=3Dthis._view;return t.base-t.y},= inRange:function(t,e){return yt(this._view,t,e)},inLabelRange:function(t,e)= {var n=3Dthis._view;return mt(n)?yt(n,t,null):yt(n,null,e)},inXRange:functi= on(t){return yt(this._view,t,null)},inYRange:function(t){return yt(this._vi= ew,null,t)},getCenterPoint:function(){var t,e,n=3Dthis._view;return mt(n)?(= t=3Dn.x,e=3D(n.y+n.base)/2):(t=3D(n.x+n.base)/2,e=3Dn.y),{x:t,y:e}},getArea= :function(){var t=3Dthis._view;return mt(t)?t.width*Math.abs(t.y-t.base):t.= height*Math.abs(t.x-t.base)},tooltipPosition:function(){var t=3Dthis._view;= return{x:t.x,y:t.y}}}),kt=3D{},wt=3Dst,Mt=3Ddt,St=3Dgt,Ct=3D_t;kt.Arc=3Dwt,= kt.Line=3DMt,kt.Point=3DSt,kt.Rectangle=3DCt;var Pt=3DH._deprecated,At=3DH.= valueOrDefault;function Dt(t,e,n){var i,a,r=3Dn.barThickness,o=3De.stackCou= nt,s=3De.pixels[t],l=3DH.isNullOrUndef(r)?function(t,e){var n,i,a,r,o=3Dt._= length;for(a=3D1,r=3De.length;a0= ?Math.min(o,Math.abs(i-n)):o,n=3Di;return o}(e.scale,e.pixels):-1;return H.= isNullOrUndef(r)?(i=3Dl*n.categoryPercentage,a=3Dn.barPercentage):(i=3Dr*o,= a=3D1),{chunk:i/o,ratio:a,start:s-i/2}}N._set("bar",{hover:{mode:"label"},s= cales:{xAxes:[{type:"category",offset:!0,gridLines:{offsetGridLines:!0}}],y= Axes:[{type:"linear"}]}}),N._set("global",{datasets:{bar:{categoryPercentag= e:.8,barPercentage:.9}}});var Tt=3Dit.extend({dataElementType:kt.Rectangle,= _dataElementOptions:["backgroundColor","borderColor","borderSkipped","borde= rWidth","barPercentage","barThickness","categoryPercentage","maxBarThicknes= s","minBarLength"],initialize:function(){var t,e,n=3Dthis;it.prototype.init= ialize.apply(n,arguments),(t=3Dn.getMeta()).stack=3Dn.getDataset().stack,t.= bar=3D!0,e=3Dn._getIndexScale().options,Pt("bar chart",e.barPercentage,"sca= les.[x/y]Axes.barPercentage","dataset.barPercentage"),Pt("bar chart",e.barT= hickness,"scales.[x/y]Axes.barThickness","dataset.barThickness"),Pt("bar ch= art",e.categoryPercentage,"scales.[x/y]Axes.categoryPercentage","dataset.ca= tegoryPercentage"),Pt("bar chart",n._getValueScale().options.minBarLength,"= scales.[x/y]Axes.minBarLength","dataset.minBarLength"),Pt("bar chart",e.max= BarThickness,"scales.[x/y]Axes.maxBarThickness","dataset.maxBarThickness")}= ,update:function(t){var e,n,i=3Dthis.getMeta().data;for(this._ruler=3Dthis.= getRuler(),e=3D0,n=3Di.length;e=3D0&&p.min>=3D0?p.min:p.max,y=3Dvoid 0=3D=3D=3Dp.start?p.end:p.max>=3D0&&= p.min>=3D0?p.max-p.min:p.min-p.max,_=3Dg.length;if(v||void 0=3D=3D=3Dv&&voi= d 0!=3D=3Db)for(i=3D0;i<_&&(a=3Dg[i]).index!=3D=3Dt;++i)a.stack=3D=3D=3Db&&= (r=3Dvoid 0=3D=3D=3D(u=3Dh._parseValue(f[a.index].data[e])).start?u.end:u.m= in>=3D0&&u.max>=3D0?u.max:u.min,(p.min<0&&r<0||p.max>=3D0&&r>0)&&(x+=3Dr));= return o=3Dh.getPixelForValue(x),l=3D(s=3Dh.getPixelForValue(x+y))-o,void 0= !=3D=3Dm&&Math.abs(l)=3D0&&!c||y<0&&c?o-m:o+m),{size:l,bas= e:o,head:s,center:s+l/2}},calculateBarIndexPixels:function(t,e,n,i){var a= =3D"flex"=3D=3D=3Di.barThickness?function(t,e,n){var i,a=3De.pixels,r=3Da[t= ],o=3Dt>0?a[t-1]:null,s=3Dt=3DRt?-zt:b<-Rt?zt:0)+m,y=3DMath.cos(b),_=3DMath.sin= (b),k=3DMath.cos(x),w=3DMath.sin(x),M=3Db<=3D0&&x>=3D0||x>=3Dzt,S=3Db<=3DNt= &&x>=3DNt||x>=3Dzt+Nt,C=3Db<=3D-Nt&&x>=3D-Nt||x>=3DRt+Nt,P=3Db=3D=3D=3D-Rt|= |x>=3DRt?-1:Math.min(y,y*p,k,k*p),A=3DC?-1:Math.min(_,_*p,w,w*p),D=3DM?1:Ma= th.max(y,y*p,k,k*p),T=3DS?1:Math.max(_,_*p,w,w*p);u=3D(D-P)/2,d=3D(T-A)/2,h= =3D-(D+P)/2,c=3D-(T+A)/2}for(i=3D0,a=3Dg.length;i0&&!isN= aN(t)?zt*(Math.abs(t)/e):0},getMaxBorderWidth:function(t){var e,n,i,a,r,o,s= ,l,u=3D0,d=3Dthis.chart;if(!t)for(e=3D0,n=3Dd.data.datasets.length;e(u=3Ds>u?s:u)?l:u);return u},setHoverStyle:function(t){var e=3Dt.= _model,n=3Dt._options,i=3DH.getHoverColor;t.$previousStyle=3D{backgroundCol= or:e.backgroundColor,borderColor:e.borderColor,borderWidth:e.borderWidth},e= .backgroundColor=3DLt(n.hoverBackgroundColor,i(n.backgroundColor)),e.border= Color=3DLt(n.hoverBorderColor,i(n.borderColor)),e.borderWidth=3DLt(n.hoverB= orderWidth,n.borderWidth)},_getRingWeightOffset:function(t){for(var e=3D0,n= =3D0;n0&&Ht(l[t-1]._model,s)&&(n.controlPointPreviousX=3Du(n.controlPointP= reviousX,s.left,s.right),n.controlPointPreviousY=3Du(n.controlPointPrevious= Y,s.top,s.bottom)),t0&&(r=3Dt.getDatasetMeta(r[0]._datasetIndex).data),r},"x-ax= is":function(t,e){return ae(t,e,{intersect:!1})},point:function(t,e){return= ee(t,Qt(e,t))},nearest:function(t,e,n){var i=3DQt(e,t);n.axis=3Dn.axis||"x= y";var a=3Die(n.axis);return ne(t,i,n.intersect,a)},x:function(t,e,n){var i= =3DQt(e,t),a=3D[],r=3D!1;return te(t,(function(t){t.inXRange(i.x)&&a.push(t= ),t.inRange(i.x,i.y)&&(r=3D!0)})),n.intersect&&!r&&(a=3D[]),a},y:function(t= ,e,n){var i=3DQt(e,t),a=3D[],r=3D!1;return te(t,(function(t){t.inYRange(i.y= )&&a.push(t),t.inRange(i.x,i.y)&&(r=3D!0)})),n.intersect&&!r&&(a=3D[]),a}}}= ,oe=3DH.extend;function se(t,e){return H.where(t,(function(t){return t.pos= =3D=3D=3De}))}function le(t,e){return t.sort((function(t,n){var i=3De?n:t,a= =3De?t:n;return i.weight=3D=3D=3Da.weight?i.index-a.index:i.weight-a.weight= }))}function ue(t,e,n,i){return Math.max(t[n],e[n])+Math.max(t[i],e[i])}fun= ction de(t,e,n){var i,a,r=3Dn.box,o=3Dt.maxPadding;if(n.size&&(t[n.pos]-=3D= n.size),n.size=3Dn.horizontal?r.height:r.width,t[n.pos]+=3Dn.size,r.getPadd= ing){var s=3Dr.getPadding();o.top=3DMath.max(o.top,s.top),o.left=3DMath.max= (o.left,s.left),o.bottom=3DMath.max(o.bottom,s.bottom),o.right=3DMath.max(o= .right,s.right)}if(i=3De.outerWidth-ue(o,t,"left","right"),a=3De.outerHeigh= t-ue(o,t,"top","bottom"),i!=3D=3Dt.w||a!=3D=3Dt.h){t.w=3Di,t.h=3Da;var l=3D= n.horizontal?[i,t.w]:[a,t.h];return!(l[0]=3D=3D=3Dl[1]||isNaN(l[0])&&isNaN(= l[1]))}}function he(t,e){var n=3De.maxPadding;function i(t){var i=3D{left:0= ,top:0,right:0,bottom:0};return t.forEach((function(t){i[t]=3DMath.max(e[t]= ,n[t])})),i}return i(t?["left","right"]:["top","bottom"])}function ce(t,e,n= ){var i,a,r,o,s,l,u=3D[];for(i=3D0,a=3Dt.length;idiv{position:absolut= e;width:1000000px;height:1000000px;left:0;top:0}.chartjs-size-monitor-shrin= k>div{position:absolute;width:200%;height:200%;left:0;top:0}"}))&&ge.defaul= t||ge,ve=3D"$chartjs",be=3D"chartjs-size-monitor",xe=3D"chartjs-render-moni= tor",ye=3D"chartjs-render-animation",_e=3D["animationstart","webkitAnimatio= nStart"],ke=3D{touchstart:"mousedown",touchmove:"mousemove",touchend:"mouse= up",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemov= e",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"};funct= ion we(t,e){var n=3DH.getStyle(t,e),i=3Dn&&n.match(/^(\d+)(\.\d+)?px$/);ret= urn i?Number(i[1]):void 0}var Me=3D!!function(){var t=3D!1;try{var e=3DObje= ct.defineProperty({},"passive",{get:function(){t=3D!0}});window.addEventLis= tener("e",null,e)}catch(t){}return t}()&&{passive:!0};function Se(t,e,n){t.= addEventListener(e,n,Me)}function Ce(t,e,n){t.removeEventListener(e,n,Me)}f= unction Pe(t,e,n,i,a){return{type:t,chart:e,native:a||null,x:void 0!=3D=3Dn= ?n:null,y:void 0!=3D=3Di?i:null}}function Ae(t){var e=3Ddocument.createElem= ent("div");return e.className=3Dt||"",e}function De(t,e,n){var i,a,r,o,s=3D= t[ve]||(t[ve]=3D{}),l=3Ds.resizer=3Dfunction(t){var e=3DAe(be),n=3DAe(be+"-= expand"),i=3DAe(be+"-shrink");n.appendChild(Ae()),i.appendChild(Ae()),e.app= endChild(n),e.appendChild(i),e._reset=3Dfunction(){n.scrollLeft=3D1e6,n.scr= ollTop=3D1e6,i.scrollLeft=3D1e6,i.scrollTop=3D1e6};var a=3Dfunction(){e._re= set(),t()};return Se(n,"scroll",a.bind(n,"expand")),Se(i,"scroll",a.bind(i,= "shrink")),e}((i=3Dfunction(){if(s.resizer){var i=3Dn.options.maintainAspec= tRatio&&t.parentNode,a=3Di?i.clientWidth:0;e(Pe("resize",n)),i&&i.clientWid= th0){var r=3Dt[0];r.label?n=3Dr.label:r.xLa= bel?n=3Dr.xLabel:a>0&&r.index-1?t.split("\n"):t}function V= e(t){var e=3DN.global;return{xPadding:t.xPadding,yPadding:t.yPadding,xAlign= :t.xAlign,yAlign:t.yAlign,rtl:t.rtl,textDirection:t.textDirection,bodyFontC= olor:t.bodyFontColor,_bodyFontFamily:ze(t.bodyFontFamily,e.defaultFontFamil= y),_bodyFontStyle:ze(t.bodyFontStyle,e.defaultFontStyle),_bodyAlign:t.bodyA= lign,bodyFontSize:ze(t.bodyFontSize,e.defaultFontSize),bodySpacing:t.bodySp= acing,titleFontColor:t.titleFontColor,_titleFontFamily:ze(t.titleFontFamily= ,e.defaultFontFamily),_titleFontStyle:ze(t.titleFontStyle,e.defaultFontStyl= e),titleFontSize:ze(t.titleFontSize,e.defaultFontSize),_titleAlign:t.titleA= lign,titleSpacing:t.titleSpacing,titleMarginBottom:t.titleMarginBottom,foot= erFontColor:t.footerFontColor,_footerFontFamily:ze(t.footerFontFamily,e.def= aultFontFamily),_footerFontStyle:ze(t.footerFontStyle,e.defaultFontStyle),f= ooterFontSize:ze(t.footerFontSize,e.defaultFontSize),_footerAlign:t.footerA= lign,footerSpacing:t.footerSpacing,footerMarginTop:t.footerMarginTop,caretS= ize:t.caretSize,cornerRadius:t.cornerRadius,backgroundColor:t.backgroundCol= or,opacity:0,legendColorBackground:t.multiKeyBackground,displayColors:t.dis= playColors,borderColor:t.borderColor,borderWidth:t.borderWidth}}function He= (t,e){return"center"=3D=3D=3De?t.x+t.width/2:"right"=3D=3D=3De?t.x+t.width-= t.xPadding:t.x+t.xPadding}function je(t){return Ee([],We(t))}var qe=3DK.ext= end({initialize:function(){this._model=3DVe(this._options),this._lastActive= =3D[]},getTitle:function(){var t=3Dthis,e=3Dt._options,n=3De.callbacks,i=3D= n.beforeTitle.apply(t,arguments),a=3Dn.title.apply(t,arguments),r=3Dn.after= Title.apply(t,arguments),o=3D[];return o=3DEe(o,We(i)),o=3DEe(o,We(a)),o=3D= Ee(o,We(r))},getBeforeBody:function(){return je(this._options.callbacks.bef= oreBody.apply(this,arguments))},getBody:function(t,e){var n=3Dthis,i=3Dn._o= ptions.callbacks,a=3D[];return H.each(t,(function(t){var r=3D{before:[],lin= es:[],after:[]};Ee(r.before,We(i.beforeLabel.call(n,t,e))),Ee(r.lines,i.lab= el.call(n,t,e)),Ee(r.after,We(i.afterLabel.call(n,t,e))),a.push(r)})),a},ge= tAfterBody:function(){return je(this._options.callbacks.afterBody.apply(thi= s,arguments))},getFooter:function(){var t=3Dthis,e=3Dt._options.callbacks,n= =3De.beforeFooter.apply(t,arguments),i=3De.footer.apply(t,arguments),a=3De.= afterFooter.apply(t,arguments),r=3D[];return r=3DEe(r,We(n)),r=3DEe(r,We(i)= ),r=3DEe(r,We(a))},update:function(t){var e,n,i,a,r,o,s,l,u,d,h=3Dthis,c=3D= h._options,f=3Dh._model,g=3Dh._model=3DVe(c),p=3Dh._active,m=3Dh._data,v=3D= {xAlign:f.xAlign,yAlign:f.yAlign},b=3D{x:f.x,y:f.y},x=3D{width:f.width,heig= ht:f.height},y=3D{x:f.caretX,y:f.caretY};if(p.length){g.opacity=3D1;var _= =3D[],k=3D[];y=3DBe[c.position].call(h,p,h._eventPosition);var w=3D[];for(e= =3D0,n=3Dp.length;ei.width&&(a=3Di.width-e.width),a<0&&(a=3D0)),"top"= =3D=3D=3Dd?r+=3Dh:r-=3D"bottom"=3D=3D=3Dd?e.height+h:e.height/2,"center"=3D= =3D=3Dd?"left"=3D=3D=3Du?a+=3Dh:"right"=3D=3D=3Du&&(a-=3Dh):"left"=3D=3D=3D= u?a-=3Dc:"right"=3D=3D=3Du&&(a+=3Dc),{x:a,y:r}}(g,x,v=3Dfunction(t,e){var n= ,i,a,r,o,s=3Dt._model,l=3Dt._chart,u=3Dt._chart.chartArea,d=3D"center",h=3D= "center";s.yl.height-e.height&&(h=3D"bottom");var c= =3D(u.left+u.right)/2,f=3D(u.top+u.bottom)/2;"center"=3D=3D=3Dh?(n=3Dfuncti= on(t){return t<=3Dc},i=3Dfunction(t){return t>c}):(n=3Dfunction(t){return t= <=3De.width/2},i=3Dfunction(t){return t>=3Dl.width-e.width/2}),a=3Dfunction= (t){return t+e.width+s.caretSize+s.caretPadding>l.width},r=3Dfunction(t){re= turn t-e.width-s.caretSize-s.caretPadding<0},o=3Dfunction(t){return t<=3Df?= "top":"bottom"},n(s.x)?(d=3D"left",a(s.x)&&(d=3D"center",h=3Do(s.y))):i(s.x= )&&(d=3D"right",r(s.x)&&(d=3D"center",h=3Do(s.y)));var g=3Dt._options;retur= n{xAlign:g.xAlign?g.xAlign:d,yAlign:g.yAlign?g.yAlign:h}}(this,x),h._chart)= }else g.opacity=3D0;return g.xAlign=3Dv.xAlign,g.yAlign=3Dv.yAlign,g.x=3Db.= x,g.y=3Db.y,g.width=3Dx.width,g.height=3Dx.height,g.caretX=3Dy.x,g.caretY= =3Dy.y,h._model=3Dg,t&&c.custom&&c.custom.call(h,g),h},drawCaret:function(t= ,e){var n=3Dthis._chart.ctx,i=3Dthis._view,a=3Dthis.getCaretPosition(t,e,i)= ;n.lineTo(a.x1,a.y1),n.lineTo(a.x2,a.y2),n.lineTo(a.x3,a.y3)},getCaretPosit= ion:function(t,e,n){var i,a,r,o,s,l,u=3Dn.caretSize,d=3Dn.cornerRadius,h=3D= n.xAlign,c=3Dn.yAlign,f=3Dt.x,g=3Dt.y,p=3De.width,m=3De.height;if("center"= =3D=3D=3Dc)s=3Dg+m/2,"left"=3D=3D=3Dh?(a=3D(i=3Df)-u,r=3Di,o=3Ds+u,l=3Ds-u)= :(a=3D(i=3Df+p)+u,r=3Di,o=3Ds-u,l=3Ds+u);else if("left"=3D=3D=3Dh?(i=3D(a= =3Df+d+u)-u,r=3Da+u):"right"=3D=3D=3Dh?(i=3D(a=3Df+p-d-u)-u,r=3Da+u):(i=3D(= a=3Dn.caretX)-u,r=3Da+u),"top"=3D=3D=3Dc)s=3D(o=3Dg)-u,l=3Do;else{s=3D(o=3D= g+m)+u,l=3Do;var v=3Dr;r=3Di,i=3Dv}return{x1:i,x2:a,x3:r,y1:o,y2:s,y3:l}},d= rawTitle:function(t,e,n){var i,a,r,o=3De.title,s=3Do.length;if(s){var l=3DN= e(e.rtl,e.x,e.width);for(t.x=3DHe(e,e._titleAlign),n.textAlign=3Dl.textAlig= n(e._titleAlign),n.textBaseline=3D"middle",i=3De.titleFontSize,a=3De.titleS= pacing,n.fillStyle=3De.titleFontColor,n.font=3DH.fontString(i,e._titleFontS= tyle,e._titleFontFamily),r=3D0;r0&&n.stroke()},d= raw:function(){var t=3Dthis._chart.ctx,e=3Dthis._view;if(0!=3D=3De.opacity)= {var n=3D{width:e.width,height:e.height},i=3D{x:e.x,y:e.y},a=3DMath.abs(e.o= pacity<.001)?0:e.opacity,r=3De.title.length||e.beforeBody.length||e.body.le= ngth||e.afterBody.length||e.footer.length;this._options.enabled&&r&&(t.save= (),t.globalAlpha=3Da,this.drawBackground(i,e,t,n),i.y+=3De.yPadding,H.rtl.o= verrideTextDirection(t,e.textDirection),this.drawTitle(i,e,t),this.drawBody= (i,e,t),this.drawFooter(i,e,t),H.rtl.restoreTextDirection(t,e.textDirection= ),t.restore())}},handleEvent:function(t){var e,n=3Dthis,i=3Dn._options;retu= rn n._lastActive=3Dn._lastActive||[],"mouseout"=3D=3D=3Dt.type?n._active=3D= []:(n._active=3Dn._chart.getElementsAtEventForMode(t,i.mode,i),i.reverse&&n= ._active.reverse()),(e=3D!H.arrayEquals(n._active,n._lastActive))&&(n._last= Active=3Dn._active,(i.enabled||i.custom)&&(n._eventPosition=3D{x:t.x,y:t.y}= ,n.update(!0),n.pivot())),e}}),Ue=3DBe,Ye=3Dqe;Ye.positioners=3DUe;var Ge= =3DH.valueOrDefault;function Xe(){return H.merge(Object.create(null),[].sli= ce.call(arguments),{merger:function(t,e,n,i){if("xAxes"=3D=3D=3Dt||"yAxes"= =3D=3D=3Dt){var a,r,o,s=3Dn[t].length;for(e[t]||(e[t]=3D[]),a=3D0;a=3De[t].l= ength&&e[t].push({}),!e[t][a].type||o.type&&o.type!=3D=3De[t][a].type?H.mer= ge(e[t][a],[Re.getScaleDefaults(r),o]):H.merge(e[t][a],o)}else H._merger(t,= e,n,i)}})}function Ke(){return H.merge(Object.create(null),[].slice.call(ar= guments),{merger:function(t,e,n,i){var a=3De[t]||Object.create(null),r=3Dn[= t];"scales"=3D=3D=3Dt?e[t]=3DXe(a,r):"scale"=3D=3D=3Dt?e[t]=3DH.merge(a,[Re= .getScaleDefaults(r.type),r]):H._merger(t,e,n,i)}})}function Ze(t){var e=3D= t.options;H.each(t.scales,(function(e){pe.removeBox(t,e)})),e=3DKe(N.global= ,N[t.config.type],e),t.options=3Dt.config.options=3De,t.ensureScalesHaveIDs= (),t.buildOrUpdateScales(),t.tooltip._options=3De.tooltips,t.tooltip.initia= lize()}function $e(t,e,n){var i,a=3Dfunction(t){return t.id=3D=3D=3Di};do{i= =3De+n++}while(H.findIndex(t,a)>=3D0);return i}function Je(t){return"top"= =3D=3D=3Dt||"bottom"=3D=3D=3Dt}function Qe(t,e){return function(n,i){return= n[t]=3D=3D=3Di[t]?n[e]-i[e]:n[t]-i[t]}}N._set("global",{elements:{},events= :["mousemove","mouseout","click","touchstart","touchmove"],hover:{onHover:n= ull,mode:"nearest",intersect:!0,animationDuration:400},onClick:null,maintai= nAspectRatio:!0,responsive:!0,responsiveAnimationDuration:0});var tn=3Dfunc= tion(t,e){return this.construct(t,e),this};H.extend(tn.prototype,{construct= :function(t,e){var n=3Dthis;e=3Dfunction(t){var e=3D(t=3Dt||Object.create(n= ull)).data=3Dt.data||{};return e.datasets=3De.datasets||[],e.labels=3De.lab= els||[],t.options=3DKe(N.global,N[t.type],t.options||{}),t}(e);var i=3DOe.a= cquireContext(t,e),a=3Di&&i.canvas,r=3Da&&a.height,o=3Da&&a.width;n.id=3DH.= uid(),n.ctx=3Di,n.canvas=3Da,n.config=3De,n.width=3Do,n.height=3Dr,n.aspect= Ratio=3Dr?o/r:null,n.options=3De.options,n._bufferedRender=3D!1,n._layers= =3D[],n.chart=3Dn,n.controller=3Dn,tn.instances[n.id]=3Dn,Object.defineProp= erty(n,"data",{get:function(){return n.config.data},set:function(t){n.confi= g.data=3Dt}}),i&&a?(n.initialize(),n.update()):console.error("Failed to cre= ate chart: can't acquire context from the given item")},initialize:function= (){var t=3Dthis;return Le.notify(t,"beforeInit"),H.retinaScale(t,t.options.= devicePixelRatio),t.bindEvents(),t.options.responsive&&t.resize(!0),t.initT= oolTip(),Le.notify(t,"afterInit"),t},clear:function(){return H.canvas.clear= (this),this},stop:function(){return J.cancelAnimation(this),this},resize:fu= nction(t){var e=3Dthis,n=3De.options,i=3De.canvas,a=3Dn.maintainAspectRatio= &&e.aspectRatio||null,r=3DMath.max(0,Math.floor(H.getMaximumWidth(i))),o=3D= Math.max(0,Math.floor(a?r/a:H.getMaximumHeight(i)));if((e.width!=3D=3Dr||e.= height!=3D=3Do)&&(i.width=3De.width=3Dr,i.height=3De.height=3Do,i.style.wid= th=3Dr+"px",i.style.height=3Do+"px",H.retinaScale(e,n.devicePixelRatio),!t)= ){var s=3D{width:r,height:o};Le.notify(e,"resize",[s]),n.onResize&&n.onResi= ze(e,s),e.stop(),e.update({duration:n.responsiveAnimationDuration})}},ensur= eScalesHaveIDs:function(){var t=3Dthis.options,e=3Dt.scales||{},n=3Dt.scale= ;H.each(e.xAxes,(function(t,n){t.id||(t.id=3D$e(e.xAxes,"x-axis-",n))})),H.= each(e.yAxes,(function(t,n){t.id||(t.id=3D$e(e.yAxes,"y-axis-",n))})),n&&(n= .id=3Dn.id||"scale")},buildOrUpdateScales:function(){var t=3Dthis,e=3Dt.opt= ions,n=3Dt.scales||{},i=3D[],a=3DObject.keys(n).reduce((function(t,e){retur= n t[e]=3D!1,t}),{});e.scales&&(i=3Di.concat((e.scales.xAxes||[]).map((funct= ion(t){return{options:t,dtype:"category",dposition:"bottom"}})),(e.scales.y= Axes||[]).map((function(t){return{options:t,dtype:"linear",dposition:"left"= }})))),e.scale&&i.push({options:e.scale,dtype:"radialLinear",isDefault:!0,d= position:"chartArea"}),H.each(i,(function(e){var i=3De.options,r=3Di.id,o= =3DGe(i.type,e.dtype);Je(i.position)!=3D=3DJe(e.dposition)&&(i.position=3De= .dposition),a[r]=3D!0;var s=3Dnull;if(r in n&&n[r].type=3D=3D=3Do)(s=3Dn[r]= ).options=3Di,s.ctx=3Dt.ctx,s.chart=3Dt;else{var l=3DRe.getScaleConstructor= (o);if(!l)return;s=3Dnew l({id:r,type:o,options:i,ctx:t.ctx,chart:t}),n[s.i= d]=3Ds}s.mergeTicksOptions(),e.isDefault&&(t.scale=3Ds)})),H.each(a,(functi= on(t,e){t||delete n[e]})),t.scales=3Dn,Re.addScalesToLayout(this)},buildOrU= pdateControllers:function(){var t,e,n=3Dthis,i=3D[],a=3Dn.data.datasets;for= (t=3D0,e=3Da.length;t=3D0;--n)this.drawDataset(= e[n],t);Le.notify(this,"afterDatasetsDraw",[t])}},drawDataset:function(t,e)= {var n=3D{meta:t,index:t.index,easingValue:e};!1!=3D=3DLe.notify(this,"befo= reDatasetDraw",[n])&&(t.controller.draw(e),Le.notify(this,"afterDatasetDraw= ",[n]))},_drawTooltip:function(t){var e=3Dthis.tooltip,n=3D{tooltip:e,easin= gValue:t};!1!=3D=3DLe.notify(this,"beforeTooltipDraw",[n])&&(e.draw(),Le.no= tify(this,"afterTooltipDraw",[n]))},getElementAtEvent:function(t){return re= .modes.single(this,t)},getElementsAtEvent:function(t){return re.modes.label= (this,t,{intersect:!0})},getElementsAtXAxis:function(t){return re.modes["x-= axis"](this,t,{intersect:!0})},getElementsAtEventForMode:function(t,e,n){va= r i=3Dre.modes[e];return"function"=3D=3Dtypeof i?i(this,t,n):[]},getDataset= AtEvent:function(t){return re.modes.dataset(this,t,{intersect:!0})},getData= setMeta:function(t){var e=3Dthis.data.datasets[t];e._meta||(e._meta=3D{});v= ar n=3De._meta[this.id];return n||(n=3De._meta[this.id]=3D{type:null,data:[= ],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:= e.order||0,index:t}),n},getVisibleDatasetCount:function(){for(var t=3D0,e= =3D0,n=3Dthis.data.datasets.length;e3?n[2]-n[1]:n[1]-n[0];Math.abs(i)>1&&t!= =3D=3DMath.floor(t)&&(i=3Dt-Math.floor(t));var a=3DH.log10(Math.abs(i)),r= =3D"";if(0!=3D=3Dt)if(Math.max(Math.abs(n[0]),Math.abs(n[n.length-1]))<1e-4= ){var o=3DH.log10(Math.abs(t)),s=3DMath.floor(o)-Math.floor(a);s=3DMath.max= (Math.min(s,20),0),r=3Dt.toExponential(s)}else{var l=3D-1*Math.floor(a);l= =3DMath.max(Math.min(l,20),0),r=3Dt.toFixed(l)}else r=3D"0";return r},logar= ithmic:function(t,e,n){var i=3Dt/Math.pow(10,Math.floor(H.log10(t)));return= 0=3D=3D=3Dt?"0":1=3D=3D=3Di||2=3D=3D=3Di||5=3D=3D=3Di||0=3D=3D=3De||e=3D= =3D=3Dn.length-1?t.toExponential():""}}},sn=3DH.isArray,ln=3DH.isNullOrUnde= f,un=3DH.valueOrDefault,dn=3DH.valueAtIndexOrDefault;function hn(t,e,n){var= i,a=3Dt.getTicks().length,r=3DMath.min(e,a-1),o=3Dt.getPixelForTick(r),s= =3Dt._startPixel,l=3Dt._endPixel;if(!(n&&(i=3D1=3D=3D=3Da?Math.max(o-s,l-o)= :0=3D=3D=3De?(t.getPixelForTick(1)-o)/2:(o-t.getPixelForTick(r-1))/2,(o+=3D= rl+1e-6)))return o}function cn(t,e,n,i){var a,r,o,s,l,u,= d,h,c,f,g,p,m,v=3Dn.length,b=3D[],x=3D[],y=3D[],_=3D0,k=3D0;for(a=3D0;ae){for(= n=3D0;n=3Dc||d<=3D1||!s.isHorizontal()?s.labelRotat= ion=3Dh:(e=3D(t=3Ds._getLabelSizes()).widest.width,n=3Dt.highest.height-t.h= ighest.offset,i=3DMath.min(s.maxWidth,s.chart.width-e),e+6>(a=3Dl.offset?s.= maxWidth/d:i/(d-1))&&(a=3Di/(d-(l.offset?.5:1)),r=3Ds.maxHeight-fn(l.gridLi= nes)-u.padding-gn(l.scaleLabel),o=3DMath.sqrt(e*e+n*n),f=3DH.toDegrees(Math= .min(Math.asin(Math.min((t.highest.height+6)/a,1)),Math.asin(Math.min(r/o,1= ))-Math.asin(n/o))),f=3DMath.max(h,Math.min(c,f))),s.labelRotation=3Df)},af= terCalculateTickRotation:function(){H.callback(this.options.afterCalculateT= ickRotation,[this])},beforeFit:function(){H.callback(this.options.beforeFit= ,[this])},fit:function(){var t=3Dthis,e=3Dt.minSize=3D{width:0,height:0},n= =3Dt.chart,i=3Dt.options,a=3Di.ticks,r=3Di.scaleLabel,o=3Di.gridLines,s=3Dt= ._isVisible(),l=3D"bottom"=3D=3D=3Di.position,u=3Dt.isHorizontal();if(u?e.w= idth=3Dt.maxWidth:s&&(e.width=3Dfn(o)+gn(r)),u?s&&(e.height=3Dfn(o)+gn(r)):= e.height=3Dt.maxHeight,a.display&&s){var d=3Dmn(a),h=3Dt._getLabelSizes(),c= =3Dh.first,f=3Dh.last,g=3Dh.widest,p=3Dh.highest,m=3D.4*d.minor.lineHeight,= v=3Da.padding;if(u){var b=3D0!=3D=3Dt.labelRotation,x=3DH.toRadians(t.label= Rotation),y=3DMath.cos(x),_=3DMath.sin(x),k=3D_*g.width+y*(p.height-(b?p.of= fset:0))+(b?0:m);e.height=3DMath.min(t.maxHeight,e.height+k+v);var w,M,S=3D= t.getPixelForTick(0)-t.left,C=3Dt.right-t.getPixelForTick(t.getTicks().leng= th-1);b?(w=3Dl?y*c.width+_*c.offset:_*(c.height-c.offset),M=3Dl?_*(f.height= -f.offset):y*f.width+_*f.offset):(w=3Dc.width/2,M=3Df.width/2),t.paddingLef= t=3DMath.max((w-S)*t.width/(t.width-S),0)+3,t.paddingRight=3DMath.max((M-C)= *t.width/(t.width-C),0)+3}else{var P=3Da.mirror?0:g.width+v+m;e.width=3DMat= h.min(t.maxWidth,e.width+P),t.paddingTop=3Dc.height/2,t.paddingBottom=3Df.h= eight/2}}t.handleMargins(),u?(t.width=3Dt._length=3Dn.width-t.margins.left-= t.margins.right,t.height=3De.height):(t.width=3De.width,t.height=3Dt._lengt= h=3Dn.height-t.margins.top-t.margins.bottom)},handleMargins:function(){var = t=3Dthis;t.margins&&(t.margins.left=3DMath.max(t.paddingLeft,t.margins.left= ),t.margins.top=3DMath.max(t.paddingTop,t.margins.top),t.margins.right=3DMa= th.max(t.paddingRight,t.margins.right),t.margins.bottom=3DMath.max(t.paddin= gBottom,t.margins.bottom))},afterFit:function(){H.callback(this.options.aft= erFit,[this])},isHorizontal:function(){var t=3Dthis.options.position;return= "top"=3D=3D=3Dt||"bottom"=3D=3D=3Dt},isFullWidth:function(){return this.opt= ions.fullWidth},getRightValue:function(t){if(ln(t))return NaN;if(("number"= =3D=3Dtypeof t||t instanceof Number)&&!isFinite(t))return NaN;if(t)if(this.= isHorizontal()){if(void 0!=3D=3Dt.x)return this.getRightValue(t.x)}else if(= void 0!=3D=3Dt.y)return this.getRightValue(t.y);return t},_convertTicksToLa= bels:function(t){var e,n,i,a=3Dthis;for(a.ticks=3Dt.map((function(t){return= t.value})),a.beforeTickToLabelConversion(),e=3Da.convertTicksToLabels(t)||= a.ticks,a.afterTickToLabelConversion(),n=3D0,i=3Dt.length;nn-1?null:this.getPixelForDecimal(t*i+(e?i/2:0))},getPix= elForDecimal:function(t){return this._reversePixels&&(t=3D1-t),this._startP= ixel+t*this._length},getDecimalForPixel:function(t){var e=3D(t-this._startP= ixel)/this._length;return this._reversePixels?1-e:e},getBasePixel:function(= ){return this.getPixelForValue(this.getBaseValue())},getBaseValue:function(= ){var t=3Dthis.min,e=3Dthis.max;return this.beginAtZero?0:t<0&&e<0?e:t>0&&e= >0?t:0},_autoSkip:function(t){var e,n,i,a,r=3Dthis.options.ticks,o=3Dthis._= length,s=3Dr.maxTicksLimit||o/this._tickSize()+1,l=3Dr.major.enabled?functi= on(t){var e,n,i=3D[];for(e=3D0,n=3Dt.length;es)return function(t,e,= n){var i,a,r=3D0,o=3De[0];for(n=3DMath.ceil(n),i=3D0;iu)return r;return Math= .max(u,1)}(l,t,0,s),u>0){for(e=3D0,n=3Du-1;e1?(h-d)/(u-1):null,bn(t,i,H.isNullOrUndef(a)?0:d-a,d),bn(t,i,h,H.i= sNullOrUndef(a)?t.length:h+a),vn(t)}return bn(t,i),vn(t)},_tickSize:functio= n(){var t=3Dthis.options.ticks,e=3DH.toRadians(this.labelRotation),n=3DMath= .abs(Math.cos(e)),i=3DMath.abs(Math.sin(e)),a=3Dthis._getLabelSizes(),r=3Dt= .autoSkipPadding||0,o=3Da?a.widest.width+r:0,s=3Da?a.highest.height+r:0;ret= urn this.isHorizontal()?s*n>o*i?o/n:s/i:s*i=3D0&&(o=3Dt),void 0= !=3D=3Dr&&(t=3Dn.indexOf(r))>=3D0&&(s=3Dt),e.minIndex=3Do,e.maxIndex=3Ds,e.= min=3Dn[o],e.max=3Dn[s]},buildTicks:function(){var t=3Dthis._getLabels(),e= =3Dthis.minIndex,n=3Dthis.maxIndex;this.ticks=3D0=3D=3D=3De&&n=3D=3D=3Dt.le= ngth-1?t:t.slice(e,n+1)},getLabelForIndex:function(t,e){var n=3Dthis.chart;= return n.getDatasetMeta(e).controller._getValueScaleId()=3D=3D=3Dthis.id?th= is.getRightValue(n.data.datasets[e].data[t]):this._getLabels()[t]},_configu= re:function(){var t=3Dthis,e=3Dt.options.offset,n=3Dt.ticks;yn.prototype._c= onfigure.call(t),t.isHorizontal()||(t._reversePixels=3D!t._reversePixels),n= &&(t._startValue=3Dt.minIndex-(e?.5:0),t._valueRange=3DMath.max(n.length-(e= ?0:1),1))},getPixelForValue:function(t,e,n){var i,a,r,o=3Dthis;return _n(e)= ||_n(n)||(t=3Do.chart.data.datasets[n].data[e]),_n(t)||(i=3Do.isHorizontal(= )?t.x:t.y),(void 0!=3D=3Di||void 0!=3D=3Dt&&isNaN(e))&&(a=3Do._getLabels(),= t=3DH.valueOrDefault(i,t),e=3D-1!=3D=3D(r=3Da.indexOf(t))?r:e,isNaN(e)&&(e= =3Dt)),o.getPixelForDecimal((e-o._startValue)/o._valueRange)},getPixelForTi= ck:function(t){var e=3Dthis.ticks;return t<0||t>e.length-1?null:this.getPix= elForValue(e[t],t+this.minIndex)},getValueForPixel:function(t){var e=3DMath= .round(this._startValue+this.getDecimalForPixel(t)*this._valueRange);return= Math.min(Math.max(e,0),this.ticks.length-1)},getBasePixel:function(){retur= n this.bottom}}),wn=3D{position:"bottom"};kn._defaults=3Dwn;var Mn=3DH.noop= ,Sn=3DH.isNullOrUndef;var Cn=3Dyn.extend({getRightValue:function(t){return"= string"=3D=3Dtypeof t?+t:yn.prototype.getRightValue.call(this,t)},handleTic= kRangeOptions:function(){var t=3Dthis,e=3Dt.options.ticks;if(e.beginAtZero)= {var n=3DH.sign(t.min),i=3DH.sign(t.max);n<0&&i<0?t.max=3D0:n>0&&i>0&&(t.mi= n=3D0)}var a=3Dvoid 0!=3D=3De.min||void 0!=3D=3De.suggestedMin,r=3Dvoid 0!= =3D=3De.max||void 0!=3D=3De.suggestedMax;void 0!=3D=3De.min?t.min=3De.min:v= oid 0!=3D=3De.suggestedMin&&(null=3D=3D=3Dt.min?t.min=3De.suggestedMin:t.mi= n=3DMath.min(t.min,e.suggestedMin)),void 0!=3D=3De.max?t.max=3De.max:void 0= !=3D=3De.suggestedMax&&(null=3D=3D=3Dt.max?t.max=3De.suggestedMax:t.max=3DM= ath.max(t.max,e.suggestedMax)),a!=3D=3Dr&&t.min>=3Dt.max&&(a?t.max=3Dt.min+= 1:t.min=3Dt.max-1),t.min=3D=3D=3Dt.max&&(t.max++,e.beginAtZero||t.min--)},g= etTickLimit:function(){var t,e=3Dthis.options.ticks,n=3De.stepSize,i=3De.ma= xTicksLimit;return n?t=3DMath.ceil(this.max/n)-Math.floor(this.min/n)+1:(t= =3Dthis._computeTickLimit(),i=3Di||11),i&&(t=3DMath.min(i,t)),t},_computeTi= ckLimit:function(){return Number.POSITIVE_INFINITY},handleDirectionalChange= s:Mn,buildTicks:function(){var t=3Dthis,e=3Dt.options.ticks,n=3Dt.getTickLi= mit(),i=3D{maxTicks:n=3DMath.max(2,n),min:e.min,max:e.max,precision:e.preci= sion,stepSize:H.valueOrDefault(e.fixedStepSize,e.stepSize)},a=3Dt.ticks=3Df= unction(t,e){var n,i,a,r,o=3D[],s=3Dt.stepSize,l=3Ds||1,u=3Dt.maxTicks-1,d= =3Dt.min,h=3Dt.max,c=3Dt.precision,f=3De.min,g=3De.max,p=3DH.niceNum((g-f)/= u/l)*l;if(p<1e-14&&Sn(d)&&Sn(h))return[f,g];(r=3DMath.ceil(g/p)-Math.floor(= f/p))>u&&(p=3DH.niceNum(r*p/u/l)*l),s||Sn(c)?n=3DMath.pow(10,H._decimalPlac= es(p)):(n=3DMath.pow(10,c),p=3DMath.ceil(p*n)/n),i=3DMath.floor(f/p)*p,a=3D= Math.ceil(g/p)*p,s&&(!Sn(d)&&H.almostWhole(d/p,p/1e3)&&(i=3Dd),!Sn(h)&&H.al= mostWhole(h/p,p/1e3)&&(a=3Dh)),r=3D(a-i)/p,r=3DH.almostEquals(r,Math.round(= r),p/1e3)?Math.round(r):Math.ceil(r),i=3DMath.round(i*n)/n,a=3DMath.round(a= *n)/n,o.push(Sn(d)?i:d);for(var m=3D1;me.length-1?null:this.getPixelForValue(e[t])}}),In=3DPn;Tn._defaults= =3DIn;var Fn=3DH.valueOrDefault,On=3DH.math.log10;var Ln=3D{position:"left"= ,ticks:{callback:on.formatters.logarithmic}};function Rn(t,e){return H.isFi= nite(t)&&t>=3D0?t:e}var zn=3Dyn.extend({determineDataLimits:function(){var = t,e,n,i,a,r,o=3Dthis,s=3Do.options,l=3Do.chart,u=3Dl.data.datasets,d=3Do.is= Horizontal();function h(t){return d?t.xAxisID=3D=3D=3Do.id:t.yAxisID=3D=3D= =3Do.id}o.min=3DNumber.POSITIVE_INFINITY,o.max=3DNumber.NEGATIVE_INFINITY,o= .minNotZero=3DNumber.POSITIVE_INFINITY;var c=3Ds.stacked;if(void 0=3D=3D=3D= c)for(t=3D0;t0){var e=3DH.min(t),n=3DH.max(t);o.mi= n=3DMath.min(o.min,e),o.max=3DMath.max(o.max,n)}}))}else for(t=3D0;t0?t.minNotZero=3Dt.min= :t.max<1?t.minNotZero=3DMath.pow(10,Math.floor(On(t.max))):t.minNotZero=3D1= )},buildTicks:function(){var t=3Dthis,e=3Dt.options.ticks,n=3D!t.isHorizont= al(),i=3D{min:Rn(e.min),max:Rn(e.max)},a=3Dt.ticks=3Dfunction(t,e){var n,i,= a=3D[],r=3DFn(t.min,Math.pow(10,Math.floor(On(e.min)))),o=3DMath.floor(On(e= .max)),s=3DMath.ceil(e.max/Math.pow(10,o));0=3D=3D=3Dr?(n=3DMath.floor(On(e= .minNotZero)),i=3DMath.floor(e.minNotZero/Math.pow(10,n)),a.push(r),r=3Di*M= ath.pow(10,n)):(n=3DMath.floor(On(r)),i=3DMath.floor(r/Math.pow(10,n)));var= l=3Dn<0?Math.pow(10,Math.abs(n)):1;do{a.push(r),10=3D=3D=3D++i&&(i=3D1,l= =3D++n>=3D0?1:l),r=3DMath.round(i*Math.pow(10,n)*l)/l}while(ne.length-1?null:this.getPixelForValue(e[t])},_getFirstTickValue:= function(t){var e=3DMath.floor(On(t));return Math.floor(t/Math.pow(10,e))*M= ath.pow(10,e)},_configure:function(){var t=3Dthis,e=3Dt.min,n=3D0;yn.protot= ype._configure.call(t),0=3D=3D=3De&&(e=3Dt._getFirstTickValue(t.minNotZero)= ,n=3DFn(t.options.ticks.fontSize,N.global.defaultFontSize)/t._length),t._st= artValue=3DOn(e),t._valueOffset=3Dn,t._valueRange=3D(On(t.max)-On(e))/(1-n)= },getPixelForValue:function(t){var e=3Dthis,n=3D0;return(t=3D+e.getRightVal= ue(t))>e.min&&t>0&&(n=3D(On(t)-e._startValue)/e._valueRange+e._valueOffset)= ,e.getPixelForDecimal(n)},getValueForPixel:function(t){var e=3Dthis,n=3De.g= etDecimalForPixel(t);return 0=3D=3D=3Dn&&0=3D=3D=3De.min?0:Math.pow(10,e._s= tartValue+(n-e._valueOffset)*e._valueRange)}}),Nn=3DLn;zn._defaults=3DNn;va= r Bn=3DH.valueOrDefault,En=3DH.valueAtIndexOrDefault,Wn=3DH.options.resolve= ,Vn=3D{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,co= lor:"rgba(0,0,0,0.1)",lineWidth:1,borderDash:[],borderDashOffset:0},gridLin= es:{circular:!1},ticks:{showLabelBackdrop:!0,backdropColor:"rgba(255,255,25= 5,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:on.formatters.linea= r},pointLabels:{display:!0,fontSize:10,callback:function(t){return t}}};fun= ction Hn(t){var e=3Dt.ticks;return e.display&&t.display?Bn(e.fontSize,N.glo= bal.defaultFontSize)+2*e.backdropPaddingY:0}function jn(t,e,n,i,a){return t= =3D=3D=3Di||t=3D=3D=3Da?{start:e-n/2,end:e+n/2}:ta?{start:e-n,end:e}:= {start:e,end:e+n}}function qn(t){return 0=3D=3D=3Dt||180=3D=3D=3Dt?"center"= :t<180?"left":"right"}function Un(t,e,n,i){var a,r,o=3Dn.y+i/2;if(H.isArray= (e))for(a=3D0,r=3De.length;a270||t<90)&&(n.y-=3De.h)}function Gn(t){return H.isNumber(t)?t:0}var Xn= =3DCn.extend({setDimensions:function(){var t=3Dthis;t.width=3Dt.maxWidth,t.= height=3Dt.maxHeight,t.paddingTop=3DHn(t.options)/2,t.xCenter=3DMath.floor(= t.width/2),t.yCenter=3DMath.floor((t.height-t.paddingTop)/2),t.drawingArea= =3DMath.min(t.height-t.paddingTop,t.width)/2},determineDataLimits:function(= ){var t=3Dthis,e=3Dt.chart,n=3DNumber.POSITIVE_INFINITY,i=3DNumber.NEGATIVE= _INFINITY;H.each(e.data.datasets,(function(a,r){if(e.isDatasetVisible(r)){v= ar o=3De.getDatasetMeta(r);H.each(a.data,(function(e,a){var r=3D+t.getRight= Value(e);isNaN(r)||o.data[a].hidden||(n=3DMath.min(r,n),i=3DMath.max(r,i))}= ))}})),t.min=3Dn=3D=3D=3DNumber.POSITIVE_INFINITY?0:n,t.max=3Di=3D=3D=3DNum= ber.NEGATIVE_INFINITY?0:i,t.handleTickRangeOptions()},_computeTickLimit:fun= ction(){return Math.ceil(this.drawingArea/Hn(this.options))},convertTicksTo= Labels:function(){var t=3Dthis;Cn.prototype.convertTicksToLabels.call(t),t.= pointLabels=3Dt.chart.data.labels.map((function(){var e=3DH.callback(t.opti= ons.pointLabels.callback,arguments,t);return e||0=3D=3D=3De?e:""}))},getLab= elForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets= [e].data[t])},fit:function(){var t=3Dthis.options;t.display&&t.pointLabels.= display?function(t){var e,n,i,a=3DH.options._parseFont(t.options.pointLabel= s),r=3D{l:0,r:t.width,t:0,b:t.height-t.paddingTop},o=3D{};t.ctx.font=3Da.st= ring,t._pointLabelSizes=3D[];var s,l,u,d=3Dt.chart.data.labels.length;for(e= =3D0;er.r&&(r.r=3D= f.end,o.r=3Dh),g.startr.b&&(r.b=3Dg.end= ,o.b=3Dh)}t.setReductions(t.drawingArea,r,o)}(this):this.setCenterPoint(0,0= ,0,0)},setReductions:function(t,e,n){var i=3Dthis,a=3De.l/Math.sin(n.l),r= =3DMath.max(e.r-i.width,0)/Math.sin(n.r),o=3D-e.t/Math.cos(n.t),s=3D-Math.m= ax(e.b-(i.height-i.paddingTop),0)/Math.cos(n.b);a=3DGn(a),r=3DGn(r),o=3DGn(= o),s=3DGn(s),i.drawingArea=3DMath.min(Math.floor(t-(a+r)/2),Math.floor(t-(o= +s)/2)),i.setCenterPoint(a,r,o,s)},setCenterPoint:function(t,e,n,i){var a= =3Dthis,r=3Da.width-e-a.drawingArea,o=3Dt+a.drawingArea,s=3Dn+a.drawingArea= ,l=3Da.height-a.paddingTop-i-a.drawingArea;a.xCenter=3DMath.floor((o+r)/2+a= .left),a.yCenter=3DMath.floor((s+l)/2+a.top+a.paddingTop)},getIndexAngle:fu= nction(t){var e=3Dthis.chart,n=3D(t*(360/e.data.labels.length)+((e.options|= |{}).startAngle||0))%360;return(n<0?n+360:n)*Math.PI*2/360},getDistanceFrom= CenterForValue:function(t){var e=3Dthis;if(H.isNullOrUndef(t))return NaN;va= r n=3De.drawingArea/(e.max-e.min);return e.options.ticks.reverse?(e.max-t)*= n:(t-e.min)*n},getPointPosition:function(t,e){var n=3Dthis.getIndexAngle(t)= -Math.PI/2;return{x:Math.cos(n)*e+this.xCenter,y:Math.sin(n)*e+this.yCenter= }},getPointPositionForValue:function(t,e){return this.getPointPosition(t,th= is.getDistanceFromCenterForValue(e))},getBasePosition:function(t){var e=3Dt= his.min,n=3Dthis.max;return this.getPointPositionForValue(t||0,this.beginAt= Zero?0:e<0&&n<0?n:e>0&&n>0?e:0)},_drawGrid:function(){var t,e,n,i=3Dthis,a= =3Di.ctx,r=3Di.options,o=3Dr.gridLines,s=3Dr.angleLines,l=3DBn(s.lineWidth,= o.lineWidth),u=3DBn(s.color,o.color);if(r.pointLabels.display&&function(t){= var e=3Dt.ctx,n=3Dt.options,i=3Dn.pointLabels,a=3DHn(n),r=3Dt.getDistanceFr= omCenterForValue(n.ticks.reverse?t.min:t.max),o=3DH.options._parseFont(i);e= .save(),e.font=3Do.string,e.textBaseline=3D"middle";for(var s=3Dt.chart.dat= a.labels.length-1;s>=3D0;s--){var l=3D0=3D=3D=3Ds?a/2:0,u=3Dt.getPointPosit= ion(s,r+l+5),d=3DEn(i.fontColor,s,N.global.defaultFontColor);e.fillStyle=3D= d;var h=3Dt.getIndexAngle(s),c=3DH.toDegrees(h);e.textAlign=3Dqn(c),Yn(c,t.= _pointLabelSizes[s],u),Un(e,t.pointLabels[s],u,o.lineHeight)}e.restore()}(i= ),o.display&&H.each(i.ticks,(function(t,n){0!=3D=3Dn&&(e=3Di.getDistanceFro= mCenterForValue(i.ticksAsNumbers[n]),function(t,e,n,i){var a,r=3Dt.ctx,o=3D= e.circular,s=3Dt.chart.data.labels.length,l=3DEn(e.color,i-1),u=3DEn(e.line= Width,i-1);if((o||s)&&l&&u){if(r.save(),r.strokeStyle=3Dl,r.lineWidth=3Du,r= .setLineDash&&(r.setLineDash(e.borderDash||[]),r.lineDashOffset=3De.borderD= ashOffset||0),r.beginPath(),o)r.arc(t.xCenter,t.yCenter,n,0,2*Math.PI);else= {a=3Dt.getPointPosition(0,n),r.moveTo(a.x,a.y);for(var d=3D1;d=3D0;t--)e=3Di.getDistanceFromCenterForValue(r.ticks= .reverse?i.min:i.max),n=3Di.getPointPosition(t,e),a.beginPath(),a.moveTo(i.= xCenter,i.yCenter),a.lineTo(n.x,n.y),a.stroke();a.restore()}},_drawLabels:f= unction(){var t=3Dthis,e=3Dt.ctx,n=3Dt.options.ticks;if(n.display){var i,a,= r=3Dt.getIndexAngle(0),o=3DH.options._parseFont(n),s=3DBn(n.fontColor,N.glo= bal.defaultFontColor);e.save(),e.font=3Do.string,e.translate(t.xCenter,t.yC= enter),e.rotate(r),e.textAlign=3D"center",e.textBaseline=3D"middle",H.each(= t.ticks,(function(r,l){(0!=3D=3Dl||n.reverse)&&(i=3Dt.getDistanceFromCenter= ForValue(t.ticksAsNumbers[l]),n.showLabelBackdrop&&(a=3De.measureText(r).wi= dth,e.fillStyle=3Dn.backdropColor,e.fillRect(-a/2-n.backdropPaddingX,-i-o.s= ize/2-n.backdropPaddingY,a+2*n.backdropPaddingX,o.size+2*n.backdropPaddingY= )),e.fillStyle=3Ds,e.fillText(r,0,-i))})),e.restore()}},_drawTitle:H.noop})= ,Kn=3DVn;Xn._defaults=3DKn;var Zn=3DH._deprecated,$n=3DH.options.resolve,Jn= =3DH.valueOrDefault,Qn=3DNumber.MIN_SAFE_INTEGER||-9007199254740991,ti=3DNu= mber.MAX_SAFE_INTEGER||9007199254740991,ei=3D{millisecond:{common:!0,size:1= ,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4= ,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,st= eps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,s= teps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e= 7}},ni=3DObject.keys(ei);function ii(t,e){return t-e}function ai(t){return = H.valueOrDefault(t.time.min,t.ticks.min)}function ri(t){return H.valueOrDef= ault(t.time.max,t.ticks.max)}function oi(t,e,n,i){var a=3Dfunction(t,e,n){f= or(var i,a,r,o=3D0,s=3Dt.length-1;o>=3D0&&o<=3Ds;){if(a=3Dt[(i=3Do+s>>1)-1]= ||null,r=3Dt[i],!a)return{lo:null,hi:r};if(r[e]n)= )return{lo:a,hi:r};s=3Di-1}}return{lo:r,hi:null}}(t,e,n),r=3Da.lo?a.hi?a.lo= :t[t.length-2]:t[0],o=3Da.lo?a.hi?a.hi:t[t.length-1]:t[1],s=3Do[e]-r[e],l= =3Ds?(n-r[e])/s:0,u=3D(o[i]-r[i])*l;return r[i]+u}function si(t,e){var n=3D= t._adapter,i=3Dt.options.time,a=3Di.parser,r=3Da||i.format,o=3De;return"fun= ction"=3D=3Dtypeof a&&(o=3Da(o)),H.isFinite(o)||(o=3D"string"=3D=3Dtypeof r= ?n.parse(o,r):n.parse(o)),null!=3D=3Do?+o:(a||"function"!=3Dtypeof r||(o=3D= r(e),H.isFinite(o)||(o=3Dn.parse(o))),o)}function li(t,e){if(H.isNullOrUnde= f(e))return null;var n=3Dt.options.time,i=3Dsi(t,t.getRightValue(e));return= null=3D=3D=3Di?i:(n.round&&(i=3D+t._adapter.startOf(i,n.round)),i)}functio= n ui(t,e,n,i){var a,r,o,s=3Dni.length;for(a=3Dni.indexOf(t);a=3D0&&(e[r].major=3D!0);return e}(t,r,o,n):r}var hi=3Dyn.extend({i= nitialize:function(){this.mergeTicksOptions(),yn.prototype.initialize.call(= this)},update:function(){var t=3Dthis,e=3Dt.options,n=3De.time||(e.time=3D{= }),i=3Dt._adapter=3Dnew rn._date(e.adapters.date);return Zn("time scale",n.= format,"time.format","time.parser"),Zn("time scale",n.min,"time.min","ticks= .min"),Zn("time scale",n.max,"time.max","ticks.max"),H.mergeIf(n.displayFor= mats,i.formats()),yn.prototype.update.apply(t,arguments)},getRightValue:fun= ction(t){return t&&void 0!=3D=3Dt.t&&(t=3Dt.t),yn.prototype.getRightValue.c= all(this,t)},determineDataLimits:function(){var t,e,n,i,a,r,o,s=3Dthis,l=3D= s.chart,u=3Ds._adapter,d=3Ds.options,h=3Dd.time.unit||"day",c=3Dti,f=3DQn,g= =3D[],p=3D[],m=3D[],v=3Ds._getLabels();for(t=3D0,n=3Dv.length;t1?function(t)= {var e,n,i,a=3D{},r=3D[];for(e=3D0,n=3Dt.length;e1e5*u)throw e+" and "= +n+" are too far apart with stepSize of "+u+" "+l;for(a=3Dh;a=3D= a&&n<=3Dr&&d.push(n);return i.min=3Da,i.max=3Dr,i._unit=3Dl.unit||(s.autoSk= ip?ui(l.minUnit,i.min,i.max,h):function(t,e,n,i,a){var r,o;for(r=3Dni.lengt= h-1;r>=3Dni.indexOf(n);r--)if(o=3Dni[r],ei[o].common&&t._adapter.diff(a,i,o= )>=3De-1)return o;return ni[n?ni.indexOf(n):0]}(i,d.length,l.minUnit,i.min,= i.max)),i._majorUnit=3Ds.major.enabled&&"year"!=3D=3Di._unit?function(t){fo= r(var e=3Dni.indexOf(t)+1,n=3Dni.length;ee&&s=3D0&&t0?s:1}}),ci=3D{position:"bottom",distribution:"linear",boun= ds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,displayFormat:!1,iso= Weekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{autoSkip:!1,sour= ce:"auto",major:{enabled:!1}}};hi._defaults=3Dci;var fi=3D{category:kn,line= ar:Tn,logarithmic:zn,radialLinear:Xn,time:hi},gi=3D{datetime:"MMM D, YYYY, = h:mm:ss a",millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",minute:"h:mm a",h= our:"hA",day:"MMM D",week:"ll",month:"MMM YYYY",quarter:"[Q]Q - YYYY",year:= "YYYY"};rn._date.override("function"=3D=3Dtypeof t?{_id:"moment",formats:fu= nction(){return gi},parse:function(e,n){return"string"=3D=3Dtypeof e&&"stri= ng"=3D=3Dtypeof n?e=3Dt(e,n):e instanceof t||(e=3Dt(e)),e.isValid()?e.value= Of():null},format:function(e,n){return t(e).format(n)},add:function(e,n,i){= return t(e).add(n,i).valueOf()},diff:function(e,n,i){return t(e).diff(t(n),= i)},startOf:function(e,n,i){return e=3Dt(e),"isoWeek"=3D=3D=3Dn?e.isoWeekda= y(i).valueOf():e.startOf(n).valueOf()},endOf:function(e,n){return t(e).endO= f(n).valueOf()},_create:function(e){return t(e)}}:{}),N._set("global",{plug= ins:{filler:{propagate:!0}}});var pi=3D{dataset:function(t){var e=3Dt.fill,= n=3Dt.chart,i=3Dn.getDatasetMeta(e),a=3Di&&n.isDatasetVisible(e)&&i.dataset= ._children||[],r=3Da.length||0;return r?function(t,e){return e=3Dn)&&i;switch(r){case= "bottom":return"start";case"top":return"end";case"zero":return"origin";case= "origin":case"start":case"end":return r;default:return!1}}function vi(t){re= turn(t.el._scale||{}).getPointPositionForValue?function(t){var e,n,i,a,r,o= =3Dt.el._scale,s=3Do.options,l=3Do.chart.data.labels.length,u=3Dt.fill,d=3D= [];if(!l)return null;for(e=3Ds.ticks.reverse?o.max:o.min,n=3Ds.ticks.revers= e?o.min:o.max,i=3Do.getPointPositionForValue(0,e),a=3D0;a0;--r)H.canvas.lineTo(t,n[r],n[r-1],!0);else for(o=3Dn[0].cx,s= =3Dn[0].cy,l=3DMath.sqrt(Math.pow(n[0].x-o,2)+Math.pow(n[0].y-s,2)),r=3Da-1= ;r>0;--r)t.arc(o,s,l,n[r].angle,n[r-1].angle,!0)}}function ki(t,e,n,i,a,r){= var o,s,l,u,d,h,c,f,g=3De.length,p=3Di.spanGaps,m=3D[],v=3D[],b=3D0,x=3D0;f= or(t.beginPath(),o=3D0,s=3Dg;o=3D0= ;--n)(e=3Dl[n].$filler)&&e.visible&&(a=3D(i=3De.el)._view,r=3Di._children||= [],o=3De.mapper,s=3Da.backgroundColor||N.global.defaultColor,o&&s&&r.length= &&(H.canvas.clipArea(u,t.chartArea),ki(u,r,o,a,s,i._loop),H.canvas.unclipAr= ea(u)))}},Mi=3DH.rtl.getRtlAdapter,Si=3DH.noop,Ci=3DH.valueOrDefault;functi= on Pi(t,e){return t.usePointStyle&&t.boxWidth>e?e:t.boxWidth}N._set("global= ",{legend:{display:!0,position:"top",align:"center",fullWidth:!0,reverse:!1= ,weight:1e3,onClick:function(t,e){var n=3De.datasetIndex,i=3Dthis.chart,a= =3Di.getDatasetMeta(n);a.hidden=3Dnull=3D=3D=3Da.hidden?!i.data.datasets[n]= .hidden:null,i.update()},onHover:null,onLeave:null,labels:{boxWidth:40,padd= ing:10,generateLabels:function(t){var e=3Dt.data.datasets,n=3Dt.options.leg= end||{},i=3Dn.labels&&n.labels.usePointStyle;return t._getSortedDatasetMeta= s().map((function(n){var a=3Dn.controller.getStyle(i?0:void 0);return{text:= e[n.index].label,fillStyle:a.backgroundColor,hidden:!t.isDatasetVisible(n.i= ndex),lineCap:a.borderCapStyle,lineDash:a.borderDash,lineDashOffset:a.borde= rDashOffset,lineJoin:a.borderJoinStyle,lineWidth:a.borderWidth,strokeStyle:= a.borderColor,pointStyle:a.pointStyle,rotation:a.rotation,datasetIndex:n.in= dex}}),this)}}},legendCallback:function(t){var e,n,i,a=3Ddocument.createEle= ment("ul"),r=3Dt.data.datasets;for(a.setAttribute("class",t.id+"-legend"),e= =3D0,n=3Dr.length;el.width)&&(h+=3Do+n.padding,d[d.length-(e>0?0:1)]=3D0),s[e]=3D{le= ft:0,top:0,width:i,height:o},d[d.length-1]+=3Di+n.padding})),l.height+=3Dh}= else{var c=3Dn.padding,f=3Dt.columnWidths=3D[],g=3Dt.columnHeights=3D[],p= =3Dn.padding,m=3D0,v=3D0;H.each(t.legendItems,(function(t,e){var i=3DPi(n,o= )+o/2+a.measureText(t.text).width;e>0&&v+o+2*c>l.height&&(p+=3Dm+n.padding,= f.push(m),g.push(v),m=3D0,v=3D0),m=3DMath.max(m,i),v+=3Do+c,s[e]=3D{left:0,= top:0,width:i,height:o}})),p+=3Dm,f.push(m),g.push(v),l.width+=3Dp}t.width= =3Dl.width,t.height=3Dl.height}else t.width=3Dl.width=3Dt.height=3Dl.height= =3D0},afterFit:Si,isHorizontal:function(){return"top"=3D=3D=3Dthis.options.= position||"bottom"=3D=3D=3Dthis.options.position},draw:function(){var t=3Dt= his,e=3Dt.options,n=3De.labels,i=3DN.global,a=3Di.defaultColor,r=3Di.elemen= ts.line,o=3Dt.height,s=3Dt.columnHeights,l=3Dt.width,u=3Dt.lineWidths;if(e.= display){var d,h=3DMi(e.rtl,t.left,t.minSize.width),c=3Dt.ctx,f=3DCi(n.font= Color,i.defaultFontColor),g=3DH.options._parseFont(n),p=3Dg.size;c.textAlig= n=3Dh.textAlign("left"),c.textBaseline=3D"middle",c.lineWidth=3D.5,c.stroke= Style=3Df,c.fillStyle=3Df,c.font=3Dg.string;var m=3DPi(n,p),v=3Dt.legendHit= Boxes,b=3Dfunction(t,i){switch(e.align){case"start":return n.padding;case"e= nd":return t-i;default:return(t-i+n.padding)/2}},x=3Dt.isHorizontal();d=3Dx= ?{x:t.left+b(l,u[0]),y:t.top+n.padding,line:0}:{x:t.left+n.padding,y:t.top+= b(o,s[0]),line:0},H.rtl.overrideTextDirection(t.ctx,e.textDirection);var y= =3Dp+n.padding;H.each(t.legendItems,(function(e,i){var f=3Dc.measureText(e.= text).width,g=3Dm+p/2+f,_=3Dd.x,k=3Dd.y;h.setWidth(t.minSize.width),x?i>0&&= _+g+n.padding>t.left+t.minSize.width&&(k=3Dd.y+=3Dy,d.line++,_=3Dd.x=3Dt.le= ft+b(l,u[d.line])):i>0&&k+y>t.top+t.minSize.height&&(_=3Dd.x=3D_+t.columnWi= dths[d.line]+n.padding,d.line++,k=3Dd.y=3Dt.top+b(o,s[d.line]));var w=3Dh.x= (_);!function(t,e,i){if(!(isNaN(m)||m<=3D0)){c.save();var o=3DCi(i.lineWidt= h,r.borderWidth);if(c.fillStyle=3DCi(i.fillStyle,a),c.lineCap=3DCi(i.lineCa= p,r.borderCapStyle),c.lineDashOffset=3DCi(i.lineDashOffset,r.borderDashOffs= et),c.lineJoin=3DCi(i.lineJoin,r.borderJoinStyle),c.lineWidth=3Do,c.strokeS= tyle=3DCi(i.strokeStyle,a),c.setLineDash&&c.setLineDash(Ci(i.lineDash,r.bor= derDash)),n&&n.usePointStyle){var s=3Dm*Math.SQRT2/2,l=3Dh.xPlus(t,m/2),u= =3De+p/2;H.canvas.drawPoint(c,i.pointStyle,s,l,u,i.rotation)}else c.fillRec= t(h.leftForLtr(t,m),e,m,p),0!=3D=3Do&&c.strokeRect(h.leftForLtr(t,m),e,m,p)= ;c.restore()}}(w,k,e),v[i].left=3Dh.leftForLtr(w,v[i].width),v[i].top=3Dk,f= unction(t,e,n,i){var a=3Dp/2,r=3Dh.xPlus(t,m+a),o=3De+a;c.fillText(n.text,r= ,o),n.hidden&&(c.beginPath(),c.lineWidth=3D2,c.moveTo(r,o),c.lineTo(h.xPlus= (r,i),o),c.stroke())}(w,k,e,f),x?d.x+=3Dg+n.padding:d.y+=3Dy})),H.rtl.resto= reTextDirection(t.ctx,e.textDirection)}},_getLegendItemAt:function(t,e){var= n,i,a,r=3Dthis;if(t>=3Dr.left&&t<=3Dr.right&&e>=3Dr.top&&e<=3Dr.bottom)for= (a=3Dr.legendHitBoxes,n=3D0;n=3D(i=3Da[n]).left&&t<=3Di.= left+i.width&&e>=3Di.top&&e<=3Di.top+i.height)return r.legendItems[n];retur= n null},handleEvent:function(t){var e,n=3Dthis,i=3Dn.options,a=3D"mouseup"= =3D=3D=3Dt.type?"click":t.type;if("mousemove"=3D=3D=3Da){if(!i.onHover&&!i.= onLeave)return}else{if("click"!=3D=3Da)return;if(!i.onClick)return}e=3Dn._g= etLegendItemAt(t.x,t.y),"click"=3D=3D=3Da?e&&i.onClick&&i.onClick.call(n,t.= native,e):(i.onLeave&&e!=3D=3Dn._hoveredItem&&(n._hoveredItem&&i.onLeave.ca= ll(n,t.native,n._hoveredItem),n._hoveredItem=3De),i.onHover&&e&&i.onHover.c= all(n,t.native,e))}});function Di(t,e){var n=3Dnew Ai({ctx:t.ctx,options:e,= chart:t});pe.configure(t,n,e),pe.addBox(t,n),t.legend=3Dn}var Ti=3D{id:"leg= end",_element:Ai,beforeInit:function(t){var e=3Dt.options.legend;e&&Di(t,e)= },beforeUpdate:function(t){var e=3Dt.options.legend,n=3Dt.legend;e?(H.merge= If(e,N.global.legend),n?(pe.configure(t,n,e),n.options=3De):Di(t,e)):n&&(pe= .removeBox(t,n),delete t.legend)},afterEvent:function(t,e){var n=3Dt.legend= ;n&&n.handleEvent(e)}},Ii=3DH.noop;N._set("global",{title:{display:!1,fontS= tyle:"bold",fullWidth:!0,padding:10,position:"top",text:"",weight:2e3}});va= r Fi=3DK.extend({initialize:function(t){H.extend(this,t),this.legendHitBoxe= s=3D[]},beforeUpdate:Ii,update:function(t,e,n){var i=3Dthis;return i.before= Update(),i.maxWidth=3Dt,i.maxHeight=3De,i.margins=3Dn,i.beforeSetDimensions= (),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabels(),i.buildLa= bels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(),i.afterUpdat= e(),i.minSize},afterUpdate:Ii,beforeSetDimensions:Ii,setDimensions:function= (){var t=3Dthis;t.isHorizontal()?(t.width=3Dt.maxWidth,t.left=3D0,t.right= =3Dt.width):(t.height=3Dt.maxHeight,t.top=3D0,t.bottom=3Dt.height),t.paddin= gLeft=3D0,t.paddingTop=3D0,t.paddingRight=3D0,t.paddingBottom=3D0,t.minSize= =3D{width:0,height:0}},afterSetDimensions:Ii,beforeBuildLabels:Ii,buildLabe= ls:Ii,afterBuildLabels:Ii,beforeFit:Ii,fit:function(){var t,e=3Dthis,n=3De.= options,i=3De.minSize=3D{},a=3De.isHorizontal();n.display?(t=3D(H.isArray(n= .text)?n.text.length:1)*H.options._parseFont(n).lineHeight+2*n.padding,e.wi= dth=3Di.width=3Da?e.maxWidth:t,e.height=3Di.height=3Da?t:e.maxHeight):e.wid= th=3Di.width=3De.height=3Di.height=3D0},afterFit:Ii,isHorizontal:function()= {var t=3Dthis.options.position;return"top"=3D=3D=3Dt||"bottom"=3D=3D=3Dt},d= raw:function(){var t=3Dthis,e=3Dt.ctx,n=3Dt.options;if(n.display){var i,a,r= ,o=3DH.options._parseFont(n),s=3Do.lineHeight,l=3Ds/2+n.padding,u=3D0,d=3Dt= .top,h=3Dt.left,c=3Dt.bottom,f=3Dt.right;e.fillStyle=3DH.valueOrDefault(n.f= ontColor,N.global.defaultFontColor),e.font=3Do.string,t.isHorizontal()?(a= =3Dh+(f-h)/2,r=3Dd+l,i=3Df-h):(a=3D"left"=3D=3D=3Dn.position?h+l:f-l,r=3Dd+= (c-d)/2,i=3Dc-d,u=3DMath.PI*("left"=3D=3D=3Dn.position?-.5:.5)),e.save(),e.= translate(a,r),e.rotate(u),e.textAlign=3D"center",e.textBaseline=3D"middle"= ;var g=3Dn.text;if(H.isArray(g))for(var p=3D0,m=3D0;m=3D0;i--){var a=3Dt[i];if(e(a))r= eturn a}},H.isNumber=3Dfunction(t){return!isNaN(parseFloat(t))&&isFinite(t)= },H.almostEquals=3Dfunction(t,e,n){return Math.abs(t-e)=3Dt},H.max=3Dfunc= tion(t){return t.reduce((function(t,e){return isNaN(e)?t:Math.max(t,e)}),Nu= mber.NEGATIVE_INFINITY)},H.min=3Dfunction(t){return t.reduce((function(t,e)= {return isNaN(e)?t:Math.min(t,e)}),Number.POSITIVE_INFINITY)},H.sign=3DMath= .sign?function(t){return Math.sign(t)}:function(t){return 0=3D=3D=3D(t=3D+t= )||isNaN(t)?t:t>0?1:-1},H.toRadians=3Dfunction(t){return t*(Math.PI/180)},H= .toDegrees=3Dfunction(t){return t*(180/Math.PI)},H._decimalPlaces=3Dfunctio= n(t){if(H.isFinite(t)){for(var e=3D1,n=3D0;Math.round(t*e)/e!=3D=3Dt;)e*=3D= 10,n++;return n}},H.getAngleFromPoint=3Dfunction(t,e){var n=3De.x-t.x,i=3De= .y-t.y,a=3DMath.sqrt(n*n+i*i),r=3DMath.atan2(i,n);return r<-.5*Math.PI&&(r+= =3D2*Math.PI),{angle:r,distance:a}},H.distanceBetweenPoints=3Dfunction(t,e)= {return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))},H.aliasPixel=3D= function(t){return t%2=3D=3D0?0:.5},H._alignPixel=3Dfunction(t,e,n){var i= =3Dt.currentDevicePixelRatio,a=3Dn/2;return Math.round((e-a)*i)/i+a},H.spli= neCurve=3Dfunction(t,e,n,i){var a=3Dt.skip?e:t,r=3De,o=3Dn.skip?e:n,s=3DMat= h.sqrt(Math.pow(r.x-a.x,2)+Math.pow(r.y-a.y,2)),l=3DMath.sqrt(Math.pow(o.x-= r.x,2)+Math.pow(o.y-r.y,2)),u=3Ds/(s+l),d=3Dl/(s+l),h=3Di*(u=3DisNaN(u)?0:u= ),c=3Di*(d=3DisNaN(d)?0:d);return{previous:{x:r.x-h*(o.x-a.x),y:r.y-h*(o.y-= a.y)},next:{x:r.x+c*(o.x-a.x),y:r.y+c*(o.y-a.y)}}},H.EPSILON=3DNumber.EPSIL= ON||1e-14,H.splineCurveMonotone=3Dfunction(t){var e,n,i,a,r,o,s,l,u,d=3D(t|= |[]).map((function(t){return{model:t._model,deltaK:0,mK:0}})),h=3Dd.length;= for(e=3D0;e0?d[e-1]:null,(a=3De<= h-1?d[e+1]:null)&&!a.model.skip){var c=3Da.model.x-i.model.x;i.deltaK=3D0!= =3D=3Dc?(a.model.y-i.model.y)/c:0}!n||n.model.skip?i.mK=3Di.deltaK:!a||a.mo= del.skip?i.mK=3Dn.deltaK:this.sign(n.deltaK)!=3D=3Dthis.sign(i.deltaK)?i.mK= =3D0:i.mK=3D(n.deltaK+i.deltaK)/2}for(e=3D0;e0?d[e-1]:null,a=3De=3Dt.length-1?t[0]:t[e+1]:e>=3Dt.length-1?t[t.lengt= h-1]:t[e+1]},H.previousItem=3Dfunction(t,e,n){return n?e<=3D0?t[t.length-1]= :t[e-1]:e<=3D0?t[0]:t[e-1]},H.niceNum=3Dfunction(t,e){var n=3DMath.floor(H.= log10(t)),i=3Dt/Math.pow(10,n);return(e?i<1.5?1:i<3?2:i<7?5:10:i<=3D1?1:i<= =3D2?2:i<=3D5?5:10)*Math.pow(10,n)},H.requestAnimFrame=3D"undefined"=3D=3Dt= ypeof window?function(t){t()}:window.requestAnimationFrame||window.webkitRe= questAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimat= ionFrame||window.msRequestAnimationFrame||function(t){return window.setTime= out(t,1e3/60)},H.getRelativePosition=3Dfunction(t,e){var n,i,a=3Dt.original= Event||t,r=3Dt.target||t.srcElement,o=3Dr.getBoundingClientRect(),s=3Da.tou= ches;s&&s.length>0?(n=3Ds[0].clientX,i=3Ds[0].clientY):(n=3Da.clientX,i=3Da= .clientY);var l=3DparseFloat(H.getStyle(r,"padding-left")),u=3DparseFloat(H= .getStyle(r,"padding-top")),d=3DparseFloat(H.getStyle(r,"padding-right")),h= =3DparseFloat(H.getStyle(r,"padding-bottom")),c=3Do.right-o.left-l-d,f=3Do.= bottom-o.top-u-h;return{x:n=3DMath.round((n-o.left-l)/c*r.width/e.currentDe= vicePixelRatio),y:i=3DMath.round((i-o.top-u)/f*r.height/e.currentDevicePixe= lRatio)}},H.getConstraintWidth=3Dfunction(t){return n(t,"max-width","client= Width")},H.getConstraintHeight=3Dfunction(t){return n(t,"max-height","clien= tHeight")},H._calculatePadding=3Dfunction(t,e,n){return(e=3DH.getStyle(t,e)= ).indexOf("%")>-1?n*parseInt(e,10)/100:parseInt(e,10)},H._getParentNode=3Df= unction(t){var e=3Dt.parentNode;return e&&"[object ShadowRoot]"=3D=3D=3De.t= oString()&&(e=3De.host),e},H.getMaximumWidth=3Dfunction(t){var e=3DH._getPa= rentNode(t);if(!e)return t.clientWidth;var n=3De.clientWidth,i=3Dn-H._calcu= latePadding(e,"padding-left",n)-H._calculatePadding(e,"padding-right",n),a= =3DH.getConstraintWidth(t);return isNaN(a)?i:Math.min(i,a)},H.getMaximumHei= ght=3Dfunction(t){var e=3DH._getParentNode(t);if(!e)return t.clientHeight;v= ar n=3De.clientHeight,i=3Dn-H._calculatePadding(e,"padding-top",n)-H._calcu= latePadding(e,"padding-bottom",n),a=3DH.getConstraintHeight(t);return isNaN= (a)?i:Math.min(i,a)},H.getStyle=3Dfunction(t,e){return t.currentStyle?t.cur= rentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue= (e)},H.retinaScale=3Dfunction(t,e){var n=3Dt.currentDevicePixelRatio=3De||"= undefined"!=3Dtypeof window&&window.devicePixelRatio||1;if(1!=3D=3Dn){var i= =3Dt.canvas,a=3Dt.height,r=3Dt.width;i.height=3Da*n,i.width=3Dr*n,t.ctx.sca= le(n,n),i.style.height||i.style.width||(i.style.height=3Da+"px",i.style.wid= th=3Dr+"px")}},H.fontString=3Dfunction(t,e,n){return e+" "+t+"px "+n},H.lon= gestText=3Dfunction(t,e,n,i){var a=3D(i=3Di||{}).data=3Di.data||{},r=3Di.ga= rbageCollect=3Di.garbageCollect||[];i.font!=3D=3De&&(a=3Di.data=3D{},r=3Di.= garbageCollect=3D[],i.font=3De),t.font=3De;var o,s,l,u,d,h=3D0,c=3Dn.length= ;for(o=3D0;on.length){for(o=3D0;oi&&(i=3Dr),i},H.numberOfLabelLines=3Dfu= nction(t){var e=3D1;return H.each(t,(function(t){H.isArray(t)&&t.length>e&&= (e=3Dt.length)})),e},H.color=3D_?function(t){return t instanceof CanvasGrad= ient&&(t=3DN.global.defaultColor),_(t)}:function(t){return console.error("C= olor.js not found!"),t},H.getHoverColor=3Dfunction(t){return t instanceof C= anvasPattern||t instanceof CanvasGradient?t:H.color(t).saturate(.5).darken(= .1).rgbString()}}(),en._adapters=3Drn,en.Animation=3D$,en.animationService= =3DJ,en.controllers=3DJt,en.DatasetController=3Dit,en.defaults=3DN,en.Eleme= nt=3DK,en.elements=3Dkt,en.Interaction=3Dre,en.layouts=3Dpe,en.platform=3DO= e,en.plugins=3DLe,en.Scale=3Dyn,en.scaleService=3DRe,en.Ticks=3Don,en.Toolt= ip=3DYe,en.helpers.each(fi,(function(t,e){en.scaleService.registerScaleType= (e,t,t._defaults)})),Li)Li.hasOwnProperty(Bi)&&en.plugins.register(Li[Bi]);= en.platform.initialize();var Ei=3Den;return"undefined"!=3Dtypeof window&&(w= indow.Chart=3Den),en.Chart=3Den,en.Legend=3DLi.legend._element,en.Title=3DL= i.title._element,en.pluginService=3Den.plugins,en.PluginBase=3Den.Element.e= xtend({}),en.canvasHelpers=3Den.helpers.canvas,en.layoutService=3Den.layout= s,en.LinearScaleBase=3DCn,en.helpers.each(["Bar","Bubble","Doughnut","Line"= ,"PolarArea","Radar","Scatter"],(function(t){en[t]=3Dfunction(e,n){return n= ew en(e,en.helpers.merge(n||{},{type:t.charAt(0).toLowerCase()+t.slice(1)})= )}})),Ei})); --=20 2.34.1