@qxs-bns/components 0.0.87 → 0.0.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var r="0.0.87";export{r as version};
1
+ var r="0.0.88";export{r as version};
2
2
  //# sourceMappingURL=package.json.mjs.map
@@ -1,2 +1,2 @@
1
- import{defineComponent as e,inject as t,ref as r,computed as a,createElementBlock as o,openBlock as i}from"vue";import{orderBy as l}from"lodash-es";import{InjectionChartMerge as s}from"../utils/injectionKeys.mjs";import{useCharts as c}from"../utils/useCharts.mjs";var n=e({name:"DataChartPie",__name:"pie",props:{chartData:{type:Object,required:!0},subShowType:{type:String,required:!0,default:"pie-simple"},chartOptions:{type:null,required:!0},lazyLoad:{type:Boolean,required:!1,default:!0}},setup(e,{expose:n}){const h=t(s,e=>e,!0),m=r(null),u=a(()=>{const{colDesc:t,xGroupByDesc:r,data:a,modelName:o}=e.chartData,i=t.length,s={title:{text:o},series:t.map((t,o)=>{const s={name:t,type:"pie",center:["50%","50%"],data:[],emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}},label:{formatter:"{b}:{c}({d}%)",rich:{b:{color:"#4C5058",fontSize:14,fontWeight:"bold",lineHeight:33}}}};let c=5;const n=a.filter(e=>void 0!==e[t]),h=l(n,[t],["desc"]),m=h.reduce((e,r)=>{const a=Number(r[t])||0;return Number.isNaN(a)?e:e+a},0);if(n.length>c)for(;c<9;){const e=h.slice(0,c);if(e.reduce((e,r)=>e+Number(r[t]),0)/m>.9||8===c){const a=h.slice(c,h.length-1);s.data=n.map(a=>{let o={};return e.forEach(e=>{JSON.stringify(e)===JSON.stringify(a)&&(o={name:r?.colDesc?a[r.colDesc]:"",value:a[t]})}),o}).filter(e=>e&&Object.keys(e).length>0),s.data.push({name:"其它",value:a.reduce((e,r)=>e+Number(r[t]),0)});break}c++}else s.data=n.map(e=>({name:r?.colDesc&&e[r.colDesc]||"",value:Number(e[t]||0)}));if(1===i?s.center=["50%","60%"]:2===i?0===o?(s.right="40%",s.left="",s.center=["40%","60%"]):(s.right="",s.left="40%",s.center=["60%","60%"]):3===i?0===o?(s.right="40%",s.bottom="50%",s.top="",s.left="",s.center=["40%","78%"]):1===o?(s.right="",s.bottom="50%",s.top="",s.left="40%",s.center=["60%","78%"]):(s.right="40%",s.bottom="",s.top="50%",s.left="",s.center=["40%","60%"]):4===i&&(0===o?(s.right="40%",s.bottom="50%",s.top="",s.left="",s.center=["40%","78%"]):1===o?(s.right="",s.bottom="50%",s.top="",s.left="40%",s.center=["60%","78%"]):2===o?(s.right="40%",s.bottom="",s.top="50%",s.left="",s.center=["40%","60%"]):(s.right="",s.bottom="",s.top="50%",s.left="40%",s.center=["60%","60%"])),"pie-borderRadius"===e.subShowType)s.radius=["50%","70%"];else s.radius="50%";return s})};return h(s,e.chartOptions)}),{myChart:p}=c({chartDOM:m,chartOptions:u,chartData:a(()=>e.chartData),lazyLoad:e.lazyLoad});return n({myChart:p}),(e,t)=>(i(),o("div",{ref_key:"dataChartPie",ref:m,class:"data-chart-pie"},null,512))}});export{n as default};
1
+ import{defineComponent as e,inject as t,ref as r,computed as a,createElementBlock as o,openBlock as i}from"vue";import{orderBy as l}from"lodash-es";import{InjectionChartMerge as s}from"../utils/injectionKeys.mjs";import{useCharts as c}from"../utils/useCharts.mjs";var n=e({name:"DataChartPie",__name:"pie",props:{chartData:{type:Object,required:!0},subShowType:{type:String,required:!0,default:"pie-simple"},chartOptions:{type:null,required:!0},lazyLoad:{type:Boolean,required:!1,default:!0}},setup(e,{expose:n}){const m=t(s,e=>e,!0),u=r(null),p=a(()=>{const{colDesc:t,xGroupByDesc:r,data:a,modelName:o}=e.chartData,i=t.length,s={title:{text:o},series:t.map((t,o)=>{const s={name:t,type:"pie",center:["50%","50%"],data:[],emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}},label:{formatter:"{b}:{c}({d}%)",rich:{b:{color:"#4C5058",fontSize:14,fontWeight:"bold",lineHeight:33}}}};let c=5;const n=a.filter(e=>void 0!==e[t]),m=l(n,[t],["desc"]),u=m.reduce((e,r)=>{const a=Number(r[t])||0;return Number.isNaN(a)?e:e+a},0);if(n.length>c)for(;c<9;){const e=m.slice(0,c);if(e.reduce((e,r)=>e+Number(r[t]),0)/u>.9||8===c){const a=m.slice(c);s.data=e.map(e=>({name:r?.colDesc?String(e[r.colDesc]||""):"",value:Number(e[t])||0}));const o=a.reduce((e,r)=>e+Number(r[t]),0);o>0&&s.data&&s.data.push({name:"其它",value:o});break}c++}else s.data=n.map(e=>({name:r?.colDesc&&e[r.colDesc]||"",value:Number(e[t]||0)}));if(1===i?s.center=["50%","60%"]:2===i?0===o?(s.right="40%",s.left="",s.center=["40%","60%"]):(s.right="",s.left="40%",s.center=["60%","60%"]):3===i?0===o?(s.right="40%",s.bottom="50%",s.top="",s.left="",s.center=["40%","78%"]):1===o?(s.right="",s.bottom="50%",s.top="",s.left="40%",s.center=["60%","78%"]):(s.right="40%",s.bottom="",s.top="50%",s.left="",s.center=["40%","60%"]):4===i&&(0===o?(s.right="40%",s.bottom="50%",s.top="",s.left="",s.center=["40%","78%"]):1===o?(s.right="",s.bottom="50%",s.top="",s.left="40%",s.center=["60%","78%"]):2===o?(s.right="40%",s.bottom="",s.top="50%",s.left="",s.center=["40%","60%"]):(s.right="",s.bottom="",s.top="50%",s.left="40%",s.center=["60%","60%"])),"pie-borderRadius"===e.subShowType)s.radius=["50%","70%"];else s.radius="50%";return s})};return console.log(s),m(s,e.chartOptions)}),{myChart:h}=c({chartDOM:u,chartOptions:p,chartData:a(()=>e.chartData),lazyLoad:e.lazyLoad});return n({myChart:h}),(e,t)=>(i(),o("div",{ref_key:"dataChartPie",ref:u,class:"data-chart-pie"},null,512))}});export{n as default};
2
2
  //# sourceMappingURL=pie.vue2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pie.vue2.mjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/pie.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { PieSeriesOption } from 'echarts/charts'\nimport type { EChartsOption, IFormatPublicData } from '../utils/types'\nimport { orderBy } from 'lodash-es'\nimport { computed, inject, ref } from 'vue'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\ndefineOptions({\n name: 'DataChartPie',\n})\nconst {\n chartData,\n subShowType = 'pie-simple',\n chartOptions,\n lazyLoad = true,\n} = defineProps<{\n chartData: IFormatPublicData\n subShowType: string\n chartOptions: EChartsOption\n lazyLoad?: boolean\n}>()\nconst merge = inject(InjectionChartMerge, (v: any) => v, true)\n\nconst dataChartPie = ref(null)\nconst pieChartOptions = computed<EChartsOption>(() => {\n const { colDesc, xGroupByDesc, data, modelName } = chartData\n const colDescLength = colDesc.length\n const config = {\n title: { text: modelName },\n series: colDesc.map((item, index) => {\n const seriesItem: PieSeriesOption = {\n name: item,\n type: 'pie',\n center: ['50%', '50%'],\n data: [],\n emphasis: {\n itemStyle: {\n shadowBlur: 10,\n shadowOffsetX: 0,\n shadowColor: 'rgba(0, 0, 0, 0.5)',\n },\n },\n label: {\n formatter: '{b}:{c}({d}%)',\n rich: {\n b: {\n color: '#4C5058',\n fontSize: 14,\n fontWeight: 'bold',\n lineHeight: 33,\n },\n },\n },\n }\n\n let cutNum = 5\n const currentItemData = data.filter(row => row[item] !== undefined)\n const orderByData = orderBy(currentItemData, [item], ['desc'])\n // 总数\n const totalDesc = orderByData.reduce((prev, cur) => {\n const value = Number(cur[item]) || 0\n return Number.isNaN(value) ? prev : prev + value\n }, 0)\n if (currentItemData.length > cutNum) {\n while (cutNum < 9) {\n const headerData = orderByData.slice(0, cutNum)\n // 前 cutNum 个总数\n const headerTotal = headerData.reduce(\n (prev, cur) => prev + Number(cur[item]),\n 0,\n )\n // 前五总占比\n const headerScale = headerTotal / totalDesc\n if (headerScale > 0.9 || cutNum === 8) {\n const footerData = orderByData.slice(\n cutNum,\n orderByData.length - 1,\n )\n seriesItem.data = currentItemData\n .map((yItem) => {\n let obj = {}\n headerData.forEach((headerDataItem) => {\n if (JSON.stringify(headerDataItem) === JSON.stringify(yItem)) {\n obj = {\n name: xGroupByDesc?.colDesc\n ? yItem[xGroupByDesc.colDesc]\n : '',\n value: yItem[item],\n }\n }\n })\n return obj\n })\n .filter(v => v && Object.keys(v).length > 0)\n seriesItem.data.push({\n name: '其它',\n value: footerData.reduce(\n (prev, cur) => prev + Number(cur[item]),\n 0,\n ),\n })\n\n break\n }\n else {\n cutNum++\n }\n }\n }\n else {\n seriesItem.data = currentItemData.map(yItem => ({\n name: xGroupByDesc?.colDesc ? (yItem[xGroupByDesc.colDesc] || '') : '',\n value: Number(yItem[item] || 0),\n }))\n }\n\n if (colDescLength === 1) {\n seriesItem.center = ['50%', '60%']\n }\n else if (colDescLength === 2) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n else {\n seriesItem.right = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '60%']\n }\n }\n else if (colDescLength === 3) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = ''\n seriesItem.center = ['40%', '78%']\n }\n else if (index === 1) {\n seriesItem.right = ''\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '78%']\n }\n else {\n seriesItem.right = '40%'\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n }\n else if (colDescLength === 4) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = ''\n seriesItem.center = ['40%', '78%']\n }\n else if (index === 1) {\n seriesItem.right = ''\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '78%']\n }\n else if (index === 2) {\n seriesItem.right = '40%'\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n else {\n seriesItem.right = ''\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '60%']\n }\n }\n // 处理图表形状\n switch (subShowType) {\n case 'pie-borderRadius':\n seriesItem.radius = ['50%', '70%']\n break\n case 'pie-simple':\n seriesItem.radius = '50%'\n break\n default:\n seriesItem.radius = '50%'\n break\n }\n return seriesItem\n }),\n }\n\n return merge(config, chartOptions)\n})\n\nconst { myChart } = useCharts({\n chartDOM: dataChartPie,\n chartOptions: pieChartOptions,\n chartData: computed(() => chartData),\n lazyLoad,\n})\n\n// 暴露 myChart 方法供父组件访问\ndefineExpose({\n myChart,\n})\n</script>\n\n<template>\n <div\n ref=\"dataChartPie\"\n class=\"data-chart-pie\"\n />\n</template>\n\n<style scoped lang=\"scss\">\n.data-chart-pie {\n width: 100%;\n height: 100%;\n}\n</style>\n"],"names":["merge","inject","InjectionChartMerge","v","dataChartPie","ref","pieChartOptions","computed","colDesc","xGroupByDesc","data","modelName","__props","chartData","colDescLength","length","config","title","text","series","map","item","index","seriesItem","name","type","center","emphasis","itemStyle","shadowBlur","shadowOffsetX","shadowColor","label","formatter","rich","b","color","fontSize","fontWeight","lineHeight","cutNum","currentItemData","filter","row","orderByData","orderBy","totalDesc","reduce","prev","cur","value","Number","isNaN","headerData","slice","footerData","yItem","obj","forEach","headerDataItem","JSON","stringify","Object","keys","push","right","left","bottom","top","subShowType","radius","chartOptions","myChart","useCharts","chartDOM","lazyLoad","__expose","_createElementBlock","class"],"mappings":"igBAsBA,MAAMA,EAAQC,EAAOC,EAAsBC,GAAWA,GAAG,GAEnDC,EAAeC,EAAI,MACnBC,EAAkBC,EAAwB,KAC9C,MAAMC,QAAEA,EAAAC,aAASA,EAAAC,KAAcA,EAAAC,UAAMA,GA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AAQ,MACnB1C,EAAW4C,OAAS,GACpB5C,EAAW6C,IAAM,MACjB7C,EAAW2C,KAAO,GAClB3C,EAAWG,OAAS,CAAC,MAAO,SAG5BH,EAAW0C,MAAQ,GACnB1C,EAAW4C,OAAS,GACpB5C,EAAW6C,IAAM,MACjB7C,EAAW2C,KAAO,MAClB3C,EAAWG,OAAS,CAAC,MAAO,SAKzB,qBADCd,EAAAyD,YAEJ9C,EAAW+C,OAAS,CAAC,MAAO,YAM5B/C,EAAW+C,OAAS,MAGxB,OAAO/C,KAIX,OAAOvB,EAAMgB,EAAQJ,EAAA2D,iBAGjBC,QAAEA,GAAYC,EAAU,CAC5BC,SAAUtE,EACVmE,aAAcjE,EACdO,UAAWN,EAAS,IAAMK,EAAAC,WAC1B8D,SAAO/D,EAAA+D,kBAITC,EAAa,CACXJ,wBAKAK,EAGE,MAAA,SAFI,eAAJxE,IAAID,EACJ0E,MAAM"}
