UNPKG

@fusioncharts/core

Version:

JavaScript Data Visualisation Library

1 lines 7.22 kB
"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 _lib=require("../../../lib");var _equal=_interopRequireDefault(require("@fusioncharts/utils/src/string/equal"));var _tool=_interopRequireDefault(require("../tool"));var _scrollTrack=_interopRequireDefault(require("./scroll-track"));var _scrollAnchor=_interopRequireDefault(require("./scroll-anchor"));var _scrollButton=_interopRequireDefault(require("./scroll-button"));var _helper=require("../helper");var UNDEF;var ScrollBar=function(_Tool){function ScrollBar(){return _Tool.apply(this,arguments)||this}(0,_inheritsLoose2.default)(ScrollBar,_Tool);var _proto=ScrollBar.prototype;_proto.__setDefaultConfig=function __setDefaultConfig(){_Tool.prototype.__setDefaultConfig.call(this);this.config.scale=1};_proto.configureAttributes=function configureAttributes(options){if(options===void 0){options={}}_Tool.prototype.configureAttributes.call(this,options);var selfConfig=this.config,chartAttrs=this.getFromEnv("chart-attrib");selfConfig.conf={};selfConfig.isOpposite=options&&!options.isHorizontal?(0,_equal.default)(chartAttrs.scrollposition,"right"):(0,_equal.default)(chartAttrs.scrollposition,"top");selfConfig.color=chartAttrs.scrollcolor&&(0,_lib.convertColor)(chartAttrs.scrollcolor);selfConfig.padding=(0,_lib.pluckNumber)(chartAttrs.scrollpadding,0);selfConfig.height=(0,_lib.pluckNumber)(chartAttrs.scrollheight,12);selfConfig.width=(0,_lib.pluckNumber)(chartAttrs.scrollwidth,12);selfConfig.displayFlat=(0,_lib.pluckNumber)(chartAttrs.flatscrollbars,0);selfConfig.scrollBar3DLighting=(0,_lib.pluckNumber)(chartAttrs.scrollbar3dlighting,1);selfConfig.startPercent=Math.min(1,Math.max(0,parseFloat(chartAttrs.scrolltoend)||0));selfConfig.showButtons=!!(0,_lib.pluckNumber)(chartAttrs.scrollshowbuttons,1);selfConfig.buttonPadding=(0,_lib.pluckNumber)(chartAttrs.scrollbtnpadding,0);selfConfig.style=options.style;selfConfig.drawStripes=options.drawStripes;selfConfig.restrictScrollAnchor=(0,_lib.pluckNumber)(options.restrictScrollAnchor,1);this.setConfiguaration(options);selfConfig.evt={tooltext:UNDEF,click:_lib.stubFN,hover:[_lib.stubFN,_lib.stubFN]};this.createScrollItems()};_proto.createScrollItems=function createScrollItems(){var _scrollbar$getChildre,_scrollbar$getChildre2,_scrollbar$getChildre3,_scrollbar$getChildre4;var scrollbar=this,selfConfig=this.config,style=selfConfig.style||{},scrollTrack=(_scrollbar$getChildre=scrollbar.getChildren("scrollTrack"))==null?void 0:_scrollbar$getChildre[0],scrollAnchor=(_scrollbar$getChildre2=scrollbar.getChildren("scrollAnchor"))==null?void 0:_scrollbar$getChildre2[0],scrollButtonStart=(_scrollbar$getChildre3=scrollbar.getChildren("scrollButtons"))==null?void 0:_scrollbar$getChildre3[0],scrollButtonEnd=(_scrollbar$getChildre4=scrollbar.getChildren("scrollButtons"))==null?void 0:_scrollbar$getChildre4[0],isLegendScrollButtonColor=!!selfConfig.legendScrollButtonArrowColor,scrollButtonStartColor=isLegendScrollButtonColor?selfConfig.legendScrollButtonArrowColor[0]:selfConfig.color,scrollButtonEndColor=isLegendScrollButtonColor?selfConfig.legendScrollButtonArrowColor.length===1?selfConfig.legendScrollButtonArrowColor[0]:selfConfig.legendScrollButtonArrowColor[1]:selfConfig.color;if(!scrollTrack){var _selfConfig$legendScr;scrollTrack=scrollbar.attachChild(_scrollTrack.default,"scrollTrack");scrollTrack.configure({style:{track:style.track},useLegendScrollGradient:selfConfig.useLegendScrollGradient,color:(_selfConfig$legendScr=selfConfig.legendScrollTrackColor)!=null?_selfConfig$legendScr:selfConfig.color,legendTrackStrokeBorderColor:selfConfig.legendTrackStrokeBorderColor,displayFlat:selfConfig.displayFlat,isHorizontal:selfConfig.isHorizontal});scrollTrack.attachEventHandlers()}if(!scrollAnchor){var _selfConfig$legendScr2;scrollAnchor=scrollbar.attachChild(_scrollAnchor.default,"scrollAnchor");scrollAnchor.configure({style:{scroller:style.scroller,grip:style.grip},drawStripes:selfConfig.drawStripes,useLegendScrollGradient:selfConfig.useLegendScrollGradient,color:(_selfConfig$legendScr2=selfConfig.legendScrollAnchorColor)!=null?_selfConfig$legendScr2:selfConfig.color,displayFlat:selfConfig.displayFlat,isHorizontal:selfConfig.isHorizontal});scrollAnchor.attachEventHandlers()}if(!scrollButtonStart&&selfConfig.showButtons){scrollButtonStart=scrollbar.attachChild(_scrollButton.default,"scrollStartButton");scrollButtonStart.configure({type:"start",color:scrollButtonStartColor,useLegendScrollGradient:selfConfig.useLegendScrollGradient,style:{button:style.button,arrow:style.arrow}});scrollButtonStart.attachEventHandlers()}if(!scrollButtonEnd&&selfConfig.showButtons){scrollButtonEnd=scrollbar.attachChild(_scrollButton.default,"scrollEndButton");scrollButtonEnd.configure({type:"end",color:scrollButtonEndColor,useLegendScrollGradient:selfConfig.useLegendScrollGradient,style:{button:style.button,arrow:style.arrow}});scrollButtonEnd.attachEventHandlers()}};_proto.getName=function getName(){return"scrollbar"};_proto.getType=function getType(){return"scrollbar"};_proto.setConfiguaration=function setConfiguaration(conf){var selfConfig=this.config;if(!selfConfig.color){selfConfig.color="#"+this.getFromEnv("chart").getFromEnv("color-manager").getColor("altHGridColor")}(0,_helper.mergeConf)(conf,selfConfig)};_proto.getLogicalSpace=function getLogicalSpace(){var selfConfig=this.config,conf=selfConfig.conf,preperaedScrollbarSpecAttr={};(0,_helper.mergeConf)(selfConfig,preperaedScrollbarSpecAttr);(0,_helper.mergeConf)(preperaedScrollbarSpecAttr,conf);return _Tool.prototype.getLogicalSpace.call(this)};_proto.setDimension=function setDimension(dim){_Tool.prototype.setDimension.call(this,dim);var scrollbar=this,scrollbarParent=scrollbar.getLinkedParent(),parentPosition=scrollbarParent.getPosition&&scrollbarParent.getPosition()||{},scrolleTrackConfig=scrollbar.getChildren("scrollTrack")[0].config;scrolleTrackConfig.transLateX=parentPosition.x||0;scrolleTrackConfig.transLateY=parentPosition.y||0};_proto.draw=function draw(){var scrollbar=this,selfConfig=scrollbar.config,conf=selfConfig.conf,preperaedScrollbarSpecAttr={};if(conf.isHorizontal){delete preperaedScrollbarSpecAttr.width}else{delete preperaedScrollbarSpecAttr.height}(0,_helper.mergeConf)(preperaedScrollbarSpecAttr,selfConfig,true);scrollbar.addGraphicalElement({el:"group",attr:{name:"scrollContainer"},component:scrollbar,container:{id:"scrollbarContainer",label:"scrollbar",isParent:true},label:"scrollbarGroup",id:"scrollbarGroup"})};_proto.attachEventHandlers=function attachEventHandlers(eventMap){var scrollbar=this,selfConfig=this.config,evt=selfConfig.evt;if(eventMap){eventMap.scroll&&typeof eventMap.scroll==="function"&&(evt.scroll=eventMap.scroll);eventMap.scrollStart&&typeof eventMap.scrollStart==="function"&&(evt.scrollStart=eventMap.scrollStart);eventMap.scrollEnd&&typeof eventMap.scrollEnd==="function"&&(evt.scrollEnd=eventMap.scrollEnd)}return scrollbar};return ScrollBar}(_tool.default);ScrollBar.registerSymbol=UNDEF;ScrollBar._setConfiguaration=_lib.stubFN;var _default=exports.default=ScrollBar;