SalesOverview-Czj2E2AG.js 5.6 KB

12
  1. var e=Object.defineProperty,a=Object.defineProperties,t=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,s=(a,t,o)=>t in a?e(a,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[t]=o,i=(e,a)=>{for(var t in a||(a={}))l.call(a,t)&&s(e,t,a[t]);if(o)for(var t of o(a))r.call(a,t)&&s(e,t,a[t]);return e},n=(e,o)=>a(e,t(o));import{g as d,h as u}from"./index-CT1qRCFx.js";/* empty css */import{u as c,b as h,L as f,g as v}from"./useChart-lXWY8jG7.js";import{j as y,r as p,c as m,w as g,d as b,P as x,a6 as w,ae as A,Q as L,G as S,R as _,ab as j,v as O}from"./vendor-D0p0RnNT.js";import{_ as D}from"./_plugin-vue_export-helper-BCo6x5W8.js";const B=D(y(n(i({},{name:"ArtLineChart"}),{__name:"index",props:{data:{default:()=>[0,0,0,0,0,0,0]},xAxisData:{default:()=>[]},lineWidth:{default:2.5},showAreaColor:{type:Boolean,default:!1},smooth:{type:Boolean,default:!0},symbol:{default:"none"},symbolSize:{default:6},animationDelay:{default:200},height:{default:c().chartHeight},loading:{type:Boolean,default:!1},isEmpty:{type:Boolean,default:!1},colors:{default:()=>c().colors},showAxisLabel:{type:Boolean,default:!0},showAxisLine:{type:Boolean,default:!0},showSplitLine:{type:Boolean,default:!0},showTooltip:{type:Boolean,default:!0},showLegend:{type:Boolean,default:!1},legendPosition:{default:"bottom"}},setup(e){const a=e,{chartRef:t,isDark:o,initChart:l,getAxisLineStyle:r,getAxisLabelStyle:s,getAxisTickStyle:c,getSplitLineStyle:y,getTooltipStyle:j,getLegendStyle:O,getGridWithLegend:D}=h(),B=p(!1),P=p(),T=p([]),C=()=>{P.value&&(clearTimeout(P.value),P.value=void 0)},W=m((()=>{if(a.isEmpty)return!0;if(Array.isArray(a.data)&&"number"==typeof a.data[0]){const e=a.data;return!e.length||e.every((e=>0===e))}if(Array.isArray(a.data)&&"object"==typeof a.data[0]){const e=a.data;return!e.length||e.every((e=>{var a;return!(null==(a=e.data)?void 0:a.length)||e.data.every((e=>0===e))}))}return!0})),E=m((()=>Array.isArray(a.data)&&a.data.length>0&&"object"==typeof a.data[0]&&"name"in a.data[0])),k=m((()=>{if(E.value){return a.data.reduce(((e,a)=>{var t;if(null==(t=a.data)?void 0:t.length){const t=Math.max(...a.data);return Math.max(e,t)}return e}),0)}{const e=a.data;return(null==e?void 0:e.length)?Math.max(...e):0}})),z=()=>{if(E.value){return a.data.map((e=>n(i({},e),{data:new Array(e.data.length).fill(0)})))}{const e=a.data;return new Array(e.length).fill(0)}},G=()=>(E.value,[...a.data]),I=(e,t)=>e||(void 0!==t?a.colors[t%a.colors.length]:d("--el-color-primary")),M=e=>{var t,o,l,r,s;return{name:e.name,data:e.data,type:"line",color:e.color,smooth:null!=(t=e.smooth)?t:a.smooth,symbol:null!=(o=e.symbol)?o:a.symbol,symbolSize:null!=(l=e.symbolSize)?l:a.symbolSize,lineStyle:{width:null!=(r=e.lineWidth)?r:a.lineWidth,color:e.color},areaStyle:e.areaStyle,emphasis:{focus:"series",lineStyle:{width:(null!=(s=e.lineWidth)?s:a.lineWidth)+1}}}},R=(e=!1)=>{const t={animation:!0,animationDuration:e?0:1300,animationDurationUpdate:e?0:1300,grid:D(a.showLegend&&E.value,a.legendPosition,{top:15,right:15,left:0}),tooltip:a.showTooltip?j():void 0,xAxis:{type:"category",boundaryGap:!1,data:a.xAxisData,axisTick:c(),axisLine:r(a.showAxisLine),axisLabel:s(a.showAxisLabel)},yAxis:{type:"value",min:0,max:k.value,axisLabel:s(a.showAxisLabel),axisLine:r(a.showAxisLine),splitLine:y(a.showSplitLine)}};if(a.showLegend&&E.value&&(t.legend=O(a.legendPosition)),E.value){const e=T.value;t.series=e.map(((e,t)=>{const o=I(a.colors[t],t),l=((e,t)=>{if(!e.areaStyle&&!e.showAreaColor&&!a.showAreaColor)return;const o=e.areaStyle||{};return o.custom?o.custom:{color:new f(0,0,0,1,[{offset:0,color:u(t,o.startOpacity||.2).rgba},{offset:1,color:u(t,o.endOpacity||.02).rgba}])}})(e,o);return M({name:e.name,data:e.data,color:o,smooth:e.smooth,symbol:e.symbol,lineWidth:e.lineWidth,areaStyle:l})}))}else{const e=T.value,o=I(a.colors[0]),l=(()=>{if(!a.showAreaColor)return;const e=I(a.colors[0]);return{color:new f(0,0,0,1,[{offset:0,color:u(e,.2).rgba},{offset:1,color:u(e,.02).rgba}])}})();t.series=[M({data:e,color:o,areaStyle:l})]}return t},V=e=>{l(e,W.value)},H=()=>{if(W.value)T.value=G(),V(R(!1));else if(C(),B.value=!0,E.value){const e=a.data;T.value=z(),V(R(!0)),e.forEach(((e,t)=>{setTimeout((()=>{const a=T.value;a[t]=i({},e),T.value=[...a],V(R(!1))}),t*a.animationDelay+100)}));const t=(e.length-1)*a.animationDelay+1500;setTimeout((()=>{B.value=!1}),t)}else T.value=z(),V(R(!0)),P.value=setTimeout((()=>{T.value=G(),V(R(!1)),B.value=!1}),100)},J=()=>{H()},K=()=>{H()};return g([()=>a.data,()=>a.xAxisData,()=>a.colors],(()=>{B.value||J()}),{deep:!0}),g(o,(()=>{var e;const a=(null==(e=t.value)?void 0:e.__echart__)||v(t.value);if(a&&!W.value){const e=R(!1);a.setOption(e)}})),b((()=>{J(),t.value&&t.value.addEventListener("chartVisible",K)})),x((()=>{C(),t.value&&t.value.removeEventListener("chartVisible",K)})),(e,o)=>{const l=A;return w((S(),L("div",{ref_key:"chartRef",ref:t,class:"art-line-chart",style:_({height:a.height})},null,4)),[[l,a.loading]])}}})),[["__scopeId","data-v-ec13d5ee"]]),P={class:"card art-custom-card"},T=D(y({__name:"SalesOverview",setup(e){const a=[50,25,40,20,70,35,65,30,35,20,40,44],t=["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"];return(e,o)=>{const l=B;return S(),L("div",P,[o[0]||(o[0]=j('<div class="card-header" data-v-ff2928a7><div class="title" data-v-ff2928a7><h4 class="box-title" data-v-ff2928a7>访问量</h4><p class="subtitle" data-v-ff2928a7>今年增长<span class="text-success" data-v-ff2928a7>+15%</span></p></div></div>',1)),O(l,{class:"chart",height:"calc(100% - 40px)",data:a,xAxisData:t,showAreaColor:!0,showAxisLine:!1})])}}}),[["__scopeId","data-v-ff2928a7"]]);export{T as default};