@verifiedinc-public/shared-ui-elements 8.22.0 → 8.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{useMemo as m}from"react";import{Stack as u,useTheme as b,Typography as v}from"@mui/material";import{ResponsiveContainer as S,AreaChart as F,CartesianGrid as T,XAxis as k,YAxis as z,Tooltip as C,Area as L}from"recharts";import{formatDateMMYY as M,formatExtendedDate as N}from"../../../utils/date.mjs";import{DEFAULT_TIMEZONE as E}from"../../form/TimezoneInput/timezones.mjs";import{EmptyChartSection as O}from"../EmptyChartSection.mjs";import{LoadingChartSection as P}from"../LoadingChartSection.mjs";import{SeriesPercentageChartLegend as w}from"../SeriesPercentageChartLegend/index.mjs";import{chartDefaultProps as K,xAxisDefaultProps as Y,yAxisDefaultProps as Z}from"../shared.mjs";import{jsx as e,jsxs as p}from"react/jsx-runtime";const I="synchronized-metrics",j=200;function h(o){const i=new Map;for(const a of o)for(const r of a.chartData){let n=i.get(r.date);n||(n={date:r.date},i.set(r.date,n)),n[a.uuid]=r.value}return Array.from(i.values()).sort((a,r)=>a.date-r.date)}function f({title:o,mergedData:i,brands:a,timezone:r,tooltipFormatter:n,yAxisTickFormatter:d,yAxisDomain:c}){const l=b();return p(u,{children:[e(v,{variant:"subtitle2",sx:{mb:.5},children:o}),e(S,{width:"100%",height:j,children:p(F,{data:i,syncId:I,margin:K.margin,children:[e(T,{vertical:!1}),e(k,{dataKey:"date",tickFormatter:t=>M(t,{timeZone:r,hour12:!1,hour:"numeric"}),...Y}),e(z,{tickFormatter:d??(t=>Number(t).toLocaleString()),allowDecimals:!1,domain:c,...Z}),e(C,{cursor:{stroke:l.palette.neutral.main,strokeWidth:1},formatter:n??(t=>Number(t).toLocaleString()),labelFormatter:t=>N(t,{timeZone:r,hour12:!1}),itemSorter:t=>-Number(t?.value??0)}),a.map(t=>e(L,{dataKey:t.uuid,name:t.name,stroke:t.color,fill:t.color,fillOpacity:.1,type:"monotone",strokeWidth:2,isAnimationActive:!1},t.uuid))]})})]})}function W({startedData:o,succeededData:i,percentageData:a,isLoading:r,isSuccess:n,isFetching:d,filter:c,sx:l}){const t=c.timezone??E,g=!o.length&&!i.length&&!a.length,y=m(()=>h(o),[o]),x=m(()=>h(i),[i]),D=m(()=>h(a),[a]),A=m(()=>o.map(s=>({uuid:s.uuid,value:s.name,color:s.color,dataKey:s.uuid,integrationType:s.description})),[o]);return g&&r?e(P,{}):g||!n?e(O,{}):e(u,{sx:{width:"100%",...l},children:p(u,{sx:{opacity:d?.4:1,gap:2},children:[e(f,{title:"Started Over Time",mergedData:y,brands:o,timezone:t}),e(f,{title:"Succeeded Over Time",mergedData:x,brands:i,timezone:t}),e(f,{title:"Success Percentage Over Time",mergedData:D,brands:a,timezone:t,tooltipFormatter:s=>`${Number(s).toFixed(1)}%`,yAxisTickFormatter:s=>`${Number(s).toFixed(0)}%`,yAxisDomain:["auto","auto"]}),e(w,{payload:A})]})})}export{W as SynchronizedMetricsChart};
|