@perses-dev/scatter-chart-plugin 0.11.0-rc.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ /*! For license information please see __federation_expose_ScatterChart.17f79ad2.js.LICENSE.txt */
2
+ "use strict";(self.chunk_ScatterChart=self.chunk_ScatterChart||[]).push([["211"],{2192(e,t,r){var a=r(70451),n=Symbol.for("react.element"),o=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var a,o={},u=null,m=null;for(a in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(m=t.ref),t)i.call(t,a)&&!l.hasOwnProperty(a)&&(o[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===o[a]&&(o[a]=t[a]);return{$$typeof:n,type:e,key:u,ref:m,props:o,_owner:s.current}}t.Fragment=o,t.jsx=u,t.jsxs=u},62540(e,t,r){e.exports=r(2192)},24310(e,t,r){r.r(t),r.d(t,{ScatterChart:()=>T});var a=r(62540),n=r(70451),o=r(57072),i=r(74653),s=r(32741),l=r(90652),u=r(61305),m=r(50944),c=r(59738),d=r(72106),f=r(55875),h=r(37573),p=r(19848);(0,i.Y)([l.a,u.a,m.a,s.a,c.a,d.a,f.a,h.a]);let y={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3};function b(e){let{width:t,height:r,options:i,link:s}=e,l=(0,o.useChartsTheme)(),{absoluteTimeRange:u}=(0,p.useTimeRange)(),{timeZone:m,dateFormatOptionsWithUserTimeZone:c}=(0,o.useTimeZone)(),d=(0,n.useMemo)(()=>{let e=c(y);return new Intl.DateTimeFormat(void 0,e).format},[c]),f=(0,p.useAllVariableValues)(),{navigate:h}=(0,p.useRouterContext)(),b=u.end.valueOf()-u.start.valueOf(),v=(0,n.useCallback)(()=>function(e){let t=new Date(Number(e));return b>15768e7?(0,o.formatWithTimeZone)(t,"yyyy",m):b>15552e6?(0,o.formatWithTimeZone)(t,"MMM yyyy",m):b>864e6?(0,o.formatWithTimeZone)(t,"dd.MM",m):b>1728e5?(0,o.formatWithTimeZone)(t,"dd.MM HH:mm",m):(0,o.formatWithTimeZone)(t,"HH:mm",m)},[b,m]),T={dataset:i.dataset,series:i.series,dataZoom:i.dataZoom,grid:{top:45,bottom:20,left:30,right:20},xAxis:{type:"time",min:u.start,max:u.end,axisLabel:{hideOverlap:!0,formatter:v()}},yAxis:{scale:!0,type:"value",name:"Duration",splitNumber:4,axisLabel:{formatter:e=>(0,o.formatValue)(e,{unit:"milliseconds"})}},animation:!1,tooltip:{padding:5,borderWidth:1,trigger:"axis",axisPointer:{type:"cross"},formatter:function(e){let t=e[0].data;return`<b>Service name</b>: ${t.rootServiceName}<br/><b>Span name</b>: ${t.rootTraceName}<br/><b>Time</b>: ${d(t.startTime)}<br/><b>Duration</b>: ${(0,o.formatValue)(t.durationMs,{unit:"milliseconds"})}<br/><b>Span count</b>: ${t.spanCount} (${t.errorCount} errors)<br/>`}},legend:{show:!0,type:"scroll",orient:"horizontal",bottom:0}},S=(0,n.useMemo)(()=>{let e={};return h&&s&&(e.click=e=>{let t=e.data.linkVariables;h((0,p.replaceVariablesInString)(s,f,t))}),e},[s,h,f]);return(0,a.jsx)(o.EChart,{style:{width:t,height:r},option:T,theme:l.echartsTheme,onEvents:S})}let v=[6,20],T={PanelComponent:function(e){let{spec:t,contentDimensions:r,queryResults:i}=e,s=(0,o.useChartsTheme)().thresholds.defaultColor||"blue",l=t.sizeRange||v,{dataset:u,minSpanCount:m,maxSpanCount:c}=(0,n.useMemo)(()=>{let e,t,r=[];for(let a of i){if(void 0===a.data.searchResult)continue;let n=a.data.searchResult.map(r=>{var n;let o=0,i=0;for(let e of Object.values(r.serviceStats))o+=e.spanCount,i+=e.errorCount??0;(void 0===e||o<e)&&(e=o),(void 0===t||o>t)&&(t=o);let s=a.definition.spec.plugin.spec;return{...r,linkVariables:{datasourceName:(null==s||null==(n=s.datasource)?void 0:n.name)??"",traceId:r.traceId},name:`${r.rootServiceName}: ${r.rootTraceName}`,startTime:new Date(r.startTimeUnixMs),spanCount:o,errorCount:i}});r.push({source:n})}return{dataset:r,minSpanCount:e??0,maxSpanCount:t??0}},[i]),d=(0,n.useMemo)(()=>{let e={type:"scatter",encode:{x:"startTime",y:"durationMs"},symbolSize:function(e){return function(e,t,r){let[a,n]=r,[o,i]=t;return i-o==0?n:a+(e-o)/(i-o)*(n-a)}(e.spanCount,[m,c],l)},itemStyle:{color:function(e){return e.data.errorCount>0?"red":s}}},t=[];for(let r=0;r<u.length;r++)t.push({...e,datasetIndex:r});return t},[u,s,m,c,l]);return i.some(e=>{var t;return((null==(t=e.data)?void 0:t.searchResult)??[]).length>0})?void 0===r?null:(0,a.jsx)("div",{"data-testid":"ScatterChartPanel_ScatterPlot",children:(0,a.jsx)(b,{width:r.width,height:r.height,options:{dataset:u,series:d},link:t.link})}):(0,a.jsx)(o.NoDataOverlay,{resource:"traces"})},supportedQueryTypes:["TraceQuery"],createInitialOptions:function(){return{}}}}}]);