@skdx/web-components-charts 0.38.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.
- package/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/area.cjs +109 -0
- package/dist/area.d.cts +2 -0
- package/dist/area.d.ts +2 -0
- package/dist/area.js +109 -0
- package/dist/bar.cjs +109 -0
- package/dist/bar.d.cts +2 -0
- package/dist/bar.d.ts +2 -0
- package/dist/bar.js +109 -0
- package/dist/boxplot.cjs +109 -0
- package/dist/boxplot.d.cts +2 -0
- package/dist/boxplot.d.ts +2 -0
- package/dist/boxplot.js +109 -0
- package/dist/bubble.cjs +109 -0
- package/dist/bubble.d.cts +2 -0
- package/dist/bubble.d.ts +2 -0
- package/dist/bubble.js +109 -0
- package/dist/bullet.cjs +109 -0
- package/dist/bullet.d.cts +2 -0
- package/dist/bullet.d.ts +2 -0
- package/dist/bullet.js +109 -0
- package/dist/bump.cjs +109 -0
- package/dist/bump.d.cts +2 -0
- package/dist/bump.d.ts +2 -0
- package/dist/bump.js +109 -0
- package/dist/candlestick.cjs +109 -0
- package/dist/candlestick.d.cts +2 -0
- package/dist/candlestick.d.ts +2 -0
- package/dist/candlestick.js +109 -0
- package/dist/chord.cjs +109 -0
- package/dist/chord.d.cts +2 -0
- package/dist/chord.d.ts +2 -0
- package/dist/chord.js +109 -0
- package/dist/circle-packing.cjs +109 -0
- package/dist/circle-packing.d.cts +2 -0
- package/dist/circle-packing.d.ts +2 -0
- package/dist/circle-packing.js +109 -0
- package/dist/combo.cjs +109 -0
- package/dist/combo.d.cts +2 -0
- package/dist/combo.d.ts +2 -0
- package/dist/combo.js +109 -0
- package/dist/dumbbell.cjs +109 -0
- package/dist/dumbbell.d.cts +2 -0
- package/dist/dumbbell.d.ts +2 -0
- package/dist/dumbbell.js +109 -0
- package/dist/funnel.cjs +109 -0
- package/dist/funnel.d.cts +2 -0
- package/dist/funnel.d.ts +2 -0
- package/dist/funnel.js +109 -0
- package/dist/gantt.cjs +109 -0
- package/dist/gantt.d.cts +2 -0
- package/dist/gantt.d.ts +2 -0
- package/dist/gantt.js +109 -0
- package/dist/gauge.cjs +109 -0
- package/dist/gauge.d.cts +2 -0
- package/dist/gauge.d.ts +2 -0
- package/dist/gauge.js +109 -0
- package/dist/heatmap.cjs +109 -0
- package/dist/heatmap.d.cts +2 -0
- package/dist/heatmap.d.ts +2 -0
- package/dist/heatmap.js +109 -0
- package/dist/histogram.cjs +109 -0
- package/dist/histogram.d.cts +2 -0
- package/dist/histogram.d.ts +2 -0
- package/dist/histogram.js +109 -0
- package/dist/icicle.cjs +109 -0
- package/dist/icicle.d.cts +2 -0
- package/dist/icicle.d.ts +2 -0
- package/dist/icicle.js +109 -0
- package/dist/index-oF5ss8v9.d.cts +2331 -0
- package/dist/index-oF5ss8v9.d.ts +2331 -0
- package/dist/index.cjs +109 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +109 -0
- package/dist/line.cjs +109 -0
- package/dist/line.d.cts +2 -0
- package/dist/line.d.ts +2 -0
- package/dist/line.js +109 -0
- package/dist/linear-gauge.cjs +109 -0
- package/dist/linear-gauge.d.cts +2 -0
- package/dist/linear-gauge.d.ts +2 -0
- package/dist/linear-gauge.js +109 -0
- package/dist/map.cjs +109 -0
- package/dist/map.d.cts +2 -0
- package/dist/map.d.ts +2 -0
- package/dist/map.js +109 -0
- package/dist/marimekko.cjs +109 -0
- package/dist/marimekko.d.cts +2 -0
- package/dist/marimekko.d.ts +2 -0
- package/dist/marimekko.js +109 -0
- package/dist/network.cjs +109 -0
- package/dist/network.d.cts +2 -0
- package/dist/network.d.ts +2 -0
- package/dist/network.js +109 -0
- package/dist/organization.cjs +109 -0
- package/dist/organization.d.cts +2 -0
- package/dist/organization.d.ts +2 -0
- package/dist/organization.js +109 -0
- package/dist/parallel.cjs +109 -0
- package/dist/parallel.d.cts +2 -0
- package/dist/parallel.d.ts +2 -0
- package/dist/parallel.js +109 -0
- package/dist/pareto.cjs +109 -0
- package/dist/pareto.d.cts +2 -0
- package/dist/pareto.d.ts +2 -0
- package/dist/pareto.js +109 -0
- package/dist/pie.cjs +109 -0
- package/dist/pie.d.cts +2 -0
- package/dist/pie.d.ts +2 -0
- package/dist/pie.js +109 -0
- package/dist/polar-area.cjs +109 -0
- package/dist/polar-area.d.cts +2 -0
- package/dist/polar-area.d.ts +2 -0
- package/dist/polar-area.js +109 -0
- package/dist/radar.cjs +109 -0
- package/dist/radar.d.cts +2 -0
- package/dist/radar.d.ts +2 -0
- package/dist/radar.js +109 -0
- package/dist/radial.cjs +109 -0
- package/dist/radial.d.cts +2 -0
- package/dist/radial.d.ts +2 -0
- package/dist/radial.js +109 -0
- package/dist/range.cjs +109 -0
- package/dist/range.d.cts +2 -0
- package/dist/range.d.ts +2 -0
- package/dist/range.js +109 -0
- package/dist/sankey.cjs +109 -0
- package/dist/sankey.d.cts +2 -0
- package/dist/sankey.d.ts +2 -0
- package/dist/sankey.js +109 -0
- package/dist/scatter.cjs +109 -0
- package/dist/scatter.d.cts +2 -0
- package/dist/scatter.d.ts +2 -0
- package/dist/scatter.js +109 -0
- package/dist/sparkline.cjs +109 -0
- package/dist/sparkline.d.cts +2 -0
- package/dist/sparkline.d.ts +2 -0
- package/dist/sparkline.js +109 -0
- package/dist/sunburst.cjs +109 -0
- package/dist/sunburst.d.cts +2 -0
- package/dist/sunburst.d.ts +2 -0
- package/dist/sunburst.js +109 -0
- package/dist/swarm.cjs +109 -0
- package/dist/swarm.d.cts +2 -0
- package/dist/swarm.d.ts +2 -0
- package/dist/swarm.js +109 -0
- package/dist/timeline.cjs +109 -0
- package/dist/timeline.d.cts +2 -0
- package/dist/timeline.d.ts +2 -0
- package/dist/timeline.js +109 -0
- package/dist/tree.cjs +109 -0
- package/dist/tree.d.cts +2 -0
- package/dist/tree.d.ts +2 -0
- package/dist/tree.js +109 -0
- package/dist/treemap.cjs +109 -0
- package/dist/treemap.d.cts +2 -0
- package/dist/treemap.d.ts +2 -0
- package/dist/treemap.js +109 -0
- package/dist/waffle.cjs +109 -0
- package/dist/waffle.d.cts +2 -0
- package/dist/waffle.d.ts +2 -0
- package/dist/waffle.js +109 -0
- package/dist/waterfall.cjs +109 -0
- package/dist/waterfall.d.cts +2 -0
- package/dist/waterfall.d.ts +2 -0
- package/dist/waterfall.js +109 -0
- package/package.json +76 -0
package/dist/treemap.cjs
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";var se=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var _t=Object.getOwnPropertyNames;var Zt=Object.prototype.hasOwnProperty;var Et=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},Wt=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of _t(n))!Zt.call(e,i)&&i!==t&&se(e,i,{get:()=>n[i],enumerable:!(r=bt(n,i))||r.enumerable});return e};var Ut=e=>Wt(se({},"__esModule",{value:!0}),e),h=(e,n,t,r)=>{for(var i=r>1?void 0:r?bt(n,t):n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=(r?s(n,t,i):s(i))||i);return r&&i&&se(n,t,i),i};var fn={};Et(fn,{SkdxTreemap:()=>A});module.exports=Ut(fn);var N=require("lit/decorators.js");var gt=e=>Number(e.toPrecision(12)),qt,Kt=e=>(qt??(qt=new Intl.NumberFormat)).format(gt(e)),Yt=e=>{let n=Math.round(Math.abs(e)),t=e<0?"-":"",r=Math.floor(n/3600),i=Math.floor(n%3600/60),o=s=>String(s).padStart(2,"0");return r>0?`${t}${r}h ${o(i)}m`:i>0?`${t}${i}m ${o(n%60)}s`:`${t}${n}s`};function xt(e){if(e===void 0)return Kt;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,s=u=>i?d=>u(d)+i:u,a=u=>r===void 0?u===void 0?{}:{maximumFractionDigits:u}:{minimumFractionDigits:r,maximumFractionDigits:r},l=u=>{let d=new Intl.NumberFormat(t,u);return s(f=>d.format(gt(f)))},c=u=>{let d=new Intl.DateTimeFormat(t,o?{...u,timeZone:o}:u);return f=>d.format(f)};switch(n){case"integer":return l({maximumFractionDigits:0});case"decimal":return l(a(2));case"percent":return l({style:"percent",...a(0)});case"currency":return l({style:"currency",currency:e.currency??"USD",...a()});case"compact":return l({notation:"compact",...a(1)});case"scientific":return l({notation:"scientific",...a(2)});case"date":return c({dateStyle:"medium"});case"time":return c({timeStyle:"short"});case"datetime":return c({dateStyle:"medium",timeStyle:"short"});case"duration":return s(Yt)}}var v=e=>Number(e.toFixed(2)),we=e=>typeof e=="number"&&Number.isFinite(e);function Me(e){let n=1/0,t=-1/0;for(let r of e)we(r)&&(r<n&&(n=r),r>t&&(t=r));return n===1/0?[0,0]:[n,t]}var X=1e3,Q=60*X,J=60*Q,ae=24*J,gn=[X,5*X,15*X,30*X,Q,5*Q,15*Q,30*Q,J,3*J,6*J,12*J,ae,2*ae,7*ae,14*ae];var Xt=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,Qt=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,Jt={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function en(e,n,t){return e.replace(Qt,(r,i,o)=>{let s=Jt[i];if(s===void 0)return i+o;let l=(o.match(Xt)??[]).map((c,u)=>{let d=Number(c);if(s===-1)return String(d+n);if(s===-2)return String(d+t);let f=u%s;return s===7?f===5?String(d+n):f===6?String(d+t):c:String(f%2===0?d+n:d+t)});return i+l.join(" ")})}var yt=(e,n,t)=>e.map(r=>{switch(r.kind){case"rect":return{...r,x:r.x+n,y:r.y+t};case"circle":return{...r,cx:r.cx+n,cy:r.cy+t};case"line":return{...r,x1:r.x1+n,x2:r.x2+n,y1:r.y1+t,y2:r.y2+t};case"text":return{...r,x:r.x+n,y:r.y+t};case"path":return{...r,d:en(r.d,n,t)}}});var Ce=["primary","success","warning","danger","neutral"].flatMap(e=>[500,700].map(n=>`var(--skdx-color-${e}-${n})`)).sort((e,n)=>Number(e.endsWith("700)"))-Number(n.endsWith("700)"))),C={axis:"var(--skdx-color-border-strong)",grid:"var(--skdx-color-border-subtle)",label:"var(--skdx-color-text-muted)",focus:"var(--skdx-color-focus-ring)",positive:"var(--skdx-color-success-500)",negative:"var(--skdx-color-danger-500)",fontFamily:"var(--skdx-font-family)",fontSize:"var(--skdx-font-size-xs)"};var vt=(e,n)=>n??Ce[e%Ce.length];function ee(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function wt(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var le=20,tn=120,Mt=e=>{let n=ee(e);return n&&(n.position==="left"||n.position==="right")?n.width??tn:0},ke=(e,n=600,t=300)=>({width:(e.width??n)-Mt(e),height:(e.height??t)-(ee(e)?.position==="bottom"?le:0)}),$e=e=>{let n=ee(e);return n&&(n.position===void 0||n.position==="top")?le:0},_=6.5,ce=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:vt(n)),Ct=(e,n)=>e.hiddenSeries?.includes(n)??!1;function Se(e,n,t=[],r={},i=10,o=8,s=!1){let a=[],l=r.maxItems,c=l!==void 0&&l>=0&&e.length>l?e.slice(0,l):e,u=e.length-c.length,d=r.interactive??!0,f=o,w=i,y=(I,m,x,k)=>{let z=(m?18:4)+I.length*_;f>o&&(s||f+z>n-8)&&(f=o,w+=le),m&&a.push({kind:"rect",part:"legend-swatch",x:f,y:w-5,width:10,height:10,fill:m,opacity:k?.3:void 0,item:x}),a.push({kind:"text",part:"legend-label",x:f+(m?14:0),y:w,text:I,baseline:"middle",fill:k?C.grid:C.label,item:x}),f+=z+12};for(let I of c){let m=t.includes(I.name),x=d?{label:I.name,series:I.name,legend:!0}:void 0;y(r.formatter?.(I.name)??I.name,I.color,x,m)}return u>0&&y(`+${u} more`,void 0,void 0,!1),r.align==="end"?nn(a,n):a}function nn(e,n){let t=new Map;for(let i of e){let o=i.kind==="rect"?i.y+5:i.y;t.set(o,[...t.get(o)??[],i])}let r=[];for(let i of t.values()){let o=Math.max(...i.map(a=>a.kind==="rect"?a.x+a.width:a.x+a.text.length*_)),s=n-8-o;for(let a of i)r.push({...a,x:a.x+s})}return r}var rn=(e,n,t={})=>new Set(Se(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function Ie(e,n,t,r=[]){let i=ee(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,s=wt(e),a=o?.position==="bottom",l=Mt(e),c=e.hiddenSeries??[],u=o?l?Se(r,1/0,c,o,10,(o.position==="right"?n:0)+8,!0):Se(r,n,c,o,a?t+10:10):[],d=a?rn(r,n,o):0;return{width:n+l,height:a?t+Math.max(1,d)*le:t,legendOffset:o?.position==="left"?l:void 0,tooltip:s.enabled,tooltipFormatter:s.formatter,axisTooltipFormatter:s.axisFormatter,tooltipPortal:s.portal,tooltipPlacement:s.placement,tooltipAnchored:s.followPointer===!1?!0:void 0,description:e.description,decorative:e.decorative,animate:e.animate===!0?300:e.animate||void 0,responsive:!!e.responsive,shapes:u}}function Te(e){let n=e.legendOffset;if(!n)return e;let t=[...yt(e.shapes.filter(l=>!l.part.startsWith("legend-")),n,0),...e.shapes.filter(l=>l.part.startsWith("legend-"))],r=l=>({...l,x:l.x+n}),i=e.hit?{...e.hit,plot:r(e.hit.plot),xs:e.hit.xs.map(l=>l+n),brush:e.hit.brush?{box:r(e.hit.brush.box),window:r(e.hit.brush.window)}:void 0}:void 0,o=e.edit,s=o?{...o,scale:l=>o.scale(l)+n,invert:l=>o.invert(l-n),bars:o.bars.map(l=>({...l,x0:l.x0+n,x1:l.x1+n}))}:void 0,a=e.map?{...e.map,plot:r(e.map.plot)}:void 0;return{...e,shapes:t,hit:i,edit:s,map:a,legendOffset:void 0}}function de(e,n,t,r,i,o="auto"){let s=Array.isArray(t)?t:[t],a=Math.max(...s.map(f=>f.length))*_+12,l=6+s.length*16,c=o==="top"?{x:e-a/2,y:n-l-8}:o==="bottom"?{x:e-a/2,y:n+8}:o==="left"?{x:e-a-8,y:n-l/2}:o==="right"?{x:e+8,y:n-l/2}:{x:e+12,y:n-l-6},u=Math.max(0,Math.min(r-a,c.x)),d=Math.max(0,Math.min(i-l,c.y));return[{kind:"rect",part:"tooltip",x:v(u),y:v(d),width:v(a),height:l,fill:"var(--skdx-color-surface-raised)",stroke:C.axis,rx:3},...s.map((f,w)=>({kind:"text",part:"tooltip-label",x:v(u+6),y:v(d+11+w*16),text:f,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:s.length>1&&w===0?"bold":void 0}))]}function St(e,n,t,r){let i=e.error!==void 0?"error":e.loading?"loading":n?"empty":null;if(!i)return null;let{width:o,height:s}=ke(e,t,r),a=i==="error"?e.error:i==="loading"?"Loading\u2026":e.emptyMessage??"No data available",l=[];return i==="loading"&&l.push({kind:"rect",part:"skeleton",x:0,y:0,width:o,height:s,fill:"var(--skdx-color-surface-sunken)",rx:4}),l.push({kind:"text",part:`state-${i}`,x:v(o/2),y:v(s/2),text:a,anchor:"middle",baseline:"middle",fill:i==="error"?"var(--skdx-color-text-danger)":C.label}),{...Ie(e,o,s),shapes:l,tooltip:!1}}var ue=(e,n,t,r={})=>({kind:"text",part:"label",x:e,y:n,text:t,fill:C.label,...r});var te=e=>Math.max(0,Math.min(1,e));function kt(e){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(n){let r=n[1],i=r.length===3?r.split("").map(o=>o+o).join(""):r;return[0,2,4].map(o=>parseInt(i.slice(o,o+2),16))}let t=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(e.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3])]:void 0}function $t(e,n){if(e.length===0)return C.axis;if(e.length===1)return e[0];let t=te(n)*(e.length-1),r=Math.min(e.length-2,Math.floor(t)),i=t-r,o=kt(e[r]),s=kt(e[r+1]);if(!o||!s)return e[Math.round(t)];let a=l=>Math.round(o[l]+(s[l]-o[l])*i);return`rgb(${a(0)}, ${a(1)}, ${a(2)})`}var It=(e,n)=>n!==void 0&&n>=2?Math.min(n-1,Math.floor(te(e)*n))/(n-1):te(e);function Tt(e,n,t,r=C.negative,i=String){let[o,s]=Me(n),a=e??{type:"sequential"},l=m=>v(.15+.85*m);if(a.type==="threshold"){let{thresholds:m,colors:x,labels:k}=a,z=O=>{if(typeof O!="number"||!Number.isFinite(O))return;let $=0;for(;$<m.length&&O>=m[$];)$++;return{fill:x[Math.min($,x.length-1)]??t,opacity:1}},j=x.map((O,$)=>({fill:O,opacity:1,label:k?.[$]??($===0?`< ${i(m[0]??0)}`:$===m.length?`\u2265 ${i(m[$-1])}`:`${i(m[$-1])} \u2013 ${i(m[$])}`)}));return{color:z,domain:[o,s],swatches:j,kind:"threshold"}}if(a.type==="ordinal"){let m=a.colors?.length?a.colors:[t];return{color:k=>typeof k=="number"&&Number.isFinite(k)?{fill:m[Math.abs(Math.round(k))%m.length],opacity:1}:void 0,domain:[o,s],swatches:m.map((k,z)=>({fill:k,opacity:1,label:String(z)})),kind:"ordinal"}}if(a.type==="diverging"){let[m,x,k]=a.domain??[-Math.max(Math.abs(o),Math.abs(s)),0,Math.max(Math.abs(o),Math.abs(s))],z=a.colors,j=L=>L<x?.5*(L-m)/Math.max(1e-12,x-m):.5+.5*(L-x)/Math.max(1e-12,k-x),O=L=>{let R=It(a.reversed?1-te(L):L,a.steps);if(z&&z.length>=2)return{fill:$t(z,R),opacity:1};let P=R<.5?r:t,V=Math.abs(R-.5)*2;return{fill:P,opacity:l(V)}},$=L=>typeof L=="number"&&Number.isFinite(L)?O(j(L)):void 0,H=a.steps??5,W=Array.from({length:H},(L,R)=>{let P=H===1?.5:R/(H-1),V=P<.5?m+(x-m)*(P*2):x+(k-x)*((P-.5)*2);return{...O(P),label:i(V)}});return{color:$,domain:[m,k],swatches:W,kind:"diverging"}}let[c,u]=a.domain??[o,s],d=a.colors,f=m=>{let x=It(a.reversed?1-te(m):m,a.steps);return d&&d.length>=2?{fill:$t(d,x),opacity:1}:{fill:d?.[0]??t,opacity:l(x)}},w=m=>typeof m!="number"||!Number.isFinite(m)?void 0:f(u===c?1:(m-c)/(u-c)),y=a.steps??5,I=Array.from({length:y},(m,x)=>{let k=y===1?1:x/(y-1);return{...f(k),label:i(c+(u-c)*k)}});return{color:w,domain:[c,u],swatches:I,kind:"sequential"}}function he(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var Oe=e=>e.id??e.name??e.series,Ot=e=>e.seriesId??e.series;function F(e,n){let t=!1;return n.id!==void 0&&(t=!0,Oe(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,Ot(e)!==n.series&&e.series!==n.series)||n.index!==void 0&&(t=!0,e.index!==n.index)||n.category!==void 0&&(t=!0,e.category!==n.category)?!1:t}function Z(e){let n={},t=Oe(e);t!==void 0&&(n.id=t);let r=Ot(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var ze=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function Le(e,n,t){let r=he(e),i=Z(n),o=r.some(s=>F(n,s));return t==="single"?o?[]:[i]:o?r.filter(s=>!F(n,s)):[...r,i]}var on=.2;function sn(e){let n=C.focus;switch(e.kind){case"rect":return{kind:"rect",part:"selected",x:e.x-1.5,y:e.y-1.5,width:e.width+3,height:e.height+3,fill:"none",stroke:n,rx:e.rx};case"circle":return{kind:"circle",part:"selected",cx:e.cx,cy:e.cy,r:e.r+2.5,fill:"none",stroke:n};case"path":return{kind:"path",part:"selected",d:e.d,fill:"none",stroke:n,strokeWidth:2.5};case"line":return{...e,part:"selected",stroke:n,strokeWidth:(e.strokeWidth??1)+3,title:void 0,item:void 0};case"text":return}}var an=(e,n)=>e.kind==="text"?{...e,fill:C.grid}:{...e,opacity:(e.opacity??1)*n};function Ae(e,n){let t=he(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:he(n.highlighted),i=r[0];if(t.length===0&&!i)return e;let o={highlighted:n.highlightScope?.highlighted??"item",faded:n.highlightScope?.faded??"global"},s=[],a=u=>!i||r.some(d=>F(u,d))?!0:o.highlighted==="series"?r.some(d=>d.series!==void 0&&F(u,{series:d.series})):!1,l=u=>{if(!i||o.faded==="none"||a(u))return!1;if(o.faded==="series"){let d=i.series;return d!==void 0&&F(u,{series:d})}return!0},c=e.shapes.map(u=>{let d=u.item;if(!d||d.legend)return u;if(t.some(f=>F(d,f))){let f=sn(u);f&&s.push(f)}return l(d)?an(u,on):u});return s.length?{...e,shapes:[...c,...s]}:{...e,shapes:c}}function Y(e,n,t,r,i){let o=e.getBoundingClientRect();return{x:o.width?(n-o.left)*r/o.width:n,y:o.height?(t-o.top)*i/o.height:t}}var Ne=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function zt(e,n){let t=0,r=1/0;return e.xs.forEach((i,o)=>{let s=Math.abs(i-n);s<r&&(r=s,t=o)}),t}function ne(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=zt(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Pe(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[zt(t,n)];return{kind:"line",part:"crosshair",x1:r,x2:r,y1:t.plot.y,y2:t.plot.y+t.plot.height,stroke:C.axis,dash:"3 3"}}function Be(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!Ne(r.plot,n,t))return[];let i=Pe(e,n),{rows:o}=ne(e,n),s=e.tooltipAnchored?r.plot.y+8:t;return[i,...de(i.x1,s,o,e.width,e.height,e.tooltipPlacement)]}function Re(e,n){let t=e.hit;if(!t||t.xs.length===0)return[];let r=t.rows.findIndex(o=>o[0]===n);if(r<0)return[];let i=t.xs[r];return Be(e,i,t.plot.y+8)}function De(e,n,t,r,i){if(!e.tooltip)return{lines:[],shapes:[]};if(e.hit?.crosshair){let{x:l,y:c}=Y(t,r,i,e.width,e.height);if(Ne(e.hit.plot,l,c)){let u=ne(e,l),d=Pe(e,l);if(u&&d)return{lines:u.rows,shapes:[d]}}}let o=n?.closest?.("[data-skdx-part]"),s=e.tooltipFormatter?E(e,n)?.item:void 0,a=s&&e.tooltipFormatter?.(s)||o&&Array.from(o.children).find(l=>l.tagName.toLowerCase()==="title")?.textContent;return a?{lines:Array.isArray(a)?a:[a],shapes:[]}:{lines:[],shapes:[]}}function Lt(e,n,t,r,i,o,s){let a=e?.closest?.("[data-skdx-part]"),l=s&&s.tooltipFormatter?E(s,e)?.item:void 0,c=l&&s?.tooltipFormatter?.(l)||a&&Array.from(a.children).find(y=>y.tagName.toLowerCase()==="title")?.textContent;if(!c)return[];let u=s?.tooltipAnchored?E(s,e):void 0,d=u?s?.shapes[u.index]:void 0,{x:f,y:w}=d?re(d):Y(n,t,r,i,o);return de(f,w,c,i,o,s?.tooltipPlacement)}function Fe(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:s}=Y(t,r,i,e.width,e.height),a=Be(e,o,s);if(a.length>0)return a}return Lt(n,t,r,i,e.width,e.height,e)}function Ge(e,n){let t=E(e,n);return t&&!t.item.legend?Z(t.item):null}var ln=(e,n)=>{let{x:t,y:r}=re(e),i=e.kind==="circle"?e.cy:e.kind==="rect"?e.y+e.height/2:r;return t>=n.x&&t<=n.x+n.width&&i>=n.y&&i<=n.y+n.height};function je(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!ln(i,n))continue;let o=Z(i.item),s=JSON.stringify(o);t.has(s)||(t.add(s),r.push(o))}return r}var He=e=>({kind:"rect",part:"selection-box",x:v(e.x),y:v(e.y),width:v(e.width),height:v(e.height),fill:C.focus,opacity:.12,stroke:C.focus}),fe=(e,n,t,r)=>({x:Math.min(e,t),y:Math.min(n,r),width:Math.abs(t-e),height:Math.abs(r-n)});function At(e,n,t){let r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let s=e[i],a=e[o];s.y>t!=a.y>t&&n<(a.x-s.x)*(t-s.y)/(a.y-s.y)+s.x&&(r=!r)}return r}function Ve(e,n){if(n.length<3)return[];let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor")continue;let{x:o,y:s}=re(i),a=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:s;if(!At(n,o,a))continue;let l=Z(i.item),c=JSON.stringify(l);t.has(c)||(t.add(c),r.push(l))}return r}var _e=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${v(n.x)} ${v(n.y)}`).join("L")}`:"",fill:C.focus,fillOpacity:.12,stroke:C.focus,dash:"4 3"}),pe=6;function Ze(e,n,t){let r=e.edit;if(r){for(let i of r.bars)if(!(t<i.y||t>i.y+i.height||n<i.x0-pe||n>i.x1+pe))return Math.abs(n-i.x0)<=pe?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=pe?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function Ee(e,n,t){let r=e.edit;return Nt(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function We(e,n,t){let r=e.edit,i=t.key==="ArrowRight"?1:t.key==="ArrowLeft"?-1:0;if(!r||n===null||!i||!(t.shiftKey||t.altKey))return;let o=r.bars.find(l=>l.index===n);if(!o)return;let s=t.altKey?t.shiftKey?"start":"end":"move",a=r.snap??r.invert(o.x0+10)-r.invert(o.x0);return Nt(r,{bar:o,mode:s},i*a)}function Nt(e,{bar:n,mode:t},r){let i=a=>e.snap?Math.round(a/e.snap)*e.snap:a,o=n.start,s=n.end;return t==="move"?(o=i(n.start+r),s=o+(n.end-n.start)):t==="start"?o=Math.min(i(n.start+r),n.end):s=Math.max(i(n.end+r),n.start),{id:n.id,name:n.name,start:o,end:s}}function Ue(e,n,t){let r=e.edit,i=r.scale(t.start),o=r.scale(t.end);return{kind:"rect",part:"edit-ghost",x:v(Math.min(i,o)),y:v(n.bar.y),width:v(Math.max(1,Math.abs(o-i))),height:v(n.bar.height),fill:C.focus,opacity:.25,stroke:C.focus,rx:2}}var cn=64,dn=e=>Math.max(1,Math.min(cn,e));function qe(e,n,t,r){let i=n>0?.8:1.25,o=dn(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:s,scale:a}=e,[l,c]=e.view.center,u=(t-(s.x+s.width/2))/a,d=(r-(s.y+s.height/2))/a,f=e.view.zoom/o;return{center:[l+u*(1-f),e.fromY(e.toY(c)-d*(1-f))],zoom:o}}function Ke(e,n,t,r){let{scale:i}=e;return{center:[n.center[0]-t/i,e.fromY(e.toY(n.center[1])+r/i)],zoom:n.zoom}}function E(e,n){let t=n?.closest?.("[data-skdx-i]"),r=Number(t?.getAttribute("data-skdx-i")),i=Number.isInteger(r)?e.shapes[r]?.item:void 0;return i?{index:r,item:i}:void 0}var me=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function re(e){switch(e.kind){case"rect":return{x:e.x+e.width/2,y:e.y};case"circle":return{x:e.cx,y:e.cy-e.r};case"line":return{x:(e.x1+e.x2)/2,y:Math.min(e.y1,e.y2)};case"text":return{x:e.x,y:e.y};case"path":{let n=/M\s*(-?[\d.]+)[ ,](-?[\d.]+)/.exec(e.d);return n?{x:Number(n[1]),y:Number(n[2])}:{x:0,y:0}}}}function Ye(e,n){let t=n===null?void 0:e.shapes[n];if(!t)return[];let r=C.focus,i;switch(t.kind){case"rect":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-2,width:t.width+4,height:t.height+4,fill:"none",stroke:r,rx:2};break;case"circle":i={kind:"circle",part:"focus",cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:r};break;case"line":i={kind:"line",part:"focus",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:r,strokeWidth:4};break;case"text":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-8,width:t.text.length*_+4,height:16,fill:"none",stroke:r,rx:2};break;case"path":i={kind:"path",part:"focus",d:t.d,stroke:r,strokeWidth:2,fill:"none"};break}let{x:o,y:s}=re(t),a=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...a?de(v(o),v(s),a,e.width,e.height):[]]}function Xe(e,n,t){let r=me(e);if(r.length===0)return;let i=n===null?-1:r.indexOf(n);switch(t){case"ArrowRight":case"ArrowDown":return r[Math.min(r.length-1,i+1)];case"ArrowLeft":case"ArrowUp":return r[Math.max(0,i<=0?0:i-1)];case"Home":return r[0];case"End":return r[r.length-1];case"Escape":return null;default:return}}var q=2,K=(e,n,t)=>{let r=Math.max(q,Math.min(t,Math.round(n))),i=Math.max(0,Math.min(t-r,Math.round(e)));return{start:i,end:i+r}},Pt=(e,n)=>!e||e.start<=0&&e.end>=n;function Qe(e,n,t){if(e.count<=q||!e.plot.width)return;let{start:r,end:i}=e.zoom,o=i-r,s=n>0?1.25:.8,a=Math.max(q,Math.min(e.count,Math.round(o*s)));if(a===o)return n>0&&!Pt(e.zoom,e.count)?K(r,a,e.count):void 0;let l=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),c=r+l*o;return K(c-l*a,a,e.count)}function Je(e,n,t,r){let i=n.end-n.start,o=Math.max(q,Math.min(e.count,Math.round(i/Math.max(.05,t)))),s=Math.max(0,Math.min(1,(r-e.plot.x)/Math.max(1,e.plot.width)));return K(n.start+s*i-s*o,o,e.count)}function et(e,n,t){let r=n.end-n.start,i=e.plot.width/Math.max(1,r);return K(n.start-t/i,r,e.count)}function tt(e,n,t){let r=e.brush;if(!r||!Ne(r.box,n,t))return;let i=r.window;if(Math.abs(n-i.x)<=6)return{grab:"left",zoom:e.zoom};if(Math.abs(n-(i.x+i.width))<=6)return{grab:"right",zoom:e.zoom};if(n>i.x&&n<i.x+i.width)return{grab:"move",zoom:e.zoom};let o=e.zoom.end-e.zoom.start,s=(n-r.box.x)/Math.max(1,r.box.width)*e.count;return{grab:"move",zoom:K(s-o/2,o,e.count)}}function nt(e,n,t,r){let i=e.brush;if(!i)return t;let o=r/Math.max(1,i.box.width)*e.count;if(n==="move")return K(t.start+o,t.end-t.start,e.count);if(n==="left")return{start:Math.max(0,Math.min(t.end-q,Math.round(t.start+o))),end:t.end};let s=Math.min(e.count,Math.max(t.start+q,Math.round(t.end+o)));return{start:t.start,end:s}}function it(e,n){switch(n.type){case"svg":return Promise.resolve(rt(e,n.label,n.resolve));case"csv":return Promise.resolve(Ft(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=rt(e,n.label,n.resolve);return Dt(t,e.width,e.height,n.scale,n.background)}}}var G=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,"""),ie=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${G(String(t))}"`).join("");function Bt(e){let n=e.title?`<title>${G(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${ie([t,["d",e.d],["fill",e.fill??"none"],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-linecap",e.strokeLinecap],["stroke-linejoin",e.strokeLinejoin],["stroke-dasharray",e.dash],["opacity",e.opacity],["fill-opacity",e.fillOpacity]])}>${n}</path>`;case"rect":return`<rect${ie([t,["x",e.x],["y",e.y],["width",e.width],["height",e.height],["rx",e.rx],["fill",e.fill],["stroke",e.stroke],["fill-opacity",e.opacity]])}>${n}</rect>`;case"line":return`<line${ie([t,["x1",e.x1],["y1",e.y1],["x2",e.x2],["y2",e.y2],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-dasharray",e.dash],["opacity",e.opacity]])}>${n}</line>`;case"circle":return`<circle${ie([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${ie([t,["x",e.x],["y",e.y],["text-anchor",e.anchor],["dominant-baseline",e.baseline],["fill",e.fill],["font-weight",e.weight],["transform",e.rotate?`rotate(${e.rotate} ${e.x} ${e.y})`:void 0]])}>${G(e.text)}</text>`}}function Rt(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${G(t.id)}" x1="0" y1="0" x2="${t.vertical===!1?1:0}" y2="${t.vertical===!1?0:1}">${t.stops.map(r=>`<stop offset="${r.offset}" stop-color="${G(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function rt(e,n,t){let r=Rt(e)+e.shapes.map(Bt).join("");return t&&(r=r.replace(/var\((--[\w-]+)\)/g,(i,o)=>t(o).trim()||i)),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e.width} ${e.height}" width="${e.width}" height="${e.height}" role="img" aria-label="${G(n)}" font-family="${G(C.fontFamily)}" font-size="${G(C.fontSize)}"><title>${G(n)}</title>${r}</svg>`}function Dt(e,n,t,r=2,i){return new Promise((o,s)=>{let a=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"})),l=new Image;l.onload=()=>{URL.revokeObjectURL(a);let c=document.createElement("canvas");c.width=Math.round(n*r),c.height=Math.round(t*r);let u=c.getContext("2d");if(!u)return s(new Error("canvas 2d context unavailable"));i&&(u.fillStyle=i,u.fillRect(0,0,c.width,c.height)),u.drawImage(l,0,0,c.width,c.height),c.toBlob(d=>d?o(d):s(new Error("toBlob failed")),"image/png")},l.onerror=()=>{URL.revokeObjectURL(a),s(new Error("svg could not be decoded"))},l.src=a})}function Ft(e){let n=t=>{let r=t==null?"":String(t);return/[",\n\r]/.test(r)?`"${r.replace(/"/g,'""')}"`:r};return e.map(t=>t.map(n).join(",")).join(`\r
|
|
2
|
+
`)}var B=e=>we(e.value)?e.value:(e.children??[]).reduce((n,t)=>n+B(t),0);var be=e=>e.id??e.name;function Gt(e,n){for(let t of e){if(be(t)===n||t.name===n)return[t];let r=Gt(t.children??[],n);if(r)return[t,...r]}}var jt=(e,n)=>n==="asc"||n==="desc"?[...e].sort((t,r)=>n==="asc"?B(t)-B(r):B(r)-B(t)):[...e];function ot(e,n,t=1){return n===void 0?[...e]:e.map(r=>t>=n?{...r,value:B(r),children:void 0}:{...r,children:r.children?ot(r.children,n,t+1):void 0})}function Ht(e,n){if(n===void 0)return{nodes:[...e],path:[]};let t=Gt(e,n);if(!t)return{nodes:[...e],path:[]};let r=t[t.length-1];return{nodes:r.children?.length?r.children:[r],path:t}}function st(e,n){if(!n)return;let t=typeof n=="object"?n.maxRows??500:500,r=e.hit;if(r&&r.rows.length>0){let a=r.rows[0];if(r.rows.length>t)return;let l=["",...a.slice(1).map(u=>u.replace(/:\s[^:]*$/,""))],c=r.rows.map(u=>[u[0],...u.slice(1).map(d=>d.slice(d.lastIndexOf(": ")+2))]);return[l,...c]}let i=e.shapes.flatMap(a=>a.item&&!a.item.legend&&!(a.part==="anchor"&&!a.title)?[a.item]:[]);if(i.length===0||i.length>t)return;let o=["series","name","category","value"].filter(a=>i.some(l=>l[a]!==void 0)),s=(a,l)=>a[l]===void 0?"":String(a[l]);return[o.map(a=>a[0]?.toUpperCase()+a.slice(1)),...i.map(a=>o.map(l=>s(a,l)))]}var at=new Map;function ge(e){let n=at.get(e);if(n)return n.group;let t=new Set,r={},i={current:r,subscribe(o){return t.add(o),()=>{t.delete(o),t.size===0&&at.delete(e)}},publish(o,s){Object.assign(r,o);for(let a of t)a(o,s)}};return at.set(e,{group:i,listeners:t}),i}var Vt='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',lt=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${Vt}{animation:skdx-in var(--skdx-chart-duration,0ms) ease-out;transition:${["x","y","width","height","cx","cy","r","opacity","fill-opacity","d"].map(e=>`${e} var(--skdx-chart-duration,0ms) ease-out`).join(",")}}@media (prefers-reduced-motion:reduce){${Vt}{animation:none;transition:none}}`;function ct(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}function dt(e,n,t,r,i,o){if(e.length===0)return;let s=(d,f)=>{let w=d.reduce((m,x)=>m+x.area,0),y=Math.max(...d.map(m=>m.area)),I=Math.min(...d.map(m=>m.area));return Math.max(f*f*y/(w*w),w*w/(f*f*I))},a=Math.min(r,i),l=[],c=0;for(;c<e.length;){let d=[...l,e[c]];if(l.length===0||s(d,a)<=s(l,a))l=d,c++;else break}let u=l.reduce((d,f)=>d+f.area,0);if(r>=i){let d=u/i,f=t;for(let w of l){let y=w.area/d;o(w,[n,f,d,y]),f+=y}dt(e.slice(c),n+d,t,r-d,i,o)}else{let d=u/r,f=n;for(let w of l){let y=w.area/d;o(w,[f,t,y,d]),f+=y}dt(e.slice(c),n,t+d,r,i-d,o)}}function un(e,n,t,r,i,o,s){let a=e.reduce((c,u)=>c+u.area,0),l=s?t:n;for(let c of e){let u=a>0?c.area/a:0;if(s){let d=i*u;o(c,[n,l,r,d]),l+=d}else{let d=r*u;o(c,[l,t,d,i]),l+=d}}}function ut(e){let{nodes:n,path:t}=Ht(e.data,e.rootId),r=ot(n,e.maxDepth),i=St(e,!r.some(O=>B(O)>0));if(i)return i;let o=xt(e.format),{width:s,height:a}=ke(e),l=e.breadcrumbs&&t.length>0,c=$e(e)+(l?20:0),u=Math.max(0,e.padding??2),d=e.sort??"desc",f=e.tiling??"squarify",w=e.labels??!0,y=[],I=r.map((O,$)=>({name:O.name,color:ce(e,$,O.color)})),m=[],x=O=>{for(let $ of O)$.children?.length?x($.children):m.push(B($))};x(r);let k=e.colorScale?Tt(e.colorScale,m,ce(e,0),void 0,o):void 0,z=(O,$,H,W,L,R,P)=>{let V=O.reduce((T,D)=>T+Math.max(0,B(D)),0),pt=jt(O,d).map(T=>{let D=B(T),U=!((T.children?.length??0)>0)&&k?k.color(D):void 0;return{node:T,value:D,color:U?.fill??T.color??R??ce(e,O.indexOf(T)),opacity:U?.opacity,area:V>0?Math.max(0,D)/V*W*L:0}}).filter(T=>T.area>0&&!(R===void 0&&Ct(e,T.node.name))),ft=(T,[D,oe,U,ye])=>{let mt=`${T.node.name}: ${o(T.value)}`,ve=(T.node.children?.length??0)>0;y.push({kind:"rect",part:ve?"branch":"tile",x:v(D),y:v(oe),width:v(U),height:v(ye),fill:T.color,opacity:ve?.15:T.opacity,stroke:"var(--skdx-color-surface-default)",title:mt,item:{label:mt,id:be(T.node),name:T.node.name,value:T.value}}),ve?z(T.node.children,D+u,oe+u,Math.max(0,U-2*u),Math.max(0,ye-2*u),T.color,P+1):w&&U>40&&ye>20&&y.push(ue(v(D+6),v(oe+6),T.node.name,{baseline:"hanging",fill:"var(--skdx-color-text-on-accent)"}))};f==="squarify"?dt(pt,$,H,W,L,ft):un(pt,$,H,W,L,ft,f==="slice"||f==="sliceDice"&&P%2===0)};z(r,0,c,s,a-c,void 0,0),l&&y.push(...hn(t,8,$e(e)+10));let j=Ie(e,s,a,I);return{...j,shapes:[...y,...j.shapes]}}function hn(e,n,t){let r=[],i=n;return e.forEach((o,s)=>{s>0&&(r.push(ue(v(i),t,"\u203A",{part:"breadcrumb-separator",baseline:"middle"})),i+=_+6),r.push(ue(v(i),t,o.name,{part:"breadcrumb",baseline:"middle",fill:"var(--skdx-color-text-default)",title:o.name,item:{label:o.name,id:be(o),name:o.name}})),i+=o.name.length*_+6}),r}var b=require("lit"),p=require("lit/decorators.js"),M=require("lit/directives/if-defined.js");var ht={fromAttribute:()=>!1},g=class extends b.LitElement{constructor(){super(...arguments);this.legend=!1;this.tooltip=!0;this.selectionMode="none";this.loading=!1;this.decorative=!1;this.accessibleTable=!1;this.zoomable=!1;this.editable=!1;this.crossFilter=!1;this.animated=!1;this.responsive=!1;this.tip=[];this.overlay=[];this.portal=null;this.highlightState=null;this.crossState=null;this.lastCross=null;this.pointers=new Map;this.hover=null;this.token={};this.focused=null;this.hiddenState=[];this.drag=null;this.onPointerMove=t=>{let r=this.layout;if(!r)return;this.pointers.has(t.pointerId)&&this.pointers.set(t.pointerId,this.viewBox(t,r).x);let i=this.drag;if(i?.grab==="select"){let{x:o,y:s}=this.viewBox(t,r);this.overlay=[He(fe(i.x,i.y,o,s))];return}if(i?.grab==="lasso"){let{x:o,y:s}=this.viewBox(t,r);i.points=[...i.points??[],{x:o,y:s}],this.overlay=[_e(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=Ee(r,i.gantt,o-i.x),this.overlay=[Ue(r,i.gantt,i.change)];return}if(i?.grab==="map"){if(!r.map||!i.view)return;let{x:o,y:s}=this.viewBox(t,r);this.setView(Ke(r.map,i.view,o-i.x,s-i.y));return}if(i&&r.hit){if(i.grab==="pinch"){let[s,a]=[...this.pointers.values()];if(s===void 0||a===void 0||!i.distance)return;this.setZoom(Je(r.hit,i.zoom,Math.abs(s-a)/i.distance,(s+a)/2));return}let{x:o}=this.viewBox(t,r);this.setZoom(i.grab==="pan"?et(r.hit,i.zoom,o-i.x):nt(r.hit,i.grab,i.zoom,o-i.x));return}if(r.tooltipPortal){let{lines:o,shapes:s}=De(r,t.target,t.currentTarget,t.clientX,t.clientY);this.tip=s,this.portal=o.length?{x:t.clientX,y:t.clientY,lines:o}:null}else{let o=Fe(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(Ge(r,t.target)),this.syncId&&r.hit?.crosshair){let o=ne(r,this.viewBox(t,r).x);this.shareCrosshair(o?r.hit.rows[o.index]?.[0]??null:null)}};this.onPointerDown=t=>{let r=this.layout;if(!r||t.button!==0)return;let{x:i,y:o}=this.viewBox(t,r),s=E(r,t.target)?.item.legend,a=this.canEdit(r)?Ze(r,i,o):void 0;if(a){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"edit",gantt:a},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.brushing()&&!s){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:this.selectionMode==="lasso"?"lasso":"select",points:[{x:i,y:o}]},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.canPan(r)&&r.map){let c=r.map.plot;if(i<c.x||i>c.x+c.width||o<c.y||o>c.y+c.height)return;this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"map",view:r.map.view},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}let l=r.hit;if(!(!l||!this.canZoom(r))){if(this.pointers.set(t.pointerId,i),this.pointers.size===2){let[c,u]=[...this.pointers.values()];this.drag={x:(c+u)/2,y:o,zoom:l.zoom,grab:"pinch",distance:Math.abs(c-u)||1}}else{let c=tt(l,i,o);if(c)this.drag={x:i,y:o,zoom:c.zoom,grab:c.grab},c.zoom!==l.zoom&&this.setZoom(c.zoom);else if(this.zoomable&&i>=l.plot.x&&i<=l.plot.x+l.plot.width&&o>=l.plot.y&&o<=l.plot.y+l.plot.height)this.drag={x:i,y:o,zoom:l.zoom,grab:"pan"};else{this.pointers.delete(t.pointerId);return}}t.currentTarget.setPointerCapture(t.pointerId),this.clearTip()}};this.onPointerUp=t=>{this.pointers.delete(t.pointerId);let r=t.currentTarget;r.hasPointerCapture(t.pointerId)&&r.releasePointerCapture(t.pointerId);let i=this.drag,o=this.layout;if(o&&(i?.grab==="select"||i?.grab==="lasso"||i?.grab==="edit"||i?.grab==="map")){this.overlay=[];let{x:s,y:a}=this.viewBox(t,o);if(Math.abs(s-i.x)>2||Math.abs(a-i.y)>2){i.grab==="select"?this.setSelected(je(o,fe(i.x,i.y,s,a))):i.grab==="lasso"?this.setSelected(Ve(o,i.points??[])):i.grab==="edit"&&i.change&&this.emit("skdx-task-change",i.change),this.drag={...i,distance:-1};return}this.drag=null;return}(this.pointers.size===0||this.drag?.grab==="pinch")&&(this.drag=null)};this.onWheel=t=>{let r=this.layout;if(!r)return;let{x:i,y:o}=this.viewBox(t,r);if(r.map&&this.canPan(r)){let l=r.map.plot;if(i<l.x||i>l.x+l.width||o<l.y||o>l.y+l.height)return;t.preventDefault(),this.setView(qe(r.map,t.deltaY,i,o));return}let s=r.hit;if(!s||!this.canZoom(r)||o<s.plot.y||o>s.plot.y+s.plot.height)return;let a=Qe(s,t.deltaY,i);a&&(t.preventDefault(),this.setZoom(a))};this.onClick=t=>{if(!this.layout)return;if(this.drag?.distance===-1){this.drag=null;return}let r=E(this.layout,t.target);r&&(r.item.range?this.setZoom(r.item.range):r.item.legend&&r.item.series!==void 0?this.toggle(r.item.series):(this.select(r.item),this.emit("skdx-item-click",r.item)))};this.onKeyDown=t=>{let r=this.layout;if(!r)return;if((t.key==="Enter"||t.key===" ")&&this.focused!==null){let a=r.shapes[this.focused]?.item;a&&(t.preventDefault(),this.select(a),this.emit("skdx-item-click",a));return}let i=this.canEdit(r)?We(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=Xe(r,this.focused,t.key);if(o===void 0)return;t.preventDefault(),this.focused=o;let s=o===null?void 0:r.shapes[o]?.item;this.highlight(s?Z(s):null)}}connectedCallback(){super.connectedCallback(),!(typeof ResizeObserver>"u")&&(this.observer=new ResizeObserver(([t])=>{let r=Math.floor(t?.contentRect.width??0);r>0&&(this.measured=r)}),this.observer.observe(this))}disconnectedCallback(){this.observer?.disconnect(),this.leave?.(),this.leave=void 0,this.joined=void 0,super.disconnectedCallback()}sized(){let{width:t,height:r,legend:i,tooltip:o,format:s,palette:a,loading:l,error:c,emptyMessage:u,description:d,decorative:f,animated:w,responsive:y,highlighted:I,highlightScope:m,accessibleTable:x}=this;return{...typeof y=="object"&&this.measured!==void 0&&this.measured<(y.breakpoint??480)?y.compact:void 0,width:y&&this.measured?this.measured:t,height:r,animate:w,responsive:y,legend:i,tooltip:o,format:s,palette:a,loading:l,error:c,emptyMessage:u,description:d,decorative:f,highlighted:I===void 0?this.highlightState:I,highlightScope:m,accessibleTable:x,hiddenSeries:this.hiddenSeries??this.hiddenState,zoom:this.zoom??this.zoomState,selected:this.selected??this.selectedState,view:this.view??this.viewState}}emit(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}publish(t){this.syncId&&ge(this.syncId).publish(t,this.token)}join(){if(this.joined===this.syncId||(this.leave?.(),this.leave=void 0,this.joined=this.syncId,!this.syncId))return;let t=ge(this.syncId),r=i=>{"highlighted"in i&&(this.highlightState=i.highlighted??null),i.selected&&(this.selectedState=i.selected,this.crossFilter&&(this.highlightState=i.selected.length?i.selected:null)),"zoom"in i&&(this.zoomState=i.zoom),i.hiddenSeries&&(this.hiddenState=i.hiddenSeries),"crosshair"in i&&(this.crossState=i.crosshair??null)};r(t.current),this.leave=t.subscribe((i,o)=>{o!==this.token&&r(i)})}setZoom(t){this.zoomState=t,this.emit("skdx-zoom-change",t),this.publish({zoom:t})}setView(t){this.viewState=t,this.emit("skdx-view-change",t)}setSelected(t){this.selectedState=t,this.emit("skdx-selected-change",t),this.publish({selected:t})}toggle(t){let r=this.hiddenSeries??this.hiddenState,i=r.includes(t)?r.filter(o=>o!==t):[...r,t];this.hiddenState=i,this.emit("skdx-hidden-series-change",i),this.publish({hiddenSeries:i})}highlight(t){let r=this.hover;r===t||r&&t&&ze(r,t)||(this.hover=t,this.emit("skdx-highlighted-change",t),this.syncId&&(this.highlightState=t,this.publish({highlighted:t})))}select(t){let r=this.selectionMode;r!=="none"&&this.setSelected(Le(this.selected??this.selectedState,t,r==="single"?"single":"multiple"))}shareCrosshair(t){!this.syncId||this.lastCross===t||(this.lastCross=t,this.publish({crosshair:t}))}clearTip(){this.tip=[],this.portal=null,this.shareCrosshair(null)}canZoom(t){return!!(t.hit&&(this.zoomable||t.hit.brush))}canPan(t){return!!(t.map&&this.zoomable)}canEdit(t){return!!(this.editable&&t.edit)}brushing(){return this.selectionMode==="brush"||this.selectionMode==="lasso"}viewBox(t,r){return Y(t.currentTarget,t.clientX,t.clientY,r.width,r.height)}getSvgElement(){return this.renderRoot.querySelector("svg")}getLayout(){return this.layout}resetZoom(){this.setZoom(void 0)}zoomTo(t){this.setZoom(t)}focusItem(t){let r=this.layout;if(!r)return!1;let i=r.shapes.findIndex(o=>o.item&&!o.item.legend&&F(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?it(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=Ae(Te(t),this.sized());if(this.layout=o,o.issues!==this.reported){this.reported=o.issues;for(let x of o.issues??[])this.emit("skdx-data-issue",x)}let s=this.canZoom(o),a=this.canPan(o),l=this.canEdit(o),c=this.brushing(),u=s||a||l||c,d=!o.decorative&&me(o).length>0,f=o.description?`${r}-desc`:void 0,w=ct(o),y=st(o,this.accessibleTable),I=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,m=this.portal;return b.html`<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
viewBox="0 0 ${o.width} ${o.height}"
|
|
5
|
+
width=${o.width}
|
|
6
|
+
height=${o.height}
|
|
7
|
+
role=${o.decorative?"presentation":"img"}
|
|
8
|
+
aria-hidden=${o.decorative?"true":b.nothing}
|
|
9
|
+
aria-label=${o.decorative?b.nothing:i}
|
|
10
|
+
aria-describedby=${(0,M.ifDefined)(f)}
|
|
11
|
+
tabindex=${d?0:b.nothing}
|
|
12
|
+
data-skdx-chart=${r}
|
|
13
|
+
data-zoomable=${s||a?"":b.nothing}
|
|
14
|
+
data-brushing=${c&&!(s||a)?"":b.nothing}
|
|
15
|
+
data-editable=${l?"":b.nothing}
|
|
16
|
+
style=${w?`--skdx-chart-duration:${w}`:b.nothing}
|
|
17
|
+
font-family=${C.fontFamily}
|
|
18
|
+
font-size=${C.fontSize}
|
|
19
|
+
@pointermove=${o.tooltip||u?this.onPointerMove:b.nothing}
|
|
20
|
+
@pointerleave=${()=>{this.clearTip(),this.highlight(null)}}
|
|
21
|
+
@pointerdown=${u?this.onPointerDown:b.nothing}
|
|
22
|
+
@pointerup=${u?this.onPointerUp:b.nothing}
|
|
23
|
+
@pointercancel=${u?this.onPointerUp:b.nothing}
|
|
24
|
+
@wheel=${s||a?this.onWheel:b.nothing}
|
|
25
|
+
@dblclick=${s||a?()=>a?this.setView(void 0):this.setZoom(void 0):b.nothing}
|
|
26
|
+
@click=${this.onClick}
|
|
27
|
+
@keydown=${d?this.onKeyDown:b.nothing}
|
|
28
|
+
@blur=${()=>{this.focused=null,this.highlight(null)}}
|
|
29
|
+
>
|
|
30
|
+
<title>${i}</title>
|
|
31
|
+
${o.description?b.svg`<desc id=${(0,M.ifDefined)(f)}>${o.description}</desc>`:b.nothing}
|
|
32
|
+
${w?b.svg`<style>${lt}</style>`:b.nothing} ${pn(o)}
|
|
33
|
+
${xe(o.shapes)}
|
|
34
|
+
${xe(this.tip.length||!this.crossState?this.tip:Re(o,this.crossState))}
|
|
35
|
+
${xe(Ye(o,this.focused))} ${xe(this.overlay)}
|
|
36
|
+
</svg>
|
|
37
|
+
${m?b.html`<div
|
|
38
|
+
role="tooltip"
|
|
39
|
+
data-skdx-tooltip=${r}
|
|
40
|
+
style="left:${m.x+12}px;top:${m.y+12}px"
|
|
41
|
+
>
|
|
42
|
+
${m.lines.map(x=>b.html`<div>${x}</div>`)}
|
|
43
|
+
</div>`:b.nothing}
|
|
44
|
+
${y?b.html`<table data-skdx-table=${r}>
|
|
45
|
+
<caption>
|
|
46
|
+
${I}
|
|
47
|
+
</caption>
|
|
48
|
+
<thead>
|
|
49
|
+
<tr>
|
|
50
|
+
${(y[0]??[]).map(x=>b.html`<th scope="col">${x}</th>`)}
|
|
51
|
+
</tr>
|
|
52
|
+
</thead>
|
|
53
|
+
<tbody>
|
|
54
|
+
${y.slice(1).map(x=>b.html`<tr>
|
|
55
|
+
${x.map((k,z)=>z===0?b.html`<th scope="row">${k}</th>`:b.html`<td>${k}</td>`)}
|
|
56
|
+
</tr>`)}
|
|
57
|
+
</tbody>
|
|
58
|
+
</table>`:b.nothing}`}};g.styles=b.css`
|
|
59
|
+
:host {
|
|
60
|
+
display: inline-block;
|
|
61
|
+
}
|
|
62
|
+
svg {
|
|
63
|
+
display: block;
|
|
64
|
+
max-width: 100%;
|
|
65
|
+
height: auto;
|
|
66
|
+
outline: none;
|
|
67
|
+
}
|
|
68
|
+
svg[data-zoomable] {
|
|
69
|
+
cursor: grab;
|
|
70
|
+
touch-action: none;
|
|
71
|
+
}
|
|
72
|
+
svg[data-brushing] {
|
|
73
|
+
cursor: crosshair;
|
|
74
|
+
touch-action: none;
|
|
75
|
+
}
|
|
76
|
+
svg[data-editable] {
|
|
77
|
+
touch-action: none;
|
|
78
|
+
}
|
|
79
|
+
:host([responsive]) {
|
|
80
|
+
display: block;
|
|
81
|
+
}
|
|
82
|
+
table {
|
|
83
|
+
position: absolute;
|
|
84
|
+
width: 1px;
|
|
85
|
+
height: 1px;
|
|
86
|
+
margin: -1px;
|
|
87
|
+
padding: 0;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
clip: rect(0 0 0 0);
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
border: 0;
|
|
92
|
+
}
|
|
93
|
+
[role='tooltip'] {
|
|
94
|
+
position: fixed;
|
|
95
|
+
pointer-events: none;
|
|
96
|
+
z-index: 1000;
|
|
97
|
+
background: var(--skdx-color-surface-raised);
|
|
98
|
+
color: var(--skdx-color-text-default);
|
|
99
|
+
border: 1px solid var(--skdx-color-border-strong);
|
|
100
|
+
border-radius: 3px;
|
|
101
|
+
padding: 4px 8px;
|
|
102
|
+
font-family: var(--skdx-font-family);
|
|
103
|
+
font-size: var(--skdx-font-size-xs);
|
|
104
|
+
white-space: nowrap;
|
|
105
|
+
}
|
|
106
|
+
[role='tooltip'] > :first-child:not(:only-child) {
|
|
107
|
+
font-weight: bold;
|
|
108
|
+
}
|
|
109
|
+
`,h([(0,p.property)({type:Number})],g.prototype,"width",2),h([(0,p.property)({type:Number})],g.prototype,"height",2),h([(0,p.property)()],g.prototype,"label",2),h([(0,p.property)({type:Boolean,reflect:!0})],g.prototype,"legend",2),h([(0,p.property)({type:Boolean,attribute:"no-tooltip",converter:ht})],g.prototype,"tooltip",2),h([(0,p.property)({attribute:!1})],g.prototype,"format",2),h([(0,p.property)({attribute:!1})],g.prototype,"palette",2),h([(0,p.property)({attribute:!1})],g.prototype,"hiddenSeries",2),h([(0,p.property)({attribute:!1})],g.prototype,"selected",2),h([(0,p.property)({attribute:"selection-mode"})],g.prototype,"selectionMode",2),h([(0,p.property)({attribute:!1})],g.prototype,"highlighted",2),h([(0,p.property)({attribute:!1})],g.prototype,"highlightScope",2),h([(0,p.property)({type:Boolean,reflect:!0})],g.prototype,"loading",2),h([(0,p.property)()],g.prototype,"error",2),h([(0,p.property)({attribute:"empty-message"})],g.prototype,"emptyMessage",2),h([(0,p.property)()],g.prototype,"description",2),h([(0,p.property)({type:Boolean,reflect:!0})],g.prototype,"decorative",2),h([(0,p.property)({type:Boolean,attribute:"accessible-table"})],g.prototype,"accessibleTable",2),h([(0,p.property)({attribute:!1})],g.prototype,"zoom",2),h([(0,p.property)({attribute:!1})],g.prototype,"view",2),h([(0,p.property)({type:Boolean,reflect:!0})],g.prototype,"zoomable",2),h([(0,p.property)({type:Boolean,reflect:!0})],g.prototype,"editable",2),h([(0,p.property)({attribute:"sync-id"})],g.prototype,"syncId",2),h([(0,p.property)({type:Boolean,attribute:"cross-filter"})],g.prototype,"crossFilter",2),h([(0,p.property)({converter:{fromAttribute:t=>t===null?!1:t===""?!0:Number(t)}})],g.prototype,"animated",2),h([(0,p.property)({type:Boolean,reflect:!0})],g.prototype,"responsive",2),h([(0,p.state)()],g.prototype,"tip",2),h([(0,p.state)()],g.prototype,"overlay",2),h([(0,p.state)()],g.prototype,"portal",2),h([(0,p.state)()],g.prototype,"measured",2),h([(0,p.state)()],g.prototype,"viewState",2),h([(0,p.state)()],g.prototype,"highlightState",2),h([(0,p.state)()],g.prototype,"crossState",2),h([(0,p.state)()],g.prototype,"focused",2),h([(0,p.state)()],g.prototype,"hiddenState",2),h([(0,p.state)()],g.prototype,"zoomState",2),h([(0,p.state)()],g.prototype,"selectedState",2);var S=class extends g{constructor(){super(...arguments);this.series=[];this.labels=!1;this.connectNulls=!1;this.stacked=!1;this.brush=!1;this.crosshair=!1}input(){let{series:t,categories:r,xAxis:i,yAxis:o,rightAxis:s,references:a,annotations:l,labels:c,curve:u,connectNulls:d,nulls:f,stacked:w,stackOffset:y,orientation:I,radius:m,barGap:x,barWidth:k,sort:z,transform:j,transforms:O,bins:$,binWidth:H,binDomain:W,binMode:L,sampling:R,brush:P,crosshair:V}=this;return{...this.sized(),series:t,categories:r,xAxis:i,yAxis:o,rightAxis:s,references:a,annotations:l,labels:c,curve:u,connectNulls:d,nulls:f,stacked:w,stackOffset:y,orientation:I,radius:m,barGap:x,barWidth:k,sort:z,transform:j,transforms:O,bins:$,binWidth:H,binDomain:W,binMode:L,sampling:R,brush:P,crosshair:V}}};h([(0,p.property)({attribute:!1})],S.prototype,"series",2),h([(0,p.property)({attribute:!1})],S.prototype,"categories",2),h([(0,p.property)({attribute:!1})],S.prototype,"xAxis",2),h([(0,p.property)({attribute:!1})],S.prototype,"yAxis",2),h([(0,p.property)({attribute:!1})],S.prototype,"rightAxis",2),h([(0,p.property)({attribute:!1})],S.prototype,"references",2),h([(0,p.property)({attribute:!1})],S.prototype,"annotations",2),h([(0,p.property)({type:Boolean,reflect:!0})],S.prototype,"labels",2),h([(0,p.property)()],S.prototype,"curve",2),h([(0,p.property)({type:Boolean,attribute:"connect-nulls"})],S.prototype,"connectNulls",2),h([(0,p.property)()],S.prototype,"nulls",2),h([(0,p.property)({reflect:!0,converter:{fromAttribute:t=>t==="percent"?"percent":t!==null}})],S.prototype,"stacked",2),h([(0,p.property)({attribute:"stack-offset"})],S.prototype,"stackOffset",2),h([(0,p.property)()],S.prototype,"orientation",2),h([(0,p.property)({type:Number})],S.prototype,"radius",2),h([(0,p.property)({type:Number,attribute:"bar-gap"})],S.prototype,"barGap",2),h([(0,p.property)({type:Number,attribute:"bar-width"})],S.prototype,"barWidth",2),h([(0,p.property)()],S.prototype,"sort",2),h([(0,p.property)()],S.prototype,"transform",2),h([(0,p.property)({attribute:!1})],S.prototype,"transforms",2),h([(0,p.property)({type:Number})],S.prototype,"bins",2),h([(0,p.property)({type:Number,attribute:"bin-width"})],S.prototype,"binWidth",2),h([(0,p.property)({attribute:!1})],S.prototype,"binDomain",2),h([(0,p.property)({attribute:"bin-mode"})],S.prototype,"binMode",2),h([(0,p.property)({attribute:!1})],S.prototype,"sampling",2),h([(0,p.property)({type:Boolean,reflect:!0})],S.prototype,"brush",2),h([(0,p.property)({type:Boolean,reflect:!0})],S.prototype,"crosshair",2);var pn=e=>e.defs&&e.defs.length?b.svg`<defs>${e.defs.map(n=>b.svg`<linearGradient id=${n.id} x1="0" y1="0" x2=${n.vertical===!1?1:0} y2=${n.vertical===!1?0:1}>${n.stops.map(t=>b.svg`<stop offset=${t.offset} stop-color=${t.color} stop-opacity=${(0,M.ifDefined)(t.opacity)}></stop>`)}</linearGradient>`)}</defs>`:b.nothing,xe=e=>b.svg`${e.map((n,t)=>{let r=n.title?b.svg`<title>${n.title}</title>`:b.nothing,i=n.item?t:void 0;switch(n.kind){case"path":return b.svg`<path data-skdx-part=${n.part} data-skdx-i=${(0,M.ifDefined)(i)} d=${n.d} fill=${n.fill??"none"} stroke=${(0,M.ifDefined)(n.stroke)} stroke-width=${(0,M.ifDefined)(n.strokeWidth)} stroke-linecap=${(0,M.ifDefined)(n.strokeLinecap)} stroke-linejoin=${(0,M.ifDefined)(n.strokeLinejoin)} stroke-dasharray=${(0,M.ifDefined)(n.dash)} opacity=${(0,M.ifDefined)(n.opacity)} fill-opacity=${(0,M.ifDefined)(n.fillOpacity)}>${r}</path>`;case"rect":return b.svg`<rect data-skdx-part=${n.part} data-skdx-i=${(0,M.ifDefined)(i)} x=${n.x} y=${n.y} width=${n.width} height=${n.height} rx=${(0,M.ifDefined)(n.rx)} fill=${n.fill} stroke=${(0,M.ifDefined)(n.stroke)} fill-opacity=${(0,M.ifDefined)(n.opacity)}>${r}</rect>`;case"line":return b.svg`<line data-skdx-part=${n.part} data-skdx-i=${(0,M.ifDefined)(i)} x1=${n.x1} y1=${n.y1} x2=${n.x2} y2=${n.y2} stroke=${n.stroke} stroke-width=${(0,M.ifDefined)(n.strokeWidth)} stroke-dasharray=${(0,M.ifDefined)(n.dash)} opacity=${(0,M.ifDefined)(n.opacity)}>${r}</line>`;case"circle":return b.svg`<circle data-skdx-part=${n.part} data-skdx-i=${(0,M.ifDefined)(i)} cx=${n.cx} cy=${n.cy} r=${n.r} fill=${n.fill} stroke=${(0,M.ifDefined)(n.stroke)} opacity=${(0,M.ifDefined)(n.opacity)}>${r}</circle>`;case"text":return b.svg`<text data-skdx-part=${n.part} data-skdx-i=${(0,M.ifDefined)(i)} x=${n.x} y=${n.y} text-anchor=${(0,M.ifDefined)(n.anchor)} dominant-baseline=${(0,M.ifDefined)(n.baseline)} fill=${(0,M.ifDefined)(n.fill)} font-weight=${(0,M.ifDefined)(n.weight)} pointer-events=${(0,M.ifDefined)(i===void 0?"none":void 0)} transform=${(0,M.ifDefined)(n.rotate?`rotate(${n.rotate} ${n.x} ${n.y})`:void 0)}>${n.text}</text>`}})}`;var A=class extends g{constructor(){super(...arguments);this.data=[];this.breadcrumbs=!1;this.labels=!0}render(){let{data:t,rootId:r,breadcrumbs:i,maxDepth:o,sort:s,padding:a,tiling:l,colorScale:c,labels:u}=this;return this.root(ut({...this.sized(),data:t,rootId:r,breadcrumbs:i,maxDepth:o,sort:s,padding:a,tiling:l,colorScale:c,labels:u}),"treemap",this.label??"Treemap")}};h([(0,N.property)({attribute:!1})],A.prototype,"data",2),h([(0,N.property)({attribute:!1})],A.prototype,"rootId",2),h([(0,N.property)({type:Boolean,reflect:!0})],A.prototype,"breadcrumbs",2),h([(0,N.property)({type:Number,attribute:"max-depth"})],A.prototype,"maxDepth",2),h([(0,N.property)()],A.prototype,"sort",2),h([(0,N.property)({type:Number})],A.prototype,"padding",2),h([(0,N.property)()],A.prototype,"tiling",2),h([(0,N.property)({attribute:!1})],A.prototype,"colorScale",2),h([(0,N.property)({type:Boolean,attribute:"no-labels",converter:ht})],A.prototype,"labels",2),A=h([(0,N.customElement)("skdx-treemap")],A);0&&(module.exports={SkdxTreemap});
|
package/dist/treemap.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var Zt=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var h=(e,n,t,r)=>{for(var i=r>1?void 0:r?Et(n,t):n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=(r?s(n,t,i):s(i))||i);return r&&i&&Zt(n,t,i),i};import{customElement as fn,property as H}from"lit/decorators.js";var xt=e=>Number(e.toPrecision(12)),Wt,Ut=e=>(Wt??(Wt=new Intl.NumberFormat)).format(xt(e)),qt=e=>{let n=Math.round(Math.abs(e)),t=e<0?"-":"",r=Math.floor(n/3600),i=Math.floor(n%3600/60),o=s=>String(s).padStart(2,"0");return r>0?`${t}${r}h ${o(i)}m`:i>0?`${t}${i}m ${o(n%60)}s`:`${t}${n}s`};function yt(e){if(e===void 0)return Ut;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,s=u=>i?d=>u(d)+i:u,a=u=>r===void 0?u===void 0?{}:{maximumFractionDigits:u}:{minimumFractionDigits:r,maximumFractionDigits:r},l=u=>{let d=new Intl.NumberFormat(t,u);return s(p=>d.format(xt(p)))},c=u=>{let d=new Intl.DateTimeFormat(t,o?{...u,timeZone:o}:u);return p=>d.format(p)};switch(n){case"integer":return l({maximumFractionDigits:0});case"decimal":return l(a(2));case"percent":return l({style:"percent",...a(0)});case"currency":return l({style:"currency",currency:e.currency??"USD",...a()});case"compact":return l({notation:"compact",...a(1)});case"scientific":return l({notation:"scientific",...a(2)});case"date":return c({dateStyle:"medium"});case"time":return c({timeStyle:"short"});case"datetime":return c({dateStyle:"medium",timeStyle:"short"});case"duration":return s(qt)}}var y=e=>Number(e.toFixed(2)),Ce=e=>typeof e=="number"&&Number.isFinite(e);function Se(e){let n=1/0,t=-1/0;for(let r of e)Ce(r)&&(r<n&&(n=r),r>t&&(t=r));return n===1/0?[0,0]:[n,t]}var ee=1e3,te=60*ee,ne=60*te,ce=24*ne,gn=[ee,5*ee,15*ee,30*ee,te,5*te,15*te,30*te,ne,3*ne,6*ne,12*ne,ce,2*ce,7*ce,14*ce];var Kt=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,Yt=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,Xt={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function Qt(e,n,t){return e.replace(Yt,(r,i,o)=>{let s=Xt[i];if(s===void 0)return i+o;let l=(o.match(Kt)??[]).map((c,u)=>{let d=Number(c);if(s===-1)return String(d+n);if(s===-2)return String(d+t);let p=u%s;return s===7?p===5?String(d+n):p===6?String(d+t):c:String(p%2===0?d+n:d+t)});return i+l.join(" ")})}var vt=(e,n,t)=>e.map(r=>{switch(r.kind){case"rect":return{...r,x:r.x+n,y:r.y+t};case"circle":return{...r,cx:r.cx+n,cy:r.cy+t};case"line":return{...r,x1:r.x1+n,x2:r.x2+n,y1:r.y1+t,y2:r.y2+t};case"text":return{...r,x:r.x+n,y:r.y+t};case"path":return{...r,d:Qt(r.d,n,t)}}});var ke=["primary","success","warning","danger","neutral"].flatMap(e=>[500,700].map(n=>`var(--skdx-color-${e}-${n})`)).sort((e,n)=>Number(e.endsWith("700)"))-Number(n.endsWith("700)"))),w={axis:"var(--skdx-color-border-strong)",grid:"var(--skdx-color-border-subtle)",label:"var(--skdx-color-text-muted)",focus:"var(--skdx-color-focus-ring)",positive:"var(--skdx-color-success-500)",negative:"var(--skdx-color-danger-500)",fontFamily:"var(--skdx-font-family)",fontSize:"var(--skdx-font-size-xs)"};var wt=(e,n)=>n??ke[e%ke.length];function re(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function Mt(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var de=20,Jt=120,Ct=e=>{let n=re(e);return n&&(n.position==="left"||n.position==="right")?n.width??Jt:0},Ie=(e,n=600,t=300)=>({width:(e.width??n)-Ct(e),height:(e.height??t)-(re(e)?.position==="bottom"?de:0)}),Te=e=>{let n=re(e);return n&&(n.position===void 0||n.position==="top")?de:0},E=6.5,ue=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:wt(n)),St=(e,n)=>e.hiddenSeries?.includes(n)??!1;function $e(e,n,t=[],r={},i=10,o=8,s=!1){let a=[],l=r.maxItems,c=l!==void 0&&l>=0&&e.length>l?e.slice(0,l):e,u=e.length-c.length,d=r.interactive??!0,p=o,v=i,x=($,m,g,S)=>{let z=(m?18:4)+$.length*E;p>o&&(s||p+z>n-8)&&(p=o,v+=de),m&&a.push({kind:"rect",part:"legend-swatch",x:p,y:v-5,width:10,height:10,fill:m,opacity:S?.3:void 0,item:g}),a.push({kind:"text",part:"legend-label",x:p+(m?14:0),y:v,text:$,baseline:"middle",fill:S?w.grid:w.label,item:g}),p+=z+12};for(let $ of c){let m=t.includes($.name),g=d?{label:$.name,series:$.name,legend:!0}:void 0;x(r.formatter?.($.name)??$.name,$.color,g,m)}return u>0&&x(`+${u} more`,void 0,void 0,!1),r.align==="end"?en(a,n):a}function en(e,n){let t=new Map;for(let i of e){let o=i.kind==="rect"?i.y+5:i.y;t.set(o,[...t.get(o)??[],i])}let r=[];for(let i of t.values()){let o=Math.max(...i.map(a=>a.kind==="rect"?a.x+a.width:a.x+a.text.length*E)),s=n-8-o;for(let a of i)r.push({...a,x:a.x+s})}return r}var tn=(e,n,t={})=>new Set($e(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function Oe(e,n,t,r=[]){let i=re(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,s=Mt(e),a=o?.position==="bottom",l=Ct(e),c=e.hiddenSeries??[],u=o?l?$e(r,1/0,c,o,10,(o.position==="right"?n:0)+8,!0):$e(r,n,c,o,a?t+10:10):[],d=a?tn(r,n,o):0;return{width:n+l,height:a?t+Math.max(1,d)*de:t,legendOffset:o?.position==="left"?l:void 0,tooltip:s.enabled,tooltipFormatter:s.formatter,axisTooltipFormatter:s.axisFormatter,tooltipPortal:s.portal,tooltipPlacement:s.placement,tooltipAnchored:s.followPointer===!1?!0:void 0,description:e.description,decorative:e.decorative,animate:e.animate===!0?300:e.animate||void 0,responsive:!!e.responsive,shapes:u}}function ze(e){let n=e.legendOffset;if(!n)return e;let t=[...vt(e.shapes.filter(l=>!l.part.startsWith("legend-")),n,0),...e.shapes.filter(l=>l.part.startsWith("legend-"))],r=l=>({...l,x:l.x+n}),i=e.hit?{...e.hit,plot:r(e.hit.plot),xs:e.hit.xs.map(l=>l+n),brush:e.hit.brush?{box:r(e.hit.brush.box),window:r(e.hit.brush.window)}:void 0}:void 0,o=e.edit,s=o?{...o,scale:l=>o.scale(l)+n,invert:l=>o.invert(l-n),bars:o.bars.map(l=>({...l,x0:l.x0+n,x1:l.x1+n}))}:void 0,a=e.map?{...e.map,plot:r(e.map.plot)}:void 0;return{...e,shapes:t,hit:i,edit:s,map:a,legendOffset:void 0}}function he(e,n,t,r,i,o="auto"){let s=Array.isArray(t)?t:[t],a=Math.max(...s.map(p=>p.length))*E+12,l=6+s.length*16,c=o==="top"?{x:e-a/2,y:n-l-8}:o==="bottom"?{x:e-a/2,y:n+8}:o==="left"?{x:e-a-8,y:n-l/2}:o==="right"?{x:e+8,y:n-l/2}:{x:e+12,y:n-l-6},u=Math.max(0,Math.min(r-a,c.x)),d=Math.max(0,Math.min(i-l,c.y));return[{kind:"rect",part:"tooltip",x:y(u),y:y(d),width:y(a),height:l,fill:"var(--skdx-color-surface-raised)",stroke:w.axis,rx:3},...s.map((p,v)=>({kind:"text",part:"tooltip-label",x:y(u+6),y:y(d+11+v*16),text:p,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:s.length>1&&v===0?"bold":void 0}))]}function kt(e,n,t,r){let i=e.error!==void 0?"error":e.loading?"loading":n?"empty":null;if(!i)return null;let{width:o,height:s}=Ie(e,t,r),a=i==="error"?e.error:i==="loading"?"Loading\u2026":e.emptyMessage??"No data available",l=[];return i==="loading"&&l.push({kind:"rect",part:"skeleton",x:0,y:0,width:o,height:s,fill:"var(--skdx-color-surface-sunken)",rx:4}),l.push({kind:"text",part:`state-${i}`,x:y(o/2),y:y(s/2),text:a,anchor:"middle",baseline:"middle",fill:i==="error"?"var(--skdx-color-text-danger)":w.label}),{...Oe(e,o,s),shapes:l,tooltip:!1}}var pe=(e,n,t,r={})=>({kind:"text",part:"label",x:e,y:n,text:t,fill:w.label,...r});var ie=e=>Math.max(0,Math.min(1,e));function $t(e){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(n){let r=n[1],i=r.length===3?r.split("").map(o=>o+o).join(""):r;return[0,2,4].map(o=>parseInt(i.slice(o,o+2),16))}let t=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(e.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3])]:void 0}function It(e,n){if(e.length===0)return w.axis;if(e.length===1)return e[0];let t=ie(n)*(e.length-1),r=Math.min(e.length-2,Math.floor(t)),i=t-r,o=$t(e[r]),s=$t(e[r+1]);if(!o||!s)return e[Math.round(t)];let a=l=>Math.round(o[l]+(s[l]-o[l])*i);return`rgb(${a(0)}, ${a(1)}, ${a(2)})`}var Tt=(e,n)=>n!==void 0&&n>=2?Math.min(n-1,Math.floor(ie(e)*n))/(n-1):ie(e);function Ot(e,n,t,r=w.negative,i=String){let[o,s]=Se(n),a=e??{type:"sequential"},l=m=>y(.15+.85*m);if(a.type==="threshold"){let{thresholds:m,colors:g,labels:S}=a,z=T=>{if(typeof T!="number"||!Number.isFinite(T))return;let k=0;for(;k<m.length&&T>=m[k];)k++;return{fill:g[Math.min(k,g.length-1)]??t,opacity:1}},V=g.map((T,k)=>({fill:T,opacity:1,label:S?.[k]??(k===0?`< ${i(m[0]??0)}`:k===m.length?`\u2265 ${i(m[k-1])}`:`${i(m[k-1])} \u2013 ${i(m[k])}`)}));return{color:z,domain:[o,s],swatches:V,kind:"threshold"}}if(a.type==="ordinal"){let m=a.colors?.length?a.colors:[t];return{color:S=>typeof S=="number"&&Number.isFinite(S)?{fill:m[Math.abs(Math.round(S))%m.length],opacity:1}:void 0,domain:[o,s],swatches:m.map((S,z)=>({fill:S,opacity:1,label:String(z)})),kind:"ordinal"}}if(a.type==="diverging"){let[m,g,S]=a.domain??[-Math.max(Math.abs(o),Math.abs(s)),0,Math.max(Math.abs(o),Math.abs(s))],z=a.colors,V=L=>L<g?.5*(L-m)/Math.max(1e-12,g-m):.5+.5*(L-g)/Math.max(1e-12,S-g),T=L=>{let D=Tt(a.reversed?1-ie(L):L,a.steps);if(z&&z.length>=2)return{fill:It(z,D),opacity:1};let P=D<.5?r:t,Z=Math.abs(D-.5)*2;return{fill:P,opacity:l(Z)}},k=L=>typeof L=="number"&&Number.isFinite(L)?T(V(L)):void 0,_=a.steps??5,K=Array.from({length:_},(L,D)=>{let P=_===1?.5:D/(_-1),Z=P<.5?m+(g-m)*(P*2):g+(S-g)*((P-.5)*2);return{...T(P),label:i(Z)}});return{color:k,domain:[m,S],swatches:K,kind:"diverging"}}let[c,u]=a.domain??[o,s],d=a.colors,p=m=>{let g=Tt(a.reversed?1-ie(m):m,a.steps);return d&&d.length>=2?{fill:It(d,g),opacity:1}:{fill:d?.[0]??t,opacity:l(g)}},v=m=>typeof m!="number"||!Number.isFinite(m)?void 0:p(u===c?1:(m-c)/(u-c)),x=a.steps??5,$=Array.from({length:x},(m,g)=>{let S=x===1?1:g/(x-1);return{...p(S),label:i(c+(u-c)*S)}});return{color:v,domain:[c,u],swatches:$,kind:"sequential"}}function fe(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var Le=e=>e.id??e.name??e.series,zt=e=>e.seriesId??e.series;function G(e,n){let t=!1;return n.id!==void 0&&(t=!0,Le(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,zt(e)!==n.series&&e.series!==n.series)||n.index!==void 0&&(t=!0,e.index!==n.index)||n.category!==void 0&&(t=!0,e.category!==n.category)?!1:t}function W(e){let n={},t=Le(e);t!==void 0&&(n.id=t);let r=zt(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var Ae=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function Ne(e,n,t){let r=fe(e),i=W(n),o=r.some(s=>G(n,s));return t==="single"?o?[]:[i]:o?r.filter(s=>!G(n,s)):[...r,i]}var nn=.2;function rn(e){let n=w.focus;switch(e.kind){case"rect":return{kind:"rect",part:"selected",x:e.x-1.5,y:e.y-1.5,width:e.width+3,height:e.height+3,fill:"none",stroke:n,rx:e.rx};case"circle":return{kind:"circle",part:"selected",cx:e.cx,cy:e.cy,r:e.r+2.5,fill:"none",stroke:n};case"path":return{kind:"path",part:"selected",d:e.d,fill:"none",stroke:n,strokeWidth:2.5};case"line":return{...e,part:"selected",stroke:n,strokeWidth:(e.strokeWidth??1)+3,title:void 0,item:void 0};case"text":return}}var on=(e,n)=>e.kind==="text"?{...e,fill:w.grid}:{...e,opacity:(e.opacity??1)*n};function Pe(e,n){let t=fe(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:fe(n.highlighted),i=r[0];if(t.length===0&&!i)return e;let o={highlighted:n.highlightScope?.highlighted??"item",faded:n.highlightScope?.faded??"global"},s=[],a=u=>!i||r.some(d=>G(u,d))?!0:o.highlighted==="series"?r.some(d=>d.series!==void 0&&G(u,{series:d.series})):!1,l=u=>{if(!i||o.faded==="none"||a(u))return!1;if(o.faded==="series"){let d=i.series;return d!==void 0&&G(u,{series:d})}return!0},c=e.shapes.map(u=>{let d=u.item;if(!d||d.legend)return u;if(t.some(p=>G(d,p))){let p=rn(u);p&&s.push(p)}return l(d)?on(u,nn):u});return s.length?{...e,shapes:[...c,...s]}:{...e,shapes:c}}function J(e,n,t,r,i){let o=e.getBoundingClientRect();return{x:o.width?(n-o.left)*r/o.width:n,y:o.height?(t-o.top)*i/o.height:t}}var Be=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function Lt(e,n){let t=0,r=1/0;return e.xs.forEach((i,o)=>{let s=Math.abs(i-n);s<r&&(r=s,t=o)}),t}function oe(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=Lt(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Re(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[Lt(t,n)];return{kind:"line",part:"crosshair",x1:r,x2:r,y1:t.plot.y,y2:t.plot.y+t.plot.height,stroke:w.axis,dash:"3 3"}}function De(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!Be(r.plot,n,t))return[];let i=Re(e,n),{rows:o}=oe(e,n),s=e.tooltipAnchored?r.plot.y+8:t;return[i,...he(i.x1,s,o,e.width,e.height,e.tooltipPlacement)]}function Fe(e,n){let t=e.hit;if(!t||t.xs.length===0)return[];let r=t.rows.findIndex(o=>o[0]===n);if(r<0)return[];let i=t.xs[r];return De(e,i,t.plot.y+8)}function Ge(e,n,t,r,i){if(!e.tooltip)return{lines:[],shapes:[]};if(e.hit?.crosshair){let{x:l,y:c}=J(t,r,i,e.width,e.height);if(Be(e.hit.plot,l,c)){let u=oe(e,l),d=Re(e,l);if(u&&d)return{lines:u.rows,shapes:[d]}}}let o=n?.closest?.("[data-skdx-part]"),s=e.tooltipFormatter?U(e,n)?.item:void 0,a=s&&e.tooltipFormatter?.(s)||o&&Array.from(o.children).find(l=>l.tagName.toLowerCase()==="title")?.textContent;return a?{lines:Array.isArray(a)?a:[a],shapes:[]}:{lines:[],shapes:[]}}function At(e,n,t,r,i,o,s){let a=e?.closest?.("[data-skdx-part]"),l=s&&s.tooltipFormatter?U(s,e)?.item:void 0,c=l&&s?.tooltipFormatter?.(l)||a&&Array.from(a.children).find(x=>x.tagName.toLowerCase()==="title")?.textContent;if(!c)return[];let u=s?.tooltipAnchored?U(s,e):void 0,d=u?s?.shapes[u.index]:void 0,{x:p,y:v}=d?se(d):J(n,t,r,i,o);return he(p,v,c,i,o,s?.tooltipPlacement)}function je(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:s}=J(t,r,i,e.width,e.height),a=De(e,o,s);if(a.length>0)return a}return At(n,t,r,i,e.width,e.height,e)}function He(e,n){let t=U(e,n);return t&&!t.item.legend?W(t.item):null}var sn=(e,n)=>{let{x:t,y:r}=se(e),i=e.kind==="circle"?e.cy:e.kind==="rect"?e.y+e.height/2:r;return t>=n.x&&t<=n.x+n.width&&i>=n.y&&i<=n.y+n.height};function Ve(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!sn(i,n))continue;let o=W(i.item),s=JSON.stringify(o);t.has(s)||(t.add(s),r.push(o))}return r}var _e=e=>({kind:"rect",part:"selection-box",x:y(e.x),y:y(e.y),width:y(e.width),height:y(e.height),fill:w.focus,opacity:.12,stroke:w.focus}),be=(e,n,t,r)=>({x:Math.min(e,t),y:Math.min(n,r),width:Math.abs(t-e),height:Math.abs(r-n)});function Nt(e,n,t){let r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let s=e[i],a=e[o];s.y>t!=a.y>t&&n<(a.x-s.x)*(t-s.y)/(a.y-s.y)+s.x&&(r=!r)}return r}function Ze(e,n){if(n.length<3)return[];let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor")continue;let{x:o,y:s}=se(i),a=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:s;if(!Nt(n,o,a))continue;let l=W(i.item),c=JSON.stringify(l);t.has(c)||(t.add(c),r.push(l))}return r}var Ee=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${y(n.x)} ${y(n.y)}`).join("L")}`:"",fill:w.focus,fillOpacity:.12,stroke:w.focus,dash:"4 3"}),me=6;function We(e,n,t){let r=e.edit;if(r){for(let i of r.bars)if(!(t<i.y||t>i.y+i.height||n<i.x0-me||n>i.x1+me))return Math.abs(n-i.x0)<=me?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=me?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function Ue(e,n,t){let r=e.edit;return Pt(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function qe(e,n,t){let r=e.edit,i=t.key==="ArrowRight"?1:t.key==="ArrowLeft"?-1:0;if(!r||n===null||!i||!(t.shiftKey||t.altKey))return;let o=r.bars.find(l=>l.index===n);if(!o)return;let s=t.altKey?t.shiftKey?"start":"end":"move",a=r.snap??r.invert(o.x0+10)-r.invert(o.x0);return Pt(r,{bar:o,mode:s},i*a)}function Pt(e,{bar:n,mode:t},r){let i=a=>e.snap?Math.round(a/e.snap)*e.snap:a,o=n.start,s=n.end;return t==="move"?(o=i(n.start+r),s=o+(n.end-n.start)):t==="start"?o=Math.min(i(n.start+r),n.end):s=Math.max(i(n.end+r),n.start),{id:n.id,name:n.name,start:o,end:s}}function Ke(e,n,t){let r=e.edit,i=r.scale(t.start),o=r.scale(t.end);return{kind:"rect",part:"edit-ghost",x:y(Math.min(i,o)),y:y(n.bar.y),width:y(Math.max(1,Math.abs(o-i))),height:y(n.bar.height),fill:w.focus,opacity:.25,stroke:w.focus,rx:2}}var an=64,ln=e=>Math.max(1,Math.min(an,e));function Ye(e,n,t,r){let i=n>0?.8:1.25,o=ln(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:s,scale:a}=e,[l,c]=e.view.center,u=(t-(s.x+s.width/2))/a,d=(r-(s.y+s.height/2))/a,p=e.view.zoom/o;return{center:[l+u*(1-p),e.fromY(e.toY(c)-d*(1-p))],zoom:o}}function Xe(e,n,t,r){let{scale:i}=e;return{center:[n.center[0]-t/i,e.fromY(e.toY(n.center[1])+r/i)],zoom:n.zoom}}function U(e,n){let t=n?.closest?.("[data-skdx-i]"),r=Number(t?.getAttribute("data-skdx-i")),i=Number.isInteger(r)?e.shapes[r]?.item:void 0;return i?{index:r,item:i}:void 0}var ge=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function se(e){switch(e.kind){case"rect":return{x:e.x+e.width/2,y:e.y};case"circle":return{x:e.cx,y:e.cy-e.r};case"line":return{x:(e.x1+e.x2)/2,y:Math.min(e.y1,e.y2)};case"text":return{x:e.x,y:e.y};case"path":{let n=/M\s*(-?[\d.]+)[ ,](-?[\d.]+)/.exec(e.d);return n?{x:Number(n[1]),y:Number(n[2])}:{x:0,y:0}}}}function Qe(e,n){let t=n===null?void 0:e.shapes[n];if(!t)return[];let r=w.focus,i;switch(t.kind){case"rect":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-2,width:t.width+4,height:t.height+4,fill:"none",stroke:r,rx:2};break;case"circle":i={kind:"circle",part:"focus",cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:r};break;case"line":i={kind:"line",part:"focus",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:r,strokeWidth:4};break;case"text":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-8,width:t.text.length*E+4,height:16,fill:"none",stroke:r,rx:2};break;case"path":i={kind:"path",part:"focus",d:t.d,stroke:r,strokeWidth:2,fill:"none"};break}let{x:o,y:s}=se(t),a=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...a?he(y(o),y(s),a,e.width,e.height):[]]}function Je(e,n,t){let r=ge(e);if(r.length===0)return;let i=n===null?-1:r.indexOf(n);switch(t){case"ArrowRight":case"ArrowDown":return r[Math.min(r.length-1,i+1)];case"ArrowLeft":case"ArrowUp":return r[Math.max(0,i<=0?0:i-1)];case"Home":return r[0];case"End":return r[r.length-1];case"Escape":return null;default:return}}var X=2,Q=(e,n,t)=>{let r=Math.max(X,Math.min(t,Math.round(n))),i=Math.max(0,Math.min(t-r,Math.round(e)));return{start:i,end:i+r}},Bt=(e,n)=>!e||e.start<=0&&e.end>=n;function et(e,n,t){if(e.count<=X||!e.plot.width)return;let{start:r,end:i}=e.zoom,o=i-r,s=n>0?1.25:.8,a=Math.max(X,Math.min(e.count,Math.round(o*s)));if(a===o)return n>0&&!Bt(e.zoom,e.count)?Q(r,a,e.count):void 0;let l=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),c=r+l*o;return Q(c-l*a,a,e.count)}function tt(e,n,t,r){let i=n.end-n.start,o=Math.max(X,Math.min(e.count,Math.round(i/Math.max(.05,t)))),s=Math.max(0,Math.min(1,(r-e.plot.x)/Math.max(1,e.plot.width)));return Q(n.start+s*i-s*o,o,e.count)}function nt(e,n,t){let r=n.end-n.start,i=e.plot.width/Math.max(1,r);return Q(n.start-t/i,r,e.count)}function rt(e,n,t){let r=e.brush;if(!r||!Be(r.box,n,t))return;let i=r.window;if(Math.abs(n-i.x)<=6)return{grab:"left",zoom:e.zoom};if(Math.abs(n-(i.x+i.width))<=6)return{grab:"right",zoom:e.zoom};if(n>i.x&&n<i.x+i.width)return{grab:"move",zoom:e.zoom};let o=e.zoom.end-e.zoom.start,s=(n-r.box.x)/Math.max(1,r.box.width)*e.count;return{grab:"move",zoom:Q(s-o/2,o,e.count)}}function it(e,n,t,r){let i=e.brush;if(!i)return t;let o=r/Math.max(1,i.box.width)*e.count;if(n==="move")return Q(t.start+o,t.end-t.start,e.count);if(n==="left")return{start:Math.max(0,Math.min(t.end-X,Math.round(t.start+o))),end:t.end};let s=Math.min(e.count,Math.max(t.start+X,Math.round(t.end+o)));return{start:t.start,end:s}}function st(e,n){switch(n.type){case"svg":return Promise.resolve(ot(e,n.label,n.resolve));case"csv":return Promise.resolve(Gt(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=ot(e,n.label,n.resolve);return Ft(t,e.width,e.height,n.scale,n.background)}}}var j=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,"""),ae=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${j(String(t))}"`).join("");function Rt(e){let n=e.title?`<title>${j(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${ae([t,["d",e.d],["fill",e.fill??"none"],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-linecap",e.strokeLinecap],["stroke-linejoin",e.strokeLinejoin],["stroke-dasharray",e.dash],["opacity",e.opacity],["fill-opacity",e.fillOpacity]])}>${n}</path>`;case"rect":return`<rect${ae([t,["x",e.x],["y",e.y],["width",e.width],["height",e.height],["rx",e.rx],["fill",e.fill],["stroke",e.stroke],["fill-opacity",e.opacity]])}>${n}</rect>`;case"line":return`<line${ae([t,["x1",e.x1],["y1",e.y1],["x2",e.x2],["y2",e.y2],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-dasharray",e.dash],["opacity",e.opacity]])}>${n}</line>`;case"circle":return`<circle${ae([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${ae([t,["x",e.x],["y",e.y],["text-anchor",e.anchor],["dominant-baseline",e.baseline],["fill",e.fill],["font-weight",e.weight],["transform",e.rotate?`rotate(${e.rotate} ${e.x} ${e.y})`:void 0]])}>${j(e.text)}</text>`}}function Dt(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${j(t.id)}" x1="0" y1="0" x2="${t.vertical===!1?1:0}" y2="${t.vertical===!1?0:1}">${t.stops.map(r=>`<stop offset="${r.offset}" stop-color="${j(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function ot(e,n,t){let r=Dt(e)+e.shapes.map(Rt).join("");return t&&(r=r.replace(/var\((--[\w-]+)\)/g,(i,o)=>t(o).trim()||i)),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e.width} ${e.height}" width="${e.width}" height="${e.height}" role="img" aria-label="${j(n)}" font-family="${j(w.fontFamily)}" font-size="${j(w.fontSize)}"><title>${j(n)}</title>${r}</svg>`}function Ft(e,n,t,r=2,i){return new Promise((o,s)=>{let a=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"})),l=new Image;l.onload=()=>{URL.revokeObjectURL(a);let c=document.createElement("canvas");c.width=Math.round(n*r),c.height=Math.round(t*r);let u=c.getContext("2d");if(!u)return s(new Error("canvas 2d context unavailable"));i&&(u.fillStyle=i,u.fillRect(0,0,c.width,c.height)),u.drawImage(l,0,0,c.width,c.height),c.toBlob(d=>d?o(d):s(new Error("toBlob failed")),"image/png")},l.onerror=()=>{URL.revokeObjectURL(a),s(new Error("svg could not be decoded"))},l.src=a})}function Gt(e){let n=t=>{let r=t==null?"":String(t);return/[",\n\r]/.test(r)?`"${r.replace(/"/g,'""')}"`:r};return e.map(t=>t.map(n).join(",")).join(`\r
|
|
2
|
+
`)}var B=e=>Ce(e.value)?e.value:(e.children??[]).reduce((n,t)=>n+B(t),0);var xe=e=>e.id??e.name;function jt(e,n){for(let t of e){if(xe(t)===n||t.name===n)return[t];let r=jt(t.children??[],n);if(r)return[t,...r]}}var Ht=(e,n)=>n==="asc"||n==="desc"?[...e].sort((t,r)=>n==="asc"?B(t)-B(r):B(r)-B(t)):[...e];function at(e,n,t=1){return n===void 0?[...e]:e.map(r=>t>=n?{...r,value:B(r),children:void 0}:{...r,children:r.children?at(r.children,n,t+1):void 0})}function Vt(e,n){if(n===void 0)return{nodes:[...e],path:[]};let t=jt(e,n);if(!t)return{nodes:[...e],path:[]};let r=t[t.length-1];return{nodes:r.children?.length?r.children:[r],path:t}}function lt(e,n){if(!n)return;let t=typeof n=="object"?n.maxRows??500:500,r=e.hit;if(r&&r.rows.length>0){let a=r.rows[0];if(r.rows.length>t)return;let l=["",...a.slice(1).map(u=>u.replace(/:\s[^:]*$/,""))],c=r.rows.map(u=>[u[0],...u.slice(1).map(d=>d.slice(d.lastIndexOf(": ")+2))]);return[l,...c]}let i=e.shapes.flatMap(a=>a.item&&!a.item.legend&&!(a.part==="anchor"&&!a.title)?[a.item]:[]);if(i.length===0||i.length>t)return;let o=["series","name","category","value"].filter(a=>i.some(l=>l[a]!==void 0)),s=(a,l)=>a[l]===void 0?"":String(a[l]);return[o.map(a=>a[0]?.toUpperCase()+a.slice(1)),...i.map(a=>o.map(l=>s(a,l)))]}var ct=new Map;function ye(e){let n=ct.get(e);if(n)return n.group;let t=new Set,r={},i={current:r,subscribe(o){return t.add(o),()=>{t.delete(o),t.size===0&&ct.delete(e)}},publish(o,s){Object.assign(r,o);for(let a of t)a(o,s)}};return ct.set(e,{group:i,listeners:t}),i}var _t='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',dt=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${_t}{animation:skdx-in var(--skdx-chart-duration,0ms) ease-out;transition:${["x","y","width","height","cx","cy","r","opacity","fill-opacity","d"].map(e=>`${e} var(--skdx-chart-duration,0ms) ease-out`).join(",")}}@media (prefers-reduced-motion:reduce){${_t}{animation:none;transition:none}}`;function ut(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}function ht(e,n,t,r,i,o){if(e.length===0)return;let s=(d,p)=>{let v=d.reduce((m,g)=>m+g.area,0),x=Math.max(...d.map(m=>m.area)),$=Math.min(...d.map(m=>m.area));return Math.max(p*p*x/(v*v),v*v/(p*p*$))},a=Math.min(r,i),l=[],c=0;for(;c<e.length;){let d=[...l,e[c]];if(l.length===0||s(d,a)<=s(l,a))l=d,c++;else break}let u=l.reduce((d,p)=>d+p.area,0);if(r>=i){let d=u/i,p=t;for(let v of l){let x=v.area/d;o(v,[n,p,d,x]),p+=x}ht(e.slice(c),n+d,t,r-d,i,o)}else{let d=u/r,p=n;for(let v of l){let x=v.area/d;o(v,[p,t,x,d]),p+=x}ht(e.slice(c),n,t+d,r,i-d,o)}}function cn(e,n,t,r,i,o,s){let a=e.reduce((c,u)=>c+u.area,0),l=s?t:n;for(let c of e){let u=a>0?c.area/a:0;if(s){let d=i*u;o(c,[n,l,r,d]),l+=d}else{let d=r*u;o(c,[l,t,d,i]),l+=d}}}function pt(e){let{nodes:n,path:t}=Vt(e.data,e.rootId),r=at(n,e.maxDepth),i=kt(e,!r.some(T=>B(T)>0));if(i)return i;let o=yt(e.format),{width:s,height:a}=Ie(e),l=e.breadcrumbs&&t.length>0,c=Te(e)+(l?20:0),u=Math.max(0,e.padding??2),d=e.sort??"desc",p=e.tiling??"squarify",v=e.labels??!0,x=[],$=r.map((T,k)=>({name:T.name,color:ue(e,k,T.color)})),m=[],g=T=>{for(let k of T)k.children?.length?g(k.children):m.push(B(k))};g(r);let S=e.colorScale?Ot(e.colorScale,m,ue(e,0),void 0,o):void 0,z=(T,k,_,K,L,D,P)=>{let Z=T.reduce((I,F)=>I+Math.max(0,B(F)),0),mt=Ht(T,d).map(I=>{let F=B(I),Y=!((I.children?.length??0)>0)&&S?S.color(F):void 0;return{node:I,value:F,color:Y?.fill??I.color??D??ue(e,T.indexOf(I)),opacity:Y?.opacity,area:Z>0?Math.max(0,F)/Z*K*L:0}}).filter(I=>I.area>0&&!(D===void 0&&St(e,I.node.name))),bt=(I,[F,le,Y,we])=>{let gt=`${I.node.name}: ${o(I.value)}`,Me=(I.node.children?.length??0)>0;x.push({kind:"rect",part:Me?"branch":"tile",x:y(F),y:y(le),width:y(Y),height:y(we),fill:I.color,opacity:Me?.15:I.opacity,stroke:"var(--skdx-color-surface-default)",title:gt,item:{label:gt,id:xe(I.node),name:I.node.name,value:I.value}}),Me?z(I.node.children,F+u,le+u,Math.max(0,Y-2*u),Math.max(0,we-2*u),I.color,P+1):v&&Y>40&&we>20&&x.push(pe(y(F+6),y(le+6),I.node.name,{baseline:"hanging",fill:"var(--skdx-color-text-on-accent)"}))};p==="squarify"?ht(mt,k,_,K,L,bt):cn(mt,k,_,K,L,bt,p==="slice"||p==="sliceDice"&&P%2===0)};z(r,0,c,s,a-c,void 0,0),l&&x.push(...dn(t,8,Te(e)+10));let V=Oe(e,s,a,$);return{...V,shapes:[...x,...V.shapes]}}function dn(e,n,t){let r=[],i=n;return e.forEach((o,s)=>{s>0&&(r.push(pe(y(i),t,"\u203A",{part:"breadcrumb-separator",baseline:"middle"})),i+=E+6),r.push(pe(y(i),t,o.name,{part:"breadcrumb",baseline:"middle",fill:"var(--skdx-color-text-default)",title:o.name,item:{label:o.name,id:xe(o),name:o.name}})),i+=o.name.length*E+6}),r}import{css as un,html as q,LitElement as hn,nothing as O,svg as N}from"lit";import{property as f,state as R}from"lit/decorators.js";import{ifDefined as C}from"lit/directives/if-defined.js";var ft={fromAttribute:()=>!1},b=class extends hn{constructor(){super(...arguments);this.legend=!1;this.tooltip=!0;this.selectionMode="none";this.loading=!1;this.decorative=!1;this.accessibleTable=!1;this.zoomable=!1;this.editable=!1;this.crossFilter=!1;this.animated=!1;this.responsive=!1;this.tip=[];this.overlay=[];this.portal=null;this.highlightState=null;this.crossState=null;this.lastCross=null;this.pointers=new Map;this.hover=null;this.token={};this.focused=null;this.hiddenState=[];this.drag=null;this.onPointerMove=t=>{let r=this.layout;if(!r)return;this.pointers.has(t.pointerId)&&this.pointers.set(t.pointerId,this.viewBox(t,r).x);let i=this.drag;if(i?.grab==="select"){let{x:o,y:s}=this.viewBox(t,r);this.overlay=[_e(be(i.x,i.y,o,s))];return}if(i?.grab==="lasso"){let{x:o,y:s}=this.viewBox(t,r);i.points=[...i.points??[],{x:o,y:s}],this.overlay=[Ee(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=Ue(r,i.gantt,o-i.x),this.overlay=[Ke(r,i.gantt,i.change)];return}if(i?.grab==="map"){if(!r.map||!i.view)return;let{x:o,y:s}=this.viewBox(t,r);this.setView(Xe(r.map,i.view,o-i.x,s-i.y));return}if(i&&r.hit){if(i.grab==="pinch"){let[s,a]=[...this.pointers.values()];if(s===void 0||a===void 0||!i.distance)return;this.setZoom(tt(r.hit,i.zoom,Math.abs(s-a)/i.distance,(s+a)/2));return}let{x:o}=this.viewBox(t,r);this.setZoom(i.grab==="pan"?nt(r.hit,i.zoom,o-i.x):it(r.hit,i.grab,i.zoom,o-i.x));return}if(r.tooltipPortal){let{lines:o,shapes:s}=Ge(r,t.target,t.currentTarget,t.clientX,t.clientY);this.tip=s,this.portal=o.length?{x:t.clientX,y:t.clientY,lines:o}:null}else{let o=je(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(He(r,t.target)),this.syncId&&r.hit?.crosshair){let o=oe(r,this.viewBox(t,r).x);this.shareCrosshair(o?r.hit.rows[o.index]?.[0]??null:null)}};this.onPointerDown=t=>{let r=this.layout;if(!r||t.button!==0)return;let{x:i,y:o}=this.viewBox(t,r),s=U(r,t.target)?.item.legend,a=this.canEdit(r)?We(r,i,o):void 0;if(a){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"edit",gantt:a},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.brushing()&&!s){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:this.selectionMode==="lasso"?"lasso":"select",points:[{x:i,y:o}]},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.canPan(r)&&r.map){let c=r.map.plot;if(i<c.x||i>c.x+c.width||o<c.y||o>c.y+c.height)return;this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"map",view:r.map.view},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}let l=r.hit;if(!(!l||!this.canZoom(r))){if(this.pointers.set(t.pointerId,i),this.pointers.size===2){let[c,u]=[...this.pointers.values()];this.drag={x:(c+u)/2,y:o,zoom:l.zoom,grab:"pinch",distance:Math.abs(c-u)||1}}else{let c=rt(l,i,o);if(c)this.drag={x:i,y:o,zoom:c.zoom,grab:c.grab},c.zoom!==l.zoom&&this.setZoom(c.zoom);else if(this.zoomable&&i>=l.plot.x&&i<=l.plot.x+l.plot.width&&o>=l.plot.y&&o<=l.plot.y+l.plot.height)this.drag={x:i,y:o,zoom:l.zoom,grab:"pan"};else{this.pointers.delete(t.pointerId);return}}t.currentTarget.setPointerCapture(t.pointerId),this.clearTip()}};this.onPointerUp=t=>{this.pointers.delete(t.pointerId);let r=t.currentTarget;r.hasPointerCapture(t.pointerId)&&r.releasePointerCapture(t.pointerId);let i=this.drag,o=this.layout;if(o&&(i?.grab==="select"||i?.grab==="lasso"||i?.grab==="edit"||i?.grab==="map")){this.overlay=[];let{x:s,y:a}=this.viewBox(t,o);if(Math.abs(s-i.x)>2||Math.abs(a-i.y)>2){i.grab==="select"?this.setSelected(Ve(o,be(i.x,i.y,s,a))):i.grab==="lasso"?this.setSelected(Ze(o,i.points??[])):i.grab==="edit"&&i.change&&this.emit("skdx-task-change",i.change),this.drag={...i,distance:-1};return}this.drag=null;return}(this.pointers.size===0||this.drag?.grab==="pinch")&&(this.drag=null)};this.onWheel=t=>{let r=this.layout;if(!r)return;let{x:i,y:o}=this.viewBox(t,r);if(r.map&&this.canPan(r)){let l=r.map.plot;if(i<l.x||i>l.x+l.width||o<l.y||o>l.y+l.height)return;t.preventDefault(),this.setView(Ye(r.map,t.deltaY,i,o));return}let s=r.hit;if(!s||!this.canZoom(r)||o<s.plot.y||o>s.plot.y+s.plot.height)return;let a=et(s,t.deltaY,i);a&&(t.preventDefault(),this.setZoom(a))};this.onClick=t=>{if(!this.layout)return;if(this.drag?.distance===-1){this.drag=null;return}let r=U(this.layout,t.target);r&&(r.item.range?this.setZoom(r.item.range):r.item.legend&&r.item.series!==void 0?this.toggle(r.item.series):(this.select(r.item),this.emit("skdx-item-click",r.item)))};this.onKeyDown=t=>{let r=this.layout;if(!r)return;if((t.key==="Enter"||t.key===" ")&&this.focused!==null){let a=r.shapes[this.focused]?.item;a&&(t.preventDefault(),this.select(a),this.emit("skdx-item-click",a));return}let i=this.canEdit(r)?qe(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=Je(r,this.focused,t.key);if(o===void 0)return;t.preventDefault(),this.focused=o;let s=o===null?void 0:r.shapes[o]?.item;this.highlight(s?W(s):null)}}connectedCallback(){super.connectedCallback(),!(typeof ResizeObserver>"u")&&(this.observer=new ResizeObserver(([t])=>{let r=Math.floor(t?.contentRect.width??0);r>0&&(this.measured=r)}),this.observer.observe(this))}disconnectedCallback(){this.observer?.disconnect(),this.leave?.(),this.leave=void 0,this.joined=void 0,super.disconnectedCallback()}sized(){let{width:t,height:r,legend:i,tooltip:o,format:s,palette:a,loading:l,error:c,emptyMessage:u,description:d,decorative:p,animated:v,responsive:x,highlighted:$,highlightScope:m,accessibleTable:g}=this;return{...typeof x=="object"&&this.measured!==void 0&&this.measured<(x.breakpoint??480)?x.compact:void 0,width:x&&this.measured?this.measured:t,height:r,animate:v,responsive:x,legend:i,tooltip:o,format:s,palette:a,loading:l,error:c,emptyMessage:u,description:d,decorative:p,highlighted:$===void 0?this.highlightState:$,highlightScope:m,accessibleTable:g,hiddenSeries:this.hiddenSeries??this.hiddenState,zoom:this.zoom??this.zoomState,selected:this.selected??this.selectedState,view:this.view??this.viewState}}emit(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}publish(t){this.syncId&&ye(this.syncId).publish(t,this.token)}join(){if(this.joined===this.syncId||(this.leave?.(),this.leave=void 0,this.joined=this.syncId,!this.syncId))return;let t=ye(this.syncId),r=i=>{"highlighted"in i&&(this.highlightState=i.highlighted??null),i.selected&&(this.selectedState=i.selected,this.crossFilter&&(this.highlightState=i.selected.length?i.selected:null)),"zoom"in i&&(this.zoomState=i.zoom),i.hiddenSeries&&(this.hiddenState=i.hiddenSeries),"crosshair"in i&&(this.crossState=i.crosshair??null)};r(t.current),this.leave=t.subscribe((i,o)=>{o!==this.token&&r(i)})}setZoom(t){this.zoomState=t,this.emit("skdx-zoom-change",t),this.publish({zoom:t})}setView(t){this.viewState=t,this.emit("skdx-view-change",t)}setSelected(t){this.selectedState=t,this.emit("skdx-selected-change",t),this.publish({selected:t})}toggle(t){let r=this.hiddenSeries??this.hiddenState,i=r.includes(t)?r.filter(o=>o!==t):[...r,t];this.hiddenState=i,this.emit("skdx-hidden-series-change",i),this.publish({hiddenSeries:i})}highlight(t){let r=this.hover;r===t||r&&t&&Ae(r,t)||(this.hover=t,this.emit("skdx-highlighted-change",t),this.syncId&&(this.highlightState=t,this.publish({highlighted:t})))}select(t){let r=this.selectionMode;r!=="none"&&this.setSelected(Ne(this.selected??this.selectedState,t,r==="single"?"single":"multiple"))}shareCrosshair(t){!this.syncId||this.lastCross===t||(this.lastCross=t,this.publish({crosshair:t}))}clearTip(){this.tip=[],this.portal=null,this.shareCrosshair(null)}canZoom(t){return!!(t.hit&&(this.zoomable||t.hit.brush))}canPan(t){return!!(t.map&&this.zoomable)}canEdit(t){return!!(this.editable&&t.edit)}brushing(){return this.selectionMode==="brush"||this.selectionMode==="lasso"}viewBox(t,r){return J(t.currentTarget,t.clientX,t.clientY,r.width,r.height)}getSvgElement(){return this.renderRoot.querySelector("svg")}getLayout(){return this.layout}resetZoom(){this.setZoom(void 0)}zoomTo(t){this.setZoom(t)}focusItem(t){let r=this.layout;if(!r)return!1;let i=r.shapes.findIndex(o=>o.item&&!o.item.legend&&G(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?st(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=Pe(ze(t),this.sized());if(this.layout=o,o.issues!==this.reported){this.reported=o.issues;for(let g of o.issues??[])this.emit("skdx-data-issue",g)}let s=this.canZoom(o),a=this.canPan(o),l=this.canEdit(o),c=this.brushing(),u=s||a||l||c,d=!o.decorative&&ge(o).length>0,p=o.description?`${r}-desc`:void 0,v=ut(o),x=lt(o,this.accessibleTable),$=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,m=this.portal;return q`<svg
|
|
3
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
+
viewBox="0 0 ${o.width} ${o.height}"
|
|
5
|
+
width=${o.width}
|
|
6
|
+
height=${o.height}
|
|
7
|
+
role=${o.decorative?"presentation":"img"}
|
|
8
|
+
aria-hidden=${o.decorative?"true":O}
|
|
9
|
+
aria-label=${o.decorative?O:i}
|
|
10
|
+
aria-describedby=${C(p)}
|
|
11
|
+
tabindex=${d?0:O}
|
|
12
|
+
data-skdx-chart=${r}
|
|
13
|
+
data-zoomable=${s||a?"":O}
|
|
14
|
+
data-brushing=${c&&!(s||a)?"":O}
|
|
15
|
+
data-editable=${l?"":O}
|
|
16
|
+
style=${v?`--skdx-chart-duration:${v}`:O}
|
|
17
|
+
font-family=${w.fontFamily}
|
|
18
|
+
font-size=${w.fontSize}
|
|
19
|
+
@pointermove=${o.tooltip||u?this.onPointerMove:O}
|
|
20
|
+
@pointerleave=${()=>{this.clearTip(),this.highlight(null)}}
|
|
21
|
+
@pointerdown=${u?this.onPointerDown:O}
|
|
22
|
+
@pointerup=${u?this.onPointerUp:O}
|
|
23
|
+
@pointercancel=${u?this.onPointerUp:O}
|
|
24
|
+
@wheel=${s||a?this.onWheel:O}
|
|
25
|
+
@dblclick=${s||a?()=>a?this.setView(void 0):this.setZoom(void 0):O}
|
|
26
|
+
@click=${this.onClick}
|
|
27
|
+
@keydown=${d?this.onKeyDown:O}
|
|
28
|
+
@blur=${()=>{this.focused=null,this.highlight(null)}}
|
|
29
|
+
>
|
|
30
|
+
<title>${i}</title>
|
|
31
|
+
${o.description?N`<desc id=${C(p)}>${o.description}</desc>`:O}
|
|
32
|
+
${v?N`<style>${dt}</style>`:O} ${pn(o)}
|
|
33
|
+
${ve(o.shapes)}
|
|
34
|
+
${ve(this.tip.length||!this.crossState?this.tip:Fe(o,this.crossState))}
|
|
35
|
+
${ve(Qe(o,this.focused))} ${ve(this.overlay)}
|
|
36
|
+
</svg>
|
|
37
|
+
${m?q`<div
|
|
38
|
+
role="tooltip"
|
|
39
|
+
data-skdx-tooltip=${r}
|
|
40
|
+
style="left:${m.x+12}px;top:${m.y+12}px"
|
|
41
|
+
>
|
|
42
|
+
${m.lines.map(g=>q`<div>${g}</div>`)}
|
|
43
|
+
</div>`:O}
|
|
44
|
+
${x?q`<table data-skdx-table=${r}>
|
|
45
|
+
<caption>
|
|
46
|
+
${$}
|
|
47
|
+
</caption>
|
|
48
|
+
<thead>
|
|
49
|
+
<tr>
|
|
50
|
+
${(x[0]??[]).map(g=>q`<th scope="col">${g}</th>`)}
|
|
51
|
+
</tr>
|
|
52
|
+
</thead>
|
|
53
|
+
<tbody>
|
|
54
|
+
${x.slice(1).map(g=>q`<tr>
|
|
55
|
+
${g.map((S,z)=>z===0?q`<th scope="row">${S}</th>`:q`<td>${S}</td>`)}
|
|
56
|
+
</tr>`)}
|
|
57
|
+
</tbody>
|
|
58
|
+
</table>`:O}`}};b.styles=un`
|
|
59
|
+
:host {
|
|
60
|
+
display: inline-block;
|
|
61
|
+
}
|
|
62
|
+
svg {
|
|
63
|
+
display: block;
|
|
64
|
+
max-width: 100%;
|
|
65
|
+
height: auto;
|
|
66
|
+
outline: none;
|
|
67
|
+
}
|
|
68
|
+
svg[data-zoomable] {
|
|
69
|
+
cursor: grab;
|
|
70
|
+
touch-action: none;
|
|
71
|
+
}
|
|
72
|
+
svg[data-brushing] {
|
|
73
|
+
cursor: crosshair;
|
|
74
|
+
touch-action: none;
|
|
75
|
+
}
|
|
76
|
+
svg[data-editable] {
|
|
77
|
+
touch-action: none;
|
|
78
|
+
}
|
|
79
|
+
:host([responsive]) {
|
|
80
|
+
display: block;
|
|
81
|
+
}
|
|
82
|
+
table {
|
|
83
|
+
position: absolute;
|
|
84
|
+
width: 1px;
|
|
85
|
+
height: 1px;
|
|
86
|
+
margin: -1px;
|
|
87
|
+
padding: 0;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
clip: rect(0 0 0 0);
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
border: 0;
|
|
92
|
+
}
|
|
93
|
+
[role='tooltip'] {
|
|
94
|
+
position: fixed;
|
|
95
|
+
pointer-events: none;
|
|
96
|
+
z-index: 1000;
|
|
97
|
+
background: var(--skdx-color-surface-raised);
|
|
98
|
+
color: var(--skdx-color-text-default);
|
|
99
|
+
border: 1px solid var(--skdx-color-border-strong);
|
|
100
|
+
border-radius: 3px;
|
|
101
|
+
padding: 4px 8px;
|
|
102
|
+
font-family: var(--skdx-font-family);
|
|
103
|
+
font-size: var(--skdx-font-size-xs);
|
|
104
|
+
white-space: nowrap;
|
|
105
|
+
}
|
|
106
|
+
[role='tooltip'] > :first-child:not(:only-child) {
|
|
107
|
+
font-weight: bold;
|
|
108
|
+
}
|
|
109
|
+
`,h([f({type:Number})],b.prototype,"width",2),h([f({type:Number})],b.prototype,"height",2),h([f()],b.prototype,"label",2),h([f({type:Boolean,reflect:!0})],b.prototype,"legend",2),h([f({type:Boolean,attribute:"no-tooltip",converter:ft})],b.prototype,"tooltip",2),h([f({attribute:!1})],b.prototype,"format",2),h([f({attribute:!1})],b.prototype,"palette",2),h([f({attribute:!1})],b.prototype,"hiddenSeries",2),h([f({attribute:!1})],b.prototype,"selected",2),h([f({attribute:"selection-mode"})],b.prototype,"selectionMode",2),h([f({attribute:!1})],b.prototype,"highlighted",2),h([f({attribute:!1})],b.prototype,"highlightScope",2),h([f({type:Boolean,reflect:!0})],b.prototype,"loading",2),h([f()],b.prototype,"error",2),h([f({attribute:"empty-message"})],b.prototype,"emptyMessage",2),h([f()],b.prototype,"description",2),h([f({type:Boolean,reflect:!0})],b.prototype,"decorative",2),h([f({type:Boolean,attribute:"accessible-table"})],b.prototype,"accessibleTable",2),h([f({attribute:!1})],b.prototype,"zoom",2),h([f({attribute:!1})],b.prototype,"view",2),h([f({type:Boolean,reflect:!0})],b.prototype,"zoomable",2),h([f({type:Boolean,reflect:!0})],b.prototype,"editable",2),h([f({attribute:"sync-id"})],b.prototype,"syncId",2),h([f({type:Boolean,attribute:"cross-filter"})],b.prototype,"crossFilter",2),h([f({converter:{fromAttribute:t=>t===null?!1:t===""?!0:Number(t)}})],b.prototype,"animated",2),h([f({type:Boolean,reflect:!0})],b.prototype,"responsive",2),h([R()],b.prototype,"tip",2),h([R()],b.prototype,"overlay",2),h([R()],b.prototype,"portal",2),h([R()],b.prototype,"measured",2),h([R()],b.prototype,"viewState",2),h([R()],b.prototype,"highlightState",2),h([R()],b.prototype,"crossState",2),h([R()],b.prototype,"focused",2),h([R()],b.prototype,"hiddenState",2),h([R()],b.prototype,"zoomState",2),h([R()],b.prototype,"selectedState",2);var M=class extends b{constructor(){super(...arguments);this.series=[];this.labels=!1;this.connectNulls=!1;this.stacked=!1;this.brush=!1;this.crosshair=!1}input(){let{series:t,categories:r,xAxis:i,yAxis:o,rightAxis:s,references:a,annotations:l,labels:c,curve:u,connectNulls:d,nulls:p,stacked:v,stackOffset:x,orientation:$,radius:m,barGap:g,barWidth:S,sort:z,transform:V,transforms:T,bins:k,binWidth:_,binDomain:K,binMode:L,sampling:D,brush:P,crosshair:Z}=this;return{...this.sized(),series:t,categories:r,xAxis:i,yAxis:o,rightAxis:s,references:a,annotations:l,labels:c,curve:u,connectNulls:d,nulls:p,stacked:v,stackOffset:x,orientation:$,radius:m,barGap:g,barWidth:S,sort:z,transform:V,transforms:T,bins:k,binWidth:_,binDomain:K,binMode:L,sampling:D,brush:P,crosshair:Z}}};h([f({attribute:!1})],M.prototype,"series",2),h([f({attribute:!1})],M.prototype,"categories",2),h([f({attribute:!1})],M.prototype,"xAxis",2),h([f({attribute:!1})],M.prototype,"yAxis",2),h([f({attribute:!1})],M.prototype,"rightAxis",2),h([f({attribute:!1})],M.prototype,"references",2),h([f({attribute:!1})],M.prototype,"annotations",2),h([f({type:Boolean,reflect:!0})],M.prototype,"labels",2),h([f()],M.prototype,"curve",2),h([f({type:Boolean,attribute:"connect-nulls"})],M.prototype,"connectNulls",2),h([f()],M.prototype,"nulls",2),h([f({reflect:!0,converter:{fromAttribute:t=>t==="percent"?"percent":t!==null}})],M.prototype,"stacked",2),h([f({attribute:"stack-offset"})],M.prototype,"stackOffset",2),h([f()],M.prototype,"orientation",2),h([f({type:Number})],M.prototype,"radius",2),h([f({type:Number,attribute:"bar-gap"})],M.prototype,"barGap",2),h([f({type:Number,attribute:"bar-width"})],M.prototype,"barWidth",2),h([f()],M.prototype,"sort",2),h([f()],M.prototype,"transform",2),h([f({attribute:!1})],M.prototype,"transforms",2),h([f({type:Number})],M.prototype,"bins",2),h([f({type:Number,attribute:"bin-width"})],M.prototype,"binWidth",2),h([f({attribute:!1})],M.prototype,"binDomain",2),h([f({attribute:"bin-mode"})],M.prototype,"binMode",2),h([f({attribute:!1})],M.prototype,"sampling",2),h([f({type:Boolean,reflect:!0})],M.prototype,"brush",2),h([f({type:Boolean,reflect:!0})],M.prototype,"crosshair",2);var pn=e=>e.defs&&e.defs.length?N`<defs>${e.defs.map(n=>N`<linearGradient id=${n.id} x1="0" y1="0" x2=${n.vertical===!1?1:0} y2=${n.vertical===!1?0:1}>${n.stops.map(t=>N`<stop offset=${t.offset} stop-color=${t.color} stop-opacity=${C(t.opacity)}></stop>`)}</linearGradient>`)}</defs>`:O,ve=e=>N`${e.map((n,t)=>{let r=n.title?N`<title>${n.title}</title>`:O,i=n.item?t:void 0;switch(n.kind){case"path":return N`<path data-skdx-part=${n.part} data-skdx-i=${C(i)} d=${n.d} fill=${n.fill??"none"} stroke=${C(n.stroke)} stroke-width=${C(n.strokeWidth)} stroke-linecap=${C(n.strokeLinecap)} stroke-linejoin=${C(n.strokeLinejoin)} stroke-dasharray=${C(n.dash)} opacity=${C(n.opacity)} fill-opacity=${C(n.fillOpacity)}>${r}</path>`;case"rect":return N`<rect data-skdx-part=${n.part} data-skdx-i=${C(i)} x=${n.x} y=${n.y} width=${n.width} height=${n.height} rx=${C(n.rx)} fill=${n.fill} stroke=${C(n.stroke)} fill-opacity=${C(n.opacity)}>${r}</rect>`;case"line":return N`<line data-skdx-part=${n.part} data-skdx-i=${C(i)} x1=${n.x1} y1=${n.y1} x2=${n.x2} y2=${n.y2} stroke=${n.stroke} stroke-width=${C(n.strokeWidth)} stroke-dasharray=${C(n.dash)} opacity=${C(n.opacity)}>${r}</line>`;case"circle":return N`<circle data-skdx-part=${n.part} data-skdx-i=${C(i)} cx=${n.cx} cy=${n.cy} r=${n.r} fill=${n.fill} stroke=${C(n.stroke)} opacity=${C(n.opacity)}>${r}</circle>`;case"text":return N`<text data-skdx-part=${n.part} data-skdx-i=${C(i)} x=${n.x} y=${n.y} text-anchor=${C(n.anchor)} dominant-baseline=${C(n.baseline)} fill=${C(n.fill)} font-weight=${C(n.weight)} pointer-events=${C(i===void 0?"none":void 0)} transform=${C(n.rotate?`rotate(${n.rotate} ${n.x} ${n.y})`:void 0)}>${n.text}</text>`}})}`;var A=class extends b{constructor(){super(...arguments);this.data=[];this.breadcrumbs=!1;this.labels=!0}render(){let{data:t,rootId:r,breadcrumbs:i,maxDepth:o,sort:s,padding:a,tiling:l,colorScale:c,labels:u}=this;return this.root(pt({...this.sized(),data:t,rootId:r,breadcrumbs:i,maxDepth:o,sort:s,padding:a,tiling:l,colorScale:c,labels:u}),"treemap",this.label??"Treemap")}};h([H({attribute:!1})],A.prototype,"data",2),h([H({attribute:!1})],A.prototype,"rootId",2),h([H({type:Boolean,reflect:!0})],A.prototype,"breadcrumbs",2),h([H({type:Number,attribute:"max-depth"})],A.prototype,"maxDepth",2),h([H()],A.prototype,"sort",2),h([H({type:Number})],A.prototype,"padding",2),h([H()],A.prototype,"tiling",2),h([H({attribute:!1})],A.prototype,"colorScale",2),h([H({type:Boolean,attribute:"no-labels",converter:ft})],A.prototype,"labels",2),A=h([fn("skdx-treemap")],A);export{A as SkdxTreemap};
|