@orbcharts/core 3.0.0-alpha.66 → 3.0.0-alpha.67
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,4 +4,4 @@
|
|
4
4
|
|
5
5
|
----> find in '${n}'`}function vt({columnName:t,expectToBe:e,from:n}){return`Value is not correct: '${t}' suppose to be '${e}', it may cause unexpected errors.'
|
6
6
|
|
7
|
-
----> find in '${n}'`}function bc(t){return t?E(t,{width:{toBe:'"auto" | number',test:n=>n==="auto"||typeof n=="number"},height:{toBe:'"auto" | number',test:n=>n==="auto"||typeof n=="number"},preset:{toBeTypes:["object"]}}):{status:"success",columnName:"",expectToBe:""}}function wc(t){return E({element:t},{element:{toBe:"Dom",test:n=>zn(n)}})}function _c(t,e){const n={series:["series","datum","none"],grid:["series","group","datum","none"],multiGrid:["series","group","datum","none"],multiValue:["category","datum","none"],relationship:["category","datum","none"],tree:["category","datum","none"],noneData:["none"]},r=E(e,{padding:{toBeTypes:["object"]},highlightTarget:{toBe:n[t].map(i=>`"${i}"`).join(" | "),test:i=>n[t].includes(i)},highlightDefault:{toBeTypes:["string","null"]},colorScheme:{toBe:'"dark" | "light"',test:i=>i==="dark"||i==="light"},colors:{toBeTypes:["object"],test:i=>i.light&&i.dark},styles:{toBeTypes:["object"]},transitionDuration:{toBeTypes:["number"]},transitionEase:{toBeTypes:["string"]}});if(e&&e.padding){const i=E(e.padding,{top:{toBeTypes:["number"]},right:{toBeTypes:["number"]},bottom:{toBeTypes:["number"]},left:{toBeTypes:["number"]}});if(i.status==="error")return i}if(e&&e.colors){const i=E(e.colors,{light:{toBeTypes:["object"]},dark:{toBeTypes:["object"]}});if(i.status==="error")return i;if(e.colors.light){const o=E(e.colors.light,{series:{toBeTypes:["string[]"]},primary:{toBeTypes:["string"]},secondary:{toBeTypes:["string"]},white:{toBeTypes:["string"]},background:{toBeTypes:["string"]}});if(o.status==="error")return o}if(e.colors.dark){const o=E(e.colors.dark,{series:{toBeTypes:["string[]"]},primary:{toBeTypes:["string"]},secondary:{toBeTypes:["string"]},white:{toBeTypes:["string"]},background:{toBeTypes:["string"]}});if(o.status==="error")return o}}return r}function xc(t,e){return E({pluginEntities:e},{pluginEntities:{toBe:`PluginEntity<'${t}'>[]`,test:r=>Array.isArray(r)&&r.every(i=>i.chartType===t||i.chartType==="noneData")}})}function ji(t,e,n){const r=st(t,e);return n==="multiGrid"&&t.gridList!=null&&(r.gridList=t.gridList.map((i,o)=>{const a=e.gridList[o]||e.gridList[0];return st(i,a)})),r}const Ac=({defaultDataFormatter:t,dataFormatterValidator:e,computedDataFn:n,dataValidator:r,contextObserverCallback:i})=>{const o=new O,a=t.type;return function(u,l){try{const{status:v,columnName:b,expectToBe:y}=bc(l);if(v==="error")throw new Error(yt({columnName:b,expectToBe:y,from:"Chart.constructor"}));if(v==="warning")console.warn(vt({columnName:b,expectToBe:y,from:"Chart.constructor"}));else{const{status:C,columnName:F,expectToBe:V}=wc(u);if(C==="error")throw new Error(yt({columnName:F,expectToBe:V,from:"Chart.constructor"}));C==="warning"&&console.warn(vt({columnName:F,expectToBe:V,from:"Chart.constructor"}))}}catch(v){throw new Error(v)}ie(u).selectAll("svg").remove();const f=ie(u).append("svg");f.attr("xmlns:xlink","http://www.w3.org/1999/xlink").attr("xmls","http://www.w3.org/2000/svg").attr("version","1.1").style("position","absolute").classed("orbcharts__root",!0);const c=f.append("g");c.classed("orbcharts__layout",!0);const h=c.append("g");h.classed("orbcharts__plugins",!0);const d={data$:new O,dataFormatter$:new O,plugins$:new O,chartParams$:new O,event$:new O},p=(v=>{const b=v||at,y=b.preset?b.preset:{};return{name:y.name??"",description:y.description??"",chartParams:y.chartParams?st(y.chartParams,Fe):Fe,dataFormatter:y.dataFormatter?ji(y.dataFormatter,t,a):t,allPluginParams:y.allPluginParams?y.allPluginParams:{}}})(l),g=d.data$.pipe(w(1)),_=d.dataFormatter$.pipe(M(o),$n({}),D(v=>{try{const{status:b,columnName:y,expectToBe:C}=e(v);if(b==="error")throw new Error(yt({columnName:y,expectToBe:C,from:"Chart.dataFormatter$"}));return b==="warning"&&console.warn(vt({columnName:y,expectToBe:C,from:"Chart.dataFormatter$"})),ji(v,p.dataFormatter,a)}catch(b){throw new Error(b)}}),Yt(v=>(console.error(Kt(v)),Et)),w(1)),x=d.chartParams$.pipe(M(o),$n({}),D(v=>{try{const{status:b,columnName:y,expectToBe:C}=_c(a,v);if(b==="error")throw new Error(yt({columnName:y,expectToBe:C,from:"Chart.chartParams$"}));return b==="warning"&&console.warn(vt({columnName:y,expectToBe:C,from:"Chart.chartParams$"})),st(v,p.chartParams)}catch(b){throw new Error(b)}}),Yt(v=>(console.error(Kt(v)),Et)),w(1)),A=x.pipe(M(o),$n({}),D(v=>st(v.padding??{},Ee)));A.pipe(M(o),fc()).subscribe(v=>{c.attr("transform",`translate(${v.left}, ${v.top})`)}),A.subscribe(v=>{c.transition().attr("transform",`translate(${v.left}, ${v.top})`)});const $=mt({width:(l==null?void 0:l.width)??at.width,height:(l==null?void 0:l.height)??at.height}).pipe(R(v=>Fi(()=>v.width==="auto"||v.height==="auto",Oi(u).pipe(D(b=>({width:v.width==="auto"?b.width:v.width,height:v.height==="auto"?b.height:v.height}))),mt(v))),M(o),An()),T=mt().pipe(dc($.pipe(oc(250)),$.pipe(mc(250))),tt((v,b)=>JSON.stringify(v)===JSON.stringify(b)),An()),S=T.subscribe(),k=U({rootSize:T,mergedPadding:A}).pipe(M(o),R(async v=>{const b=v.rootSize.width>0?v.rootSize.width:Bn,y=v.rootSize.height>0?v.rootSize.height:Gn;return{width:b-v.mergedPadding.left-v.mergedPadding.right,height:y-v.mergedPadding.top-v.mergedPadding.bottom,top:v.mergedPadding.top,right:v.mergedPadding.right,bottom:v.mergedPadding.bottom,left:v.mergedPadding.left,rootWidth:b,rootHeight:y}}),w(1));k.subscribe(v=>{f.attr("width",v.rootWidth).attr("height",v.rootHeight)});const N=U({data:g,dataFormatter:_,chartParams:x}).pipe(M(o),R(async v=>v),R(v=>mt(v).pipe(D(b=>{try{const{status:y,columnName:C,expectToBe:F}=r(b.data);if(y==="error")throw new Error(yt({columnName:C,expectToBe:F,from:"Chart.data$"}));return y==="warning"&&console.warn(vt({columnName:C,expectToBe:F,from:"Chart.data$"})),n({data:b.data,dataFormatter:b.dataFormatter,chartParams:b.chartParams})}catch(y){throw new Error(y)}}),Yt(b=>(console.error(Kt(b)),Et)))),w(1));N.subscribe();const I={};return d.plugins$.subscribe(v=>{try{const{status:b,columnName:y,expectToBe:C}=xc(a,v);if(b==="error")throw new Error(yt({columnName:y,expectToBe:C,from:"Chart.plugins$"}));b==="warning"&&console.warn(vt({columnName:y,expectToBe:C,from:"Chart.plugins$"}))}catch(b){throw new Error(b)}h.selectAll("g.orbcharts__plugin").data(v,b=>b.name).join(b=>b.append("g").attr("class",y=>`orbcharts__plugin orbcharts__${y.name}`).each((y,C,F)=>{const V={fullParams$:new L,fullChartParams$:x,fullDataFormatter$:_,computedData$:N,layout$:k},it=i({observer:V,subject:d}),et={selection:ie(F[C]),rootSelection:f,name:y.name,chartType:a,subject:d,observer:it};y.setPresetParams(p.allPluginParams[y.name]??{}),y.setContext(et),I[et.name]=y,y.init()}),b=>b,b=>b.each((y,C,F)=>{I[y.name]&&(I[y.name].destroy(),I[y.name]=void 0)}).remove()).sort((b,y)=>b.layerIndex-y.layerIndex)}),{...d,selection:f,destroy(){ie(u).selectAll("svg").remove(),o.next(void 0),S.unsubscribe()}}}};class Ot{constructor({defaultDataFormatter:e,dataFormatterValidator:n,computedDataFn:r,dataValidator:i,contextObserverCallback:o},a,s){this.data$=new O,this.dataFormatter$=new O,this.plugins$=new O,this.chartParams$=new O,this.event$=new O;try{const l=Ac({defaultDataFormatter:e,dataFormatterValidator:n,computedDataFn:r,dataValidator:i,contextObserverCallback:o})(a,s);this.selection=l.selection,this.destroy=l.destroy,this.data$=l.data$,this.dataFormatter$=l.dataFormatter$,this.plugins$=l.plugins$,this.chartParams$=l.chartParams$,this.event$=l.event$}catch(u){console.error(Kt(u))}}}class Dc extends Ot{constructor(e,n){super({defaultDataFormatter:Le,dataFormatterValidator:eo,computedDataFn:al,dataValidator:sl,contextObserverCallback:gc},e,n)}}const $c=t=>{const e=E(t,{visibleFilter:{toBeTypes:["Function"]},grid:{toBeTypes:["object"]},container:{toBeTypes:["object"]}});if(t.grid){const n=E(t.grid,{seriesDirection:{toBe:'"row" | "column"',test:r=>r==="row"||r==="column"},rowLabels:{toBeTypes:["string[]"]},columnLabels:{toBeTypes:["string[]"]},valueAxis:{toBeTypes:["object"]},groupAxis:{toBeTypes:["object"]},separateSeries:{toBeTypes:["boolean"]}});if(n.status==="error")return n;if(t.grid.valueAxis){const r=E(t.grid.valueAxis,{position:{toBe:'"left" | "right"',test:i=>i==="left"||i==="right"},scaleDomain:{toBe:'[number | "min" | "auto", number | "max" | "auto"]',test:i=>Array.isArray(i)&&i.length===2&&(typeof i[0]=="number"||i[0]==="min"||i[0]==="auto")&&(typeof i[1]=="number"||i[1]==="max"||i[1]==="auto")},scaleRange:{toBe:"[number, number]",test:i=>Array.isArray(i)&&i.length===2&&typeof i[0]=="number"&&typeof i[1]=="number"},label:{toBeTypes:["string"]}});if(r.status==="error")return r}if(t.grid.groupAxis){const r=E(t.grid.groupAxis,{position:{toBe:'"top" | "bottom"',test:i=>i==="top"||i==="bottom"},scaleDomain:{toBe:'[number, number | "max"]',test:i=>Array.isArray(i)&&i.length===2&&typeof i[0]=="number"&&(typeof i[1]=="number"||i[1]==="max")},scalePadding:{toBeTypes:["number"]},label:{toBeTypes:["string"]}});if(r.status==="error")return r}}if(t.container){const n=E(t.container,{gap:{toBeTypes:["number"]},rowAmount:{toBeTypes:["number"]},columnAmount:{toBeTypes:["number"]}});if(n.status==="error")return n}return e};function Xi(t,e){if(!t.length)return[];try{const n=t.reduce((a,s)=>s.length>a?s.length:a,0),i=t.map((a,s)=>{if(a.length===n)return a;const u=Object.assign([],a);for(let l=u.length;l<n;l++)u[l]=null;return u}).map((a,s)=>a.map((u,l)=>u==null?{id:"",label:"",data:{},value:null}:typeof u=="number"?{id:"",label:"",data:{},value:u}:{id:u.id??"",label:u.label??"",data:u.data??{},value:u.value}));return Qr(e.seriesDirection,i)}catch{return[]}}const Tc=t=>{const{data:e=[],dataFormatter:n,chartParams:r}=t;if(!e.length)return[];let i;try{const o=Xi(e,n.grid),a=un({transposedDataGrid:o,dataFormatterGrid:n.grid,chartType:"grid"}),s=Kr({transposedDataGrid:o,dataFormatterGrid:n.grid,chartType:"grid"});let u=0;i=o.map((l,f)=>l.map((c,h)=>{const d=Ht("grid",0,f,h),p=s[h],g={id:c.id?c.id:d,index:u,label:c.label?c.label:d,description:c.description??"",data:c.data,value:c.value,gridIndex:0,seriesIndex:f,seriesLabel:a[f],groupIndex:h,groupLabel:p,color:jt(f,r),visible:!0};return g.visible=n.visibleFilter(g,t),u++,g}))}catch(o){throw Error(o)}return i},Sc=t=>E({data:t},{data:{toBe:"(DataGridDatum | DataGridValue)[][]",test:n=>Array.isArray(n)}}),Cc=({subject:t,observer:e})=>{const n=Jt(e.fullChartParams$).pipe(w(1)),r=e.fullDataFormatter$.pipe(D($=>$.grid.separateSeries),tt(),w(1)),i=Gi({computedData$:e.computedData$,fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$}),o=Mn({fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$}).pipe(w(1)),a=En({gridAxesTransform$:o}).pipe(w(1)),s=Fn({computedData$:e.computedData$,fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$}).pipe(w(1)),u=Ln({gridContainerPosition$:i,gridAxesTransform$:o,gridGraphicTransform$:s}),l=On({fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$}).pipe(w(1)),f=e.computedData$.pipe(D($=>$.flat())).pipe(w(1)),c=Wt({datumList$:f,fullChartParams$:e.fullChartParams$,event$:t.event$}).pipe(w(1)),h=Pn({computedData$:e.computedData$}),d=Ce({datumList$:f}).pipe(w(1)),p=Tn({datumList$:f}).pipe(w(1)),g=Cn({computedData$:e.computedData$,fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$}).pipe(w(1)),_=Rn({computedData$:e.computedData$}).pipe(w(1)),x=Nn({computedLayoutData$:g}).pipe(w(1)),A=In({computedData$:e.computedData$,isSeriesSeprate$:r}).pipe(w(1));return{fullParams$:e.fullParams$,fullChartParams$:e.fullChartParams$,fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$,textSizePx$:n,isSeriesSeprate$:r,gridContainerPosition$:i,gridAxesTransform$:o,gridAxesReverseTransform$:a,gridGraphicTransform$:s,gridGraphicReverseScale$:u,gridAxesSize$:l,gridHighlight$:c,seriesLabels$:h,SeriesDataMap$:d,GroupDataMap$:p,computedLayoutData$:g,visibleComputedData$:_,visibleComputedLayoutData$:x,computedStackedData$:A}};class Mc extends Ot{constructor(e,n){super({defaultDataFormatter:Pe,dataFormatterValidator:$c,computedDataFn:Tc,dataValidator:Sc,contextObserverCallback:Cc},e,n)}}const Ec=t=>{const e=E(t,{visibleFilter:{toBeTypes:["Function"]},gridList:{toBeTypes:["object[]"]},container:{toBeTypes:["object"]},separateGrid:{toBeTypes:["boolean"]}});if(t.gridList){const r=t.gridList.map((i,o)=>{const a=E(i,{seriesDirection:{toBe:'"row" | "column"',test:s=>s==="row"||s==="column"},rowLabels:{toBeTypes:["string[]"]},columnLabels:{toBeTypes:["string[]"]},valueAxis:{toBeTypes:["object"]},groupAxis:{toBeTypes:["object"]},separateSeries:{toBeTypes:["boolean"]}});if(a.status==="error")return a;if(i.valueAxis){const s=E(i.valueAxis,{position:{toBe:'"top" | "bottom" | "left" | "right"',test:u=>u==="top"||u==="bottom"||u==="left"||u==="right"},scaleDomain:{toBe:'[number | "min" | "auto", number | "max" | "auto"]',test:u=>Array.isArray(u)&&u.length===2&&(typeof u[0]=="number"||u[0]==="min"||u[0]==="auto")&&(typeof u[1]=="number"||u[1]==="max"||u[1]==="auto")},scaleRange:{toBe:"[number, number]",test:u=>Array.isArray(u)&&u.length===2&&typeof u[0]=="number"&&typeof u[1]=="number"},label:{toBeTypes:["string"]}});if(s.status==="error")return s}else if(i.groupAxis){const s=E(i.groupAxis,{position:{toBe:'"top" | "bottom" | "left" | "right"',test:u=>u==="top"||u==="bottom"||u==="left"||u==="right"},scaleDomain:{toBe:'[number, number | "max"]',test:u=>Array.isArray(u)&&u.length===2&&typeof u[0]=="number"&&(typeof u[1]=="number"||u[1]==="max")},scalePadding:{toBeTypes:["number"]},label:{toBeTypes:["string"]}});if(s.status==="error")return s}return{status:"success",columnName:"",expectToBe:""}}).find(i=>i.status==="error");if(r.status==="error")return r}if(t.container){const n=E(t.container,{gap:{toBeTypes:["number"]},rowAmount:{toBeTypes:["number"]},columnAmount:{toBeTypes:["number"]}});if(n.status==="error")return n}return e},Fc=t=>{const{data:e=[],dataFormatter:n,chartParams:r}=t;if(!e.length)return[];let i=[];try{const o=n.gridList[0]||Pt,a=e.map((c,h)=>n.gridList[h]||o),s=e.map((c,h)=>Xi(c,a[h])),u=n.separateGrid?s.map((c,h)=>un({transposedDataGrid:c,dataFormatterGrid:a[h],chartType:"multiGrid"})):s.map((c,h)=>Jr({transposedDataGrid:c,dataFormatterGrid:a[h],chartType:"multiGrid",gridIndex:h})),l=new Map;let f=0;u.flat().forEach((c,h)=>{if(!l.has(c)){const d=jt(f,r);l.set(c,d),f++}}),i=s.map((c,h)=>{const d=u[h],p=Zr({transposedDataGrid:c,dataFormatterGrid:a[h],chartType:"multiGrid",gridIndex:h});let g=0;return c.map((x,A)=>x.map(($,T)=>{const S=Ht("multiGrid",h,A,T),k=p[T],N=d[A],I={id:$.id?$.id:S,index:g,label:$.label?$.label:S,description:$.description??"",data:$.data,value:$.value,gridIndex:h,seriesIndex:A,seriesLabel:N,groupIndex:T,groupLabel:k,color:l.get(N),visible:!0};return I.visible=n.visibleFilter(I,t),g++,I}))})}catch(o){throw Error(o)}return i},Lc=t=>E({data:t},{data:{toBe:"DataGrid[]",test:n=>Array.isArray(n)}}),Oc=({subject:t,observer:e})=>{const n=Jt(e.fullChartParams$).pipe(w(1)),r=Vi({fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$,fullChartParams$:e.fullChartParams$,event$:t.event$}).pipe(w(1)),i=kn({computedData$:e.computedData$,fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$});return{fullParams$:e.fullParams$,fullChartParams$:e.fullChartParams$,fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$,textSizePx$:n,multiGridContainerPosition$:i,multiGridEachDetail$:r}};class Pc extends Ot{constructor(e,n){super({defaultDataFormatter:Re,dataFormatterValidator:Ec,computedDataFn:Fc,dataValidator:Lc,contextObserverCallback:Oc},e,n)}}const Rc=t=>({status:"success",columnName:"",expectToBe:""}),Nc=t=>{const{data:e,dataFormatter:n,chartParams:r}=t;if(!e.length)return[];const i={width:1e3,height:1e3};let o=[];try{const a=e.map((A,$)=>A.map((T,S)=>typeof T=="number"?{id:"",label:"",description:"",data:{},categoryLabel:"",value:T}:{id:T.id??"",label:T.label??"",description:T.description??"",data:T.data??{},categoryLabel:T.categoryLabel??"",value:T.value})),[s,u]=Ae(a.map(A=>A[0])),[l,f]=Ae(a.map(A=>A[1])),c=n.xAxis.position==="top"||n.xAxis.position==="bottom"?i.width:i.height,h=n.yAxis.position==="left"||n.yAxis.position==="right"?i.height:i.width,d=gt({maxValue:u,minValue:s,axisWidth:c,scaleDomain:[s,u],scaleRange:[0,1]}),p=gt({maxValue:f,minValue:l,axisWidth:h,scaleDomain:[l,f],scaleRange:[0,1]}),g=[n.xAxis.scaleDomain[0]==="auto"?s<0?s:0:n.xAxis.scaleDomain[0]==="min"?s:n.xAxis.scaleDomain[0],n.xAxis.scaleDomain[1]==="auto"?u>=0?u:0:n.xAxis.scaleDomain[1]==="max"?u:n.xAxis.scaleDomain[1]],_=[n.yAxis.scaleDomain[0]==="auto"?s<0?s:0:n.yAxis.scaleDomain[0]==="min"?s:n.yAxis.scaleDomain[0],n.yAxis.scaleDomain[1]==="auto"?u>=0?u:0:n.yAxis.scaleDomain[1]==="max"?u:n.yAxis.scaleDomain[1]];let x=0;o=a.map((A,$)=>A.map((T,S)=>{const k=x;x++;const N=Ht(n.type,$,S),I={id:T.id?T.id:N,index:k,label:T.label?T.label:N,description:T.description??"",data:T.data,value:T.value,categoryIndex:0,categoryLabel:"",axis:S==0?d(T.value):p(T.value),visible:!0,color:""};return I.visible=n.visibleFilter(I,t),I}))}catch(a){throw Error(a)}return o},Ic=t=>({status:"success",columnName:"",expectToBe:""}),kc=({subject:t,observer:e})=>({fullParams$:e.fullParams$,fullChartParams$:e.fullChartParams$,fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$});class Bc extends Ot{constructor(e,n){super({defaultDataFormatter:Ne,dataFormatterValidator:Rc,computedDataFn:Nc,dataValidator:Ic,contextObserverCallback:kc},e,n)}}const Gc=t=>({status:"success",columnName:"",expectToBe:""}),Vc=t=>{const{data:e,dataFormatter:n,chartParams:r}=t;let i=[],o=[];try{let a=[],s=[];if(e.nodes)a=e.nodes,s=e.edges;else if(e[0])a=e[0],s=e[1];else return{nodes:[],edges:[]};i=a.map((c,h)=>({id:c.id,index:h,label:c.label??"",description:c.description??"",data:c.data??{},value:c.value??0,categoryIndex:0,categoryLabel:"",color:"",startNodes:[],startNodeIds:[],endNodes:[],endNodeIds:[],visible:!0}));const u=new Map(i.map(c=>[c.id,c]));o=s.map((c,h)=>({id:c.id,index:h,label:c.label??"",description:c.description??"",data:c.data??{},value:c.value??0,startNode:u.get(c.start),startNodeId:c.start,endNode:u.get(c.end),endNodeId:c.end,visible:!0}));const l=function(){const c=new Map;return o.forEach(h=>{const d=c.get(h.endNodeId)??[];d.push(h.startNode),c.set(h.endNodeId,d)}),c}(),f=function(){const c=new Map;return o.forEach(h=>{const d=c.get(h.startNodeId)??[];d.push(h.endNode),c.set(h.startNodeId,d)}),c}();Array.from(u).forEach(([c,h])=>{h.startNodes=l.get(c),h.startNodeIds=h.startNodes.map(d=>d.id),h.endNodes=f.get(c),h.endNodeIds=h.endNodes.map(d=>d.id),h.visible=n.visibleFilter(h,t)}),o=o.map(c=>(c.visible=!!(c.startNode.visible&&c.endNode.visible),c))}catch(a){throw Error(a)}return{nodes:i,edges:o}},Uc=t=>({status:"success",columnName:"",expectToBe:""}),zc=({subject:t,observer:e})=>({fullParams$:e.fullParams$,fullChartParams$:e.fullChartParams$,fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$});class Hc extends Ot{constructor(e,n){super({defaultDataFormatter:ke,dataFormatterValidator:Gc,computedDataFn:Vc,dataValidator:Uc,contextObserverCallback:zc},e,n)}}const jc=t=>E(t,{visibleFilter:{toBeTypes:["Function"]},categoryLabels:{toBeTypes:["string[]"]}}),Xc=t=>{const{data:e=[],dataFormatter:n,chartParams:r}=t,i=new Map(n.categoryLabels.map((a,s)=>[a,s]));let o={id:"",index:0,label:"",description:"",categoryIndex:0,categoryLabel:"",color:"",visible:!0,data:{},value:0,level:0,seq:0,children:[]};try{const a=function(){if(H(e)===!0)return JSON.parse(JSON.stringify(e));if(Array.isArray(e)===!1)return{id:""};let l;const f=new Map;e.forEach(h=>{if(!h.parent)l=h;else{const d=f.get(h.parent)??[];d.push(h),f.set(h.parent,d)}});const c=h=>({id:h.id,label:h.label,data:h.data,value:h.value,categoryLabel:h.categoryLabel,children:(f.get(h.id)??[]).map(d=>c(d))});return l?c(l):{id:""}}();let s=0;const u=(l,f,c)=>{const h=f+1,d=l.categoryLabel??null;let p=0;d!=null&&(i.has(d)||i.set(d,i.size),p=i.get(d)??0);const g=s;s++;const _={id:l.id,index:g,level:f,seq:c,label:l.label??"",description:l.description??"",categoryIndex:p,categoryLabel:d,color:jt(p,r),data:l.data??{},value:l.value,visible:!0,children:(l.children??[]).map((x,A)=>u(x,h,A))};return _.visible=n.visibleFilter(_,t),_};o=u(a,0,0)}catch(a){throw Error(a)}return o},qc=t=>E({data:t},{data:{toBe:"DataTreeObj | DataTreeDatum[]",test:n=>H(n)&&n.id!==void 0}}),Yc=({subject:t,observer:e})=>{const n=Jt(e.fullChartParams$).pipe(w(1)),r=Ui({computedData$:e.computedData$}).pipe(w(1)),i=Wt({datumList$:r,fullChartParams$:e.fullChartParams$,event$:t.event$}).pipe(w(1)),o=zi({nodeList$:r,fullDataFormatter$:e.fullDataFormatter$}).pipe(w(1)),a=Pi({datumList$:r}).pipe(w(1)),s=Hi({computedData$:e.computedData$}).pipe(w(1));return{fullParams$:e.fullParams$,fullChartParams$:e.fullChartParams$,fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$,textSizePx$:n,treeHighlight$:i,existCategoryLabels$:o,CategoryDataMap$:a,visibleComputedData$:s}};class Wc extends Ot{constructor(e,n){super({defaultDataFormatter:Ie,dataFormatterValidator:jc,computedDataFn:Xc,dataValidator:qc,contextObserverCallback:Yc},e,n)}}function Jc({chartType:t,config:e,initFn:n}){const r=new O,i=new WeakMap;let o=()=>{},a;const s=new ci(e.defaultParams),u=new ci({}),l=s.pipe(R(f=>u.pipe(M(r),D(c=>{try{const{status:h,columnName:d,expectToBe:p}=e.validator(c,{validateColumns:E});if(h==="error")throw new Error(yt({columnName:d,expectToBe:p,from:`${e.name}.params$`}));return h==="warning"&&console.warn(vt({columnName:d,expectToBe:p,from:`${e.name}.params$`})),st(c,f)}catch(h){throw new Error(h.message)}}),Yt(c=>(console.error(Kt(c)),Et)))),w(1));return{params$:u,name:e.name,chartType:t,defaultParams:e.defaultParams,layerIndex:e.layerIndex,init(){a&&(o=n(a)??(()=>{}),i.set(a.selection,a))},destroy(){o(),a&&(a.selection.remove(),a=void 0),r.next(void 0)},setPresetParams:f=>{s.next(st(f,e.defaultParams))},setContext:f=>{a=f,a.observer.fullParams$=l}}}const bt=t=>function(n){return function(i){return class{constructor(){const a=Jc({chartType:t,config:n,initFn:i});this.params$=a.params$,this.name=a.name,this.chartType=a.chartType,this.defaultParams=a.defaultParams,this.layerIndex=a.layerIndex,this.init=a.init,this.destroy=a.destroy,this.setPresetParams=a.setPresetParams,this.setContext=a.setContext}}}},Kc=bt("series"),Zc=bt("grid"),Qc=bt("multiGrid"),tf=bt("multiValue"),ef=bt("noneData"),nf=bt("relationship"),rf=bt("tree");m.CHART_HEIGHT_DEFAULT=Gn,m.CHART_OPTIONS_DEFAULT=at,m.CHART_PARAMS_DEFAULT=Fe,m.CHART_WIDTH_DEFAULT=Bn,m.DATA_FORMATTER_CONTAINER_DEFAULT=Zt,m.DATA_FORMATTER_GRID_DEFAULT=Pe,m.DATA_FORMATTER_GRID_GRID_DEFAULT=Oe,m.DATA_FORMATTER_GROUP_AXIS_DEFAULT=Vn,m.DATA_FORMATTER_MULTI_GRID_DEFAULT=Re,m.DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT=Pt,m.DATA_FORMATTER_MULTI_VALUE_DEFAULT=Ne,m.DATA_FORMATTER_RELATIONAL_DEFAULT=ke,m.DATA_FORMATTER_SERIES_DEFAULT=Le,m.DATA_FORMATTER_TREE_DEFAULT=Ie,m.DATA_FORMATTER_VALUE_AXIS_DEFAULT=J,m.DATA_GRID_DEFAULT=Yi,m.DATA_MULTI_GRID_DEFAULT=Wi,m.DATA_MULTI_VALUE_DEFAULT=Ji,m.DATA_RELATIONA_DEFAULTL=Zi,m.DATA_SERIES_DEFAULT=qi,m.DATA_TREE_DEFAULT=Ki,m.GridChart=Mc,m.MultiGridChart=Pc,m.MultiValueChart=Bc,m.PADDING_DEFAULT=Ee,m.RelationshipChart=Hc,m.SeriesChart=Dc,m.TreeChart=Wc,m.calcGridContainerLayout=De,m.calcSeriesContainerLayout=cn,m.categoryDataMapObservable=Pi,m.computedStackedDataObservables=In,m.createAxisLinearScale=gt,m.createAxisPointScale=yc,m.createAxisQuantizeScale=vc,m.createDefaultDatumId=Ht,m.createDefaultGroupLabel=sn,m.createDefaultSeriesLabel=xe,m.createGridGroupLabels=Kr,m.createGridSeriesLabels=un,m.createMultiGridGroupLabels=Zr,m.createMultiGridSeriesLabels=Jr,m.defineGridPlugin=Zc,m.defineMultiGridPlugin=Qc,m.defineMultiValuePlugin=tf,m.defineNoneDataPlugin=ef,m.defineRelationshipPlugin=nf,m.defineSeriesPlugin=Kc,m.defineTreePlugin=rf,m.existCategoryLabelsObservable=zi,m.formatCommaNumber=Qi,m.formatValueToLabel=nl,m.getMinAndMax=Tt,m.getMinAndMaxGrid=ln,m.getMinAndMaxMultiGrid=il,m.getMinAndMaxMultiValue=ol,m.getMinAndMaxSeries=rl,m.getMinAndMaxValue=Ae,m.gridAxesReverseTransformObservable=En,m.gridAxesSizeObservable=On,m.gridAxesTransformObservable=Mn,m.gridComputedLayoutDataObservable=Cn,m.gridContainerPositionObservable=Gi,m.gridGraphicReverseScaleObservable=Ln,m.gridGraphicTransformObservable=Fn,m.gridSeriesLabelsObservable=Pn,m.gridVisibleComputedDataObservable=Rn,m.gridVisibleComputedLayoutDataObservable=Nn,m.groupDataMapObservable=Tn,m.highlightObservable=Wt,m.isDom=zn,m.isFunction=Un,m.isPlainObject=H,m.mergeOptionsWithDefault=st,m.multiGridContainerObservable=kn,m.multiGridEachDetailObservable=Vi,m.nodeListObservable=Ui,m.resizeObservable=Oi,m.separateSeriesObservable=Ri,m.seriesColorPredicate=jt,m.seriesComputedLayoutDataObservable=Ii,m.seriesContainerPositionMapObservable=Bi,m.seriesContainerPositionObservable=ki,m.seriesDataMapObservable=Ce,m.seriesLabelsObservable=Ni,m.seriesVisibleComputedDataObservable=Sn,m.textSizePxObservable=Jt,m.transposeData=Qr,m.treeVisibleComputedDataObservable=Hi,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
7
|
+
----> find in '${n}'`}function bc(t){return t?E(t,{width:{toBe:'"auto" | number',test:n=>n==="auto"||typeof n=="number"},height:{toBe:'"auto" | number',test:n=>n==="auto"||typeof n=="number"},preset:{toBeTypes:["object"]}}):{status:"success",columnName:"",expectToBe:""}}function wc(t){return E({element:t},{element:{toBe:"Dom",test:n=>zn(n)}})}function _c(t,e){const n={series:["series","datum","none"],grid:["series","group","datum","none"],multiGrid:["series","group","datum","none"],multiValue:["category","datum","none"],relationship:["category","datum","none"],tree:["category","datum","none"],noneData:["none"]},r=E(e,{padding:{toBeTypes:["object"]},highlightTarget:{toBe:n[t].map(i=>`"${i}"`).join(" | "),test:i=>n[t].includes(i)},highlightDefault:{toBeTypes:["string","null"]},colorScheme:{toBe:'"dark" | "light"',test:i=>i==="dark"||i==="light"},colors:{toBeTypes:["object"],test:i=>i.light&&i.dark},styles:{toBeTypes:["object"]},transitionDuration:{toBeTypes:["number"]},transitionEase:{toBeTypes:["string"]}});if(e&&e.padding){const i=E(e.padding,{top:{toBeTypes:["number"]},right:{toBeTypes:["number"]},bottom:{toBeTypes:["number"]},left:{toBeTypes:["number"]}});if(i.status==="error")return i}if(e&&e.colors){const i=E(e.colors,{light:{toBeTypes:["object"]},dark:{toBeTypes:["object"]}});if(i.status==="error")return i;if(e.colors.light){const o=E(e.colors.light,{series:{toBeTypes:["string[]"]},primary:{toBeTypes:["string"]},secondary:{toBeTypes:["string"]},white:{toBeTypes:["string"]},background:{toBeTypes:["string"]}});if(o.status==="error")return o}if(e.colors.dark){const o=E(e.colors.dark,{series:{toBeTypes:["string[]"]},primary:{toBeTypes:["string"]},secondary:{toBeTypes:["string"]},white:{toBeTypes:["string"]},background:{toBeTypes:["string"]}});if(o.status==="error")return o}}return r}function xc(t,e){return E({pluginEntities:e},{pluginEntities:{toBe:`PluginEntity<'${t}'>[]`,test:r=>Array.isArray(r)&&r.every(i=>i.chartType===t||i.chartType==="noneData")}})}function ji(t,e,n){const r=st(t,e);return n==="multiGrid"&&t.gridList!=null&&(r.gridList=t.gridList.map((i,o)=>{const a=e.gridList[o]||e.gridList[0];return st(i,a)})),r}const Ac=({defaultDataFormatter:t,dataFormatterValidator:e,computedDataFn:n,dataValidator:r,contextObserverCallback:i})=>{const o=new O,a=t.type;return function(u,l){try{const{status:v,columnName:b,expectToBe:y}=bc(l);if(v==="error")throw new Error(yt({columnName:b,expectToBe:y,from:"Chart.constructor"}));if(v==="warning")console.warn(vt({columnName:b,expectToBe:y,from:"Chart.constructor"}));else{const{status:C,columnName:F,expectToBe:V}=wc(u);if(C==="error")throw new Error(yt({columnName:F,expectToBe:V,from:"Chart.constructor"}));C==="warning"&&console.warn(vt({columnName:F,expectToBe:V,from:"Chart.constructor"}))}}catch(v){throw new Error(v)}ie(u).selectAll("svg").remove();const f=ie(u).append("svg");f.attr("xmlns:xlink","http://www.w3.org/1999/xlink").attr("xmls","http://www.w3.org/2000/svg").attr("version","1.1").style("position","absolute").classed("orbcharts__root",!0);const c=f.append("g");c.classed("orbcharts__layout",!0);const h=c.append("g");h.classed("orbcharts__plugins",!0);const d={data$:new O,dataFormatter$:new O,plugins$:new O,chartParams$:new O,event$:new O},p=(v=>{const b=v||at,y=b.preset?b.preset:{};return{name:y.name??"",description:y.description??"",chartParams:y.chartParams?st(y.chartParams,Fe):Fe,dataFormatter:y.dataFormatter?ji(y.dataFormatter,t,a):t,allPluginParams:y.allPluginParams?y.allPluginParams:{}}})(l),g=d.data$.pipe(w(1)),_=d.dataFormatter$.pipe(M(o),$n({}),D(v=>{try{const{status:b,columnName:y,expectToBe:C}=e(v);if(b==="error")throw new Error(yt({columnName:y,expectToBe:C,from:"Chart.dataFormatter$"}));return b==="warning"&&console.warn(vt({columnName:y,expectToBe:C,from:"Chart.dataFormatter$"})),ji(v,p.dataFormatter,a)}catch(b){throw new Error(b)}}),Yt(v=>(console.error(Kt(v)),Et)),w(1)),x=d.chartParams$.pipe(M(o),$n({}),D(v=>{try{const{status:b,columnName:y,expectToBe:C}=_c(a,v);if(b==="error")throw new Error(yt({columnName:y,expectToBe:C,from:"Chart.chartParams$"}));return b==="warning"&&console.warn(vt({columnName:y,expectToBe:C,from:"Chart.chartParams$"})),st(v,p.chartParams)}catch(b){throw new Error(b)}}),Yt(v=>(console.error(Kt(v)),Et)),w(1)),A=x.pipe(M(o),$n({}),D(v=>st(v.padding??{},Ee)));A.pipe(M(o),fc()).subscribe(v=>{c.attr("transform",`translate(${v.left}, ${v.top})`)}),A.subscribe(v=>{c.transition().attr("transform",`translate(${v.left}, ${v.top})`)});const $=mt({width:(l==null?void 0:l.width)??at.width,height:(l==null?void 0:l.height)??at.height}).pipe(R(v=>Fi(()=>v.width==="auto"||v.height==="auto",Oi(u).pipe(D(b=>({width:v.width==="auto"?b.width:v.width,height:v.height==="auto"?b.height:v.height}))),mt(v))),M(o),An()),T=mt().pipe(dc($.pipe(oc(250)),$.pipe(mc(250))),tt((v,b)=>JSON.stringify(v)===JSON.stringify(b)),An()),S=T.subscribe(),k=U({rootSize:T,mergedPadding:A}).pipe(M(o),R(async v=>{const b=v.rootSize.width>0?v.rootSize.width:Bn,y=v.rootSize.height>0?v.rootSize.height:Gn;return{width:b-v.mergedPadding.left-v.mergedPadding.right,height:y-v.mergedPadding.top-v.mergedPadding.bottom,top:v.mergedPadding.top,right:v.mergedPadding.right,bottom:v.mergedPadding.bottom,left:v.mergedPadding.left,rootWidth:b,rootHeight:y}}),w(1));k.subscribe(v=>{f.attr("width",v.rootWidth).attr("height",v.rootHeight)});const N=U({data:g,dataFormatter:_,chartParams:x}).pipe(M(o),R(async v=>v),R(v=>mt(v).pipe(D(b=>{try{const{status:y,columnName:C,expectToBe:F}=r(b.data);if(y==="error")throw new Error(yt({columnName:C,expectToBe:F,from:"Chart.data$"}));return y==="warning"&&console.warn(vt({columnName:C,expectToBe:F,from:"Chart.data$"})),n({data:b.data,dataFormatter:b.dataFormatter,chartParams:b.chartParams})}catch(y){throw new Error(y)}}),Yt(b=>(console.error(Kt(b)),Et)))),w(1));N.subscribe();const I={};return d.plugins$.subscribe(v=>{try{const{status:b,columnName:y,expectToBe:C}=xc(a,v);if(b==="error")throw new Error(yt({columnName:y,expectToBe:C,from:"Chart.plugins$"}));b==="warning"&&console.warn(vt({columnName:y,expectToBe:C,from:"Chart.plugins$"}))}catch(b){throw new Error(b)}h.selectAll("g.orbcharts__plugin").data(v,b=>b.name).join(b=>b.append("g").attr("class",y=>`orbcharts__plugin orbcharts__${y.name}`).each((y,C,F)=>{const V={fullParams$:new L,fullChartParams$:x,fullDataFormatter$:_,computedData$:N,layout$:k},it=i({observer:V,subject:d}),et={selection:ie(F[C]),rootSelection:f,name:y.name,chartType:a,subject:d,observer:it};y.setPresetParams(p.allPluginParams[y.name]??{}),y.setContext(et),I[et.name]=y,y.init()}),b=>b,b=>b.each((y,C,F)=>{I[y.name]&&(I[y.name].destroy(),I[y.name]=void 0)}).remove()).sort((b,y)=>b.layerIndex-y.layerIndex)}),{...d,selection:f,destroy(){ie(u).selectAll("svg").remove(),o.next(void 0),S.unsubscribe()}}}};class Ot{constructor({defaultDataFormatter:e,dataFormatterValidator:n,computedDataFn:r,dataValidator:i,contextObserverCallback:o},a,s){this.data$=new O,this.dataFormatter$=new O,this.plugins$=new O,this.chartParams$=new O,this.event$=new O;try{const l=Ac({defaultDataFormatter:e,dataFormatterValidator:n,computedDataFn:r,dataValidator:i,contextObserverCallback:o})(a,s);this.selection=l.selection,this.destroy=l.destroy,this.data$=l.data$,this.dataFormatter$=l.dataFormatter$,this.plugins$=l.plugins$,this.chartParams$=l.chartParams$,this.event$=l.event$}catch(u){console.error(Kt(u))}}}class Dc extends Ot{constructor(e,n){super({defaultDataFormatter:Le,dataFormatterValidator:eo,computedDataFn:al,dataValidator:sl,contextObserverCallback:gc},e,n)}}const $c=t=>{const e=E(t,{visibleFilter:{toBeTypes:["Function"]},grid:{toBeTypes:["object"]},container:{toBeTypes:["object"]}});if(t.grid){const n=E(t.grid,{seriesDirection:{toBe:'"row" | "column"',test:r=>r==="row"||r==="column"},rowLabels:{toBeTypes:["string[]"]},columnLabels:{toBeTypes:["string[]"]},valueAxis:{toBeTypes:["object"]},groupAxis:{toBeTypes:["object"]},separateSeries:{toBeTypes:["boolean"]}});if(n.status==="error")return n;if(t.grid.valueAxis){const r=E(t.grid.valueAxis,{position:{toBe:'"left" | "right"',test:i=>i==="left"||i==="right"},scaleDomain:{toBe:'[number | "min" | "auto", number | "max" | "auto"]',test:i=>Array.isArray(i)&&i.length===2&&(typeof i[0]=="number"||i[0]==="min"||i[0]==="auto")&&(typeof i[1]=="number"||i[1]==="max"||i[1]==="auto")},scaleRange:{toBe:"[number, number]",test:i=>Array.isArray(i)&&i.length===2&&typeof i[0]=="number"&&typeof i[1]=="number"},label:{toBeTypes:["string"]}});if(r.status==="error")return r}if(t.grid.groupAxis){const r=E(t.grid.groupAxis,{position:{toBe:'"top" | "bottom"',test:i=>i==="top"||i==="bottom"},scaleDomain:{toBe:'[number, number | "max"]',test:i=>Array.isArray(i)&&i.length===2&&typeof i[0]=="number"&&(typeof i[1]=="number"||i[1]==="max")},scalePadding:{toBeTypes:["number"]},label:{toBeTypes:["string"]}});if(r.status==="error")return r}}if(t.container){const n=E(t.container,{gap:{toBeTypes:["number"]},rowAmount:{toBeTypes:["number"]},columnAmount:{toBeTypes:["number"]}});if(n.status==="error")return n}return e};function Xi(t,e){if(!t.length)return[];try{const n=t.reduce((a,s)=>s.length>a?s.length:a,0),i=t.map((a,s)=>{if(a.length===n)return a;const u=Object.assign([],a);for(let l=u.length;l<n;l++)u[l]=null;return u}).map((a,s)=>a.map((u,l)=>u==null?{id:"",label:"",data:{},value:null}:typeof u=="number"?{id:"",label:"",data:{},value:u}:{id:u.id??"",label:u.label??"",data:u.data??{},value:u.value}));return Qr(e.seriesDirection,i)}catch{return[]}}const Tc=t=>{const{data:e=[],dataFormatter:n,chartParams:r}=t;if(!e.length)return[];let i;try{const o=Xi(e,n.grid),a=un({transposedDataGrid:o,dataFormatterGrid:n.grid,chartType:"grid"}),s=Kr({transposedDataGrid:o,dataFormatterGrid:n.grid,chartType:"grid"});let u=0;i=o.map((l,f)=>l.map((c,h)=>{const d=Ht("grid",0,f,h),p=s[h],g={id:c.id?c.id:d,index:u,label:c.label?c.label:d,description:c.description??"",data:c.data,value:c.value,gridIndex:0,seriesIndex:f,seriesLabel:a[f],groupIndex:h,groupLabel:p,color:jt(f,r),visible:!0};return g.visible=n.visibleFilter(g,t),u++,g}))}catch(o){throw Error(o)}return i},Sc=t=>E({data:t},{data:{toBe:"(DataGridDatum | DataGridValue)[][]",test:n=>Array.isArray(n)}}),Cc=({subject:t,observer:e})=>{const n=Jt(e.fullChartParams$).pipe(w(1)),r=e.fullDataFormatter$.pipe(D($=>$.grid.separateSeries),tt(),w(1)),i=Gi({computedData$:e.computedData$,fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$}),o=Mn({fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$}).pipe(w(1)),a=En({gridAxesTransform$:o}).pipe(w(1)),s=Fn({computedData$:e.computedData$,fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$}).pipe(w(1)),u=Ln({gridContainerPosition$:i,gridAxesTransform$:o,gridGraphicTransform$:s}),l=On({fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$}).pipe(w(1)),f=e.computedData$.pipe(D($=>$.flat())).pipe(w(1)),c=Wt({datumList$:f,fullChartParams$:e.fullChartParams$,event$:t.event$}).pipe(w(1)),h=Pn({computedData$:e.computedData$}),d=Ce({datumList$:f}).pipe(w(1)),p=Tn({datumList$:f}).pipe(w(1)),g=Cn({computedData$:e.computedData$,fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$}).pipe(w(1)),_=Rn({computedData$:e.computedData$}).pipe(w(1)),x=Nn({computedLayoutData$:g}).pipe(w(1)),A=In({computedData$:e.computedData$,isSeriesSeprate$:r}).pipe(w(1));return{fullParams$:e.fullParams$,fullChartParams$:e.fullChartParams$,fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$,textSizePx$:n,isSeriesSeprate$:r,gridContainerPosition$:i,gridAxesTransform$:o,gridAxesReverseTransform$:a,gridGraphicTransform$:s,gridGraphicReverseScale$:u,gridAxesSize$:l,gridHighlight$:c,seriesLabels$:h,SeriesDataMap$:d,GroupDataMap$:p,computedLayoutData$:g,visibleComputedData$:_,visibleComputedLayoutData$:x,computedStackedData$:A}};class Mc extends Ot{constructor(e,n){super({defaultDataFormatter:Pe,dataFormatterValidator:$c,computedDataFn:Tc,dataValidator:Sc,contextObserverCallback:Cc},e,n)}}const Ec=t=>{const e=E(t,{visibleFilter:{toBeTypes:["Function"]},gridList:{toBeTypes:["object[]"]},container:{toBeTypes:["object"]},separateGrid:{toBeTypes:["boolean"]}});if(t.gridList){const r=t.gridList.map((i,o)=>{const a=E(i,{seriesDirection:{toBe:'"row" | "column"',test:s=>s==="row"||s==="column"},rowLabels:{toBeTypes:["string[]"]},columnLabels:{toBeTypes:["string[]"]},valueAxis:{toBeTypes:["object"]},groupAxis:{toBeTypes:["object"]},separateSeries:{toBeTypes:["boolean"]}});if(a.status==="error")return a;if(i.valueAxis){const s=E(i.valueAxis,{position:{toBe:'"top" | "bottom" | "left" | "right"',test:u=>u==="top"||u==="bottom"||u==="left"||u==="right"},scaleDomain:{toBe:'[number | "min" | "auto", number | "max" | "auto"]',test:u=>Array.isArray(u)&&u.length===2&&(typeof u[0]=="number"||u[0]==="min"||u[0]==="auto")&&(typeof u[1]=="number"||u[1]==="max"||u[1]==="auto")},scaleRange:{toBe:"[number, number]",test:u=>Array.isArray(u)&&u.length===2&&typeof u[0]=="number"&&typeof u[1]=="number"},label:{toBeTypes:["string"]}});if(s.status==="error")return s}else if(i.groupAxis){const s=E(i.groupAxis,{position:{toBe:'"top" | "bottom" | "left" | "right"',test:u=>u==="top"||u==="bottom"||u==="left"||u==="right"},scaleDomain:{toBe:'[number, number | "max"]',test:u=>Array.isArray(u)&&u.length===2&&typeof u[0]=="number"&&(typeof u[1]=="number"||u[1]==="max")},scalePadding:{toBeTypes:["number"]},label:{toBeTypes:["string"]}});if(s.status==="error")return s}return{status:"success",columnName:"",expectToBe:""}}).find(i=>i.status==="error");if(r)return r}if(t.container){const n=E(t.container,{gap:{toBeTypes:["number"]},rowAmount:{toBeTypes:["number"]},columnAmount:{toBeTypes:["number"]}});if(n.status==="error")return n}return e},Fc=t=>{const{data:e=[],dataFormatter:n,chartParams:r}=t;if(!e.length)return[];let i=[];try{const o=n.gridList[0]||Pt,a=e.map((c,h)=>n.gridList[h]||o),s=e.map((c,h)=>Xi(c,a[h])),u=n.separateGrid?s.map((c,h)=>un({transposedDataGrid:c,dataFormatterGrid:a[h],chartType:"multiGrid"})):s.map((c,h)=>Jr({transposedDataGrid:c,dataFormatterGrid:a[h],chartType:"multiGrid",gridIndex:h})),l=new Map;let f=0;u.flat().forEach((c,h)=>{if(!l.has(c)){const d=jt(f,r);l.set(c,d),f++}}),i=s.map((c,h)=>{const d=u[h],p=Zr({transposedDataGrid:c,dataFormatterGrid:a[h],chartType:"multiGrid",gridIndex:h});let g=0;return c.map((x,A)=>x.map(($,T)=>{const S=Ht("multiGrid",h,A,T),k=p[T],N=d[A],I={id:$.id?$.id:S,index:g,label:$.label?$.label:S,description:$.description??"",data:$.data,value:$.value,gridIndex:h,seriesIndex:A,seriesLabel:N,groupIndex:T,groupLabel:k,color:l.get(N),visible:!0};return I.visible=n.visibleFilter(I,t),g++,I}))})}catch(o){throw Error(o)}return i},Lc=t=>E({data:t},{data:{toBe:"DataGrid[]",test:n=>Array.isArray(n)}}),Oc=({subject:t,observer:e})=>{const n=Jt(e.fullChartParams$).pipe(w(1)),r=Vi({fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$,fullChartParams$:e.fullChartParams$,event$:t.event$}).pipe(w(1)),i=kn({computedData$:e.computedData$,fullDataFormatter$:e.fullDataFormatter$,layout$:e.layout$});return{fullParams$:e.fullParams$,fullChartParams$:e.fullChartParams$,fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$,textSizePx$:n,multiGridContainerPosition$:i,multiGridEachDetail$:r}};class Pc extends Ot{constructor(e,n){super({defaultDataFormatter:Re,dataFormatterValidator:Ec,computedDataFn:Fc,dataValidator:Lc,contextObserverCallback:Oc},e,n)}}const Rc=t=>({status:"success",columnName:"",expectToBe:""}),Nc=t=>{const{data:e,dataFormatter:n,chartParams:r}=t;if(!e.length)return[];const i={width:1e3,height:1e3};let o=[];try{const a=e.map((A,$)=>A.map((T,S)=>typeof T=="number"?{id:"",label:"",description:"",data:{},categoryLabel:"",value:T}:{id:T.id??"",label:T.label??"",description:T.description??"",data:T.data??{},categoryLabel:T.categoryLabel??"",value:T.value})),[s,u]=Ae(a.map(A=>A[0])),[l,f]=Ae(a.map(A=>A[1])),c=n.xAxis.position==="top"||n.xAxis.position==="bottom"?i.width:i.height,h=n.yAxis.position==="left"||n.yAxis.position==="right"?i.height:i.width,d=gt({maxValue:u,minValue:s,axisWidth:c,scaleDomain:[s,u],scaleRange:[0,1]}),p=gt({maxValue:f,minValue:l,axisWidth:h,scaleDomain:[l,f],scaleRange:[0,1]}),g=[n.xAxis.scaleDomain[0]==="auto"?s<0?s:0:n.xAxis.scaleDomain[0]==="min"?s:n.xAxis.scaleDomain[0],n.xAxis.scaleDomain[1]==="auto"?u>=0?u:0:n.xAxis.scaleDomain[1]==="max"?u:n.xAxis.scaleDomain[1]],_=[n.yAxis.scaleDomain[0]==="auto"?s<0?s:0:n.yAxis.scaleDomain[0]==="min"?s:n.yAxis.scaleDomain[0],n.yAxis.scaleDomain[1]==="auto"?u>=0?u:0:n.yAxis.scaleDomain[1]==="max"?u:n.yAxis.scaleDomain[1]];let x=0;o=a.map((A,$)=>A.map((T,S)=>{const k=x;x++;const N=Ht(n.type,$,S),I={id:T.id?T.id:N,index:k,label:T.label?T.label:N,description:T.description??"",data:T.data,value:T.value,categoryIndex:0,categoryLabel:"",axis:S==0?d(T.value):p(T.value),visible:!0,color:""};return I.visible=n.visibleFilter(I,t),I}))}catch(a){throw Error(a)}return o},Ic=t=>({status:"success",columnName:"",expectToBe:""}),kc=({subject:t,observer:e})=>({fullParams$:e.fullParams$,fullChartParams$:e.fullChartParams$,fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$});class Bc extends Ot{constructor(e,n){super({defaultDataFormatter:Ne,dataFormatterValidator:Rc,computedDataFn:Nc,dataValidator:Ic,contextObserverCallback:kc},e,n)}}const Gc=t=>({status:"success",columnName:"",expectToBe:""}),Vc=t=>{const{data:e,dataFormatter:n,chartParams:r}=t;let i=[],o=[];try{let a=[],s=[];if(e.nodes)a=e.nodes,s=e.edges;else if(e[0])a=e[0],s=e[1];else return{nodes:[],edges:[]};i=a.map((c,h)=>({id:c.id,index:h,label:c.label??"",description:c.description??"",data:c.data??{},value:c.value??0,categoryIndex:0,categoryLabel:"",color:"",startNodes:[],startNodeIds:[],endNodes:[],endNodeIds:[],visible:!0}));const u=new Map(i.map(c=>[c.id,c]));o=s.map((c,h)=>({id:c.id,index:h,label:c.label??"",description:c.description??"",data:c.data??{},value:c.value??0,startNode:u.get(c.start),startNodeId:c.start,endNode:u.get(c.end),endNodeId:c.end,visible:!0}));const l=function(){const c=new Map;return o.forEach(h=>{const d=c.get(h.endNodeId)??[];d.push(h.startNode),c.set(h.endNodeId,d)}),c}(),f=function(){const c=new Map;return o.forEach(h=>{const d=c.get(h.startNodeId)??[];d.push(h.endNode),c.set(h.startNodeId,d)}),c}();Array.from(u).forEach(([c,h])=>{h.startNodes=l.get(c),h.startNodeIds=h.startNodes.map(d=>d.id),h.endNodes=f.get(c),h.endNodeIds=h.endNodes.map(d=>d.id),h.visible=n.visibleFilter(h,t)}),o=o.map(c=>(c.visible=!!(c.startNode.visible&&c.endNode.visible),c))}catch(a){throw Error(a)}return{nodes:i,edges:o}},Uc=t=>({status:"success",columnName:"",expectToBe:""}),zc=({subject:t,observer:e})=>({fullParams$:e.fullParams$,fullChartParams$:e.fullChartParams$,fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$});class Hc extends Ot{constructor(e,n){super({defaultDataFormatter:ke,dataFormatterValidator:Gc,computedDataFn:Vc,dataValidator:Uc,contextObserverCallback:zc},e,n)}}const jc=t=>E(t,{visibleFilter:{toBeTypes:["Function"]},categoryLabels:{toBeTypes:["string[]"]}}),Xc=t=>{const{data:e=[],dataFormatter:n,chartParams:r}=t,i=new Map(n.categoryLabels.map((a,s)=>[a,s]));let o={id:"",index:0,label:"",description:"",categoryIndex:0,categoryLabel:"",color:"",visible:!0,data:{},value:0,level:0,seq:0,children:[]};try{const a=function(){if(H(e)===!0)return JSON.parse(JSON.stringify(e));if(Array.isArray(e)===!1)return{id:""};let l;const f=new Map;e.forEach(h=>{if(!h.parent)l=h;else{const d=f.get(h.parent)??[];d.push(h),f.set(h.parent,d)}});const c=h=>({id:h.id,label:h.label,data:h.data,value:h.value,categoryLabel:h.categoryLabel,children:(f.get(h.id)??[]).map(d=>c(d))});return l?c(l):{id:""}}();let s=0;const u=(l,f,c)=>{const h=f+1,d=l.categoryLabel??null;let p=0;d!=null&&(i.has(d)||i.set(d,i.size),p=i.get(d)??0);const g=s;s++;const _={id:l.id,index:g,level:f,seq:c,label:l.label??"",description:l.description??"",categoryIndex:p,categoryLabel:d,color:jt(p,r),data:l.data??{},value:l.value,visible:!0,children:(l.children??[]).map((x,A)=>u(x,h,A))};return _.visible=n.visibleFilter(_,t),_};o=u(a,0,0)}catch(a){throw Error(a)}return o},qc=t=>E({data:t},{data:{toBe:"DataTreeObj | DataTreeDatum[]",test:n=>H(n)&&n.id!==void 0}}),Yc=({subject:t,observer:e})=>{const n=Jt(e.fullChartParams$).pipe(w(1)),r=Ui({computedData$:e.computedData$}).pipe(w(1)),i=Wt({datumList$:r,fullChartParams$:e.fullChartParams$,event$:t.event$}).pipe(w(1)),o=zi({nodeList$:r,fullDataFormatter$:e.fullDataFormatter$}).pipe(w(1)),a=Pi({datumList$:r}).pipe(w(1)),s=Hi({computedData$:e.computedData$}).pipe(w(1));return{fullParams$:e.fullParams$,fullChartParams$:e.fullChartParams$,fullDataFormatter$:e.fullDataFormatter$,computedData$:e.computedData$,layout$:e.layout$,textSizePx$:n,treeHighlight$:i,existCategoryLabels$:o,CategoryDataMap$:a,visibleComputedData$:s}};class Wc extends Ot{constructor(e,n){super({defaultDataFormatter:Ie,dataFormatterValidator:jc,computedDataFn:Xc,dataValidator:qc,contextObserverCallback:Yc},e,n)}}function Jc({chartType:t,config:e,initFn:n}){const r=new O,i=new WeakMap;let o=()=>{},a;const s=new ci(e.defaultParams),u=new ci({}),l=s.pipe(R(f=>u.pipe(M(r),D(c=>{try{const{status:h,columnName:d,expectToBe:p}=e.validator(c,{validateColumns:E});if(h==="error")throw new Error(yt({columnName:d,expectToBe:p,from:`${e.name}.params$`}));return h==="warning"&&console.warn(vt({columnName:d,expectToBe:p,from:`${e.name}.params$`})),st(c,f)}catch(h){throw new Error(h.message)}}),Yt(c=>(console.error(Kt(c)),Et)))),w(1));return{params$:u,name:e.name,chartType:t,defaultParams:e.defaultParams,layerIndex:e.layerIndex,init(){a&&(o=n(a)??(()=>{}),i.set(a.selection,a))},destroy(){o(),a&&(a.selection.remove(),a=void 0),r.next(void 0)},setPresetParams:f=>{s.next(st(f,e.defaultParams))},setContext:f=>{a=f,a.observer.fullParams$=l}}}const bt=t=>function(n){return function(i){return class{constructor(){const a=Jc({chartType:t,config:n,initFn:i});this.params$=a.params$,this.name=a.name,this.chartType=a.chartType,this.defaultParams=a.defaultParams,this.layerIndex=a.layerIndex,this.init=a.init,this.destroy=a.destroy,this.setPresetParams=a.setPresetParams,this.setContext=a.setContext}}}},Kc=bt("series"),Zc=bt("grid"),Qc=bt("multiGrid"),tf=bt("multiValue"),ef=bt("noneData"),nf=bt("relationship"),rf=bt("tree");m.CHART_HEIGHT_DEFAULT=Gn,m.CHART_OPTIONS_DEFAULT=at,m.CHART_PARAMS_DEFAULT=Fe,m.CHART_WIDTH_DEFAULT=Bn,m.DATA_FORMATTER_CONTAINER_DEFAULT=Zt,m.DATA_FORMATTER_GRID_DEFAULT=Pe,m.DATA_FORMATTER_GRID_GRID_DEFAULT=Oe,m.DATA_FORMATTER_GROUP_AXIS_DEFAULT=Vn,m.DATA_FORMATTER_MULTI_GRID_DEFAULT=Re,m.DATA_FORMATTER_MULTI_GRID_GRID_DEFAULT=Pt,m.DATA_FORMATTER_MULTI_VALUE_DEFAULT=Ne,m.DATA_FORMATTER_RELATIONAL_DEFAULT=ke,m.DATA_FORMATTER_SERIES_DEFAULT=Le,m.DATA_FORMATTER_TREE_DEFAULT=Ie,m.DATA_FORMATTER_VALUE_AXIS_DEFAULT=J,m.DATA_GRID_DEFAULT=Yi,m.DATA_MULTI_GRID_DEFAULT=Wi,m.DATA_MULTI_VALUE_DEFAULT=Ji,m.DATA_RELATIONA_DEFAULTL=Zi,m.DATA_SERIES_DEFAULT=qi,m.DATA_TREE_DEFAULT=Ki,m.GridChart=Mc,m.MultiGridChart=Pc,m.MultiValueChart=Bc,m.PADDING_DEFAULT=Ee,m.RelationshipChart=Hc,m.SeriesChart=Dc,m.TreeChart=Wc,m.calcGridContainerLayout=De,m.calcSeriesContainerLayout=cn,m.categoryDataMapObservable=Pi,m.computedStackedDataObservables=In,m.createAxisLinearScale=gt,m.createAxisPointScale=yc,m.createAxisQuantizeScale=vc,m.createDefaultDatumId=Ht,m.createDefaultGroupLabel=sn,m.createDefaultSeriesLabel=xe,m.createGridGroupLabels=Kr,m.createGridSeriesLabels=un,m.createMultiGridGroupLabels=Zr,m.createMultiGridSeriesLabels=Jr,m.defineGridPlugin=Zc,m.defineMultiGridPlugin=Qc,m.defineMultiValuePlugin=tf,m.defineNoneDataPlugin=ef,m.defineRelationshipPlugin=nf,m.defineSeriesPlugin=Kc,m.defineTreePlugin=rf,m.existCategoryLabelsObservable=zi,m.formatCommaNumber=Qi,m.formatValueToLabel=nl,m.getMinAndMax=Tt,m.getMinAndMaxGrid=ln,m.getMinAndMaxMultiGrid=il,m.getMinAndMaxMultiValue=ol,m.getMinAndMaxSeries=rl,m.getMinAndMaxValue=Ae,m.gridAxesReverseTransformObservable=En,m.gridAxesSizeObservable=On,m.gridAxesTransformObservable=Mn,m.gridComputedLayoutDataObservable=Cn,m.gridContainerPositionObservable=Gi,m.gridGraphicReverseScaleObservable=Ln,m.gridGraphicTransformObservable=Fn,m.gridSeriesLabelsObservable=Pn,m.gridVisibleComputedDataObservable=Rn,m.gridVisibleComputedLayoutDataObservable=Nn,m.groupDataMapObservable=Tn,m.highlightObservable=Wt,m.isDom=zn,m.isFunction=Un,m.isPlainObject=H,m.mergeOptionsWithDefault=st,m.multiGridContainerObservable=kn,m.multiGridEachDetailObservable=Vi,m.nodeListObservable=Ui,m.resizeObservable=Oi,m.separateSeriesObservable=Ri,m.seriesColorPredicate=jt,m.seriesComputedLayoutDataObservable=Ii,m.seriesContainerPositionMapObservable=Bi,m.seriesContainerPositionObservable=ki,m.seriesDataMapObservable=Ce,m.seriesLabelsObservable=Ni,m.seriesVisibleComputedDataObservable=Sn,m.textSizePxObservable=Jt,m.transposeData=Qr,m.treeVisibleComputedDataObservable=Hi,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -92,7 +92,7 @@ export const dataFormatterValidator: DataFormatterValidator<'multiGrid'> = (data
|
|
92
92
|
}
|
93
93
|
})
|
94
94
|
const gridListResult = gridListResultArr.find((gridResult) => gridResult.status === 'error')
|
95
|
-
if (gridListResult
|
95
|
+
if (gridListResult) {
|
96
96
|
return gridListResult
|
97
97
|
}
|
98
98
|
}
|