-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdatart-dv.iife.js
1 lines (1 loc) · 36.8 KB
/
datart-dv.iife.js
1
(function(){"use strict";var t='<svg t="1648004031151" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2324" width="32" height="32"><path d="M921.6 870.4v102.4H102.4v-102.4h819.2zM1024 51.2v665.6H0V51.2h1024z m-102.4 102.4H102.4v460.8h819.2V153.6z" p-id="2325"></path></svg>';var e={line:{name:"折线图",option:{title:{text:"折线图",left:"center",show:false},tooltip:{trigger:"axis"},legend:{show:false},grid:{left:"5%",right:"5%",bottom:"8%",top:"20%",containLabel:true},xAxis:{type:"category",axisLine:{lineStyle:{color:"#eee"},show:true},data:[]},yAxis:{type:"value",axisLine:{lineStyle:{color:"#eee"},show:true},splitLine:{show:false}},series:[{type:"line",smooth:true}]}},bar:{name:"柱状图",option:{title:{text:"柱状图",left:"center",show:false},tooltip:{trigger:"axis"},legend:{show:false},grid:{left:"5%",right:"5%",bottom:"8%",top:"20%",containLabel:true},xAxis:{type:"category",axisLine:{lineStyle:{color:"#eee"},show:true},data:[]},yAxis:{type:"value",axisLine:{lineStyle:{color:"#eee"},show:true},splitLine:{show:false}},series:[{itemStyle:{color:{x:0,y:0,x2:0,y2:1,type:"linear",global:false,colorStops:[{offset:0,color:"#00BFFF"},{offset:1,color:"#54FF9F"}]}}}]}},pie:{name:"饼图",option:{title:{text:"饼图",show:false},tooltip:{trigger:"item"},legend:{show:false},series:[{name:"Access From",type:"pie",radius:"50%",data:[]}]}},scatter:{name:"散点图",option:{title:{text:"散点图",left:"center",show:false},xAxis:{},yAxis:{},series:[{symbolSize:20,data:[],type:"scatter"}]}},radar:{name:"雷达图",option:{title:{text:"雷达图",show:false},legend:{show:false},radar:{indicator:[{name:"Sales",max:6500},{name:"Administration",max:16e3},{name:"Information Technology",max:3e4},{name:"Customer Support",max:38e3},{name:"Development",max:52e3},{name:"Marketing",max:25e3}]},series:[{name:"Budget vs spending",type:"radar",data:[]}]}},gauge:{name:"仪表盘",option:{title:{text:"仪表盘",show:false},tooltip:{formatter:"{a} <br/>{b} : {c}%"},legend:{show:false},series:[{name:"Pressure",type:"gauge",progress:{show:true},detail:{formatter:"{value}"},data:[]}]}},map:{name:"地图",option:{title:{text:"地图",show:false},geo:{map:"china",zoom:1.2,label:{emphasis:{show:false}},roam:true,itemStyle:{normal:{areaColor:"#142957",borderColor:"#0692a4"},emphasis:{areaColor:"#0b1c2d"}}},series:[]},plugins:"https://oss.yzcstatic.com/static/datart/plugins/geoChina.js,https://oss.yzcstatic.com/static/datart/plugins/myMapSeries.js"},funnel:{name:"漏斗图",option:{title:{text:"漏斗图",show:false},tooltip:{trigger:"item",formatter:"{a} <br/>{b} : {c}%"},legend:{show:false},series:[{name:"Funnel",type:"funnel",left:"10%",top:60,bottom:60,width:"80%",min:0,max:100,minSize:"0%",maxSize:"100%",sort:"descending",gap:2,label:{show:true,position:"inside"},labelLine:{length:10,lineStyle:{width:1,type:"solid"}},itemStyle:{borderColor:"#fff",borderWidth:1},emphasis:{label:{fontSize:20}},data:[]}]}},liquidFill:{name:"水球图",option:{title:{text:"水球图",show:false},legend:{show:false},graphic:[{type:"group",left:"center",top:"25%",children:[{type:"text",z:100,left:"40",top:"middle",style:{fill:"#aab2fa",text:"统计标题",font:"30px Microsoft YaHei"}}]}],series:[{type:"liquidFill",radius:"98%",center:["50%","50%"],color:[{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"#446bf5"},{offset:1,color:"#2ca3e2"}],globalCoord:false}],data:[],backgroundStyle:{borderWidth:1,color:"RGBA(51, 66, 127, 0.7)"},label:{color:"#fff"},outline:{show:false,borderDistance:10,itemStyle:{borderWidth:2,borderColor:"#112165"}}}]},plugins:"https://oss.yzcstatic.com/static/datart/plugins/echarts-liquidfill.min.js"},progressPoll:{name:"进度池",option:{title:{text:"进度池",show:false},backgroundColor:"#071347",xAxis:[{show:false}],yAxis:[{axisTick:"none",axisLine:"none",offset:"2",axisLabel:{textStyle:{color:"#fff",fontSize:"14"}},data:[]},{axisTick:"none",axisLine:"none",axisLabel:{textStyle:{color:"#fff",fontSize:"14"}},data:[]},{nameTextStyle:{color:"#fff",fontSize:"14"},axisLine:{lineStyle:{color:"rgba(0,0,0,0)"}},data:[]}],series:[{name:"条",type:"bar",yAxisIndex:0,data:[],label:{normal:{show:false,position:"right",textStyle:{color:"#fff",fontSize:"12"}}},barWidth:10,itemStyle:{normal:{barBorderRadius:8,color:function(t){var e=myColor.length;return{type:"linear",x:0,y:0,x2:1,y2:1,colorStops:[{offset:0,color:"#0F1F45"},{offset:1,color:myColor[t.dataIndex%e]}]}}}},z:2,animation:true,animationEasing:"cubicOut"},{type:"scatter",yAxisIndex:0,symbol:"rect",symbolSize:[2,4],data:[],itemStyle:{normal:{barBorderRadius:50,borderColor:"#E2F2FF",color:"#E2F2FF"}},z:2},{name:"外框",type:"bar",yAxisIndex:2,data:[],barWidth:12,itemStyle:{normal:{barBorderRadius:8,color:"rgba(255,255,255,0.2)"}},z:0}]}},thermometer:{name:"温度计",option:`\n var warnTp=20;\n var option={\n backgroundColor: '#0C2F6F',\n title: {\n text: '温度计',\n show: false\n },\n yAxis: [{\n show: false,\n data: [],\n min: 0,\n max: 135,\n axisLine: {\n show: false\n }\n }, {\n show: false,\n min: 0,\n max: 50,\n }, {\n type: 'category',\n data: ['', '', '', '', '', '', '', '', '', '', '°C'],\n position: 'left',\n offset: -80,\n axisLabel: {\n fontSize: 10,\n color: 'white'\n },\n axisLine: {\n show: false\n },\n axisTick: {\n show: false\n },\n }],\n series: [{\n name: '条',\n type: 'bar',\n xAxisIndex: 0,\n data: [{\n label: {\n normal: {\n show: true,\n width: 200,\n height: 100,\n rich: {\n back: {\n align: 'center',\n lineHeight: 50,\n fontSize: 40,\n fontFamily: 'digifacewide',\n },\n unit: {\n fontFamily: '微软雅黑',\n fontSize: 15,\n lineHeight: 50,\n },\n downTxt: {\n lineHeight: 50,\n fontSize: 25,\n align: 'center',\n color: '#fff'\n }\n }\n }\n }\n }],\n barWidth: 18,\n itemStyle: {\n },\n z: 2\n }, {\n name: '白框',\n type: 'bar',\n xAxisIndex: 1,\n barGap: '-100%',\n data: [134],\n barWidth: 28,\n itemStyle: {\n normal: {\n color: '#0C2E6D',\n barBorderRadius: 50,\n }\n },\n z: 1\n }, {\n name: '外框',\n type: 'bar',\n xAxisIndex: 2,\n barGap: '-100%',\n data: [135],\n barWidth: 38,\n itemStyle: {\n normal: {\n color: '#4577BA',\n barBorderRadius: 50,\n }\n },\n z: 0\n }, {\n name: '圆',\n type: 'scatter',\n hoverAnimation: false,\n data: [0],\n xAxisIndex: 0,\n symbolSize: 48,\n itemStyle: {\n normal: {\n color: '#93FE94',\n opacity: 1,\n }\n },\n z: 2\n }, {\n name: '白圆',\n type: 'scatter',\n hoverAnimation: false,\n data: [0],\n xAxisIndex: 1,\n symbolSize: 60,\n itemStyle: {\n normal: {\n color: '#0C2E6D',\n opacity: 1,\n }\n },\n z: 1\n }, {\n name: '外圆',\n type: 'scatter',\n hoverAnimation: false,\n data: [0],\n xAxisIndex: 2,\n symbolSize: 70,\n itemStyle: {\n normal: {\n color: '#4577BA',\n opacity: 1,\n }\n },\n z: 0\n }, {\n name: '刻度',\n type: 'bar',\n yAxisIndex: 0,\n xAxisIndex: 3,\n label: {\n normal: {\n show: true,\n position: 'left',\n distance: 10,\n color: 'white',\n fontSize: 14,\n formatter: function (params) {\n if (params.dataIndex > 130 || params.dataIndex < 10) {\n return '';\n } else {\n if ((params.dataIndex - 10) % 20 === 0) {\n return params.dataIndex - 70;\n } else {\n return '';\n }\n }\n }\n }\n },\n barGap: '-100%',\n barWidth: 1,\n itemStyle: {\n normal: {\n color: 'white',\n barBorderRadius: 120,\n }\n },\n z: 0\n }]\n }`}};var o={datas:[{label:"dimension",key:"dimension",required:true,type:"group"},{label:"metrics",key:"metrics",required:true,type:"aggregate"},{label:"filter",key:"filter",type:"filter",allowSameField:true}],styles:[{label:"chart.title",key:"chart",comType:"group",expand:true,rows:[{label:"chart.type",key:"chartType",default:"",comType:"select",options:{getItems:()=>{const t=[{label:"选择图表",value:""}];Object.keys(e).map((o=>{t.push({label:e[o].name,value:o})}));return t}}},{label:"chart.plugins",key:"chartPlugins",default:"",comType:"input"},{label:"chart.autoToolTip",key:"autoToolTip",default:"",comType:"inputNumber",options:{placeholder:"自动播放时间(秒)"}},{label:"chart.edit",key:"chartEdit",default:"",comType:"input"}]},{label:"common.title",key:"delta",comType:"group",rows:[{label:"delta.richText",key:"richText",default:"",comType:"input"}]},{label:"border.title",key:"border",comType:"group",rows:[{label:"border.type",key:"borderType",default:"dv-border-box-1",comType:"select",options:{items:(()=>{var t=[{label:"无边框",value:""}];for(var e=1;e<=13;e++)t.push({label:"BorderBox"+e,value:"dv-border-box-"+e});return t})()}},{label:"border.color",key:"borderColor",comType:"input",default:'["#4fd2dd", "#235fa7"]'},{label:"border.backgroundColor",key:"borderBackgroundColor",comType:"fontColor",default:"rgba(0,0,0,.3)"}]},{label:"decorate.title",key:"decorate",comType:"group",rows:[{label:"decorate.type",key:"decorateType",default:"",comType:"select",options:{items:(()=>{var t=[{label:"无装饰",value:""}];for(var e=1;e<=12;e++)t.push({label:"装饰"+e,value:"dv-decoration-"+e});return t})()}},{label:"decorate.color",key:"decorateColor",comType:"input",default:'["#4fd2dd", "#235fa7"]'},{label:"decorate.size",key:"decorateSize",comType:"input",default:"200,40",options:{placeholder:"width,height"}},{label:"decorate.position",key:"decoratePosition",comType:"input",default:"",options:{placeholder:"top,right,bottom,left"}}]}],settings:[{label:"viz.palette.setting.paging.title",key:"paging",comType:"group",rows:[{label:"viz.palette.setting.paging.pageSize",key:"pageSize",default:1e3,comType:"inputNumber",options:{needRefresh:true,step:1,min:0}}]}],i18ns:[{lang:"zh-CN",translation:{chartName:"[Experiment] 大屏图表",common:{title:"富文本"},delta:{text:"内容"},code:{title:"代码配置",js:"js配置"},chart:{title:"图表设置",option:"自定义Option",type:"图表类型",plugins:"扩展脚本",autoToolTip:"自动播放"},border:{title:"边框设置",type:"边框类型",color:"边框颜色",backgroundColor:"边框背景色"},decorate:{title:"装饰设置",type:"装饰类型",color:"装饰颜色",position:"装饰位置",size:"尺寸"}}},{lang:"en-US",translation:{chartName:"[Experiment] 大屏图表",common:{showTitleAndUnit:"显示标题和刻度",nameGap:"标题与轴线距离",min:"最小值",max:"最大值"}}}]};var a={editOptionValue:"",init:function(t,e){this.editMode="edit";this.mcontext=e;this.env=t.widgetSpecialConfig?.env;const o=`\n .dv-chart-wrapper{width:100%;height:100%;position:relative;}\n .dv-editor-wrapper{margin-left:-50px;height:400px;width:calc(100% + 50px);box-shadow:0 0 10px rgba(0,0,0,.12)}\n .dv-editor-wrapper.max{position:fixed;left:50%;top:50%;background:#fff;width:50% !important;height:50% !important;}\n .dv-editor{width:100%;height:calc(100% - 20px)}\n .dv-editor-tools{background:#eee;width:100%;display:flex;align-items:center;justify-content: flex-end;padding-left: 10px;}\n .dv-editor-tools .btn {padding:5px 8px;}\n .dv-editor-wrapper.edit-mode{position:fixed;width:581px;top:145px;left:67px;z-index:200;height:calc(100% - 165px)}\n .btn-save{cursor:pointer; border: none;background: #67c23a;color: #fff;font-size:12px;}\n .btn-save:hover{background: #58b729;}\n .btn-format {font-size: 12px;color:#666;margin-right: 10px}\n .btn-format svg {width: 15px;height: 15px;color: #999;display: inline-block;vertical-align: middle;}\n .kLGcuu{padding-right:0 !important;}\n .ant-row.ant-form-item{flex-direction: row !important;margin-bottom:5px;}\n .datart-config-panel .ant-collapse-content > .ant-collapse-content-box{padding-top:0 !important;}\n .dv-opt-lnk{color:#1B9AEE;margin-right: auto;margin-left:20px;}\n .dv-opt-lnk:hover{text-direction:underline;}\n `;const a=`\n .dv-tip-wrapper {position: fixed;top:0;left:0;width:100%;padding: 8px 20px;transition: all .2s linear;transform: translateY(-100%);font-size: 14px;}\n .dv-tip-wrapper.error{color:#fff;background: rgba(245, 108, 108,.98);}\n .dv-tip-wrapper.on{transform: translateY(0);}\n `;this.addStyle(document.getElementsByTagName("head")[0],a,"dv-style");if("workbench"===this.env){this.addStyle(parent.document.getElementsByTagName("head")[0],o,"dv-chart-style");this.initView()}},initView(){if(parent.document.getElementById("btnSaveOption"))return;const t=this;const e=parent.document.querySelector('[data-layout-path="/ts1/t0"] div:nth-child(2)');let o=e.children;const a=o[2];const n=o[3];a.querySelectorAll(".ant-collapse-item")[1].style.display="none";if("false"===a.querySelectorAll(".ant-collapse-header")[0].getAttribute("aria-expanded")){a.querySelectorAll(".ant-collapse-header")[0].click();n.querySelectorAll(".ant-collapse-header")[0].click()}a.querySelectorAll(".chart-config-item-layout")[1].innerHTML=`<div class="ant-row ant-form-item sc-iCfMLu ejLifI" style="row-gap: 0px;"><div class="ant-col ant-form-item-label"><label class="ant-form-item-no-colon" title="扩展插件">扩展插件</label></div><div class="ant-col ant-form-item-control"><div class="ant-form-item-control-input"><div class="ant-form-item-control-input-content"><input type="text" placeholder="扩展插件JS路径,多个逗号隔开" class="ant-input datart-ant-input" id="chartPluginsInput" value="" style="font-size:12px;" /></div></div></div></div>`;a.querySelectorAll(".chart-config-item-layout")[3].querySelectorAll(".ant-form-item-control-input")[0].parentNode.parentNode.innerHTML='<div class="dv-editor-wrapper"><div class="dv-editor-tools"><a class="dv-opt-lnk" href="https://echarts.apache.org/zh/option.html#title" target="_blank">配置手册</a><a class="btn-format" id="btnMode" href="javascript:;"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"></path></svg><span class="txt">编辑模式</span></a><button class="btn btn-save" id="btnSaveOption">保存预览</button></div><div class="dv-editor" id="dv-option-edit"></div></div>';this.btnSaveOption=parent.document.getElementById("btnSaveOption");this.btnMode=parent.document.getElementById("btnMode");this.btnSaveOption.addEventListener("click",(function(){t.mcontext&&t.mcontext.saveCustomOption(t.editor.getValue())}));this.tabsets=parent.document.querySelectorAll(".flexlayout__tab");this.splitters=parent.document.querySelectorAll(".flexlayout__splitter");this.btnModeText=parent.document.querySelector("#btnMode .txt");this.editWrapper=parent.document.querySelector(".dv-editor-wrapper");this.tabsetWidth="256px";this.initLayoutView(false);this.btnMode.addEventListener("click",(function(){t.initLayoutView("normal"===t.editMode);setTimeout((function(){t.editor.resize()}))}))},initLayoutView(t){try{const{tabsets:e,splitters:o,btnModeText:a}=this;if(!t){this.removeClass(this.editWrapper,"edit-mode");e[0].style.width=this.tabsetWidth;e[1].style.left=this.tabsetWidth;e[1].style.width=616-parseInt(this.tabsetWidth)+"px";o[0].style.display="block";o[1].style.display="block";this.editMode="normal";a.innerHTML="编辑模式"}else{this.addClass(this.editWrapper,"edit-mode");this.tabsetWidth=e[0].style.width;e[0].style.width="0px";e[1].style.left="0px";e[1].style.width="616px";o[0].style.display="none";o[1].style.display="none";this.editMode="edit";a.innerHTML="标准模式"}}catch(t){}},initEditor:function(){if(this.editor)return;const t=parent.document.getElementById("dv-option-edit");this.editor=parent.window.ace.edit(t,{mode:"ace/mode/javascript",selectionStyle:"text"});this.editor.setOptions({tabSize:2})},setChartPlugins:function(t){parent.document.getElementById("chartPluginsInput").value=t},getChartPlugins:function(){return parent.document.getElementById("chartPluginsInput").value},setEditorValue:function(t){this.editor.setValue(t);this.beautifyCode()},beautifyCode:function(){var t=parent.window.ace.require("ace/ext/beautify");t.beautify(this.editor.session)},addClass:function(t,e){if(!t)return;if(!this.hasClass(t,e))t.className=""==t.className?e:t.className+" "+e},removeClass:function(t,e){if(!t)return;if(this.hasClass(t,e)){var o=" "+t.className.replace(/[\t\r\n]/g,"")+" ";while(o.indexOf(" "+e+" ")>=0)o=o.replace(" "+e+" "," ");t.className=o.replace(/^\s+|\s+$/g,"")}},hasClass:function(t,e){e=e||"";if(0==e.replace(/\s/g,"").length)return false;return new RegExp(" "+e+" ").test(" "+t.className+" ")},addStyle:function(t,e,o){if(parent.document.getElementById(o))return;const a=parent.document.createElement("style");a.id=o;a.appendChild(parent.document.createTextNode(e));t.appendChild(a)},removeStyle:function(t,e){const o=e.getElementById(t);o?.parentNode?.removeChild(o)},removeDataField:function(t,e="data"){const o=this;if(Array.isArray(t))t.forEach((function(t){o.removeDataField(t,e)}));else if("object"===typeof t)Object.getOwnPropertyNames(t).forEach((function(a){if(-1!==e.indexOf(a))delete t[a];else o.removeDataField(t[a],e)}));return t},formatPercent:function(t){const e=t+"";return e.length-(e.indexOf(".")+1)>2?t.toFixed(2):e},uuid:function(){const t=URL.createObjectURL(new Blob);const e=t.toString();URL.revokeObjectURL(t);return e.substr(e.lastIndexOf("/")+1)},isObject:function(t){return"[object Object]"===Object.prototype.toString.call(t)},isArray:function(t){return Array.isArray(t)},loadJs:function(t,e,o){return new Promise((a=>{if(o.getElementById(e))return a();const n=o.createElement("script");n.id=e;n.onload=()=>{a()};n.src=t;o.getElementsByTagName("head")[0].appendChild(n)}))},isPlainObject:function(t){return t?t.constructor===Object:false},each:function(t,e,o){if(t)return(Array.isArray(t)?this.arrayEach:this.objectEach)(t,e,o);return t},hasOwnProp:function(t,e){return t&&t.hasOwnProperty?t.hasOwnProperty(e):false},arrayEach:function(t,e,o){if(t)if(t.forEach)t.forEach(e,o);else for(var a=0,n=t.length;a<n;a++)e.call(o,t[a],a,t)},objectEach:function(t,e,o){if(t)for(var a in t)if(t&&t.hasOwnProperty?t.hasOwnProperty(a):false)e.call(o,t[a],a,t)},toRawType:function(t){const e=Object.prototype.toString;return e.call(t).slice(8,-1)},handleMerge:function(t,e){const o=this;if("Object"===this.toRawType(t)&&"Object"===this.toRawType(e)||Array.isArray(t)&&Array.isArray(e)){this.each(e,(function(e,a){t[a]=o.handleMerge(t[a],e)}));return t}return e},deepMerge:function(t){if(!t)t={};const e=arguments;const o=e.length;for(var a,n=1;n<o;n++){a=e[n];if(a)this.handleMerge(t,a)}return t},obj2str:function(t){if(!t)return"false";let e=[];if("string"==typeof t)return'"'+t.replace(/([\'\"\\])/g,"\\$1").replace(/(\n)/g,"\\n").replace(/(\r)/g,"\\r").replace(/(\t)/g,"\\t")+'"';if("object"==typeof t){if(!t.sort){for(var o in t)e.push(o+":"+this.obj2str(t[o]));if(!!document.all&&!/^\n?function\s*toString\(\)\s*\{\n?\s*\[native code\]\n?\s*\}\n?\s*$/.test(t.toString))e.push("toString:"+t.toString.toString());e="{"+e.join()+"}"}else{for(let o=0;o<t.length;o++)e.push(this.obj2str(t[o]));e="["+e.join()+"]"}return e}return t.toString()},adaptationDv:function(){const t=document.querySelector(".sc-dVNjXY ");const e=parseInt(t.style.width);const o=parseInt(t.style.height);const a=window.innerWidth;const n=window.innerHeight;let r,i,s;if(a/n>e/o){s=n/o;i=0;r=(a-e*s)/2}else{s=a/e;r=0;i=(n-o*s)/2}t.setAttribute("style",`transform:scale(${s});left:${r}px;top:${i}px;width:${e}px;height:${o}px`)}};if(location.search.indexOf("from=dv")>=0)setInterval((()=>{if(parent.document.querySelector(".dyVrIE")){parent.document.querySelector(".dyVrIE").style.display="none";parent.document.querySelector(".grid-background").style.background="#000";parent.document.querySelector(".grid-background").style.overflow="hidden";a.adaptationDv()}}));function n({dHelper:n}){return{config:o,useIFrame:true,isISOContainer:"dv-echarts",dependency:["https://oss.yzcstatic.com/static/vue/2.5/vue.min.js","https://oss.yzcstatic.com/static/datart/datav.min.vue.js","https://oss.yzcstatic.com/static/datart/echarts.min.js"],meta:{id:"dv-echarts",name:"大屏图表",icon:t,containerId:""},async onMount(t,o){if(!o.document)return;this.context=o;this.options=t;this.onReady=false;const r=t.config.styles;const{chartType:i,autoToolTip:s}=this.getChartStyle(r);const l=t.widgetSpecialConfig?.env;const[c]=n.getStyles(r,["delta"],["richText"]);const d=e[i]?e[i].option:"";this.currentChartType=i;this.defaultChartOption=e;this.autoToolTip=parseInt((s+"").replace("秒",""));this.env=l;if("workbench"===l){await a.loadJs("https://oss.yzcstatic.com/static/datart/src-min-noconflict/ace.js","ace",parent.document);await a.loadJs("https://oss.yzcstatic.com/static/datart/src-min-noconflict/ext-beautify.js","ace-ext-beautify",parent.document);a.init(t,o);a.initEditor();a.setEditorValue(c.option||`option=${a.obj2str(d)}`);setTimeout((()=>{a.beautifyCode()}),500);a.setChartPlugins(c.plugins||"")}if(this.autoToolTip>0)await a.loadJs("https://oss.yzcstatic.com/static/datart/echarts-auto-tooltip.js","echarts-auto-tooltip",parent.document);o.saveCustomOption=this.saveCustomOption.bind(this);this.initChartView(t,o);await this.loadChartPlugins(c.plugins||"");if(i){const t=this.getOptions(this.options.dataset,this.options.config);this.chart?.draw(Object.assign({},t),true);if(this.autoToolTip>0&&!this.loopToolTip)this.loopToolTip=parent.window.tools.loopShowTooltip(this.chart.$chart,t,{interval:1e3*this.autoToolTip,loopSeries:true})}},async onUpdated(t){const e=t.config.styles;const{chartType:o}=this.getChartStyle(e);this.options=t;this.env=t.widgetSpecialConfig?.env;if(!this.onReady)return;if(!this.isMatchRequirement(t.config))return;this.chart?.updateBorder(this.getBorder(e));this.chart?.updateDecorate(this.getDecorate(e));if(this.currentChartType!==o){if(!o){this.currentChartType=o;a.setEditorValue("");this.chartOption=null;this.chart?.$chart.clear();return}this.onReady=false;await this.loadChartPlugins(this.defaultChartOption[o].plugins||"");this.destoryVmOption().then((()=>{this.chart?.$chart.clear();this.currentChartType=o;this.chartOption=this.getOptions(t.dataset,t.config,true);let e=this.defaultChartOption[o].option;e="string"===typeof e?e:a.obj2str(e);let n=e.indexOf("option")<0?`option=${e}`:e;a.setEditorValue(n);this.chartOption.onChange({option:n,plugins:a.getChartPlugins()});this.chart?.draw(Object.assign({},this.chartOption),true)}))}else{this.chartOption=this.getOptions(t.dataset,t.config);this.chart.draw(Object.assign({},this.chartOption),true)}setTimeout((()=>{this.updated=false}),1e3)},onUnMount(){this.chart?.dispose();this.destoryVmOption();a.initLayoutView(false);a.editor=null},onResize(){this.chart?.$chart.resize()},initChartView(t,e){const o=this;const a=t.containerId;const n=e.document.createElement("div");const r=a+"-dv";n.id=r;e.document.getElementById(a).appendChild(n);const i=t.config.styles;const s=e.window.Vue;const l=this.getBorder(i);const c=this.getDecorate(i);this.chart=new s({el:e.document.getElementById(r),data:{tipMsg:"",borderStyle:l,decorate:c,options:t,chartOption:{},$chart:null,containerId:a},template:this.getTemplate(),mounted(){this.$chart=e.window.echarts.init(this.$refs.chart)},watch:{borderStyle:{handler(t,a){if("workbench"===o.env)setTimeout((()=>{this.$chart=e.window.echarts.init(this.$refs.chart);this.draw(o.chartOption)}),50)},immediate:false,deep:true}},computed:{decorateSize(){return this.decorate.decorateSize.split(",")},decoratePosition(){let t=this.decorate.decoratePosition.split(",");switch(t.length){case 0:return[0,0,0,0];case 1:return[t[0],0,0,0];case 2:return[t[0],t[1],0,0];case 3:return[t[0],t[1],t[2],0];case 4:return[t[0],t[1],t[2],t[3]]}},decorateStyle(){const{decoratePosition:t,decorateSize:e}=this;return{top:this.getPos(t[0]),right:this.getPos(t[1]),bottom:this.getPos(t[2]),left:this.getPos(t[3]),width:this.getPos(e[0]),height:this.getPos(e[1])}}},methods:{getPos(t){if("string"===typeof t)return t;return t+"px"},draw(t,e=true){if(!t)return;try{if(o.onReady)this.$chart.setOption(t,e)}catch(t){this.showTip(t+"");console.error(t);this.$chart.dispose()}},updateBorder(t){this.borderStyle=t},updateDecorate(t){this.decorate=t},dispose(){this.$chart?.dispose();this.$refs.dvWrapper&&this.$refs.dvWrapper.parentNode.removeChild(this.$refs.dvWrapper)},showTip(t,e={type:"error",duration:3e3}){this.tipDuration=e.duration;this.tipMsg=t;this.tipTimer&&clearTimeout(this.tipTimer);this.tipTimer=setTimeout((()=>{this.tipMsg=""}),this.tipDuration)},onTipMouseEnter(){this.tipTimer&&clearTimeout(this.tipTimer)},onTipMouseLeave(){this.tipTimer=setTimeout((()=>{this.tipMsg=""}),this.tipDuration)}}})},getOptions(t,e,o,r){const i=e.styles;const[s]=n.getStyles(i,["delta"],["richText"]);const l=e.datas||[];const c=l.filter((t=>"group"===t.type)).flatMap((t=>t.rows||[]));const d=l.filter((t=>"aggregate"===t.type)).flatMap((t=>t.rows||[]));const p=l.filter((t=>"info"===t.type)).flatMap((t=>t.rows||[]));const h=l.filter((t=>"size"===t.type)).flatMap((t=>t.rows||[]));const u=n.transformToDataSet(t.rows,t.columns,l);if(!this.currentChartType)return null;let m={};if(r)m=r;else if(s&&!o)m=this.getVmOption(s.option)||{};else{const{option:t,plugins:e}=this.defaultChartOption[this.currentChartType];if("string"===typeof t)m=this.getVmOption(t)||{};else m=JSON.parse(JSON.stringify(t));"workbench"===this.env&&a.setChartPlugins(e||"")}const f=d.map(((t,o)=>{const a={name:n.getColumnRenderName(t),color:e.color?.start,type:m.series&&m.series[o]&&m.series[o].type?m.series[o].type:this.currentChartType,data:u.map((e=>({...t,...this.getExtraSeriesRowData(e),...this.getExtraSeriesDataFormat(t?.format),value:e.getCell(t)}))),...this.getLabelStyle(i)};if("gauge"===this.currentChartType)a.detail=this.getGaugeDetail(i,d[0]);return a}));let g={tooltip:{trigger:"item",formatter:this.getTooltipFormmater(i,c,d,p,u)},legend:{data:f.map((t=>t?.name))||[]}};if("pie"===this.currentChartType)g.series=this.getPieSeries(i,u,c,d,p);else if("funnel"===this.currentChartType){const t=!c.length?u:u?.sort(((t,e)=>e?.getCell(d[0])-t?.getCell(d[0])));const e=!c.length?d?.sort(((t,e)=>u?.[0]?.getCell(e)-u?.[0]?.getCell(t))):d;Object.assign(g.tooltip,{trigger:"item"});g.series=this.getFunnelSeries(i,e,c,t,p)}else g.series=f;if("progressPoll"===this.currentChartType)g=this.getProgressOption(t,e);else if("thermometer"===this.currentChartType)g=this.getThermometerOption(t);else if("map"===this.currentChartType){const t=this.context.window.geoChina;this.context.window.geoChinaCity;this.isNormalGeoMap=false;this.geoMap=t;g=this.getMapOption(u,c,d,h,i,p)}if(!/^(progressPoll|thermometer|map)$/.test(this.currentChartType)&&m.xAxis)g.xAxis=this.getXAxis(i,c,u);return Object.assign({},a.deepMerge({},m,g),{...this.getOnChange()})},getXAxis(t,e,o){const a=e[0];return{type:"category",data:o.map((t=>t.getCell(a)))}},getOnChange(){return this.mouseEvents?.reduce(((t,e)=>{if("click"===e.name)Object.assign(t,{onChange:t=>{this.updated=true;e.callback?.({seriesName:"richText",value:t})}});return t}),{})},getPieSeries(t,e,o,a,r){if(!o?.length){const i=e?.[0];return[{...this.getBarSeiesImpl(t),data:a.map((t=>({...t,name:n.getColumnRenderName(t),value:[t].concat(r).map((t=>i?.getCell(t))),itemStyle:this.getDataItemStyle(t,o,i),...this.getExtraSeriesRowData(i),...this.getExtraSeriesDataFormat(t?.format)})))}]}const i=a.map((i=>({...this.getBarSeiesImpl(t),name:n.getColumnRenderName(i),data:e?.map((t=>({...i,name:o.map(t.getCell,t).join("-"),value:a.concat(r).map(t.getCell,t),itemStyle:this.getDataItemStyle(i,o,t),...this.getExtraSeriesRowData(t),...this.getExtraSeriesDataFormat(i?.format)})))})));return i},getFunnelSeries(t,e,o,a,r){if(!o.length){const i=a?.[0];const s=e.map((t=>({...t,value:[t].concat(r).map((t=>i?.getCell(t))),name:n.getColumnRenderName(t),itemStyle:this.getDataItemStyle(t,o,i),...this.getExtraSeriesRowData(i),...this.getExtraSeriesDataFormat(t?.format)})));return{type:"funnel",...this.getLabelStyle(t),labelLayout:{hideOverlap:true},data:this.getFunnelSeriesData(s)}}const i=e.flatMap((t=>{const n=a.map((a=>({...t,value:e.concat(r).map((t=>a?.getCell(t))),name:o.map((t=>a.getCell(t))).join("-"),itemStyle:this.getDataItemStyle(t,o,a),...this.getExtraSeriesRowData(a),...this.getExtraSeriesDataFormat(t?.format)})));return n}));const s={type:"funnel",...this.getLabelStyle(t),data:this.getFunnelSeriesData(i)};return s},getProgressOption(t,e){const o=e.datas||[];const a=n.transformToDataSet(t.rows,t.columns,o);const r=a.map((t=>({...this.getExtraSeriesRowData(t).rowData})));const i=[];const s=100;const l=[];const c=[];const d=["#eb2100","#eb3600","#d0570e","#d0a00e","#34da62","#00e9db","#00c0e9","#0096f3","#33CCFF","#469f4b","#96bfff","#604f70","#fb7293","#ff9f7f","#ffdb5c","#67e0e3","#32c5e9","#37a2da"];r.map((t=>{i.push(t.value);l.push(s);c.push(t.name)}));return{xAxis:[{show:false}],yAxis:[{data:c},{data:i},{data:[]}],series:[{name:"条",type:"bar",yAxisIndex:0,data:i,itemStyle:{normal:{color:function(t){const e=d.length;return{type:"linear",x:0,y:0,x2:1,y2:1,colorStops:[{offset:0,color:"#0F1F45"},{offset:1,color:d[t.dataIndex%e]}]}}}},z:2,animation:true,animationEasing:"cubicOut"},{type:"scatter",yAxisIndex:0,symbol:"rect",data:i,z:2},{name:"外框",type:"bar",yAxisIndex:2,data:l,z:0}]}},getThermometerOption(t){const e=t.rows&&t.rows[0]?t.rows[0][0]:0;const o=[];const a=[];let n="";let r="";const i=[65,0];let s="";const l=this.vmIframe?.contentWindow?.warnTp||20;for(let t=0,e=135;t<=e;t++)if(t<10||t>130)o.push("");else if((t-10)%20===0)o.push("-3");else if((t-10)%4===0)o.push("-1");else o.push("");if(e>l){s="温度偏高";a.push({offset:0,color:"#93FE94"},{offset:.5,color:"#E4D225"},{offset:1,color:"#E01F28"})}else if(e>-l){s="温度正常";a.push({offset:0,color:"#93FE94"},{offset:1,color:"#E4D225"})}else{s="温度偏低";a.push({offset:1,color:"#93FE94"})}if(e>62)r=62;else if(e<-60)r=-60;else r=e;if(e<-10)i=[65,-120];n=a[a.length-1].color;return{yAxis:[{data:[]},{},{type:"category",data:["","","","","","","","","","",""]}],xAxis:[{show:false,min:-10,max:80,data:[]},{show:false,min:-10,max:80,data:[]},{show:false,min:-10,max:80,data:[]},{show:false,min:-5,max:80}],series:[{name:"条",type:"bar",xAxisIndex:0,data:[{value:r+70,label:{normal:{position:i,formatter:"{back| "+e+" }{unit|°C}\n{downTxt|"+s+"}",rich:{back:{color:n},unit:{color:n},downTxt:{}}}}}],itemStyle:{normal:{color:new this.context.window.echarts.graphic.LinearGradient(0,1,0,0,a)}},z:2},{name:"白框",data:[134],type:"bar",z:1},{name:"外框",type:"bar",data:[135],xAxisIndex:2,z:0},{name:"圆",type:"scatter",data:[0],z:2},{name:"白圆",type:"scatter",data:[0],z:1},{name:"外圆",type:"scatter",data:[0],z:0},{name:"刻度",type:"bar",yAxisIndex:0,xAxisIndex:3,data:o,label:{normal:{formatter:function(t){if(t.dataIndex>130||t.dataIndex<10)return"";else if((t.dataIndex-10)%20===0)return t.dataIndex-70;else return""}}},z:0}]}},getMapOption(t,e,o,a,n,r){return{geo:{map:"china",zoom:1.2,label:{emphasis:{show:false}},roam:true,itemStyle:{normal:{areaColor:"#142957",borderColor:"#0692a4"},emphasis:{areaColor:"#0b1c2d"}}},series:[{type:"lines",zlevel:1,effect:{show:true,period:6,trailLength:.7,color:"#fff",symbolSize:3},lineStyle:{normal:{width:0,curveness:.2}}}]}},getFunnelSeriesData(t){const e=(e,o)=>{if(o){e.conversion=a.formatPercent(e.value?.[0]/t[o-1].value?.[0]*100);e.arrival=a.formatPercent(e.value?.[0]/t[0].value?.[0]*100)}return e};return t.map(e)},getBarSeiesImpl(t){return{type:"pie",...this.getLabelStyle(t)}},getExtraSeriesRowData(t){return{rowData:t?.convertToCaseSensitiveObject()}},getExtraSeriesDataFormat(t){return{format:t}},getDataItemStyle(t,e,o){const a=e?.[0];const n=t?.color?.start;if(a){const t=o?.getCell(a);const n=e[0]?.color?.colors?.find((e=>e.key===t));return{color:n?.value}}else if(n)return{color:n}},getTooltip(t,e){const[o,a]=n.getStyles(t,["gauge"],["prefix","suffix"]);return{formatter:({data:t})=>`${t.name} : ${o}${toFormattedValue(t.value,e[0].format)}${a}`}},getTooltipFormmater(t,e,o,a,r){return t=>{let i=Array.isArray(t)?t[0]:t;if("series"!==i.componentType)return i.name;const{data:s,value:l,percent:c,seriesName:d,seriesType:p}=i;if(/^(gauge)$/.test(p))return`${s.name||d} :${n.toFormattedValue(s.value,o[0].format)}`;if(!e?.length){const t=[s].concat(a).map(((t,e)=>n.valueFormatter(t,l?.[e])));t[0]+="("+c+"%)";return t.join("<br />")}a.map((t=>{let e=0;r.forEach((o=>{e+=Number(o.getCell(t))}));return e}));let h=[];if(/^(bar|line|scatter)$/.test(p)){const t=i?.data?.name||i?.seriesName;const a=i?.data?.rowData||{};h=[].concat(e||[]).concat(o.filter((e=>n.getColumnRenderName(e)===t))||[]).map((t=>n.valueFormatter(t,a?.[r.getFieldOriginKey(t)])))}else{const{data:r}=t;h=!!e?.length?[`${e?.map((t=>n.getColumnRenderName(t))).join("-")}: ${t?.name}`]:[];const i=!!e?.length?this.getSeriesTooltips4Scatter([t],o.concat(a)):this.getSeriesTooltips4Scatter([t],[r].concat(a));h=h.concat(i)}return h.join("<br />")}},getSeriesTooltips4Scatter(t,e,o){const a=t?.[0]?.value;return e.map(((t,e)=>n.valueFormatter(t,a?.[!!o?o+e:e])))},getLabelStyle(t){const e=this.getLabelFormatter(t);return{label:{formatter:e},labelLayout:{hideOverlap:true}}},getLabelFormatter(t){return t=>{const{name:e,value:o,percent:a,data:r}=t;const i=n.toFormattedValue(Array.isArray(o)?o?.[0]:o,r.format);const s=[];const l=e?`${e}: ${i}`:i;s.push(l);return s.join("\n")}},getGaugeDetail(t,e){return{formatter:t=>`${n.toFormattedValue(t||0,e.format)}`}},getChartStyle(t){const[e,o,a]=n.getStyles(t,["chart"],["chartType","chartPlugins","autoToolTip"]);return{chartType:e,chartPlugins:o,autoToolTip:a}},getBorder(t){const[e,o,a]=n.getStyles(t,["border"],["borderType","borderColor","borderBackgroundColor"]);return{borderType:e,borderColor:o?JSON.parse(o):[],borderBackgroundColor:a}},getDecorate(t){const[e,o,a,r]=n.getStyles(t,["decorate"],["decorateType","decorateColor","decorateSize","decoratePosition"]);return{decorateType:e,decorateColor:o?JSON.parse(o):[],decorateSize:a,decoratePosition:r}},removeDataField(t){if("thermometer"===this.currentChartType)return t;return a.removeDataField(t)},saveCustomOption(t){try{const{options:e}=this;const o=this.removeDataField(this.getVmOption(t));const n=this.getOptions(e.dataset,e.config,false,o);const r=a.getChartPlugins();a.beautifyCode();n.onChange({option:t.replace(/\r|\n/gm,""),plugins:r});this.chartOption=n;this.autoToolTip=this.getChartStyle();console.log(this.chartOption,JSON.stringify(this.chartOption))}catch(t){console.error(t,"===e");this.chart.showTip(t+"")}},destoryVmOption(){return new Promise((t=>{const e=this.vmIframe;if(!e)return t();e.src="javascript:void(0)";try{e?.contentWindow?.document.write("");e?.contentWindow?.document.clear()}catch(e){t();console.error(e,"--")}setTimeout((()=>{e?.parentNode?.removeChild(e);t()}),10)}))},getVmOption(t){let e=this.context.document.getElementById("dvVmOptionIframe");if(!e){e=this.context.document.createElement("iframe");e.id="dvVmOptionIframe";e.style.display="none";this.context.document.body.appendChild(e)}e.contentWindow.dataset=this.options.dataset;e.contentWindow.echarts=window.echarts;e.contentWindow.myChart=this.chart?.$chart;e.contentWindow.tools=this.context.window.tools;e.contentWindow.eval(t.indexOf("option")<0?`option=${t}`:t);this.vmIframe=e;return e.contentWindow.option},async loadChartPlugins(t){if(!t){this.onReady=true;return}const e=t.split(",");const{document:o}=this.context;for(let t=0,n=e.length;t<n;t++)await a.loadJs(e[t],e[t].split("/").pop().replace(".js",""),o);this.onReady=true},getTemplate(){return`\n <div ref="dvWrapper" class="dv-chart-wrapper">\n <compnent :is="borderStyle.borderType" :color="borderStyle.borderColor" :backgroundColor="borderStyle.borderBackgroundColor" v-if="borderStyle.borderType">\n <div id="dv-chart" ref="chart" style="width:100%;height:100%"></div>\n </compnent>\n <div id="dv-chart" ref="chart" style="width:100%;height:100%" v-else></div>\n <compnent :is="decorate.decorateType" :color="decorate.decorateColor" v-if="decorate.decorateType" class="dv-decorate" :style="decorateStyle" style="position:absolute;z-index:2"></compnent>\n <div class="dv-tip-wrapper error" ref="dvTipWrapper" :class="[tipMsg?'on':'']" @mouseenter="onTipMouseEnter" @mouseleave="onTipMouseLeave">{{tipMsg}}</div>\n </div>\n `}}}return n})();