bezel-charts 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ /*! Bezel Charts v1.6.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
+ import{a as xt,b as yt,e as St,f as bt,h as wt}from"./shared-56ZZ4O3F.js";import{B as vt,C as dt,D as Ct,E as Nt,F as Rt,G as Mt,c as lt,e as f,g as B,h as U,j as X,k as ft,m as Z,o as ht,p as b,r as Y,s as D,t as st,u as mt,v as gt,w as pt}from"./shared-YIDF72XF.js";function H(r,n){for(var t=kt(r),i=X(r.series),e=gt(r,n),s=B(r.height,190),u=t?t.S:[],m=u.length,g=m>1||i.length>0,M=ht(r.percent),k=function(o){return i[o]||"Series "+(o+1)},w=Object.assign({},r,{decimals:U(r.decimals)?r.decimals:t?t.dp:0}),p=function(o){return b(t.edge(o),w)+" to "+b(t.edge(o+1),w)},v=function(o,x){return Math.round(t.counts[o][x]/u[o].length*100)},F=function(o,x){return M?t.counts[o][x]/u[o].length*100:t.counts[o][x]},R=X(r.mark).filter(function(o){return o==="mean"||o==="median"}),E=m>1?bt(r.patterns,St,"solid"):null,W="",O=[],h=0;E&&h<m;h++)if(E(h)!=="solid"){var $=lt("g");W+=wt($,E(h),e[h%e.length],r.background||n.tile),O[h]="url(#"+$+")"}var q=E&&function(o,x,z){return'<rect x="'+f(x)+'" y="'+f(z+1)+'" width="10" height="10" rx="2" fill="'+(O[o]||e[o%e.length])+'"/>'},J=0,j=0;if(t){for(var d=0;d<t.count;d++)Et(t,d)>Et(t,J)&&(J=d);u.forEach(function(o){j+=o.length})}return vt(r,n,s,function(o,x,z,tt){if(!t)return pt(n,o,x,z,tt);var _=W?"<defs>"+W+"</defs>":"",y=x;if(g){var nt=yt(u.map(function(a,c){return k(c)}),e,n,o,y,z,q,q&&15);_+=nt.svg,y+=nt.height}var K=0;u.forEach(function(a,c){for(var l=0;l<t.count;l++)K=Math.max(K,F(c,l))});var T=xt(0,K||1,4),rt=T.ticks.map(function(a){return b(a,{lang:r.lang},!0)+(M?"%":"")}),at=Math.max.apply(null,rt.map(function(a){return Z(a,10,!0)}))+10,C=o+at,G=z-at,N=tt-(y-x)-20,I=G/t.count,L=function(a){return C+a*I},et=function(a){return y+N-(a-T.lo)/(T.hi-T.lo)*N};T.ticks.forEach(function(a,c){var l=et(a);_+='<line x1="'+f(C)+'" x2="'+f(C+G)+'" y1="'+f(l)+'" y2="'+f(l)+'" stroke="'+n.grid+'"'+(a===0?"":' stroke-dasharray="2 4"')+"/>"+Y(C-8,l+3.5,rt[c],D(n,10,'text-anchor="end"'))});for(var Q=[],S=0;S<=t.count;S++)Q.push(b(t.edge(S),w,!0));var Ot=Math.max(1,Math.ceil((Math.max.apply(null,Q.map(function(a){return Z(a,10,!0)}))*1.5+8)/I));for(S=0;S<=t.count;S+=Ot)_+=Y(L(S),y+N+15,Q[S],D(n,10,'text-anchor="'+(S===0?"start":S===t.count?"end":"middle")+'"'));u.forEach(function(a,c){for(var l=0;l<t.count;l++){var A=F(c,l);if(A){var ct=et(A);_+='<rect x="'+f(L(l)+.5)+'" y="'+f(ct)+'" width="'+f(Math.max(1,I-1))+'" height="'+f(y+N-ct)+'" fill="'+(O[c]||e[c%e.length])+'"'+(g?' fill-opacity=".55"':"")+mt(r,"bzc-g",Math.min(.6,l*.03))+"/>"}}});var ot=t.edge(0),_t=t.edge(t.count)-ot,P=[];if(u.forEach(function(a,c){R.forEach(function(l){var A=l==="mean"?Tt(a):At(a);P.push({x:C+(A-ot)/_t*G,c:g?e[c%e.length]:n.fg,t:(g?k(c)+" ":"")+l+" "+b(A,r)})})}),P.length){var V=P.map(function(a){return a.x}),ut=(Math.min.apply(null,V)+Math.max.apply(null,V))/2>C+G/2,Wt=ut?Math.min.apply(null,V)-5:Math.max.apply(null,V)+5;P.forEach(function(a,c){_+='<line x1="'+f(a.x)+'" x2="'+f(a.x)+'" y1="'+f(y)+'" y2="'+f(y+N)+'" stroke="'+a.c+'" stroke-width="1.5" stroke-dasharray="4 3"/>'+Y(Wt,y+9+c*12,a.t,D(n,10,'text-anchor="'+(ut?"end":"start")+'"',g?a.c:n.fg))})}for(d=0;d<t.count;d++){var it=p(d);u.forEach(function(a,c){it+=`
3
+ `+(g?k(c)+": ":"")+t.counts[c][d]+" ("+v(c,d)+"%)"}),_+=st(L(d),y,I,N,it)}return _},{summary:t?(g?m+" series, ":"")+j+" values in "+t.count+" ranges from "+b(t.edge(0),w)+" to "+b(t.edge(t.count),w)+", most in "+p(J):"no data"})}H.table=function(r){var n=kt(r),t=X(r.series);if(!n)return{head:["Range","Count"],rows:[]};for(var i=n.S.length>1||t.length>0,e=Object.assign({},r,{decimals:U(r.decimals)?r.decimals:n.dp}),s=[],u=0;u<n.count;u++){var m=[b(n.edge(u),e)+" to "+b(n.edge(u+1),e)];i?n.S.forEach(function(g,M){m.push(String(n.counts[M][u]))}):m.push(String(n.counts[0][u]),Math.round(n.counts[0][u]/n.S[0].length*100)+"%"),s.push(m)}return{head:["Range"].concat(i?n.S.map(function(g,M){return t[M]||"Series "+(M+1)}):["Count","Share"]),rows:s}};function zt(r){var n=Math.floor(Math.log10(r)),t=+("1e"+n),i=r/t,e=i<1.4142?1:i<2.2361?2:i<3.5355?2.5:i<7.0711?5:10;return{w:e*t,dp:Math.max(0,e===10?-n-1:-n)+(e===2.5?1:0)}}function kt(r){var n=ft(r.values),t=[].concat.apply([],n);if(!t.length)return null;var i=Math.min.apply(null,t),e=Math.max.apply(null,t),s=B(r.binWidth,0),u,m;if(s>0&&(e-i)/s<=200){var g=String(r.binWidth),M=g.indexOf(".");u=M<0?0:Math.min(6,g.length-M-1)}else{var k=B(r.bins,0)>0?Math.round(B(r.bins,0)):Math.ceil(Math.log2(t.length)+1);k=Math.min(Math.max(k,1),50),m=zt(e>i?(e-i)/k:Math.abs(i)||1),s=m.w,u=m.dp}for(var w=Math.floor(i/s),p=function(R){return Number(((w+R)*s).toFixed(u+3))};p(0)>i;)w--;for(var v=Math.max(1,Math.ceil((e-p(0))/s));v>1&&p(v-1)>=e;)v--;for(;p(v)<e;)v++;var F=n.map(function(R){for(var E=[],W=0;W<v;W++)E.push(0);return R.forEach(function(O){for(var h=Math.min(v-1,Math.max(0,Math.floor((O-p(0))/s)));h>0&&O<p(h);)h--;for(;h<v-1&&O>=p(h+1);)h++;E[h]++}),E});return{S:n,edge:p,count:v,counts:F,dp:u}}function Et(r,n){var t=0;return r.counts.forEach(function(i){t+=i[n]}),t}function Tt(r){var n=0;return r.forEach(function(t){n+=t}),n/r.length}function At(r){var n=r.slice().sort(function(i,e){return i-e}),t=Math.floor(n.length/2);return n.length%2?n[t]:(n[t-1]+n[t])/2}dt("histogram",H);Mt("histogram");export{Rt as BezelChart,Ct as render,Nt as toSVG};
@@ -1,3 +1,3 @@
1
- /*! Bezel Charts v1.4.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
- import{a as ae,b as ie,c as le,d as se,e as oe}from"./shared-XBZ5QGIC.js";import{c as E,d as te,f as z,j as ne}from"./shared-APAAEWNX.js";import{B as j,C as ee,D as he,E as de,F as ve,G as re,c as N,e as f,g as T,j as w,k as Z,o as v,p as y,q as _,r as q,s as J,u as Q,v as R,w as U,x as W,z as $}from"./shared-4QPUIMAU.js";function g(e,s){var a=Z(e.values),M=w(e.series),x=w(e.labels),m=R(e,s),fe=T(e.height,170),u=Math.max.apply(null,[0].concat(a.map(function(o){return o.length}))),pe=W(e,x),G=a.length>1||M.length>0,me=$(a[0]||[],e,""),c=z(e.dash,Object.keys(E),"solid"),h=z(e.markers,te,"none"),b=e.background||s.tile,L=(c||h)&&le(m,c,h,b),A=function(o){return M[o]||"Series "+(o+1)};return j(e,s,fe,function(o,F,H,P){if(!u)return U(s,o,F,H,P);var V=[].concat.apply([],a),i=ae(e,s,{n:u,names:G?a.map(function(t,n){return A(n)}):null,pal:m,key:L,kw:L&&24,lo:Math.min.apply(null,V),hi:Math.max.apply(null,V),zero:v(e.zero),labels:x,notes:pe,tick:function(t){return y(t,e,!0)}},o,F,H,P),p=i.svg,S=i.X,O=i.Y,X=i.px,ue=i.pw,Y=i.top,B=i.ph;return a.forEach(function(t,n){var l=m[n%m.length],r=t.map(function(d,k){return[S(k),O(d)]});r.length===1&&(r=[[X,r[0][1]],[X+ue,r[0][1]]]);var C=_(r,v(e.straight));if(n===0){var D=N("g"),ce=r[r.length-1];p+='<defs><linearGradient id="'+D+'" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="'+l+'" stop-opacity=".26"/><stop offset="1" stop-color="'+l+'" stop-opacity="0"/></linearGradient></defs><path d="'+C+"L"+f(ce[0])+","+f(Y+B)+"L"+f(r[0][0])+","+f(Y+B)+'Z" fill="url(#'+D+')"'+Q(e,"bzc-a")+"/>"}var I=h?h(n):"none";if(p+=se(e,C,l,n,c?E[c(n)]:""),I!=="none")p+=oe(e,I,t,S,O,l,b,n);else{var K=r[r.length-1];p+='<circle cx="'+f(K[0])+'" cy="'+f(K[1])+'" r="4" fill="'+l+'" stroke="'+b+'" stroke-width="2"/>'}v(e.showValues)&&t.forEach(function(d,k){p+=q(S(k),O(d)-8,y(d,e,!0),J(s,9,'text-anchor="middle"'))})}),p+ie(e,s,i,u,function(t){var n=x[t]||"#"+(t+1);return a.forEach(function(l,r){t<l.length&&(n+=`
1
+ /*! Bezel Charts v1.6.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
+ import{a as ae,b as ie,c as le,d as se,e as oe}from"./shared-CYFOZG36.js";import{c as E,d as te,f as z,j as ne}from"./shared-56ZZ4O3F.js";import{B as j,C as ee,D as he,E as de,F as ve,G as re,c as N,e as f,g as T,j as w,k as Z,o as v,p as y,q as _,r as q,s as J,u as Q,v as R,w as U,x as W,z as $}from"./shared-YIDF72XF.js";function g(e,s){var a=Z(e.values),M=w(e.series),x=w(e.labels),m=R(e,s),fe=T(e.height,170),u=Math.max.apply(null,[0].concat(a.map(function(o){return o.length}))),pe=W(e,x),G=a.length>1||M.length>0,me=$(a[0]||[],e,""),c=z(e.dash,Object.keys(E),"solid"),h=z(e.markers,te,"none"),b=e.background||s.tile,L=(c||h)&&le(m,c,h,b),A=function(o){return M[o]||"Series "+(o+1)};return j(e,s,fe,function(o,F,H,P){if(!u)return U(s,o,F,H,P);var V=[].concat.apply([],a),i=ae(e,s,{n:u,names:G?a.map(function(t,n){return A(n)}):null,pal:m,key:L,kw:L&&24,lo:Math.min.apply(null,V),hi:Math.max.apply(null,V),zero:v(e.zero),labels:x,notes:pe,tick:function(t){return y(t,e,!0)}},o,F,H,P),p=i.svg,S=i.X,O=i.Y,X=i.px,ue=i.pw,Y=i.top,B=i.ph;return a.forEach(function(t,n){var l=m[n%m.length],r=t.map(function(d,k){return[S(k),O(d)]});r.length===1&&(r=[[X,r[0][1]],[X+ue,r[0][1]]]);var C=_(r,v(e.straight));if(n===0){var D=N("g"),ce=r[r.length-1];p+='<defs><linearGradient id="'+D+'" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="'+l+'" stop-opacity=".26"/><stop offset="1" stop-color="'+l+'" stop-opacity="0"/></linearGradient></defs><path d="'+C+"L"+f(ce[0])+","+f(Y+B)+"L"+f(r[0][0])+","+f(Y+B)+'Z" fill="url(#'+D+')"'+Q(e,"bzc-a")+"/>"}var I=h?h(n):"none";if(p+=se(e,C,l,n,c?E[c(n)]:""),I!=="none")p+=oe(e,I,t,S,O,l,b,n);else{var K=r[r.length-1];p+='<circle cx="'+f(K[0])+'" cy="'+f(K[1])+'" r="4" fill="'+l+'" stroke="'+b+'" stroke-width="2"/>'}v(e.showValues)&&t.forEach(function(d,k){p+=q(S(k),O(d)-8,y(d,e,!0),J(s,9,'text-anchor="middle"'))})}),p+ie(e,s,i,u,function(t){var n=x[t]||"#"+(t+1);return a.forEach(function(l,r){t<l.length&&(n+=`
3
3
  `+(G?A(r)+": ":"")+y(l[t],e))}),n})},{stat:me,summary:a.length+" series over "+u+" points"})}g.table=function(e){return ne(e)};ee("line",g);re("line");export{ve as BezelChart,he as render,de as toSVG};
@@ -1,2 +1,2 @@
1
- /*! Bezel Charts v1.4.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
- import{A as T,B as U,C as W,D as tr,E as ar,F as er,G as X,a as E,b as P,c as D,d as O,e as u,f as F,g as V,h as x,i as L,j as N,l as A,m as B,p as l,r as C,t as H,u as J,v as K,w as Q,z as R}from"./shared-4QPUIMAU.js";function z(r,e){var f=L(r.values).map(function(a){return Math.max(0,a)}),h=N(r.labels),m=K(r,e),o=f.length===1,g=A(f),t=x(r.max)?V(r.max,100):o?100:g;t>0||(t=1);var S=!x(r.prefix)&&!x(r.suffix)&&t===100&&o,k=function(a){return l(a,r)+(S?"%":"")},Y=T(r),Z=Y.w,b=0,G=[];if(!o&&f.length){var M=0;b=1,f.forEach(function(a,y){var i=h[y]||"#"+(y+1),w=14+B(i,12)+6+B(l(a,r),11,!0)+18;M>0&&M+w>Z&&(M=0,b++),G.push({x:M,row:b-1,l:i}),M+=w})}var _=36+(b?12+b*20:0),$=R(f,r,"");return U(r,e,_,function(a,y,i,w){if(!f.length)return Q(e,a,y,i,w);var n="",p=y+22,I=D("c"),rr=o?k(f[0])+(S?"":" of "+l(t,r)):l(g,r)+" of "+l(t,r);o&&h[0]&&(n+=C(a,y+11,h[0],'fill="'+e.fg+'" font-family="'+E+'" font-size="12"')),n+=C(a+i,y+11,rr,'text-anchor="end" fill="'+e.fg+'" font-family="'+P+'" font-size="11" font-weight="600"'),n+='<rect x="'+a+'" y="'+p+'" width="'+i+'" height="14" rx="7" fill="'+e.grid+'" fill-opacity=".7"/>',n+='<clipPath id="'+I+'"><rect x="'+a+'" y="'+p+'" width="'+i+'" height="14" rx="7"/></clipPath><g clip-path="url(#'+I+')"><g'+J(r,"bzc-gx")+">";var d=0;if(f.forEach(function(s,v){var c=Math.min(s,Math.max(0,t-d))/t*i;c>0&&(n+='<rect x="'+u(a+d/t*i)+'" y="'+p+'" width="'+u(c)+'" height="14" fill="'+m[v%m.length]+'"/>'),v>0&&c>0&&(n+='<rect x="'+u(a+d/t*i-1)+'" y="'+p+'" width="2" height="14" fill="'+(r.background||e.tile)+'"/>'),d+=s}),n+="</g></g>",x(r.goal)){var j=a+F(+r.goal/t,0,1)*i;n+='<line x1="'+u(j)+'" x2="'+u(j)+'" y1="'+(p-4)+'" y2="'+(p+18)+'" stroke="'+e.fg+'" stroke-width="2" stroke-linecap="round"/>'}return d=0,f.forEach(function(s,v){var c=Math.min(s,Math.max(0,t-d))/t*i;c>0&&(n+=H(a+d/t*i,p-4,c,22,(h[v]||(o?"Progress":"#"+(v+1)))+": "+k(s)+(o?"":" ("+Math.round(s/t*100)+"%)"))),d+=s}),G.forEach(function(s,v){var c=a+s.x,q=p+14+12+s.row*20+8;n+='<circle cx="'+u(c+4)+'" cy="'+u(q)+'" r="4" fill="'+m[v%m.length]+'"/><text x="'+u(c+14)+'" y="'+u(q+4)+'" fill="'+e.fg+'" font-family="'+E+'" font-size="12">'+O(s.l)+'<tspan dx="6" fill="'+e.muted+'" font-family="'+P+'" font-size="11">'+O(l(f[v],r))+"</tspan></text>"}),n},{stat:$,summary:o?k(f[0])+(S?"":" of "+l(t,r)):l(g,r)+" of "+l(t,r)})}z.table=function(r){var e=L(r.values).map(function(g){return Math.max(0,g)}),f=N(r.labels),h=e.length===1,m=x(r.max)?V(r.max,100):h?100:A(e);m>0||(m=1);var o=!x(r.prefix)&&!x(r.suffix)&&m===100&&h;return h?{head:["Label","Value"],rows:[[f[0]||"Progress",l(e[0],r)+(o?"%":" of "+l(m,r))]]}:{head:["Label","Value","Share"],rows:e.map(function(g,t){return[f[t]||"#"+(t+1),l(g,r),Math.round(g/m*100)+"%"]})}};W("progress",z);X("progress");export{er as BezelChart,tr as render,ar as toSVG};
1
+ /*! Bezel Charts v1.6.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
+ import{A as T,B as U,C as W,D as tr,E as ar,F as er,G as X,a as E,b as P,c as D,d as O,e as u,f as F,g as V,h as x,i as L,j as N,l as A,m as B,p as l,r as C,t as H,u as J,v as K,w as Q,z as R}from"./shared-YIDF72XF.js";function z(r,e){var f=L(r.values).map(function(a){return Math.max(0,a)}),h=N(r.labels),m=K(r,e),o=f.length===1,g=A(f),t=x(r.max)?V(r.max,100):o?100:g;t>0||(t=1);var S=!x(r.prefix)&&!x(r.suffix)&&t===100&&o,k=function(a){return l(a,r)+(S?"%":"")},Y=T(r),Z=Y.w,b=0,G=[];if(!o&&f.length){var M=0;b=1,f.forEach(function(a,y){var i=h[y]||"#"+(y+1),w=14+B(i,12)+6+B(l(a,r),11,!0)+18;M>0&&M+w>Z&&(M=0,b++),G.push({x:M,row:b-1,l:i}),M+=w})}var _=36+(b?12+b*20:0),$=R(f,r,"");return U(r,e,_,function(a,y,i,w){if(!f.length)return Q(e,a,y,i,w);var n="",p=y+22,I=D("c"),rr=o?k(f[0])+(S?"":" of "+l(t,r)):l(g,r)+" of "+l(t,r);o&&h[0]&&(n+=C(a,y+11,h[0],'fill="'+e.fg+'" font-family="'+E+'" font-size="12"')),n+=C(a+i,y+11,rr,'text-anchor="end" fill="'+e.fg+'" font-family="'+P+'" font-size="11" font-weight="600"'),n+='<rect x="'+a+'" y="'+p+'" width="'+i+'" height="14" rx="7" fill="'+e.grid+'" fill-opacity=".7"/>',n+='<clipPath id="'+I+'"><rect x="'+a+'" y="'+p+'" width="'+i+'" height="14" rx="7"/></clipPath><g clip-path="url(#'+I+')"><g'+J(r,"bzc-gx")+">";var d=0;if(f.forEach(function(s,v){var c=Math.min(s,Math.max(0,t-d))/t*i;c>0&&(n+='<rect x="'+u(a+d/t*i)+'" y="'+p+'" width="'+u(c)+'" height="14" fill="'+m[v%m.length]+'"/>'),v>0&&c>0&&(n+='<rect x="'+u(a+d/t*i-1)+'" y="'+p+'" width="2" height="14" fill="'+(r.background||e.tile)+'"/>'),d+=s}),n+="</g></g>",x(r.goal)){var j=a+F(+r.goal/t,0,1)*i;n+='<line x1="'+u(j)+'" x2="'+u(j)+'" y1="'+(p-4)+'" y2="'+(p+18)+'" stroke="'+e.fg+'" stroke-width="2" stroke-linecap="round"/>'}return d=0,f.forEach(function(s,v){var c=Math.min(s,Math.max(0,t-d))/t*i;c>0&&(n+=H(a+d/t*i,p-4,c,22,(h[v]||(o?"Progress":"#"+(v+1)))+": "+k(s)+(o?"":" ("+Math.round(s/t*100)+"%)"))),d+=s}),G.forEach(function(s,v){var c=a+s.x,q=p+14+12+s.row*20+8;n+='<circle cx="'+u(c+4)+'" cy="'+u(q)+'" r="4" fill="'+m[v%m.length]+'"/><text x="'+u(c+14)+'" y="'+u(q+4)+'" fill="'+e.fg+'" font-family="'+E+'" font-size="12">'+O(s.l)+'<tspan dx="6" fill="'+e.muted+'" font-family="'+P+'" font-size="11">'+O(l(f[v],r))+"</tspan></text>"}),n},{stat:$,summary:o?k(f[0])+(S?"":" of "+l(t,r)):l(g,r)+" of "+l(t,r)})}z.table=function(r){var e=L(r.values).map(function(g){return Math.max(0,g)}),f=N(r.labels),h=e.length===1,m=x(r.max)?V(r.max,100):h?100:A(e);m>0||(m=1);var o=!x(r.prefix)&&!x(r.suffix)&&m===100&&h;return h?{head:["Label","Value"],rows:[[f[0]||"Progress",l(e[0],r)+(o?"%":" of "+l(m,r))]]}:{head:["Label","Value","Share"],rows:e.map(function(g,t){return[f[t]||"#"+(t+1),l(g,r),Math.round(g/m*100)+"%"]})}};W("progress",z);X("progress");export{er as BezelChart,tr as render,ar as toSVG};
@@ -1,2 +1,2 @@
1
- /*! Bezel Charts v1.4.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
- import{B as P,C as Q,D as Y,E as Z,F as _,G as R,a as N,b as q,d as w,e as r,f as V,g as S,h as d,i as j,j as A,n as D,p as y,r as x,s as F,v as I,w as J,z as K}from"./shared-4QPUIMAU.js";function O(t,i){var e=j(t.values),l=A(t.labels),u=I(t,i),p=S(t.max,100)||100,T=S(t.height,140),B=!d(t.prefix)&&!d(t.suffix)&&p===100,b=function(a){return y(a,t)+(B?"%":"")},U=K(e,t,"");return P(t,i,T,function(a,v,h,k){if(!e.length)return J(i,a,v,h,k);var c="",z=e.length===1,f=Math.min(k,z?h:h*.55),g=z?a+h/2:a+f/2,o=v+k/2,m=z?f*.12:V(f*.42/(e.length*1.35),5,16),W=m*.38;if(e.forEach(function(M,n){var s=f/2-m/2-n*(m+W);if(!(s<=m/2)){var C=V(M/p*100,0,100),G=u[n%u.length];c+='<circle cx="'+r(g)+'" cy="'+r(o)+'" r="'+r(s)+'" fill="none" stroke="'+G+'" stroke-opacity=".16" stroke-width="'+r(m)+'"/>',C>0&&(c+='<circle cx="'+r(g)+'" cy="'+r(o)+'" r="'+r(s)+'" fill="none" stroke="'+G+'" stroke-width="'+r(m)+'" stroke-linecap="round" pathLength="100" transform="rotate(-90 '+r(g)+" "+r(o)+')" style="stroke-dasharray:'+r(C)+" 100"+(t.animate?";animation-delay:"+n*.12+"s":"")+'"'+(t.animate?' class="bzc-s"':"")+"/>"),c+='<circle cx="'+r(g)+'" cy="'+r(o)+'" r="'+r(s+m/2)+'" fill="#000" fill-opacity="0" class="bzc-hit" data-tip="'+w((l[n]||"#"+(n+1))+": "+b(M)+(B?"":" of "+y(p,t)))+'"/>'}}),z)c+=x(g,o+f*.08,b(e[0]),'text-anchor="middle" fill="'+i.fg+'" font-family="'+N+'" font-size="'+r(f*.22)+'" font-weight="800"'),l[0]&&(c+=x(g,o+f*.08+16,l[0],F(i,10,'text-anchor="middle"')));else{var E=a+f+22,L=Math.min(26,k/e.length),X=o-L*e.length/2;e.forEach(function(M,n){var s=X+n*L+L/2;c+='<circle cx="'+r(E+4)+'" cy="'+r(s)+'" r="4" fill="'+u[n%u.length]+'"/>'+x(E+14,s+4,D(l[n]||"#"+(n+1),Math.floor((a+h-E-60)/6.7)),'fill="'+i.fg+'" font-family="'+N+'" font-size="12"')+x(a+h,s+4,b(M),'text-anchor="end" fill="'+i.fg+'" font-family="'+q+'" font-size="11" font-weight="600"')})}return c},{stat:U,summary:e.map(function(a,v){return(l[v]?l[v]+" ":"")+b(a)}).join(", ")})}O.table=function(t){var i=A(t.labels),e=S(t.max,100)||100,l=!d(t.prefix)&&!d(t.suffix)&&e===100;return{head:["Label","Value"],rows:j(t.values).map(function(u,p){return[i[p]||"#"+(p+1),y(u,t)+(l?"%":" of "+y(e,t))]})}};Q("ring",O);R("ring");export{_ as BezelChart,Y as render,Z as toSVG};
1
+ /*! Bezel Charts v1.6.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
+ import{B as P,C as Q,D as Y,E as Z,F as _,G as R,a as N,b as q,d as w,e as r,f as V,g as S,h as d,i as j,j as A,n as D,p as y,r as x,s as F,v as I,w as J,z as K}from"./shared-YIDF72XF.js";function O(t,i){var e=j(t.values),l=A(t.labels),u=I(t,i),p=S(t.max,100)||100,T=S(t.height,140),B=!d(t.prefix)&&!d(t.suffix)&&p===100,b=function(a){return y(a,t)+(B?"%":"")},U=K(e,t,"");return P(t,i,T,function(a,v,h,k){if(!e.length)return J(i,a,v,h,k);var c="",z=e.length===1,f=Math.min(k,z?h:h*.55),g=z?a+h/2:a+f/2,o=v+k/2,m=z?f*.12:V(f*.42/(e.length*1.35),5,16),W=m*.38;if(e.forEach(function(M,n){var s=f/2-m/2-n*(m+W);if(!(s<=m/2)){var C=V(M/p*100,0,100),G=u[n%u.length];c+='<circle cx="'+r(g)+'" cy="'+r(o)+'" r="'+r(s)+'" fill="none" stroke="'+G+'" stroke-opacity=".16" stroke-width="'+r(m)+'"/>',C>0&&(c+='<circle cx="'+r(g)+'" cy="'+r(o)+'" r="'+r(s)+'" fill="none" stroke="'+G+'" stroke-width="'+r(m)+'" stroke-linecap="round" pathLength="100" transform="rotate(-90 '+r(g)+" "+r(o)+')" style="stroke-dasharray:'+r(C)+" 100"+(t.animate?";animation-delay:"+n*.12+"s":"")+'"'+(t.animate?' class="bzc-s"':"")+"/>"),c+='<circle cx="'+r(g)+'" cy="'+r(o)+'" r="'+r(s+m/2)+'" fill="#000" fill-opacity="0" class="bzc-hit" data-tip="'+w((l[n]||"#"+(n+1))+": "+b(M)+(B?"":" of "+y(p,t)))+'"/>'}}),z)c+=x(g,o+f*.08,b(e[0]),'text-anchor="middle" fill="'+i.fg+'" font-family="'+N+'" font-size="'+r(f*.22)+'" font-weight="800"'),l[0]&&(c+=x(g,o+f*.08+16,l[0],F(i,10,'text-anchor="middle"')));else{var E=a+f+22,L=Math.min(26,k/e.length),X=o-L*e.length/2;e.forEach(function(M,n){var s=X+n*L+L/2;c+='<circle cx="'+r(E+4)+'" cy="'+r(s)+'" r="4" fill="'+u[n%u.length]+'"/>'+x(E+14,s+4,D(l[n]||"#"+(n+1),Math.floor((a+h-E-60)/6.7)),'fill="'+i.fg+'" font-family="'+N+'" font-size="12"')+x(a+h,s+4,b(M),'text-anchor="end" fill="'+i.fg+'" font-family="'+q+'" font-size="11" font-weight="600"')})}return c},{stat:U,summary:e.map(function(a,v){return(l[v]?l[v]+" ":"")+b(a)}).join(", ")})}O.table=function(t){var i=A(t.labels),e=S(t.max,100)||100,l=!d(t.prefix)&&!d(t.suffix)&&e===100;return{head:["Label","Value"],rows:j(t.values).map(function(u,p){return[i[p]||"#"+(p+1),y(u,t)+(l?"%":" of "+y(e,t))]})}};Q("ring",O);R("ring");export{_ as BezelChart,Y as render,Z as toSVG};
@@ -1,5 +1,5 @@
1
- /*! Bezel Charts v1.4.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
- import{a as T,b as va,d as da,f as ga,g as U,i as ba}from"./shared-APAAEWNX.js";import{B as ha,C as xa,D as Oa,E as Pa,F as za,G as ya,e as n,f as F,g as oa,h as x,j as H,k as N,o as R,p as E,r as P,s as w,t as sa,v as fa,w as ua,x as ma,y as pa}from"./shared-4QPUIMAU.js";function Xa(a,r){var y=Math.min(a.length,r.length);if(y<2)return null;var u=0,h=0,e;for(e=0;e<y;e++)u+=a[e],h+=r[e];u/=y,h/=y;var f=0,l=0,m=0;for(e=0;e<y;e++)f+=(a[e]-u)*(a[e]-u),l+=(r[e]-h)*(r[e]-h),m+=(a[e]-u)*(r[e]-h);if(!f)return null;var b=m/f;return{slope:b,intercept:h-b*u,r:l?m/Math.sqrt(f*l):0}}function I(a,r){for(var y=N(a.x),u=N(a.y),h=H(a.series),e=H(a.labels),f=fa(a,r),l=[],m=0;m<Math.max(y.length,u.length);m++){var b=y[m]||[],S=u[m]||[],z=Math.min(b.length,S.length);l.push({xs:b.slice(0,z),ys:S.slice(0,z)})}l=l.filter(function(o){return o.xs.length});var k=l.reduce(function(o,v){return o+v.xs.length},0),ka=oa(a.height,210),J=l.length>1||h.length>0,Ma=R(a.trend),Z=function(o){return h[o]||"Group "+(o+1)},$={decimals:a.decimals,compact:a.compact,lang:a.lang},La=ma(a,e),K=ga(a.markers,da,"circle"),Ea=a.background||r.tile,j=function(o){var v=K?K(o):"circle";return v==="none"?"circle":v},wa=K&&function(o,v,X){return U(j(o),v+4,X+6,4,' fill="'+f[o%f.length]+'"')};return ha(a,r,ka,function(o,v,X,aa){if(!k)return ua(r,o,v,X,aa);var p="",s=v;if(J){var ta=va(l.map(function(t,i){return Z(i)}),f,r,o,s,X,wa);p+=ta.svg,s+=ta.height}var ra=[].concat.apply([],l.map(function(t){return t.xs})),ea=[].concat.apply([],l.map(function(t){return t.ys})),Y=Math.min.apply(null,ea),q=Math.max.apply(null,ea);x(a.goal)&&(Y=Math.min(Y,+a.goal),q=Math.max(q,+a.goal)),R(a.zero)&&(Y=Math.min(0,Y),q=Math.max(0,q));var W=T(Y,q,4),A=T(Math.min.apply(null,ra),Math.max.apply(null,ra),5),na=W.ticks.map(function(t){return E(t,a,!0)}),la=ba(na)+(x(a.yLabel)?14:0),Sa=20+(x(a.xLabel)?16:0),d=o+la,M=X-la,g=aa-(s-v)-Sa,G=function(t){return d+6+(t-A.lo)/(A.hi-A.lo)*(M-12)},L=function(t){return s+6+g-6-(t-W.lo)/(W.hi-W.lo)*(g-6)};W.ticks.forEach(function(t,i){var c=L(t);p+='<line x1="'+n(d)+'" x2="'+n(d+M)+'" y1="'+n(c)+'" y2="'+n(c)+'" stroke="'+r.grid+'" stroke-dasharray="2 4"/>'+P(d-8,c+3.5,na[i],w(r,10,'text-anchor="end"'))});var Ga=Math.max(1,Math.ceil(A.ticks.length*44/M));if(A.ticks.forEach(function(t,i){if(!(i%Ga)){var c=G(t);p+='<line x1="'+n(c)+'" x2="'+n(c)+'" y1="'+n(s)+'" y2="'+n(s+g)+'" stroke="'+r.grid+'" stroke-dasharray="2 4"/>'+P(c,s+g+15,E(t,$,!0),w(r,10,'text-anchor="middle"'))}}),x(a.xLabel)&&(p+=P(d+M/2,s+g+32,a.xLabel,w(r,10,'text-anchor="middle" font-weight="600"'))),x(a.yLabel)){var ia=s+g/2;p+='<text x="'+n(o+4)+'" y="'+n(ia)+'" transform="rotate(-90 '+n(o+4)+" "+n(ia)+')" text-anchor="middle" '+w(r,10,'font-weight="600"')+' dominant-baseline="hanging">'+String(a.yLabel).replace(/[&<>"]/g,function(t){return{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[t]})+"</text>"}x(a.goal)&&(p+=pa(a,r,d,d+M,L(+a.goal))),Ma&&l.forEach(function(t,i){var c=Xa(t.xs,t.ys);if(c){var B=Math.min.apply(null,t.xs),O=Math.max.apply(null,t.xs),_=c.slope*B+c.intercept,C=c.slope*O+c.intercept,D=f[i%f.length];p+='<line x1="'+n(G(B))+'" y1="'+n(F(L(_),s,s+g))+'" x2="'+n(G(O))+'" y2="'+n(F(L(C),s,s+g))+'" stroke="'+D+'" stroke-width="2" stroke-dasharray="6 4" stroke-linecap="round" stroke-opacity=".9"/>',p+=P(Math.min(G(O),d+M)-2,F(L(C),s+10,s+g)-7,"r = "+c.r.toFixed(2),w(r,10,'text-anchor="end" font-weight="600"',D))}});var V=0,Q=k>150?3:4.5;l.forEach(function(t,i){var c=f[i%f.length];t.xs.forEach(function(B,O){var _=G(B),C=L(t.ys[O]),D=(e[V]?e[V]+`
1
+ /*! Bezel Charts v1.6.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
+ import{a as T,b as va,d as da,f as ga,g as U,i as ba}from"./shared-56ZZ4O3F.js";import{B as ha,C as xa,D as Oa,E as Pa,F as za,G as ya,e as n,f as F,g as oa,h as x,j as H,k as N,o as R,p as E,r as P,s as w,t as sa,v as fa,w as ua,x as ma,y as pa}from"./shared-YIDF72XF.js";function Xa(a,r){var y=Math.min(a.length,r.length);if(y<2)return null;var u=0,h=0,e;for(e=0;e<y;e++)u+=a[e],h+=r[e];u/=y,h/=y;var f=0,l=0,m=0;for(e=0;e<y;e++)f+=(a[e]-u)*(a[e]-u),l+=(r[e]-h)*(r[e]-h),m+=(a[e]-u)*(r[e]-h);if(!f)return null;var b=m/f;return{slope:b,intercept:h-b*u,r:l?m/Math.sqrt(f*l):0}}function I(a,r){for(var y=N(a.x),u=N(a.y),h=H(a.series),e=H(a.labels),f=fa(a,r),l=[],m=0;m<Math.max(y.length,u.length);m++){var b=y[m]||[],S=u[m]||[],z=Math.min(b.length,S.length);l.push({xs:b.slice(0,z),ys:S.slice(0,z)})}l=l.filter(function(o){return o.xs.length});var k=l.reduce(function(o,v){return o+v.xs.length},0),ka=oa(a.height,210),J=l.length>1||h.length>0,Ma=R(a.trend),Z=function(o){return h[o]||"Group "+(o+1)},$={decimals:a.decimals,compact:a.compact,lang:a.lang},La=ma(a,e),K=ga(a.markers,da,"circle"),Ea=a.background||r.tile,j=function(o){var v=K?K(o):"circle";return v==="none"?"circle":v},wa=K&&function(o,v,X){return U(j(o),v+4,X+6,4,' fill="'+f[o%f.length]+'"')};return ha(a,r,ka,function(o,v,X,aa){if(!k)return ua(r,o,v,X,aa);var p="",s=v;if(J){var ta=va(l.map(function(t,i){return Z(i)}),f,r,o,s,X,wa);p+=ta.svg,s+=ta.height}var ra=[].concat.apply([],l.map(function(t){return t.xs})),ea=[].concat.apply([],l.map(function(t){return t.ys})),Y=Math.min.apply(null,ea),q=Math.max.apply(null,ea);x(a.goal)&&(Y=Math.min(Y,+a.goal),q=Math.max(q,+a.goal)),R(a.zero)&&(Y=Math.min(0,Y),q=Math.max(0,q));var W=T(Y,q,4),A=T(Math.min.apply(null,ra),Math.max.apply(null,ra),5),na=W.ticks.map(function(t){return E(t,a,!0)}),la=ba(na)+(x(a.yLabel)?14:0),Sa=20+(x(a.xLabel)?16:0),d=o+la,M=X-la,g=aa-(s-v)-Sa,G=function(t){return d+6+(t-A.lo)/(A.hi-A.lo)*(M-12)},L=function(t){return s+6+g-6-(t-W.lo)/(W.hi-W.lo)*(g-6)};W.ticks.forEach(function(t,i){var c=L(t);p+='<line x1="'+n(d)+'" x2="'+n(d+M)+'" y1="'+n(c)+'" y2="'+n(c)+'" stroke="'+r.grid+'" stroke-dasharray="2 4"/>'+P(d-8,c+3.5,na[i],w(r,10,'text-anchor="end"'))});var Ga=Math.max(1,Math.ceil(A.ticks.length*44/M));if(A.ticks.forEach(function(t,i){if(!(i%Ga)){var c=G(t);p+='<line x1="'+n(c)+'" x2="'+n(c)+'" y1="'+n(s)+'" y2="'+n(s+g)+'" stroke="'+r.grid+'" stroke-dasharray="2 4"/>'+P(c,s+g+15,E(t,$,!0),w(r,10,'text-anchor="middle"'))}}),x(a.xLabel)&&(p+=P(d+M/2,s+g+32,a.xLabel,w(r,10,'text-anchor="middle" font-weight="600"'))),x(a.yLabel)){var ia=s+g/2;p+='<text x="'+n(o+4)+'" y="'+n(ia)+'" transform="rotate(-90 '+n(o+4)+" "+n(ia)+')" text-anchor="middle" '+w(r,10,'font-weight="600"')+' dominant-baseline="hanging">'+String(a.yLabel).replace(/[&<>"]/g,function(t){return{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[t]})+"</text>"}x(a.goal)&&(p+=pa(a,r,d,d+M,L(+a.goal))),Ma&&l.forEach(function(t,i){var c=Xa(t.xs,t.ys);if(c){var B=Math.min.apply(null,t.xs),O=Math.max.apply(null,t.xs),_=c.slope*B+c.intercept,C=c.slope*O+c.intercept,D=f[i%f.length];p+='<line x1="'+n(G(B))+'" y1="'+n(F(L(_),s,s+g))+'" x2="'+n(G(O))+'" y2="'+n(F(L(C),s,s+g))+'" stroke="'+D+'" stroke-width="2" stroke-dasharray="6 4" stroke-linecap="round" stroke-opacity=".9"/>',p+=P(Math.min(G(O),d+M)-2,F(L(C),s+10,s+g)-7,"r = "+c.r.toFixed(2),w(r,10,'text-anchor="end" font-weight="600"',D))}});var V=0,Q=k>150?3:4.5;l.forEach(function(t,i){var c=f[i%f.length];t.xs.forEach(function(B,O){var _=G(B),C=L(t.ys[O]),D=(e[V]?e[V]+`
3
3
  `:J?Z(i)+`
4
4
  `:"")+(x(a.xLabel)?a.xLabel:"x")+": "+E(B,$)+`
5
5
  `+(x(a.yLabel)?a.yLabel:"y")+": "+E(t.ys[O],a);p+=U(j(i),_,C,Q,' fill="'+c+'" fill-opacity=".85" stroke="'+Ea+'" stroke-width="1.5"'+(a.animate?' class="bzc-a" style="animation-delay:'+n(Math.min(.8,V*.012))+'s"':"")),p+=sa(_-8,C-8,16,16,D),V++})});var ca=[];return l.forEach(function(t){t.xs.forEach(function(i,c){ca.push([G(i),L(t.ys[c])])})}),La.forEach(function(t){var i=ca[t.i];i&&(p+='<circle cx="'+n(i[0])+'" cy="'+n(i[1])+'" r="'+(Q+4)+'" fill="none" stroke="'+r.fg+'" stroke-width="1.5"/>'+P(F(i[0],d+30,d+M-30),i[1]-Q-9,t.text,w(r,10,'text-anchor="middle"',r.fg)))}),p},{summary:k+" points"+(J?" in "+l.length+" groups":"")})}I.table=function(a){var r=N(a.x),y=N(a.y),u=H(a.series),h=H(a.labels),e=r.length>1||u.length>0,f={decimals:a.decimals,compact:a.compact,lang:a.lang},l=[],m=0;return r.forEach(function(b,S){for(var z=y[S]||[],k=0;k<Math.min(b.length,z.length);k++,m++)l.push([h[m]||"#"+(m+1)].concat(e?[u[S]||"Group "+(S+1)]:[],[E(b[k],f),E(z[k],a)]))}),{head:["Point"].concat(e?["Group"]:[],[x(a.xLabel)?a.xLabel:"x",x(a.yLabel)?a.yLabel:"y"]),rows:l}};xa("scatter",I);ya("scatter");export{za as BezelChart,Oa as render,Pa as toSVG};
@@ -1,2 +1,2 @@
1
- /*! Bezel Charts v1.4.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
- import{a as w,e,j as d,k as x,m as g,p as v,r as L}from"./shared-4QPUIMAU.js";function m(r,t,a){if(r===t)if(r===0)t=1;else{var n=Math.abs(r)*.1;r-=n,t+=n}for(var l=(t-r)/(a||4),i=Math.pow(10,Math.floor(Math.log10(l))),u=l/i,o=(u<=1?1:u<=2?2:u<=5?5:10)*i,f=Math.floor(r/o)*o,h=Math.ceil(t/o)*o,s=[],c=f;c<=h+o/2;c+=o)s.push(+c.toFixed(10));return{lo:f,hi:h,ticks:s}}function E(r,t,a,n,l,i,u,o){var f=n,h=l,s="",c=o||13;return r.forEach(function(p,M){var S=c+g(p,12)+16;f>n&&f+S-16>n+i&&(f=n,h+=20),s+=(u?u(M,f,h):'<circle cx="'+e(f+4)+'" cy="'+e(h+6)+'" r="4" fill="'+t[M%t.length]+'"/>')+L(f+c,h+10,p,'fill="'+a.fg+'" font-family="'+w+'" font-size="12"'),f+=S}),{svg:s,height:h-l+24}}var T={solid:"",dashed:"7 5",dotted:"1 5",dashdot:"9 4 1 4"},A=["circle","square","triangle","diamond"],H=["solid","stripes","dots","grid"];function O(r,t,a){if(r==null||r===!1||r==="none"||r==="false")return null;var n=r===!0||r===""||r==="auto"?t:d(r).map(function(l){return t.indexOf(l)<0?a:l});return n.length?function(l){return n[l%n.length]}:null}function q(r,t,a,n,l){var i=n*1.15,u=n*.85;return r==="square"?'<rect x="'+e(t-u)+'" y="'+e(a-u)+'" width="'+e(2*u)+'" height="'+e(2*u)+'" rx="1"'+l+"/>":r==="triangle"?'<path d="M'+e(t)+","+e(a-i)+"L"+e(t+i)+","+e(a+u)+"L"+e(t-i)+","+e(a+u)+'Z"'+l+"/>":r==="diamond"?'<path d="M'+e(t)+","+e(a-i*1.1)+"L"+e(t+i)+","+e(a)+"L"+e(t)+","+e(a+i*1.1)+"L"+e(t-i)+","+e(a)+'Z"'+l+"/>":'<circle cx="'+e(t)+'" cy="'+e(a)+'" r="'+e(n)+'"'+l+"/>"}function N(r,t,a,n){var l=' stroke="'+n+'" stroke-opacity=".55" stroke-width="1.5"';return'<pattern id="'+r+'" width="6" height="6" patternUnits="userSpaceOnUse"'+(t==="dots"?"":' patternTransform="rotate(45)"')+'><rect width="6" height="6" fill="'+a+'"/>'+(t==="dots"?'<circle cx="3" cy="3" r="1.3" fill="'+n+'" fill-opacity=".55"/>':'<path d="M3,0V6'+(t==="grid"?"M0,3H6":"")+'"'+l+"/>")+"</pattern>"}function P(r){return Math.max.apply(null,r.map(function(t){return g(t,10,!0)}))+10}function U(r,t){for(var a=x(r.values),n=d(r.series),l=d(r.labels),i=[],u=Math.max.apply(null,[0].concat(a.map(function(c){return c.length}))),o=0;o<u;o++){var f=[l[o]||"#"+(o+1)],h=0;a.forEach(function(c){f.push(o<c.length?v(c[o],r):""),h+=o<c.length?c[o]:0}),t&&f.push(v(h,r)),i.push(f)}var s=a.length>1||n.length?a.map(function(c,p){return n[p]||"Series "+(p+1)}):["Value"];return{head:["Label"].concat(s,t?["Total"]:[]),rows:i}}export{m as a,E as b,T as c,A as d,H as e,O as f,q as g,N as h,P as i,U as j};
1
+ /*! Bezel Charts v1.6.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
+ import{a as w,e,j as d,k as x,m as g,p as v,r as L}from"./shared-YIDF72XF.js";function m(r,t,a){if(r===t)if(r===0)t=1;else{var n=Math.abs(r)*.1;r-=n,t+=n}for(var l=(t-r)/(a||4),i=Math.pow(10,Math.floor(Math.log10(l))),u=l/i,o=(u<=1?1:u<=2?2:u<=5?5:10)*i,f=Math.floor(r/o)*o,h=Math.ceil(t/o)*o,s=[],c=f;c<=h+o/2;c+=o)s.push(+c.toFixed(10));return{lo:f,hi:h,ticks:s}}function E(r,t,a,n,l,i,u,o){var f=n,h=l,s="",c=o||13;return r.forEach(function(p,M){var S=c+g(p,12)+16;f>n&&f+S-16>n+i&&(f=n,h+=20),s+=(u?u(M,f,h):'<circle cx="'+e(f+4)+'" cy="'+e(h+6)+'" r="4" fill="'+t[M%t.length]+'"/>')+L(f+c,h+10,p,'fill="'+a.fg+'" font-family="'+w+'" font-size="12"'),f+=S}),{svg:s,height:h-l+24}}var T={solid:"",dashed:"7 5",dotted:"1 5",dashdot:"9 4 1 4"},A=["circle","square","triangle","diamond"],H=["solid","stripes","dots","grid"];function O(r,t,a){if(r==null||r===!1||r==="none"||r==="false")return null;var n=r===!0||r===""||r==="auto"?t:d(r).map(function(l){return t.indexOf(l)<0?a:l});return n.length?function(l){return n[l%n.length]}:null}function q(r,t,a,n,l){var i=n*1.15,u=n*.85;return r==="square"?'<rect x="'+e(t-u)+'" y="'+e(a-u)+'" width="'+e(2*u)+'" height="'+e(2*u)+'" rx="1"'+l+"/>":r==="triangle"?'<path d="M'+e(t)+","+e(a-i)+"L"+e(t+i)+","+e(a+u)+"L"+e(t-i)+","+e(a+u)+'Z"'+l+"/>":r==="diamond"?'<path d="M'+e(t)+","+e(a-i*1.1)+"L"+e(t+i)+","+e(a)+"L"+e(t)+","+e(a+i*1.1)+"L"+e(t-i)+","+e(a)+'Z"'+l+"/>":'<circle cx="'+e(t)+'" cy="'+e(a)+'" r="'+e(n)+'"'+l+"/>"}function N(r,t,a,n){var l=' stroke="'+n+'" stroke-opacity=".55" stroke-width="1.5"';return'<pattern id="'+r+'" width="6" height="6" patternUnits="userSpaceOnUse"'+(t==="dots"?"":' patternTransform="rotate(45)"')+'><rect width="6" height="6" fill="'+a+'"/>'+(t==="dots"?'<circle cx="3" cy="3" r="1.3" fill="'+n+'" fill-opacity=".55"/>':'<path d="M3,0V6'+(t==="grid"?"M0,3H6":"")+'"'+l+"/>")+"</pattern>"}function P(r){return Math.max.apply(null,r.map(function(t){return g(t,10,!0)}))+10}function U(r,t){for(var a=x(r.values),n=d(r.series),l=d(r.labels),i=[],u=Math.max.apply(null,[0].concat(a.map(function(c){return c.length}))),o=0;o<u;o++){var f=[l[o]||"#"+(o+1)],h=0;a.forEach(function(c){f.push(o<c.length?v(c[o],r):""),h+=o<c.length?c[o]:0}),t&&f.push(v(h,r)),i.push(f)}var s=a.length>1||n.length?a.map(function(c,p){return n[p]||"Series "+(p+1)}):["Value"];return{head:["Label"].concat(s,t?["Total"]:[]),rows:i}}export{m as a,E as b,T as c,A as d,H as e,O as f,q as g,N as h,P as i,U as j};
@@ -1,2 +1,2 @@
1
- /*! Bezel Charts v1.4.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
- import{a as q,b as B,c as C,g as Y}from"./shared-APAAEWNX.js";import{e as p,f as H,h as L,m as S,r as M,s as b,t as K,u as X,y as W}from"./shared-4QPUIMAU.js";function Q(e,t,r,i,l,h,u){var a="",n=l,s=r.n,k=r.labels;if(r.names){var c=B(r.names,r.pal,t,i,n,h,r.key,r.kw);a+=c.svg,n+=c.height}var f=r.lo,v=r.hi;L(e.goal)&&(f=Math.min(f,+e.goal),v=Math.max(v,+e.goal)),r.zero&&(f=Math.min(0,f),v=Math.max(0,v));var g=q(f,v,4),F=g.ticks.map(r.tick),A=Math.max.apply(null,F.map(function(o){return S(o,10,!0)}))+10,G=k.length?20:4,m=i+A,d=h-A,y=u-(n-l)-G,z=function(o){return s===1?m+d/2:m+o*d/(s-1)},D=function(o){return n+y-(o-g.lo)/(g.hi-g.lo)*y};if(g.ticks.forEach(function(o,w){var E=D(o);a+='<line x1="'+p(m)+'" x2="'+p(m+d)+'" y1="'+p(E)+'" y2="'+p(E)+'" stroke="'+t.grid+'"'+(o===0?"":' stroke-dasharray="2 4"')+"/>"+M(m-8,E+3.5,F[w],b(t,10,'text-anchor="end"'))}),k.length){for(var I=Math.max(1,Math.ceil(s*(Math.max.apply(null,k.map(function(o){return S(o,10,!0)}))+10)/d)),x=0;x<s;x+=I)if(k[x]!=null){var J=s>1&&x===0?"start":s>1&&x===s-1?"end":"middle";a+=M(z(x),n+y+15,k[x],b(t,10,'text-anchor="'+J+'"'))}}return r.notes.forEach(function(o){if(!(o.i>=s)){var w=z(o.i);a+='<line x1="'+p(w)+'" x2="'+p(w)+'" y1="'+p(n+12)+'" y2="'+p(n+y)+'" stroke="'+t.fg+'" stroke-opacity=".4" stroke-dasharray="3 3"/>'+M(H(w,m+30,m+d-30),n+8,o.text,b(t,10,'text-anchor="middle"',t.fg))}}),{svg:a,X:z,Y:D,px:m,pw:d,top:n,ph:y}}function R(e,t,r,i,l){for(var h=L(e.goal)?W(e,t,r.px,r.px+r.pw,r.Y(+e.goal)):"",u=i>1?r.pw/(i-1):r.pw,a=0;a<i;a++)h+=K(r.X(a)-u/2,r.top,u,r.ph,l(a));return h}function T(e,t,r,i){return function(l,h,u){var a=e[l%e.length],n=t?C[t(l)]:"",s=r?r(l):"none";return'<line x1="'+p(h)+'" x2="'+p(h+18)+'" y1="'+p(u+6)+'" y2="'+p(u+6)+'" stroke="'+a+'" stroke-width="2.5" stroke-linecap="round"'+(n?' stroke-dasharray="'+n+'"':"")+"/>"+(s!=="none"?Y(s,h+9,u+6,3.5,' fill="'+a+'" stroke="'+i+'" stroke-width="1.5"'):"")}}function U(e,t,r,i,l){return l?'<path d="'+t+'" fill="none" stroke="'+r+'" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="'+l+'"'+X(e,"bzc-a",i*.15)+"/>":'<path d="'+t+'" fill="none" stroke="'+r+'" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" pathLength="1" style="stroke-dasharray:1'+(e.animate?";animation-delay:"+i*.15+"s":"")+'"'+(e.animate?' class="bzc-d"':"")+"/>"}function V(e,t,r,i,l,h,u,a){var n="",s=Math.ceil(r.length/40);return r.forEach(function(k,c){(c%s===0||c===r.length-1)&&(n+=Y(t,i(c),l(k),3.5,' fill="'+h+'" stroke="'+u+'" stroke-width="1.5"'+X(e,"bzc-a",.6+a*.15)))}),n}export{Q as a,R as b,T as c,U as d,V as e};
1
+ /*! Bezel Charts v1.6.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
+ import{a as q,b as B,c as C,g as Y}from"./shared-56ZZ4O3F.js";import{e as p,f as H,h as L,m as S,r as M,s as b,t as K,u as X,y as W}from"./shared-YIDF72XF.js";function Q(e,t,r,i,l,h,u){var a="",n=l,s=r.n,k=r.labels;if(r.names){var c=B(r.names,r.pal,t,i,n,h,r.key,r.kw);a+=c.svg,n+=c.height}var f=r.lo,v=r.hi;L(e.goal)&&(f=Math.min(f,+e.goal),v=Math.max(v,+e.goal)),r.zero&&(f=Math.min(0,f),v=Math.max(0,v));var g=q(f,v,4),F=g.ticks.map(r.tick),A=Math.max.apply(null,F.map(function(o){return S(o,10,!0)}))+10,G=k.length?20:4,m=i+A,d=h-A,y=u-(n-l)-G,z=function(o){return s===1?m+d/2:m+o*d/(s-1)},D=function(o){return n+y-(o-g.lo)/(g.hi-g.lo)*y};if(g.ticks.forEach(function(o,w){var E=D(o);a+='<line x1="'+p(m)+'" x2="'+p(m+d)+'" y1="'+p(E)+'" y2="'+p(E)+'" stroke="'+t.grid+'"'+(o===0?"":' stroke-dasharray="2 4"')+"/>"+M(m-8,E+3.5,F[w],b(t,10,'text-anchor="end"'))}),k.length){for(var I=Math.max(1,Math.ceil(s*(Math.max.apply(null,k.map(function(o){return S(o,10,!0)}))+10)/d)),x=0;x<s;x+=I)if(k[x]!=null){var J=s>1&&x===0?"start":s>1&&x===s-1?"end":"middle";a+=M(z(x),n+y+15,k[x],b(t,10,'text-anchor="'+J+'"'))}}return r.notes.forEach(function(o){if(!(o.i>=s)){var w=z(o.i);a+='<line x1="'+p(w)+'" x2="'+p(w)+'" y1="'+p(n+12)+'" y2="'+p(n+y)+'" stroke="'+t.fg+'" stroke-opacity=".4" stroke-dasharray="3 3"/>'+M(H(w,m+30,m+d-30),n+8,o.text,b(t,10,'text-anchor="middle"',t.fg))}}),{svg:a,X:z,Y:D,px:m,pw:d,top:n,ph:y}}function R(e,t,r,i,l){for(var h=L(e.goal)?W(e,t,r.px,r.px+r.pw,r.Y(+e.goal)):"",u=i>1?r.pw/(i-1):r.pw,a=0;a<i;a++)h+=K(r.X(a)-u/2,r.top,u,r.ph,l(a));return h}function T(e,t,r,i){return function(l,h,u){var a=e[l%e.length],n=t?C[t(l)]:"",s=r?r(l):"none";return'<line x1="'+p(h)+'" x2="'+p(h+18)+'" y1="'+p(u+6)+'" y2="'+p(u+6)+'" stroke="'+a+'" stroke-width="2.5" stroke-linecap="round"'+(n?' stroke-dasharray="'+n+'"':"")+"/>"+(s!=="none"?Y(s,h+9,u+6,3.5,' fill="'+a+'" stroke="'+i+'" stroke-width="1.5"'):"")}}function U(e,t,r,i,l){return l?'<path d="'+t+'" fill="none" stroke="'+r+'" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="'+l+'"'+X(e,"bzc-a",i*.15)+"/>":'<path d="'+t+'" fill="none" stroke="'+r+'" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" pathLength="1" style="stroke-dasharray:1'+(e.animate?";animation-delay:"+i*.15+"s":"")+'"'+(e.animate?' class="bzc-d"':"")+"/>"}function V(e,t,r,i,l,h,u,a){var n="",s=Math.ceil(r.length/40);return r.forEach(function(k,c){(c%s===0||c===r.length-1)&&(n+=Y(t,i(c),l(k),3.5,' fill="'+h+'" stroke="'+u+'" stroke-width="1.5"'+X(e,"bzc-a",.6+a*.15)))}),n}export{Q as a,R as b,T as c,U as d,V as e};
@@ -0,0 +1,2 @@
1
+ /*! Bezel Charts v1.6.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
+ var g={dark:{tile:"#15151d",bezel:"#000000",fg:"#f2f1f7",muted:"#8c8aa0",grid:"#2a2935",up:"#5EE6C8",down:"#F675A8",palette:["#9FA1FF","#F675A8","#5EE6C8","#FFC857","#7CC4FF","#FF8A5B"]},light:{tile:"#ffffff",bezel:"#000000",fg:"#17161f",muted:"#6b6980",grid:"#e8e6ef",up:"#12a383",down:"#d63f7c",palette:["#6E70F0","#E2508C","#16A884","#D99A0E","#2F8FE0","#EE6431"]}};var x="ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif",w="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace",W=0;function nt(t){return"bzc"+t+(++W).toString(36)+Math.random().toString(36).slice(2,6)}function h(t){return String(t??"").replace(/[&<>"']/g,function(e){return{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e]})}function s(t){return Math.round(t*100)/100}function u(t,e,r){return Math.max(e,Math.min(r,t))}function v(t,e){var r=parseFloat(t);return isFinite(r)?r:e}function c(t){return t!=null&&t!==""}function T(t){return Array.isArray(t)?t.map(function(e){var r=+e;return isFinite(r)?r:0}):c(t)?String(t).split(/[\s,;]+/).filter(Boolean).map(function(e){var r=+e;return isFinite(r)?r:0}):[]}function V(t){return Array.isArray(t)?t.map(String):c(t)?String(t).split(",").map(function(e){return e.trim()}):[]}function at(t){return Array.isArray(t)?Array.isArray(t[0])?t.map(T):[T(t)]:c(t)?String(t).split("|").map(T).filter(function(e){return e.length}):[]}function Y(t){return t.reduce(function(e,r){return e+r},0)}function ot(t,e,r){return String(t).length*e*(r?.6:.56)}function st(t,e){return t=String(t),t.length>e?t.slice(0,Math.max(1,e-1))+"\u2026":t}function C(t){return t===!0||t===""||t==="true"||t==="1"}function k(t,e,r){if(!isFinite(t))return"\u2013";var i=Math.abs(t),n;c(e.decimals)?n=u(parseInt(e.decimals,10)||0,0,6):n=t%1===0?0:i<10?2:i<100?1:0;var a={maximumFractionDigits:n,minimumFractionDigits:c(e.decimals)?n:0};(C(e.compact)||r)&&i>=1e4&&(a={notation:"compact",maximumFractionDigits:1});var o;try{o=new Intl.NumberFormat(e.lang||"en-GB",a).format(i)}catch{o=String(s(i))}return(t<0?"\u2212":"")+(e.prefix||"")+o+(e.suffix||"")}function lt(t,e){if(!t.length)return"";for(var r="M"+s(t[0][0])+","+s(t[0][1]),i=1;i<t.length;i++){var n=t[i-1],a=t[i];if(e)r+="L"+s(a[0])+","+s(a[1]);else{var o=(n[0]+a[0])/2;r+="C"+s(o)+","+s(n[1])+" "+s(o)+","+s(a[1])+" "+s(a[0])+","+s(a[1])}}return r}function p(t,e,r,i){return'<text x="'+s(t)+'" y="'+s(e)+'" '+(i||"")+">"+h(r)+"</text>"}function F(t,e,r,i){return'fill="'+(i||t.muted)+'" font-family="'+w+'" font-size="'+(e||10)+'"'+(r?" "+r:"")}function ct(t,e,r,i,n){return'<rect class="bzc-hit" x="'+s(t)+'" y="'+s(e)+'" width="'+s(Math.max(1,r))+'" height="'+s(Math.max(1,i))+'" fill="#000" fill-opacity="0" data-tip="'+h(n)+'"/>'}function ht(t,e,r){return t.animate?' class="'+e+'"'+(r?' style="animation-delay:'+s(r)+'s"':""):""}function ut(t,e){var r=V(t.color).filter(Boolean);return r.length?r:e.palette}function dt(t,e,r,i,n){return p(e+i/2,r+n/2+4,"No data yet",'text-anchor="middle" fill="'+t.muted+'" font-family="'+x+'" font-size="13"')}function ft(t,e){return c(t.notes)?String(t.notes).split(";").map(function(r){var i=r.indexOf(":");if(i<0)return null;var n=r.slice(0,i).trim(),a=r.slice(i+1).trim(),o=e.map(String).indexOf(n);return o<0&&String(parseInt(n,10))===n&&(o=parseInt(n,10)),o>=0&&a?{i:o,text:a}:null}).filter(Boolean):[]}function mt(t,e,r,i,n){var a=(c(t.goalLabel)?t.goalLabel:"Goal")+" "+k(v(t.goal,0),t);return'<line x1="'+s(r)+'" x2="'+s(i)+'" y1="'+s(n)+'" y2="'+s(n)+'" stroke="'+e.fg+'" stroke-opacity=".55" stroke-width="1.25" stroke-dasharray="4 4"/>'+p(i,n-5,a,F(e,10,'text-anchor="end"'))}function pt(t,e,r){var i=String(c(e.stat)?e.stat:r||"").toLowerCase();if(!i||i==="none"||!t.length)return null;var n=Y(t),a={last:t[t.length-1],total:n,sum:n,average:n/t.length,avg:n/t.length,max:Math.max.apply(null,t),min:Math.min.apply(null,t)};if(!(i in a))return null;var o=null;return i==="last"&&t.length>1&&e.delta!=="none"&&(o=t[t.length-1]-t[0]),{val:a[i],delta:o}}var N=["spark","line","area","bars","histogram","boxplot","scatter","ring","donut","gauge","progress","heatmap"],A={};function wt(t,e){A[t]=e}var X=t=>t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase());function U(t,e){if(!A[t])throw new Error(N.includes(t)?`Bezel Charts: the ${t} chart isn't loaded. Add import 'bezel-charts/${t}', or load dist/charts/${t}.js.`:`Bezel Charts: unknown chart type "${t}". Choose one of: ${N.join(", ")}.`);let r={};for(let[i,n]of Object.entries(e))r[X(i)]=n;return r}function S(t,e={}){let r=U(t,e);r.animate=C(r.animate),r.frame=r.frame==="none"?"none":"bezel";let i=r.theme==="light"||r.theme==="dark"?r.theme:r.autoTheme||"dark";return A[t](r,g[i])}function j(t,e={}){return A[t].table(U(t,e))}function $(t){return t.replace(/<rect class="bzc-hit"[^>]*\/>/g,"").replace(/<circle[^>]* class="bzc-hit"[^>]*\/>/g,"").replace(/ data-tip="[^"]*"/g,"")}function yt(t,e={}){return $(S(t,{...e,animate:!1}))}var q=["type","values","labels","series","heading","prefix","suffix","decimals","compact","color","theme","frame","width","height","goal","goal-label","notes","show-values","stat","delta","delta-label","max","min","value","zones","horizontal","straight","zero","start","lang","corners","background","center-label","highlight","x","y","x-label","y-label","trend","static","no-tooltips","stacked","angle-labels","dash","markers","patterns","bins","bin-width","mark","percent","whiskers"],_=`:host{display:block;position:relative;max-width:100%}:host([hidden]){display:none}svg{display:block;max-width:100%;height:auto;overflow:visible}.tip{position:absolute;left:0;top:0;pointer-events:none;background:#0b0b10;color:#f2f1f7;font:600 12px/1.5 ${w};padding:7px 10px;border-radius:10px;white-space:pre;opacity:0;transform:translate(-50%,calc(-100% - 12px));transition:opacity .12s;z-index:3;border:1px solid #2a2935;box-shadow:0 8px 24px rgba(0,0,0,.35)}.tip.on{opacity:1}.c{outline:none}.c:focus-visible{outline:2px solid #fff;outline-offset:3px;box-shadow:0 0 0 7px #000}.k{stroke:currentColor;stroke-width:2;stroke-opacity:1}.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@media (forced-colors:active){.c:focus-visible{outline-color:Highlight}}`,Q={ArrowLeft:-1,ArrowUp:-1,ArrowRight:1,ArrowDown:1},J=()=>typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null,K=()=>{let t=typeof document<"u"&&document.documentElement?.getAttribute?.("data-theme");return t==="light"||t==="dark"?t:null},R=new Set;typeof MutationObserver=="function"&&typeof document<"u"&&document.documentElement&&new MutationObserver(()=>R.forEach(t=>t.refresh())).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});var Z=typeof HTMLElement>"u"?class{}:HTMLElement,z=class extends Z{static get observedAttributes(){return q}static get themes(){return g}get resolvedTheme(){let e=this.getAttribute("theme");return e==="light"||e==="dark"?e:this.options.autoTheme}get chartType(){return this.getAttribute("type")||"spark"}connectedCallback(){this.shadowRoot||(this.attachShadow({mode:"open"}).innerHTML=`<style>${_}</style><div class="c" role="group" aria-roledescription="chart"></div><p class="sr" id="h">Use the arrow keys to step through the values.</p><div class="tip" aria-hidden="true"></div><div class="sr" aria-live="polite"></div><div class="sr"></div>`,[,this.#t,,this.#r,this.#s,this.#h]=this.shadowRoot.children,this.shadowRoot.addEventListener("pointermove",e=>this.#d(e)),this.shadowRoot.addEventListener("pointerdown",e=>this.#d(e)),this.addEventListener("pointerleave",()=>this.#r.classList.remove("on")),this.#t.addEventListener("keydown",e=>this.#g(e)),this.#t.addEventListener("blur",()=>this.#b())),R.add(this),this.#i=J(),this.#i?.addEventListener?.("change",this.#u),typeof ResizeObserver=="function"?(this.#o=new ResizeObserver(([e])=>{let r=Math.round(e.contentRect.width);(!this.#n||!this.hasAttribute("width")&&r>0&&Math.abs(r-this.#l)>1)&&this.#a()}),this.#o.observe(this)):this.#a()}disconnectedCallback(){R.delete(this),this.#o?.disconnect(),this.#i?.removeEventListener?.("change",this.#u)}attributeChangedCallback(){!this.#n||this.#c||(this.#c=!0,queueMicrotask(()=>{this.#c=!1,this.#a()}))}get options(){let e={};for(let r of q)this.hasAttribute(r)&&(e[r]=this.getAttribute(r));return e.width||(e.width=this.#l||360),e.autoTheme=K()||(this.#i?this.#i.matches?"dark":"light":"dark"),e}refresh(){this.#n&&this.#a()}toSVG(e={}){return $(S(this.chartType,{...this.options,...e,animate:!1}))}download(e){let r=URL.createObjectURL(new Blob([this.toSVG()],{type:"image/svg+xml"})),i=Object.assign(document.createElement("a"),{href:r,download:`${(e||this.getAttribute("heading")||this.chartType).replace(/[^\w-]+/g,"-").toLowerCase()}.svg`});document.body.append(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}#o=null;#t=null;#r=null;#s=null;#h=null;#e=-1;#i=null;#l=0;#n=!1;#c=!1;#u=()=>{let e=this.getAttribute("theme");(!e||e==="auto")&&this.refresh()};#a(){if(!this.shadowRoot)return;let e=Math.round(this.getBoundingClientRect?.().width||0);this.#l=e>0?e:360;let r=this.options;r.animate=!this.#n&&!this.hasAttribute("static");let i,n=null;try{i=S(this.chartType,r),n=j(this.chartType,r)}catch(d){i=`<p style="font:13px ${x};color:#d63f7c">${h(d.message)}</p>`}let a=this.#t;a.innerHTML=i.replace(/<title>[\s\S]*?<\/title>/,"");let o=a.querySelector("svg");o?(a.setAttribute("aria-label",o.getAttribute("aria-label")),o.removeAttribute("role"),o.removeAttribute("aria-label"),o.setAttribute("aria-hidden","true")):a.removeAttribute("aria-label");let l=!!o&&!this.hasAttribute("no-tooltips");l?(a.setAttribute("tabindex","0"),a.setAttribute("aria-describedby","h")):(a.removeAttribute("tabindex"),a.removeAttribute("aria-describedby")),a.style.color=g[r.theme==="light"||r.theme==="dark"?r.theme:r.autoTheme].fg,a.style.borderRadius=`${r.frame==="none"?4:u(+r.corners||22,0,60)}px`,this.#h.innerHTML=n&&n.rows.length?tt(r.heading,n):"",this.#e>=0&&l&&this.shadowRoot.activeElement===a?this.#p(this.#e):this.#e=-1,this.#n=!0,this.dispatchEvent(new CustomEvent("bezel-render",{bubbles:!0}))}#d(e){if(this.hasAttribute("no-tooltips"))return;let r=e.target?.closest?.("[data-tip]");if(!r){this.#r.classList.remove("on");return}this.#f(r,e.clientX,e.clientY)}#f(e,r,i){let n=this.#r;n.textContent=e.getAttribute("data-tip");let a=this.getBoundingClientRect?.()||{left:0,top:0,width:0},o=n.offsetWidth/2;n.style.left=`${u(r-a.left,o,Math.max(o,a.width-o))}px`,n.style.top=`${i-a.top}px`,n.classList.add("on")}#m(){return[...this.#t.querySelectorAll("[data-tip]:not([data-skip])")]}#g(e){let r=this.#m(),i=r.length;if(!i)return;let n=this.#e,a=Q[e.key];if(a)this.chartType==="heatmap"&&/Left|Right/.test(e.key)&&(a*=7),n=n<0?a>0?0:i-1:u(n+a,0,i-1);else if(e.key==="Home"||e.key==="End")n=e.key==="Home"?0:i-1;else{e.key==="Escape"&&this.#b();return}e.preventDefault(),this.#p(n,!0)}#p(e,r){let i=this.#m();if(!i.length)return;e=u(e,0,i.length-1),this.#t.querySelector(".k")?.classList.remove("k");let n=i[e],a=n.getBoundingClientRect?.()||{left:0,top:0,width:0};n.classList.add("k"),this.#e=e,this.#f(n,a.left+a.width/2,a.top),r&&(this.#s.textContent=`${n.getAttribute("data-tip").replace(/\n/g,", ")}. ${e+1} of ${i.length}`)}#b(){this.#t.querySelector(".k")?.classList.remove("k"),this.#r.classList.remove("on"),this.#s.textContent="",this.#e=-1}};function tt(t,{head:e,rows:r}){let i=n=>n.map((a,o)=>o?`<td>${h(a)}</td>`:`<th scope="row">${h(a)}</th>`).join("");return`<table><caption>${h(t||"Chart data")}</caption><thead><tr>${e.map(n=>`<th scope="col">${h(n)}</th>`).join("")}</tr></thead><tbody>${r.map(n=>`<tr>${i(n)}</tr>`).join("")}</tbody></table>`}function zt(t){typeof customElements>"u"||typeof HTMLElement>"u"||(customElements.get(`bezel-${t}`)||customElements.define(`bezel-${t}`,class extends z{get chartType(){return t}}),customElements.get("bezel-chart")||customElements.define("bezel-chart",class extends z{}))}function et(t){var e=Math.round(u(v(t.width,360),160,2400)),r=t.frame==="none"?0:4,i=t.frame==="none"?8:20;return{W:e,b:r,P:i,w:e-2*(r+i)}}var rt=".bzc-a{animation:bzc-in .6s ease both}.bzc-d{animation:bzc-draw 1.1s cubic-bezier(.3,.7,.2,1) both}.bzc-g{transform-box:fill-box;transform-origin:50% 100%;animation:bzc-grow .7s cubic-bezier(.2,.8,.2,1) both}.bzc-gn{transform-box:fill-box;transform-origin:50% 0;animation:bzc-grow .7s cubic-bezier(.2,.8,.2,1) both}.bzc-gx{transform-box:fill-box;transform-origin:0 50%;animation:bzc-growx .8s cubic-bezier(.2,.8,.2,1) both}.bzc-s{animation:bzc-sweep 1.1s cubic-bezier(.2,.8,.2,1) both}@keyframes bzc-in{from{opacity:0}}@keyframes bzc-draw{from{stroke-dashoffset:1}}@keyframes bzc-grow{from{transform:scaleY(0)}}@keyframes bzc-growx{from{transform:scaleX(0)}}@keyframes bzc-sweep{from{stroke-dasharray:0 100}}@media (prefers-reduced-motion:reduce){[class^=bzc-]{animation:none!important}}";function Ft(t,e,r,i,n){var a=et(t),o=a.W,l=a.b,d=a.P,O=a.w,E=u(v(t.corners,22),0,60),f=l+d,y="";c(t.heading)&&(y+=p(l+d,f+10,String(t.heading).toUpperCase(),F(e,11,'font-weight="600" letter-spacing="1.3"')),f+=24);var m=n&&n.stat;if(m){if(y+=p(l+d,f+30,k(m.val,t),'fill="'+e.fg+'" font-family="'+x+'" font-size="32" font-weight="800" letter-spacing="-0.5"'),m.delta!=null){var M=m.delta>0,H=m.delta===0,I=t.delta==="inverse"?!M:M,D=H?e.muted:I?e.up:e.down,P=(H?"\u25CF ":M?"\u25B2 ":"\u25BC ")+k(Math.abs(m.delta),t)+" "+(c(t.deltaLabel)?t.deltaLabel:"since start");y+=p(l+d+O,f+28,P,'text-anchor="end" fill="'+D+'" font-family="'+w+'" font-size="11" font-weight="600"')}f+=44}var G=i(l+d,f,O,r),b=Math.round(f+r+d+l),L="";t.frame!=="none"?L='<rect width="'+o+'" height="'+b+'" rx="'+E+'" fill="'+e.bezel+'"/><rect x="'+l+'" y="'+l+'" width="'+(o-2*l)+'" height="'+(b-2*l)+'" rx="'+Math.max(0,E-l)+'" fill="'+(t.background||e.tile)+'"/>':c(t.background)&&(L='<rect width="'+o+'" height="'+b+'" rx="'+E+'" fill="'+t.background+'"/>');var B=(c(t.heading)?t.heading+": ":"")+(n&&n.summary||"chart");return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '+o+" "+b+'" width="'+o+'" height="'+b+'" role="img" aria-label="'+h(B)+'"><title>'+h(B)+"</title>"+(t.animate?"<style>"+rt+"</style>":"")+L+y+G+"</svg>"}export{x as a,w as b,nt as c,h as d,s as e,u as f,v as g,c as h,T as i,V as j,at as k,Y as l,ot as m,st as n,C as o,k as p,lt as q,p as r,F as s,ct as t,ht as u,ut as v,dt as w,ft as x,mt as y,pt as z,et as A,Ft as B,wt as C,S as D,yt as E,z as F,zt as G};
@@ -1,2 +1,2 @@
1
- /*! Bezel Charts v1.4.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
- import{B as H,C as J,D as U,E as W,F as _,G as K,c as I,e as n,f as N,g as P,h as y,i as b,j as x,o as L,p as h,q as X,r as M,s as E,t as Y,u as z,v as Z,w as q,x as A,y as D,z as F}from"./shared-4QPUIMAU.js";function k(t,l){var r=b(t.values),o=Z(t,l)[0],Q=P(t.height,64),G=x(t.labels),R=A(t,G),T=F(r,t,"last");return H(t,l,Q,function(i,c,p,f){if(!r.length)return q(l,i,c,p,f);var v=r.length===1?[r[0],r[0]]:r,u=Math.min.apply(null,v),m=Math.max.apply(null,v);y(t.goal)&&(u=Math.min(u,+t.goal),m=Math.max(m,+t.goal));var V=(m-u||Math.abs(m)||1)*.12;u-=V,m+=V;var O=function(a){return i+a*p/(v.length-1)},S=function(a){return c+f-(a-u)/(m-u)*f},d=v.map(function(a,e){return[O(e),S(a)]}),j=X(d,L(t.straight)),B=I("g"),g=d[d.length-1],s='<defs><linearGradient id="'+B+'" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="'+o+'" stop-opacity=".32"/><stop offset="1" stop-color="'+o+'" stop-opacity="0"/></linearGradient></defs>';[1/3,2/3].forEach(function(a){s+='<line x1="'+i+'" x2="'+(i+p)+'" y1="'+n(c+f*a)+'" y2="'+n(c+f*a)+'" stroke="'+l.grid+'" stroke-dasharray="2 4"/>'}),s+='<path d="'+j+"L"+n(g[0])+","+(c+f)+"L"+i+","+(c+f)+'Z" fill="url(#'+B+')"'+z(t,"bzc-a")+"/>",s+='<path d="'+j+'" fill="none" stroke="'+o+'" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" pathLength="1" style="stroke-dasharray:1"'+z(t,"bzc-d")+"/>",y(t.goal)&&(s+=D(t,l,i,i+p,S(+t.goal))),R.forEach(function(a){if(!(a.i>=r.length)){var e=d[a.i];s+='<circle cx="'+n(e[0])+'" cy="'+n(e[1])+'" r="3.5" fill="'+l.fg+'"/>'+M(N(e[0],i+30,i+p-30),e[1]-9,a.text,E(l,10,'text-anchor="middle"',l.fg))}}),s+='<circle cx="'+n(g[0])+'" cy="'+n(g[1])+'" r="9" fill="'+o+'" fill-opacity=".25"/><circle cx="'+n(g[0])+'" cy="'+n(g[1])+'" r="4.5" fill="'+o+'"/>',L(t.showValues)&&d.forEach(function(a,e){e<r.length&&(s+=M(a[0],a[1]-8,h(r[e],t,!0),E(l,9,'text-anchor="middle"')))});var C=r.length>1?p/(r.length-1):p;return r.forEach(function(a,e){s+=Y(O(e)-C/2,c-6,C,f+12,(G[e]||"#"+(e+1))+": "+h(a,t))}),s},{stat:T,summary:r.length?"latest "+h(r[r.length-1],t):"no data"})}k.table=function(t){var l=x(t.labels);return{head:["Label","Value"],rows:b(t.values).map(function(r,o){return[l[o]||"#"+(o+1),h(r,t)]})}};J("spark",k);K("spark");export{_ as BezelChart,U as render,W as toSVG};
1
+ /*! Bezel Charts v1.6.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
+ import{B as H,C as J,D as U,E as W,F as _,G as K,c as I,e as n,f as N,g as P,h as y,i as b,j as x,o as L,p as h,q as X,r as M,s as E,t as Y,u as z,v as Z,w as q,x as A,y as D,z as F}from"./shared-YIDF72XF.js";function k(t,l){var r=b(t.values),o=Z(t,l)[0],Q=P(t.height,64),G=x(t.labels),R=A(t,G),T=F(r,t,"last");return H(t,l,Q,function(i,c,p,f){if(!r.length)return q(l,i,c,p,f);var v=r.length===1?[r[0],r[0]]:r,u=Math.min.apply(null,v),m=Math.max.apply(null,v);y(t.goal)&&(u=Math.min(u,+t.goal),m=Math.max(m,+t.goal));var V=(m-u||Math.abs(m)||1)*.12;u-=V,m+=V;var O=function(a){return i+a*p/(v.length-1)},S=function(a){return c+f-(a-u)/(m-u)*f},d=v.map(function(a,e){return[O(e),S(a)]}),j=X(d,L(t.straight)),B=I("g"),g=d[d.length-1],s='<defs><linearGradient id="'+B+'" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="'+o+'" stop-opacity=".32"/><stop offset="1" stop-color="'+o+'" stop-opacity="0"/></linearGradient></defs>';[1/3,2/3].forEach(function(a){s+='<line x1="'+i+'" x2="'+(i+p)+'" y1="'+n(c+f*a)+'" y2="'+n(c+f*a)+'" stroke="'+l.grid+'" stroke-dasharray="2 4"/>'}),s+='<path d="'+j+"L"+n(g[0])+","+(c+f)+"L"+i+","+(c+f)+'Z" fill="url(#'+B+')"'+z(t,"bzc-a")+"/>",s+='<path d="'+j+'" fill="none" stroke="'+o+'" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" pathLength="1" style="stroke-dasharray:1"'+z(t,"bzc-d")+"/>",y(t.goal)&&(s+=D(t,l,i,i+p,S(+t.goal))),R.forEach(function(a){if(!(a.i>=r.length)){var e=d[a.i];s+='<circle cx="'+n(e[0])+'" cy="'+n(e[1])+'" r="3.5" fill="'+l.fg+'"/>'+M(N(e[0],i+30,i+p-30),e[1]-9,a.text,E(l,10,'text-anchor="middle"',l.fg))}}),s+='<circle cx="'+n(g[0])+'" cy="'+n(g[1])+'" r="9" fill="'+o+'" fill-opacity=".25"/><circle cx="'+n(g[0])+'" cy="'+n(g[1])+'" r="4.5" fill="'+o+'"/>',L(t.showValues)&&d.forEach(function(a,e){e<r.length&&(s+=M(a[0],a[1]-8,h(r[e],t,!0),E(l,9,'text-anchor="middle"')))});var C=r.length>1?p/(r.length-1):p;return r.forEach(function(a,e){s+=Y(O(e)-C/2,c-6,C,f+12,(G[e]||"#"+(e+1))+": "+h(a,t))}),s},{stat:T,summary:r.length?"latest "+h(r[r.length-1],t):"no data"})}k.table=function(t){var l=x(t.labels);return{head:["Label","Value"],rows:b(t.values).map(function(r,o){return[l[o]||"#"+(o+1),h(r,t)]})}};J("spark",k);K("spark");export{_ as BezelChart,U as render,W as toSVG};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bezel-charts",
3
- "version": "1.4.0",
4
- "description": "Small, polished charts as zero-dependency web components. Sparklines, lines, areas, bars, rings, donuts, gauges, progress bars and heatmaps, with one-click static SVG export for READMEs.",
3
+ "version": "1.6.0",
4
+ "description": "Small, polished charts as zero-dependency web components. Sparklines, lines, areas, bars, histograms, box plots, rings, donuts, gauges, progress bars and heatmaps, with one-click static SVG export for READMEs.",
5
5
  "type": "module",
6
6
  "main": "dist/bezel-charts.js",
7
7
  "module": "dist/bezel-charts.js",
@@ -11,6 +11,8 @@
11
11
  "./line": "./dist/charts/line.js",
12
12
  "./area": "./dist/charts/area.js",
13
13
  "./bars": "./dist/charts/bars.js",
14
+ "./histogram": "./dist/charts/histogram.js",
15
+ "./boxplot": "./dist/charts/boxplot.js",
14
16
  "./scatter": "./dist/charts/scatter.js",
15
17
  "./ring": "./dist/charts/ring.js",
16
18
  "./donut": "./dist/charts/donut.js",
@@ -40,7 +42,9 @@
40
42
  "svg",
41
43
  "dashboard",
42
44
  "readme",
43
- "data-visualization"
45
+ "data-visualization",
46
+ "histogram",
47
+ "boxplot"
44
48
  ],
45
49
  "author": "Shaz Moghaddam (https://shazmoghaddam.github.io)",
46
50
  "license": "MIT",
@@ -0,0 +1,134 @@
1
+ import { r2, num, has, list, series, bool, fmt, tw, trunc, text, small, hit, anim, palette, emptyState, goalLine } from '../core/util.js';
2
+ import { niceScale, marker } from '../core/series.js';
3
+ import { tile } from '../core/tile.js';
4
+
5
+ /**
6
+ * Box plots: one box per group of raw values, side by side so spreads compare. The box runs from the lower to the
7
+ * upper quartile with a line at the median, and whiskers reach the furthest values within 1.5 times the box's height.
8
+ * Anything further out is an outlier dot. whiskers="range" reaches the lowest and highest values instead.
9
+ * Quartiles use linear interpolation, as pandas, NumPy and Excel's QUARTILE.INC do.
10
+ */
11
+ export default function boxplot(o, th) {
12
+ var S = series(o.values), names = list(o.series), pal = palette(o, th), k = S.length;
13
+ var horiz = bool(o.horizontal), many = list(o.color).length > 1, showMean = list(o.mark).indexOf('mean') >= 0;
14
+ var stats = S.map(function (v) { return summary(v, o.whiskers === 'range'); });
15
+ var nameOf = function (i) { return names[i] || 'Group ' + (i + 1); };
16
+ var h = num(o.height, horiz ? Math.max(120, k * 36 + 24) : 200);
17
+ var f = function (v) { return fmt(v, o); };
18
+
19
+ var meds = stats.map(function (s) { return s.median; });
20
+ var about = k === 1
21
+ ? 'median ' + f(stats[0].median) + ', middle half ' + f(stats[0].q1) + ' to ' + f(stats[0].q3)
22
+ : k + ' groups, medians from ' + f(Math.min.apply(null, meds)) + ' to ' + f(Math.max.apply(null, meds));
23
+
24
+ return tile(o, th, h, function (x0, y0, w, h) {
25
+ if (!k) return emptyState(th, x0, y0, w, h);
26
+ var lo = Math.min.apply(null, stats.map(function (s) { return s.min; })), hi = Math.max.apply(null, stats.map(function (s) { return s.max; }));
27
+ if (has(o.goal)) { lo = Math.min(lo, +o.goal); hi = Math.max(hi, +o.goal); }
28
+ var sc = niceScale(lo, hi, 4), s = '';
29
+ var tl = sc.ticks.map(function (t) { return fmt(t, o, true); });
30
+ // Value axis: up the left when upright, along the bottom when horizontal. Group names take the other side.
31
+ var nameW = horiz ? Math.min(w * 0.4, Math.max.apply(null, S.map(function (_, i) { return tw(nameOf(i), 11); })) + 12) : 0;
32
+ var axisW = horiz ? 0 : Math.max.apply(null, tl.map(function (t) { return tw(t, 10, true); })) + 10;
33
+ var px = x0 + (horiz ? nameW : axisW), pw = w - (horiz ? nameW : axisW), ph = h - 20;
34
+ var V = horiz
35
+ ? function (v) { return px + (v - sc.lo) / (sc.hi - sc.lo) * pw; }
36
+ : function (v) { return y0 + ph - (v - sc.lo) / (sc.hi - sc.lo) * ph; };
37
+ var band = (horiz ? ph : pw) / k, half = Math.min(28, band * 0.28);
38
+ var C = function (i) { return (horiz ? y0 : px) + band * (i + 0.5); };
39
+ // A point from a group's centre line c and a value position v.
40
+ var P = function (c, v) { return horiz ? [v, c] : [c, v]; };
41
+ var seg = function (c1, v1, c2, v2, attrs) {
42
+ var a = P(c1, v1), b = P(c2, v2);
43
+ return '<line x1="' + r2(a[0]) + '" y1="' + r2(a[1]) + '" x2="' + r2(b[0]) + '" y2="' + r2(b[1]) + '"' + attrs + '/>';
44
+ };
45
+
46
+ sc.ticks.forEach(function (t, i) {
47
+ var v = V(t);
48
+ s += seg(horiz ? y0 : px, v, horiz ? y0 + ph : px + pw, v, ' stroke="' + th.grid + '"' + (t === 0 ? '' : ' stroke-dasharray="2 4"')) +
49
+ (horiz ? text(v, y0 + ph + 15, tl[i], small(th, 10, 'text-anchor="middle"')) : text(px - 8, v + 3.5, tl[i], small(th, 10, 'text-anchor="end"')));
50
+ });
51
+ stats.forEach(function (st, i) {
52
+ var c = C(i), col = many ? pal[i % pal.length] : pal[0], line = ' stroke="' + col + '" stroke-width="1.5"';
53
+ // One unnamed group needs no name under it.
54
+ if (k > 1 || names.length) {
55
+ var label = fit(nameOf(i), horiz ? nameW - 10 : band - 6, horiz ? 11 : 10, !horiz);
56
+ s += horiz
57
+ ? text(x0, c + 4, label, small(th, 11, '', th.fg))
58
+ : text(c, y0 + ph + 15, label, small(th, 10, 'text-anchor="middle"'));
59
+ }
60
+ if (!st.n) return;
61
+ var a1 = P(c - half, V(st.q1)), a2 = P(c + half, V(st.q3));
62
+ s += '<g' + anim(o, 'bzc-a', Math.min(0.6, i * 0.06)) + '>' +
63
+ seg(c, V(st.low), c, V(st.q1), line) + seg(c, V(st.q3), c, V(st.high), line) +
64
+ seg(c - half / 2, V(st.low), c + half / 2, V(st.low), line) + seg(c - half / 2, V(st.high), c + half / 2, V(st.high), line) +
65
+ '<rect x="' + r2(Math.min(a1[0], a2[0])) + '" y="' + r2(Math.min(a1[1], a2[1])) + '" width="' + r2(Math.abs(a2[0] - a1[0])) + '" height="' + r2(Math.max(1, Math.abs(a2[1] - a1[1]))) +
66
+ '" rx="3" fill="' + col + '" fill-opacity=".22"' + line + '/>' +
67
+ seg(c - half, V(st.median), c + half, V(st.median), ' stroke="' + col + '" stroke-width="2.5"');
68
+ st.outliers.forEach(function (v) {
69
+ var p = P(c, V(v));
70
+ s += '<circle cx="' + r2(p[0]) + '" cy="' + r2(p[1]) + '" r="2.5" fill="none"' + line + '/>';
71
+ });
72
+ if (showMean) {
73
+ var m = P(c, V(st.mean));
74
+ s += marker('diamond', m[0], m[1], 4, ' fill="' + (o.background || th.tile) + '"' + line);
75
+ }
76
+ s += '</g>';
77
+ });
78
+ if (has(o.goal)) {
79
+ var g = V(+o.goal);
80
+ s += horiz
81
+ ? seg(g, y0, g, y0 + ph, ' stroke="' + th.fg + '" stroke-opacity=".55" stroke-dasharray="4 4"')
82
+ : goalLine(o, th, px, px + pw, g);
83
+ }
84
+ stats.forEach(function (st, i) {
85
+ if (!st.n) return;
86
+ var tip = nameOf(i) + '\nMedian ' + f(st.median) + '\nMiddle half ' + f(st.q1) + ' to ' + f(st.q3) +
87
+ '\n' + (st.outliers.length ? 'Range without outliers ' : 'Range ') + f(st.low) + ' to ' + f(st.high) +
88
+ (st.outliers.length ? '\n' + st.outliers.length + (st.outliers.length === 1 ? ' outlier' : ' outliers') : '') +
89
+ (showMean ? '\nMean ' + f(st.mean) : '') + '\nn = ' + st.n;
90
+ s += horiz ? hit(px, C(i) - band / 2, pw, band, tip) : hit(C(i) - band / 2, y0, band, ph, tip);
91
+ });
92
+ return s;
93
+ }, { summary: k ? about : 'no data' });
94
+ }
95
+
96
+ boxplot.table = function (o) {
97
+ var S = series(o.values), names = list(o.series), showMean = list(o.mark).indexOf('mean') >= 0;
98
+ var f = function (v) { return fmt(v, o); };
99
+ return {
100
+ head: ['Group', 'Count', 'Lowest', 'Lower quartile', 'Median', 'Upper quartile', 'Highest', 'Outliers'].concat(showMean ? ['Mean'] : []),
101
+ rows: S.map(function (v, i) {
102
+ var st = summary(v, o.whiskers === 'range');
103
+ return [names[i] || 'Group ' + (i + 1), String(st.n), f(st.min), f(st.q1), f(st.median), f(st.q3), f(st.max), String(st.outliers.length)].concat(showMean ? [f(st.mean)] : []);
104
+ }),
105
+ };
106
+ };
107
+
108
+ /** Shortens a name with an ellipsis until it fits the width. */
109
+ function fit(name, width, size, mono) {
110
+ var t = String(name);
111
+ while (t.length > 1 && tw(t, size, mono) > width) t = trunc(t, t.length - 1);
112
+ return t;
113
+ }
114
+
115
+ /** Quartile p of sorted values, interpolating between neighbours (pandas' default, also called type 7). */
116
+ function quantile(s, p) {
117
+ var h = (s.length - 1) * p, i = Math.floor(h);
118
+ return i + 1 < s.length ? s[i] + (h - i) * (s[i + 1] - s[i]) : s[i];
119
+ }
120
+
121
+ /** The five numbers, the mean and the outliers for one group. range makes the whiskers reach the extremes. */
122
+ function summary(v, range) {
123
+ var s = v.slice().sort(function (a, b) { return a - b; }), n = s.length;
124
+ if (!n) return { n: 0, outliers: [] };
125
+ var q1 = quantile(s, 0.25), q3 = quantile(s, 0.75), iqr = q3 - q1, t = 0;
126
+ var lowFence = range ? -Infinity : q1 - 1.5 * iqr, highFence = range ? Infinity : q3 + 1.5 * iqr;
127
+ var inside = s.filter(function (x) { return x >= lowFence && x <= highFence; });
128
+ s.forEach(function (x) { t += x; });
129
+ return {
130
+ n: n, min: s[0], max: s[n - 1], q1: q1, median: quantile(s, 0.5), q3: q3, mean: t / n,
131
+ low: inside[0], high: inside[inside.length - 1],
132
+ outliers: s.filter(function (x) { return x < lowFence || x > highFence; }),
133
+ };
134
+ }
@@ -0,0 +1,182 @@
1
+ import { newId, r2, num, has, list, series, bool, fmt, tw, text, small, hit, anim, palette, emptyState } from '../core/util.js';
2
+ import { niceScale, legend, styleOf, pattern, PATTERNS } from '../core/series.js';
3
+ import { tile } from '../core/tile.js';
4
+
5
+ /**
6
+ * How raw values spread out. The chart counts how many fall into each range: the ranges have round edges, include
7
+ * their lower edge and not their upper one, except the last, which includes both so the largest value is counted.
8
+ * Several series share the same ranges and overlap, so their spreads can be compared.
9
+ */
10
+ export default function histogram(o, th) {
11
+ var b = binned(o), names = list(o.series), pal = palette(o, th), h = num(o.height, 190);
12
+ var S = b ? b.S : [], k = S.length, multi = k > 1 || names.length > 0, pct = bool(o.percent);
13
+ var nameOf = function (j) { return names[j] || 'Series ' + (j + 1); };
14
+ // Range edges get as many decimals as the range width needs, so 0.5-wide ranges read 2.5, 3.0, 3.5.
15
+ var eo = Object.assign({}, o, { decimals: has(o.decimals) ? o.decimals : b ? b.dp : 0 });
16
+ var range = function (i) { return fmt(b.edge(i), eo) + ' to ' + fmt(b.edge(i + 1), eo); };
17
+ var share = function (j, i) { return Math.round(b.counts[j][i] / S[j].length * 100); };
18
+ var height = function (j, i) { return pct ? b.counts[j][i] / S[j].length * 100 : b.counts[j][i]; };
19
+ var marks = list(o.mark).filter(function (m) { return m === 'mean' || m === 'median'; });
20
+
21
+ var patOf = k > 1 ? styleOf(o.patterns, PATTERNS, 'solid') : null, defs = '', fills = [];
22
+ for (var q = 0; patOf && q < k; q++) {
23
+ if (patOf(q) === 'solid') continue;
24
+ var pid = newId('g');
25
+ defs += pattern(pid, patOf(q), pal[q % pal.length], o.background || th.tile);
26
+ fills[q] = 'url(#' + pid + ')';
27
+ }
28
+ var key = patOf && function (j, x, y) { return '<rect x="' + r2(x) + '" y="' + r2(y + 1) + '" width="10" height="10" rx="2" fill="' + (fills[j] || pal[j % pal.length]) + '"/>'; };
29
+
30
+ var peak = 0, n = 0;
31
+ if (b) {
32
+ for (var i = 0; i < b.count; i++) if (total(b, i) > total(b, peak)) peak = i;
33
+ S.forEach(function (s) { n += s.length; });
34
+ }
35
+
36
+ return tile(o, th, h, function (x0, y0, w, h) {
37
+ if (!b) return emptyState(th, x0, y0, w, h);
38
+ var s = defs ? '<defs>' + defs + '</defs>' : '', top = y0;
39
+ if (multi) {
40
+ var lg = legend(S.map(function (_, j) { return nameOf(j); }), pal, th, x0, top, w, key, key && 15);
41
+ s += lg.svg;
42
+ top += lg.height;
43
+ }
44
+ var most = 0;
45
+ S.forEach(function (_, j) { for (var i = 0; i < b.count; i++) most = Math.max(most, height(j, i)); });
46
+ var sc = niceScale(0, most || 1, 4);
47
+ var tl = sc.ticks.map(function (t) { return fmt(t, { lang: o.lang }, true) + (pct ? '%' : ''); });
48
+ var axisW = Math.max.apply(null, tl.map(function (t) { return tw(t, 10, true); })) + 10;
49
+ var px = x0 + axisW, pw = w - axisW, ph = h - (top - y0) - 20, cw = pw / b.count;
50
+ var X = function (i) { return px + i * cw; };
51
+ var Y = function (v) { return top + ph - (v - sc.lo) / (sc.hi - sc.lo) * ph; };
52
+ sc.ticks.forEach(function (t, i) {
53
+ var y = Y(t);
54
+ s += '<line x1="' + r2(px) + '" x2="' + r2(px + pw) + '" y1="' + r2(y) + '" y2="' + r2(y) + '" stroke="' + th.grid + '"' + (t === 0 ? '' : ' stroke-dasharray="2 4"') + '/>' +
55
+ text(px - 8, y + 3.5, tl[i], small(th, 10, 'text-anchor="end"'));
56
+ });
57
+ // Edge labels, thinned out when they would crowd.
58
+ var el = [];
59
+ for (var e = 0; e <= b.count; e++) el.push(fmt(b.edge(e), eo, true));
60
+ // The first and last labels hang inwards from the edges, so neighbours need one and a half labels of room.
61
+ var every = Math.max(1, Math.ceil((Math.max.apply(null, el.map(function (l) { return tw(l, 10, true); })) * 1.5 + 8) / cw));
62
+ for (e = 0; e <= b.count; e += every) {
63
+ s += text(X(e), top + ph + 15, el[e], small(th, 10, 'text-anchor="' + (e === 0 ? 'start' : e === b.count ? 'end' : 'middle') + '"'));
64
+ }
65
+ // Bars touch, with a hairline gap, because the ranges run on from each other. Several series overlap.
66
+ S.forEach(function (_, j) {
67
+ for (var i = 0; i < b.count; i++) {
68
+ var v = height(j, i);
69
+ if (!v) continue;
70
+ var y = Y(v);
71
+ s += '<rect x="' + r2(X(i) + 0.5) + '" y="' + r2(y) + '" width="' + r2(Math.max(1, cw - 1)) + '" height="' + r2(top + ph - y) + '" fill="' + (fills[j] || pal[j % pal.length]) + '"' +
72
+ (multi ? ' fill-opacity=".55"' : '') + anim(o, 'bzc-g', Math.min(0.6, i * 0.03)) + '/>';
73
+ }
74
+ });
75
+ // Mean and median lines, one per series. Their labels stack at the top beside the outermost line, on the side with
76
+ // more room, so no label crosses a line.
77
+ var lo = b.edge(0), span = b.edge(b.count) - lo, lines = [];
78
+ S.forEach(function (ser, j) {
79
+ marks.forEach(function (m) {
80
+ var v = m === 'mean' ? mean(ser) : median(ser);
81
+ lines.push({ x: px + (v - lo) / span * pw, c: multi ? pal[j % pal.length] : th.fg, t: (multi ? nameOf(j) + ' ' : '') + m + ' ' + fmt(v, o) });
82
+ });
83
+ });
84
+ if (lines.length) {
85
+ var xs = lines.map(function (l) { return l.x; }), left = (Math.min.apply(null, xs) + Math.max.apply(null, xs)) / 2 > px + pw / 2;
86
+ var lx = left ? Math.min.apply(null, xs) - 5 : Math.max.apply(null, xs) + 5;
87
+ lines.forEach(function (l, r) {
88
+ s += '<line x1="' + r2(l.x) + '" x2="' + r2(l.x) + '" y1="' + r2(top) + '" y2="' + r2(top + ph) + '" stroke="' + l.c + '" stroke-width="1.5" stroke-dasharray="4 3"/>' +
89
+ text(lx, top + 9 + r * 12, l.t, small(th, 10, 'text-anchor="' + (left ? 'end' : 'start') + '"', multi ? l.c : th.fg));
90
+ });
91
+ }
92
+ for (i = 0; i < b.count; i++) {
93
+ var tip = range(i);
94
+ S.forEach(function (_, j) { tip += '\n' + (multi ? nameOf(j) + ': ' : '') + b.counts[j][i] + ' (' + share(j, i) + '%)'; });
95
+ s += hit(X(i), top, cw, ph, tip);
96
+ }
97
+ return s;
98
+ }, {
99
+ summary: b ? (multi ? k + ' series, ' : '') + n + ' values in ' + b.count + ' ranges from ' + fmt(b.edge(0), eo) + ' to ' + fmt(b.edge(b.count), eo) + ', most in ' + range(peak) : 'no data',
100
+ });
101
+ }
102
+
103
+ histogram.table = function (o) {
104
+ var b = binned(o), names = list(o.series);
105
+ if (!b) return { head: ['Range', 'Count'], rows: [] };
106
+ var multi = b.S.length > 1 || names.length > 0, eo = Object.assign({}, o, { decimals: has(o.decimals) ? o.decimals : b.dp }), rows = [];
107
+ for (var i = 0; i < b.count; i++) {
108
+ var row = [fmt(b.edge(i), eo) + ' to ' + fmt(b.edge(i + 1), eo)];
109
+ if (multi) b.S.forEach(function (_, j) { row.push(String(b.counts[j][i])); });
110
+ else row.push(String(b.counts[0][i]), Math.round(b.counts[0][i] / b.S[0].length * 100) + '%');
111
+ rows.push(row);
112
+ }
113
+ return { head: ['Range'].concat(multi ? b.S.map(function (_, j) { return names[j] || 'Series ' + (j + 1); }) : ['Count', 'Share']), rows: rows };
114
+ };
115
+
116
+ /**
117
+ * The round width (1, 2, 2.5 or 5 times a power of ten) nearest to raw, and the decimals it needs. Nearest on a log
118
+ * scale: the thresholds sit halfway between the steps, at √2, √5, √12.5 and √50.
119
+ */
120
+ function niceWidth(raw) {
121
+ var e = Math.floor(Math.log10(raw)), p = Number('1e' + e), f = raw / p;
122
+ var m = f < 1.4142 ? 1 : f < 2.2361 ? 2 : f < 3.5355 ? 2.5 : f < 7.0711 ? 5 : 10;
123
+ return { w: m * p, dp: Math.max(0, m === 10 ? -e - 1 : -e) + (m === 2.5 ? 1 : 0) };
124
+ }
125
+
126
+ /**
127
+ * Sorts every value into ranges. bin-width sets the width; otherwise bins sets roughly how many ranges, and by default
128
+ * there are about log2(n) + 1. Returns null when there is nothing to count.
129
+ */
130
+ function binned(o) {
131
+ var S = series(o.values), all = [].concat.apply([], S);
132
+ if (!all.length) return null;
133
+ var lo = Math.min.apply(null, all), hi = Math.max.apply(null, all), w = num(o.binWidth, 0), dp, nice;
134
+ if (w > 0 && (hi - lo) / w <= 200) {
135
+ var str = String(o.binWidth), dot = str.indexOf('.');
136
+ dp = dot < 0 ? 0 : Math.min(6, str.length - dot - 1);
137
+ } else {
138
+ var k = num(o.bins, 0) > 0 ? Math.round(num(o.bins, 0)) : Math.ceil(Math.log2(all.length) + 1);
139
+ k = Math.min(Math.max(k, 1), 50);
140
+ nice = niceWidth(hi > lo ? (hi - lo) / k : Math.abs(lo) || 1);
141
+ w = nice.w;
142
+ dp = nice.dp;
143
+ }
144
+ // Edges are whole multiples of the width, rounded to the width's decimals so 3 × 0.1 is 0.3, not 0.30000000000000004.
145
+ // Counting compares values against these same edges, so a value typed as 0.3 lands in the range that starts at 0.3.
146
+ var s0 = Math.floor(lo / w);
147
+ var edge = function (i) { return Number(((s0 + i) * w).toFixed(dp + 3)); };
148
+ while (edge(0) > lo) s0--;
149
+ // Just enough ranges to reach the largest value, which the last range includes even when it sits on an edge.
150
+ var count = Math.max(1, Math.ceil((hi - edge(0)) / w));
151
+ while (count > 1 && edge(count - 1) >= hi) count--;
152
+ while (edge(count) < hi) count++;
153
+ var counts = S.map(function (ser) {
154
+ var c = [];
155
+ for (var i = 0; i < count; i++) c.push(0);
156
+ ser.forEach(function (x) {
157
+ var i = Math.min(count - 1, Math.max(0, Math.floor((x - edge(0)) / w)));
158
+ while (i > 0 && x < edge(i)) i--;
159
+ while (i < count - 1 && x >= edge(i + 1)) i++;
160
+ c[i]++;
161
+ });
162
+ return c;
163
+ });
164
+ return { S: S, edge: edge, count: count, counts: counts, dp: dp };
165
+ }
166
+
167
+ function total(b, i) {
168
+ var t = 0;
169
+ b.counts.forEach(function (c) { t += c[i]; });
170
+ return t;
171
+ }
172
+
173
+ function mean(v) {
174
+ var t = 0;
175
+ v.forEach(function (x) { t += x; });
176
+ return t / v.length;
177
+ }
178
+
179
+ function median(v) {
180
+ var s = v.slice().sort(function (a, b) { return a - b; }), m = Math.floor(s.length / 2);
181
+ return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2;
182
+ }
package/src/element.js CHANGED
@@ -7,7 +7,7 @@ export const ATTRIBUTES = [
7
7
  'type', 'values', 'labels', 'series', 'heading', 'prefix', 'suffix', 'decimals', 'compact', 'color', 'theme', 'frame',
8
8
  'width', 'height', 'goal', 'goal-label', 'notes', 'show-values', 'stat', 'delta', 'delta-label', 'max', 'min', 'value',
9
9
  'zones', 'horizontal', 'straight', 'zero', 'start', 'lang', 'corners', 'background', 'center-label', 'highlight',
10
- 'x', 'y', 'x-label', 'y-label', 'trend', 'static', 'no-tooltips', 'stacked', 'angle-labels', 'dash', 'markers', 'patterns',
10
+ 'x', 'y', 'x-label', 'y-label', 'trend', 'static', 'no-tooltips', 'stacked', 'angle-labels', 'dash', 'markers', 'patterns', 'bins', 'bin-width', 'mark', 'percent', 'whiskers',
11
11
  ];
12
12
 
13
13
  const HOST_CSS =
@@ -0,0 +1,10 @@
1
+ /** <bezel-boxplot> on its own: import 'bezel-charts/boxplot', or load dist/charts/boxplot.js. */
2
+ import boxplot from '../charts/boxplot.js';
3
+ import { register } from '../render.js';
4
+ import { define } from '../element.js';
5
+
6
+ register('boxplot', boxplot);
7
+ define('boxplot');
8
+
9
+ export { render, toSVG } from '../render.js';
10
+ export { BezelChart } from '../element.js';
@@ -0,0 +1,10 @@
1
+ /** <bezel-histogram> on its own: import 'bezel-charts/histogram', or load dist/charts/histogram.js. */
2
+ import histogram from '../charts/histogram.js';
3
+ import { register } from '../render.js';
4
+ import { define } from '../element.js';
5
+
6
+ register('histogram', histogram);
7
+ define('histogram');
8
+
9
+ export { render, toSVG } from '../render.js';
10
+ export { BezelChart } from '../element.js';