index-Hs8vXepH.js 5.0 KB

12
  1. var e=Object.defineProperty,a=Object.defineProperties,t=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,i=(a,t,o)=>t in a?e(a,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[t]=o,n=(e,a)=>{for(var t in a||(a={}))l.call(a,t)&&i(e,t,a[t]);if(o)for(var t of o(a))r.call(a,t)&&i(e,t,a[t]);return e},s=(e,o)=>a(e,t(o));import{g as u,P as d}from"./index-DF0Gm8tW.js";/* empty css */import{g as c,L as y}from"./index-BIE_y9uC.js";import{u as h,b as m}from"./useChart-B4uBReHb.js";import{k as f,r as p,c as v,w as g,d as b,O as x,a7 as w,aJ as A,P as L,D as S,Q as j}from"./vendor-CgKklJ4r.js";import{_ as O}from"./_plugin-vue_export-helper-BCo6x5W8.js";const _=O(f(s(n({},{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:h().chartHeight},loading:{type:Boolean,default:!1},isEmpty:{type:Boolean,default:!1},colors:{default:()=>h().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:i,getAxisTickStyle:h,getSplitLineStyle:f,getTooltipStyle:O,getLegendStyle:_,getGridWithLegend:D}=m(),P=p(!1),B=p(),T=p([]),W=()=>{B.value&&(clearTimeout(B.value),B.value=void 0)},C=v((()=>{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=v((()=>Array.isArray(a.data)&&a.data.length>0&&"object"==typeof a.data[0]&&"name"in a.data[0])),k=v((()=>{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=>s(n({},e),{data:new Array(e.data.length).fill(0)})))}{const e=a.data;return new Array(e.length).fill(0)}},M=()=>(E.value,[...a.data]),G=(e,t)=>e||(void 0!==t?a.colors[t%a.colors.length]:u("--el-color-primary")),I=e=>{var t,o,l,r,i;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!=(i=e.lineWidth)?i:a.lineWidth)+1}}}},Q=(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?O():void 0,xAxis:{type:"category",boundaryGap:!1,data:a.xAxisData,axisTick:h(),axisLine:r(a.showAxisLine),axisLabel:i(a.showAxisLabel)},yAxis:{type:"value",min:0,max:k.value,axisLabel:i(a.showAxisLabel),axisLine:r(a.showAxisLine),splitLine:f(a.showSplitLine)}};if(a.showLegend&&E.value&&(t.legend=_(a.legendPosition)),E.value){const e=T.value;t.series=e.map(((e,t)=>{const o=G(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 y(0,0,0,1,[{offset:0,color:d(t,o.startOpacity||.2).rgba},{offset:1,color:d(t,o.endOpacity||.02).rgba}])}})(e,o);return I({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=G(a.colors[0]),l=(()=>{if(!a.showAreaColor)return;const e=G(a.colors[0]);return{color:new y(0,0,0,1,[{offset:0,color:d(e,.2).rgba},{offset:1,color:d(e,.02).rgba}])}})();t.series=[I({data:e,color:o,areaStyle:l})]}return t},R=e=>{l(e,C.value)},V=()=>{if(C.value)T.value=M(),R(Q(!1));else if(W(),P.value=!0,E.value){const e=a.data;T.value=z(),R(Q(!0)),e.forEach(((e,t)=>{setTimeout((()=>{const a=T.value;a[t]=n({},e),T.value=[...a],R(Q(!1))}),t*a.animationDelay+100)}));const t=(e.length-1)*a.animationDelay+1500;setTimeout((()=>{P.value=!1}),t)}else T.value=z(),R(Q(!0)),B.value=setTimeout((()=>{T.value=M(),R(Q(!1)),P.value=!1}),100)},H=()=>{V()},J=()=>{V()};return g([()=>a.data,()=>a.xAxisData,()=>a.colors],(()=>{P.value||H()}),{deep:!0}),g(o,(()=>{var e;const a=(null==(e=t.value)?void 0:e.__echart__)||c(t.value);if(a&&!C.value){const e=Q(!1);a.setOption(e)}})),b((()=>{H(),t.value&&t.value.addEventListener("chartVisible",J)})),x((()=>{W(),t.value&&t.value.removeEventListener("chartVisible",J)})),(e,o)=>{const l=A;return w((S(),L("div",{ref_key:"chartRef",ref:t,class:"art-line-chart",style:j({height:a.height})},null,4)),[[l,a.loading]])}}})),[["__scopeId","data-v-ec13d5ee"]]);export{_};