@qxs-bns/components 0.0.88 → 0.0.89
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/es/package.json.mjs +1 -1
- package/es/src/data-chart/src/components/bar.vue2.mjs +1 -1
- package/es/src/data-chart/src/components/bar.vue2.mjs.map +1 -1
- package/lib/package.json.cjs +1 -1
- package/lib/src/data-chart/src/components/bar.vue2.cjs +1 -1
- package/lib/src/data-chart/src/components/bar.vue2.cjs.map +1 -1
- package/package.json +1 -1
- package/types/src/data-chart/src/components/bar.vue.d.ts.map +1 -1
- package/types/tsconfig.tsbuildinfo +1 -1
package/es/package.json.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var r="0.0.
|
|
1
|
+
var r="0.0.89";export{r as version};
|
|
2
2
|
//# sourceMappingURL=package.json.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineComponent as e,inject as a,ref as t,computed as
|
|
1
|
+
import{defineComponent as e,inject as a,ref as t,computed as r,createElementBlock as s,openBlock as l}from"vue";import{uniq as o}from"lodash-es";import{InjectionChartMerge as i}from"../utils/injectionKeys.mjs";import{useCharts as c}from"../utils/useCharts.mjs";var n=e({name:"DataChartBar",__name:"bar",props:{chartData:{type:Object,required:!0},subShowType:{type:String,required:!0,default:"bar-simple"},chartOptions:{type:null,required:!0},lazyLoad:{type:Boolean,required:!1,default:!0}},setup(e,{expose:n}){const p=a(i,e=>e,!0),u=t(null),y=r(()=>{const{colDesc:a,xGroupByDesc:t,groupByDesc:r,data:s=[],modelName:l}=e.chartData,i=Array.from(new Set(s.map(e=>e[t.colDesc||""]))).filter(e=>null!=e)||[],c={...r.find(e=>!e.xAxis)||{groupByDesc:null,groupByValues:[],colDesc:"",xAxis:!1},groupByValues:o(s.map(e=>r.find(e=>!e.xAxis)?.colDesc?String(e[r.find(e=>!e.xAxis)?.colDesc||""]):""))},n=t?{...t,groupByValues:o(s.map(e=>t.colDesc?String(e[t.colDesc]):""))}:t,u={title:{text:l},xAxis:{name:"",type:"category",axisLabel:{interval:0,formatter:e=>e.length>5?`${e.substring(0,5)}...`:e},data:i},yAxis:{type:"value"},legend:{data:[]},dataZoom:[{type:"inside",disabled:i.length<15}]};if(1===r.length)u.series=a.map(e=>({name:e,data:s.map(a=>a[e]),type:"bar",emphasis:{focus:"series"},label:{show:!0,position:"inside"}})),u.legend.data=a;else if(2===r.length){const e=a.map(e=>c.groupByValues?.map(a=>{const t={name:`${a||"/"}-${e}`,type:"bar",stack:e,emphasis:{focus:"series"},data:[],label:{show:!0,position:"inside"}};return t.data=(n?.groupByValues||[]).map(e=>{let r=null;return s.forEach(s=>{c.colDesc&&s[c.colDesc]===a&&n?.colDesc&&s[n.colDesc]===e&&t.stack&&(r=s[t.stack]??null)}),r||""}).filter(e=>""!==e),t})||[]).flat();u.series=e,delete u.legend}function y(e,a,t,r){Array.isArray(e)?e.forEach(e=>{e&&(e.type=a,"category"===a&&(e.data=t||[],e.name=r||""))}):e&&(e.type=a,"category"===a&&(e.data=t||[],e.name=r||""))}switch(e.subShowType){case"bar-simple":case"default":y(u.xAxis,"category",i,t?.colDesc||""),y(u.yAxis,"value");break;case"bar-y-category":y(u.xAxis,"value"),y(u.yAxis,"category",i,t?.colDesc||""),u.grid={top:80,...u.grid}}return p(u,e.chartOptions)}),{myChart:d}=c({chartDOM:u,chartOptions:y,chartData:r(()=>e.chartData),lazyLoad:e.lazyLoad});return n({myChart:d}),(e,a)=>(l(),s("div",{ref_key:"dataChartBar",ref:u,class:"data-chart-bar"},null,512))}});export{n as default};
|
|
2
2
|
//# sourceMappingURL=bar.vue2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar.vue2.mjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/bar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { LegendComponentOption, XAXisComponentOption, YAXisComponentOption } from 'echarts'\nimport type {\n EChartsOption,\n IFormatPublicData,\n SeriesOption,\n} from '../utils/types'\nimport { uniq } from 'lodash-es'\nimport { computed, inject, ref } from 'vue'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\n// 定义组件名称\ndefineOptions({\n name: 'DataChartBar',\n})\n\n// 定义组件属性\nconst {\n chartOptions,\n chartData,\n subShowType = 'bar-simple',\n lazyLoad = true,\n} = defineProps<{\n chartData: IFormatPublicData\n subShowType: string\n chartOptions: EChartsOption\n lazyLoad?: boolean\n}>()\n\n// 注入合并函数,并明确类型\nconst merge = inject(InjectionChartMerge, (v: any) => v, true) as (config: EChartsOption, chartOptions: EChartsOption) => EChartsOption\nconst dataChartBar = ref<HTMLElement | null>(null)\n\n// 计算图表选项\nconst barChartOptions = computed<EChartsOption>(() => {\n const { colDesc, xGroupByDesc, groupByDesc, data = [], modelName } = chartData\n\n const axisData = Array.from(new Set(data.map(item => item[xGroupByDesc.colDesc || '']))).filter(item => item !== undefined && item !== null) || []\n\n // 创建新的对象而不是修改原对象\n const yGroupByDesc = {\n ...groupByDesc.find(item => !item.xAxis) || {\n groupByDesc: null,\n groupByValues: [],\n colDesc: '',\n xAxis: false,\n },\n groupByValues: uniq(data.map(item => groupByDesc.find(item => !item.xAxis)?.colDesc ? String(item[groupByDesc.find(item => !item.xAxis)?.colDesc || '']) : '')),\n }\n\n // 创建新的 xGroupByDesc 对象\n const newXGroupByDesc = xGroupByDesc\n ? {\n ...xGroupByDesc,\n groupByValues: uniq(data.map(item => xGroupByDesc.colDesc ? String(item[xGroupByDesc.colDesc]) : '')),\n }\n : xGroupByDesc\n\n const config: EChartsOption = {\n title: {\n text: modelName,\n },\n xAxis: {\n name: '',\n type: 'category',\n axisLabel: {\n interval: 0, // 强制显示所有标签\n formatter(value: string) {\n const screenshotLength = 5\n return value.length > screenshotLength ? `${value.substring(0, screenshotLength)}...` : value // 截取前5个字符并添加省略号\n },\n },\n data: axisData,\n },\n yAxis: {\n type: 'value',\n },\n legend: {\n data: [],\n },\n dataZoom: [{\n type: 'inside',\n disabled: axisData.length < 15,\n }],\n }\n\n // 堆叠图\n if (groupByDesc.length === 1) {\n config.series = colDesc.map((yItem) => {\n return {\n name: yItem,\n data: data.map(item => item[yItem]),\n type: 'bar',\n emphasis: {\n focus: 'series',\n },\n label: {\n show: true,\n position: 'inside',\n },\n }\n });\n (config.legend as LegendComponentOption).data = colDesc\n }\n else if (groupByDesc.length === 2) {\n const arr = colDesc.map((colDescItem) => {\n return yGroupByDesc.groupByValues?.map((yGroupByDescItem) => {\n const obj: SeriesOption = {\n name: `${yGroupByDescItem || '/'}-${colDescItem}`,\n type: 'bar',\n stack: colDescItem,\n emphasis: {\n focus: 'series',\n },\n data: [],\n label: {\n show: true,\n position: 'inside',\n },\n }\n obj.data = (newXGroupByDesc?.groupByValues || []).map((xGroupByDescItem) => {\n let targetVal: number | string | null = null\n data.forEach((item) => {\n if (yGroupByDesc.colDesc && item[yGroupByDesc.colDesc] === yGroupByDescItem && newXGroupByDesc?.colDesc && item[newXGroupByDesc.colDesc] === xGroupByDescItem) {\n if (obj.stack) {\n targetVal = item[obj.stack] ?? null\n }\n }\n })\n return targetVal || ''\n }).filter(v => v !== '')\n return obj\n }) || []\n }).flat()\n\n config.series = arr\n delete config.legend\n }\n\n // 1. 定义轴类型\n type CategoryAxisOption = XAXisComponentOption & {\n type: 'category'\n data: (string | number)[]\n }\n\n // 2. 创建配置轴的辅助函数\n function configureAxis(\n axis: XAXisComponentOption | XAXisComponentOption[] | YAXisComponentOption | YAXisComponentOption[] | undefined,\n type: 'category' | 'value',\n data?: (string | number)[],\n name?: string,\n ) {\n if (Array.isArray(axis)) {\n axis.forEach((item) => {\n if (item) {\n item.type = type\n if (type === 'category') {\n (item as CategoryAxisOption).data = data || []\n item.name = name || ''\n }\n }\n })\n }\n else if (axis) {\n axis.type = type\n if (type === 'category') {\n (axis as CategoryAxisOption).data = data || []\n axis.name = name || ''\n }\n }\n }\n\n // 3. 使用配置函数\n switch (subShowType) {\n case 'bar-simple':\n case 'default':\n configureAxis(config.xAxis, 'category', axisData, xGroupByDesc?.colDesc || '')\n configureAxis(config.yAxis, 'value')\n break\n\n case 'bar-y-category':\n configureAxis(config.xAxis, 'value')\n configureAxis(config.yAxis, 'category', axisData, xGroupByDesc?.colDesc || '')\n break\n }\n\n return merge(config, chartOptions)\n})\n\nconst { myChart } = useCharts({\n chartDOM: dataChartBar,\n chartOptions: barChartOptions,\n chartData: computed(() => chartData),\n lazyLoad,\n})\n\n// 暴露 myChart 方法供父组件访问\ndefineExpose({\n myChart,\n})\n</script>\n\n<template>\n <div\n ref=\"dataChartBar\"\n class=\"data-chart-bar\"\n />\n</template>\n\n<style scoped lang=\"scss\">\n.data-chart-bar {\n width: 100%;\n height: 100%;\n}\n</style>\n"],"names":["merge","inject","InjectionChartMerge","v","dataChartBar","ref","barChartOptions","computed","colDesc","xGroupByDesc","groupByDesc","data","modelName","__props","chartData","axisData","Array","from","Set","map","item","filter","yGroupByDesc","find","xAxis","groupByValues","uniq","String","newXGroupByDesc","config","title","text","name","type","axisLabel","interval","formatter","value","length","substring","yAxis","legend","dataZoom","disabled","series","yItem","emphasis","focus","label","show","position","arr","colDescItem","yGroupByDescItem","obj","stack","xGroupByDescItem","targetVal","forEach","flat","configureAxis","axis","isArray","subShowType","chartOptions","myChart","useCharts","chartDOM","lazyLoad","__expose","_createElementBlock","class"],"mappings":"8fA+BA,MAAMA,EAAQC,EAAOC,EAAsBC,GAAWA,GAAG,GACnDC,EAAeC,EAAwB,MAGvCC,EAAkBC,EAAwB,KAC9C,MAAMC,QAAEA,eAASC,EAAAC,YAAcA,EAAAC,KAAaA,EAAO,GAACC,UAAGA,GAAcC,EAAAC,UAE/DC,EAAWC,MAAMC,KAAK,IAAIC,IAAIP,EAAKQ,IAAIC,GAAQA,EAAKX,EAAaD,SAAW,OAAOa,OAAOD,GAAQA,UAAwC,GAG1IE,EAAe,IAChBZ,EAAYa,SAAcH,EAAKI,QAAU,CAC1Cd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+C,QAAStC,IACRE,EAAad,SAAWY,EAAKE,EAAad,WAAa6C,GAAoBzB,GAAiBpB,SAAWY,EAAKQ,EAAgBpB,WAAagD,GACvIF,EAAIC,QACNE,EAAYrC,EAAKkC,EAAIC,QAAU,QAI9BE,GAAa,KACnBpC,OAAOlB,GAAW,KAANA,GACRmD,KACH,IACLK,OAEH9B,EAAOe,OAASO,SACTtB,EAAOY,MAChB,CASA,SAASmB,EACPC,EACA5B,EACAtB,EACAqB,GAEIhB,MAAM8C,QAAQD,GAChBA,EAAKH,QAAStC,IACRA,IACFA,EAAKa,KAAOA,EACC,aAATA,IACDb,EAA4BT,KAAOA,GAAQ,GAC5CS,EAAKY,KAAOA,GAAQ,OAKnB6B,IACPA,EAAK5B,KAAOA,EACC,aAATA,IACD4B,EAA4BlD,KAAOA,GAAQ,GAC5CkD,EAAK7B,KAAOA,GAAQ,IAG1B,CAGA,OAAQnB,EAAAkD,aACN,IAAK,aACL,IAAK,UACHH,EAAc/B,EAAOL,MAAO,WAAYT,EAAUN,GAAcD,SAAW,IAC3EoD,EAAc/B,EAAOW,MAAO,SAC5B,MAEF,IAAK,iBACHoB,EAAc/B,EAAOL,MAAO,SAC5BoC,EAAc/B,EAAOW,MAAO,WAAYzB,EAAUN,GAAcD,SAAW,
|
|
1
|
+
{"version":3,"file":"bar.vue2.mjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/bar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { LegendComponentOption, XAXisComponentOption, YAXisComponentOption } from 'echarts'\nimport type {\n EChartsOption,\n IFormatPublicData,\n SeriesOption,\n} from '../utils/types'\nimport { uniq } from 'lodash-es'\nimport { computed, inject, ref } from 'vue'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\n// 定义组件名称\ndefineOptions({\n name: 'DataChartBar',\n})\n\n// 定义组件属性\nconst {\n chartOptions,\n chartData,\n subShowType = 'bar-simple',\n lazyLoad = true,\n} = defineProps<{\n chartData: IFormatPublicData\n subShowType: string\n chartOptions: EChartsOption\n lazyLoad?: boolean\n}>()\n\n// 注入合并函数,并明确类型\nconst merge = inject(InjectionChartMerge, (v: any) => v, true) as (config: EChartsOption, chartOptions: EChartsOption) => EChartsOption\nconst dataChartBar = ref<HTMLElement | null>(null)\n\n// 计算图表选项\nconst barChartOptions = computed<EChartsOption>(() => {\n const { colDesc, xGroupByDesc, groupByDesc, data = [], modelName } = chartData\n\n const axisData = Array.from(new Set(data.map(item => item[xGroupByDesc.colDesc || '']))).filter(item => item !== undefined && item !== null) || []\n\n // 创建新的对象而不是修改原对象\n const yGroupByDesc = {\n ...groupByDesc.find(item => !item.xAxis) || {\n groupByDesc: null,\n groupByValues: [],\n colDesc: '',\n xAxis: false,\n },\n groupByValues: uniq(data.map(item => groupByDesc.find(item => !item.xAxis)?.colDesc ? String(item[groupByDesc.find(item => !item.xAxis)?.colDesc || '']) : '')),\n }\n\n // 创建新的 xGroupByDesc 对象\n const newXGroupByDesc = xGroupByDesc\n ? {\n ...xGroupByDesc,\n groupByValues: uniq(data.map(item => xGroupByDesc.colDesc ? String(item[xGroupByDesc.colDesc]) : '')),\n }\n : xGroupByDesc\n\n const config: EChartsOption = {\n title: {\n text: modelName,\n },\n xAxis: {\n name: '',\n type: 'category',\n axisLabel: {\n interval: 0, // 强制显示所有标签\n formatter(value: string) {\n const screenshotLength = 5\n return value.length > screenshotLength ? `${value.substring(0, screenshotLength)}...` : value // 截取前5个字符并添加省略号\n },\n },\n data: axisData,\n },\n yAxis: {\n type: 'value',\n },\n legend: {\n data: [],\n },\n dataZoom: [{\n type: 'inside',\n disabled: axisData.length < 15,\n }],\n }\n\n // 堆叠图\n if (groupByDesc.length === 1) {\n config.series = colDesc.map((yItem) => {\n return {\n name: yItem,\n data: data.map(item => item[yItem]),\n type: 'bar',\n emphasis: {\n focus: 'series',\n },\n label: {\n show: true,\n position: 'inside',\n },\n }\n });\n (config.legend as LegendComponentOption).data = colDesc\n }\n else if (groupByDesc.length === 2) {\n const arr = colDesc.map((colDescItem) => {\n return yGroupByDesc.groupByValues?.map((yGroupByDescItem) => {\n const obj: SeriesOption = {\n name: `${yGroupByDescItem || '/'}-${colDescItem}`,\n type: 'bar',\n stack: colDescItem,\n emphasis: {\n focus: 'series',\n },\n data: [],\n label: {\n show: true,\n position: 'inside',\n },\n }\n obj.data = (newXGroupByDesc?.groupByValues || []).map((xGroupByDescItem) => {\n let targetVal: number | string | null = null\n data.forEach((item) => {\n if (yGroupByDesc.colDesc && item[yGroupByDesc.colDesc] === yGroupByDescItem && newXGroupByDesc?.colDesc && item[newXGroupByDesc.colDesc] === xGroupByDescItem) {\n if (obj.stack) {\n targetVal = item[obj.stack] ?? null\n }\n }\n })\n return targetVal || ''\n }).filter(v => v !== '')\n return obj\n }) || []\n }).flat()\n\n config.series = arr\n delete config.legend\n }\n\n // 1. 定义轴类型\n type CategoryAxisOption = XAXisComponentOption & {\n type: 'category'\n data: (string | number)[]\n }\n\n // 2. 创建配置轴的辅助函数\n function configureAxis(\n axis: XAXisComponentOption | XAXisComponentOption[] | YAXisComponentOption | YAXisComponentOption[] | undefined,\n type: 'category' | 'value',\n data?: (string | number)[],\n name?: string,\n ) {\n if (Array.isArray(axis)) {\n axis.forEach((item) => {\n if (item) {\n item.type = type\n if (type === 'category') {\n (item as CategoryAxisOption).data = data || []\n item.name = name || ''\n }\n }\n })\n }\n else if (axis) {\n axis.type = type\n if (type === 'category') {\n (axis as CategoryAxisOption).data = data || []\n axis.name = name || ''\n }\n }\n }\n\n // 3. 使用配置函数\n switch (subShowType) {\n case 'bar-simple':\n case 'default':\n configureAxis(config.xAxis, 'category', axisData, xGroupByDesc?.colDesc || '')\n configureAxis(config.yAxis, 'value')\n break\n\n case 'bar-y-category':\n configureAxis(config.xAxis, 'value')\n configureAxis(config.yAxis, 'category', axisData, xGroupByDesc?.colDesc || '')\n // 增加顶部距离,为图例和轴名称预留空间\n config.grid = {\n top: 80,\n ...config.grid,\n }\n break\n }\n\n return merge(config, chartOptions)\n})\n\nconst { myChart } = useCharts({\n chartDOM: dataChartBar,\n chartOptions: barChartOptions,\n chartData: computed(() => chartData),\n lazyLoad,\n})\n\n// 暴露 myChart 方法供父组件访问\ndefineExpose({\n myChart,\n})\n</script>\n\n<template>\n <div\n ref=\"dataChartBar\"\n class=\"data-chart-bar\"\n />\n</template>\n\n<style scoped lang=\"scss\">\n.data-chart-bar {\n width: 100%;\n height: 100%;\n}\n</style>\n"],"names":["merge","inject","InjectionChartMerge","v","dataChartBar","ref","barChartOptions","computed","colDesc","xGroupByDesc","groupByDesc","data","modelName","__props","chartData","axisData","Array","from","Set","map","item","filter","yGroupByDesc","find","xAxis","groupByValues","uniq","String","newXGroupByDesc","config","title","text","name","type","axisLabel","interval","formatter","value","length","substring","yAxis","legend","dataZoom","disabled","series","yItem","emphasis","focus","label","show","position","arr","colDescItem","yGroupByDescItem","obj","stack","xGroupByDescItem","targetVal","forEach","flat","configureAxis","axis","isArray","subShowType","grid","top","chartOptions","myChart","useCharts","chartDOM","lazyLoad","__expose","_createElementBlock","class"],"mappings":"8fA+BA,MAAMA,EAAQC,EAAOC,EAAsBC,GAAWA,GAAG,GACnDC,EAAeC,EAAwB,MAGvCC,EAAkBC,EAAwB,KAC9C,MAAMC,QAAEA,eAASC,EAAAC,YAAcA,EAAAC,KAAaA,EAAO,GAACC,UAAGA,GAAcC,EAAAC,UAE/DC,EAAWC,MAAMC,KAAK,IAAIC,IAAIP,EAAKQ,IAAIC,GAAQA,EAAKX,EAAaD,SAAW,OAAOa,OAAOD,GAAQA,UAAwC,GAG1IE,EAAe,IAChBZ,EAAYa,SAAcH,EAAKI,QAAU,CAC1Cd,YAAa,KACbe,cAAe,GACfjB,QAAS,GACTgB,OAAO,GAETC,cAAeC,EAAKf,EAAKQ,IAAIC,GAAQV,EAAYa,KAAKH,IAASA,EAAKI,QAAQhB,QAAUmB,OAAOP,EAAKV,EAAYa,KAAKH,IAASA,EAAKI,QAAQhB,SAAW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W,KAANA,GACRmD,KACH,IACLK,OAEH9B,EAAOe,OAASO,SACTtB,EAAOY,MAChB,CASA,SAASmB,EACPC,EACA5B,EACAtB,EACAqB,GAEIhB,MAAM8C,QAAQD,GAChBA,EAAKH,QAAStC,IACRA,IACFA,EAAKa,KAAOA,EACC,aAATA,IACDb,EAA4BT,KAAOA,GAAQ,GAC5CS,EAAKY,KAAOA,GAAQ,OAKnB6B,IACPA,EAAK5B,KAAOA,EACC,aAATA,IACD4B,EAA4BlD,KAAOA,GAAQ,GAC5CkD,EAAK7B,KAAOA,GAAQ,IAG1B,CAGA,OAAQnB,EAAAkD,aACN,IAAK,aACL,IAAK,UACHH,EAAc/B,EAAOL,MAAO,WAAYT,EAAUN,GAAcD,SAAW,IAC3EoD,EAAc/B,EAAOW,MAAO,SAC5B,MAEF,IAAK,iBACHoB,EAAc/B,EAAOL,MAAO,SAC5BoC,EAAc/B,EAAOW,MAAO,WAAYzB,EAAUN,GAAcD,SAAW,IAE3EqB,EAAOmC,KAAO,CACZC,IAAK,MACFpC,EAAOmC,MAKhB,OAAOhE,EAAM6B,EAAQhB,EAAAqD,iBAGjBC,QAAEA,GAAYC,EAAU,CAC5BC,SAAUjE,EACV8D,aAAc5D,EACdQ,UAAWP,EAAS,IAAMM,EAAAC,WAC1BwD,SAAOzD,EAAAyD,kBAITC,EAAa,CACXJ,wBAKAK,EAGE,MAAA,SAFI,eAAJnE,IAAID,EACJqE,MAAM"}
|
package/lib/package.json.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";exports.version="0.0.
|
|
1
|
+
"use strict";exports.version="0.0.89";
|
|
2
2
|
//# sourceMappingURL=package.json.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),a=require("lodash-es"),t=require("../utils/injectionKeys.cjs"),r=require("../utils/useCharts.cjs"),s=e.defineComponent({name:"DataChartBar",__name:"bar",props:{chartData:{type:Object,required:!0},subShowType:{type:String,required:!0,default:"bar-simple"},chartOptions:{type:null,required:!0},lazyLoad:{type:Boolean,required:!1,default:!0}},setup(s,{expose:l}){const c=e.inject(t.InjectionChartMerge,e=>e,!0),o=e.ref(null),i=e.computed(()=>{const{colDesc:e,xGroupByDesc:t,groupByDesc:r,data:l=[],modelName:o}=s.chartData,i=Array.from(new Set(l.map(e=>e[t.colDesc||""]))).filter(e=>null!=e)||[],n={...r.find(e=>!e.xAxis)||{groupByDesc:null,groupByValues:[],colDesc:"",xAxis:!1},groupByValues:a.uniq(l.map(e=>r.find(e=>!e.xAxis)?.colDesc?String(e[r.find(e=>!e.xAxis)?.colDesc||""]):""))},u=t?{...t,groupByValues:a.uniq(l.map(e=>t.colDesc?String(e[t.colDesc]):""))}:t,p={title:{text:o},xAxis:{name:"",type:"category",axisLabel:{interval:0,formatter:e=>e.length>5?`${e.substring(0,5)}...`:e},data:i},yAxis:{type:"value"},legend:{data:[]},dataZoom:[{type:"inside",disabled:i.length<15}]};if(1===r.length)p.series=e.map(e=>({name:e,data:l.map(a=>a[e]),type:"bar",emphasis:{focus:"series"},label:{show:!0,position:"inside"}})),p.legend.data=e;else if(2===r.length){const a=e.map(e=>n.groupByValues?.map(a=>{const t={name:`${a||"/"}-${e}`,type:"bar",stack:e,emphasis:{focus:"series"},data:[],label:{show:!0,position:"inside"}};return t.data=(u?.groupByValues||[]).map(e=>{let r=null;return l.forEach(s=>{n.colDesc&&s[n.colDesc]===a&&u?.colDesc&&s[u.colDesc]===e&&t.stack&&(r=s[t.stack]??null)}),r||""}).filter(e=>""!==e),t})||[]).flat();p.series=a,delete p.legend}function d(e,a,t,r){Array.isArray(e)?e.forEach(e=>{e&&(e.type=a,"category"===a&&(e.data=t||[],e.name=r||""))}):e&&(e.type=a,"category"===a&&(e.data=t||[],e.name=r||""))}switch(s.subShowType){case"bar-simple":case"default":d(p.xAxis,"category",i,t?.colDesc||""),d(p.yAxis,"value");break;case"bar-y-category":d(p.xAxis,"value"),d(p.yAxis,"category",i,t?.colDesc||"")}return c(p,s.chartOptions)}),{myChart:n}=r.useCharts({chartDOM:o,chartOptions:i,chartData:e.computed(()=>s.chartData),lazyLoad:s.lazyLoad});return l({myChart:n}),(a,t)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataChartBar",ref:o,class:"data-chart-bar"},null,512))}});exports.default=s;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vue"),a=require("lodash-es"),t=require("../utils/injectionKeys.cjs"),r=require("../utils/useCharts.cjs"),s=e.defineComponent({name:"DataChartBar",__name:"bar",props:{chartData:{type:Object,required:!0},subShowType:{type:String,required:!0,default:"bar-simple"},chartOptions:{type:null,required:!0},lazyLoad:{type:Boolean,required:!1,default:!0}},setup(s,{expose:l}){const c=e.inject(t.InjectionChartMerge,e=>e,!0),o=e.ref(null),i=e.computed(()=>{const{colDesc:e,xGroupByDesc:t,groupByDesc:r,data:l=[],modelName:o}=s.chartData,i=Array.from(new Set(l.map(e=>e[t.colDesc||""]))).filter(e=>null!=e)||[],n={...r.find(e=>!e.xAxis)||{groupByDesc:null,groupByValues:[],colDesc:"",xAxis:!1},groupByValues:a.uniq(l.map(e=>r.find(e=>!e.xAxis)?.colDesc?String(e[r.find(e=>!e.xAxis)?.colDesc||""]):""))},u=t?{...t,groupByValues:a.uniq(l.map(e=>t.colDesc?String(e[t.colDesc]):""))}:t,p={title:{text:o},xAxis:{name:"",type:"category",axisLabel:{interval:0,formatter:e=>e.length>5?`${e.substring(0,5)}...`:e},data:i},yAxis:{type:"value"},legend:{data:[]},dataZoom:[{type:"inside",disabled:i.length<15}]};if(1===r.length)p.series=e.map(e=>({name:e,data:l.map(a=>a[e]),type:"bar",emphasis:{focus:"series"},label:{show:!0,position:"inside"}})),p.legend.data=e;else if(2===r.length){const a=e.map(e=>n.groupByValues?.map(a=>{const t={name:`${a||"/"}-${e}`,type:"bar",stack:e,emphasis:{focus:"series"},data:[],label:{show:!0,position:"inside"}};return t.data=(u?.groupByValues||[]).map(e=>{let r=null;return l.forEach(s=>{n.colDesc&&s[n.colDesc]===a&&u?.colDesc&&s[u.colDesc]===e&&t.stack&&(r=s[t.stack]??null)}),r||""}).filter(e=>""!==e),t})||[]).flat();p.series=a,delete p.legend}function d(e,a,t,r){Array.isArray(e)?e.forEach(e=>{e&&(e.type=a,"category"===a&&(e.data=t||[],e.name=r||""))}):e&&(e.type=a,"category"===a&&(e.data=t||[],e.name=r||""))}switch(s.subShowType){case"bar-simple":case"default":d(p.xAxis,"category",i,t?.colDesc||""),d(p.yAxis,"value");break;case"bar-y-category":d(p.xAxis,"value"),d(p.yAxis,"category",i,t?.colDesc||""),p.grid={top:80,...p.grid}}return c(p,s.chartOptions)}),{myChart:n}=r.useCharts({chartDOM:o,chartOptions:i,chartData:e.computed(()=>s.chartData),lazyLoad:s.lazyLoad});return l({myChart:n}),(a,t)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"dataChartBar",ref:o,class:"data-chart-bar"},null,512))}});exports.default=s;
|
|
2
2
|
//# sourceMappingURL=bar.vue2.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar.vue2.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/bar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { LegendComponentOption, XAXisComponentOption, YAXisComponentOption } from 'echarts'\nimport type {\n EChartsOption,\n IFormatPublicData,\n SeriesOption,\n} from '../utils/types'\nimport { uniq } from 'lodash-es'\nimport { computed, inject, ref } from 'vue'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\n// 定义组件名称\ndefineOptions({\n name: 'DataChartBar',\n})\n\n// 定义组件属性\nconst {\n chartOptions,\n chartData,\n subShowType = 'bar-simple',\n lazyLoad = true,\n} = defineProps<{\n chartData: IFormatPublicData\n subShowType: string\n chartOptions: EChartsOption\n lazyLoad?: boolean\n}>()\n\n// 注入合并函数,并明确类型\nconst merge = inject(InjectionChartMerge, (v: any) => v, true) as (config: EChartsOption, chartOptions: EChartsOption) => EChartsOption\nconst dataChartBar = ref<HTMLElement | null>(null)\n\n// 计算图表选项\nconst barChartOptions = computed<EChartsOption>(() => {\n const { colDesc, xGroupByDesc, groupByDesc, data = [], modelName } = chartData\n\n const axisData = Array.from(new Set(data.map(item => item[xGroupByDesc.colDesc || '']))).filter(item => item !== undefined && item !== null) || []\n\n // 创建新的对象而不是修改原对象\n const yGroupByDesc = {\n ...groupByDesc.find(item => !item.xAxis) || {\n groupByDesc: null,\n groupByValues: [],\n colDesc: '',\n xAxis: false,\n },\n groupByValues: uniq(data.map(item => groupByDesc.find(item => !item.xAxis)?.colDesc ? String(item[groupByDesc.find(item => !item.xAxis)?.colDesc || '']) : '')),\n }\n\n // 创建新的 xGroupByDesc 对象\n const newXGroupByDesc = xGroupByDesc\n ? {\n ...xGroupByDesc,\n groupByValues: uniq(data.map(item => xGroupByDesc.colDesc ? String(item[xGroupByDesc.colDesc]) : '')),\n }\n : xGroupByDesc\n\n const config: EChartsOption = {\n title: {\n text: modelName,\n },\n xAxis: {\n name: '',\n type: 'category',\n axisLabel: {\n interval: 0, // 强制显示所有标签\n formatter(value: string) {\n const screenshotLength = 5\n return value.length > screenshotLength ? `${value.substring(0, screenshotLength)}...` : value // 截取前5个字符并添加省略号\n },\n },\n data: axisData,\n },\n yAxis: {\n type: 'value',\n },\n legend: {\n data: [],\n },\n dataZoom: [{\n type: 'inside',\n disabled: axisData.length < 15,\n }],\n }\n\n // 堆叠图\n if (groupByDesc.length === 1) {\n config.series = colDesc.map((yItem) => {\n return {\n name: yItem,\n data: data.map(item => item[yItem]),\n type: 'bar',\n emphasis: {\n focus: 'series',\n },\n label: {\n show: true,\n position: 'inside',\n },\n }\n });\n (config.legend as LegendComponentOption).data = colDesc\n }\n else if (groupByDesc.length === 2) {\n const arr = colDesc.map((colDescItem) => {\n return yGroupByDesc.groupByValues?.map((yGroupByDescItem) => {\n const obj: SeriesOption = {\n name: `${yGroupByDescItem || '/'}-${colDescItem}`,\n type: 'bar',\n stack: colDescItem,\n emphasis: {\n focus: 'series',\n },\n data: [],\n label: {\n show: true,\n position: 'inside',\n },\n }\n obj.data = (newXGroupByDesc?.groupByValues || []).map((xGroupByDescItem) => {\n let targetVal: number | string | null = null\n data.forEach((item) => {\n if (yGroupByDesc.colDesc && item[yGroupByDesc.colDesc] === yGroupByDescItem && newXGroupByDesc?.colDesc && item[newXGroupByDesc.colDesc] === xGroupByDescItem) {\n if (obj.stack) {\n targetVal = item[obj.stack] ?? null\n }\n }\n })\n return targetVal || ''\n }).filter(v => v !== '')\n return obj\n }) || []\n }).flat()\n\n config.series = arr\n delete config.legend\n }\n\n // 1. 定义轴类型\n type CategoryAxisOption = XAXisComponentOption & {\n type: 'category'\n data: (string | number)[]\n }\n\n // 2. 创建配置轴的辅助函数\n function configureAxis(\n axis: XAXisComponentOption | XAXisComponentOption[] | YAXisComponentOption | YAXisComponentOption[] | undefined,\n type: 'category' | 'value',\n data?: (string | number)[],\n name?: string,\n ) {\n if (Array.isArray(axis)) {\n axis.forEach((item) => {\n if (item) {\n item.type = type\n if (type === 'category') {\n (item as CategoryAxisOption).data = data || []\n item.name = name || ''\n }\n }\n })\n }\n else if (axis) {\n axis.type = type\n if (type === 'category') {\n (axis as CategoryAxisOption).data = data || []\n axis.name = name || ''\n }\n }\n }\n\n // 3. 使用配置函数\n switch (subShowType) {\n case 'bar-simple':\n case 'default':\n configureAxis(config.xAxis, 'category', axisData, xGroupByDesc?.colDesc || '')\n configureAxis(config.yAxis, 'value')\n break\n\n case 'bar-y-category':\n configureAxis(config.xAxis, 'value')\n configureAxis(config.yAxis, 'category', axisData, xGroupByDesc?.colDesc || '')\n break\n }\n\n return merge(config, chartOptions)\n})\n\nconst { myChart } = useCharts({\n chartDOM: dataChartBar,\n chartOptions: barChartOptions,\n chartData: computed(() => chartData),\n lazyLoad,\n})\n\n// 暴露 myChart 方法供父组件访问\ndefineExpose({\n myChart,\n})\n</script>\n\n<template>\n <div\n ref=\"dataChartBar\"\n class=\"data-chart-bar\"\n />\n</template>\n\n<style scoped lang=\"scss\">\n.data-chart-bar {\n width: 100%;\n height: 100%;\n}\n</style>\n"],"names":["merge","inject","InjectionChartMerge","v","dataChartBar","ref","barChartOptions","computed","colDesc","xGroupByDesc","groupByDesc","data","modelName","__props","chartData","axisData","Array","from","Set","map","item","filter","yGroupByDesc","find","xAxis","groupByValues","uniq","String","newXGroupByDesc","config","title","text","name","type","axisLabel","interval","formatter","value","length","substring","yAxis","legend","dataZoom","disabled","series","yItem","emphasis","focus","label","show","position","arr","colDescItem","yGroupByDescItem","obj","stack","xGroupByDescItem","targetVal","forEach","flat","configureAxis","axis","isArray","subShowType","chartOptions","myChart","useCharts","chartDOM","lazyLoad","__expose","_createElementBlock","class"],"mappings":"icA+BA,MAAMA,EAAQC,EAAAA,OAAOC,EAAAA,oBAAsBC,GAAWA,GAAG,GACnDC,EAAeC,EAAAA,IAAwB,MAGvCC,EAAkBC,EAAAA,SAAwB,KAC9C,MAAMC,QAAEA,eAASC,EAAAC,YAAcA,EAAAC,KAAaA,EAAO,GAACC,UAAGA,GAAcC,EAAAC,UAE/DC,EAAWC,MAAMC,KAAK,IAAIC,IAAIP,EAAKQ,IAAIC,GAAQA,EAAKX,EAAaD,SAAW,OAAOa,OAAOD,GAAQA,UAAwC,GAG1IE,EAAe,IAChBZ,EAAYa,SAAcH,EAAKI,QAAU,CAC1Cd,YAAa,KACbe,cAAe,GACfjB,QAAS,GACTgB,OAAO,GAETC,cAAeC,EAAAA,KAAKf,EAAKQ,IAAIC,GAAQV,EAAYa,KAAKH,IAASA,EAAKI,QAAQhB,QAAUmB,OAAOP,EAAKV,EAAYa,KAAKH,IAASA,EAAKI,QAAQhB,SAAW,KAAO,MAIvJoB,EAAkBnB,EACpB,IACKA,EACHgB,cAAeC,EAAAA,KAAKf,EAAKQ,OAAYV,EAAaD,QAAUmB,OAAOP,EAAKX,EAAaD,U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B,MAAM8C,QAAQD,GAChBA,EAAKH,QAAStC,IACRA,IACFA,EAAKa,KAAOA,EACC,aAATA,IACDb,EAA4BT,KAAOA,GAAQ,GAC5CS,EAAKY,KAAOA,GAAQ,OAKnB6B,IACPA,EAAK5B,KAAOA,EACC,aAATA,IACD4B,EAA4BlD,KAAOA,GAAQ,GAC5CkD,EAAK7B,KAAOA,GAAQ,IAG1B,CAGA,OAAQnB,EAAAkD,aACN,IAAK,aACL,IAAK,UACHH,EAAc/B,EAAOL,MAAO,WAAYT,EAAUN,GAAcD,SAAW,IAC3EoD,EAAc/B,EAAOW,MAAO,SAC5B,MAEF,IAAK,iBACHoB,EAAc/B,EAAOL,MAAO,SAC5BoC,EAAc/B,EAAOW,MAAO,WAAYzB,EAAUN,GAAcD,SAAW,
|
|
1
|
+
{"version":3,"file":"bar.vue2.cjs","sources":["../../../../../../../packages/components/src/data-chart/src/components/bar.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { LegendComponentOption, XAXisComponentOption, YAXisComponentOption } from 'echarts'\nimport type {\n EChartsOption,\n IFormatPublicData,\n SeriesOption,\n} from '../utils/types'\nimport { uniq } from 'lodash-es'\nimport { computed, inject, ref } from 'vue'\nimport { InjectionChartMerge } from '../utils/injectionKeys'\nimport { useCharts } from '../utils/useCharts'\n\n// 定义组件名称\ndefineOptions({\n name: 'DataChartBar',\n})\n\n// 定义组件属性\nconst {\n chartOptions,\n chartData,\n subShowType = 'bar-simple',\n lazyLoad = true,\n} = defineProps<{\n chartData: IFormatPublicData\n subShowType: string\n chartOptions: EChartsOption\n lazyLoad?: boolean\n}>()\n\n// 注入合并函数,并明确类型\nconst merge = inject(InjectionChartMerge, (v: any) => v, true) as (config: EChartsOption, chartOptions: EChartsOption) => EChartsOption\nconst dataChartBar = ref<HTMLElement | null>(null)\n\n// 计算图表选项\nconst barChartOptions = computed<EChartsOption>(() => {\n const { colDesc, xGroupByDesc, groupByDesc, data = [], modelName } = chartData\n\n const axisData = Array.from(new Set(data.map(item => item[xGroupByDesc.colDesc || '']))).filter(item => item !== undefined && item !== null) || []\n\n // 创建新的对象而不是修改原对象\n const yGroupByDesc = {\n ...groupByDesc.find(item => !item.xAxis) || {\n groupByDesc: null,\n groupByValues: [],\n colDesc: '',\n xAxis: false,\n },\n groupByValues: uniq(data.map(item => groupByDesc.find(item => !item.xAxis)?.colDesc ? String(item[groupByDesc.find(item => !item.xAxis)?.colDesc || '']) : '')),\n }\n\n // 创建新的 xGroupByDesc 对象\n const newXGroupByDesc = xGroupByDesc\n ? {\n ...xGroupByDesc,\n groupByValues: uniq(data.map(item => xGroupByDesc.colDesc ? String(item[xGroupByDesc.colDesc]) : '')),\n }\n : xGroupByDesc\n\n const config: EChartsOption = {\n title: {\n text: modelName,\n },\n xAxis: {\n name: '',\n type: 'category',\n axisLabel: {\n interval: 0, // 强制显示所有标签\n formatter(value: string) {\n const screenshotLength = 5\n return value.length > screenshotLength ? `${value.substring(0, screenshotLength)}...` : value // 截取前5个字符并添加省略号\n },\n },\n data: axisData,\n },\n yAxis: {\n type: 'value',\n },\n legend: {\n data: [],\n },\n dataZoom: [{\n type: 'inside',\n disabled: axisData.length < 15,\n }],\n }\n\n // 堆叠图\n if (groupByDesc.length === 1) {\n config.series = colDesc.map((yItem) => {\n return {\n name: yItem,\n data: data.map(item => item[yItem]),\n type: 'bar',\n emphasis: {\n focus: 'series',\n },\n label: {\n show: true,\n position: 'inside',\n },\n }\n });\n (config.legend as LegendComponentOption).data = colDesc\n }\n else if (groupByDesc.length === 2) {\n const arr = colDesc.map((colDescItem) => {\n return yGroupByDesc.groupByValues?.map((yGroupByDescItem) => {\n const obj: SeriesOption = {\n name: `${yGroupByDescItem || '/'}-${colDescItem}`,\n type: 'bar',\n stack: colDescItem,\n emphasis: {\n focus: 'series',\n },\n data: [],\n label: {\n show: true,\n position: 'inside',\n },\n }\n obj.data = (newXGroupByDesc?.groupByValues || []).map((xGroupByDescItem) => {\n let targetVal: number | string | null = null\n data.forEach((item) => {\n if (yGroupByDesc.colDesc && item[yGroupByDesc.colDesc] === yGroupByDescItem && newXGroupByDesc?.colDesc && item[newXGroupByDesc.colDesc] === xGroupByDescItem) {\n if (obj.stack) {\n targetVal = item[obj.stack] ?? null\n }\n }\n })\n return targetVal || ''\n }).filter(v => v !== '')\n return obj\n }) || []\n }).flat()\n\n config.series = arr\n delete config.legend\n }\n\n // 1. 定义轴类型\n type CategoryAxisOption = XAXisComponentOption & {\n type: 'category'\n data: (string | number)[]\n }\n\n // 2. 创建配置轴的辅助函数\n function configureAxis(\n axis: XAXisComponentOption | XAXisComponentOption[] | YAXisComponentOption | YAXisComponentOption[] | undefined,\n type: 'category' | 'value',\n data?: (string | number)[],\n name?: string,\n ) {\n if (Array.isArray(axis)) {\n axis.forEach((item) => {\n if (item) {\n item.type = type\n if (type === 'category') {\n (item as CategoryAxisOption).data = data || []\n item.name = name || ''\n }\n }\n })\n }\n else if (axis) {\n axis.type = type\n if (type === 'category') {\n (axis as CategoryAxisOption).data = data || []\n axis.name = name || ''\n }\n }\n }\n\n // 3. 使用配置函数\n switch (subShowType) {\n case 'bar-simple':\n case 'default':\n configureAxis(config.xAxis, 'category', axisData, xGroupByDesc?.colDesc || '')\n configureAxis(config.yAxis, 'value')\n break\n\n case 'bar-y-category':\n configureAxis(config.xAxis, 'value')\n configureAxis(config.yAxis, 'category', axisData, xGroupByDesc?.colDesc || '')\n // 增加顶部距离,为图例和轴名称预留空间\n config.grid = {\n top: 80,\n ...config.grid,\n }\n break\n }\n\n return merge(config, chartOptions)\n})\n\nconst { myChart } = useCharts({\n chartDOM: dataChartBar,\n chartOptions: barChartOptions,\n chartData: computed(() => chartData),\n lazyLoad,\n})\n\n// 暴露 myChart 方法供父组件访问\ndefineExpose({\n myChart,\n})\n</script>\n\n<template>\n <div\n ref=\"dataChartBar\"\n class=\"data-chart-bar\"\n />\n</template>\n\n<style scoped lang=\"scss\">\n.data-chart-bar {\n width: 100%;\n height: 100%;\n}\n</style>\n"],"names":["merge","inject","InjectionChartMerge","v","dataChartBar","ref","barChartOptions","computed","colDesc","xGroupByDesc","groupByDesc","data","modelName","__props","chartData","axisData","Array","from","Set","map","item","filter","yGroupByDesc","find","xAxis","groupByValues","uniq","String","newXGroupByDesc","config","title","text","name","type","axisLabel","interval","formatter","value","length","substring","yAxis","legend","dataZoom","disabled","series","yItem","emphasis","focus","label","show","position","arr","colDescItem","yGroupByDescItem","obj","stack","xGroupByDescItem","targetVal","forEach","flat","configureAxis","axis","isArray","subShowType","grid","top","chartOptions","myChart","useCharts","chartDOM","lazyLoad","__expose","_createElementBlock","class"],"mappings":"icA+BA,MAAMA,EAAQC,EAAAA,OAAOC,EAAAA,oBAAsBC,GAAWA,GAAG,GACnDC,EAAeC,EAAAA,IAAwB,MAGvCC,EAAkBC,EAAAA,SAAwB,KAC9C,MAAMC,QAAEA,eAASC,EAAAC,YAAcA,EAAAC,KAAaA,EAAO,GAACC,UAAGA,GAAcC,EAAAC,UAE/DC,EAAWC,MAAMC,KAAK,IAAIC,IAAIP,EAAKQ,IAAIC,GAAQA,EAAKX,EAAaD,SAAW,OAAOa,OAAOD,GAAQA,UAAwC,GAG1IE,EAAe,IAChBZ,EAAYa,SAAcH,EAAKI,QAAU,CAC1Cd,YAAa,KACbe,cAAe,GACfjB,QAAS,GACTgB,OAAO,GAETC,cAAeC,EAAAA,KAAKf,EAAKQ,IAAIC,GAAQV,EAAYa,KAAKH,IAASA,EAAKI,QAAQhB,QAAUmB,OAAOP,EAAKV,EAAYa,KAAKH,IAASA,EAAKI,QAAQhB,SAAW,KAAO,MAIvJoB,EAAkBnB,EACpB,IACKA,EACHgB,cAAeC,EAAAA,KAAKf,EAAKQ,OAAYV,EAAaD,QAAUmB,OAAOP,EAAKX,EAAaD,UAAY,MAEnGC,EAEEoB,EAAwB,CAC5BC,MAAO,CACLC,KAAMnB,GAERY,MAAO,CACLQ,KAAM,GACNC,KAAM,WACNC,UAAW,CACTC,SAAU,EACVC,UAAUC,GAEDA,EAAMC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IACPA,EAAK5B,KAAOA,EACC,aAATA,IACD4B,EAA4BlD,KAAOA,GAAQ,GAC5CkD,EAAK7B,KAAOA,GAAQ,IAG1B,CAGA,OAAQnB,EAAAkD,aACN,IAAK,aACL,IAAK,UACHH,EAAc/B,EAAOL,MAAO,WAAYT,EAAUN,GAAcD,SAAW,IAC3EoD,EAAc/B,EAAOW,MAAO,SAC5B,MAEF,IAAK,iBACHoB,EAAc/B,EAAOL,MAAO,SAC5BoC,EAAc/B,EAAOW,MAAO,WAAYzB,EAAUN,GAAcD,SAAW,IAE3EqB,EAAOmC,KAAO,CACZC,IAAK,MACFpC,EAAOmC,MAKhB,OAAOhE,EAAM6B,EAAQhB,EAAAqD,iBAGjBC,QAAEA,GAAYC,YAAU,CAC5BC,SAAUjE,EACV8D,aAAc5D,EACdQ,UAAWP,EAAAA,SAAS,IAAMM,EAAAC,WAC1BwD,SAAOzD,EAAAyD,kBAITC,EAAa,CACXJ,kCAKAK,EAAAA,mBAGE,MAAA,SAFI,eAAJnE,IAAID,EACJqE,MAAM"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar.vue.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/data-chart/src/components/bar.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bar.vue.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/data-chart/src/components/bar.vue"],"names":[],"mappings":"AAgOA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,gBAAgB,CAAA;AAYvB,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;;;;AAiOF,wBAGG"}
|