UNPKG

basb-cli

Version:
2 lines (1 loc) 4.5 kB
import{_ as t,G as e,ae as r,af as o,ag as i,ah as a,ai as s,o as n,aj as p,C as l,c as f,S as c}from"./index.js";import{S as u}from"./SymbolDraw.js";import{S as h}from"./Symbol.js";import{p as y}from"./points.js";import"./labelHelper.js";function m(t,e){var r=e.rippleEffectColor||e.color;t.eachChild((function(t){t.attr({z:e.z,zlevel:e.zlevel,style:{stroke:"stroke"===e.brushType?r:null,fill:"fill"===e.brushType?r:null}})}))}var d=function(p){function l(t,r){var o=p.call(this)||this,i=new h(t,r),a=new e;return o.add(i),o.add(a),o.updateData(t,r),o}return t(l,p),l.prototype.stopEffectAnimation=function(){this.childAt(1).removeAll()},l.prototype.startEffectAnimation=function(t){for(var e=t.symbolType,o=t.color,i=t.rippleNumber,a=this.childAt(1),s=0;s<i;s++){var n=r(e,-1,-1,2,2,o);n.attr({style:{strokeNoScale:!0},z2:99,silent:!0,scaleX:.5,scaleY:.5});var p=-s/i*t.period+t.effectOffset;n.animate("",!0).when(t.period,{scaleX:t.rippleScale/2,scaleY:t.rippleScale/2}).delay(p).start(),n.animateStyle(!0).when(t.period,{opacity:0}).delay(p).start(),a.add(n)}m(a,t)},l.prototype.updateEffectAnimation=function(t){for(var e=this._effectCfg,r=this.childAt(1),o=["symbolType","period","rippleScale","rippleNumber"],i=0;i<o.length;i++){var a=o[i];if(e[a]!==t[a])return this.stopEffectAnimation(),void this.startEffectAnimation(t)}m(r,t)},l.prototype.highlight=function(){o(this)},l.prototype.downplay=function(){i(this)},l.prototype.getSymbolType=function(){var t=this.childAt(0);return t&&t.getSymbolType()},l.prototype.updateData=function(t,e){var r=this,o=t.hostModel;this.childAt(0).updateData(t,e);var i=this.childAt(1),p=t.getItemModel(e),l=t.getItemVisual(e,"symbol"),f=a(t.getItemVisual(e,"symbolSize")),c=t.getItemVisual(e,"style"),u=c&&c.fill,h=p.getModel("emphasis");i.setScale(f),i.traverse((function(t){t.setStyle("fill",u)}));var y=s(t.getItemVisual(e,"symbolOffset"),f);y&&(i.x=y[0],i.y=y[1]);var m=t.getItemVisual(e,"symbolRotate");i.rotation=(m||0)*Math.PI/180||0;var d={};d.showEffectOn=o.get("showEffectOn"),d.rippleScale=p.get(["rippleEffect","scale"]),d.brushType=p.get(["rippleEffect","brushType"]),d.period=1e3*p.get(["rippleEffect","period"]),d.effectOffset=e/t.count(),d.z=o.getShallow("z")||0,d.zlevel=o.getShallow("zlevel")||0,d.symbolType=l,d.color=u,d.rippleEffectColor=p.get(["rippleEffect","color"]),d.rippleNumber=p.get(["rippleEffect","number"]),"render"===d.showEffectOn?(this._effectCfg?this.updateEffectAnimation(d):this.startEffectAnimation(d),this._effectCfg=d):(this._effectCfg=null,this.stopEffectAnimation(),this.onHoverStateChange=function(t){"emphasis"===t?"render"!==d.showEffectOn&&r.startEffectAnimation(d):"normal"===t&&"render"!==d.showEffectOn&&r.stopEffectAnimation()}),this._effectCfg=d,n(this,h.get("focus"),h.get("blurScope"),h.get("disabled"))},l.prototype.fadeOut=function(t){t&&t()},l}(e),g=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=r.type,t}return t(r,e),r.prototype.init=function(){this._symbolDraw=new u(d)},r.prototype.render=function(t,e,r){var o=t.getData(),i=this._symbolDraw;i.updateData(o,{clipShape:this._getClipShape(t)}),this.group.add(i.group)},r.prototype._getClipShape=function(t){var e=t.coordinateSystem,r=e&&e.getArea&&e.getArea();return t.get("clip",!0)?r:null},r.prototype.updateTransform=function(t,e,r){var o=t.getData();this.group.dirty();var i=y("").reset(t,e,r);i.progress&&i.progress({start:0,end:o.count(),count:o.count()},o),this._symbolDraw.updateLayout()},r.prototype._updateGroupTransform=function(t){var e=t.coordinateSystem;e&&e.getRoamTransform&&(this.group.transform=p(e.getRoamTransform()),this.group.decomposeTransform())},r.prototype.remove=function(t,e){this._symbolDraw&&this._symbolDraw.remove(!0)},r.type="effectScatter",r}(l),v=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=r.type,t.hasSymbolVisual=!0,t}return t(r,e),r.prototype.getInitialData=function(t,e){return f(null,this,{useEncodeDefaulter:!0})},r.prototype.brushSelector=function(t,e,r){return r.point(e.getItemLayout(t))},r.type="series.effectScatter",r.dependencies=["grid","polar"],r.defaultOption={coordinateSystem:"cartesian2d",z:2,legendHoverLink:!0,effectType:"ripple",progressive:0,showEffectOn:"render",clip:!0,rippleEffect:{period:4,scale:2.5,brushType:"fill",number:3},universalTransition:{divideShape:"clone"},symbolSize:10},r}(c);function S(t){t.registerChartView(g),t.registerSeriesModel(v),t.registerLayout(y("effectScatter"))}export{S as install};