amis-reports
Version:
爱速搭报表,基于 ECharts 实现的图表功能组件,旨在为用户提供简单和快捷的可视化报表能力,帮助用户在爱速搭平台上快速设计常见的数据报表页和大屏报表效果页。
1 lines • 144 kB
JavaScript
import{S as t,h as e,A as s,i as a,j as i,k as r,l as o,m as h,n,_ as p,o as c,p as d,q as l,r as m,s as f,t as u,v as g,G as y,w as C,x as b,y as D,z as x,B as v,C as T,D as P,E as U,M as L,F as S,H as w,I as F,J as A,K as M,L as B,N as W,Y as N,O as k,P as R,Q as E,R as z,T as I,U as j,V as O,W as V,X as G,Z as H,$,a0 as Z,a1 as _,a2 as Y,a3 as q,a4 as J,a5 as K,a6 as Q,a7 as X,a8 as tt,a9 as et,aa as st,ab as at,ac as it,ad as rt,ae as ot,af as ht,ag as nt,ah as pt}from"./en-US-1cc0b4d9.js";import{toast as ct,Renderer as dt}from"amis";import{ScopedContext as lt,isExpression as mt,FormulaExec as ft,buildStyle as ut,ServiceStore as gt,setThemeClassName as yt,CustomStyle as Ct}from"amis-core";import bt from"lodash/pick";import Dt from"lodash/debounce";import xt from"lodash/isPlainObject";import vt from"lodash/find";import Tt from"lodash/isArray";import Pt from"react";import Ut from"lodash/isObject";import Lt from"lodash/isEqual";import St from"lodash/isString";import wt from"lodash/uniqBy";import Ft from"lodash/floor";import{Chart as At}from"amis/lib/renderers/Chart";class Mt extends At{static contextType=lt;config;curChartData=null;chartStylePadding="";onChartMount;chartCanvasDebounce;chartUpdateDebounce;preProps;preChartProps;reportTimer;isLoading=!1;constructor(e,s){super(e);s.registerComponent(this),this.updateChartCanvasPadding=this.updateChartCanvasPadding.bind(this),this.onChartMount=()=>{this.config=this.getChartConfig(this.curChartData),this.renderChart(this.config),this.isLoading&&setTimeout((()=>{this.echarts?.showLoading()}),100),setTimeout((()=>{this.updateChartCanvasPadding(),this.isLoading||this.echarts?.hideLoading()}),500)},this.chartCanvasDebounce=Dt(((e,s)=>{const a=this.preChartProps||s||{};for(const s of t)if((a.style||{})[s]!==(e.style||{})[s]){this.preChartProps=e,this.updateChartCanvasPadding();break}}),400,{leading:!0,trailing:!1}),this.setReportTimer=this.setReportTimer.bind(this),this.reload=this.reload.bind(this)}async componentDidMount(){this.setReportTimer()}componentDidUpdate(t){this.chartCanvasDebounce(this.props,this.preChartProps),this.props.reportInterval!==t.reportInterval&&this.setReportTimer()}showLoading(){this.isLoading=!0,this.echarts?.showLoading()}hideLoading(){this.isLoading=!1,this.echarts?.hideLoading()}componentWillUnmount(){super.componentWillUnmount();this.context.unRegisterComponent(this),this.chartCanvasDebounce?.cancel(),this.echarts&&(this.echarts.off("rendered"),this.echarts.off("finished")),clearInterval(this.reportTimer)}reloadEcharts(t){this.echarts?.setOption(t,{replaceMerge:["xAxis","yAxis","series"]})}sortRoprtDataByMeasures(t,e){let s=t;return Tt(t)&&e&&e.length&&e.map((e=>{const a=e.orderBy,i=e.as;t[0][i]&&a&&("asc"===a?s=t.sort(((t,e)=>t[i]-e[i])):"desc"===a&&(s=t.sort(((t,e)=>e[i]-t[i]))))})),s}sortRoprtDataByDate(t,e){let s=t;return Tt(t)&&e&&e.length&&e.map((e=>{const a=e.orderBy,i=e.as;"date"===e.type&&t[0][i]&&a&&("asc"===a?s=t.sort(((t,e)=>Date.parse(t[i])-Date.parse(e[i]))):"desc"===a&&(s=t.sort(((t,e)=>Date.parse(e[i])-Date.parse(t[i])))))})),s}reload(){const t=this.preProps||this.props;e(t).then((e=>{e&&e.data&&(this.curChartData=e.data,this.updateChartData(e.data,!0,t))}))}setReportTimer(){let t=this.props.reportInterval;t&&St(t)&&(t=Number.parseInt(t)),this.reportTimer&&clearInterval(this.reportTimer),t?this.mounted&&(this.reportTimer=setInterval(this.reload,Math.max(t,1e3))):this.reportTimer&&clearInterval(this.reportTimer)}setSchema(t){if(!t)return;let e=t;if(Tt(t))e=s(t);else if(!Ut(t))return;const r=a(e,this.props.data),o=i(this.preProps,r);"chart-map"!==o.type&&"chart-scatter-map"!==o.type||!r?.mapName||r.mapName===this.preProps.mapName?setTimeout((()=>{this.chartUpdateDebounce(o)}),300):this.loadReportMapData(o,(()=>{this.chartUpdateDebounce(o)}))}setData(t,e){const{store:s}=this.props;if(s.updateData(t,void 0,e),Ut(t)){const e={...this.preProps.data,...t},s=r(this.props,e),a={...this.preProps,...s,data:e};"chart-map"===this.preProps.type&&s?.mapName&&s.mapName!==this.preProps.mapName?this.loadReportMapData(a,(()=>{this.chartUpdateDebounce(a,this.preProps)})):this.chartUpdateDebounce(a,this.preProps)}}doAction(t,e,s,a){const i=t?.actionType;"setSchema"===i?this.setSchema(a?.chartSchema||a?.value):"gradientStatus"===i&&this.setSchema({gradientStatus:a?.gradientStatus})}getMapURL(t,e,s){let a=s||"";if(t){const s=e||{};if(t){mt(t)&&(t=ft.formula(t,s)),t=o(t)||t,a=a&&a.startsWith("/api/geojson/beijing/")?`/api/geojson/beijing/${t}`:`/api/geojson/city/${t}`;const e=h(t);"china"===t||"world"===t?a=`/api/geojson/${t}`:e&&(a=`/api/geojson/province/${t}`)}}return{mapName:t,mapURL:a}}fetchChartMapData(t,e){const{mapName:s,mapURL:a,env:i,data:r}=t;a&&window.echarts&&i.fetcher(a,r).then((t=>{t.ok||ct.warning(`获取不到当前地图(${s})的数据。`),window.echarts.registerMap(s,t.data),e&&e()}))}loadReportMapData(t,e){if(t&&window.echarts){const{data:s,env:a}=t,{mapName:i,mapURL:r}=this.getMapURL(t.mapName,s,t.mapURL);r!==t.mapURL&&this.fetchChartMapData({mapName:i,mapURL:r,env:a,data:s},e)}}refreshConfigByMapName(t,e){const s=t||{};return s.series&&Tt(s.series)&&s.series.forEach((t=>{t.mapType=e})),s}getChartConfig(t){return t||{}}updateChartData(t,e,s){return t||{}}updateChartCanvasPadding(t){if(this.ref&&this.mounted){const e=this.ref.getElementsByTagName("canvas");if(e&&e[0]){const{style:s,data:a}=this.props,i=t||s,r=e[0];let o="",h={};i?(h=ut(i,a),r.style||(r.style={}),o=h.padding?h.padding:h.paddingTop===h.paddingRight&&h.paddingBottom===h.paddingRight&&h.paddingLeft===h.paddingBottom?h.paddingTop||"":`${h.paddingTop||0} ${h.paddingRight||0} ${h.paddingBottom||0} ${h.paddingLeft||0}`):o="",this.chartStylePadding!==o&&(this.chartStylePadding=o,r.style.padding=o,this.reloadEcharts(this.config))}}}}function Bt(t,e,s,a){const i=t||[],r=s||[],o=[],h=(a||[])[0],p=[],c={};for(let t=0;t<i.length;t++){const s=i[t],a=s[e];p.indexOf(a)<0&&(p.push(a),c[a]={});const d=r.map((t=>n(s[t.as])||"")).filter((t=>""!==t)).join("-");o.indexOf(d)<0&&o.push(d),c[a][d]={...s,value:s[h.as]}}return{categories:o,groupFieldValues:p,groupFieldData:c}}let Wt=class extends Mt{config;chartUpdateDebounce;constructor(t,e){super(t,e),this.config=this.getChartConfig(),this.chartUpdateDebounce=Dt((async(t,e)=>{const s=this.preProps||e||{};this.showLoading();const a=await c(t,s);this.hideLoading(),a&&a.data&&(this.curChartData=a.data,this.updateChartData(a.data,!0,t));const i=d(t,s);i&&this.updateChartConfig(this.curChartData,i,t),this.preProps=t}),300)}async componentDidMount(){super.componentDidMount();const t=a(this.props,this.props.data);this.preProps=t,this.showLoading();const{data:s}=await e(t);this.hideLoading(),s?(this.curChartData=s,this.updateChartData(s,t)):this.renderChart(this.config);const{dispatchEvent:i}=this.props;await i("init",s,this),this.echarts&&this.echarts.on("finished",(()=>{this.updateChartCanvasPadding(this.props.style),this.hideLoading()}))}componentDidUpdate(t){super.componentDidUpdate(t);const e=this.props.formStore?.data||this.props.data;if(this.preProps&&this.props.data!==t.data){const t=r(this.props,e);this.chartUpdateDebounce({...this.preProps,...t,data:e},this.preProps)}else{const t=a(this.props,e);this.chartUpdateDebounce(t,this.preProps)}}componentWillUnmount(){super.componentWillUnmount(),this.chartUpdateDebounce?.cancel()}doAction(t,e,s,a){const i=t?.actionType;if("chartTypeChange"===i){const t=a?.chartType;this.setSchema({columnChartType:t,xyFlip:"horizontal"===t})}else"xyFlip"===i?this.setSchema({xyFlip:a?.xyFlip}):super.doAction(t,e,s,a)}getChartConfig(t,e){let s=e;e||(s=a(this.props,this.props.data));const i=l(s,this.ref),{measures:r,dimensions:o,xyFlip:h,colorBy:p,columnChartType:c,columnBarWidth:d,columnBarMaxWidth:M,columnBarMinWidth:B,columnBarGap:W,columnBarMinHeight:N,groupField:k}=i;let R=t;const E=o||[],z=r||[],I={tooltip:m(i,void 0,this.ref),color:f(i),title:u(i,this.ref),grid:g(bt(i,y)),series:[],...C(bt(i,b))},j=D(i,void 0,this.ref),O=x(i,void 0,this.ref);if(h?(I.xAxis=O,I.yAxis=j):(I.yAxis=O,I.xAxis=j),R&&xt(R)&&(R=[R]),!R?.length)return I;if(R=this.sortRoprtDataByDate(R,E),R=this.sortRoprtDataByMeasures(R,z),z&&1===z.length&&k){const t=z[0],{categories:e,groupFieldValues:s,groupFieldData:a}=Bt(R,k,E,z);for(let r=0;r<s.length;r++){const o=s[r],n=a[o],l=[],m={data:[],type:"bar",name:o||v(t)};for(let t=0;t<e.length;t++){const s=e[t];let a=n[s]?.value||"";"twoWayComparison"!==c||0!==r||A(a)||(a=-a),l.push(a)}m.data=l,"stacked"!==c&&"twoWayComparison"!==c||(m.stack="default"),m.label=T(i,t.formatter||"twoWayComparison"===c?{type:t.formatter,formatterToFixed:t.formatterToFixed,negative:"twoWayComparison"===c}:void 0,this.ref),m.colorBy=p,m.barWidth=d,m.barMaxWidth=M,m.barMinWidth=B,m.barGap=W,m.barMinHeight=N,m.itemStyle=P(i,this.ref),m.markPoint=U(bt(i,L),this.ref),m.markLine=S(bt(i,w),h,this.ref),I.series.push(m)}j.data=e}else{for(let t=0;t<z.length;t++){const e=z[t],s={data:R.map((s=>{const a=s[e.as];return"twoWayComparison"===c&&0===t?-a:a})),type:"bar",name:v(e)};"stacked"!==c&&"twoWayComparison"!==c||(s.stack="default"),s.label=T(i,e.formatter||"twoWayComparison"===c?{type:e.formatter,formatterToFixed:e.formatterToFixed,negative:"twoWayComparison"===c}:void 0,this.ref),s.colorBy=p,s.barWidth=d,s.barMaxWidth=M,s.barMinWidth=B,s.barGap=W,s.barMinHeight=N,s.itemStyle=P(i,this.ref),s.markPoint=U(bt(i,L),this.ref),s.markLine=S(bt(i,w),h,this.ref),I.series.push(s)}const t=R.map((t=>E.map((e=>n(t[e.as])||"")).filter((t=>""!==t)).join("-")));j.data=t}return I.legend=F(i,I.series,this.ref),I}updateChartData(t,e,s){const a=s||this.props,i=l(a,this.ref),{measures:r,dimensions:o,xyFlip:h,columnChartType:p,columnBarWidth:c,columnBarMaxWidth:d,columnBarMinWidth:m,columnBarGap:f,columnBarMinHeight:u,groupField:g,colorBy:y}=i,{measures:C,groupField:b}=this.preProps||{};let D=t;const x=o||[],M=r||[],B=C||[];if(D){xt(D)&&(D=[D]),this.config.series=[];let t=[];if(D&&D.length>0){if(D=this.sortRoprtDataByDate(D,x),D=this.sortRoprtDataByMeasures(D,M),1===M.length&&g){const e=M[0],{categories:s,groupFieldValues:a,groupFieldData:r}=Bt(D,g,x,M);t=s;for(let s=0;s<a.length;s++){const o=a[s],n=r[o],l=[],g={data:[],type:"bar",name:o||v(e)};for(let e=0;e<t.length;e++){const a=t[e];let i=n[a]?.value||"";"twoWayComparison"!==p||0!==s||A(i)||(i=-i),l.push(i)}g.data=l,"stacked"!==p&&"twoWayComparison"!==p||(g.stack="default"),g.label=T(i,e.formatter||"twoWayComparison"===p?{type:e.formatter,formatterToFixed:e.formatterToFixed,negative:"twoWayComparison"===p}:void 0,this.ref),g.colorBy=y,g.barWidth=c,g.barMaxWidth=d,g.barMinWidth=m,g.barGap=f,g.barMinHeight=u,g.itemStyle=P(i,this.ref),g.markPoint=U(bt(i,L),this.ref),g.markLine=S(bt(i,w),h,this.ref),this.config.series.push(g)}}else{for(let t=0;t<M.length;t++){const e=M[t],s={data:D.map((s=>{const a=s[e.as];return"twoWayComparison"===p&&0===t?-a:a})),type:"bar",name:v(e)};"stacked"!==p&&"twoWayComparison"!==p||(s.stack="default"),s.label=T(i,e.formatter||"twoWayComparison"===p?{type:e.formatter,formatterToFixed:e.formatterToFixed,negative:"twoWayComparison"===p}:void 0,this.ref),s.colorBy=y,s.barWidth=c,s.barMaxWidth=d,s.barMinWidth=m,s.barGap=f,s.barMinHeight=u,s.itemStyle=P(i,this.ref),s.markPoint=U(bt(i,L),this.ref),s.markLine=S(bt(i,w),h,this.ref),this.config.series.push(s)}t=D.map((t=>x.map((e=>n(t[e.as])||"")).filter((t=>""!==t)).join("-")))}h&&this.config?.yAxis?.data?this.config.yAxis.data=t:this.config?.xAxis?.data&&(this.config.xAxis.data=t)}this.config.legend=F(i,this.config.series,this.ref),e?(0!==t.length&&0!==this.config.series.length&&B.length===M.length&&b===g||!this.echarts?.clear||this.echarts?.clear(),this.reloadEcharts(this.config)):(this.echarts?.clear&&this.echarts?.clear(),this.renderChart(this.config))}}updateChartConfig(t,e,s){const a=this.getChartConfig(t,s);a&&(this.config=a,void 0!==e?.__notEChartsDiff?.columnChartType||void 0!==e?.groupField?(this.echarts?.clear&&this.echarts?.clear(),this.renderChart(a)):this.reloadEcharts(a))}};Wt=p([dt({type:"chart-column",storeType:gt.name})],Wt);let Nt=class extends Mt{config;chartUpdateDebounce;constructor(t,e){super(t,e),this.config=this.getChartConfig(),this.chartUpdateDebounce=Dt((async(t,e)=>{const s=this.preProps||e||{};this.showLoading();const a=await c(t,s);this.hideLoading(),a&&a.data&&(this.curChartData=a.data,this.updateChartData(a.data,!0,t));const i=d(t,s);i&&this.updateChartConfig(this.curChartData,i,t),this.preProps=t}),300)}async componentDidMount(){super.componentDidMount();const t=a(this.props,this.props.data);this.preProps=t,this.showLoading();const{data:s}=await e(t);this.hideLoading(),s?(this.curChartData=s,this.updateChartData(s)):this.renderChart(this.config);const{dispatchEvent:i}=this.props;await i("init",s,this),this.echarts&&this.echarts.on("finished",(()=>{this.updateChartCanvasPadding(this.props.style),this.hideLoading()}))}componentDidUpdate(t){super.componentDidUpdate(t);const e=this.props.formStore?.data||this.props.data;if(this.preProps&&this.props.data!==t.data){const t=r(this.props,e);this.chartUpdateDebounce({...this.preProps,...t,data:e},this.preProps)}else{const t=a(this.props,e);this.chartUpdateDebounce(t,this.preProps)}}componentWillUnmount(){super.componentWillUnmount(),this.chartUpdateDebounce?.cancel()}doAction(t,e,s,a){const i=t?.actionType;if("chartTypeChange"===i){const t=a?.chartType;"line"===t?this.setSchema({stackedLineChart:!1}):"stackedLine"===t&&this.setSchema({stackedLineChart:!0})}else"xAxisInverse"===i?this.setSchema({xAxisInverse:a?.xAxisInverse}):super.doAction(t,e,s,a)}getChartConfig(t,e){let s=e;e||(s=a(this.props,this.props.data));const i=l(s,this.ref),{measures:r,measures2:o,dimensions:h,stackedLineChart:p,lineType:c,lineStepPosition:d,lineSymbol:A,columnLineMix:R,doubleYAxis:E,doubleYAxisAlign:z,columnBarWidth:I,columnBarMaxWidth:j,columnBarMinWidth:O,columnBarGap:V,columnBarMinHeight:G,groupField:H,colorBy:$}=i;let Z=t;const _=r||[],Y=h||[];if(Z&&xt(Z)&&(Z=[Z]),!t||0===t.length)return{};const q={tooltip:m(i,void 0,this.ref),title:u(i,this.ref),color:f(i),series:[],grid:g(bt(i,y)),xAxis:{data:[],type:"category",...D(i,void 0,this.ref)},...C(bt(i,b))};if(!Z?.length)return q;Z=this.sortRoprtDataByDate(Z,Y),Z=this.sortRoprtDataByMeasures(Z,_);const J=E&&o?[].concat(_).concat(o):_;let K=[];if(!E&&1===_.length&&H){const t=_[0],{categories:e,groupFieldValues:s,groupFieldData:a}=Bt(Z,H,Y,J);K=e;for(let e=0;e<s.length;e++){const r=s[e],o=a[r],h=[];let n={data:[],type:R?M(t,e):"line",name:r||v(t)};for(let t=0;t<K.length;t++){const e=K[t];h.push(o[e]?.value||"")}n.data=h,n=Object.assign(n,{symbol:A||"emptyCircle"},B(bt(i,W))),p&&"default"!==p&&(n.stack="default",n.areaStyle={}),n.label=T(i,t.formatter?{type:t.formatter,formatterToFixed:t.formatterToFixed,negative:!1}:void 0,this.ref),n.colorBy=$,n.smooth="smooth"===c,n.step="step"===c?d||"start":"",n.markPoint=U(bt(i,L),this.ref),n.markLine=S(bt(i,w),!1,this.ref),q.series.push(n)}}else{for(let t=0;t<J.length;t++){const e=J[t];if(!e)continue;let s={data:Z.map((t=>t[e.as])),type:R?M(e,t):"line",name:v(e)};"line"===s.type?s=Object.assign(s,{symbol:A||"emptyCircle"},B(bt(i,W))):(s.barWidth=I,s.barMaxWidth=j,s.barMinWidth=O,s.barGap=V,s.barMinHeight=G,s.itemStyle=P(i,this.ref)),t>=_.length&&(s.yAxisIndex=1),p&&"default"!==p&&(s.stack="default",s.areaStyle={}),s.label=T(i,e.formatter?{type:e.formatter,formatterToFixed:e.formatterToFixed,negative:!1}:void 0,this.ref),s.colorBy=$,s.smooth="smooth"===c,s.step="step"===c?d||"start":"",s.markPoint=U(bt(i,L),this.ref),s.markLine=S(bt(i,w),!1,this.ref),q.series.push(s)}K=Z.map((t=>Y.map((e=>n(t[e.as])||"")).join("-")))}if(q.xAxis.data=K,E){const t=bt(i,N);let e=bt(i,k);e={...t,yAxisLabelFontSize:e.yAxisLabelFontSize2,yAxisMin:e.yAxisMin2,yAxisMax:e.yAxisMax2,yAxisLabelRotate:e.yAxisLabelRotate2,yAxisPreUnit:e.yAxisPreUnit2,yAxisAfterUnit:e.yAxisAfterUnit2,yAxisName:e.yAxisName2,yAxisNameConfig:e.yAxis2NameConfig,yAxisFormatter:e.yAxisFormatter2,yAxisLabelStyle:e.yAxis2LabelStyle},q.yAxis=x([t,e],{},this.ref)}else q.yAxis=x(i,{},this.ref);return q.legend=F(i,q.series,this.ref),q}updateChartData(t,e,s){const a=s||this.props,i=l(a,this.ref),{measures:r,dimensions:o,measures2:h,groupField:p,stackedLineChart:c,lineType:d,lineStepPosition:m,lineSymbol:f,columnLineMix:u,doubleYAxis:g,doubleYAxisAlign:y,columnBarWidth:C,columnBarMaxWidth:b,columnBarMinWidth:D,columnBarGap:A,columnBarMinHeight:R,colorBy:E}=i,{measures:z,measures2:I}=this.preProps||{};let j=t;const O=o||[],V=r||[];if(this.config.xAxis||(this.config=this.getChartConfig(t)),j){this.config.series=[];let t=[];if(xt(j)&&(j=[j]),j&&j.length>0){j=this.sortRoprtDataByDate(j,O),j=this.sortRoprtDataByMeasures(j,V);const e=g&&h?[].concat(V).concat(h):V;if(!g&&1===V.length&&p){const e=V[0],{categories:s,groupFieldValues:a,groupFieldData:r}=Bt(j,p,O,V);t=s;for(let s=0;s<a.length;s++){const o=a[s],h=r[o],n=[];let p={data:[],type:u?M(e,s):"line",name:o||v(e)};for(let e=0;e<t.length;e++){const s=t[e];n.push(h[s]?.value||"")}p.data=n,p=Object.assign(p,{symbol:f||"emptyCircle"},B(bt(i,W))),c&&"default"!==c&&(p.stack="default",p.areaStyle={}),p.label=T(i,e.formatter?{type:e.formatter,formatterToFixed:e.formatterToFixed,negative:!1}:void 0,this.ref),p.colorBy=E,p.smooth="smooth"===d,p.step="step"===d?m||"start":"",p.markPoint=U(bt(i,L),this.ref),p.markLine=S(bt(i,w),!1,this.ref),this.config.series.push(p)}}else{for(let t=0;t<e.length;t++){const s=e[t];if(!s)continue;let a={data:j.map((t=>t[s.as])),type:u?M(s,t):"line",name:v(s)};"line"===a.type?a=Object.assign(a,{symbol:f||"emptyCircle"},B(bt(i,W))):(a.barWidth=C,a.barMaxWidth=b,a.barMinWidth=D,a.barGap=A,a.barMinHeight=R,a.itemStyle=P(i,this.ref)),t>=V.length&&(a.yAxisIndex=1),c&&"default"!==c&&(a.stack="default",a.areaStyle={}),a.label=T(i,s.formatter?{type:s.formatter,formatterToFixed:s.formatterToFixed,negative:!1}:void 0,this.ref),a.colorBy=E,a.smooth="smooth"===d,a.step="step"===d?m||"start":"",a.markPoint=U(bt(i,L),this.ref),a.markLine=S(bt(i,w),!1,this.ref),this.config.series.push(a)}O.length>0&&(t=j.map((t=>O.map((e=>n(t[e.as])||"")).join("-"))))}if(this.config?.xAxis?.data&&(this.config.xAxis.data=t),g){const t=bt(i,N);let e=bt(i,k);e={...t,yAxisLabelFontSize:e.yAxisLabelFontSize2,yAxisMin:e.yAxisMin2,yAxisMax:e.yAxisMax2,yAxisLabelRotate:e.yAxisLabelRotate2,yAxisPreUnit:e.yAxisPreUnit2,yAxisAfterUnit:e.yAxisAfterUnit2,yAxisName:e.yAxisName2,yAxisFormatter:e.yAxisFormatter2,yAxisLabelStyle:e.yAxis2LabelStyle},this.config.yAxis=x([t,e],{},this.ref)}else this.config.yAxis=x(i,{},this.ref)}this.config.legend=F(i,this.config.series,this.ref),e?(0!==t.length&&0!==this.config.series.length&&z?.length===r?.length&&I?.length===h?.length||!this.echarts?.clear||this.echarts?.clear(),this.reloadEcharts(this.config)):(this.echarts?.clear&&this.echarts?.clear(),this.renderChart(this.config))}}updateChartConfig(t,e,s){const a=this.getChartConfig(t,s);a&&(this.config=a,void 0!==e?.__notEChartsDiff?.doubleYAxisAlign||void 0!==e?.__notEChartsDiff?.stackedLineChart?(this.echarts?.clear&&this.echarts?.clear(),this.renderChart(a)):this.reloadEcharts(a))}};Nt=p([dt({type:"chart-line",storeType:gt.name})],Nt);let kt=class extends Mt{config;chartUpdateDebounce;constructor(t,e){super(t,e),this.config=this.getChartConfig(),this.chartUpdateDebounce=Dt((async(t,e)=>{const s=this.preProps||e||{};this.showLoading();const a=await c(t,s);this.hideLoading(),a&&a.data&&(this.curChartData=a.data,this.updateChartData(a.data,!0,t));const i=d(t,s);i&&this.updateChartConfig(this.curChartData,i,t),this.preProps=t}),300)}async componentDidMount(){super.componentDidMount();const t=a(this.props,this.props.data);this.preProps=t,this.showLoading();const{data:s}=await e(t);this.hideLoading(),s?(this.curChartData=s,this.updateChartData(s,t)):this.renderChart(this.config);const{dispatchEvent:i}=this.props;await i("init",s,this),this.echarts&&this.echarts.on("finished",(()=>{this.updateChartCanvasPadding(this.props.style),this.hideLoading()}))}componentDidUpdate(t){super.componentDidUpdate(t);const e=this.props.formStore?.data||this.props.data;if(this.preProps&&this.props.data!==t.data){const t=r(this.props,e);this.chartUpdateDebounce({...this.preProps,...t,data:e},this.preProps)}else{const t=a(this.props,e);this.chartUpdateDebounce(t,this.preProps)}}componentWillUnmount(){super.componentWillUnmount(),this.chartUpdateDebounce?.cancel()}doAction(t,e,s,a){const i=t?.actionType;if("chartTypeChange"===i){const t=a?.chartType;this.setSchema({pieChartType:t,innerRadius:"ring"===t?60:void 0})}else super.doAction(t,e,s,a)}getChartConfig(t,e){let s=e;e||(s=a(this.props,this.props.data));const{measures:i,dimensions:r,dataType:o,pieChartType:h,pieChartRoseType:p,color:c}=s,d=l(s,this.ref);let g=t;const y=i||[],D=r||[];let x=[];const v={tooltip:m(d,void 0,this.ref),title:u(d,this.ref),color:f(d),series:[],...C(bt(d,b))};if("rose"===h&&(v.roseType=p),!g)return v;if(1===o){xt(g)&&(g=[g]);const t=g.map((t=>D.map((e=>n(t[e.as])||"")).join("-"))),e=y[0];if(!e)return v;x=g.map(((s,a)=>({value:s[e.as],name:t[a],itemStyle:R(d)}))),v.series.push({data:x,type:"pie",...E(bt(d,z)),label:T(d,e.formatter?{type:e.formatter,formatterToFixed:e.formatterToFixed,negative:!1}:void 0,this.ref)})}else{const t=[];Tt(g)&&(g=g[0]);for(const e in g){const s=vt(y,(t=>t.as===e));s&&t.push({value:g[e],name:I(s,e),itemStyle:R(d)})}x=t,v.series.push({data:x,type:"pie",...E(bt(d,z)),label:{...T(d,void 0,this.ref),overflow:"none"}})}return v.legend=F(d,x,this.ref),v}updateChartData(t,e,s){const a=s||this.props,{measures:i,dimensions:r,dataType:o}=a,h=i||[],p=r||[],c=l(a,this.ref);let d=t;if(t){if(this.config.series=[],1===o){xt(d)&&(d=[d]);const t=d.map((t=>p.map((e=>n(t[e.as])||"")).join("-"))),e=h[0];e&&this.config.series.push({data:d.map(((s,a)=>({value:s[e.as],name:t[a],itemStyle:R(c)}))),type:"pie",...E(bt(c,z)),label:T(c,e.formatter?{type:e.formatter,formatterToFixed:e.formatterToFixed,negative:!1}:void 0,this.ref)})}else{Tt(d)&&(d=d[0]);const t=[];for(const e in d){const s=vt(h,(t=>t.as===e));s&&t.push({value:d[e],name:I(s,e),itemStyle:R(c)})}this.config.series.push({data:t,type:"pie",...E(bt(c,z)),label:{...T(c,void 0,this.ref),overflow:"none"}})}this.config.legend=F(c,this.config.series,this.ref),e?(0===this.config.series.length&&this.echarts?.clear&&this.echarts?.clear(),this.reloadEcharts(this.config)):(this.echarts?.clear&&this.echarts?.clear(),this.renderChart(this.config))}}updateChartConfig(t,e,s){const a=this.getChartConfig(t,s);if(a){const{dataType:t,roseType:s}=e||{};void 0===t&&void 0===s||!this.echarts?.clear||this.echarts?.clear(),this.config=a,void 0!==s?this.renderChart(a):this.reloadEcharts(a)}}};kt=p([dt({type:"chart-pie",storeType:gt.name})],kt);let Rt=class extends Pt.Component{static contextType=lt;chartUpdateDebounce;preProps;reportTimer;domRef=Pt.createRef();constructor(t,e){super(t);e.registerComponent(this),this.state={targetNumbers:{},targetNumberTime:(new Date).getTime()},this.chartUpdateDebounce=Dt((async(t,e)=>{const s=this.preProps||e||{},a=await c(t,this.preProps);a?.data&&this.updateChartData(a.data),this.preProps=t;d(t,s)&&this.forceRender()}),300),this.setReportTimer=this.setReportTimer.bind(this),this.reload=this.reload.bind(this)}async componentDidMount(){const t=a(this.props,this.props.data);this.preProps=t;const s=await e(t);s?.data&&this.updateChartData(s?.data);const{dispatchEvent:i}=this.props;await i("init",s?.data||{},this),this.setReportTimer()}componentDidUpdate(t,e){const s=this.props,i=s.formStore?.data||s.data;if(e.targetNumberTime===this.state.targetNumberTime){if(this.preProps&&s.data!==t.data){const t=r(s,i);this.chartUpdateDebounce({...this.preProps,...t,data:i},this.preProps)}else{const t=a(s,i);this.chartUpdateDebounce(t,this.preProps)}this.props.reportInterval!==t.reportInterval&&this.setReportTimer()}}componentWillUnmount(){this.context.unRegisterComponent(this),this.chartUpdateDebounce?.cancel(),clearInterval(this.reportTimer)}getReportProps(){let t=this.preProps;if(!t){t=this.props;const e=this.props.formStore?.data||this.props.data;return a(t,e)}return t}reload(){const t=this.preProps||this.props;e(t).then((t=>{t&&t.data&&this.updateChartData(t.data)}))}setData(t,e){const{store:s}=this.props;if(s.updateData(t,void 0,e),Ut(t)){const e={...this.preProps.data,...t},s=r(this.props,e),a={...this.preProps,...s,data:e};this.chartUpdateDebounce(a,this.preProps)}}setSchema(t){if(!t)return;let e=t;if(Tt(t))e=s(t);else if(!Ut(t))return;const r=a(e,this.props.data),o=i(this.preProps,r);this.chartUpdateDebounce(o)}doAction(t,e,s,a){const i=t?.actionType;"setSchema"===i&&this.setSchema(a?.chartSchema||a?.value)}setReportTimer(){let t=this.props.reportInterval;t&&St(t)&&(t=Number.parseInt(t)),this.reportTimer&&clearInterval(this.reportTimer),t?this.reportTimer=setInterval(this.reload,Math.max(t,1e3)):this.reportTimer&&clearInterval(this.reportTimer)}forceRender(){this.setState({targetNumberTime:(new Date).getTime()})}updateChartData(t){Lt(this.state.targetNumbers,t)||this.setState({targetNumbers:t})}renderTitle(){const t=this.getReportProps(),{classnames:e,titleShow:s,titleText:a,titleAlignment:i,titleColor:r,titleBackgroundColor:o,titleFontSize:h,titleLink:n}=t,p=u(t,this.domRef),c={display:s?"block":"none",textAlign:i,color:r||j("color.text"),fontSize:h,...p.textStyle};return Pt.createElement("div",{className:e("TargetNumberTitle"),style:c},n?Pt.createElement("a",{style:{background:o||"none",color:c.color,fontSize:c.fontSize},href:n,target:"_blank"},a):Pt.createElement("span",{style:{background:o||"none"}},a))}renderValExpr(t){const e=O(t||"",this.props.data||{});return void 0!==e?e.toString():""}render(){const t=this.getReportProps(),{className:e,classnames:s,style:a,classPrefix:i,alignClass:r,data:o,id:h,wrapperCustomStyle:n,env:p,themeCss:c,baseControlClassName:d}=t,l=r??"flex-col";let{targetNumbers:m,targetNumberTime:f}=this.state;const{measures:u}=t,g=u||[],{dataSourceType:y,contextData:C,fontSize:b,fontColor:D,fontWeight:x}=t;Tt(m)&&(m=m[0]);const T=ut(a,o),P={fontSize:b||32,fontWeight:x||400,...V(t,"chartStyle",{color:j("color.brand"),fontSize:b||"32px"},this.domRef)},U=V(t,"subTitleStyle",{color:j("color.text"),fontSize:"12px"},this.domRef);return("context"===y&&y||m&&0!==g.length)&&("context"!==y||C&&0!==C.length)?"context"===y?Pt.createElement("div",{className:s("TargetContainer",e,yt({name:"baseControlClassName",id:h,themeCss:c}),yt({name:"wrapperCustomStyle",id:h,themeCss:n})),style:T,ref:t=>{this.domRef=t}},this.renderTitle(),C.map(((t,e)=>{let a=this.renderValExpr(t.data);return t.formatter&&(a=G[t.formatter](a||0,t)),Pt.createElement("div",{className:s("TargetBlock",l),key:e},Pt.createElement("div",{className:s("TargetNumber","break-all"),style:P},a),Pt.createElement("div",{className:s("TargetTitle","break-all"),style:U},this.renderValExpr(t.title||"")),Pt.createElement(Ct,{config:{wrapperCustomStyle:n,id:h,themeCss:c,classNames:[{key:"baseControlClassName"}]},env:p}))}))):Pt.createElement("div",{className:s("TargetContainer",e,yt({name:"baseControlClassName",id:h,themeCss:c}),yt({name:"wrapperCustomStyle",id:h,themeCss:n})),style:T,ref:t=>{this.domRef=t}},this.renderTitle(),g.map(((t,e)=>{let a=m[t.as]??"-";return t.formatter&&(a=G[t.formatter](a||0,t)),Pt.createElement("div",{className:s("TargetBlock",l),key:e},Pt.createElement("div",{className:s("TargetNumber","break-all"),style:P},a),Pt.createElement("div",{className:s("TargetTitle","break-all"),style:U},v(t)),Pt.createElement(Ct,{config:{wrapperCustomStyle:n,id:h,themeCss:c,classNames:[{key:"baseControlClassName"}]},env:p}))}))):Pt.createElement("div",{className:s("TargetContainer",e,yt({name:"baseControlClassName",id:h,themeCss:c}),yt({name:"wrapperCustomStyle",id:h,themeCss:n})),style:T,"data-time":f,ref:t=>{this.domRef=t}},this.renderTitle(),Pt.createElement("div",{className:s("TargetBlock",l)},Pt.createElement("div",{className:s("TargetNumber"),style:P},"-"),Pt.createElement("div",{className:s("TargetTitle"),style:U},"-")),Pt.createElement(Ct,{config:{wrapperCustomStyle:n,id:h,themeCss:c,classNames:[{key:"baseControlClassName"}]},env:p}))}};Rt=p([dt({type:"target-number",storeType:gt.name})],Rt);let Et=class extends Mt{config;chartUpdateDebounce;constructor(t,e){super(t,e),this.config=this.getChartConfig(),this.chartUpdateDebounce=Dt((async(t,e)=>{const s=this.preProps||e||{};this.showLoading();const a=await c(t,s);this.hideLoading(),a&&a.data&&(this.curChartData=a.data,this.updateChartData(a.data,!0,t));d(t,s)&&this.updateChartConfig(t),this.preProps=t}),300)}async componentDidMount(){super.componentDidMount();const t=a(this.props,this.props.data);this.preProps=t,this.showLoading();const{data:s}=await e(t);this.hideLoading(),s?(this.curChartData=s,this.updateChartData(s)):this.renderChart(this.config);const{dispatchEvent:i}=this.props;await i("init",s,this),this.echarts&&this.echarts.on("finished",(()=>{this.updateChartCanvasPadding(this.props.style),this.hideLoading()}))}componentDidUpdate(t){super.componentDidUpdate(t);const e=this.props.formStore?.data||this.props.data;if(this.preProps&&this.props.data!==t.data){const t=r(this.props,e);this.chartUpdateDebounce({...this.preProps,...t,data:e},this.preProps)}else{const t=a(this.props,e);this.chartUpdateDebounce(t,this.preProps)}}componentWillUnmount(){super.componentWillUnmount(),this.chartUpdateDebounce?.cancel()}getChartConfig(t,e){let s=e;e||(s=a(this.props,this.props.data));const{measures:i,progressStartAngle:r,progressEndAngle:o,dataSourceType:h,contextData:n,data:p}=s,c=l(s,this.ref);let d=(i||[])[0]||{};const m={};let f=t||{},g=100;if(t&&Tt(t)&&(f=t[0]),"context"===h){const t=n&&n[0]?n[0]:{};d=t,m.value=O(t.data,p),m.name=O(t.title,p)}else m.value=f[d.as],m.name=v(d);return"numberToPercent"===d.formatter?g=1:"totalToPercent"===d.formatter&&d.totalField&&(g=f[d.totalFieldAs||d.totalField],"context"===h&&(g=p[d.totalField])),{series:[{type:"gauge",startAngle:r,endAngle:o,pointer:H(c),progress:$(c,this.ref),axisLine:Z(c,this.ref),splitLine:_(c,this.ref),axisTick:Y(c,this.ref),axisLabel:q(c,this.ref),...E(c),data:[m],min:0,max:g,title:J(c,this.ref),detail:K(c,d,this.ref)}],title:u(c,this.ref)}}updateChartData(t,e,s){const a=s||this.props,{dataSourceType:i,measures:r,data:o,contextData:h}=a,n=l(a,this.ref),p={};let c=(r||[])[0]||{},d=t||{},m=100;if(t&&Tt(t)&&(d=t[0]),"context"===i){const t=h&&h[0]?h[0]:{};c=t,p.value=O(t.data,o),p.name=O(t.title,o)}else p.value=d[c.as],p.name=v(c);"numberToPercent"===c.formatter?m=1:"totalToPercent"===c.formatter&&c.totalField&&(m=d[c.totalFieldAs||c.totalField],"context"===i&&(m=o[c.totalField])),this.config.series[0].data=[p],this.config.series[0].detail=K(n,c,this.ref),this.config.series[0].max=m,e?this.reloadEcharts(this.config):(this.echarts?.clear&&this.echarts?.clear(),this.renderChart(this.config))}updateChartConfig(t){const e=t||this.props,{measures:s}=e,{measures:a}=this.preProps||{},i=this.getChartConfig(this.curChartData,t);if(i){this.config=i;const t=(s||[])[0]?.formatter,e=(a||[])[0]?.formatter;e&&!t&&this.echarts?.clear&&this.echarts?.clear(),this.reloadEcharts(i)}}};Et=p([dt({type:"chart-percent",storeType:gt.name})],Et);let zt=class extends Mt{config;chartUpdateDebounce;constructor(t,e){super(t,e),this.config=this.getChartConfig(),this.chartUpdateDebounce=Dt((async(t,e)=>{const s=this.preProps||e||{};this.showLoading();const a=await c(t,s);this.hideLoading(),a&&a.data&&(this.curChartData=a.data,this.updateChartData(a.data,!0,t));const i=d(t,s);i&&this.updateChartConfig(this.curChartData,i,t),this.preProps=t}),300)}async componentDidMount(){super.componentDidMount();const t=a(this.props,this.props.data);this.preProps=t,this.showLoading();const{data:s}=await e(t);this.hideLoading(),s?(this.curChartData=s,this.updateChartData(s)):this.renderChart(this.config);const{dispatchEvent:i}=this.props;await i("init",s,this),this.echarts&&this.echarts.on("finished",(()=>{this.updateChartCanvasPadding(this.props.style),this.hideLoading()}))}componentDidUpdate(t){super.componentDidUpdate(t);const e=this.props.formStore?.data||this.props.data;if(this.preProps&&this.props.data!==t.data){const t=r(this.props,e);this.chartUpdateDebounce({...this.preProps,...t,data:e},this.preProps)}else{const t=a(this.props,e);this.chartUpdateDebounce(t,this.preProps)}}componentWillUnmount(){super.componentWillUnmount(),this.chartUpdateDebounce?.cancel()}getChartConfig(t,e){let s=e;e||(s=a(this.props,this.props.data));const i=l(s,this.ref),{measures:r,dimensions:o,color:h,groupField:n}=i;let p=t;const c=r||[],d=o||[],y={color:f(i),title:u(i,this.ref),grid:g(i),radar:{indicator:[],...E(bt(i,z)),axisLine:{show:i.axisLineStyle?.show??!0,lineStyle:Q(i,"axisLineStyle",this.ref)},splitLine:{show:i.splitLineStyle?.show??!0,lineStyle:Q(i,"splitLineStyle",this.ref)}},series:[{type:"radar",data:[],areaStyle:X(i)}],...C(bt(i,b))};if(0===c.length||0===d.length)return y;if(p&&xt(p)&&(p=[p]),!p?.length)return y;const D=d[0].as;let x=[];if(c&&1===c.length&&n){const t=c[0],{categories:e,groupFieldValues:s,groupFieldData:a}=Bt(p,n,d,c);let r=e.map((t=>({name:t})));r=wt(r,"name"),y.radar.indicator=r;for(let r=0;r<s.length;r++){const o=s[r],h=a[o],n=[],p={value:[],name:o||v(t)};for(let t=0;t<e.length;t++){const s=e[t];n.push(h[s]?.value||"")}p.value=n,p.label=T(i,t.formatter?{type:t.formatter,formatterToFixed:t.formatterToFixed}:void 0,this.ref),y.series[0].data.push(p)}}else{for(const t of c){if(!t)continue;const e=p.map((e=>e[t.as]));x=x.concat(e),y.series[0].data.push({value:e,name:v(t),label:T(i,t.formatter?{type:t.formatter,formatterToFixed:t.formatterToFixed,negative:!1}:void 0,this.ref)})}const t=Math.max(...x);y.radar.indicator=p.map((e=>({name:e[D],max:t})))}return y.tooltip=m(i,y.radar.indicator,this.ref),y.legend=F(i,y.series[0].data,this.ref),y}updateChartData(t,e,s){const a=s||this.props,i=l(a,this.ref),{measures:r,dimensions:o,groupField:h}=i;let n=t;const p=r||[],c=o||[];if(n){this.config.series=[{type:"radar",data:[],areaStyle:X(i)}],xt(n)&&(n=[n]);const t=c[0]?.as;let s=[];if(p&&1===p.length&&h){const t=p[0],{categories:e,groupFieldValues:s,groupFieldData:a}=Bt(n,h,c,p);let r=e.map((t=>({name:t})));r=wt(r,"name"),this.config.radar.indicator=r;for(let r=0;r<s.length;r++){const o=s[r],h=a[o],n=[],p={value:[],name:o||v(t)};for(let t=0;t<e.length;t++){const s=e[t];n.push(h[s]?.value||"")}p.value=n,p.label=T(i,t.formatter?{type:t.formatter,formatterToFixed:t.formatterToFixed}:void 0,this.ref),this.config.series[0].data.push(p)}}else{for(const t of p){if(!t)continue;const e=n.map((e=>e[t.as]));s=s.concat(e),this.config.series[0].data.push({value:e,name:v(t),label:T(i,t.formatter?{type:t.formatter,formatterToFixed:t.formatterToFixed,negative:!1}:void 0,this.ref)})}const e=Math.max(...s);this.config.radar.indicator=n.map((s=>({name:s[t],max:e})))}this.config.tooltip=m(i,this.config.radar.indicator,this.ref),this.config.legend=F(i,this.config.series[0].data,this.ref),e?(0===this.config.series.length&&this.echarts?.clear&&this.echarts?.clear(),this.reloadEcharts(this.config)):(this.echarts?.clear&&this.echarts?.clear(),this.renderChart(this.config))}}updateChartConfig(t,e,s){const a=this.getChartConfig(t,s);a&&(this.config=a,this.reloadEcharts(a))}};zt=p([dt({type:"chart-radar",storeType:gt.name})],zt);let It=class extends Mt{config;chartUpdateDebounce;constructor(t,e){super(t,e),this.config=this.getChartConfig(),this.chartUpdateDebounce=Dt((async(t,e)=>{const s=this.preProps||e||{};this.showLoading();const a=await c(t,s);this.hideLoading(),a&&a.data&&(this.curChartData=a.data,this.updateChartData(a.data,!0,t));const i=d(t,s);i&&this.updateChartConfig(this.curChartData,i,t),this.preProps=t}),300)}async componentDidMount(){super.componentDidMount();const t=a(this.props,this.props.data);this.preProps=t,this.showLoading();const{data:s}=await e(t);this.hideLoading(),s?(this.curChartData=s,this.updateChartData(s)):this.renderChart(this.config);const{dispatchEvent:i}=this.props;await i("init",s,this),this.echarts&&this.echarts.on("finished",(()=>{this.updateChartCanvasPadding(this.props.style),this.hideLoading()}))}componentDidUpdate(t){super.componentDidUpdate(t);const e=this.props.formStore?.data||this.props.data;if(this.preProps&&this.props.data!==t.data){const t=r(this.props,e);this.chartUpdateDebounce({...this.preProps,...t,data:e},this.preProps)}else{const t=a(this.props,e);this.chartUpdateDebounce(t,this.preProps)}}componentWillUnmount(){super.componentWillUnmount(),this.chartUpdateDebounce?.cancel()}getChartConfig(t,e){let s=e;e||(s=a(this.props,this.props.data));const{measures:i,dimensions:r,dataType:o,funnelOrient:h}=s,p=l(s,this.ref);let c=t;const d=i||[],y=r||[];let D=[];const x={tooltip:m(p,void 0,this.ref),title:u(p,this.ref),color:f(p),series:[],...C(bt(p,b))};if(!c)return x;if(1===o){xt(c)&&(c=[c]);const t=c.map((t=>y.map((e=>n(t[e.as])||"")).join("-"))),e=d[0];if(!e)return x;D=c.map(((s,a)=>({value:s[e.as],name:t[a]}))),x.series.push({data:D,type:"funnel",orient:h,label:T(p,e.formatter?{type:e.formatter,formatterToFixed:e.formatterToFixed,negative:!1}:void 0,this.ref),...g(p)})}else{const t=[];Tt(c)&&(c=c[0]);for(const e in c){const s=vt(d,(t=>t.as===e));s&&t.push({value:c[e],name:I(s,e)})}D=t,x.series.push({data:D,type:"funnel",orient:h,label:{...T(p,void 0,this.ref)},...g(p)})}return x.legend=F(p,D,this.ref),x}updateChartData(t,e,s){const a=s||this.props,{measures:i,dimensions:r,dataType:o,funnelOrient:h}=a;let p=t;const c=i||[],d=r||[],m=l(a,this.ref);if(t){if(this.config.series=[],1===o){xt(p)&&(p=[p]);const t=p.map((t=>d.map((e=>n(t[e.as])||"")).join("-"))),e=c[0];e&&this.config.series.push({data:p.map(((s,a)=>({value:s[e.as],name:t[a]}))),type:"funnel",orient:h,label:T(m,e.formatter?{type:e.formatter,formatterToFixed:e.formatterToFixed,negative:!1}:void 0,this.ref),...g(m)})}else{Tt(p)&&(p=p[0]);const t=[];for(const e in p){const s=vt(c,(t=>t.as===e));s&&t.push({value:p[e],name:I(s,e)})}this.config.series.push({data:t,type:"funnel",orient:h,label:{...T(m,void 0,this.ref)},...g(m)})}this.config.legend=F(m,this.config.series,this.ref),e?(0===this.config.series.length&&this.echarts?.clear&&this.echarts?.clear(),this.reloadEcharts(this.config)):(this.echarts?.clear&&this.echarts?.clear(),this.renderChart(this.config))}}updateChartConfig(t,e,s){const a=this.getChartConfig(t,s);if(a){const{dataType:t,roseType:s}=e||{};void 0===t&&void 0===s||!this.echarts?.clear||this.echarts?.clear(),this.config=a,void 0!==s?this.renderChart(a):this.reloadEcharts(a)}}};It=p([dt({type:"chart-funnel",storeType:gt.name})],It);let jt=class extends Mt{config;chartUpdateDebounce;constructor(t,e){super(t,e),this.config=this.getChartConfig(),this.chartUpdateDebounce=Dt((async(t,e)=>{const s=this.preProps||e||{};this.showLoading();const a=await c(t,s);this.hideLoading(),a&&a.data&&(this.curChartData=a.data,this.updateChartData(a.data,!0,t));const i=d(t,s);i&&this.updateChartConfig(this.curChartData,i,t),this.preProps=t}),300)}async componentDidMount(){super.componentDidMount();const t=a(this.props,this.props.data);this.preProps=t,this.showLoading();const{data:s}=await e(t);this.hideLoading(),s?(this.curChartData=s,this.updateChartData(s)):this.renderChart(this.config);const{dispatchEvent:i}=this.props;await i("init",s,this),this.echarts&&this.echarts.on("finished",(()=>{this.updateChartCanvasPadding(this.props.style),this.hideLoading()}))}componentDidUpdate(t){super.componentDidUpdate(t);const e=this.props.formStore?.data||this.props.data;if(this.preProps&&this.props.data!==t.data){const t=r(this.props,e);this.chartUpdateDebounce({...this.preProps,...t,data:e},this.preProps)}else{const t=a(this.props,e);this.chartUpdateDebounce(t,this.preProps)}}componentWillUnmount(){super.componentWillUnmount(),this.chartUpdateDebounce?.cancel()}doAction(t,e,s,a){const i=t?.actionType;"chartTypeChange"===i?this.setSchema({shape:a?.chartType}):super.doAction(t,e,s,a)}getChartConfig(t,e){let s=e;e||(s=a(this.props,this.props.data));const{measures:i,dimensions:r,color:o}=s,h=l(s,this.ref);let p=t;const c=i||[],d=r||[],y={tooltip:m(h),title:u(h,this.ref),textStyle:{fontFamily:"PingFangSC-Semibold",fontWeight:600,color:()=>{const t=f(h);return t[Ft(Math.random()*t.length,0)]}},series:[],grid:g(h),...C(bt(h,b))};if(!p)return y;xt(p)&&(p=[p]);const D=p.map((t=>d.map((e=>n(t[e.as])||"")).join("-"))),x=c[0];return x?(y.series.push({data:p.map(((t,e)=>({value:t[x.as],name:D[e]}))),type:"wordCloud",...tt(h),rotationStep:5,drawOutOfBound:!1,shrinkToFit:!0,layoutAnimation:!0}),y):y}updateChartData(t,e,s){const a=s||this.props,{measures:i,dimensions:r}=a,o=l(a,this.ref);let h=t;const p=i||[],c=r||[];if(h){this.config.series=[],xt(h)&&(h=[h]);const t=h.map((t=>c.map((e=>n(t[e.as])||"")).join("-"))),s=p[0];s&&this.config.series.push({data:h.map(((e,a)=>({value:e[s.as],name:t[a]}))),type:"wordCloud",...tt(o),rotationStep:10,drawOutOfBound:!1,shrinkToFit:!1,layoutAnimation:!0}),e?(0===this.config.series.length&&this.echarts?.clear&&this.echarts?.clear(),this.reloadEcharts(this.config)):(this.echarts?.clear&&this.echarts?.clear(),this.renderChart(this.config))}}updateChartConfig(t,e,s){const a=this.getChartConfig(t,s);if(a){const{dataType:t,roseType:s}=e||{};void 0===t&&void 0===s||!this.echarts?.clear||this.echarts?.clear(),this.config=a,void 0!==s?this.renderChart(a):this.reloadEcharts(a)}}};jt=p([dt({type:"chart-word-cloud",storeType:gt.name})],jt);const Ot={...{"北京市":"北京","上海市":"上海","天津市":"天津","重庆市":"重庆","香港市":"香港","香港特别行政区":"香港","澳门市":"澳门","澳门特别行政区":"澳门","河北省":"河北","山西省":"山西","内蒙古省":"内蒙古","内蒙古自治区":"内蒙古","辽宁省":"辽宁","吉林省":"吉林","黑龙江省":"黑龙江","江苏省":"江苏","浙江省":"浙江","安徽省":"安徽","福建省":"福建","江西省":"江西","山东省":"山东","河南省":"河南","湖北省":"湖北","湖南省":"湖南","广东省":"广东","广西省":"广西","广西壮族自治区":"广西","海南省":"海南","四川省":"四川","贵州省":"贵州","云南省":"云南","西藏省":"西藏","西藏自治区":"西藏","陕西省":"陕西","甘肃省":"甘肃","青海省":"青海","宁夏省":"宁夏","宁夏回族自治区":"宁夏","新疆省":"新疆","新疆维吾尔自治区":"新疆","台湾省":"台湾","石家庄":"石家庄市","唐山":"唐山市","秦皇岛":"秦皇岛市","邯郸":"邯郸市","邢台":"邢台市","保定":"保定市","张家口":"张家口市","承德":"承德市","沧州":"沧州市","廊坊":"廊坊市","衡水":"衡水市","太原":"太原市","大同":"大同市","阳泉":"阳泉市","长治":"长治市","晋城":"晋城市","朔州":"朔州市","晋中":"晋中市","运城":"运城市","忻州":"忻州市","临汾":"临汾市","吕梁":"吕梁市","呼和浩特":"呼和浩特市","包头":"包头市","乌海":"乌海市","赤峰":"赤峰市","通辽":"通辽市","鄂尔多斯":"鄂尔多斯市","呼伦贝尔":"呼伦贝尔市","巴彦淖尔":"巴彦淖尔市","巴彦淖尔盟":"巴彦淖尔市","乌兰察布":"乌兰察布市","兴安市":"兴安盟","兴安":"兴安盟","锡林郭勒":"锡林郭勒盟","阿拉善":"阿拉善盟","阿拉善市":"阿拉善盟","沈阳":"沈阳市","大连":"大连市","鞍山":"鞍山市","抚顺":"抚顺市","本溪":"本溪市","丹东":"丹东市","锦州":"锦州市","营口":"营口市","阜新":"阜新市","辽阳":"辽阳市","盘锦":"盘锦市","铁岭":"铁岭市","朝阳":"朝阳市","葫芦岛":"葫芦岛市","长春":"长春市","四平":"四平市","辽源":"辽源市","通化":"通化市","白山":"白山市","松原":"松原市","白城":"白城市","延边朝鲜族":"延边朝鲜族自治州","延边":"延边朝鲜族自治州","延边市":"延边朝鲜族自治州","哈尔滨":"哈尔滨市","齐齐哈尔":"齐齐哈尔市","鸡西":"鸡西市","鹤岗":"鹤岗市","双鸭山":"双鸭山市","大庆":"大庆市","伊春":"伊春市","佳木斯":"佳木斯市","七台河":"七台河市","牡丹江":"牡丹江市","黑河":"黑河市","绥化":"绥化市","大兴安岭":"大兴安岭地区","大兴安岭市":"大兴安岭地区","南京":"南京市","无锡":"无锡市","徐州":"徐州市","常州":"常州市","苏州":"苏州市","南通":"南通市","连云港":"连云港市","淮安":"淮安市","盐城":"盐城市","扬州":"扬州市","镇江":"镇江市","泰州":"泰州市","宿迁":"宿迁市","杭州":"杭州市","宁波":"宁波市","温州":"温州市","嘉兴":"嘉兴市","湖州":"湖州市","绍兴":"绍兴市","金华":"金华市","衢州":"衢州市","舟山":"舟山市","台州":"台州市","丽水":"丽水市","合肥":"合肥市","芜湖":"芜湖市","蚌埠":"蚌埠市","淮南":"淮南市","马鞍山":"马鞍山市","淮北":"淮北市","铜陵":"铜陵市","安庆":"安庆市","黄山":"黄山市","滁州":"滁州市","阜阳":"阜阳市","宿州":"宿州市","六安":"六安市","亳州":"亳州市","池州":"池州市","宣城":"宣城市","福州":"福州市","厦门":"厦门市","莆田":"莆田市","三明":"三明市","泉州":"泉州市","漳州":"漳州市","南平":"南平市","龙岩":"龙岩市","宁德":"宁德市","南昌":"南昌市","景德镇":"景德镇市","萍乡":"萍乡市","九江":"九江市","新余":"新余市","鹰潭":"鹰潭市","赣州":"赣州市","吉安":"吉安市","宜春":"宜春市","抚州":"抚州市","上饶":"上饶市","济南":"济南市","青岛":"青岛市","淄博":"淄博市","枣庄":"枣庄市","东营":"东营市","烟台":"烟台市","潍坊":"潍坊市","济宁":"济宁市","泰安":"泰安市","威海":"威海市","日照":"日照市","临沂":"临沂市","德州":"德州市","聊城":"聊城市","滨州":"滨州市","菏泽":"菏泽市","郑州":"郑州市","开封":"开封市","洛阳":"洛阳市","平顶山":"平顶山市","安阳":"安阳市","鹤壁":"鹤壁市","新乡":"新乡市","焦作":"焦作市","濮阳":"濮阳市","许昌":"许昌市","漯河":"漯河市","三门峡":"三门峡市","南阳":"南阳市","商丘":"商丘市","信阳":"信阳市","周口":"周口市","驻马店":"驻马店市","济源":"济源市","武汉":"武汉市","黄石":"黄石市","十堰":"十堰市","宜昌":"宜昌市","襄阳":"襄阳市","鄂州":"鄂州市","荆门":"荆门市","孝感":"孝感市","荆州":"荆州市","黄冈":"黄冈市","咸宁":"咸宁市","随州":"随州市","恩施":"恩施土家族苗族自治州","恩施市":"恩施土家族苗族自治州","恩施土家族苗族":"恩施土家族苗族自治州","仙桃":"仙桃市","潜江":"潜江市","天门":"天门市","神农架":"神农架林区","长沙":"长沙市","株洲":"株洲市","湘潭":"湘潭市","衡阳":"衡阳市","邵阳":"邵阳市","岳阳":"岳阳市","常德":"常德市","张家界":"张家界市","益阳":"益阳市","郴州":"郴州市","永州":"永州市","怀化":"怀化市","娄底":"娄底市","湘西":"湘西土家族苗族自治州","湘西市":"湘西土家族苗族自治州","湘西土家族苗族":"湘西土家族苗族自治州","广州":"广州市","韶关":"韶关市","深圳":"深圳市","珠海":"珠海市","汕头":"汕头市","佛山":"佛山市","江门":"江门市","湛江":"湛江市","茂名":"茂名市","肇庆":"肇庆市","惠州":"惠州市","梅州":"梅州市","汕尾":"汕尾市","河源":"河源市","阳江":"阳江市","清远":"清远市","东莞":"东莞市","中山":"中山市","潮州":"潮州市","揭阳":"揭阳市","云浮":"云浮市","南宁":"南宁市","柳州":"柳州市","桂林":"桂林市","梧州":"梧州市","北海":"北海市","防城港":"防城港市","钦州":"钦州市","贵港":"贵港市","玉林":"玉林市","百色":"百色市","贺州":"贺州市","河池":"河池市","来宾":"来宾市","崇左":"崇左市","海口":"海口市","三亚":"三亚市","三沙":"三沙市","儋州":"儋州市","五指山":"五指山市","琼海":"琼海市","文昌":"文昌市","万宁":"万宁市","东方":"东方市","定安":"定安县","屯昌":"屯昌县","澄迈":"澄迈县","临高":"临高县","白沙黎族":"白沙黎族自治县","白沙":"白沙黎族自治县","昌江黎族":"昌江黎族自治县","昌江":"昌江黎族自治县","乐东黎族":"乐东黎族自治县","乐东":"乐东黎族自治县","陵水黎族":"陵水黎族自治县","陵水":"陵水黎族自治县","保亭黎族苗族":"保亭黎族苗族自治县","保亭":"保亭黎族苗族自治县","琼中黎族苗族":"琼中黎族苗族自治县","琼中":"琼中黎族苗族自治县","成都":"成都市","自贡":"自贡市","攀枝花":"攀枝花市","泸州":"泸州市","德阳":"德阳市","绵阳":"绵阳市","广元":"广元市","遂宁":"遂宁市","内江":"内江市","乐山":"乐山市","南充":"南充市","眉山":"眉山市","宜宾":"宜宾市","广安":"广安市","达州":"达州市","雅安":"雅安市","巴中":"巴中市","资阳":"资阳市","阿坝藏族羌族":"阿坝藏族羌族自治州","阿坝":"阿坝藏族羌族自治州","阿坝市":"阿坝藏族羌族自治州","甘孜藏族":"甘孜藏族自治州","甘孜":"甘孜藏族自治州","甘孜市":"甘孜藏族自治州","凉山彝族":"凉山彝族自治州","凉山":"凉山彝族自治州","凉山市":"凉山彝族自治州","贵阳":"贵阳市","六盘水":"六盘水市","遵义":"遵义市","安顺":"安顺市","毕节":"毕节市","铜仁":"铜仁市","黔西南布依族苗族":"黔西南布依族苗族自治州","黔西南":"黔西南布依族苗族自治州","黔东南苗族侗族":"黔东南苗族侗族自治州","黔东南":"黔东南苗族侗族自治州","黔南布依族苗族":"黔南布依族苗族自治州","黔南":"黔南布依族苗族自治州","昆明":"昆明市","曲靖":"曲靖市","玉溪":"玉溪市","保山":"保山市","昭通":"昭通市","丽江":"丽江市","普洱":"普洱市","临沧":"临沧市","楚雄彝族":"楚雄彝族自治州","楚雄":"楚雄彝族自治州","楚雄市":"楚雄彝族自治州","红河哈尼族彝族":"红河哈尼族彝族自治州","红河":"红河哈尼族彝族自治州","红河市":"红河哈尼族彝族自治州","文山壮族苗族":"文山壮族苗族自治州","文山":"文山壮族苗族自治州","文山市":"文山壮族苗族自治州","西双版纳傣族":"西双版纳傣族自治州","西双版纳":"西双版纳傣族自治州","西双版纳市":"西双版纳傣族自治州","大理白族":"大理白族自治州","大理":"大理白族自治州","大理市":"大理白族自治州","德宏傣族景颇族":"德宏傣族景颇族自治州","德宏":"德宏傣族景颇族自治州","德宏市":"德宏傣族景颇族自治州","怒江傈僳族":"怒江傈僳族自治州","怒江":"怒江傈僳族自治州","怒江市":"怒江傈僳族自治州","迪庆藏族":"迪庆藏族自治州","迪庆":"迪庆藏族自治州","迪庆市":"迪庆藏族自治州","拉萨":"拉萨市","日喀则":"日喀则市","昌都":"昌都市","林芝":"林芝市","山南":"山南市","那曲":"那曲市","那曲地区":"那曲市","阿里":"阿里地区","阿里市":"阿里地区","西安":"西安市","铜川":"铜川市","宝鸡":"宝鸡市","咸阳":"咸阳市","渭南":"渭南市","延安":"延安市","汉中":"汉中市","榆林":"榆林市","安康":"安康市","商洛":"商洛市","兰州":"兰州市","嘉峪关":"嘉峪关市","金昌":"金昌市","白银":"白银市","天水":"天水市","武威":"武威市","张掖":"张掖市","平凉":"平凉市","酒泉":"酒泉市","庆阳":"庆阳市","定西":"定西市","陇南":"陇南市","临夏回族":"临夏回族自治州","临夏":"临夏回族自治州","临夏市":"临夏回族自治州","甘南藏族":"甘南藏族自治州","甘南":"甘南藏族自治州","甘南市":"甘南藏族自治州","西宁":"西宁市","海东":"海东市","海北藏族":"海北藏族自治州","海北":"海北藏族自治州","海北市":"海北藏族自治州","黄南藏族":"黄南藏族自治州","黄南":"黄南藏族自治州","黄南市":"黄南藏族自治州","海南藏族":"海南藏族自治州","果洛藏族":"果洛藏族自治州","果洛":"果洛藏族自治州","果洛市":"果洛藏族自治州","玉树藏族":"玉树藏族自治州","玉树":"玉树藏族自治州","玉树市":"玉树藏族自治州","海西蒙古族藏族":"海西蒙古族藏族自治州","海西":"海西蒙古族藏族自治州","海西市":"海西蒙古族藏族自治州","银川":"银川市","石嘴山":"石嘴山市","吴忠":"吴忠市","固原":"固原市","中卫":"中卫市","乌鲁木齐":"乌鲁木齐市","克拉玛依":"克拉玛依市","吐鲁番":"吐鲁番市","哈密":"哈密市","昌吉回族":"昌吉回族自治州","昌吉":"昌吉回族自治州","昌吉市":"昌吉回族自治州","博尔塔拉蒙古":"博尔塔拉蒙古自治州","博尔塔拉":"博尔塔拉蒙古自治州","博尔塔拉市":"博尔塔拉蒙古自治州","巴音郭楞蒙古":"巴音郭楞蒙古自治州","巴音郭楞":"巴音郭楞蒙古自治州","巴音郭楞市":"巴音郭楞蒙古自治州","阿克苏":"阿克苏地区","阿克苏市":"阿克苏地区","克孜勒苏柯尔克孜":"克孜勒苏柯尔克孜自治州","克孜勒苏柯尔克孜市":"克孜勒苏柯尔克孜自治州","喀什":"喀什地区","喀什市":"喀什地区","和田":"和田地区","和田市":"和田地区","伊犁哈萨克":"伊犁哈萨克自治州","伊犁":"伊犁哈萨克自治州","伊犁市":"伊犁哈萨克自治州","塔城":"塔城地区","塔城市":"塔城地区","阿勒泰":"阿勒泰地区","阿勒泰市":"阿勒泰地区","石河子":"石河子市","阿拉尔":"阿拉尔市","图木舒克":"图木舒克市","五家渠":"五家渠市","北屯":"北屯市","铁门关":"铁门关市","双河":"双河市","可克达拉":"可克达拉市","昆玉":"昆玉市","胡杨河":"胡杨河市","高雄":"高雄市","屏东":"屏东县","台南":"台南市","新竹":"新竹县","宜兰":"宜兰县","基隆":"基隆市","苗栗":"苗栗县","台北":"台北市","新北":"新北市","桃园":"桃园市","彰化":"彰化县","嘉义":"嘉义市","花莲":"花莲县","南投":"南投县","台中":"台中市","云林":"云林县","台东":"台东县","澎湖":"澎湖县","金门":"金门县","连江":"连江县","花地玛堂":"花地玛堂区","花王堂":"花王堂区","望德堂":"望德堂区","大堂":"大堂区","风顺堂":"风顺堂区","嘉模堂":"嘉模堂区","路凼填海":"路凼填海区","圣方济各堂":"圣方济各堂区","东城":"东城区","西城":"西城区","朝阳":"朝阳区","丰台":"丰台区","石景山":"石景山区","海淀":"海淀区","门头沟":"门头沟区","房山":"房山区","通州":"通州区","顺义":"顺义区","昌平":"昌平区","大兴":"大兴区","怀柔":"怀柔区","平谷":"平谷区","密云":"密云区","延庆":"延庆区","万州":"万州区","涪陵":"涪陵区","渝中":"渝中区","大渡口":"大渡口区","江北":"江北区","沙坪坝":"沙坪坝区","九龙坡":"九龙坡区","南岸":"南岸区","北碚":"北碚区","綦江":"綦江区","大足":"大足区","渝北":"渝北区","巴南":"巴南区","黔江":"黔江区","长寿":"长寿区","江津":"江津区","合川":"合川区","永川":"永川区","南川":"南川区","璧山":"璧山区","铜梁":"铜梁区","潼南":"潼南区","荣昌":"荣昌区","开州":"开州区","梁平":"梁平区","武隆":"武隆区","城口":"城口县","丰都":"丰都县","垫江":"垫江县","云阳":"云阳县","奉节":"奉节县","巫山":"巫山县","巫溪":"巫溪县","石柱土家族":"石柱土家族自治县","秀山土家族苗族":"秀山土家族苗族自治县","酉阳土家族苗族":"酉阳土家族苗族自治县","彭水苗族土家族":"彭水苗族土家族自治县","黄浦":"黄浦区","徐汇":"徐汇区","长宁":"长宁县","静安":"静安区","普陀":"普陀区","虹口":"虹口区","杨浦":"杨浦区","闵行":"闵行区","宝山":"宝山区","嘉定":"嘉定区","浦东新":"浦东新区","金山":"金山区","松江":"松江区","青浦":"青浦区","奉贤":"奉贤区","崇明":"崇明区","和平":"和平县","河东":"河东区","河西":"河西区","南开":"南开区","红桥":"红桥区","东丽":"东丽区","西青":"西青区","津南":"津南区","北辰":"北辰区","武清":"武清区","宝坻":"宝坻区","滨海新":"滨海新区","宁河":"宁河区","静海":"静海区","蓟州":"蓟州区","中西":"中西区","湾仔":"湾仔区","油尖旺":"油尖旺区","深水埗":"深水埗区","九龙城":"九龙城区","黄大仙":"黄大仙区","观塘":"观塘区","荃湾":"荃湾区","屯门":"屯门区","元朗":"元朗区","大埔":"大埔县","西贡":"西贡区","沙田":"沙田区","葵青":"葵青区","离岛":"离岛区","长安":"长安区","桥西":"桥西区","新华":"新华区","井陉矿":"井陉矿区","裕华":"裕华区","藁城":"藁城区","鹿泉":"鹿泉区","栾城":"栾城区","井陉":"井陉县","正定":"正定县","行唐":"行唐县","灵寿":"灵寿县","高邑":"高邑县","深泽":"深泽县","赞皇":"赞皇县","无极":"无极县","平山":"平山区","元氏":"元氏县","辛集":"辛集市","晋州":"晋州市","新乐":"新乐市","路南":"路南区","路北":"路北区","古冶":"古冶区","开平":"开平市","丰南":"丰南区","丰润":"丰润区","曹妃甸":"曹妃甸区","滦南":"滦南县","乐亭":"乐亭县","迁西":"迁西县","玉田":"玉田县","遵化":"遵化市","迁安":"迁安市","滦州":"滦州市","海港":"海港区","山海关":"山海关区","北戴河":"北戴河区","抚宁":"抚宁区","青龙满族":"青龙满族自治县","昌黎":"昌黎县","卢龙":"卢龙县","邯山":"邯山区","丛台":"丛台区","复兴":"复兴区","峰峰":"峰峰矿区","肥乡":"肥乡区","永年":"永年区","临漳":"临漳县","成安":"成安县","大名":"大名县","鸡泽":"鸡泽县","广平":"广平县","馆陶":"馆陶县","曲周":"曲周县","武安":"武安市","襄都":"襄都区","信都":"信都区","任泽":"任泽区","南和":"南和区","临城":"临城县","内丘":"内丘县","柏乡":"柏乡县","隆尧":"隆尧县","宁晋":"宁晋县","巨鹿":"巨鹿县","新河":"新河县","广宗":"广宗县","平乡":"平乡县","清河":"清河区","临西":"临西县","南宫":"南宫市","沙河":"沙河市","竞秀":"竞秀区","莲池":"莲池区","满城":"满城区","清苑":"清苑区","徐水":"徐水区","涞水":"涞水县","阜平":"阜平县","定兴":"定兴县","高阳":"高阳县","容城":"容城县","涞源":"涞源县","望都":"望都县","安新":"安新县","曲阳":"曲阳县","顺平":"顺平县","博野":"博野县","涿州":"涿州市","定州":"定州市","安国":"安国市","高碑店":"高碑店市","桥东":"