1
+ {"version":3,"file":"pie.vue2.mjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/pie.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { PieSeriesOption } from 'echarts/charts'\nimport type { EChartsOption, IFormatPublicData } from '../utils/types'\nimport { orderBy } from 'lodash-es'\nimport { computed, inject, ref } from 'vue'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\ndefineOptions({\n name: 'DataChartPie',\n})\nconst {\n chartData,\n subShowType = 'pie-simple',\n chartOptions,\n lazyLoad = true,\n} = defineProps<{\n chartData: IFormatPublicData\n subShowType: string\n chartOptions: EChartsOption\n lazyLoad?: boolean\n}>()\nconst merge = inject(InjectionChartMerge, (v: any) => v, true)\n\nconst dataChartPie = ref(null)\nconst pieChartOptions = computed<EChartsOption>(() => {\n const { colDesc, xGroupByDesc, data, modelName } = chartData\n const colDescLength = colDesc.length\n const config = {\n title: { text: modelName },\n series: colDesc.map((item, index) => {\n const seriesItem: PieSeriesOption = {\n name: item,\n type: 'pie',\n center: ['50%', '50%'],\n data: [],\n emphasis: {\n itemStyle: {\n shadowBlur: 10,\n shadowOffsetX: 0,\n shadowColor: 'rgba(0, 0, 0, 0.5)',\n },\n },\n label: {\n formatter: '{b}:{c}({d}%)',\n rich: {\n b: {\n color: '#4C5058',\n fontSize: 14,\n fontWeight: 'bold',\n lineHeight: 33,\n },\n },\n },\n }\n\n let cutNum = 5\n const currentItemData = data.filter(row => row[item] !== undefined)\n const orderByData = orderBy(currentItemData, [item], ['desc'])\n // 总数\n const totalDesc = orderByData.reduce((prev, cur) => {\n const value = Number(cur[item]) || 0\n return Number.isNaN(value) ? prev : prev + value\n }, 0)\n if (currentItemData.length > cutNum) {\n while (cutNum < 9) {\n const headerData = orderByData.slice(0, cutNum)\n // 前 cutNum 个总数\n const headerTotal = headerData.reduce(\n (prev, cur) => prev + Number(cur[item]),\n 0,\n )\n // 前N项总占比\n const headerScale = headerTotal / totalDesc\n if (headerScale > 0.9 || cutNum === 8) {\n const footerData = orderByData.slice(cutNum)\n\n // 处理前N项数据\n seriesItem.data = headerData.map(headerItem => ({\n name: xGroupByDesc?.colDesc\n ? String(headerItem[xGroupByDesc.colDesc] || '')\n : '',\n value: Number(headerItem[item]) || 0,\n }))\n\n // 添加\"其它\"项,包含剩余所有数据\n const footerTotal = footerData.reduce(\n (prev, cur) => prev + Number(cur[item]),\n 0,\n )\n\n if (footerTotal > 0 && seriesItem.data) {\n seriesItem.data.push({\n name: '其它',\n value: footerTotal,\n })\n }\n\n break\n }\n else {\n cutNum++\n }\n }\n }\n else {\n seriesItem.data = currentItemData.map(yItem => ({\n name: xGroupByDesc?.colDesc ? (yItem[xGroupByDesc.colDesc] || '') : '',\n value: Number(yItem[item] || 0),\n }))\n }\n\n if (colDescLength === 1) {\n seriesItem.center = ['50%', '60%']\n }\n else if (colDescLength === 2) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n else {\n seriesItem.right = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '60%']\n }\n }\n else if (colDescLength === 3) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = ''\n seriesItem.center = ['40%', '78%']\n }\n else if (index === 1) {\n seriesItem.right = ''\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '78%']\n }\n else {\n seriesItem.right = '40%'\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n }\n else if (colDescLength === 4) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = ''\n seriesItem.center = ['40%', '78%']\n }\n else if (index === 1) {\n seriesItem.right = ''\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '78%']\n }\n else if (index === 2) {\n seriesItem.right = '40%'\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n else {\n seriesItem.right = ''\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '60%']\n }\n }\n // 处理图表形状\n switch (subShowType) {\n case 'pie-borderRadius':\n seriesItem.radius = ['50%', '70%']\n break\n case 'pie-simple':\n seriesItem.radius = '50%'\n break\n default:\n seriesItem.radius = '50%'\n break\n }\n return seriesItem\n }),\n }\n console.log(config)\n\n return merge(config, chartOptions)\n})\n\nconst { myChart } = useCharts({\n chartDOM: dataChartPie,\n chartOptions: pieChartOptions,\n chartData: computed(() => chartData),\n lazyLoad,\n})\n\n// 暴露 myChart 方法供父组件访问\ndefineExpose({\n myChart,\n})\n</script>\n\n<template>\n <div\n ref=\"dataChartPie\"\n class=\"data-chart-pie\"\n />\n</template>\n\n<style scoped lang=\"scss\">\n.data-chart-pie {\n width: 100%;\n height: 100%;\n}\n</style>\n"],"names":["merge","inject","InjectionChartMerge","v","dataChartPie","ref","pieChartOptions","computed","colDesc","xGroupByDesc","data","modelName","__props","chartData","colDescLength","length","config","title","text","series","map","item","index","seriesItem","name","type","center","emphasis","itemStyle","shadowBlur","shadowOffsetX","shadowColor","label","formatter","rich","b","color","fontSize","fontWeight","lineHeight","cutNum","currentItemData","filter","row","orderByData","orderBy","totalDesc","reduce","prev","cur","value","Number","isNaN","headerData","slice","footerData","headerItem","String","footerTotal","push","yItem","right","left","bottom","top","subShowType","radius","console","log","chartOptions","myChart","useCharts","chartDOM","lazyLoad","__expose","_createElementBlock","class"],"mappings":"igBAsBA,MAAMA,EAAQC,EAAOC,EAAsBC,GAAWA,GAAG,GAEnDC,EAAeC,EAAI,MACnBC,EAAkBC,EAAwB,KAC9C,MAAMC,QAAEA,EAAAC,aAASA,EAAAC,KAAcA,EAAAC,UAAMA,GAAcC,EAAAC,UAC7CC,EAAgBN,EAAQO,OACxBC,EAAS,CACbC,MAAO,CAAEC,KAAMP,GACfQ,OAAQX,EAAQY,IAAI,CAACC,EAAMC,KACzB,MAAMC,EAA8B,CAClCC,KAAMH,EACNI,KAAM,MACNC,OAAQ,CAAC,MAAO,OAChBhB,KAAM,GACNiB,SAAU,CACRC,UAAW,CACTC,WAAY,GACZC,cAAe,EACfC,YAAa,uBAGjBC,MAAO,CACLC,UAAW,gBACXC,KAAM,CACJC,EAAG,CACDC,MAAO,UACPC,SAAU,GACVC,WAAY,OACZC,WAAY,OAMpB,IAAIC,EAAS,EACb,MAAMC,EAAkB/B,EAAKgC,eAA4B,IAAdC,EAAItB,IACzCuB,EAAcC,EAAQJ,EAAiB,CAACpB,GAAO,CAAC,SAEhDyB,EAAYF,EAAYG,OAAO,CAACC,EAAMC,KAC1C,MAAMC,EAAQC,OAAOF,EAAI5B,KAAU,EACnC,OAAO8B,OAAOC,MAAMF,GAASF,EAAOA,EAAOE,GAC1C,GACH,GAAIT,EAAgB1B,OAASyB,EAC3B,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MAAO,SAG5BH,EAAWsC,MAAQ,MACnBtC,EAAWwC,OAAS,GACpBxC,EAAWyC,IAAM,MACjBzC,EAAWuC,KAAO,GAClBvC,EAAWG,OAAS,CAAC,MAAO,QAGL,IAAlBZ,IACO,IAAVQ,GACFC,EAAWsC,MAAQ,MACnBtC,EAAWwC,OAAS,MACpBxC,EAAWyC,IAAM,GACjBzC,EAAWuC,KAAO,GAClBvC,EAAWG,OAAS,CAAC,MAAO,QAEX,IAAVJ,GACPC,EAAWsC,MAAQ,GACnBtC,EAAWwC,OAAS,MACpBxC,EAAWyC,IAAM,GACjBzC,EAAWuC,KAAO,MAClBvC,EAAWG,OAAS,CAAC,MAAO,QAEX,IAAVJ,GACPC,EAAWsC,MAAQ,MACnBtC,EAAWwC,OAAS,GACpBxC,EAAWyC,IAAM,MACjBzC,EAAWuC,KAAO,GAClBvC,EAAWG,OAAS,CAAC,MAAO,SAG5BH,EAAWsC,MAAQ,GACnBtC,EAAWwC,OAAS,GACpBxC,EAAWyC,IAAM,MACjBzC,EAAWuC,KAAO,MAClBvC,EAAWG,OAAS,CAAC,MAAO,SAKzB,qBADCd,EAAAqD,YAEJ1C,EAAW2C,OAAS,CAAC,MAAO,YAM5B3C,EAAW2C,OAAS,MAGxB,OAAO3C,KAKX,OAFA4C,QAAQC,IAAIpD,GAELhB,EAAMgB,EAAQJ,EAAAyD,iBAGjBC,QAAEA,GAAYC,EAAU,CAC5BC,SAAUpE,EACViE,aAAc/D,EACdO,UAAWN,EAAS,IAAMK,EAAAC,WAC1B4D,SAAO7D,EAAA6D,kBAITC,EAAa,CACXJ,wBAKAK,EAGE,MAAA,SAFI,eAAJtE,IAAID,EACJwE,MAAM"}
@@ -1,2 +1,2 @@
1
- "use strict";exports.version="0.0.87";
1
+ "use strict";exports.version="0.0.88";
2
2
  //# sourceMappingURL=package.json.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),t=require("lodash-es"),r=require("../utils/injectionKeys.cjs"),a=require("../utils/useCharts.cjs"),o=e.defineComponent({name:"DataChartPie",__name:"pie",props:{chartData:{type:Object,required:!0},subShowType:{type:String,required:!0,default:"pie-simple"},chartOptions:{type:null,required:!0},lazyLoad:{type:Boolean,required:!1,default:!0}},setup(o,{expose:i}){const c=e.inject(r.InjectionChartMerge,e=>e,!0),l=e.ref(null),s=e.computed(()=>{const{colDesc:e,xGroupByDesc:r,data:a,modelName:i}=o.chartData,l=e.length,s={title:{text:i},series:e.map((e,i)=>{const c={name:e,type:"pie",center:["50%","50%"],data:[],emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}},label:{formatter:"{b}:{c}({d}%)",rich:{b:{color:"#4C5058",fontSize:14,fontWeight:"bold",lineHeight:33}}}};let s=5;const n=a.filter(t=>void 0!==t[e]),u=t.orderBy(n,[e],["desc"]),h=u.reduce((t,r)=>{const a=Number(r[e])||0;return Number.isNaN(a)?t:t+a},0);if(n.length>s)for(;s<9;){const t=u.slice(0,s);if(t.reduce((t,r)=>t+Number(r[e]),0)/h>.9||8===s){const a=u.slice(s,u.length-1);c.data=n.map(a=>{let o={};return t.forEach(t=>{JSON.stringify(t)===JSON.stringify(a)&&(o={name:r?.colDesc?a[r.colDesc]:"",value:a[e]})}),o}).filter(e=>e&&Object.keys(e).length>0),c.data.push({name:"其它",value:a.reduce((t,r)=>t+Number(r[e]),0)});break}s++}else c.data=n.map(t=>({name:r?.colDesc&&t[r.colDesc]||"",value:Number(t[e]||0)}));if(1===l?c.center=["50%","60%"]:2===l?0===i?(c.right="40%",c.left="",c.center=["40%","60%"]):(c.right="",c.left="40%",c.center=["60%","60%"]):3===l?0===i?(c.right="40%",c.bottom="50%",c.top="",c.left="",c.center=["40%","78%"]):1===i?(c.right="",c.bottom="50%",c.top="",c.left="40%",c.center=["60%","78%"]):(c.right="40%",c.bottom="",c.top="50%",c.left="",c.center=["40%","60%"]):4===l&&(0===i?(c.right="40%",c.bottom="50%",c.top="",c.left="",c.center=["40%","78%"]):1===i?(c.right="",c.bottom="50%",c.top="",c.left="40%",c.center=["60%","78%"]):2===i?(c.right="40%",c.bottom="",c.top="50%",c.left="",c.center=["40%","60%"]):(c.right="",c.bottom="",c.top="50%",c.left="40%",c.center=["60%","60%"])),"pie-borderRadius"===o.subShowType)c.radius=["50%","70%"];else c.radius="50%";return c})};return c(s,o.chartOptions)}),{myChart:n}=a.useCharts({chartDOM:l,chartOptions:s,chartData:e.computed(()=>o.chartData),lazyLoad:o.lazyLoad});return i({myChart:n}),(t,r)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataChartPie",ref:l,class:"data-chart-pie"},null,512))}});exports.default=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),t=require("lodash-es"),r=require("../utils/injectionKeys.cjs"),a=require("../utils/useCharts.cjs"),o=e.defineComponent({name:"DataChartPie",__name:"pie",props:{chartData:{type:Object,required:!0},subShowType:{type:String,required:!0,default:"pie-simple"},chartOptions:{type:null,required:!0},lazyLoad:{type:Boolean,required:!1,default:!0}},setup(o,{expose:c}){const i=e.inject(r.InjectionChartMerge,e=>e,!0),l=e.ref(null),s=e.computed(()=>{const{colDesc:e,xGroupByDesc:r,data:a,modelName:c}=o.chartData,l=e.length,s={title:{text:c},series:e.map((e,c)=>{const i={name:e,type:"pie",center:["50%","50%"],data:[],emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}},label:{formatter:"{b}:{c}({d}%)",rich:{b:{color:"#4C5058",fontSize:14,fontWeight:"bold",lineHeight:33}}}};let s=5;const n=a.filter(t=>void 0!==t[e]),u=t.orderBy(n,[e],["desc"]),d=u.reduce((t,r)=>{const a=Number(r[e])||0;return Number.isNaN(a)?t:t+a},0);if(n.length>s)for(;s<9;){const t=u.slice(0,s);if(t.reduce((t,r)=>t+Number(r[e]),0)/d>.9||8===s){const a=u.slice(s);i.data=t.map(t=>({name:r?.colDesc?String(t[r.colDesc]||""):"",value:Number(t[e])||0}));const o=a.reduce((t,r)=>t+Number(r[e]),0);o>0&&i.data&&i.data.push({name:"其它",value:o});break}s++}else i.data=n.map(t=>({name:r?.colDesc&&t[r.colDesc]||"",value:Number(t[e]||0)}));if(1===l?i.center=["50%","60%"]:2===l?0===c?(i.right="40%",i.left="",i.center=["40%","60%"]):(i.right="",i.left="40%",i.center=["60%","60%"]):3===l?0===c?(i.right="40%",i.bottom="50%",i.top="",i.left="",i.center=["40%","78%"]):1===c?(i.right="",i.bottom="50%",i.top="",i.left="40%",i.center=["60%","78%"]):(i.right="40%",i.bottom="",i.top="50%",i.left="",i.center=["40%","60%"]):4===l&&(0===c?(i.right="40%",i.bottom="50%",i.top="",i.left="",i.center=["40%","78%"]):1===c?(i.right="",i.bottom="50%",i.top="",i.left="40%",i.center=["60%","78%"]):2===c?(i.right="40%",i.bottom="",i.top="50%",i.left="",i.center=["40%","60%"]):(i.right="",i.bottom="",i.top="50%",i.left="40%",i.center=["60%","60%"])),"pie-borderRadius"===o.subShowType)i.radius=["50%","70%"];else i.radius="50%";return i})};return console.log(s),i(s,o.chartOptions)}),{myChart:n}=a.useCharts({chartDOM:l,chartOptions:s,chartData:e.computed(()=>o.chartData),lazyLoad:o.lazyLoad});return c({myChart:n}),(t,r)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataChartPie",ref:l,class:"data-chart-pie"},null,512))}});exports.default=o;
