bezel-charts 1.1.0 → 1.1.1

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.
package/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  **Charts that look finished the moment you add them.**
4
4
 
5
5
  [![Web components release](https://img.shields.io/github/v/release/ShazMoghaddam/bezel-charts?filter=v*&label=web%20components&color=6E70F0)](https://github.com/ShazMoghaddam/bezel-charts/releases)
6
+ [![npm](https://img.shields.io/npm/v/bezel-charts?label=npm&color=CB3837)](https://www.npmjs.com/package/bezel-charts)
6
7
  [![PyPI](https://img.shields.io/pypi/v/bezel-charts?label=PyPI&color=16A884)](https://pypi.org/project/bezel-charts/)
7
8
  [![CI](https://github.com/ShazMoghaddam/bezel-charts/actions/workflows/ci.yml/badge.svg)](https://github.com/ShazMoghaddam/bezel-charts/actions/workflows/ci.yml)
8
9
  [![Python](https://github.com/ShazMoghaddam/bezel-charts/actions/workflows/python.yml/badge.svg)](https://github.com/ShazMoghaddam/bezel-charts/actions/workflows/python.yml)
@@ -46,16 +47,16 @@ A sibling of [Bezel](https://github.com/ShazMoghaddam/bezel), the clock, calenda
46
47
  <bezel-bars heading="Commits this week" values="4,9,6,3,8,5,3" labels="M,T,W,T,F,S,S" stat="total"></bezel-bars>
47
48
  ```
48
49
 
49
- `@1` always loads the latest 1.x release, so you get fixes without changing anything. To pin an exact version, use `@v1.1.0` instead.
50
+ `@1` always loads the latest 1.x release, so you get fixes without changing anything. To pin an exact version, use `@v1.1.1` instead.
50
51
 
51
52
  That's all. Charts fill the width of whatever they sit in and redraw when it changes, so they work in a sidebar, a card grid or a full-width section without extra CSS.
52
53
 
53
54
  Prefer a classic script tag? `dist/bezel-charts.iife.js` registers the same elements and exposes a `BezelCharts` global.
54
55
 
55
- With npm, straight from GitHub:
56
+ With npm:
56
57
 
57
58
  ```sh
58
- npm install github:ShazMoghaddam/bezel-charts
59
+ npm install bezel-charts
59
60
  ```
60
61
 
61
62
  ```js
@@ -407,6 +408,10 @@ test/ node:test suites, plus a Playwright browser test
407
408
 
408
409
  Each chart is a pure function that takes its options and a theme and returns an SVG string, which keeps them easy to test and lets the same code run in Node. The bundle has a 14 kB gzip budget, checked in CI. See [CONTRIBUTING.md](CONTRIBUTING.md).
409
410
 
411
+ ## Security
412
+
413
+ Found a security problem? Please report it privately through GitHub rather than in an issue. [SECURITY.md](SECURITY.md) explains how, and which versions get fixes.
414
+
410
415
  ## Credits
411
416
 
412
417
  Typeface Geist (SIL Open Font License) on the website; the charts themselves use the system font. Designed and built by [Shaz Moghaddam](https://shazmoghaddam.github.io), London.
@@ -1,4 +1,4 @@
1
- /*! Bezel Charts v1.1.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
1
+ /*! Bezel Charts v1.1.1 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
2
  var BezelCharts=(()=>{var le=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Pe=Object.prototype.hasOwnProperty;var Ue=(t,e)=>{for(var r in e)le(t,r,{get:e[r],enumerable:!0})},He=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of Ge(e))!Pe.call(t,l)&&l!==r&&le(t,l,{get:()=>e[l],enumerable:!(i=De(e,l))||i.enumerable});return t};var Ie=t=>He(le({},"__esModule",{value:!0}),t);var Je={};Ue(Je,{BezelChart:()=>Vt,render:()=>Yt,themes:()=>Ht,toSVG:()=>Ae,types:()=>Fe,version:()=>Qe});var Ht={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 tt="ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif",lt="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace",$e=0;function It(t){return"bzc"+t+(++$e).toString(36)+Math.random().toString(36).slice(2,6)}function ut(t){return String(t??"").replace(/[&<>"']/g,function(e){return{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e]})}function a(t){return Math.round(t*100)/100}function X(t,e,r){return Math.max(e,Math.min(r,t))}function _(t,e){var r=parseFloat(t);return isFinite(r)?r:e}function O(t){return t!=null&&t!==""}function ct(t){return Array.isArray(t)?t.map(function(e){var r=+e;return isFinite(r)?r:0}):O(t)?String(t).split(/[\s,;]+/).filter(Boolean).map(function(e){var r=+e;return isFinite(r)?r:0}):[]}function Z(t){return Array.isArray(t)?t.map(String):O(t)?String(t).split(",").map(function(e){return e.trim()}):[]}function Ct(t){return Array.isArray(t)?Array.isArray(t[0])?t.map(ct):[ct(t)]:O(t)?String(t).split("|").map(ct).filter(function(e){return e.length}):[]}function Lt(t){return t.reduce(function(e,r){return e+r},0)}function vt(t,e,r){return String(t).length*e*(r?.6:.56)}function Nt(t,e){return t=String(t),t.length>e?t.slice(0,Math.max(1,e-1))+"\u2026":t}function J(t){return t===!0||t===""||t==="true"||t==="1"}function g(t,e,r){if(!isFinite(t))return"\u2013";var i=Math.abs(t),l;O(e.decimals)?l=X(parseInt(e.decimals,10)||0,0,6):l=t%1===0?0:i<10?2:i<100?1:0;var n={maximumFractionDigits:l,minimumFractionDigits:O(e.decimals)?l:0};(J(e.compact)||r)&&i>=1e4&&(n={notation:"compact",maximumFractionDigits:1});var s;try{s=new Intl.NumberFormat(e.lang||"en-GB",n).format(i)}catch{s=String(a(i))}return(t<0?"\u2212":"")+(e.prefix||"")+s+(e.suffix||"")}function Qt(t,e,r){if(t===e)if(t===0)e=1;else{var i=Math.abs(t)*.1;t-=i,e+=i}for(var l=(e-t)/(r||4),n=Math.pow(10,Math.floor(Math.log10(l))),s=l/n,o=(s<=1?1:s<=2?2:s<=5?5:10)*n,c=Math.floor(t/o)*o,A=Math.ceil(e/o)*o,x=[],y=c;y<=A+o/2;y+=o)x.push(+y.toFixed(10));return{lo:c,hi:A,ticks:x}}function jt(t,e){if(!t.length)return"";for(var r="M"+a(t[0][0])+","+a(t[0][1]),i=1;i<t.length;i++){var l=t[i-1],n=t[i];if(e)r+="L"+a(n[0])+","+a(n[1]);else{var s=(l[0]+n[0])/2;r+="C"+a(s)+","+a(l[1])+" "+a(s)+","+a(n[1])+" "+a(n[0])+","+a(n[1])}}return r}function M(t,e,r,i){return'<text x="'+a(t)+'" y="'+a(e)+'" '+(i||"")+">"+ut(r)+"</text>"}function H(t,e,r,i){return'fill="'+(i||t.muted)+'" font-family="'+lt+'" font-size="'+(e||10)+'"'+(r?" "+r:"")}function pt(t,e,r,i,l){return'<rect class="bzc-hit" x="'+a(t)+'" y="'+a(e)+'" width="'+a(Math.max(1,r))+'" height="'+a(Math.max(1,i))+'" fill="#000" fill-opacity="0" data-tip="'+ut(l)+'"/>'}function ot(t,e,r){return t.animate?' class="'+e+'"'+(r?' style="animation-delay:'+a(r)+'s"':""):""}function at(t,e){var r=Z(t.color).filter(Boolean);return r.length?r:e.palette}function nt(t,e,r,i,l){return M(e+i/2,r+l/2+4,"No data yet",'text-anchor="middle" fill="'+t.muted+'" font-family="'+tt+'" font-size="13"')}function $t(t,e){return O(t.notes)?String(t.notes).split(";").map(function(r){var i=r.indexOf(":");if(i<0)return null;var l=r.slice(0,i).trim(),n=r.slice(i+1).trim(),s=e.map(String).indexOf(l);return s<0&&String(parseInt(l,10))===l&&(s=parseInt(l,10)),s>=0&&n?{i:s,text:n}:null}).filter(Boolean):[]}function At(t,e,r,i,l){var n=(O(t.goalLabel)?t.goalLabel:"Goal")+" "+g(_(t.goal,0),t);return'<line x1="'+a(r)+'" x2="'+a(i)+'" y1="'+a(l)+'" y2="'+a(l)+'" stroke="'+e.fg+'" stroke-opacity=".55" stroke-width="1.25" stroke-dasharray="4 4"/>'+M(i,l-5,n,H(e,10,'text-anchor="end"'))}function xt(t,e,r){var i=String(O(e.stat)?e.stat:r||"").toLowerCase();if(!i||i==="none"||!t.length)return null;var l=Lt(t),n={last:t[t.length-1],total:l,sum:l,average:l/t.length,avg:l/t.length,max:Math.max.apply(null,t),min:Math.min.apply(null,t)};if(!(i in n))return null;var s=null;return i==="last"&&t.length>1&&e.delta!=="none"&&(s=t[t.length-1]-t[0]),{val:n[i],delta:s}}function Rt(t,e,r,i,l,n){var s=i,o=l,c="";return t.forEach(function(A,x){var y=13+vt(A,12)+16;s>i&&s+y-16>i+n&&(s=i,o+=20),c+='<circle cx="'+a(s+4)+'" cy="'+a(o+6)+'" r="4" fill="'+e[x%e.length]+'"/>'+M(s+13,o+10,A,'fill="'+r.fg+'" font-family="'+tt+'" font-size="12"'),s+=y}),{svg:c,height:o-l+24}}function Ee(t){return Math.max.apply(null,t.map(function(e){return vt(e,10,!0)}))+10}function Bt(t){var e=Math.round(X(_(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 Ye=".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 it(t,e,r,i,l){var n=Bt(t),s=n.W,o=n.b,c=n.P,A=n.w,x=X(_(t.corners,22),0,60),y=o+c,u="";O(t.heading)&&(u+=M(o+c,y+10,String(t.heading).toUpperCase(),H(e,11,'font-weight="600" letter-spacing="1.3"')),y+=24);var S=l&&l.stat;if(S){if(u+=M(o+c,y+30,g(S.val,t),'fill="'+e.fg+'" font-family="'+tt+'" font-size="32" font-weight="800" letter-spacing="-0.5"'),S.delta!=null){var F=S.delta>0,C=S.delta===0,T=t.delta==="inverse"?!F:F,k=C?e.muted:T?e.up:e.down,E=(C?"\u25CF ":F?"\u25B2 ":"\u25BC ")+g(Math.abs(S.delta),t)+" "+(O(t.deltaLabel)?t.deltaLabel:"since start");u+=M(o+c+A,y+28,E,'text-anchor="end" fill="'+k+'" font-family="'+lt+'" font-size="11" font-weight="600"')}y+=44}var f=i(o+c,y,A,r),R=Math.round(y+r+c+o),v="";t.frame!=="none"?v='<rect width="'+s+'" height="'+R+'" rx="'+x+'" fill="'+e.bezel+'"/><rect x="'+o+'" y="'+o+'" width="'+(s-2*o)+'" height="'+(R-2*o)+'" rx="'+Math.max(0,x-o)+'" fill="'+(t.background||e.tile)+'"/>':O(t.background)&&(v='<rect width="'+s+'" height="'+R+'" rx="'+x+'" fill="'+t.background+'"/>');var b=(O(t.heading)?t.heading+": ":"")+(l&&l.summary||"chart");return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '+s+" "+R+'" width="'+s+'" height="'+R+'" role="img" aria-label="'+ut(b)+'"><title>'+ut(b)+"</title>"+(t.animate?"<style>"+Ye+"</style>":"")+v+u+f+"</svg>"}function oe(t,e){var r=ct(t.values),i=at(t,e)[0],l=_(t.height,64),n=Z(t.labels),s=$t(t,n),o=xt(r,t,"last");return it(t,e,l,function(c,A,x,y){if(!r.length)return nt(e,c,A,x,y);var u=r.length===1?[r[0],r[0]]:r,S=Math.min.apply(null,u),F=Math.max.apply(null,u);O(t.goal)&&(S=Math.min(S,+t.goal),F=Math.max(F,+t.goal));var C=(F-S||Math.abs(F)||1)*.12;S-=C,F+=C;var T=function(m){return c+m*x/(u.length-1)},k=function(m){return A+y-(m-S)/(F-S)*y},E=u.map(function(m,h){return[T(h),k(m)]}),f=jt(E,J(t.straight)),R=It("g"),v=E[E.length-1],b='<defs><linearGradient id="'+R+'" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="'+i+'" stop-opacity=".32"/><stop offset="1" stop-color="'+i+'" stop-opacity="0"/></linearGradient></defs>';[1/3,2/3].forEach(function(m){b+='<line x1="'+c+'" x2="'+(c+x)+'" y1="'+a(A+y*m)+'" y2="'+a(A+y*m)+'" stroke="'+e.grid+'" stroke-dasharray="2 4"/>'}),b+='<path d="'+f+"L"+a(v[0])+","+(A+y)+"L"+c+","+(A+y)+'Z" fill="url(#'+R+')"'+ot(t,"bzc-a")+"/>",b+='<path d="'+f+'" fill="none" stroke="'+i+'" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" pathLength="1" style="stroke-dasharray:1"'+ot(t,"bzc-d")+"/>",O(t.goal)&&(b+=At(t,e,c,c+x,k(+t.goal))),s.forEach(function(m){if(!(m.i>=r.length)){var h=E[m.i];b+='<circle cx="'+a(h[0])+'" cy="'+a(h[1])+'" r="3.5" fill="'+e.fg+'"/>'+M(X(h[0],c+30,c+x-30),h[1]-9,m.text,H(e,10,'text-anchor="middle"',e.fg))}}),b+='<circle cx="'+a(v[0])+'" cy="'+a(v[1])+'" r="9" fill="'+i+'" fill-opacity=".25"/><circle cx="'+a(v[0])+'" cy="'+a(v[1])+'" r="4.5" fill="'+i+'"/>',J(t.showValues)&&E.forEach(function(m,h){h<r.length&&(b+=M(m[0],m[1]-8,g(r[h],t,!0),H(e,9,'text-anchor="middle"')))});var N=r.length>1?x/(r.length-1):x;return r.forEach(function(m,h){b+=pt(T(h)-N/2,A-6,N,y+12,(n[h]||"#"+(h+1))+": "+g(m,t))}),b},{stat:o,summary:r.length?"latest "+g(r[r.length-1],t):"no data"})}function se(t,e){var r=Ct(t.values),i=Z(t.series),l=Z(t.labels),n=at(t,e),s=_(t.height,170),o=Math.max.apply(null,[0].concat(r.map(function(y){return y.length}))),c=$t(t,l),A=r.length>1||i.length>0,x=xt(r[0]||[],t,"");return it(t,e,s,function(y,u,S,F){if(!o)return nt(e,y,u,S,F);var C="",T=u;if(A){var k=Rt(r.map(function(w,z){return i[z]||"Series "+(z+1)}),n,e,y,T,S);C+=k.svg,T+=k.height}var E=[].concat.apply([],r),f=Math.min.apply(null,E),R=Math.max.apply(null,E);O(t.goal)&&(f=Math.min(f,+t.goal),R=Math.max(R,+t.goal)),J(t.zero)&&(f=Math.min(0,f),R=Math.max(0,R));var v=Qt(f,R,4),b=v.ticks.map(function(w){return g(w,t,!0)}),N=Math.max.apply(null,b.map(function(w){return vt(w,10,!0)}))+10,m=l.length?20:4,h=y+N,I=S-N,p=F-(T-u)-m,D=function(w){return o===1?h+I/2:h+w*I/(o-1)},L=function(w){return T+p-(w-v.lo)/(v.hi-v.lo)*p};if(v.ticks.forEach(function(w,z){var $=L(w);C+='<line x1="'+a(h)+'" x2="'+a(h+I)+'" y1="'+a($)+'" y2="'+a($)+'" stroke="'+e.grid+'"'+(w===0?"":' stroke-dasharray="2 4"')+"/>"+M(h-8,$+3.5,b[z],H(e,10,'text-anchor="end"'))}),l.length){for(var U=Math.max(1,Math.ceil(o*(Math.max.apply(null,l.map(function(w){return vt(w,10,!0)}))+10)/I)),W=0;W<o;W+=U)if(l[W]!=null){var q=o>1&&W===0?"start":o>1&&W===o-1?"end":"middle";C+=M(D(W),T+p+15,l[W],H(e,10,'text-anchor="'+q+'"'))}}c.forEach(function(w){if(!(w.i>=o)){var z=D(w.i);C+='<line x1="'+a(z)+'" x2="'+a(z)+'" y1="'+a(T+12)+'" y2="'+a(T+p)+'" stroke="'+e.fg+'" stroke-opacity=".4" stroke-dasharray="3 3"/>'+M(X(z,h+30,h+I-30),T+8,w.text,H(e,10,'text-anchor="middle"',e.fg))}}),r.forEach(function(w,z){var $=n[z%n.length],G=w.map(function(mt,B){return[D(B),L(mt)]});G.length===1&&(G=[[h,G[0][1]],[h+I,G[0][1]]]);var dt=jt(G,J(t.straight));if(z===0){var ht=It("g"),et=G[G.length-1];C+='<defs><linearGradient id="'+ht+'" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="'+$+'" stop-opacity=".26"/><stop offset="1" stop-color="'+$+'" stop-opacity="0"/></linearGradient></defs><path d="'+dt+"L"+a(et[0])+","+a(T+p)+"L"+a(G[0][0])+","+a(T+p)+'Z" fill="url(#'+ht+')"'+ot(t,"bzc-a")+"/>"}C+='<path d="'+dt+'" fill="none" stroke="'+$+'" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" pathLength="1" style="stroke-dasharray:1'+(t.animate?";animation-delay:"+z*.15+"s":"")+'"'+(t.animate?' class="bzc-d"':"")+"/>";var ft=G[G.length-1];C+='<circle cx="'+a(ft[0])+'" cy="'+a(ft[1])+'" r="4" fill="'+$+'" stroke="'+(t.background||e.tile)+'" stroke-width="2"/>',J(t.showValues)&&w.forEach(function(mt,B){C+=M(D(B),L(mt)-8,g(mt,t,!0),H(e,9,'text-anchor="middle"'))})}),O(t.goal)&&(C+=At(t,e,h,h+I,L(+t.goal)));for(var st=o>1?I/(o-1):I,Q=0;Q<o;Q++){var d=l[Q]||"#"+(Q+1);r.forEach(function(w,z){Q<w.length&&(d+=`
3
3
  `+(A?(i[z]||"Series "+(z+1))+": ":"")+g(w[Q],t))}),C+=pt(D(Q)-st/2,T,st,p,d)}return C},{stat:x,summary:r.length+" series over "+o+" points"})}var Le=40,Oe=24;function fe(t,e){for(var r=Ct(t.values),i=Z(t.series),l=Z(t.labels),n=at(t,e),s=r.length,o=Math.max.apply(null,[0].concat(r.map(function(d){return d.length}))),c=s>1,A=J(t.horizontal),x=c&&J(t.stacked),y=!c&&Z(t.color).filter(Boolean).length>1,u=r[0]||[],S=[].concat.apply([],r),F=function(d,w){return r.reduce(function(z,$){return d<$.length&&$[d]*w>0?z+$[d]:z},0)},C=[],T=[],k=[],E=0;x&&E<o;E++)T.push(F(E,1)),k.push(F(E,-1)),C.push(T[E]+k[E]);var f=x?T.concat(k):S,R=f.length?Math.max.apply(null,f):0,v=function(d){return i[d]||"Series "+(d+1)},b=function(d,w){return c?n[d%n.length]:y?n[w%n.length]:n[0]},N=function(d){return c||y||t.highlight==="none"||d===R?1:.5},m=function(d){return l[d]||"#"+(d+1)},h=function(d){return c?m(d)+r.map(function(w,z){return d<w.length?`
4
4
  `+v(z)+": "+g(w[d],t):""}).join("")+(x?`
@@ -6,4 +6,4 @@ Total: `+g(C[d],t):""):m(d)+": "+g(u[d],t)},I=Bt(t),p=c||i.length?Rt(r.map(funct
6
6
  Goal: `+g(+t.goal,t):"")),p},{summary:isFinite(i)?F(i)+" on a scale of "+g(n,t)+" to "+g(s,t):"no data"})}function me(t,e){var r=ct(t.values).map(function(k){return Math.max(0,k)}),i=Z(t.labels),l=at(t,e),n=r.length===1,s=Lt(r),o=O(t.max)?_(t.max,100):n?100:s;o>0||(o=1);var c=!O(t.prefix)&&!O(t.suffix)&&o===100&&n,A=function(k){return g(k,t)+(c?"%":"")},x=Bt(t),y=x.w,u=0,S=[];if(!n&&r.length){var F=0;u=1,r.forEach(function(k,E){var f=i[E]||"#"+(E+1),R=14+vt(f,12)+6+vt(g(k,t),11,!0)+18;F>0&&F+R>y&&(F=0,u++),S.push({x:F,row:u-1,l:f}),F+=R})}var C=36+(u?12+u*20:0),T=xt(r,t,"");return it(t,e,C,function(k,E,f,R){if(!r.length)return nt(e,k,E,f,R);var v="",b=E+22,N=It("c"),m=n?A(r[0])+(c?"":" of "+g(o,t)):g(s,t)+" of "+g(o,t);n&&i[0]&&(v+=M(k,E+11,i[0],'fill="'+e.fg+'" font-family="'+tt+'" font-size="12"')),v+=M(k+f,E+11,m,'text-anchor="end" fill="'+e.fg+'" font-family="'+lt+'" font-size="11" font-weight="600"'),v+='<rect x="'+k+'" y="'+b+'" width="'+f+'" height="14" rx="7" fill="'+e.grid+'" fill-opacity=".7"/>',v+='<clipPath id="'+N+'"><rect x="'+k+'" y="'+b+'" width="'+f+'" height="14" rx="7"/></clipPath><g clip-path="url(#'+N+')"><g'+ot(t,"bzc-gx")+">";var h=0;if(r.forEach(function(p,D){var L=Math.min(p,Math.max(0,o-h))/o*f;L>0&&(v+='<rect x="'+a(k+h/o*f)+'" y="'+b+'" width="'+a(L)+'" height="14" fill="'+l[D%l.length]+'"/>'),D>0&&L>0&&(v+='<rect x="'+a(k+h/o*f-1)+'" y="'+b+'" width="2" height="14" fill="'+(t.background||e.tile)+'"/>'),h+=p}),v+="</g></g>",O(t.goal)){var I=k+X(+t.goal/o,0,1)*f;v+='<line x1="'+a(I)+'" x2="'+a(I)+'" y1="'+(b-4)+'" y2="'+(b+18)+'" stroke="'+e.fg+'" stroke-width="2" stroke-linecap="round"/>'}return h=0,r.forEach(function(p,D){var L=Math.min(p,Math.max(0,o-h))/o*f;L>0&&(v+=pt(k+h/o*f,b-4,L,22,(i[D]||(n?"Progress":"#"+(D+1)))+": "+A(p)+(n?"":" ("+Math.round(p/o*100)+"%)"))),h+=p}),S.forEach(function(p,D){var L=k+p.x,U=b+14+12+p.row*20+8;v+='<circle cx="'+a(L+4)+'" cy="'+a(U)+'" r="4" fill="'+l[D%l.length]+'"/><text x="'+a(L+14)+'" y="'+a(U+4)+'" fill="'+e.fg+'" font-family="'+tt+'" font-size="12">'+ut(p.l)+'<tspan dx="6" fill="'+e.muted+'" font-family="'+lt+'" font-size="11">'+ut(g(r[D],t))+"</tspan></text>"}),v},{stat:T,summary:n?A(r[0])+(c?"":" of "+g(o,t)):g(s,t)+" of "+g(o,t)})}function pe(t,e){var r=ct(t.values),i=at(t,e)[0],l=t.lang||"en-GB",n;if(O(t.start)&&/^\d{4}-\d{2}-\d{2}$/.test(String(t.start)))n=new Date(String(t.start)+"T00:00:00Z");else{var s=new Date;n=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())-Math.max(0,r.length-1)*864e5)}var o=(n.getUTCDay()+6)%7,c=Math.max(1,Math.ceil((o+r.length)/7)),A=Bt(t),x=28,y=Math.max(1,Math.floor((A.w-x)/10));if(c>y){var u=(c-y)*7-o;r=r.slice(u),n=new Date(n.getTime()+u*864e5),o=0,c=y}var S=Math.min(18,(A.w-x)/c),F=S<8?1:3,C=S-F,T=16+7*S+26,k=r.length?Math.max.apply(null,r):0,E=function(N){try{return new Intl.DateTimeFormat(l,Object.assign({timeZone:"UTC"},N))}catch{return new Intl.DateTimeFormat("en-GB",Object.assign({timeZone:"UTC"},N))}},f=E({month:"short"}),R=E({weekday:"short"}),v=E({weekday:"short",day:"numeric",month:"short",year:"numeric"}),b=xt(r,t,"");return it(t,e,T,function(N,m,h,I){if(!r.length)return nt(e,N,m,h,I);var p="",D=N+x,L=m+16,U=-99,W=[.28,.5,.75,1];S>=9&&[0,2,4].forEach(function(Y){var V=new Date(Date.UTC(2024,0,1+Y));p+=M(N,L+Y*S+C/2+3.5,R.format(V),H(e,9))});for(var q=0;q<r.length;q++){var st=o+q,Q=Math.floor(st/7),d=st%7,w=new Date(n.getTime()+q*864e5),z=D+Q*S,$=L+d*S;(w.getUTCDate()===1||q===0)&&z-U>30&&(p+=M(z,m+9,f.format(w),H(e,9)),U=z);var G=r[q]<=0||!k?0:Math.ceil(r[q]/k*4),dt=G?i:e.grid,ht=G?W[G-1]:.7;p+='<rect x="'+a(z)+'" y="'+a($)+'" width="'+a(C)+'" height="'+a(C)+'" rx="'+a(C*.24)+'" fill="'+dt+'" fill-opacity="'+ht+'"'+(t.animate?' class="bzc-a" style="animation-delay:'+a(Q*.012)+'s"':"")+' data-tip="'+ut(v.format(w)+": "+g(r[q],t))+'"/>'}var et=L+7*S+14,ft=10,mt=N+h-5*(ft+3)-30;p+=M(N,et+8,g(Lt(r),t,!0)+" in "+r.length+" days",H(e,10)),p+=M(mt-6,et+8,"Less",H(e,9,'text-anchor="end"'));for(var B=0;B<5;B++)p+='<rect x="'+a(mt+B*(ft+3))+'" y="'+et+'" width="'+ft+'" height="'+ft+'" rx="2.5" fill="'+(B?i:e.grid)+'" fill-opacity="'+(B?W[B-1]:.7)+'"/>';return p+=M(mt+5*(ft+3)+3,et+8,"More",H(e,9)),p},{stat:b,summary:g(Lt(r),t)+" across "+r.length+" days"})}function Ve(t,e){var r=Math.min(t.length,e.length);if(r<2)return null;var i=0,l=0,n;for(n=0;n<r;n++)i+=t[n],l+=e[n];i/=r,l/=r;var s=0,o=0,c=0;for(n=0;n<r;n++)s+=(t[n]-i)*(t[n]-i),o+=(e[n]-l)*(e[n]-l),c+=(t[n]-i)*(e[n]-l);if(!s)return null;var A=c/s;return{slope:A,intercept:l-A*i,r:o?c/Math.sqrt(s*o):0}}function de(t,e){for(var r=Ct(t.x),i=Ct(t.y),l=Z(t.series),n=Z(t.labels),s=at(t,e),o=[],c=0;c<Math.max(r.length,i.length);c++){var A=r[c]||[],x=i[c]||[],y=Math.min(A.length,x.length);o.push({xs:A.slice(0,y),ys:x.slice(0,y)})}o=o.filter(function(f){return f.xs.length});var u=o.reduce(function(f,R){return f+R.xs.length},0),S=_(t.height,210),F=o.length>1||l.length>0,C=J(t.trend),T=function(f){return l[f]||"Group "+(f+1)},k={decimals:t.decimals,compact:t.compact,lang:t.lang},E=$t(t,n);return it(t,e,S,function(f,R,v,b){if(!u)return nt(e,f,R,v,b);var N="",m=R;if(F){var h=Rt(o.map(function(B,Y){return T(Y)}),s,e,f,m,v);N+=h.svg,m+=h.height}var I=[].concat.apply([],o.map(function(B){return B.xs})),p=[].concat.apply([],o.map(function(B){return B.ys})),D=Math.min.apply(null,p),L=Math.max.apply(null,p);O(t.goal)&&(D=Math.min(D,+t.goal),L=Math.max(L,+t.goal)),J(t.zero)&&(D=Math.min(0,D),L=Math.max(0,L));var U=Qt(D,L,4),W=Qt(Math.min.apply(null,I),Math.max.apply(null,I),5),q=U.ticks.map(function(B){return g(B,t,!0)}),st=Ee(q)+(O(t.yLabel)?14:0),Q=20+(O(t.xLabel)?16:0),d=f+st,w=v-st,z=b-(m-R)-Q,$=function(B){return d+6+(B-W.lo)/(W.hi-W.lo)*(w-12)},G=function(B){return m+6+z-6-(B-U.lo)/(U.hi-U.lo)*(z-6)};U.ticks.forEach(function(B,Y){var V=G(B);N+='<line x1="'+a(d)+'" x2="'+a(d+w)+'" y1="'+a(V)+'" y2="'+a(V)+'" stroke="'+e.grid+'" stroke-dasharray="2 4"/>'+M(d-8,V+3.5,q[Y],H(e,10,'text-anchor="end"'))});var dt=Math.max(1,Math.ceil(W.ticks.length*44/w));if(W.ticks.forEach(function(B,Y){if(!(Y%dt)){var V=$(B);N+='<line x1="'+a(V)+'" x2="'+a(V)+'" y1="'+a(m)+'" y2="'+a(m+z)+'" stroke="'+e.grid+'" stroke-dasharray="2 4"/>'+M(V,m+z+15,g(B,k,!0),H(e,10,'text-anchor="middle"'))}}),O(t.xLabel)&&(N+=M(d+w/2,m+z+32,t.xLabel,H(e,10,'text-anchor="middle" font-weight="600"'))),O(t.yLabel)){var ht=m+z/2;N+='<text x="'+a(f+4)+'" y="'+a(ht)+'" transform="rotate(-90 '+a(f+4)+" "+a(ht)+')" text-anchor="middle" '+H(e,10,'font-weight="600"')+' dominant-baseline="hanging">'+String(t.yLabel).replace(/[&<>"]/g,function(B){return{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[B]})+"</text>"}O(t.goal)&&(N+=At(t,e,d,d+w,G(+t.goal))),C&&o.forEach(function(B,Y){var V=Ve(B.xs,B.ys);if(V){var kt=Math.min.apply(null,B.xs),K=Math.max.apply(null,B.xs),bt=V.slope*kt+V.intercept,Ot=V.slope*K+V.intercept,Dt=s[Y%s.length];N+='<line x1="'+a($(kt))+'" y1="'+a(X(G(bt),m,m+z))+'" x2="'+a($(K))+'" y2="'+a(X(G(Ot),m,m+z))+'" stroke="'+Dt+'" stroke-width="2" stroke-dasharray="6 4" stroke-linecap="round" stroke-opacity=".9"/>',N+=M(Math.min($(K),d+w)-2,X(G(Ot),m+10,m+z)-7,"r = "+V.r.toFixed(2),H(e,10,'text-anchor="end" font-weight="600"',Dt))}});var et=0,ft=u>150?3:4.5;o.forEach(function(B,Y){var V=s[Y%s.length];B.xs.forEach(function(kt,K){var bt=$(kt),Ot=G(B.ys[K]),Dt=(n[et]?n[et]+`
7
7
  `:F?T(Y)+`
8
8
  `:"")+(O(t.xLabel)?t.xLabel:"x")+": "+g(kt,k)+`
9
- `+(O(t.yLabel)?t.yLabel:"y")+": "+g(B.ys[K],t);N+='<circle cx="'+a(bt)+'" cy="'+a(Ot)+'" r="'+ft+'" fill="'+V+'" fill-opacity=".85" stroke="'+(t.background||e.tile)+'" stroke-width="1.5"'+(t.animate?' class="bzc-a" style="animation-delay:'+a(Math.min(.8,et*.012))+'s"':"")+"/>",N+=pt(bt-8,Ot-8,16,16,Dt),et++})});var mt=[];return o.forEach(function(B){B.xs.forEach(function(Y,V){mt.push([$(Y),G(B.ys[V])])})}),E.forEach(function(B){var Y=mt[B.i];Y&&(N+='<circle cx="'+a(Y[0])+'" cy="'+a(Y[1])+'" r="'+(ft+4)+'" fill="none" stroke="'+e.fg+'" stroke-width="1.5"/>'+M(X(Y[0],d+30,d+w-30),Y[1]-ft-9,B.text,H(e,10,'text-anchor="middle"',e.fg)))}),N},{summary:u+" points"+(F?" in "+o.length+" groups":"")})}var Jt={spark:oe,line:se,bars:fe,scatter:de,ring:ce,donut:ue,gauge:he,progress:me,heatmap:pe},We=t=>t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase());function Yt(t,e={}){if(!Jt[t])throw new Error(`Bezel Charts: unknown chart type "${t}". Choose one of: ${Object.keys(Jt).join(", ")}.`);let r={};for(let[l,n]of Object.entries(e))r[We(l)]=n;r.animate=J(r.animate),r.frame=r.frame==="none"?"none":"bezel";let i=r.theme==="light"||r.theme==="dark"?r.theme:r.autoTheme||"dark";return Jt[t](r,Ht[i])}function ge(t){return t.replace(/<rect class="bzc-hit"[^>]*\/>/g,"").replace(/<circle[^>]* class="bzc-hit"[^>]*\/>/g,"").replace(/ data-tip="[^"]*"/g,"")}function Ae(t,e={}){return ge(Yt(t,{...e,animate:!1}))}var Te=["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"],Xe=`: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 ${lt};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}`,_e=()=>typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null,qe=()=>{let t=typeof document<"u"&&document.documentElement?.getAttribute?.("data-theme");return t==="light"||t==="dark"?t:null},ve=new Set;typeof MutationObserver=="function"&&typeof document<"u"&&document.documentElement&&new MutationObserver(()=>ve.forEach(t=>t.refresh())).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});var Ze=typeof HTMLElement>"u"?class{}:HTMLElement,Vt=class extends Ze{static get observedAttributes(){return Te}static get themes(){return Ht}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"}),this.shadowRoot.addEventListener("pointermove",e=>this.#o(e)),this.shadowRoot.addEventListener("pointerdown",e=>this.#o(e)),this.addEventListener("pointerleave",()=>this.shadowRoot.querySelector(".tip")?.classList.remove("on"))),ve.add(this),this.#t=_e(),this.#t?.addEventListener?.("change",this.#l),typeof ResizeObserver=="function"?(this.#a=new ResizeObserver(([e])=>{let r=Math.round(e.contentRect.width);(!this.#e||!this.hasAttribute("width")&&r>0&&Math.abs(r-this.#n)>1)&&this.#r()}),this.#a.observe(this)):this.#r()}disconnectedCallback(){ve.delete(this),this.#a?.disconnect(),this.#t?.removeEventListener?.("change",this.#l)}attributeChangedCallback(){!this.#e||this.#i||(this.#i=!0,queueMicrotask(()=>{this.#i=!1,this.#r()}))}get options(){let e={};for(let r of Te)this.hasAttribute(r)&&(e[r]=this.getAttribute(r));return e.width||(e.width=this.#n||360),e.autoTheme=qe()||(this.#t?this.#t.matches?"dark":"light":"dark"),e}refresh(){this.#e&&this.#r()}toSVG(e={}){return ge(Yt(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)}#a=null;#t=null;#n=0;#e=!1;#i=!1;#l=()=>{let e=this.getAttribute("theme");(!e||e==="auto")&&this.refresh()};#r(){if(!this.shadowRoot)return;let e=Math.round(this.getBoundingClientRect?.().width||0);this.#n=e>0?e:360;let r=this.options;r.animate=!this.#e&&!this.hasAttribute("static");let i;try{i=Yt(this.chartType,r)}catch(l){i=`<p style="font:13px ${tt};color:#d63f7c">${ut(l.message)}</p>`}i=i.replace(/<title>[\s\S]*?<\/title>/,""),this.shadowRoot.innerHTML=`<style>${Xe}</style>${i}<div class="tip" role="status"></div>`,this.#e=!0,this.dispatchEvent(new CustomEvent("bezel-render",{bubbles:!0}))}#o(e){let r=this.shadowRoot.querySelector(".tip");if(!r||this.hasAttribute("no-tooltips"))return;let i=e.target?.closest?.("[data-tip]");if(!i){r.classList.remove("on");return}r.textContent=i.getAttribute("data-tip");let l=this.getBoundingClientRect(),n=r.offsetWidth/2;r.style.left=`${X(e.clientX-l.left,n,Math.max(n,l.width-n))}px`,r.style.top=`${e.clientY-l.top}px`,r.classList.add("on")}};var Qe="1.1.0",Fe=Object.keys(Jt);if(typeof customElements<"u"&&typeof HTMLElement<"u"){for(let t of Fe){let e=`bezel-${t}`;customElements.get(e)||customElements.define(e,class extends Vt{get chartType(){return t}})}customElements.get("bezel-chart")||customElements.define("bezel-chart",class extends Vt{})}return Ie(Je);})();
9
+ `+(O(t.yLabel)?t.yLabel:"y")+": "+g(B.ys[K],t);N+='<circle cx="'+a(bt)+'" cy="'+a(Ot)+'" r="'+ft+'" fill="'+V+'" fill-opacity=".85" stroke="'+(t.background||e.tile)+'" stroke-width="1.5"'+(t.animate?' class="bzc-a" style="animation-delay:'+a(Math.min(.8,et*.012))+'s"':"")+"/>",N+=pt(bt-8,Ot-8,16,16,Dt),et++})});var mt=[];return o.forEach(function(B){B.xs.forEach(function(Y,V){mt.push([$(Y),G(B.ys[V])])})}),E.forEach(function(B){var Y=mt[B.i];Y&&(N+='<circle cx="'+a(Y[0])+'" cy="'+a(Y[1])+'" r="'+(ft+4)+'" fill="none" stroke="'+e.fg+'" stroke-width="1.5"/>'+M(X(Y[0],d+30,d+w-30),Y[1]-ft-9,B.text,H(e,10,'text-anchor="middle"',e.fg)))}),N},{summary:u+" points"+(F?" in "+o.length+" groups":"")})}var Jt={spark:oe,line:se,bars:fe,scatter:de,ring:ce,donut:ue,gauge:he,progress:me,heatmap:pe},We=t=>t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase());function Yt(t,e={}){if(!Jt[t])throw new Error(`Bezel Charts: unknown chart type "${t}". Choose one of: ${Object.keys(Jt).join(", ")}.`);let r={};for(let[l,n]of Object.entries(e))r[We(l)]=n;r.animate=J(r.animate),r.frame=r.frame==="none"?"none":"bezel";let i=r.theme==="light"||r.theme==="dark"?r.theme:r.autoTheme||"dark";return Jt[t](r,Ht[i])}function ge(t){return t.replace(/<rect class="bzc-hit"[^>]*\/>/g,"").replace(/<circle[^>]* class="bzc-hit"[^>]*\/>/g,"").replace(/ data-tip="[^"]*"/g,"")}function Ae(t,e={}){return ge(Yt(t,{...e,animate:!1}))}var Te=["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"],Xe=`: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 ${lt};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}`,_e=()=>typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null,qe=()=>{let t=typeof document<"u"&&document.documentElement?.getAttribute?.("data-theme");return t==="light"||t==="dark"?t:null},ve=new Set;typeof MutationObserver=="function"&&typeof document<"u"&&document.documentElement&&new MutationObserver(()=>ve.forEach(t=>t.refresh())).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});var Ze=typeof HTMLElement>"u"?class{}:HTMLElement,Vt=class extends Ze{static get observedAttributes(){return Te}static get themes(){return Ht}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"}),this.shadowRoot.addEventListener("pointermove",e=>this.#o(e)),this.shadowRoot.addEventListener("pointerdown",e=>this.#o(e)),this.addEventListener("pointerleave",()=>this.shadowRoot.querySelector(".tip")?.classList.remove("on"))),ve.add(this),this.#t=_e(),this.#t?.addEventListener?.("change",this.#l),typeof ResizeObserver=="function"?(this.#a=new ResizeObserver(([e])=>{let r=Math.round(e.contentRect.width);(!this.#e||!this.hasAttribute("width")&&r>0&&Math.abs(r-this.#n)>1)&&this.#r()}),this.#a.observe(this)):this.#r()}disconnectedCallback(){ve.delete(this),this.#a?.disconnect(),this.#t?.removeEventListener?.("change",this.#l)}attributeChangedCallback(){!this.#e||this.#i||(this.#i=!0,queueMicrotask(()=>{this.#i=!1,this.#r()}))}get options(){let e={};for(let r of Te)this.hasAttribute(r)&&(e[r]=this.getAttribute(r));return e.width||(e.width=this.#n||360),e.autoTheme=qe()||(this.#t?this.#t.matches?"dark":"light":"dark"),e}refresh(){this.#e&&this.#r()}toSVG(e={}){return ge(Yt(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)}#a=null;#t=null;#n=0;#e=!1;#i=!1;#l=()=>{let e=this.getAttribute("theme");(!e||e==="auto")&&this.refresh()};#r(){if(!this.shadowRoot)return;let e=Math.round(this.getBoundingClientRect?.().width||0);this.#n=e>0?e:360;let r=this.options;r.animate=!this.#e&&!this.hasAttribute("static");let i;try{i=Yt(this.chartType,r)}catch(l){i=`<p style="font:13px ${tt};color:#d63f7c">${ut(l.message)}</p>`}i=i.replace(/<title>[\s\S]*?<\/title>/,""),this.shadowRoot.innerHTML=`<style>${Xe}</style>${i}<div class="tip" role="status"></div>`,this.#e=!0,this.dispatchEvent(new CustomEvent("bezel-render",{bubbles:!0}))}#o(e){let r=this.shadowRoot.querySelector(".tip");if(!r||this.hasAttribute("no-tooltips"))return;let i=e.target?.closest?.("[data-tip]");if(!i){r.classList.remove("on");return}r.textContent=i.getAttribute("data-tip");let l=this.getBoundingClientRect(),n=r.offsetWidth/2;r.style.left=`${X(e.clientX-l.left,n,Math.max(n,l.width-n))}px`,r.style.top=`${e.clientY-l.top}px`,r.classList.add("on")}};var Qe="1.1.1",Fe=Object.keys(Jt);if(typeof customElements<"u"&&typeof HTMLElement<"u"){for(let t of Fe){let e=`bezel-${t}`;customElements.get(e)||customElements.define(e,class extends Vt{get chartType(){return t}})}customElements.get("bezel-chart")||customElements.define("bezel-chart",class extends Vt{})}return Ie(Je);})();
@@ -1,4 +1,4 @@
1
- /*! Bezel Charts v1.1.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
1
+ /*! Bezel Charts v1.1.1 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
2
 
3
3
  // src/core/themes.js
4
4
  var THEMES = {
@@ -1196,7 +1196,7 @@ var BezelChart = class extends Base {
1196
1196
  };
1197
1197
 
1198
1198
  // src/index.js
1199
- var version = "1.1.0";
1199
+ var version = "1.1.1";
1200
1200
  var types = Object.keys(TYPES);
1201
1201
  if (typeof customElements !== "undefined" && typeof HTMLElement !== "undefined") {
1202
1202
  for (const type of types) {
@@ -1,4 +1,4 @@
1
- /*! Bezel Charts v1.1.0 | MIT | github.com/ShazMoghaddam/bezel-charts */
1
+ /*! Bezel Charts v1.1.1 | MIT | github.com/ShazMoghaddam/bezel-charts */
2
2
  var _t={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 tt="ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif",lt="ui-monospace,SFMono-Regular,Menlo,Consolas,monospace",Ne=0;function Ht(t){return"bzc"+t+(++Ne).toString(36)+Math.random().toString(36).slice(2,6)}function ut(t){return String(t??"").replace(/[&<>"']/g,function(e){return{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e]})}function a(t){return Math.round(t*100)/100}function X(t,e,r){return Math.max(e,Math.min(r,t))}function _(t,e){var r=parseFloat(t);return isFinite(r)?r:e}function O(t){return t!=null&&t!==""}function ct(t){return Array.isArray(t)?t.map(function(e){var r=+e;return isFinite(r)?r:0}):O(t)?String(t).split(/[\s,;]+/).filter(Boolean).map(function(e){var r=+e;return isFinite(r)?r:0}):[]}function Z(t){return Array.isArray(t)?t.map(String):O(t)?String(t).split(",").map(function(e){return e.trim()}):[]}function Ct(t){return Array.isArray(t)?Array.isArray(t[0])?t.map(ct):[ct(t)]:O(t)?String(t).split("|").map(ct).filter(function(e){return e.length}):[]}function Lt(t){return t.reduce(function(e,r){return e+r},0)}function vt(t,e,r){return String(t).length*e*(r?.6:.56)}function Nt(t,e){return t=String(t),t.length>e?t.slice(0,Math.max(1,e-1))+"\u2026":t}function J(t){return t===!0||t===""||t==="true"||t==="1"}function g(t,e,r){if(!isFinite(t))return"\u2013";var i=Math.abs(t),l;O(e.decimals)?l=X(parseInt(e.decimals,10)||0,0,6):l=t%1===0?0:i<10?2:i<100?1:0;var n={maximumFractionDigits:l,minimumFractionDigits:O(e.decimals)?l:0};(J(e.compact)||r)&&i>=1e4&&(n={notation:"compact",maximumFractionDigits:1});var s;try{s=new Intl.NumberFormat(e.lang||"en-GB",n).format(i)}catch{s=String(a(i))}return(t<0?"\u2212":"")+(e.prefix||"")+s+(e.suffix||"")}function qt(t,e,r){if(t===e)if(t===0)e=1;else{var i=Math.abs(t)*.1;t-=i,e+=i}for(var l=(e-t)/(r||4),n=Math.pow(10,Math.floor(Math.log10(l))),s=l/n,o=(s<=1?1:s<=2?2:s<=5?5:10)*n,c=Math.floor(t/o)*o,A=Math.ceil(e/o)*o,x=[],y=c;y<=A+o/2;y+=o)x.push(+y.toFixed(10));return{lo:c,hi:A,ticks:x}}function jt(t,e){if(!t.length)return"";for(var r="M"+a(t[0][0])+","+a(t[0][1]),i=1;i<t.length;i++){var l=t[i-1],n=t[i];if(e)r+="L"+a(n[0])+","+a(n[1]);else{var s=(l[0]+n[0])/2;r+="C"+a(s)+","+a(l[1])+" "+a(s)+","+a(n[1])+" "+a(n[0])+","+a(n[1])}}return r}function M(t,e,r,i){return'<text x="'+a(t)+'" y="'+a(e)+'" '+(i||"")+">"+ut(r)+"</text>"}function H(t,e,r,i){return'fill="'+(i||t.muted)+'" font-family="'+lt+'" font-size="'+(e||10)+'"'+(r?" "+r:"")}function pt(t,e,r,i,l){return'<rect class="bzc-hit" x="'+a(t)+'" y="'+a(e)+'" width="'+a(Math.max(1,r))+'" height="'+a(Math.max(1,i))+'" fill="#000" fill-opacity="0" data-tip="'+ut(l)+'"/>'}function ot(t,e,r){return t.animate?' class="'+e+'"'+(r?' style="animation-delay:'+a(r)+'s"':""):""}function at(t,e){var r=Z(t.color).filter(Boolean);return r.length?r:e.palette}function nt(t,e,r,i,l){return M(e+i/2,r+l/2+4,"No data yet",'text-anchor="middle" fill="'+t.muted+'" font-family="'+tt+'" font-size="13"')}function It(t,e){return O(t.notes)?String(t.notes).split(";").map(function(r){var i=r.indexOf(":");if(i<0)return null;var l=r.slice(0,i).trim(),n=r.slice(i+1).trim(),s=e.map(String).indexOf(l);return s<0&&String(parseInt(l,10))===l&&(s=parseInt(l,10)),s>=0&&n?{i:s,text:n}:null}).filter(Boolean):[]}function At(t,e,r,i,l){var n=(O(t.goalLabel)?t.goalLabel:"Goal")+" "+g(_(t.goal,0),t);return'<line x1="'+a(r)+'" x2="'+a(i)+'" y1="'+a(l)+'" y2="'+a(l)+'" stroke="'+e.fg+'" stroke-opacity=".55" stroke-width="1.25" stroke-dasharray="4 4"/>'+M(i,l-5,n,H(e,10,'text-anchor="end"'))}function xt(t,e,r){var i=String(O(e.stat)?e.stat:r||"").toLowerCase();if(!i||i==="none"||!t.length)return null;var l=Lt(t),n={last:t[t.length-1],total:l,sum:l,average:l/t.length,avg:l/t.length,max:Math.max.apply(null,t),min:Math.min.apply(null,t)};if(!(i in n))return null;var s=null;return i==="last"&&t.length>1&&e.delta!=="none"&&(s=t[t.length-1]-t[0]),{val:n[i],delta:s}}function Rt(t,e,r,i,l,n){var s=i,o=l,c="";return t.forEach(function(A,x){var y=13+vt(A,12)+16;s>i&&s+y-16>i+n&&(s=i,o+=20),c+='<circle cx="'+a(s+4)+'" cy="'+a(o+6)+'" r="4" fill="'+e[x%e.length]+'"/>'+M(s+13,o+10,A,'fill="'+r.fg+'" font-family="'+tt+'" font-size="12"'),s+=y}),{svg:c,height:o-l+24}}function Se(t){return Math.max.apply(null,t.map(function(e){return vt(e,10,!0)}))+10}function Bt(t){var e=Math.round(X(_(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 Re=".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 it(t,e,r,i,l){var n=Bt(t),s=n.W,o=n.b,c=n.P,A=n.w,x=X(_(t.corners,22),0,60),y=o+c,u="";O(t.heading)&&(u+=M(o+c,y+10,String(t.heading).toUpperCase(),H(e,11,'font-weight="600" letter-spacing="1.3"')),y+=24);var S=l&&l.stat;if(S){if(u+=M(o+c,y+30,g(S.val,t),'fill="'+e.fg+'" font-family="'+tt+'" font-size="32" font-weight="800" letter-spacing="-0.5"'),S.delta!=null){var F=S.delta>0,C=S.delta===0,T=t.delta==="inverse"?!F:F,k=C?e.muted:T?e.up:e.down,E=(C?"\u25CF ":F?"\u25B2 ":"\u25BC ")+g(Math.abs(S.delta),t)+" "+(O(t.deltaLabel)?t.deltaLabel:"since start");u+=M(o+c+A,y+28,E,'text-anchor="end" fill="'+k+'" font-family="'+lt+'" font-size="11" font-weight="600"')}y+=44}var f=i(o+c,y,A,r),R=Math.round(y+r+c+o),v="";t.frame!=="none"?v='<rect width="'+s+'" height="'+R+'" rx="'+x+'" fill="'+e.bezel+'"/><rect x="'+o+'" y="'+o+'" width="'+(s-2*o)+'" height="'+(R-2*o)+'" rx="'+Math.max(0,x-o)+'" fill="'+(t.background||e.tile)+'"/>':O(t.background)&&(v='<rect width="'+s+'" height="'+R+'" rx="'+x+'" fill="'+t.background+'"/>');var b=(O(t.heading)?t.heading+": ":"")+(l&&l.summary||"chart");return'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 '+s+" "+R+'" width="'+s+'" height="'+R+'" role="img" aria-label="'+ut(b)+'"><title>'+ut(b)+"</title>"+(t.animate?"<style>"+Re+"</style>":"")+v+u+f+"</svg>"}function le(t,e){var r=ct(t.values),i=at(t,e)[0],l=_(t.height,64),n=Z(t.labels),s=It(t,n),o=xt(r,t,"last");return it(t,e,l,function(c,A,x,y){if(!r.length)return nt(e,c,A,x,y);var u=r.length===1?[r[0],r[0]]:r,S=Math.min.apply(null,u),F=Math.max.apply(null,u);O(t.goal)&&(S=Math.min(S,+t.goal),F=Math.max(F,+t.goal));var C=(F-S||Math.abs(F)||1)*.12;S-=C,F+=C;var T=function(m){return c+m*x/(u.length-1)},k=function(m){return A+y-(m-S)/(F-S)*y},E=u.map(function(m,h){return[T(h),k(m)]}),f=jt(E,J(t.straight)),R=Ht("g"),v=E[E.length-1],b='<defs><linearGradient id="'+R+'" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="'+i+'" stop-opacity=".32"/><stop offset="1" stop-color="'+i+'" stop-opacity="0"/></linearGradient></defs>';[1/3,2/3].forEach(function(m){b+='<line x1="'+c+'" x2="'+(c+x)+'" y1="'+a(A+y*m)+'" y2="'+a(A+y*m)+'" stroke="'+e.grid+'" stroke-dasharray="2 4"/>'}),b+='<path d="'+f+"L"+a(v[0])+","+(A+y)+"L"+c+","+(A+y)+'Z" fill="url(#'+R+')"'+ot(t,"bzc-a")+"/>",b+='<path d="'+f+'" fill="none" stroke="'+i+'" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" pathLength="1" style="stroke-dasharray:1"'+ot(t,"bzc-d")+"/>",O(t.goal)&&(b+=At(t,e,c,c+x,k(+t.goal))),s.forEach(function(m){if(!(m.i>=r.length)){var h=E[m.i];b+='<circle cx="'+a(h[0])+'" cy="'+a(h[1])+'" r="3.5" fill="'+e.fg+'"/>'+M(X(h[0],c+30,c+x-30),h[1]-9,m.text,H(e,10,'text-anchor="middle"',e.fg))}}),b+='<circle cx="'+a(v[0])+'" cy="'+a(v[1])+'" r="9" fill="'+i+'" fill-opacity=".25"/><circle cx="'+a(v[0])+'" cy="'+a(v[1])+'" r="4.5" fill="'+i+'"/>',J(t.showValues)&&E.forEach(function(m,h){h<r.length&&(b+=M(m[0],m[1]-8,g(r[h],t,!0),H(e,9,'text-anchor="middle"')))});var N=r.length>1?x/(r.length-1):x;return r.forEach(function(m,h){b+=pt(T(h)-N/2,A-6,N,y+12,(n[h]||"#"+(h+1))+": "+g(m,t))}),b},{stat:o,summary:r.length?"latest "+g(r[r.length-1],t):"no data"})}function oe(t,e){var r=Ct(t.values),i=Z(t.series),l=Z(t.labels),n=at(t,e),s=_(t.height,170),o=Math.max.apply(null,[0].concat(r.map(function(y){return y.length}))),c=It(t,l),A=r.length>1||i.length>0,x=xt(r[0]||[],t,"");return it(t,e,s,function(y,u,S,F){if(!o)return nt(e,y,u,S,F);var C="",T=u;if(A){var k=Rt(r.map(function(w,z){return i[z]||"Series "+(z+1)}),n,e,y,T,S);C+=k.svg,T+=k.height}var E=[].concat.apply([],r),f=Math.min.apply(null,E),R=Math.max.apply(null,E);O(t.goal)&&(f=Math.min(f,+t.goal),R=Math.max(R,+t.goal)),J(t.zero)&&(f=Math.min(0,f),R=Math.max(0,R));var v=qt(f,R,4),b=v.ticks.map(function(w){return g(w,t,!0)}),N=Math.max.apply(null,b.map(function(w){return vt(w,10,!0)}))+10,m=l.length?20:4,h=y+N,I=S-N,p=F-(T-u)-m,D=function(w){return o===1?h+I/2:h+w*I/(o-1)},L=function(w){return T+p-(w-v.lo)/(v.hi-v.lo)*p};if(v.ticks.forEach(function(w,z){var $=L(w);C+='<line x1="'+a(h)+'" x2="'+a(h+I)+'" y1="'+a($)+'" y2="'+a($)+'" stroke="'+e.grid+'"'+(w===0?"":' stroke-dasharray="2 4"')+"/>"+M(h-8,$+3.5,b[z],H(e,10,'text-anchor="end"'))}),l.length){for(var U=Math.max(1,Math.ceil(o*(Math.max.apply(null,l.map(function(w){return vt(w,10,!0)}))+10)/I)),W=0;W<o;W+=U)if(l[W]!=null){var q=o>1&&W===0?"start":o>1&&W===o-1?"end":"middle";C+=M(D(W),T+p+15,l[W],H(e,10,'text-anchor="'+q+'"'))}}c.forEach(function(w){if(!(w.i>=o)){var z=D(w.i);C+='<line x1="'+a(z)+'" x2="'+a(z)+'" y1="'+a(T+12)+'" y2="'+a(T+p)+'" stroke="'+e.fg+'" stroke-opacity=".4" stroke-dasharray="3 3"/>'+M(X(z,h+30,h+I-30),T+8,w.text,H(e,10,'text-anchor="middle"',e.fg))}}),r.forEach(function(w,z){var $=n[z%n.length],G=w.map(function(mt,B){return[D(B),L(mt)]});G.length===1&&(G=[[h,G[0][1]],[h+I,G[0][1]]]);var dt=jt(G,J(t.straight));if(z===0){var ht=Ht("g"),et=G[G.length-1];C+='<defs><linearGradient id="'+ht+'" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="'+$+'" stop-opacity=".26"/><stop offset="1" stop-color="'+$+'" stop-opacity="0"/></linearGradient></defs><path d="'+dt+"L"+a(et[0])+","+a(T+p)+"L"+a(G[0][0])+","+a(T+p)+'Z" fill="url(#'+ht+')"'+ot(t,"bzc-a")+"/>"}C+='<path d="'+dt+'" fill="none" stroke="'+$+'" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" pathLength="1" style="stroke-dasharray:1'+(t.animate?";animation-delay:"+z*.15+"s":"")+'"'+(t.animate?' class="bzc-d"':"")+"/>";var ft=G[G.length-1];C+='<circle cx="'+a(ft[0])+'" cy="'+a(ft[1])+'" r="4" fill="'+$+'" stroke="'+(t.background||e.tile)+'" stroke-width="2"/>',J(t.showValues)&&w.forEach(function(mt,B){C+=M(D(B),L(mt)-8,g(mt,t,!0),H(e,9,'text-anchor="middle"'))})}),O(t.goal)&&(C+=At(t,e,h,h+I,L(+t.goal)));for(var st=o>1?I/(o-1):I,Q=0;Q<o;Q++){var d=l[Q]||"#"+(Q+1);r.forEach(function(w,z){Q<w.length&&(d+=`
3
3
  `+(A?(i[z]||"Series "+(z+1))+": ":"")+g(w[Q],t))}),C+=pt(D(Q)-st/2,T,st,p,d)}return C},{stat:x,summary:r.length+" series over "+o+" points"})}var Ee=40,Le=24;function se(t,e){for(var r=Ct(t.values),i=Z(t.series),l=Z(t.labels),n=at(t,e),s=r.length,o=Math.max.apply(null,[0].concat(r.map(function(d){return d.length}))),c=s>1,A=J(t.horizontal),x=c&&J(t.stacked),y=!c&&Z(t.color).filter(Boolean).length>1,u=r[0]||[],S=[].concat.apply([],r),F=function(d,w){return r.reduce(function(z,$){return d<$.length&&$[d]*w>0?z+$[d]:z},0)},C=[],T=[],k=[],E=0;x&&E<o;E++)T.push(F(E,1)),k.push(F(E,-1)),C.push(T[E]+k[E]);var f=x?T.concat(k):S,R=f.length?Math.max.apply(null,f):0,v=function(d){return i[d]||"Series "+(d+1)},b=function(d,w){return c?n[d%n.length]:y?n[w%n.length]:n[0]},N=function(d){return c||y||t.highlight==="none"||d===R?1:.5},m=function(d){return l[d]||"#"+(d+1)},h=function(d){return c?m(d)+r.map(function(w,z){return d<w.length?`
4
4
  `+v(z)+": "+g(w[d],t):""}).join("")+(x?`
@@ -6,4 +6,4 @@ Total: `+g(C[d],t):""):m(d)+": "+g(u[d],t)},I=Bt(t),p=c||i.length?Rt(r.map(funct
6
6
  Goal: `+g(+t.goal,t):"")),p},{summary:isFinite(i)?F(i)+" on a scale of "+g(n,t)+" to "+g(s,t):"no data"})}function he(t,e){var r=ct(t.values).map(function(k){return Math.max(0,k)}),i=Z(t.labels),l=at(t,e),n=r.length===1,s=Lt(r),o=O(t.max)?_(t.max,100):n?100:s;o>0||(o=1);var c=!O(t.prefix)&&!O(t.suffix)&&o===100&&n,A=function(k){return g(k,t)+(c?"%":"")},x=Bt(t),y=x.w,u=0,S=[];if(!n&&r.length){var F=0;u=1,r.forEach(function(k,E){var f=i[E]||"#"+(E+1),R=14+vt(f,12)+6+vt(g(k,t),11,!0)+18;F>0&&F+R>y&&(F=0,u++),S.push({x:F,row:u-1,l:f}),F+=R})}var C=36+(u?12+u*20:0),T=xt(r,t,"");return it(t,e,C,function(k,E,f,R){if(!r.length)return nt(e,k,E,f,R);var v="",b=E+22,N=Ht("c"),m=n?A(r[0])+(c?"":" of "+g(o,t)):g(s,t)+" of "+g(o,t);n&&i[0]&&(v+=M(k,E+11,i[0],'fill="'+e.fg+'" font-family="'+tt+'" font-size="12"')),v+=M(k+f,E+11,m,'text-anchor="end" fill="'+e.fg+'" font-family="'+lt+'" font-size="11" font-weight="600"'),v+='<rect x="'+k+'" y="'+b+'" width="'+f+'" height="14" rx="7" fill="'+e.grid+'" fill-opacity=".7"/>',v+='<clipPath id="'+N+'"><rect x="'+k+'" y="'+b+'" width="'+f+'" height="14" rx="7"/></clipPath><g clip-path="url(#'+N+')"><g'+ot(t,"bzc-gx")+">";var h=0;if(r.forEach(function(p,D){var L=Math.min(p,Math.max(0,o-h))/o*f;L>0&&(v+='<rect x="'+a(k+h/o*f)+'" y="'+b+'" width="'+a(L)+'" height="14" fill="'+l[D%l.length]+'"/>'),D>0&&L>0&&(v+='<rect x="'+a(k+h/o*f-1)+'" y="'+b+'" width="2" height="14" fill="'+(t.background||e.tile)+'"/>'),h+=p}),v+="</g></g>",O(t.goal)){var I=k+X(+t.goal/o,0,1)*f;v+='<line x1="'+a(I)+'" x2="'+a(I)+'" y1="'+(b-4)+'" y2="'+(b+18)+'" stroke="'+e.fg+'" stroke-width="2" stroke-linecap="round"/>'}return h=0,r.forEach(function(p,D){var L=Math.min(p,Math.max(0,o-h))/o*f;L>0&&(v+=pt(k+h/o*f,b-4,L,22,(i[D]||(n?"Progress":"#"+(D+1)))+": "+A(p)+(n?"":" ("+Math.round(p/o*100)+"%)"))),h+=p}),S.forEach(function(p,D){var L=k+p.x,U=b+14+12+p.row*20+8;v+='<circle cx="'+a(L+4)+'" cy="'+a(U)+'" r="4" fill="'+l[D%l.length]+'"/><text x="'+a(L+14)+'" y="'+a(U+4)+'" fill="'+e.fg+'" font-family="'+tt+'" font-size="12">'+ut(p.l)+'<tspan dx="6" fill="'+e.muted+'" font-family="'+lt+'" font-size="11">'+ut(g(r[D],t))+"</tspan></text>"}),v},{stat:T,summary:n?A(r[0])+(c?"":" of "+g(o,t)):g(s,t)+" of "+g(o,t)})}function me(t,e){var r=ct(t.values),i=at(t,e)[0],l=t.lang||"en-GB",n;if(O(t.start)&&/^\d{4}-\d{2}-\d{2}$/.test(String(t.start)))n=new Date(String(t.start)+"T00:00:00Z");else{var s=new Date;n=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate())-Math.max(0,r.length-1)*864e5)}var o=(n.getUTCDay()+6)%7,c=Math.max(1,Math.ceil((o+r.length)/7)),A=Bt(t),x=28,y=Math.max(1,Math.floor((A.w-x)/10));if(c>y){var u=(c-y)*7-o;r=r.slice(u),n=new Date(n.getTime()+u*864e5),o=0,c=y}var S=Math.min(18,(A.w-x)/c),F=S<8?1:3,C=S-F,T=16+7*S+26,k=r.length?Math.max.apply(null,r):0,E=function(N){try{return new Intl.DateTimeFormat(l,Object.assign({timeZone:"UTC"},N))}catch{return new Intl.DateTimeFormat("en-GB",Object.assign({timeZone:"UTC"},N))}},f=E({month:"short"}),R=E({weekday:"short"}),v=E({weekday:"short",day:"numeric",month:"short",year:"numeric"}),b=xt(r,t,"");return it(t,e,T,function(N,m,h,I){if(!r.length)return nt(e,N,m,h,I);var p="",D=N+x,L=m+16,U=-99,W=[.28,.5,.75,1];S>=9&&[0,2,4].forEach(function(Y){var V=new Date(Date.UTC(2024,0,1+Y));p+=M(N,L+Y*S+C/2+3.5,R.format(V),H(e,9))});for(var q=0;q<r.length;q++){var st=o+q,Q=Math.floor(st/7),d=st%7,w=new Date(n.getTime()+q*864e5),z=D+Q*S,$=L+d*S;(w.getUTCDate()===1||q===0)&&z-U>30&&(p+=M(z,m+9,f.format(w),H(e,9)),U=z);var G=r[q]<=0||!k?0:Math.ceil(r[q]/k*4),dt=G?i:e.grid,ht=G?W[G-1]:.7;p+='<rect x="'+a(z)+'" y="'+a($)+'" width="'+a(C)+'" height="'+a(C)+'" rx="'+a(C*.24)+'" fill="'+dt+'" fill-opacity="'+ht+'"'+(t.animate?' class="bzc-a" style="animation-delay:'+a(Q*.012)+'s"':"")+' data-tip="'+ut(v.format(w)+": "+g(r[q],t))+'"/>'}var et=L+7*S+14,ft=10,mt=N+h-5*(ft+3)-30;p+=M(N,et+8,g(Lt(r),t,!0)+" in "+r.length+" days",H(e,10)),p+=M(mt-6,et+8,"Less",H(e,9,'text-anchor="end"'));for(var B=0;B<5;B++)p+='<rect x="'+a(mt+B*(ft+3))+'" y="'+et+'" width="'+ft+'" height="'+ft+'" rx="2.5" fill="'+(B?i:e.grid)+'" fill-opacity="'+(B?W[B-1]:.7)+'"/>';return p+=M(mt+5*(ft+3)+3,et+8,"More",H(e,9)),p},{stat:b,summary:g(Lt(r),t)+" across "+r.length+" days"})}function Be(t,e){var r=Math.min(t.length,e.length);if(r<2)return null;var i=0,l=0,n;for(n=0;n<r;n++)i+=t[n],l+=e[n];i/=r,l/=r;var s=0,o=0,c=0;for(n=0;n<r;n++)s+=(t[n]-i)*(t[n]-i),o+=(e[n]-l)*(e[n]-l),c+=(t[n]-i)*(e[n]-l);if(!s)return null;var A=c/s;return{slope:A,intercept:l-A*i,r:o?c/Math.sqrt(s*o):0}}function pe(t,e){for(var r=Ct(t.x),i=Ct(t.y),l=Z(t.series),n=Z(t.labels),s=at(t,e),o=[],c=0;c<Math.max(r.length,i.length);c++){var A=r[c]||[],x=i[c]||[],y=Math.min(A.length,x.length);o.push({xs:A.slice(0,y),ys:x.slice(0,y)})}o=o.filter(function(f){return f.xs.length});var u=o.reduce(function(f,R){return f+R.xs.length},0),S=_(t.height,210),F=o.length>1||l.length>0,C=J(t.trend),T=function(f){return l[f]||"Group "+(f+1)},k={decimals:t.decimals,compact:t.compact,lang:t.lang},E=It(t,n);return it(t,e,S,function(f,R,v,b){if(!u)return nt(e,f,R,v,b);var N="",m=R;if(F){var h=Rt(o.map(function(B,Y){return T(Y)}),s,e,f,m,v);N+=h.svg,m+=h.height}var I=[].concat.apply([],o.map(function(B){return B.xs})),p=[].concat.apply([],o.map(function(B){return B.ys})),D=Math.min.apply(null,p),L=Math.max.apply(null,p);O(t.goal)&&(D=Math.min(D,+t.goal),L=Math.max(L,+t.goal)),J(t.zero)&&(D=Math.min(0,D),L=Math.max(0,L));var U=qt(D,L,4),W=qt(Math.min.apply(null,I),Math.max.apply(null,I),5),q=U.ticks.map(function(B){return g(B,t,!0)}),st=Se(q)+(O(t.yLabel)?14:0),Q=20+(O(t.xLabel)?16:0),d=f+st,w=v-st,z=b-(m-R)-Q,$=function(B){return d+6+(B-W.lo)/(W.hi-W.lo)*(w-12)},G=function(B){return m+6+z-6-(B-U.lo)/(U.hi-U.lo)*(z-6)};U.ticks.forEach(function(B,Y){var V=G(B);N+='<line x1="'+a(d)+'" x2="'+a(d+w)+'" y1="'+a(V)+'" y2="'+a(V)+'" stroke="'+e.grid+'" stroke-dasharray="2 4"/>'+M(d-8,V+3.5,q[Y],H(e,10,'text-anchor="end"'))});var dt=Math.max(1,Math.ceil(W.ticks.length*44/w));if(W.ticks.forEach(function(B,Y){if(!(Y%dt)){var V=$(B);N+='<line x1="'+a(V)+'" x2="'+a(V)+'" y1="'+a(m)+'" y2="'+a(m+z)+'" stroke="'+e.grid+'" stroke-dasharray="2 4"/>'+M(V,m+z+15,g(B,k,!0),H(e,10,'text-anchor="middle"'))}}),O(t.xLabel)&&(N+=M(d+w/2,m+z+32,t.xLabel,H(e,10,'text-anchor="middle" font-weight="600"'))),O(t.yLabel)){var ht=m+z/2;N+='<text x="'+a(f+4)+'" y="'+a(ht)+'" transform="rotate(-90 '+a(f+4)+" "+a(ht)+')" text-anchor="middle" '+H(e,10,'font-weight="600"')+' dominant-baseline="hanging">'+String(t.yLabel).replace(/[&<>"]/g,function(B){return{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[B]})+"</text>"}O(t.goal)&&(N+=At(t,e,d,d+w,G(+t.goal))),C&&o.forEach(function(B,Y){var V=Be(B.xs,B.ys);if(V){var kt=Math.min.apply(null,B.xs),K=Math.max.apply(null,B.xs),bt=V.slope*kt+V.intercept,Ot=V.slope*K+V.intercept,Dt=s[Y%s.length];N+='<line x1="'+a($(kt))+'" y1="'+a(X(G(bt),m,m+z))+'" x2="'+a($(K))+'" y2="'+a(X(G(Ot),m,m+z))+'" stroke="'+Dt+'" stroke-width="2" stroke-dasharray="6 4" stroke-linecap="round" stroke-opacity=".9"/>',N+=M(Math.min($(K),d+w)-2,X(G(Ot),m+10,m+z)-7,"r = "+V.r.toFixed(2),H(e,10,'text-anchor="end" font-weight="600"',Dt))}});var et=0,ft=u>150?3:4.5;o.forEach(function(B,Y){var V=s[Y%s.length];B.xs.forEach(function(kt,K){var bt=$(kt),Ot=G(B.ys[K]),Dt=(n[et]?n[et]+`
7
7
  `:F?T(Y)+`
8
8
  `:"")+(O(t.xLabel)?t.xLabel:"x")+": "+g(kt,k)+`
9
- `+(O(t.yLabel)?t.yLabel:"y")+": "+g(B.ys[K],t);N+='<circle cx="'+a(bt)+'" cy="'+a(Ot)+'" r="'+ft+'" fill="'+V+'" fill-opacity=".85" stroke="'+(t.background||e.tile)+'" stroke-width="1.5"'+(t.animate?' class="bzc-a" style="animation-delay:'+a(Math.min(.8,et*.012))+'s"':"")+"/>",N+=pt(bt-8,Ot-8,16,16,Dt),et++})});var mt=[];return o.forEach(function(B){B.xs.forEach(function(Y,V){mt.push([$(Y),G(B.ys[V])])})}),E.forEach(function(B){var Y=mt[B.i];Y&&(N+='<circle cx="'+a(Y[0])+'" cy="'+a(Y[1])+'" r="'+(ft+4)+'" fill="none" stroke="'+e.fg+'" stroke-width="1.5"/>'+M(X(Y[0],d+30,d+w-30),Y[1]-ft-9,B.text,H(e,10,'text-anchor="middle"',e.fg)))}),N},{summary:u+" points"+(F?" in "+o.length+" groups":"")})}var Zt={spark:le,line:oe,bars:se,scatter:pe,ring:fe,donut:ce,gauge:ue,progress:he,heatmap:me},De=t=>t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase());function Qt(t,e={}){if(!Zt[t])throw new Error(`Bezel Charts: unknown chart type "${t}". Choose one of: ${Object.keys(Zt).join(", ")}.`);let r={};for(let[l,n]of Object.entries(e))r[De(l)]=n;r.animate=J(r.animate),r.frame=r.frame==="none"?"none":"bezel";let i=r.theme==="light"||r.theme==="dark"?r.theme:r.autoTheme||"dark";return Zt[t](r,_t[i])}function de(t){return t.replace(/<rect class="bzc-hit"[^>]*\/>/g,"").replace(/<circle[^>]* class="bzc-hit"[^>]*\/>/g,"").replace(/ data-tip="[^"]*"/g,"")}function Ge(t,e={}){return de(Qt(t,{...e,animate:!1}))}var Oe=["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"],Pe=`: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 ${lt};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}`,Ue=()=>typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null,He=()=>{let t=typeof document<"u"&&document.documentElement?.getAttribute?.("data-theme");return t==="light"||t==="dark"?t:null},ge=new Set;typeof MutationObserver=="function"&&typeof document<"u"&&document.documentElement&&new MutationObserver(()=>ge.forEach(t=>t.refresh())).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});var Ie=typeof HTMLElement>"u"?class{}:HTMLElement,Jt=class extends Ie{static get observedAttributes(){return Oe}static get themes(){return _t}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"}),this.shadowRoot.addEventListener("pointermove",e=>this.#o(e)),this.shadowRoot.addEventListener("pointerdown",e=>this.#o(e)),this.addEventListener("pointerleave",()=>this.shadowRoot.querySelector(".tip")?.classList.remove("on"))),ge.add(this),this.#t=Ue(),this.#t?.addEventListener?.("change",this.#l),typeof ResizeObserver=="function"?(this.#a=new ResizeObserver(([e])=>{let r=Math.round(e.contentRect.width);(!this.#e||!this.hasAttribute("width")&&r>0&&Math.abs(r-this.#n)>1)&&this.#r()}),this.#a.observe(this)):this.#r()}disconnectedCallback(){ge.delete(this),this.#a?.disconnect(),this.#t?.removeEventListener?.("change",this.#l)}attributeChangedCallback(){!this.#e||this.#i||(this.#i=!0,queueMicrotask(()=>{this.#i=!1,this.#r()}))}get options(){let e={};for(let r of Oe)this.hasAttribute(r)&&(e[r]=this.getAttribute(r));return e.width||(e.width=this.#n||360),e.autoTheme=He()||(this.#t?this.#t.matches?"dark":"light":"dark"),e}refresh(){this.#e&&this.#r()}toSVG(e={}){return de(Qt(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)}#a=null;#t=null;#n=0;#e=!1;#i=!1;#l=()=>{let e=this.getAttribute("theme");(!e||e==="auto")&&this.refresh()};#r(){if(!this.shadowRoot)return;let e=Math.round(this.getBoundingClientRect?.().width||0);this.#n=e>0?e:360;let r=this.options;r.animate=!this.#e&&!this.hasAttribute("static");let i;try{i=Qt(this.chartType,r)}catch(l){i=`<p style="font:13px ${tt};color:#d63f7c">${ut(l.message)}</p>`}i=i.replace(/<title>[\s\S]*?<\/title>/,""),this.shadowRoot.innerHTML=`<style>${Pe}</style>${i}<div class="tip" role="status"></div>`,this.#e=!0,this.dispatchEvent(new CustomEvent("bezel-render",{bubbles:!0}))}#o(e){let r=this.shadowRoot.querySelector(".tip");if(!r||this.hasAttribute("no-tooltips"))return;let i=e.target?.closest?.("[data-tip]");if(!i){r.classList.remove("on");return}r.textContent=i.getAttribute("data-tip");let l=this.getBoundingClientRect(),n=r.offsetWidth/2;r.style.left=`${X(e.clientX-l.left,n,Math.max(n,l.width-n))}px`,r.style.top=`${e.clientY-l.top}px`,r.classList.add("on")}};var Vr="1.1.0",$e=Object.keys(Zt);if(typeof customElements<"u"&&typeof HTMLElement<"u"){for(let t of $e){let e=`bezel-${t}`;customElements.get(e)||customElements.define(e,class extends Jt{get chartType(){return t}})}customElements.get("bezel-chart")||customElements.define("bezel-chart",class extends Jt{})}export{Jt as BezelChart,Qt as render,_t as themes,Ge as toSVG,$e as types,Vr as version};
9
+ `+(O(t.yLabel)?t.yLabel:"y")+": "+g(B.ys[K],t);N+='<circle cx="'+a(bt)+'" cy="'+a(Ot)+'" r="'+ft+'" fill="'+V+'" fill-opacity=".85" stroke="'+(t.background||e.tile)+'" stroke-width="1.5"'+(t.animate?' class="bzc-a" style="animation-delay:'+a(Math.min(.8,et*.012))+'s"':"")+"/>",N+=pt(bt-8,Ot-8,16,16,Dt),et++})});var mt=[];return o.forEach(function(B){B.xs.forEach(function(Y,V){mt.push([$(Y),G(B.ys[V])])})}),E.forEach(function(B){var Y=mt[B.i];Y&&(N+='<circle cx="'+a(Y[0])+'" cy="'+a(Y[1])+'" r="'+(ft+4)+'" fill="none" stroke="'+e.fg+'" stroke-width="1.5"/>'+M(X(Y[0],d+30,d+w-30),Y[1]-ft-9,B.text,H(e,10,'text-anchor="middle"',e.fg)))}),N},{summary:u+" points"+(F?" in "+o.length+" groups":"")})}var Zt={spark:le,line:oe,bars:se,scatter:pe,ring:fe,donut:ce,gauge:ue,progress:he,heatmap:me},De=t=>t.replace(/-([a-z])/g,(e,r)=>r.toUpperCase());function Qt(t,e={}){if(!Zt[t])throw new Error(`Bezel Charts: unknown chart type "${t}". Choose one of: ${Object.keys(Zt).join(", ")}.`);let r={};for(let[l,n]of Object.entries(e))r[De(l)]=n;r.animate=J(r.animate),r.frame=r.frame==="none"?"none":"bezel";let i=r.theme==="light"||r.theme==="dark"?r.theme:r.autoTheme||"dark";return Zt[t](r,_t[i])}function de(t){return t.replace(/<rect class="bzc-hit"[^>]*\/>/g,"").replace(/<circle[^>]* class="bzc-hit"[^>]*\/>/g,"").replace(/ data-tip="[^"]*"/g,"")}function Ge(t,e={}){return de(Qt(t,{...e,animate:!1}))}var Oe=["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"],Pe=`: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 ${lt};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}`,Ue=()=>typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null,He=()=>{let t=typeof document<"u"&&document.documentElement?.getAttribute?.("data-theme");return t==="light"||t==="dark"?t:null},ge=new Set;typeof MutationObserver=="function"&&typeof document<"u"&&document.documentElement&&new MutationObserver(()=>ge.forEach(t=>t.refresh())).observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});var Ie=typeof HTMLElement>"u"?class{}:HTMLElement,Jt=class extends Ie{static get observedAttributes(){return Oe}static get themes(){return _t}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"}),this.shadowRoot.addEventListener("pointermove",e=>this.#o(e)),this.shadowRoot.addEventListener("pointerdown",e=>this.#o(e)),this.addEventListener("pointerleave",()=>this.shadowRoot.querySelector(".tip")?.classList.remove("on"))),ge.add(this),this.#t=Ue(),this.#t?.addEventListener?.("change",this.#l),typeof ResizeObserver=="function"?(this.#a=new ResizeObserver(([e])=>{let r=Math.round(e.contentRect.width);(!this.#e||!this.hasAttribute("width")&&r>0&&Math.abs(r-this.#n)>1)&&this.#r()}),this.#a.observe(this)):this.#r()}disconnectedCallback(){ge.delete(this),this.#a?.disconnect(),this.#t?.removeEventListener?.("change",this.#l)}attributeChangedCallback(){!this.#e||this.#i||(this.#i=!0,queueMicrotask(()=>{this.#i=!1,this.#r()}))}get options(){let e={};for(let r of Oe)this.hasAttribute(r)&&(e[r]=this.getAttribute(r));return e.width||(e.width=this.#n||360),e.autoTheme=He()||(this.#t?this.#t.matches?"dark":"light":"dark"),e}refresh(){this.#e&&this.#r()}toSVG(e={}){return de(Qt(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)}#a=null;#t=null;#n=0;#e=!1;#i=!1;#l=()=>{let e=this.getAttribute("theme");(!e||e==="auto")&&this.refresh()};#r(){if(!this.shadowRoot)return;let e=Math.round(this.getBoundingClientRect?.().width||0);this.#n=e>0?e:360;let r=this.options;r.animate=!this.#e&&!this.hasAttribute("static");let i;try{i=Qt(this.chartType,r)}catch(l){i=`<p style="font:13px ${tt};color:#d63f7c">${ut(l.message)}</p>`}i=i.replace(/<title>[\s\S]*?<\/title>/,""),this.shadowRoot.innerHTML=`<style>${Pe}</style>${i}<div class="tip" role="status"></div>`,this.#e=!0,this.dispatchEvent(new CustomEvent("bezel-render",{bubbles:!0}))}#o(e){let r=this.shadowRoot.querySelector(".tip");if(!r||this.hasAttribute("no-tooltips"))return;let i=e.target?.closest?.("[data-tip]");if(!i){r.classList.remove("on");return}r.textContent=i.getAttribute("data-tip");let l=this.getBoundingClientRect(),n=r.offsetWidth/2;r.style.left=`${X(e.clientX-l.left,n,Math.max(n,l.width-n))}px`,r.style.top=`${e.clientY-l.top}px`,r.classList.add("on")}};var Vr="1.1.1",$e=Object.keys(Zt);if(typeof customElements<"u"&&typeof HTMLElement<"u"){for(let t of $e){let e=`bezel-${t}`;customElements.get(e)||customElements.define(e,class extends Jt{get chartType(){return t}})}customElements.get("bezel-chart")||customElements.define("bezel-chart",class extends Jt{})}export{Jt as BezelChart,Qt as render,_t as themes,Ge as toSVG,$e as types,Vr as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bezel-charts",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Small, polished charts as zero-dependency web components. Sparklines, lines, bars, 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",
@@ -38,7 +38,7 @@
38
38
  "type": "git",
39
39
  "url": "git+https://github.com/ShazMoghaddam/bezel-charts.git"
40
40
  },
41
- "homepage": "https://shazmoghaddam.github.io/bezel-charts/",
41
+ "homepage": "https://shazmoghaddam.github.io/bezel-charts/site/",
42
42
  "bugs": "https://github.com/ShazMoghaddam/bezel-charts/issues",
43
43
  "engines": {
44
44
  "node": ">=20"
package/src/index.js CHANGED
@@ -7,7 +7,7 @@ import { TYPES, render, toSVG } from './render.js';
7
7
  import { THEMES } from './core/themes.js';
8
8
  import { BezelChart } from './element.js';
9
9
 
10
- export const version = '1.1.0';
10
+ export const version = '1.1.1';
11
11
  export const types = Object.keys(TYPES);
12
12
  export { render, toSVG, BezelChart, THEMES as themes };
13
13