From 83c9f100e562fe6e296b10bb8bcfcd81f778ed77 Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Fri, 4 Dec 2020 01:41:29 -0600 Subject: [PATCH] pass extendGap and buildClip helpers to pathBuilder --- dist/uPlot.cjs.js | 21 ++++++++++----------- dist/uPlot.d.ts | 8 +++++++- dist/uPlot.esm.js | 21 ++++++++++----------- dist/uPlot.iife.js | 21 ++++++++++----------- dist/uPlot.iife.min.js | 2 +- src/uPlot.js | 21 ++++++++++----------- 6 files changed, 48 insertions(+), 46 deletions(-) diff --git a/dist/uPlot.cjs.js b/dist/uPlot.cjs.js index 8fdb3fb5..03bc1e7d 100644 --- a/dist/uPlot.cjs.js +++ b/dist/uPlot.cjs.js @@ -2043,7 +2043,7 @@ function uPlot(opts, data, then) { series.forEach(function (s, i) { if (i > 0 && s.show && s._paths == null) { var _idxs = getOuterIdxs(data[i]); - s._paths = s.paths(self, i, _idxs[0], _idxs[1]); + s._paths = s.paths(self, i, _idxs[0], _idxs[1], extendGap, buildClip); } }); @@ -2123,13 +2123,11 @@ function uPlot(opts, data, then) { { dir *= -1; } } - function buildClip(is, gaps) { - var s = series[is]; - + function buildClip(gaps) { var clip = null; // create clip path (invert gaps and non-gaps) - if (gaps.length > 0 && !s.spanGaps) { + if (gaps.length > 0) { clip = new Path2D(); var prevGapEnd = plotLft; @@ -2148,7 +2146,7 @@ function uPlot(opts, data, then) { return clip; } - function addGap(gaps, fromX, toX) { + function extendGap(gaps, fromX, toX) { if (toX > fromX) { var prevGap = gaps[gaps.length - 1]; @@ -2168,7 +2166,7 @@ function uPlot(opts, data, then) { return -1; } - function buildPaths(self, is, _i0, _i1) { + function buildPaths(self, is, _i0, _i1, extendGap, buildClip) { var s = series[is]; var isGap = s.isGap; @@ -2198,7 +2196,7 @@ function uPlot(opts, data, then) { var rgtX = incrRound(getXPos(xdata[rgtIdx], scaleX, plotWid, plotLft), 0.5); if (lftX > plotLft) - { addGap(gaps, plotLft, lftX); } + { extendGap(gaps, plotLft, lftX); } // the moves the shape edge outside the canvas so stroke doesnt bleed in if (s.band && dir == 1) @@ -2247,14 +2245,14 @@ function uPlot(opts, data, then) { { accGaps = true; } } - _addGap && addGap(gaps, outX, x); + _addGap && extendGap(gaps, outX, x); accX = x; } } if (rgtX < plotLft + plotWid) - { addGap(gaps, rgtX, plotLft + plotWid); } + { extendGap(gaps, rgtX, plotLft + plotWid); } if (s.band) { var _x, _iy, ydata2; @@ -2276,7 +2274,8 @@ function uPlot(opts, data, then) { } if (dir == 1) { - _paths.clip = buildClip(is, gaps, ydata[_i0] == null, ydata[_i1] == null); + if (!s.spanGaps) + { _paths.clip = buildClip(gaps); } if (s.fill != null) { var fill = _paths.fill = new Path2D(stroke); diff --git a/dist/uPlot.d.ts b/dist/uPlot.d.ts index 1f8290a2..24a90276 100644 --- a/dist/uPlot.d.ts +++ b/dist/uPlot.d.ts @@ -447,7 +447,13 @@ export namespace Series { export type Show = boolean | ((self: uPlot, seriesIdx: number, idx0: number, idx1: number) => boolean | undefined); } - export type PathBuilder = (self: uPlot, seriesIdx: number, idx0: number, idx1: number) => Paths | null; + export type Gaps = [from: number, to: number][]; + + export type ExtendGap = (gaps: Gaps, fromX: number, toX: number) => void; + + export type BuildClip = (gaps: Gaps) => Path2D | null; + + export type PathBuilder = (self: uPlot, seriesIdx: number, idx0: number, idx1: number, extendGap: ExtendGap, buildClip: BuildClip) => Paths | null; export type MinMaxIdxs = [minIdx: number, maxIdx: number]; diff --git a/dist/uPlot.esm.js b/dist/uPlot.esm.js index c47f727f..2dca3406 100644 --- a/dist/uPlot.esm.js +++ b/dist/uPlot.esm.js @@ -2035,7 +2035,7 @@ function uPlot(opts, data, then) { series.forEach((s, i) => { if (i > 0 && s.show && s._paths == null) { let _idxs = getOuterIdxs(data[i]); - s._paths = s.paths(self, i, _idxs[0], _idxs[1]); + s._paths = s.paths(self, i, _idxs[0], _idxs[1], extendGap, buildClip); } }); @@ -2112,13 +2112,11 @@ function uPlot(opts, data, then) { dir *= -1; } - function buildClip(is, gaps) { - let s = series[is]; - + function buildClip(gaps) { let clip = null; // create clip path (invert gaps and non-gaps) - if (gaps.length > 0 && !s.spanGaps) { + if (gaps.length > 0) { clip = new Path2D(); let prevGapEnd = plotLft; @@ -2137,7 +2135,7 @@ function uPlot(opts, data, then) { return clip; } - function addGap(gaps, fromX, toX) { + function extendGap(gaps, fromX, toX) { if (toX > fromX) { let prevGap = gaps[gaps.length - 1]; @@ -2157,7 +2155,7 @@ function uPlot(opts, data, then) { return -1; } - function buildPaths(self, is, _i0, _i1) { + function buildPaths(self, is, _i0, _i1, extendGap, buildClip) { const s = series[is]; const isGap = s.isGap; @@ -2187,7 +2185,7 @@ function uPlot(opts, data, then) { let rgtX = incrRound(getXPos(xdata[rgtIdx], scaleX, plotWid, plotLft), 0.5); if (lftX > plotLft) - addGap(gaps, plotLft, lftX); + extendGap(gaps, plotLft, lftX); // the moves the shape edge outside the canvas so stroke doesnt bleed in if (s.band && dir == 1) @@ -2236,14 +2234,14 @@ function uPlot(opts, data, then) { accGaps = true; } - _addGap && addGap(gaps, outX, x); + _addGap && extendGap(gaps, outX, x); accX = x; } } if (rgtX < plotLft + plotWid) - addGap(gaps, rgtX, plotLft + plotWid); + extendGap(gaps, rgtX, plotLft + plotWid); if (s.band) { let _x, _iy, ydata2; @@ -2265,7 +2263,8 @@ function uPlot(opts, data, then) { } if (dir == 1) { - _paths.clip = buildClip(is, gaps, ydata[_i0] == null, ydata[_i1] == null); + if (!s.spanGaps) + _paths.clip = buildClip(gaps); if (s.fill != null) { let fill = _paths.fill = new Path2D(stroke); diff --git a/dist/uPlot.iife.js b/dist/uPlot.iife.js index c27bda0d..e5ee259b 100644 --- a/dist/uPlot.iife.js +++ b/dist/uPlot.iife.js @@ -2044,7 +2044,7 @@ var uPlot = (function () { series.forEach(function (s, i) { if (i > 0 && s.show && s._paths == null) { var _idxs = getOuterIdxs(data[i]); - s._paths = s.paths(self, i, _idxs[0], _idxs[1]); + s._paths = s.paths(self, i, _idxs[0], _idxs[1], extendGap, buildClip); } }); @@ -2124,13 +2124,11 @@ var uPlot = (function () { { dir *= -1; } } - function buildClip(is, gaps) { - var s = series[is]; - + function buildClip(gaps) { var clip = null; // create clip path (invert gaps and non-gaps) - if (gaps.length > 0 && !s.spanGaps) { + if (gaps.length > 0) { clip = new Path2D(); var prevGapEnd = plotLft; @@ -2149,7 +2147,7 @@ var uPlot = (function () { return clip; } - function addGap(gaps, fromX, toX) { + function extendGap(gaps, fromX, toX) { if (toX > fromX) { var prevGap = gaps[gaps.length - 1]; @@ -2169,7 +2167,7 @@ var uPlot = (function () { return -1; } - function buildPaths(self, is, _i0, _i1) { + function buildPaths(self, is, _i0, _i1, extendGap, buildClip) { var s = series[is]; var isGap = s.isGap; @@ -2199,7 +2197,7 @@ var uPlot = (function () { var rgtX = incrRound(getXPos(xdata[rgtIdx], scaleX, plotWid, plotLft), 0.5); if (lftX > plotLft) - { addGap(gaps, plotLft, lftX); } + { extendGap(gaps, plotLft, lftX); } // the moves the shape edge outside the canvas so stroke doesnt bleed in if (s.band && dir == 1) @@ -2248,14 +2246,14 @@ var uPlot = (function () { { accGaps = true; } } - _addGap && addGap(gaps, outX, x); + _addGap && extendGap(gaps, outX, x); accX = x; } } if (rgtX < plotLft + plotWid) - { addGap(gaps, rgtX, plotLft + plotWid); } + { extendGap(gaps, rgtX, plotLft + plotWid); } if (s.band) { var _x, _iy, ydata2; @@ -2277,7 +2275,8 @@ var uPlot = (function () { } if (dir == 1) { - _paths.clip = buildClip(is, gaps, ydata[_i0] == null, ydata[_i1] == null); + if (!s.spanGaps) + { _paths.clip = buildClip(gaps); } if (s.fill != null) { var fill = _paths.fill = new Path2D(stroke); diff --git a/dist/uPlot.iife.min.js b/dist/uPlot.iife.min.js index d6df7deb..67508e0f 100644 --- a/dist/uPlot.iife.min.js +++ b/dist/uPlot.iife.min.js @@ -1,2 +1,2 @@ /*! https://github.com/leeoniya/uPlot (v1.4.6) */ -var uPlot=function(){"use strict";function n(n,t,e,r){var i;e=e||0;for(var o=2147483647>=(r=r||t.length-1);r-e>1;)n>t[i=o?e+r>>1:v((e+r)/2)]?e=i:r=i;return n-t[e]>t[r]-n?r:e}var t=[0,0];function e(n,e,r,i){return t[0]=0>r?D(n,-r):n,t[1]=0>i?D(e,-i):e,t}function r(n,t,r,i){var o,l,a,u=10==r?w:x;return n==t&&(n/=r,t*=r),i?(o=v(u(n)),l=m(u(t)),n=(a=e(g(r,o),g(r,l),o,l))[0],t=a[1]):(o=v(u(n)),l=v(u(t)),n=z(n,(a=e(g(r,o),g(r,l),o,l))[0]),t=T(t,a[1])),[n,t]}var i={pad:0,soft:null,mode:0},o={min:i,max:i};function l(n,t,e,r){return H(e)?u(n,t,e):(i.pad=e,i.soft=r?0:null,i.mode=r?2:0,u(n,t,o))}function a(n,t){return null==n?t:n}function u(n,t,e){var r=e.min,i=e.max,o=a(r.pad,0),l=a(i.pad,0),u=a(r.hard,-b),s=a(i.hard,b),f=a(r.soft,b),h=a(i.soft,-b),m=a(r.mode,0),x=a(i.mode,0),_=t-n,y=_||c(t)||1e3,M=w(y),k=g(10,v(M)),S=D(z(n-y*(0==_?0==n?.1:1:o),k/100),6),E=n>=f&&(1==m||2==m&&f>S)?f:b,W=p(u,E>S&&n>=E?E:d(E,S)),Y=D(T(t+y*(0==_?0==t?.1:1:l),k/100),6),C=h>=t&&(1==x||2==x&&Y>h)?h:-b,A=d(s,Y>C&&C>=t?C:p(C,Y));return W==A&&0==W&&(A=100),[W,A]}var s=new Intl.NumberFormat(navigator.language).format,f=Math,c=f.abs,v=f.floor,h=f.round,m=f.ceil,d=f.min,p=f.max,g=f.pow,w=f.log10,x=f.log2,_=f.PI,b=1/0;function y(n,t){return h(n/t)*t}function M(n,t,e){return d(p(n,t),e)}function k(n){return"function"==typeof n?n:function(){return n}}function S(n,t){return t}function T(n,t){return m(n/t)*t}function z(n,t){return v(n/t)*t}function D(n,t){return h(n*(t=Math.pow(10,t)))/t}var E=new Map;function W(n){return((""+n).split(".")[1]||"").length}function Y(n,t,e,r){for(var i=[],o=r.map(W),l=t;e>l;l++)for(var a=c(l),u=D(g(n,l),a),s=0;r.length>s;s++){var f=r[s]*u,v=(0>f||0>l?a:0)+(o[s]>l?o[s]:0),h=D(f,v);i.push(h),E.set(h,v)}return i}var C={},A=Array.isArray;function F(n){return"string"==typeof n}function H(n){return"object"==typeof n&&null!==n}function P(n){var t;if(A(n))t=n.map(P);else if(H(n))for(var e in t={},n)t[e]=P(n[e]);else t=n;return t}function N(n){for(var t=arguments,e=1;t.length>e;e++){var r=t[e];for(var i in r)H(n[i])?N(n[i],P(r[i])):n[i]=P(r[i])}return n}var I="undefined"==typeof queueMicrotask?function(n){return Promise.resolve().then(n)}:queueMicrotask,V="width",L="height",G="top",O="bottom",j="left",B="right",R="#000",U="#0000",J="mousemove",q="mousedown",Z="mouseup",X="mouseenter",K="mouseleave",Q="dblclick",$="resize",nn="scroll",tn="u-off",en="u-label",rn=requestAnimationFrame,on=document,ln=window,an=devicePixelRatio;function un(n,t){null!=t&&n.classList.add(t)}function sn(n,t){n.classList.remove(t)}function fn(n,t,e){n.style[t]=e+"px"}function cn(n,t,e,r){var i=on.createElement(n);return null!=t&&un(i,t),null!=e&&e.insertBefore(i,r),i}function vn(n,t){return cn("div",n,t)}function hn(n,t,e,r,i){n.style.transform="translate("+t+"px,"+e+"px)",0>t||0>e||t>r||e>i?un(n,tn):sn(n,tn)}var mn={passive:!0};function dn(n,t,e){t.addEventListener(n,e,mn)}function pn(n,t,e){t.removeEventListener(n,e,mn)}var gn=["January","February","March","April","May","June","July","August","September","October","November","December"],wn=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function xn(n){return n.slice(0,3)}var _n=wn.map(xn),bn=gn.map(xn),yn={MMMM:gn,MMM:bn,WWWW:wn,WWW:_n};function Mn(n){return(10>n?"0":"")+n}var kn={YYYY:function(n){return n.getFullYear()},YY:function(n){return(n.getFullYear()+"").slice(2)},MMMM:function(n,t){return t.MMMM[n.getMonth()]},MMM:function(n,t){return t.MMM[n.getMonth()]},MM:function(n){return Mn(n.getMonth()+1)},M:function(n){return n.getMonth()+1},DD:function(n){return Mn(n.getDate())},D:function(n){return n.getDate()},WWWW:function(n,t){return t.WWWW[n.getDay()]},WWW:function(n,t){return t.WWW[n.getDay()]},HH:function(n){return Mn(n.getHours())},H:function(n){return n.getHours()},h:function(n){var t=n.getHours();return 0==t?12:t>12?t-12:t},AA:function(n){return 12>n.getHours()?"AM":"PM"},aa:function(n){return 12>n.getHours()?"am":"pm"},a:function(n){return 12>n.getHours()?"a":"p"},mm:function(n){return Mn(n.getMinutes())},m:function(n){return n.getMinutes()},ss:function(n){return Mn(n.getSeconds())},s:function(n){return n.getSeconds()},fff:function(n){return function(n){return(10>n?"00":100>n?"0":"")+n}(n.getMilliseconds())}};function Sn(n,t){t=t||yn;for(var e,r=[],i=/\{([a-z]+)\}|[^{]+/gi;e=i.exec(n);)r.push("{"==e[0][0]?kn[e[1]]:e[0]);return function(n){for(var e="",i=0;r.length>i;i++)e+="string"==typeof r[i]?r[i]:r[i](n,t);return e}}var Tn=(new Intl.DateTimeFormat).resolvedOptions().timeZone,zn=function(n){return n%1==0},Dn=[1,2,2.5,5],En=Y(10,-16,0,Dn),Wn=Y(10,0,16,Dn),Yn=Wn.filter(zn),Cn=En.concat(Wn),An="{YYYY}",Fn="\n"+An,Hn="{M}/{D}",Pn="\n"+Hn,Nn=Pn+"/{YY}",In="{aa}",Vn="{h}:{mm}"+In,Ln="\n"+Vn,Gn=":{ss}",On=null;function jn(n){var t=1e3*n,e=60*t,r=60*e,i=24*r,o=30*i,l=365*i;return[(1==n?Y(10,0,3,Dn).filter(zn):Y(10,-3,0,Dn)).concat([t,5*t,10*t,15*t,30*t,e,5*e,10*e,15*e,30*e,r,2*r,3*r,4*r,6*r,8*r,12*r,i,2*i,3*i,4*i,5*i,6*i,7*i,8*i,9*i,10*i,15*i,o,2*o,3*o,4*o,6*o,l,2*l,5*l,10*l,25*l,50*l,100*l]),[[l,An,On,On,On,On,On,On,1],[28*i,"{MMM}",Fn,On,On,On,On,On,1],[i,Hn,Fn,On,On,On,On,On,1],[r,"{h}"+In,Nn,On,Pn,On,On,On,1],[e,Vn,Nn,On,Pn,On,On,On,1],[t,Gn,Nn+" "+Vn,On,Pn+" "+Vn,On,Ln,On,1],[n,Gn+".{fff}",Nn+" "+Vn,On,Pn+" "+Vn,On,Ln,On,1]],function(t){return function(a,u,s,f,c,h){var m=[],d=c>=l,p=c>=o&&l>c,g=t(s),w=g*n,x=nt(g.getFullYear(),d?0:g.getMonth(),p||d?1:g.getDate()),_=x*n;if(p||d)for(var b=p?c/o:0,y=d?c/l:0,M=w==_?w:nt(x.getFullYear()+y,x.getMonth()+b,1)*n,k=new Date(M/n),S=k.getFullYear(),z=k.getMonth(),E=0;f>=M;E++){var W=nt(S+y*E,z+b*E,1);(M=(+W+(W-t(W*n)))*n)>f||m.push(M)}else{var Y=i>c?c:i,C=_+(v(s)-v(w))+T(w-_,Y);m.push(C);for(var A=t(C),F=A.getHours()+A.getMinutes()/e+A.getSeconds()/r,H=c/r,P=h/a.axes[u]._space;(C=D(C+c,1==n?0:3))<=f;)if(H>1){var N=v(D(F+H,6))%24,I=t(C).getHours()-N;I>1&&(I=-1),F=(F+H)%24,.7>D(((C-=I*r)-m[m.length-1])/c,3)*P||m.push(C)}else m.push(C)}return m}}]}var Bn=jn(1),Rn=Bn[0],Un=Bn[1],Jn=Bn[2],qn=jn(.001),Zn=qn[0],Xn=qn[1],Kn=qn[2];function Qn(n,t){return n.map((function(n){return n.map((function(e,r){return 0==r||8==r||null==e?e:t(1==r||0==n[8]?e:n[1]+e)}))}))}function $n(n,t){return function(e,r,i,o,l){var a,u,s,f,c,v,h=t.find((function(n){return l>=n[0]}))||t[t.length-1];return r.map((function(t){var e=n(t),r=e.getFullYear(),i=e.getMonth(),o=e.getDate(),l=e.getHours(),m=e.getMinutes(),d=e.getSeconds(),p=r!=a&&h[2]||i!=u&&h[3]||o!=s&&h[4]||l!=f&&h[5]||m!=c&&h[6]||d!=v&&h[7]||h[1];return a=r,u=i,s=o,f=l,c=m,v=d,p(e)}))}}function nt(n,t,e){return new Date(n,t,e)}function tt(n,t){return t(n)}function et(n,t){return function(e,r){return t(n(r))}}Y(2,-53,53,[1]);var rt=[0,0];function it(n,t,e){return function(n){0==n.button&&e(n)}}function ot(n,t,e){return e}var lt={show:!0,x:!0,y:!0,lock:!1,move:function(n,t,e){return rt[0]=t,rt[1]=e,rt},points:{show:function(n,t){var e=n.series[t],r=vn();r.style.background=e.stroke||R;var i=Mt(e.width,1),o=(i-1)/-2;return fn(r,V,i),fn(r,L,i),fn(r,"marginLeft",o),fn(r,"marginTop",o),r}},bind:{mousedown:it,mouseup:it,click:it,dblclick:it,mousemove:ot,mouseleave:ot,mouseenter:ot},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,_x:!1,_y:!1},focus:{prox:-1},left:-10,top:-10,idx:null,dataIdx:function(n,t,e){return e}},at={show:!0,stroke:"rgba(0,0,0,0.07)",width:2,filter:S},ut=N({},at,{size:10}),st='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',ft="bold "+st,ct={show:!0,scale:"x",space:50,gap:5,size:50,labelSize:30,labelFont:ft,side:2,grid:at,ticks:ut,font:st,rotate:0},vt={show:!0,scale:"x",auto:!1,sorted:1,min:b,max:-b,idxs:[]};function ht(n,t){return t.map((function(n){return null==n?"":s(n)}))}function mt(n,t,e,r,i,o,l){for(var a=[],u=E.get(i)||0,s=e=l?e:D(T(e,i),u);r>=s;s=D(s+i,u))a.push(Object.is(s,-0)?0:s);return a}function dt(n,t,e,r,i){var o=[],l=n.scales[n.axes[t].scale].log,a=v((10==l?w:x)(e));i=g(l,a),0>a&&(i=D(i,-a));var u=e;do{o.push(u),i*l>(u=D(u+i,E.get(i)))||(i=u)}while(r>=u);return o}var pt=/./,gt=/[12357]/,wt=/[125]/,xt=/1/;function _t(n,t,e){var r=n.axes[e],i=r.scale;if(2==n.scales[i].log)return t;var o=n.valToPos,l=r._space,a=o(10,i),u=o(9,i)-a=r[1]-r[0]}},values:null,min:b,max:-b,idxs:[],path:null,clip:null},Tt={time:!0,auto:!0,distr:1,log:10,min:null,max:null},zt=N({},Tt,{time:!1}),Dt={};function Et(){var n=[];return{sub:function(t){n.push(t)},unsub:function(t){n=n.filter((function(n){return n!=t}))},pub:function(t,e,r,i,o,l,a){n.length>1&&n.forEach((function(n){n!=e&&n.pub(t,e,r,i,o,l,a)}))}}}function Wt(n,t,e,r){return(r?[n[0],n[1]].concat(n.slice(2)):[n[0]].concat(n.slice(1))).map((function(n,r){return Yt(n,r,t,e)}))}function Yt(n,t,e,r){return N({},0==t||n&&n.side%2==0?e:r,n)}function Ct(n,t){return 3==t.distr?w(n/t.min)/w(t.max/t.min):(n-t.min)/(t.max-t.min)}function At(n,t,e,r){return r+(1-Ct(n,t))*e}function Ft(n,t,e,r){return r+Ct(n,t)*e}var Ht=[null,null];function Pt(n,t,e){return null==t?Ht:[t,e]}var Nt=Pt;function It(n,t,e){return null==t?Ht:l(t,e,.1,!0)}function Vt(n,t,e,i){return null==t?Ht:r(t,e,n.scales[i].log,!1)}var Lt=Vt;function Gt(n){var t;return[n=n.replace(/(\d+)px/,(function(n,e){return(t=h(e*an))+"px"})),t]}function Ot(t,e,i){var o={},a=!1;o.status=0;var u=o.root=vn("uplot");null!=t.id&&(u.id=t.id),un(u,t.class),t.title&&(vn("u-title",u).textContent=t.title);var s=cn("canvas"),f=o.ctx=s.getContext("2d"),x=vn("u-wrap",u),T=vn("u-under",x);x.appendChild(s);var z=vn("u-over",x);((t=P(t)).plugins||[]).forEach((function(n){n.opts&&(t=n.opts(o,t)||t)}));var W=t.ms||.001,Y=o.series=Wt(t.series||[],vt,St,!1),mn=o.axes=Wt(t.axes||[],ct,yt,!0),gn=o.scales={},wn=Y[0].scale;function xn(n){var e=gn[n];if(null==e){var r=(t.scales||C)[n]||C;if(null!=r.from)xn(r.from),gn[n]=N({},gn[r.from],r);else{var i=(e=gn[n]=N({},n==wn?Tt:zt,r)).time,o=3==e.distr,a=e.range;if(n!=wn&&!A(a)&&H(a)){var u=a;a=function(n,t,e){return null==t?Ht:l(t,e,u)}}e.range=k(a||(i?Nt:n==wn?o?Lt:Pt:o?Vt:It)),e.auto=k(e.auto)}}}for(var _n in xn("x"),xn("y"),Y.forEach((function(n){xn(n.scale)})),t.scales)xn(_n);var bn=gn[wn].distr,yn={};for(var Mn in gn){var kn=gn[Mn];null==kn.min&&null==kn.max||(yn[Mn]={min:kn.min,max:kn.max})}var Tn=o.gutters=N({x:h(yt.size/2),y:h(ct.size/3),_x:null,_y:null},t.gutters);Tn.x=k(Tn.x),Tn.y=k(Tn.y),Tn._x=Tn.x(o),Tn._y=Tn.y(o);var zn,Dn,En=t.tzDate||function(n){return new Date(n/W)},Wn=t.fmtDate||Sn,An=1==W?Jn(En):Kn(En),Fn=$n(En,Qn(1==W?Un:Xn,Wn)),Hn=et(En,tt("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",Wn)),Pn=N({show:!0,live:!0},t.legend),Nn=Pn.show,In=[],Vn=!1;if(Nn){zn=cn("table","u-legend",u);var Ln=Y[1]?Y[1].values:null;if(Vn=null!=Ln){var Gn=cn("tr","u-thead",zn);for(var On in cn("th",null,Gn),Dn=Ln(o,1,0))cn("th",en,Gn).textContent=On}else Dn={_:0},un(zn,"u-inline"),Pn.live&&un(zn,"u-live")}var jn=new Map;function Bn(n,t,e){var r=jn.get(t)||{},i=Rt.bind[n](o,t,e);i&&(dn(n,t,r[n]=i),jn.set(t,r))}var qn=0,nt=0,rt=0,it=0,ot=0,at=0,ut=0,st=0,ft=0,pt=0;o.bbox={};var gt=!1,wt=!1,xt=!1,Ct=!1,Ot=!1;function jt(n,t){n==o.width&&t==o.height||Bt(n,t),ve(!1),xt=!0,wt=!0,Ct=!0,Ot=!0,ke()}function Bt(n,t){o.width=qn=rt=n,o.height=nt=it=t,ot=at=0,function(){var n=!1,t=!1,e=!1,r=!1;mn.forEach((function(i){if(i.show&&i._show){var o=i.side,l=o%2,a=i._size+(i.labelSize=null!=i.label?i.labelSize||30:0);a>0&&(l?(rt-=a,3==o?(ot+=a,r=!0):e=!0):(it-=a,0==o?(at+=a,n=!0):t=!0))}})),(n||t)&&(e||(rt-=Tn._x),r||(rt-=Tn._x,ot+=Tn._x)),(r||e)&&(t||(it-=Tn._y),n||(it-=Tn._y,at+=Tn._y))}(),function(){var n=ot+rt,t=at+it,e=ot,r=at;function i(i,o){switch(i){case 1:return(n+=o)-o;case 2:return(t+=o)-o;case 3:return(e-=o)+o;case 0:return(r-=o)+o}}mn.forEach((function(n){if(n.show&&n._show){var t=n.side;n._pos=i(t,n._size),null!=n.label&&(n._lpos=i(t,n.labelSize))}}))}();var e=o.bbox;ut=e.left=y(ot*an,.5),st=e.top=y(at*an,.5),ft=e.width=y(rt*an,.5),pt=e.height=y(it*an,.5)}o.setSize=function(n){jt(n.width,n.height)};var Rt=o.cursor=N({},lt,t.cursor);Rt._lock=!1,Rt.points.show=k(Rt.points.show);var Ut,Jt=o.focus=N({},t.focus||{alpha:.3},Rt.focus),qt=Jt.prox>=0,Zt=[null];function Xt(n,t){var e=gn[n.scale].time,r=n.value;if(n.value=e?F(r)?et(En,tt(r,Wn)):r||Hn:r||bt,n.label=n.label||(e?"Time":"Value"),t>0){n.width=null==n.width?1:n.width,n.paths=n.paths||ue,n.fillTo=n.fillTo||kt;var i=Mt(n.width,1);n.points=N({},{size:i,width:p(1,.2*i),stroke:n.stroke,space:2*i},n.points),n.points.show=k(n.points.show),n._paths=null}if(Nn&&In.splice(t,0,function(n,t){if(0==t&&(Vn||!Pn.live))return null;var e=[],r=cn("tr","u-series",zn,zn.childNodes[t]);un(r,n.class),n.show||un(r,tn);var i=cn("th",null,r),o=vn("u-marker",i);o.style.borderColor=n.width?n.stroke:t>0&&n.points.width?n.points.stroke:null,o.style.backgroundColor=n.fill||null;var l=vn(en,i);for(var a in l.textContent=n.label,t>0&&(Bn("click",i,(function(){Rt._lock||Ve(Y.indexOf(n),{show:!n.show},rr.setSeries)})),qt&&Bn(X,i,(function(){Rt._lock||Ve(Y.indexOf(n),{focus:!0},rr.setSeries)}))),Dn){var u=cn("td","u-value",r);u.textContent="--",e.push(u)}return e}(n,t)),Rt.show){var l=function(n,t){if(t>0){var e=Rt.points.show(o,t);if(e)return un(e,"u-cursor-pt"),un(e,n.class),hn(e,-10,-10,rt,it),z.insertBefore(e,Zt[t]),e}}(n,t);l&&Zt.splice(t,0,l)}}o.addSeries=function(n,t){n=Yt(n,t=null==t?Y.length:t,vt,St),Y.splice(t,0,n),Xt(Y[t],t)},o.delSeries=function(n){Y.splice(n,1),Nn&&In.splice(n,1)[0][0].parentNode.remove(),Zt.length>1&&Zt.splice(n,1)[0].remove()},Y.forEach(Xt),mn.forEach((function(n,t){if(n._show=n.show,n.show){var e=gn[n.scale];null==e&&(n.scale=n.side%2?Y[1].scale:wn,e=gn[n.scale]);var r=e.time;n.size=k(n.size),n.space=k(n.space),n.rotate=k(n.rotate),n.incrs=k(n.incrs||(2==e.distr?Yn:r?1==W?Rn:Zn:Cn)),n.splits=k(n.splits||(r&&1==e.distr?An:3==e.distr?dt:mt));var i=n.values;n.values=r?A(i)?$n(En,Qn(i,Wn)):F(i)?function(n,t){var e=Sn(t);return function(t,r){return r.map((function(t){return e(n(t))}))}}(En,i):i||Fn:i||ht,n.filter=k(n.filter||(3==e.distr?_t:S)),n.font=Gt(n.font),n.labelFont=Gt(n.labelFont),n._size=n.size(o,null,t,0),n._space=n._rotate=n._incrs=n._found=n._splits=n._values=null}}));var Kt=null,Qt=null,$t=Y[0].idxs,ne=null,te=!1;function ee(n,t){if(!A(n)&&H(n)&&(n.isGap&&Y.forEach((function(t){t.isGap=n.isGap})),n=n.data),(n=n||[])[0]=n[0]||[],o.data=n,e=n.slice(),Ut=(ne=e[0]).length,2==bn&&(e[0]=ne.map((function(n,t){return t}))),ve(!0),er("setData"),!1!==t){var r=gn[wn];r.auto(o,te)?re():Ie(wn,r.min,r.max),Ct=!0,Ot=!0,ke()}}function re(){var n,t,i,o;te=!0,Ut>0?(Kt=$t[0]=0,Qt=$t[1]=Ut-1,i=e[0][Kt],o=e[0][Qt],2==bn?(i=Kt,o=Qt):1==Ut&&(3==bn?(i=(n=r(i,i,gn[wn].log,!1))[0],o=n[1]):gn[wn].time?o=i+86400/W:(i=(t=l(i,o,.1,!0))[0],o=t[1]))):(Kt=$t[0]=i=null,Qt=$t[1]=o=null),Ie(wn,i,o),te=!1}function ie(n,t,e,r){f.strokeStyle=n||U,f.lineWidth=t,f.lineJoin="round",f.setLineDash(e||[]),f.fillStyle=r||U}o.setData=ee;var oe=1;function le(n,t,e){if(e>t){var r=n[n.length-1];r&&r[0]==t?r[1]=e:n.push([t,e])}}function ae(n,t,e,r){for(var i=1==r?t:e;i>=t&&e>=i;i+=r)if(null!=n[i])return i;return-1}function ue(n,t,r,i){var o,l,a,u,s,f=Y[t],c=f.isGap,v=e[0],m=e[t],g=gn[wn],w=gn[f.scale],x=1==oe?{stroke:new Path2D,fill:null,clip:null}:Y[t-1]._paths,_=x.stroke,M=D(f.width*an,3),k=b,S=-b,T=[],z=h(Ft(v[1==oe?r:i],g,ft,ut)),E=!1,W=ae(m,r,i,1),C=ae(m,r,i,-1),A=y(Ft(v[W],g,ft,ut),.5),F=y(Ft(v[C],g,ft,ut),.5);A>ut&&le(T,ut,A),f.band&&1==oe&&_.lineTo(A-2*M,h(At(m[r],w,pt,st)));for(var H=1==oe?r:i;H>=r&&i>=H;H+=oe){var P=h(Ft(v[H],g,ft,ut));if(P==z)null!=m[H]?(o=h(At(m[H],w,pt,st)),k=d(o,k),S=p(o,S)):!E&&c(n,t,H)&&(E=!0);else{var N=!1;k!=b?(_.lineTo(z,k),_.lineTo(z,S),_.lineTo(z,o),l=z):E&&(N=!0,E=!1),null!=m[H]?(o=h(At(m[H],w,pt,st)),_.lineTo(P,o),k=S=o,P-z>1&&null==m[H-1]&&c(n,t,H-1)&&(N=!0)):(k=b,S=-b,!E&&c(n,t,H)&&(E=!0)),N&&le(T,l,P),z=P}}if(ut+ft>F&&le(T,F,ut+ft),f.band&&(1==oe?(a=F+2*M,u=C,s=e[t+1]):(a=A-2*M,u=W,s=e[t-1]),_.lineTo(a,h(At(m[u],w,pt,st))),_.lineTo(a,h(At(s[u],w,pt,st)))),1==oe&&(x.clip=function(n,t){var e=null;if(t.length>0&&!Y[n].spanGaps){e=new Path2D;for(var r=ut,i=0;t.length>i;i++){var o=t[i];e.rect(r,st,o[0]-r,st+pt),r=o[1]}e.rect(r,st,ut+ft-r,st+pt)}return e}(t,T),null!=f.fill)){var I=x.fill=new Path2D(_),V=h(At(f.fillTo(n,t,f.min,f.max),w,pt,st));I.lineTo(F,V),I.lineTo(A,V)}return f.band&&(oe*=-1),x}function se(n,t,e,r,i,o,l,a,u){var s=l%2/2;f.translate(s,s),ie(a,l,u),f.beginPath();var c,v,h,m,d=i+(0==r||3==r?-o:o);0==e?(v=i,m=d):(c=i,h=d),n.forEach((function(n,r){null!=t[r]&&(0==e?c=h=n:v=m=n,f.moveTo(c,v),f.lineTo(h,m))})),f.stroke(),f.translate(-s,-s)}function fe(n){var t=!0;return mn.forEach((function(e,r){if(e.show){var i=gn[e.scale];if(null!=i.min){e._show||(t=!1,e._show=!0,ve(!1));var l=e.side,a=i.min,u=i.max,s=function(n,t,e,r){var i,l=mn[n];if(r>0){var a=l._space=l.space(o,n,t,e,r),u=l._incrs=l.incrs(o,n,t,e,r,a);i=l._found=function(n,t,e,r,i){for(var o=r/(t-n),l=(""+v(n)).length,a=0;e.length>a;a++){var u=e[a]*o,s=10>e[a]?E.get(e[a]):0;if(u>=i&&17>l+s)return[e[a],u]}return[0,0]}(t,e,u,r,a)}else i=[0,0];return i}(r,a,u,0==l%2?rt:it),f=s[0],c=s[1];if(0!=c){var h=e._splits=e.splits(o,r,a,u,f,c,2==i.distr),d=2==i.distr?h.map((function(n){return ne[n]})):h,p=2==i.distr?ne[h[1]]-ne[h[0]]:f,g=e._values=e.values(o,e.filter(o,d,r,c,p),r,c,p);e._rotate=2==l?e.rotate(o,g,r,c):0;var w=e._size;e._size=m(e.size(o,g,r,n)),null!=w&&e._size!=w&&(t=!1)}}else e._show&&(t=!1,e._show=!1,ve(!1))}})),t}function ce(n){var t=!0,e=Tn._x,r=Tn._y;return Tn._x=m(Tn.x(o,n)),Tn._y=m(Tn.y(o,n)),Tn._x==e&&Tn._y==r||(t=!1),t}function ve(n){Y.forEach((function(t,e){e>0&&(t._paths=null,n&&(t.min=null,t.max=null))}))}o.paths=ue;var he,me,de,pe,ge,we,xe,_e,be,ye,Me=!1;function ke(){Me||(I(Se),Me=!0)}function Se(){gt&&(function(){var t=P(gn);for(var r in t){var i=t[r],l=yn[r];if(null!=l&&null!=l.min)N(i,l),r==wn&&ve(!0);else if(r!=wn)if(0==Ut&&null==i.from){var a=i.range(o,null,null,r);i.min=a[0],i.max=a[1]}else i.min=b,i.max=-b}if(Ut>0)for(var u in Y.forEach((function(r,i){var l=r.scale,a=t[l],u=yn[l];if(0==i){var s=a.range(o,a.min,a.max,l);a.min=s[0],a.max=s[1],Kt=n(a.min,e[0]),Qt=n(a.max,e[0]),a.min>e[0][Kt]&&Kt++,e[0][Qt]>a.max&&Qt--,r.min=ne[Kt],r.max=ne[Qt]}else if(r.show&&r.auto&&a.auto(o,te)&&(null==u||null==u.min)){var f=null==r.min?function(n,t,e,r){var i=b,o=-b;if(1==r)i=n[t],o=n[e];else if(-1==r)i=n[e],o=n[t];else for(var l=t;e>=l;l++)null!=n[l]&&(i=d(i,n[l]),o=p(o,n[l]));return[i,o]}(e[i],Kt,Qt,r.sorted):[r.min,r.max];a.min=d(a.min,r.min=f[0]),a.max=p(a.max,r.max=f[1])}r.idxs[0]=Kt,r.idxs[1]=Qt})),t){var s=t[u],f=yn[u];if(null==s.from&&(null==f||null==f.min)){var c=s.range(o,s.min==b?null:s.min,s.max==-b?null:s.max,u);s.min=c[0],s.max=c[1]}}for(var v in t){var h=t[v];if(null!=h.from){var m=t[h.from],g=h.range(o,m.min,m.max,v);h.min=g[0],h.max=g[1]}}var w={},x=!1;for(var _ in t){var y=t[_],M=gn[_];M.min==y.min&&M.max==y.max||(M.min=y.min,M.max=y.max,w[_]=x=!0)}if(x){for(var k in Y.forEach((function(n){w[n.scale]&&(n._paths=null)})),w)xt=!0,er("setScale",k);Rt.show&&(Ct=!0)}for(var S in yn)yn[S]=null}(),gt=!1),xt&&(function(){for(var n=!1,t=0;!n;){var e=fe(++t),r=ce(t);(n=e&&r)||(Bt(o.width,o.height),wt=!0)}}(),xt=!1),wt&&(fn(T,j,ot),fn(T,G,at),fn(T,V,rt),fn(T,L,it),fn(z,j,ot),fn(z,G,at),fn(z,V,rt),fn(z,L,it),fn(x,V,qn),fn(x,L,nt),s.width=h(qn*an),s.height=h(nt*an),Re(),er("setSize"),wt=!1),Rt.show&&Ct&&(je(),Ct=!1),qn>0&&nt>0&&(f.clearRect(0,0,s.width,s.height),er("drawClear"),function(){mn.forEach((function(n,t){if(n.show&&n._show){var e=gn[n.scale],r=n.side,i=r%2,l=0==i?Ft:At,a=0==i?ft:pt,u=0==i?ut:st,s=h(n.gap*an),c=n.ticks,v=c.show?h(c.size*an):0,m=n._found,d=m[0],p=m[1],g=n._splits,w=2==e.distr?g.map((function(n){return ne[n]})):g,x=2==e.distr?ne[g[1]]-ne[g[0]]:d,b=n._rotate*-_/180,y=h(n._pos*an),M=y+(v+s)*(0==i&&0==r||1==i&&3==r?-1:1),k=0==i?M:0,S=1==i?M:0;f.font=n.font[0],f.fillStyle=n.stroke||R,f.textAlign=1==n.align?j:2==n.align?B:b>0?j:0>b?B:0==i?"center":3==r?B:j,f.textBaseline=b||1==i?"middle":2==r?G:O;var T=1.5*n.font[1],z=g.map((function(n){return h(l(n,e,a,u))}));if(n._values.forEach((function(n,t){null!=n&&(0==i?S=z[t]:k=z[t],(""+n).split(/\n/gm).forEach((function(n,t){b?(f.save(),f.translate(S,k+t*T),f.rotate(b),f.fillText(n,0,0),f.restore()):f.fillText(n,S,k+t*T)})))})),n.label){f.save();var E=h(n._lpos*an);1==i?(S=k=0,f.translate(E,h(st+pt/2)),f.rotate((3==r?-_:_)/2)):(S=h(ut+ft/2),k=E),f.font=n.labelFont[0],f.textAlign="center",f.textBaseline=2==r?G:O,f.fillText(n.label,S,k),f.restore()}c.show&&se(z,c.filter(o,w,t,p,x),i,r,y,v,D(c.width*an,3),c.stroke);var W=n.grid;W.show&&se(z,W.filter(o,w,t,p,x),i,0==i?2:1,0==i?st:ut,0==i?pt:ft,D(W.width*an,3),W.stroke,W.dash)}})),er("drawAxes")}(),Ut>0&&function(){Y.forEach((function(n,t){if(t>0&&n.show&&null==n._paths){var r=function(n){for(var t=M(Kt-1,0,Ut-1),e=M(Qt+1,0,Ut-1);null==n[t]&&t>0;)t--;for(;null==n[e]&&Ut-1>e;)e++;return[t,e]}(e[t]);n._paths=n.paths(o,t,r[0],r[1])}})),Y.forEach((function(n,t){t>0&&n.show&&(n._paths&&function(n){var t=Y[n];if(1==oe){var e=t._paths,r=e.stroke,i=e.fill,o=e.clip,l=D(t.width*an,3),a=l%2/2;ie(t.stroke,l,t.dash,t.fill),f.globalAlpha=t.alpha,f.translate(a,a),f.save();var u=ut,s=st,c=ft,v=pt,h=l*an/2;0==t.min&&(v+=h),0==t.max&&(s-=h,v+=h),f.beginPath(),f.rect(u,s,c,v),f.clip(),null!=o&&f.clip(o),t.band?(f.fill(r),l&&f.stroke(r)):(null!=t.fill&&f.fill(i),l&&f.stroke(r)),f.restore(),f.translate(-a,-a),f.globalAlpha=1}t.band&&(oe*=-1)}(t),n.points.show(o,t,Kt,Qt)&&function(n){var t=Y[n],r=t.points,i=D(r.width*an,3),o=i%2/2,l=r.width>0,a=(r.size-r.width)/2*an,u=D(2*a,3);f.translate(o,o),f.save(),f.beginPath(),f.rect(ut-u,st-u,ft+2*u,pt+2*u),f.clip(),f.globalAlpha=t.alpha;for(var s=new Path2D,c=Kt;Qt>=c;c++)if(null!=e[n][c]){var v=h(Ft(e[0][c],gn[wn],ft,ut)),m=h(At(e[n][c],gn[t.scale],pt,st));s.moveTo(v+a,m),s.arc(v,m,a,0,2*_)}ie(r.stroke,i,null,r.fill||(l?"#fff":t.stroke)),f.fill(s),l&&f.stroke(s),f.globalAlpha=1,f.restore(),f.translate(-o,-o)}(t),er("drawSeries",t))}))}(),er("draw")),a||(a=!0,o.status=1,er("ready")),Me=!1}function Te(t,r){var i=gn[t];if(null==i.from){if(0==Ut){var l=i.range(o,r.min,r.max,t);r.min=l[0],r.max=l[1]}if(Ut>1&&null!=r.min&&null!=r.max&&1e-16>r.max-r.min)return;t==wn&&2==i.distr&&Ut>0&&(r.min=n(r.min,e[0]),r.max=n(r.max,e[0])),yn[t]=r,gt=!0,ke()}}o.redraw=function(n){!1!==n?Ie(wn,gn[wn].min,gn[wn].max):ke()},o.setScale=Te;var ze=!1,De=Rt.drag,Ee=De.x,We=De.y;Rt.show&&(Rt.x&&(be=Rt.left,he=vn("u-cursor-x",z)),Rt.y&&(ye=Rt.top,me=vn("u-cursor-y",z)));var Ye,Ce,Ae,Fe=o.select=N({show:!0,over:!0,left:0,width:0,top:0,height:0},t.select),He=Fe.show?vn("u-select",Fe.over?z:T):null;function Pe(n,t){if(Fe.show){for(var e in n)fn(He,e,Fe[e]=n[e]);!1!==t&&er("setSelect")}}function Ne(n){var t=Nn?In[n][0].parentNode:null;Y[n].show?t&&sn(t,tn):(t&&un(t,tn),Zt.length>1&&hn(Zt[n],-10,-10,rt,it))}function Ie(n,t,e){Te(n,{min:t,max:e})}function Ve(n,t,e){var r=Y[n];if(null!=t.focus&&function(n){n!=Ae&&(Y.forEach((function(t,e){!function(n,t){var e=Y[n];Le(n,t),e.band&&Le(Y[n+1].band?n+1:n-1,t)}(e,null==n||0==e||e==n?1:Jt.alpha)})),Ae=n,ke())}(n),null!=t.show){if(r.show=t.show,Ne(n),r.band){var i=Y[n+1]&&Y[n+1].band?n+1:n-1;Y[i].show=r.show,Ne(i)}Ie(r.scale,null,null),ke()}er("setSeries",n,t),e&&or.pub("setSeries",o,n,t)}function Le(n,t){Y[n].alpha=t,Rt.show&&Zt[n]&&(Zt[n].style.opacity=t),Nn&&In[n]&&(In[n][0].parentNode.style.opacity=t)}function Ge(n,t){var e=rt;t!=wn&&(n=(e=it)-n);var r=n/e,i=gn[t],o=i.min,l=i.max;return 3==i.distr?(o=w(o),l=w(l),g(10,o+(l-o)*r)):o+(l-o)*r}o.setSelect=Pe,o.setSeries=Ve,Nn&&qt&&dn(K,zn,(function(){Rt._lock||(Ve(null,{focus:!1},rr.setSeries),je())})),o.valToIdx=function(t){return n(t,e[0])},o.posToIdx=function(t){return n(Ge(t,wn),e[0],Kt,Qt)},o.posToVal=Ge,o.valToPos=function(n,t,e){return t==wn?Ft(n,gn[t],e?ft:rt,e?ut:0):At(n,gn[t],e?pt:it,e?st:0)},o.batch=function(n){n(o),ke()},o.setCursor=function(n){be=n.left,ye=n.top,je()};var Oe=0;function je(t,r){var i,l;if(Oe=0,xe=be,_e=ye,i=Rt.move(o,be,ye),be=i[0],ye=i[1],Rt.show&&(Rt.x&&hn(he,h(be),0,rt,it),Rt.y&&hn(me,0,h(ye),rt,it)),Ye=b,0>be||0==Ut||Kt>Qt){l=null;for(var u=0;Y.length>u;u++)if(u>0&&Zt.length>1&&hn(Zt[u],-10,-10,rt,it),Nn&&Pn.live){if(0==u&&Vn)continue;for(var s=0;In[u].length>s;s++)In[u][s].firstChild.nodeValue="--"}qt&&Ve(null,{focus:!0},rr.setSeries)}else{var f=Ge(be,wn);l=n(f,e[0],Kt,Qt);for(var v=gn[wn],m=D(Ft(e[0][l],v,rt,0),3),p=0;Y.length>p;p++){var g=Y[p],w=Rt.dataIdx(o,p,l,f),x=w==l?m:D(Ft(e[0][w],v,rt,0),3);if(p>0&&g.show){var _=e[p][w],y=null==_?-10:D(At(_,gn[g.scale],it,0),3);if(y>0){var M=c(y-ye);M>Ye||(Ye=M,Ce=p)}Zt.length>1&&hn(Zt[p],x,y,rt,it)}if(Nn&&Pn.live){if(w==Rt.idx&&!Ot||0==p&&Vn)continue;var k=0==p&&2==bn?ne:e[p],S=Vn?g.values(o,p,w):{_:g.value(o,k[w],p,w)},T=0;for(var z in S)In[p][T++].firstChild.nodeValue=S[z]}}Ot=!1}if(Fe.show&&ze)if(null!=r){var E=rr.scales,W=E[0],C=E[1],A=r.cursor.drag;if(Ee=A._x,We=A._y,W){var F=gn[W],H=r.posToVal(r.select.left,W),P=r.posToVal(r.select.left+r.select.width,W);Fe.left=Ft(H,F,rt,0),Fe.width=c(Fe.left-Ft(P,F,rt,0)),fn(He,j,Fe.left),fn(He,V,Fe.width),C||(fn(He,G,Fe.top=0),fn(He,L,Fe.height=it))}if(C){var N=gn[C],I=r.posToVal(r.select.top,C),O=r.posToVal(r.select.top+r.select.height,C);Fe.top=At(I,N,it,0),Fe.height=c(Fe.top-At(O,N,it,0)),fn(He,G,Fe.top),fn(He,L,Fe.height),W||(fn(He,j,Fe.left=0),fn(He,V,Fe.width=rt))}}else{var B=c(xe-de),R=c(_e-pe);Ee=De.x&&B>=De.dist,We=De.y&&R>=De.dist;var U=De.uni;if(null!=U?Ee&&We&&(We=R>=U,(Ee=B>=U)||We||(R>B?We=!0:Ee=!0)):De.x&&De.y&&(Ee||We)&&(Ee=We=!0),Ee){var q=d(ge,be),Z=c(be-ge);fn(He,j,Fe.left=q),fn(He,V,Fe.width=Z),We||(fn(He,G,Fe.top=0),fn(He,L,Fe.height=it))}if(We){var X=d(we,ye),K=c(ye-we);fn(He,G,Fe.top=X),fn(He,L,Fe.height=K),Ee||(fn(He,j,Fe.left=0),fn(He,V,Fe.width=rt))}Ee||We||(fn(He,L,Fe.height=0),fn(He,V,Fe.width=0))}Rt.idx=l,Rt.left=be,Rt.top=ye,De._x=Ee,De._y=We,null!=t&&(or.pub(J,o,be,ye,rt,it,l),qt&&Ve(Ye>Jt.prox?null:Ce,{focus:!0},rr.setSeries)),a&&er("setCursor")}var Be=null;function Re(){Be=z.getBoundingClientRect()}function Ue(n,t,e,r,i,o){Rt._lock||(Je(n,t,e,r,i,o,0,!1,null!=n),null!=n?0==Oe&&(Oe=rn(je)):je(null,t))}function Je(n,t,e,r,i,l,a,u,s){var f;if(null!=n)e=n.clientX-Be.left,r=n.clientY-Be.top;else{if(0>e||0>r)return be=-10,void(ye=-10);var c=rr.scales,v=c[0],h=c[1];e=null!=v?Ft(t.posToVal(e,v),gn[v],rt,0):rt*(e/i),r=null!=h?At(t.posToVal(r,h),gn[h],it,0):it*(r/l)}s&&(e>1&&rt-1>e||(e=y(e,rt)),r>1&&it-1>r||(r=y(r,it))),u?(de=e,pe=r,f=Rt.move(o,e,r),ge=f[0],we=f[1]):(be=e,ye=r)}function qe(){Pe({width:0,height:0},!1)}function Ze(n,t,e,r,i,l){ze=!0,Ee=We=De._x=De._y=!1,Je(n,t,e,r,i,l,0,!0,!1),null!=n&&(Bn(Z,on,Xe),or.pub(q,o,ge,we,rt,it,null))}function Xe(n,t,e,r,i,l){ze=De._x=De._y=!1,Je(n,t,e,r,i,l,0,!1,!0);var a=Fe.width>0||Fe.height>0;if(a&&Pe(Fe),De.setScale&&a){if(Ee&&Ie(wn,Ge(Fe.left,wn),Ge(Fe.left+Fe.width,wn)),We)for(var u in gn){var s=gn[u];u!=wn&&null==s.from&&s.min!=b&&Ie(u,Ge(Fe.top+Fe.height,u),Ge(Fe.top,u))}qe()}else Rt.lock&&(Rt._lock=!Rt._lock,Rt._lock||je());null!=n&&(function(n,t){var e=jn.get(t)||{};pn(n,t,e[n]),e[n]=null}(Z,on),or.pub(Z,o,be,ye,rt,it,null))}function Ke(){if(!Rt._lock){var n=ze;if(ze){var t=!0,e=!0;if(Ee&&We&&(t=10>=be||be>=rt-10,e=10>=ye||ye>=it-10),Ee&&t){var r=be,i=rt-be,o=d(r,i);o==r&&(be=0),o==i&&(be=rt)}if(We&&e){var l=ye,a=it-ye,u=d(l,a);u==l&&(ye=0),u==a&&(ye=it)}je(1),ze=!1}be=-10,ye=-10,je(1),n&&(ze=n)}}function Qe(n){re(),qe(),null!=n&&or.pub(Q,o,be,ye,rt,it,null)}var $e,nr={};nr.mousedown=Ze,nr.mousemove=Ue,nr.mouseup=Xe,nr.dblclick=Qe,nr.setSeries=function(n,t,e,r){Ve(e,r)},Rt.show&&(Bn(q,z,Ze),Bn(J,z,Ue),Bn(X,z,Re),Bn(K,z,(function(){rn(Ke)})),Bn(Q,z,Qe),$e=function(n){var t=null;function e(){t=null,n()}return function(){clearTimeout(t),t=setTimeout(e,100)}}(Re),dn($,ln,$e),dn(nn,ln,$e),o.syncRect=Re);var tr=o.hooks=t.hooks||{};function er(n,t,e){n in tr&&tr[n].forEach((function(n){n.call(null,o,t,e)}))}(t.plugins||[]).forEach((function(n){for(var t in n.hooks)tr[t]=(tr[t]||[]).concat(n.hooks[t])}));var rr=N({key:null,setSeries:!1,scales:[wn,null]},Rt.sync),ir=rr.key,or=null!=ir?Dt[ir]=Dt[ir]||Et():Et();function lr(){er("init",t,e),ee(e||t.data,!1),yn[wn]?Te(wn,yn[wn]):re(),jt(t.width,t.height),Pe(Fe,!1)}return or.sub(o),o.pub=function(n,t,e,r,i,o,l){nr[n](null,t,e,r,i,o,l)},o.destroy=function(){or.unsub(o),pn($,ln,$e),pn(nn,ln,$e),u.remove(),er("destroy")},i?i instanceof HTMLElement?(i.appendChild(u),lr()):i(o,lr):lr(),o}return Ot.assign=N,Ot.fmtNum=s,Ot.rangeNum=l,Ot.rangeLog=r,Ot.fmtDate=Sn,Ot.tzDate=function(n,t){var e;return"Etc/UTC"==t?e=new Date(+n+6e4*n.getTimezoneOffset()):t==Tn?e=n:(e=new Date(n.toLocaleString("en-US",{timeZone:t}))).setMilliseconds(n.getMilliseconds()),e},Ot}(); +var uPlot=function(){"use strict";function n(n,t,e,r){var i;e=e||0;for(var o=2147483647>=(r=r||t.length-1);r-e>1;)n>t[i=o?e+r>>1:v((e+r)/2)]?e=i:r=i;return n-t[e]>t[r]-n?r:e}var t=[0,0];function e(n,e,r,i){return t[0]=0>r?D(n,-r):n,t[1]=0>i?D(e,-i):e,t}function r(n,t,r,i){var o,l,a,u=10==r?w:x;return n==t&&(n/=r,t*=r),i?(o=v(u(n)),l=m(u(t)),n=(a=e(g(r,o),g(r,l),o,l))[0],t=a[1]):(o=v(u(n)),l=v(u(t)),n=z(n,(a=e(g(r,o),g(r,l),o,l))[0]),t=T(t,a[1])),[n,t]}var i={pad:0,soft:null,mode:0},o={min:i,max:i};function l(n,t,e,r){return H(e)?u(n,t,e):(i.pad=e,i.soft=r?0:null,i.mode=r?2:0,u(n,t,o))}function a(n,t){return null==n?t:n}function u(n,t,e){var r=e.min,i=e.max,o=a(r.pad,0),l=a(i.pad,0),u=a(r.hard,-b),s=a(i.hard,b),f=a(r.soft,b),h=a(i.soft,-b),m=a(r.mode,0),x=a(i.mode,0),_=t-n,y=_||c(t)||1e3,M=w(y),k=g(10,v(M)),S=D(z(n-y*(0==_?0==n?.1:1:o),k/100),6),E=n>=f&&(1==m||2==m&&f>S)?f:b,W=p(u,E>S&&n>=E?E:d(E,S)),Y=D(T(t+y*(0==_?0==t?.1:1:l),k/100),6),C=h>=t&&(1==x||2==x&&Y>h)?h:-b,A=d(s,Y>C&&C>=t?C:p(C,Y));return W==A&&0==W&&(A=100),[W,A]}var s=new Intl.NumberFormat(navigator.language).format,f=Math,c=f.abs,v=f.floor,h=f.round,m=f.ceil,d=f.min,p=f.max,g=f.pow,w=f.log10,x=f.log2,_=f.PI,b=1/0;function y(n,t){return h(n/t)*t}function M(n,t,e){return d(p(n,t),e)}function k(n){return"function"==typeof n?n:function(){return n}}function S(n,t){return t}function T(n,t){return m(n/t)*t}function z(n,t){return v(n/t)*t}function D(n,t){return h(n*(t=Math.pow(10,t)))/t}var E=new Map;function W(n){return((""+n).split(".")[1]||"").length}function Y(n,t,e,r){for(var i=[],o=r.map(W),l=t;e>l;l++)for(var a=c(l),u=D(g(n,l),a),s=0;r.length>s;s++){var f=r[s]*u,v=(0>f||0>l?a:0)+(o[s]>l?o[s]:0),h=D(f,v);i.push(h),E.set(h,v)}return i}var C={},A=Array.isArray;function F(n){return"string"==typeof n}function H(n){return"object"==typeof n&&null!==n}function P(n){var t;if(A(n))t=n.map(P);else if(H(n))for(var e in t={},n)t[e]=P(n[e]);else t=n;return t}function N(n){for(var t=arguments,e=1;t.length>e;e++){var r=t[e];for(var i in r)H(n[i])?N(n[i],P(r[i])):n[i]=P(r[i])}return n}var I="undefined"==typeof queueMicrotask?function(n){return Promise.resolve().then(n)}:queueMicrotask,V="width",L="height",G="top",O="bottom",j="left",B="right",R="#000",U="#0000",J="mousemove",q="mousedown",Z="mouseup",X="mouseenter",K="mouseleave",Q="dblclick",$="resize",nn="scroll",tn="u-off",en="u-label",rn=requestAnimationFrame,on=document,ln=window,an=devicePixelRatio;function un(n,t){null!=t&&n.classList.add(t)}function sn(n,t){n.classList.remove(t)}function fn(n,t,e){n.style[t]=e+"px"}function cn(n,t,e,r){var i=on.createElement(n);return null!=t&&un(i,t),null!=e&&e.insertBefore(i,r),i}function vn(n,t){return cn("div",n,t)}function hn(n,t,e,r,i){n.style.transform="translate("+t+"px,"+e+"px)",0>t||0>e||t>r||e>i?un(n,tn):sn(n,tn)}var mn={passive:!0};function dn(n,t,e){t.addEventListener(n,e,mn)}function pn(n,t,e){t.removeEventListener(n,e,mn)}var gn=["January","February","March","April","May","June","July","August","September","October","November","December"],wn=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function xn(n){return n.slice(0,3)}var _n=wn.map(xn),bn=gn.map(xn),yn={MMMM:gn,MMM:bn,WWWW:wn,WWW:_n};function Mn(n){return(10>n?"0":"")+n}var kn={YYYY:function(n){return n.getFullYear()},YY:function(n){return(n.getFullYear()+"").slice(2)},MMMM:function(n,t){return t.MMMM[n.getMonth()]},MMM:function(n,t){return t.MMM[n.getMonth()]},MM:function(n){return Mn(n.getMonth()+1)},M:function(n){return n.getMonth()+1},DD:function(n){return Mn(n.getDate())},D:function(n){return n.getDate()},WWWW:function(n,t){return t.WWWW[n.getDay()]},WWW:function(n,t){return t.WWW[n.getDay()]},HH:function(n){return Mn(n.getHours())},H:function(n){return n.getHours()},h:function(n){var t=n.getHours();return 0==t?12:t>12?t-12:t},AA:function(n){return 12>n.getHours()?"AM":"PM"},aa:function(n){return 12>n.getHours()?"am":"pm"},a:function(n){return 12>n.getHours()?"a":"p"},mm:function(n){return Mn(n.getMinutes())},m:function(n){return n.getMinutes()},ss:function(n){return Mn(n.getSeconds())},s:function(n){return n.getSeconds()},fff:function(n){return function(n){return(10>n?"00":100>n?"0":"")+n}(n.getMilliseconds())}};function Sn(n,t){t=t||yn;for(var e,r=[],i=/\{([a-z]+)\}|[^{]+/gi;e=i.exec(n);)r.push("{"==e[0][0]?kn[e[1]]:e[0]);return function(n){for(var e="",i=0;r.length>i;i++)e+="string"==typeof r[i]?r[i]:r[i](n,t);return e}}var Tn=(new Intl.DateTimeFormat).resolvedOptions().timeZone,zn=function(n){return n%1==0},Dn=[1,2,2.5,5],En=Y(10,-16,0,Dn),Wn=Y(10,0,16,Dn),Yn=Wn.filter(zn),Cn=En.concat(Wn),An="{YYYY}",Fn="\n"+An,Hn="{M}/{D}",Pn="\n"+Hn,Nn=Pn+"/{YY}",In="{aa}",Vn="{h}:{mm}"+In,Ln="\n"+Vn,Gn=":{ss}",On=null;function jn(n){var t=1e3*n,e=60*t,r=60*e,i=24*r,o=30*i,l=365*i;return[(1==n?Y(10,0,3,Dn).filter(zn):Y(10,-3,0,Dn)).concat([t,5*t,10*t,15*t,30*t,e,5*e,10*e,15*e,30*e,r,2*r,3*r,4*r,6*r,8*r,12*r,i,2*i,3*i,4*i,5*i,6*i,7*i,8*i,9*i,10*i,15*i,o,2*o,3*o,4*o,6*o,l,2*l,5*l,10*l,25*l,50*l,100*l]),[[l,An,On,On,On,On,On,On,1],[28*i,"{MMM}",Fn,On,On,On,On,On,1],[i,Hn,Fn,On,On,On,On,On,1],[r,"{h}"+In,Nn,On,Pn,On,On,On,1],[e,Vn,Nn,On,Pn,On,On,On,1],[t,Gn,Nn+" "+Vn,On,Pn+" "+Vn,On,Ln,On,1],[n,Gn+".{fff}",Nn+" "+Vn,On,Pn+" "+Vn,On,Ln,On,1]],function(t){return function(a,u,s,f,c,h){var m=[],d=c>=l,p=c>=o&&l>c,g=t(s),w=g*n,x=nt(g.getFullYear(),d?0:g.getMonth(),p||d?1:g.getDate()),_=x*n;if(p||d)for(var b=p?c/o:0,y=d?c/l:0,M=w==_?w:nt(x.getFullYear()+y,x.getMonth()+b,1)*n,k=new Date(M/n),S=k.getFullYear(),z=k.getMonth(),E=0;f>=M;E++){var W=nt(S+y*E,z+b*E,1);(M=(+W+(W-t(W*n)))*n)>f||m.push(M)}else{var Y=i>c?c:i,C=_+(v(s)-v(w))+T(w-_,Y);m.push(C);for(var A=t(C),F=A.getHours()+A.getMinutes()/e+A.getSeconds()/r,H=c/r,P=h/a.axes[u]._space;(C=D(C+c,1==n?0:3))<=f;)if(H>1){var N=v(D(F+H,6))%24,I=t(C).getHours()-N;I>1&&(I=-1),F=(F+H)%24,.7>D(((C-=I*r)-m[m.length-1])/c,3)*P||m.push(C)}else m.push(C)}return m}}]}var Bn=jn(1),Rn=Bn[0],Un=Bn[1],Jn=Bn[2],qn=jn(.001),Zn=qn[0],Xn=qn[1],Kn=qn[2];function Qn(n,t){return n.map((function(n){return n.map((function(e,r){return 0==r||8==r||null==e?e:t(1==r||0==n[8]?e:n[1]+e)}))}))}function $n(n,t){return function(e,r,i,o,l){var a,u,s,f,c,v,h=t.find((function(n){return l>=n[0]}))||t[t.length-1];return r.map((function(t){var e=n(t),r=e.getFullYear(),i=e.getMonth(),o=e.getDate(),l=e.getHours(),m=e.getMinutes(),d=e.getSeconds(),p=r!=a&&h[2]||i!=u&&h[3]||o!=s&&h[4]||l!=f&&h[5]||m!=c&&h[6]||d!=v&&h[7]||h[1];return a=r,u=i,s=o,f=l,c=m,v=d,p(e)}))}}function nt(n,t,e){return new Date(n,t,e)}function tt(n,t){return t(n)}function et(n,t){return function(e,r){return t(n(r))}}Y(2,-53,53,[1]);var rt=[0,0];function it(n,t,e){return function(n){0==n.button&&e(n)}}function ot(n,t,e){return e}var lt={show:!0,x:!0,y:!0,lock:!1,move:function(n,t,e){return rt[0]=t,rt[1]=e,rt},points:{show:function(n,t){var e=n.series[t],r=vn();r.style.background=e.stroke||R;var i=Mt(e.width,1),o=(i-1)/-2;return fn(r,V,i),fn(r,L,i),fn(r,"marginLeft",o),fn(r,"marginTop",o),r}},bind:{mousedown:it,mouseup:it,click:it,dblclick:it,mousemove:ot,mouseleave:ot,mouseenter:ot},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,_x:!1,_y:!1},focus:{prox:-1},left:-10,top:-10,idx:null,dataIdx:function(n,t,e){return e}},at={show:!0,stroke:"rgba(0,0,0,0.07)",width:2,filter:S},ut=N({},at,{size:10}),st='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',ft="bold "+st,ct={show:!0,scale:"x",space:50,gap:5,size:50,labelSize:30,labelFont:ft,side:2,grid:at,ticks:ut,font:st,rotate:0},vt={show:!0,scale:"x",auto:!1,sorted:1,min:b,max:-b,idxs:[]};function ht(n,t){return t.map((function(n){return null==n?"":s(n)}))}function mt(n,t,e,r,i,o,l){for(var a=[],u=E.get(i)||0,s=e=l?e:D(T(e,i),u);r>=s;s=D(s+i,u))a.push(Object.is(s,-0)?0:s);return a}function dt(n,t,e,r,i){var o=[],l=n.scales[n.axes[t].scale].log,a=v((10==l?w:x)(e));i=g(l,a),0>a&&(i=D(i,-a));var u=e;do{o.push(u),i*l>(u=D(u+i,E.get(i)))||(i=u)}while(r>=u);return o}var pt=/./,gt=/[12357]/,wt=/[125]/,xt=/1/;function _t(n,t,e){var r=n.axes[e],i=r.scale;if(2==n.scales[i].log)return t;var o=n.valToPos,l=r._space,a=o(10,i),u=o(9,i)-a=r[1]-r[0]}},values:null,min:b,max:-b,idxs:[],path:null,clip:null},Tt={time:!0,auto:!0,distr:1,log:10,min:null,max:null},zt=N({},Tt,{time:!1}),Dt={};function Et(){var n=[];return{sub:function(t){n.push(t)},unsub:function(t){n=n.filter((function(n){return n!=t}))},pub:function(t,e,r,i,o,l,a){n.length>1&&n.forEach((function(n){n!=e&&n.pub(t,e,r,i,o,l,a)}))}}}function Wt(n,t,e,r){return(r?[n[0],n[1]].concat(n.slice(2)):[n[0]].concat(n.slice(1))).map((function(n,r){return Yt(n,r,t,e)}))}function Yt(n,t,e,r){return N({},0==t||n&&n.side%2==0?e:r,n)}function Ct(n,t){return 3==t.distr?w(n/t.min)/w(t.max/t.min):(n-t.min)/(t.max-t.min)}function At(n,t,e,r){return r+(1-Ct(n,t))*e}function Ft(n,t,e,r){return r+Ct(n,t)*e}var Ht=[null,null];function Pt(n,t,e){return null==t?Ht:[t,e]}var Nt=Pt;function It(n,t,e){return null==t?Ht:l(t,e,.1,!0)}function Vt(n,t,e,i){return null==t?Ht:r(t,e,n.scales[i].log,!1)}var Lt=Vt;function Gt(n){var t;return[n=n.replace(/(\d+)px/,(function(n,e){return(t=h(e*an))+"px"})),t]}function Ot(t,e,i){var o={},a=!1;o.status=0;var u=o.root=vn("uplot");null!=t.id&&(u.id=t.id),un(u,t.class),t.title&&(vn("u-title",u).textContent=t.title);var s=cn("canvas"),f=o.ctx=s.getContext("2d"),x=vn("u-wrap",u),T=vn("u-under",x);x.appendChild(s);var z=vn("u-over",x);((t=P(t)).plugins||[]).forEach((function(n){n.opts&&(t=n.opts(o,t)||t)}));var W=t.ms||.001,Y=o.series=Wt(t.series||[],vt,St,!1),mn=o.axes=Wt(t.axes||[],ct,yt,!0),gn=o.scales={},wn=Y[0].scale;function xn(n){var e=gn[n];if(null==e){var r=(t.scales||C)[n]||C;if(null!=r.from)xn(r.from),gn[n]=N({},gn[r.from],r);else{var i=(e=gn[n]=N({},n==wn?Tt:zt,r)).time,o=3==e.distr,a=e.range;if(n!=wn&&!A(a)&&H(a)){var u=a;a=function(n,t,e){return null==t?Ht:l(t,e,u)}}e.range=k(a||(i?Nt:n==wn?o?Lt:Pt:o?Vt:It)),e.auto=k(e.auto)}}}for(var _n in xn("x"),xn("y"),Y.forEach((function(n){xn(n.scale)})),t.scales)xn(_n);var bn=gn[wn].distr,yn={};for(var Mn in gn){var kn=gn[Mn];null==kn.min&&null==kn.max||(yn[Mn]={min:kn.min,max:kn.max})}var Tn=o.gutters=N({x:h(yt.size/2),y:h(ct.size/3),_x:null,_y:null},t.gutters);Tn.x=k(Tn.x),Tn.y=k(Tn.y),Tn._x=Tn.x(o),Tn._y=Tn.y(o);var zn,Dn,En=t.tzDate||function(n){return new Date(n/W)},Wn=t.fmtDate||Sn,An=1==W?Jn(En):Kn(En),Fn=$n(En,Qn(1==W?Un:Xn,Wn)),Hn=et(En,tt("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",Wn)),Pn=N({show:!0,live:!0},t.legend),Nn=Pn.show,In=[],Vn=!1;if(Nn){zn=cn("table","u-legend",u);var Ln=Y[1]?Y[1].values:null;if(Vn=null!=Ln){var Gn=cn("tr","u-thead",zn);for(var On in cn("th",null,Gn),Dn=Ln(o,1,0))cn("th",en,Gn).textContent=On}else Dn={_:0},un(zn,"u-inline"),Pn.live&&un(zn,"u-live")}var jn=new Map;function Bn(n,t,e){var r=jn.get(t)||{},i=Rt.bind[n](o,t,e);i&&(dn(n,t,r[n]=i),jn.set(t,r))}var qn=0,nt=0,rt=0,it=0,ot=0,at=0,ut=0,st=0,ft=0,pt=0;o.bbox={};var gt=!1,wt=!1,xt=!1,Ct=!1,Ot=!1;function jt(n,t){n==o.width&&t==o.height||Bt(n,t),he(!1),xt=!0,wt=!0,Ct=!0,Ot=!0,Se()}function Bt(n,t){o.width=qn=rt=n,o.height=nt=it=t,ot=at=0,function(){var n=!1,t=!1,e=!1,r=!1;mn.forEach((function(i){if(i.show&&i._show){var o=i.side,l=o%2,a=i._size+(i.labelSize=null!=i.label?i.labelSize||30:0);a>0&&(l?(rt-=a,3==o?(ot+=a,r=!0):e=!0):(it-=a,0==o?(at+=a,n=!0):t=!0))}})),(n||t)&&(e||(rt-=Tn._x),r||(rt-=Tn._x,ot+=Tn._x)),(r||e)&&(t||(it-=Tn._y),n||(it-=Tn._y,at+=Tn._y))}(),function(){var n=ot+rt,t=at+it,e=ot,r=at;function i(i,o){switch(i){case 1:return(n+=o)-o;case 2:return(t+=o)-o;case 3:return(e-=o)+o;case 0:return(r-=o)+o}}mn.forEach((function(n){if(n.show&&n._show){var t=n.side;n._pos=i(t,n._size),null!=n.label&&(n._lpos=i(t,n.labelSize))}}))}();var e=o.bbox;ut=e.left=y(ot*an,.5),st=e.top=y(at*an,.5),ft=e.width=y(rt*an,.5),pt=e.height=y(it*an,.5)}o.setSize=function(n){jt(n.width,n.height)};var Rt=o.cursor=N({},lt,t.cursor);Rt._lock=!1,Rt.points.show=k(Rt.points.show);var Ut,Jt=o.focus=N({},t.focus||{alpha:.3},Rt.focus),qt=Jt.prox>=0,Zt=[null];function Xt(n,t){var e=gn[n.scale].time,r=n.value;if(n.value=e?F(r)?et(En,tt(r,Wn)):r||Hn:r||bt,n.label=n.label||(e?"Time":"Value"),t>0){n.width=null==n.width?1:n.width,n.paths=n.paths||se,n.fillTo=n.fillTo||kt;var i=Mt(n.width,1);n.points=N({},{size:i,width:p(1,.2*i),stroke:n.stroke,space:2*i},n.points),n.points.show=k(n.points.show),n._paths=null}if(Nn&&In.splice(t,0,function(n,t){if(0==t&&(Vn||!Pn.live))return null;var e=[],r=cn("tr","u-series",zn,zn.childNodes[t]);un(r,n.class),n.show||un(r,tn);var i=cn("th",null,r),o=vn("u-marker",i);o.style.borderColor=n.width?n.stroke:t>0&&n.points.width?n.points.stroke:null,o.style.backgroundColor=n.fill||null;var l=vn(en,i);for(var a in l.textContent=n.label,t>0&&(Bn("click",i,(function(){Rt._lock||Le(Y.indexOf(n),{show:!n.show},ir.setSeries)})),qt&&Bn(X,i,(function(){Rt._lock||Le(Y.indexOf(n),{focus:!0},ir.setSeries)}))),Dn){var u=cn("td","u-value",r);u.textContent="--",e.push(u)}return e}(n,t)),Rt.show){var l=function(n,t){if(t>0){var e=Rt.points.show(o,t);if(e)return un(e,"u-cursor-pt"),un(e,n.class),hn(e,-10,-10,rt,it),z.insertBefore(e,Zt[t]),e}}(n,t);l&&Zt.splice(t,0,l)}}o.addSeries=function(n,t){n=Yt(n,t=null==t?Y.length:t,vt,St),Y.splice(t,0,n),Xt(Y[t],t)},o.delSeries=function(n){Y.splice(n,1),Nn&&In.splice(n,1)[0][0].parentNode.remove(),Zt.length>1&&Zt.splice(n,1)[0].remove()},Y.forEach(Xt),mn.forEach((function(n,t){if(n._show=n.show,n.show){var e=gn[n.scale];null==e&&(n.scale=n.side%2?Y[1].scale:wn,e=gn[n.scale]);var r=e.time;n.size=k(n.size),n.space=k(n.space),n.rotate=k(n.rotate),n.incrs=k(n.incrs||(2==e.distr?Yn:r?1==W?Rn:Zn:Cn)),n.splits=k(n.splits||(r&&1==e.distr?An:3==e.distr?dt:mt));var i=n.values;n.values=r?A(i)?$n(En,Qn(i,Wn)):F(i)?function(n,t){var e=Sn(t);return function(t,r){return r.map((function(t){return e(n(t))}))}}(En,i):i||Fn:i||ht,n.filter=k(n.filter||(3==e.distr?_t:S)),n.font=Gt(n.font),n.labelFont=Gt(n.labelFont),n._size=n.size(o,null,t,0),n._space=n._rotate=n._incrs=n._found=n._splits=n._values=null}}));var Kt=null,Qt=null,$t=Y[0].idxs,ne=null,te=!1;function ee(n,t){if(!A(n)&&H(n)&&(n.isGap&&Y.forEach((function(t){t.isGap=n.isGap})),n=n.data),(n=n||[])[0]=n[0]||[],o.data=n,e=n.slice(),Ut=(ne=e[0]).length,2==bn&&(e[0]=ne.map((function(n,t){return t}))),he(!0),rr("setData"),!1!==t){var r=gn[wn];r.auto(o,te)?re():Ve(wn,r.min,r.max),Ct=!0,Ot=!0,Se()}}function re(){var n,t,i,o;te=!0,Ut>0?(Kt=$t[0]=0,Qt=$t[1]=Ut-1,i=e[0][Kt],o=e[0][Qt],2==bn?(i=Kt,o=Qt):1==Ut&&(3==bn?(i=(n=r(i,i,gn[wn].log,!1))[0],o=n[1]):gn[wn].time?o=i+86400/W:(i=(t=l(i,o,.1,!0))[0],o=t[1]))):(Kt=$t[0]=i=null,Qt=$t[1]=o=null),Ve(wn,i,o),te=!1}function ie(n,t,e,r){f.strokeStyle=n||U,f.lineWidth=t,f.lineJoin="round",f.setLineDash(e||[]),f.fillStyle=r||U}o.setData=ee;var oe=1;function le(n){var t=null;if(n.length>0){t=new Path2D;for(var e=ut,r=0;n.length>r;r++){var i=n[r];t.rect(e,st,i[0]-e,st+pt),e=i[1]}t.rect(e,st,ut+ft-e,st+pt)}return t}function ae(n,t,e){if(e>t){var r=n[n.length-1];r&&r[0]==t?r[1]=e:n.push([t,e])}}function ue(n,t,e,r){for(var i=1==r?t:e;i>=t&&e>=i;i+=r)if(null!=n[i])return i;return-1}function se(n,t,r,i,o,l){var a,u,s,f,c,v=Y[t],m=v.isGap,g=e[0],w=e[t],x=gn[wn],_=gn[v.scale],M=1==oe?{stroke:new Path2D,fill:null,clip:null}:Y[t-1]._paths,k=M.stroke,S=D(v.width*an,3),T=b,z=-b,E=[],W=h(Ft(g[1==oe?r:i],x,ft,ut)),C=!1,A=ue(w,r,i,1),F=ue(w,r,i,-1),H=y(Ft(g[A],x,ft,ut),.5),P=y(Ft(g[F],x,ft,ut),.5);H>ut&&o(E,ut,H),v.band&&1==oe&&k.lineTo(H-2*S,h(At(w[r],_,pt,st)));for(var N=1==oe?r:i;N>=r&&i>=N;N+=oe){var I=h(Ft(g[N],x,ft,ut));if(I==W)null!=w[N]?(a=h(At(w[N],_,pt,st)),T=d(a,T),z=p(a,z)):!C&&m(n,t,N)&&(C=!0);else{var V=!1;T!=b?(k.lineTo(W,T),k.lineTo(W,z),k.lineTo(W,a),u=W):C&&(V=!0,C=!1),null!=w[N]?(a=h(At(w[N],_,pt,st)),k.lineTo(I,a),T=z=a,I-W>1&&null==w[N-1]&&m(n,t,N-1)&&(V=!0)):(T=b,z=-b,!C&&m(n,t,N)&&(C=!0)),V&&o(E,u,I),W=I}}if(ut+ft>P&&o(E,P,ut+ft),v.band&&(1==oe?(s=P+2*S,f=F,c=e[t+1]):(s=H-2*S,f=A,c=e[t-1]),k.lineTo(s,h(At(w[f],_,pt,st))),k.lineTo(s,h(At(c[f],_,pt,st)))),1==oe&&(v.spanGaps||(M.clip=l(E)),null!=v.fill)){var L=M.fill=new Path2D(k),G=h(At(v.fillTo(n,t,v.min,v.max),_,pt,st));L.lineTo(P,G),L.lineTo(H,G)}return v.band&&(oe*=-1),M}function fe(n,t,e,r,i,o,l,a,u){var s=l%2/2;f.translate(s,s),ie(a,l,u),f.beginPath();var c,v,h,m,d=i+(0==r||3==r?-o:o);0==e?(v=i,m=d):(c=i,h=d),n.forEach((function(n,r){null!=t[r]&&(0==e?c=h=n:v=m=n,f.moveTo(c,v),f.lineTo(h,m))})),f.stroke(),f.translate(-s,-s)}function ce(n){var t=!0;return mn.forEach((function(e,r){if(e.show){var i=gn[e.scale];if(null!=i.min){e._show||(t=!1,e._show=!0,he(!1));var l=e.side,a=i.min,u=i.max,s=function(n,t,e,r){var i,l=mn[n];if(r>0){var a=l._space=l.space(o,n,t,e,r),u=l._incrs=l.incrs(o,n,t,e,r,a);i=l._found=function(n,t,e,r,i){for(var o=r/(t-n),l=(""+v(n)).length,a=0;e.length>a;a++){var u=e[a]*o,s=10>e[a]?E.get(e[a]):0;if(u>=i&&17>l+s)return[e[a],u]}return[0,0]}(t,e,u,r,a)}else i=[0,0];return i}(r,a,u,0==l%2?rt:it),f=s[0],c=s[1];if(0!=c){var h=e._splits=e.splits(o,r,a,u,f,c,2==i.distr),d=2==i.distr?h.map((function(n){return ne[n]})):h,p=2==i.distr?ne[h[1]]-ne[h[0]]:f,g=e._values=e.values(o,e.filter(o,d,r,c,p),r,c,p);e._rotate=2==l?e.rotate(o,g,r,c):0;var w=e._size;e._size=m(e.size(o,g,r,n)),null!=w&&e._size!=w&&(t=!1)}}else e._show&&(t=!1,e._show=!1,he(!1))}})),t}function ve(n){var t=!0,e=Tn._x,r=Tn._y;return Tn._x=m(Tn.x(o,n)),Tn._y=m(Tn.y(o,n)),Tn._x==e&&Tn._y==r||(t=!1),t}function he(n){Y.forEach((function(t,e){e>0&&(t._paths=null,n&&(t.min=null,t.max=null))}))}o.paths=se;var me,de,pe,ge,we,xe,_e,be,ye,Me,ke=!1;function Se(){ke||(I(Te),ke=!0)}function Te(){gt&&(function(){var t=P(gn);for(var r in t){var i=t[r],l=yn[r];if(null!=l&&null!=l.min)N(i,l),r==wn&&he(!0);else if(r!=wn)if(0==Ut&&null==i.from){var a=i.range(o,null,null,r);i.min=a[0],i.max=a[1]}else i.min=b,i.max=-b}if(Ut>0)for(var u in Y.forEach((function(r,i){var l=r.scale,a=t[l],u=yn[l];if(0==i){var s=a.range(o,a.min,a.max,l);a.min=s[0],a.max=s[1],Kt=n(a.min,e[0]),Qt=n(a.max,e[0]),a.min>e[0][Kt]&&Kt++,e[0][Qt]>a.max&&Qt--,r.min=ne[Kt],r.max=ne[Qt]}else if(r.show&&r.auto&&a.auto(o,te)&&(null==u||null==u.min)){var f=null==r.min?function(n,t,e,r){var i=b,o=-b;if(1==r)i=n[t],o=n[e];else if(-1==r)i=n[e],o=n[t];else for(var l=t;e>=l;l++)null!=n[l]&&(i=d(i,n[l]),o=p(o,n[l]));return[i,o]}(e[i],Kt,Qt,r.sorted):[r.min,r.max];a.min=d(a.min,r.min=f[0]),a.max=p(a.max,r.max=f[1])}r.idxs[0]=Kt,r.idxs[1]=Qt})),t){var s=t[u],f=yn[u];if(null==s.from&&(null==f||null==f.min)){var c=s.range(o,s.min==b?null:s.min,s.max==-b?null:s.max,u);s.min=c[0],s.max=c[1]}}for(var v in t){var h=t[v];if(null!=h.from){var m=t[h.from],g=h.range(o,m.min,m.max,v);h.min=g[0],h.max=g[1]}}var w={},x=!1;for(var _ in t){var y=t[_],M=gn[_];M.min==y.min&&M.max==y.max||(M.min=y.min,M.max=y.max,w[_]=x=!0)}if(x){for(var k in Y.forEach((function(n){w[n.scale]&&(n._paths=null)})),w)xt=!0,rr("setScale",k);Rt.show&&(Ct=!0)}for(var S in yn)yn[S]=null}(),gt=!1),xt&&(function(){for(var n=!1,t=0;!n;){var e=ce(++t),r=ve(t);(n=e&&r)||(Bt(o.width,o.height),wt=!0)}}(),xt=!1),wt&&(fn(T,j,ot),fn(T,G,at),fn(T,V,rt),fn(T,L,it),fn(z,j,ot),fn(z,G,at),fn(z,V,rt),fn(z,L,it),fn(x,V,qn),fn(x,L,nt),s.width=h(qn*an),s.height=h(nt*an),Ue(),rr("setSize"),wt=!1),Rt.show&&Ct&&(Be(),Ct=!1),qn>0&&nt>0&&(f.clearRect(0,0,s.width,s.height),rr("drawClear"),function(){mn.forEach((function(n,t){if(n.show&&n._show){var e=gn[n.scale],r=n.side,i=r%2,l=0==i?Ft:At,a=0==i?ft:pt,u=0==i?ut:st,s=h(n.gap*an),c=n.ticks,v=c.show?h(c.size*an):0,m=n._found,d=m[0],p=m[1],g=n._splits,w=2==e.distr?g.map((function(n){return ne[n]})):g,x=2==e.distr?ne[g[1]]-ne[g[0]]:d,b=n._rotate*-_/180,y=h(n._pos*an),M=y+(v+s)*(0==i&&0==r||1==i&&3==r?-1:1),k=0==i?M:0,S=1==i?M:0;f.font=n.font[0],f.fillStyle=n.stroke||R,f.textAlign=1==n.align?j:2==n.align?B:b>0?j:0>b?B:0==i?"center":3==r?B:j,f.textBaseline=b||1==i?"middle":2==r?G:O;var T=1.5*n.font[1],z=g.map((function(n){return h(l(n,e,a,u))}));if(n._values.forEach((function(n,t){null!=n&&(0==i?S=z[t]:k=z[t],(""+n).split(/\n/gm).forEach((function(n,t){b?(f.save(),f.translate(S,k+t*T),f.rotate(b),f.fillText(n,0,0),f.restore()):f.fillText(n,S,k+t*T)})))})),n.label){f.save();var E=h(n._lpos*an);1==i?(S=k=0,f.translate(E,h(st+pt/2)),f.rotate((3==r?-_:_)/2)):(S=h(ut+ft/2),k=E),f.font=n.labelFont[0],f.textAlign="center",f.textBaseline=2==r?G:O,f.fillText(n.label,S,k),f.restore()}c.show&&fe(z,c.filter(o,w,t,p,x),i,r,y,v,D(c.width*an,3),c.stroke);var W=n.grid;W.show&&fe(z,W.filter(o,w,t,p,x),i,0==i?2:1,0==i?st:ut,0==i?pt:ft,D(W.width*an,3),W.stroke,W.dash)}})),rr("drawAxes")}(),Ut>0&&function(){Y.forEach((function(n,t){if(t>0&&n.show&&null==n._paths){var r=function(n){for(var t=M(Kt-1,0,Ut-1),e=M(Qt+1,0,Ut-1);null==n[t]&&t>0;)t--;for(;null==n[e]&&Ut-1>e;)e++;return[t,e]}(e[t]);n._paths=n.paths(o,t,r[0],r[1],ae,le)}})),Y.forEach((function(n,t){t>0&&n.show&&(n._paths&&function(n){var t=Y[n];if(1==oe){var e=t._paths,r=e.stroke,i=e.fill,o=e.clip,l=D(t.width*an,3),a=l%2/2;ie(t.stroke,l,t.dash,t.fill),f.globalAlpha=t.alpha,f.translate(a,a),f.save();var u=ut,s=st,c=ft,v=pt,h=l*an/2;0==t.min&&(v+=h),0==t.max&&(s-=h,v+=h),f.beginPath(),f.rect(u,s,c,v),f.clip(),null!=o&&f.clip(o),t.band?(f.fill(r),l&&f.stroke(r)):(null!=t.fill&&f.fill(i),l&&f.stroke(r)),f.restore(),f.translate(-a,-a),f.globalAlpha=1}t.band&&(oe*=-1)}(t),n.points.show(o,t,Kt,Qt)&&function(n){var t=Y[n],r=t.points,i=D(r.width*an,3),o=i%2/2,l=r.width>0,a=(r.size-r.width)/2*an,u=D(2*a,3);f.translate(o,o),f.save(),f.beginPath(),f.rect(ut-u,st-u,ft+2*u,pt+2*u),f.clip(),f.globalAlpha=t.alpha;for(var s=new Path2D,c=Kt;Qt>=c;c++)if(null!=e[n][c]){var v=h(Ft(e[0][c],gn[wn],ft,ut)),m=h(At(e[n][c],gn[t.scale],pt,st));s.moveTo(v+a,m),s.arc(v,m,a,0,2*_)}ie(r.stroke,i,null,r.fill||(l?"#fff":t.stroke)),f.fill(s),l&&f.stroke(s),f.globalAlpha=1,f.restore(),f.translate(-o,-o)}(t),rr("drawSeries",t))}))}(),rr("draw")),a||(a=!0,o.status=1,rr("ready")),ke=!1}function ze(t,r){var i=gn[t];if(null==i.from){if(0==Ut){var l=i.range(o,r.min,r.max,t);r.min=l[0],r.max=l[1]}if(Ut>1&&null!=r.min&&null!=r.max&&1e-16>r.max-r.min)return;t==wn&&2==i.distr&&Ut>0&&(r.min=n(r.min,e[0]),r.max=n(r.max,e[0])),yn[t]=r,gt=!0,Se()}}o.redraw=function(n){!1!==n?Ve(wn,gn[wn].min,gn[wn].max):Se()},o.setScale=ze;var De=!1,Ee=Rt.drag,We=Ee.x,Ye=Ee.y;Rt.show&&(Rt.x&&(ye=Rt.left,me=vn("u-cursor-x",z)),Rt.y&&(Me=Rt.top,de=vn("u-cursor-y",z)));var Ce,Ae,Fe,He=o.select=N({show:!0,over:!0,left:0,width:0,top:0,height:0},t.select),Pe=He.show?vn("u-select",He.over?z:T):null;function Ne(n,t){if(He.show){for(var e in n)fn(Pe,e,He[e]=n[e]);!1!==t&&rr("setSelect")}}function Ie(n){var t=Nn?In[n][0].parentNode:null;Y[n].show?t&&sn(t,tn):(t&&un(t,tn),Zt.length>1&&hn(Zt[n],-10,-10,rt,it))}function Ve(n,t,e){ze(n,{min:t,max:e})}function Le(n,t,e){var r=Y[n];if(null!=t.focus&&function(n){n!=Fe&&(Y.forEach((function(t,e){!function(n,t){var e=Y[n];Ge(n,t),e.band&&Ge(Y[n+1].band?n+1:n-1,t)}(e,null==n||0==e||e==n?1:Jt.alpha)})),Fe=n,Se())}(n),null!=t.show){if(r.show=t.show,Ie(n),r.band){var i=Y[n+1]&&Y[n+1].band?n+1:n-1;Y[i].show=r.show,Ie(i)}Ve(r.scale,null,null),Se()}rr("setSeries",n,t),e&&lr.pub("setSeries",o,n,t)}function Ge(n,t){Y[n].alpha=t,Rt.show&&Zt[n]&&(Zt[n].style.opacity=t),Nn&&In[n]&&(In[n][0].parentNode.style.opacity=t)}function Oe(n,t){var e=rt;t!=wn&&(n=(e=it)-n);var r=n/e,i=gn[t],o=i.min,l=i.max;return 3==i.distr?(o=w(o),l=w(l),g(10,o+(l-o)*r)):o+(l-o)*r}o.setSelect=Ne,o.setSeries=Le,Nn&&qt&&dn(K,zn,(function(){Rt._lock||(Le(null,{focus:!1},ir.setSeries),Be())})),o.valToIdx=function(t){return n(t,e[0])},o.posToIdx=function(t){return n(Oe(t,wn),e[0],Kt,Qt)},o.posToVal=Oe,o.valToPos=function(n,t,e){return t==wn?Ft(n,gn[t],e?ft:rt,e?ut:0):At(n,gn[t],e?pt:it,e?st:0)},o.batch=function(n){n(o),Se()},o.setCursor=function(n){ye=n.left,Me=n.top,Be()};var je=0;function Be(t,r){var i,l;if(je=0,_e=ye,be=Me,i=Rt.move(o,ye,Me),ye=i[0],Me=i[1],Rt.show&&(Rt.x&&hn(me,h(ye),0,rt,it),Rt.y&&hn(de,0,h(Me),rt,it)),Ce=b,0>ye||0==Ut||Kt>Qt){l=null;for(var u=0;Y.length>u;u++)if(u>0&&Zt.length>1&&hn(Zt[u],-10,-10,rt,it),Nn&&Pn.live){if(0==u&&Vn)continue;for(var s=0;In[u].length>s;s++)In[u][s].firstChild.nodeValue="--"}qt&&Le(null,{focus:!0},ir.setSeries)}else{var f=Oe(ye,wn);l=n(f,e[0],Kt,Qt);for(var v=gn[wn],m=D(Ft(e[0][l],v,rt,0),3),p=0;Y.length>p;p++){var g=Y[p],w=Rt.dataIdx(o,p,l,f),x=w==l?m:D(Ft(e[0][w],v,rt,0),3);if(p>0&&g.show){var _=e[p][w],y=null==_?-10:D(At(_,gn[g.scale],it,0),3);if(y>0){var M=c(y-Me);M>Ce||(Ce=M,Ae=p)}Zt.length>1&&hn(Zt[p],x,y,rt,it)}if(Nn&&Pn.live){if(w==Rt.idx&&!Ot||0==p&&Vn)continue;var k=0==p&&2==bn?ne:e[p],S=Vn?g.values(o,p,w):{_:g.value(o,k[w],p,w)},T=0;for(var z in S)In[p][T++].firstChild.nodeValue=S[z]}}Ot=!1}if(He.show&&De)if(null!=r){var E=ir.scales,W=E[0],C=E[1],A=r.cursor.drag;if(We=A._x,Ye=A._y,W){var F=gn[W],H=r.posToVal(r.select.left,W),P=r.posToVal(r.select.left+r.select.width,W);He.left=Ft(H,F,rt,0),He.width=c(He.left-Ft(P,F,rt,0)),fn(Pe,j,He.left),fn(Pe,V,He.width),C||(fn(Pe,G,He.top=0),fn(Pe,L,He.height=it))}if(C){var N=gn[C],I=r.posToVal(r.select.top,C),O=r.posToVal(r.select.top+r.select.height,C);He.top=At(I,N,it,0),He.height=c(He.top-At(O,N,it,0)),fn(Pe,G,He.top),fn(Pe,L,He.height),W||(fn(Pe,j,He.left=0),fn(Pe,V,He.width=rt))}}else{var B=c(_e-pe),R=c(be-ge);We=Ee.x&&B>=Ee.dist,Ye=Ee.y&&R>=Ee.dist;var U=Ee.uni;if(null!=U?We&&Ye&&(Ye=R>=U,(We=B>=U)||Ye||(R>B?Ye=!0:We=!0)):Ee.x&&Ee.y&&(We||Ye)&&(We=Ye=!0),We){var q=d(we,ye),Z=c(ye-we);fn(Pe,j,He.left=q),fn(Pe,V,He.width=Z),Ye||(fn(Pe,G,He.top=0),fn(Pe,L,He.height=it))}if(Ye){var X=d(xe,Me),K=c(Me-xe);fn(Pe,G,He.top=X),fn(Pe,L,He.height=K),We||(fn(Pe,j,He.left=0),fn(Pe,V,He.width=rt))}We||Ye||(fn(Pe,L,He.height=0),fn(Pe,V,He.width=0))}Rt.idx=l,Rt.left=ye,Rt.top=Me,Ee._x=We,Ee._y=Ye,null!=t&&(lr.pub(J,o,ye,Me,rt,it,l),qt&&Le(Ce>Jt.prox?null:Ae,{focus:!0},ir.setSeries)),a&&rr("setCursor")}var Re=null;function Ue(){Re=z.getBoundingClientRect()}function Je(n,t,e,r,i,o){Rt._lock||(qe(n,t,e,r,i,o,0,!1,null!=n),null!=n?0==je&&(je=rn(Be)):Be(null,t))}function qe(n,t,e,r,i,l,a,u,s){var f;if(null!=n)e=n.clientX-Re.left,r=n.clientY-Re.top;else{if(0>e||0>r)return ye=-10,void(Me=-10);var c=ir.scales,v=c[0],h=c[1];e=null!=v?Ft(t.posToVal(e,v),gn[v],rt,0):rt*(e/i),r=null!=h?At(t.posToVal(r,h),gn[h],it,0):it*(r/l)}s&&(e>1&&rt-1>e||(e=y(e,rt)),r>1&&it-1>r||(r=y(r,it))),u?(pe=e,ge=r,f=Rt.move(o,e,r),we=f[0],xe=f[1]):(ye=e,Me=r)}function Ze(){Ne({width:0,height:0},!1)}function Xe(n,t,e,r,i,l){De=!0,We=Ye=Ee._x=Ee._y=!1,qe(n,t,e,r,i,l,0,!0,!1),null!=n&&(Bn(Z,on,Ke),lr.pub(q,o,we,xe,rt,it,null))}function Ke(n,t,e,r,i,l){De=Ee._x=Ee._y=!1,qe(n,t,e,r,i,l,0,!1,!0);var a=He.width>0||He.height>0;if(a&&Ne(He),Ee.setScale&&a){if(We&&Ve(wn,Oe(He.left,wn),Oe(He.left+He.width,wn)),Ye)for(var u in gn){var s=gn[u];u!=wn&&null==s.from&&s.min!=b&&Ve(u,Oe(He.top+He.height,u),Oe(He.top,u))}Ze()}else Rt.lock&&(Rt._lock=!Rt._lock,Rt._lock||Be());null!=n&&(function(n,t){var e=jn.get(t)||{};pn(n,t,e[n]),e[n]=null}(Z,on),lr.pub(Z,o,ye,Me,rt,it,null))}function Qe(){if(!Rt._lock){var n=De;if(De){var t=!0,e=!0;if(We&&Ye&&(t=10>=ye||ye>=rt-10,e=10>=Me||Me>=it-10),We&&t){var r=ye,i=rt-ye,o=d(r,i);o==r&&(ye=0),o==i&&(ye=rt)}if(Ye&&e){var l=Me,a=it-Me,u=d(l,a);u==l&&(Me=0),u==a&&(Me=it)}Be(1),De=!1}ye=-10,Me=-10,Be(1),n&&(De=n)}}function $e(n){re(),Ze(),null!=n&&lr.pub(Q,o,ye,Me,rt,it,null)}var nr,tr={};tr.mousedown=Xe,tr.mousemove=Je,tr.mouseup=Ke,tr.dblclick=$e,tr.setSeries=function(n,t,e,r){Le(e,r)},Rt.show&&(Bn(q,z,Xe),Bn(J,z,Je),Bn(X,z,Ue),Bn(K,z,(function(){rn(Qe)})),Bn(Q,z,$e),nr=function(n){var t=null;function e(){t=null,n()}return function(){clearTimeout(t),t=setTimeout(e,100)}}(Ue),dn($,ln,nr),dn(nn,ln,nr),o.syncRect=Ue);var er=o.hooks=t.hooks||{};function rr(n,t,e){n in er&&er[n].forEach((function(n){n.call(null,o,t,e)}))}(t.plugins||[]).forEach((function(n){for(var t in n.hooks)er[t]=(er[t]||[]).concat(n.hooks[t])}));var ir=N({key:null,setSeries:!1,scales:[wn,null]},Rt.sync),or=ir.key,lr=null!=or?Dt[or]=Dt[or]||Et():Et();function ar(){rr("init",t,e),ee(e||t.data,!1),yn[wn]?ze(wn,yn[wn]):re(),jt(t.width,t.height),Ne(He,!1)}return lr.sub(o),o.pub=function(n,t,e,r,i,o,l){tr[n](null,t,e,r,i,o,l)},o.destroy=function(){lr.unsub(o),pn($,ln,nr),pn(nn,ln,nr),u.remove(),rr("destroy")},i?i instanceof HTMLElement?(i.appendChild(u),ar()):i(o,ar):ar(),o}return Ot.assign=N,Ot.fmtNum=s,Ot.rangeNum=l,Ot.rangeLog=r,Ot.fmtDate=Sn,Ot.tzDate=function(n,t){var e;return"Etc/UTC"==t?e=new Date(+n+6e4*n.getTimezoneOffset()):t==Tn?e=n:(e=new Date(n.toLocaleString("en-US",{timeZone:t}))).setMilliseconds(n.getMilliseconds()),e},Ot}(); diff --git a/src/uPlot.js b/src/uPlot.js index f02fb795..cda6f6e1 100644 --- a/src/uPlot.js +++ b/src/uPlot.js @@ -1040,7 +1040,7 @@ export default function uPlot(opts, data, then) { series.forEach((s, i) => { if (i > 0 && s.show && s._paths == null) { let _idxs = getOuterIdxs(data[i]); - s._paths = s.paths(self, i, _idxs[0], _idxs[1]); + s._paths = s.paths(self, i, _idxs[0], _idxs[1], extendGap, buildClip); } }); @@ -1117,13 +1117,11 @@ export default function uPlot(opts, data, then) { dir *= -1; } - function buildClip(is, gaps) { - let s = series[is]; - + function buildClip(gaps) { let clip = null; // create clip path (invert gaps and non-gaps) - if (gaps.length > 0 && !s.spanGaps) { + if (gaps.length > 0) { clip = new Path2D(); let prevGapEnd = plotLft; @@ -1142,7 +1140,7 @@ export default function uPlot(opts, data, then) { return clip; } - function addGap(gaps, fromX, toX) { + function extendGap(gaps, fromX, toX) { if (toX > fromX) { let prevGap = gaps[gaps.length - 1]; @@ -1162,7 +1160,7 @@ export default function uPlot(opts, data, then) { return -1; } - function buildPaths(self, is, _i0, _i1) { + function buildPaths(self, is, _i0, _i1, extendGap, buildClip) { const s = series[is]; const isGap = s.isGap; @@ -1192,7 +1190,7 @@ export default function uPlot(opts, data, then) { let rgtX = incrRound(getXPos(xdata[rgtIdx], scaleX, plotWid, plotLft), 0.5); if (lftX > plotLft) - addGap(gaps, plotLft, lftX); + extendGap(gaps, plotLft, lftX); // the moves the shape edge outside the canvas so stroke doesnt bleed in if (s.band && dir == 1) @@ -1241,14 +1239,14 @@ export default function uPlot(opts, data, then) { accGaps = true; } - _addGap && addGap(gaps, outX, x); + _addGap && extendGap(gaps, outX, x); accX = x; } } if (rgtX < plotLft + plotWid) - addGap(gaps, rgtX, plotLft + plotWid); + extendGap(gaps, rgtX, plotLft + plotWid); if (s.band) { let _x, _iy, ydata2; @@ -1270,7 +1268,8 @@ export default function uPlot(opts, data, then) { } if (dir == 1) { - _paths.clip = buildClip(is, gaps, ydata[_i0] == null, ydata[_i1] == null); + if (!s.spanGaps) + _paths.clip = buildClip(gaps); if (s.fill != null) { let fill = _paths.fill = new Path2D(stroke);