@perses-dev/timeseries-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/{TimeSeriesChart.1b9392b7.js → TimeSeriesChart.42841bce.js} +2 -2
- package/__mf/js/async/{137.59c998ab.js → 518.2ac1df43.js} +1 -1
- package/__mf/js/async/{546.c53e636c.js → 546.5fecffa4.js} +2 -2
- package/__mf/js/async/655.2f794f77.js +1 -0
- package/__mf/js/async/{984.3fc3c480.js → 984.83bd5c6d.js} +6 -6
- package/__mf/js/async/__federation_expose_TimeSeriesChart.0ab11cd4.js +1 -0
- package/__mf/js/{main.dc72f3eb.js → main.691eecd6.js} +2 -2
- package/lib/QuerySettingsEditor.js +5 -5
- package/lib/QuerySettingsEditor.js.map +1 -1
- package/lib/cjs/QuerySettingsEditor.js +5 -5
- package/mf-manifest.json +13 -13
- package/mf-stats.json +13 -13
- package/package.json +5 -5
- package/__mf/js/async/655.dbf8c618.js +0 -1
- package/__mf/js/async/__federation_expose_TimeSeriesChart.8b44fc75.js +0 -1
- /package/__mf/js/async/{984.3fc3c480.js.LICENSE.txt → 984.83bd5c6d.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.chunk_TimeSeriesChart=self.chunk_TimeSeriesChart||[]).push([["53"],{6443(e,t,l){l.r(t),l.d(t,{TimeSeriesChart:()=>eI});let n={unit:"decimal",shortValues:!0},a={show:!0,label:"",format:n,min:void 0,max:void 0,logBase:void 0},i="Label",o="Min",r="Max",s="Log Base",d={display:"line",lineWidth:1.25,lineStyle:"solid",areaOpacity:0,pointRadius:2.75,connectNulls:!1},u="Line Width",c="slider-line-width",h=.25,m=3,p=.25,x="Line Style",v="Area Opacity",g="slider-area-opacity",y=0,f=1,b=.05,j="Stack Series",A="Connect Nulls",C={none:{label:"None"},all:{label:"All"}},S=Object.entries(C).map(e=>{let[t,l]=e;return{id:t,...l}}),M={solid:{label:"Solid"},dashed:{label:"Dashes"},dotted:{label:"Dots"}},O={none:{label:"None",log:void 0},2:{label:"2",log:2},10:{label:"10",log:10}},w=Object.entries(O).map(e=>{let[t,l]=e;return{id:t,...l}});var T=l(62540),k=l(7013),E=l(38662),I=l(57072),L=l(19848),D=l(61375),R=l(31729),P=l(40704),N=l(68003);function F(e){let{value:t,onChange:l}=e,n=t.stack??"none",a=C[n];return(0,T.jsxs)(I.OptionsEditorGroup,{title:"Visual",children:[(0,T.jsx)(I.OptionsEditorControl,{label:j,control:(0,T.jsx)(I.SettingsAutocomplete,{value:{...a,id:n},options:S,onChange:(e,n)=>{let a={...t,stack:"none"===n.id?void 0:n.id};"all"!==n.id||t.areaOpacity||(a.areaOpacity=.3),l(a)},disabled:void 0===t,disableClearable:!0})}),(0,T.jsx)(I.OptionsEditorControl,{label:"Display",control:(0,T.jsxs)(D.A,{color:"primary",exclusive:!0,value:t.display??"line",onChange:(e,n)=>{l({...t,display:n})},children:[(0,T.jsx)(R.A,{value:"line",selected:void 0===t.display||"line"===t.display,"aria-label":"display line series",children:"Line"}),(0,T.jsx)(R.A,{value:"bar","aria-label":"display bar series",children:"Bar"})]})}),"line"===t.display&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(I.OptionsEditorControl,{label:u,control:(0,T.jsx)(P.Ay,{"data-testid":c,value:t.lineWidth??1.25,valueLabelDisplay:"auto",step:p,marks:!0,min:h,max:m,onChange:(e,n)=>{let a=Array.isArray(n)?n[0]:n,i=void 0!==a?a+1.5:2.75;l((0,E.jM)(t,e=>{e.lineWidth=a,e.pointRadius=i}))}})}),(0,T.jsx)(I.OptionsEditorControl,{label:x,control:(0,T.jsx)(D.A,{color:"primary",exclusive:!0,value:t.lineStyle??"solid",onChange:(e,n)=>{l({...t,lineStyle:n})},children:Object.entries(M).map(e=>{let[t,l]=e;return(0,T.jsx)(R.A,{value:t,"aria-label":`${t} line style`,children:l.label},t)})})}),(0,T.jsx)(I.OptionsEditorControl,{label:v,control:(0,T.jsx)(P.Ay,{"data-testid":g,value:t.areaOpacity??0,valueLabelDisplay:"auto",step:b,marks:!0,min:y,max:f,onChange:(e,n)=>{let a=Array.isArray(n)?n[0]:n;l((0,E.jM)(t,e=>{e.areaOpacity=a}))}})}),(0,T.jsx)(I.OptionsEditorControl,{label:A,control:(0,T.jsx)(N.A,{checked:t.connectNulls??!1,onChange:e=>{l({...t,connectNulls:e.target.checked})}})})]})]})}var _=l(93648);function W(e){let{value:t,onChange:l}=e,d=t.logBase?O[t.logBase]:void 0;return(0,T.jsxs)(I.OptionsEditorGroup,{title:"Y Axis",children:[(0,T.jsx)(I.OptionsEditorControl,{label:"Show",control:(0,T.jsx)(N.A,{checked:t.show??a.show,onChange:e=>{l({...t,show:e.target.checked})}})}),(0,T.jsx)(I.FormatControls,{value:t.format??n,onChange:e=>l({...t,format:e})}),(0,T.jsx)(I.OptionsEditorControl,{label:s,control:(0,T.jsx)(I.SettingsAutocomplete,{value:{...d,id:(null==d?void 0:d.label)??"None"},options:w,onChange:(e,n)=>{l({...t,logBase:n.log??void 0})},disabled:void 0===t,disableClearable:!0})}),(0,T.jsx)(I.OptionsEditorControl,{label:i,control:(0,T.jsx)(_.A,{value:t.label??"",inputProps:{"aria-label":"enter y axis label"},onChange:e=>l({...t,label:e.target.value}),placeholder:"Default"})}),(0,T.jsx)(I.OptionsEditorControl,{label:o,control:(0,T.jsx)(_.A,{type:"number",value:t.min??"",onChange:e=>{let n=e.target.value?Number(e.target.value):void 0;l({...t,min:n})},placeholder:"Default"})}),(0,T.jsx)(I.OptionsEditorControl,{label:r,control:(0,T.jsx)(_.A,{type:"number",value:t.max??"",onChange:e=>{let n=e.target.value?Number(e.target.value):void 0;l({...t,max:n})},placeholder:"Default"})})]})}var V=l(315),G=l(88091),Y=l(97653),z=l(74628),B=l(47095),$=l(30145),H=l(56599),q=l(70451),U=l(86067),Z=l(86742),X=l(7800);let Q="#555";function K(e){let{querySettings:{queryIndex:t,colorMode:l,colorValue:n,lineStyle:a,areaOpacity:i,format:o,negativeY:r,stack:s},availableQueryIndexes:d,queryNames:u,onQueryIndexChange:c,onColorModeChange:h,onColorValueChange:m,onLineStyleChange:p,onAreaOpacityChange:x,onDelete:v,inputRef:g,onAddColor:y,onRemoveColor:f,onAddLineStyle:b,onRemoveLineStyle:j,onAddAreaOpacity:A,onRemoveAreaOpacity:C,onAddFormat:S,onRemoveFormat:O,onFormatChange:w,onAddNegativeY:k,onRemoveNegativeY:E,onAddStack:L,onRemoveStack:F,onStackChange:W}=e,H=d.concat(t).sort((e,t)=>e-t),[X,K]=(0,q.useState)(null),ee=(0,q.useMemo)(()=>{let e=[];return l||e.push({key:"color",label:"Color",action:y}),a||e.push({key:"lineStyle",label:"Line Style",action:b}),void 0===i&&e.push({key:"opacity",label:"Opacity",action:A}),void 0===o&&e.push({key:"format",label:"Format",action:S}),r||e.push({key:"negativeY",label:"Negative Y",action:k}),void 0===s&&e.push({key:"stack",label:"Stack",action:L}),e},[l,a,i,o,r,s,y,b,A,S,k,L]),et=()=>{K(null)};return(0,T.jsxs)(V.A,{sx:{borderBottom:"1px solid",borderColor:"divider",borderRadius:1,p:2,display:"flex",flexWrap:"nowrap",flexDirection:"row"},children:[(0,T.jsxs)(V.A,{direction:"row",alignItems:"center",sx:{flexWrap:"wrap",gap:2,flexGrow:1},children:[(0,T.jsx)(_.A,{select:!0,inputRef:g,value:t,label:"Query",onChange:c,sx:{minWidth:"75px"},children:H.map(e=>(0,T.jsx)(Y.A,{value:e,children:u[e]??`#${e+1}`},`query-${e}`))}),l&&(0,T.jsxs)(J,{label:"Color",onRemove:f,children:[(0,T.jsxs)(_.A,{select:!0,value:l,onChange:h,size:"small",sx:{flexGrow:1},children:[(0,T.jsx)(Y.A,{value:"fixed",children:"Fixed"}),(0,T.jsx)(Y.A,{value:"fixed-single",children:"Fixed (single series)"})]}),(0,T.jsx)(I.OptionsColorPicker,{label:u[t]??`Query n\xb0${t+1}`,color:n||Q,onColorChange:m})]}),a&&(0,T.jsxs)(J,{label:"Line Style",onRemove:j,children:[(0,T.jsx)(D.A,{color:"primary",exclusive:!0,value:a,onChange:(e,t)=>{null!==t&&p(t)},size:"small",children:Object.entries(M).map(e=>{let[t,l]=e;return(0,T.jsx)(R.A,{value:t,"aria-label":`${t} line style`,children:l.label},t)})}),(0,T.jsx)(z.A,{sx:{flexGrow:1}})]}),void 0!==i&&(0,T.jsxs)(J,{label:"Opacity",onRemove:C,children:[(0,T.jsx)(z.A,{}),(0,T.jsx)(P.Ay,{value:i,valueLabelDisplay:"auto",step:.05,marks:!0,min:0,max:1,onChange:x,sx:{flexGrow:1}})]}),void 0!==o&&(0,T.jsx)(J,{label:"Format",onRemove:O,children:(0,T.jsx)(z.A,{sx:{minWidth:"180px",display:"flex",gap:1,flexDirection:"column"},children:(0,T.jsx)(I.FormatControls,{value:o,onChange:w})})}),r&&(0,T.jsx)(J,{label:"Negative Y",onRemove:E,children:(0,T.jsx)(G.A,{variant:"body2",color:"text.secondary",sx:{flexGrow:1,py:.5},children:"Series rendered below the X axis"})}),void 0!==s&&(0,T.jsxs)(J,{label:"Stack",onRemove:F,children:[(0,T.jsx)(N.A,{checked:s,onChange:e=>W(e.target.checked),slotProps:{input:{"aria-label":"stack override"}}}),(0,T.jsx)(z.A,{sx:{flexGrow:1}})]}),ee.length>0&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(B.A,{onClick:e=>{1===ee.length&&ee[0]?ee[0].action():K(e.currentTarget)},"aria-label":"Add option",children:(0,T.jsx)(Z.default,{})}),(0,T.jsx)($.A,{anchorEl:X,open:!!X,onClose:et,anchorOrigin:{vertical:"bottom",horizontal:"left"},children:ee.map(e=>(0,T.jsxs)(Y.A,{onClick:()=>{(0,e.action)(),et()},sx:{minWidth:"120px"},children:[(0,T.jsx)(Z.default,{sx:{mr:1,fontSize:"1rem"}}),e.label]},e.key))})]})]}),(0,T.jsx)(z.A,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:(0,T.jsx)(B.A,{"aria-label":`delete settings for ${u[t]??`query n\xb0${t+1}`}`,onClick:v,children:(0,T.jsx)(U.default,{})})})]})}function J(e){let{label:t,children:l,onRemove:n}=e,a=(0,H.A)();return(0,T.jsxs)(z.A,{sx:{position:"relative",minWidth:"250px"},children:[(0,T.jsx)(G.A,{variant:"caption",sx:{position:"absolute",top:-8,left:12,backgroundColor:a.palette.background.code,px:.5,color:"text.secondary",zIndex:1},children:t}),(0,T.jsxs)(V.A,{direction:"row",alignItems:"center",spacing:1,sx:{border:"1px solid",borderColor:"divider",borderRadius:1,p:1},children:[l,(0,T.jsx)(B.A,{size:"small",onClick:n,"aria-label":`Remove ${t}`,children:(0,T.jsx)(X.default,{})})]})]})}var ee=l(25632),et=l.n(ee),el=l(35432);function en(e){let t=Math.floor(Math.log10(Math.abs(e)));return Math.floor(e/Math.pow(10,t))*Math.pow(10,t)}var ea=l(92959);let ei=new ea.A({hue:{min:20,max:360}}),eo=new ea.A({hue:{min:0,max:20}}),er={};var es=l(18264),ed=l.n(es),eu=l(74653),ec=l(62707),eh=l(31373),em=l(59738),ep=l(90652),ex=l(61305),ev=l(64404),eg=l(28502),ey=l(48683),ef=l(72106),eb=l(40988),ej=l(55875),eA=l(37573),eC=l(36961),eS=l(6227),eM=l(4491),eO=l(29917),ew=l(85180);function eT(e){let{annotation:t,containerId:l,formatWithUserTimeZone:n,pinnedPos:a,enablePinning:i=!0,onUnpinClick:o}=e,r=(0,I.useMousePosition)(),{height:s,width:d,ref:u}=(0,ew.default)(),c=null!==a;if(!c&&null===r)return null;let h=l?document.querySelector(l):void 0,m=h?h.getBoundingClientRect().height:void 0,p=(0,I.assembleTransform)(r,a,s??0,d??0,h),x=(0,I.getDateAndTime)(t.start,n),v=void 0!==t.end?(0,I.getDateAndTime)(t.end,n):null;return(0,T.jsx)(eC.A,{container:h,children:(0,T.jsx)(z.A,{ref:u,sx:e=>(0,I.getTooltipStyles)(e,a,m),style:{transform:p},children:(0,T.jsxs)(V.A,{spacing:.5,children:[(0,T.jsxs)(z.A,{sx:e=>{var t;return{width:"100%",maxWidth:I.TOOLTIP_MAX_WIDTH,padding:e.spacing(1.5,2,.5,2),backgroundColor:(null==(t=e.palette.designSystem)?void 0:t.grey[800])??I.TOOLTIP_BG_COLOR_FALLBACK,position:"sticky",top:0,left:0}},children:[(0,T.jsxs)(z.A,{sx:{display:"flex",alignItems:"center",paddingBottom:.5,width:"100%"},children:[(0,T.jsx)(z.A,{sx:{width:8,height:8,borderRadius:"50%",backgroundColor:t.color??L.DEFAULT_ANNOTATION_COLOR,marginRight:1,flexShrink:0}}),(0,T.jsxs)(z.A,{sx:{flexGrow:1,minWidth:0},children:[(0,T.jsxs)(G.A,{variant:"caption",children:[x.formattedDate," - ",(0,T.jsx)("strong",{children:x.formattedTime})]}),v&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(G.A,{variant:"caption",children:" → "}),(0,T.jsxs)(G.A,{variant:"caption",children:[v.formattedDate," - ",(0,T.jsx)("strong",{children:v.formattedTime})]})]})]}),i&&(0,T.jsxs)(V.A,{direction:"row",alignItems:"center",sx:{marginLeft:1,flexShrink:0},children:[(0,T.jsx)(G.A,{sx:{marginRight:.5,fontSize:11,verticalAlign:"middle"},children:c?I.UNPIN_TOOLTIP_HELP_TEXT:I.PIN_TOOLTIP_HELP_TEXT}),c?(0,T.jsx)(eM.default,{onClick:()=>{void 0!==o&&o()},sx:{fontSize:16,cursor:"pointer"}}):(0,T.jsx)(eO.default,{sx:{fontSize:16}})]})]}),(0,T.jsx)(eS.A,{sx:e=>({width:"100%",borderColor:e.palette.grey["500"]})})]}),(0,T.jsxs)(z.A,{sx:e=>({padding:e.spacing(.5,2,1.5,2)}),children:[t.title&&(0,T.jsx)(G.A,{variant:"caption",sx:{display:"block",fontWeight:"bold",marginBottom:.5},children:t.title}),t.legend&&(0,T.jsx)(G.A,{variant:"caption",sx:{display:"block",marginBottom:.5},children:t.legend}),t.tags&&Object.keys(t.tags).length>0&&(0,T.jsx)(z.A,{sx:{display:"flex",flexWrap:"wrap",gap:.5,marginTop:.5},children:Object.entries(t.tags).map(e=>{let[t,l]=e;return(0,T.jsxs)(z.A,{sx:e=>({backgroundColor:e.palette.grey["700"],borderRadius:"4px",padding:"2px 6px",fontSize:"0.7rem",fontFamily:"monospace"}),children:[t,": ",l]},t)})})]})]})})})}(0,eu.Y)([ec.a,eh.a,em.a,ep.a,ex.a,ev.a,eg.a,ey.a,ef.a,eb.a,ej.a,eA.a]);let ek=(0,q.forwardRef)(function(e,t){var l;let n,{height:a,data:i,seriesMapping:o,annotations:r,timeScale:s,yAxis:d,format:u,seriesFormatMap:c,grid:h,isStackedBar:m=!1,tooltipConfig:p=I.DEFAULT_TOOLTIP_CONFIG,noDataVariant:x="message",syncGroup:v,onDataZoom:g,onDoubleClick:y,__experimentalEChartsOptionsOverride:f}=e,{chartsTheme:b,enablePinning:j,enableSyncGrouping:A,lastTooltipPinnedCoords:C,setLastTooltipPinnedCoords:S}=(0,I.useChartsContext)(),M=p.enablePinning&&j,O=(0,q.useRef)(),[w,k]=(0,q.useState)(!0),[E,D]=(0,q.useState)(null),[R,P]=(0,q.useState)(null),[N,F]=(0,q.useState)(!1),[_,W]=(0,q.useState)(0),[V,G]=(0,q.useState)(null),[Y,B]=(0,q.useState)(null),[$,H]=(0,q.useState)(null),{timeZone:U,formatWithUserTimeZone:Z}=(0,I.useTimeZone)(),X=(0,q.useCallback)(e=>function(t){let l=new Date(Number(t));return e>15768e7?(0,I.formatWithTimeZone)(l,"yyyy",U):e>63072e6?(0,I.formatWithTimeZone)(l,"MMM yyyy",U):e>864e6&&e<1577664e4?(0,I.formatWithTimeZone)(l,"dd.MM",U):e>1728e5&&e<=864e6?(0,I.formatWithTimeZone)(l,"dd.MM HH:mm",U):(0,I.formatWithTimeZone)(l,"HH:mm",U)},[U]);if(void 0===s){let e=(0,I.getCommonTimeScale)(i);if(void 0===e){let e=new Date,t=new Date(e);t.setFullYear(e.getFullYear()-5);let l=e.getTime(),a=t.getTime();n={startMs:a,endMs:l,stepMs:1,rangeMs:l-a}}else n=e}else n=s;(0,q.useImperativeHandle)(t,()=>({highlightSeries(e){let{name:t}=e;O.current&&O.current.dispatchAction({type:"highlight",seriesId:t})},clearHighlightedSeries:()=>{O.current&&(0,I.clearHighlightedSeries)(O.current)}}),[]);let Q=(0,q.useMemo)(()=>({datazoom:e=>{if(void 0===g&&setTimeout(()=>{D(null)},10),void 0===g||void 0===e.batch[0])return;let t=e.batch[0].startValue,l=e.batch[0].endValue;void 0!==t&&void 0!==l&&g({start:t,end:l})},finished:()=>{void 0!==O.current&&(0,I.enableDataZoom)(O.current)},mouseover:e=>{var t;if(r&&"markPoint"===e.componentType&&(null==(t=e.data)?void 0:t.annotationIndex)!==void 0){let t=r[e.data.annotationIndex]||null;if(t)return void G(t)}G(null)},mouseout:e=>{var t;if(r&&"markPoint"===e.componentType&&(null==(t=e.data)?void 0:t.annotationIndex)!==void 0&&r){let t=r[e.data.annotationIndex]||null;G(e=>e===t?null:e)}},globalout:()=>{r&&G(null)}}),[r,g]),K=(0,q.useMemo)(()=>(function(e){if(!(null==e?void 0:e.length))return[];let t=[],l=[],n=[];return e.forEach((e,a)=>{let i=e.color??L.DEFAULT_ANNOTATION_COLOR;if(void 0!==e.end)for(let o of(l.push({xAxis:e.start,lineStyle:{color:i,width:2,type:"dashed"},label:{show:!1},annotationIndex:a}),l.push({xAxis:e.end,lineStyle:{color:i,width:2,type:"dashed"},label:{show:!1},annotationIndex:a}),t.push([{xAxis:e.start,itemStyle:{color:i,opacity:.3}},{xAxis:e.end}]),[!0,!1]))n.push({coord:[o?e.start:e.end,0],symbol:"triangle",symbolSize:[12,12],symbolRotate:0,symbolOffset:[0,4],itemStyle:{color:i},annotationIndex:a,emphasis:{disabled:!0},isStart:o,isEnd:!o});else l.push({xAxis:e.start,lineStyle:{color:i,width:2,type:"dashed"},label:{show:!1},annotationIndex:a}),n.push({coord:[e.start,0],symbol:"triangle",symbolSize:[12,10],symbolRotate:0,symbolOffset:[0,"120%"],itemStyle:{color:i},annotationIndex:a,isPoint:!0})}),[{type:"line",data:[],silent:!1,markArea:t.length>0?{silent:!0,data:t,label:{show:!1}}:void 0,markLine:l.length>0?{silent:!0,symbol:["none","none"],data:l,lineStyle:{type:"dashed"}}:void 0,markPoint:n.length>0?{silent:!1,data:n,label:{show:!1}}:void 0}]})(r),[r]),{noDataOption:J}=b,ee=(0,q.useMemo)(()=>{if(null===i||0===i.length&&"message"===x)return J;let e=[];i.map((t,l)=>{let n=t.values.map(e=>{let[t,l]=e;return[t,null===l?"-":l]});e.push({id:l,source:[...n],dimensions:["time","value"]})});let t={dataset:e,series:j&&null!==R?[...o,R,...K]:[...o,...K],xAxis:{type:"time",min:n.startMs,max:n.endMs,axisLabel:{hideOverlap:!0,formatter:X(n.rangeMs??0)},axisPointer:{snap:!1}},yAxis:Array.isArray(d)?d:(0,I.getFormattedAxis)(d,u),animation:!1,tooltip:{show:!0,showContent:m,trigger:m?"item":"axis",appendToBody:m},axisPointer:{type:"line",z:0,triggerEmphasis:!1,triggerTooltip:!1,snap:!1},toolbox:{feature:{dataZoom:{icon:null,yAxisIndex:"none"}}},grid:h};return f?f(t):t},[i,o,K,n,d,u,h,J,f,x,m,j,R,X]);return(0,q.useEffect)(()=>{null===E||null===C||ed()(C,E)||(D(null),null!==E&&null!==R&&P(null))},[C,o]),(0,T.jsxs)(z.A,{style:{height:a},onClick:e=>{if(null!==V&&e.target instanceof HTMLCanvasElement){let t={page:{x:e.pageX,y:e.pageY},client:{x:e.clientX,y:e.clientY},plotCanvas:{x:e.nativeEvent.offsetX,y:e.nativeEvent.offsetY},target:e.target};B(e=>e===V?(H(null),null):(H(t),V));return}let t=e.ctrlKey||e.metaKey;t&&e.preventDefault();let l=(0,I.getPointInGrid)(e.nativeEvent.offsetX,e.nativeEvent.offsetY,O.current);if(null!==l&&M&&e.target instanceof HTMLCanvasElement){let n={page:{x:e.pageX,y:e.pageY},client:{x:e.clientX,y:e.clientY},plotCanvas:{x:e.nativeEvent.offsetX,y:e.nativeEvent.offsetY},target:e.target};D(e=>null===e?n:(P(null),null)),P(e=>{if(null!==e)return null;{var t;let e=l[0],n=null==(t=i[0])?void 0:t.values,a=(0,I.getClosestTimestamp)(n,e);return et()({},I.DEFAULT_PINNED_CROSSHAIR,{markLine:{data:[{xAxis:a}]}})}}),t||S(n)}},onMouseDown:e=>{let{clientX:t}=e;F(!0),W(t)},onMouseMove:e=>{if(!(e.target instanceof HTMLCanvasElement))return;let{clientX:t}=e;N&&t-_>0&&k(!1)},onMouseUp:()=>{F(!1),W(0),k(!0)},onMouseLeave:()=>{null===E&&k(!1),G(null),void 0!==O.current&&(0,I.clearHighlightedSeries)(O.current)},onMouseEnter:()=>{k(!0),void 0!==O.current&&(0,I.enableDataZoom)(O.current)},onDoubleClick:e=>{D(null),void 0===y?void 0!==O.current&&(0,I.restoreChart)(O.current):y(e)},children:[!0===w&&(null!==E||null===V)&&(null==(l=ee.tooltip)?void 0:l.showContent)===!1&&!0!==p.hidden&&(0,T.jsx)(I.TimeChartTooltip,{containerId:b.tooltipPortalContainerId,chartRef:O,data:i,seriesMapping:o,wrapLabels:p.wrapLabels,enablePinning:M,pinnedPos:E,format:u,seriesFormatMap:c,onUnpinClick:()=>{D(null),P(null)}}),(Y??V)&&(0,T.jsx)(eT,{annotation:Y??V,containerId:b.tooltipPortalContainerId,formatWithUserTimeZone:Z,pinnedPos:null!==Y?$:null,enablePinning:M,onUnpinClick:()=>{B(null),H(null)}}),(0,T.jsx)(I.EChart,{sx:{width:"100%",height:"100%"},option:ee,theme:b.echartsTheme,onEvents:Q,_instance:O,syncGroup:A?v:void 0})]})});var eE=l(54042);let eI={PanelComponent:function(e){var t;let{spec:{thresholds:l,yAxis:i,tooltip:o,querySettings:r},contentDimensions:s,queryResults:u}=e,c=(0,I.useChartsTheme)(),h=(0,H.A)(),m=(0,I.useId)("time-series-panel"),p=(0,q.useRef)(null),x=c.echartsTheme.color,v=c.container.padding.default,g=s?{width:s.width-2*v,height:s.height-2*v}:void 0,y=(0,q.useMemo)(()=>e.spec.legend&&(0,L.validateLegendSpec)(e.spec.legend)?et()({},I.DEFAULT_LEGEND,e.spec.legend):void 0,[e.spec.legend]),f=(null==(t=e.spec.yAxis)?void 0:t.format)??n,b=(0,q.useMemo)(()=>et()({},d,e.spec.visual),[e.spec.visual]),j=(0,q.useMemo)(()=>(function(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=void 0!==t.logBase?void 0:(null==t?void 0:t.min)!==void 0?t.min:e=>e.min>=0&&e.min<=1?0:e.min>0?en(.8*e.min):en(1.2*e.min);let l={show:(null==t?void 0:t.show)??a.show,min:e,max:null==t?void 0:t.max};return void 0!==t.logBase?{...l,type:"log",logBase:t.logBase}:l})(i),[i]),{additionalFormats:A,formatToYAxisIndex:C,seriesFormatMap:S}=(0,q.useMemo)(()=>{let e=(null==f?void 0:f.unit)??"decimal",t=[],l=new Map,n=new Map;for(let n of(l.set(e,0),r??[])){var a;if((null==(a=n.format)?void 0:a.unit)&&n.format.unit!==e){let e=n.format.unit;l.has(e)||(l.set(e,1+t.length),t.push(n.format))}}return{additionalFormats:t,formatToYAxisIndex:l,seriesFormatMap:n}},[f,r]),[M,O]=(0,q.useState)("ALL"),[w,k]=(0,q.useState)(),{setTimeRange:E}=(0,L.useTimeRange)(),D=(0,el.useAnnotationsWithData)(),R=(0,q.useMemo)(()=>(function(e){let t=[];for(let l of e)for(let e of l.data)l.definition.display.hidden||t.push({...l.definition.display,...e});return t})(D),[D]),{timeScale:P,timeChartData:N,timeSeriesMapping:F,legendItems:_,seriesFormatMap:W,maxValuesByFormat:V}=(0,q.useMemo)(()=>{let e,t=(e=u.map(e=>e.data),(0,I.getCommonTimeScale)(e));if(void 0===t)return{timeChartData:[],timeSeriesMapping:[],seriesFormatMap:new Map,maxValuesByFormat:new Map};let n=[],a=[],o=[],s=new Map,d=0;for(let e=0;e<u.length;e++){let l,i=u[e];for(let t of r??[])t.queryIndex===e&&(l=t);if(i)for(let r=0;r<i.data.series.length;r++){var p,v,g;let c=i.data.series[r];if(void 0===c)return{timeChartData:[],timeSeriesMapping:[],legendItems:[]};let f=c.formattedName??c.name,j=function(e){var t,l,n;let{categoricalPalette:a,visual:i,muiPrimaryColor:o,seriesName:r,seriesIndex:s,querySettings:d,queryHasMultipleResults:u}=e;if(d){if("fixed"===d.colorMode&&d.colorValue)return d.colorValue;else if("fixed-single"===d.colorMode&&!u&&d.colorValue)return d.colorValue}let c=Array.isArray(a)&&a[0]?a[0]:o;return(null==(t=i.palette)?void 0:t.mode)==="categorical"?function(e,t,l){if(void 0===e)return l;let n=e.length??1;return e[t%n]??l}(a,s,c):(l=r,n=c,function(e){var t;let l,n;return t=e.toLowerCase().includes("error"),(n=er[l=`${e}_____${t}`])||(n=function(e,t){let[l,n,a]=t?eo.hsl(e):ei.hsl(e),i=`${(100*n).toFixed(0)}%`,o=`${(100*a).toFixed(0)}%`;return`hsla(${l.toFixed(2)},${i},${o},0.9)`}(e,t),er[l]=n),n}(l)??n)}({categoricalPalette:x,visual:b,muiPrimaryColor:h.palette.primary.main,seriesName:f,seriesIndex:d,querySettings:l,queryHasMultipleResults:((null==(g=u[e])||null==(v=g.data)||null==(p=v.series)?void 0:p.length)??0)>1}),A=m+c.name+d,O=(null==y?void 0:y.values)?(0,L.getCalculations)(c.values,y.values):void 0,w="ALL"===M;if(!w&&M[A]||w){let e=a.length,n=null==l?void 0:l.format,i=(null==n?void 0:n.unit)?C.get(n.unit)??0:0;if(o.push(function(e,t,l,n,a,i,o,r){let s=n.lineWidth??1.25,d=n.pointRadius??2.75,u=(null==o?void 0:o.stack)!==void 0?o.stack:"all"===n.stack,c=a.rangeMs<=9e5;return("always"===n.showPoints&&(c=!0),"bar"===n.display)?{type:"bar",id:e,datasetIndex:t,name:l,color:i,stack:u?"all":void 0,yAxisIndex:r,label:{show:!1}}:{type:"line",id:e,datasetIndex:t,name:l,connectNulls:n.connectNulls??!1,color:i,stack:u?"all":void 0,yAxisIndex:r,sampling:"lttb",progressiveThreshold:I.OPTIMIZED_MODE_SERIES_LIMIT,showSymbol:c,showAllSymbol:!0,symbolSize:d,lineStyle:{width:s,type:(null==o?void 0:o.lineStyle)??n.lineStyle},areaStyle:{opacity:(null==o?void 0:o.areaOpacity)??n.areaOpacity??0},emphasis:{focus:"series",disabled:void 0!==n.areaOpacity&&n.areaOpacity>0,lineStyle:{width:s+1,opacity:1,type:n.lineStyle}},blur:{lineStyle:{width:s,opacity:.5,type:n.lineStyle}}}}(A,e,f,b,t,j,l,i)),n){S.set(A,n);let e=n.unit;if(e){let t=Math.max(...c.values.map(e=>Math.abs(e[1]??0)));t>(s.get(e)??0)&&s.set(e,t)}}let r=(0,I.getTimeSeriesValues)(c,t),d=(null==l?void 0:l.negativeY)?r.map(e=>{let[t,l]=e;return[t,null===l?null:-l]}):r;a.push({name:f,values:d})}y&&n&&n.push({id:A,label:f,color:j,data:O}),d++}}if(l&&l.steps&&a.length>0){let e=c.thresholds,n=l.defaultColor??e.defaultColor;l.steps.forEach((r,s)=>{var u,c,h,m,p;let x,v,g,y=e.palette[s]??n,f={color:r.color??y,value:"percent"===l.mode?(u=r.value,c=null==i?void 0:i.max,h=null==i?void 0:i.min,v=c??(x=0,(m=a).length&&void 0!==m[0]&&(null==(p=m[0])?void 0:p.values)?m.forEach(e=>{e.values.forEach(e=>{let[t,l]=e;"number"==typeof l&&Math.abs(l)>x&&(x=Math.abs(l))})}):m.forEach(e=>{void 0!==e.data&&e.data.forEach(e=>{"number"==typeof e&&Math.abs(e)>x&&(x=Math.abs(e))})}),x),u/100*(v-(g=h??0))+g):r.value},b=r.name??`Threshold ${s+1}`,j=[],A=t.startMs;for(;A<=t.endMs;)j.push([A,f.value]),A+=15e3;a.push({name:b,values:j}),o.push({type:"line",name:b,id:b,datasetId:b,datasetIndex:d,color:f.color,label:{show:!1},lineStyle:{type:"dashed",width:2},emphasis:{focus:"series",lineStyle:{width:2.5}},blur:{lineStyle:{opacity:.5}}}),d++})}return{timeScale:t,timeChartData:a,timeSeriesMapping:o,legendItems:n,seriesFormatMap:S,maxValuesByFormat:s}},[u,l,M,y,b,r,null==i?void 0:i.max,null==i?void 0:i.min,x,m,c.thresholds,h.palette.primary.main,C,S]),G=(0,q.useMemo)(()=>{if(0===A.length)return;let e=A.map(e=>{let t=e.unit;return t?(null==V?void 0:V.get(t))??1e3:1e3});return(0,I.getFormattedMultipleYAxes)(j,f,A,e)},[j,f,A,V]),Y=(0,q.useMemo)(()=>(null==y?void 0:y.values)?L.legendValues.reduce((e,t)=>{var l;let n=L.LEGEND_VALUE_CONFIG[t];return n&&(null==y||null==(l=y.values)?void 0:l.includes(t))&&e.push({accessorKey:`data.${t}`,header:n.label,headerDescription:n.description,width:72,align:"right",cell:e=>{let{getValue:t}=e,l=t();return"number"==typeof l&&f?(0,I.formatValue)(l,f):l},cellDescription:!0,enableSorting:!0}),e},[]):[],[null==y?void 0:y.values,f]),B=(0,q.useMemo)(()=>!1===j.show?{left:0,right:0,bottom:30,containLabel:!1}:{left:i&&i.label?30:20,right:A.length>0?10:20,bottom:0,containLabel:!0},[j.show,i,A.length]);if(void 0===g)return null;let $=e=>{E({start:new Date(e.start),end:new Date(e.end)})},U="bar"===b.display&&F.some(e=>(null==e?void 0:e.type)==="bar"&&"all"===e.stack),Z=!0;U?Z=!1:(null==o?void 0:o.enablePinning)!==void 0&&(Z=o.enablePinning);let X={...I.DEFAULT_TOOLTIP_CONFIG,enablePinning:Z};return(0,T.jsx)(z.A,{sx:{padding:`${v}px`},children:(0,T.jsx)(I.ContentWithLegend,{width:g.width,height:g.height,minChildrenHeight:50,legendSize:null==y?void 0:y.size,legendProps:y&&{options:y,data:_||[],selectedItems:M,onSelectedItemsChange:O,tableProps:{columns:Y,sorting:w,onSortingChange:k},onItemMouseOver:(e,t)=>{var l;let{id:n}=t;null==(l=p.current)||l.highlightSeries({name:n})},onItemMouseOut:()=>{var e;null==(e=p.current)||e.clearHighlightedSeries()}},children:e=>{let{height:t,width:l}=e;return(0,T.jsxs)(z.A,{style:{height:t,width:l},children:[i&&i.show&&i.label&&(0,T.jsx)(I.YAxisLabel,{name:i.label,height:t}),(0,T.jsx)(ek,{ref:p,height:t,data:N,seriesMapping:F,annotations:R,timeScale:P,yAxis:G??j,format:f,seriesFormatMap:W,grid:B,isStackedBar:U,tooltipConfig:X,syncGroup:"default-panel-group",onDataZoom:$,noDataVariant:!N.length&&_&&_.length>0?"chart":"message"})]})}})})},supportedQueryTypes:["TimeSeriesQuery"],panelOptionsEditorComponents:[{label:"General Settings",content:function(e){let{onChange:t,value:l}=e;return(0,T.jsxs)(I.OptionsEditorGrid,{children:[(0,T.jsxs)(I.OptionsEditorColumn,{children:[(0,T.jsx)(L.LegendOptionsEditor,{calculation:"aggregation",value:l.legend,onChange:e=>{t((0,E.jM)(l,t=>{t.legend=e}))}}),(0,T.jsx)(F,{value:l.visual??d,onChange:e=>{t((0,E.jM)(l,t=>{t.visual=e}))}})]}),(0,T.jsx)(I.OptionsEditorColumn,{children:(0,T.jsx)(W,{value:l.yAxis??a,onChange:e=>{t((0,E.jM)(l,t=>{t.yAxis=e}))}})}),(0,T.jsxs)(I.OptionsEditorColumn,{children:[(0,T.jsx)(I.ThresholdsEditor,{hideDefault:!0,thresholds:l.thresholds,onChange:e=>{t((0,E.jM)(l,t=>{t.thresholds=e}))}}),(0,T.jsx)(I.OptionsEditorGroup,{title:"Reset Settings",children:(0,T.jsx)(k.A,{variant:"outlined",color:"secondary",onClick:()=>{t((0,E.jM)(l,e=>{e.yAxis=void 0,e.legend=void 0,e.visual=void 0,e.thresholds=void 0}))},children:"Reset To Defaults"})})]})]})}},{label:"Query Settings",content:function(e){let{onChange:t,value:l}=e,n=l.querySettings,a=e=>{t((0,E.jM)(l,t=>{t.querySettings=e}))},i=(0,q.useRef)(null),o=(0,q.useRef)(!1);(0,q.useEffect)(()=>{var e;i.current&&o.current&&(null==(e=i.current)||e.focus(),o.current=!1)},[null==n?void 0:n.length]);let r=(e,t)=>{void 0!==n&&a((0,E.jM)(n,l=>{let n=l[e];n&&t(n)}))},{queryDefinitions:s}=(0,L.useDataQueriesContext)(),d=s.length,u=(0,q.useMemo)(()=>(0,L.generateQueryNames)(s),[s]),c=(0,q.useMemo)(()=>{let e=(null==n?void 0:n.map(e=>e.queryIndex))??[];return Array.from({length:d},(e,t)=>t).filter((t,l)=>!e.includes(l))},[n,d]),h=(0,q.useMemo)(()=>c[0]??-1,[c]),m={queryIndex:h};return(0,T.jsxs)(V.A,{children:[0===d?(0,T.jsx)(G.A,{mb:2,fontStyle:"italic",children:"No query defined"}):null==n?void 0:n.map((e,t)=>(0,T.jsx)(K,{inputRef:t===n.length-1?i:void 0,querySettings:e,availableQueryIndexes:c,queryNames:u,onQueryIndexChange:e=>{void 0!==n&&a((0,E.jM)(n,l=>{let n=null==l?void 0:l[t];n&&(n.queryIndex=parseInt(e.target.value))}))},onColorModeChange:e=>{void 0!==n&&a((0,E.jM)(n,l=>{if(void 0!==l){let n=l[t];if(n){let t=e.target.value;t?n.colorMode=t:(n.colorMode=void 0,n.colorValue=void 0)}}}))},onColorValueChange:e=>{void 0!==n&&a((0,E.jM)(n,l=>{if(void 0!==l){let n=l[t];n&&(n.colorValue=e)}}))},onLineStyleChange:e=>{void 0!==n&&a((0,E.jM)(n,l=>{if(void 0!==l){let n=l[t];n&&(n.lineStyle=e)}}))},onAreaOpacityChange:(e,l)=>{let i;return i=Array.isArray(l)?l[0]:l,void(void 0!==n&&a((0,E.jM)(n,e=>{if(void 0!==e){let l=e[t];l&&(l.areaOpacity=i)}})))},onDelete:()=>{void 0!==n&&a((0,E.jM)(n,e=>{e.splice(t,1)}))},onAddColor:()=>{r(t,e=>{e.colorMode="fixed",e.colorValue=Q})},onRemoveColor:()=>{r(t,e=>{e.colorMode=void 0,e.colorValue=void 0})},onAddLineStyle:()=>{r(t,e=>{e.lineStyle="solid"})},onRemoveLineStyle:()=>{r(t,e=>{e.lineStyle=void 0})},onAddAreaOpacity:()=>{r(t,e=>{e.areaOpacity=0})},onRemoveAreaOpacity:()=>{r(t,e=>{e.areaOpacity=void 0})},onAddFormat:()=>{r(t,e=>{e.format={unit:"decimal",shortValues:!0}})},onRemoveFormat:()=>{r(t,e=>{e.format=void 0})},onFormatChange:e=>{r(t,t=>{t.format=e})},onAddNegativeY:()=>{r(t,e=>{e.negativeY=!0})},onRemoveNegativeY:()=>{r(t,e=>{e.negativeY=void 0})},onAddStack:()=>{r(t,e=>{e.stack=!1})},onRemoveStack:()=>{r(t,e=>{e.stack=void 0})},onStackChange:e=>{r(t,t=>{t.stack=e})}},t)),d>0&&-1!==h&&(0,T.jsx)(k.A,{variant:"contained",startIcon:(0,T.jsx)(Z.default,{}),sx:{marginTop:1},onClick:()=>{o.current=!0,void 0===n?a([m]):a((0,E.jM)(n,e=>{e.push(m)}))},children:"Add Query Settings"})]})}}],createInitialOptions:function(){return{}},actions:[{component:e=>{let{queryResults:t,definition:l}=e,n=(0,q.useMemo)(()=>(0,L.extractExportableData)(t),[t]),a=(0,q.useMemo)(()=>(0,L.isExportableData)(n),[n]),i=(0,q.useCallback)(()=>{if(n&&a)try{var e,t;let a=(null==l||null==(t=l.spec)||null==(e=t.display)?void 0:e.name)||"Time Series Data",i=(0,L.exportDataAsCSV)({data:n}),o=(0,L.sanitizeFilename)(a),r=`${o}_data.csv`,s=document.createElement("a");s.href=URL.createObjectURL(i),s.download=r,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(s.href)}catch(e){console.error("Time series export failed:",e)}},[n,a,l]);return a?(0,T.jsx)(I.InfoTooltip,{description:"Export as CSV",children:(0,T.jsx)(B.A,{size:"small",onClick:i,"aria-label":"Export time series data as CSV",children:(0,T.jsx)(eE.default,{fontSize:"inherit"})})}):null},location:"header"}]}}}]);
|