2
2
  //# sourceMappingURL=pie.vue2.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pie.vue2.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/pie.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { PieSeriesOption } from 'echarts/charts'\nimport type { EChartsOption, IFormatPublicData } from '../utils/types'\nimport { orderBy } from 'lodash-es'\nimport { computed, inject, ref } from 'vue'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\ndefineOptions({\n name: 'DataChartPie',\n})\nconst {\n chartData,\n subShowType = 'pie-simple',\n chartOptions,\n lazyLoad = true,\n} = defineProps<{\n chartData: IFormatPublicData\n subShowType: string\n chartOptions: EChartsOption\n lazyLoad?: boolean\n}>()\nconst merge = inject(InjectionChartMerge, (v: any) => v, true)\n\nconst dataChartPie = ref(null)\nconst pieChartOptions = computed<EChartsOption>(() => {\n const { colDesc, xGroupByDesc, data, modelName } = chartData\n const colDescLength = colDesc.length\n const config = {\n title: { text: modelName },\n series: colDesc.map((item, index) => {\n const seriesItem: PieSeriesOption = {\n name: item,\n type: 'pie',\n center: ['50%', '50%'],\n data: [],\n emphasis: {\n itemStyle: {\n shadowBlur: 10,\n shadowOffsetX: 0,\n shadowColor: 'rgba(0, 0, 0, 0.5)',\n },\n },\n label: {\n formatter: '{b}:{c}({d}%)',\n rich: {\n b: {\n color: '#4C5058',\n fontSize: 14,\n fontWeight: 'bold',\n lineHeight: 33,\n },\n },\n },\n }\n\n let cutNum = 5\n const currentItemData = data.filter(row => row[item] !== undefined)\n const orderByData = orderBy(currentItemData, [item], ['desc'])\n // 总数\n const totalDesc = orderByData.reduce((prev, cur) => {\n const value = Number(cur[item]) || 0\n return Number.isNaN(value) ? prev : prev + value\n }, 0)\n if (currentItemData.length > cutNum) {\n while (cutNum < 9) {\n const headerData = orderByData.slice(0, cutNum)\n // 前 cutNum 个总数\n const headerTotal = headerData.reduce(\n (prev, cur) => prev + Number(cur[item]),\n 0,\n )\n // 前五总占比\n const headerScale = headerTotal / totalDesc\n if (headerScale > 0.9 || cutNum === 8) {\n const footerData = orderByData.slice(\n cutNum,\n orderByData.length - 1,\n )\n seriesItem.data = currentItemData\n .map((yItem) => {\n let obj = {}\n headerData.forEach((headerDataItem) => {\n if (JSON.stringify(headerDataItem) === JSON.stringify(yItem)) {\n obj = {\n name: xGroupByDesc?.colDesc\n ? yItem[xGroupByDesc.colDesc]\n : '',\n value: yItem[item],\n }\n }\n })\n return obj\n })\n .filter(v => v && Object.keys(v).length > 0)\n seriesItem.data.push({\n name: '其它',\n value: footerData.reduce(\n (prev, cur) => prev + Number(cur[item]),\n 0,\n ),\n })\n\n break\n }\n else {\n cutNum++\n }\n }\n }\n else {\n seriesItem.data = currentItemData.map(yItem => ({\n name: xGroupByDesc?.colDesc ? (yItem[xGroupByDesc.colDesc] || '') : '',\n value: Number(yItem[item] || 0),\n }))\n }\n\n if (colDescLength === 1) {\n seriesItem.center = ['50%', '60%']\n }\n else if (colDescLength === 2) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n else {\n seriesItem.right = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '60%']\n }\n }\n else if (colDescLength === 3) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = ''\n seriesItem.center = ['40%', '78%']\n }\n else if (index === 1) {\n seriesItem.right = ''\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '78%']\n }\n else {\n seriesItem.right = '40%'\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n }\n else if (colDescLength === 4) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = ''\n seriesItem.center = ['40%', '78%']\n }\n else if (index === 1) {\n seriesItem.right = ''\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '78%']\n }\n else if (index === 2) {\n seriesItem.right = '40%'\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n else {\n seriesItem.right = ''\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '60%']\n }\n }\n // 处理图表形状\n switch (subShowType) {\n case 'pie-borderRadius':\n seriesItem.radius = ['50%', '70%']\n break\n case 'pie-simple':\n seriesItem.radius = '50%'\n break\n default:\n seriesItem.radius = '50%'\n break\n }\n return seriesItem\n }),\n }\n\n return merge(config, chartOptions)\n})\n\nconst { myChart } = useCharts({\n chartDOM: dataChartPie,\n chartOptions: pieChartOptions,\n chartData: computed(() => chartData),\n lazyLoad,\n})\n\n// 暴露 myChart 方法供父组件访问\ndefineExpose({\n myChart,\n})\n</script>\n\n<template>\n <div\n ref=\"dataChartPie\"\n class=\"data-chart-pie\"\n />\n</template>\n\n<style scoped lang=\"scss\">\n.data-chart-pie {\n width: 100%;\n height: 100%;\n}\n</style>\n"],"names":["merge","inject","InjectionChartMerge","v","dataChartPie","ref","pieChartOptions","computed","colDesc","xGroupByDesc","data","modelName","__props","chartData","colDescLength","length","config","title","text","series","map","item","index","seriesItem","name","type","center","emphasis","itemStyle","shadowBlur","shadowOffsetX","shadowColor","label","formatter","rich","b","color","fontSize","fontWeight","lineHeight","cutNum","currentItemData","filter","row","orderByData","orderBy","totalDesc","reduce","prev","cur","value","Number","isNaN","headerData","slice","footerData","yItem","obj","forEach","headerDataItem","JSON","stringify","Object","keys","push","right","left","bottom","top","subShowType","radius","chartOptions","myChart","useCharts","chartDOM","lazyLoad","__expose","_createElementBlock","class"],"mappings":"icAsBA,MAAMA,EAAQC,EAAAA,OAAOC,EAAAA,oBAAsBC,GAAWA,GAAG,GAEnDC,EAAeC,EAAAA,IAAI,MACnBC,EAAkBC,EAAAA,SAAwB,KAC9C,MAAMC,QAAEA,EAAAC,aAASA,EAAAC,KAAcA,EAAAC,UAAMA,GAAcC,EAAAC,UAC7CC,EAAgBN,EAAQO,OACxBC,EAAS,CACbC,MAAO,CAAEC,KAAMP,GACfQ,OAAQX,EAAQY,IAAI,CAACC,EAAMC,KACzB,MAAMC,EAA8B,CAClCC,KAAMH,EACNI,KAAM,MACNC,OAAQ,CAAC,MAAO,OAChBhB,KAAM,GACNiB,SAAU,CAC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AWG,OAAS,CAAC,MAAO,SAKzB,qBADCd,EAAAyD,YAEJ9C,EAAW+C,OAAS,CAAC,MAAO,YAM5B/C,EAAW+C,OAAS,MAGxB,OAAO/C,KAIX,OAAOvB,EAAMgB,EAAQJ,EAAA2D,iBAGjBC,QAAEA,GAAYC,YAAU,CAC5BC,SAAUtE,EACVmE,aAAcjE,EACdO,UAAWN,EAAAA,SAAS,IAAMK,EAAAC,WAC1B8D,SAAO/D,EAAA+D,kBAITC,EAAa,CACXJ,kCAKAK,EAAAA,mBAGE,MAAA,SAFI,eAAJxE,IAAID,EACJ0E,MAAM"}
