!function(e,t){"function"==typeof define&&define.amd?define("Chartist",[],function(){return e.Chartist=t()}):"object"==typeof module&&module.exports?module.exports=t():e.Chartist=t()}(this,function(){var e={version:"0.11.0"};return function(e,t,i){"use strict";i.namespaces={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns/",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",ct:"http://gionkunz.github.com/chartist-js/ct"},i.noop=function(e){return e},i.alphaNumerate=function(e){return String.fromCharCode(97+e%26)},i.extend=function(e){var t,n,s;for(e=e||{},t=1;t":">",'"':""","'":"'"},i.serialize=function(e){return null===e||void 0===e?e:("number"==typeof e?e=""+e:"object"==typeof e&&(e=JSON.stringify({data:e})),Object.keys(i.escapingMap).reduce(function(e,t){return i.replaceAll(e,t,i.escapingMap[t])},e))},i.deserialize=function(e){if("string"!=typeof e)return e;e=Object.keys(i.escapingMap).reduce(function(e,t){return i.replaceAll(e,i.escapingMap[t],t)},e);try{e=void 0!==(e=JSON.parse(e)).data?e.data:e}catch(e){}return e},i.createSvg=function(e,t,n,s){var r;return t=t||"100%",n=n||"100%",Array.prototype.slice.call(e.querySelectorAll("svg")).filter(function(e){return e.getAttributeNS(i.namespaces.xmlns,"ct")}).forEach(function(t){e.removeChild(t)}),(r=new i.Svg("svg").attr({width:t,height:n}).addClass(s))._node.style.width=t,r._node.style.height=n,e.appendChild(r._node),r},i.normalizeData=function(e,t,n){var s,r={raw:e,normalized:{}};return r.normalized.series=i.getDataArray({series:e.series||[]},t,n),s=r.normalized.series.every(function(e){return e instanceof Array})?Math.max.apply(null,r.normalized.series.map(function(e){return e.length})):r.normalized.series.length,r.normalized.labels=(e.labels||[]).slice(),Array.prototype.push.apply(r.normalized.labels,i.times(Math.max(0,s-r.normalized.labels.length)).map(function(){return""})),t&&i.reverseData(r.normalized),r},i.safeHasProperty=function(e,t){return null!==e&&"object"==typeof e&&e.hasOwnProperty(t)},i.isDataHoleValue=function(e){return null===e||void 0===e||"number"==typeof e&&isNaN(e)},i.reverseData=function(e){e.labels.reverse(),e.series.reverse();for(var t=0;ts.high&&(s.high=o),a&&o0?s.low=0:(s.high=1,s.low=0)),s},i.isNumeric=function(e){return null!==e&&isFinite(e)},i.isFalseyButZero=function(e){return!e&&0!==e},i.getNumberOrUndefined=function(e){return i.isNumeric(e)?+e:void 0},i.isMultiValue=function(e){return"object"==typeof e&&("x"in e||"y"in e)},i.getMultiValue=function(e,t){return i.isMultiValue(e)?i.getNumberOrUndefined(e[t||"y"]):i.getNumberOrUndefined(e)},i.rho=function(e){function t(e,i){return e%i==0?i:t(i,e%i)}function i(e){return e*e+1}if(1===e)return e;var n,s=2,r=2;if(e%2==0)return 2;do{s=i(s)%e,r=i(i(r))%e,n=t(Math.abs(s-r),e)}while(1===n);return n},i.getBounds=function(e,t,n,s){function r(e,t){return e===(e+=t)&&(e*=1+(t>0?p:-p)),e}var a,o,l,c=0,u={high:t.high,low:t.low};u.valueRange=u.high-u.low,u.oom=i.orderOfMagnitude(u.valueRange),u.step=Math.pow(10,u.oom),u.min=Math.floor(u.low/u.step)*u.step,u.max=Math.ceil(u.high/u.step)*u.step,u.range=u.max-u.min,u.numberOfSteps=Math.round(u.range/u.step);var h=i.projectLength(e,u.step,u)=n)u.step=1;else if(s&&d=n)u.step=d;else for(;;){if(h&&i.projectLength(e,u.step,u)<=n)u.step*=2;else{if(h||!(i.projectLength(e,u.step/2,u)>=n))break;if(u.step/=2,s&&u.step%1!=0){u.step*=2;break}}if(c++>1e3)throw new Error("Exceeded maximum number of iterations while optimizing scale step!")}var p=2.221e-16;for(u.step=Math.max(u.step,p),o=u.min,l=u.max;o+u.step<=u.low;)o=r(o,u.step);for(;l-u.step>=u.high;)l=r(l,-u.step);u.min=o,u.max=l,u.range=u.max-u.min;var f=[];for(a=u.min;a<=u.max;a=r(a,u.step)){var m=i.roundWithPrecision(a);m!==f[f.length-1]&&f.push(m)}return u.values=f,u},i.polarToCartesian=function(e,t,i,n){var s=(n-90)*Math.PI/180;return{x:e+i*Math.cos(s),y:t+i*Math.sin(s)}},i.createChartRect=function(e,t,n){var s=!(!t.axisX&&!t.axisY),r=s?t.axisY.offset:0,a=s?t.axisX.offset:0,o=e.width()||i.quantity(t.width).value||0,l=e.height()||i.quantity(t.height).value||0,c=i.normalizePadding(t.chartPadding,n);o=Math.max(o,r+c.left+c.right),l=Math.max(l,a+c.top+c.bottom);var u={padding:c,width:function(){return this.x2-this.x1},height:function(){return this.y1-this.y2}};return s?("start"===t.axisX.position?(u.y2=c.top+a,u.y1=Math.max(l-c.bottom,u.y2+1)):(u.y2=c.top,u.y1=Math.max(l-c.bottom-a,u.y2+1)),"start"===t.axisY.position?(u.x1=c.left+r,u.x2=Math.max(o-c.right,u.x1+1)):(u.x1=c.left,u.x2=Math.max(o-c.right-r,u.x1+1))):(u.x1=c.left,u.x2=Math.max(o-c.right,u.x1+1),u.y2=c.top,u.y1=Math.max(l-c.bottom,u.y2+1)),u},i.createGrid=function(e,t,n,s,r,a,o,l){var c={};c[n.units.pos+"1"]=e,c[n.units.pos+"2"]=e,c[n.counterUnits.pos+"1"]=s,c[n.counterUnits.pos+"2"]=s+r;var u=a.elem("line",c,o.join(" "));l.emit("draw",i.extend({type:"grid",axis:n,index:t,group:a,element:u},c))},i.createGridBackground=function(e,t,i,n){var s=e.elem("rect",{x:t.x1,y:t.y2,width:t.width(),height:t.height()},i,!0);n.emit("draw",{type:"gridBackground",group:e,element:s})},i.createLabel=function(e,n,s,r,a,o,l,c,u,h,d){var p,f={};if(f[a.units.pos]=e+l[a.units.pos],f[a.counterUnits.pos]=l[a.counterUnits.pos],f[a.units.len]=n,f[a.counterUnits.len]=Math.max(0,o-10),h){var m=t.createElement("span");m.className=u.join(" "),m.setAttribute("xmlns",i.namespaces.xhtml),m.innerText=r[s],m.style[a.units.len]=Math.round(f[a.units.len])+"px",m.style[a.counterUnits.len]=Math.round(f[a.counterUnits.len])+"px",p=c.foreignObject(m,i.extend({style:"overflow: visible;"},f))}else p=c.elem("text",f,u.join(" ")).text(r[s]);d.emit("draw",i.extend({type:"label",axis:a,index:s,group:c,element:p,text:r[s]},f))},i.getSeriesOption=function(e,t,i){if(e.name&&t.series&&t.series[e.name]){var n=t.series[e.name];return n.hasOwnProperty(i)?n[i]:t[i]}return t[i]},i.optionsProvider=function(t,n,s){function r(t){var r=a;if(a=i.extend({},l),n)for(o=0;o=2&&e[a]<=e[a-2]&&(r=!0),r&&(s.push({pathCoordinates:[],valueData:[]}),r=!1),s[s.length-1].pathCoordinates.push(e[a],e[a+1]),s[s.length-1].valueData.push(t[a/2]));return s}}(window,document,e),function(e,t,i){"use strict";i.Interpolation={},i.Interpolation.none=function(e){return e=i.extend({},{fillHoles:!1},e),function(t,n){for(var s=new i.Svg.Path,r=!0,a=0;a1){var l=[];return o.forEach(function(e){l.push(s(e.pathCoordinates,e.valueData))}),i.Svg.Path.join(l)}if(r=o[0].pathCoordinates,a=o[0].valueData,r.length<=4)return i.Interpolation.none()(r,a);for(var c=(new i.Svg.Path).move(r[0],r[1],!1,a[0]),u=0,h=r.length;h-2>u;u+=2){var d=[{x:+r[u-2],y:+r[u-1]},{x:+r[u],y:+r[u+1]},{x:+r[u+2],y:+r[u+3]},{x:+r[u+4],y:+r[u+5]}];h-4===u?d[3]=d[2]:u||(d[0]={x:+r[u],y:+r[u+1]}),c.curve(t*(-d[0].x+6*d[1].x+d[2].x)/6+n*d[2].x,t*(-d[0].y+6*d[1].y+d[2].y)/6+n*d[2].y,t*(d[1].x+6*d[2].x-d[3].x)/6+n*d[2].x,t*(d[1].y+6*d[2].y-d[3].y)/6+n*d[2].y,d[2].x,d[2].y,!1,a[(u+2)/2])}return c}return i.Interpolation.none()([])}},i.Interpolation.monotoneCubic=function(e){return e=i.extend({},{fillHoles:!1},e),function t(n,s){var r=i.splitIntoSegments(n,s,{fillHoles:e.fillHoles,increasingX:!0});if(r.length){if(r.length>1){var a=[];return r.forEach(function(e){a.push(t(e.pathCoordinates,e.valueData))}),i.Svg.Path.join(a)}if(n=r[0].pathCoordinates,s=r[0].valueData,n.length<=4)return i.Interpolation.none()(n,s);var o,l,c=[],u=[],h=n.length/2,d=[],p=[],f=[],m=[];for(o=0;o0!=p[o]>0?d[o]=0:(d[o]=3*(m[o-1]+m[o])/((2*m[o]+m[o-1])/p[o-1]+(m[o]+2*m[o-1])/p[o]),isFinite(d[o])||(d[o]=0));for(l=(new i.Svg.Path).move(c[0],u[0],!1,s[0]),o=0;o1}).map(function(e){var t=e.pathElements[0],i=e.pathElements[e.pathElements.length-1];return e.clone(!0).position(0).remove(1).move(t.x,g).line(t.x,t.y).position(e.pathElements.length+1).line(i.x,g)}).forEach(function(i){var o=l.elem("path",{d:i.stringify()},e.classNames.area,!0);this.eventEmitter.emit("draw",{type:"area",values:t.normalized.series[a],path:i.clone(),series:n,seriesIndex:a,axisX:s,axisY:r,chartRect:c,index:a,group:l,element:o})}.bind(this))}}.bind(this)),this.eventEmitter.emit("created",{bounds:r.bounds,chartRect:c,axisX:s,axisY:r,svg:this.svg,options:e})}})}(window,document,e),function(e,t,i){"use strict";var n={axisX:{offset:30,position:"end",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:i.noop,scaleMinSpace:30,onlyInteger:!1},axisY:{offset:40,position:"start",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:i.noop,scaleMinSpace:20,onlyInteger:!1},width:void 0,height:void 0,high:void 0,low:void 0,referenceValue:0,chartPadding:{top:15,right:15,bottom:5,left:10},seriesBarDistance:15,stackBars:!1,stackMode:"accumulate",horizontalBars:!1,distributeSeries:!1,reverseData:!1,showGridBackground:!1,classNames:{chart:"ct-chart-bar",horizontalBars:"ct-horizontal-bars",label:"ct-label",labelGroup:"ct-labels",series:"ct-series",bar:"ct-bar",grid:"ct-grid",gridGroup:"ct-grids",gridBackground:"ct-grid-background",vertical:"ct-vertical",horizontal:"ct-horizontal",start:"ct-start",end:"ct-end"}};i.Bar=i.Base.extend({constructor:function(e,t,s,r){i.Bar.super.constructor.call(this,e,t,n,i.extend({},n,s),r)},createChart:function(e){var t,s;e.distributeSeries?(t=i.normalizeData(this.data,e.reverseData,e.horizontalBars?"x":"y")).normalized.series=t.normalized.series.map(function(e){return[e]}):t=i.normalizeData(this.data,e.reverseData,e.horizontalBars?"x":"y"),this.svg=i.createSvg(this.container,e.width,e.height,e.classNames.chart+(e.horizontalBars?" "+e.classNames.horizontalBars:""));var r=this.svg.elem("g").addClass(e.classNames.gridGroup),a=this.svg.elem("g"),o=this.svg.elem("g").addClass(e.classNames.labelGroup);if(e.stackBars&&0!==t.normalized.series.length){var l=i.serialMap(t.normalized.series,function(){return Array.prototype.slice.call(arguments).map(function(e){return e}).reduce(function(e,t){return{x:e.x+(t&&t.x)||0,y:e.y+(t&&t.y)||0}},{x:0,y:0})});s=i.getHighLow([l],e,e.horizontalBars?"x":"y")}else s=i.getHighLow(t.normalized.series,e,e.horizontalBars?"x":"y");s.high=+e.high||(0===e.high?0:s.high),s.low=+e.low||(0===e.low?0:s.low);var c,u,h,d,p,f=i.createChartRect(this.svg,e,n.padding);u=e.distributeSeries&&e.stackBars?t.normalized.labels.slice(0,1):t.normalized.labels,e.horizontalBars?(c=d=void 0===e.axisX.type?new i.AutoScaleAxis(i.Axis.units.x,t.normalized.series,f,i.extend({},e.axisX,{highLow:s,referenceValue:0})):e.axisX.type.call(i,i.Axis.units.x,t.normalized.series,f,i.extend({},e.axisX,{highLow:s,referenceValue:0})),h=p=void 0===e.axisY.type?new i.StepAxis(i.Axis.units.y,t.normalized.series,f,{ticks:u}):e.axisY.type.call(i,i.Axis.units.y,t.normalized.series,f,e.axisY)):(h=d=void 0===e.axisX.type?new i.StepAxis(i.Axis.units.x,t.normalized.series,f,{ticks:u}):e.axisX.type.call(i,i.Axis.units.x,t.normalized.series,f,e.axisX),c=p=void 0===e.axisY.type?new i.AutoScaleAxis(i.Axis.units.y,t.normalized.series,f,i.extend({},e.axisY,{highLow:s,referenceValue:0})):e.axisY.type.call(i,i.Axis.units.y,t.normalized.series,f,i.extend({},e.axisY,{highLow:s,referenceValue:0})));var m=e.horizontalBars?f.x1+c.projectValue(0):f.y1-c.projectValue(0),g=[];h.createGridAndLabels(r,o,this.supportsForeignObject,e,this.eventEmitter),c.createGridAndLabels(r,o,this.supportsForeignObject,e,this.eventEmitter),e.showGridBackground&&i.createGridBackground(r,f,e.classNames.gridBackground,this.eventEmitter),t.raw.series.forEach(function(n,s){var r,o,l=s-(t.raw.series.length-1)/2;r=e.distributeSeries&&!e.stackBars?h.axisLength/t.normalized.series.length/2:e.distributeSeries&&e.stackBars?h.axisLength/2:h.axisLength/t.normalized.series[s].length/2,(o=a.elem("g")).attr({"ct:series-name":n.name,"ct:meta":i.serialize(n.meta)}),o.addClass([e.classNames.series,n.className||e.classNames.series+"-"+i.alphaNumerate(s)].join(" ")),t.normalized.series[s].forEach(function(a,u){var v,x,y,b;if(b=e.distributeSeries&&!e.stackBars?s:e.distributeSeries&&e.stackBars?0:u,v=e.horizontalBars?{x:f.x1+c.projectValue(a&&a.x?a.x:0,u,t.normalized.series[s]),y:f.y1-h.projectValue(a&&a.y?a.y:0,b,t.normalized.series[s])}:{x:f.x1+h.projectValue(a&&a.x?a.x:0,b,t.normalized.series[s]),y:f.y1-c.projectValue(a&&a.y?a.y:0,u,t.normalized.series[s])},h instanceof i.StepAxis&&(h.options.stretch||(v[h.units.pos]+=r*(e.horizontalBars?-1:1)),v[h.units.pos]+=e.stackBars||e.distributeSeries?0:l*e.seriesBarDistance*(e.horizontalBars?-1:1)),y=g[u]||m,g[u]=y-(m-v[h.counterUnits.pos]),void 0!==a){var w={};w[h.units.pos+"1"]=v[h.units.pos],w[h.units.pos+"2"]=v[h.units.pos],!e.stackBars||"accumulate"!==e.stackMode&&e.stackMode?(w[h.counterUnits.pos+"1"]=m,w[h.counterUnits.pos+"2"]=v[h.counterUnits.pos]):(w[h.counterUnits.pos+"1"]=y,w[h.counterUnits.pos+"2"]=g[u]),w.x1=Math.min(Math.max(w.x1,f.x1),f.x2),w.x2=Math.min(Math.max(w.x2,f.x1),f.x2),w.y1=Math.min(Math.max(w.y1,f.y2),f.y1),w.y2=Math.min(Math.max(w.y2,f.y2),f.y1);var E=i.getMetaData(n,u);x=o.elem("line",w,e.classNames.bar).attr({"ct:value":[a.x,a.y].filter(i.isNumeric).join(","),"ct:meta":i.serialize(E)}),this.eventEmitter.emit("draw",i.extend({type:"bar",value:a,index:u,meta:E,series:n,seriesIndex:s,axisX:d,axisY:p,chartRect:f,group:o,element:x},w))}}.bind(this))}.bind(this)),this.eventEmitter.emit("created",{bounds:c.bounds,chartRect:f,axisX:d,axisY:p,svg:this.svg,options:e})}})}(window,document,e),function(e,t,i){"use strict";function n(e,t,i){var n=t.x>e.x;return n&&"explode"===i||!n&&"implode"===i?"start":n&&"implode"===i||!n&&"explode"===i?"end":"middle"}var s={width:void 0,height:void 0,chartPadding:5,classNames:{chartPie:"ct-chart-pie",chartDonut:"ct-chart-donut",series:"ct-series",slicePie:"ct-slice-pie",sliceDonut:"ct-slice-donut",sliceDonutSolid:"ct-slice-donut-solid",label:"ct-label"},startAngle:0,total:void 0,donut:!1,donutSolid:!1,donutWidth:60,showLabel:!0,labelOffset:0,labelPosition:"inside",labelInterpolationFnc:i.noop,labelDirection:"neutral",reverseData:!1,ignoreEmptyValues:!1};i.Pie=i.Base.extend({constructor:function(e,t,n,r){i.Pie.super.constructor.call(this,e,t,s,i.extend({},s,n),r)},createChart:function(e){var t,r,a,o,l,c=i.normalizeData(this.data),u=[],h=e.startAngle;this.svg=i.createSvg(this.container,e.width,e.height,e.donut?e.classNames.chartDonut:e.classNames.chartPie),r=i.createChartRect(this.svg,e,s.padding),a=Math.min(r.width()/2,r.height()/2),l=e.total||c.normalized.series.reduce(function(e,t){return e+t},0);var d=i.quantity(e.donutWidth);"%"===d.unit&&(d.value*=a/100),a-=e.donut&&!e.donutSolid?d.value/2:0,o="outside"===e.labelPosition||e.donut&&!e.donutSolid?a:"center"===e.labelPosition?0:e.donutSolid?a-d.value/2:a/2,o+=e.labelOffset;var p={x:r.x1+r.width()/2,y:r.y2+r.height()/2},f=1===c.raw.series.filter(function(e){return e.hasOwnProperty("value")?0!==e.value:0!==e}).length;c.raw.series.forEach(function(e,t){u[t]=this.svg.elem("g",null,null)}.bind(this)),e.showLabel&&(t=this.svg.elem("g",null,null)),c.raw.series.forEach(function(s,r){if(0!==c.normalized.series[r]||!e.ignoreEmptyValues){u[r].attr({"ct:series-name":s.name}),u[r].addClass([e.classNames.series,s.className||e.classNames.series+"-"+i.alphaNumerate(r)].join(" "));var m=l>0?h+c.normalized.series[r]/l*360:0,g=Math.max(0,h-(0===r||f?0:.2));m-g>=359.99&&(m=g+359.99);var v,x,y,b=i.polarToCartesian(p.x,p.y,a,g),w=i.polarToCartesian(p.x,p.y,a,m),E=new i.Svg.Path(!e.donut||e.donutSolid).move(w.x,w.y).arc(a,a,0,m-h>180,0,b.x,b.y);e.donut?e.donutSolid&&(y=a-d.value,v=i.polarToCartesian(p.x,p.y,y,h-(0===r||f?0:.2)),x=i.polarToCartesian(p.x,p.y,y,m),E.line(v.x,v.y),E.arc(y,y,0,m-h>180,1,x.x,x.y)):E.line(p.x,p.y);var S=e.classNames.slicePie;e.donut&&(S=e.classNames.sliceDonut,e.donutSolid&&(S=e.classNames.sliceDonutSolid));var A=u[r].elem("path",{d:E.stringify()},S);if(A.attr({"ct:value":c.normalized.series[r],"ct:meta":i.serialize(s.meta)}),e.donut&&!e.donutSolid&&(A._node.style.strokeWidth=d.value+"px"),this.eventEmitter.emit("draw",{type:"slice",value:c.normalized.series[r],totalDataSum:l,index:r,meta:s.meta,series:s,group:u[r],element:A,path:E.clone(),center:p,radius:a,startAngle:h,endAngle:m}),e.showLabel){var z,N;z=1===c.raw.series.length?{x:p.x,y:p.y}:i.polarToCartesian(p.x,p.y,o,h+(m-h)/2),N=c.normalized.labels&&!i.isFalseyButZero(c.normalized.labels[r])?c.normalized.labels[r]:c.normalized.series[r];var C=e.labelInterpolationFnc(N,r);if(C||0===C){var M=t.elem("text",{dx:z.x,dy:z.y,"text-anchor":n(p,z,e.labelDirection)},e.classNames.label).text(""+C);this.eventEmitter.emit("draw",{type:"label",index:r,group:t,element:M,text:""+C,x:z.x,y:z.y})}}h=m}}.bind(this)),this.eventEmitter.emit("created",{chartRect:r,svg:this.svg,options:e})},determineAnchorPosition:n})}(window,document,e),e}),function(e,t){"function"==typeof define&&define.amd?define(["chartist"],function(i){return e.returnExportsGlobal=t(i)}):"object"==typeof exports?module.exports=t(require("chartist")):e["Chartist.plugins.legend"]=t(e.Chartist)}(this,function(e){"use strict";var t={className:"",classNames:!1,removeAll:!1,legendNames:!1,clickable:!0,onClick:null,position:"top"};return e.plugins=e.plugins||{},e.plugins.legend=function(i){function n(e,t){return e-t}if(i&&i.position){if(!("top"===i.position||"bottom"===i.position||i.position instanceof HTMLElement))throw Error("The position you entered is not a valid position");if(i.position instanceof HTMLElement){var s=i.position;delete i.position}}return i=e.extend({},t,i),s&&(i.position=s),function(t){var s=t.container.querySelector(".ct-legend");if(s&&s.parentNode.removeChild(s),i.clickable){var r=t.data.series.map(function(i,n){return"object"!=typeof i&&(i={value:i}),i.className=i.className||t.options.classNames.series+"-"+e.alphaNumerate(n),i});t.data.series=r}var a=document.createElement("ul"),o=t instanceof e.Pie;a.className="ct-legend",t instanceof e.Pie&&a.classList.add("ct-legend-inside"),"string"==typeof i.className&&i.className.length>0&&a.classList.add(i.className),t.options.width&&(a.style.cssText="width: "+t.options.width+"px;margin: 0 auto;");var l=[],c=t.data.series.slice(0),u=t.data.series,h=o&&t.data.labels;if(h){var d=t.data.labels.slice(0);u=t.data.labels}u=i.legendNames||u;var p=Array.isArray(i.classNames)&&i.classNames.length===u.length;u.forEach(function(e,t){var n=document.createElement("li");n.className="ct-series-"+t,p&&(n.className+=" "+i.classNames[t]),n.setAttribute("data-legend",t),n.textContent=e.name||e,a.appendChild(n)}),t.on("created",function(e){if(i.position instanceof HTMLElement)i.position.insertBefore(a,null);else switch(i.position){case"top":t.container.insertBefore(a,t.container.childNodes[0]);break;case"bottom":t.container.insertBefore(a,null)}}),i.clickable&&a.addEventListener("click",function(e){var s=e.target;if(s.parentNode===a&&s.hasAttribute("data-legend")){e.preventDefault();var r=parseInt(s.getAttribute("data-legend")),o=l.indexOf(r);if(o>-1)l.splice(o,1),s.classList.remove("inactive");else if(i.removeAll)l.push(r),s.classList.add("inactive");else if(t.data.series.length>1)l.push(r),s.classList.add("inactive");else l=[],Array.prototype.slice.call(a.childNodes).forEach(function(e){e.classList.remove("inactive")});var u=c.slice(0);if(h)var p=d.slice(0);l.sort(n).reverse(),l.forEach(function(e){u.splice(e,1),h&&p.splice(e,1)}),i.onClick&&i.onClick(t,e),t.data.series=u,h&&(t.data.labels=p),t.update()}})}},e.plugins.legend});