-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdatart-zrender.iife.js
1 lines (1 loc) · 3.06 KB
/
datart-zrender.iife.js
1
(function(){"use strict";function t({dHelper:t}){return{config:{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},{label:"colorize",key:"color",type:"color"}],styles:[{label:"label.title",key:"label",comType:"group",rows:[{label:"label.text",key:"text",default:"datart",comType:"input"},{label:"label.fontLeft",key:"fontL",comType:"font",default:{fontFamily:"Lato",fontSize:200,fontWeight:"bolder",fontStyle:"normal",color:"#0ff"}},{label:"label.fontRight",key:"fontR",comType:"font",default:{fontFamily:"Lato",fontSize:200,fontWeight:"bolder",fontStyle:"normal",color:"#f0f"}}]}],i18ns:[{lang:"zh-CN",translation:{label:{title:"标签",text:"文本",fontLeft:"主字体",fontRight:"副字体"}}}]},isISOContainer:"experiment-zrender-chart",dependency:["https://ecomfe.github.io/zrender-doc/public/lib/js/zrender.min.js"],meta:{id:"experiment-zrender-chart",name:"[Experiment] ZRender Chart",icon:"chart",requirements:[{group:null,aggregate:null}]},onMount(t,e){if(void 0===t.containerId||!e.document)return;const{zrender:n}=e.window;if(!n)return;this.chart=n.init(e.document.getElementById(t.containerId));this.mouseEvents.forEach((t=>{this.chart.on(t.name,t.callback)}))},onUpdated(t,e){if(!t.dataset||!t.dataset.columns||!t.config)return;if(!this.isMatchRequirement(t.config)){this.chart.clear();return}this.draw(e,t.config.styles)},onUnMount(){this.chart&&this.chart.dispose()},onResize(t,e){this.draw(e,t?.config?.styles)},draw(t,e){const{text:n,fontL:i,fontR:o}=this.getText(e);const{zrender:r}=t.window;const a=this.chart;var l=t.width||a.getWidth();var f=t.height||a.getHeight();a.clear();a.resize({width:l,height:f});var h=new r.Rect({style:{fill:"#333"},shape:{width:l,height:f}});a.add(h);var d=new r.Text({style:{text:n,textAlign:"center",textVerticalAlign:"middle",fontSize:i.fontSize,fontFamily:i.fontFamily,fontWeight:i.fontWight,textFill:i.color,blend:"lighten"},position:[l/2+5,f/2]});a.add(d);var s=new r.Text({style:{text:n,textAlign:"center",textVerticalAlign:"middle",fontSize:o.fontSize,fontFamily:o.fontFamily,fontWeight:o.fontWight,textFill:o.color,blend:"lighten"},position:[l/2,f/2]});a.add(s);var c=[];for(var m=0;m<16;++m){var g=new r.Rect({shape:{x:l*(Math.random()-.3),y:f*Math.random(),width:l*(Math.random()+.3),height:8*Math.random()},style:{fill:["#ff0","#f0f","#0ff","#00f"][Math.floor(4*Math.random())],blend:"lighten",opacity:0}});a.add(g);c.push(g)}if(this.timerId)t.window.clearInterval(this.timerId);this.timerId=setInterval((function(){if(Math.random()>.2){s.attr("position",[l/2+50*Math.random(),f/2]);for(var t=0;t<c.length;++t){c[t].attr("shape",{x:l*Math.random(),y:f*Math.random(),width:l*Math.random(),height:8*Math.random()});c[t].attr("style",{opacity:1})}setTimeout((function(){s.attr("position",[l/2,f/2]);for(var t=0;t<c.length;++t)c[t].attr("style",{opacity:0})}),100)}}),500)},getText(e){if(e){const[n,i,o]=t.getStyles(e,["label"],["text","fontL","fontR"]);this.textObj={text:n,fontL:i,fontR:o}}return this.textObj}}}return t})();