import{_ as B,bL as i,r as g,aA as D,o as y,c as v,v as h,F as z,A as W,O as $,n as _,x as M,S as O}from"./index.8d733f79.js";import{N as H}from"./no-data-to-display.104be120.js";import{A as I}from"./annotations.d7724f2a.js";import{E as R}from"./exporting.83037eec.js";const K={class:"chart-box"},N={class:"chart-legend"},P=["onClick"],T={class:"legend-name"},U={__name:"dashboard-barChart",props:{legendClick:{type:Boolean,default:!0}},emits:["barClick","legendClick"],setup(E,{expose:S,emit:b}){const w=E;H(i),i.setOptions({lang:{noData:"\u6682\u65E0\u6570\u636E",loading:"\u52A0\u8F7D\u4E2D..."},loading:{style:{color:"#A9C1E0",fontSize:"14px",backgroundColor:"transparent",opacity:1}},noData:{style:{color:"#A9C1E0",fontSize:"14px"}}}),I(i),R(i);let l=null;const k=g(null);let u;const f=g([]),n=g([]),m=(a,r)=>{l&&l.destroy();const t=new Map,o=[];a.forEach(e=>{t.set(e.value,e.label),o.push(e.value)}),u=t,f.value=r.map(e=>({name:e.name,key:e.key,color:e.color})),n.value=f.value.map(e=>e.key),l=i.chart(k.value,{credits:{enabled:!1},legend:{enabled:!1},chart:{type:"column",backgroundColor:"transparent",borderWidth:0,margin:[14,25,50,56]},exporting:{enabled:!1},title:void 0,xAxis:{type:"category",categories:o,gridLineDashStyle:"ShortDash",gridLineColor:"#0A538C",lineColor:"#10466F",gridLineWidth:1,tickLength:4,labels:{allowOverlap:!0,distance:4,style:{color:"rgb(242, 246, 250, 0.8)",fontSize:"11px",whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden",width:56},formatter(){return u.get(this.value)}},crosshair:{color:"#93B3E0",dashStyle:"dash",width:1}},yAxis:{title:{text:null},lineColor:"#fff",gridLineDashStyle:"ShortDash",gridLineColor:"#10466F",gridLineWidth:1,labels:{x:-8,style:{color:"#F2F6FA",fontSize:"11px"}}},tooltip:{shared:!0,useHTML:!0,backgroundColor:"rgba(0, 39, 69, 0.8)",borderColor:"#3B72B3",borderWidth:1,borderRadius:4,headerFormat:'<div style="font-size: 12px;color:#E4F1FF">\u603B\u6570\uFF1A{point.total}</div>',style:{color:"#93B3E0",fontSize:"12px"},pointFormatter(){const e=`<div style="display:inline-block;width:8px;height:8px;border-radius:50%;background-color:${this.series.color};"></div>`,c=`<div style="margin-left:4px;margin-right:16px">${this.series.name}</div><div>${this.y}</div>`;return`<div style="display:flex;align-items:center">${e}${c}</div>`}},plotOptions:{column:{stacking:"normal",borderWidth:0,borderRadius:0,allowPointSelect:!0,states:{select:{color:null,borderColor:"#ff3333",borderWidth:3}},point:{events:{click(e){e.preventDefault();const c=this.series.chart,L=this.x;let x=!1;const p=[],C=[];c.series.forEach(s=>{s.points.forEach(d=>{C.push(d),d.x===L&&(p.push(d),d.selected&&(x=!0))})}),x?p.forEach(s=>s.select(!1,!0)):(C.forEach(s=>s.select(!1,!0)),p.forEach(s=>s.select(!0,!0))),c.redraw(),b("barClick",e,this)}}},events:{legendItemClick(e){return e.preventDefault(),e.target.select(!1),!1},legendItemHover(){}}}},series:r})},A=(a,r)=>{if(!l)m(a,r);else{if(a){const t=[],o=new Map;a.forEach(e=>{o.set(e.value,e.label),t.push(e.value)}),u=o,l.xAxis[0].update({categories:t},!0)}r&&l.series.forEach((t,o)=>{t.update({data:r[o].data},!1)}),l.redraw()}},F=a=>{if(!w.legendClick)return;const r=[...n.value];r.includes(a.key)?r.length>1?n.value=r.filter(t=>t!==a.key):O.warning("\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u56FE\u4F8B"):n.value=[...r,a.key],b("legendClick",a,n.value)};return D(()=>{l&&l.destroy()}),S({loadChart:m,updateChart:A}),(a,r)=>(y(),v("div",K,[h("div",{class:"chart",id:"chart",ref_key:"chartRef",ref:k},null,512),h("div",N,[(y(!0),v(z,null,W(_(f),t=>(y(),v("div",{key:t.key,class:"legend-item",onClick:o=>F(t)},[h("div",{class:"legend-symbol",style:$({backgroundColor:_(n).includes(t.key)?t.color:"#A8A8A8"})},null,4),h("div",T,M(t.name),1)],8,P))),128))])]))}},G=B(U,[["__scopeId","data-v-5ef46e78"]]);export{G as default};
