var W=Object.defineProperty,H=Object.defineProperties;var Z=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var $=(o,i,n)=>i in o?W(o,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[i]=n,g=(o,i)=>{for(var n in i||(i={}))j.call(i,n)&&$(o,n,i[n]);if(A)for(var n of A(i))F.call(i,n)&&$(o,n,i[n]);return o},y=(o,i)=>H(o,Z(i));import{e as m,j as V,k as E,L as S,o as p,c as b,a as x,t as h,g as v,b as q,u as G,n as M}from"./index-1783349984056.js";import{aS as I}from"./chartTheme-259740ff-1783349984056.js";const U={class:"smart-chart-header"},J={key:0},K={key:0},Q={key:0,class:"smart-chart-source"},N="口径",te={__name:"SmartChartRenderer",props:{chart:{type:Object,required:!0}},emits:["ready"],setup(o,{emit:i}){const n=i,a=o,c=["#30dcff","#27f0c0","#ffd76c","#7aa7ff","#ff8f6b","#a6f06d"],T=m(()=>{const e=(a.chart.rows||[]).filter(t=>Number.isFinite(Number(t.value)));return a.chart.type==="pie"?O(e):a.chart.type==="line"?P(e):C(e)}),w=m(()=>{const e=a.chart.rows||[];return a.chart.type==="bar"&&_(e)}),z=m(()=>{const e=R(a.chart.subtitle);if(e)return e;const t=a.chart.source||{},r=f(t.period||t.dataPeriod||a.chart.period),s=a.chart.unit?`单位：${a.chart.unit}`:"";return[r,s].filter(Boolean).join(" · ")}),L=m(()=>{const e=a.chart.source||{},t=D(e),r=f(e.period||e.dataPeriod||a.chart.period),s=f(e.generatedAt||e.updateTime||e.updatedAt,!0),l=[t,r,s?`更新 ${s}`:""].filter(Boolean);return l.length?`数据来源：${l.join(" · ")}`:"数据来源：业务统计库"});V(()=>{E(()=>{window.requestAnimationFrame(()=>n("ready"))})});function C(e){return _(e)?B(e):{animationDuration:700,grid:{left:52,right:26,top:28,bottom:54},tooltip:u(),xAxis:{type:"category",data:e.map(t=>t.name),axisTick:{show:!1},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.28)"}},axisLabel:{color:"rgba(223, 250, 255, 0.76)",fontSize:11,interval:0,rotate:e.length>6?28:0}},yAxis:{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:"rgba(48, 220, 255, 0.1)",type:"dashed"}},axisLabel:{color:"rgba(223, 250, 255, 0.58)",fontSize:11}},series:[{name:a.chart.title,type:"bar",barWidth:e.length>7?16:22,data:e.map((t,r)=>({value:t.value,name:t.name,itemStyle:{borderRadius:[8,8,0,0],color:new S(0,0,0,1,[{offset:0,color:c[r%c.length]},{offset:1,color:"rgba(48, 220, 255, 0.08)"}])}})),label:{show:!0,position:"top",color:"#ffffff",fontSize:11,formatter:({value:t})=>d(t)}}]}}function B(e){return{animationDuration:700,grid:{left:78,right:72,top:22,bottom:20},tooltip:y(g({},u()),{trigger:"axis",axisPointer:{type:"shadow"}}),xAxis:{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:"rgba(48, 220, 255, 0.1)",type:"dashed"}},axisLabel:{color:"rgba(223, 250, 255, 0.58)",fontSize:11}},yAxis:{type:"category",inverse:!0,data:e.map(t=>t.name),axisTick:{show:!1},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.22)"}},axisLabel:{color:"rgba(223, 250, 255, 0.82)",fontSize:12}},series:[{name:a.chart.title,type:"bar",barWidth:13,data:e.map((t,r)=>({value:t.value,name:t.name,itemStyle:{borderRadius:[0,8,8,0],color:new S(0,0,1,0,[{offset:0,color:"rgba(48, 220, 255, 0.16)"},{offset:1,color:c[r%c.length]}])}})),label:{show:!0,position:"right",color:"#ffffff",fontSize:11,formatter:({value:t})=>d(t)}}]}}function O(e){return{animationDuration:700,tooltip:u(),legend:{orient:"vertical",right:10,top:"middle",itemWidth:10,itemHeight:10,textStyle:{color:"rgba(223, 250, 255, 0.78)",fontSize:11}},series:[{name:a.chart.title,type:"pie",radius:["48%","68%"],center:["35%","52%"],avoidLabelOverlap:!0,label:{color:"#fff",fontSize:11,formatter:`{b}
{d}%`},labelLine:{lineStyle:{color:"rgba(223, 250, 255, 0.42)"}},itemStyle:{borderColor:"rgba(3, 18, 31, 0.92)",borderWidth:3},data:e.map((t,r)=>({name:t.name,value:t.value,itemStyle:{color:c[r%c.length]}}))}]}}function P(e){return{animationDuration:760,grid:{left:52,right:28,top:30,bottom:48},tooltip:y(g({},u()),{trigger:"axis",axisPointer:{type:"line",lineStyle:{color:"rgba(255, 215, 108, 0.52)"}}}),xAxis:{type:"category",boundaryGap:!1,data:e.map(t=>t.name),axisTick:{show:!1},axisLine:{lineStyle:{color:"rgba(48, 220, 255, 0.28)"}},axisLabel:{color:"rgba(223, 250, 255, 0.76)",fontSize:11,interval:0}},yAxis:{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{color:"rgba(48, 220, 255, 0.1)",type:"dashed"}},axisLabel:{color:"rgba(223, 250, 255, 0.58)",fontSize:11}},series:[{name:a.chart.title,type:"line",smooth:!0,symbol:"circle",symbolSize:8,lineStyle:{width:3,color:"#30dcff"},itemStyle:{color:"#ffd76c",borderColor:"#041522",borderWidth:2},areaStyle:{color:new S(0,0,0,1,[{offset:0,color:"rgba(48, 220, 255, 0.24)"},{offset:1,color:"rgba(48, 220, 255, 0.02)"}])},label:{show:!0,position:"top",color:"#ffffff",fontSize:11,formatter:({value:t})=>d(t)},data:e.map(t=>({value:t.value,name:t.name}))}]}}function u(){return{trigger:"item",backgroundColor:"rgba(2, 13, 22, 0.94)",borderColor:"rgba(48, 220, 255, 0.34)",borderWidth:1,textStyle:{color:"#fff",fontSize:12},formatter:e=>{const t=(a.chart.rows||[]).find(l=>l.name===e.name),r=(t==null?void 0:t.unit)||a.chart.unit||"",s=t!=null&&t.extra?`<br/><span style="color:rgba(223,250,255,.62)">${t.extra}</span>`:"";return`${e.marker}${e.name}: ${d(e.value)}${r}${s}`}}}function _(e=[]){return e.length>6||e.some(t=>String(t.name||"").length>4)}function D(e={}){const t=f(e.sourceName||e.name||e.label);if(t)return t;const r=String(e.mode||"").trim();return/openapi|api|stat/i.test(r)?"业务统计库":/local|mock|fallback/i.test(r)?"本地统计":"业务统计库"}function f(e,t=!1){const r=String(e||"").trim();return r?t&&/^\d{4}-\d{2}-\d{2}/.test(r)?r.slice(0,10):k(r)?"":r:""}function R(e){const t=String(e||"").trim();if(!t)return"";const r=new RegExp(N,"g"),s=new RegExp(`统计${N}`,"g"),l=t.replace(s,"统计数据").replace(r,"数据").replace(/来源[：:]\s*openApi\s*统计库\s*[a-zA-Z0-9_./:-]*[，,、]?\s*/gi,"").replace(/openApi\s*统计库\s*/gi,"").replace(/\b[a-zA-Z][a-zA-Z0-9]*(?:_[a-zA-Z0-9]+){2,}\b/g,"").replace(/[，,、]\s*[，,、]+/g,"，").replace(/^[\s，,、:：]+|[\s，,、]+$/g,"");return!l||/^来源[：:]?$/.test(l)||k(l)?"":l}function k(e){return/^[a-zA-Z0-9_./:-]+$/.test(e)&&(e.includes("_")||e.length>24)}function d(e){const t=Number(e);return Number.isFinite(t)?Number.isInteger(t)?t.toLocaleString("zh-CN"):t.toLocaleString("zh-CN",{maximumFractionDigits:2}):"--"}return(e,t)=>(p(),b("div",{class:M(["smart-chart-card",{"is-horizontal":w.value}])},[x("div",U,[x("div",null,[x("strong",null,h(o.chart.title),1),z.value?(p(),b("span",J,h(z.value),1)):v("",!0)]),o.chart.unit?(p(),b("em",K,h(o.chart.unit),1)):v("",!0)]),q(G(I),{class:"smart-chart",option:T.value,autoresize:""},null,8,["option"]),L.value?(p(),b("div",Q,h(L.value),1)):v("",!0)],2))}};export{te as default};
