@perses-dev/stat-chart-plugin 0.13.0-rc.1 → 0.13.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/__mf/js/{StatChart.6e3c3101.js → StatChart.2eecc4a4.js} +2 -2
- package/__mf/js/async/{546.97a22d02.js → 546.f27d00a1.js} +4 -4
- package/__mf/js/async/{580.5a3fa127.js → 580.4076ee7b.js} +2 -2
- package/__mf/js/async/{__federation_expose_StatChart.b01aa787.js → __federation_expose_StatChart.f4a2f598.js} +1 -1
- package/__mf/js/{main.35575c5a.js → main.8c422eca.js} +2 -2
- package/lib/StatChart.d.ts.map +1 -1
- package/lib/StatChart.js +0 -3
- package/lib/StatChart.js.map +1 -1
- package/lib/cjs/StatChart.js +0 -3
- package/mf-manifest.json +9 -9
- package/mf-stats.json +9 -9
- package/package.json +4 -4
- /package/__mf/js/async/{546.97a22d02.js.LICENSE.txt → 546.f27d00a1.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{580.5a3fa127.js.LICENSE.txt → 580.4076ee7b.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.chunk_StatChart=self.chunk_StatChart||[]).push([["903"],{82372(e,t,l){let n;l.r(t),l.d(t,{StatChart:()=>N});let o=[{id:"none",label:"None"},{id:"value",label:"Text"},{id:"background_solid",label:"Background"}],i=[{id:"auto",label:"Auto",description:"Show legend for multi-series, hide legend for single series"},{id:"on",label:"On",description:"Always show legend"},{id:"off",label:"Off",description:"Always hide legend"}];var a=l(62540),r=l(
|
|
1
|
+
"use strict";(self.chunk_StatChart=self.chunk_StatChart||[]).push([["903"],{82372(e,t,l){let n;l.r(t),l.d(t,{StatChart:()=>N});let o=[{id:"none",label:"None"},{id:"value",label:"Text"},{id:"background_solid",label:"Background"}],i=[{id:"auto",label:"Auto",description:"Show legend for multi-series, hide legend for single series"},{id:"on",label:"On",description:"Always show legend"},{id:"off",label:"Off",description:"Always hide legend"}];var a=l(62540),r=l(57072),s=l(68003),d=l(19848),u=l(38662),c=l(25632),h=l.n(c),p=l(70451);let f={unit:"percent-decimal"};var g=l(315),m=l(88091);let x=(e,t)=>(void 0===d.CalculationsMap[e]&&console.warn(`Invalid StatChart panel calculation ${e}, fallback to ${d.DEFAULT_CALCULATION}`),(d.CalculationsMap[e]??d.CalculationsMap[d.DEFAULT_CALCULATION])(t.values));var v=l(56599),C=l(74628),b=l(77308),M=l(74653),S=l(62707),j=l(59738),w=l(90652),y=l(72106),A=l(55875),k=l(37573),O=l(2849);function F(e){let{text:t,fontWeight:l,width:o,height:i,lineHeight:a,maxSize:s,fontSizeOverride:d}=e,u=function(){if(!n&&null===(n=document.createElement("canvas").getContext("2d")))throw Error("Canvas context is null.");return n}(),{echartsTheme:c}=(0,r.useChartsTheme)();if(void 0!==d)return Number(d);let h=c.textStyle,p=Number(null==h?void 0:h.fontSize)??12,f=(null==h?void 0:h.fontFamily)??"Lato";u.font=`${l} ${p}px ${f}`;let g=Math.min(i/a,o/u.measureText(t).width*p);return s?Math.min(g,s):g}(0,M.Y)([S.a,j.a,w.a,y.a,A.a,k.a]);let E="#FFFFFF",z="#000000",T=e=>{var t,l,n,o;let{width:i,height:s,data:d,data:{color:u},sparkline:c,showSeriesName:f,format:g,valueFontSize:m,colorMode:x}=e,{palette:{mode:b,text:{secondary:M}}}=(0,v.A)(),S=(0,r.useChartsTheme)(),j=(n=d.calculatedValue,o=g,null===n?"null":"number"==typeof n?(0,r.formatValue)(n,o):void 0===n?"":n),w=S.container.padding.default,y=F({text:(null==d||null==(t=d.seriesData)?void 0:t.name)??"",fontWeight:400,width:i,height:.125*s,lineHeight:1.2,maxSize:30}),A=f?1.2*y+w:0,k=i-2*w,T=s-A,D=F({text:j,fontSizeOverride:m,fontWeight:700,width:c?k:.5*k,height:c?.25*T:.9*T,lineHeight:1.2}),_=1.2*D;y=Math.min(.7*D,y);let N=(0,p.useMemo)(()=>{if(!d.seriesData)return S.noDataOption;let e=d.seriesData,t=[];if(c){let l={type:"line",name:e.name,data:e.values,zlevel:1,symbol:"none",animation:!1,silent:!0},n={...c};"background_solid"===x&&(n.areaStyle={color:E,opacity:.4},n.lineStyle={color:E,opacity:1});let o=h()(l,n);t.push(o)}return{title:{show:!1},grid:{show:!1,top:"35%",right:0,bottom:0,left:0,containLabel:!1},xAxis:{type:"time",show:!1,boundaryGap:!1},yAxis:{type:"value",show:!1,min:e=>e.min>=0&&e.min<=1?0:e.min},tooltip:{show:!1},series:t}},[d,S,c,x]),I=c?"auto":"center",V=(0,p.useMemo)(()=>{let e="";switch(x){case"background_solid":e=O.Ay.contrast(u,E)>O.Ay.contrast(u,z)?E:z;break;case"none":e="dark"===b?E:z;break;default:e=u}return(0,a.jsx)($,{variant:"h3",color:e,fontSize:D,padding:w,children:j})},[x,w,D,j,u,b]),G=(0,p.useMemo)(()=>{var e;if(!f)return null;let t="";return t="background_solid"===x?O.Ay.contrast(u,E)>O.Ay.contrast(u,z)?E:z:M,(0,a.jsx)(L,{padding:w,fontSize:y,color:t,children:null==(e=d.seriesData)?void 0:e.name})},[x,f,M,u,w,y,null==d||null==(l=d.seriesData)?void 0:l.name]);return(0,a.jsxs)(C.A,{sx:{height:"100%",width:"100%",backgroundColor:"background_solid"===x?u:"transparent",display:"flex",flexDirection:"column",justifyContent:I,alignItems:I},children:[G,V,c&&(0,a.jsx)(r.EChart,{sx:{width:"100%"},style:{height:Math.floor(s-A-_)},option:N,theme:S.echartsTheme,renderer:"svg"})]})},L=(0,b.A)(m.A,{shouldForwardProp:e=>"padding"!==e&&"fontSize"!==e})(e=>{let{padding:t,fontSize:l,color:n}=e;return{color:n,padding:`${t}px`,fontSize:`${l}px`,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}),$=(0,b.A)(m.A,{shouldForwardProp:e=>"color"!==e&&"padding"!==e&&"fontSize"!==e&&"sparkline"!==e})(e=>{let{theme:t,color:l,padding:n,fontSize:o,sparkline:i}=e;return{color:l??t.palette.text.primary,fontSize:`${o}px`,padding:i?`${n}px ${n}px 0 ${n}px`:` 0 ${n}px`,whiteSpace:"nowrap",lineHeight:1.2}}),D=(e,t,l)=>l||((null==t?void 0:t.length)&&null!=e?(0,r.applyValueMapping)(e,t).value:e),_=(e,t)=>{if(t&&e){for(let[l,n]of Object.entries(t))if((0,r.createRegexFromString)(e).test(l))return n}},N={PanelComponent:e=>{let t,l,n,{spec:o,contentDimensions:i,queryResults:s}=e,{format:d,sparkline:u,valueFontSize:c,colorMode:h}=o,f=(0,r.useChartsTheme)(),v=(t=s,l=o,n=f,(0,p.useMemo)(()=>{let{calculation:e,mappings:o,metricLabel:i}=l,a=[];for(let s of t)for(let t of s.data.series){let s=x(e,t),d=D(s,o,_(i,t.labels)),u=function(e,t,l){let{mappings:n,thresholds:o}=t??{},i=(null==o?void 0:o.defaultColor)??e.thresholds.defaultColor;if(null==l||""===l||!(null==o?void 0:o.steps)&&!n)return i;if(null==n?void 0:n.length){let e=function(e,t){if((null==t?void 0:t.length)&&null!=e){let{color:l}=(0,r.applyValueMapping)(e,t);return l||null}return null}(l,n);if(e)return e}if(o){let t=function(e,t,l,n){if((null==t?void 0:t.steps)&&"number"==typeof e){let o=t.steps.map((t,o)=>e>=t.value?t.color??l.thresholds.palette[o]??n:null).filter(e=>null!==e);return o[o.length-1]??null}return null}(l,o,e,i);if(t)return t}return i}(n,l,s),c={name:t.formattedName??"",values:t.values};a.push({calculatedValue:d,seriesData:c,color:u})}return a},[t,l,n])),C=v.length>1,b="on"===o.legendMode||"off"!==o.legendMode&&C;if(!i)return null;let M=2*(v.length-1),S=(i.width-M)/v.length;C&&S<100&&(S=100);let j=f.noDataOption.title.textStyle;return(0,a.jsx)(g.A,{height:i.height,width:i.width,spacing:"2px",direction:"row",justifyContent:C?"left":"center",alignItems:"center",sx:{overflowX:C?"scroll":"auto"},children:v.length?v.map((e,t)=>{let l=function(e,t,l){if(void 0!==l)return{lineStyle:{width:l.width??e.sparkline.width,color:t,opacity:1},areaStyle:{color:t,opacity:.4}}}(f,e.color,u);return(0,a.jsx)(T,{width:S,height:i.height,data:e,format:d,sparkline:l,showSeriesName:b,valueFontSize:c,colorMode:h},t)}):(0,a.jsx)(m.A,{sx:{...j},children:"No data"})})},supportedQueryTypes:["TimeSeriesQuery"],panelOptionsEditorComponents:[{label:"Settings",content:function(e){let{onChange:t,value:l}=e,n=h()({},f,l.format),c=(0,p.useCallback)((e,n)=>{t((0,u.jM)(l,e=>{e.legendMode=n.id}))},[t,l]),g=(0,p.useCallback)((e,n)=>{t((0,u.jM)(l,e=>{e.colorMode=n.id}))},[t,l]),m=(0,p.useMemo)(()=>(0,a.jsx)(r.OptionsEditorControl,{label:"Show",control:(0,a.jsx)(r.SettingsAutocomplete,{onChange:c,options:i,disableClearable:!0,value:i.find(e=>e.id===l.legendMode)??i.find(e=>"auto"===e.id)})}),[l.legendMode,c]),x=(0,p.useMemo)(()=>(0,a.jsx)(r.OptionsEditorControl,{label:"Color mode",control:(0,a.jsx)(r.SettingsAutocomplete,{onChange:g,options:o.map(e=>{let{id:t,label:l}=e;return{id:t,label:l}}),disableClearable:!0,value:o.find(e=>e.id===l.colorMode)??o.find(e=>"value"===e.id)})}),[l.colorMode,g]);return(0,a.jsxs)(r.OptionsEditorGrid,{children:[(0,a.jsxs)(r.OptionsEditorColumn,{children:[(0,a.jsx)(r.OptionsEditorGroup,{title:"Legend",children:m}),(0,a.jsxs)(r.OptionsEditorGroup,{title:"Misc",children:[(0,a.jsx)(r.OptionsEditorControl,{label:"Sparkline",control:(0,a.jsx)(s.A,{checked:!!l.sparkline,onChange:(e,n)=>{t((0,u.jM)(l,e=>{e.sparkline=n?{}:void 0}))}})}),(0,a.jsx)(r.FormatControls,{value:n,onChange:e=>{t((0,u.jM)(l,t=>{t.format=e}))}}),(0,a.jsx)(d.CalculationSelector,{value:l.calculation,onChange:e=>{t((0,u.jM)(l,t=>{t.calculation=e}))}}),(0,a.jsx)(d.MetricLabelInput,{value:l.metricLabel,onChange:e=>{t((0,u.jM)(l,t=>{t.metricLabel=e}))}}),(0,a.jsx)(r.FontSizeSelector,{value:l.valueFontSize,onChange:e=>{t((0,u.jM)(l,t=>{t.valueFontSize=e}))}}),x]})]}),(0,a.jsx)(r.OptionsEditorColumn,{children:(0,a.jsx)(r.ThresholdsEditor,{disablePercentMode:!0,thresholds:l.thresholds,onChange:e=>{t((0,u.jM)(l,t=>{t.thresholds=e}))}})})]})}},{label:"Value mapping",content:e=>{let{onChange:t,value:l}=e;return(0,a.jsx)(r.ValueMappingsEditor,{mappings:l.mappings??[],onChange:function(e){t({...l,mappings:e})}})}}],createInitialOptions:function(){return{calculation:"last-number",format:{unit:"decimal"},sparkline:{},legendMode:"auto"}}}}}]);
|