@object-ui/plugin-charts 17.5.0 → 17.7.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/CHANGELOG.md +3143 -0
- package/README.md +32 -17
- package/dist/AdvancedChartImpl.d.ts +57 -18
- package/dist/ChartRenderer.d.ts +15 -7
- package/dist/ObjectChart.d.ts +144 -5
- package/dist/index.d.ts +67 -7
- package/dist/index.js +1729 -1006
- package/dist/index.umd.cjs +2 -2
- package/dist/normalizeChartSchema.d.ts +225 -14
- package/dist/types.d.ts +31 -28
- package/package.json +13 -12
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("react/jsx-runtime"),require("recharts"),require("@object-ui/react"),require("lucide-react"),require("@object-ui/i18n")):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`react/jsx-runtime`,`recharts`,`@object-ui/react`,`lucide-react`,`@object-ui/i18n`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginCharts={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.react_jsx_runtime,e.recharts,e.ObjectUIReact,e.lucide_react,e._object_ui_i18n))})(this,function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=Object.create,u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,p=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,h=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},g=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t||u(n,Symbol.toStringTag,{value:`Module`}),n},_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=f(t),a=0,o=i.length,s;a<o;a++)s=i[a],!m.call(e,s)&&s!==n&&u(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=d(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:l(p(e)),_(t||!e||!e.__esModule||!m.call(e,`default`)?u(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);function v(e){let t=T(e);if(t)return t;if(w(e))return Object.values(e).find(e=>typeof e==`string`&&e)}function ee(e){if(!w(e))return;let t={},n=T(e.field);n&&(t.field=n);let r=T(e.format);r&&(t.format=r);let i=E(e.min);i!==void 0&&(t.min=i);let a=E(e.max);a!==void 0&&(t.max=a);let o=E(e.stepSize);o!==void 0&&o>0&&(t.stepSize=o),typeof e.showGridLines==`boolean`&&(t.showGridLines=e.showGridLines),typeof e.logarithmic==`boolean`&&(t.logarithmic=e.logarithmic);let s=T(e.position);(s===`left`||s===`right`||s===`top`||s===`bottom`)&&(t.position=s);let c=v(e.title);return c&&(t.title=c),t}function te(e){if(!w(e)){let t=T(e);return t?{dataKey:t}:void 0}let t=T(e.dataKey)??T(e.name);if(!t)return;let n={dataKey:t},r=v(e.label);r&&(n.label=r);let i=T(e.chartType)??T(e.type);(i===`bar`||i===`line`||i===`area`)&&(n.chartType=i);let a=T(e.variant);(a===`comparison`||a===`current`||a===`primary`)&&(n.variant=a);let o=E(e.opacity);o!==void 0&&(n.opacity=o);let s=T(e.dashArray);s&&(n.dashArray=s);let c=T(e.stack);c&&(n.stack=c);let l=T(e.yAxis);(l===`left`||l===`right`)&&(n.yAxis=l);let u=T(e.color);return u&&(n.color=u),n}function y(e){if(!w(e))return{};let t={},n=T(e.type),r=T(e.chartType)??T(e.specType)??(n&&C.has(n)?n:void 0);r&&x.has(r)&&(t.chartType=r);let i=e.xAxis,a=ee(i);a&&(a.format||a.title||a.showGridLines!==void 0)&&(t.xAxis=a);let o=T(e.xAxisKey)??a?.field??T(i);o&&(t.xAxisKey=o);let s=(Array.isArray(e.yAxis)?e.yAxis:e.yAxis===void 0?[]:[e.yAxis]).map(e=>ee(e)??(T(e)?{field:T(e)}:void 0)).filter(e=>!!e);s.length&&(t.yAxes=s);let c=(Array.isArray(e.series)?e.series:Array.isArray(e.categories)?e.categories:void 0)?.map(te).filter(e=>!!e);if(!c?.length){let e=s.filter(e=>e.field).map((e,t)=>({dataKey:e.field,...e.title?{label:e.title}:{},...t>0||e.position===`right`?{yAxis:`right`}:{}}));e.length&&(c=e)}c?.length&&(t.series=c),typeof e.showLegend==`boolean`&&(t.showLegend=e.showLegend),typeof e.showDataLabels==`boolean`&&(t.showDataLabels=e.showDataLabels);let l=v(e.title);l&&(t.title=l);let u=v(e.subtitle);u&&(t.subtitle=u);let d=v(e.description);d&&(t.description=d);let f=E(e.height);return f!==void 0&&f>0&&(t.height=f),Array.isArray(e.annotations)&&e.annotations.length&&(t.annotations=e.annotations.filter(w)),w(e.interaction)&&(t.interaction=e.interaction),t}function ne(e){if(e===`bar`||e===`column`)return`bar`;if(e===`line`)return`line`;if(e===`area`)return`area`}function re(e,t){if(e===`combo`)return`combo`;let n=ne(e);if(!n||!t||t.length<2)return e;let r=t.map(e=>e.chartType??n);return new Set(r).size>1?`combo`:e}function b(e){if(!e)return;let t=e.includes(`%`),n=/^([$£€¥₹])/.exec(e),r=e.includes(`,`),i=/\.(0+)/.exec(e)?.[1].length??0,a={$:`USD`,"£":`GBP`,"€":`EUR`,"¥":`CNY`,"₹":`INR`};if(!t&&!n&&!r&&i===0)return;let o={minimumFractionDigits:i,maximumFractionDigits:i,useGrouping:r};return t?o.style=`percent`:n&&(o.style=`currency`,o.currency=a[n[1]]??`USD`),e=>{let t=typeof e==`number`?e:Number(e);if(!Number.isFinite(t))return e==null?``:String(e);try{return new Intl.NumberFormat(void 0,o).format(t)}catch{return String(t)}}}function ie(e,t){let n=e?.stepSize;if(!n||n<=0)return;let r=t.filter(e=>Number.isFinite(e)),i=r.length?Math.min(...r):void 0,a=r.length?Math.max(...r):void 0,o=e.min??Math.min(0,i??0),s=e.max??a;if(s===void 0||!Number.isFinite(o)||!Number.isFinite(s)||s<o)return;let c=Math.floor(o/n)*n,l=e.max===void 0?Math.ceil(s/n)*n:e.max,u=Math.floor((l-c)/n+1e-9)+1;if(u<1||u>D)return;let d=[];for(let e=0;e<u;e++)d.push(Number((c+e*n).toPrecision(12)));return e.max!==void 0&&d[d.length-1]<e.max&&d.push(e.max),d}function ae(e){if(!e)return;let{min:t,max:n}=e;if(t!==void 0||n!==void 0)return[t??`auto`,n??`auto`]}var x,S,oe,C,w,T,E,D,O=h((()=>{x=new Set([`bar`,`column`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`radar`,`scatter`,`treemap`,`sankey`,`combo`]),S=new Set([`gauge`,`solid-gauge`,`metric`,`kpi`,`bullet`]),oe=new Set([`table`,`pivot`]),C=new Set([...x,...S,...oe]),w=e=>!!e&&typeof e==`object`&&!Array.isArray(e),T=e=>typeof e==`string`&&e?e:void 0,E=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,D=200})),k=g({default:()=>M});function A(e,t=14){return e.length>t?`${e.slice(0,t-1)}…`:e}function j({x:e,y:t,payload:n}){let r=String(n?.value??``),a=A(r);return(0,i.jsx)(`g`,{transform:`translate(${e},${t})`,children:(0,i.jsxs)(`text`,{dy:10,textAnchor:`end`,transform:`rotate(-32)`,fill:`hsl(var(--muted-foreground))`,fontSize:11,fontFamily:`monospace`,children:[r!==a&&(0,i.jsx)(`title`,{children:r}),a]})})}function M({data:e=[],dataKey:t=`value`,xAxisKey:n=`name`,height:r=400,className:o=``,color:s=`hsl(var(--primary))`}){let c=e.map(e=>String(e?.[n]??``)),l=c.length>4||c.some(e=>e.length>8);return(0,i.jsx)(`div`,{className:`p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${o}`,children:(0,i.jsx)(a.ResponsiveContainer,{width:`100%`,height:r,children:(0,i.jsxs)(a.BarChart,{data:e,margin:{top:10,right:10,left:10,bottom:l?24:5},children:[(0,i.jsxs)(`defs`,{children:[(0,i.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,i.jsx)(`stop`,{offset:`0%`,stopColor:s,stopOpacity:1}),(0,i.jsx)(`stop`,{offset:`90%`,stopColor:s,stopOpacity:.6}),(0,i.jsx)(`stop`,{offset:`100%`,stopColor:s,stopOpacity:.3})]}),(0,i.jsxs)(`filter`,{id:`glow`,height:`130%`,children:[(0,i.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`3`,result:`blur`}),(0,i.jsx)(`feOffset`,{in:`blur`,dx:`0`,dy:`0`,result:`offsetBlur`}),(0,i.jsx)(`feFlood`,{floodColor:s,floodOpacity:`0.5`,result:`offsetColor`}),(0,i.jsx)(`feComposite`,{in:`offsetColor`,in2:`offsetBlur`,operator:`in`,result:`offsetBlur`}),(0,i.jsxs)(`feMerge`,{children:[(0,i.jsx)(`feMergeNode`,{in:`offsetBlur`}),(0,i.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]})]}),(0,i.jsx)(a.CartesianGrid,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,i.jsx)(a.XAxis,{dataKey:n,tick:l?(0,i.jsx)(j,{}):{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:{stroke:`hsl(var(--border))`},interval:0,height:l?56:void 0,dy:l?void 0:10}),(0,i.jsx)(a.YAxis,{tick:{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:!1}),(0,i.jsx)(a.Tooltip,{cursor:{fill:`hsl(var(--muted))`,opacity:.2},contentStyle:{backgroundColor:`hsl(var(--popover))`,borderColor:`hsl(var(--border))`,color:`hsl(var(--popover-foreground))`,borderRadius:`8px`,fontFamily:`monospace`,boxShadow:`0 4px 6px -1px rgb(0 0 0 / 0.1)`},itemStyle:{color:`hsl(var(--primary))`}}),(0,i.jsx)(a.Legend,{wrapperStyle:{paddingTop:`20px`,fontFamily:`monospace`}}),(0,i.jsx)(a.Bar,{dataKey:t,fill:`url(#barGradient)`,radius:[4,4,0,0],filter:`url(#glow)`,animationDuration:1500})]})})})}var se=h((()=>{}));function N(){let e=n.useContext(B);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function P({id:e,className:t,children:r,config:o,disableSettleRemount:s,style:c,...l}){let u=n.useId(),d=`chart-${e||u.replace(/:/g,``)}`,f=n.useRef(null),[p,m]=n.useState(0);n.useEffect(()=>{if(s)return;let e=f.current;if(e==null||typeof ResizeObserver>`u`)return;let t=!1,n,r=new ResizeObserver(e=>{if(t)return;let i=e[0]?.contentRect;i==null||i.width<=0||i.height<=0||(n!=null&&clearTimeout(n),n=setTimeout(()=>{t=!0,r.disconnect(),m(e=>e+1)},80))});return r.observe(e),()=>{t=!0,n!=null&&clearTimeout(n),r.disconnect()}},[s]);let h=c?.height!=null||c?.minHeight!=null,g=c?.width!=null||c?.minWidth!=null,_={...h?{}:{minHeight:280},...g?{}:{minWidth:0},...c};return(0,i.jsx)(B.Provider,{value:{config:o},children:(0,i.jsxs)(`div`,{ref:f,"data-slot":`chart`,"data-chart":d,className:R(`block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground`,t),style:_,...l,children:[(0,i.jsx)(V,{id:d,config:o}),(0,i.jsx)(a.ResponsiveContainer,{width:`100%`,height:`100%`,children:r},p)]})})}function F({active:e,payload:t,className:r,indicator:a=`dot`,hideLabel:o=!1,hideIndicator:s=!1,label:c,labelFormatter:l,labelClassName:u,formatter:d,color:f,nameKey:p,labelKey:m}){let{config:h}=N(),g=n.useMemo(()=>{if(o||!t?.length)return null;let[e]=t,n=`${m||e?.dataKey||e?.name||`value`}`,r=L(h,e,n),a=!m&&typeof c==`string`?h[c]?.label||c:r?.label;return l?(0,i.jsx)(`div`,{className:R(`font-medium`,u),children:l(a,t)}):a?(0,i.jsx)(`div`,{className:R(`font-medium`,u),children:a}):null},[c,l,t,o,u,h,m]);if(!e||!t?.length)return null;let _=t.length===1&&a!==`dot`;return(0,i.jsxs)(`div`,{className:R(`border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl`,r),children:[_?null:g,(0,i.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=`${p||e.name||e.dataKey||`value`}`,r=L(h,e,n),o=f||e.payload.fill||e.color;return(0,i.jsx)(`div`,{className:R(`[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5`,a===`dot`?`items-center`:``),children:d&&e?.value!==void 0&&e.name?d(e.value,e.name,e,t,e.payload):(0,i.jsxs)(i.Fragment,{children:[r?.icon?(0,i.jsx)(r.icon,{}):!s&&(0,i.jsx)(`div`,{className:R(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,a===`dot`?`h-2.5 w-2.5`:``,a===`line`?`w-1`:``,a===`dashed`?`w-0 border-[1.5px] border-dashed bg-transparent`:``,_&&a===`dashed`?`my-0.5`:``),style:{"--color-bg":o,"--color-border":o}}),(0,i.jsxs)(`div`,{className:R(`flex flex-1 justify-between leading-none`,_?`items-end`:`items-center`),children:[(0,i.jsxs)(`div`,{className:`grid gap-1.5`,children:[_?g:null,(0,i.jsx)(`span`,{className:`text-muted-foreground`,children:r?.label||e.name})]}),e.value&&(0,i.jsx)(`span`,{className:`text-foreground font-mono font-medium tabular-nums`,children:e.value.toLocaleString()})]})]})},e.dataKey)})})]})}function I({className:e,hideIcon:t=!1,payload:n,verticalAlign:r=`bottom`,nameKey:a}){let{config:o}=N();return n?.length?(0,i.jsx)(`div`,{className:R(`flex items-center justify-center gap-4`,r===`top`?`pb-3`:`pt-3`,e),children:n.filter(e=>e.type!==`none`).map(e=>{let n=`${a||e.dataKey||`value`}`,r=L(o,e,n);return(0,i.jsxs)(`div`,{className:R(`[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3`),children:[r?.icon&&!t?(0,i.jsx)(r.icon,{}):(0,i.jsx)(`div`,{className:`h-2 w-2 shrink-0 rounded-[2px]`,style:{backgroundColor:e.color}}),r?.label]},e.value)})}):null}function L(e,t,n){if(typeof t!=`object`||!t)return;let r=`payload`in t&&typeof t.payload==`object`&&t.payload!==null?t.payload:void 0,i=n;return r&&n in r&&typeof r[n]==`string`?i=r[n]:n in t&&typeof t[n]==`string`&&(i=t[n]),i in e?e[i]:e[n]}var R,z,B,V,H,U,W=h((()=>{R=(...e)=>e.filter(Boolean).join(` `),z={light:``,dark:`.dark`},B=n.createContext(null),V=({id:e,config:t})=>{let n=Object.entries(t).filter(([,e])=>e.theme||e.color);return n.length?(0,i.jsx)(`style`,{dangerouslySetInnerHTML:{__html:Object.entries(z).map(([t,r])=>`
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("@object-ui/i18n"),require("react/jsx-runtime"),require("recharts"),require("@object-ui/react"),require("lucide-react")):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`@object-ui/i18n`,`react/jsx-runtime`,`recharts`,`@object-ui/react`,`lucide-react`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginCharts={},e.ObjectUICore,e.React,e.ObjectUIComponents,e._object_ui_i18n,e.react_jsx_runtime,e.recharts,e.ObjectUIReact,e.lucide_react))})(this,function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=Object.create,u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,p=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,h=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},g=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t||u(n,Symbol.toStringTag,{value:`Module`}),n},_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=f(t),a=0,o=i.length,s;a<o;a++)s=i[a],!m.call(e,s)&&s!==n&&u(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=d(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:l(p(e)),_(t||!e||!e.__esModule||!m.call(e,`default`)?u(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);function ee(e){if(!e)return;let t=e.startsWith(w)?e.slice(14):e;return C.get(t)}function v(e,t){if(typeof e==`string`||T(e))return(0,i.pickLocalized)(e,t)||void 0}function te(e,t){if(!T(e))return;let n={},r=E(e.field);r&&(n.field=r);let i=E(e.format);i&&(n.format=i);let a=D(e.min);a!==void 0&&(n.min=a);let o=D(e.max);o!==void 0&&(n.max=o);let s=D(e.stepSize);s!==void 0&&s>0&&(n.stepSize=s),typeof e.showGridLines==`boolean`&&(n.showGridLines=e.showGridLines),typeof e.logarithmic==`boolean`&&(n.logarithmic=e.logarithmic);let c=E(e.position);(c===`left`||c===`right`||c===`top`||c===`bottom`)&&(n.position=c);let l=v(e.title,t);return l&&(n.title=l),n}function ne(e,t){if(!T(e)){let t=E(e);return t?{dataKey:t}:void 0}let n=E(e.dataKey)??E(e.name);if(!n)return;let r={dataKey:n},i=v(e.label,t);i&&(r.label=i);let a=E(e.chartType)??E(e.type);(a===`bar`||a===`line`||a===`area`)&&(r.chartType=a);let o=E(e.variant);(o===`comparison`||o===`current`||o===`primary`)&&(r.variant=o);let s=D(e.opacity);s!==void 0&&(r.opacity=s);let c=E(e.dashArray);c&&(r.dashArray=c);let l=E(e.stack);l&&(r.stack=l);let u=E(e.yAxis);(u===`left`||u===`right`)&&(r.yAxis=u);let d=E(e.color);return d&&(r.color=d),r}function re(e,t){let n=t===`horizontal-bar`,r=t===`scatter`?1:2,i=(e??[]).slice(0,r),a=[],o=e=>n?e===`bottom`?`left`:e===`top`?`right`:void 0:e===`left`||e===`right`?e:void 0,s=e=>e===`left`?`right`:`left`,c=i.map(e=>o(e.position)),l=[];if(i.length===1)l.push(c[0]??`left`);else if(i.length===2){let[e,t]=c;e&&t?l.push(e,e===t?s(e):t):e?l.push(e,s(e)):t?l.push(s(t),t):l.push(`left`,`right`)}i.forEach((e,t)=>{e.position&&(c[t]?c[t]!==l[t]&&a.push({index:t,position:e.position,reason:`taken`,drawn:l[t]}):a.push({index:t,position:e.position,reason:`side`,drawn:l[t]}))});let u=r===1?l[0]:`right`,d={slotOf:l,notes:a,undrawn:(e??[]).slice(i.length).map((e,t)=>({index:i.length+t,boundTo:u}))};return l.forEach((e,t)=>{d[e]=t}),d}function ie(e,t){if(!T(e))return{};let n={},r=E(e.type),i=E(e.chartType)??E(e.specType)??(r&&le.has(r)?r:void 0)??ee(r);i&&(n.chartType=i);let a=e.xAxis,o=te(a,t);o&&Object.keys(o).some(e=>e!==`field`)&&(n.xAxis=o);let s=E(e.xAxisKey)??o?.field??E(a);s&&(n.xAxisKey=s);let c=(Array.isArray(e.yAxis)?e.yAxis:e.yAxis===void 0?[]:[e.yAxis]).map(e=>te(e,t)??(E(e)?{field:E(e)}:void 0)).filter(e=>!!e);c.length&&(n.yAxes=c);let l=(Array.isArray(e.series)?e.series:Array.isArray(e.categories)?e.categories:void 0)?.map(e=>ne(e,t)).filter(e=>!!e);if(!l?.length){let e=re(c,i),t=[...e.slotOf,...e.undrawn.map(e=>e.boundTo)],n=c.map((e,n)=>({a:e,slot:t[n],i:n})).filter(({a:e})=>e.field).map(({a:e,slot:t,i:n})=>({dataKey:e.field,...e.title?{label:e.title}:{},...t===`right`||n>0?{yAxis:t}:{}}));n.length&&(l=n)}l?.length&&(n.series=l),typeof e.showLegend==`boolean`&&(n.showLegend=e.showLegend),typeof e.showDataLabels==`boolean`&&(n.showDataLabels=e.showDataLabels);let u=v(e.title,t);u&&(n.title=u);let d=v(e.subtitle,t);d&&(n.subtitle=d);let f=v(e.description,t);f&&(n.description=f);let p=D(e.height);return p!==void 0&&p>0&&(n.height=p),Array.isArray(e.annotations)&&e.annotations.length&&(n.annotations=e.annotations.filter(T)),T(e.interaction)&&(n.interaction=e.interaction),n}function ae(e){if(e===`bar`||e===`column`)return`bar`;if(e===`line`)return`line`;if(e===`area`)return`area`}function oe(e,t){if(e===`combo`)return`combo`;let n=ae(e);if(!n||!t||t.length<2)return e;let r=t.map(e=>e.chartType??n);return new Set(r).size>1?`combo`:e}function y(e,t){if(!e)return;let n=e.includes(`%`),r=/^([$£€¥₹])/.exec(e),i=e.includes(`,`),a=/\.(0+)/.exec(e)?.[1].length??0,o={$:`USD`,"£":`GBP`,"€":`EUR`,"¥":`CNY`,"₹":`INR`};if(!n&&!r&&!i&&a===0)return;let s={minimumFractionDigits:a,maximumFractionDigits:a,useGrouping:i};return n?s.style=`percent`:r&&(s.style=`currency`,s.currency=o[r[1]]??`USD`),e=>{let n=typeof e==`number`?e:Number(e);if(!Number.isFinite(n))return e==null?``:String(e);try{return new Intl.NumberFormat(t,s).format(n)}catch{return String(n)}}}function b(e,t){let n=e?.stepSize;if(!n||n<=0)return;let r=t.filter(e=>Number.isFinite(e)),i=r.length?Math.min(...r):void 0,a=r.length?Math.max(...r):void 0,o=e.min??Math.min(0,i??0),s=e.max??a;if(s===void 0||!Number.isFinite(o)||!Number.isFinite(s)||s<o)return;let c=Math.floor(o/n)*n,l=e.max===void 0?Math.ceil(s/n)*n:e.max,u=Math.floor((l-c)/n+1e-9)+1;if(u<1||u>O)return;let d=[];for(let e=0;e<u;e++)d.push(Number((c+e*n).toPrecision(12)));return e.max!==void 0&&d[d.length-1]<e.max&&d.push(e.max),d}function x(e){if(!e)return;let{min:t,max:n}=e;if(t!==void 0||n!==void 0)return[t??`auto`,n??`auto`]}var se,ce,S,le,C,w,T,E,D,O,k=h((()=>{se=new Set([`bar`,`column`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`radar`,`scatter`,`treemap`,`sankey`,`combo`]),ce=new Set([`gauge`,`solid-gauge`,`metric`,`kpi`,`bullet`]),S=new Set([`table`,`pivot`]),le=new Set([...se,...ce,...S]),C=new Map([[`chart:bar`,`bar`]]),w=`plugin-charts:`,T=e=>!!e&&typeof e==`object`&&!Array.isArray(e),E=e=>typeof e==`string`&&e?e:void 0,D=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,O=200})),A=g({default:()=>de});function ue(e,t=14){return e.length>t?`${e.slice(0,t-1)}…`:e}function j({x:e,y:t,payload:n}){let r=String(n?.value??``),i=ue(r);return(0,a.jsx)(`g`,{transform:`translate(${e},${t})`,children:(0,a.jsxs)(`text`,{dy:10,textAnchor:`end`,transform:`rotate(-32)`,fill:`hsl(var(--muted-foreground))`,fontSize:11,fontFamily:`monospace`,children:[r!==i&&(0,a.jsx)(`title`,{children:r}),i]})})}function de({data:e=[],dataKey:t=`value`,xAxisKey:n=`name`,height:r=400,className:i=``,color:s=`hsl(var(--primary))`}){let c=e.map(e=>String(e?.[n]??``)),l=c.length>4||c.some(e=>e.length>8);return(0,a.jsx)(`div`,{className:`p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${i}`,children:(0,a.jsx)(o.ResponsiveContainer,{width:`100%`,height:r,children:(0,a.jsxs)(o.BarChart,{data:e,margin:{top:10,right:10,left:10,bottom:l?24:5},children:[(0,a.jsxs)(`defs`,{children:[(0,a.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,a.jsx)(`stop`,{offset:`0%`,stopColor:s,stopOpacity:1}),(0,a.jsx)(`stop`,{offset:`90%`,stopColor:s,stopOpacity:.6}),(0,a.jsx)(`stop`,{offset:`100%`,stopColor:s,stopOpacity:.3})]}),(0,a.jsxs)(`filter`,{id:`glow`,height:`130%`,children:[(0,a.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`3`,result:`blur`}),(0,a.jsx)(`feOffset`,{in:`blur`,dx:`0`,dy:`0`,result:`offsetBlur`}),(0,a.jsx)(`feFlood`,{floodColor:s,floodOpacity:`0.5`,result:`offsetColor`}),(0,a.jsx)(`feComposite`,{in:`offsetColor`,in2:`offsetBlur`,operator:`in`,result:`offsetBlur`}),(0,a.jsxs)(`feMerge`,{children:[(0,a.jsx)(`feMergeNode`,{in:`offsetBlur`}),(0,a.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]})]}),(0,a.jsx)(o.CartesianGrid,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,a.jsx)(o.XAxis,{dataKey:n,tick:l?(0,a.jsx)(j,{}):{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:{stroke:`hsl(var(--border))`},interval:0,height:l?56:void 0,dy:l?void 0:10}),(0,a.jsx)(o.YAxis,{tick:{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:!1}),(0,a.jsx)(o.Tooltip,{cursor:{fill:`hsl(var(--muted))`,opacity:.2},contentStyle:{backgroundColor:`hsl(var(--popover))`,borderColor:`hsl(var(--border))`,color:`hsl(var(--popover-foreground))`,borderRadius:`8px`,fontFamily:`monospace`,boxShadow:`0 4px 6px -1px rgb(0 0 0 / 0.1)`},itemStyle:{color:`hsl(var(--primary))`}}),(0,a.jsx)(o.Legend,{wrapperStyle:{paddingTop:`20px`,fontFamily:`monospace`}}),(0,a.jsx)(o.Bar,{dataKey:t,fill:`url(#barGradient)`,radius:[4,4,0,0],filter:`url(#glow)`,animationDuration:1500})]})})})}var fe=h((()=>{}));function pe(){let e=n.useContext(me);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function M({id:e,className:t,children:r,config:i,disableSettleRemount:s,style:c,...l}){let u=n.useId(),d=`chart-${e||u.replace(/:/g,``)}`,f=n.useRef(null),[p,m]=n.useState(0);n.useEffect(()=>{if(s)return;let e=f.current;if(e==null||typeof ResizeObserver>`u`)return;let t=!1,n,r=new ResizeObserver(e=>{if(t)return;let i=e[0]?.contentRect;i==null||i.width<=0||i.height<=0||(n!=null&&clearTimeout(n),n=setTimeout(()=>{t=!0,r.disconnect(),m(e=>e+1)},80))});return r.observe(e),()=>{t=!0,n!=null&&clearTimeout(n),r.disconnect()}},[s]);let h=c?.height!=null||c?.minHeight!=null,g=c?.width!=null||c?.minWidth!=null,_={...h?{}:{minHeight:he},...g?{}:{minWidth:0},...c};return(0,a.jsx)(me.Provider,{value:{config:i},children:(0,a.jsxs)(`div`,{ref:f,"data-slot":`chart`,"data-chart":d,className:I(`block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground`,t),style:_,...l,children:[(0,a.jsx)(R,{id:d,config:i}),(0,a.jsx)(o.ResponsiveContainer,{width:`100%`,height:`100%`,...h?{}:{minHeight:he},children:r},p)]})})}function N({active:e,payload:t,className:r,indicator:o=`dot`,hideLabel:s=!1,hideIndicator:c=!1,label:l,labelFormatter:u,labelClassName:d,formatter:f,color:p,nameKey:m,labelKey:h}){let{config:g}=pe(),_=(0,i.useDisplayLocale)(),ee=n.useMemo(()=>{if(s||!t?.length)return null;let[e]=t,n=`${h||e?.dataKey||e?.name||`value`}`,r=F(g,e,n),i=!h&&typeof l==`string`?g[l]?.label||l:r?.label;return u?(0,a.jsx)(`div`,{className:I(`font-medium`,d),children:u(i,t)}):i?(0,a.jsx)(`div`,{className:I(`font-medium`,d),children:i}):null},[l,u,t,s,d,g,h]);if(!e||!t?.length)return null;let v=t.length===1&&o!==`dot`;return(0,a.jsxs)(`div`,{className:I(`border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl`,r),children:[v?null:ee,(0,a.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=`${m||e.name||e.dataKey||`value`}`,r=F(g,e,n),i=p||e.payload.fill||e.color;return(0,a.jsx)(`div`,{className:I(`[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5`,o===`dot`?`items-center`:``),children:f&&e?.value!==void 0&&e.name?f(e.value,e.name,e,t,e.payload):(0,a.jsxs)(a.Fragment,{children:[r?.icon?(0,a.jsx)(r.icon,{}):!c&&(0,a.jsx)(`div`,{className:I(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,o===`dot`?`h-2.5 w-2.5`:``,o===`line`?`w-1`:``,o===`dashed`?`w-0 border-[1.5px] border-dashed bg-transparent`:``,v&&o===`dashed`?`my-0.5`:``),style:{"--color-bg":i,"--color-border":i}}),(0,a.jsxs)(`div`,{className:I(`flex flex-1 justify-between leading-none`,v?`items-end`:`items-center`),children:[(0,a.jsxs)(`div`,{className:`grid gap-1.5`,children:[v?ee:null,(0,a.jsx)(`span`,{className:`text-muted-foreground`,children:r?.label||e.name})]}),e.value&&(0,a.jsx)(`span`,{className:`text-foreground font-mono font-medium tabular-nums`,children:e.value.toLocaleString(_)})]})]})},e.dataKey)})})]})}function P({className:e,hideIcon:t=!1,payload:n,verticalAlign:r=`bottom`,nameKey:i}){let{config:o}=pe();return n?.length?(0,a.jsx)(`div`,{className:I(`flex items-center justify-center gap-4`,r===`top`?`pb-3`:`pt-3`,e),children:n.filter(e=>e.type!==`none`).map(e=>{let n=`${i||e.dataKey||`value`}`,r=F(o,e,n);return(0,a.jsxs)(`div`,{className:I(`[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3`),children:[r?.icon&&!t?(0,a.jsx)(r.icon,{}):(0,a.jsx)(`div`,{className:`h-2 w-2 shrink-0 rounded-[2px] bg-(--color-bg)`,style:{"--color-bg":e.color}}),r?.label??e.value]},e.value)})}):null}function F(e,t,n){if(typeof t!=`object`||!t)return;let r=`payload`in t&&typeof t.payload==`object`&&t.payload!==null?t.payload:void 0,i=n;return r&&n in r&&typeof r[n]==`string`?i=r[n]:n in t&&typeof t[n]==`string`&&(i=t[n]),i in e?e[i]:e[n]}var I,L,me,he,R,z,B,ge=h((()=>{I=(...e)=>e.filter(Boolean).join(` `),L={light:``,dark:`.dark`},me=n.createContext(null),he=280,R=({id:e,config:t})=>{let n=Object.entries(t).filter(([,e])=>e.theme||e.color);return n.length?(0,a.jsx)(`style`,{dangerouslySetInnerHTML:{__html:Object.entries(L).map(([t,r])=>`
|
|
2
2
|
${r} [data-chart=${e}] {
|
|
3
3
|
${n.map(([e,n])=>{let r=n.theme?.[t]||n.color;return r?` --color-${e}: ${r};`:null}).join(`
|
|
4
4
|
`)}
|
|
5
5
|
}
|
|
6
6
|
`).join(`
|
|
7
|
-
`)}}):null},H=a.Tooltip,U=a.Legend}));function ce(e){return e?.[0]?.dataKey||`value`}function le(e,t,n){if(!e)return null;let r=e.payload??e,i=r?.[t];if(i==null)return null;let a=ce(n);return{category:String(i),series:a,value:typeof r?.[a]==`number`?r[a]:void 0}}function ue(e,t){if(!e)return null;let n=e.name??e.payload?.name??e.root?.name;if(n==null)return null;let r=e.value??e.size??e.payload?.size;return{category:String(n),series:ce(t),value:typeof r==`number`?r:void 0}}function de(e,t){if(!e)return null;let n=e.payload??e,r=n?.name;return r==null||n?.depth===0?null:{category:String(r),series:ce(t),value:typeof n?.value==`number`?n.value:void 0}}var fe=h((()=>{})),pe=g({default:()=>ve});function me(e){let{x:t,y:n,width:r,height:a,name:o,fill:s}=e;return r<=0||a<=0?null:(0,i.jsxs)(`g`,{children:[(0,i.jsx)(`rect`,{x:t,y:n,width:r,height:a,fill:s,stroke:`hsl(var(--background))`,strokeWidth:2}),r>48&&a>18?(0,i.jsx)(`text`,{x:t+6,y:n+18,fill:`#fff`,fontSize:12,className:`pointer-events-none`,children:o}):null]})}function he({title:e,subtitle:t,children:n}){return!e&&!t?(0,i.jsx)(i.Fragment,{children:n}):(0,i.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,i.jsxs)(`div`,{className:`mb-2 shrink-0`,children:[e?(0,i.jsx)(`div`,{className:`text-sm font-medium leading-tight text-foreground`,children:e}):null,t?(0,i.jsx)(`div`,{className:`text-xs leading-tight text-muted-foreground`,children:t}):null]}),(0,i.jsx)(`div`,{className:`min-h-0 flex-1`,children:n})]})}function ge({chartType:e=`bar`,data:r=[],config:o={},xAxisKey:s=`name`,series:c=[],className:l=``,colors:u,categoryColors:d,categoryOrder:f,onChartClick:p,isAnimationActive:m,xAxis:h,yAxes:g,showLegend:_,showDataLabels:v,title:ee,subtitle:te,description:y,height:C,annotations:w,interaction:T}){let E=e===`column`?`bar`:e,D=re(E,c),O=ne(E),k=Array.isArray(r)?r:[],A=m===!1?{isAnimationActive:!1}:{},j={...m===!1?{disableSettleRemount:!0}:{},...C?{style:{height:C}}:{},...y?{role:`img`,"aria-label":y}:{}},[M,se]=n.useState(!1),N=n.useCallback(e=>{if(!p||!e)return;let t=Array.isArray(e.activePayload)?e.activePayload[0]:void 0;p({category:e.activeLabel==null?void 0:String(e.activeLabel),series:t?.dataKey?String(t.dataKey):void 0,value:typeof t?.value==`number`?t.value:void 0})},[p]),L=n.useCallback(e=>{if(!p||!e)return;let t=e.payload?.[s],n=c[0]?.dataKey||`value`;p({category:t==null?void 0:String(t),series:n,value:typeof e.payload?.[n]==`number`?e.payload[n]:void 0})},[p,s,c]),R=p?{onClick:N,style:{cursor:`pointer`}}:{},z=p?{onClick:L,style:{cursor:`pointer`}}:{},B=n.useCallback((e,t,n)=>d&&d[e==null?``:String(e)]||n[t%n.length],[d]),V=n.useCallback(e=>{if(!p)return;let t=le(e,s,c);t&&p(t)},[p,s,c]),W=n.useCallback(e=>{if(!p)return;let t=ue(e,c);t&&p(t)},[p,c]),ce=n.useCallback(e=>{if(!p)return;let t=de(e,c);t&&p(t)},[p,c]),fe=p?{onClick:V,cursor:`pointer`}:{},pe=p?{onClick:W,style:{cursor:`pointer`}}:{},ge=p?{onClick:ce,style:{cursor:`pointer`}}:{};n.useEffect(()=>{let e=()=>se(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let _e={bar:a.BarChart,"horizontal-bar":a.BarChart,line:a.LineChart,area:a.AreaChart,pie:a.PieChart,donut:a.PieChart,radar:a.RadarChart,scatter:a.ScatterChart,funnel:a.FunnelChart,combo:a.ComposedChart,treemap:a.BarChart,sankey:a.BarChart}[D]||a.BarChart,ve=n.useCallback(e=>{if(e==null||e===``)return``;let t=o?.[String(e)]?.label;if(t!=null)return String(t);let n=typeof e==`string`?e:String(e);if(/^\d{4}-\d{2}-\d{2}/.test(n)){let e=new Date(n);if(!Number.isNaN(e.getTime())){let t=(k.length>1?Math.abs(new Date(String(k[k.length-1][s]??``)).getTime()-new Date(String(k[0][s]??``)).getTime()):0)/864e5;try{return t<=62?e.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):e.toLocaleDateString(void 0,{month:`short`,year:`numeric`})}catch{return e.toISOString().slice(0,10)}}}return M&&n.length>8?n.slice(0,8)+`…`:n},[k,s,M,o]),be=n.useMemo(()=>k.some(e=>String(e[s]||``).length>5),[k,s]),q=()=>Array.isArray(u)&&u.length>0?u:[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],xe=n.useCallback(e=>{if(e==null||e===``)return``;let t=typeof e==`number`?e:Number(e);if(!Number.isFinite(t))return String(e);try{return new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(t)}catch{return String(t)}},[]),J=g?.[0],Y=g&&g.length>1?g[1]:J?.position===`right`?J:void 0,X=!!g&&g.length>1,Z=n.useMemo(()=>b(h?.format)??ve,[h?.format,ve]),Q=n.useMemo(()=>b(J?.format)??xe,[J?.format,xe]),Se=n.useMemo(()=>b(Y?.format)??xe,[Y?.format,xe]),Ce=n.useCallback(e=>{let t=c.filter(t=>X?(t.yAxis===`right`?`right`:`left`)===e:e===`left`).map(e=>e.dataKey),n=[];for(let e of k)for(let r of t){let t=Number(e?.[r]);Number.isFinite(t)&&n.push(t)}return n},[k,c,X]),we=n.useCallback((e,t=`left`)=>{if(!e)return{};let n=ae(e),r=ie(e,Ce(t));return{...r?{ticks:r}:{},...n?{domain:n}:{},...n?{allowDataOverflow:!0}:{},...e.logarithmic?{scale:`log`,domain:n??[1,`auto`]}:{},...e.title?{label:{value:e.title,angle:-90,position:`insideLeft`}}:{}}},[Ce]),Te=J?.showGridLines!==!1,Ee={vertical:h?.showGridLines===!0,horizontal:Te},De=_!==!1,Oe=n.useMemo(()=>{if(!Array.isArray(w)||w.length===0)return null;let e={solid:void 0,dashed:`4 4`,dotted:`1 4`};return w.map((t,n)=>{let r=t?.axis===`x`,o=G(String(t?.color||`hsl(var(--muted-foreground))`)),s=e[String(t?.style??`dashed`)],c=typeof t?.label==`string`?t.label:void 0,l=c?{label:{value:c,position:`insideTopRight`,fill:o,fontSize:11}}:{};if(t?.type===`region`){let e=r?{x1:t.value,x2:t.endValue}:{y1:t.value,y2:t.endValue};return(0,i.jsx)(a.ReferenceArea,{...e,...X&&!r?{yAxisId:`left`}:{},fill:o,fillOpacity:.12,stroke:o,strokeOpacity:.35,...l},`ann-${n}`)}return(0,i.jsx)(a.ReferenceLine,{...r?{x:t?.value}:{y:t?.value},...X&&!r?{yAxisId:`left`}:{},stroke:o,strokeDasharray:s,...l},`ann-${n}`)})},[w,X]),ke=T?.tooltips!==!1,Ae=T?.brush===!0?(0,i.jsx)(a.Brush,{dataKey:s,height:24,travellerWidth:8,stroke:`hsl(var(--muted-foreground))`}):null,je=e=>v?(0,i.jsx)(a.LabelList,{position:`top`,className:`fill-foreground`,fontSize:11,...e?{formatter:e}:{}}):null,Me=n.useMemo(()=>({tickLine:!1,tickMargin:10,axisLine:!1,interval:`preserveStartEnd`,minTickGap:M?32:48,tickFormatter:Z,...h?.title?{label:{value:h.title,position:`insideBottom`,offset:-4}}:{},...!M&&be&&{angle:-35,textAnchor:`end`,height:60}}),[M,be,Z,h?.title]);if(D&&S.has(D)){let e=c[0]?.dataKey||`value`,t=k[0]?.[e],n=typeof t==`number`?t:Number(t),r=c[0]?.label??o?.[e]?.label??e;return(0,i.jsx)(`div`,{className:l,"data-testid":`advanced-chart-single-value`,children:(0,i.jsxs)(`div`,{className:`flex flex-col gap-1 py-4`,children:[(0,i.jsx)(`span`,{className:`text-3xl font-semibold tabular-nums`,children:Number.isFinite(n)?new Intl.NumberFormat().format(n):String(t??`—`)}),(0,i.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:String(r)})]})})}if(D&&oe.has(D))return(0,i.jsxs)(`div`,{className:`rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${l??``}`,"data-testid":`advanced-chart-tabular-notice`,role:`note`,children:[`Chart type “`,D,`” is tabular — render it with the data-table / pivot components; a chart block draws series charts.`]});if(D&&!x.has(D))return(0,i.jsxs)(`div`,{className:`rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${l??``}`,"data-testid":`advanced-chart-unknown-type`,role:`note`,children:[`Chart type “`,D,`” is not a spec chart type — nothing was drawn.`]});if(D===`pie`||D===`donut`){let e=D===`donut`?`52%`:0,t=q(),n={...o};return k.forEach((e,r)=>{let i=e?.[s];if(i==null||i===``)return;let a=String(i);n[a]||(n[a]={label:a,color:B(i,r,t)})}),(0,i.jsx)(P,{config:n,className:l,...j,children:(0,i.jsxs)(a.PieChart,{children:[(0,i.jsx)(H,{cursor:!1,content:(0,i.jsx)(F,{hideLabel:!0})}),(0,i.jsx)(a.Pie,{data:k,dataKey:c[0]?.dataKey||`value`,nameKey:s||`name`,innerRadius:e,strokeWidth:5,paddingAngle:2,outerRadius:`85%`,...A,...z,children:k.map((e,n)=>{let r=B(e?.[s],n,t);return(0,i.jsx)(a.Cell,{fill:G(r)},`cell-${n}`)})}),De?(0,i.jsx)(U,{verticalAlign:`bottom`,wrapperStyle:{fontSize:M?`11px`:`12px`,paddingTop:`8px`},content:(0,i.jsx)(I,{nameKey:s,className:`flex-wrap`})}):null]})})}if(D===`funnel`){let e=c[0]?.dataKey||`value`,n=q(),r=p?t=>{t&&p({category:t?.payload?.[s]??t?.[s],value:t?.payload?.[e]??t?.[e]})}:void 0,u=r?{onClick:r,style:{cursor:`pointer`}}:{},d=(0,t.buildCategoryRank)(f),m=d?[...k].sort((e,t)=>(d.get(String(e?.[s]??``))??2**53-1)-(d.get(String(t?.[s]??``))??2**53-1)):[...k].sort((t,n)=>{let r=Number(t?.[e]??0);return Number(n?.[e]??0)-r});return(0,i.jsx)(P,{config:o,className:l,...j,children:(0,i.jsxs)(a.FunnelChart,{children:[(0,i.jsx)(H,{content:(0,i.jsx)(F,{})}),(0,i.jsxs)(a.Funnel,{dataKey:e,data:m,nameKey:s,...A,...u,children:[(0,i.jsx)(a.LabelList,{position:`right`,fill:`hsl(var(--foreground))`,stroke:`none`,dataKey:s}),m.map((e,t)=>(0,i.jsx)(a.Cell,{fill:G(n[t%n.length])},`funnel-cell-${t}`))]})]})})}if(D===`treemap`){let e=c[0]?.dataKey||`value`,t=q(),n=k.map((n,r)=>({name:String(n?.[s]??``),size:Number(n?.[e])||0,fill:G(t[r%t.length])}));return(0,i.jsx)(P,{config:o,className:l,...j,children:(0,i.jsx)(a.Treemap,{data:n,dataKey:`size`,nameKey:`name`,...A,content:(0,i.jsx)(me,{}),...pe,children:(0,i.jsx)(a.Tooltip,{})})})}if(D===`sankey`){let e=c[0]?.dataKey||`value`,t=c[0]?.label||e,n=k.filter(t=>(Number(t?.[e])||0)>0),r=[{name:t},...n.map(e=>({name:String(e?.[s]??``)}))],u=n.map((t,n)=>({source:0,target:n+1,value:Number(t?.[e])||0}));return u.length===0?(0,i.jsx)(`div`,{className:l}):(0,i.jsx)(P,{config:o,className:l,...j,children:(0,i.jsx)(a.Sankey,{data:{nodes:r,links:u},nodePadding:24,link:{stroke:`hsl(var(--muted-foreground))`,strokeOpacity:.25},node:{fill:`hsl(var(--chart-1))`},...ge,children:(0,i.jsx)(a.Tooltip,{})})})}if(D===`radar`)return(0,i.jsx)(P,{config:o,className:l,...j,children:(0,i.jsxs)(a.RadarChart,{data:k,children:[(0,i.jsx)(a.PolarGrid,{}),(0,i.jsx)(a.PolarAngleAxis,{dataKey:s}),(0,i.jsx)(a.PolarRadiusAxis,{}),(0,i.jsx)(H,{content:(0,i.jsx)(F,{})}),(0,i.jsx)(U,{content:(0,i.jsx)(I,{}),...M&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),c.map(e=>{let t=G(o[e.dataKey]?.color||ye);return(0,i.jsx)(a.Radar,{dataKey:e.dataKey,stroke:t,fill:t,fillOpacity:.6,...A},e.dataKey)})]})});if(D===`scatter`)return(0,i.jsx)(P,{config:o,className:l,...j,children:(0,i.jsxs)(a.ScatterChart,{children:[(0,i.jsx)(a.CartesianGrid,{vertical:!1}),(0,i.jsx)(a.XAxis,{type:`number`,dataKey:s,name:String(o[s]?.label||s),tickLine:!1,axisLine:!1,minTickGap:M?32:48}),(0,i.jsx)(a.YAxis,{type:`number`,dataKey:c[0]?.dataKey||`value`,name:String(o[c[0]?.dataKey]?.label||c[0]?.dataKey),tickLine:!1,axisLine:!1,tickFormatter:xe,width:48}),(0,i.jsx)(a.ZAxis,{type:`number`,range:[60,400]}),(0,i.jsx)(H,{content:(0,i.jsx)(F,{})}),(0,i.jsx)(U,{content:(0,i.jsx)(I,{}),...M&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),c.map((e,t)=>{let n=q(),r=G(o[e.dataKey]?.color||n[t%n.length]),s=K(e,`scatter`);return(0,i.jsx)(a.Scatter,{name:o[e.dataKey]?.label||e.dataKey,data:k,fill:r,fillOpacity:s?.fillOpacity,...A,...fe},e.dataKey)})]})});if(D===`combo`)return(0,i.jsx)(he,{title:ee,subtitle:te,children:(0,i.jsx)(P,{config:o,className:l,...j,children:(0,i.jsxs)(a.ComposedChart,{data:k,children:[(0,i.jsx)(a.CartesianGrid,{...Ee}),(0,i.jsx)(a.XAxis,{dataKey:s,...Me}),(0,i.jsx)(a.YAxis,{yAxisId:`left`,tickLine:!1,axisLine:!1,tickFormatter:Q,width:48,...we(J)}),(0,i.jsx)(a.YAxis,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:Se,width:48,...we(Y,`right`)}),ke?(0,i.jsx)(H,{content:(0,i.jsx)(F,{})}):null,De?(0,i.jsx)(U,{content:(0,i.jsx)(I,{}),...M&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Oe,Ae,c.map((e,t)=>{let n=G(o[e.dataKey]?.color||ye),r=e.chartType||O||(t===0?`bar`:`line`),s=e.yAxis===`right`||e.yAxis===`left`?e.yAxis:O||r===`bar`?`left`:`right`,c=K(e,r),l=e.stack?{stackId:String(e.stack)}:{},u=b((s===`right`?Y:J)?.format);return r===`line`?(0,i.jsx)(a.Line,{yAxisId:s,type:`monotone`,dataKey:e.dataKey,stroke:n,strokeWidth:2,dot:!1,strokeOpacity:c?.strokeOpacity,strokeDasharray:c?.strokeDasharray,...A,children:je(u)},e.dataKey):r===`area`?(0,i.jsx)(a.Area,{yAxisId:s,type:`monotone`,dataKey:e.dataKey,fill:n,stroke:n,fillOpacity:c?.fillOpacity??.4,strokeOpacity:c?.strokeOpacity,strokeDasharray:c?.strokeDasharray,...l,...A,children:je(u)},e.dataKey):(0,i.jsx)(a.Bar,{yAxisId:s,dataKey:e.dataKey,fill:n,radius:4,fillOpacity:c?.fillOpacity,...l,...A,children:je(u)},e.dataKey)})]})})});let Ne=D===`horizontal-bar`,Pe=q(),Fe=d?Object.values(d).map(e=>G(String(e))):[],Ie=Array.from(new Set([...Pe,...Fe,...c.map((e,t)=>G(o[e.dataKey]?.color||Pe[t%Pe.length]||ye))])),$=e=>`g`+e.replace(/[^a-zA-Z0-9]/g,``);return(0,i.jsx)(he,{title:ee,subtitle:te,children:(0,i.jsx)(P,{config:o,className:l,...j,children:(0,i.jsxs)(_e,{data:k,layout:Ne?`vertical`:`horizontal`,...R,children:[(0,i.jsx)(`defs`,{children:Ie.map(e=>(0,i.jsxs)(n.Fragment,{children:[(0,i.jsxs)(`linearGradient`,{id:`bg-${$(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,i.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.95}),(0,i.jsx)(`stop`,{offset:`100%`,style:{stopColor:e},stopOpacity:.5})]}),(0,i.jsxs)(`linearGradient`,{id:`ag-${$(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,i.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.5}),(0,i.jsx)(`stop`,{offset:`95%`,style:{stopColor:e},stopOpacity:.05})]})]},$(e)))}),(0,i.jsx)(a.CartesianGrid,{...Ee}),Ne?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.XAxis,{type:`number`,tickLine:!1,axisLine:!1,tickFormatter:Q,...we(J)}),(0,i.jsx)(a.YAxis,{type:`category`,dataKey:s,tickLine:!1,axisLine:!1,width:Math.min(140,Math.max(60,Math.max(...k.map(e=>String(e[s]??``).length))*7)),tickFormatter:Z})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.XAxis,{dataKey:s,...Me}),(0,i.jsx)(a.YAxis,{...X?{yAxisId:`left`}:{},tickLine:!1,axisLine:!1,tickFormatter:Q,width:48,...we(J)}),X?(0,i.jsx)(a.YAxis,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:Se,width:48,...we(Y,`right`)}):null]}),ke?(0,i.jsx)(H,{content:(0,i.jsx)(F,{})}):null,De?(0,i.jsx)(U,{content:(0,i.jsx)(I,{}),...M&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Oe,Ae,c.map((e,t)=>{let n=q(),r=e.variant===`comparison`,l=r?c.slice(0,t).find(e=>e.variant!==`comparison`)||c[0]:e,u=r?c.indexOf(l):t,d=G(o[l.dataKey]?.color||n[u%n.length]||ye),f=X?{yAxisId:e.yAxis===`right`?`right`:`left`}:{},p=e.stack?{stackId:String(e.stack)}:{},m=b((e.yAxis===`right`?Y:J)?.format);if(D===`bar`||D===`horizontal-bar`){let t=c.filter(e=>e.variant!==`comparison`).length===1&&!r&&c.length===1&&k.length>1,o=K(e,`bar`);return(0,i.jsxs)(a.Bar,{dataKey:e.dataKey,fill:`url(#bg-${$(d)})`,radius:4,fillOpacity:o?.fillOpacity,...p,...f,...A,children:[t&&k.map((e,t)=>(0,i.jsx)(a.Cell,{fill:`url(#bg-${$(G(B(e?.[s],t,n)))})`},`cell-${t}`)),je(m)]},e.dataKey)}if(D===`line`){let t=K(e,`line`);return(0,i.jsx)(a.Line,{type:`monotone`,dataKey:e.dataKey,stroke:d,strokeWidth:2,dot:!1,strokeOpacity:t?.strokeOpacity,strokeDasharray:t?.strokeDasharray,...f,...A,children:je(m)},e.dataKey)}if(D===`area`){let t=K(e,`area`);return(0,i.jsx)(a.Area,{type:`monotone`,dataKey:e.dataKey,fill:`url(#ag-${$(d)})`,stroke:d,strokeWidth:2,fillOpacity:t?.fillOpacity??1,strokeOpacity:t?.strokeOpacity,strokeDasharray:t?.strokeDasharray,...p,...f,...A,children:je(m)},e.dataKey)}return null})]})})})}function _e(e){let t=e.chartType===`column`?`bar`:e.chartType??`bar`,n=Array.isArray(e.data)?e.data:[],r=e.xAxisKey??`name`;return q.has(t)&&n.length>0&&!n.some(e=>typeof e==`object`&&!!e&&r in e)}function ve(e){let t=_e(e),r=e.xAxisKey??`name`,a=n.useMemo(()=>Object.keys((Array.isArray(e.data)?e.data[0]:void 0)??{}),[e.data]);return n.useEffect(()=>{t&&console.warn(`[chart] no row has the category key "${r}" — rendering an explanatory placeholder instead of an empty axis. Row keys: ${JSON.stringify(a)}. A dataset query must PROJECT the dimension it groups by (framework#4033).`)},[t,r,a]),t?(0,i.jsx)(`div`,{className:`flex h-full min-h-[120px] w-full items-center justify-center p-4 text-center text-sm text-muted-foreground ${e.className??``}`,role:`status`,"data-chart-error":`missing-category-key`,children:(0,i.jsxs)(`span`,{children:[`This chart cannot plot its category axis: no row has a`,` `,(0,i.jsx)(`code`,{className:`font-mono`,children:r}),` field.`]})}):(0,i.jsx)(ge,{...e})}var ye,be,G,K,q,xe=h((()=>{W(),fe(),O(),ye=`hsl(var(--primary))`,be={slate:`#64748b`,gray:`#6b7280`,zinc:`#71717a`,neutral:`#737373`,stone:`#78716c`,red:`#ef4444`,orange:`#f97316`,amber:`#f59e0b`,yellow:`#eab308`,lime:`#84cc16`,green:`#22c55e`,emerald:`#10b981`,teal:`#14b8a6`,cyan:`#06b6d4`,sky:`#0ea5e9`,blue:`#3b82f6`,indigo:`#6366f1`,violet:`#8b5cf6`,purple:`#a855f7`,fuchsia:`#d946ef`,pink:`#ec4899`,rose:`#f43f5e`},G=e=>be[e]||e,K=(e,t)=>e?.variant===`comparison`?{strokeOpacity:typeof e.opacity==`number`?e.opacity:t===`line`||t===`scatter`?.5:.6,fillOpacity:typeof e.opacity==`number`?e.opacity:t===`bar`?.4:t===`area`?.2:.5,strokeDasharray:e.dashArray??(t===`line`||t===`area`?`4 4`:void 0)}:null,q=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`radar`,`funnel`,`combo`])}));O();var J=n.default.lazy(()=>Promise.resolve().then(()=>(se(),k))),Y=n.default.lazy(()=>Promise.resolve().then(()=>(xe(),pe))),X=({schema:e})=>(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,i.jsx)(J,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),Z=({schema:e,onChartClick:t})=>{let a=n.default.useMemo(()=>{let t=y(e),n=Array.isArray(e.series)?e.series:void 0,r=(n?.length&&n.every(e=>!!e&&typeof e==`object`&&`dataKey`in e)?n:t.series)??n,i=e.xAxisKey??t.xAxisKey,a=e.config;if(i||(e.index?i=e.index:e.category&&(i=e.category)),r||(e.categories?r=e.categories.map(e=>({dataKey:e})):e.value&&(r=[{dataKey:e.value}])),!a&&r){let t=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],n={};r.forEach((e,r)=>{n[e.dataKey]={label:e.label||e.dataKey,color:e.color||t[r%t.length]}}),a=n}return{chartType:e.chartType??t.chartType,data:Array.isArray(e.data)?e.data:[],config:a,xAxisKey:i,series:r,className:e.className,spec:t}},[e]);return(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,i.jsx)(Y,{chartType:a.chartType,data:a.data,config:a.config,xAxisKey:a.xAxisKey,series:a.series,className:a.className,colors:Array.isArray(e.colors)?e.colors:void 0,categoryColors:e.categoryColors,categoryOrder:e.categoryOrder,isAnimationActive:e.isAnimationActive,onChartClick:t,xAxis:a.spec.xAxis,yAxes:a.spec.yAxes,showLegend:a.spec.showLegend,showDataLabels:a.spec.showDataLabels,title:a.spec.title,subtitle:a.spec.subtitle,description:a.spec.description,height:a.spec.height??e.height,annotations:a.spec.annotations,interaction:a.spec.interaction})})};function Q(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Se(e){return e.field||e.function||`count`}var Ce=`__comparison`;function we(e,t){let{field:n,function:r,groupBy:i}=t,a=Se(t),o={};for(let t of e){let e=String(t[i]??`Unknown`);o[e]||(o[e]=[]),o[e].push(t)}return Object.entries(o).map(([e,t])=>{let o=n?t.map(e=>Number(e[n])||0):[],s;switch(r){case`count`:s=t.length;break;case`avg`:s=o.length>0?o.reduce((e,t)=>e+t,0)/o.length:0;break;case`min`:s=o.length>0?Math.min(...o):0;break;case`max`:s=o.length>0?Math.max(...o):0;break;default:s=o.reduce((e,t)=>e+t,0)}return{[i]:e,[a]:s}})}async function Te(e,n,r,i,a){if(!e.length||!n)return e;let o=a||((e,t)=>t),s=`__raw_${n}`,c=r?.fields?.[n];if(!c){let t=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[n],i=String(r??``),a=t.test(i)?i:Q(i);return{...e,[n]:o(i,a),[s]:r}})}let l=c.type;if(l===`select`||l===`picklist`||l===`dropdown`){let t=c.options||[];if(t.length===0)return e.map(e=>{let t=e[n],r=String(t??``),i=Q(r);return{...e,[n]:o(r,i),[s]:t}});let r={};for(let e of t)typeof e==`string`?r[e]=e:e&&typeof e==`object`&&(r[String(e.value)]=e.label||String(e.value));return e.map(e=>{let t=e[n],i=String(t??``),a=r[i]||Q(i);return{...e,[n]:o(i,a),[s]:t}})}if(l===`lookup`||l===`master_detail`){let r=c.reference_to||c.reference;if(!r||!i||typeof i.find!=`function`)return e.map(e=>({...e,[s]:e[n]}));let a=[...new Set(e.map(e=>e[n]).filter(e=>e!=null))];if(a.length===0)return e.map(e=>({...e,[s]:e[n]}));let o=c.id_field||`id`;try{let l=await i.find(r,{$filter:{[o]:{$in:a}},$top:a.length}),u=(0,t.extractRecords)(l),d=c.reference_field||c.display_field||`name`,f={};for(let e of u){let t=String(e[o]??e.id??e._id??``),n=e[d]||e.name||e.label||e.title||t;t&&(f[t]=String(n))}return e.map(e=>{let t=e[n],r=String(t??``);return{...e,[n]:f[r]||r,[s]:t}})}catch(t){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,t),e.map(e=>({...e,[s]:e[n]}))}}if(l===`date`||l===`datetime`||l===`date_time`||l===`timestamp`||l===`time`)return e.map(e=>({...e,[s]:e[n]}));let u=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let t=e[n],r=String(t??``);return{...e,[n]:u.test(r)?r:Q(r),[s]:t}})}var Ee=e=>{let{schema:a}=e,l=e.onSegmentClick,u=(0,n.useContext)(o.SchemaRendererContext),d=e.dataSource||u?.dataSource,f=u?.apiFetch,p=(0,o.useDataScope)(a.bind),{fieldOptionLabel:m}=(0,c.useSafeFieldLabel)(),h=(0,n.useRef)(m);(0,n.useEffect)(()=>{h.current=m},[m]);let[g,_]=(0,n.useState)([]),[v,ee]=(0,n.useState)(null),[te,y]=(0,n.useState)(()=>!(Array.isArray(a.data)&&a.data.length>0)&&(!!a.objectName||!!a.dataset)),[ne,re]=(0,n.useState)(null),[b,ie]=(0,n.useState)(null),[ae,x]=(0,n.useState)(null),{openRecordList:S}=(0,o.useDrillNavigation)(),oe=(0,c.useSafeTranslate)(),C=(0,n.useMemo)(()=>a.aggregate?JSON.stringify(a.aggregate):``,[a.aggregate]),w=(0,n.useMemo)(()=>a.filter?JSON.stringify(a.filter):``,[a.filter]),T=(0,n.useMemo)(()=>a.compareTo?JSON.stringify(a.compareTo):``,[a.compareTo]),E=(0,n.useMemo)(()=>a.dataset?JSON.stringify({d:a.dataset,dim:a.dimensions??[],val:a.values??[]}):``,[a.dataset,a.dimensions,a.values]),D=e=>e!==`pie`&&e!==`donut`&&e!==`funnel`;(0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let n=f??fetch,r={headers:{accept:`application/json`},credentials:`include`},i=a.objectName,o,s=null,c=a.aggregate?.groupBy;if(i)o=c&&typeof c==`object`&&!Array.isArray(c)?c.field:typeof c==`string`?c:a.xAxisKey;else if(a.dataset){let e=Array.isArray(a.dimensions)&&a.dimensions.length?a.dimensions[0]:void 0,t=await(await n(`/api/v1/meta/dataset/${encodeURIComponent(a.dataset)}`,r)).json().catch(()=>null);s=t?.item??t?.data??t,i=s?.object,o=((s?.dimensions||[]).find(t=>t?.name===e)??(s?.dimensions||[])[0])?.field??e}if(!i||!o){e||x(null);return}let l=async e=>{let t=await(await n(`/api/v1/meta/object/${encodeURIComponent(e)}`,r)).json().catch(()=>null);return t?.item??t?.data??t},u={};if(a.dataset&&Array.isArray(a.dimensions))for(let e of a.dimensions)u[e]=(s?.dimensions||[]).find(t=>t?.name===e)?.field??e;let d=await(0,t.loadDimensionFieldMeta)(l,i,[o,...Object.values(u)]);e||x({metaByPath:d,colorPath:o,fieldByDim:a.dataset&&Array.isArray(a.dimensions)?u:null})}catch{e||x(null)}})(),()=>{e=!0}},[a.objectName,a.dataset,E,C,a.xAxisKey,f]);let{fieldOptionColors:O,dimensionLabels:k}=(0,n.useMemo)(()=>{if(!ae)return{fieldOptionColors:null,dimensionLabels:null};let{metaByPath:e,colorPath:n,fieldByDim:r}=ae,i=(0,t.localizeFieldOptions)(e[n]?.options,(0,t.dimensionOptionTranslator)(e[n],m)),a=(0,t.deriveDimensionLabelMaps)(e,r?Object.entries(r).map(([e,t])=>({dim:e,path:t})):null,m);return{fieldOptionColors:(0,t.buildOptionColorMap)(i),dimensionLabels:a}},[ae,m]),A=(0,n.useCallback)(async(e,n)=>{if(a.aggregate&&typeof e.aggregate==`function`){let t=a.aggregate.groupBy;if(t&&typeof t==`object`&&!Array.isArray(t)){let r=a.aggregate.field,i=a.aggregate.function,o={function:i,alias:Se(a.aggregate)};i!==`count`&&r&&(o.field=r);let s=await e.aggregate(a.objectName,{groupBy:[t],aggregations:[o],where:n});return Array.isArray(s)?s:[]}let r=await e.aggregate(a.objectName,{field:a.aggregate.field,function:a.aggregate.function,groupBy:t,filter:n});return Array.isArray(r)?r:[]}if(typeof e.find==`function`){let r=await e.find(a.objectName,{$filter:n}),i=(0,t.extractRecords)(r);return a.aggregate&&i.length>0&&(i=we(i,a.aggregate)),i}return[]},[a.objectName,C]),j=(0,o.useFilterScope)(),M=(0,n.useCallback)(async(e,n)=>{if(!e||!a.objectName&&!a.dataset){n.current&&y(!1);return}n.current&&(y(!0),re(null));try{if(a.dataset&&typeof e.queryDataset==`function`){let r=(0,t.resolveFilterPlaceholders)(a.filter,j),i=await e.queryDataset(a.dataset,{dimensions:Array.isArray(a.dimensions)?a.dimensions:[],measures:Array.isArray(a.values)?a.values:[],...r?{runtimeFilter:r}:{}});n.current&&(_(Array.isArray(i?.rows)?i.rows:[]),ee(Array.isArray(i?.fields)?i.fields:null));return}let r=(0,t.resolveFilterPlaceholders)(a.filter,j),i=a.compareTo,o=!!i&&D(a.chartType),s=o?(0,t.resolveContextTokens)((0,t.shiftFilterByCompareTo)(a.filter,i),j):null,[c,l]=await Promise.all([A(e,r),s?A(e,s):Promise.resolve([])]),u=c,d=a.aggregate?.groupBy,f=d&&typeof d==`object`&&!Array.isArray(d)?d.alias||d.field:d||a.xAxisKey;if(o&&l.length>0&&a.aggregate){let e=a.aggregate.field,t=a.aggregate.function,n=Se(a.aggregate),r=r=>{if(r==null)return null;if(e){let n=`${e}_${t}`;if(n in r)return Number(r[n]);if(t===`count`&&`${e}_count`in r)return Number(r[`${e}_count`])}return n in r?Number(r[n]):`value`in r?Number(r.value):`count`in r?Number(r.count):null},i=`${n}${Ce}`,o=f;if(o&&u.some(e=>e[o]!=null)&&l.some(e=>e[o]!=null)){let e=new Map;for(let t of l){let n=String(t[o]??``);e.set(n,r(t))}u=u.map(t=>{let n=String(t[o]??``),r=e.get(n);return r==null?t:{...t,[i]:r}});let t=new Set(u.map(e=>String(e[o]??``)));for(let e of l){let n=String(e[o]??``);t.has(n)||u.push({[o]:n,[i]:r(e)})}}else{let e=Math.max(u.length,l.length),t=[];for(let n=0;n<e;n++){let e=u[n]||{},a=l[n];t.push(a?{...e,[i]:r(a)}:e)}u=t}}if(f&&typeof e.getObjectSchema==`function`)try{let t=await e.getObjectSchema(a.objectName);u=await Te(u,f,t,e,(e,t)=>h.current(a.objectName,f,e,t))}catch{}n.current&&_(u)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&re(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&y(!1)}},[a.objectName,E,C,w,T,a.xAxisKey,a.chartType,A,j]);(0,n.useEffect)(()=>{let e={current:!0};return(a.objectName||a.dataset)&&!p&&!a.data?M(d,e):e.current&&y(!1),()=>{e.current=!1}},[a.objectName,E,d,p,a.data,w,C,T,M]);let se=p||a.data||g,N=Array.isArray(se)?se:[],P=a.drillDown,F=a.aggregate?.groupBy||a.xAxisKey,I=(0,n.useMemo)(()=>{if(!F)return new Map;let e=new Map,t=`__raw_${F}`;for(let n of N){let r=n?.[F];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[N,F]),L=(0,n.useMemo)(()=>{if(b)return{...a.filter||{},...(0,t.computeDrillFilter)(P,b,{groupByField:F})}},[b,P,F,w]),R=!l&&!!b&&!!a.objectName&&P?.target===`navigate`&&!!S;(0,n.useEffect)(()=>{R&&(S(a.objectName,L),ie(null))},[R]);let z=a.compareTo,B=a.aggregate?Se(a.aggregate):void 0,V=B?`${B}${Ce}`:void 0,H=!!z&&D(a.chartType)&&!!V&&N.some(e=>e[V]!=null),U=(0,n.useMemo)(()=>{let e=Array.isArray(a.series)?a.series:null;if(!H)return e;let n=e||[{dataKey:B}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[(0,t.compareToTrendLabelKey)(z,a.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:V,label:r,variant:`comparison`}]},[H,a.series,B,V,a.filter,z]),W=a.dataset?(0,t.buildChartSeries)((0,t.relabelDimensions)(N,k),a.dimensions,a.values,v,{nullCategoryLabel:oe(`chart.nullCategory`,`(None)`)}):null,ce=W?{...a,data:W.data,xAxisKey:W.xAxisKey,series:W.series}:{...a,data:N,...U?{series:U}:{}},le=a.colors&&!Array.isArray(a.colors)&&typeof a.colors==`object`?a.colors:null,ue=Array.isArray(a.colors)?a.colors:void 0,de=O||le?{...O||{},...le||{}}:void 0,fe={...ce,colors:ue,...de?{categoryColors:de}:{}};if(te&&N.length===0)return(0,i.jsxs)(`div`,{className:`p-2 `+(a.className||``),"data-testid":`chart-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,i.jsx)(`span`,{className:`sr-only`,children:`Loading chart data…`}),(0,i.jsx)(r.ChartSkeleton,{className:`h-full`})]});if(ne)return(0,i.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(a.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,i.jsx)(s.AlertCircle,{className:`h-6 w-6 text-destructive opacity-60`}),(0,i.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,i.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:ne})]});if(!d&&a.objectName&&N.length===0)return(0,i.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(a.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,a.objectName,`”`]});let pe=(0,t.isDrillEnabled)(P)?e=>{let t=e.category,n=t!=null&&I.has(String(t))?I.get(String(t)):t;ie({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,me=l??pe,he=!l&&b&&a.objectName&&!R?(()=>{let e=L??{},n=(0,t.resolveDrillTitle)(P,b,a.title||`Details`),c=P?.target??`drawer`,l={type:`object-data-table`,objectName:a.objectName,filter:e,pagination:!0,pageSize:P?.maxRows,columns:P?.columns?.map(e=>({accessorKey:e,header:e})),drillDown:{enabled:!0,mode:`record`,target:`dialog`}},u=(0,i.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,i.jsx)(o.SchemaRenderer,{schema:l,dataSource:d})}),f=S&&a.objectName?(0,i.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{S(a.objectName,e),ie(null)},children:[oe(`dashboard.openInList`,`Open in list`),(0,i.jsx)(s.ArrowUpRight,{className:`ml-1 h-3.5 w-3.5`})]}):null;return c===`dialog`?(0,i.jsx)(r.Dialog,{open:!0,onOpenChange:e=>!e&&ie(null),children:(0,i.jsxs)(r.DialogContent,{className:`max-w-4xl`,children:[(0,i.jsxs)(r.DialogHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,i.jsx)(r.DialogTitle,{children:n}),f]}),u]})}):(0,i.jsx)(r.Sheet,{open:!0,onOpenChange:e=>!e&&ie(null),children:(0,i.jsxs)(r.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,i.jsxs)(r.SheetHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,i.jsx)(r.SheetTitle,{children:n}),f]}),(0,i.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:u})]})})})():null;return(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsx)(r.RefreshIndicator,{active:te&&N.length>0}),(0,i.jsx)(Z,{...e,schema:fe,onChartClick:me}),he]})},De={filter:!0},Oe=e=>(0,i.jsx)(o.ElementDataSourceGate,{schema:e.schema,mapping:De,dataSource:e.dataSource,testId:`object-chart`,errorTitle:`This chart’s data source could not be resolved`,children:t=>(0,i.jsx)(Ee,{...e,schema:t})});t.ComponentRegistry.register(`object-chart`,Oe,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`data`,type:`array`,label:`Data`,description:`Optional static data`},{name:`filter`,type:`array`,label:`Filter`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`},{name:`drillDown`,type:`object`,label:`Drill-down`,description:`Segment drill config: { enabled?, filter?, title?, target?: 'drawer' | 'dialog', columns?, maxRows? }. Present = on; {} is enough. Clicking a segment opens the underlying records filtered by the clicked category.`}]}),O();var ke={"bar-chart":X,chart:Z};t.ComponentRegistry.register(`bar-chart`,X,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,label:`Data`,required:!0},{name:`dataKey`,type:`string`,label:`Data Key`,defaultValue:`value`},{name:`xAxisKey`,type:`string`,label:`X-Axis Key`,defaultValue:`name`},{name:`height`,type:`number`,label:`Height`,defaultValue:400},{name:`color`,type:`color`,label:`Color`,defaultValue:`#8884d8`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),t.ComponentRegistry.register(`chart`,Oe,{namespace:`view`,category:`view`,label:`Chart`,skipFallback:!0,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`type`,type:`string`,label:`Chart Type`},{name:`categoryField`,type:`string`,label:`Category Field`},{name:`valueField`,type:`string`,label:`Value Field`}]}),t.ComponentRegistry.register(`chart`,Z,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,label:`Chart Type`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}],defaultValue:`bar`},{name:`data`,type:`code`,label:`Data (JSON)`,required:!0},{name:`config`,type:`code`,label:`Config (JSON)`},{name:`xAxisKey`,type:`string`,label:`X Axis Key`,defaultValue:`name`},{name:`series`,type:`code`,label:`Series (JSON Array)`,required:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),t.ComponentRegistry.register(`chart:bar`,Z,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`,defaultProps:{chartType:`bar`}}),t.ComponentRegistry.register(`pie-chart`,Z,{namespace:`plugin-charts`,label:`Pie Chart`,category:`plugin`,defaultProps:{chartType:`pie`}}),t.ComponentRegistry.register(`donut-chart`,Z,{namespace:`plugin-charts`,label:`Donut Chart`,category:`plugin`,defaultProps:{chartType:`donut`}}),t.ComponentRegistry.register(`radar-chart`,Z,{namespace:`plugin-charts`,label:`Radar Chart`,category:`plugin`,defaultProps:{chartType:`radar`}}),t.ComponentRegistry.register(`scatter-chart`,Z,{namespace:`plugin-charts`,label:`Scatter Chart`,category:`plugin`,defaultProps:{chartType:`scatter`}}),e.ChartBarRenderer=X,e.ChartRenderer=Z,e.ObjectChart=Ee,e.ObjectChartBlock=Oe,e.chartComponents=ke,e.normalizeChartSchema=y});
|
|
7
|
+
`)}}):null},z=o.Tooltip,B=o.Legend}));function V(e){return e?.[0]?.dataKey||`value`}function _e(e,t,n){if(!e)return null;let r=e.payload??e,i=r?.[t];if(i==null)return null;let a=V(n);return{category:String(i),series:a,value:typeof r?.[a]==`number`?r[a]:void 0}}function ve(e,t){if(!e)return null;let n=e.name??e.payload?.name??e.root?.name;if(n==null)return null;let r=e.value??e.size??e.payload?.size;return{category:String(n),series:V(t),value:typeof r==`number`?r:void 0}}function ye(e,t){if(!e)return null;let n=e.payload??e,r=n?.name;return r==null||n?.depth===0?null:{category:String(r),series:V(t),value:typeof n?.value==`number`?n.value:void 0}}var be=h((()=>{})),xe=g({default:()=>G});function Se(e){return e===`top`?ft:dt}function Ce(e){return e===`right`?pt:X}function we(e,t){return e?t?e===`left`||e===`right`?{down:e}:{refused:e}:e===`top`||e===`bottom`?{across:e}:{refused:e}:{}}function Te(e,t){return e?(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`x-axis-position`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`xAxis.position`}),` is`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` —`,` `,t?(0,a.jsx)(a.Fragment,{children:`this chart's categories run down its side, so its x axis sits on the left or the right. It is drawn on the left.`}):(0,a.jsx)(a.Fragment,{children:`this chart's x axis runs across it, so it sits at the top or the bottom. It is drawn at the bottom.`})]}):null}function Ee(e,t){return t?e===`left`?`bottom`:`top`:e}function De(e){return e===`left`||e===`right`?`on the ${e}`:`at the ${e}`}function Oe(e,t){return e?t?gt:ht:mt}function ke(e,t){if(e.notes.length===0)return null;let n=t?`this chart's value axes run across it, so each sits at the bottom or the top.`:`this chart's value axes run up its side, so each sits on the left or the right.`;return je(...e.notes.map(e=>{let r=De(Ee(e.drawn,t));return(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`y-axis-position`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${e.index}].position`}),` is`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e.position}),` —`,` `,e.reason===`side`?(0,a.jsxs)(a.Fragment,{children:[n,` It is drawn `,r,`.`]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[0]`}),` already sits `,De(e.position),`, so this axis is drawn `,r,`.`]})]},e.index)}))}function Ae(e,t,n){if(e.undrawn.length===0)return null;let r=e.slotOf.length===1,i=n?`one at the bottom and one at the top`:`one on each side`;return je(...e.undrawn.map(o=>{let s=e[o.boundTo];if(r)return(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`y-axis-undrawn`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${o.index}]`}),` is not drawn — this chart draws one value axis`,s===void 0?null:(0,a.jsxs)(a.Fragment,{children:[`, `,(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${s}]`})]}),`.`]},o.index);let c=t?.[o.index]?.field;return(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`y-axis-undrawn`,className:`px-1 text-xs text-muted-foreground`,children:[(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${o.index}]`}),` is not drawn — this chart draws at most two value axes, `,i,`.`,c?(0,a.jsxs)(a.Fragment,{children:[` `,`When the chart declares neither `,(0,a.jsx)(`code`,{className:`font-mono`,children:`series`}),` nor`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:`categories`}),`, its field `,(0,a.jsx)(`code`,{className:`font-mono`,children:c}),` is plotted against the axis `,De(Ee(o.boundTo,n)),s===void 0?null:(0,a.jsxs)(a.Fragment,{children:[`, `,(0,a.jsx)(`code`,{className:`font-mono`,children:`yAxis[${s}]`})]}),`.`]}):null]},o.index)}))}function je(...e){let t=e.filter(e=>e!=null&&e!==!1);return t.length<=1?t[0]??null:(0,a.jsx)(a.Fragment,{children:t.map((e,t)=>(0,a.jsx)(n.Fragment,{children:e},t))})}function Me(e,t,n){if(!e)return{};let r=x(e),i=b(e,t);return{...i?{ticks:i}:{},...r?{domain:r}:{},...r?{allowDataOverflow:!0}:{},...e.logarithmic?{scale:`log`,domain:r??[1,`auto`]}:{},...e.title?{label:{value:e.title,...n}}:{}}}function Ne(e){let{x:t,y:n,width:r,height:i,name:o,fill:s}=e;return r<=0||i<=0?null:(0,a.jsxs)(`g`,{children:[(0,a.jsx)(`rect`,{x:t,y:n,width:r,height:i,fill:s,stroke:`hsl(var(--background))`,strokeWidth:2}),r>48&&i>18?(0,a.jsx)(`text`,{x:t+6,y:n+18,fill:`#fff`,fontSize:12,className:`pointer-events-none`,children:o}):null]})}function Pe({title:e,subtitle:t,children:n}){return!e&&!t?(0,a.jsx)(a.Fragment,{children:n}):(0,a.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,a.jsxs)(`div`,{className:`mb-2 shrink-0`,children:[e?(0,a.jsx)(`div`,{className:`text-sm font-medium leading-tight text-foreground`,children:e}):null,t?(0,a.jsx)(`div`,{className:`text-xs leading-tight text-muted-foreground`,children:t}):null]}),(0,a.jsx)(`div`,{className:`min-h-0 flex-1`,children:n})]})}function Fe({note:e,children:t}){return e?(0,a.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,a.jsx)(`div`,{className:`min-h-0 flex-1`,children:t}),(0,a.jsx)(`div`,{className:`mt-1 shrink-0`,children:e})]}):(0,a.jsx)(a.Fragment,{children:t})}function Ie(e,t){let n=0;for(let r of e){let e=Number(r?.[t]);Number.isFinite(e)&&e>0&&(n+=1)}return{sizable:n,total:e.length}}function Le({dataKey:e,className:t}){return(0,a.jsxs)(W,{code:`no-positive-magnitude`,className:t,children:[`This chart has nothing to size: no row's`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` is above zero.`]})}function Re(e,t,n){let r=t-e;return r<=0?null:(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`unsized-rows`,className:`px-1 text-xs text-muted-foreground`,children:[r,` of `,t,` rows `,r===1?`has`:`have`,` no`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:n}),` above zero — this chart sizes by value, so`,` `,r===1?`that row is`:`those rows are`,` not drawn to scale.`]})}function ze(e){return e!=null&&Number.isFinite(Number(e))}function Be(e,t,n){let r=0;for(let i of e){let e=i;ze(e?.[t])&&ze(e?.[n])&&(r+=1)}return{plottable:r,total:e.length}}function Ve({xKey:e,yKey:t,className:n}){return(0,a.jsxs)(W,{code:`no-plottable-points`,className:n,children:[`This chart has nothing to place: no row carries a number for both`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` and`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:t}),`.`]})}function He(e){return typeof e==`boolean`?!1:Array.isArray(e)?Ue(e[0])&&Ue(e[1]):Ue(e)}function Ue(e){return typeof e==`number`||e instanceof Number||typeof e==`string`||e instanceof Date?Number.isFinite(Number(e)):!1}function We(e){let t=e=>typeof e==`number`&&Number.isFinite(e);return t(e?.min)&&t(e?.max)||t(e?.stepSize)}function Ge(e,t){return e.some(e=>He(e?.[t]))}function Ke(e,t,n){let r=t[n];if(!r?.stack)return`none`;let i=oe(e,t),a=i===`combo`?r.chartType||ae(e)||(n===0?`bar`:`line`):i;return a===`line`?`none`:a===`area`?`area`:`bar`}function qe({keys:e,total:t,className:r}){return(0,a.jsxs)(W,{code:`no-numeric-value`,className:r,children:[`This chart has no scale to draw on:`,` `,t===1?`its only row has no`:`none of the ${t} rows has a`,` numeric value for`,` `,e.map((e,t)=>(0,a.jsxs)(n.Fragment,{children:[t>0?` or `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},`${t}-${e}`)),`.`]})}function Je({seriesKeys:e,className:t}){let r=(0,i.useSafeTranslate)();return(0,a.jsxs)(W,{code:`scatter-multi-series`,className:t,children:[r(`chart.scatterOneMeasure`,`A scatter plots one measure. Keep exactly one series:`),` `,e.map((e,t)=>(0,a.jsxs)(n.Fragment,{children:[t>0?`, `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},`${t}-${e}`))]})}function Ye(e,t,n,r){let i=t-e;return i<=0?null:(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`unplotted-points`,className:`px-1 text-xs text-muted-foreground`,children:[i,` of `,t,` rows `,i===1?`has`:`have`,` no number for both`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:n}),` and`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:r}),` — this chart plots by position, so`,` `,i===1?`that point is`:`those points are`,` not drawn.`]})}function Xe({chartType:e,data:r=[],config:s={},xAxisKey:c=`name`,series:l=[],className:u=``,colors:d,categoryColors:f,categoryOrder:p,onChartClick:m,isAnimationActive:h,xAxis:g,yAxes:_,showLegend:ee,showDataLabels:v,title:te,subtitle:ne,description:ie,height:b,annotations:x,interaction:le}){let C=e===`column`?`bar`:e,w=oe(C,l),T=ae(C),E=Array.isArray(r)?r:[],D=(0,i.useDisplayLocale)(),O=h===!1?{isAnimationActive:!1}:{},k={...h===!1?{disableSettleRemount:!0}:{},...b?{style:{height:b}}:{},...ie?{role:`img`,"aria-label":ie}:{}},[A,ue]=n.useState(!1),j=n.useRef(null),de=n.useCallback(e=>(...t)=>{let n=at(t);n!==void 0&&(j.current={gesture:n,dataKey:String(e.dataKey)})},[]),fe=m?e=>({onClick:de(e)}):()=>({}),pe=n.useCallback((e,n,r)=>{if(!m||!e)return;let i=e.activeTooltipIndex??e.activeIndex,a=i==null?NaN:Number(i),o=Number.isInteger(a)&&a>=0?E[a]:void 0,s=j.current;j.current=null;let c=it(n),u=s!=null&&c!==void 0&&s.gesture===c;if(r&&!u)return;let d=u?s.dataKey:rt(e.activeDataKey,l),f=d!=null&&o?o[d]:void 0;m({category:e.activeLabel==null?void 0:String(e.activeLabel),categoryId:(0,t.chartRowBucketId)(o),series:d,seriesLabel:ot(d,l),value:typeof f==`number`?f:void 0})},[m,E,l]),F=n.useCallback((e,t)=>{pe(e,t,!1)},[pe]),I=n.useCallback((e,t)=>{pe(e,t,!0)},[pe]),L=n.useCallback(e=>{if(!m||!e)return;let n=e.payload?.[c],r=l[0]?.dataKey||`value`;m({category:n==null?void 0:String(n),categoryId:(0,t.chartRowBucketId)(e.payload),series:r,seriesLabel:ot(r,l),value:typeof e.payload?.[r]==`number`?e.payload[r]:void 0})},[m,c,l]),me=m?{onClick:F,style:{cursor:`pointer`}}:{},he=m?{onClick:I}:{},R=m?e=>({...fe(e),cursor:`pointer`}):()=>({}),ge=m?{onClick:L,style:{cursor:`pointer`}}:{},V=n.useCallback((e,t,n)=>f&&f[e==null?``:String(e)]||n[t%n.length],[f]),be=n.useCallback(e=>{if(!m)return;let t=_e(e,c,l);t&&m(t)},[m,c,l]),xe=n.useCallback(e=>{if(!m)return;let t=ve(e,l);t&&m(t)},[m,l]),Ee=n.useCallback(e=>{if(!m)return;let t=ye(e,l);t&&m(t)},[m,l]),De=m?{onClick:be,cursor:`pointer`}:{},ze=m?{onClick:xe,style:{cursor:`pointer`}}:{},He=m?{onClick:Ee,style:{cursor:`pointer`}}:{};n.useEffect(()=>{let e=()=>ue(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let Ue=n.useCallback(e=>{if(e==null||e===``)return``;let n=s?.[String(e)]?.label;if(n!=null)return String(n);let r=typeof e==`string`?e:String(e);if(/^\d{4}-\d{2}-\d{2}/.test(r)){let e=(0,t.toDisplayDate)(r);if(!Number.isNaN(e.getTime())){let n=(E.length>1?Math.abs(new Date(String(E[E.length-1][c]??``)).getTime()-new Date(String(E[0][c]??``)).getTime()):0)/864e5;try{return n<=62?e.toLocaleDateString(D,{month:`short`,day:`numeric`}):e.toLocaleDateString(D,{month:`short`,year:`numeric`})}catch{return(0,t.isRealCalendarDate)(r)?(0,t.toDateInputValue)(e):e.toISOString().slice(0,10)}}}return A&&r.length>8?r.slice(0,8)+`…`:r},[E,c,A,s,D]),Ke=n.useMemo(()=>E.some(e=>String(e[c]||``).length>5),[E,c]),Xe=E.length>0&&E.length<=st,H=(Xe||!A)&&Ke,Ze=()=>Array.isArray(d)&&d.length>0?d:[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],Qe=n.useCallback(e=>{if(e==null||e===``)return``;let t=typeof e==`number`?e:Number(e);if(!Number.isFinite(t))return String(e);try{return new Intl.NumberFormat(D,{notation:`compact`,maximumFractionDigits:1}).format(t)}catch{return String(t)}},[D]),$e=_?.[0],U=w===`horizontal-bar`,et=re(_,w),G=et.left===void 0?void 0:_?.[et.left],K=et.right===void 0?void 0:_?.[et.right],J=!!G&&!!K,Y=w===`combo`||J,X=et.slotOf[0]??`left`,pt=je(ke(et,U),Ae(et,_,U)),mt=e=>J?e.yAxis===`right`?K:G:$e,ht=n.useMemo(()=>y(g?.format,D)??Ue,[g?.format,D,Ue]),gt=n.useMemo(()=>!Xe||!H?ht:e=>{let t=String(ht(e)??``);return t.length>ct?`${t.slice(0,11)}…`:t},[Xe,H,ht]),_t=n.useMemo(()=>y($e?.format,D)??Qe,[$e?.format,D,Qe]),vt=n.useMemo(()=>y(G?.format,D)??Qe,[G?.format,D,Qe]),yt=n.useMemo(()=>y(K?.format,D)??Qe,[K?.format,D,Qe]),bt=n.useCallback(e=>{let t=l.filter(t=>!J||(t.yAxis===`right`?`right`:`left`)===e).map(e=>e.dataKey),n=[];for(let e of E)for(let r of t){let t=Number(e?.[r]);Number.isFinite(t)&&n.push(t)}return n},[E,l,J]),Z=n.useCallback((e,t=`left`,n)=>Me(e,bt(t),n??Ce(t)),[bt]),xt=$e?.showGridLines!==!1,St={vertical:g?.showGridLines===!0,horizontal:xt},{across:Q,down:Ct,refused:wt}=we(g?.position,U),Tt=Te(wt,U),Et=ee!==!1,Dt=n.useMemo(()=>{if(!Array.isArray(x)||x.length===0)return null;let e={solid:void 0,dashed:`4 4`,dotted:`1 4`},t=Oe(Y,U);return x.map((n,r)=>{let i=n?.axis===`x`,s=q(String(n?.color||`hsl(var(--muted-foreground))`)),c=e[String(n?.style??`dashed`)],l=typeof n?.label==`string`?n.label:void 0,u=l?{label:{value:l,position:`insideTopRight`,fill:s,fontSize:11}}:{};if(n?.type===`region`){let e=i?{x1:n.value,x2:n.endValue}:{y1:n.value,y2:n.endValue};return(0,a.jsx)(o.ReferenceArea,{...e,...t,fill:s,fillOpacity:.12,stroke:s,strokeOpacity:.35,...u},`ann-${r}`)}return(0,a.jsx)(o.ReferenceLine,{...i?{x:n?.value}:{y:n?.value},...t,stroke:s,strokeDasharray:c,...u},`ann-${r}`)})},[x,Y,U]),Ot=le?.tooltips!==!1,kt=le?.brush===!0?(0,a.jsx)(o.Brush,{dataKey:c,height:24,travellerWidth:8,stroke:`hsl(var(--muted-foreground))`}):null,$=e=>v?(0,a.jsx)(o.LabelList,{position:`top`,className:`fill-foreground`,fontSize:11,...e?{formatter:e}:{}}):null,At=n.useMemo(()=>({tickLine:!1,tickMargin:10,axisLine:!1,...Xe?{interval:0}:{interval:`preserveStartEnd`,minTickGap:0},tickFormatter:gt,...Q?{orientation:Q}:{},...g?.title?{label:{value:g.title,...Se(Q)}}:{},...H&&{angle:Q===`top`?35:-35,textAnchor:`end`,height:60}}),[Xe,H,gt,g?.title,Q]);if(w&&ce.has(w)){let e=l[0]?.dataKey||`value`,t=E[0]?.[e],n=typeof t==`number`?t:Number(t),r=l[0]?.label??s?.[e]?.label??e;return(0,a.jsx)(`div`,{className:u,"data-testid":`advanced-chart-single-value`,children:(0,a.jsxs)(`div`,{className:`flex flex-col gap-1 py-4`,children:[(0,a.jsx)(`span`,{className:`text-3xl font-semibold tabular-nums`,children:Number.isFinite(n)?new Intl.NumberFormat(D).format(n):String(t??`—`)}),(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:String(r)})]})})}if(w&&S.has(w))return(0,a.jsxs)(`div`,{className:`rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${u??``}`,"data-testid":`advanced-chart-tabular-notice`,role:`note`,children:[`Chart type “`,w,`” is tabular — render it with the data-table / pivot components; a chart block draws series charts.`]});if(!w||!se.has(w))return(0,a.jsx)(`div`,{className:`rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${u??``}`,"data-testid":`advanced-chart-unknown-type`,role:`note`,children:w?(0,a.jsxs)(a.Fragment,{children:[`Chart type “`,w,`” is not a spec chart type — nothing was drawn.`]}):(0,a.jsx)(a.Fragment,{children:`This chart names no chart type — nothing was drawn.`})});let jt={bar:o.BarChart,"horizontal-bar":o.BarChart,line:o.LineChart,area:o.AreaChart,pie:o.PieChart,donut:o.PieChart,radar:o.RadarChart,scatter:o.ScatterChart,funnel:o.FunnelChart,combo:o.ComposedChart,treemap:o.BarChart,sankey:o.BarChart}[w]||o.BarChart;if(w===`pie`||w===`donut`){let e=w===`donut`?`52%`:0,t=Ze(),n=l[0]?.dataKey||`value`,r=Ie(E,n);if(r.total>0&&r.sizable===0)return(0,a.jsx)(Le,{dataKey:n,className:u});let i={...s};E.forEach((e,n)=>{let r=e?.[c];if(r==null||r===``)return;let a=String(r);i[a]||(i[a]={label:a,color:V(r,n,t)})});let d=(0,a.jsx)(M,{config:i,className:u,...k,children:(0,a.jsxs)(o.PieChart,{children:[(0,a.jsx)(z,{cursor:!1,content:(0,a.jsx)(N,{hideLabel:!0})}),(0,a.jsx)(o.Pie,{data:E,dataKey:n,nameKey:c||`name`,innerRadius:e,strokeWidth:5,paddingAngle:2,outerRadius:`85%`,...O,...ge,children:E.map((e,n)=>{let r=V(e?.[c],n,t);return(0,a.jsx)(o.Cell,{fill:q(r)},`cell-${n}`)})}),Et?(0,a.jsx)(B,{verticalAlign:`bottom`,wrapperStyle:{fontSize:A?`11px`:`12px`,paddingTop:`8px`},content:(0,a.jsx)(P,{nameKey:c,className:`flex-wrap`})}):null]})});return(0,a.jsx)(Fe,{note:Re(r.sizable,r.total,n),children:d})}if(w===`funnel`){let e=l[0]?.dataKey||`value`,n=Ze(),r=Ie(E,e);if(r.total>0&&r.sizable===0)return(0,a.jsx)(Le,{dataKey:e,className:u});let i=m?n=>{n&&m({category:n?.payload?.[c]??n?.[c],categoryId:(0,t.chartRowBucketId)(n?.payload)??(0,t.chartRowBucketId)(n),value:n?.payload?.[e]??n?.[e]})}:void 0,d=i?{onClick:i,style:{cursor:`pointer`}}:{},f=(0,t.buildCategoryRank)(p),h=f?[...E].sort((e,t)=>(f.get(String(e?.[c]??``))??2**53-1)-(f.get(String(t?.[c]??``))??2**53-1)):[...E].sort((t,n)=>{let r=Number(t?.[e]??0);return Number(n?.[e]??0)-r}),g=(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsxs)(o.FunnelChart,{children:[(0,a.jsx)(z,{content:(0,a.jsx)(N,{})}),(0,a.jsxs)(o.Funnel,{dataKey:e,data:h,nameKey:c,...O,...d,children:[(0,a.jsx)(o.LabelList,{position:`right`,fill:`hsl(var(--foreground))`,stroke:`none`,dataKey:c}),h.map((e,t)=>(0,a.jsx)(o.Cell,{fill:q(n[t%n.length])},`funnel-cell-${t}`))]})]})});return(0,a.jsx)(Fe,{note:Re(r.sizable,r.total,e),children:g})}if(w===`treemap`){let e=l[0]?.dataKey||`value`,t=Ze(),n=Ie(E,e);if(n.total>0&&n.sizable===0)return(0,a.jsx)(Le,{dataKey:e,className:u});let r=E.map((n,r)=>({name:String(n?.[c]??``),size:Number(n?.[e])||0,fill:q(t[r%t.length])})),i=(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsx)(o.Treemap,{data:r,dataKey:`size`,nameKey:`name`,...O,content:(0,a.jsx)(Ne,{}),...ze,children:(0,a.jsx)(o.Tooltip,{})})});return(0,a.jsx)(Fe,{note:Re(n.sizable,n.total,e),children:i})}if(w===`sankey`){let e=l[0]?.dataKey||`value`,t=l[0]?.label||e,n=E.filter(t=>(Number(t?.[e])||0)>0),r=[{name:t},...n.map(e=>({name:String(e?.[c]??``)}))],i=n.map((t,n)=>({source:0,target:n+1,value:Number(t?.[e])||0}));if(i.length===0)return E.length===0?(0,a.jsx)(`div`,{className:u}):(0,a.jsxs)(W,{code:`no-positive-flow`,className:u,children:[`This chart has no flow to draw: no row's`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` is above zero.`]});let d=E.length-n.length;return(0,a.jsx)(Fe,{note:d>0?(0,a.jsxs)(`p`,{role:`note`,"data-chart-note":`omitted-rows`,className:`px-1 text-xs text-muted-foreground`,children:[`Showing `,n.length,` of `,E.length,` rows — `,d,` `,d===1?`row has`:`rows have`,` no`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:e}),` above zero, which a flow cannot draw.`]}):null,children:(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsx)(o.Sankey,{data:{nodes:r,links:i},nodePadding:24,link:{stroke:`hsl(var(--muted-foreground))`,strokeOpacity:.25},node:{fill:`hsl(var(--chart-1))`},...He,children:(0,a.jsx)(o.Tooltip,{})})})})}if(w===`radar`)return(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsxs)(o.RadarChart,{data:E,children:[(0,a.jsx)(o.PolarGrid,{}),(0,a.jsx)(o.PolarAngleAxis,{dataKey:c}),(0,a.jsx)(o.PolarRadiusAxis,{}),(0,a.jsx)(z,{content:(0,a.jsx)(N,{})}),(0,a.jsx)(B,{content:(0,a.jsx)(P,{}),...A&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),l.map(e=>{let t=q(s[e.dataKey]?.color||tt),n=nt(e,`radar`);return(0,a.jsx)(o.Radar,{dataKey:e.dataKey,stroke:t,fill:t,fillOpacity:n.fillOpacity??.6,strokeOpacity:n.strokeOpacity,strokeDasharray:n.strokeDasharray,...O},e.dataKey)})]})});if(w===`scatter`){if(l.length>1)return(0,a.jsx)(Je,{seriesKeys:l.map(e=>String(e.dataKey)),className:u});let e=l[0]?.dataKey||`value`,t=Be(E,c,e),n=E.map(e=>Number(e?.[c])).filter(e=>Number.isFinite(e)),r=y(g?.format,D);if(t.total>0&&t.plottable===0)return(0,a.jsx)(Ve,{xKey:c,yKey:e,className:u});if(t.total>0){let n=[[c,g],[e,_?.[0]]].filter(([e,t])=>!We(t)&&!Ge(E,e)).map(([e])=>e).filter((e,t,n)=>n.indexOf(e)===t);if(n.length>0)return(0,a.jsx)(qe,{keys:n,total:t.total,className:u})}return(0,a.jsx)(Fe,{note:je(Ye(t.plottable,t.total,c,e),Tt,pt),children:(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsxs)(o.ScatterChart,{children:[(0,a.jsx)(o.CartesianGrid,{...St}),(0,a.jsx)(o.XAxis,{type:`number`,dataKey:c,name:String(s[c]?.label||c),tickLine:!1,axisLine:!1,minTickGap:A?32:48,padding:lt,...r?{tickFormatter:r}:{},...Q?{orientation:Q}:{},...Me(g,n,Se(Q))}),(0,a.jsx)(o.YAxis,{type:`number`,dataKey:e,name:String(s[l[0]?.dataKey]?.label||l[0]?.dataKey),tickLine:!1,axisLine:!1,tickFormatter:_t,width:48,padding:ut,...X===`right`?{orientation:`right`}:{},...Z($e,X)}),(0,a.jsx)(z,{content:(0,a.jsx)(N,{})}),(0,a.jsx)(B,{content:(0,a.jsx)(P,{nameKey:e}),...A&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),l.map((e,t)=>{let n=Ze(),r=q(s[e.dataKey]?.color||n[t%n.length]),i=nt(e,`scatter`);return(0,a.jsx)(o.Scatter,{name:s[e.dataKey]?.label||e.dataKey,data:E,fill:r,fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity,strokeDasharray:i.strokeDasharray,...O,...De},e.dataKey)})]})})})}if(w===`combo`)return(0,a.jsx)(Pe,{title:te,subtitle:ne,children:(0,a.jsx)(Fe,{note:je(Tt,pt),children:(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsxs)(o.ComposedChart,{data:E,...he,children:[(0,a.jsx)(o.CartesianGrid,{...St,...Oe(Y,U)}),(0,a.jsx)(o.XAxis,{dataKey:c,...At}),(0,a.jsx)(o.YAxis,{yAxisId:`left`,tickLine:!1,axisLine:!1,tickFormatter:vt,width:48,...Z(G,`left`)}),(0,a.jsx)(o.YAxis,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:yt,width:48,...Z(K,`right`)}),Ot?(0,a.jsx)(z,{content:(0,a.jsx)(N,{})}):null,Et?(0,a.jsx)(B,{content:(0,a.jsx)(P,{}),...A&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Dt,kt,l.map((e,t)=>{let n=q(s[e.dataKey]?.color||tt),r=e.chartType||T||(t===0?`bar`:`line`),i=e.yAxis===`right`||e.yAxis===`left`?e.yAxis:T||r===`bar`?`left`:`right`,c=nt(e,r),l=e.stack?{stackId:String(e.stack)}:{},u=y((i===`right`?K:G)?.format,D);return r===`line`?(0,a.jsx)(o.Line,{yAxisId:i,type:`monotone`,dataKey:e.dataKey,stroke:n,strokeWidth:2,dot:!1,strokeOpacity:c.strokeOpacity,strokeDasharray:c.strokeDasharray,...O,...R(e),children:$(u)},e.dataKey):r===`area`?(0,a.jsx)(o.Area,{yAxisId:i,type:`monotone`,dataKey:e.dataKey,fill:n,stroke:n,fillOpacity:c.fillOpacity??.4,strokeOpacity:c.strokeOpacity,strokeDasharray:c.strokeDasharray,...l,...O,...R(e),children:$(u)},e.dataKey):(0,a.jsx)(o.Bar,{yAxisId:i,dataKey:e.dataKey,fill:n,radius:4,fillOpacity:c.fillOpacity,strokeOpacity:c.strokeOpacity,strokeDasharray:c.strokeDasharray,...l,...O,...R(e),children:$(u)},e.dataKey)})]})})})});let Mt=w===`horizontal-bar`,Nt=Ze(),Pt=f?Object.values(f).map(e=>q(String(e))):[],Ft=Array.from(new Set([...Nt,...Pt,...l.map((e,t)=>q(s[e.dataKey]?.color||Nt[t%Nt.length]||tt))])),It=e=>`g`+e.replace(/[^a-zA-Z0-9]/g,``);return(0,a.jsx)(Pe,{title:te,subtitle:ne,children:(0,a.jsx)(Fe,{note:je(Tt,pt),children:(0,a.jsx)(M,{config:s,className:u,...k,children:(0,a.jsxs)(jt,{data:E,layout:Mt?`vertical`:`horizontal`,...me,children:[(0,a.jsx)(`defs`,{children:Ft.map(e=>(0,a.jsxs)(n.Fragment,{children:[(0,a.jsxs)(`linearGradient`,{id:`bg-${It(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,a.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.95}),(0,a.jsx)(`stop`,{offset:`100%`,style:{stopColor:e},stopOpacity:.5})]}),(0,a.jsxs)(`linearGradient`,{id:`ag-${It(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,a.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.5}),(0,a.jsx)(`stop`,{offset:`95%`,style:{stopColor:e},stopOpacity:.05})]})]},It(e)))}),(0,a.jsx)(o.CartesianGrid,{...St,...Oe(Y,U)}),Mt?(0,a.jsxs)(a.Fragment,{children:[J?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.XAxis,{xAxisId:`left`,type:`number`,tickLine:!1,axisLine:!1,tickFormatter:vt,...Z(G,`left`,dt)}),(0,a.jsx)(o.XAxis,{xAxisId:`right`,orientation:`top`,type:`number`,tickLine:!1,axisLine:!1,tickFormatter:yt,...Z(K,`right`,ft)})]}):(0,a.jsx)(o.XAxis,{type:`number`,tickLine:!1,axisLine:!1,tickFormatter:_t,...X===`right`?{orientation:`top`}:{},...Z($e,X,Se(X===`right`?`top`:`bottom`))}),(0,a.jsx)(o.YAxis,{type:`category`,dataKey:c,tickLine:!1,axisLine:!1,width:Math.min(140,Math.max(60,Math.max(...E.map(e=>String(e[c]??``).length))*7)),tickFormatter:ht,...Ct?{orientation:Ct}:{},...g?.title?{label:{value:g.title,...Ce(Ct)}}:{}})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.XAxis,{dataKey:c,...At}),J?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.YAxis,{yAxisId:`left`,tickLine:!1,axisLine:!1,tickFormatter:vt,width:48,...Z(G,`left`)}),(0,a.jsx)(o.YAxis,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:yt,width:48,...Z(K,`right`)})]}):(0,a.jsx)(o.YAxis,{tickLine:!1,axisLine:!1,tickFormatter:_t,width:48,...X===`right`?{orientation:`right`}:{},...Z($e,X)})]}),Ot?(0,a.jsx)(z,{content:(0,a.jsx)(N,{})}):null,Et?(0,a.jsx)(B,{content:(0,a.jsx)(P,{}),...A&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Dt,kt,l.map((e,t)=>{let n=Ze(),r=e.variant===`comparison`,i=r?l.slice(0,t).find(e=>e.variant!==`comparison`)||l[0]:e,u=r?l.indexOf(i):t,d=q(s[i.dataKey]?.color||n[u%n.length]||tt),f=e.yAxis===`right`?`right`:`left`,p=J?Mt?{xAxisId:f}:{yAxisId:f}:{},m=e.stack?{stackId:String(e.stack)}:{},h=y(mt(e)?.format,D);if(w===`bar`||w===`horizontal-bar`){let t=l.filter(e=>e.variant!==`comparison`).length===1&&!r&&l.length===1&&E.length>1,i=nt(e,`bar`);return(0,a.jsxs)(o.Bar,{dataKey:e.dataKey,fill:`url(#bg-${It(d)})`,radius:4,fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity,strokeDasharray:i.strokeDasharray,...m,...p,...O,...fe(e),children:[t&&E.map((e,t)=>(0,a.jsx)(o.Cell,{fill:`url(#bg-${It(q(V(e?.[c],t,n)))})`},`cell-${t}`)),$(h)]},e.dataKey)}if(w===`line`){let t=nt(e,`line`);return(0,a.jsx)(o.Line,{type:`monotone`,dataKey:e.dataKey,stroke:d,strokeWidth:2,dot:!1,strokeOpacity:t.strokeOpacity,strokeDasharray:t.strokeDasharray,...p,...O,...fe(e),children:$(h)},e.dataKey)}if(w===`area`){let t=nt(e,`area`);return(0,a.jsx)(o.Area,{type:`monotone`,dataKey:e.dataKey,fill:`url(#ag-${It(d)})`,stroke:d,strokeWidth:2,fillOpacity:t.fillOpacity??1,strokeOpacity:t.strokeOpacity,strokeDasharray:t.strokeDasharray,...m,...p,...O,...fe(e),children:$(h)},e.dataKey)}return null})]})})})})}function H(e){return e.chartType===`column`?`bar`:e.chartType}function Ze(e){let t=H(e),n=Array.isArray(e.data)?e.data:[],r=e.xAxisKey??`name`;return t!==void 0&&J.has(t)&&n.length>0&&!n.some(e=>typeof e==`object`&&!!e&&r in e)}function Qe(e){let t=H(e),n=Array.isArray(e.data)?e.data:[];return t===void 0||!_t.has(t)||n.length===0?null:e.series===void 0?`undeclared`:Array.isArray(e.series)&&e.series.length===0?`empty`:null}function $e(e){let t=H(e),n=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.series)?e.series:[];if(t===void 0||!_t.has(t)||n.length===0||r.length===0)return null;let i=Array.from(new Set(r.map(e=>String(e.dataKey))));if(!i.every(e=>n.some(t=>typeof t==`object`&&!!t&&Object.prototype.hasOwnProperty.call(t,e))))return null;let a=Array.isArray(e.yAxes)?e.yAxes:[],o=re(a,t),s=o.left===void 0?void 0:a[o.left],c=o.right===void 0?void 0:a[o.right],l=!!s&&!!c,u=e=>We(s)||(!l||e.yAxis!==`left`)&&We(c);return r.some((e,i)=>Ke(t,r,i)!==`none`||u(e)||Ge(n,String(e.dataKey)))?null:i}function U(e){let t=H(e),n=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.series)?e.series:[];if(t===void 0||!_t.has(t)||n.length===0||r.length===0)return null;let i=Array.from(new Set(r.map(e=>e.dataKey)));return i.every(e=>typeof e==`string`&&/^[^.[]+$/.test(e)&&!n.some(t=>typeof t==`object`&&!!t&&e in t))?i:null}function et({keys:e,className:t}){return(0,a.jsxs)(W,{code:`missing-series-key`,className:t,children:[`This chart cannot plot its series: no row has a`,` `,e.map((e,t)=>(0,a.jsxs)(n.Fragment,{children:[t>0?` or `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},`${t}-${e}`)),` `,`field.`]})}function W({code:e,className:t,children:n}){return(0,a.jsx)(`div`,{className:`flex h-full min-h-[120px] w-full items-center justify-center p-4 text-center text-sm text-muted-foreground ${t??``}`,role:`status`,"data-chart-error":e,children:(0,a.jsx)(`span`,{children:n})})}function G(e){let t=Ze(e),r=t?null:Qe(e),i=t||r?null:U(e),o=t||r||i?null:$e(e),s=e.xAxisKey??`name`,c=n.useMemo(()=>Object.keys((Array.isArray(e.data)?e.data[0]:void 0)??{}),[e.data]),l=i?JSON.stringify(i):null,u=JSON.stringify(c);return n.useEffect(()=>{t&&console.warn(`[chart] no row has the category key "${s}" — rendering an explanatory placeholder instead of an empty axis. Row keys: ${JSON.stringify(c)}. A dataset query must PROJECT the dimension it groups by (framework#4033).`)},[t,s,c]),n.useEffect(()=>{if(r){if(r===`undeclared`){console.warn(`[chart] no series binding was declared for the category axis "${s}" — rendering an explanatory placeholder instead of an empty frame. Row keys: ${JSON.stringify(c)}. A bar / line / area / combo chart draws only the columns its \`series\` (or \`categories\`, or a y-axis \`field\`) names (objectui#4695).`);return}console.warn(`[chart] no series to plot against the category axis "${s}" — rendering an explanatory placeholder instead of an empty frame. Row keys: ${JSON.stringify(c)}. A grouped chart's SECOND dimension must be PROJECTED by the dataset query, and a chart with no measure selected has nothing to draw either (objectui#4683, framework#4033).`)}},[r,s,c]),n.useEffect(()=>{l&&console.warn(`[chart] no row has the series key(s) ${l} — rendering an explanatory placeholder instead of an empty frame. Row keys: ${u}. A series \`dataKey\` must name a column the rows carry (objectui#10396).`)},[l,u]),t?(0,a.jsxs)(W,{code:`missing-category-key`,className:e.className,children:[`This chart cannot plot its category axis: no row has a`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:s}),` field.`]}):r===`undeclared`?(0,a.jsxs)(W,{code:`no-plottable-series`,className:e.className,children:[`This chart cannot plot any series: none was declared to draw against its`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:s}),` axis.`]}):r===`empty`?(0,a.jsxs)(W,{code:`no-plottable-series`,className:e.className,children:[`This chart cannot plot any series: no measure or group reached its`,` `,(0,a.jsx)(`code`,{className:`font-mono`,children:s}),` axis.`]}):i?(0,a.jsx)(et,{keys:i,className:e.className}):o?(0,a.jsx)(qe,{keys:o,total:Array.isArray(e.data)?e.data.length:0,className:e.className}):(0,a.jsx)(Xe,{...e})}var tt,K,q,nt,rt,it,at,ot,J,st,ct,Y,lt,ut,X,dt,ft,pt,mt,ht,gt,_t,vt=h((()=>{ge(),be(),k(),tt=`hsl(var(--primary))`,K={slate:`#64748b`,gray:`#6b7280`,zinc:`#71717a`,neutral:`#737373`,stone:`#78716c`,red:`#ef4444`,orange:`#f97316`,amber:`#f59e0b`,yellow:`#eab308`,lime:`#84cc16`,green:`#22c55e`,emerald:`#10b981`,teal:`#14b8a6`,cyan:`#06b6d4`,sky:`#0ea5e9`,blue:`#3b82f6`,indigo:`#6366f1`,violet:`#8b5cf6`,purple:`#a855f7`,fuchsia:`#d946ef`,pink:`#ec4899`,rose:`#f43f5e`},q=e=>K[e]||e,nt=(e,t)=>{let n=e?.variant===`comparison`,r=t===`area`||t===`radar`,i=typeof e?.opacity==`number`?e.opacity:void 0;return{strokeOpacity:i??(n?t===`line`?.5:r?.6:void 0:void 0),fillOpacity:i??(n?t===`bar`?.4:r?.2:.5:void 0),strokeDasharray:e?.dashArray??(n&&(t===`line`||r)?`4 4`:void 0)}},rt=(e,t)=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);if(t!==``)return t}if(t.length===1){let e=t[0]?.dataKey;if(e!=null&&String(e)!==``)return String(e)}},it=e=>{if(e&&typeof e==`object`&&`nativeEvent`in e)return e.nativeEvent},at=e=>{for(let t=e.length-1;t>=0;--t){let n=it(e[t]);if(n!==void 0)return n}},ot=(e,t)=>{if(e==null)return;let n=t.find(t=>String(t.dataKey)===e);return typeof n?.label==`string`?n.label:void 0},J=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`radar`,`funnel`,`combo`]),st=5,ct=12,Y=Math.ceil(Math.sqrt(400/Math.PI)),lt={left:Y,right:Y},ut={top:Y,bottom:Y},X={angle:-90,position:`insideLeft`},dt={position:`insideBottom`,offset:-4},ft={position:`insideTop`,offset:-4},pt={angle:90,position:`insideRight`},mt={},ht={yAxisId:`left`},gt={xAxisId:`left`},_t=new Set([`bar`,`horizontal-bar`,`line`,`area`,`combo`])}));k();var yt=n.default.lazy(()=>Promise.resolve().then(()=>(fe(),A))),bt=n.default.lazy(()=>Promise.resolve().then(()=>(vt(),xe))),Z=({schema:e})=>(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,a.jsx)(yt,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),xt=({schema:e,onChartClick:t})=>{let{language:o}=(0,i.useObjectTranslation)(),s=n.default.useMemo(()=>{let t=ie(e,o),n=Array.isArray(e.series)?e.series:void 0,r=t.series??n,i=e.xAxisKey??t.xAxisKey,a=e.config;if(!a&&r){let t=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],n={};r.forEach((e,r)=>{n[e.dataKey]={label:e.label||e.dataKey,color:e.color||t[r%t.length]}}),a=n}return{chartType:e.chartType??t.chartType,data:Array.isArray(e.data)?e.data:[],config:a,xAxisKey:i,series:r,className:e.className,spec:t}},[e,o]);return(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,a.jsx)(bt,{chartType:s.chartType,data:s.data,config:s.config,xAxisKey:s.xAxisKey,series:s.series,className:s.className,colors:Array.isArray(e.colors)?e.colors:void 0,categoryColors:e.categoryColors,categoryOrder:e.categoryOrder,isAnimationActive:e.isAnimationActive,onChartClick:t,xAxis:s.spec.xAxis,yAxes:s.spec.yAxes,showLegend:s.spec.showLegend,showDataLabels:s.spec.showDataLabels,title:s.spec.title,subtitle:s.spec.subtitle,description:s.spec.description,height:s.spec.height??e.height,annotations:s.spec.annotations,interaction:s.spec.interaction})})};k();function St(e){return(0,t.chartMeasureKey)(e,e.function||`count`)}var Q=[`aggregate.groupBy`,`xAxisKey`,`xAxis.field`];function Ct(e){let t=e?.aggregate?.groupBy;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.field;return typeof e==`string`&&e?e:void 0}return typeof t==`string`&&t?t:ie(e).xAxisKey}var wt=`__comparison`;function Tt(e){let t=e?.groupBy;return t&&typeof t==`object`&&!Array.isArray(t)?t.alias||t.field:typeof t==`string`?t:void 0}function Et(e,t){let{field:n,function:r,groupBy:i}=t,a=St(t),o={};for(let t of e){let e=String(t[i]??`Unknown`);o[e]||(o[e]=[]),o[e].push(t)}return Object.entries(o).map(([e,t])=>{let o=n?t.map(e=>Number(e[n])||0):[],s;switch(r){case`count`:s=t.length;break;case`avg`:s=o.length>0?o.reduce((e,t)=>e+t,0)/o.length:0;break;case`min`:s=o.length>0?Math.min(...o):0;break;case`max`:s=o.length>0?Math.max(...o):0;break;default:s=o.reduce((e,t)=>e+t,0)}return{[i]:e,[a]:s}})}async function Dt(e,n,r,i,a){if(!e.length||!n)return e;let o=a||((e,t)=>t),s=`__raw_${n}`,c=r?.fields?.[n];if(!c){let r=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let i=e[n],a=String(i??``),c=r.test(a)?a:(0,t.humanizeLabel)(a);return{...e,[n]:o(a,c),[s]:i}})}let l=c.type;if(l===`select`||l===`picklist`||l===`dropdown`){let r=c.options||[];if(r.length===0)return e.map(e=>{let r=e[n],i=String(r??``),a=(0,t.humanizeLabel)(i);return{...e,[n]:o(i,a),[s]:r}});let i={};for(let e of r)typeof e==`string`?i[e]=e:e&&typeof e==`object`&&(i[String(e.value)]=e.label||String(e.value));return e.map(e=>{let r=e[n],a=String(r??``),c=i[a]||(0,t.humanizeLabel)(a);return{...e,[n]:o(a,c),[s]:r}})}if(l===`lookup`||l===`master_detail`){let r=c.reference;if(!r||!i||typeof i.find!=`function`)return e.map(e=>({...e,[s]:e[n]}));let a=[...new Set(e.map(e=>e[n]).filter(e=>e!=null))];if(a.length===0)return e.map(e=>({...e,[s]:e[n]}));let o=c.id_field||`id`;try{let l=await i.find(r,{$filter:{[o]:{$in:a}},$top:a.length}),u=(0,t.extractRecords)(l),d=c.displayField||c.reference_field||`name`,f={};for(let e of u){let t=String(e[o]??e.id??e._id??``),n=e[d]||e.name||e.label||e.title||t;t&&(f[t]=String(n))}return e.map(e=>{let t=e[n],r=String(t??``);return{...e,[n]:f[r]||r,[s]:t}})}catch(t){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,t),e.map(e=>({...e,[s]:e[n]}))}}if(l===`date`||l===`datetime`||l===`date_time`||l===`timestamp`||l===`time`)return e.map(e=>({...e,[s]:e[n]}));let u=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[n],i=String(r??``);return{...e,[n]:u.test(i)?i:(0,t.humanizeLabel)(i),[s]:r}})}var Ot=e=>{let{schema:o}=e,l=e.onSegmentClick,u=(0,n.useContext)(s.SchemaRendererContext),d=e.dataSource||u?.dataSource,f=u?.apiFetch,p=(0,s.useDataScope)(o.bind),{fieldOptionLabel:m}=(0,i.useSafeFieldLabel)(),[h,g]=(0,n.useState)([]),[_,ee]=(0,n.useState)(null),[v,te]=(0,n.useState)(void 0),[ne,re]=(0,n.useState)(()=>!(Array.isArray(o.data)&&o.data.length>0)&&(!!o.objectName||!!o.dataset)),[ae,oe]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),[x,se]=(0,n.useState)(null),{openRecordList:ce}=(0,s.useDrillNavigation)(),S=(0,i.useSafeTranslate)(),{t:le,language:C}=(0,i.useObjectTranslation)(),w=(0,n.useMemo)(()=>ie(o,C).chartType,[o,C]),T=(0,n.useMemo)(()=>o.aggregate?JSON.stringify(o.aggregate):``,[o.aggregate]),E=(0,n.useMemo)(()=>o.filter?JSON.stringify(o.filter):``,[o.filter]),D=(0,n.useMemo)(()=>o.compareTo?JSON.stringify(o.compareTo):``,[o.compareTo]),O=(0,n.useMemo)(()=>o.dataset?JSON.stringify({d:o.dataset,dim:o.dimensions??[],val:o.values??[]}):``,[o.dataset,o.dimensions,o.values]);(0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let n=f??fetch,r={headers:{accept:`application/json`},credentials:`include`},i=o.objectName,a,s=null;if(i)a=Ct(o);else if(o.dataset){let e=Array.isArray(o.dimensions)&&o.dimensions.length?o.dimensions[0]:void 0,t=await(await n(`/api/v1/meta/dataset/${encodeURIComponent(o.dataset)}`,r)).json().catch(()=>null);s=t?.item??t?.data??t,i=s?.object,a=((s?.dimensions||[]).find(t=>t?.name===e)??(s?.dimensions||[])[0])?.field??e}if(!i||!a){e||se(null);return}let c=async e=>{let t=await(await n(`/api/v1/meta/object/${encodeURIComponent(e)}`,r)).json().catch(()=>null);return t?.item??t?.data??t},l={};if(o.dataset&&Array.isArray(o.dimensions))for(let e of o.dimensions)l[e]=(s?.dimensions||[]).find(t=>t?.name===e)?.field??e;let u=await(0,t.loadDimensionFieldMeta)(c,i,[a,...Object.values(l)]);e||se({metaByPath:u,colorPath:a,fieldByDim:o.dataset&&Array.isArray(o.dimensions)?l:null})}catch{e||se(null)}})(),()=>{e=!0}},[o.objectName,o.dataset,O,T,o.xAxisKey,f]);let{fieldOptionColors:k,dimensionLabels:A}=(0,n.useMemo)(()=>{if(!x)return{fieldOptionColors:null,dimensionLabels:null};let{metaByPath:e,colorPath:n,fieldByDim:r}=x,i=(0,t.localizeFieldOptions)(e[n]?.options,(0,t.dimensionOptionTranslator)(e[n],m)),a=(0,t.deriveDimensionLabelMaps)(e,r?Object.entries(r).map(([e,t])=>({dim:e,path:t})):null,m);return{fieldOptionColors:(0,t.buildOptionColorMap)(i),dimensionLabels:a}},[x,m]),ue=(0,n.useCallback)(async(e,n)=>{if(o.aggregate&&typeof e.aggregate==`function`){let r=o.aggregate.groupBy;if((0,t.isStructuredGroupBy)(r)){let i=await e.aggregate(o.objectName,(0,t.objectAggregateSpecQuery)(o.aggregate,r,n));return Array.isArray(i)?i:[]}let i=await e.aggregate(o.objectName,{field:o.aggregate.field,function:o.aggregate.function,groupBy:r,filter:n});return Array.isArray(i)?i:[]}if(typeof e.find==`function`){let r=await e.find(o.objectName,{$filter:n}),i=(0,t.extractRecords)(r),a=Tt(o.aggregate);return o.aggregate&&a&&i.length>0&&(i=Et(i,{...o.aggregate,groupBy:a})),i}return[]},[o.objectName,T]),j=(0,s.useFilterScope)(),de=(0,n.useCallback)(async(e,n)=>{if(!e||!o.objectName&&!o.dataset){n.current&&re(!1);return}n.current&&(re(!0),oe(null));try{if(o.dataset&&typeof e.queryDataset==`function`){let r=(0,t.resolveFilterPlaceholders)(o.filter,j),i=await e.queryDataset(o.dataset,{dimensions:Array.isArray(o.dimensions)?o.dimensions:[],measures:Array.isArray(o.values)?o.values:[],...r?{runtimeFilter:r}:{}});n.current&&(g(Array.isArray(i?.rows)?i.rows:[]),ee(Array.isArray(i?.fields)?i.fields:null),te(typeof i?.object==`string`&&i.object?i.object:void 0));return}let r=(0,t.resolveFilterPlaceholders)(o.filter,j),i=o.compareTo,a=!!i&&!(0,t.chartTypeIgnoresCompareTo)(w),s=a?(0,t.resolveContextTokens)((0,t.shiftFilterByCompareTo)(o.filter,i),j):null,[c,l]=await Promise.all([ue(e,r),s?ue(e,s):Promise.resolve([])]),u=c,d=Tt(o.aggregate)||o.xAxisKey;if(a&&l.length>0&&o.aggregate){let e=o.aggregate.field,t=o.aggregate.function,n=St(o.aggregate),r=r=>{if(r==null)return null;if(e){let n=`${e}_${t}`;if(n in r)return Number(r[n]);if(t===`count`&&`${e}_count`in r)return Number(r[`${e}_count`])}return n in r?Number(r[n]):`value`in r?Number(r.value):`count`in r?Number(r.count):null},i=`${n}${wt}`,a=d;if(a&&u.some(e=>e[a]!=null)&&l.some(e=>e[a]!=null)){let e=new Map;for(let t of l){let n=String(t[a]??``);e.set(n,r(t))}u=u.map(t=>{let n=String(t[a]??``),r=e.get(n);return r==null?t:{...t,[i]:r}});let t=new Set(u.map(e=>String(e[a]??``)));for(let e of l){let n=String(e[a]??``);t.has(n)||u.push({[a]:n,[i]:r(e)})}}else{let e=Math.max(u.length,l.length),t=[];for(let n=0;n<e;n++){let e=u[n]||{},a=l[n];t.push(a?{...e,[i]:r(a)}:e)}u=t}}if(d&&o.objectName&&typeof e.getObjectSchema==`function`){let t=o.objectName;try{let n=await e.getObjectSchema(t);u=await Dt(u,d,n,e,(e,n)=>m(t,d,e,n))}catch{}}n.current&&g(u)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&oe(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&re(!1)}},[o.objectName,O,T,E,D,o.xAxisKey,w,ue,j,m]),fe=!!(o.objectName||o.dataset)&&!p&&!o.data,pe=(0,s.useDataInvalidation)(fe?o.dataset?v:o.objectName:void 0);(0,n.useEffect)(()=>{let e={current:!0};return fe?de(d,e):e.current&&re(!1),()=>{e.current=!1}},[o.objectName,O,d,p,o.data,E,T,D,de,pe]);let M=p||o.data||h,N=Array.isArray(M)?M:[],P=o.drillDown,F=Tt(o.aggregate)||o.xAxisKey,I=(0,n.useMemo)(()=>{if(!F)return new Map;let e=new Map,t=`__raw_${F}`;for(let n of N){let r=n?.[F];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[N,F]),L=(0,n.useMemo)(()=>{if(y)try{return{ok:!0,filter:(0,t.composeDrillFilter)(o.filter,(0,t.computeDrillFilter)(P,y,{groupByField:F}))}}catch(e){if(!(e instanceof t.FilterOperatorError))throw e;return{ok:!1,refusal:e}}},[y,P,F,E]),me=L?.ok?L.filter:void 0,he=L?.ok===!1,R=L?.ok===!1?L.refusal.message:void 0;(0,n.useEffect)(()=>{R&&console.warn(`[ObjectChart] drill-down refused — the drilled list cannot be scoped: ${R}`)},[R]);let z=!l&&!!y&&!he&&!!o.objectName&&P?.target===`navigate`&&!!ce;(0,n.useEffect)(()=>{z&&(ce(o.objectName,me),b(null))},[z]);let B=o.compareTo,ge=o.aggregate?St(o.aggregate):void 0,V=ge?`${ge}${wt}`:void 0,_e=!!B&&!(0,t.chartTypeIgnoresCompareTo)(w)&&!!V&&N.some(e=>e[V]!=null),ve=(0,n.useMemo)(()=>{let e=Array.isArray(o.series)?o.series:null;if(!_e)return e;let n=e||[{dataKey:ge}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[(0,t.compareToTrendLabelKey)(B,o.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:V,label:r,variant:`comparison`}]},[_e,o.series,ge,V,o.filter,B]),ye=o.dataset?(0,t.buildChartSeries)((0,t.relabelDimensions)(N,A),o.dimensions,o.values,_,{nullCategoryLabel:S(`chart.nullCategory`,`(None)`),builtinAggregateLabels:(0,i.builtinAggregateLabels)(S)}):null,be=!!p||Array.isArray(o.data),xe=!!o.objectName&&!o.dataset&&!be,Se=xe&&!ie(o,C).xAxisKey?Tt(o.aggregate):void 0,Ce=ye?{...o,data:ye.data,xAxisKey:ye.xAxisKey,series:ye.series}:{...o,data:N,...Se?{xAxisKey:Se}:{},...ve?{series:ve}:{}},we=o.colors&&!Array.isArray(o.colors)&&typeof o.colors==`object`?o.colors:null,Te=Array.isArray(o.colors)?o.colors:void 0,Ee=k||we?{...k||{},...we||{}}:void 0,De={...Ce,colors:Te,...Ee?{categoryColors:Ee}:{}};if(xe&&!Ct(o))return(0,a.jsxs)(`div`,{className:`p-4 text-destructive `+(o.className||``),"data-testid":`chart-missing-category-axis`,role:`alert`,children:[S(`chart.unconfigured.noCategoryAxis`,`Chart category axis required — an object-bound chart will not invent one. Declare one of:`),` `,Q.map((e,t)=>(0,a.jsxs)(n.default.Fragment,{children:[t>0?`, `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},e))]});if(ne&&N.length===0)return(0,a.jsxs)(`div`,{className:`p-2 `+(o.className||``),"data-testid":`chart-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,a.jsx)(`span`,{className:`sr-only`,children:`Loading chart data…`}),(0,a.jsx)(r.ChartSkeleton,{className:`h-full`})]});if(ae)return(0,a.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(o.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,a.jsx)(c.AlertCircle,{className:`h-6 w-6 text-destructive opacity-60`}),(0,a.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,a.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:ae})]});if(!d&&o.objectName&&N.length===0)return(0,a.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(o.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,o.objectName,`”`]});if((o.objectName||o.dataset)&&!p&&!o.data&&N.length===0)return(0,a.jsx)(r.DataEmptyState,{role:`status`,"data-testid":`chart-empty-state`,className:`h-full w-full gap-2 p-4 [&>h3]:text-sm [&>h3]:font-medium [&>p]:text-xs `+(o.className||``),icon:(0,a.jsx)(c.Inbox,{className:`h-5 w-5 text-muted-foreground/70`}),iconWrapperClassName:`flex size-9 items-center justify-center rounded-lg bg-muted`,title:S(`dashboard.empty.title`,`No data yet`),description:S(`dashboard.empty.message`,`This widget loaded successfully and its query returned no records yet.`),children:(0,a.jsxs)(`p`,{className:`text-xs text-muted-foreground/80`,"data-testid":`chart-empty-source`,children:[(0,a.jsx)(`span`,{children:S(`dashboard.empty.sourceLabel`,`Source:`)}),` `,(0,a.jsx)(`span`,{className:`font-mono`,children:o.dataset||o.objectName})]})});let Oe=(0,t.isDrillEnabled)(P)?e=>{let t=e.category,n=t!=null&&I.has(String(t))?I.get(String(t)):t;b({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,ke=l??Oe,Ae=!l&&y&&!he&&o.objectName&&!z?(()=>{let e=me??{},n=(0,t.resolveDrillTitle)(P,y,(0,i.pickLocalized)(o.title,C)||`Details`),l=P?.target??`drawer`,u={type:`object-data-table`,objectName:o.objectName,filter:e,pagination:!0,pageSize:P?.maxRows,columns:P?.columns?.map(e=>({accessorKey:e,header:e})),drillDown:{enabled:!0,mode:`record`,target:`dialog`}},f=(0,a.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,a.jsx)(s.SchemaRenderer,{schema:u,dataSource:d})}),p=ce&&o.objectName?(0,a.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{ce(o.objectName,e),b(null)},children:[S(`dashboard.openInList`,`Open in list`),(0,a.jsx)(c.ArrowUpRight,{className:`ml-1 h-3.5 w-3.5`})]}):null;return l===`dialog`?(0,a.jsx)(r.Dialog,{open:!0,onOpenChange:e=>!e&&b(null),children:(0,a.jsxs)(r.DialogContent,{className:`max-w-4xl`,children:[(0,a.jsxs)(r.DialogHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,a.jsx)(r.DialogTitle,{children:n}),p]}),f]})}):(0,a.jsx)(r.Sheet,{open:!0,onOpenChange:e=>!e&&b(null),children:(0,a.jsxs)(r.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,a.jsxs)(r.SheetHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,a.jsx)(r.SheetTitle,{children:n}),p]}),(0,a.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:f})]})})})():null;return(0,a.jsxs)(`div`,{className:`relative h-full`,children:[(0,a.jsx)(r.RefreshIndicator,{active:ne&&N.length>0,ariaLabel:le(`chart.refreshing`)}),(0,a.jsx)(xt,{...e,schema:De,onChartClick:ke}),Ae]})},kt={filter:!0},$=(0,t.elementDataSourceBlock)(e=>(0,a.jsx)(s.ElementDataSourceGate,{schema:e.schema,mapping:kt,dataSource:e.dataSource,testId:`object-chart`,errorTitle:`This chart’s data source could not be resolved`,children:t=>(0,a.jsx)(Ot,{...e,schema:t})}));t.ComponentRegistry.register(`object-chart`,$,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`data`,type:`array`,description:`Optional static data`},{name:`filter`,type:`array`},{name:`aggregate`,type:`object`,description:`Aggregation config: { field, function, groupBy }`},{name:`drillDown`,type:`object`,description:`Segment drill config: { enabled?, filter?, title?, target?: 'drawer' | 'dialog', columns?, maxRows? }. Present = on; {} is enough. Clicking a segment opens the underlying records filtered by the clicked category.`}]}),k();var At={"bar-chart":Z,chart:xt};t.ComponentRegistry.register(`bar-chart`,Z,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,required:!0},{name:`dataKey`,type:`string`},{name:`xAxisKey`,type:`string`},{name:`height`,type:`number`},{name:`color`,type:`color`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),t.ComponentRegistry.register(`chart`,$,{namespace:`view`,category:`view`,label:`Chart`,skipFallback:!0,inputs:[{name:`objectName`,type:`string`,required:!0},{name:`type`,type:`string`},{name:`categoryField`,type:`string`},{name:`valueField`,type:`string`}]}),t.ComponentRegistry.register(`chart`,xt,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}]},{name:`data`,type:`code`,required:!0},{name:`config`,type:`code`},{name:`xAxisKey`,type:`string`},{name:`series`,type:`code`,required:!0},{name:`className`,type:`string`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),t.ComponentRegistry.register(`chart:bar`,xt,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`}),e.ChartBarRenderer=Z,e.ChartRenderer=xt,e.ObjectChart=Ot,e.ObjectChartBlock=$,e.chartComponents=At,e.normalizeChartSchema=ie});
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* ObjectUI
|
|
3
|
-
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
1
|
+
import { ObjectChartSchema } from '@object-ui/types';
|
|
8
2
|
/**
|
|
9
3
|
* The ONE place the spec's author-facing chart shape is translated into the
|
|
10
4
|
* renderer's internal pipeline contract (framework#3729 / objectui#2880).
|
|
@@ -63,6 +57,23 @@
|
|
|
63
57
|
* because dropping a name that is already authored breaks those charts.
|
|
64
58
|
*/
|
|
65
59
|
export type ChartFamily = 'bar' | 'column' | 'horizontal-bar' | 'line' | 'area' | 'pie' | 'donut' | 'funnel' | 'radar' | 'scatter' | 'treemap' | 'sankey' | 'combo';
|
|
60
|
+
/**
|
|
61
|
+
* Every chart family a schema can name on this renderer's family channels, as
|
|
62
|
+
* the faces DECLARE them (objectui#11520): the union of `object-chart`'s two
|
|
63
|
+
* family keys, read off `ObjectChartSchema` by reference and ⛔ never restated.
|
|
64
|
+
*
|
|
65
|
+
* - `specType` is the spec's whole `ChartType` (the react tier's family; a bare
|
|
66
|
+
* `chart` node's `chartType` declares the same domain).
|
|
67
|
+
* - `chartType` is the node's own union, the families this block draws
|
|
68
|
+
* (objectui#11513). It sits inside the spec's today, and is named anyway so
|
|
69
|
+
* the type says which two channels it covers.
|
|
70
|
+
*
|
|
71
|
+
* Wider than {@link ChartFamily} on purpose: it includes the single-value and
|
|
72
|
+
* tabular families, which `AdvancedChartImpl`'s dispatch routes to the number
|
|
73
|
+
* card and the tabular notice. Narrower than `string` on purpose: a misspelled
|
|
74
|
+
* family is a compile error, not a runtime notice.
|
|
75
|
+
*/
|
|
76
|
+
export type DeclaredChartFamily = NonNullable<ObjectChartSchema['chartType'] | ObjectChartSchema['specType']>;
|
|
66
77
|
export declare const RENDERABLE: Set<string>;
|
|
67
78
|
/**
|
|
68
79
|
* Every value the spec's `ChartTypeSchema` admits — a superset of
|
|
@@ -89,6 +100,65 @@ export declare const SINGLE_VALUE_CHART_TYPES: ReadonlySet<string>;
|
|
|
89
100
|
* so instead of drawing the same silent empty plot (#2942).
|
|
90
101
|
*/
|
|
91
102
|
export declare const TABULAR_CHART_TYPES: ReadonlySet<string>;
|
|
103
|
+
/**
|
|
104
|
+
* The component keywords this package registers for ONE named chart family,
|
|
105
|
+
* mapped to the family each keyword names (objectui#7401).
|
|
106
|
+
*
|
|
107
|
+
* ## Why these are not just more members of {@link CHART_TYPES}
|
|
108
|
+
*
|
|
109
|
+
* `CHART_TYPES` answers "is this bare `type` a chart FAMILY" — `'pie'`,
|
|
110
|
+
* `'scatter'`, the spec's own vocabulary. These are something else: they are
|
|
111
|
+
* SDUI component discriminators, the keys `index.tsx` hands
|
|
112
|
+
* `ComponentRegistry.register`. `type: 'chart:bar'` does not name a family in
|
|
113
|
+
* any spec; it names a registration whose whole purpose is to draw one.
|
|
114
|
+
*
|
|
115
|
+
* Since objectui#10859 batch 8 the table holds that one row: the
|
|
116
|
+
* `pie-chart`, `donut-chart`, `radar-chart` (phase 2c) and `scatter-chart`
|
|
117
|
+
* (phase 2b) keys were retired with their rows, and those families are reached
|
|
118
|
+
* as `{ type: 'chart', chartType: … }`. The history below is why the table
|
|
119
|
+
* exists at all.
|
|
120
|
+
*
|
|
121
|
+
* ## Why the derivation exists at all (objectui#7401)
|
|
122
|
+
*
|
|
123
|
+
* Each of these registrations declared its family as
|
|
124
|
+
* `defaultProps: { chartType: … }` — and **nothing on the SDUI path has ever
|
|
125
|
+
* read a registration's `defaultProps`**. `SchemaRenderer` does not; the one
|
|
126
|
+
* consumer in the tree, `WidgetRegistry.ts`, WRITES manifest defaults INTO the
|
|
127
|
+
* registry rather than reading them back out. So `pie-chart`, `donut-chart`,
|
|
128
|
+
* `radar-chart` and `scatter-chart` all arrived here with no family at all and
|
|
129
|
+
* fell to `AdvancedChartImpl`'s `'bar'` default: valid data, a confidently
|
|
130
|
+
* wrong picture, and no refusal that could fire. Ruled route C (director seat,
|
|
131
|
+
* 2026-09-06, on maintainer authorisation): derive the family from the
|
|
132
|
+
* schema's own `type`, and the inert `defaultProps` go with it — a second
|
|
133
|
+
* declaration nothing reads is the `AGENTS.md` #0.1 hazard, and leaving it
|
|
134
|
+
* beside a derivation that works would fossilize exactly the wrong convention.
|
|
135
|
+
*
|
|
136
|
+
* ## Why a table and not a `-chart` suffix rule
|
|
137
|
+
*
|
|
138
|
+
* A suffix rule accepts the whole cross product of {@link RENDERABLE} — it
|
|
139
|
+
* would answer `'funnel'` for `type: 'funnel-chart'`, a keyword this package
|
|
140
|
+
* does not register and the SDUI path therefore never resolves. That answer is
|
|
141
|
+
* unreachable today and would silently become load-bearing the day someone
|
|
142
|
+
* registers the keyword with a different family in mind. The table names
|
|
143
|
+
* exactly the keywords that exist, and
|
|
144
|
+
* `__tests__/chart-family-from-type-7401.test.tsx` pins it against the live
|
|
145
|
+
* registry in both directions, so adding a registration without a family entry
|
|
146
|
+
* (or an entry without a registration) is what goes red.
|
|
147
|
+
*
|
|
148
|
+
* ⛔ `bar-chart` is deliberately ABSENT: it is registered to
|
|
149
|
+
* `ChartBarRenderer`, a different component that never calls this function.
|
|
150
|
+
* An entry for it would be inert in precisely the way this card removed.
|
|
151
|
+
*/
|
|
152
|
+
export declare const CHART_TYPE_KEYWORD_FAMILIES: ReadonlyMap<string, ChartFamily>;
|
|
153
|
+
/**
|
|
154
|
+
* The family a registered chart-type keyword names, or `undefined` for a
|
|
155
|
+
* `type` that is not one of them.
|
|
156
|
+
*
|
|
157
|
+
* `undefined` is the honest answer for every other discriminator that reaches
|
|
158
|
+
* a chart — `object-chart`, `chart`, a dashboard widget's own type — and the
|
|
159
|
+
* caller's own default is a better answer than a guess.
|
|
160
|
+
*/
|
|
161
|
+
export declare function familyFromComponentType(rawType: string | undefined): ChartFamily | undefined;
|
|
92
162
|
export type AnyRec = Record<string, any>;
|
|
93
163
|
/** A y-axis (or the x-axis) after normalization — spec `ChartAxis`, resolved. */
|
|
94
164
|
export interface NormalizedAxis {
|
|
@@ -130,12 +200,28 @@ export interface NormalizedSeries {
|
|
|
130
200
|
color?: string;
|
|
131
201
|
}
|
|
132
202
|
export interface NormalizedChartSchema {
|
|
133
|
-
|
|
203
|
+
/**
|
|
204
|
+
* The chart family the schema names, as named: `chartType`, else `specType`,
|
|
205
|
+
* else a bare `type` that is a spec family, else a registered keyword's family
|
|
206
|
+
* (objectui#11520). It is NOT narrowed to the families this renderer draws:
|
|
207
|
+
* `AdvancedChartImpl`'s family dispatch decides the form (a chart, the number
|
|
208
|
+
* card, the tabular notice, or a notice naming the value), so a family this
|
|
209
|
+
* module dropped could only ever reach that dispatch as no family at all.
|
|
210
|
+
*
|
|
211
|
+
* Typed as the vocabulary the faces DECLARE ({@link DeclaredChartFamily}),
|
|
212
|
+
* not as `string`, so a misspelled family is a compile error for every
|
|
213
|
+
* producer. A value outside it can still arrive in unvalidated JSON; see the
|
|
214
|
+
* JSON-boundary cast in {@link normalizeChartSchema}.
|
|
215
|
+
*/
|
|
216
|
+
chartType?: DeclaredChartFamily;
|
|
134
217
|
xAxisKey?: string;
|
|
135
218
|
series?: NormalizedSeries[];
|
|
136
219
|
/** X-axis presentation config (its `field` is hoisted to `xAxisKey`). */
|
|
137
220
|
xAxis?: NormalizedAxis;
|
|
138
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Y-axes, in declaration order. Index 0 is the primary axis; the side each
|
|
223
|
+
* entry is drawn on is {@link placeYAxes}'s answer, not its index.
|
|
224
|
+
*/
|
|
139
225
|
yAxes?: NormalizedAxis[];
|
|
140
226
|
showLegend?: boolean;
|
|
141
227
|
showDataLabels?: boolean;
|
|
@@ -148,12 +234,129 @@ export interface NormalizedChartSchema {
|
|
|
148
234
|
annotations?: AnyRec[];
|
|
149
235
|
interaction?: AnyRec;
|
|
150
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* The two value-axis slots a cartesian chart draws, named in the spec's own
|
|
239
|
+
* `ChartSeries.yAxis` vocabulary: a series binds to a slot by writing
|
|
240
|
+
* `yAxis: 'left' | 'right'`, and `'left'` is the spec default.
|
|
241
|
+
*
|
|
242
|
+
* On a chart whose value axes run up its side (bar, line, area, combo,
|
|
243
|
+
* scatter) the slot IS the side it is drawn on. On `horizontal-bar` the value
|
|
244
|
+
* axes run across the plot, so the chart is the vertical one transposed: the
|
|
245
|
+
* `'left'` slot is drawn along the bottom and the `'right'` slot along the
|
|
246
|
+
* top — the same swap `placeXAxis` reads for the `xAxis` object there.
|
|
247
|
+
*/
|
|
248
|
+
export type ValueAxisSlot = 'left' | 'right';
|
|
249
|
+
/** A `yAxis` entry whose `position` was not honoured, and why. */
|
|
250
|
+
export interface YAxisPositionNote {
|
|
251
|
+
/** Index of the entry in `yAxis`. */
|
|
252
|
+
index: number;
|
|
253
|
+
/** The side it named. */
|
|
254
|
+
position: NonNullable<NormalizedAxis['position']>;
|
|
255
|
+
/**
|
|
256
|
+
* `'side'` — a side a value axis of this chart cannot take (`top` /
|
|
257
|
+
* `bottom` up the side of the plot; `left` / `right` across it).
|
|
258
|
+
* `'taken'` — an open side the first entry already holds.
|
|
259
|
+
*/
|
|
260
|
+
reason: 'side' | 'taken';
|
|
261
|
+
/** The slot the entry was drawn in instead. */
|
|
262
|
+
drawn: ValueAxisSlot;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* A `yAxis` entry drawn on no axis — every entry after the ones the chart
|
|
266
|
+
* places: after the second (objectui#10691), or after the first on `scatter`,
|
|
267
|
+
* which draws one value axis (objectui#10721). The spec's `ChartConfig.yAxis`
|
|
268
|
+
* is an uncapped list, so such an entry validates; a chart draws at most two
|
|
269
|
+
* value axes, one per slot.
|
|
270
|
+
*/
|
|
271
|
+
export interface YAxisUndrawnNote {
|
|
272
|
+
/** Index of the entry in `yAxis` — 2 or more; 1 or more on `scatter`. */
|
|
273
|
+
index: number;
|
|
274
|
+
/**
|
|
275
|
+
* The slot a series derived from the entry binds to (the chart declares
|
|
276
|
+
* neither `series` nor `categories`), and so the axis its `field` is
|
|
277
|
+
* plotted against. On `scatter`, the one slot the chart draws.
|
|
278
|
+
*/
|
|
279
|
+
boundTo: ValueAxisSlot;
|
|
280
|
+
}
|
|
281
|
+
export interface YAxisPlacement {
|
|
282
|
+
/** Index of the `yAxis` entry drawn in each slot; absent when none is. */
|
|
283
|
+
left?: number;
|
|
284
|
+
right?: number;
|
|
285
|
+
/**
|
|
286
|
+
* The slot of each placed entry, by index (the first two entries; the first
|
|
287
|
+
* on `scatter`).
|
|
288
|
+
*/
|
|
289
|
+
slotOf: ValueAxisSlot[];
|
|
290
|
+
notes: YAxisPositionNote[];
|
|
291
|
+
/** Every entry after the placed ones, in index order: drawn on no axis. */
|
|
292
|
+
undrawn: YAxisUndrawnNote[];
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Where each `yAxis` entry is drawn, read from its `position`
|
|
296
|
+
* (objectui#10654, the y-side twin of objectui#10587).
|
|
297
|
+
*
|
|
298
|
+
* The ONE place a y side is resolved: `normalizeChartSchema` binds the series
|
|
299
|
+
* it derives from the entries with it, and `AdvancedChartImpl` places the
|
|
300
|
+
* axes and writes the notes from the same answer, so a derived series always
|
|
301
|
+
* plots against its own entry's axis.
|
|
302
|
+
*
|
|
303
|
+
* Only the first two entries are placed — a chart draws at most two value
|
|
304
|
+
* axes, one per slot — and on `scatter` only the first: it draws one y axis,
|
|
305
|
+
* the primary's (objectui#10721). The rule, in order:
|
|
306
|
+
*
|
|
307
|
+
* 1. An entry whose `position` names a side a value axis of this chart
|
|
308
|
+
* cannot take is REFUSED: it is placed as if it named no side, and the
|
|
309
|
+
* chart carries a note naming `yAxis[N].position`. ⛔ Never mapped to a
|
|
310
|
+
* "nearest" open side — `top` names no side of an axis that runs up the
|
|
311
|
+
* plot.
|
|
312
|
+
* 2. An entry that names an open side is drawn there.
|
|
313
|
+
* 3. When BOTH entries name the same side, the first keeps it —
|
|
314
|
+
* `yAxis[0]` is the primary axis, the one declaration order already
|
|
315
|
+
* makes primary — and the second is drawn on the other side with a note
|
|
316
|
+
* naming `yAxis[1].position`.
|
|
317
|
+
* 4. An entry that names no side takes the side the other entry left free;
|
|
318
|
+
* with neither naming one, the first is drawn in the `'left'` slot and
|
|
319
|
+
* the second in the `'right'` slot, exactly as before `position` was read.
|
|
320
|
+
*
|
|
321
|
+
* Every entry after the placed ones is listed in `undrawn` (objectui#10691,
|
|
322
|
+
* and objectui#10721 for `scatter`): it is drawn on no axis, so none of its
|
|
323
|
+
* keys — `position` included — is read, and the chart carries a note naming
|
|
324
|
+
* `yAxis[N]`. A series derived from it binds to the `'right'` slot, as it did
|
|
325
|
+
* before this list existed; on `scatter` to the one slot the chart draws,
|
|
326
|
+
* because a scatter reads no series binding and measures every series it
|
|
327
|
+
* plots against that axis. ⛔ The count is not narrowed: the spec declares
|
|
328
|
+
* `yAxis` uncapped, so the entry stays valid and the note is the answer.
|
|
329
|
+
*
|
|
330
|
+
* `chartType` is the family the chart is drawn as, and every caller passes
|
|
331
|
+
* its own, so the slice above is expressed here once rather than at each call
|
|
332
|
+
* site. On `horizontal-bar` the value axes run across the plot (see
|
|
333
|
+
* {@link ValueAxisSlot}): there `bottom` / `top` are the open sides.
|
|
334
|
+
*/
|
|
335
|
+
export declare function placeYAxes(yAxes: readonly NormalizedAxis[] | undefined, chartType: string | undefined): YAxisPlacement;
|
|
151
336
|
/**
|
|
152
337
|
* Translate a chart schema — spec shape, internal shape, or a mix — into the
|
|
153
338
|
* renderer's internal contract. Only keys that resolve to something are
|
|
154
339
|
* present on the result, so callers can spread it over their own defaults.
|
|
340
|
+
*
|
|
341
|
+
* @param language the VIEWER's active language, for every `I18nLabel` slot this
|
|
342
|
+
* resolves — the chart's `title` / `subtitle` / `description`, an axis
|
|
343
|
+
* `title`, and a series `label`. Pure on purpose: this module cannot call a
|
|
344
|
+
* hook, so a React caller reads the language once
|
|
345
|
+
* (`useObjectTranslation().language`) and hands it down. See {@link label}.
|
|
346
|
+
*
|
|
347
|
+
* ⚠️ OMITTING IT IS NOT NEUTRAL. `pickLocalized` reads an absent language as
|
|
348
|
+
* `'en'`, so a locale map resolves through `default` -> `en` -> first value.
|
|
349
|
+
* That is the right answer for a caller with no viewer (a build-time or
|
|
350
|
+
* server-side normalisation) and the WRONG one for a rendering caller — which
|
|
351
|
+
* is why `ChartRenderer` passes it. A caller that reads only structural keys
|
|
352
|
+
* off the result (`resolveChartCategoryField` reads `xAxisKey` and nothing
|
|
353
|
+
* else) resolves no label at all and may omit it.
|
|
354
|
+
*
|
|
355
|
+
* The parameter is optional so that every existing caller keeps compiling and
|
|
356
|
+
* every non-label key keeps its byte-for-byte behaviour; it is NOT optional
|
|
357
|
+
* in the sense of "safe to skip when a heading is on screen".
|
|
155
358
|
*/
|
|
156
|
-
export declare function normalizeChartSchema(schema: unknown): NormalizedChartSchema;
|
|
359
|
+
export declare function normalizeChartSchema(schema: unknown, language?: string | null): NormalizedChartSchema;
|
|
157
360
|
/**
|
|
158
361
|
* Which family an un-annotated series takes when the chart is drawn as a combo,
|
|
159
362
|
* or `undefined` when the chart's own family has no per-series meaning.
|
|
@@ -183,10 +386,11 @@ export declare function comboBaseFamily(chartType: string | undefined): SeriesFa
|
|
|
183
386
|
* same family keeps its own family, so nothing that renders correctly today
|
|
184
387
|
* changes; and an explicit `combo` is returned untouched.
|
|
185
388
|
*
|
|
186
|
-
* Pass the chart's EFFECTIVE family
|
|
187
|
-
*
|
|
389
|
+
* Pass the chart's EFFECTIVE family — the answer depends on what an
|
|
390
|
+
* un-annotated series would otherwise have drawn. A chart that names no family
|
|
391
|
+
* gets `undefined` back: there is no default family to widen (objectui#11520).
|
|
188
392
|
*/
|
|
189
|
-
export declare function effectiveChartFamily<T extends
|
|
393
|
+
export declare function effectiveChartFamily<T extends DeclaredChartFamily | undefined>(chartType: T, series: readonly Pick<NormalizedSeries, 'chartType'>[] | undefined): T | 'combo';
|
|
190
394
|
/**
|
|
191
395
|
* Build a tick formatter from a spec `ChartAxis.format` string.
|
|
192
396
|
*
|
|
@@ -196,8 +400,15 @@ export declare function effectiveChartFamily<T extends ChartFamily | undefined>(
|
|
|
196
400
|
* places — and drives `Intl.NumberFormat`, which is already loaded and
|
|
197
401
|
* locale-aware. An unrecognized format returns `undefined`, so the caller
|
|
198
402
|
* keeps its own default formatting rather than rendering something wrong.
|
|
403
|
+
*
|
|
404
|
+
* `locale` is the chart's DISPLAY locale (`useDisplayLocale()` in the caller)
|
|
405
|
+
* and it is REQUIRED on purpose: this is a plain function with no hook to read
|
|
406
|
+
* it from, and the version that took no locale handed `Intl` an explicit
|
|
407
|
+
* `undefined` — the MACHINE's locale, neither of the repo's two locale
|
|
408
|
+
* channels (objectui#9909). A required parameter is the one shape a caller
|
|
409
|
+
* cannot forget.
|
|
199
410
|
*/
|
|
200
|
-
export declare function formatterFor(format: string | undefined): ((value: any) => string) | undefined;
|
|
411
|
+
export declare function formatterFor(format: string | undefined, locale: string): ((value: any) => string) | undefined;
|
|
201
412
|
export declare function ticksFor(axis: NormalizedAxis | undefined, values: number[]): number[] | undefined;
|
|
202
413
|
/**
|
|
203
414
|
* Recharts `domain` for an axis, or `undefined` to keep the auto domain.
|