1
+ {"version":3,"file":"pie.vue2.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/pie.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { PieSeriesOption } from 'echarts/charts'\nimport type { EChartsOption, IFormatPublicData } from '../utils/types'\nimport { orderBy } from 'lodash-es'\nimport { computed, inject, ref } from 'vue'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\ndefineOptions({\n name: 'DataChartPie',\n})\nconst {\n chartData,\n subShowType = 'pie-simple',\n chartOptions,\n lazyLoad = true,\n} = defineProps<{\n chartData: IFormatPublicData\n subShowType: string\n chartOptions: EChartsOption\n lazyLoad?: boolean\n}>()\nconst merge = inject(InjectionChartMerge, (v: any) => v, true)\n\nconst dataChartPie = ref(null)\nconst pieChartOptions = computed<EChartsOption>(() => {\n const { colDesc, xGroupByDesc, data, modelName } = chartData\n const colDescLength = colDesc.length\n const config = {\n title: { text: modelName },\n series: colDesc.map((item, index) => {\n const seriesItem: PieSeriesOption = {\n name: item,\n type: 'pie',\n center: ['50%', '50%'],\n data: [],\n emphasis: {\n itemStyle: {\n shadowBlur: 10,\n shadowOffsetX: 0,\n shadowColor: 'rgba(0, 0, 0, 0.5)',\n },\n },\n label: {\n formatter: '{b}:{c}({d}%)',\n rich: {\n b: {\n color: '#4C5058',\n fontSize: 14,\n fontWeight: 'bold',\n lineHeight: 33,\n },\n },\n },\n }\n\n let cutNum = 5\n const currentItemData = data.filter(row => row[item] !== undefined)\n const orderByData = orderBy(currentItemData, [item], ['desc'])\n // 总数\n const totalDesc = orderByData.reduce((prev, cur) => {\n const value = Number(cur[item]) || 0\n return Number.isNaN(value) ? prev : prev + value\n }, 0)\n if (currentItemData.length > cutNum) {\n while (cutNum < 9) {\n const headerData = orderByData.slice(0, cutNum)\n // 前 cutNum 个总数\n const headerTotal = headerData.reduce(\n (prev, cur) => prev + Number(cur[item]),\n 0,\n )\n // 前N项总占比\n const headerScale = headerTotal / totalDesc\n if (headerScale > 0.9 || cutNum === 8) {\n const footerData = orderByData.slice(cutNum)\n\n // 处理前N项数据\n seriesItem.data = headerData.map(headerItem => ({\n name: xGroupByDesc?.colDesc\n ? String(headerItem[xGroupByDesc.colDesc] || '')\n : '',\n value: Number(headerItem[item]) || 0,\n }))\n\n // 添加\"其它\"项,包含剩余所有数据\n const footerTotal = footerData.reduce(\n (prev, cur) => prev + Number(cur[item]),\n 0,\n )\n\n if (footerTotal > 0 && seriesItem.data) {\n seriesItem.data.push({\n name: '其它',\n value: footerTotal,\n })\n }\n\n break\n }\n else {\n cutNum++\n }\n }\n }\n else {\n seriesItem.data = currentItemData.map(yItem => ({\n name: xGroupByDesc?.colDesc ? (yItem[xGroupByDesc.colDesc] || '') : '',\n value: Number(yItem[item] || 0),\n }))\n }\n\n if (colDescLength === 1) {\n seriesItem.center = ['50%', '60%']\n }\n else if (colDescLength === 2) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n else {\n seriesItem.right = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '60%']\n }\n }\n else if (colDescLength === 3) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = ''\n seriesItem.center = ['40%', '78%']\n }\n else if (index === 1) {\n seriesItem.right = ''\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '78%']\n }\n else {\n seriesItem.right = '40%'\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n }\n else if (colDescLength === 4) {\n if (index === 0) {\n seriesItem.right = '40%'\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = ''\n seriesItem.center = ['40%', '78%']\n }\n else if (index === 1) {\n seriesItem.right = ''\n seriesItem.bottom = '50%'\n seriesItem.top = ''\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '78%']\n }\n else if (index === 2) {\n seriesItem.right = '40%'\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = ''\n seriesItem.center = ['40%', '60%']\n }\n else {\n seriesItem.right = ''\n seriesItem.bottom = ''\n seriesItem.top = '50%'\n seriesItem.left = '40%'\n seriesItem.center = ['60%', '60%']\n }\n }\n // 处理图表形状\n switch (subShowType) {\n case 'pie-borderRadius':\n seriesItem.radius = ['50%', '70%']\n break\n case 'pie-simple':\n seriesItem.radius = '50%'\n break\n default:\n seriesItem.radius = '50%'\n break\n }\n return seriesItem\n }),\n }\n console.log(config)\n\n return merge(config, chartOptions)\n})\n\nconst { myChart } = useCharts({\n chartDOM: dataChartPie,\n chartOptions: pieChartOptions,\n chartData: computed(() => chartData),\n lazyLoad,\n})\n\n// 暴露 myChart 方法供父组件访问\ndefineExpose({\n myChart,\n})\n</script>\n\n<template>\n <div\n ref=\"dataChartPie\"\n class=\"data-chart-pie\"\n />\n</template>\n\n<style scoped lang=\"scss\">\n.data-chart-pie {\n width: 100%;\n height: 100%;\n}\n</style>\n"],"names":["merge","inject","InjectionChartMerge","v","dataChartPie","ref","pieChartOptions","computed","colDesc","xGroupByDesc","data","modelName","__props","chartData","colDescLength","length","config","title","text","series","map","item","index","seriesItem","name","type","center","emphasis","itemStyle","shadowBlur","shadowOffsetX","shadowColor","label","formatter","rich","b","color","fontSize","fontWeight","lineHeight","cutNum","currentItemData","filter","row","orderByData","orderBy","totalDesc","reduce","prev","cur","value","Number","isNaN","headerData","slice","footerData","headerItem","String","footerTotal","push","yItem","right","left","bottom","top","subShowType","radius","console","log","chartOptions","myChart","useCharts","chartDOM","lazyLoad","__expose","_createElementBlock","class"],"mappings":"icAsBA,MAAMA,EAAQC,EAAAA,OAAOC,EAAAA,oBAAsBC,GAAWA,GAAG,GAEnDC,EAAeC,EAAAA,IAAI,MACnBC,EAAkBC,EAAAA,SAAwB,KAC9C,MAAMC,QAAEA,EAAAC,aAASA,EAAAC,KAAcA,EAAAC,UAAMA,GAAcC,EAAAC,UAC7CC,EAAgBN,EAAQO,OACxBC,EAAS,CACbC,MAAO,CAAEC,KAAMP,GACfQ,OAAQX,EAAQY,IAAI,CAACC,EAAMC,KACzB,MAAMC,EAA8B,CAClCC,KAAMH,EACNI,KAAM,MACNC,OAAQ,CAAC,MAAO,OAChBhB,KAAM,GACNiB,SAAU,CACRC,UAAW,CACTC,WAAY,GACZC,cAAe,EACfC,YAAa,uBAGjBC,MAAO,CACLC,UAAW,gBACXC,KAAM,CACJC,EAAG,CACDC,MAAO,UACPC,SAAU,GACVC,WAAY,OACZC,WAAY,OAMpB,IAAIC,EAAS,EACb,MAAMC,EAAkB/B,EAAKgC,eAA4B,IAAdC,EAAItB,IACzCuB,EAAcC,EAAAA,QAAQJ,EAAiB,CAACpB,GAAO,CAAC,SAEhDyB,EAAYF,EAAYG,OAAO,CAACC,EAAMC,KAC1C,MAAMC,EAAQC,OAAOF,EAAI5B,KAAU,EACnC,OAAO8B,OAAOC,MAAMF,GAASF,EAAOA,EAAOE,GAC1C,GACH,GAAIT,EAAgB1B,OAASyB,EAC3B,KAAOA,EAAS,GAAG,CACjB,MAAMa,EAAaT,EAAYU,MAAM,EAAGd,GAQxC,GANoBa,EAAWN,OAC7B,CAACC,EAAMC,IAAQD,EAAOG,OAAOF,EAAI5B,IACjC,GAGgCyB,EAChB,IAAkB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,GACFC,EAAWsC,MAAQ,MACnBtC,EAAWwC,OAAS,MACpBxC,EAAWyC,IAAM,GACjBzC,EAAWuC,KAAO,GAClBvC,EAAWG,OAAS,CAAC,MAAO,QAEX,IAAVJ,GACPC,EAAWsC,MAAQ,GACnBtC,EAAWwC,OAAS,MACpBxC,EAAWyC,IAAM,GACjBzC,EAAWuC,KAAO,MAClBvC,EAAWG,OAAS,CAAC,MAAO,QAEX,IAAVJ,GACPC,EAAWsC,MAAQ,MACnBtC,EAAWwC,OAAS,GACpBxC,EAAWyC,IAAM,MACjBzC,EAAWuC,KAAO,GAClBvC,EAAWG,OAAS,CAAC,MAAO,SAG5BH,EAAWsC,MAAQ,GACnBtC,EAAWwC,OAAS,GACpBxC,EAAWyC,IAAM,MACjBzC,EAAWuC,KAAO,MAClBvC,EAAWG,OAAS,CAAC,MAAO,SAKzB,qBADCd,EAAAqD,YAEJ1C,EAAW2C,OAAS,CAAC,MAAO,YAM5B3C,EAAW2C,OAAS,MAGxB,OAAO3C,KAKX,OAFA4C,QAAQC,IAAIpD,GAELhB,EAAMgB,EAAQJ,EAAAyD,iBAGjBC,QAAEA,GAAYC,YAAU,CAC5BC,SAAUpE,EACViE,aAAc/D,EACdO,UAAWN,EAAAA,SAAS,IAAMK,EAAAC,WAC1B4D,SAAO7D,EAAA6D,kBAITC,EAAa,CACXJ,kCAKAK,EAAAA,mBAGE,MAAA,SAFI,eAAJtE,IAAID,EACJwE,MAAM"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qxs-bns/components",
3
3
  "type": "module",
4
- "version": "0.0.87",
4
+ "version": "0.0.88",
5
5
  "description": "Vue 3 Component Library",
6
6
  "license": "MIT",
7
7
  "homepage": "https://qxs-bns.pages.dev/guide/components/overview.html",
@@ -46,7 +46,7 @@
46
46
  "@qxs-bns/directives": "0.0.19",
47
47
  "@qxs-bns/hooks": "0.0.7",
48
48
  "@qxs-bns/icons": "0.0.10",
49
- "@qxs-bns/utils": "0.0.29",
49
+ "@qxs-bns/utils": "0.0.34",
50
50
  "@vueuse/core": "^11.3.0",
51
51
  "echarts": "^5.5.1",
52
52
  "lodash-es": "^4.17.21",
@@ -1 +1 @@
1
- {"version":3,"file":"pie.vue.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/data-chart/src/components/pie.vue"],"names":[],"mappings":"AAyOA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAStE,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,aAAa,CAAA;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;;;;AAiPF,wBAGG"}
1
+ {"version":3,"file":"pie.vue.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/data-chart/src/components/pie.vue"],"names":[],"mappings":"AAqOA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAStE,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,aAAa,CAAA;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAC;;;;AA6OF,wBAGG"}