text: !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Slider=e():t.Slider=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var a=i[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var i={};return e.m=t,e.c=i,e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,i){var n=i(1);window&&!window.G2&&console.err("Please load the G2 script first!"),t.exports=n},function(t,e,i){var n=i(2),a=window&&window.G2,s=a.Chart,r=a.Util,h=a.G,o=a.Global,l=h.Canvas,d=r.DomUtil,g=function(t){return"number"==typeof t},u=function(){function t(t){this._initProps(),r.deepMix(this,t);var e=this.container;if(!e)throw new Error("Please specify the container for the Slider!");r.isString(e)?this.domContainer=document.getElementById(e):this.domContainer=e,this.handleStyle=r.mix({width:this.height,height:this.height},this.handleStyle),"auto"===this.width&&window.addEventListener("resize",r.wrapBehavior(this,"_initForceFitEvent"))}var e=t.prototype;return e._initProps=function(){this.height=26,this.width="auto",this.padding=o.plotCfg.padding,this.container=null,this.xAxis=null,this.yAxis=null,this.fillerStyle={fill:"#BDCCED",fillOpacity:.3},this.backgroundStyle={stroke:"#CCD6EC",fill:"#CCD6EC",fillOpacity:.3,lineWidth:1},this.range=[0,100],this.layout="horizontal",this.textStyle={fill:"#545454"},this.handleStyle={img:"https://gw.alipayobjects.com/zos/rmsportal/QXtfhORGlDuRvLXFzpsQ.png",width:5},this.backgroundChart={type:["area"],color:"#CCD6EC"}},e._initForceFitEvent=function(){var t=setTimeout(r.wrapBehavior(this,"forceFit"),200);clearTimeout(this.resizeTimer),this.resizeTimer=t},e.forceFit=function(){if(this&&!this.destroyed){var t=d.getWidth(this.domContainer),e=this.height;if(t!==this.domWidth){var i=this.canvas;i.changeSize(t,e),this.bgChart&&this.bgChart.changeWidth(t),i.clear(),this._initWidth(),this._initSlider(),this._bindEvent(),i.draw()}}},e._initWidth=function(){var t;t="auto"===this.width?d.getWidth(this.domContainer):this.width,this.domWidth=t;var e=r.toAllPadding(this.padding);"horizontal"===this.layout?(this.plotWidth=t-e[1]-e[3],this.plotPadding=e[3],this.plotHeight=this.height):"vertical"===this.layout&&(this.plotWidth=this.width,this.plotHeight=this.height-e[0]-e[2],this.plotPadding=e[0])},e.render=function(){this._initWidth(),this._initCanvas(),this._initBackground(),this._initSlider(),this._bindEvent(),this.canvas.draw()},e.changeData=function(t){this.data=t,this.repaint()},e.destroy=function(){clearTimeout(this.resizeTimer),this.rangeElement.off("sliderchange"),this.bgChart&&this.bgChart.destroy(),this.canvas.destroy();for(var t=this.domContainer;t.hasChildNodes();)t.removeChild(t.firstChild);window.removeEventListener("resize",r.getWrapBehavior(this,"_initForceFitEvent")),this.destroyed=!0},e.clear=function(){this.canvas.clear(),this.bgChart&&this.bgChart.destroy(),this.bgChart=null,this.scale=null,this.canvas.draw()},e.repaint=function(){this.clear(),this.render()},e._initCanvas=function(){var t=this.domWidth,e=this.height,i=new l({width:t,height:e,containerDOM:this.domContainer,capture:!1}),n=i.get("el");n.style.position="absolute",n.style.top=0,n.style.left=0,n.style.zIndex=3,this.canvas=i},e._initBackground=function(){var t,e=this.data,i=this.xAxis,n=this.yAxis,a=r.deepMix((t={},t[""+i]={range:[0,1]},t),this.scales);if(!e)throw new Error("Please specify the data!");if(!i)throw new Error("Please specify the xAxis!");if(!n)throw new Error("Please specify the yAxis!");var h=this.backgroundChart,o=h.type,l=h.color;r.isArray(o)||(o=[o]);var d=r.toAllPadding(this.padding),g=new s({container:this.container,width:this.domWidth,height:this.height,padding:[0,d[1],0,d[3]],animate:!1});g.source(e),g.scale(a),g.axis(!1),g.tooltip(!1),g.legend(!1),r.each(o,function(t){g[t]().position(i+"*"+n).color(l).opacity(1)}),g.render(),this.bgChart=g,this.scale="horizontal"===this.layout?g.getXScale():g.getYScales()[0],"vertical"===this.layout&&g.destroy()},e._initRange=function(){var t=this.startRadio,e=this.endRadio,i=this.start,n=this.end,a=this.scale,s=0,r=1;g(t)?s=t:i&&(s=a.scale(a.translate(i))),g(e)?r=e:n&&(r=a.scale(a.translate(n)));var h=this.minSpan,o=this.maxSpan,l=0;if("time"===a.type||"timeCat"===a.type){var d=a.values,u=d[0];l=d[d.length-1]-u}else a.isLinear&&(l=a.max-a.min);l&&h&&(this.minRange=h/l*100),l&&o&&(this.maxRange=o/l*100);var c=[100*s,100*r];return this.range=c,c},e._getHandleValue=function(t){var e=this.range,i=e[0]/100,n=e[1]/100,a=this.scale;return"min"===t?this.start?this.start:a.invert(i):this.end?this.end:a.invert(n)},e._initSlider=function(){var t=this.canvas,e=this._initRange(),i=this.scale,a=t.addGroup(n,{middleAttr:this.fillerStyle,range:e,minRange:this.minRange,maxRange:this.maxRange,layout:this.layout,width:this.plotWidth,height:this.plotHeight,backgroundStyle:this.backgroundStyle,textStyle:this.textStyle,handleStyle:this.handleStyle,minText:i.getText(this._getHandleValue("min")),maxText:i.getText(this._getHandleValue("max"))});"horizontal"===this.layout?a.translate(this.plotPadding,0):"vertical"===this.layout&&a.translate(0,this.plotPadding),this.rangeElement=a},e._bindEvent=function(){var t=this;t.rangeElement.on("sliderchange",function(e){var i=e.range,n=i[0]/100,a=i[1]/100;t._updateElement(n,a)})},e._updateElement=function(t,e){var i=this.scale,n=this.rangeElement,a=n.get("minTextElement"),s=n.get("maxTextElement"),r=i.invert(t),h=i.invert(e),o=i.getText(r),l=i.getText(h);a.attr("text",o),s.attr("text",l),this.start=r,this.end=h,this.onChange&&this.onChange({startText:o,endText:l,startValue:r,endValue:h,startRadio:t,endRadio:e})},t}();t.exports=u},function(t,e){function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var n=window&&window.G2,a=n.Util,s=n.G.Group,r=a.DomUtil,h=function(t){function e(){return t.apply(this,arguments)||this}i(e,t);var n=e.prototype;return n.getDefaultCfg=function(){return{range:null,middleAttr:null,backgroundElement:null,minHandleElement:null,maxHandleElement:null,middleHandleElement:null,currentTarget:null,layout:"vertical",width:null,height:null,pageX:null,pageY:null}},n._initHandle=function(t){var e,i,n,s=this.addGroup(),r=this.get("layout"),h=this.get("handleStyle"),o=h.img,l=h.width,d=h.height;if("horizontal"===r){var g=h.width;n="ew-resize",i=s.addShape("Image",{attrs:{x:-g/2,y:0,width:g,height:d,img:o,cursor:n}}),e=s.addShape("Text",{attrs:a.mix({x:"min"===t?-(g/2+5):g/2+5,y:d/2,textAlign:"min"===t?"end":"start",textBaseline:"middle",text:"min"===t?this.get("minText"):this.get("maxText"),cursor:n},this.get("textStyle"))})}else n="ns-resize",i=s.addShape("Image",{attrs:{x:0,y:-d/2,width:l,height:d,img:o,cursor:n}}),e=s.addShape("Text",{attrs:a.mix({x:l/2,y:"min"===t?d/2+5:-(d/2+5),textAlign:"center",textBaseline:"middle",text:"min"===t?this.get("minText"):this.get("maxText"),cursor:n},this.get("textStyle"))});return this.set(t+"TextElement",e),this.set(t+"IconElement",i),s},n._initSliderBackground=function(){var t=this.addGroup();return t.initTransform(),t.translate(0,0),t.addShape("Rect",{attrs:a.mix({x:0,y:0,width:this.get("width"),height:this.get("height")},this.get("backgroundStyle"))}),t},n._beforeRenderUI=function(){var t=this._initSliderBackground(),e=this._initHandle("min"),i=this._initHandle("max"),n=this.addShape("rect",{attrs:this.get("middleAttr")});this.set("middleHandleElement",n),this.set("minHandleElement",e),this.set("maxHandleElement",i),this.set("backgroundElement",t),t.set("zIndex",0),n.set("zIndex",1),e.set("zIndex",2),i.set("zIndex",2),n.attr("cursor","move"),this.sort()},n._renderUI=function(){"horizontal"===this.get("layout")?this._renderHorizontal():this._renderVertical()},n._transform=function(t){var e=this.get("range"),i=e[0]/100,n=e[1]/100,a=this.get("width"),s=this.get("height"),r=this.get("minHandleElement"),h=this.get("maxHandleElement"),o=this.get("middleHandleElement");r.resetMatrix?(r.resetMatrix(),h.resetMatrix()):(r.initTransform(),h.initTransform()),"horizontal"===t?(o.attr({x:a*i,y:0,width:(n-i)*a,height:s}),r.translate(i*a,0),h.translate(n*a,0)):(o.attr({x:0,y:s*(1-n),width:a,height:(n-i)*s}),r.translate(0,(1-i)*s),h.translate(0,(1-n)*s))},n._renderHorizontal=function(){this._transform("horizontal")},n._renderVertical=function(){this._transform("vertical")},n._bindUI=function(){this.on("mousedown",a.wrapBehavior(this,"_onMouseDown"))},n._isElement=function(t,e){var i=this.get(e);return t===i||!!i.isGroup&&i.get("children").indexOf(t)>-1},n._getRange=function(t,e){var i=t+e;return i=i>100?100:i,i=i<0?0:i},n._limitRange=function(t,e,i){i[0]=this._getRange(t,i[0]),i[1]=i[0]+e,i[1]>100&&(i[1]=100,i[0]=i[1]-e)},n._updateStatus=function(t,e){var i="x"===t?this.get("width"):this.get("height");t=a.upperFirst(t);var n,s=this.get("range"),r=this.get("page"+t),h=this.get("currentTarget"),o=this.get("rangeStash"),l="vertical"===this.get("layout")?-1:1,d=e["page"+t],g=(d-r)/i*100*l,u=this.get("minRange"),c=this.get("maxRange");s[1]<=s[0]?(this._isElement(h,"minHandleElement")||this._isElement(h,"maxHandleElement"))&&(s[0]=this._getRange(g,s[0]),s[1]=this._getRange(g,s[0])):(this._isElement(h,"minHandleElement")&&(s[0]=this._getRange(g,s[0]),u&&s[1]-s[0]<=u&&this._limitRange(g,u,s),c&&s[1]-s[0]>=c&&this._limitRange(g,c,s)),this._isElement(h,"maxHandleElement")&&(s[1]=this._getRange(g,s[1]),u&&s[1]-s[0]<=u&&this._limitRange(g,u,s),c&&s[1]-s[0]>=c&&this._limitRange(g,c,s))),this._isElement(h,"middleHandleElement")&&(n=o[1]-o[0],this._limitRange(g,n,s)),this.emit("sliderchange",{range:s}),this.set("page"+t,d),this._renderUI(),this.get("canvas").draw()},n._onMouseDown=function(t){var e=t.currentTarget,i=t.event,n=this.get("range");i.stopPropagation(),i.preventDefault(),this.set("pageX",i.pageX),this.set("pageY",i.pageY),this.set("currentTarget",e),this.set("rangeStash",[n[0],n[1]]),this._bindCanvasEvents()},n._bindCanvasEvents=function(){var t=this.get("canvas").get("containerDOM");this.onMouseMoveListener=r.addEventListener(t,"mousemove",a.wrapBehavior(this,"_onCanvasMouseMove")),this.onMouseUpListener=r.addEventListener(t,"mouseup",a.wrapBehavior(this,"_onCanvasMouseUp")),this.onMouseLeaveListener=r.addEventListener(t,"mouseleave",a.wrapBehavior(this,"_onCanvasMouseUp"))},n._onCanvasMouseMove=function(t){"horizontal"===this.get("layout")?this._updateStatus("x",t):this._updateStatus("y",t)},n._onCanvasMouseUp=function(){this._removeDocumentEvents()},n._removeDocumentEvents=function(){this.onMouseMoveListener.remove(),this.onMouseUpListener.remove(),this.onMouseLeaveListener.remove()},e}(s);t.exports=h}])});