@fusioncharts/fusiontime
Version:
FusionCharts JavaScript time-series charting framework
1 lines • 5.06 kB
JavaScript
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.default=void 0;var _inheritsLoose2=_interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _componentInterface=require("@fusioncharts/core/src/component-interface");var _handle=_interopRequireDefault(require("./handle"));var _label=_interopRequireDefault(require("./label"));var _selection=_interopRequireDefault(require("./selection"));var Brush=function(_SmartRenderer){function Brush(){var _this;_this=_SmartRenderer.call(this)||this;_this._maxDimensions={};_this._currDimensions={};return _this}(0,_inheritsLoose2.default)(Brush,_SmartRenderer);var _proto=Brush.prototype;_proto.__setDefaultConfig=function __setDefaultConfig(obj){if(obj===void 0){obj={}}_SmartRenderer.prototype.__setDefaultConfig.call(this,obj);var config=this.config;config.handleWidth=12;config.handleHeight=20};_proto.configureAttributes=function configureAttributes(obj){if(obj===void 0){obj={}}_SmartRenderer.prototype.configureAttributes.call(this,obj);var brush=this;brush.config.style=obj.style;brush.createChildComponents()};_proto.setChildDimension=function setChildDimension(){var brush=this,selfConfig=brush.config,selection=brush.getChildren("selection")[0],leftHandle=brush.getChildren("leftHandle")[0],rightHandle=brush.getChildren("rightHandle")[0],leftLabel=brush.getChildren("leftLabel")[0],rightLabel=brush.getChildren("rightLabel")[0],currDimension=brush.getCurrentBrushDimensions(),startPx=currDimension.x,endPx=currDimension.x+currDimension.width;selection.setDimension({x:startPx,y:currDimension.y,width:currDimension.width,height:currDimension.height});leftHandle.setDimension({x:startPx-selfConfig.handleWidth,y:currDimension.y+currDimension.height/2-selfConfig.handleHeight/2,width:selfConfig.handleWidth,height:selfConfig.handleHeight});rightHandle.setDimension({x:endPx,y:currDimension.y+currDimension.height/2-selfConfig.handleHeight/2,width:selfConfig.handleWidth,height:selfConfig.handleHeight});leftLabel.setDimension({x:startPx,y:currDimension.y});rightLabel.setDimension({x:endPx,y:currDimension.y})};_proto.getLabelSpace=function getLabelSpace(){var brush=this,leftLabel=brush.getChildren("leftLabel")[0],rightLabel=brush.getChildren("rightLabel")[0];return Math.max(leftLabel.getLabelDimension().height,rightLabel.getLabelDimension().height)};_proto.draw=function draw(){var brush=this;brush.addGraphicalElement({el:"group",attr:{name:"brush-group"},id:"brushGroup",label:"brushGroup",component:brush,container:{id:"exo",label:"group",isParent:true}})};_proto.hideAllLabels=function hideAllLabels(){var brush=this,leftLabel=brush.getChildren("leftLabel")[0],rightLabel=brush.getChildren("rightLabel")[0];if(!brush.config.pointerReleasedOnParent){leftLabel.config.showLabel=rightLabel.config.showLabel=false;leftLabel.asyncDraw();rightLabel.asyncDraw()}};_proto.setBrushValue=function setBrushValue(value){var brush=this,leftLabel=brush.getChildren("leftLabel")[0],rightLabel=brush.getChildren("rightLabel")[0];leftLabel.setValue(value[0]);rightLabel.setValue(value[1])};_proto.createChildComponents=function createChildComponents(){var brush=this,brushConfig=brush.config,getStyleDef=brush.getFromEnv("getStyleDef"),leftHandle,rightHandle,leftLabel,rightLabel,selection;selection=brush.attachChild(_selection.default,"selection");selection.attachHandlers();selection.configure({orientation:"horizontal",style:{mask:getStyleDef(brushConfig.style.mask)}});leftHandle=brush.attachChild(_handle.default,"leftHandle");leftHandle.attachHandlers();leftHandle.configure({orientation:"horizontal",type:"leftHandle",style:{handle:getStyleDef(brushConfig.style.handle),"handle-grip":getStyleDef(brushConfig.style["handle-grip"])}});rightHandle=brush.attachChild(_handle.default,"rightHandle");rightHandle.attachHandlers();rightHandle.configure({orientation:"horizontal",type:"rightHandle",style:{handle:getStyleDef(brushConfig.style.handle),"handle-grip":getStyleDef(brushConfig.style["handle-grip"])}});leftLabel=brush.attachChild(_label.default,"leftLabel");leftLabel.attachHandlers();leftLabel.configure({orientation:"horizontal",type:"leftLabel",style:{label:getStyleDef(brushConfig.style.label),labelBg:getStyleDef(brushConfig.style["label-background"])}});rightLabel=brush.attachChild(_label.default,"rightLabel");rightLabel.attachHandlers();rightLabel.configure({orientation:"horizontal",type:"rightLabel",style:{label:getStyleDef(brushConfig.style.label),labelBg:getStyleDef(brushConfig.style["label-background"])}})};_proto.setMaxBrushDimensions=function setMaxBrushDimensions(dim){this._maxDimensions=dim};_proto.getMaxBrushDimensions=function getMaxBrushDimensions(){return this._maxDimensions};_proto.setCurrentBrushDimensions=function setCurrentBrushDimensions(dim){this._currDimensions=dim;this.setChildDimension()};_proto.getCurrentBrushDimensions=function getCurrentBrushDimensions(){return this._currDimensions};return Brush}(_componentInterface.SmartRenderer);var _default=exports.default=Brush;