@object-ui/plugin-charts 17.6.0 → 18.0.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 +3254 -0
- package/README.md +32 -17
- package/dist/AdvancedChartImpl.d.ts +29 -11
- package/dist/ChartRenderer.d.ts +19 -2
- package/dist/ObjectChart.d.ts +136 -4
- package/dist/index.d.ts +67 -7
- package/dist/index.js +1753 -1066
- package/dist/index.umd.cjs +2 -2
- package/dist/normalizeChartSchema.d.ts +242 -14
- package/dist/types.d.ts +31 -28
- package/package.json +13 -12
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=O(e);if(t)return t;if(D(e))return Object.values(e).find(e=>typeof e==`string`&&e)}function y(e){if(!D(e))return;let t={},n=O(e.field);n&&(t.field=n);let r=O(e.format);r&&(t.format=r);let i=k(e.min);i!==void 0&&(t.min=i);let a=k(e.max);a!==void 0&&(t.max=a);let o=k(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=O(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 b(e){if(!D(e)){let t=O(e);return t?{dataKey:t}:void 0}let t=O(e.dataKey)??O(e.name);if(!t)return;let n={dataKey:t},r=v(e.label);r&&(n.label=r);let i=O(e.chartType)??O(e.type);(i===`bar`||i===`line`||i===`area`)&&(n.chartType=i);let a=O(e.variant);(a===`comparison`||a===`current`||a===`primary`)&&(n.variant=a);let o=k(e.opacity);o!==void 0&&(n.opacity=o);let s=O(e.dashArray);s&&(n.dashArray=s);let c=O(e.stack);c&&(n.stack=c);let l=O(e.yAxis);(l===`left`||l===`right`)&&(n.yAxis=l);let u=O(e.color);return u&&(n.color=u),n}function x(e){if(!D(e))return{};let t={},n=O(e.type),r=O(e.chartType)??O(e.specType)??(n&&E.has(n)?n:void 0);r&&w.has(r)&&(t.chartType=r);let i=e.xAxis,a=y(i);a&&(a.format||a.title||a.showGridLines!==void 0)&&(t.xAxis=a);let o=O(e.xAxisKey)??a?.field??O(i);o&&(t.xAxisKey=o);let s=(Array.isArray(e.yAxis)?e.yAxis:e.yAxis===void 0?[]:[e.yAxis]).map(e=>y(e)??(O(e)?{field:O(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(b).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=k(e.height);return f!==void 0&&f>0&&(t.height=f),Array.isArray(e.annotations)&&e.annotations.length&&(t.annotations=e.annotations.filter(D)),D(e.interaction)&&(t.interaction=e.interaction),t}function ee(e){if(e===`bar`||e===`column`)return`bar`;if(e===`line`)return`line`;if(e===`area`)return`area`}function S(e,t){if(e===`combo`)return`combo`;let n=ee(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 C(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 te(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>A)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 ne(e){if(!e)return;let{min:t,max:n}=e;if(t!==void 0||n!==void 0)return[t??`auto`,n??`auto`]}var w,re,T,E,D,O,k,A,ie=h((()=>{w=new Set([`bar`,`column`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`radar`,`scatter`,`treemap`,`sankey`,`combo`]),re=new Set([`gauge`,`solid-gauge`,`metric`,`kpi`,`bullet`]),T=new Set([`table`,`pivot`]),E=new Set([...w,...re,...T]),D=e=>!!e&&typeof e==`object`&&!Array.isArray(e),O=e=>typeof e==`string`&&e?e:void 0,k=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,A=200})),j=g({default:()=>P});function M(e,t=14){return e.length>t?`${e.slice(0,t-1)}…`:e}function N({x:e,y:t,payload:n}){let r=String(n?.value??``),a=M(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 P({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)(N,{}):{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 F=h((()=>{}));function I(){let e=n.useContext(U);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function L({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:ae},...g?{}:{minWidth:0},...c};return(0,i.jsx)(U.Provider,{value:{config:o},children:(0,i.jsxs)(`div`,{ref:f,"data-slot":`chart`,"data-chart":d,className:V(`block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground`,t),style:_,...l,children:[(0,i.jsx)(oe,{id:d,config:o}),(0,i.jsx)(a.ResponsiveContainer,{width:`100%`,height:`100%`,...h?{}:{minHeight:ae},children:r},p)]})})}function R({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}=I(),g=n.useMemo(()=>{if(o||!t?.length)return null;let[e]=t,n=`${m||e?.dataKey||e?.name||`value`}`,r=B(h,e,n),a=!m&&typeof c==`string`?h[c]?.label||c:r?.label;return l?(0,i.jsx)(`div`,{className:V(`font-medium`,u),children:l(a,t)}):a?(0,i.jsx)(`div`,{className:V(`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:V(`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=B(h,e,n),o=f||e.payload.fill||e.color;return(0,i.jsx)(`div`,{className:V(`[&>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:V(`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:V(`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 z({className:e,hideIcon:t=!1,payload:n,verticalAlign:r=`bottom`,nameKey:a}){let{config:o}=I();return n?.length?(0,i.jsx)(`div`,{className:V(`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=B(o,e,n);return(0,i.jsxs)(`div`,{className:V(`[&>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 B(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 V,H,U,ae,oe,W,G,se=h((()=>{V=(...e)=>e.filter(Boolean).join(` `),H={light:``,dark:`.dark`},U=n.createContext(null),ae=280,oe=({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(H).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(C)?e.slice(14):e;return de.get(t)}function te(e){return e.length>0&&e.every(e=>(0,t.isIntegerAggregate)(e.aggregate))}function ne(e,t){if(typeof e==`string`||w(e))return(0,i.pickLocalized)(e,t)||void 0}function re(e,t){if(!w(e))return;let n={},r=T(e.field);r&&(n.field=r);let i=T(e.format);i&&(n.format=i);let a=E(e.min);a!==void 0&&(n.min=a);let o=E(e.max);o!==void 0&&(n.max=o);let s=E(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=T(e.position);(c===`left`||c===`right`||c===`top`||c===`bottom`)&&(n.position=c);let l=ne(e.title,t);return l&&(n.title=l),n}function ie(e,t){if(!w(e)){let t=T(e);return t?{dataKey:t}:void 0}let n=T(e.dataKey)??T(e.name);if(!n)return;let r={dataKey:n},i=ne(e.label,t);i&&(r.label=i);let a=T(e.chartType)??T(e.type);(a===`bar`||a===`line`||a===`area`)&&(r.chartType=a);let o=T(e.variant);(o===`comparison`||o===`current`||o===`primary`)&&(r.variant=o);let s=E(e.opacity);s!==void 0&&(r.opacity=s);let c=T(e.dashArray);c&&(r.dashArray=c);let l=T(e.stack);l&&(r.stack=l);let u=T(e.yAxis);(u===`left`||u===`right`)&&(r.yAxis=u);let d=T(e.color);d&&(r.color=d);let f=T(e.aggregate);return f&&(r.aggregate=f),r}function ae(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 oe(e,t){if(!w(e))return{};let n={},r=T(e.type),i=T(e.chartType)??T(e.specType)??(r&&S.has(r)?r:void 0)??ee(r);i&&(n.chartType=i);let a=e.xAxis,o=re(a,t);o&&Object.keys(o).some(e=>e!==`field`)&&(n.xAxis=o);let s=T(e.xAxisKey)??o?.field??T(a);s&&(n.xAxisKey=s);let c=(Array.isArray(e.yAxis)?e.yAxis:e.yAxis===void 0?[]:[e.yAxis]).map(e=>re(e,t)??(T(e)?{field:T(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=>ie(e,t)).filter(e=>!!e);if(!l?.length){let e=ae(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=ne(e.title,t);u&&(n.title=u);let d=ne(e.subtitle,t);d&&(n.subtitle=d);let f=ne(e.description,t);f&&(n.description=f);let p=E(e.height);return p!==void 0&&p>0&&(n.height=p),Array.isArray(e.annotations)&&e.annotations.length&&(n.annotations=e.annotations.filter(w)),w(e.interaction)&&(n.interaction=e.interaction),n}function se(e){if(e===`bar`||e===`column`)return`bar`;if(e===`line`)return`line`;if(e===`area`)return`area`}function v(e,t){if(e===`combo`)return`combo`;let n=se(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 ce(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 b(e){if(!e)return;let{min:t,max:n}=e;if(t!==void 0||n!==void 0)return[t??`auto`,n??`auto`]}var le,x,ue,S,de,C,w,T,E,D,O=h((()=>{le=new Set([`bar`,`column`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`radar`,`scatter`,`treemap`,`sankey`,`combo`]),x=new Set([`gauge`,`solid-gauge`,`metric`,`kpi`,`bullet`]),ue=new Set([`table`,`pivot`]),S=new Set([...le,...x,...ue]),de=new Map([[`chart:bar`,`bar`]]),C=`plugin-charts:`,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:()=>me});function fe(e,t=14){return e.length>t?`${e.slice(0,t-1)}…`:e}function pe({x:e,y:t,payload:n}){let r=String(n?.value??``),i=fe(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 me({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)(pe,{}):{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 he=h((()=>{}));function ge(){let e=n.useContext(F);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function A({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:I},...g?{}:{minWidth:0},...c};return(0,a.jsx)(F.Provider,{value:{config:i},children:(0,a.jsxs)(`div`,{ref:f,"data-slot":`chart`,"data-chart":d,className:N(`block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground`,t),style:_,...l,children:[(0,a.jsx)(ve,{id:d,config:i}),(0,a.jsx)(o.ResponsiveContainer,{width:`100%`,height:`100%`,...h?{}:{minHeight:I},children:r},p)]})})}function j({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}=ge(),_=(0,i.useDisplayLocale)(),ee=n.useMemo(()=>{if(s||!t?.length)return null;let[e]=t,n=`${h||e?.dataKey||e?.name||`value`}`,r=M(g,e,n),i=!h&&typeof l==`string`?g[l]?.label||l:r?.label;return u?(0,a.jsx)(`div`,{className:N(`font-medium`,d),children:u(i,t)}):i?(0,a.jsx)(`div`,{className:N(`font-medium`,d),children:i}):null},[l,u,t,s,d,g,h]);if(!e||!t?.length)return null;let te=t.length===1&&o!==`dot`;return(0,a.jsxs)(`div`,{className:N(`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:[te?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=M(g,e,n),i=p||e.payload.fill||e.color;return(0,a.jsx)(`div`,{className:N(`[&>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:N(`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`:``,te&&o===`dashed`?`my-0.5`:``),style:{"--color-bg":i,"--color-border":i}}),(0,a.jsxs)(`div`,{className:N(`flex flex-1 justify-between leading-none`,te?`items-end`:`items-center`),children:[(0,a.jsxs)(`div`,{className:`grid gap-1.5`,children:[te?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 _e({className:e,hideIcon:t=!1,payload:n,verticalAlign:r=`bottom`,nameKey:i}){let{config:o}=ge();return n?.length?(0,a.jsx)(`div`,{className:N(`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=M(o,e,n);return(0,a.jsxs)(`div`,{className:N(`[&>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 M(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 N,P,F,I,ve,L,R,ye=h((()=>{N=(...e)=>e.filter(Boolean).join(` `),P={light:``,dark:`.dark`},F=n.createContext(null),I=280,ve=({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(P).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},W=a.Tooltip,G=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:()=>be});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:y,subtitle:b,description:x,height:E,annotations:D,interaction:O}){let k=e===`column`?`bar`:e,A=S(k,c),ie=ee(k),j=Array.isArray(r)?r:[],M=m===!1?{isAnimationActive:!1}:{},N={...m===!1?{disableSettleRemount:!0}:{},...E?{style:{height:E}}:{},...x?{role:`img`,"aria-label":x}:{}},[P,F]=n.useState(!1),I=n.useRef(null),B=n.useCallback(e=>(...t)=>{let n=Te(t);n!==void 0&&(I.current={gesture:n,dataKey:String(e.dataKey)})},[]),V=p?e=>({onClick:B(e)}):()=>({}),H=n.useCallback((e,n,r)=>{if(!p||!e)return;let i=e.activeTooltipIndex??e.activeIndex,a=i==null?NaN:Number(i),o=Number.isInteger(a)&&a>=0?j[a]:void 0,s=I.current;I.current=null;let l=we(n),u=s!=null&&l!==void 0&&s.gesture===l;if(r&&!u)return;let d=u?s.dataKey:Ce(e.activeDataKey,c),f=d!=null&&o?o[d]:void 0;p({category:e.activeLabel==null?void 0:String(e.activeLabel),categoryId:(0,t.chartRowBucketId)(o),series:d,seriesLabel:Ee(d,c),value:typeof f==`number`?f:void 0})},[p,j,c]),U=n.useCallback((e,t)=>{H(e,t,!1)},[H]),ae=n.useCallback((e,t)=>{H(e,t,!0)},[H]),oe=n.useCallback(e=>{if(!p||!e)return;let n=e.payload?.[s],r=c[0]?.dataKey||`value`;p({category:n==null?void 0:String(n),categoryId:(0,t.chartRowBucketId)(e.payload),series:r,seriesLabel:Ee(r,c),value:typeof e.payload?.[r]==`number`?e.payload[r]:void 0})},[p,s,c]),se=p?{onClick:U,style:{cursor:`pointer`}}:{},ce=p?{onClick:ae}:{},fe=p?e=>({...V(e),cursor:`pointer`}):()=>({}),pe=p?{onClick:oe,style:{cursor:`pointer`}}:{},ge=n.useCallback((e,t,n)=>d&&d[e==null?``:String(e)]||n[t%n.length],[d]),_e=n.useCallback(e=>{if(!p)return;let t=le(e,s,c);t&&p(t)},[p,s,c]),ve=n.useCallback(e=>{if(!p)return;let t=ue(e,c);t&&p(t)},[p,c]),ye=n.useCallback(e=>{if(!p)return;let t=de(e,c);t&&p(t)},[p,c]),be=p?{onClick:_e,cursor:`pointer`}:{},Se=p?{onClick:ve,style:{cursor:`pointer`}}:{},De=p?{onClick:ye,style:{cursor:`pointer`}}:{};n.useEffect(()=>{let e=()=>F(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let Oe={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}[A]||a.BarChart,ke=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=(j.length>1?Math.abs(new Date(String(j[j.length-1][s]??``)).getTime()-new Date(String(j[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 P&&n.length>8?n.slice(0,8)+`…`:n},[j,s,P,o]),Ae=n.useMemo(()=>j.some(e=>String(e[s]||``).length>5),[j,s]),J=()=>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))`],Y=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)}},[]),X=g?.[0],Z=g&&g.length>1?g[1]:X?.position===`right`?X:void 0,Q=!!g&&g.length>1,je=n.useMemo(()=>C(h?.format)??ke,[h?.format,ke]),Me=n.useMemo(()=>C(X?.format)??Y,[X?.format,Y]),Ne=n.useMemo(()=>C(Z?.format)??Y,[Z?.format,Y]),Pe=n.useCallback(e=>{let t=c.filter(t=>Q?(t.yAxis===`right`?`right`:`left`)===e:e===`left`).map(e=>e.dataKey),n=[];for(let e of j)for(let r of t){let t=Number(e?.[r]);Number.isFinite(t)&&n.push(t)}return n},[j,c,Q]),$=n.useCallback((e,t=`left`)=>{if(!e)return{};let n=ne(e),r=te(e,Pe(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`}}:{}}},[Pe]),Fe=X?.showGridLines!==!1,Ie={vertical:h?.showGridLines===!0,horizontal:Fe},Le=_!==!1,Re=n.useMemo(()=>{if(!Array.isArray(D)||D.length===0)return null;let e={solid:void 0,dashed:`4 4`,dotted:`1 4`};return D.map((t,n)=>{let r=t?.axis===`x`,o=K(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,...Q&&!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},...Q&&!r?{yAxisId:`left`}:{},stroke:o,strokeDasharray:s,...l},`ann-${n}`)})},[D,Q]),ze=O?.tooltips!==!1,Be=O?.brush===!0?(0,i.jsx)(a.Brush,{dataKey:s,height:24,travellerWidth:8,stroke:`hsl(var(--muted-foreground))`}):null,Ve=e=>v?(0,i.jsx)(a.LabelList,{position:`top`,className:`fill-foreground`,fontSize:11,...e?{formatter:e}:{}}):null,He=n.useMemo(()=>({tickLine:!1,tickMargin:10,axisLine:!1,interval:`preserveStartEnd`,minTickGap:P?32:48,tickFormatter:je,...h?.title?{label:{value:h.title,position:`insideBottom`,offset:-4}}:{},...!P&&Ae&&{angle:-35,textAnchor:`end`,height:60}}),[P,Ae,je,h?.title]);if(A&&re.has(A)){let e=c[0]?.dataKey||`value`,t=j[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(A&&T.has(A))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 “`,A,`” is tabular — render it with the data-table / pivot components; a chart block draws series charts.`]});if(A&&!w.has(A))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 “`,A,`” is not a spec chart type — nothing was drawn.`]});if(A===`pie`||A===`donut`){let e=A===`donut`?`52%`:0,t=J(),n={...o};return j.forEach((e,r)=>{let i=e?.[s];if(i==null||i===``)return;let a=String(i);n[a]||(n[a]={label:a,color:ge(i,r,t)})}),(0,i.jsx)(L,{config:n,className:l,...N,children:(0,i.jsxs)(a.PieChart,{children:[(0,i.jsx)(W,{cursor:!1,content:(0,i.jsx)(R,{hideLabel:!0})}),(0,i.jsx)(a.Pie,{data:j,dataKey:c[0]?.dataKey||`value`,nameKey:s||`name`,innerRadius:e,strokeWidth:5,paddingAngle:2,outerRadius:`85%`,...M,...pe,children:j.map((e,n)=>{let r=ge(e?.[s],n,t);return(0,i.jsx)(a.Cell,{fill:K(r)},`cell-${n}`)})}),Le?(0,i.jsx)(G,{verticalAlign:`bottom`,wrapperStyle:{fontSize:P?`11px`:`12px`,paddingTop:`8px`},content:(0,i.jsx)(z,{nameKey:s,className:`flex-wrap`})}):null]})})}if(A===`funnel`){let e=c[0]?.dataKey||`value`,n=J(),r=p?n=>{n&&p({category:n?.payload?.[s]??n?.[s],categoryId:(0,t.chartRowBucketId)(n?.payload)??(0,t.chartRowBucketId)(n),value:n?.payload?.[e]??n?.[e]})}:void 0,u=r?{onClick:r,style:{cursor:`pointer`}}:{},d=(0,t.buildCategoryRank)(f),m=d?[...j].sort((e,t)=>(d.get(String(e?.[s]??``))??2**53-1)-(d.get(String(t?.[s]??``))??2**53-1)):[...j].sort((t,n)=>{let r=Number(t?.[e]??0);return Number(n?.[e]??0)-r});return(0,i.jsx)(L,{config:o,className:l,...N,children:(0,i.jsxs)(a.FunnelChart,{children:[(0,i.jsx)(W,{content:(0,i.jsx)(R,{})}),(0,i.jsxs)(a.Funnel,{dataKey:e,data:m,nameKey:s,...M,...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:K(n[t%n.length])},`funnel-cell-${t}`))]})]})})}if(A===`treemap`){let e=c[0]?.dataKey||`value`,t=J(),n=j.map((n,r)=>({name:String(n?.[s]??``),size:Number(n?.[e])||0,fill:K(t[r%t.length])}));return(0,i.jsx)(L,{config:o,className:l,...N,children:(0,i.jsx)(a.Treemap,{data:n,dataKey:`size`,nameKey:`name`,...M,content:(0,i.jsx)(me,{}),...Se,children:(0,i.jsx)(a.Tooltip,{})})})}if(A===`sankey`){let e=c[0]?.dataKey||`value`,t=c[0]?.label||e,n=j.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)(L,{config:o,className:l,...N,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))`},...De,children:(0,i.jsx)(a.Tooltip,{})})})}if(A===`radar`)return(0,i.jsx)(L,{config:o,className:l,...N,children:(0,i.jsxs)(a.RadarChart,{data:j,children:[(0,i.jsx)(a.PolarGrid,{}),(0,i.jsx)(a.PolarAngleAxis,{dataKey:s}),(0,i.jsx)(a.PolarRadiusAxis,{}),(0,i.jsx)(W,{content:(0,i.jsx)(R,{})}),(0,i.jsx)(G,{content:(0,i.jsx)(z,{}),...P&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),c.map(e=>{let t=K(o[e.dataKey]?.color||xe);return(0,i.jsx)(a.Radar,{dataKey:e.dataKey,stroke:t,fill:t,fillOpacity:.6,...M},e.dataKey)})]})});if(A===`scatter`)return(0,i.jsx)(L,{config:o,className:l,...N,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:P?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:Y,width:48}),(0,i.jsx)(a.ZAxis,{type:`number`,range:[60,400]}),(0,i.jsx)(W,{content:(0,i.jsx)(R,{})}),(0,i.jsx)(G,{content:(0,i.jsx)(z,{}),...P&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),c.map((e,t)=>{let n=J(),r=K(o[e.dataKey]?.color||n[t%n.length]),s=q(e,`scatter`);return(0,i.jsx)(a.Scatter,{name:o[e.dataKey]?.label||e.dataKey,data:j,fill:r,fillOpacity:s?.fillOpacity,...M,...be},e.dataKey)})]})});if(A===`combo`)return(0,i.jsx)(he,{title:y,subtitle:b,children:(0,i.jsx)(L,{config:o,className:l,...N,children:(0,i.jsxs)(a.ComposedChart,{data:j,...ce,children:[(0,i.jsx)(a.CartesianGrid,{...Ie}),(0,i.jsx)(a.XAxis,{dataKey:s,...He}),(0,i.jsx)(a.YAxis,{yAxisId:`left`,tickLine:!1,axisLine:!1,tickFormatter:Me,width:48,...$(X)}),(0,i.jsx)(a.YAxis,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:Ne,width:48,...$(Z,`right`)}),ze?(0,i.jsx)(W,{content:(0,i.jsx)(R,{})}):null,Le?(0,i.jsx)(G,{content:(0,i.jsx)(z,{}),...P&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Re,Be,c.map((e,t)=>{let n=K(o[e.dataKey]?.color||xe),r=e.chartType||ie||(t===0?`bar`:`line`),s=e.yAxis===`right`||e.yAxis===`left`?e.yAxis:ie||r===`bar`?`left`:`right`,c=q(e,r),l=e.stack?{stackId:String(e.stack)}:{},u=C((s===`right`?Z:X)?.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,...M,...fe(e),children:Ve(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,...M,...fe(e),children:Ve(u)},e.dataKey):(0,i.jsx)(a.Bar,{yAxisId:s,dataKey:e.dataKey,fill:n,radius:4,fillOpacity:c?.fillOpacity,...l,...M,...fe(e),children:Ve(u)},e.dataKey)})]})})});let Ue=A===`horizontal-bar`,We=J(),Ge=d?Object.values(d).map(e=>K(String(e))):[],Ke=Array.from(new Set([...We,...Ge,...c.map((e,t)=>K(o[e.dataKey]?.color||We[t%We.length]||xe))])),qe=e=>`g`+e.replace(/[^a-zA-Z0-9]/g,``);return(0,i.jsx)(he,{title:y,subtitle:b,children:(0,i.jsx)(L,{config:o,className:l,...N,children:(0,i.jsxs)(Oe,{data:j,layout:Ue?`vertical`:`horizontal`,...se,children:[(0,i.jsx)(`defs`,{children:Ke.map(e=>(0,i.jsxs)(n.Fragment,{children:[(0,i.jsxs)(`linearGradient`,{id:`bg-${qe(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-${qe(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})]})]},qe(e)))}),(0,i.jsx)(a.CartesianGrid,{...Ie}),Ue?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.XAxis,{type:`number`,tickLine:!1,axisLine:!1,tickFormatter:Me,...$(X)}),(0,i.jsx)(a.YAxis,{type:`category`,dataKey:s,tickLine:!1,axisLine:!1,width:Math.min(140,Math.max(60,Math.max(...j.map(e=>String(e[s]??``).length))*7)),tickFormatter:je})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.XAxis,{dataKey:s,...He}),(0,i.jsx)(a.YAxis,{...Q?{yAxisId:`left`}:{},tickLine:!1,axisLine:!1,tickFormatter:Me,width:48,...$(X)}),Q?(0,i.jsx)(a.YAxis,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:Ne,width:48,...$(Z,`right`)}):null]}),ze?(0,i.jsx)(W,{content:(0,i.jsx)(R,{})}):null,Le?(0,i.jsx)(G,{content:(0,i.jsx)(z,{}),...P&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Re,Be,c.map((e,t)=>{let n=J(),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=K(o[l.dataKey]?.color||n[u%n.length]||xe),f=Q?{yAxisId:e.yAxis===`right`?`right`:`left`}:{},p=e.stack?{stackId:String(e.stack)}:{},m=C((e.yAxis===`right`?Z:X)?.format);if(A===`bar`||A===`horizontal-bar`){let t=c.filter(e=>e.variant!==`comparison`).length===1&&!r&&c.length===1&&j.length>1,o=q(e,`bar`);return(0,i.jsxs)(a.Bar,{dataKey:e.dataKey,fill:`url(#bg-${qe(d)})`,radius:4,fillOpacity:o?.fillOpacity,...p,...f,...M,...V(e),children:[t&&j.map((e,t)=>(0,i.jsx)(a.Cell,{fill:`url(#bg-${qe(K(ge(e?.[s],t,n)))})`},`cell-${t}`)),Ve(m)]},e.dataKey)}if(A===`line`){let t=q(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,...M,...V(e),children:Ve(m)},e.dataKey)}if(A===`area`){let t=q(e,`area`);return(0,i.jsx)(a.Area,{type:`monotone`,dataKey:e.dataKey,fill:`url(#ag-${qe(d)})`,stroke:d,strokeWidth:2,fillOpacity:t?.fillOpacity??1,strokeOpacity:t?.strokeOpacity,strokeDasharray:t?.strokeDasharray,...p,...f,...M,...V(e),children:Ve(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 De.has(t)&&n.length>0&&!n.some(e=>typeof e==`object`&&!!e&&r in e)}function ve(e){let t=e.chartType===`column`?`bar`:e.chartType??`bar`,n=Array.isArray(e.data)?e.data:[];return Oe.has(t)&&n.length>0&&Array.isArray(e.series)&&e.series.length===0}function ye({code:e,className:t,children:n}){return(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 ${t??``}`,role:`status`,"data-chart-error":e,children:(0,i.jsx)(`span`,{children:n})})}function be(e){let t=_e(e),r=!t&&ve(e),a=e.xAxisKey??`name`,o=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 "${a}" — rendering an explanatory placeholder instead of an empty axis. Row keys: ${JSON.stringify(o)}. A dataset query must PROJECT the dimension it groups by (framework#4033).`)},[t,a,o]),n.useEffect(()=>{r&&console.warn(`[chart] no series to plot against the category axis "${a}" — rendering an explanatory placeholder instead of an empty frame. Row keys: ${JSON.stringify(o)}. 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,a,o]),t?(0,i.jsxs)(ye,{code:`missing-category-key`,className:e.className,children:[`This chart cannot plot its category axis: no row has a`,` `,(0,i.jsx)(`code`,{className:`font-mono`,children:a}),` field.`]}):r?(0,i.jsxs)(ye,{code:`no-plottable-series`,className:e.className,children:[`This chart cannot plot any series: no measure or group reached its`,` `,(0,i.jsx)(`code`,{className:`font-mono`,children:a}),` axis.`]}):(0,i.jsx)(ge,{...e})}var xe,Se,K,q,Ce,we,Te,Ee,De,Oe,ke=h((()=>{se(),fe(),ie(),xe=`hsl(var(--primary))`,Se={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`},K=e=>Se[e]||e,q=(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,Ce=(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)}},we=e=>{if(e&&typeof e==`object`&&`nativeEvent`in e)return e.nativeEvent},Te=e=>{for(let t=e.length-1;t>=0;--t){let n=we(e[t]);if(n!==void 0)return n}},Ee=(e,t)=>{if(e==null)return;let n=t.find(t=>String(t.dataKey)===e);return typeof n?.label==`string`?n.label:void 0},De=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`radar`,`funnel`,`combo`]),Oe=new Set([`bar`,`horizontal-bar`,`line`,`area`,`combo`])}));ie();var Ae=n.default.lazy(()=>Promise.resolve().then(()=>(F(),j))),J=n.default.lazy(()=>Promise.resolve().then(()=>(ke(),pe))),Y=({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)(Ae,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),X=({schema:e,onChartClick:t})=>{let a=n.default.useMemo(()=>{let t=x(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)(J,{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 Z(e){return e.field||e.function||`count`}var Q=`__comparison`;function je(e,t){let{field:n,function:r,groupBy:i}=t,a=Z(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 Me(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_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 r=e[n],i=String(r??``);return{...e,[n]:u.test(i)?i:(0,t.humanizeLabel)(i),[s]:r}})}var Ne=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,g]=(0,n.useState)([]),[_,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(()=>!(Array.isArray(a.data)&&a.data.length>0)&&(!!a.objectName||!!a.dataset)),[x,ee]=(0,n.useState)(null),[S,C]=(0,n.useState)(null),[te,ne]=(0,n.useState)(null),{openRecordList:w}=(0,o.useDrillNavigation)(),re=(0,c.useSafeTranslate)(),T=(0,n.useMemo)(()=>a.aggregate?JSON.stringify(a.aggregate):``,[a.aggregate]),E=(0,n.useMemo)(()=>a.filter?JSON.stringify(a.filter):``,[a.filter]),D=(0,n.useMemo)(()=>a.compareTo?JSON.stringify(a.compareTo):``,[a.compareTo]),O=(0,n.useMemo)(()=>a.dataset?JSON.stringify({d:a.dataset,dim:a.dimensions??[],val:a.values??[]}):``,[a.dataset,a.dimensions,a.values]),k=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||ne(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||ne({metaByPath:d,colorPath:o,fieldByDim:a.dataset&&Array.isArray(a.dimensions)?u:null})}catch{e||ne(null)}})(),()=>{e=!0}},[a.objectName,a.dataset,O,T,a.xAxisKey,f]);let{fieldOptionColors:A,dimensionLabels:ie}=(0,n.useMemo)(()=>{if(!te)return{fieldOptionColors:null,dimensionLabels:null};let{metaByPath:e,colorPath:n,fieldByDim:r}=te,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}},[te,m]),j=(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:Z(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=je(i,a.aggregate)),i}return[]},[a.objectName,T]),M=(0,o.useFilterScope)(),N=(0,n.useCallback)(async(e,n)=>{if(!e||!a.objectName&&!a.dataset){n.current&&b(!1);return}n.current&&(b(!0),ee(null));try{if(a.dataset&&typeof e.queryDataset==`function`){let r=(0,t.resolveFilterPlaceholders)(a.filter,M),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&&(g(Array.isArray(i?.rows)?i.rows:[]),v(Array.isArray(i?.fields)?i.fields:null));return}let r=(0,t.resolveFilterPlaceholders)(a.filter,M),i=a.compareTo,o=!!i&&k(a.chartType),s=o?(0,t.resolveContextTokens)((0,t.shiftFilterByCompareTo)(a.filter,i),M):null,[c,l]=await Promise.all([j(e,r),s?j(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=Z(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}${Q}`,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 Me(u,f,t,e,(e,t)=>m(a.objectName,f,e,t))}catch{}n.current&&g(u)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&ee(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&b(!1)}},[a.objectName,O,T,E,D,a.xAxisKey,a.chartType,j,M,m]);(0,n.useEffect)(()=>{let e={current:!0};return(a.objectName||a.dataset)&&!p&&!a.data?N(d,e):e.current&&b(!1),()=>{e.current=!1}},[a.objectName,O,d,p,a.data,E,T,D,N]);let P=p||a.data||h,F=Array.isArray(P)?P:[],I=a.drillDown,L=a.aggregate?.groupBy||a.xAxisKey,R=(0,n.useMemo)(()=>{if(!L)return new Map;let e=new Map,t=`__raw_${L}`;for(let n of F){let r=n?.[L];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[F,L]),z=(0,n.useMemo)(()=>{if(S)return{...a.filter||{},...(0,t.computeDrillFilter)(I,S,{groupByField:L})}},[S,I,L,E]),B=!l&&!!S&&!!a.objectName&&I?.target===`navigate`&&!!w;(0,n.useEffect)(()=>{B&&(w(a.objectName,z),C(null))},[B]);let V=a.compareTo,H=a.aggregate?Z(a.aggregate):void 0,U=H?`${H}${Q}`:void 0,ae=!!V&&k(a.chartType)&&!!U&&F.some(e=>e[U]!=null),oe=(0,n.useMemo)(()=>{let e=Array.isArray(a.series)?a.series:null;if(!ae)return e;let n=e||[{dataKey:H}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[(0,t.compareToTrendLabelKey)(V,a.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:U,label:r,variant:`comparison`}]},[ae,a.series,H,U,a.filter,V]),W=a.dataset?(0,t.buildChartSeries)((0,t.relabelDimensions)(F,ie),a.dimensions,a.values,_,{nullCategoryLabel:re(`chart.nullCategory`,`(None)`)}):null,G=W?{...a,data:W.data,xAxisKey:W.xAxisKey,series:W.series}:{...a,data:F,...oe?{series:oe}:{}},se=a.colors&&!Array.isArray(a.colors)&&typeof a.colors==`object`?a.colors:null,ce=Array.isArray(a.colors)?a.colors:void 0,le=A||se?{...A||{},...se||{}}:void 0,ue={...G,colors:ce,...le?{categoryColors:le}:{}};if(y&&F.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(x)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:x})]});if(!d&&a.objectName&&F.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 de=(0,t.isDrillEnabled)(I)?e=>{let t=e.category,n=t!=null&&R.has(String(t))?R.get(String(t)):t;C({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,fe=l??de,pe=!l&&S&&a.objectName&&!B?(()=>{let e=z??{},n=(0,t.resolveDrillTitle)(I,S,a.title||`Details`),c=I?.target??`drawer`,l={type:`object-data-table`,objectName:a.objectName,filter:e,pagination:!0,pageSize:I?.maxRows,columns:I?.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=w&&a.objectName?(0,i.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{w(a.objectName,e),C(null)},children:[re(`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&&C(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&&C(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 h-full`,children:[(0,i.jsx)(r.RefreshIndicator,{active:y&&F.length>0}),(0,i.jsx)(X,{...e,schema:ue,onChartClick:fe}),pe]})},Pe={filter:!0},$=e=>(0,i.jsx)(o.ElementDataSourceGate,{schema:e.schema,mapping:Pe,dataSource:e.dataSource,testId:`object-chart`,errorTitle:`This chart’s data source could not be resolved`,children:t=>(0,i.jsx)(Ne,{...e,schema:t})});t.ComponentRegistry.register(`object-chart`,$,{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.`}]}),ie();var Fe={"bar-chart":Y,chart:X};t.ComponentRegistry.register(`bar-chart`,Y,{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`,$,{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`,X,{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`,X,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`,defaultProps:{chartType:`bar`}}),t.ComponentRegistry.register(`pie-chart`,X,{namespace:`plugin-charts`,label:`Pie Chart`,category:`plugin`,defaultProps:{chartType:`pie`}}),t.ComponentRegistry.register(`donut-chart`,X,{namespace:`plugin-charts`,label:`Donut Chart`,category:`plugin`,defaultProps:{chartType:`donut`}}),t.ComponentRegistry.register(`radar-chart`,X,{namespace:`plugin-charts`,label:`Radar Chart`,category:`plugin`,defaultProps:{chartType:`radar`}}),t.ComponentRegistry.register(`scatter-chart`,X,{namespace:`plugin-charts`,label:`Scatter Chart`,category:`plugin`,defaultProps:{chartType:`scatter`}}),e.ChartBarRenderer=Y,e.ChartRenderer=X,e.ObjectChart=Ne,e.ObjectChartBlock=$,e.chartComponents=Fe,e.normalizeChartSchema=x});
|
|
7
|
+
`)}}):null},L=o.Tooltip,R=o.Legend}));function be(e){return e?.[0]?.dataKey||`value`}function xe(e,t,n){if(!e)return null;let r=e.payload??e,i=r?.[t];if(i==null)return null;let a=be(n);return{category:String(i),series:a,value:typeof r?.[a]==`number`?r[a]:void 0}}function Se(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:be(t),value:typeof r==`number`?r:void 0}}function Ce(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:be(t),value:typeof n?.value==`number`?n.value:void 0}}var we=h((()=>{})),z=g({default:()=>H});function Te(e){let t=0;for(let n of e)t+=vt.test(n)?1:J;return t*q}function Ee(e,t){if(e.length===0||t<=0)return!1;let n=t/e.length;return e.reduce((e,t)=>Math.max(e,Te(t)),0)+Y<=n}function De(e){let t=gt*Math.PI/180,n=e.reduce((e,t)=>Math.max(e,Te(t)),0);return Math.ceil(16+q*Math.cos(t)+n*Math.sin(t))}function Oe(e){return e===`top`?Tt:wt}function ke(e){return e===`right`?Et:Ct}function Ae(e,t){return e?t?e===`left`||e===`right`?{down:e}:{refused:e}:e===`top`||e===`bottom`?{across:e}:{refused:e}:{}}function je(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 Me(e,t){return t?e===`left`?`bottom`:`top`:e}function Ne(e){return e===`left`||e===`right`?`on the ${e}`:`at the ${e}`}function Pe(e,t){return e?t?kt:Ot:Dt}function Fe(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 Le(...e.notes.map(e=>{let r=Ne(Me(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 `,Ne(e.position),`, so this axis is drawn `,r,`.`]})]},e.index)}))}function Ie(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 Le(...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 `,Ne(Me(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 Le(...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 Re(e,t,n){if(!e)return{};let r=b(e),i=ce(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 ze(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 Be({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 Ve({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 He(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 Ue({dataKey:e,className:t}){return(0,a.jsxs)(V,{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 We(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 Ge(e){return e!=null&&Number.isFinite(Number(e))}function Ke(e,t,n){let r=0;for(let i of e){let e=i;Ge(e?.[t])&&Ge(e?.[n])&&(r+=1)}return{plottable:r,total:e.length}}function qe({xKey:e,yKey:t,className:n}){return(0,a.jsxs)(V,{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 Je(e){return typeof e==`boolean`?!1:Array.isArray(e)?Ye(e[0])&&Ye(e[1]):Ye(e)}function Ye(e){return typeof e==`number`||e instanceof Number||typeof e==`string`||e instanceof Date?Number.isFinite(Number(e)):!1}function Xe(e){let t=e=>typeof e==`number`&&Number.isFinite(e);return t(e?.min)&&t(e?.max)||t(e?.stepSize)}function Ze(e,t){return e.some(e=>Je(e?.[t]))}function Qe(e,t,n){let r=t[n];if(!r?.stack)return`none`;let i=v(e,t),a=i===`combo`?r.chartType||se(e)||(n===0?`bar`:`line`):i;return a===`line`?`none`:a===`area`?`area`:`bar`}function $e({keys:e,total:t,className:r}){return(0,a.jsxs)(V,{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 et({seriesKeys:e,className:t}){let r=(0,i.useSafeTranslate)();return(0,a.jsxs)(V,{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 tt(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 nt({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:ne,title:re,subtitle:ie,description:oe,height:ce,annotations:b,interaction:S}){let de=e===`column`?`bar`:e,C=v(de,l),w=se(de),T=Array.isArray(r)?r:[],E=(0,i.useDisplayLocale)(),D=h===!1?{isAnimationActive:!1}:{},O={...h===!1?{disableSettleRemount:!0}:{},...ce?{style:{height:ce}}:{},...oe?{role:`img`,"aria-label":oe}:{}},[k,fe]=n.useState(!1),[pe,me]=n.useState(null),[he,ge]=n.useState(void 0);n.useEffect(()=>{if(pe==null||typeof ResizeObserver>`u`)return;let e=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;t!=null&&t>0&&ge(Math.round(t))});return e.observe(pe),()=>e.disconnect()},[pe]);let M=n.useRef(null),N=n.useCallback(e=>(...t)=>{let n=ft(t);n!==void 0&&(M.current={gesture:n,dataKey:String(e.dataKey)})},[]),P=m?e=>({onClick:N(e)}):()=>({}),F=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?T[a]:void 0,s=M.current;M.current=null;let c=dt(n),u=s!=null&&c!==void 0&&s.gesture===c;if(r&&!u)return;let d=u?s.dataKey:ut(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:pt(d,l),value:typeof f==`number`?f:void 0})},[m,T,l]),I=n.useCallback((e,t)=>{F(e,t,!1)},[F]),ve=n.useCallback((e,t)=>{F(e,t,!0)},[F]),ye=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:pt(r,l),value:typeof e.payload?.[r]==`number`?e.payload[r]:void 0})},[m,c,l]),be=m?{onClick:I,style:{cursor:`pointer`}}:{},we=m?{onClick:ve}:{},z=m?e=>({...P(e),cursor:`pointer`}):()=>({}),Te=m?{onClick:ye,style:{cursor:`pointer`}}:{},Me=n.useCallback((e,t,n)=>f&&f[e==null?``:String(e)]||n[t%n.length],[f]),Ne=n.useCallback(e=>{if(!m)return;let t=xe(e,c,l);t&&m(t)},[m,c,l]),Ge=n.useCallback(e=>{if(!m)return;let t=Se(e,l);t&&m(t)},[m,l]),Je=n.useCallback(e=>{if(!m)return;let t=Ce(e,l);t&&m(t)},[m,l]),Ye=m?{onClick:Ne,cursor:`pointer`}:{},Qe=m?{onClick:Ge,style:{cursor:`pointer`}}:{},nt=m?{onClick:Je,style:{cursor:`pointer`}}:{};n.useEffect(()=>{let e=()=>fe(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let rt=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=(T.length>1?Math.abs(new Date(String(T[T.length-1][c]??``)).getTime()-new Date(String(T[0][c]??``)).getTime()):0)/864e5;try{return n<=62?e.toLocaleDateString(E,{month:`short`,day:`numeric`}):e.toLocaleDateString(E,{month:`short`,year:`numeric`})}catch{return(0,t.isRealCalendarDate)(r)?(0,t.toDateInputValue)(e):e.toISOString().slice(0,10)}}}return k&&r.length>8?r.slice(0,8)+`…`:r},[T,c,k,s,E]),it=n.useMemo(()=>T.some(e=>String(e[c]||``).length>5),[T,c]),at=T.length>0&&T.length<=mt,ot=()=>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))`],st=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(E,{notation:`compact`,maximumFractionDigits:1}).format(t)}catch{return String(t)}},[E]),B=_?.[0],H=C===`horizontal-bar`,U=ae(_,C),G=U.left===void 0?void 0:_?.[U.left],q=U.right===void 0?void 0:_?.[U.right],J=!!G&&!!q,vt=C===`combo`||J,Y=U.slotOf[0]??`left`,X=Le(Fe(U,H),Ie(U,_,H)),Ct=e=>J?e.yAxis===`right`?q:G:B,Et=n.useMemo(()=>y(g?.format,E)??rt,[g?.format,E,rt]),Dt=he===void 0?void 0:Ee(T.map(e=>String(Et(e?.[c])??``)),he-yt-(C===`combo`||J?2:1)*bt),Ot=(at||!k)&&it&&Dt!==!0,kt=n.useMemo(()=>Ot?e=>{let t=String(Et(e)??``);return t.length>ht?`${t.slice(0,11)}…`:t}:Et,[Ot,Et]),At=Ot?De(T.map(e=>String(kt(e?.[c])??``))):void 0,jt=n.useMemo(()=>y(B?.format,E)??st,[B?.format,E,st]),Mt=n.useMemo(()=>y(G?.format,E)??st,[G?.format,E,st]),Nt=n.useMemo(()=>y(q?.format,E)??st,[q?.format,E,st]),Pt=n.useCallback(e=>l.filter(t=>!J||(t.yAxis===`right`?`right`:`left`)===e),[l,J]),Z=n.useCallback(e=>{let t=Pt(e).map(e=>e.dataKey),n=[];for(let e of T)for(let r of t){let t=Number(e?.[r]);Number.isFinite(t)&&n.push(t)}return n},[T,Pt]),Q=n.useCallback((e,t=`left`,n)=>({...te(Pt(t))?{allowDecimals:!1}:{},...Re(e,Z(t),n??ke(t))}),[Z,Pt]),Ft=B?.showGridLines!==!1,It={vertical:g?.showGridLines===!0,horizontal:Ft},{across:$,down:Lt,refused:Rt}=Ae(g?.position,H),zt=je(Rt,H),Bt=ee!==!1,Vt=n.useMemo(()=>{if(!Array.isArray(b)||b.length===0)return null;let e={solid:void 0,dashed:`4 4`,dotted:`1 4`},t=Pe(vt,H);return b.map((n,r)=>{let i=n?.axis===`x`,s=W(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}`)})},[b,vt,H]),Ht=S?.tooltips!==!1,Ut=S?.brush===!0?(0,a.jsx)(o.Brush,{dataKey:c,height:24,travellerWidth:8,stroke:`hsl(var(--muted-foreground))`}):null,Wt=e=>ne?(0,a.jsx)(o.LabelList,{position:`top`,className:`fill-foreground`,fontSize:11,...e?{formatter:e}:{}}):null,Gt=n.useMemo(()=>({tick:K,tickLine:!1,tickMargin:_t,axisLine:!1,...at?{interval:0}:{interval:`preserveStartEnd`,minTickGap:0},tickFormatter:kt,...$?{orientation:$}:{},...g?.title?{label:{value:g.title,...Oe($)}}:{},...Ot&&{angle:$===`top`?gt:-35,textAnchor:`end`,height:At}}),[at,Ot,kt,g?.title,$,At]);if(C&&x.has(C)){let e=l[0]?.dataKey||`value`,t=T[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(E).format(n):String(t??`—`)}),(0,a.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:String(r)})]})})}if(C&&ue.has(C))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 “`,C,`” is tabular — render it with the data-table / pivot components; a chart block draws series charts.`]});if(!C||!le.has(C))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:C?(0,a.jsxs)(a.Fragment,{children:[`Chart type “`,C,`” 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 Kt={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}[C]||o.BarChart;if(C===`pie`||C===`donut`){let e=C===`donut`?`52%`:0,t=ot(),n=l[0]?.dataKey||`value`,r=He(T,n);if(r.total>0&&r.sizable===0)return(0,a.jsx)(Ue,{dataKey:n,className:u});let i={...s};T.forEach((e,n)=>{let r=e?.[c];if(r==null||r===``)return;let a=String(r);i[a]||(i[a]={label:a,color:Me(r,n,t)})});let d=(0,a.jsx)(A,{config:i,className:u,...O,children:(0,a.jsxs)(o.PieChart,{children:[(0,a.jsx)(L,{cursor:!1,content:(0,a.jsx)(j,{hideLabel:!0})}),(0,a.jsx)(o.Pie,{data:T,dataKey:n,nameKey:c||`name`,innerRadius:e,strokeWidth:5,paddingAngle:2,outerRadius:`85%`,...D,...Te,children:T.map((e,n)=>{let r=Me(e?.[c],n,t);return(0,a.jsx)(o.Cell,{fill:W(r)},`cell-${n}`)})}),Bt?(0,a.jsx)(R,{verticalAlign:`bottom`,wrapperStyle:{fontSize:k?`11px`:`12px`,paddingTop:`8px`},content:(0,a.jsx)(_e,{nameKey:c,className:`flex-wrap`})}):null]})});return(0,a.jsx)(Ve,{note:We(r.sizable,r.total,n),children:d})}if(C===`funnel`){let e=l[0]?.dataKey||`value`,n=ot(),r=He(T,e);if(r.total>0&&r.sizable===0)return(0,a.jsx)(Ue,{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?[...T].sort((e,t)=>(f.get(String(e?.[c]??``))??2**53-1)-(f.get(String(t?.[c]??``))??2**53-1)):[...T].sort((t,n)=>{let r=Number(t?.[e]??0);return Number(n?.[e]??0)-r}),g=(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsxs)(o.FunnelChart,{children:[(0,a.jsx)(L,{content:(0,a.jsx)(j,{})}),(0,a.jsxs)(o.Funnel,{dataKey:e,data:h,nameKey:c,...D,...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:W(n[t%n.length])},`funnel-cell-${t}`))]})]})});return(0,a.jsx)(Ve,{note:We(r.sizable,r.total,e),children:g})}if(C===`treemap`){let e=l[0]?.dataKey||`value`,t=ot(),n=He(T,e);if(n.total>0&&n.sizable===0)return(0,a.jsx)(Ue,{dataKey:e,className:u});let r=T.map((n,r)=>({name:String(n?.[c]??``),size:Number(n?.[e])||0,fill:W(t[r%t.length])})),i=(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsx)(o.Treemap,{data:r,dataKey:`size`,nameKey:`name`,...D,content:(0,a.jsx)(ze,{}),...Qe,children:(0,a.jsx)(o.Tooltip,{})})});return(0,a.jsx)(Ve,{note:We(n.sizable,n.total,e),children:i})}if(C===`sankey`){let e=l[0]?.dataKey||`value`,t=l[0]?.label||e,n=T.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 T.length===0?(0,a.jsx)(`div`,{className:u}):(0,a.jsxs)(V,{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=T.length-n.length;return(0,a.jsx)(Ve,{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 `,T.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)(A,{config:s,className:u,...O,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))`},...nt,children:(0,a.jsx)(o.Tooltip,{})})})})}if(C===`radar`)return(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsxs)(o.RadarChart,{data:T,children:[(0,a.jsx)(o.PolarGrid,{}),(0,a.jsx)(o.PolarAngleAxis,{dataKey:c,tick:K}),(0,a.jsx)(o.PolarRadiusAxis,{tick:K}),(0,a.jsx)(L,{content:(0,a.jsx)(j,{})}),(0,a.jsx)(R,{content:(0,a.jsx)(_e,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),l.map(e=>{let t=W(s[e.dataKey]?.color||ct),n=lt(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,...D},e.dataKey)})]})});if(C===`scatter`){if(l.length>1)return(0,a.jsx)(et,{seriesKeys:l.map(e=>String(e.dataKey)),className:u});let e=l[0]?.dataKey||`value`,t=Ke(T,c,e),n=T.map(e=>Number(e?.[c])).filter(e=>Number.isFinite(e)),r=y(g?.format,E);if(t.total>0&&t.plottable===0)return(0,a.jsx)(qe,{xKey:c,yKey:e,className:u});if(t.total>0){let n=[[c,g],[e,_?.[0]]].filter(([e,t])=>!Xe(t)&&!Ze(T,e)).map(([e])=>e).filter((e,t,n)=>n.indexOf(e)===t);if(n.length>0)return(0,a.jsx)($e,{keys:n,total:t.total,className:u})}return(0,a.jsx)(Ve,{note:Le(tt(t.plottable,t.total,c,e),zt,X),children:(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsxs)(o.ScatterChart,{children:[(0,a.jsx)(o.CartesianGrid,{...It}),(0,a.jsx)(o.XAxis,{type:`number`,dataKey:c,name:String(s[c]?.label||c),tick:K,tickLine:!1,axisLine:!1,minTickGap:k?32:48,padding:xt,...r?{tickFormatter:r}:{},...$?{orientation:$}:{},...Re(g,n,Oe($))}),(0,a.jsx)(o.YAxis,{type:`number`,dataKey:e,name:String(s[l[0]?.dataKey]?.label||l[0]?.dataKey),tick:K,tickLine:!1,axisLine:!1,tickFormatter:jt,width:48,padding:St,...Y===`right`?{orientation:`right`}:{},...Q(B,Y)}),(0,a.jsx)(L,{content:(0,a.jsx)(j,{})}),(0,a.jsx)(R,{content:(0,a.jsx)(_e,{nameKey:e}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),l.map((e,t)=>{let n=ot(),r=W(s[e.dataKey]?.color||n[t%n.length]),i=lt(e,`scatter`);return(0,a.jsx)(o.Scatter,{name:s[e.dataKey]?.label||e.dataKey,data:T,fill:r,fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity,strokeDasharray:i.strokeDasharray,...D,...Ye},e.dataKey)})]})})})}if(C===`combo`)return(0,a.jsx)(Be,{title:re,subtitle:ie,children:(0,a.jsx)(Ve,{note:Le(zt,X),children:(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsxs)(o.ComposedChart,{ref:me,data:T,...we,children:[(0,a.jsx)(o.CartesianGrid,{...It,...Pe(vt,H)}),(0,a.jsx)(o.XAxis,{dataKey:c,...Gt}),(0,a.jsx)(o.YAxis,{yAxisId:`left`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Mt,width:48,...Q(G,`left`)}),(0,a.jsx)(o.YAxis,{yAxisId:`right`,orientation:`right`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Nt,width:48,...Q(q,`right`)}),Ht?(0,a.jsx)(L,{content:(0,a.jsx)(j,{})}):null,Bt?(0,a.jsx)(R,{content:(0,a.jsx)(_e,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Vt,Ut,l.map((e,t)=>{let n=W(s[e.dataKey]?.color||ct),r=e.chartType||w||(t===0?`bar`:`line`),i=e.yAxis===`right`||e.yAxis===`left`?e.yAxis:w||r===`bar`?`left`:`right`,c=lt(e,r),l=e.stack?{stackId:String(e.stack)}:{},u=y((i===`right`?q:G)?.format,E);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,...D,...z(e),children:Wt(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,...D,...z(e),children:Wt(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,...D,...z(e),children:Wt(u)},e.dataKey)})]})})})});let qt=C===`horizontal-bar`,Jt=ot(),Yt=f?Object.values(f).map(e=>W(String(e))):[],Xt=Array.from(new Set([...Jt,...Yt,...l.map((e,t)=>W(s[e.dataKey]?.color||Jt[t%Jt.length]||ct))])),Zt=e=>`g`+e.replace(/[^a-zA-Z0-9]/g,``);return(0,a.jsx)(Be,{title:re,subtitle:ie,children:(0,a.jsx)(Ve,{note:Le(zt,X),children:(0,a.jsx)(A,{config:s,className:u,...O,children:(0,a.jsxs)(Kt,{ref:me,data:T,layout:qt?`vertical`:`horizontal`,...be,children:[(0,a.jsx)(`defs`,{children:Xt.map(e=>(0,a.jsxs)(n.Fragment,{children:[(0,a.jsxs)(`linearGradient`,{id:`bg-${Zt(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-${Zt(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})]})]},Zt(e)))}),(0,a.jsx)(o.CartesianGrid,{...It,...Pe(vt,H)}),qt?(0,a.jsxs)(a.Fragment,{children:[J?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.XAxis,{xAxisId:`left`,type:`number`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Mt,...Q(G,`left`,wt)}),(0,a.jsx)(o.XAxis,{xAxisId:`right`,orientation:`top`,type:`number`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Nt,...Q(q,`right`,Tt)})]}):(0,a.jsx)(o.XAxis,{type:`number`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:jt,...Y===`right`?{orientation:`top`}:{},...Q(B,Y,Oe(Y===`right`?`top`:`bottom`))}),(0,a.jsx)(o.YAxis,{type:`category`,dataKey:c,tick:K,tickLine:!1,axisLine:!1,width:Math.min(140,Math.max(60,Math.max(...T.map(e=>String(e[c]??``).length))*7)),tickFormatter:Et,...Lt?{orientation:Lt}:{},...g?.title?{label:{value:g.title,...ke(Lt)}}:{}})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.XAxis,{dataKey:c,...Gt}),J?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.YAxis,{yAxisId:`left`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Mt,width:48,...Q(G,`left`)}),(0,a.jsx)(o.YAxis,{yAxisId:`right`,orientation:`right`,tick:K,tickLine:!1,axisLine:!1,tickFormatter:Nt,width:48,...Q(q,`right`)})]}):(0,a.jsx)(o.YAxis,{tick:K,tickLine:!1,axisLine:!1,tickFormatter:jt,width:48,...Y===`right`?{orientation:`right`}:{},...Q(B,Y)})]}),Ht?(0,a.jsx)(L,{content:(0,a.jsx)(j,{})}):null,Bt?(0,a.jsx)(R,{content:(0,a.jsx)(_e,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}):null,Vt,Ut,l.map((e,t)=>{let n=ot(),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=W(s[i.dataKey]?.color||n[u%n.length]||ct),f=e.yAxis===`right`?`right`:`left`,p=J?qt?{xAxisId:f}:{yAxisId:f}:{},m=e.stack?{stackId:String(e.stack)}:{},h=y(Ct(e)?.format,E);if(C===`bar`||C===`horizontal-bar`){let t=l.filter(e=>e.variant!==`comparison`).length===1&&!r&&l.length===1&&T.length>1,i=lt(e,`bar`);return(0,a.jsxs)(o.Bar,{dataKey:e.dataKey,fill:`url(#bg-${Zt(d)})`,radius:4,fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity,strokeDasharray:i.strokeDasharray,...m,...p,...D,...P(e),children:[t&&T.map((e,t)=>(0,a.jsx)(o.Cell,{fill:`url(#bg-${Zt(W(Me(e?.[c],t,n)))})`},`cell-${t}`)),Wt(h)]},e.dataKey)}if(C===`line`){let t=lt(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,...D,...P(e),children:Wt(h)},e.dataKey)}if(C===`area`){let t=lt(e,`area`);return(0,a.jsx)(o.Area,{type:`monotone`,dataKey:e.dataKey,fill:`url(#ag-${Zt(d)})`,stroke:d,strokeWidth:2,fillOpacity:t.fillOpacity??1,strokeOpacity:t.strokeOpacity,strokeDasharray:t.strokeDasharray,...m,...p,...D,...P(e),children:Wt(h)},e.dataKey)}return null})]})})})})}function rt(e){return e.chartType===`column`?`bar`:e.chartType}function it(e){let t=rt(e),n=Array.isArray(e.data)?e.data:[],r=e.xAxisKey??`name`;return t!==void 0&&G.has(t)&&n.length>0&&!n.some(e=>typeof e==`object`&&!!e&&r in e)}function at(e){let t=rt(e),n=Array.isArray(e.data)?e.data:[];return t===void 0||!At.has(t)||n.length===0?null:e.series===void 0?`undeclared`:Array.isArray(e.series)&&e.series.length===0?`empty`:null}function ot(e){let t=rt(e),n=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.series)?e.series:[];if(t===void 0||!At.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=ae(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=>Xe(s)||(!l||e.yAxis!==`left`)&&Xe(c);return r.some((e,i)=>Qe(t,r,i)!==`none`||u(e)||Ze(n,String(e.dataKey)))?null:i}function st(e){let t=rt(e),n=Array.isArray(e.data)?e.data:[],r=Array.isArray(e.series)?e.series:[];if(t===void 0||!At.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 B({keys:e,className:t}){return(0,a.jsxs)(V,{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 V({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 H(e){let t=it(e),r=t?null:at(e),i=t||r?null:st(e),o=t||r||i?null:ot(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)(V,{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)(V,{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)(V,{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)(B,{keys:i,className:e.className}):o?(0,a.jsx)($e,{keys:o,total:Array.isArray(e.data)?e.data.length:0,className:e.className}):(0,a.jsx)(nt,{...e})}var ct,U,W,lt,ut,dt,ft,pt,G,mt,ht,gt,_t,K,q,J,vt,yt,bt,Y,X,xt,St,Ct,wt,Tt,Et,Dt,Ot,kt,At,jt=h((()=>{ye(),we(),O(),ct=`hsl(var(--primary))`,U={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`},W=e=>U[e]||e,lt=(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)}},ut=(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)}},dt=e=>{if(e&&typeof e==`object`&&`nativeEvent`in e)return e.nativeEvent},ft=e=>{for(let t=e.length-1;t>=0;--t){let n=dt(e[t]);if(n!==void 0)return n}},pt=(e,t)=>{if(e==null)return;let n=t.find(t=>String(t.dataKey)===e);return typeof n?.label==`string`?n.label:void 0},G=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`radar`,`funnel`,`combo`]),mt=5,ht=12,gt=35,_t=10,K={fill:`hsl(var(--muted-foreground))`},q=12,J=.65,vt=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\u3000-\u303f\uff00-\uffef]/u,yt=10,bt=48,Y=8,X=Math.ceil(Math.sqrt(400/Math.PI)),xt={left:X,right:X},St={top:X,bottom:X},Ct={angle:-90,position:`insideLeft`},wt={position:`insideBottom`,offset:-4},Tt={position:`insideTop`,offset:-4},Et={angle:90,position:`insideRight`},Dt={},Ot={yAxisId:`left`},kt={xAxisId:`left`},At=new Set([`bar`,`horizontal-bar`,`line`,`area`,`combo`])}));O();var Mt=n.default.lazy(()=>Promise.resolve().then(()=>(he(),k))),Nt=n.default.lazy(()=>Promise.resolve().then(()=>(jt(),z))),Pt=({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)(Mt,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),Z=({schema:e,onChartClick:t})=>{let{language:o}=(0,i.useObjectTranslation)(),s=n.default.useMemo(()=>{let t=oe(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)(Nt,{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})})};O();function Q(e){return(0,t.chartMeasureKey)(e,e.function||`count`)}var Ft=[`aggregate.groupBy`,`xAxisKey`,`xAxis.field`];function It(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:oe(e).xAxisKey}var $=`__comparison`;function Lt(e){let t=e?.groupBy;return t&&typeof t==`object`&&!Array.isArray(t)?t.alias||t.field:typeof t==`string`?t:void 0}function Rt(e,t){let{field:n,function:r,groupBy:i}=t,a=Q(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 zt(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 Bt=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),[te,ne]=(0,n.useState)(void 0),[re,ie]=(0,n.useState)(()=>!(Array.isArray(o.data)&&o.data.length>0)&&(!!o.objectName||!!o.dataset)),[ae,se]=(0,n.useState)(null),[v,y]=(0,n.useState)(null),[ce,b]=(0,n.useState)(null),{openRecordList:le}=(0,s.useDrillNavigation)(),x=(0,i.useSafeTranslate)(),{t:ue,language:S}=(0,i.useObjectTranslation)(),de=(0,n.useMemo)(()=>oe(o,S).chartType,[o,S]),C=(0,n.useMemo)(()=>o.aggregate?JSON.stringify(o.aggregate):``,[o.aggregate]),w=(0,n.useMemo)(()=>o.filter?JSON.stringify(o.filter):``,[o.filter]),T=(0,n.useMemo)(()=>o.compareTo?JSON.stringify(o.compareTo):``,[o.compareTo]),E=(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=It(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||b(null);return}let c=typeof d?.getObjectSchema==`function`?e=>d.getObjectSchema(e):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||b({metaByPath:u,colorPath:a,fieldByDim:o.dataset&&Array.isArray(o.dimensions)?l:null})}catch{e||b(null)}})(),()=>{e=!0}},[o.objectName,o.dataset,E,C,o.xAxisKey,f,d]);let{fieldOptionColors:D,dimensionLabels:O}=(0,n.useMemo)(()=>{if(!ce)return{fieldOptionColors:null,dimensionLabels:null};let{metaByPath:e,colorPath:n,fieldByDim:r}=ce,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}},[ce,m]),k=(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=Lt(o.aggregate);return o.aggregate&&a&&i.length>0&&(i=Rt(i,{...o.aggregate,groupBy:a})),i}return[]},[o.objectName,C]),fe=(0,s.useFilterScope)(),pe=(0,n.useCallback)(async(e,n)=>{if(!e||!o.objectName&&!o.dataset){n.current&&ie(!1);return}n.current&&(ie(!0),se(null));try{if(o.dataset&&typeof e.queryDataset==`function`){let r=(0,t.resolveFilterPlaceholders)(o.filter,fe),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),ne(typeof i?.object==`string`&&i.object?i.object:void 0));return}let r=(0,t.resolveFilterPlaceholders)(o.filter,fe),i=o.compareTo,a=!!i&&!(0,t.chartTypeIgnoresCompareTo)(de),s=a?(0,t.resolveContextTokens)((0,t.shiftFilterByCompareTo)(o.filter,i),fe):null,[c,l]=await Promise.all([k(e,r),s?k(e,s):Promise.resolve([])]),u=c,d=Lt(o.aggregate)||o.xAxisKey;if(a&&l.length>0&&o.aggregate){let e=o.aggregate.field,t=o.aggregate.function,n=Q(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}${$}`,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 zt(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&&se(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&ie(!1)}},[o.objectName,E,C,w,T,o.xAxisKey,de,k,fe,m]),me=!!p||Array.isArray(o.data),he=!!o.objectName&&!o.dataset&&!me,ge=he&&!It(o),A=!!(o.objectName||o.dataset)&&!p&&!o.data&&!ge,j=(0,s.useDataInvalidation)(A?o.dataset?te:o.objectName:void 0);(0,n.useEffect)(()=>{let e={current:!0};return A?pe(d,e):e.current&&ie(!1),()=>{e.current=!1}},[o.objectName,E,d,p,o.data,w,C,T,pe,j,A]);let _e=p||o.data||h,M=Array.isArray(_e)?_e:[],N=o.drillDown,P=Lt(o.aggregate)||o.xAxisKey,F=(0,n.useMemo)(()=>{if(!P)return new Map;let e=new Map,t=`__raw_${P}`;for(let n of M){let r=n?.[P];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[M,P]),I=(0,n.useMemo)(()=>{if(v)try{return{ok:!0,filter:(0,t.composeDrillFilter)(o.filter,(0,t.computeDrillFilter)(N,v,{groupByField:P}))}}catch(e){if(!(e instanceof t.FilterOperatorError))throw e;return{ok:!1,refusal:e}}},[v,N,P,w]),ve=I?.ok?I.filter:void 0,L=I?.ok===!1,R=I?.ok===!1?I.refusal.message:void 0;(0,n.useEffect)(()=>{R&&console.warn(`[ObjectChart] drill-down refused — the drilled list cannot be scoped: ${R}`)},[R]);let ye=!l&&!!v&&!L&&!!o.objectName&&N?.target===`navigate`&&!!le;(0,n.useEffect)(()=>{ye&&(le(o.objectName,ve),y(null))},[ye]);let be=o.compareTo,xe=o.aggregate?Q(o.aggregate):void 0,Se=xe?`${xe}${$}`:void 0,Ce=!!be&&!(0,t.chartTypeIgnoresCompareTo)(de)&&!!Se&&M.some(e=>e[Se]!=null),we=(0,n.useMemo)(()=>{let e=Array.isArray(o.series)?o.series:null;if(!Ce)return e;let n=e||[{dataKey:xe}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[(0,t.compareToTrendLabelKey)(be,o.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:Se,label:r,variant:`comparison`}]},[Ce,o.series,xe,Se,o.filter,be]),z=o.dataset?(0,t.buildChartSeries)((0,t.relabelDimensions)(M,O),o.dimensions,o.values,_,{nullCategoryLabel:x(`chart.nullCategory`,`(None)`),builtinAggregateLabels:(0,i.builtinAggregateLabels)(x)}):null,Te=he&&!oe(o,S).xAxisKey?Lt(o.aggregate):void 0,Ee=z?{...o,data:z.data,xAxisKey:z.xAxisKey,series:z.series}:{...o,data:M,...Te?{xAxisKey:Te}:{},...we?{series:we}:{}},De=o.colors&&!Array.isArray(o.colors)&&typeof o.colors==`object`?o.colors:null,Oe=Array.isArray(o.colors)?o.colors:void 0,ke=D||De?{...D||{},...De||{}}:void 0,Ae={...Ee,colors:Oe,...ke?{categoryColors:ke}:{}};if(ge)return(0,a.jsxs)(`div`,{className:`p-4 text-destructive `+(o.className||``),"data-testid":`chart-missing-category-axis`,role:`alert`,children:[x(`chart.unconfigured.noCategoryAxis`,`Chart category axis required — an object-bound chart will not invent one. Declare one of:`),` `,Ft.map((e,t)=>(0,a.jsxs)(n.default.Fragment,{children:[t>0?`, `:``,(0,a.jsx)(`code`,{className:`font-mono`,children:e})]},e))]});if(re&&M.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&&M.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&&M.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:x(`dashboard.empty.title`,`No data yet`),description:x(`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:x(`dashboard.empty.sourceLabel`,`Source:`)}),` `,(0,a.jsx)(`span`,{className:`font-mono`,children:o.dataset||o.objectName})]})});let je=(0,t.isDrillEnabled)(N)?e=>{let t=e.category,n=t!=null&&F.has(String(t))?F.get(String(t)):t;y({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,Me=l??je,Ne=!l&&v&&!L&&o.objectName&&!ye?(()=>{let e=ve??{},n=(0,t.resolveDrillTitle)(N,v,(0,i.pickLocalized)(o.title,S)||`Details`),l=N?.target??`drawer`,u={type:`object-data-table`,objectName:o.objectName,filter:e,pagination:!0,pageSize:N?.maxRows,columns:N?.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=le&&o.objectName?(0,a.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{le(o.objectName,e),y(null)},children:[x(`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&&y(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&&y(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:re&&M.length>0,ariaLabel:ue(`chart.refreshing`)}),(0,a.jsx)(Z,{...e,schema:Ae,onChartClick:Me}),Ne]})},Vt={filter:!0},Ht=e=>e.data==null&&e.bind==null&&Reflect.get(e,`dataset`)==null,Ut=(0,t.elementDataSourceBlock)(e=>{let{t}=(0,i.useObjectTranslation)();return(0,a.jsx)(s.ElementDataSourceGate,{schema:e.schema,mapping:Vt,dataSource:e.dataSource,testId:`object-chart`,errorTitle:t(`element.chart.sourceUnresolved`,{defaultValue:`This chart’s data source could not be resolved`}),requiresObject:Ht(e.schema),children:t=>(0,a.jsx)(Bt,{...e,schema:t})})});t.ComponentRegistry.register(`object-chart`,Ut,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,description:"Object this chart aggregates. Not required: the node's `dataSource` binding can name the object instead, and `dataSource.object` lands on this key, outranking an authored value. With neither, and no inline `data`, the chart shows a hint naming this key instead of an empty frame."},{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.`}]}),O();var Wt={"bar-chart":Pt,chart:Z};t.ComponentRegistry.register(`bar-chart`,Pt,{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`,Ut,{namespace:`view`,category:`view`,label:`Chart`,skipFallback:!0,inputs:[{name:`objectName`,type:`string`,description:"Object this chart aggregates. Not required: the node's `dataSource` binding can name the object instead, and `dataSource.object` lands on this key, outranking an authored value. With neither, and no inline `data`, the chart shows a hint naming this key instead of an empty frame."},{name:`type`,type:`string`},{name:`categoryField`,type:`string`},{name:`valueField`,type:`string`}]}),t.ComponentRegistry.register(`chart`,Z,{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`,Z,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`}),e.ChartBarRenderer=Pt,e.ChartRenderer=Z,e.ObjectChart=Bt,e.ObjectChartBlock=Ut,e.chartComponents=Wt,e.normalizeChartSchema=oe});
|
|
@@ -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 {
|
|
@@ -128,14 +198,47 @@ export interface NormalizedSeries {
|
|
|
128
198
|
/** Which y-axis this series binds to (dual-axis charts). */
|
|
129
199
|
yAxis?: 'left' | 'right';
|
|
130
200
|
color?: string;
|
|
201
|
+
/**
|
|
202
|
+
* The aggregate of the measure this series plots — renderer-internal, the
|
|
203
|
+
* dataset answer's `fields[].aggregate` carried by `buildChartSeries`
|
|
204
|
+
* (objectui#11681). It decides one thing: a value axis whose series all plot
|
|
205
|
+
* a count draws whole-number ticks ({@link plotsWholeNumbers}). On the
|
|
206
|
+
* authoring face it is refused by name (`ChartDataSeriesSchema.aggregate`),
|
|
207
|
+
* so an author cannot claim integer ticks for a currency sum.
|
|
208
|
+
*/
|
|
209
|
+
aggregate?: string;
|
|
131
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Whether a value axis plotting `series` should draw whole-number ticks only
|
|
213
|
+
* (objectui#11681): true exactly when at least one series is bound to it and
|
|
214
|
+
* EVERY one plots an integer aggregate (`count` / `count_distinct`). One sum,
|
|
215
|
+
* average or undeclared series on the axis keeps recharts' default ticks, so a
|
|
216
|
+
* sum over currency keeps its decimals.
|
|
217
|
+
*/
|
|
218
|
+
export declare function plotsWholeNumbers(series: readonly NormalizedSeries[]): boolean;
|
|
132
219
|
export interface NormalizedChartSchema {
|
|
133
|
-
|
|
220
|
+
/**
|
|
221
|
+
* The chart family the schema names, as named: `chartType`, else `specType`,
|
|
222
|
+
* else a bare `type` that is a spec family, else a registered keyword's family
|
|
223
|
+
* (objectui#11520). It is NOT narrowed to the families this renderer draws:
|
|
224
|
+
* `AdvancedChartImpl`'s family dispatch decides the form (a chart, the number
|
|
225
|
+
* card, the tabular notice, or a notice naming the value), so a family this
|
|
226
|
+
* module dropped could only ever reach that dispatch as no family at all.
|
|
227
|
+
*
|
|
228
|
+
* Typed as the vocabulary the faces DECLARE ({@link DeclaredChartFamily}),
|
|
229
|
+
* not as `string`, so a misspelled family is a compile error for every
|
|
230
|
+
* producer. A value outside it can still arrive in unvalidated JSON; see the
|
|
231
|
+
* JSON-boundary cast in {@link normalizeChartSchema}.
|
|
232
|
+
*/
|
|
233
|
+
chartType?: DeclaredChartFamily;
|
|
134
234
|
xAxisKey?: string;
|
|
135
235
|
series?: NormalizedSeries[];
|
|
136
236
|
/** X-axis presentation config (its `field` is hoisted to `xAxisKey`). */
|
|
137
237
|
xAxis?: NormalizedAxis;
|
|
138
|
-
/**
|
|
238
|
+
/**
|
|
239
|
+
* Y-axes, in declaration order. Index 0 is the primary axis; the side each
|
|
240
|
+
* entry is drawn on is {@link placeYAxes}'s answer, not its index.
|
|
241
|
+
*/
|
|
139
242
|
yAxes?: NormalizedAxis[];
|
|
140
243
|
showLegend?: boolean;
|
|
141
244
|
showDataLabels?: boolean;
|
|
@@ -148,12 +251,129 @@ export interface NormalizedChartSchema {
|
|
|
148
251
|
annotations?: AnyRec[];
|
|
149
252
|
interaction?: AnyRec;
|
|
150
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* The two value-axis slots a cartesian chart draws, named in the spec's own
|
|
256
|
+
* `ChartSeries.yAxis` vocabulary: a series binds to a slot by writing
|
|
257
|
+
* `yAxis: 'left' | 'right'`, and `'left'` is the spec default.
|
|
258
|
+
*
|
|
259
|
+
* On a chart whose value axes run up its side (bar, line, area, combo,
|
|
260
|
+
* scatter) the slot IS the side it is drawn on. On `horizontal-bar` the value
|
|
261
|
+
* axes run across the plot, so the chart is the vertical one transposed: the
|
|
262
|
+
* `'left'` slot is drawn along the bottom and the `'right'` slot along the
|
|
263
|
+
* top — the same swap `placeXAxis` reads for the `xAxis` object there.
|
|
264
|
+
*/
|
|
265
|
+
export type ValueAxisSlot = 'left' | 'right';
|
|
266
|
+
/** A `yAxis` entry whose `position` was not honoured, and why. */
|
|
267
|
+
export interface YAxisPositionNote {
|
|
268
|
+
/** Index of the entry in `yAxis`. */
|
|
269
|
+
index: number;
|
|
270
|
+
/** The side it named. */
|
|
271
|
+
position: NonNullable<NormalizedAxis['position']>;
|
|
272
|
+
/**
|
|
273
|
+
* `'side'` — a side a value axis of this chart cannot take (`top` /
|
|
274
|
+
* `bottom` up the side of the plot; `left` / `right` across it).
|
|
275
|
+
* `'taken'` — an open side the first entry already holds.
|
|
276
|
+
*/
|
|
277
|
+
reason: 'side' | 'taken';
|
|
278
|
+
/** The slot the entry was drawn in instead. */
|
|
279
|
+
drawn: ValueAxisSlot;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* A `yAxis` entry drawn on no axis — every entry after the ones the chart
|
|
283
|
+
* places: after the second (objectui#10691), or after the first on `scatter`,
|
|
284
|
+
* which draws one value axis (objectui#10721). The spec's `ChartConfig.yAxis`
|
|
285
|
+
* is an uncapped list, so such an entry validates; a chart draws at most two
|
|
286
|
+
* value axes, one per slot.
|
|
287
|
+
*/
|
|
288
|
+
export interface YAxisUndrawnNote {
|
|
289
|
+
/** Index of the entry in `yAxis` — 2 or more; 1 or more on `scatter`. */
|
|
290
|
+
index: number;
|
|
291
|
+
/**
|
|
292
|
+
* The slot a series derived from the entry binds to (the chart declares
|
|
293
|
+
* neither `series` nor `categories`), and so the axis its `field` is
|
|
294
|
+
* plotted against. On `scatter`, the one slot the chart draws.
|
|
295
|
+
*/
|
|
296
|
+
boundTo: ValueAxisSlot;
|
|
297
|
+
}
|
|
298
|
+
export interface YAxisPlacement {
|
|
299
|
+
/** Index of the `yAxis` entry drawn in each slot; absent when none is. */
|
|
300
|
+
left?: number;
|
|
301
|
+
right?: number;
|
|
302
|
+
/**
|
|
303
|
+
* The slot of each placed entry, by index (the first two entries; the first
|
|
304
|
+
* on `scatter`).
|
|
305
|
+
*/
|
|
306
|
+
slotOf: ValueAxisSlot[];
|
|
307
|
+
notes: YAxisPositionNote[];
|
|
308
|
+
/** Every entry after the placed ones, in index order: drawn on no axis. */
|
|
309
|
+
undrawn: YAxisUndrawnNote[];
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Where each `yAxis` entry is drawn, read from its `position`
|
|
313
|
+
* (objectui#10654, the y-side twin of objectui#10587).
|
|
314
|
+
*
|
|
315
|
+
* The ONE place a y side is resolved: `normalizeChartSchema` binds the series
|
|
316
|
+
* it derives from the entries with it, and `AdvancedChartImpl` places the
|
|
317
|
+
* axes and writes the notes from the same answer, so a derived series always
|
|
318
|
+
* plots against its own entry's axis.
|
|
319
|
+
*
|
|
320
|
+
* Only the first two entries are placed — a chart draws at most two value
|
|
321
|
+
* axes, one per slot — and on `scatter` only the first: it draws one y axis,
|
|
322
|
+
* the primary's (objectui#10721). The rule, in order:
|
|
323
|
+
*
|
|
324
|
+
* 1. An entry whose `position` names a side a value axis of this chart
|
|
325
|
+
* cannot take is REFUSED: it is placed as if it named no side, and the
|
|
326
|
+
* chart carries a note naming `yAxis[N].position`. ⛔ Never mapped to a
|
|
327
|
+
* "nearest" open side — `top` names no side of an axis that runs up the
|
|
328
|
+
* plot.
|
|
329
|
+
* 2. An entry that names an open side is drawn there.
|
|
330
|
+
* 3. When BOTH entries name the same side, the first keeps it —
|
|
331
|
+
* `yAxis[0]` is the primary axis, the one declaration order already
|
|
332
|
+
* makes primary — and the second is drawn on the other side with a note
|
|
333
|
+
* naming `yAxis[1].position`.
|
|
334
|
+
* 4. An entry that names no side takes the side the other entry left free;
|
|
335
|
+
* with neither naming one, the first is drawn in the `'left'` slot and
|
|
336
|
+
* the second in the `'right'` slot, exactly as before `position` was read.
|
|
337
|
+
*
|
|
338
|
+
* Every entry after the placed ones is listed in `undrawn` (objectui#10691,
|
|
339
|
+
* and objectui#10721 for `scatter`): it is drawn on no axis, so none of its
|
|
340
|
+
* keys — `position` included — is read, and the chart carries a note naming
|
|
341
|
+
* `yAxis[N]`. A series derived from it binds to the `'right'` slot, as it did
|
|
342
|
+
* before this list existed; on `scatter` to the one slot the chart draws,
|
|
343
|
+
* because a scatter reads no series binding and measures every series it
|
|
344
|
+
* plots against that axis. ⛔ The count is not narrowed: the spec declares
|
|
345
|
+
* `yAxis` uncapped, so the entry stays valid and the note is the answer.
|
|
346
|
+
*
|
|
347
|
+
* `chartType` is the family the chart is drawn as, and every caller passes
|
|
348
|
+
* its own, so the slice above is expressed here once rather than at each call
|
|
349
|
+
* site. On `horizontal-bar` the value axes run across the plot (see
|
|
350
|
+
* {@link ValueAxisSlot}): there `bottom` / `top` are the open sides.
|
|
351
|
+
*/
|
|
352
|
+
export declare function placeYAxes(yAxes: readonly NormalizedAxis[] | undefined, chartType: string | undefined): YAxisPlacement;
|
|
151
353
|
/**
|
|
152
354
|
* Translate a chart schema — spec shape, internal shape, or a mix — into the
|
|
153
355
|
* renderer's internal contract. Only keys that resolve to something are
|
|
154
356
|
* present on the result, so callers can spread it over their own defaults.
|
|
357
|
+
*
|
|
358
|
+
* @param language the VIEWER's active language, for every `I18nLabel` slot this
|
|
359
|
+
* resolves — the chart's `title` / `subtitle` / `description`, an axis
|
|
360
|
+
* `title`, and a series `label`. Pure on purpose: this module cannot call a
|
|
361
|
+
* hook, so a React caller reads the language once
|
|
362
|
+
* (`useObjectTranslation().language`) and hands it down. See {@link label}.
|
|
363
|
+
*
|
|
364
|
+
* ⚠️ OMITTING IT IS NOT NEUTRAL. `pickLocalized` reads an absent language as
|
|
365
|
+
* `'en'`, so a locale map resolves through `default` -> `en` -> first value.
|
|
366
|
+
* That is the right answer for a caller with no viewer (a build-time or
|
|
367
|
+
* server-side normalisation) and the WRONG one for a rendering caller — which
|
|
368
|
+
* is why `ChartRenderer` passes it. A caller that reads only structural keys
|
|
369
|
+
* off the result (`resolveChartCategoryField` reads `xAxisKey` and nothing
|
|
370
|
+
* else) resolves no label at all and may omit it.
|
|
371
|
+
*
|
|
372
|
+
* The parameter is optional so that every existing caller keeps compiling and
|
|
373
|
+
* every non-label key keeps its byte-for-byte behaviour; it is NOT optional
|
|
374
|
+
* in the sense of "safe to skip when a heading is on screen".
|
|
155
375
|
*/
|
|
156
|
-
export declare function normalizeChartSchema(schema: unknown): NormalizedChartSchema;
|
|
376
|
+
export declare function normalizeChartSchema(schema: unknown, language?: string | null): NormalizedChartSchema;
|
|
157
377
|
/**
|
|
158
378
|
* Which family an un-annotated series takes when the chart is drawn as a combo,
|
|
159
379
|
* or `undefined` when the chart's own family has no per-series meaning.
|
|
@@ -183,10 +403,11 @@ export declare function comboBaseFamily(chartType: string | undefined): SeriesFa
|
|
|
183
403
|
* same family keeps its own family, so nothing that renders correctly today
|
|
184
404
|
* changes; and an explicit `combo` is returned untouched.
|
|
185
405
|
*
|
|
186
|
-
* Pass the chart's EFFECTIVE family
|
|
187
|
-
*
|
|
406
|
+
* Pass the chart's EFFECTIVE family — the answer depends on what an
|
|
407
|
+
* un-annotated series would otherwise have drawn. A chart that names no family
|
|
408
|
+
* gets `undefined` back: there is no default family to widen (objectui#11520).
|
|
188
409
|
*/
|
|
189
|
-
export declare function effectiveChartFamily<T extends
|
|
410
|
+
export declare function effectiveChartFamily<T extends DeclaredChartFamily | undefined>(chartType: T, series: readonly Pick<NormalizedSeries, 'chartType'>[] | undefined): T | 'combo';
|
|
190
411
|
/**
|
|
191
412
|
* Build a tick formatter from a spec `ChartAxis.format` string.
|
|
192
413
|
*
|
|
@@ -196,8 +417,15 @@ export declare function effectiveChartFamily<T extends ChartFamily | undefined>(
|
|
|
196
417
|
* places — and drives `Intl.NumberFormat`, which is already loaded and
|
|
197
418
|
* locale-aware. An unrecognized format returns `undefined`, so the caller
|
|
198
419
|
* keeps its own default formatting rather than rendering something wrong.
|
|
420
|
+
*
|
|
421
|
+
* `locale` is the chart's DISPLAY locale (`useDisplayLocale()` in the caller)
|
|
422
|
+
* and it is REQUIRED on purpose: this is a plain function with no hook to read
|
|
423
|
+
* it from, and the version that took no locale handed `Intl` an explicit
|
|
424
|
+
* `undefined` — the MACHINE's locale, neither of the repo's two locale
|
|
425
|
+
* channels (objectui#9909). A required parameter is the one shape a caller
|
|
426
|
+
* cannot forget.
|
|
199
427
|
*/
|
|
200
|
-
export declare function formatterFor(format: string | undefined): ((value: any) => string) | undefined;
|
|
428
|
+
export declare function formatterFor(format: string | undefined, locale: string): ((value: any) => string) | undefined;
|
|
201
429
|
export declare function ticksFor(axis: NormalizedAxis | undefined, values: number[]): number[] | undefined;
|
|
202
430
|
/**
|
|
203
431
|
* Recharts `domain` for an axis, or `undefined` to keep the auto domain.
|