📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv7.demodesign.com.tr
/
panel
/
assets
/
js
📝
apexcharts.js
← Geri Dön
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define("ApexCharts", [], factory); else if(typeof exports === 'object') exports["ApexCharts"] = factory(); else root["ApexCharts"] = factory(); })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // identity function for calling harmony imports with the correct context /******/ __webpack_require__.i = function(value) { return value; }; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 166); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); var _Filters = __webpack_require__(6); var _Filters2 = _interopRequireDefault(_Filters); var _Animations = __webpack_require__(25); var _Animations2 = _interopRequireDefault(_Animations); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Graphics Class for all drawing operations. * * @module Graphics **/ var Graphics = function () { function Graphics(ctx) { _classCallCheck(this, Graphics); this.ctx = ctx; this.w = ctx.w; } _createClass(Graphics, [{ key: 'drawLine', value: function drawLine(x1, y1, x2, y2) { var lineColor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '#a8a8a8'; var dashArray = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; var strokeWidth = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; var w = this.w; var line = w.globals.dom.Paper.line().attr({ x1: x1, y1: y1, x2: x2, y2: y2, stroke: lineColor, 'stroke-dasharray': dashArray, 'stroke-width': strokeWidth }); return line; } }, { key: 'drawRect', value: function drawRect() { var x1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; var y1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var x2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var y2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; var radius = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; var color = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '#fefefe'; var opacity = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 1; var strokeWidth = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null; var strokeColor = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null; var strokeDashArray = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : 0; var w = this.w; var rect = w.globals.dom.Paper.rect(); rect.attr({ x: x1, y: y1, width: x2 > 0 ? x2 : 0, height: y2 > 0 ? y2 : 0, rx: radius, ry: radius, fill: color, opacity: opacity, 'stroke-width': strokeWidth !== null ? strokeWidth : 0, stroke: strokeColor !== null ? strokeColor : 'none', 'stroke-dasharray': strokeDashArray }); return rect; } }, { key: 'drawCircle', value: function drawCircle(radius) { var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var w = this.w; var c = w.globals.dom.Paper.circle(radius * 2); if (attrs !== null) { c.attr(attrs); } return c; } }, { key: 'drawPath', value: function drawPath(_ref) { var _ref$d = _ref.d, d = _ref$d === undefined ? '' : _ref$d, _ref$stroke = _ref.stroke, stroke = _ref$stroke === undefined ? '#a8a8a8' : _ref$stroke, strokeWidth = _ref.strokeWidth, fill = _ref.fill, _ref$fillOpacity = _ref.fillOpacity, fillOpacity = _ref$fillOpacity === undefined ? 1 : _ref$fillOpacity, _ref$strokeOpacity = _ref.strokeOpacity, strokeOpacity = _ref$strokeOpacity === undefined ? 1 : _ref$strokeOpacity, classes = _ref.classes, _ref$strokeLinecap = _ref.strokeLinecap, strokeLinecap = _ref$strokeLinecap === undefined ? null : _ref$strokeLinecap, _ref$strokeDashArray = _ref.strokeDashArray, strokeDashArray = _ref$strokeDashArray === undefined ? 0 : _ref$strokeDashArray; var w = this.w; if (strokeLinecap === null) { strokeLinecap = w.config.stroke.lineCap; } if (d.indexOf('undefined') > -1 || d.indexOf('NaN') > -1) { d = 'M 0 ' + w.globals.gridHeight; } var p = w.globals.dom.Paper.path(d).attr({ fill: fill, 'fill-opacity': fillOpacity, stroke: stroke, 'stroke-opacity': strokeOpacity, 'stroke-linecap': strokeLinecap, 'stroke-width': strokeWidth, 'stroke-dasharray': strokeDashArray, class: classes }); return p; } }, { key: 'group', value: function group() { var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var w = this.w; var g = w.globals.dom.Paper.group(); if (attrs !== null) { g.attr(attrs); } return g; } }, { key: 'move', value: function move(x, y) { var move = ['M', x, y].join(' '); return move; } }, { key: 'line', value: function line(x, y) { var hORv = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; var line = null; if (hORv === null) { line = ['L', x, y].join(' '); } else { line = [hORv, x].join(' '); } return line; } }, { key: 'curve', value: function curve(x1, y1, x2, y2, x, y) { var curve = ['C', x1, y1, x2, y2, x, y].join(' '); return curve; } }, { key: 'quadraticCurve', value: function quadraticCurve(x1, y1, x, y) { var curve = ['Q', x1, y1, x, y].join(' '); return curve; } }, { key: 'arc', value: function arc(rx, ry, axisRotation, largeArcFlag, sweepFlag, x, y) { var relative = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false; var coord = 'A'; if (relative) coord = 'a'; var arc = [coord, rx, ry, axisRotation, largeArcFlag, sweepFlag, x, y].join(' '); return arc; } /** * @memberof Graphics * @param {object} * i = series's index * realIndex = realIndex is series's actual index when it was drawn time. After several redraws, the iterating "i" may change in loops, but realIndex doesn't * pathFrom = existing pathFrom to animateTo * pathTo = new Path to which d attr will be animated from pathFrom to pathTo * stroke = line Color * strokeWidth = width of path Line * fill = it can be gradient, single color, pattern or image * animationDelay = how much to delay when starting animation (in milliseconds) * dataChangeSpeed = for dynamic animations, when data changes * hideStrokesInChange = for certain charts, we hide strokes during anim * className = class attribute to add * @return {object} svg.js path object **/ }, { key: 'renderPaths', value: function renderPaths(_ref2) { var i = _ref2.i, j = _ref2.j, realIndex = _ref2.realIndex, pathFrom = _ref2.pathFrom, pathTo = _ref2.pathTo, stroke = _ref2.stroke, strokeWidth = _ref2.strokeWidth, strokeLinecap = _ref2.strokeLinecap, fill = _ref2.fill, animationDelay = _ref2.animationDelay, initialSpeed = _ref2.initialSpeed, dataChangeSpeed = _ref2.dataChangeSpeed, _ref2$hideStrokesInCh = _ref2.hideStrokesInChange, hideStrokesInChange = _ref2$hideStrokesInCh === undefined ? false : _ref2$hideStrokesInCh, className = _ref2.className, id = _ref2.id; var w = this.w; var filters = new _Filters2.default(this.ctx); var anim = new _Animations2.default(this.ctx); var initialAnim = this.w.config.chart.animations.enabled; var dynamicAnim = initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled; var d = void 0; var shouldAnimate = !!(initialAnim && !w.globals.resized || dynamicAnim && w.globals.dataChanged && w.globals.shouldAnimate); if (shouldAnimate) { d = pathFrom; } else { d = pathTo; } var strokeDashArrayOpt = w.config.stroke.dashArray; var strokeDashArray = 0; if (Array.isArray(strokeDashArrayOpt)) { strokeDashArray = strokeDashArrayOpt[realIndex]; } else { strokeDashArray = w.config.stroke.dashArray; } var el = this.drawPath({ d: d, stroke: stroke, strokeWidth: strokeWidth, fill: fill, fillOpacity: 1, classes: className, strokeLinecap: strokeLinecap, strokeDashArray: strokeDashArray }); el.attr('id', id + '-' + i); el.attr('index', realIndex); // const defaultFilter = el.filterer if (w.config.states.normal.filter.type !== 'none') { filters.getDefaultFilter(el, w.config.states.normal.filter.type, w.config.states.normal.filter.value); } else { if (w.config.chart.dropShadow.enabled) { if (!w.config.chart.dropShadow.enabledSeries || w.config.chart.dropShadow.enabledSeries && w.config.chart.dropShadow.enabledSeries.indexOf(realIndex) !== -1) { var shadow = w.config.chart.dropShadow; filters.dropShadow(el, shadow); } } } el.node.addEventListener('mouseenter', this.pathMouseEnter.bind(this, el)); el.node.addEventListener('mouseleave', this.pathMouseLeave.bind(this, el)); el.node.addEventListener('mousedown', this.pathMouseDown.bind(this, el)); el.node.addEventListener('touchstart', this.pathMouseDown.bind(this, el), { passive: true }); el.attr({ pathTo: pathTo, pathFrom: pathFrom }); var defaultAnimateOpts = { el: el, j: j, pathFrom: pathFrom, pathTo: pathTo, strokeWidth: strokeWidth }; if (initialAnim && !w.globals.resized && !w.globals.dataChanged) { anim.animatePathsGradually(_extends({}, defaultAnimateOpts, { speed: initialSpeed, delay: animationDelay })); } if (w.globals.dataChanged && dynamicAnim && shouldAnimate) { anim.animatePathsGradually(_extends({}, defaultAnimateOpts, { speed: dataChangeSpeed })); } return el; } }, { key: 'drawPattern', value: function drawPattern(style, width, height) { var stroke = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#a8a8a8'; var strokeWidth = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; var opacity = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1; var w = this.w; var p = w.globals.dom.Paper.pattern(width, height, function (add) { if (style === 'horizontalLines') { add.line(0, 0, height, 0).stroke({ color: stroke, width: strokeWidth + 1 }); } else if (style === 'verticalLines') { add.line(0, 0, 0, width).stroke({ color: stroke, width: strokeWidth + 1 }); } else if (style === 'slantedLines') { add.line(0, 0, width, height).stroke({ color: stroke, width: strokeWidth }); } else if (style === 'squares') { add.rect(width, height).fill('none').stroke({ color: stroke, width: strokeWidth }); } else if (style === 'circles') { add.circle(width).fill('none').stroke({ color: stroke, width: strokeWidth }); } }); return p; } }, { key: 'drawGradient', value: function drawGradient(style, gfrom, gto, opacityFrom, opacityTo) { var size = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; var stops = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; var w = this.w; gfrom = _Utils2.default.hexToRgba(gfrom, opacityFrom); gto = _Utils2.default.hexToRgba(gto, opacityTo); var stop1 = 0; var stop2 = 1; var stop3 = 1; var stop4 = null; if (stops !== null) { stop1 = typeof stops[0] !== 'undefined' ? stops[0] / 100 : 0; stop2 = typeof stops[1] !== 'undefined' ? stops[1] / 100 : 1; stop3 = typeof stops[2] !== 'undefined' ? stops[2] / 100 : 1; stop4 = typeof stops[3] !== 'undefined' ? stops[3] / 100 : null; } var radial = !!(w.config.chart.type === 'donut' || w.config.chart.type === 'pie' || w.config.chart.type === 'bubble'); var p = w.globals.dom.Paper.gradient(radial ? 'radial' : 'linear', function (stop) { stop.at(stop1, gfrom, opacityFrom); stop.at(stop2, gto, opacityTo); stop.at(stop3, gto, opacityTo); if (stop4 !== null) { stop.at(stop4, gfrom, opacityFrom); } }); if (!radial) { if (style === 'vertical') { p.from(0, 0).to(0, 1); } else if (style === 'diagonal') { p.from(0, 0).to(1, 1); } else if (style === 'horizontal') { p.from(0, 1).to(1, 1); } else if (style === 'diagonal2') { p.from(0, 1).to(2, 2); } } else { var offx = w.globals.gridWidth / 2; var offy = w.globals.gridHeight / 2; if (w.config.chart.type !== 'bubble') { p.attr({ 'gradientUnits': 'userSpaceOnUse', cx: offx, cy: offy, r: size }); } else { p.attr({ cx: 0.5, cy: 0.5, r: 0.8, fx: 0.2, fy: 0.2 }); } } return p; } }, { key: 'drawText', value: function drawText(opts) { var w = this.w; var x = opts.x, y = opts.y, text = opts.text, textAnchor = opts.textAnchor, fontSize = opts.fontSize, fontFamily = opts.fontFamily, foreColor = opts.foreColor, opacity = opts.opacity; if (!textAnchor) { textAnchor = 'start'; } if (!foreColor) { foreColor = w.config.chart.foreColor; } var elText = void 0; if (Array.isArray(text)) { elText = w.globals.dom.Paper.text(function (add) { for (var i = 0; i < text.length; i++) { add.tspan(text[i]); } }); } else { elText = w.globals.dom.Paper.plain(text); } elText.attr({ x: x, y: y, 'text-anchor': textAnchor, 'dominate-baseline': 'central', 'font-size': fontSize, 'font-family': fontFamily, fill: foreColor, class: true ? opts.cssClass : '' }); elText.node.style.fontFamily = fontFamily; elText.node.style.opacity = opacity; return elText; } }, { key: 'drawMarker', value: function drawMarker(x, y, opts) { x = x || 0; var size = opts.pSize || 0; var elPoint = null; if (opts.shape === 'square') { var radius = opts.pRadius === undefined ? size / 2 : opts.pRadius; if (y === null) { size = 0; radius = 0; } var nSize = size * 1.2 + radius; var p = this.drawRect(nSize, nSize, nSize, nSize, radius); p.attr({ x: x - nSize / 2, y: y - nSize / 2, cx: x, cy: y, class: opts.class ? opts.class : '', fill: opts.pointFillColor, 'fill-opacity': opts.pointFillOpacity ? opts.pointFillOpacity : 1, stroke: opts.pointStrokeColor, 'stroke-width': opts.pWidth ? opts.pWidth : 0, 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1 }); elPoint = p; } else if (opts.shape === 'circle') { if (!_Utils2.default.isNumber(y)) { size = 0; y = 0; } // let nSize = size - opts.pRadius / 2 < 0 ? 0 : size - opts.pRadius / 2 elPoint = this.drawCircle(size, { cx: x, cy: y, class: opts.class ? opts.class : '', stroke: opts.pointStrokeColor, fill: opts.pointFillColor, 'fill-opacity': opts.pointFillOpacity ? opts.pointFillOpacity : 1, 'stroke-width': opts.pWidth ? opts.pWidth : 0, 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1 }); } return elPoint; } }, { key: 'pathMouseEnter', value: function pathMouseEnter(path, e) { var w = this.w; var filters = new _Filters2.default(this.ctx); var i = parseInt(path.node.getAttribute('index')); var j = parseInt(path.node.getAttribute('j')); if (typeof w.config.chart.events.dataPointMouseEnter === 'function') { w.config.chart.events.dataPointMouseEnter(e, this.ctx, { seriesIndex: i, dataPointIndex: j, config: w.config, globals: w.globals }); } this.ctx.fireEvent('dataPointMouseEnter', [e, this.ctx, { seriesIndex: i, dataPointIndex: j, config: w.config, globals: w.globals }]); if (w.config.states.active.filter.type !== 'none') { if (path.node.getAttribute('selected') === 'true') { return; } } if (w.config.states.hover.filter.type !== 'none') { var hoverFilter = w.config.states.hover.filter; filters.applyFilter(path, hoverFilter.type, hoverFilter.value); } } }, { key: 'pathMouseLeave', value: function pathMouseLeave(path, e) { var w = this.w; var filters = new _Filters2.default(this.ctx); var i = parseInt(path.node.getAttribute('index')); var j = parseInt(path.node.getAttribute('j')); if (typeof w.config.chart.events.dataPointMouseLeave === 'function') { w.config.chart.events.dataPointMouseLeave(e, this.ctx, { seriesIndex: i, dataPointIndex: j, config: w.config, globals: w.globals }); } this.ctx.fireEvent('dataPointMouseLeave', [e, this.ctx, { seriesIndex: i, dataPointIndex: j, config: w.config, globals: w.globals }]); if (w.config.states.active.filter.type !== 'none') { if (path.node.getAttribute('selected') === 'true') { return; } } if (w.config.states.hover.filter.type !== 'none') { filters.getDefaultFilter(path); } } }, { key: 'pathMouseDown', value: function pathMouseDown(path, e) { var w = this.w; var filters = new _Filters2.default(this.ctx); var i = parseInt(path.node.getAttribute('index')); var j = parseInt(path.node.getAttribute('j')); var selected = 'false'; if (path.node.getAttribute('selected') === 'true') { path.node.setAttribute('selected', 'false'); if (w.globals.selectedDataPoints[i].indexOf(j) > -1) { var index = w.globals.selectedDataPoints[i].indexOf(j); w.globals.selectedDataPoints[i].splice(index, 1); } } else { if (!w.config.states.active.allowMultipleDataPointsSelection && w.globals.selectedDataPoints.length > 0) { w.globals.selectedDataPoints = []; var elPaths = w.globals.dom.Paper.select('.apexcharts-series path').members; var elCircles = w.globals.dom.Paper.select('.apexcharts-series circle').members; var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = elPaths[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var elPath = _step.value; elPath.node.setAttribute('selected', 'false'); filters.getDefaultFilter(elPath); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } var _iteratorNormalCompletion2 = true; var _didIteratorError2 = false; var _iteratorError2 = undefined; try { for (var _iterator2 = elCircles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { var circle = _step2.value; circle.node.setAttribute('selected', 'false'); filters.getDefaultFilter(circle); } } catch (err) { _didIteratorError2 = true; _iteratorError2 = err; } finally { try { if (!_iteratorNormalCompletion2 && _iterator2.return) { _iterator2.return(); } } finally { if (_didIteratorError2) { throw _iteratorError2; } } } } path.node.setAttribute('selected', 'true'); selected = 'true'; if (typeof w.globals.selectedDataPoints[i] === 'undefined') { w.globals.selectedDataPoints[i] = []; } w.globals.selectedDataPoints[i].push(j); } if (selected === 'true') { var activeFilter = w.config.states.active.filter; if (activeFilter !== 'none') { filters.applyFilter(path, activeFilter.type, activeFilter.value); } } else { if (w.config.states.active.filter.type !== 'none') { filters.getDefaultFilter(path); } } if (typeof w.config.chart.events.dataPointSelection === 'function') { w.config.chart.events.dataPointSelection(e, this.ctx, { selectedDataPoints: w.globals.selectedDataPoints, seriesIndex: i, dataPointIndex: j, config: w.config, globals: w.globals }); } this.ctx.fireEvent('dataPointSelection', [e, this.ctx, { selectedDataPoints: w.globals.selectedDataPoints, seriesIndex: i, dataPointIndex: j, config: w.config, globals: w.globals }]); // if (this.w.config.chart.selection.selectedPoints !== undefined) { // this.w.config.chart.selection.selectedPoints(w.globals.selectedDataPoints) // } } }, { key: 'rotateAroundCenter', value: function rotateAroundCenter(el) { var coord = el.getBBox(); var x = coord.x + coord.width / 2; var y = coord.y + coord.height / 2; return { x: x, y: y }; } }, { key: 'getTextRects', value: function getTextRects(text, fontSize, fontFamily, transform) { var useBBox = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true; var w = this.w; var virtualText = this.drawText({ x: -200, y: -200, text: text, textAnchor: 'start', fontSize: fontSize, fontFamily: fontFamily, foreColor: '#fff', opacity: 0 }); if (transform) { virtualText.attr('transform', transform); } w.globals.dom.Paper.add(virtualText); var rect = virtualText.bbox(); if (!useBBox) { rect = virtualText.node.getBoundingClientRect(); } virtualText.remove(); return { width: rect.width, height: rect.height }; } /** * append ... to long text * http://stackoverflow.com/questions/9241315/trimming-text-to-a-given-pixel-width-in-svg * @memberof Graphics **/ }, { key: 'placeTextWithEllipsis', value: function placeTextWithEllipsis(textObj, textString, width) { textObj.textContent = textString; if (textString.length > 0) { // ellipsis is needed if (textObj.getSubStringLength(0, textString.length) >= width) { for (var x = textString.length - 3; x > 0; x -= 3) { if (textObj.getSubStringLength(0, x) <= width) { textObj.textContent = textString.substring(0, x) + '...'; return; } } textObj.textContent = '...'; // can't place at all } } } }], [{ key: 'setAttrs', value: function setAttrs(el, attrs) { for (var key in attrs) { if (attrs.hasOwnProperty(key)) { el.setAttribute(key, attrs[key]); } } } }]); return Graphics; }(); exports.default = Graphics; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* ** Generic functions which are not dependent on ApexCharts */ var Utils = function () { function Utils() { _classCallCheck(this, Utils); } _createClass(Utils, [{ key: 'shadeColor', // beautiful color shading blending code // http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors value: function shadeColor(p, from) { var to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; if (from[0] !== '#' || from[0] !== 'r') { from = this.getHexColorFromName(from); } if (typeof p !== 'number' || p < -1 || p > 1 || typeof from !== 'string' || from[0] !== 'r' && from[0] !== '#' || typeof to !== 'string' && typeof to !== 'undefined') return null; // ErrorCheck var i = parseInt, r = Math.round, h = from.length > 9, h = typeof to === 'string' ? to.length > 9 ? true : to === 'c' ? !h : false : h, b = p < 0, p = b ? p * -1 : p, to = to && to !== 'c' ? to : b ? '#000000' : '#FFFFFF', f = this.sbcRip(from), t = this.sbcRip(to); if (!f || !t) return null; // ErrorCheck if (h) return 'rgb(' + r((t[0] - f[0]) * p + f[0]) + ',' + r((t[1] - f[1]) * p + f[1]) + ',' + r((t[2] - f[2]) * p + f[2]) + (f[3] < 0 && t[3] < 0 ? ')' : ',' + (f[3] > -1 && t[3] > -1 ? r(((t[3] - f[3]) * p + f[3]) * 10000) / 10000 : t[3] < 0 ? f[3] : t[3]) + ')');else return '#' + (0x100000000 + (f[3] > -1 && t[3] > -1 ? r(((t[3] - f[3]) * p + f[3]) * 255) : t[3] > -1 ? r(t[3] * 255) : f[3] > -1 ? r(f[3] * 255) : 255) * 0x1000000 + r((t[0] - f[0]) * p + f[0]) * 0x10000 + r((t[1] - f[1]) * p + f[1]) * 0x100 + r((t[2] - f[2]) * p + f[2])).toString(16).slice(f[3] > -1 || t[3] > -1 ? 1 : 3); } // helper function of shadeColor }, { key: 'sbcRip', value: function sbcRip(d) { var l = d.length, RGB = new Object(); var i = parseInt, r = Math.round; if (l > 9) { d = d.split(','); if (d.length < 3 || d.length > 4) return null; // ErrorCheck RGB[0] = i(d[0].slice(4)), RGB[1] = i(d[1]), RGB[2] = i(d[2]), RGB[3] = d[3] ? parseFloat(d[3]) : -1; } else { if (l === 8 || l === 6 || l < 4) return null; // ErrorCheck if (l < 6) d = '#' + d[1] + d[1] + d[2] + d[2] + d[3] + d[3] + (l > 4 ? d[4] + '' + d[4] : ''); // 3 digit d = i(d.slice(1), 16), RGB[0] = d >> 16 & 255, RGB[1] = d >> 8 & 255, RGB[2] = d & 255, RGB[3] = l === 9 || l === 5 ? r((d >> 24 & 255) / 255 * 10000) / 10000 : -1; } return RGB; } // https://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes }, { key: 'getHexColorFromName', value: function getHexColorFromName(colorStr) { var a = document.createElement('div'); a.style.color = colorStr; var colors = window.getComputedStyle(document.body.appendChild(a)).color.match(/\d+/g).map(function (a) { return parseInt(a, 10); }); document.body.removeChild(a); return colors.length >= 3 ? '#' + ((1 << 24) + (colors[0] << 16) + (colors[1] << 8) + colors[2]).toString(16).substr(1) : false; } }], [{ key: 'bind', value: function bind(fn, me) { return function () { return fn.apply(me, arguments); }; } }, { key: 'isObject', value: function isObject(item) { return item && (typeof item === 'undefined' ? 'undefined' : _typeof(item)) === 'object' && !Array.isArray(item) && item != null; } // to extend defaults with user options // credit: http://stackoverflow.com/questions/27936772/deep-object-merging-in-es6-es7#answer-34749873 }, { key: 'extend', value: function extend(target, source) { var _this = this; if (typeof Object.assign !== 'function') { (function () { Object.assign = function (target) { 'use strict'; // We must check against these specific cases. if (target === undefined || target === null) { throw new TypeError('Cannot convert undefined or null to object'); } var output = Object(target); for (var index = 1; index < arguments.length; index++) { var _source = arguments[index]; if (_source !== undefined && _source !== null) { for (var nextKey in _source) { if (_source.hasOwnProperty(nextKey)) { output[nextKey] = _source[nextKey]; } } } } return output; }; })(); } var output = Object.assign({}, target); if (this.isObject(target) && this.isObject(source)) { Object.keys(source).forEach(function (key) { if (_this.isObject(source[key])) { if (!(key in target)) { Object.assign(output, _defineProperty({}, key, source[key])); } else { output[key] = _this.extend(target[key], source[key]); } } else { Object.assign(output, _defineProperty({}, key, source[key])); } }); } return output; } }, { key: 'extendArray', value: function extendArray(arrToExtend, resultArr) { var extendedArr = []; arrToExtend.map(function (item) { extendedArr.push(Utils.extend(resultArr, item)); }); arrToExtend = extendedArr; return arrToExtend; } }, { key: 'addProps', value: function addProps(obj, arr, val) { if (typeof arr === 'string') { arr = arr.split('.'); } obj[arr[0]] = obj[arr[0]] || {}; var tmpObj = obj[arr[0]]; if (arr.length > 1) { arr.shift(); this.addProps(tmpObj, arr, val); } else { obj[arr[0]] = val; } return obj; } }, { key: 'clone', value: function clone(source) { if (Object.prototype.toString.call(source) === '[object Array]') { var cloneResult = []; for (var i = 0; i < source.length; i++) { cloneResult[i] = this.clone(source[i]); } return cloneResult; } else if ((typeof source === 'undefined' ? 'undefined' : _typeof(source)) === 'object') { var _cloneResult = {}; for (var prop in source) { if (source.hasOwnProperty(prop)) { _cloneResult[prop] = this.clone(source[prop]); } } return _cloneResult; } else { return source; } } }, { key: 'getDimensions', value: function getDimensions(el) { var computedStyle = getComputedStyle(el); var ret = []; var elementHeight = el.clientHeight; var elementWidth = el.clientWidth; elementHeight -= parseFloat(computedStyle.paddingTop) + parseFloat(computedStyle.paddingBottom); elementWidth -= parseFloat(computedStyle.paddingLeft) + parseFloat(computedStyle.paddingRight); ret.push(elementWidth); ret.push(elementHeight); return ret; } }, { key: 'getBoundingClientRect', value: function getBoundingClientRect(element) { var rect = element.getBoundingClientRect(); return { top: rect.top, right: rect.right, bottom: rect.bottom, left: rect.left, width: rect.width, height: rect.height, x: rect.x, y: rect.y }; } // http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb#answer-12342275 }, { key: 'hexToRgba', value: function hexToRgba() { var hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#999999'; var opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6; if (hex.substring(0, 1) !== '#') { hex = '#999999'; } var h = hex.replace('#', ''); h = h.match(new RegExp('(.{' + h.length / 3 + '})', 'g')); for (var i = 0; i < h.length; i++) { h[i] = parseInt(h[i].length === 1 ? h[i] + h[i] : h[i], 16); } if (typeof opacity !== 'undefined') h.push(opacity); return 'rgba(' + h.join(',') + ')'; } }, { key: 'rgb2hex', value: function rgb2hex(rgb) { rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i); return rgb && rgb.length === 4 ? '#' + ('0' + parseInt(rgb[1], 10).toString(16)).slice(-2) + ('0' + parseInt(rgb[2], 10).toString(16)).slice(-2) + ('0' + parseInt(rgb[3], 10).toString(16)).slice(-2) : ''; } }, { key: 'polarToCartesian', value: function polarToCartesian(centerX, centerY, radius, angleInDegrees) { var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0; return { x: centerX + radius * Math.cos(angleInRadians), y: centerY + radius * Math.sin(angleInRadians) }; } }, { key: 'negToZero', value: function negToZero(val) { return val < 0 ? 0 : val; } }, { key: 'randomString', value: function randomString(len) { var text = ''; var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; for (var i = 0; i < len; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)); } return text; } }, { key: 'findAncestor', value: function findAncestor(el, cls) { while ((el = el.parentElement) && !el.classList.contains(cls)) {} return el; } }, { key: 'setELstyles', value: function setELstyles(el, styles) { for (var key in styles) { if (styles.hasOwnProperty(key)) { el.style.key = styles[key]; } } } }, { key: 'isNumber', value: function isNumber(value) { return !isNaN(value) && parseFloat(Number(value)) === value && !isNaN(parseInt(value, 10)); } }, { key: 'isFloat', value: function isFloat(n) { return Number(n) === n && n % 1 !== 0; } }, { key: 'isSafari', value: function isSafari() { return (/^((?!chrome|android).)*safari/i.test(navigator.userAgent) ); } }, { key: 'isFirefox', value: function isFirefox() { return navigator.userAgent.toLowerCase().indexOf('firefox') > -1; } }, { key: 'isIE', value: function isIE() { var ua = window.navigator.userAgent; var msie = ua.indexOf('MSIE '); if (msie > 0) { // IE 10 or older => return version number return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); } var trident = ua.indexOf('Trident/'); if (trident > 0) { // IE 11 => return version number var rv = ua.indexOf('rv:'); return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); } var edge = ua.indexOf('Edge/'); if (edge > 0) { // Edge (IE 12+) => return version number return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); } // other browser return false; } }]); return Utils; }(); exports.default = Utils; /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var store = __webpack_require__(40)('wks'); var uid = __webpack_require__(24); var _Symbol = __webpack_require__(3).Symbol; var USE_SYMBOL = typeof _Symbol == 'function'; var $exports = module.exports = function (name) { return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : uid)('Symbol.' + name)); }; $exports.store = store; /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self // eslint-disable-next-line no-new-func : Function('return this')(); if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var core = module.exports = { version: '2.5.7' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var global = __webpack_require__(3); var core = __webpack_require__(4); var hide = __webpack_require__(12); var redefine = __webpack_require__(15); var ctx = __webpack_require__(14); var PROTOTYPE = 'prototype'; var $export = function $export(type, name, source) { var IS_FORCED = type & $export.F; var IS_GLOBAL = type & $export.G; var IS_STATIC = type & $export.S; var IS_PROTO = type & $export.P; var IS_BIND = type & $export.B; var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]; var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}); var key, own, out, exp; if (IS_GLOBAL) source = name; for (key in source) { // contains in native own = !IS_FORCED && target && target[key] !== undefined; // export native or passed out = (own ? target : source)[key]; // bind timers to global for call from export context exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; // extend global if (target) redefine(target, key, out, type & $export.U); // export if (exports[key] != out) hide(exports, key, exp); if (IS_PROTO && expProto[key] != out) expProto[key] = out; } }; global.core = core; // type bitmap $export.F = 1; // forced $export.G = 2; // global $export.S = 4; // static $export.P = 8; // proto $export.B = 16; // bind $export.W = 32; // wrap $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Filters Class for setting value formatters for axes as well as tooltips. * * @module Formatters **/ var Filters = function () { function Filters(ctx) { _classCallCheck(this, Filters); this.ctx = ctx; this.w = ctx.w; } // create a re-usable filter which can be appended other filter effects and applied to multiple elements _createClass(Filters, [{ key: 'getDefaultFilter', value: function getDefaultFilter(el) { var w = this.w; el.unfilter(true); var filter = new window.SVG.Filter(); filter.size('120%', '180%', '-5%', '-40%'); if (w.config.states.normal.filter !== 'none') { this.applyFilter(el, w.config.states.normal.filter.type, w.config.states.normal.filter.value); } else { if (w.config.chart.dropShadow.enabled) { this.dropShadow(el, w.config.chart.dropShadow); } } } }, { key: 'addNormalFilter', value: function addNormalFilter(el) { var w = this.w; if (w.config.chart.dropShadow.enabled) { this.dropShadow(el, w.config.chart.dropShadow); } } }, { key: 'addDesaturateFilter', value: function addDesaturateFilter(el) { var _this = this; var w = this.w; el.unfilter(true); var filter = new window.SVG.Filter(); filter.size('120%', '180%', '-5%', '-40%'); el.filter(function (add) { var shadowAttr = w.config.chart.dropShadow; if (shadowAttr.enabled) { filter = _this.addShadow(add, shadowAttr); } else { filter = add; } filter.colorMatrix('matrix', [0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 0, 0.5, 0, 0, 0, 1.0, 0]).colorMatrix('saturate', 0); }); el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse'); } // appends dropShadow to the filter object which can be chained with other filter effects }, { key: 'addLightenFilter', value: function addLightenFilter(el, attrs) { var _this2 = this; var w = this.w; var intensity = attrs.intensity; if (_Utils2.default.isFirefox()) { return; } el.unfilter(true); var filter = new window.SVG.Filter(); filter.size('120%', '180%', '-5%', '-40%'); el.filter(function (add) { var shadowAttr = w.config.chart.dropShadow; if (shadowAttr.enabled) { filter = _this2.addShadow(add, shadowAttr); } else { filter = add; } filter.componentTransfer({ rgb: { type: 'linear', slope: 1.5, intercept: intensity } }); }); el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse'); } // appends dropShadow to the filter object which can be chained with other filter effects }, { key: 'addDarkenFilter', value: function addDarkenFilter(el, attrs) { var _this3 = this; var w = this.w; var intensity = attrs.intensity; if (_Utils2.default.isFirefox()) { return; } el.unfilter(true); var filter = new window.SVG.Filter(); filter.size('120%', '180%', '-5%', '-40%'); el.filter(function (add) { var shadowAttr = w.config.chart.dropShadow; if (shadowAttr.enabled) { filter = _this3.addShadow(add, shadowAttr); } else { filter = add; } filter.componentTransfer({ rgb: { type: 'linear', slope: intensity } }); }); el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse'); } }, { key: 'applyFilter', value: function applyFilter(el, filter) { var intensity = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5; switch (filter) { case 'none': { this.addNormalFilter(el); break; } case 'lighten': { this.addLightenFilter(el, { intensity: intensity }); break; } case 'darken': { this.addDarkenFilter(el, { intensity: intensity }); break; } case 'desaturate': { this.addDesaturateFilter(el); break; } default: // do nothing break; } } // appends dropShadow to the filter object which can be chained with other filter effects }, { key: 'addShadow', value: function addShadow(add, attrs) { var blur = attrs.blur, top = attrs.top, left = attrs.left, opacity = attrs.opacity; var shadowBlur = add.flood('black', opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur).merge(add.source); return add.blend(add.source, shadowBlur); } // directly adds dropShadow to the element and returns the same element. // the only way it is different from the addShadow() function is that addShadow is chainable to other filters, while this function discards all filters and add dropShadow }, { key: 'dropShadow', value: function dropShadow(el, attrs) { var top = attrs.top, left = attrs.left, blur = attrs.blur, opacity = attrs.opacity; el.unfilter(true); var filter = new window.SVG.Filter(); filter.size('120%', '180%', '-5%', '-40%'); el.filter(function (add) { var shadowBlur = null; if (_Utils2.default.isSafari() || _Utils2.default.isFirefox() || _Utils2.default.isIE()) { // safari/firefox has some alternative way to use this filter shadowBlur = add.flood('black', opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur); } else { shadowBlur = add.flood('black', opacity).composite(add.sourceAlpha, 'in').offset(left, top).gaussianBlur(blur).merge(add.source); } add.blend(add.source, shadowBlur); }); el.filterer.node.setAttribute('filterUnits', 'userSpaceOnUse'); return el; } // directly adds darken filter to the element and returns the same element. // darken (el, intensity = 0.2) { // let darkenFilter = null // el.filter(function (add) { // darkenFilter = add.componentTransfer({ // rgb: { type: 'linear', slope: intensity } // }) // }) // return darkenFilter // } // directly adds lighten to the element and returns the same element. // lighten (el, intensity = 0.2) { // el.filter(function (add) { // add.componentTransfer({ // rgb: { type: 'linear', slope: 1.5, intercept: 0.2 } // }) // }) // return el // } }]); return Filters; }(); exports.default = Filters; /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var isObject = __webpack_require__(8); module.exports = function (it) { if (!isObject(it)) throw TypeError(it + ' is not an object!'); return it; }; /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; module.exports = function (it) { return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) === 'object' ? it !== null : typeof it === 'function'; }; /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var anObject = __webpack_require__(7); var IE8_DOM_DEFINE = __webpack_require__(55); var toPrimitive = __webpack_require__(42); var dP = Object.defineProperty; exports.f = __webpack_require__(10) ? Object.defineProperty : function defineProperty(O, P, Attributes) { anObject(O); P = toPrimitive(P, true); anObject(Attributes); if (IE8_DOM_DEFINE) try { return dP(O, P, Attributes); } catch (e) {/* empty */} if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); if ('value' in Attributes) O[P] = Attributes.value; return O; }; /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // Thank's IE8 for his funny defineProperty module.exports = !__webpack_require__(19)(function () { return Object.defineProperty({}, 'a', { get: function get() { return 7; } }).a != 7; }); /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var hasOwnProperty = {}.hasOwnProperty; module.exports = function (it, key) { return hasOwnProperty.call(it, key); }; /***/ }), /* 12 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var dP = __webpack_require__(9); var createDesc = __webpack_require__(22); module.exports = __webpack_require__(10) ? function (object, key, value) { return dP.f(object, key, createDesc(1, value)); } : function (object, key, value) { object[key] = value; return object; }; /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Fill Class for setting fill options of the paths. * * @module Fill **/ var Fill = function () { function Fill(ctx) { _classCallCheck(this, Fill); this.ctx = ctx; this.w = ctx.w; this.opts = null; this.seriesIndex = 0; } _createClass(Fill, [{ key: 'clippedImgArea', value: function clippedImgArea(params) { var w = this.w; var cnf = w.config; var svgW = parseInt(w.globals.gridWidth); var svgH = parseInt(w.globals.gridHeight); var size = svgW > svgH ? svgW : svgH; var fillImg = params.image; var imgWidth = 0; var imgHeight = 0; if (typeof params.width === 'undefined' && typeof params.height === 'undefined') { if (cnf.fill.image.width !== undefined && cnf.fill.image.height !== undefined) { imgWidth = cnf.fill.image.width + 1; imgHeight = cnf.fill.image.height; } else { imgWidth = size + 1; imgHeight = size; } } else { imgWidth = params.width; imgHeight = params.height; } var elPattern = document.createElementNS(w.globals.svgNS, 'pattern'); _Graphics2.default.setAttrs(elPattern, { id: params.patternID, patternUnits: 'userSpaceOnUse', width: imgWidth + 'px', height: imgHeight + 'px' }); var elImage = document.createElementNS(w.globals.svgNS, 'image'); elPattern.appendChild(elImage); elImage.setAttributeNS('http://www.w3.org/1999/xlink', 'href', fillImg); _Graphics2.default.setAttrs(elImage, { x: 0, y: 0, preserveAspectRatio: 'none', width: imgWidth + 'px', height: imgHeight + 'px' }); elImage.style.opacity = params.opacity; w.globals.dom.elDefs.node.appendChild(elPattern); } }, { key: 'getSeriesIndex', value: function getSeriesIndex(opts) { var w = this.w; if (w.config.chart.type === 'bar' && w.config.plotOptions.bar.distributed || w.config.chart.type === 'heatmap') { this.seriesIndex = opts.seriesNumber; } else { this.seriesIndex = opts.seriesNumber % w.globals.series.length; } return this.seriesIndex; } }, { key: 'fillPath', value: function fillPath(elSeries, opts) { var w = this.w; this.opts = opts; var cnf = this.w.config; var pathFill = void 0; var patternFill = void 0, gradientFill = void 0; this.seriesIndex = this.getSeriesIndex(opts); var fillColors = this.getFillColors(); var fillOpacity = Array.isArray(cnf.fill.opacity) ? cnf.fill.opacity[this.seriesIndex] : cnf.fill.opacity; var defaultColor = _Utils2.default.hexToRgba(fillColors[this.seriesIndex], fillOpacity); var fillColor = fillColors[this.seriesIndex]; if (cnf.fill.type === 'pattern') { patternFill = this.handlePatternFill(patternFill, fillColor, fillOpacity, defaultColor); } if (cnf.fill.type === 'gradient') { gradientFill = this.handleGradientFill(gradientFill, fillColor, fillOpacity); } if (cnf.fill.image.src.length > 0 && cnf.fill.type === 'image') { if (opts.seriesNumber < cnf.fill.image.src.length) { this.clippedImgArea({ opacity: fillOpacity, image: cnf.fill.image.src[opts.seriesNumber], patternID: 'pattern' + w.globals.cuid + (opts.seriesNumber + 1) }); pathFill = 'url(#pattern' + w.globals.cuid + (opts.seriesNumber + 1) + ')'; } else { pathFill = defaultColor; } } else if (cnf.fill.type === 'gradient') { pathFill = gradientFill; } else if (cnf.fill.type === 'pattern') { pathFill = patternFill; } else { pathFill = defaultColor; } if (opts.solid) { pathFill = defaultColor; } if (opts.color) { pathFill = opts.color; } return pathFill; } }, { key: 'getFillColors', value: function getFillColors() { var w = this.w; var cnf = w.config; var opts = this.opts; var fillColors = []; if (w.globals.comboCharts) { if (w.config.series[this.seriesIndex].type === 'line') { if (w.globals.stroke.colors instanceof Array) { fillColors = w.globals.stroke.colors; } else { fillColors.push(w.globals.stroke.colors); } } else { if (w.globals.fill.colors instanceof Array) { fillColors = w.globals.fill.colors; } else { fillColors.push(w.globals.fill.colors); } } } else { if (cnf.chart.type === 'line') { if (w.globals.stroke.colors instanceof Array) { fillColors = w.globals.stroke.colors; } else { fillColors.push(w.globals.stroke.colors); } } else { if (w.globals.fill.colors instanceof Array) { fillColors = w.globals.fill.colors; } else { fillColors.push(w.globals.fill.colors); } } } // colors passed in arguments if (typeof opts.fillColors !== 'undefined') { fillColors = []; if (opts.fillColors instanceof Array) { fillColors = opts.fillColors.slice(); } else { fillColors.push(opts.fillColors); } } return fillColors; } }, { key: 'handlePatternFill', value: function handlePatternFill(patternFill, fillColor, fillOpacity, defaultColor) { var cnf = this.w.config; var opts = this.opts; var graphics = new _Graphics2.default(this.ctx); var patternStrokeWidth = cnf.fill.pattern.strokeWidth === undefined ? Array.isArray(cnf.stroke.width) ? cnf.stroke.width[this.seriesIndex] : cnf.stroke.width : Array.isArray(cnf.fill.pattern.strokeWidth) ? cnf.fill.pattern.strokeWidth[this.seriesIndex] : cnf.fill.pattern.strokeWidth; var patternLineColor = fillColor; if (cnf.fill.pattern.style instanceof Array) { if (typeof cnf.fill.pattern.style[opts.seriesNumber] !== 'undefined') { var pf = graphics.drawPattern(cnf.fill.pattern.style[opts.seriesNumber], cnf.fill.pattern.width, cnf.fill.pattern.height, patternLineColor, patternStrokeWidth, fillOpacity); patternFill = pf; } else { patternFill = defaultColor; } } else { patternFill = graphics.drawPattern(cnf.fill.pattern.style, cnf.fill.pattern.width, cnf.fill.pattern.height, patternLineColor, patternStrokeWidth, fillOpacity); } return patternFill; } }, { key: 'handleGradientFill', value: function handleGradientFill(gradientFill, fillColor, fillOpacity) { var cnf = this.w.config; var opts = this.opts; var graphics = new _Graphics2.default(this.ctx); var utils = new _Utils2.default(); var type = cnf.fill.gradient.type; var gradientFrom = void 0, gradientTo = void 0; var opacityFrom = cnf.fill.gradient.opacityFrom === undefined ? fillOpacity : cnf.fill.gradient.opacityFrom; var opacityTo = cnf.fill.gradient.opacityTo === undefined ? fillOpacity : cnf.fill.gradient.opacityTo; gradientFrom = fillColor; if (cnf.fill.gradient.gradientToColors === undefined || cnf.fill.gradient.gradientToColors.length === 0) { if (cnf.fill.gradient.shade === 'dark') { gradientTo = utils.shadeColor(parseFloat(cnf.fill.gradient.shadeIntensity) * -1, fillColor); } else { gradientTo = utils.shadeColor(parseFloat(cnf.fill.gradient.shadeIntensity), fillColor); } } else { gradientTo = cnf.fill.gradient.gradientToColors[opts.seriesNumber]; } if (cnf.fill.gradient.inverseColors) { var t = gradientFrom; gradientFrom = gradientTo; gradientTo = t; } gradientFill = graphics.drawGradient(type, gradientFrom, gradientTo, opacityFrom, opacityTo, opts.size, cnf.fill.gradient.stops); return gradientFill; } }]); return Fill; }(); exports.default = Fill; /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // optional / simple context binding var aFunction = __webpack_require__(17); module.exports = function (fn, that, length) { aFunction(fn); if (that === undefined) return fn; switch (length) { case 1: return function (a) { return fn.call(that, a); }; case 2: return function (a, b) { return fn.call(that, a, b); }; case 3: return function (a, b, c) { return fn.call(that, a, b, c); }; } return function () /* ...args */{ return fn.apply(that, arguments); }; }; /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var global = __webpack_require__(3); var hide = __webpack_require__(12); var has = __webpack_require__(11); var SRC = __webpack_require__(24)('src'); var TO_STRING = 'toString'; var $toString = Function[TO_STRING]; var TPL = ('' + $toString).split(TO_STRING); __webpack_require__(4).inspectSource = function (it) { return $toString.call(it); }; (module.exports = function (O, key, val, safe) { var isFunction = typeof val == 'function'; if (isFunction) has(val, 'name') || hide(val, 'name', key); if (O[key] === val) return; if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); if (O === global) { O[key] = val; } else if (!safe) { delete O[key]; hide(O, key, val); } else if (O[key]) { O[key] = val; } else { hide(O, key, val); } // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative })(Function.prototype, TO_STRING, function toString() { return typeof this == 'function' && this[SRC] || $toString.call(this); }); /***/ }), /* 16 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // to indexed object, toObject with fallback for non-array-like ES3 strings var IObject = __webpack_require__(36); var defined = __webpack_require__(33); module.exports = function (it) { return IObject(defined(it)); }; /***/ }), /* 17 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = function (it) { if (typeof it != 'function') throw TypeError(it + ' is not a function!'); return it; }; /***/ }), /* 18 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var toString = {}.toString; module.exports = function (it) { return toString.call(it).slice(8, -1); }; /***/ }), /* 19 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = function (exec) { try { return !!exec(); } catch (e) { return true; } }; /***/ }), /* 20 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = {}; /***/ }), /* 21 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = false; /***/ }), /* 22 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = function (bitmap, value) { return { enumerable: !(bitmap & 1), configurable: !(bitmap & 2), writable: !(bitmap & 4), value: value }; }; /***/ }), /* 23 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 7.1.15 ToLength var toInteger = __webpack_require__(41); var min = Math.min; module.exports = function (it) { return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; /***/ }), /* 24 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var id = 0; var px = Math.random(); module.exports = function (key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; /***/ }), /* 25 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Animation Class. * * @module Animations **/ var Animations = function () { function Animations(ctx) { _classCallCheck(this, Animations); this.ctx = ctx; this.w = ctx.w; this.setEasingFunctions(); } _createClass(Animations, [{ key: 'setEasingFunctions', value: function setEasingFunctions() { var easing = void 0; var userDefinedEasing = this.w.config.chart.animations.easing; switch (userDefinedEasing) { case 'linear': { easing = '-'; break; } case 'easein': { easing = '<'; break; } case 'easeout': { easing = '>'; break; } case 'easeinout': { easing = '<>'; break; } case 'swing': { easing = function easing(pos) { var s = 1.70158; return (pos -= 1) * pos * ((s + 1) * pos + s) + 1; }; break; } case 'bounce': { easing = function easing(pos) { if (pos < 1 / 2.75) { return 7.5625 * pos * pos; } else if (pos < 2 / 2.75) { return 7.5625 * (pos -= 1.5 / 2.75) * pos + 0.75; } else if (pos < 2.5 / 2.75) { return 7.5625 * (pos -= 2.25 / 2.75) * pos + 0.9375; } else { return 7.5625 * (pos -= 2.625 / 2.75) * pos + 0.984375; } }; break; } case 'elastic': { easing = function easing(pos) { if (pos === !!pos) return pos; return Math.pow(2, -10 * pos) * Math.sin((pos - 0.075) * (2 * Math.PI) / 0.3) + 1; }; break; } default: { easing = '<>'; } } this.w.globals.easing = easing; } }, { key: 'animateLine', value: function animateLine(el, from, to, speed) { el.attr(from).animate(speed).attr(to); } /* ** Animate radius of a circle element */ }, { key: 'animateCircleRadius', value: function animateCircleRadius(el, from, to, speed, easing) { if (!from) from = 0; el.attr({ r: from }).animate(speed, easing).attr({ r: to }); } /* ** Animate radius and position of a circle element */ }, { key: 'animateCircle', value: function animateCircle(el, from, to, speed, easing) { el.attr({ r: from.r, cx: from.cx, cy: from.cy }).animate(speed, easing).attr({ r: to.r, cx: to.cx, cy: to.cy }); } /* ** Animate rect properties */ }, { key: 'animateRect', value: function animateRect(el, from, to, speed) { el.attr(from).animate(speed).attr(to); } }, { key: 'animatePathsGradually', value: function animatePathsGradually(params) { var el = params.el, j = params.j, pathFrom = params.pathFrom, pathTo = params.pathTo, speed = params.speed, delay = params.delay, strokeWidth = params.strokeWidth; var me = this; var w = this.w; var delayFactor = 0; if (w.config.chart.animations.animateGradually.enabled) { delayFactor = w.config.chart.animations.animateGradually.delay; } if (w.config.chart.animations.dynamicAnimation.enabled && w.globals.dataChanged) { delayFactor = 0; } me.morphSVG(el, j, pathFrom, pathTo, speed, strokeWidth, delay * delayFactor); } // SVG.js animation for morphing one path to another }, { key: 'morphSVG', value: function morphSVG(el, j, pathFrom, pathTo, speed, strokeWidth, delay) { var _this = this; var w = this.w; if (!pathFrom) { pathFrom = el.attr('pathFrom'); } if (!pathTo) { pathTo = el.attr('pathTo'); } if (pathFrom.indexOf('undefined') > -1 || pathFrom.indexOf('NaN') > -1) { pathFrom = 'M 0 ' + w.globals.gridHeight; speed = 1; } if (pathTo.indexOf('undefined') > -1 || pathTo.indexOf('NaN') > -1) { pathTo = 'M 0 ' + w.globals.gridHeight; speed = 1; } if (!w.globals.shouldAnimate) { speed = 1; } el.plot(pathFrom).animate(1, w.globals.easing, delay).plot(pathFrom).animate(speed, w.globals.easing, delay).plot(pathTo).afterAll(function () { // a flag to indicate that the original mount function can return true now as animation finished here if (typeof w.config.chart.events.animationEnd === 'function') { if (_Utils2.default.isNumber(j)) { if (j === w.globals.series[w.globals.maxValsInArrayIndex].length - 2 && w.globals.shouldAnimate) { w.config.chart.events.animationEnd(_this.ctx, w); } } else if (w.globals.shouldAnimate) { w.config.chart.events.animationEnd(_this.ctx, w); } } w.globals.delayedElements.forEach(function (d) { var ele = d.el; ele.classList.remove('hidden'); }); }); } }]); return Animations; }(); module.exports = Animations; /***/ }), /* 26 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Series Class for interation with the Series of the chart. * * @module Series **/ var Series = function () { function Series(ctx) { _classCallCheck(this, Series); this.ctx = ctx; this.w = ctx.w; } _createClass(Series, [{ key: 'getAllSeriesEls', value: function getAllSeriesEls() { return this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-series'); } }, { key: 'getSeriesByName', value: function getSeriesByName(seriesName) { return this.w.globals.dom.baseEl.querySelector('.apexcharts-series.' + seriesName.replace(/ /g, '-')); } }, { key: 'addCollapsedClassToSeries', value: function addCollapsedClassToSeries(elSeries, index) { var w = this.w; for (var cs = 0; cs < w.globals.collapsedSeries.length; cs++) { if (w.globals.collapsedSeries[cs].index === index) { elSeries.node.classList.add('apexcharts-series-collapsed'); } } } }, { key: 'toggleSeriesOnHover', value: function toggleSeriesOnHover(e, targetElement) { var w = this.w; var allSeriesEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series'); if (e.type === 'mousemove') { var seriesCnt = parseInt(targetElement.getAttribute('rel')) - 1; var seriesEl = null; if (w.globals.axisCharts || w.config.chart.type === 'radialBar') { if (w.globals.axisCharts) { seriesEl = w.globals.dom.baseEl.querySelector('.apexcharts-series[data\\:realIndex=\'' + seriesCnt + '\']'); } else { seriesEl = w.globals.dom.baseEl.querySelector('.apexcharts-series[rel=\'' + (seriesCnt + 1) + '\']'); } } else { seriesEl = w.globals.dom.baseEl.querySelector('.apexcharts-series[rel=\'' + (seriesCnt + 1) + '\'] path'); } for (var se = 0; se < allSeriesEls.length; se++) { allSeriesEls[se].classList.add('legend-mouseover-inactive'); } if (seriesEl !== null) { if (!w.globals.axisCharts) { seriesEl.parentNode.classList.remove('legend-mouseover-inactive'); } seriesEl.classList.remove('legend-mouseover-inactive'); } } else if (e.type === 'mouseout') { for (var _se = 0; _se < allSeriesEls.length; _se++) { allSeriesEls[_se].classList.remove('legend-mouseover-inactive'); } } } }, { key: 'highlightRangeInSeries', value: function highlightRangeInSeries(e, targetElement) { var w = this.w; var allHeatMapElements = w.globals.dom.baseEl.querySelectorAll('.apexcharts-heatmap-rect'); var allActive = function allActive() { for (var i = 0; i < allHeatMapElements.length; i++) { allHeatMapElements[i].classList.remove('legend-mouseover-inactive'); } }; var allInactive = function allInactive() { for (var i = 0; i < allHeatMapElements.length; i++) { allHeatMapElements[i].classList.add('legend-mouseover-inactive'); } }; var selectedActive = function selectedActive(range) { for (var i = 0; i < allHeatMapElements.length; i++) { var val = parseInt(allHeatMapElements[i].getAttribute('val')); if (val >= range.from && val <= range.to) { allHeatMapElements[i].classList.remove('legend-mouseover-inactive'); } } }; if (e.type === 'mousemove') { var seriesCnt = parseInt(targetElement.getAttribute('rel')) - 1; allActive(); allInactive(); var range = w.config.plotOptions.heatmap.colorScale.ranges[seriesCnt]; selectedActive(range); } else if (e.type === 'mouseout') { allActive(); } } }, { key: 'getActiveSeriesIndex', value: function getActiveSeriesIndex() { var w = this.w; var activeIndex = 0; if (w.globals.series.length > 1) { // active series flag is required to know if user has not deactivated via legend click var firstActiveSeriesIndex = w.globals.series.map(function (series, index) { if (series.length > 0 && w.config.series[index].type !== 'bar' && w.config.series[index].type !== 'column') { return index; } else { return -1; } }); for (var a = 0; a < firstActiveSeriesIndex.length; a++) { if (firstActiveSeriesIndex[a] !== -1) { activeIndex = firstActiveSeriesIndex[a]; break; } } } return activeIndex; } }, { key: 'getActiveConfigSeriesIndex', value: function getActiveConfigSeriesIndex() { var w = this.w; var activeIndex = 0; if (w.config.series.length > 1) { // active series flag is required to know if user has not deactivated via legend click var firstActiveSeriesIndex = w.config.series.map(function (series, index) { if (series.data && series.data.length > 0) { return index; } else { return -1; } }); for (var a = 0; a < firstActiveSeriesIndex.length; a++) { if (firstActiveSeriesIndex[a] !== -1) { activeIndex = firstActiveSeriesIndex[a]; break; } } } return activeIndex; } }, { key: 'getPreviousPaths', value: function getPreviousPaths() { var w = this.w; w.globals.previousPaths = []; function pushPaths(seriesEls, i, type) { var paths = seriesEls[i].childNodes; var dArr = { type: type, paths: [], realIndex: seriesEls[i].getAttribute('data:realIndex') }; for (var j = 0; j < paths.length; j++) { if (paths[j].hasAttribute('pathTo')) { var d = paths[j].getAttribute('pathTo'); if (type === 'area') { if (paths[j].classList.contains('apexcharts-line') || paths[j].classList.contains('apexcharts-area')) { dArr.paths.push({ d: d }); } } else { dArr.paths.push({ d: d }); } } } w.globals.previousPaths.push(dArr); } var linePaths = w.globals.dom.baseEl.querySelectorAll('.apexcharts-line-series .apexcharts-series'); if (linePaths.length > 0) { for (var p = linePaths.length - 1; p >= 0; p--) { pushPaths(linePaths, p, 'line'); } } var areapaths = w.globals.dom.baseEl.querySelectorAll('.apexcharts-area-series .apexcharts-series'); if (areapaths.length > 0) { for (var i = areapaths.length - 1; i >= 0; i--) { pushPaths(areapaths, i, 'area'); } } var barPaths = w.globals.dom.baseEl.querySelectorAll('.apexcharts-bar-series .apexcharts-series'); if (barPaths.length > 0) { for (var _p = 0; _p < barPaths.length; _p++) { pushPaths(barPaths, _p, 'bar'); } } var candlestickPaths = w.globals.dom.baseEl.querySelectorAll('.apexcharts-candlestick-series .apexcharts-series'); if (candlestickPaths.length > 0) { for (var _p2 = 0; _p2 < candlestickPaths.length; _p2++) { pushPaths(candlestickPaths, _p2, 'candlestick'); } } var bubblepaths = w.globals.dom.baseEl.querySelectorAll('.apexcharts-bubble-series .apexcharts-series'); if (bubblepaths.length > 0) { for (var s = 0; s < bubblepaths.length; s++) { var seriesEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-bubble-series .apexcharts-series[data\\:realIndex=\'' + s + '\'] circle'); var dArr = []; for (var _i = 0; _i < seriesEls.length; _i++) { dArr.push({ x: seriesEls[_i].getAttribute('cx'), y: seriesEls[_i].getAttribute('cy'), r: seriesEls[_i].getAttribute('r') }); } w.globals.previousPaths.push(dArr); } } var scatterpaths = w.globals.dom.baseEl.querySelectorAll('.apexcharts-scatter-series .apexcharts-series'); if (scatterpaths.length > 0) { for (var _s = 0; _s < scatterpaths.length; _s++) { var _seriesEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-scatter-series .apexcharts-series[data\\:realIndex=\'' + _s + '\'] circle'); var _dArr = []; for (var _i2 = 0; _i2 < _seriesEls.length; _i2++) { _dArr.push({ x: _seriesEls[_i2].getAttribute('cx'), y: _seriesEls[_i2].getAttribute('cy'), r: _seriesEls[_i2].getAttribute('r') }); } w.globals.previousPaths.push(_dArr); } } var heatmapColors = w.globals.dom.baseEl.querySelectorAll('.apexcharts-heatmap .apexcharts-series'); if (heatmapColors.length > 0) { for (var h = 0; h < heatmapColors.length; h++) { var _seriesEls2 = w.globals.dom.baseEl.querySelectorAll('.apexcharts-heatmap .apexcharts-series[data\\:realIndex=\'' + h + '\'] rect'); var _dArr2 = []; for (var _i3 = 0; _i3 < _seriesEls2.length; _i3++) { _dArr2.push({ color: _seriesEls2[_i3].getAttribute('color') }); } w.globals.previousPaths.push(_dArr2); } } if (!w.globals.axisCharts) { // for non-axis charts (i.e., circular charts, pathFrom is not usable. We need whole series) w.globals.previousPaths = w.globals.series; } } }, { key: 'handleNoData', value: function handleNoData() { var w = this.w; var me = this; var noDataOpts = w.config.noData; var graphics = new _Graphics2.default(me.ctx); var x = w.globals.svgWidth / 2; var y = w.globals.svgHeight / 2; var textAnchor = 'middle'; w.globals.noData = true; if (noDataOpts.align === 'left') { x = 10; textAnchor = 'start'; } else if (noDataOpts.align === 'right') { x = w.globals.svgWidth - 10; textAnchor = 'end'; } if (noDataOpts.verticalAlign === 'top') { y = 50; } else if (noDataOpts.verticalAlign === 'bottom') { y = w.globals.svgHeight - 50; } x = x + noDataOpts.offsetX; y = y + parseInt(noDataOpts.style.fontSize) + 2; if (noDataOpts.text !== undefined && noDataOpts.text !== '') { var titleText = graphics.drawText({ x: x, y: y, text: noDataOpts.text, textAnchor: textAnchor, fontSize: noDataOpts.style.fontSize, fontFamily: noDataOpts.style.fontFamily, foreColor: noDataOpts.style.color, opacity: 1, class: 'apexcharts-text-nodata' }); titleText.node.setAttribute('class', 'apexcharts-title-text'); w.globals.dom.Paper.add(titleText); } } // When user clicks on legends, the collapsed series is filled with [0,0,0,...,0] // This is because we don't want to alter the series' length as it is used at many places }, { key: 'setNullSeriesToZeroValues', value: function setNullSeriesToZeroValues(series) { var w = this.w; for (var sl = 0; sl < series.length; sl++) { if (series[sl].length === 0) { for (var j = 0; j < series[w.globals.maxValsInArrayIndex].length; j++) { series[sl].push(0); } } } return series; } }]); return Series; }(); exports.default = Series; /***/ }), /* 27 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = __webpack_require__(64); var enumBugKeys = __webpack_require__(35); module.exports = Object.keys || function keys(O) { return $keys(O, enumBugKeys); }; /***/ }), /* 28 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var def = __webpack_require__(9).f; var has = __webpack_require__(11); var TAG = __webpack_require__(2)('toStringTag'); module.exports = function (it, tag, stat) { if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag }); }; /***/ }), /* 29 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 7.1.13 ToObject(argument) var defined = __webpack_require__(33); module.exports = function (it) { return Object(defined(it)); }; /***/ }), /* 30 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _DateTime = __webpack_require__(52); var _DateTime2 = _interopRequireDefault(_DateTime); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Formatter Class for setting value formatters for axes as well as tooltips. * * @module Formatters **/ var Formatters = function () { function Formatters(ctx) { _classCallCheck(this, Formatters); this.ctx = ctx; this.w = ctx.w; this.tooltipKeyFormat = 'dd MMM'; } _createClass(Formatters, [{ key: 'xLabelFormat', value: function xLabelFormat(fn, val) { var w = this.w; if (w.config.xaxis.type === 'datetime') { // if user has not specified a custom formatter, use the default tooltip.x.format if (w.config.tooltip.x.formatter === undefined) { var datetimeObj = new _DateTime2.default(this.ctx); return datetimeObj.formatDate(new Date(val), w.config.tooltip.x.format, true, true); } } return fn(val); } }, { key: 'setLabelFormatters', value: function setLabelFormatters() { var w = this.w; w.globals.xLabelFormatter = function (val) { return val; }; w.globals.xaxisTooltipFormatter = function (val) { return val; }; w.globals.ttKeyFormatter = function (val) { return val; }; w.globals.ttZFormatter = function (val) { return val; }; w.globals.legendFormatter = function (val) { return val; }; if (typeof w.config.tooltip.x.formatter === 'function') { w.globals.ttKeyFormatter = w.config.tooltip.x.formatter; } if (typeof w.config.xaxis.tooltip.formatter === 'function') { w.globals.xaxisTooltipFormatter = w.config.xaxis.tooltip.formatter; } if (Array.isArray(w.config.tooltip.y)) { w.globals.ttVal = w.config.tooltip.y; } else { if (w.config.tooltip.y.formatter !== undefined) { w.globals.ttVal = w.config.tooltip.y; } } if (w.config.tooltip.z.formatter !== undefined) { w.globals.ttZFormatter = w.config.tooltip.z.formatter; } // legend formatter - if user wants to append any global values of series to legend text if (w.config.legend.formatter !== undefined) { w.globals.legendFormatter = w.config.legend.formatter; } // formatter function will always overwrite format property if (w.config.xaxis.labels.formatter !== undefined) { w.globals.xLabelFormatter = w.config.xaxis.labels.formatter; } else { w.globals.xLabelFormatter = function (val) { if (_Utils2.default.isNumber(val)) { // numeric xaxis may have smaller range, so defaulting to 1 decimal if (w.config.xaxis.type === 'numeric' && w.globals.dataPoints < 50) { return val.toFixed(1); } return val.toFixed(0); } return val; }; } // formatter function will always overwrite format property w.config.yaxis.forEach(function (yaxe, i) { if (typeof yaxe.labels.formatter === 'function') { w.globals.yLabelFormatters[i] = yaxe.labels.formatter; } else { w.globals.yLabelFormatters[i] = function (val) { if (_Utils2.default.isNumber(val)) { if (w.globals.yValueDecimal !== 0) { return val.toFixed(yaxe.decimalsInFloat); } else { return val.toFixed(0); } } return val; }; } }); return w.globals; } }, { key: 'heatmapLabelFormatters', value: function heatmapLabelFormatters() { var w = this.w; if (w.config.chart.type === 'heatmap') { w.globals.yAxisScale[0].result = w.globals.seriesNames.slice(); // get the longest string from the labels array and also apply label formatter to it var longest = w.globals.seriesNames.reduce(function (a, b) { return a.length > b.length ? a : b; }, 0); w.globals.yAxisScale[0].niceMax = longest; w.globals.yAxisScale[0].niceMin = longest; // cnf.yaxis[0].labels.formatter = function (val) { // return val // } w.globals.yLabelFormatters[0] = function (val) { return val; }; } } }]); return Formatters; }(); exports.default = Formatters; /***/ }), /* 31 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 22.1.3.31 Array.prototype[@@unscopables] var UNSCOPABLES = __webpack_require__(2)('unscopables'); var ArrayProto = Array.prototype; if (ArrayProto[UNSCOPABLES] == undefined) __webpack_require__(12)(ArrayProto, UNSCOPABLES, {}); module.exports = function (key) { ArrayProto[UNSCOPABLES][key] = true; }; /***/ }), /* 32 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // getting tag from 19.1.3.6 Object.prototype.toString() var cof = __webpack_require__(18); var TAG = __webpack_require__(2)('toStringTag'); // ES3 wrong here var ARG = cof(function () { return arguments; }()) == 'Arguments'; // fallback for IE11 Script Access Denied error var tryGet = function tryGet(it, key) { try { return it[key]; } catch (e) {/* empty */} }; module.exports = function (it) { var O, T, B; return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T // builtinTag case : ARG ? cof(O) // ES3 arguments fallback : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; }; /***/ }), /* 33 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 7.2.1 RequireObjectCoercible(argument) module.exports = function (it) { if (it == undefined) throw TypeError("Can't call method on " + it); return it; }; /***/ }), /* 34 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var isObject = __webpack_require__(8); var document = __webpack_require__(3).document; // typeof document.createElement is 'object' in old IE var is = isObject(document) && isObject(document.createElement); module.exports = function (it) { return is ? document.createElement(it) : {}; }; /***/ }), /* 35 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // IE 8- don't enum bug keys module.exports = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(','); /***/ }), /* 36 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // fallback for non-array-like ES3 and non-enumerable old V8 strings var cof = __webpack_require__(18); // eslint-disable-next-line no-prototype-builtins module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { return cof(it) == 'String' ? it.split('') : Object(it); }; /***/ }), /* 37 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 25.4.1.5 NewPromiseCapability(C) var aFunction = __webpack_require__(17); function PromiseCapability(C) { var resolve, reject; this.promise = new C(function ($$resolve, $$reject) { if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); resolve = $$resolve; reject = $$reject; }); this.resolve = aFunction(resolve); this.reject = aFunction(reject); } module.exports.f = function (C) { return new PromiseCapability(C); }; /***/ }), /* 38 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.f = {}.propertyIsEnumerable; /***/ }), /* 39 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var shared = __webpack_require__(40)('keys'); var uid = __webpack_require__(24); module.exports = function (key) { return shared[key] || (shared[key] = uid(key)); }; /***/ }), /* 40 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var core = __webpack_require__(4); var global = __webpack_require__(3); var SHARED = '__core-js_shared__'; var store = global[SHARED] || (global[SHARED] = {}); (module.exports = function (key, value) { return store[key] || (store[key] = value !== undefined ? value : {}); })('versions', []).push({ version: core.version, mode: __webpack_require__(21) ? 'pure' : 'global', copyright: '© 2018 Denis Pushkarev (zloirock.ru)' }); /***/ }), /* 41 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 7.1.4 ToInteger var ceil = Math.ceil; var floor = Math.floor; module.exports = function (it) { return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; /***/ }), /* 42 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 7.1.1 ToPrimitive(input [, PreferredType]) var isObject = __webpack_require__(8); // instead of the ES6 spec version, we didn't implement @@toPrimitive case // and the second argument - flag - preferred type is a string module.exports = function (it, S) { if (!isObject(it)) return it; var fn, val; if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; throw TypeError("Can't convert object to primitive value"); }; /***/ }), /* 43 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var global = __webpack_require__(3); var core = __webpack_require__(4); var LIBRARY = __webpack_require__(21); var wksExt = __webpack_require__(69); var defineProperty = __webpack_require__(9).f; module.exports = function (name) { var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {}); if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) }); }; /***/ }), /* 44 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Fill = __webpack_require__(13); var _Fill2 = _interopRequireDefault(_Fill); var _Filters = __webpack_require__(6); var _Filters2 = _interopRequireDefault(_Filters); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _DataLabels = __webpack_require__(45); var _DataLabels2 = _interopRequireDefault(_DataLabels); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Bar Class responsible for drawing both Columns and Bars. * * @module Bar **/ var Bar = function () { function Bar(ctx, xyRatios) { _classCallCheck(this, Bar); this.ctx = ctx; this.w = ctx.w; var w = this.w; this.barOptions = w.config.plotOptions.bar; this.isHorizontal = this.barOptions.horizontal; this.strokeWidth = w.config.stroke.width; this.isNullValue = false; this.xyRatios = xyRatios; if (this.xyRatios !== null) { this.xRatio = xyRatios.xRatio; this.yRatio = xyRatios.yRatio; this.invertedXRatio = xyRatios.invertedXRatio; this.invertedYRatio = xyRatios.invertedYRatio; this.baseLineY = xyRatios.baseLineY; this.baseLineInvertedY = xyRatios.baseLineInvertedY; } this.yaxisIndex = 0; this.seriesLen = 0; } /** primary draw method which is called on bar object * @memberof Bar * @param {array} series - user supplied series values * @param {int} seriesIndex - the index by which series will be drawn on the svg * @return {node} element which is supplied to parent chart draw method for appending **/ _createClass(Bar, [{ key: 'draw', value: function draw(series, seriesIndex) { var _this = this; var w = this.w; var graphics = new _Graphics2.default(this.ctx); var fill = new _Fill2.default(this.ctx); this.initVariables(series); var ret = graphics.group({ class: 'apexcharts-bar-series apexcharts-plot-series' }); ret.attr('clip-path', 'url(#gridRectMask' + w.globals.cuid + ')'); var _loop = function _loop(i, bc) { var pathTo = void 0, pathFrom = void 0; var x = void 0, y = void 0, xDivision = void 0, // xDivision is the GRIDWIDTH divided by number of datapoints (columns) yDivision = void 0, // yDivision is the GRIDHEIGHT divided by number of datapoints (bars) zeroH = void 0, // zeroH is the baseline where 0 meets y axis zeroW = void 0; // zeroW is the baseline where 0 meets x axis var yArrj = []; // hold y values of current iterating series var xArrj = []; // hold x values of current iterating series var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn var elSeries = graphics.group({ class: 'apexcharts-series ' + w.globals.seriesNames[realIndex].replace(/ /g, '-'), 'rel': i + 1, 'data:realIndex': realIndex }); _this.ctx.series.addCollapsedClassToSeries(elSeries, realIndex); if (series[i].length > 0) { _this.visibleI = _this.visibleI + 1; } var strokeWidth = 0; var barHeight = 0; var barWidth = 0; if (_this.yRatio.length > 1) { _this.yaxisIndex = realIndex; } var initPositions = _this.initialPositions(); y = initPositions.y; barHeight = initPositions.barHeight; yDivision = initPositions.yDivision; zeroW = initPositions.zeroW; x = initPositions.x; barWidth = initPositions.barWidth; xDivision = initPositions.xDivision; zeroH = initPositions.zeroH; if (!_this.horizontal) { xArrj.push(x + barWidth / 2); } // eldatalabels var elDataLabelsWrap = graphics.group({ class: 'apexcharts-datalabels' }); var _loop2 = function _loop2(j, tj) { if (typeof _this.series[i][j] === 'undefined' || series[i][j] === null) { _this.isNullValue = true; } else { _this.isNullValue = false; } if (w.config.stroke.show) { if (_this.isNullValue) { strokeWidth = 0; } else { strokeWidth = Array.isArray(_this.strokeWidth) ? _this.strokeWidth[realIndex] : _this.strokeWidth; } } var paths = null; if (_this.isHorizontal) { paths = _this.drawBarPaths({ indexes: { i: i, j: j, realIndex: realIndex, bc: bc }, barHeight: barHeight, strokeWidth: strokeWidth, pathTo: pathTo, pathFrom: pathFrom, zeroW: zeroW, x: x, y: y, yDivision: yDivision, elSeries: elSeries }); } else { paths = _this.drawColumnPaths({ indexes: { i: i, j: j, realIndex: realIndex, bc: bc }, x: x, y: y, xDivision: xDivision, pathTo: pathTo, pathFrom: pathFrom, barWidth: barWidth, zeroH: zeroH, strokeWidth: strokeWidth, elSeries: elSeries }); } pathTo = paths.pathTo; pathFrom = paths.pathFrom; y = paths.y; x = paths.x; // push current X if (j > 0) { xArrj.push(x + barWidth / 2); } yArrj.push(y); var seriesNumber = _this.barOptions.distributed ? j : i; var fillColor = null; if (_this.barOptions.colors.ranges.length > 0) { var colorRange = _this.barOptions.colors.ranges; colorRange.map(function (range) { if (series[i][j] >= range.from && series[i][j] <= range.to) { fillColor = range.color; } }); } var pathFill = fill.fillPath(elSeries, { seriesNumber: _this.barOptions.distributed ? seriesNumber : realIndex, color: fillColor }); elSeries = _this.renderSeries({ realIndex: realIndex, pathFill: pathFill, j: j, i: i, pathFrom: pathFrom, pathTo: pathTo, strokeWidth: strokeWidth, elSeries: elSeries, x: x, y: y, series: series, barHeight: barHeight, barWidth: barWidth, elDataLabelsWrap: elDataLabelsWrap, visibleSeries: _this.visibleI, type: 'bar' }); }; for (var j = 0, tj = w.globals.dataPoints; j < w.globals.dataPoints; j++, tj--) { _loop2(j, tj); } // push all x val arrays into main xArr w.globals.seriesXvalues[realIndex] = xArrj; w.globals.seriesYvalues[realIndex] = yArrj; ret.add(elSeries); }; for (var i = 0, bc = 0; i < series.length; i++, bc++) { _loop(i, bc); } return ret; } }, { key: 'renderSeries', value: function renderSeries(_ref) { var realIndex = _ref.realIndex, pathFill = _ref.pathFill, lineFill = _ref.lineFill, j = _ref.j, i = _ref.i, pathFrom = _ref.pathFrom, pathTo = _ref.pathTo, strokeWidth = _ref.strokeWidth, elSeries = _ref.elSeries, x = _ref.x, y = _ref.y, series = _ref.series, barHeight = _ref.barHeight, barWidth = _ref.barWidth, elDataLabelsWrap = _ref.elDataLabelsWrap, visibleSeries = _ref.visibleSeries, type = _ref.type; var w = this.w; var graphics = new _Graphics2.default(this.ctx); if (!lineFill) { lineFill = w.globals.stroke.colors[realIndex]; } if (this.isNullValue) { pathFill = 'none'; } var delay = j / w.config.chart.animations.animateGradually.delay * (w.config.chart.animations.speed / w.globals.dataPoints) / 2.4; var renderedPath = graphics.renderPaths({ i: i, j: j, realIndex: realIndex, pathFrom: pathFrom, pathTo: pathTo, stroke: lineFill, strokeWidth: strokeWidth, strokeLineCap: w.config.stroke.lineCap, fill: pathFill, animationDelay: delay, initialSpeed: w.config.chart.animations.speed, dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed, className: 'apexcharts-' + type + '-area', id: 'apexcharts-' + type + '-area' }); this.setSelectedBarFilter(renderedPath, realIndex, j); elSeries.add(renderedPath); var dataLabels = this.calculateDataLabelsPos({ x: x, y: y, i: i, j: j, series: series, realIndex: realIndex, barHeight: barHeight, barWidth: barWidth, renderedPath: renderedPath, visibleSeries: visibleSeries }); if (dataLabels !== null) { elDataLabelsWrap.add(dataLabels); } elSeries.add(elDataLabelsWrap); return elSeries; } }, { key: 'initVariables', value: function initVariables(series) { var w = this.w; this.series = series; this.totalItems = 0; this.seriesLen = 0; this.visibleI = -1; this.visibleItems = 1; // number of visible bars after user zoomed in/out for (var sl = 0; sl < series.length; sl++) { if (series[sl].length > 0) { this.seriesLen = this.seriesLen + 1; this.totalItems += series[sl].length; } if (w.globals.isXNumeric) { for (var j = 0; j < series[sl].length; j++) { if (w.globals.seriesX[sl][j] > w.globals.minX && w.globals.seriesX[sl][j] < w.globals.maxX) { this.visibleItems++; } } } else { this.visibleItems = w.globals.dataPoints; } } if (this.seriesLen === 0) { // A small adjustment when combo charts are used this.seriesLen = 1; } } }, { key: 'initialPositions', value: function initialPositions() { var w = this.w; var x = void 0, y = void 0, yDivision = void 0, xDivision = void 0, barHeight = void 0, barWidth = void 0, zeroH = void 0, zeroW = void 0; if (this.isHorizontal) { // height divided into equal parts yDivision = w.globals.gridHeight / w.globals.dataPoints; barHeight = yDivision / this.seriesLen; if (w.globals.isXNumeric) { yDivision = w.globals.gridHeight / this.totalItems; barHeight = yDivision / this.seriesLen; } barHeight = barHeight * parseInt(this.barOptions.barHeight) / 100; zeroW = this.baseLineInvertedY + w.globals.padHorizontal; y = (yDivision - barHeight * this.seriesLen) / 2; } else { // width divided into equal parts xDivision = w.globals.gridWidth / this.visibleItems; barWidth = xDivision / this.seriesLen * parseInt(this.barOptions.columnWidth) / 100; zeroH = w.globals.gridHeight - this.baseLineY[this.yaxisIndex]; x = w.globals.padHorizontal + (xDivision - barWidth * this.seriesLen) / 2; } return { x: x, y: y, yDivision: yDivision, xDivision: xDivision, barHeight: barHeight, barWidth: barWidth, zeroH: zeroH, zeroW: zeroW }; } }, { key: 'drawBarPaths', value: function drawBarPaths(_ref2) { var indexes = _ref2.indexes, barHeight = _ref2.barHeight, strokeWidth = _ref2.strokeWidth, pathTo = _ref2.pathTo, pathFrom = _ref2.pathFrom, zeroW = _ref2.zeroW, x = _ref2.x, y = _ref2.y, yDivision = _ref2.yDivision, elSeries = _ref2.elSeries; var w = this.w; var graphics = new _Graphics2.default(this.ctx); var i = indexes.i; var j = indexes.j; var realIndex = indexes.realIndex; var bc = indexes.bc; if (w.globals.isXNumeric) { y = (w.globals.seriesX[i][j] - w.globals.minX) / this.invertedXRatio - barHeight; } var barYPosition = y + barHeight * this.visibleI; pathTo = graphics.move(zeroW, barYPosition); pathFrom = graphics.move(zeroW, barYPosition); if (w.globals.previousPaths.length > 0) { pathFrom = this.getPathFrom(realIndex, j, true); } if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) { x = zeroW; } else { x = zeroW + this.series[i][j] / this.invertedYRatio; } var endingShapeOpts = { barHeight: barHeight, strokeWidth: strokeWidth, barYPosition: barYPosition, x: x, zeroW: zeroW }; var endingShape = this.barEndingShape(w, endingShapeOpts, this.series, i, j); pathTo = pathTo + graphics.line(endingShape.newX, barYPosition) + endingShape.path + graphics.line(zeroW, barYPosition + barHeight - strokeWidth) + graphics.line(zeroW, barYPosition); pathFrom = pathFrom + graphics.line(zeroW, barYPosition) + endingShape.ending_p_from + graphics.line(zeroW, barYPosition + barHeight - strokeWidth) + graphics.line(zeroW, barYPosition + barHeight - strokeWidth) + graphics.line(zeroW, barYPosition); if (!w.globals.isXNumeric) { y = y + yDivision; } if (this.barOptions.colors.backgroundBarColors.length > 0 && i === 0) { if (bc >= this.barOptions.colors.backgroundBarColors.length) { bc = 0; } var bcolor = this.barOptions.colors.backgroundBarColors[bc]; var rect = graphics.drawRect(0, barYPosition - barHeight * this.visibleI, w.globals.gridWidth, barHeight * this.seriesLen, 0, bcolor, this.barOptions.colors.backgroundBarOpacity); elSeries.add(rect); rect.node.classList.add('apexcharts-backgroundBar'); } return { pathTo: pathTo, pathFrom: pathFrom, x: x, y: y, barYPosition: barYPosition }; } }, { key: 'drawColumnPaths', value: function drawColumnPaths(_ref3) { var indexes = _ref3.indexes, x = _ref3.x, y = _ref3.y, xDivision = _ref3.xDivision, pathTo = _ref3.pathTo, pathFrom = _ref3.pathFrom, barWidth = _ref3.barWidth, zeroH = _ref3.zeroH, strokeWidth = _ref3.strokeWidth, elSeries = _ref3.elSeries; var w = this.w; var graphics = new _Graphics2.default(this.ctx); var i = indexes.i; var j = indexes.j; var realIndex = indexes.realIndex; var bc = indexes.bc; if (w.globals.isXNumeric) { x = (w.globals.seriesX[i][j] - w.globals.minX) / this.xRatio - barWidth / 2; } var barXPosition = x + barWidth * this.visibleI; pathTo = graphics.move(barXPosition, zeroH); pathFrom = graphics.move(barXPosition, zeroH); if (w.globals.previousPaths.length > 0) { pathFrom = this.getPathFrom(realIndex, j, true); } if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) { y = zeroH; } else { y = zeroH - this.series[i][j] / this.yRatio[this.yaxisIndex]; } var endingShapeOpts = { barWidth: barWidth, strokeWidth: strokeWidth, barXPosition: barXPosition, y: y, zeroH: zeroH }; var endingShape = this.barEndingShape(w, endingShapeOpts, this.series, i, j); pathTo = pathTo + graphics.line(barXPosition, endingShape.newY) + endingShape.path + graphics.line(barXPosition + barWidth - strokeWidth, zeroH) + graphics.line(barXPosition, zeroH); pathFrom = pathFrom + graphics.line(barXPosition, zeroH) + endingShape.ending_p_from + graphics.line(barXPosition + barWidth - strokeWidth, zeroH) + graphics.line(barXPosition + barWidth - strokeWidth, zeroH) + graphics.line(barXPosition, zeroH); if (!w.globals.isXNumeric) { x = x + xDivision; } if (this.barOptions.colors.backgroundBarColors.length > 0 && i === 0) { if (bc >= this.barOptions.colors.backgroundBarColors.length) { bc = 0; } var bcolor = this.barOptions.colors.backgroundBarColors[bc]; var rect = graphics.drawRect(barXPosition - barWidth * this.visibleI, 0, barWidth * this.seriesLen, w.globals.gridHeight, 0, bcolor, this.barOptions.colors.backgroundBarOpacity); elSeries.add(rect); rect.node.classList.add('apexcharts-backgroundBar'); } return { pathTo: pathTo, pathFrom: pathFrom, x: x, y: y, barXPosition: barXPosition }; } /** getPathFrom is a common function for bars/columns which is used to get previous paths when data changes. * @memberof Bar * @param {int} realIndex - current iterating i * @param {int} j - current iterating series's j index * @param {bool} typeGroup - Bars/columns are not stacked, but grouped * @return {string} pathFrom is the string which will be appended in animations **/ }, { key: 'getPathFrom', value: function getPathFrom(realIndex, j) { var typeGroup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; var w = this.w; var pathFrom = void 0; for (var pp = 0; pp < w.globals.previousPaths.length; pp++) { var gpp = w.globals.previousPaths[pp]; if (gpp.paths.length > 0 && parseInt(gpp.realIndex) === parseInt(realIndex)) { if (typeof w.globals.previousPaths[pp].paths[j] !== 'undefined') { pathFrom = w.globals.previousPaths[pp].paths[j].d; } } } return pathFrom; } /** calculateBarDataLabels is used to calculate the positions for the data-labels * It also sets the element's data attr for bars and calls drawCalculatedBarDataLabels() * @memberof Bar * @param {object} {barProps} most of the bar properties used throughout the bar * drawing function * @return {object} dataLabels node-element which you can append later **/ }, { key: 'calculateDataLabelsPos', value: function calculateDataLabelsPos(_ref4) { var x = _ref4.x, y = _ref4.y, i = _ref4.i, j = _ref4.j, realIndex = _ref4.realIndex, series = _ref4.series, barHeight = _ref4.barHeight, barWidth = _ref4.barWidth, visibleSeries = _ref4.visibleSeries, renderedPath = _ref4.renderedPath; var w = this.w; var graphics = new _Graphics2.default(this.ctx); var strokeWidth = Array.isArray(this.strokeWidth) ? this.strokeWidth[realIndex] : this.strokeWidth; var bcx = x + parseFloat(barWidth * visibleSeries); var bcy = y + parseFloat(barHeight * visibleSeries); if (w.globals.isXNumeric) { bcx = x + parseFloat(barWidth * (visibleSeries + 1)) - strokeWidth; bcy = y + parseFloat(barHeight * (visibleSeries + 1)) - strokeWidth; } var dataLabels = null; var dataLabelsX = x; var dataLabelsY = y; var dataLabelsPos = {}; var dataLabelsConfig = w.config.dataLabels; var barDataLabelsConfig = this.barOptions.dataLabels; var offX = dataLabelsConfig.offsetX; var offY = dataLabelsConfig.offsetY; var textRects = graphics.getTextRects(w.globals.yLabelFormatters[0](w.globals.maxY), parseInt(dataLabelsConfig.style.fontSize)); if (this.isHorizontal) { dataLabelsPos = this.calculateBarsDataLabelsPosition({ x: x, y: y, i: i, j: j, bcy: bcy, barHeight: barHeight, textRects: textRects, strokeWidth: strokeWidth, dataLabelsX: dataLabelsX, dataLabelsY: dataLabelsY, barDataLabelsConfig: barDataLabelsConfig, offX: offX, offY: offY }); } else { dataLabelsPos = this.calculateColumnsDataLabelsPosition({ x: x, y: y, i: i, j: j, realIndex: realIndex, bcx: bcx, bcy: bcy, barHeight: barHeight, barWidth: barWidth, textRects: textRects, strokeWidth: strokeWidth, dataLabelsY: dataLabelsY, barDataLabelsConfig: barDataLabelsConfig, offX: offX, offY: offY }); } renderedPath.attr({ cy: dataLabelsPos.bcy, cx: dataLabelsPos.bcx, j: j, val: series[i][j], barHeight: barHeight, barWidth: barWidth }); dataLabels = this.drawCalculatedDataLabels({ x: dataLabelsPos.dataLabelsX, y: dataLabelsPos.dataLabelsY, val: series[i][j], i: realIndex, j: j, dataLabelsConfig: dataLabelsConfig }); return dataLabels; } }, { key: 'calculateColumnsDataLabelsPosition', value: function calculateColumnsDataLabelsPosition(opts) { var w = this.w; var i = opts.i, j = opts.j, realIndex = opts.realIndex, y = opts.y, bcx = opts.bcx, barWidth = opts.barWidth, textRects = opts.textRects, dataLabelsY = opts.dataLabelsY, barDataLabelsConfig = opts.barDataLabelsConfig, strokeWidth = opts.strokeWidth, offX = opts.offX, offY = opts.offY; var dataLabelsX = void 0; var barHeight = this.series[i][j] / this.yRatio[this.yaxisIndex]; var dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints; bcx = bcx - strokeWidth / 2; if (w.globals.isXNumeric) { dataLabelsX = bcx - barWidth / 2 + offX; } else { dataLabelsX = bcx - dataPointsDividedWidth + barWidth / 2 + offX; } var baseline = w.globals.gridHeight - this.baseLineY[this.yaxisIndex]; var valIsNegative = !!(y > baseline && Math.abs(this.baseLineY[this.yaxisIndex]) !== 0); var negValuesPresent = Math.abs(w.globals.minYArr[realIndex]) !== 0; switch (barDataLabelsConfig.position) { case 'center': dataLabelsY = y + barHeight / 2 + textRects.height / 2 - offY; if (negValuesPresent) { if (valIsNegative) { dataLabelsY = y + barHeight / 2 + textRects.height / 2 + offY; } else { dataLabelsY = y + barHeight / 2 + textRects.height / 2 - offY; } } break; case 'bottom': if (negValuesPresent) { if (valIsNegative) { dataLabelsY = y + barHeight + textRects.height + strokeWidth + offY; } else { dataLabelsY = y + barHeight - textRects.height / 2 + strokeWidth - offY; } } else { dataLabelsY = w.globals.gridHeight - textRects.height / 2 - offY; } break; case 'top': if (negValuesPresent) { if (valIsNegative) { dataLabelsY = y - textRects.height / 2 - offY; } else { dataLabelsY = y + textRects.height + offY; } } else { dataLabelsY = y + textRects.height + offY; } break; } return { bcx: bcx, bcy: y, dataLabelsX: dataLabelsX, dataLabelsY: dataLabelsY }; } }, { key: 'calculateBarsDataLabelsPosition', value: function calculateBarsDataLabelsPosition(opts) { var w = this.w; var x = opts.x, i = opts.i, j = opts.j, bcy = opts.bcy, barHeight = opts.barHeight, textRects = opts.textRects, dataLabelsX = opts.dataLabelsX, strokeWidth = opts.strokeWidth, barDataLabelsConfig = opts.barDataLabelsConfig, offX = opts.offX, offY = opts.offY; var dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints; var dataLabelsY = bcy - dataPointsDividedHeight + barHeight / 2 + textRects.height / 2 + offY - 3; var barWidth = this.series[i][j] / this.invertedYRatio; var valIsNegative = this.series[i][j] <= 0; var negValuesPresent = Math.abs(w.globals.minY) !== 0; switch (barDataLabelsConfig.position) { case 'center': dataLabelsX = x - barWidth / 2 + offX; if (negValuesPresent) { if (valIsNegative) { dataLabelsX = x - barWidth / 2 - offX; } else { dataLabelsX = x - barWidth / 2 + offX; } } break; case 'bottom': if (negValuesPresent) { if (valIsNegative) { dataLabelsX = x - barWidth - strokeWidth - Math.round(textRects.width / 2) - offX; } else { dataLabelsX = x - barWidth + strokeWidth + Math.round(textRects.width / 2) + offX; } } else { dataLabelsX = x - barWidth + strokeWidth + Math.round(textRects.width / 2) + offX; } break; case 'top': if (negValuesPresent) { if (valIsNegative) { dataLabelsX = x - strokeWidth + Math.round(textRects.width / 2) - offX; } else { dataLabelsX = x - strokeWidth - Math.round(textRects.width / 2) + offX; } } else { dataLabelsX = x + strokeWidth - Math.round(textRects.width / 2) + offX; } break; } if (dataLabelsX < 0) { dataLabelsX = textRects.width + strokeWidth; } else if (dataLabelsX + textRects.width / 2 > w.globals.gridWidth) { dataLabelsX = dataLabelsX - textRects.width - strokeWidth; } return { bcx: x, bcy: bcy, dataLabelsX: dataLabelsX, dataLabelsY: dataLabelsY }; } }, { key: 'drawCalculatedDataLabels', value: function drawCalculatedDataLabels(_ref5) { var x = _ref5.x, y = _ref5.y, val = _ref5.val, i = _ref5.i, j = _ref5.j, dataLabelsConfig = _ref5.dataLabelsConfig; var w = this.w; var dataLabels = new _DataLabels2.default(this.ctx); var graphics = new _Graphics2.default(this.ctx); var formatter = dataLabelsConfig.formatter; var elDataLabelsWrap = null; var isSeriesNotCollapsed = w.globals.collapsedSeriesIndices.indexOf(i) > -1; if (dataLabelsConfig.enabled && !isSeriesNotCollapsed) { elDataLabelsWrap = graphics.group({ class: 'apexcharts-data-labels' }); var text = ''; if (typeof val !== 'undefined') { text = formatter(val, { seriesIndex: i, dataPointIndex: j, globals: w.globals }); } dataLabels.plotDataLabelsText(x, y, text, i, j, elDataLabelsWrap, dataLabelsConfig, true); } return elDataLabelsWrap; } /** barEndingShape draws the various shapes on top of bars/columns * @memberof Bar * @param {object} w - chart context * @param {object} opts - consists several properties like barHeight/barWidth * @param {array} series - global primary series * @param {int} i - current iterating series's index * @param {int} j - series's j of i * @return {object} path - ending shape whether round/arrow * ending_p_from - similar to pathFrom * newY - which is calculated from existing y and new shape's top **/ }, { key: 'barEndingShape', value: function barEndingShape(w, opts, series, i, j) { var graphics = new _Graphics2.default(this.ctx); if (this.isHorizontal) { var endingShape = null; var endingShapeFrom = ''; var _x2 = opts.x; if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) { var inverse = series[i][j] < 0; var eX = opts.barHeight / 2 - opts.strokeWidth; if (inverse) eX = -opts.barHeight / 2 - opts.strokeWidth; if (!w.config.chart.stacked) { // if (Math.abs(series[i][j] / this.invertedYRatio) > eX) { if (this.barOptions.endingShape === 'arrow') { _x2 = opts.x - eX; } else if (this.barOptions.endingShape === 'rounded') { _x2 = opts.x - eX / 2; } // } } switch (this.barOptions.endingShape) { case 'flat': endingShape = graphics.line(_x2, opts.barYPosition + opts.barHeight - opts.strokeWidth); break; case 'arrow': endingShape = graphics.line(_x2 + eX, opts.barYPosition + (opts.barHeight - opts.strokeWidth) / 2) + graphics.line(_x2, opts.barYPosition + opts.barHeight - opts.strokeWidth); endingShapeFrom = graphics.line(opts.zeroW, opts.barYPosition + opts.barHeight - opts.strokeWidth); break; case 'rounded': endingShape = graphics.quadraticCurve(_x2 + eX, opts.barYPosition + (opts.barHeight - opts.strokeWidth) / 2, _x2, opts.barYPosition + opts.barHeight - opts.strokeWidth); break; } } return { path: endingShape, ending_p_from: endingShapeFrom, newX: _x2 }; } else { var _endingShape = null; var _endingShapeFrom = ''; var _y = opts.y; if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) { var _inverse = series[i][j] < 0; var eY = opts.barWidth / 2 - opts.strokeWidth; if (_inverse) eY = -opts.barWidth / 2 - opts.strokeWidth; if (!w.config.chart.stacked) { // if (Math.abs(series[i][j] / this.yRatio[this.yaxisIndex]) > eY) { // the arrow exceeds the chart height, hence reduce y if (this.barOptions.endingShape === 'arrow') { _y = _y + eY; } else if (this.barOptions.endingShape === 'rounded') { _y = _y + eY / 2; } // } } switch (this.barOptions.endingShape) { case 'flat': _endingShape = graphics.line(opts.barXPosition + opts.barWidth - opts.strokeWidth, _y); break; case 'arrow': _endingShape = graphics.line(opts.barXPosition + (opts.barWidth - opts.strokeWidth) / 2, _y - eY) + graphics.line(opts.barXPosition + opts.barWidth - opts.strokeWidth, _y); _endingShapeFrom = graphics.line(opts.barXPosition + opts.barWidth - opts.strokeWidth, opts.zeroH); break; case 'rounded': _endingShape = graphics.quadraticCurve(opts.barXPosition + (opts.barWidth - opts.strokeWidth) / 2, _y - eY, opts.barXPosition + opts.barWidth - opts.strokeWidth, _y); break; } } return { path: _endingShape, ending_p_from: _endingShapeFrom, newY: _y }; } } }, { key: 'setSelectedBarFilter', value: function setSelectedBarFilter(el, realIndex, j) { var w = this.w; if (typeof w.globals.selectedDataPoints[realIndex] !== 'undefined') { if (w.globals.selectedDataPoints[realIndex].indexOf(j) > -1) { el.node.setAttribute('selected', true); var activeFilter = w.config.states.active.filter; if (activeFilter !== 'none') { var filters = new _Filters2.default(this.ctx); filters.applyFilter(el, activeFilter.type, activeFilter.value); } } } } }]); return Bar; }(); exports.default = Bar; /***/ }), /* 45 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Scatter = __webpack_require__(74); var _Scatter2 = _interopRequireDefault(_Scatter); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Filters = __webpack_require__(6); var _Filters2 = _interopRequireDefault(_Filters); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts DataLabels Class for drawing dataLabels on Axes based Charts. * * @module DataLabels **/ var DataLabels = function () { function DataLabels(ctx) { _classCallCheck(this, DataLabels); this.ctx = ctx; this.w = ctx.w; } // When there are many datalabels to be printed, and some of them overlaps each other in the same series, this method will take care of that // Also, when datalabels exceeds the drawable area and get clipped off, we need to adjust and move some pixels to make them visible again _createClass(DataLabels, [{ key: 'dataLabelsCorrection', value: function dataLabelsCorrection(x, y, val, i, realIndexP, alwaysDrawDataLabel, fontSize, pointSize) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var drawnextLabel = false; // var textRects = graphics.getTextRects(val, fontSize); var width = textRects.width; var height = textRects.height; // first value in series, so push an empty array if (typeof w.globals.dataLabelsRects[i] === 'undefined') w.globals.dataLabelsRects[i] = []; // then start pushing actual rects in that sub-array w.globals.dataLabelsRects[i].push({ x: x, y: y, width: width, height: height }); var len = w.globals.dataLabelsRects[i].length - 2; var lastDrawnIndex = typeof w.globals.lastDrawnDataLabelsIndexes[i] !== 'undefined' ? w.globals.lastDrawnDataLabelsIndexes[i][w.globals.lastDrawnDataLabelsIndexes[i].length - 1] : 0; if (typeof w.globals.dataLabelsRects[i][len] !== 'undefined') { var lastDataLabelRect = w.globals.dataLabelsRects[i][lastDrawnIndex]; if ( // next label forward and x not intersecting x > lastDataLabelRect.x + lastDataLabelRect.width + 2 || y > lastDataLabelRect.y + lastDataLabelRect.height + 2 || x + width < lastDataLabelRect.x // next label is going to be drawn backwards ) { // the 2 indexes don't override, so OK to draw next label drawnextLabel = true; } } if (realIndexP === 0 || alwaysDrawDataLabel) { drawnextLabel = true; } return { x: x, y: y, drawnextLabel: drawnextLabel }; } }, { key: 'drawDataLabel', value: function drawDataLabel(pos, i, j) { var z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; // this method handles line, area, bubble, scatter charts as those charts contains markers/points which have pre-defined x/y positions // all other charts like bars / heatmaps will define their own drawDataLabel routine var w = this.w; var graphics = new _Graphics2.default(this.ctx); var dataLabelsConfig = w.config.dataLabels; var x = 0; var y = 0; var realIndexP = j; var elDataLabelsWrap = null; if (!dataLabelsConfig.enabled || pos.x instanceof Array !== true) { return elDataLabelsWrap; } elDataLabelsWrap = graphics.group({ class: 'apexcharts-data-labels' }); for (var q = 0; q < pos.x.length; q++) { x = pos.x[q] + dataLabelsConfig.offsetX; y = pos.y[q] + dataLabelsConfig.offsetY - w.config.markers.size - 5; if (!isNaN(x)) { // a small hack as we have 2 points for the first val to connect it if (j === 1 && q === 0) realIndexP = 0; if (j === 1 && q === 1) realIndexP = 1; var val = w.globals.series[i][realIndexP]; var text = ''; if (w.config.chart.type === 'bubble') { text = w.globals.seriesZ[i][realIndexP]; y = pos.y[q] + w.config.dataLabels.offsetY; var scatter = new _Scatter2.default(this.ctx); var centerTextInBubbleCoords = scatter.centerTextInBubble(y, i, realIndexP); y = centerTextInBubbleCoords.y; } else { if (typeof val !== 'undefined') { text = w.config.dataLabels.formatter(val, { seriesIndex: i, dataPointIndex: realIndexP, globals: w.globals }); } } this.plotDataLabelsText(x, y, text, i, realIndexP, elDataLabelsWrap, w.config.dataLabels); } } return elDataLabelsWrap; } }, { key: 'plotDataLabelsText', value: function plotDataLabelsText(x, y, text, i, j, elToAppendTo, dataLabelsConfig) { var alwaysDrawDataLabel = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false; var w = this.w; var graphics = new _Graphics2.default(this.ctx); var correctedLabels = this.dataLabelsCorrection(x, y, text, i, j, alwaysDrawDataLabel, parseInt(dataLabelsConfig.style.fontSize), w.config.markers.size <= w.config.markers.hover.size ? w.config.markers.hover.size : w.config.markers.size); // when zoomed, we don't need to correct labels offsets, // but if normally, labels get cropped, correct them if (!w.globals.zoomed) { x = correctedLabels.x; y = correctedLabels.y; } if (correctedLabels.drawnextLabel) { var dataLabelText = graphics.drawText({ width: 100, height: parseInt(dataLabelsConfig.style.fontSize), x: x, y: y, foreColor: w.globals.dataLabels.style.colors[i], textAnchor: dataLabelsConfig.textAnchor, text: text, fontSize: dataLabelsConfig.style.fontSize, fontFamily: dataLabelsConfig.style.fontFamily }); dataLabelText.attr({ class: 'apexcharts-datalabel', cx: x, cy: y }); if (dataLabelsConfig.dropShadow.enabled) { var textShadow = dataLabelsConfig.dropShadow; var filters = new _Filters2.default(this.ctx); filters.dropShadow(dataLabelText, textShadow); } elToAppendTo.add(dataLabelText); if (typeof w.globals.lastDrawnDataLabelsIndexes[i] === 'undefined') { w.globals.lastDrawnDataLabelsIndexes[i] = []; } w.globals.lastDrawnDataLabelsIndexes[i].push(j); } } }]); return DataLabels; }(); exports.default = DataLabels; /***/ }), /* 46 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Formatters = __webpack_require__(30); var _Formatters2 = _interopRequireDefault(_Formatters); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); var _YAxis = __webpack_require__(49); var _YAxis2 = _interopRequireDefault(_YAxis); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Dimensions Class for calculating rects of all elements that are drawn and will be drawn. * * @module Dimensions **/ var Dimensions = function () { function Dimensions(ctx) { _classCallCheck(this, Dimensions); this.ctx = ctx; this.w = ctx.w; this.lgRect = {}; this.yAxisWidth = 0; this.xAxisHeight = 0; this.isSparkline = this.w.config.chart.sparkline.enabled; this.isBarHorizontal = !!(this.w.config.chart.type === 'bar' && this.w.config.plotOptions.bar.horizontal); } /** * @memberof Dimensions * @param {object} w - chart context **/ _createClass(Dimensions, [{ key: 'plotCoords', value: function plotCoords() { var w = this.w; var gl = w.globals; // if user specified a type in series too, turn on comboCharts flag if (w.config.series.length && typeof w.config.series[0].type !== 'undefined') { w.globals.comboCharts = true; } var lgRect = this.getLegendsRect(); if (gl.axisCharts) { // for line / area / scatter / column this.setGridCoordsForAxisCharts(lgRect); } else { // for pie / donuts / circle this.setGridCoordsForNonAxisCharts(lgRect); } this.titleSubtitleOffset(); } }, { key: 'conditionalChecksForAxisCoords', value: function conditionalChecksForAxisCoords(xaxisLabelCoords, xtitleCoords) { var w = this.w; this.xAxisHeight = (xaxisLabelCoords.height + xtitleCoords.height) * w.globals.lineHeightRatio + 15; this.xAxisWidth = xaxisLabelCoords.width; if (this.xAxisHeight - xtitleCoords.height > w.config.xaxis.labels.maxHeight) { this.xAxisHeight = w.config.xaxis.labels.maxHeight; } if (w.config.xaxis.labels.minHeight && this.xAxisHeight < w.config.xaxis.labels.minHeight) { this.xAxisHeight = w.config.xaxis.labels.minHeight; } if (w.config.xaxis.floating) { this.xAxisHeight = 0; } if (!this.isBarHorizontal) { this.yAxisWidth = this.getTotalYAxisWidth(); } else { this.yAxisWidth = w.globals.yLabelsCoords[0].width + w.globals.yTitleCoords[0].width + 15; } if (!w.globals.isMultipleYAxis) { if (this.yAxisWidth < w.config.yaxis[0].labels.minWidth) { this.yAxisWidth = w.config.yaxis[0].labels.minWidth; } if (this.yAxisWidth > w.config.yaxis[0].labels.maxWidth) { this.yAxisWidth = w.config.yaxis[0].labels.maxWidth; } } } }, { key: 'setGridCoordsForAxisCharts', value: function setGridCoordsForAxisCharts(lgRect) { var w = this.w; var gl = w.globals; var yaxisLabelCoords = this.getyAxisLabelsCoords(); var xaxisLabelCoords = this.getxAxisLabelsCoords(); var yTitleCoords = this.getyAxisTitleCoords(); var xtitleCoords = this.getxAxisTitleCoords(); w.globals.yLabelsCoords = []; w.globals.yTitleCoords = []; w.config.yaxis.map(function (yaxe, index) { // store the labels and titles coords in global vars w.globals.yLabelsCoords.push({ width: yaxisLabelCoords[index].width, index: index }); w.globals.yTitleCoords.push({ width: yTitleCoords[index].width, index: index }); }); this.conditionalChecksForAxisCoords(xaxisLabelCoords, xtitleCoords); gl.translateXAxisY = w.globals.rotateXLabels ? this.xAxisHeight / 8 : -4; gl.translateXAxisX = w.globals.rotateXLabels && w.globals.isXNumeric && w.config.xaxis.labels.rotate <= -45 ? -this.xAxisWidth / 4 : 0; if (this.isBarHorizontal) { gl.rotateXLabels = false; gl.translateXAxisY = -1 * (parseInt(w.config.xaxis.labels.style.fontSize) / 1.5); } gl.translateXAxisY = gl.translateXAxisY + w.config.xaxis.labels.offsetY; gl.translateXAxisX = gl.translateXAxisX + w.config.xaxis.labels.offsetX; var yAxisWidth = this.yAxisWidth; var xAxisHeight = this.xAxisHeight; gl.xAxisLabelsHeight = this.xAxisHeight; gl.xAxisHeight = this.xAxisHeight; var translateY = 10; if (!w.config.grid.show) { yAxisWidth = 0; xAxisHeight = 35; } if (this.isSparkline) { lgRect = { height: 0, width: 0 }; xAxisHeight = 0; yAxisWidth = 0; translateY = 0; } switch (w.config.legend.position) { case 'bottom': gl.translateY = translateY; gl.translateX = yAxisWidth; gl.gridHeight = gl.svgHeight - lgRect.height - xAxisHeight - (!this.isSparkline ? w.globals.rotateXLabels ? 10 : 15 : 0); gl.gridWidth = gl.svgWidth - yAxisWidth; break; case 'top': gl.translateY = lgRect.height + translateY; gl.translateX = yAxisWidth; gl.gridHeight = gl.svgHeight - lgRect.height - xAxisHeight - (!this.isSparkline ? w.globals.rotateXLabels ? 10 : 15 : 0); gl.gridWidth = gl.svgWidth - yAxisWidth; break; case 'left': gl.translateY = translateY; gl.translateX = lgRect.width + yAxisWidth; gl.gridHeight = gl.svgHeight - xAxisHeight - 12; gl.gridWidth = gl.svgWidth - lgRect.width - yAxisWidth; break; case 'right': gl.translateY = translateY; gl.translateX = yAxisWidth; gl.gridHeight = gl.svgHeight - xAxisHeight - 12; gl.gridWidth = gl.svgWidth - lgRect.width - yAxisWidth; break; default: throw new Error('Legend position not supported'); } gl.gridHeight = gl.gridHeight - w.config.grid.padding.top - w.config.grid.padding.bottom; gl.gridWidth = gl.gridWidth - w.config.grid.padding.left - w.config.grid.padding.right; gl.translateX = gl.translateX + w.config.grid.padding.left; gl.translateY = gl.translateY + w.config.grid.padding.top; if (!this.isBarHorizontal) { this.setGridXPosForDualYAxis(yTitleCoords, yaxisLabelCoords); } // after drawing everything, set the Y axis positions var objyAxis = new _YAxis2.default(this.ctx); objyAxis.setYAxisXPosition(yaxisLabelCoords, yTitleCoords); } }, { key: 'setGridCoordsForNonAxisCharts', value: function setGridCoordsForNonAxisCharts(lgRect) { var w = this.w; var gl = w.globals; var xPad = 0; if (w.config.legend.show && !w.config.legend.floating) { xPad = w.config.legend.markers.size * 4 + w.config.legend.itemMargin.horizontal; } var offY = 10; if (w.config.chart.type === 'pie' || w.config.chart.type === 'donut') { offY = offY + w.config.plotOptions.pie.offsetY; } else if (w.config.chart.type === 'radialBar') { offY = offY + w.config.plotOptions.radialBar.offsetY; } switch (w.config.legend.position) { case 'bottom': gl.gridHeight = gl.svgHeight - lgRect.height - 35; gl.gridWidth = gl.gridHeight; gl.translateY = offY - 20; gl.translateX = (gl.svgWidth - gl.gridWidth) / 2; break; case 'top': gl.gridHeight = gl.svgHeight - lgRect.height - 35; gl.gridWidth = gl.gridHeight; gl.translateY = lgRect.height + offY; gl.translateX = (gl.svgWidth - gl.gridWidth) / 2; break; case 'left': gl.gridWidth = gl.svgWidth - lgRect.width - xPad; gl.gridHeight = gl.gridWidth; gl.translateY = offY; gl.translateX = lgRect.width + xPad; break; case 'right': gl.gridWidth = gl.svgWidth - lgRect.width - xPad; gl.gridHeight = gl.gridWidth; gl.translateY = offY; gl.translateX = 5; break; default: throw new Error('Legend position not supported'); } } }, { key: 'setGridXPosForDualYAxis', value: function setGridXPosForDualYAxis(yTitleCoords, yaxisLabelCoords) { var w = this.w; w.config.yaxis.map(function (yaxe, index) { if (!w.globals.ignoreYAxisIndexes.indexOf(index) > -1 && !w.config.yaxis[index].floating) { if (yaxe.opposite) { w.globals.translateX = w.globals.translateX - (yaxisLabelCoords[index].width + yTitleCoords[index].width) - parseInt(w.config.yaxis[index].labels.style.fontSize) / 1.2 - 12; } } }); } }, { key: 'titleSubtitleOffset', value: function titleSubtitleOffset() { var w = this.w; var gl = w.globals; var gridShrinkOffset = this.isSparkline ? 0 : 10; if (w.config.title.text !== undefined) { gridShrinkOffset += w.config.title.margin; } else { gridShrinkOffset += this.isSparkline ? 0 : 5; } if (w.config.subtitle.text !== undefined) { gridShrinkOffset += w.config.subtitle.margin; } else { gridShrinkOffset += this.isSparkline ? 0 : 5; } if (w.config.legend.show && w.config.legend.position === 'bottom' && !w.config.legend.floating && w.config.series.length > 1) { gridShrinkOffset += 10; } var titleCoords = this.getTitleSubtitleCoords('title'); var subtitleCoords = this.getTitleSubtitleCoords('subtitle'); gl.gridHeight = gl.gridHeight - titleCoords.height - subtitleCoords.height - gridShrinkOffset; gl.translateY = gl.translateY + titleCoords.height + subtitleCoords.height + gridShrinkOffset; } }, { key: 'getTotalYAxisWidth', value: function getTotalYAxisWidth() { var w = this.w; var yAxisWidth = 0; var padding = 10; w.globals.yLabelsCoords.map(function (yLabelCoord, index) { var floating = w.config.yaxis[index].floating; if (yLabelCoord.width > 0 && !floating) { yAxisWidth = yAxisWidth + yLabelCoord.width + padding; if (w.globals.ignoreYAxisIndexes.indexOf(index) > -1) { yAxisWidth = yAxisWidth - yLabelCoord.width - padding; } } else { yAxisWidth = yAxisWidth + (floating ? 0 : 5); } }); w.globals.yTitleCoords.map(function (yTitleCoord, index) { var floating = w.config.yaxis[index].floating; padding = parseInt(w.config.yaxis[index].title.style.fontSize); if (yTitleCoord.width > 0 && !floating) { yAxisWidth = yAxisWidth + yTitleCoord.width + padding; if (w.globals.ignoreYAxisIndexes.indexOf(index) > -1) { yAxisWidth = yAxisWidth - yTitleCoord.width - padding; } } else { yAxisWidth = yAxisWidth + (floating ? 0 : 5); } }); return yAxisWidth; } }, { key: 'getxAxisTimeScaleLabelsCoords', value: function getxAxisTimeScaleLabelsCoords() { var w = this.w; var rect = void 0; var timescaleLabels = w.globals.timelineLabels.slice(); var labels = timescaleLabels.map(function (label) { return label.value; }); // get the longest string from the labels array and also apply label formatter to it var val = labels.reduce(function (a, b) { // if undefined, maybe user didn't pass the datetime(x) values if (typeof a === 'undefined') { console.error('You have possibly supplied invalid Date format. Please supply a valid JavaScript Date'); return 0; } else { return a.length > b.length ? a : b; } }, 0); var graphics = new _Graphics2.default(this.ctx); rect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize); var totalWidthRotated = rect.width * 1.05 * labels.length; if (totalWidthRotated > w.globals.gridWidth && w.config.xaxis.labels.rotate !== 0) { w.globals.overlappingXLabels = true; } return rect; } /** * Get X Axis Dimensions * @memberof Dimensions * @return {{width, height}} **/ }, { key: 'getxAxisLabelsCoords', value: function getxAxisLabelsCoords() { var w = this.w; var xaxisLabels = w.globals.labels.slice(); var rect = { width: 0, height: 0 }; if (w.globals.timelineLabels.length > 0) { var coords = this.getxAxisTimeScaleLabelsCoords(); rect = { width: coords.width, height: coords.height }; } else { var lgWidthForSideLegends = w.config.legend.position === 'left' && w.config.legend.position === 'right' && !w.config.legend.floating ? this.lgRect.width : 0; // get the longest string from the labels array and also apply label formatter to it var val = xaxisLabels.reduce(function (a, b) { return a.length > b.length ? a : b; }, 0); var xlbFormatter = w.globals.xLabelFormatter; var xFormat = new _Formatters2.default(this.ctx); val = xFormat.xLabelFormat(xlbFormatter, val); var graphics = new _Graphics2.default(this.ctx); var xLabelrect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize); rect = { width: xLabelrect.width, height: xLabelrect.height }; if (rect.width * xaxisLabels.length > w.globals.svgWidth - lgWidthForSideLegends - this.yAxisWidth && w.config.xaxis.labels.rotate !== 0) { if (!this.isBarHorizontal) { w.globals.rotateXLabels = true; xLabelrect = graphics.getTextRects(val, w.config.xaxis.labels.style.fontSize, w.config.xaxis.labels.style.fontFamily, 'rotate(' + w.config.xaxis.labels.rotate + ' 0 0)', false); rect.height = xLabelrect.height / 1.66; } } else { w.globals.rotateXLabels = false; } } if (!w.config.xaxis.labels.show) { rect = { width: 0, height: 0 }; } return { width: rect.width, height: rect.height }; } /** * Get Y Axis Dimensions * @memberof Dimensions * @return {{width, height}} **/ }, { key: 'getyAxisLabelsCoords', value: function getyAxisLabelsCoords() { var _this = this; var w = this.w; var width = 0; var height = 0; var ret = []; var labelPad = 10; w.config.yaxis.map(function (yaxe, index) { if (yaxe.show && yaxe.labels.show && w.globals.yAxisScale[index].result.length) { var lbFormatter = w.globals.yLabelFormatters[index]; var val = lbFormatter(w.globals.yAxisScale[index].niceMax); if (_this.isBarHorizontal) { labelPad = 0; var barYaxisLabels = w.globals.labels.slice(); // get the longest string from the labels array and also apply label formatter to it val = barYaxisLabels.reduce(function (a, b) { return a.length > b.length ? a : b; }, 0); val = lbFormatter(val); } var graphics = new _Graphics2.default(_this.ctx); var rect = graphics.getTextRects(val, yaxe.labels.style.fontSize); ret.push({ width: rect.width + labelPad, height: rect.height }); } else { ret.push({ width: width, height: height }); } }); return ret; } /** * Get X Axis Title Dimensions * @memberof Dimensions * @return {{width, height}} **/ }, { key: 'getxAxisTitleCoords', value: function getxAxisTitleCoords() { var w = this.w; var width = 0; var height = 0; if (w.config.xaxis.title.text !== undefined) { var graphics = new _Graphics2.default(this.ctx); var rect = graphics.getTextRects(w.config.xaxis.title.text, w.config.xaxis.title.style.fontSize); width = rect.width; height = rect.height; } return { width: width, height: height }; } /** * Get Y Axis Dimensions * @memberof Dimensions * @return {{width, height}} **/ }, { key: 'getyAxisTitleCoords', value: function getyAxisTitleCoords() { var _this2 = this; var w = this.w; var ret = []; w.config.yaxis.map(function (yaxe, index) { if (yaxe.show && yaxe.title.text !== undefined) { var graphics = new _Graphics2.default(_this2.ctx); var rect = graphics.getTextRects(yaxe.title.text, yaxe.title.style.fontSize, yaxe.title.style.fontFamily, 'rotate(-90 0 0)', false); ret.push({ width: rect.width, height: rect.height }); } else { ret.push({ width: 0, height: 0 }); } }); return ret; } /** * Get Chart Title/Subtitle Dimensions * @memberof Dimensions * @return {{width, height}} **/ }, { key: 'getTitleSubtitleCoords', value: function getTitleSubtitleCoords(type) { var w = this.w; var width = 0; var height = 0; var floating = type === 'title' ? w.config.title.floating : w.config.subtitle.floating; var el = w.globals.dom.baseEl.querySelector('.apexcharts-' + type + '-text'); if (el !== null && !floating) { var coord = el.getBoundingClientRect(); width = coord.width; height = w.globals.axisCharts ? coord.height + 5 : coord.height; } return { width: width, height: height }; } }, { key: 'getLegendsRect', value: function getLegendsRect() { var w = this.w; var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend'); var lgRect = Object.assign({}, _Utils2.default.getBoundingClientRect(elLegendWrap)); lgRect.height = lgRect.height + w.config.legend.containerMargin.top + w.config.legend.containerMargin.bottom; lgRect.width = lgRect.width + w.config.legend.containerMargin.left + w.config.legend.containerMargin.right; if (elLegendWrap !== null && !w.config.legend.floating && w.config.legend.show) { this.lgRect = lgRect; } else { this.lgRect = { x: 0, y: 0, height: 0, width: 0 }; } return this.lgRect; } }]); return Dimensions; }(); module.exports = Dimensions; /***/ }), /* 47 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Filters = __webpack_require__(6); var _Filters2 = _interopRequireDefault(_Filters); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Markers Class for drawing points on y values in axes charts. * * @module Markers **/ var Markers = function () { function Markers(ctx, opts) { _classCallCheck(this, Markers); this.ctx = ctx; this.w = ctx.w; } _createClass(Markers, [{ key: 'plotChartMarkers', value: function plotChartMarkers(pointsPos, seriesIndex, j) { var _this = this; var w = this.w; var p = pointsPos; var elPointsWrap = null; var graphics = new _Graphics2.default(this.ctx); var point = void 0; if (w.config.markers.size > 0) { elPointsWrap = graphics.group({ class: 'apexcharts-series-markers' }); } if (p.x instanceof Array) { var _loop = function _loop(q) { var realIndexP = j; var PointClasses = 'apexcharts-marker'; if ((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts && !w.config.tooltip.intersect) { PointClasses += ' no-pointer-events'; } if (w.config.markers.size > 0) { if (p.y[q] !== null) { PointClasses += ' w' + (Math.random() + 1).toString(36).substring(4); } else { PointClasses = 'apexcharts-nullpoint'; } var opts = _this.getMarkerConfig(PointClasses, seriesIndex); w.config.markers.discrete.map(function (marker, mIndex) { if (marker.i === seriesIndex && marker.j === realIndexP) { opts.pointStrokeColor = marker.strokeColor; opts.pointFillColor = marker.fillColor; opts.size = marker.size; } }); point = graphics.drawMarker(p.x[q], p.y[q], opts); // a small hack as we have 2 points for the first val to connect it if (j === 1 && q === 0) realIndexP = 0; if (j === 1 && q === 1) realIndexP = 1; point.attr('rel', realIndexP); point.attr('j', realIndexP); point.attr('index', seriesIndex); _this.setSelectedPointFilter(point, seriesIndex, realIndexP); _this.addEvents(point); if (elPointsWrap) { elPointsWrap.add(point); } } else { // dynamic array creation - multidimensional if (typeof w.globals.pointsArray[seriesIndex] === 'undefined') w.globals.pointsArray[seriesIndex] = []; w.globals.pointsArray[seriesIndex].push([p.x[q], p.y[q]]); } }; for (var q = 0; q < p.x.length; q++) { _loop(q); } } return elPointsWrap; } }, { key: 'getMarkerConfig', value: function getMarkerConfig(cssClass, seriesIndex) { var w = this.w; var pStyle = this.getMarkerStyle(seriesIndex); var pSize = w.config.markers.size; return { pSize: pSize instanceof Array ? pSize[seriesIndex] : pSize, pRadius: w.config.markers.radius, pWidth: w.config.markers.strokeWidth, pointStrokeColor: pStyle.pointStrokeColor, pointFillColor: pStyle.pointFillColor, shape: w.config.markers.shape instanceof Array ? w.config.markers.shape[seriesIndex] : w.config.markers.shape, class: cssClass, pointStrokeOpacity: w.config.markers.strokeOpacity, pointFillOpacity: w.config.markers.fillOpacity, seriesIndex: seriesIndex }; } }, { key: 'addEvents', value: function addEvents(circle) { var graphics = new _Graphics2.default(this.ctx); circle.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this.ctx, circle)); circle.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this.ctx, circle)); circle.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this.ctx, circle)); circle.node.addEventListener('touchstart', graphics.pathMouseDown.bind(this.ctx, circle), { passive: true }); } }, { key: 'setSelectedPointFilter', value: function setSelectedPointFilter(circle, realIndex, realIndexP) { var w = this.w; if (typeof w.globals.selectedDataPoints[realIndex] !== 'undefined') { if (w.globals.selectedDataPoints[realIndex].indexOf(realIndexP) > -1) { circle.node.setAttribute('selected', true); var activeFilter = w.config.states.active.filter; if (activeFilter !== 'none') { var filters = new _Filters2.default(this.ctx); filters.applyFilter(circle, activeFilter.type, activeFilter.value); } } } } }, { key: 'getMarkerStyle', value: function getMarkerStyle(seriesIndex) { var w = this.w; var colors = w.globals.markers.colors; var pointStrokeColor = w.config.markers.strokeColor; var pointFillColor = colors instanceof Array ? colors[seriesIndex] : colors; return { pointStrokeColor: pointStrokeColor, pointFillColor: pointFillColor }; } }]); return Markers; }(); module.exports = Markers; /***/ }), /* 48 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _YAxis = __webpack_require__(49); var _YAxis2 = _interopRequireDefault(_YAxis); var _Formatters = __webpack_require__(30); var _Formatters2 = _interopRequireDefault(_Formatters); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts XAxis Class for drawing X-Axis. * * @module XAxis **/ var XAxis = function () { function XAxis(ctx) { _classCallCheck(this, XAxis); this.ctx = ctx; this.w = ctx.w; var w = this.w; this.xaxisLabels = w.globals.labels.slice(); if (w.globals.timelineLabels.length > 0) { // timeline labels are there this.xaxisLabels = w.globals.timelineLabels.slice(); } this.drawnLabels = []; if (w.config.xaxis.position === 'top') { this.offY = 0; } else { this.offY = w.globals.gridHeight + 1; } this.offY = this.offY + w.config.xaxis.axisBorder.offsetY; this.xaxisFontSize = w.config.xaxis.labels.style.fontSize; this.xaxisFontFamily = w.config.xaxis.labels.style.fontFamily; this.xaxisForeColors = w.config.xaxis.labels.style.colors; this.xaxisBorderWidth = w.config.xaxis.axisBorder.width; if (this.xaxisBorderWidth.indexOf('%') > -1) { this.xaxisBorderWidth = w.globals.gridWidth * parseInt(this.xaxisBorderWidth) / 100; } else { this.xaxisBorderWidth = parseInt(this.xaxisBorderWidth); } this.xaxisBorderHeight = w.config.xaxis.axisBorder.height; // For bars, we will only consider single y xais, // as we are not providing multiple yaxis for bar charts this.yaxis = w.config.yaxis[0]; } _createClass(XAxis, [{ key: 'drawXaxis', value: function drawXaxis() { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var elXaxis = graphics.group({ 'class': 'apexcharts-xaxis' }); var elXaxisTexts = graphics.group({ 'class': 'apexcharts-xaxis-texts-g', 'transform': 'translate(' + w.globals.translateXAxisX + ', ' + w.globals.translateXAxisY + ')' }); elXaxis.add(elXaxisTexts); var colWidth = void 0; // initial x Position (keep adding column width in the loop) var xPos = w.globals.padHorizontal; var labels = []; for (var i = 0; i < this.xaxisLabels.length; i++) { labels.push(this.xaxisLabels[i]); } if (w.config.chart.type === 'line' || w.config.chart.type === 'area') { if (w.globals.isXNumeric) { colWidth = w.globals.gridWidth / (labels.length - 1); xPos = xPos + colWidth / 2 + w.config.xaxis.labels.offsetX; } else { // no isXNumeric, only y values values and labels not provided if (w.globals.noLabelsProvided) { colWidth = w.globals.gridWidth / this.xaxisLabels.length; } else { // labels provided colWidth = w.globals.gridWidth / labels.length; } xPos = xPos + colWidth + w.config.xaxis.labels.offsetX; } } else { if (w.globals.isXNumeric) { if (w.config.chart.type !== 'bar') { colWidth = w.globals.gridWidth / (this.xaxisLabels.length - 1); xPos = xPos + colWidth / 2 + w.config.xaxis.labels.offsetX; } else { colWidth = w.globals.gridWidth / w.globals.labels.length; xPos = xPos + colWidth / 2 + w.config.xaxis.labels.offsetX; } } else { if (w.globals.noLabelsProvided && w.config.chart.type !== 'bar') { colWidth = w.globals.gridWidth / this.xaxisLabels.length; xPos = xPos + colWidth / 2 + w.config.xaxis.labels.offsetX; } else { colWidth = w.globals.gridWidth / labels.length; xPos = xPos + colWidth + w.config.xaxis.labels.offsetX; } } } var xlbFormatter = w.globals.xLabelFormatter; var customFormatter = w.config.xaxis.labels.formatter; var labelsLen = labels.length; if (w.config.xaxis.labels.show) { for (var _i = 0; _i <= labelsLen - 1; _i++) { var label = typeof labels[_i] === 'undefined' ? '' : labels[_i]; var xFormat = new _Formatters2.default(this.ctx); label = xFormat.xLabelFormat(xlbFormatter, label); if (customFormatter !== undefined && xlbFormatter.toString() !== customFormatter.toString()) { label = customFormatter(label, this.xaxisLabels[_i], _i); } var x = xPos - colWidth / 2 + w.config.xaxis.labels.offsetX; if (w.globals.timelineLabels.length > 0) { x = w.globals.timelineLabels[_i].position; label = w.globals.timelineLabels[_i].value; } label = label.toString(); if (label.indexOf('NaN') === 0 || label === 'undefined' || label.toLowerCase().indexOf('invalid') === 0 || label.toLowerCase().indexOf('infinity') >= 0 || this.drawnLabels.indexOf(label) >= 0 && !w.config.xaxis.labels.showDuplicates) { label = ''; } this.drawnLabels.push(label); var offsetYCorrection = 28; if (w.globals.rotateXLabels) { offsetYCorrection = 22; } var elTick = graphics.drawText({ x: x, y: this.offY + w.config.xaxis.labels.offsetY + offsetYCorrection, text: '', textAnchor: 'middle', fontSize: this.xaxisFontSize, fontFamily: this.xaxisFontFamily, foreColor: Array.isArray(this.xaxisForeColors) ? this.xaxisForeColors[_i] : this.xaxisForeColors, cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass }); elXaxisTexts.add(elTick); var tspan = elTick.tspan(label); tspan.node.style.fontFamily = this.xaxisFontFamily; var elTooltipTitle = document.createElementNS(w.globals.svgNS, 'title'); elTooltipTitle.textContent = label; elTick.node.appendChild(elTooltipTitle); xPos = xPos + colWidth; } } if (w.config.xaxis.title.text !== undefined) { var elXaxisTitle = graphics.group({ class: 'apexcharts-xaxis-title' }); var elXAxisTitleText = graphics.drawText({ x: w.globals.gridWidth / 2 + w.config.xaxis.title.offsetX, y: this.offY - parseInt(this.xaxisFontSize) + w.globals.xAxisLabelsHeight + w.config.xaxis.title.offsetY, text: w.config.xaxis.title.text, textAnchor: 'middle', fontSize: w.config.xaxis.title.style.fontSize, fontFamily: w.config.xaxis.title.style.fontFamily, foreColor: w.config.xaxis.title.style.color, cssClass: 'apexcharts-xaxis-title-text ' + w.config.xaxis.title.style.cssClass }); elXaxisTitle.add(elXAxisTitleText); elXaxis.add(elXaxisTitle); } if (w.config.xaxis.axisBorder.show) { var lineCorrection = 0; if (w.config.chart.type === 'bar' && w.globals.isXNumeric) { lineCorrection = lineCorrection - 15; } var elHorzLine = graphics.drawLine(w.globals.padHorizontal + lineCorrection + w.config.xaxis.axisBorder.offsetX, this.offY, this.xaxisBorderWidth, this.offY, w.config.xaxis.axisBorder.color, 0, this.xaxisBorderHeight); elXaxis.add(elHorzLine); } return elXaxis; } // this actually becomes the vertical axis (for bar charts) }, { key: 'drawXaxisInversed', value: function drawXaxisInversed(realIndex) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var elYaxis = graphics.group({ class: 'apexcharts-yaxis apexcharts-xaxis-inversed', 'rel': realIndex }); var elYaxisTexts = graphics.group({ class: 'apexcharts-yaxis-texts-g apexcharts-xaxis-inversed-texts-g' }); elYaxis.add(elYaxisTexts); var colHeight = void 0; // initial x Position (keep adding column width in the loop) var yPos = void 0; var labels = []; for (var i = 0; i < this.xaxisLabels.length; i++) { labels.push(this.xaxisLabels[i]); } colHeight = w.globals.gridHeight / labels.length; yPos = -(colHeight / 2.2); var lbFormatter = w.globals.yLabelFormatters[0]; if (w.config.yaxis[0].labels.show) { for (var _i2 = 0; _i2 <= labels.length - 1; _i2++) { var label = typeof labels[_i2] === 'undefined' ? '' : labels[_i2]; label = lbFormatter(label); var elTick = graphics.drawText({ x: w.config.yaxis[0].labels.offsetX - 15, y: yPos + colHeight + w.config.yaxis[0].labels.offsetY, text: label, textAnchor: 'end', foreColor: w.config.yaxis[0].labels.style.colors[_i2], fontSize: w.config.yaxis[0].labels.style.fontSize, fontFamily: w.config.yaxis[0].labels.style.fontFamily, cssClass: 'apexcharts-yaxis-label ' + w.config.yaxis[0].labels.style.cssClass }); elYaxisTexts.add(elTick); yPos = yPos + colHeight; } } if (w.config.yaxis[0].title.text !== undefined) { var elXaxisTitle = graphics.group({ class: 'apexcharts-yaxis-title apexcharts-xaxis-title-inversed' }); var elXAxisTitleText = graphics.drawText({ x: 0, y: w.globals.gridHeight / 2, text: w.config.yaxis[0].title.text, textAnchor: 'middle', foreColor: w.config.yaxis[0].title.style.color, fontSize: w.config.yaxis[0].title.style.fontSize, fontFamily: w.config.yaxis[0].title.style.fontFamily, cssClass: 'apexcharts-yaxis-title-text ' + w.config.yaxis[0].title.style.cssClass }); elXaxisTitle.add(elXAxisTitleText); elYaxis.add(elXaxisTitle); } if (w.config.xaxis.axisBorder.show) { var elHorzLine = graphics.drawLine(w.globals.padHorizontal + w.config.xaxis.axisBorder.offsetX, this.offY, this.xaxisBorderWidth, this.offY, this.yaxis.axisBorder.color, 0, this.xaxisBorderHeight); elYaxis.add(elHorzLine); // let x = w.globals.yAxisWidths[0] / 2 // if (w.config.yaxis[0].opposite) { // x = -w.globals.yAxisWidths[0] / 2 // } var yaxis = new _YAxis2.default(this.ctx); yaxis.drawAxisTicks(0, labels.length, w.config.yaxis[0].axisBorder, w.config.yaxis[0].axisTicks, 0, colHeight, elYaxis); } return elYaxis; } }, { key: 'drawXaxisTicks', value: function drawXaxisTicks(x1, appendToElement) { var w = this.w; var x2 = x1; if (x1 < 0 || x1 > w.globals.gridWidth) return; var y1 = this.offY + w.config.xaxis.axisTicks.offsetY; var y2 = y1 + w.config.xaxis.axisTicks.height; if (w.config.xaxis.axisTicks.show) { var graphics = new _Graphics2.default(this.ctx); var line = graphics.drawLine(x1 + w.config.xaxis.axisTicks.offsetX, y1, x2 + w.config.xaxis.axisTicks.offsetX, y2, w.config.xaxis.axisTicks.color); // we are not returning anything, but appending directly to the element pased in param appendToElement.add(line); line.node.classList.add('apexcharts-xaxis-tick'); } } }, { key: 'getXAxisTicksPositions', value: function getXAxisTicksPositions() { var w = this.w; var xAxisTicksPositions = []; var xCount = this.xaxisLabels.length; var x1 = w.globals.padHorizontal; if (w.globals.timelineLabels.length > 0) { for (var i = 0; i < xCount; i++) { x1 = this.xaxisLabels[i].position; xAxisTicksPositions.push(x1); } } else { var xCountForCategoryCharts = xCount; for (var _i3 = 0; _i3 < xCountForCategoryCharts; _i3++) { var x1Count = xCountForCategoryCharts; if (w.globals.isXNumeric && w.config.chart.type !== 'bar') { x1Count -= 1; } x1 = x1 + w.globals.gridWidth / x1Count; xAxisTicksPositions.push(x1); } } return xAxisTicksPositions; } // to rotate x-axis labels or to put ... for longer text in xaxis }, { key: 'xAxisLabelCorrections', value: function xAxisLabelCorrections() { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var xAxis = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-texts-g'); var xAxisTexts = w.globals.dom.baseEl.querySelectorAll('.apexcharts-xaxis-texts-g text'); var yAxisTextsInversed = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxis-inversed text'); var xAxisTextsInversed = w.globals.dom.baseEl.querySelectorAll('.apexcharts-xaxis-inversed-texts-g text'); if (w.globals.rotateXLabels || w.config.xaxis.labels.rotateAlways) { for (var xat = 0; xat < xAxisTexts.length; xat++) { var textRotatingCenter = graphics.rotateAroundCenter(xAxisTexts[xat]); textRotatingCenter.y = textRotatingCenter.y - 1; // + tickWidth/4; textRotatingCenter.x = textRotatingCenter.x + 1; xAxisTexts[xat].setAttribute('transform', 'rotate(' + w.config.xaxis.labels.rotate + ' ' + textRotatingCenter.x + ' ' + textRotatingCenter.y + ')'); xAxisTexts[xat].setAttribute('text-anchor', 'end'); var offsetHeight = 10; xAxis.setAttribute('transform', 'translate(0, ' + -offsetHeight + ')'); var tSpan = xAxisTexts[xat].childNodes; if (w.config.xaxis.labels.trim) { graphics.placeTextWithEllipsis(tSpan[0], tSpan[0].textContent, w.config.xaxis.labels.maxHeight - 40); } } } else { var width = w.globals.gridWidth / w.globals.labels.length; for (var _xat = 0; _xat < xAxisTexts.length; _xat++) { var _tSpan = xAxisTexts[_xat].childNodes; if (w.config.xaxis.labels.trim && w.config.chart.type !== 'bar' && w.config.plotOptions.bar.horizontal) { graphics.placeTextWithEllipsis(_tSpan[0], _tSpan[0].textContent, width); } } } if (yAxisTextsInversed.length > 0) { // truncate rotated y axis in bar chart (x axis) var firstLabelPosX = yAxisTextsInversed[yAxisTextsInversed.length - 1].getBBox(); var lastLabelPosX = yAxisTextsInversed[0].getBBox(); if (firstLabelPosX.x < -20) { yAxisTextsInversed[yAxisTextsInversed.length - 1].parentNode.removeChild(yAxisTextsInversed[yAxisTextsInversed.length - 1]); } if (lastLabelPosX.x + lastLabelPosX.width > w.globals.gridWidth) { yAxisTextsInversed[0].parentNode.removeChild(yAxisTextsInversed[0]); } // truncate rotated x axis in bar chart (y axis) for (var _xat2 = 0; _xat2 < xAxisTextsInversed.length; _xat2++) { graphics.placeTextWithEllipsis(xAxisTextsInversed[_xat2], xAxisTextsInversed[_xat2].textContent, w.config.yaxis[0].labels.maxWidth - parseInt(w.config.yaxis[0].title.style.fontSize) * 2 - 20); } } } // renderXAxisBands() { // let w = this.w; // let plotBand = document.createElementNS(w.globals.svgNS, 'rect') // w.globals.dom.elGraphical.add(plotBand) // } }]); return XAxis; }(); module.exports = XAxis; /***/ }), /* 49 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts YAxis Class for drawing Y-Axis. * * @module YAxis **/ var YAxis = function () { function YAxis(ctx) { _classCallCheck(this, YAxis); this.ctx = ctx; this.w = ctx.w; this.xaxisFontSize = this.w.config.xaxis.labels.style.fontSize; this.axisFontFamily = this.w.config.xaxis.labels.style.fontFamily; this.isBarHorizontal = !!(this.w.config.chart.type === 'bar' && this.w.config.plotOptions.bar.horizontal); this.xaxisForeColors = this.w.config.xaxis.labels.style.colors; this.xAxisoffX = 0; if (this.w.config.xaxis.position === 'bottom') { this.xAxisoffX = this.w.globals.gridHeight; } } _createClass(YAxis, [{ key: 'drawYaxis', value: function drawYaxis(xyRatios, realIndex) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var yaxisFontSize = w.config.yaxis[realIndex].labels.style.fontSize; var yaxisFontFamily = w.config.yaxis[realIndex].labels.style.fontFamily; var elYaxis = graphics.group({ class: 'apexcharts-yaxis', 'rel': realIndex, 'transform': 'translate(' + w.globals.translateYAxisX[realIndex] + ', 0)' }); if (!w.config.yaxis[realIndex].show) { return elYaxis; } var elYaxisTexts = graphics.group({ 'class': 'apexcharts-yaxis-texts-g' }); elYaxis.add(elYaxisTexts); var tickAmount = w.globals.yAxisScale[realIndex].result.length - 1; // labelsDivider is simply svg height/number of ticks var labelsDivider = w.globals.gridHeight / tickAmount + 0.1; // initial label position = 0; var l = w.globals.translateY; var lbFormatter = w.globals.yLabelFormatters[realIndex]; if (w.config.yaxis[realIndex].labels.show) { for (var i = tickAmount; i >= 0; i--) { var val = w.globals.yAxisScale[realIndex].result[i]; val = lbFormatter(val); var xPad = 20; if (w.config.yaxis[realIndex].opposite) { xPad = xPad * -1; } if (w.config.yaxis.length === 0) { xPad = 20; } var label = graphics.drawText({ x: xPad, y: l + tickAmount / 10 + w.config.yaxis[realIndex].labels.offsetY + 1, text: val, textAnchor: w.config.yaxis[realIndex].opposite ? 'start' : 'end', fontSize: yaxisFontSize, fontFamily: yaxisFontFamily, foreColor: w.config.yaxis[realIndex].labels.style.color, cssClass: 'apexcharts-yaxis-label ' + w.config.yaxis[realIndex].labels.style.cssClass }); elYaxisTexts.add(label); l = l + labelsDivider; } } if (w.config.yaxis[realIndex].title.text !== undefined) { var elYaxisTitle = graphics.group({ 'class': 'apexcharts-yaxis-title' }); var x = 0; if (w.config.yaxis[realIndex].opposite) { x = w.globals.translateYAxisX[realIndex]; } var elYAxisTitleText = graphics.drawText({ x: x, y: w.globals.gridHeight / 2 + w.globals.translateY, text: w.config.yaxis[realIndex].title.text, textAnchor: 'end', foreColor: w.config.yaxis[realIndex].labels.style.color, fontSize: w.config.yaxis[realIndex].title.style.fontSize, fontFamily: w.config.yaxis[realIndex].title.style.fontFamily, cssClass: 'apexcharts-yaxis-title-text ' + w.config.yaxis[realIndex].title.style.cssClass }); elYaxisTitle.add(elYAxisTitleText); elYaxis.add(elYaxisTitle); } var axisBorder = w.config.yaxis[realIndex].axisBorder; if (axisBorder.show) { var _x = 31 + axisBorder.offsetX; if (w.config.yaxis[realIndex].opposite) { _x = -31 - axisBorder.offsetX; } var elVerticalLine = graphics.drawLine(_x, w.globals.translateY + axisBorder.offsetY - 2, _x, w.globals.gridHeight + w.globals.translateY + axisBorder.offsetY + 2, axisBorder.color); elYaxis.add(elVerticalLine); this.drawAxisTicks(_x, tickAmount, axisBorder, w.config.yaxis[realIndex].axisTicks, realIndex, labelsDivider, elYaxis); } return elYaxis; } // This actually becomes horizonal axis (for bar charts) }, { key: 'drawYaxisInversed', value: function drawYaxisInversed(realIndex) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var elXaxis = graphics.group({ 'class': 'apexcharts-xaxis apexcharts-yaxis-inversed' }); var elXaxisTexts = graphics.group({ 'class': 'apexcharts-xaxis-texts-g', 'transform': 'translate(' + w.globals.translateXAxisX + ', ' + w.globals.translateXAxisY + ')' }); elXaxis.add(elXaxisTexts); var tickAmount = w.globals.yAxisScale[realIndex].result.length - 1; // labelsDivider is simply svg width/number of ticks var labelsDivider = w.globals.gridWidth / tickAmount + 0.1; // initial label position; var l = labelsDivider + w.config.xaxis.labels.offsetX; var lbFormatter = w.globals.xLabelFormatter; if (w.config.xaxis.labels.show) { for (var i = tickAmount; i >= 0; i--) { var val = w.globals.yAxisScale[realIndex].result[i]; val = lbFormatter(val); var elTick = graphics.drawText({ x: w.globals.gridWidth + w.globals.padHorizontal - (l - labelsDivider + w.config.xaxis.labels.offsetX), y: this.xAxisoffX + w.config.xaxis.labels.offsetY + 30, text: '', textAnchor: 'middle', foreColor: Array.isArray(this.xaxisForeColors) ? this.xaxisForeColors[realIndex] : this.xaxisForeColors, fontSize: this.xaxisFontSize, fontFamily: this.xaxisFontFamily, cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass }); elXaxisTexts.add(elTick); elTick.tspan(val); var elTooltipTitle = document.createElementNS(w.globals.svgNS, 'title'); elTooltipTitle.textContent = val; elTick.node.appendChild(elTooltipTitle); l = l + labelsDivider; } } if (w.config.xaxis.title.text !== undefined) { var elYaxisTitle = graphics.group({ 'class': 'apexcharts-xaxis-title apexcharts-yaxis-title-inversed' }); var elYAxisTitleText = graphics.drawText({ x: w.globals.gridWidth / 2, y: this.xAxisoffX + parseInt(this.xaxisFontSize) + parseInt(w.config.xaxis.title.style.fontSize) + 20, text: w.config.xaxis.title.text, textAnchor: 'middle', fontSize: w.config.xaxis.title.style.fontSize, fontFamily: w.config.xaxis.title.style.fontFamily, cssClass: 'apexcharts-xaxis-title-text ' + w.config.xaxis.title.style.cssClass }); elYaxisTitle.add(elYAxisTitleText); elXaxis.add(elYaxisTitle); } var axisBorder = w.config.yaxis[realIndex].axisBorder; if (axisBorder.show) { var elVerticalLine = graphics.drawLine(w.globals.padHorizontal + axisBorder.offsetX, 1 + axisBorder.offsetY, w.globals.padHorizontal + axisBorder.offsetX, w.globals.gridHeight + axisBorder.offsetY, axisBorder.color); elXaxis.add(elVerticalLine); } return elXaxis; } }, { key: 'drawAxisTicks', value: function drawAxisTicks(x, tickAmount, axisBorder, axisTicks, realIndex, labelsDivider, elYaxis) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); // initial label position = 0; var t = w.globals.translateY; if (axisTicks.show) { if (w.config.yaxis[realIndex].opposite === true) x = x + axisTicks.width; for (var i = tickAmount; i >= 0; i--) { var tY = t + tickAmount / 10 + w.config.yaxis[realIndex].labels.offsetY - 1; if (this.isBarHorizontal) { tY = labelsDivider * i; } var elTick = graphics.drawLine(x + axisBorder.offsetX - axisTicks.width + axisTicks.offsetX, tY + axisTicks.offsetY, x + axisBorder.offsetX + axisTicks.offsetX, tY + axisTicks.offsetY, axisBorder.color); elYaxis.add(elTick); t = t + labelsDivider; } } } }, { key: 'yAxisTitleRotate', value: function yAxisTitleRotate(realIndex, yAxisOpposite) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var yAxisLabelsCoord = { width: 0, height: 0 }; var yAxisTitleCoord = { width: 0, height: 0 }; var elYAxisLabelsWrap = w.globals.dom.baseEl.querySelector(' .apexcharts-yaxis[rel=\'' + realIndex + '\'] .apexcharts-yaxis-texts-g'); if (elYAxisLabelsWrap !== null) { yAxisLabelsCoord = elYAxisLabelsWrap.getBoundingClientRect(); } var yAxisTitle = w.globals.dom.baseEl.querySelector('.apexcharts-yaxis[rel=\'' + realIndex + '\'] .apexcharts-yaxis-title text'); if (yAxisTitle !== null) { yAxisTitleCoord = yAxisTitle.getBoundingClientRect(); } if (yAxisTitle !== null) { var x = this.xPaddingForYAxisTitle(realIndex, yAxisLabelsCoord, yAxisTitleCoord, yAxisOpposite); yAxisTitle.setAttribute('x', x.xPos - (yAxisOpposite ? 10 : 0)); } if (yAxisTitle !== null) { var titleRotatingCenter = graphics.rotateAroundCenter(yAxisTitle); if (!yAxisOpposite) { yAxisTitle.setAttribute('transform', 'rotate(-90 ' + titleRotatingCenter.x + ' ' + titleRotatingCenter.y + ')'); } else { yAxisTitle.setAttribute('transform', 'rotate(90 ' + titleRotatingCenter.x + ' ' + titleRotatingCenter.y + ')'); } } } }, { key: 'xPaddingForYAxisTitle', value: function xPaddingForYAxisTitle(realIndex, yAxisLabelsCoord, yAxisTitleCoord, yAxisOpposite) { var w = this.w; var oppositeAxisCount = 0; var x = 0; var padd = 20; if (yAxisOpposite) { x = yAxisLabelsCoord.width + w.config.yaxis[realIndex].title.offsetX + padd + yAxisTitleCoord.width / 2 - 15; oppositeAxisCount += 1; if (oppositeAxisCount === 0) { x = x - 15; } } else { x = yAxisLabelsCoord.width * -1 + w.config.yaxis[realIndex].title.offsetX + padd + yAxisTitleCoord.width / 2 - 15; if (this.isBarHorizontal) { padd = 25; x = yAxisLabelsCoord.width * -1 - w.config.yaxis[realIndex].title.offsetX - padd; } } return { xPos: x, padd: padd }; } // sets the x position of the y-axis by counting the labels width, title width and any offset }, { key: 'setYAxisXPosition', value: function setYAxisXPosition(yaxisLabelCoords, yTitleCoords) { var _this = this; var w = this.w; var xLeft = 0; var xRight = 0; var leftDrawnYs = 0; // already drawn y axis on left side var rightDrawnYs = 1; // already drawn y axis on right side var multipleYPadd = 20; this.multipleYs = false; if (w.config.yaxis.length > 1) { this.multipleYs = true; } w.config.yaxis.map(function (yaxe, index) { var yAxisWidth = yaxisLabelCoords[index].width + yTitleCoords[index].width; var paddingForYAxisTitle = _this.xPaddingForYAxisTitle(index, { width: yaxisLabelCoords[index].width }, { width: yTitleCoords[index].width }, yaxe.opposite); if (w.config.yaxis.length > 1) { // multiple yaxis yAxisWidth = yAxisWidth + Math.abs(paddingForYAxisTitle.padd); } else { // just a single y axis in axis chart if (yaxe.title.text === undefined) { yAxisWidth = yAxisWidth + Math.abs(paddingForYAxisTitle.padd) + 15; } else { yAxisWidth = yAxisWidth + Math.abs(paddingForYAxisTitle.padd); } } if (!yaxe.opposite) { // left side y axis var offset = yAxisWidth + 5; if (w.globals.ignoreYAxisIndexes.indexOf(index) > -1) { offset = 0; } if (_this.multipleYs) { xLeft = w.globals.translateX - yAxisWidth - leftDrawnYs + multipleYPadd + parseInt(w.config.yaxis[index].labels.style.fontSize) / 1.2 + yaxe.labels.offsetX; } else { xLeft = w.globals.translateX - yAxisWidth + yaxisLabelCoords[index].width + yaxe.labels.offsetX; } leftDrawnYs = leftDrawnYs + offset; w.globals.translateYAxisX[index] = xLeft; } else { // right side y axis xRight = w.globals.gridWidth + w.globals.translateX + rightDrawnYs + 30 + (w.globals.series.length - w.globals.collapsedSeries.length); w.globals.collapsedSeries.forEach(function (c) { if (c.index === index) { rightDrawnYs = rightDrawnYs - yAxisWidth; } }); rightDrawnYs = rightDrawnYs + yAxisWidth; w.globals.translateYAxisX[index] = xRight - yaxe.labels.offsetX; } // w.globals.yAxisWidths.push(yAxisWidth) }); } }]); return YAxis; }(); module.exports = YAxis; /***/ }), /* 50 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Defaults = __webpack_require__(141); var _Defaults2 = _interopRequireDefault(_Defaults); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); var _Options = __webpack_require__(51); var _Options2 = _interopRequireDefault(_Options); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Config Class for extending user options with pre-defined ApexCharts config. * * @module Config **/ var Config = function () { function Config(opts) { _classCallCheck(this, Config); this.opts = opts; } _createClass(Config, [{ key: 'init', value: function init() { var opts = this.opts; var options = new _Options2.default(); var defaults = new _Defaults2.default(opts); this.chartType = opts.chart.type; if (this.chartType === 'histogram') { // technically, a histogram can be drawn by a column chart with no spaces in between opts.chart.type = 'bar'; opts = _Utils2.default.extend({ plotOptions: { bar: { columnWidth: '99.99%' } } }, opts); } opts.series = this.checkEmptySeries(opts.series); opts = this.extendYAxis(opts); opts = this.extendAnnotations(opts); var config = options.init(); var newDefaults = {}; if (opts && (typeof opts === 'undefined' ? 'undefined' : _typeof(opts)) === 'object') { var chartDefaults = {}; switch (this.chartType) { case 'line': chartDefaults = defaults.line(); break; case 'area': chartDefaults = defaults.area(); break; case 'bar': chartDefaults = defaults.bar(); break; case 'candlestick': chartDefaults = defaults.candlestick(); break; case 'histogram': chartDefaults = defaults.bar(); break; case 'bubble': chartDefaults = defaults.bubble(); break; case 'scatter': chartDefaults = defaults.scatter(); break; case 'heatmap': chartDefaults = defaults.heatmap(); break; case 'pie': chartDefaults = defaults.pie(); break; case 'donut': chartDefaults = defaults.donut(); break; case 'radialBar': chartDefaults = defaults.radialBar(); break; default: chartDefaults = defaults.line(); } if (opts.chart.brush && opts.chart.brush.enabled) { chartDefaults = defaults.brush(chartDefaults); } if (opts.chart.stacked && opts.chart.stackType === '100%') { defaults.stacked100(); } if (opts.chart.sparkline && opts.chart.sparkline.enabled || window.Apex.chart && window.Apex.chart.sparkline && window.Apex.chart.sparkline.enabled) { chartDefaults = defaults.sparkline(chartDefaults); } newDefaults = _Utils2.default.extend(config, chartDefaults); } // config should cascade in this fashion // default-config < global-apex-variable-config < user-defined-config // get GLOBALLY defined options and merge with the default config var mergedWithDefaultConfig = _Utils2.default.extend(newDefaults, window.Apex); // get the merged config and extend with user defined config config = _Utils2.default.extend(mergedWithDefaultConfig, opts); // some features are not supported. those mismatches should be handled config = this.handleUserInputErrors(config); return config; } }, { key: 'extendYAxis', value: function extendYAxis(opts) { var options = new _Options2.default(); if (typeof opts.yaxis === 'undefined') { opts.yaxis = {}; } // extend global yaxis config (only if object is provided / not an array) if (opts.yaxis.constructor !== Array && window.Apex.yaxis && window.Apex.yaxis.constructor !== Array) { opts.yaxis = _Utils2.default.extend(opts.yaxis, window.Apex.yaxis); } // as we can't extend nested object's array with extend, we need to do it first // user can provide either an array or object in yaxis config if (opts.yaxis.constructor !== Array) { // convert the yaxis to array if user supplied object opts.yaxis = [_Utils2.default.extend(options.yAxis, opts.yaxis)]; } else { opts.yaxis = _Utils2.default.extendArray(opts.yaxis, options.yAxis); } return opts; } // annotations also accepts array, so we need to extend them manually }, { key: 'extendAnnotations', value: function extendAnnotations(opts) { if (typeof opts.annotations === 'undefined') { opts.annotations = {}; opts.annotations.yaxis = []; opts.annotations.xaxis = []; opts.annotations.points = []; } opts = this.extendYAxisAnnotations(opts); opts = this.extendXAxisAnnotations(opts); opts = this.extendPointAnnotations(opts); return opts; } }, { key: 'extendYAxisAnnotations', value: function extendYAxisAnnotations(opts) { var options = new _Options2.default(); opts.annotations.yaxis = _Utils2.default.extendArray(typeof opts.annotations.yaxis !== 'undefined' ? opts.annotations.yaxis : [], options.yAxisAnnotation); return opts; } }, { key: 'extendXAxisAnnotations', value: function extendXAxisAnnotations(opts) { var options = new _Options2.default(); opts.annotations.xaxis = _Utils2.default.extendArray(typeof opts.annotations.xaxis !== 'undefined' ? opts.annotations.xaxis : [], options.xAxisAnnotation); return opts; } }, { key: 'extendPointAnnotations', value: function extendPointAnnotations(opts) { var options = new _Options2.default(); opts.annotations.points = _Utils2.default.extendArray(typeof opts.annotations.points !== 'undefined' ? opts.annotations.points : [], options.pointAnnotation); return opts; } }, { key: 'checkEmptySeries', value: function checkEmptySeries(ser) { if (ser.length === 0) { return [{ data: [] }]; } return ser; } }, { key: 'handleUserInputErrors', value: function handleUserInputErrors(opts) { var config = opts; // conflicting tooltip option. intersect makes sure to focus on 1 point at a time. Shared cannot be used along with it if (config.tooltip.shared && config.tooltip.intersect) { throw new Error('tooltip.shared cannot be enabled when tooltip.intersect is true. Turn off any other option by setting it to false'); } if (config.chart.scroller) { console.warn('Scroller has been deprecated since v2.0.0. Please remove the configuration for chart.scroller'); } if (config.chart.type === 'bar' && config.plotOptions.bar.horizontal) { // No time series for horizontal bars if (config.xaxis.type === 'datetime') { throw new Error('Timelines on bars are not supported yet. Switch to column chart by setting plotOptions.bar.horizontal=false'); } // No multiple yaxis for bars if (config.yaxis.length > 1) { throw new Error('Multiple Y Axis for bars are not supported. Switch to column chart by setting plotOptions.bar.horizontal=false'); } config.xaxis.tooltip.enabled = false; // no xaxis tooltip for horizontal bar config.yaxis[0].tooltip.enabled = false; // no xaxis tooltip for horizontal bar config.chart.zoom.enabled = false; // no zooming for horz bars } if (config.chart.type === 'bar') { if (config.tooltip.shared) { if (config.xaxis.crosshairs.width === 'barWidth' && config.series.length > 1) { console.warn('crosshairs.width = "barWidth" is only supported in single series, not in a multi-series barChart'); config.xaxis.crosshairs.width = 'tickWidth'; } if (config.plotOptions.bar.horizontal) { config.states.hover.type = 'none'; } if (!config.tooltip.followCursor) { console.warn('followCursor option in shared columns cannot be turned off'); config.tooltip.followCursor = true; } } } // if user supplied array for stroke width, it will only be applicable to line/area charts, for any other charts, revert back to Number if (Array.isArray(config.stroke.width)) { if (config.chart.type !== 'line' && config.chart.type !== 'area') { console.warn('stroke.width option accepts array only for line and area charts. Reverted back to Number'); config.stroke.width = config.stroke.width[0]; } } return config; } }]); return Config; }(); module.exports = Config; /***/ }), /* 51 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Options for setting the initial configuration of ApexCharts **/ var en = __webpack_require__(81); var Options = function () { function Options() { _classCallCheck(this, Options); this.defaultFont = 'Helvetica, Arial, sans-serif'; this.yAxis = { show: true, opposite: false, tickAmount: 6, max: undefined, min: undefined, decimalsInFloat: 2, floating: false, seriesName: undefined, labels: { show: true, minWidth: 0, maxWidth: 160, offsetX: 0, offsetY: 0, style: { colors: [], fontSize: '11px', fontFamily: this.defaultFont, cssClass: 'apexcharts-yaxis-label' }, formatter: undefined }, axisBorder: { show: false, color: '#78909C', offsetX: 0, offsetY: 0 }, axisTicks: { show: false, color: '#78909C', width: 6, offsetX: 0, offsetY: 0 }, title: { text: undefined, rotate: -90, offsetY: 0, offsetX: 0, style: { color: undefined, fontSize: '11px', fontFamily: this.defaultFont, cssClass: 'apexcharts-yaxis-title' } }, tooltip: { enabled: false, offsetX: 0 }, crosshairs: { show: true, position: 'front', stroke: { color: '#b6b6b6', width: 1, dashArray: 0 } } }; this.xAxisAnnotation = { x: 0, strokeDashArray: 4, borderColor: '#c2c2c2', offsetX: 0, offsetY: 0, label: { borderColor: '#c2c2c2', borderWidth: 1, text: undefined, textAnchor: 'middle', orientation: 'vertical', position: 'top', offsetX: 0, offsetY: 0, style: { background: '#fff', color: undefined, fontSize: '11px', fontFamily: this.defaultFont, cssClass: 'apexcharts-xaxis-annotation-label', padding: { left: 5, right: 5, top: 2, bottom: 2 } } } }; this.yAxisAnnotation = { y: 0, strokeDashArray: 4, borderColor: '#c2c2c2', offsetX: 0, offsetY: 0, yAxisIndex: 0, label: { borderColor: '#c2c2c2', borderWidth: 1, text: undefined, textAnchor: 'end', position: 'right', offsetX: 0, offsetY: -3, style: { background: '#fff', color: undefined, fontSize: '11px', fontFamily: this.defaultFont, cssClass: 'apexcharts-yaxis-annotation-label', padding: { left: 5, right: 5, top: 0, bottom: 2 } } } }; this.pointAnnotation = { x: 0, y: null, yAxisIndex: 0, seriesIndex: 0, marker: { size: 0, fillColor: '#fff', strokeWidth: 2, strokeColor: '#333', shape: 'circle', radius: 2 }, label: { borderColor: '#c2c2c2', borderWidth: 1, text: undefined, textAnchor: 'middle', offsetX: 0, offsetY: -15, style: { background: '#fff', color: undefined, fontSize: '11px', fontFamily: this.defaultFont, cssClass: 'apexcharts-point-annotation-label', padding: { left: 5, right: 5, top: 0, bottom: 2 } } } }; } _createClass(Options, [{ key: 'init', value: function init() { return { annotations: { position: 'front', yaxis: [this.yAxisAnnotation], xaxis: [this.xAxisAnnotation], points: [this.pointAnnotation] }, chart: { animations: { enabled: true, easing: 'easeinout', // linear, easeout, easein, easeinout, swing, bounce, elastic speed: 800, animateGradually: { delay: 150, enabled: true }, dynamicAnimation: { enabled: true, speed: 350 } }, background: 'transparent', locales: [en], defaultLocale: 'en', dropShadow: { enabled: false, enabledSeries: undefined, top: 2, left: 2, blur: 4, opacity: 0.35 }, events: { animationEnd: undefined, beforeMount: undefined, mounted: undefined, updated: undefined, clicked: undefined, selection: undefined, dataPointSelection: undefined, dataPointMouseEnter: undefined, dataPointMouseLeave: undefined, beforeZoom: undefined, // if defined, should return true for the zoom event to occur zoomed: undefined, scrolled: undefined }, foreColor: '#373d3f', height: 'auto', id: undefined, offsetX: 0, offsetY: 0, selection: { enabled: true, type: 'x', // selectedPoints: undefined, // default datapoints that should be selected automatically fill: { color: '#24292e', opacity: 0.1 }, stroke: { width: 1, color: '#24292e', opacity: 0.4, dashArray: 3 }, xaxis: { min: undefined, max: undefined }, yaxis: { min: undefined, max: undefined } }, sparkline: { enabled: false }, brush: { enabled: false, target: undefined }, stacked: false, stackType: 'normal', toolbar: { show: true, tools: { download: true, selection: true, zoom: true, zoomin: true, zoomout: true, pan: true, reset: true }, autoSelected: 'zoom' // accepts -> zoom, pan, selection }, type: 'line', width: '100%', zoom: { enabled: true, type: 'x', zoomedArea: { fill: { color: '#90CAF9', opacity: 0.4 }, stroke: { color: '#0D47A1', opacity: 0.4, width: 1 } } } }, plotOptions: { bar: { horizontal: false, endingShape: 'flat', columnWidth: '70%', // should be in percent 0 - 100 barHeight: '70%', // should be in percent 0 - 100 distributed: false, colors: { ranges: [], backgroundBarColors: [], backgroundBarOpacity: 1 }, dataLabels: { position: 'top' // top, center, bottom // TODO: provide stackedLabels for stacked charts which gives additions of values } }, candlestick: { colors: { upward: '#00B746', downward: '#EF403C' }, wick: { useFillColor: true } }, heatmap: { radius: 2, enableShades: true, shadeIntensity: 0.5, colorScale: { ranges: [] } }, radialBar: { size: undefined, inverseOrder: false, startAngle: 0, endAngle: 360, offsetX: 0, offsetY: 0, hollow: { margin: 5, size: '50%', background: 'transparent', image: undefined, imageWidth: 150, imageHeight: 150, imageOffsetX: 0, imageOffsetY: 0, imageClipped: true, position: 'front', dropShadow: { enabled: false, top: 0, left: 0, blur: 3, opacity: 0.5 } }, track: { show: true, startAngle: undefined, endAngle: undefined, background: '#f2f2f2', strokeWidth: '97%', opacity: 1, margin: 5, // margin is in pixels dropShadow: { enabled: false, top: 0, left: 0, blur: 3, opacity: 0.5 } }, dataLabels: { showOn: 'always', // hover/always name: { show: true, fontSize: '16px', fontFamily: this.defaultFont, color: undefined, offsetY: -10 }, value: { show: true, fontSize: '14px', fontFamily: this.defaultFont, color: undefined, offsetY: 16, formatter: function formatter(val) { return val + '%'; } } } }, pie: { size: undefined, donut: { size: '65%', background: 'transparent' // TODO: draw labels in donut area // labels: { // showOn: 'hover', // name: { // show: false, // fontSize: '14px', // color: undefined, // offsetY: -10 // }, // value: { // show: true, // offsetY: 16, // fontSize: '12px', // color: undefined, // formatter: function (val) { // return val + '%' // } // } // } }, customScale: 0, offsetX: 0, offsetY: 0, dataLabels: { offset: 0 // offset by which labels will move outside } } }, colors: undefined, dataLabels: { enabled: true, formatter: function formatter(val) { return val; }, textAnchor: 'middle', offsetX: 0, offsetY: 0, style: { fontSize: '12px', fontFamily: this.defaultFont, colors: undefined }, dropShadow: { enabled: false, top: 1, left: 1, blur: 1, opacity: 0.45 } }, fill: { type: 'solid', colors: undefined, // array of colors, opacity: 0.85, gradient: { shade: 'dark', type: 'horizontal', shadeIntensity: 0.5, gradientToColors: undefined, inverseColors: true, opacityFrom: 1, opacityTo: 1, stops: [0, 50, 100] }, image: { src: [], width: undefined, // optional height: undefined // optional }, pattern: { style: 'sqaures', // string or array of strings width: 6, height: 6, strokeWidth: 2 } }, grid: { show: true, borderColor: '#e0e0e0', strokeDashArray: 0, position: 'back', clipMarkers: false, xaxis: { lines: { show: false, animate: false } }, yaxis: { lines: { show: true, animate: true } }, row: { colors: undefined, // takes as array which will be repeated on rows opacity: 0.5 }, column: { colors: undefined, // takes an array which will be repeated on columns opacity: 0.5 }, padding: { top: 0, right: 10, bottom: 0, left: 10 } }, labels: [], legend: { show: true, floating: false, position: 'bottom', // whether to position legends in 1 of 4 // direction - top, bottom, left, right horizontalAlign: 'center', // when position top/bottom, you can // specify whether to align legends // left, right or center verticalAlign: 'middle', fontSize: '12px', fontFamily: this.defaultFont, textAnchor: 'start', offsetY: 0, offsetX: 0, formatter: undefined, labels: { colors: undefined, useSeriesColors: false }, markers: { size: 6, strokeWidth: 0, strokeColor: '#fff', offsetX: 0, offsetY: 0, shape: 'circle', radius: 2 }, itemMargin: { horizontal: 20, vertical: 5 }, containerMargin: { left: 10, top: 4, right: 10, bottom: 0 }, onItemClick: { toggleDataSeries: true }, onItemHover: { highlightDataSeries: true } }, markers: { discrete: [], size: 0, colors: undefined, strokeColor: '#fff', strokeWidth: 2, strokeOpacity: 0.9, fillOpacity: 1, shape: 'circle', radius: 2, offsetX: 0, offsetY: 0, hover: { size: 6 } }, noData: { text: undefined, align: 'center', verticalAlign: 'middle', offsetX: 0, offsetY: 0, style: { color: undefined, fontSize: '14px', fontFamily: this.defaultFont } }, responsive: [], // breakpoints should follow ascending order 400, then 700, then 1000 series: undefined, states: { normal: { filter: { type: 'none', value: 0 } }, hover: { filter: { type: 'lighten', value: 0.15 } }, active: { allowMultipleDataPointsSelection: false, filter: { type: 'darken', value: 0.35 } } }, title: { text: undefined, align: 'left', margin: 10, offsetX: 0, offsetY: 0, floating: false, style: { fontSize: '14px', fontFamily: this.defaultFont, color: undefined } }, subtitle: { text: undefined, align: 'left', margin: 10, offsetX: 0, offsetY: 30, floating: false, style: { fontSize: '12px', fontFamily: this.defaultFont, color: undefined } }, stroke: { show: true, curve: 'smooth', // "smooth" or "straight" lineCap: 'butt', // round, butt , square width: 2, colors: undefined, // array of colors dashArray: 0 // single value or array of values }, tooltip: { enabled: true, shared: true, followCursor: false, // when disabled, the tooltip will show on top of the series instead of mouse position intersect: false, // when enabled, tooltip will only show when user directly hovers over point inverseOrder: false, custom: undefined, fillSeriesColor: false, onDatasetHover: { highlightDataSeries: false }, theme: 'light', x: { // x value show: true, format: 'dd MMM', // dd/MM, dd MMM yy, dd MMM yyyy formatter: undefined // a custom user supplied formatter function }, y: { formatter: undefined, title: { formatter: function formatter(seriesName) { return seriesName; } } }, z: { formatter: undefined, title: 'Size: ' }, marker: { show: true }, items: { display: 'flex' }, fixed: { enabled: false, position: 'topRight', // topRight, topLeft, bottomRight, bottomLeft offsetX: 0, offsetY: 0 } }, xaxis: { type: 'category', categories: [], labels: { show: true, rotate: -45, rotateAlways: false, hideOverlappingLabels: true, trim: true, minHeight: undefined, maxHeight: 120, showDuplicates: false, style: { colors: [], fontSize: '12px', fontFamily: this.defaultFont, cssClass: 'apexcharts-xaxis-label' }, offsetX: 0, offsetY: 0, format: undefined, formatter: undefined, // custom formatter function which will override format datetimeFormatter: { year: 'yyyy', month: 'MMM \'yy', day: 'dd MMM', hour: 'HH:mm', minute: 'HH:mm:ss' } }, axisBorder: { show: true, color: '#78909C', width: '100%', height: 1, offsetX: 0, offsetY: 0 }, axisTicks: { show: true, color: '#78909C', height: 6, offsetX: 0, offsetY: 0 }, tickAmount: undefined, min: undefined, max: undefined, range: undefined, floating: false, position: 'bottom', title: { text: undefined, offsetX: 0, offsetY: 0, style: { color: undefined, fontSize: '12px', fontFamily: this.defaultFont, cssClass: 'apexcharts-xaxis-title' } }, crosshairs: { show: true, width: 1, // tickWidth/barWidth or an integer position: 'back', opacity: 0.9, stroke: { color: '#b6b6b6', width: 0, dashArray: 0 }, fill: { type: 'solid', // solid, gradient color: '#B1B9C4', gradient: { colorFrom: '#D8E3F0', colorTo: '#BED1E6', stops: [0, 100], opacityFrom: 0.4, opacityTo: 0.5 } }, dropShadow: { enabled: false, left: 0, top: 0, blur: 1, opacity: 0.4 } }, tooltip: { enabled: true, offsetY: 0, formatter: undefined } }, yaxis: this.yAxis, theme: { palette: 'palette1', // If defined, it will overwrite globals.colors variable monochrome: { // monochrome allows you to select just 1 color and fill out the rest with light/dark shade (intensity can be selected) enabled: false, color: '#008FFB', shadeTo: 'light', shadeIntensity: 0.65 } } }; } }]); return Options; }(); exports.default = Options; /***/ }), /* 52 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _TimeScale = __webpack_require__(77); var _TimeScale2 = _interopRequireDefault(_TimeScale); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * DateTime Class to manipulate datetime values. * * @module DateTime **/ var DateTime = function () { function DateTime(ctx) { _classCallCheck(this, DateTime); this.ctx = ctx; this.w = ctx.w; this.months31 = [1, 3, 5, 7, 8, 10, 12]; this.months30 = [2, 4, 6, 9, 11]; this.daysCntOfYear = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; } _createClass(DateTime, [{ key: 'isValidDate', value: function isValidDate(date) { return !isNaN(this.parseDate(date)); } }, { key: 'getUTCTimeStamp', value: function getUTCTimeStamp(dateStr) { return new Date(new Date(dateStr).toUTCString().substr(0, 25)).getTime(); // return new Date(new Date(dateStr).setMinutes(new Date().getTimezoneOffset())) } }, { key: 'parseDate', value: function parseDate(dateStr) { var parsed = Date.parse(dateStr); if (!isNaN(parsed)) { return this.getUTCTimeStamp(dateStr); } var output = Date.parse(dateStr.replace(/-/g, '/').replace(/[a-z]+/gi, ' ')); output = this.getUTCTimeStamp(output); return output; } // https://stackoverflow.com/a/11252167/6495043 }, { key: 'treatAsUtc', value: function treatAsUtc(dateStr) { var result = new Date(dateStr); result.setMinutes(result.getMinutes() - result.getTimezoneOffset()); return result; } // http://stackoverflow.com/questions/14638018/current-time-formatting-with-javascript#answer-14638191 }, { key: 'formatDate', value: function formatDate(date, format) { var utc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; var convertToUTC = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; var locale = this.w.globals.locale; var MMMM = ['\x00'].concat(_toConsumableArray(locale.months)); var MMM = ['\x01'].concat(_toConsumableArray(locale.shortMonths)); var dddd = ['\x02'].concat(_toConsumableArray(locale.days)); var ddd = ['\x03'].concat(_toConsumableArray(locale.shortDays)); function ii(i, len) { var s = i + ''; len = len || 2; while (s.length < len) { s = '0' + s; }return s; } if (convertToUTC) { date = this.treatAsUtc(date); } var y = utc ? date.getUTCFullYear() : date.getFullYear(); format = format.replace(/(^|[^\\])yyyy+/g, '$1' + y); format = format.replace(/(^|[^\\])yy/g, '$1' + y.toString().substr(2, 2)); format = format.replace(/(^|[^\\])y/g, '$1' + y); var M = (utc ? date.getUTCMonth() : date.getMonth()) + 1; format = format.replace(/(^|[^\\])MMMM+/g, '$1' + MMMM[0]); format = format.replace(/(^|[^\\])MMM/g, '$1' + MMM[0]); format = format.replace(/(^|[^\\])MM/g, '$1' + ii(M)); format = format.replace(/(^|[^\\])M/g, '$1' + M); var d = utc ? date.getUTCDate() : date.getDate(); format = format.replace(/(^|[^\\])dddd+/g, '$1' + dddd[0]); format = format.replace(/(^|[^\\])ddd/g, '$1' + ddd[0]); format = format.replace(/(^|[^\\])dd/g, '$1' + ii(d)); format = format.replace(/(^|[^\\])d/g, '$1' + d); var H = utc ? date.getUTCHours() : date.getHours(); format = format.replace(/(^|[^\\])HH+/g, '$1' + ii(H)); format = format.replace(/(^|[^\\])H/g, '$1' + H); var h = H > 12 ? H - 12 : H === 0 ? 12 : H; format = format.replace(/(^|[^\\])hh+/g, '$1' + ii(h)); format = format.replace(/(^|[^\\])h/g, '$1' + h); var m = utc ? date.getUTCMinutes() : date.getMinutes(); format = format.replace(/(^|[^\\])mm+/g, '$1' + ii(m)); format = format.replace(/(^|[^\\])m/g, '$1' + m); var s = utc ? date.getUTCSeconds() : date.getSeconds(); format = format.replace(/(^|[^\\])ss+/g, '$1' + ii(s)); format = format.replace(/(^|[^\\])s/g, '$1' + s); var f = utc ? date.getUTCMilliseconds() : date.getMilliseconds(); format = format.replace(/(^|[^\\])fff+/g, '$1' + ii(f, 3)); f = Math.round(f / 10); format = format.replace(/(^|[^\\])ff/g, '$1' + ii(f)); f = Math.round(f / 10); format = format.replace(/(^|[^\\])f/g, '$1' + f); var T = H < 12 ? 'AM' : 'PM'; format = format.replace(/(^|[^\\])TT+/g, '$1' + T); format = format.replace(/(^|[^\\])T/g, '$1' + T.charAt(0)); var t = T.toLowerCase(); format = format.replace(/(^|[^\\])tt+/g, '$1' + t); format = format.replace(/(^|[^\\])t/g, '$1' + t.charAt(0)); var tz = -date.getTimezoneOffset(); var K = utc || !tz ? 'Z' : tz > 0 ? '+' : '-'; if (!utc) { tz = Math.abs(tz); var tzHrs = Math.floor(tz / 60); var tzMin = tz % 60; K += ii(tzHrs) + ':' + ii(tzMin); } format = format.replace(/(^|[^\\])K/g, '$1' + K); var day = (utc ? date.getUTCDay() : date.getDay()) + 1; format = format.replace(new RegExp(dddd[0], 'g'), dddd[day]); format = format.replace(new RegExp(ddd[0], 'g'), ddd[day]); format = format.replace(new RegExp(MMMM[0], 'g'), MMMM[M]); format = format.replace(new RegExp(MMM[0], 'g'), MMM[M]); format = format.replace(/\\(.)/g, '$1'); return format; } }, { key: 'getTimeUnitsfromTimestamp', value: function getTimeUnitsfromTimestamp(minX, maxX) { var w = this.w; if (w.config.xaxis.min !== undefined) { minX = w.config.xaxis.min; } if (w.config.xaxis.max !== undefined) { maxX = w.config.xaxis.max; } var minYear = new Date(minX).getFullYear(); var maxYear = new Date(maxX).getFullYear(); var minMonth = new Date(minX).getMonth(); var maxMonth = new Date(maxX).getMonth(); var minDate = new Date(minX).getDate(); var maxDate = new Date(maxX).getDate(); var minHour = new Date(minX).getHours(); var maxHour = new Date(maxX).getHours(); var minMinute = new Date(minX).getMinutes(); var maxMinute = new Date(maxX).getMinutes(); return { minMinute: minMinute, maxMinute: maxMinute, minHour: minHour, maxHour: maxHour, minDate: minDate, maxDate: maxDate, minMonth: minMonth, maxMonth: maxMonth, minYear: minYear, maxYear: maxYear }; } }, { key: 'isLeapYear', value: function isLeapYear(year) { return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0; } }, { key: 'calculcateLastDaysOfMonth', value: function calculcateLastDaysOfMonth(month, year, subtract) { var days = this.determineDaysOfMonths(month, year); // whatever days we get, subtract the number of days asked return days - subtract; } }, { key: 'determineDaysOfYear', value: function determineDaysOfYear(year) { var days = 365; if (this.isLeapYear(year)) { days = 366; } return days; } }, { key: 'determineRemainingDaysOfYear', value: function determineRemainingDaysOfYear(year, month, date) { var dayOfYear = this.daysCntOfYear[month] + date; if (month > 1 && this.isLeapYear()) dayOfYear++; return dayOfYear; } }, { key: 'determineDaysOfMonths', value: function determineDaysOfMonths(month, year) { var days = 30; var ts = new _TimeScale2.default(this.ctx); month = ts.monthMod(month); switch (true) { case this.months30.includes(month): if (month === 2) { if (this.isLeapYear(year)) { days = 29; } else { days = 28; } } break; case this.months31.includes(month): days = 31; break; default: days = 31; break; } return days; } }]); return DateTime; }(); exports.default = DateTime; /***/ }), /* 53 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // false -> Array#indexOf // true -> Array#includes var toIObject = __webpack_require__(16); var toLength = __webpack_require__(23); var toAbsoluteIndex = __webpack_require__(110); module.exports = function (IS_INCLUDES) { return function ($this, el, fromIndex) { var O = toIObject($this); var length = toLength(O.length); var index = toAbsoluteIndex(fromIndex, length); var value; // Array#includes uses SameValueZero equality algorithm // eslint-disable-next-line no-self-compare if (IS_INCLUDES && el != el) while (length > index) { value = O[index++]; // eslint-disable-next-line no-self-compare if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not } else for (; length > index; index++) { if (IS_INCLUDES || index in O) { if (O[index] === el) return IS_INCLUDES || index || 0; } }return !IS_INCLUDES && -1; }; }; /***/ }), /* 54 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var document = __webpack_require__(3).document; module.exports = document && document.documentElement; /***/ }), /* 55 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = !__webpack_require__(10) && !__webpack_require__(19)(function () { return Object.defineProperty(__webpack_require__(34)('div'), 'a', { get: function get() { return 7; } }).a != 7; }); /***/ }), /* 56 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // check on default Array iterator var Iterators = __webpack_require__(20); var ITERATOR = __webpack_require__(2)('iterator'); var ArrayProto = Array.prototype; module.exports = function (it) { return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); }; /***/ }), /* 57 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 7.2.2 IsArray(argument) var cof = __webpack_require__(18); module.exports = Array.isArray || function isArray(arg) { return cof(arg) == 'Array'; }; /***/ }), /* 58 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // call something on iterator step with safe closing on error var anObject = __webpack_require__(7); module.exports = function (iterator, fn, value, entries) { try { return entries ? fn(anObject(value)[0], value[1]) : fn(value); // 7.4.6 IteratorClose(iterator, completion) } catch (e) { var ret = iterator['return']; if (ret !== undefined) anObject(ret.call(iterator)); throw e; } }; /***/ }), /* 59 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var LIBRARY = __webpack_require__(21); var $export = __webpack_require__(5); var redefine = __webpack_require__(15); var hide = __webpack_require__(12); var Iterators = __webpack_require__(20); var $iterCreate = __webpack_require__(98); var setToStringTag = __webpack_require__(28); var getPrototypeOf = __webpack_require__(105); var ITERATOR = __webpack_require__(2)('iterator'); var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` var FF_ITERATOR = '@@iterator'; var KEYS = 'keys'; var VALUES = 'values'; var returnThis = function returnThis() { return this; }; module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { $iterCreate(Constructor, NAME, next); var getMethod = function getMethod(kind) { if (!BUGGY && kind in proto) return proto[kind]; switch (kind) { case KEYS: return function keys() { return new Constructor(this, kind); }; case VALUES: return function values() { return new Constructor(this, kind); }; }return function entries() { return new Constructor(this, kind); }; }; var TAG = NAME + ' Iterator'; var DEF_VALUES = DEFAULT == VALUES; var VALUES_BUG = false; var proto = Base.prototype; var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; var $default = $native || getMethod(DEFAULT); var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; var methods, key, IteratorPrototype; // Fix native if ($anyNative) { IteratorPrototype = getPrototypeOf($anyNative.call(new Base())); if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { // Set @@toStringTag to native iterators setToStringTag(IteratorPrototype, TAG, true); // fix for some old engines if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis); } } // fix Array#{values, @@iterator}.name in V8 / FF if (DEF_VALUES && $native && $native.name !== VALUES) { VALUES_BUG = true; $default = function values() { return $native.call(this); }; } // Define iterator if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { hide(proto, ITERATOR, $default); } // Plug for library Iterators[NAME] = $default; Iterators[TAG] = returnThis; if (DEFAULT) { methods = { values: DEF_VALUES ? $default : getMethod(VALUES), keys: IS_SET ? $default : getMethod(KEYS), entries: $entries }; if (FORCED) for (key in methods) { if (!(key in proto)) redefine(proto, key, methods[key]); } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); } return methods; }; /***/ }), /* 60 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var ITERATOR = __webpack_require__(2)('iterator'); var SAFE_CLOSING = false; try { var riter = [7][ITERATOR](); riter['return'] = function () { SAFE_CLOSING = true; }; // eslint-disable-next-line no-throw-literal Array.from(riter, function () { throw 2; }); } catch (e) {/* empty */} module.exports = function (exec, skipClosing) { if (!skipClosing && !SAFE_CLOSING) return false; var safe = false; try { var arr = [7]; var iter = arr[ITERATOR](); iter.next = function () { return { done: safe = true }; }; arr[ITERATOR] = function () { return iter; }; exec(arr); } catch (e) {/* empty */} return safe; }; /***/ }), /* 61 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) var anObject = __webpack_require__(7); var dPs = __webpack_require__(102); var enumBugKeys = __webpack_require__(35); var IE_PROTO = __webpack_require__(39)('IE_PROTO'); var Empty = function Empty() {/* empty */}; var PROTOTYPE = 'prototype'; // Create object with fake `null` prototype: use iframe Object with cleared prototype var _createDict = function createDict() { // Thrash, waste and sodomy: IE GC bug var iframe = __webpack_require__(34)('iframe'); var i = enumBugKeys.length; var lt = '<'; var gt = '>'; var iframeDocument; iframe.style.display = 'none'; __webpack_require__(54).appendChild(iframe); iframe.src = 'javascript:'; // eslint-disable-line no-script-url // createDict = iframe.contentWindow.Object; // html.removeChild(iframe); iframeDocument = iframe.contentWindow.document; iframeDocument.open(); iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); iframeDocument.close(); _createDict = iframeDocument.F; while (i--) { delete _createDict[PROTOTYPE][enumBugKeys[i]]; }return _createDict(); }; module.exports = Object.create || function create(O, Properties) { var result; if (O !== null) { Empty[PROTOTYPE] = anObject(O); result = new Empty(); Empty[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill result[IE_PROTO] = O; } else result = _createDict(); return Properties === undefined ? result : dPs(result, Properties); }; /***/ }), /* 62 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) var $keys = __webpack_require__(64); var hiddenKeys = __webpack_require__(35).concat('length', 'prototype'); exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { return $keys(O, hiddenKeys); }; /***/ }), /* 63 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.f = Object.getOwnPropertySymbols; /***/ }), /* 64 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var has = __webpack_require__(11); var toIObject = __webpack_require__(16); var arrayIndexOf = __webpack_require__(53)(false); var IE_PROTO = __webpack_require__(39)('IE_PROTO'); module.exports = function (object, names) { var O = toIObject(object); var i = 0; var result = []; var key; for (key in O) { if (key != IE_PROTO) has(O, key) && result.push(key); } // Don't enum bug & hidden keys while (names.length > i) { if (has(O, key = names[i++])) { ~arrayIndexOf(result, key) || result.push(key); } }return result; }; /***/ }), /* 65 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = function (exec) { try { return { e: false, v: exec() }; } catch (e) { return { e: true, v: e }; } }; /***/ }), /* 66 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var anObject = __webpack_require__(7); var isObject = __webpack_require__(8); var newPromiseCapability = __webpack_require__(37); module.exports = function (C, x) { anObject(C); if (isObject(x) && x.constructor === C) return x; var promiseCapability = newPromiseCapability.f(C); var resolve = promiseCapability.resolve; resolve(x); return promiseCapability.promise; }; /***/ }), /* 67 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 7.3.20 SpeciesConstructor(O, defaultConstructor) var anObject = __webpack_require__(7); var aFunction = __webpack_require__(17); var SPECIES = __webpack_require__(2)('species'); module.exports = function (O, D) { var C = anObject(O).constructor; var S; return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); }; /***/ }), /* 68 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var ctx = __webpack_require__(14); var invoke = __webpack_require__(97); var html = __webpack_require__(54); var cel = __webpack_require__(34); var global = __webpack_require__(3); var process = global.process; var setTask = global.setImmediate; var clearTask = global.clearImmediate; var MessageChannel = global.MessageChannel; var Dispatch = global.Dispatch; var counter = 0; var queue = {}; var ONREADYSTATECHANGE = 'onreadystatechange'; var defer, channel, port; var run = function run() { var id = +this; // eslint-disable-next-line no-prototype-builtins if (queue.hasOwnProperty(id)) { var fn = queue[id]; delete queue[id]; fn(); } }; var listener = function listener(event) { run.call(event.data); }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise: if (!setTask || !clearTask) { setTask = function setImmediate(fn) { var args = []; var i = 1; while (arguments.length > i) { args.push(arguments[i++]); }queue[++counter] = function () { // eslint-disable-next-line no-new-func invoke(typeof fn == 'function' ? fn : Function(fn), args); }; defer(counter); return counter; }; clearTask = function clearImmediate(id) { delete queue[id]; }; // Node.js 0.8- if (__webpack_require__(18)(process) == 'process') { defer = function defer(id) { process.nextTick(ctx(run, id, 1)); }; // Sphere (JS game engine) Dispatch API } else if (Dispatch && Dispatch.now) { defer = function defer(id) { Dispatch.now(ctx(run, id, 1)); }; // Browsers with MessageChannel, includes WebWorkers } else if (MessageChannel) { channel = new MessageChannel(); port = channel.port2; channel.port1.onmessage = listener; defer = ctx(port.postMessage, port, 1); // Browsers with postMessage, skip WebWorkers // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) { defer = function defer(id) { global.postMessage(id + '', '*'); }; global.addEventListener('message', listener, false); // IE8- } else if (ONREADYSTATECHANGE in cel('script')) { defer = function defer(id) { html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () { html.removeChild(this); run.call(id); }; }; // Rest old browsers } else { defer = function defer(id) { setTimeout(ctx(run, id, 1), 0); }; } } module.exports = { set: setTask, clear: clearTask }; /***/ }), /* 69 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.f = __webpack_require__(2); /***/ }), /* 70 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var classof = __webpack_require__(32); var ITERATOR = __webpack_require__(2)('iterator'); var Iterators = __webpack_require__(20); module.exports = __webpack_require__(4).getIteratorMethod = function (it) { if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)]; }; /***/ }), /* 71 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 19.1.3.6 Object.prototype.toString() var classof = __webpack_require__(32); var test = {}; test[__webpack_require__(2)('toStringTag')] = 'z'; if (test + '' != '[object z]') { __webpack_require__(15)(Object.prototype, 'toString', function toString() { return '[object ' + classof(this) + ']'; }, true); } /***/ }), /* 72 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var $at = __webpack_require__(109)(true); // 21.1.3.27 String.prototype[@@iterator]() __webpack_require__(59)(String, 'String', function (iterated) { this._t = String(iterated); // target this._i = 0; // next index // 21.1.5.2.1 %StringIteratorPrototype%.next() }, function () { var O = this._t; var index = this._i; var point; if (index >= O.length) return { value: undefined, done: true }; point = $at(O, index); this._i += point.length; return { value: point, done: false }; }); /***/ }), /* 73 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Fill = __webpack_require__(13); var _Fill2 = _interopRequireDefault(_Fill); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Filters = __webpack_require__(6); var _Filters2 = _interopRequireDefault(_Filters); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Pie Class for drawing Pie / Donut Charts. * @module Pie **/ var Pie = function () { function Pie(ctx) { _classCallCheck(this, Pie); this.ctx = ctx; this.w = ctx.w; this.chartType = this.w.config.chart.type; this.initialAnim = this.w.config.chart.animations.enabled; this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled; this.animBeginArr = [0]; this.animDur = 0; var w = this.w; this.lineColorArr = w.globals.stroke.colors !== undefined ? w.globals.stroke.colors : w.globals.colors; this.defaultSize = w.globals.svgHeight < w.globals.svgWidth ? w.globals.svgHeight - 35 : w.globals.gridWidth; this.centerY = this.defaultSize / 2; this.centerX = w.globals.gridWidth / 2; this.fullAngle = 360; this.size = 0; this.donutSize = 0; this.prevSectorAngleArr = []; // for dynamic animations } _createClass(Pie, [{ key: 'draw', value: function draw(series) { var self = this; var w = this.w; var graphics = new _Graphics2.default(this.ctx); var ret = graphics.group({ class: 'apexcharts-pie' }); var total = 0; for (var k = 0; k < series.length; k++) { // CALCULATE THE TOTAL total += _Utils2.default.negToZero(series[k]); } var sectorAngleArr = []; // el to which series will be drawn var elSeries = graphics.group(); for (var i = 0; i < series.length; i++) { // CALCULATE THE ANGLES var angle = this.fullAngle * _Utils2.default.negToZero(series[i]) / total; sectorAngleArr.push(angle); } if (w.globals.dataChanged) { var prevTotal = 0; for (var _k = 0; _k < w.globals.previousPaths.length; _k++) { // CALCULATE THE PREV TOTAL prevTotal += _Utils2.default.negToZero(w.globals.previousPaths[_k]); } var previousAngle = void 0; for (var _i = 0; _i < w.globals.previousPaths.length; _i++) { // CALCULATE THE PREVIOUS ANGLES previousAngle = this.fullAngle * _Utils2.default.negToZero(w.globals.previousPaths[_i]) / prevTotal; this.prevSectorAngleArr.push(previousAngle); } } this.size = this.defaultSize / 2.05 - w.config.stroke.width - w.config.chart.dropShadow.blur; if (w.config.plotOptions.pie.size !== undefined) { this.size = w.config.plotOptions.pie.size; } this.donutSize = this.size * parseInt(w.config.plotOptions.pie.donut.size) / 100; var scaleSize = 1 + w.config.plotOptions.pie.customScale; var halfW = w.globals.gridWidth / 2; var halfH = w.globals.gridHeight / 2; var translateX = halfW - w.globals.gridWidth / 2 * scaleSize; var translateY = halfH - w.globals.gridHeight / 2 * scaleSize; if (w.config.chart.type === 'donut') { // draw the inner circle and add some text to it var circle = graphics.drawCircle(this.donutSize); circle.attr({ cx: this.centerX, cy: this.centerY, fill: w.config.plotOptions.pie.donut.background }); elSeries.add(circle); } var elG = self.drawArcs(sectorAngleArr, series); elSeries.attr({ 'transform': 'translate(' + translateX + ', ' + (translateY - 25) + ') scale(' + scaleSize + ')' }); ret.attr({ 'data:innerTranslateX': translateX, 'data:innerTranslateY': translateY - 25 }); elSeries.add(elG); ret.add(elSeries); return ret; } // core function for drawing pie arcs }, { key: 'drawArcs', value: function drawArcs(sectorAngleArr, series) { var w = this.w; var filters = new _Filters2.default(this.ctx); var graphics = new _Graphics2.default(this.ctx); var fill = new _Fill2.default(this.ctx); var g = graphics.group(); var startAngle = 0; var prevStartAngle = 0; var endAngle = 0; var prevEndAngle = 0; this.strokeWidth = w.config.stroke.show ? w.config.stroke.width : 0; for (var i = 0; i < sectorAngleArr.length; i++) { // if(sectorAngleArr[i]>0) { var elPieArc = graphics.group({ class: 'apexcharts-series apexcharts-pie-series ' + w.globals.seriesNames[i].replace(/ /g, '-'), id: 'apexcharts-series-' + i, rel: i + 1 }); g.add(elPieArc); startAngle = endAngle; prevStartAngle = prevEndAngle; endAngle = startAngle + sectorAngleArr[i]; prevEndAngle = prevStartAngle + this.prevSectorAngleArr[i]; var angle = endAngle - startAngle; var pathFill = fill.fillPath(elPieArc, { seriesNumber: i, size: this.size }); // additionaly, pass size for gradient drawing in the fillPath function var path = this.getChangedPath(prevStartAngle, prevEndAngle); var elPath = graphics.drawPath({ d: path, stroke: this.lineColorArr instanceof Array ? this.lineColorArr[i] : this.lineColorArr, strokeWidth: this.strokeWidth, fill: pathFill, fillOpacity: w.config.fill.opacity, classes: 'apexcharts-pie-area' }); elPath.attr({ id: 'apexcharts-pieSlice-' + i, index: 0, j: i }); if (w.config.chart.dropShadow.enabled) { var shadow = w.config.chart.dropShadow; filters.dropShadow(elPath, shadow); } this.addListeners(elPath); _Graphics2.default.setAttrs(elPath.node, { 'data:angle': angle, 'data:startAngle': startAngle, 'data:strokeWidth': this.strokeWidth, 'data:value': series[i] }); var labelPosition = void 0; if (w.config.chart.type === 'pie') { labelPosition = _Utils2.default.polarToCartesian(this.centerX, this.centerY, this.size / 1.25 + w.config.plotOptions.pie.dataLabels.offset, startAngle + (endAngle - startAngle) / 2); } else if (w.config.chart.type === 'donut') { labelPosition = _Utils2.default.polarToCartesian(this.centerX, this.centerY, (this.size + this.donutSize) / 2 + w.config.plotOptions.pie.dataLabels.offset, startAngle + (endAngle - startAngle) / 2); } elPieArc.add(elPath); // Animation code starts var dur = 0; if (this.initialAnim && !w.globals.resized && !w.globals.dataChanged) { dur = (endAngle - startAngle) / this.fullAngle * w.config.chart.animations.speed; this.animDur = dur + this.animDur; this.animBeginArr.push(this.animDur); } else { this.animBeginArr.push(0); } if (this.dynamicAnim && w.globals.dataChanged) { this.animatePaths(elPath, { endAngle: endAngle, startAngle: startAngle, prevStartAngle: prevStartAngle, prevEndAngle: prevEndAngle, animateStartingPos: true, i: i, animBeginArr: this.animBeginArr, dur: w.config.chart.animations.dynamicAnimation.speed }); } else { this.animatePaths(elPath, { endAngle: endAngle, startAngle: startAngle, i: i, totalItems: sectorAngleArr.length - 1, animBeginArr: this.animBeginArr, dur: dur }); } // animation code ends elPath.click(this.pieClicked.bind(this, i)); if (w.config.dataLabels.enabled) { var xPos = labelPosition.x; var yPos = labelPosition.y; var text = 100 * (endAngle - startAngle) / 360 + '%'; if (angle !== 0) { var formatter = w.config.dataLabels.formatter; if (formatter !== undefined) { text = formatter(w.globals.seriesPercent[i][0], { seriesIndex: i, globals: w.globals }); } var foreColor = w.globals.dataLabels.style.colors[i]; var elPieLabel = graphics.drawText({ x: xPos, y: yPos, text: text, textAnchor: 'middle', fontSize: w.config.dataLabels.style.fontSize, fontFamily: w.config.dataLabels.style.fontFamily, foreColor: foreColor }); if (w.config.dataLabels.dropShadow.enabled) { var textShadow = w.config.dataLabels.dropShadow; var _filters = new _Filters2.default(this.ctx); _filters.dropShadow(elPieLabel, textShadow); } elPieLabel.node.classList.add('apexcharts-pie-label'); if (w.config.chart.animations.animate && w.globals.resized === false) { elPieLabel.node.classList.add('apexcharts-pie-label-delay'); elPieLabel.node.style.animationDelay = w.config.chart.animations.speed / 940 + 's'; } elPieArc.add(elPieLabel); } } // } } return g; } }, { key: 'addListeners', value: function addListeners(elPath) { var graphics = new _Graphics2.default(this.ctx); // append filters on mouseenter and mouseleave elPath.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, elPath)); elPath.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, elPath)); elPath.node.addEventListener('mousedown', graphics.pathMouseDown.bind(this, elPath)); elPath.node.addEventListener('touchStart', graphics.pathMouseDown.bind(this, elPath), { passive: true }); } // This function can be used for other circle charts too }, { key: 'animatePaths', value: function animatePaths(el, opts) { var w = this.w; var me = this; var angle = opts.endAngle - opts.startAngle; var prevAngle = angle; var fromStartAngle = opts.startAngle; var toStartAngle = opts.startAngle; if (opts.prevStartAngle !== undefined && opts.prevEndAngle !== undefined) { fromStartAngle = opts.prevEndAngle; prevAngle = opts.prevEndAngle - opts.prevStartAngle; } if (opts.i === w.config.series.length - 1) { // some adjustments for the last overlapping paths if (angle + toStartAngle > this.fullAngle) { opts.endAngle = opts.endAngle - (angle + toStartAngle); } else if (angle + toStartAngle < this.fullAngle) { opts.endAngle = opts.endAngle + (this.fullAngle - (angle + toStartAngle)); } } if (angle === this.fullAngle) angle = this.fullAngle - 0.01; me.animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, opts); } }, { key: 'animateArc', value: function animateArc(el, fromStartAngle, toStartAngle, angle, prevAngle, params) { var me = this; var w = this.w; var size = me.size; if (!size) { size = params.size; } var path = void 0; var opts = params; if (isNaN(fromStartAngle) || isNaN(prevAngle)) { fromStartAngle = toStartAngle; prevAngle = angle; opts.dur = 0; } var currAngle = angle; var startAngle = toStartAngle; var fromAngle = fromStartAngle - toStartAngle; if (w.globals.dataChanged && params.shouldSetPrevPaths) { // to avoid flickering, set prev path first and then we will animate from there path = me.getPiePath({ me: me, startAngle: startAngle, angle: prevAngle, size: size }); el.attr({ d: path }); } if (opts.dur !== 0) { el.animate(opts.dur, w.globals.easing, opts.animBeginArr[opts.i]).afterAll(function () { if (w.config.chart.type === 'pie' || w.config.chart.type === 'donut') { this.animate(300).attr({ 'stroke-width': w.config.stroke.width }); } }).during(function (pos) { currAngle = fromAngle + (angle - fromAngle) * pos; if (params.animateStartingPos) { currAngle = prevAngle + (angle - prevAngle) * pos; startAngle = fromStartAngle - prevAngle + (toStartAngle - (fromStartAngle - prevAngle)) * pos; } path = me.getPiePath({ me: me, startAngle: startAngle, angle: currAngle, size: size }); el.node.setAttribute('data:pathOrig', path); el.attr({ d: path }); }); } else { path = me.getPiePath({ me: me, startAngle: startAngle, angle: angle, size: size }); el.node.setAttribute('data:pathOrig', path); el.attr({ d: path }); } } }, { key: 'pieClicked', value: function pieClicked(i) { var w = this.w; var me = this; var path = void 0; var size = me.size + 10; var elPath = w.globals.dom.Paper.select('#apexcharts-pieSlice-' + i).members[0]; var pathFrom = elPath.attr('d'); if (elPath.attr('data:pieClicked') === 'true') { elPath.attr({ 'data:pieClicked': 'false' }); var origPath = elPath.attr('data:pathOrig'); elPath.attr({ 'd': origPath }); return; } else { // reset all elems var allEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-pie-area'); Array.prototype.forEach.call(allEls, function (pieSlice) { pieSlice.setAttribute('data:pieClicked', 'false'); var origPath = pieSlice.getAttribute('data:pathOrig'); pieSlice.setAttribute('d', origPath); }); elPath.attr('data:pieClicked', 'true'); } var startAngle = parseInt(elPath.attr('data:startAngle')); var angle = parseInt(elPath.attr('data:angle')); path = me.getPiePath({ me: me, startAngle: startAngle, angle: angle, size: size }); if (angle === 360) return; elPath.plot(path).animate(1).plot(pathFrom).animate(100).plot(path); } }, { key: 'getChangedPath', value: function getChangedPath(prevStartAngle, prevEndAngle) { var path = ''; if (this.dynamicAnim && this.w.globals.dataChanged) { path = this.getPiePath({ me: this, startAngle: prevStartAngle, angle: prevEndAngle - prevStartAngle, size: this.size }); } return path; } }, { key: 'getPiePath', value: function getPiePath(_ref) { var me = _ref.me, startAngle = _ref.startAngle, angle = _ref.angle, size = _ref.size; var w = this.w; var path = void 0; var startDeg = startAngle; var startRadians = Math.PI * (startDeg - 90) / 180; var endDeg = angle + startAngle; if (endDeg > 360) endDeg = 360; var endRadians = Math.PI * (endDeg - 90) / 180; var x1 = me.centerX + size * Math.cos(startRadians); var y1 = me.centerY + size * Math.sin(startRadians); var x2 = me.centerX + size * Math.cos(endRadians); var y2 = me.centerY + size * Math.sin(endRadians); var startInner = _Utils2.default.polarToCartesian(me.centerX, me.centerY, me.donutSize, endDeg); var endInner = _Utils2.default.polarToCartesian(me.centerX, me.centerY, me.donutSize, startDeg); var largeArc = angle > 180 ? 1 : 0; if (w.config.chart.type === 'donut') { path = ['M', x1, y1, 'A', size, size, 0, largeArc, 1, x2, y2, 'L', startInner.x, startInner.y, 'A', me.donutSize, me.donutSize, 0, largeArc, 0, endInner.x, endInner.y, 'L', x1, y1, 'z'].join(' '); } else if (w.config.chart.type === 'pie') { path = ['M', x1, y1, 'A', size, size, 0, largeArc, 1, x2, y2, 'L', me.centerX, me.centerY, 'L', x1, y1].join(' '); } else { path = ['M', x1, y1, 'A', size, size, 0, largeArc, 1, x2, y2].join(' '); } return path; } }]); return Pie; }(); exports.default = Pie; /***/ }), /* 74 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Animations = __webpack_require__(25); var _Animations2 = _interopRequireDefault(_Animations); var _Fill = __webpack_require__(13); var _Fill2 = _interopRequireDefault(_Fill); var _Filters = __webpack_require__(6); var _Filters2 = _interopRequireDefault(_Filters); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Markers = __webpack_require__(47); var _Markers2 = _interopRequireDefault(_Markers); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Scatter Class. * This Class also handles bubbles chart as currently there is no major difference in drawing them, * @module Scatter **/ var Scatter = function () { function Scatter(ctx) { _classCallCheck(this, Scatter); this.ctx = ctx; this.w = ctx.w; this.initialAnim = this.w.config.chart.animations.enabled; this.dynamicAnim = this.initialAnim && this.w.config.chart.animations.dynamicAnimation.enabled; // this array will help in centering the label in bubbles this.radiusSizes = []; } _createClass(Scatter, [{ key: 'draw', value: function draw(elSeries, j, opts) { var w = this.w; var anim = new _Animations2.default(this.ctx); var graphics = new _Graphics2.default(this.ctx); var filters = new _Filters2.default(this.ctx); var fill = new _Fill2.default(this.ctx); var realIndex = opts.realIndex; var pointsPos = opts.pointsPos; var zRatio = opts.zRatio; var elPointsMain = opts.elParent; var pathFillCircle = fill.fillPath(elSeries, { seriesNumber: realIndex }); var elPointsWrap = graphics.group({ class: 'apexcharts-series-markers apexcharts-series-' + w.config.chart.type }); if (pointsPos.x instanceof Array) { for (var q = 0; q < pointsPos.x.length; q++) { var realIndexP = j + 1; // a small hack as we have 2 points for the first val to connect it if (j === 0 && q === 0) realIndexP = 0; if (j === 0 && q === 1) realIndexP = 1; var radius = 0; var finishRadius = w.config.markers.size; if (zRatio !== Infinity) { // means we have a bubble finishRadius = w.globals.seriesZ[realIndex][realIndexP] / zRatio; if (typeof this.radiusSizes[realIndex] === 'undefined') { this.radiusSizes.push([]); } this.radiusSizes[realIndex].push(finishRadius); } if (!w.config.chart.animations.enabled) { radius = finishRadius; } var x = pointsPos.x[q]; var y = pointsPos.y[q]; x = x || 0; y = y || 0; radius = radius || 0; if (x === 0 && y === 0 || typeof w.globals.series[realIndex][realIndexP] === 'undefined') return; var circle = graphics.drawCircle(radius); circle.attr({ cx: x, cy: y, fill: pathFillCircle }); if (w.config.chart.dropShadow.enabled) { filters.dropShadow(circle, { top: w.config.chart.dropShadow.top, left: w.config.chart.dropShadow.left, blur: w.config.chart.dropShadow.blur }); } if (this.initialAnim && !w.globals.dataChanged) { var speed = 1; if (!w.globals.resized) { speed = w.config.chart.animations.speed; } anim.animateCircleRadius(circle, 0, finishRadius, speed, w.globals.easing); } if (w.globals.dataChanged) { if (this.dynamicAnim) { var _speed = w.config.chart.animations.dynamicAnimation.speed; var prevX = void 0, prevY = void 0, prevR = void 0; var prevPathJ = w.globals.previousPaths[realIndex][j]; if (typeof prevPathJ !== 'undefined') { // series containing less elements will ignore these values and revert to 0 prevX = prevPathJ.x; prevY = prevPathJ.y; prevR = typeof prevPathJ.r !== 'undefined' ? prevPathJ.r : finishRadius; } for (var cs = 0; cs < w.globals.collapsedSeries.length; cs++) { if (w.globals.collapsedSeries[cs].index === realIndex) { _speed = 1; finishRadius = 0; } } if (x === 0 && y === 0) finishRadius = 0; anim.animateCircle(circle, { cx: prevX, cy: prevY, r: prevR }, { cx: x, cy: y, r: finishRadius }, _speed, w.globals.easing); } else { circle.attr({ r: finishRadius }); } } circle.attr({ 'rel': realIndexP, 'j': realIndexP, 'index': realIndex }); var markers = new _Markers2.default(this.ctx); markers.setSelectedPointFilter(circle, realIndex, realIndexP); markers.addEvents(circle); circle.node.classList.add('apexcharts-marker'); elPointsWrap.add(circle); elPointsMain.add(elPointsWrap); } } } }, { key: 'centerTextInBubble', value: function centerTextInBubble(y, i, realIndexP) { var w = this.w; y = y + parseInt(w.config.dataLabels.style.fontSize) / 4; return { y: y }; } }]); return Scatter; }(); module.exports = Scatter; /***/ }), /* 75 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* ** Util functions which are dependent on ApexCharts instance */ var CoreUtils = function () { function CoreUtils(ctx) { _classCallCheck(this, CoreUtils); this.ctx = ctx; this.w = ctx.w; } /** * @memberof CoreUtils * returns the sum of all individual values in a multiple stacked series * Eg. w.globals.series = [[32,33,43,12], [2,3,5,1]] * @return [34,36,48,13] **/ _createClass(CoreUtils, [{ key: "getStackedSeriesTotals", value: function getStackedSeriesTotals() { var w = this.w; var total = []; for (var i = 0; i < w.globals.series[w.globals.maxValsInArrayIndex].length; i++) { var t = 0; for (var j = 0; j < w.globals.series.length; j++) { t += w.globals.series[j][i]; } total.push(t); } w.globals.stackedSeriesTotals = total; return total; } // get total of the all values inside all series }, { key: "getSeriesTotalByIndex", value: function getSeriesTotalByIndex() { var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; if (index === null) { // non-plot chart types - pie / donut / circle return this.w.config.series.reduce(function (acc, cur) { return acc + cur; }, 0); } else { // axis charts - supporting multiple series return this.w.config.series[index].data.reduce(function (acc, cur) { return acc + cur; }, 0); } } // maxValsInArrayIndex is the index of series[] which has the largest number of items }, { key: "getLargestSeries", value: function getLargestSeries() { var w = this.w; w.globals.maxValsInArrayIndex = w.globals.series.map(function (a) { return a.length; }).indexOf(Math.max.apply(Math, w.globals.series.map(function (a) { return a.length; }))); } /** * @memberof Core * returns the sum of all values in a series * Eg. w.globals.series = [[32,33,43,12], [2,3,5,1]] * @return [120, 11] **/ }, { key: "getSeriesTotals", value: function getSeriesTotals() { var w = this.w; w.globals.seriesTotals = w.globals.series.map(function (ser, index) { var total = 0; if (Array.isArray(ser)) { for (var j = 0; j < ser.length; j++) { total += ser[j]; } } else { // for pie/donuts/gauges total += ser; } return total; }); } }, { key: "getSeriesTotalsXRange", value: function getSeriesTotalsXRange(minX, maxX) { var w = this.w; var seriesTotalsXRange = w.globals.series.map(function (ser, index) { var total = 0; for (var j = 0; j < ser.length; j++) { if (w.globals.seriesX[index][j] > minX && w.globals.seriesX[index][j] < maxX) { total += ser[j]; } } return total; }); return seriesTotalsXRange; } /** * @memberof CoreUtils * returns the percentage value of all individual values which can be used in a 100% stacked series * Eg. w.globals.series = [[32, 33, 43, 12], [2, 3, 5, 1]] * @return [[94.11, 91.66, 89.58, 92.30], [5.88, 8.33, 10.41, 7.7]] **/ }, { key: "getPercentSeries", value: function getPercentSeries() { var w = this.w; w.globals.seriesPercent = w.globals.series.map(function (ser, index) { var seriesPercent = []; if (Array.isArray(ser)) { for (var j = 0; j < ser.length; j++) { var total = w.globals.stackedSeriesTotals[j]; var percent = 100 * ser[j] / total; seriesPercent.push(percent); } } else { var _total = w.globals.seriesTotals.reduce(function (acc, val) { return acc + val; }, 0); var _percent = 100 * ser / _total; seriesPercent.push(_percent); } return seriesPercent; }); } // Some config objects can be array - and we need to extend them correctly }], [{ key: "extendArrayProps", value: function extendArrayProps(configInstance, options) { if (options.yaxis) { options = configInstance.extendYAxis(options); } if (options.annotations) { if (options.annotations.yaxis) { options = configInstance.extendYAxisAnnotations(options); } if (options.annotations.xaxis) { options = configInstance.extendXAxisAnnotations(options); } if (options.annotations.points) { options = configInstance.extendPointAnnotations(options); } } return options; } }]); return CoreUtils; }(); exports.default = CoreUtils; /***/ }), /* 76 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Filters = __webpack_require__(6); var _Filters2 = _interopRequireDefault(_Filters); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Crosshairs = function () { function Crosshairs(ctx) { _classCallCheck(this, Crosshairs); this.ctx = ctx; this.w = ctx.w; } _createClass(Crosshairs, [{ key: 'drawXCrosshairs', value: function drawXCrosshairs() { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var filters = new _Filters2.default(this.ctx); var crosshairGradient = w.config.xaxis.crosshairs.fill.gradient; var crosshairShadow = w.config.xaxis.crosshairs.dropShadow; var fillType = w.config.xaxis.crosshairs.fill.type; var gradientFrom = crosshairGradient.colorFrom; var gradientTo = crosshairGradient.colorTo; var opacityFrom = crosshairGradient.opacityFrom; var opacityTo = crosshairGradient.opacityTo; var stops = crosshairGradient.stops; var shadow = 'none'; var dropShadow = crosshairShadow.enabled; var shadowLeft = crosshairShadow.left; var shadowTop = crosshairShadow.top; var shadowBlur = crosshairShadow.blur; var shadowOpacity = crosshairShadow.opacity; var xcrosshairsFill = w.config.xaxis.crosshairs.fill.color; if (w.config.xaxis.crosshairs.show) { if (fillType === 'gradient') { xcrosshairsFill = graphics.drawGradient('vertical', gradientFrom, gradientTo, opacityFrom, opacityTo, null, stops); } var xcrosshairs = graphics.drawRect(); xcrosshairs.attr({ class: 'apexcharts-xcrosshairs', x: 0, y: 0, width: 0, height: w.globals.gridHeight, fill: xcrosshairsFill, filter: shadow, 'fill-opacity': w.config.xaxis.crosshairs.opacity, 'stroke': w.config.xaxis.crosshairs.stroke.color, 'stroke-width': w.config.xaxis.crosshairs.stroke.width, 'stroke-dasharray': w.config.xaxis.crosshairs.stroke.dashArray }); if (dropShadow) { xcrosshairs = filters.dropShadow(xcrosshairs, { left: shadowLeft, top: shadowTop, blur: shadowBlur, opacity: shadowOpacity }); } w.globals.dom.elGraphical.add(xcrosshairs); } } }, { key: 'drawYCrosshairs', value: function drawYCrosshairs() { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var crosshair = w.config.yaxis[0].crosshairs; if (w.config.yaxis[0].crosshairs.show) { var ycrosshairs = graphics.drawLine(0, 0, w.globals.gridWidth, 0, crosshair.stroke.color, crosshair.stroke.dashArray, crosshair.stroke.width); ycrosshairs.attr({ class: 'apexcharts-ycrosshairs' }); w.globals.dom.elGraphical.add(ycrosshairs); } // draw an invisible crosshair to help in positioning the yaxis tooltip var ycrosshairsHidden = graphics.drawLine(0, 0, w.globals.gridWidth, 0, crosshair.stroke.color, 0, 0); ycrosshairsHidden.attr({ class: 'apexcharts-ycrosshairs-hidden' }); w.globals.dom.elGraphical.add(ycrosshairsHidden); } }]); return Crosshairs; }(); exports.default = Crosshairs; /***/ }), /* 77 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _DateTime = __webpack_require__(52); var _DateTime2 = _interopRequireDefault(_DateTime); var _Dimensions = __webpack_require__(46); var _Dimensions2 = _interopRequireDefault(_Dimensions); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts TimeScale Class for generating time ticks for x-axis. * * @module TimeScale **/ var TimeScale = function () { function TimeScale(ctx) { _classCallCheck(this, TimeScale); this.ctx = ctx; this.w = ctx.w; this.timeScaleArray = []; } _createClass(TimeScale, [{ key: 'calculateTimeScaleTicks', value: function calculateTimeScaleTicks(minX, maxX) { var _this = this; var w = this.w; // null check when no series to show if (w.globals.allSeriesCollapsed) { w.globals.labels = []; w.globals.timelineLabels = []; return []; } var dt = new _DateTime2.default(this.ctx); var daysDiff = (maxX - minX) / (1000 * 60 * 60 * 24); this.determineInterval(daysDiff); w.globals.disableZoomIn = false; w.globals.disableZoomOut = false; if (daysDiff < 0.005) { w.globals.disableZoomIn = true; } else if (daysDiff > 50000) { w.globals.disableZoomOut = true; } var timeIntervals = dt.getTimeUnitsfromTimestamp(minX, maxX); var daysWidthOnXAxis = w.globals.gridWidth / daysDiff; var hoursWidthOnXAxis = daysWidthOnXAxis / 24; var minutesWidthOnXAxis = hoursWidthOnXAxis / 60; var numberOfHours = Math.floor(daysDiff * 24); var numberOfMinutes = Math.floor(daysDiff * 24 * 60); var numberOfDays = Math.floor(daysDiff); var numberOfMonths = Math.floor(daysDiff / 30); var numberOfYears = Math.floor(daysDiff / 365); var firstVal = { minMinute: timeIntervals.minMinute, minHour: timeIntervals.minHour, minDate: timeIntervals.minDate, minMonth: timeIntervals.minMonth, minYear: timeIntervals.minYear }; var currentMinute = firstVal.minMinute; var currentHour = firstVal.minHour; var currentMonthDate = firstVal.minDate; var currentDate = firstVal.minDate; var currentMonth = firstVal.minMonth; var currentYear = firstVal.minYear; var params = { firstVal: firstVal, currentMinute: currentMinute, currentHour: currentHour, currentMonthDate: currentMonthDate, currentDate: currentDate, currentMonth: currentMonth, currentYear: currentYear, daysWidthOnXAxis: daysWidthOnXAxis, hoursWidthOnXAxis: hoursWidthOnXAxis, minutesWidthOnXAxis: minutesWidthOnXAxis, numberOfMinutes: numberOfMinutes, numberOfHours: numberOfHours, numberOfDays: numberOfDays, numberOfMonths: numberOfMonths, numberOfYears: numberOfYears }; switch (this.tickInterval) { case 'years': { this.generateYearScale(params); break; } case 'months': case 'half_year': { this.generateMonthScale(params); break; } case 'months_days': case 'months_fortnight': case 'days': case 'week_days': { this.generateDayScale(params); break; } case 'hours': { this.generateHourScale(params); break; } case 'minutes': this.generateMinuteScale(params); break; } // first, we will adjust the month values index // as in the upper function, it is starting from 0 // we will start them from 1 var adjustedMonthInTimeScaleArray = this.timeScaleArray.map(function (ts) { var defaultReturn = { position: ts.position, unit: ts.unit, year: ts.year, day: ts.day ? ts.day : 1, hour: ts.hour ? ts.hour : 0, month: ts.month + 1 }; if (ts.unit === 'month') { return _extends({}, defaultReturn, { value: ts.value + 1 }); } else if (ts.unit === 'day' || ts.unit === 'hour') { return _extends({}, defaultReturn, { value: ts.value }); } else if (ts.unit === 'minute') { return _extends({}, defaultReturn, { value: ts.value, minute: ts.value }); } return ts; }); var filteredTimeScale = adjustedMonthInTimeScaleArray.filter(function (ts) { var modulo = 1; var ticks = Math.ceil(w.globals.gridWidth / 120); var value = ts.value; if (w.config.xaxis.tickAmount !== undefined) { ticks = w.config.xaxis.tickAmount; } if (adjustedMonthInTimeScaleArray.length > ticks) { modulo = Math.floor(adjustedMonthInTimeScaleArray.length / ticks); } var shouldNotSkipUnit = false; // there is a big change in unit i.e days to months var shouldNotPrint = false; // should skip these values switch (_this.tickInterval) { case 'half_year': modulo = 7; if (ts.unit === 'year') { shouldNotSkipUnit = true; } break; case 'months': modulo = 1; if (ts.unit === 'year') { shouldNotSkipUnit = true; } break; case 'months_fortnight': modulo = 15; if (ts.unit === 'year' || ts.unit === 'month') { shouldNotSkipUnit = true; } if (value === 30) { shouldNotPrint = true; } break; case 'months_days': modulo = 10; if (ts.unit === 'month') { shouldNotSkipUnit = true; } if (value === 30) { shouldNotPrint = true; } break; case 'week_days': modulo = 8; if (ts.unit === 'month') { shouldNotSkipUnit = true; } break; case 'days': modulo = 1; if (ts.unit === 'month') { shouldNotSkipUnit = true; } break; case 'hours': if (ts.unit === 'day') { shouldNotSkipUnit = true; } break; case 'minutes': if (value % 5 !== 0) { shouldNotPrint = true; } break; } if (_this.tickInterval === 'minutes') { if (!shouldNotPrint) { return true; } } else { if ((value % modulo === 0 || shouldNotSkipUnit) && !shouldNotPrint) { return true; } } }); return filteredTimeScale; } }, { key: 'recalcDimensionsBasedOnFormat', value: function recalcDimensionsBasedOnFormat(filteredTimeScale) { var w = this.w; var reformattedTimescaleArray = this.formatDates(filteredTimeScale); var removedOverlappingTS = this.removeOverlappingTS(reformattedTimescaleArray); w.globals.timelineLabels = removedOverlappingTS.slice(); // at this stage, we need to re-calculate coords of the grid as timeline labels may have altered the xaxis labels coords // The reason we can't do this prior to this stage is because timeline labels depends on gridWidth, and as the ticks are calculated based on available gridWidth, there can be unknown number of ticks generated for different minX and maxX // Dependency on Dimensions(), need to refactor correctly // TODO - find an alternate way to avoid calling this Heavy method twice var dimensions = new _Dimensions2.default(this.ctx); dimensions.plotCoords(); } }, { key: 'determineInterval', value: function determineInterval(daysDiff) { switch (true) { case daysDiff > 1825: // difference is more than 5 years this.tickInterval = 'years'; break; case daysDiff > 800 && daysDiff <= 1825: this.tickInterval = 'half_year'; break; case daysDiff > 180 && daysDiff <= 800: this.tickInterval = 'months'; break; case daysDiff > 90 && daysDiff <= 180: this.tickInterval = 'months_fortnight'; break; case daysDiff > 60 && daysDiff <= 90: this.tickInterval = 'months_days'; break; case daysDiff > 30 && daysDiff <= 60: this.tickInterval = 'week_days'; break; case daysDiff > 2 && daysDiff <= 30: this.tickInterval = 'days'; break; case daysDiff > 0.1 && daysDiff <= 2: // less than 2 days this.tickInterval = 'hours'; break; case daysDiff < 0.1: this.tickInterval = 'minutes'; break; default: this.tickInterval = 'days'; break; } } }, { key: 'generateYearScale', value: function generateYearScale(params) { var firstVal = params.firstVal, currentMonth = params.currentMonth, currentYear = params.currentYear, daysWidthOnXAxis = params.daysWidthOnXAxis, numberOfYears = params.numberOfYears; var firstTickValue = firstVal.minYear; var firstTickPosition = 0; var dt = new _DateTime2.default(this.ctx); var unit = 'year'; if (firstVal.minDate > 1 && firstVal.minMonth > 0) { var remainingDays = dt.determineRemainingDaysOfYear(firstVal.minYear, firstVal.minMonth, firstVal.minDate); // remainingDaysofFirstMonth is used to reacht the 2nd tick position var remainingDaysOfFirstYear = dt.determineDaysOfYear(firstVal.minYear) - remainingDays + 1; // calculate the first tick position firstTickPosition = remainingDaysOfFirstYear * daysWidthOnXAxis; firstTickValue = firstVal.minYear + 1; // push the first tick in the array this.timeScaleArray.push({ position: firstTickPosition, value: firstTickValue, unit: unit, year: firstTickValue, month: this.monthMod(currentMonth + 1) }); } else if (firstVal.minDate === 1 && firstVal.minMonth === 0) { // push the first tick in the array this.timeScaleArray.push({ position: firstTickPosition, value: firstTickValue, unit: unit, year: currentYear, month: this.monthMod(currentMonth + 1) }); } var year = firstTickValue; var pos = firstTickPosition; // keep drawing rest of the ticks for (var i = 0; i < numberOfYears; i++) { year++; pos = dt.determineDaysOfYear(year - 1) * daysWidthOnXAxis + pos; this.timeScaleArray.push({ position: pos, value: year, unit: unit, year: year, month: 1 }); } } }, { key: 'generateMonthScale', value: function generateMonthScale(params) { var firstVal = params.firstVal, currentMonthDate = params.currentMonthDate, currentMonth = params.currentMonth, currentYear = params.currentYear, daysWidthOnXAxis = params.daysWidthOnXAxis, numberOfMonths = params.numberOfMonths; var firstTickValue = currentMonth; var firstTickPosition = 0; var dt = new _DateTime2.default(this.ctx); var unit = 'month'; var yrCounter = 0; if (firstVal.minDate > 1) { // remainingDaysofFirstMonth is used to reacht the 2nd tick position var remainingDaysOfFirstMonth = dt.determineDaysOfMonths(currentMonth + 1, firstVal.minYear) - currentMonthDate + 1; // calculate the first tick position firstTickPosition = remainingDaysOfFirstMonth * daysWidthOnXAxis; firstTickValue = this.monthMod(currentMonth + 1); var year = currentYear + yrCounter; var _month = this.monthMod(firstTickValue); var value = firstTickValue; // it's Jan, so update the year if (firstTickValue === 0) { unit = 'year'; value = year; _month = 1; yrCounter += 1; year = year + yrCounter; } // push the first tick in the array this.timeScaleArray.push({ position: firstTickPosition, value: value, unit: unit, year: year, month: _month }); } else { // push the first tick in the array this.timeScaleArray.push({ position: firstTickPosition, value: firstTickValue, unit: unit, year: currentYear, month: this.monthMod(currentMonth) }); } var month = firstTickValue + 1; var pos = firstTickPosition; // keep drawing rest of the ticks for (var i = 0, j = 1; i < numberOfMonths; i++, j++) { month = this.monthMod(month); if (month === 0) { unit = 'year'; yrCounter += 1; } else { unit = 'month'; } var _year = currentYear + Math.floor(month / 12) + yrCounter; pos = dt.determineDaysOfMonths(month, _year) * daysWidthOnXAxis + pos; var monthVal = month === 0 ? _year : month; this.timeScaleArray.push({ position: pos, value: monthVal, unit: unit, year: _year, month: month === 0 ? 1 : month }); month++; } } }, { key: 'generateDayScale', value: function generateDayScale(params) { var firstVal = params.firstVal, currentMonth = params.currentMonth, currentYear = params.currentYear, hoursWidthOnXAxis = params.hoursWidthOnXAxis, numberOfDays = params.numberOfDays; var dt = new _DateTime2.default(this.ctx); var unit = 'day'; var remainingHours = 24 - firstVal.minHour; var yrCounter = 0; // calculate the first tick position var firstTickPosition = remainingHours * hoursWidthOnXAxis; var firstTickValue = firstVal.minDate + 1; var val = firstTickValue; var changeMonth = function changeMonth(dateVal, month, year) { var monthdays = dt.determineDaysOfMonths(month + 1, year); if (dateVal > monthdays) { month = month + 1; date = 1; unit = 'month'; val = month; return month; } return month; }; var date = firstTickValue; var month = changeMonth(date, currentMonth, currentYear); // push the first tick in the array this.timeScaleArray.push({ position: firstTickPosition, value: val, unit: unit, year: currentYear, month: this.monthMod(month), day: date }); var pos = firstTickPosition; // keep drawing rest of the ticks for (var i = 0; i < numberOfDays; i++) { date += 1; unit = 'day'; month = changeMonth(date, month, currentYear + Math.floor(month / 12) + yrCounter); var year = currentYear + Math.floor(month / 12) + yrCounter; pos = 24 * hoursWidthOnXAxis + pos; var _val = date === 1 ? this.monthMod(month) : date; this.timeScaleArray.push({ position: pos, value: _val, unit: unit, year: year, month: this.monthMod(month), day: _val }); } } }, { key: 'generateHourScale', value: function generateHourScale(params) { var firstVal = params.firstVal, currentDate = params.currentDate, currentMonth = params.currentMonth, currentYear = params.currentYear, minutesWidthOnXAxis = params.minutesWidthOnXAxis, numberOfHours = params.numberOfHours; var dt = new _DateTime2.default(this.ctx); var yrCounter = 0; var unit = 'hour'; var changeDate = function changeDate(dateVal, month) { var monthdays = dt.determineDaysOfMonths(month + 1, currentYear); if (dateVal > monthdays) { date = 1; month = month + 1; } return { month: month, date: date }; }; var changeMonth = function changeMonth(dateVal, month) { var monthdays = dt.determineDaysOfMonths(month + 1, currentYear); if (dateVal > monthdays) { month = month + 1; return month; } return month; }; var remainingMins = 60 - firstVal.minMinute; var firstTickPosition = remainingMins * minutesWidthOnXAxis; var firstTickValue = firstVal.minHour + 1; var hour = firstTickValue + 1; var date = currentDate; var month = changeMonth(date, currentMonth); // push the first tick in the array this.timeScaleArray.push({ position: firstTickPosition, value: firstTickValue, unit: unit, day: date, hour: hour, year: currentYear, month: this.monthMod(month) }); var pos = firstTickPosition; // keep drawing rest of the ticks for (var i = 0; i < numberOfHours; i++) { unit = 'hour'; if (hour >= 24) { hour = 0; date += 1; unit = 'day'; var checkNextMonth = changeDate(date, month); month = checkNextMonth.month; month = changeMonth(date, month); } var year = currentYear + Math.floor(month / 12) + yrCounter; pos = hour === 0 && i === 0 ? remainingMins * minutesWidthOnXAxis : 60 * minutesWidthOnXAxis + pos; var val = hour === 0 ? date : hour; this.timeScaleArray.push({ position: pos, value: val, unit: unit, hour: hour, day: date, year: year, month: this.monthMod(month) }); hour++; } } }, { key: 'generateMinuteScale', value: function generateMinuteScale(params) { var firstVal = params.firstVal, currentMinute = params.currentMinute, currentHour = params.currentHour, currentDate = params.currentDate, currentMonth = params.currentMonth, currentYear = params.currentYear, minutesWidthOnXAxis = params.minutesWidthOnXAxis, numberOfMinutes = params.numberOfMinutes; var yrCounter = 0; var unit = 'minute'; var remainingMins = currentMinute - firstVal.minMinute; var firstTickPosition = minutesWidthOnXAxis - remainingMins; var firstTickValue = firstVal.minMinute + 1; var minute = firstTickValue + 1; var date = currentDate; var month = currentMonth; var year = currentYear; var hour = currentHour; // push the first tick in the array this.timeScaleArray.push({ position: firstTickPosition, value: firstTickValue, unit: unit, day: date, hour: hour, minute: minute, year: year, month: this.monthMod(month) }); var pos = firstTickPosition; // keep drawing rest of the ticks for (var i = 0; i < numberOfMinutes; i++) { if (minute >= 60) { minute = 0; hour += 1; if (hour === 24) { hour = 0; } } var _year2 = currentYear + Math.floor(month / 12) + yrCounter; pos = minutesWidthOnXAxis + pos; var val = minute; this.timeScaleArray.push({ position: pos, value: val, unit: unit, hour: hour, minute: minute, day: date, year: _year2, month: this.monthMod(month) }); minute++; } } }, { key: 'createRawDateString', value: function createRawDateString(ts, value) { var raw = ts.year; raw += '-' + ('0' + ts.month.toString()).slice(-2); // unit is day if (ts.unit === 'day') { raw += ts.unit === 'day' ? '-' + ('0' + value).slice(-2) : '-01'; } else { raw += '-' + ('0' + (ts.day ? ts.day : '1')).slice(-2); } // unit is hour if (ts.unit === 'hour') { raw += ts.unit === 'hour' ? 'T' + ('0' + value).slice(-2) : 'T00'; } else { raw += 'T' + ('0' + (ts.hour ? ts.hour : '0')).slice(-2); } // unit is minute raw += ts.unit === 'minute' ? ':' + ('0' + value).slice(-2) + ':00.000Z' : ':00:00.000Z'; return raw; } }, { key: 'formatDates', value: function formatDates(filteredTimeScale) { var _this2 = this; var w = this.w; var reformattedTimescaleArray = filteredTimeScale.map(function (ts) { var value = ts.value.toString(); var dt = new _DateTime2.default(_this2.ctx); var raw = _this2.createRawDateString(ts, value); // parse the whole ISO datestring var dateString = new Date(Date.parse(raw)); if (w.config.xaxis.labels.format === undefined) { var customFormat = 'dd MMM'; var dtFormatter = w.config.xaxis.labels.datetimeFormatter; if (ts.unit === 'year') customFormat = dtFormatter.year; if (ts.unit === 'month') customFormat = dtFormatter.month; if (ts.unit === 'day') customFormat = dtFormatter.day; if (ts.unit === 'hour') customFormat = dtFormatter.hour; if (ts.unit === 'minute') customFormat = dtFormatter.minute; value = dt.formatDate(dateString, customFormat, true, false); } else { value = dt.formatDate(dateString, w.config.xaxis.labels.format); } return { dateString: raw, position: ts.position, value: value, unit: ts.unit, year: ts.year, month: ts.month }; }); return reformattedTimescaleArray; } }, { key: 'removeOverlappingTS', value: function removeOverlappingTS(arr) { var _this3 = this; var graphics = new _Graphics2.default(this.ctx); var lastDrawnIndex = 0; var filteredArray = arr.map(function (item, index) { if (index > 0 && _this3.w.config.xaxis.labels.hideOverlappingLabels) { var prevLabelWidth = graphics.getTextRects(arr[lastDrawnIndex].value).width; var prevPos = arr[lastDrawnIndex].position; var pos = item.position; if (pos > prevPos + prevLabelWidth + 10) { lastDrawnIndex = index; return item; } else { return null; } } else { return item; } }); filteredArray = filteredArray.filter(function (f) { return f !== null; }); return filteredArray; } // If month counter exceeds 12, it starts again from 1 }, { key: 'monthMod', value: function monthMod(month) { return month % 12; } }]); return TimeScale; }(); exports.default = TimeScale; /***/ }), /* 78 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Exports = __webpack_require__(133); var _Exports2 = _interopRequireDefault(_Exports); var _icoPanHand = __webpack_require__(162); var _icoPanHand2 = _interopRequireDefault(_icoPanHand); var _icoZoomIn = __webpack_require__(165); var _icoZoomIn2 = _interopRequireDefault(_icoZoomIn); var _icoHome = __webpack_require__(160); var _icoHome2 = _interopRequireDefault(_icoHome); var _icoPlus = __webpack_require__(163); var _icoPlus2 = _interopRequireDefault(_icoPlus); var _icoMinus = __webpack_require__(161); var _icoMinus2 = _interopRequireDefault(_icoMinus); var _icoSelect = __webpack_require__(164); var _icoSelect2 = _interopRequireDefault(_icoSelect); var _icoCamera = __webpack_require__(159); var _icoCamera2 = _interopRequireDefault(_icoCamera); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Toolbar Class for creating toolbar in axis based charts. * * @module Toolbar **/ var Toolbar = function () { function Toolbar(ctx) { _classCallCheck(this, Toolbar); this.ctx = ctx; this.w = ctx.w; this.ev = this.w.config.chart.events; this.localeValues = this.w.globals.locale.toolbar; } _createClass(Toolbar, [{ key: 'createToolbar', value: function createToolbar() { var w = this.w; var elToolbarWrap = document.createElement('div'); elToolbarWrap.setAttribute('class', 'apexcharts-toolbar'); w.globals.dom.elWrap.appendChild(elToolbarWrap); this.elZoom = document.createElement('div'); this.elZoomIn = document.createElement('div'); this.elZoomOut = document.createElement('div'); this.elPan = document.createElement('div'); this.elSelection = document.createElement('div'); this.elZoomReset = document.createElement('div'); this.elCamera = document.createElement('div'); var toolbarControls = []; if (w.config.chart.toolbar.tools.download) { toolbarControls.push({ el: this.elCamera, icon: _icoCamera2.default, title: this.localeValues.download, class: 'apexcharts-download-icon' }); } if (w.config.chart.toolbar.tools.selection) { toolbarControls.push({ el: this.elSelection, icon: _icoSelect2.default, title: this.localeValues.selection, class: 'apexcharts-selection-icon' }); } if (w.config.chart.toolbar.tools.zoomin && w.config.chart.zoom.enabled) { toolbarControls.push({ el: this.elZoomIn, icon: _icoPlus2.default, title: this.localeValues.zoomIn, class: 'apexcharts-zoom-in-icon' }); } if (w.config.chart.toolbar.tools.zoomout && w.config.chart.zoom.enabled) { toolbarControls.push({ el: this.elZoomOut, icon: _icoMinus2.default, title: this.localeValues.zoomOut, class: 'apexcharts-zoom-out-icon' }); } if (w.config.chart.toolbar.tools.zoom && w.config.chart.zoom.enabled) { toolbarControls.push({ el: this.elZoom, icon: _icoZoomIn2.default, title: this.localeValues.selectionZoom, class: 'apexcharts-zoom-icon' }); } if (w.config.chart.toolbar.tools.pan && w.config.chart.zoom.enabled) { toolbarControls.push({ el: this.elPan, icon: _icoPanHand2.default, title: this.localeValues.pan, class: 'apexcharts-pan-icon' }); } if (w.config.chart.toolbar.tools.reset) { toolbarControls.push({ el: this.elZoomReset, icon: _icoHome2.default, title: this.localeValues.reset, class: 'apexcharts-reset-zoom-icon' }); } for (var i = 0; i < toolbarControls.length; i++) { _Graphics2.default.setAttrs(toolbarControls[i].el, { class: toolbarControls[i].class, title: toolbarControls[i].title }); toolbarControls[i].el.innerHTML = toolbarControls[i].icon; elToolbarWrap.appendChild(toolbarControls[i].el); } if (w.globals.zoomEnabled) { this.elZoom.classList.add('selected'); } else if (w.globals.panEnabled) { this.elPan.classList.add('selected'); } else if (w.globals.selectionEnabled) { this.elSelection.classList.add('selected'); } this.addToolbarEventListeners(); } }, { key: 'addToolbarEventListeners', value: function addToolbarEventListeners() { this.elZoomReset.addEventListener('click', this.handleZoomReset.bind(this)); this.elSelection.addEventListener('click', this.toggleSelection.bind(this)); this.elZoom.addEventListener('click', this.toggleZooming.bind(this)); this.elZoomIn.addEventListener('click', this.handleZoomIn.bind(this)); this.elZoomOut.addEventListener('click', this.handleZoomOut.bind(this)); this.elPan.addEventListener('click', this.togglePanning.bind(this)); this.elCamera.addEventListener('click', this.downloadSVG.bind(this)); } }, { key: 'toggleSelection', value: function toggleSelection() { this.toggleOtherControls(); this.w.globals.selectionEnabled = !this.w.globals.selectionEnabled; if (!this.elSelection.classList.contains('selected')) { this.elSelection.classList.add('selected'); } else { this.elSelection.classList.remove('selected'); } } }, { key: 'toggleZooming', value: function toggleZooming() { this.toggleOtherControls(); this.w.globals.zoomEnabled = !this.w.globals.zoomEnabled; if (!this.elZoom.classList.contains('selected')) { this.elZoom.classList.add('selected'); } else { this.elZoom.classList.remove('selected'); } } }, { key: 'getToolbarIconsReference', value: function getToolbarIconsReference() { var w = this.w; if (!this.elZoom) { this.elZoom = w.globals.dom.baseEl.querySelector('.apexcharts-zoom-icon'); } if (!this.elPan) { this.elPan = w.globals.dom.baseEl.querySelector('.apexcharts-pan-icon'); } if (!this.elSelection) { this.elSelection = w.globals.dom.baseEl.querySelector('.apexcharts-selection-icon'); } } }, { key: 'enableZooming', value: function enableZooming() { this.toggleOtherControls(); this.w.globals.zoomEnabled = true; if (this.elZoom) { this.elZoom.classList.add('selected'); } if (this.elPan) { this.elPan.classList.remove('selected'); } } }, { key: 'enablePanning', value: function enablePanning() { this.toggleOtherControls(); this.w.globals.panEnabled = true; if (this.elPan) { this.elPan.classList.add('selected'); } if (this.elZoom) { this.elZoom.classList.remove('selected'); } } }, { key: 'togglePanning', value: function togglePanning() { this.toggleOtherControls(); this.w.globals.panEnabled = !this.w.globals.panEnabled; if (!this.elPan.classList.contains('selected')) { this.elPan.classList.add('selected'); } else { this.elPan.classList.remove('selected'); } } }, { key: 'toggleOtherControls', value: function toggleOtherControls() { var w = this.w; w.globals.panEnabled = false; w.globals.zoomEnabled = false; w.globals.selectionEnabled = false; this.getToolbarIconsReference(); if (this.elPan) { this.elPan.classList.remove('selected'); } if (this.elSelection) { this.elSelection.classList.remove('selected'); } if (this.elZoom) { this.elZoom.classList.remove('selected'); } } }, { key: 'handleZoomIn', value: function handleZoomIn() { var w = this.w; var centerX = (w.globals.minX + w.globals.maxX) / 2; var newMinX = (w.globals.minX + centerX) / 2; var newMaxX = (w.globals.maxX + centerX) / 2; if (!w.globals.disableZoomIn) { this.zoomUpdateOptions(newMinX, newMaxX); } } }, { key: 'handleZoomOut', value: function handleZoomOut() { var w = this.w; // avoid zooming out beyond 1000 which may result in NaN values being printed on x-axis if (w.config.xaxis.type === 'datetime' && new Date(w.globals.minX).getUTCFullYear() < 1000) { return; } var centerX = (w.globals.minX + w.globals.maxX) / 2; var newMinX = w.globals.minX - (centerX - w.globals.minX); var newMaxX = w.globals.maxX - (centerX - w.globals.maxX); if (!w.globals.disableZoomOut) { this.zoomUpdateOptions(newMinX, newMaxX); } } }, { key: 'zoomUpdateOptions', value: function zoomUpdateOptions(newMinX, newMaxX) { var xaxis = { min: newMinX, max: newMaxX }; var beforeZoomRange = this.getBeforeZoomRange(xaxis); if (beforeZoomRange) { xaxis = beforeZoomRange.xaxis; } this.w.globals.zoomed = true; this.ctx.updateOptionsInternal({ xaxis: xaxis }, false, this.w.config.chart.animations.dynamicAnimation.enabled); this.zoomCallback({ min: newMinX, max: newMaxX }); } }, { key: 'zoomCallback', value: function zoomCallback(xaxis, yaxis) { if (typeof this.ev.zoomed === 'function') { this.ev.zoomed(this.ctx, { xaxis: xaxis, yaxis: yaxis }); } } }, { key: 'getBeforeZoomRange', value: function getBeforeZoomRange(xaxis, yaxis) { var newRange = null; if (typeof this.ev.beforeZoom === 'function') { newRange = this.ev.beforeZoom(this, { xaxis: xaxis, yaxis: yaxis }); } return newRange; } }, { key: 'downloadSVG', value: function downloadSVG() { var downloadSVG = new _Exports2.default(this.ctx); downloadSVG.exportToSVG(); } }, { key: 'handleZoomReset', value: function handleZoomReset(e) { var charts = this.ctx.getSyncedCharts(); charts.forEach(function (ch) { var w = ch.w; if (w.globals.minX !== w.globals.initialminX && w.globals.maxX !== w.globals.initialmaxX) { ch.revertDefaultAxisMinMax(); w.globals.zoomed = false; ch.updateSeriesInternal(w.globals.initialSeries, w.config.chart.animations.dynamicAnimation.enabled); } }); } }, { key: 'destroy', value: function destroy() { if (this.elZoomReset) { this.elZoomReset.removeEventListener('click', this.handleZoomReset.bind(this)); this.elSelection.removeEventListener('click', this.toggleSelection.bind(this)); this.elZoom.removeEventListener('click', this.toggleZooming.bind(this)); this.elZoomIn.removeEventListener('click', this.handleZoomIn.bind(this)); this.elZoomOut.removeEventListener('click', this.handleZoomOut.bind(this)); this.elPan.removeEventListener('click', this.togglePanning.bind(this)); this.elCamera.removeEventListener('click', this.downloadSVG.bind(this)); } this.elZoom = null; this.elZoomIn = null; this.elZoomOut = null; this.elPan = null; this.elSelection = null; this.elZoomReset = null; this.elCamera = null; } }]); return Toolbar; }(); module.exports = Toolbar; /***/ }), /* 79 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Series = __webpack_require__(26); var _Series2 = _interopRequireDefault(_Series); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Tooltip.Position Class to move the tooltip based on x and y position. * * @module Tooltip.Position **/ var Position = function () { function Position(tooltipContext) { _classCallCheck(this, Position); this.ttCtx = tooltipContext; this.ctx = tooltipContext.ctx; this.w = tooltipContext.w; } /** * This will move the crosshair (the vertical/horz line that moves along with mouse) * Along with this, this function also calls the xaxisMove function * @memberof Position * @param {int} - cx = point's x position, wherever point's x is, you need to move crosshair */ _createClass(Position, [{ key: 'moveXCrosshairs', value: function moveXCrosshairs(cx) { var j = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var ttCtx = this.ttCtx; var w = this.w; var xcrosshairs = ttCtx.getElXCrosshairs(); var x = cx - ttCtx.xcrosshairsWidth / 2; var tickAmount = w.globals.labels.slice().length; if (j !== null) { x = w.globals.gridWidth / tickAmount * j; } if (w.config.xaxis.crosshairs.width === 'tickWidth' || w.config.xaxis.crosshairs.width === 'barWidth') { if (x + ttCtx.xcrosshairsWidth > w.globals.gridWidth) { x = w.globals.gridWidth - ttCtx.xcrosshairsWidth; } } else { if (j !== null) { x = x + w.globals.gridWidth / tickAmount / 2; } } if (x < 0) { x = 0; } if (x > w.globals.gridWidth) { x = w.globals.gridWidth; } if (xcrosshairs !== null) { xcrosshairs.setAttribute('x', x); xcrosshairs.classList.add('active'); } if (ttCtx.blxaxisTooltip) { var tx = x; if (w.config.xaxis.crosshairs.width === 'tickWidth' || w.config.xaxis.crosshairs.width === 'barWidth') { tx = x + ttCtx.xcrosshairsWidth / 2; } this.moveXAxisTooltip(tx); } } /** * This will move the crosshair (the vertical/horz line that moves along with mouse) * Along with this, this function also calls the xaxisMove function * @memberof Position * @param {int} - cx = point's x position, wherever point's x is, you need to move crosshair */ }, { key: 'moveYCrosshairs', value: function moveYCrosshairs(cy) { var ttCtx = this.ttCtx; if (ttCtx.ycrosshairs !== null) { _Graphics2.default.setAttrs(ttCtx.ycrosshairs, { y1: cy, y2: cy }); _Graphics2.default.setAttrs(ttCtx.ycrosshairsHidden, { y1: cy, y2: cy }); } } /** ** AxisTooltip is the small rectangle which appears on x axis with x value, when user moves * @memberof Position * @param {int} - cx = point's x position, wherever point's x is, you need to move */ }, { key: 'moveXAxisTooltip', value: function moveXAxisTooltip(cx) { var w = this.w; var ttCtx = this.ttCtx; if (ttCtx.xaxisTooltip !== null) { ttCtx.xaxisTooltip.classList.add('active'); var cy = ttCtx.xaxisOffY + w.config.xaxis.tooltip.offsetY + w.globals.translateY + 1; var xaxisTTText = ttCtx.xaxisTooltip.getBoundingClientRect(); var xaxisTTTextWidth = xaxisTTText.width; cx = cx - xaxisTTTextWidth / 2; if (!isNaN(cx)) { cx = cx + w.globals.translateX; var textRect = 0; var graphics = new _Graphics2.default(this.ctx); textRect = graphics.getTextRects(ttCtx.xaxisTooltipText.innerHTML); ttCtx.xaxisTooltipText.style.minWidth = textRect.width + 'px'; ttCtx.xaxisTooltip.style.left = cx + 'px'; ttCtx.xaxisTooltip.style.top = cy + 'px'; } } } }, { key: 'moveYAxisTooltip', value: function moveYAxisTooltip(index) { var w = this.w; var ttCtx = this.ttCtx; if (ttCtx.yaxisTTEls === null) { ttCtx.yaxisTTEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxistooltip'); } var ycrosshairsHiddenRectY1 = parseInt(ttCtx.ycrosshairsHidden.getAttribute('y1')); var cy = w.globals.translateY + ycrosshairsHiddenRectY1; var yAxisTTRect = ttCtx.yaxisTTEls[index].getBoundingClientRect(); var yAxisTTHeight = yAxisTTRect.height; var cx = w.globals.translateYAxisX[index] - 2; if (w.config.yaxis[index].opposite) { cx = cx - 26; } cy = cy - yAxisTTHeight / 2; if (!w.globals.ignoreYAxisIndexes.indexOf(index) > -1) { ttCtx.yaxisTTEls[index].classList.add('active'); ttCtx.yaxisTTEls[index].style.top = cy + 'px'; ttCtx.yaxisTTEls[index].style.left = cx + w.config.yaxis[index].tooltip.offsetX + 'px'; } else { ttCtx.yaxisTTEls[index].classList.remove('active'); } } /** ** moves the whole tooltip by changing x, y attrs * @memberof Position * @param {int} - cx = point's x position, wherever point's x is, you need to move tooltip * @param {int} - cy = point's y position, wherever point's y is, you need to move tooltip * @param {int} - r = point's radius */ }, { key: 'moveTooltip', value: function moveTooltip(cx, cy) { var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; var w = this.w; var ttCtx = this.ttCtx; var tooltipEl = ttCtx.getElTooltip(); var tooltipRect = ttCtx.tooltipRect; var pointR = r !== null ? parseInt(r) : 1; var x = parseInt(cx) + pointR + 5; var y = parseInt(cy) + pointR / 2; // - tooltipRect.ttHeight / 2 if (x > w.globals.gridWidth / 2) { x = x - tooltipRect.ttWidth - pointR - 15; } if (x > w.globals.gridWidth - tooltipRect.ttWidth - 10) { x = w.globals.gridWidth - tooltipRect.ttWidth; } if (x < -20) { x = -20; } if (w.config.tooltip.followCursor) { var elGrid = ttCtx.getElGrid(); var seriesBound = elGrid.getBoundingClientRect(); y = ttCtx.e.clientY - seriesBound.top - tooltipRect.ttHeight / 2; } var newPositions = this.positionChecks(tooltipRect, x, y); x = newPositions.x; y = newPositions.y; if (!isNaN(x)) { x = x + w.globals.translateX; tooltipEl.style.left = x + 'px'; tooltipEl.style.top = y + 'px'; } } }, { key: 'positionChecks', value: function positionChecks(tooltipRect, x, y) { var w = this.w; if (tooltipRect.ttHeight + y > w.globals.gridHeight) { y = w.globals.gridHeight - tooltipRect.ttHeight + w.globals.translateY; } if (y < 0) { y = 0; } return { x: x, y: y }; } }, { key: 'moveMarkers', value: function moveMarkers(i, j) { var w = this.w; var ttCtx = this.ttCtx; if (w.config.markers.size > 0) { var allPoints = w.globals.dom.baseEl.querySelectorAll(' .apexcharts-series[data\\:realIndex=\'' + i + '\'] .apexcharts-marker'); for (var p = 0; p < allPoints.length; p++) { if (parseInt(allPoints[p].getAttribute('rel')) === j) { ttCtx.marker.resetPointsSize(); ttCtx.marker.enlargeCurrentPoint(j, allPoints[p]); } } } else { ttCtx.marker.resetPointsSize(); this.moveDynamicPointOnHover(j, i); } } // This function is used when you need to show markers/points only on hover - // DIFFERENT X VALUES in multiple series }, { key: 'moveDynamicPointOnHover', value: function moveDynamicPointOnHover(j, capturedSeries) { var w = this.w; var ttCtx = this.ttCtx; var cx = 0; var cy = 0; var pointsArr = w.globals.pointsArray; var hoverSize = w.config.markers.hover.size; cx = pointsArr[capturedSeries][j][0]; cy = pointsArr[capturedSeries][j][1] ? pointsArr[capturedSeries][j][1] : 0; var point = w.globals.dom.baseEl.querySelector('.apexcharts-series[data\\:realIndex=\'' + capturedSeries + '\'] .apexcharts-series-markers circle'); point.setAttribute('r', hoverSize); point.setAttribute('cx', cx); point.setAttribute('cy', cy); // point.style.opacity = w.config.markers.hover.opacity this.moveXCrosshairs(cx); if (!ttCtx.fixedTooltip) { this.moveTooltip(cx, cy, hoverSize); } } // This function is used when you need to show markers/points only on hover - // SAME X VALUES in multiple series }, { key: 'moveDynamicPointsOnHover', value: function moveDynamicPointsOnHover(j) { var ttCtx = this.ttCtx; var w = ttCtx.w; var cx = 0; var cy = 0; var activeSeries = 0; var pointsArr = w.globals.pointsArray; var series = new _Series2.default(this.ctx); activeSeries = series.getActiveSeriesIndex(); var hoverSize = w.config.markers.hover.size; if (pointsArr[activeSeries]) { cx = pointsArr[activeSeries][j][0]; cy = pointsArr[activeSeries][j][1]; } var points = null; var allPoints = ttCtx.getAllMarkers(); if (allPoints !== null) { points = allPoints; } else { points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers circle'); } if (points !== null) { for (var p = 0; p < points.length; p++) { var pointArr = pointsArr[p]; if (pointArr && pointArr.length) { var pcy = pointsArr[p][j][1]; points[p].setAttribute('cx', cx); var realIndex = parseInt(points[p].parentNode.parentNode.parentNode.getAttribute('data:realIndex')); if (pcy !== null) { points[realIndex] && points[realIndex].setAttribute('r', hoverSize); points[realIndex] && points[realIndex].setAttribute('cy', pcy); } else { points[realIndex] && points[realIndex].setAttribute('r', 0); } } } } this.moveXCrosshairs(cx); if (!ttCtx.fixedTooltip) { var tcy = cy || w.globals.gridHeight; this.moveTooltip(cx, tcy, hoverSize); } } }, { key: 'moveStickyTooltipOverBars', value: function moveStickyTooltipOverBars(j) { var w = this.w; var ttCtx = this.ttCtx; var jBar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-series .apexcharts-series[rel=\'1\'] path[j=\'' + j + '\'], .apexcharts-candlestick-series .apexcharts-series[rel=\'1\'] path[j=\'' + j + '\']'); var bcx = jBar ? parseFloat(jBar.getAttribute('cx')) : 0; var bcy = 0; var bw = jBar ? parseFloat(jBar.getAttribute('barWidth')) : 0; if (w.globals.isXNumeric) { bcx = bcx - bw / 2; } else { bcx = ttCtx.xAxisTicksPositions[j - 1] + ttCtx.dataPointsDividedWidth / 2; if (isNaN(bcx)) { bcx = ttCtx.xAxisTicksPositions[j] - ttCtx.dataPointsDividedWidth / 2; } } // tooltip will move vertically along with mouse as it is a shared tooltip var elGrid = ttCtx.getElGrid(); var seriesBound = elGrid.getBoundingClientRect(); bcy = ttCtx.e.clientY - seriesBound.top - ttCtx.tooltipRect.ttHeight / 2; this.moveXCrosshairs(bcx); if (!ttCtx.fixedTooltip) { var tcy = bcy || w.globals.gridHeight; this.moveTooltip(bcx, tcy); } } }]); return Position; }(); module.exports = Position; /***/ }), /* 80 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Tooltip.Utils Class to support Tooltip functionality. * * @module Tooltip.Utils **/ var Utils = function () { function Utils(tooltipContext) { _classCallCheck(this, Utils); this.w = tooltipContext.w; this.ttCtx = tooltipContext; this.ctx = tooltipContext.ctx; } /** ** When hovering over series, you need to capture which series is being hovered on. ** This function will return both capturedseries index as well as inner index of that series * @memberof Utils * @param {object} * - context = chart's context * - hoverArea = the rect on which user hovers * - elGrid = dimensions of the hover rect (it can be different than hoverarea) * - lineSeriesWidth = Whatever series the user hovered on, get the width of it * @return {object} * - capturedSeries = i * - j is the inner index of the capturedSeries */ _createClass(Utils, [{ key: 'getNearestValues', value: function getNearestValues(_ref) { var hoverArea = _ref.hoverArea, elGrid = _ref.elGrid, clientX = _ref.clientX, clientY = _ref.clientY, hasBars = _ref.hasBars; var w = this.w; var hoverWidth = w.globals.gridWidth; var xDivisor = hoverWidth / (w.globals.dataPoints - 1); var seriesBound = elGrid.getBoundingClientRect(); if (hasBars && w.globals.comboCharts || hasBars) { xDivisor = hoverWidth / w.globals.dataPoints; } var hoverX = clientX - seriesBound.left; var hoverY = clientY - seriesBound.top; var inRect = hoverX < 0 || hoverY < 0 || hoverX > w.globals.gridWidth || hoverY > w.globals.gridHeight; if (inRect) { hoverArea.classList.remove('hovering-zoom'); hoverArea.classList.remove('hovering-pan'); } else { if (w.globals.zoomEnabled) { hoverArea.classList.remove('hovering-pan'); hoverArea.classList.add('hovering-zoom'); } else if (w.globals.panEnabled) { hoverArea.classList.remove('hovering-zoom'); hoverArea.classList.add('hovering-pan'); } } var j = Math.round(hoverX / xDivisor); if (hasBars) { j = Math.ceil(hoverX / xDivisor); j = j - 1; } var capturedSeries = null; var closest = null; var seriesXValArr = []; var seriesYValArr = []; for (var s = 0; s < w.globals.seriesXvalues.length; s++) { seriesXValArr.push([w.globals.seriesXvalues[s][0] - 0.000001].concat(w.globals.seriesXvalues[s])); } seriesXValArr = seriesXValArr.map(function (seriesXVal) { return seriesXVal.filter(function (s) { return s; }); }); seriesYValArr = w.globals.seriesYvalues.map(function (seriesYVal) { return seriesYVal.filter(function (s) { return s; }); }); // if X axis type is not category and tooltip is not shared, then we need to find the cursor position and get the nearest value if (w.globals.isXNumeric) { closest = this.closestInMultiArray(hoverX, hoverY, seriesXValArr, seriesYValArr); capturedSeries = closest.index; j = closest.j; if (capturedSeries !== null) { // initial push, it should be a little smaller than the 1st val seriesXValArr = w.globals.seriesXvalues[capturedSeries]; closest = this.closestInArray(hoverX, seriesXValArr); j = closest.index; } } if (!j || j < 1) j = 0; return { capturedSeries: capturedSeries, j: j, hoverX: hoverX, hoverY: hoverY }; } }, { key: 'closestInMultiArray', value: function closestInMultiArray(hoverX, hoverY, Xarrays, Yarrays) { var w = this.w; var activeIndex = 0; var currIndex = null; var j = -1; if (w.globals.series.length > 1) { activeIndex = this.getFirstActiveXArray(Xarrays); } else { currIndex = 0; } var currY = Yarrays[activeIndex][0]; var currX = Xarrays[activeIndex][0]; var diffX = Math.abs(hoverX - currX); var diffY = Math.abs(hoverY - currY); var diff = diffY + diffX; Yarrays.map(function (arrY, arrIndex) { arrY.map(function (y, innerKey) { var newdiffY = Math.abs(hoverY - Yarrays[arrIndex][innerKey]); var newdiffX = Math.abs(hoverX - Xarrays[arrIndex][innerKey]); var newdiff = newdiffX + newdiffY; if (newdiff < diff) { diff = newdiff; diffX = newdiffX; diffY = newdiffY; currIndex = arrIndex; j = innerKey; } }); }); return { index: currIndex, j: j }; } }, { key: 'getFirstActiveXArray', value: function getFirstActiveXArray(Xarrays) { var activeIndex = 0; var firstActiveSeriesIndex = Xarrays.map(function (xarr, index) { if (xarr.length > 0) { return index; } else { return -1; } }); for (var a = 0; a < firstActiveSeriesIndex.length; a++) { if (firstActiveSeriesIndex[a] !== -1) { activeIndex = firstActiveSeriesIndex[a]; break; } } return activeIndex; } }, { key: 'closestInArray', value: function closestInArray(val, arr) { var curr = arr[0]; var currIndex = null; var diff = Math.abs(val - curr); for (var i = 0; i < arr.length; i++) { var newdiff = Math.abs(val - arr[i]); if (newdiff < diff) { diff = newdiff; curr = arr[i]; currIndex = i; } } return { index: currIndex }; } /** * When there are multiple series, it is possible to have different x values for each series. * But it may be possible in those multiple series, that there is same x value for 2 or more * series. * @memberof Utils * @param {int} * - j = is the inner index of series -> (series[i][j]) * @return {bool} */ }, { key: 'isXoverlap', value: function isXoverlap(j) { var w = this.w; var xSameForAllSeriesJArr = []; var seriesX = w.globals.seriesX.filter(function (s) { return typeof s[0] !== 'undefined'; }); if (seriesX.length > 0) { for (var i = 0; i < seriesX.length - 1; i++) { if (typeof seriesX[i][j] !== 'undefined' && typeof seriesX[i + 1][j] !== 'undefined') { if (seriesX[i][j] !== seriesX[i + 1][j]) { xSameForAllSeriesJArr.push('unEqual'); } } } } if (xSameForAllSeriesJArr.length === 0) { return true; } return false; } }, { key: 'isinitialSeriesSameLen', value: function isinitialSeriesSameLen() { var sameLen = true; var initialSeries = this.w.globals.initialSeries; for (var i = 0; i < initialSeries.length - 1; i++) { if (initialSeries[i].data.length !== initialSeries[i + 1].data.length) { sameLen = false; break; } } return sameLen; } }, { key: 'isSeriesSameLen', value: function isSeriesSameLen() { var sameLen = true; var filteredSerX = this.filteredSeriesX(); for (var i = 0; i < filteredSerX.length - 1; i++) { if (filteredSerX[i][0] !== filteredSerX[i + 1][0]) { sameLen = false; break; } } return sameLen; } }, { key: 'filteredSeriesX', value: function filteredSeriesX() { var w = this.w; var filteredSeriesX = w.globals.seriesX.map(function (ser, index) { if (ser.length > 0) { return ser; } else { return []; } }); return filteredSeriesX; } }, { key: 'getBarsHeight', value: function getBarsHeight(allbars) { var bars = [].concat(_toConsumableArray(allbars)); var totalHeight = bars.reduce(function (acc, bar) { return acc + bar.getBBox().height; }, 0); return totalHeight; } }, { key: 'toggleAllTooltipSeriesGroups', value: function toggleAllTooltipSeriesGroups(state) { var w = this.w; var ttCtx = this.ttCtx; if (ttCtx.allTooltipSeriesGroups.length === 0) { ttCtx.allTooltipSeriesGroups = w.globals.dom.baseEl.querySelectorAll('.apexcharts-tooltip-series-group'); } var allTooltipSeriesGroups = ttCtx.allTooltipSeriesGroups; for (var i = 0; i < allTooltipSeriesGroups.length; i++) { if (state === 'enable') { allTooltipSeriesGroups[i].classList.add('active'); allTooltipSeriesGroups[i].style.display = w.config.tooltip.items.display; } else { allTooltipSeriesGroups[i].classList.remove('active'); allTooltipSeriesGroups[i].style.display = 'none'; } } } }]); return Utils; }(); module.exports = Utils; /***/ }), /* 81 */ /***/ (function(module, exports) { module.exports = {"name":"en","options":{"months":["January","February","March","April","May","June","July","August","September","October","November","December"],"shortMonths":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"days":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"shortDays":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"toolbar":{"download":"Download SVG","selection":"Selection","selectionZoom":"Selection Zoom","zoomIn":"Zoom In","zoomOut":"Zoom Out","pan":"Panning","reset":"Reset Zoom"}}} /***/ }), /* 82 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; __webpack_require__(112); module.exports = __webpack_require__(4).Array.find; /***/ }), /* 83 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; __webpack_require__(72); __webpack_require__(113); module.exports = __webpack_require__(4).Array.from; /***/ }), /* 84 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; __webpack_require__(118); module.exports = __webpack_require__(4).Array.includes; /***/ }), /* 85 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; __webpack_require__(115); module.exports = __webpack_require__(4).Array.reduce; /***/ }), /* 86 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; __webpack_require__(71); __webpack_require__(72); __webpack_require__(123); __webpack_require__(116); __webpack_require__(119); __webpack_require__(120); module.exports = __webpack_require__(4).Promise; /***/ }), /* 87 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; __webpack_require__(117); __webpack_require__(71); __webpack_require__(121); __webpack_require__(122); module.exports = __webpack_require__(4).Symbol; /***/ }), /* 88 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Annotations = __webpack_require__(130); var _Annotations2 = _interopRequireDefault(_Annotations); var _Animations = __webpack_require__(25); var _Animations2 = _interopRequireDefault(_Animations); var _Base = __webpack_require__(131); var _Base2 = _interopRequireDefault(_Base); var _Config = __webpack_require__(50); var _Config2 = _interopRequireDefault(_Config); var _Core = __webpack_require__(132); var _Core2 = _interopRequireDefault(_Core); var _CoreUtils = __webpack_require__(75); var _CoreUtils2 = _interopRequireDefault(_CoreUtils); var _Crosshairs = __webpack_require__(76); var _Crosshairs2 = _interopRequireDefault(_Crosshairs); var _Dimensions = __webpack_require__(46); var _Dimensions2 = _interopRequireDefault(_Dimensions); var _Formatters = __webpack_require__(30); var _Formatters2 = _interopRequireDefault(_Formatters); var _Legend = __webpack_require__(134); var _Legend2 = _interopRequireDefault(_Legend); var _Responsive = __webpack_require__(136); var _Responsive2 = _interopRequireDefault(_Responsive); var _Series = __webpack_require__(26); var _Series2 = _interopRequireDefault(_Series); var _Theme = __webpack_require__(137); var _Theme2 = _interopRequireDefault(_Theme); var _Tooltip = __webpack_require__(147); var _Tooltip2 = _interopRequireDefault(_Tooltip); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); var _ZoomPanSelection = __webpack_require__(139); var _ZoomPanSelection2 = _interopRequireDefault(_ZoomPanSelection); var _TitleSubtitle = __webpack_require__(138); var _TitleSubtitle2 = _interopRequireDefault(_TitleSubtitle); var _Toolbar = __webpack_require__(78); var _Toolbar2 = _interopRequireDefault(_Toolbar); var _Options = __webpack_require__(51); var _Options2 = _interopRequireDefault(_Options); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } __webpack_require__(154); __webpack_require__(150); __webpack_require__(151); __webpack_require__(149); __webpack_require__(153); __webpack_require__(152); __webpack_require__(157); __webpack_require__(155); var en = __webpack_require__(81); // global Apex object which user can use to override chart's defaults globally window.Apex = {}; /** * * @module ApexCharts **/ var ApexCharts = function () { function ApexCharts(el, opts) { _classCallCheck(this, ApexCharts); this.opts = opts; this.ctx = this; // Pass the user supplied options to the Base Class where these options will be extended with defaults. The returned object from Base Class will become the config object in the entire codebase. this.w = new _Base2.default(opts).init(); this.el = el; this.w.globals.cuid = (Math.random() + 1).toString(36).substring(4); this.w.globals.chartID = this.w.config.chart.id ? this.w.config.chart.id : this.w.globals.cuid; this.initModules(); this.create = _Utils2.default.bind(this.create, this); this.windowResizeHandler = this.windowResize.bind(this); } /** * The primary method user will call to render the chart. */ _createClass(ApexCharts, [{ key: 'render', value: function render() { var _this = this; // main method return new Promise(function (resolve, reject) { // only draw chart, if element found if (_this.el !== null) { if (typeof Apex._chartInstances === 'undefined') { Apex._chartInstances = []; } if (_this.w.config.chart.id) { Apex._chartInstances.push({ id: _this.w.globals.chartID, group: _this.w.config.chart.group, chart: _this }); } // set the locale here _this.setLocale(_this.w.config.chart.defaultLocale); var beforeMount = _this.w.config.chart.events.beforeMount; if (typeof beforeMount === 'function') { beforeMount(_this, _this.w); } _this.fireEvent('beforeMount', [_this, _this.w]); window.addEventListener('resize', _this.windowResizeHandler); var graphData = _this.create(_this.w.config.series); if (!graphData) return resolve(_this); _this.mount(graphData).then(function () { resolve(graphData); if (typeof _this.w.config.chart.events.mounted === 'function') { _this.w.config.chart.events.mounted(_this, _this.w); } _this.fireEvent('mounted', [_this, _this.w]); }).catch(function (e) { reject(e); // handle error in case no data or element not found }); } else { reject(new Error('Element not found')); } }); } }, { key: 'initModules', value: function initModules() { this.animations = new _Animations2.default(this.ctx); this.annotations = new _Annotations2.default(this.ctx); this.core = new _Core2.default(this.el, this); this.coreUtils = new _CoreUtils2.default(this); this.config = new _Config2.default({}); this.crosshairs = new _Crosshairs2.default(this.ctx); this.options = new _Options2.default(); this.responsive = new _Responsive2.default(this.ctx); this.series = new _Series2.default(this.ctx); this.theme = new _Theme2.default(this.ctx); this.formatters = new _Formatters2.default(this.ctx); this.titleSubtitle = new _TitleSubtitle2.default(this.ctx); this.legend = new _Legend2.default(this.ctx); this.toolbar = new _Toolbar2.default(this.ctx); this.dimensions = new _Dimensions2.default(this.ctx); this.zoomPanSelection = new _ZoomPanSelection2.default(this.ctx); this.w.globals.tooltip = new _Tooltip2.default(this.ctx); } }, { key: 'addEventListener', value: function addEventListener(name, handler) { var w = this.w; if (w.globals.events.hasOwnProperty(name)) { w.globals.events[name].push(handler); } else { w.globals.events[name] = [handler]; } } }, { key: 'removeEventListener', value: function removeEventListener(name, handler) { var w = this.w; if (!w.globals.events.hasOwnProperty(name)) { return; } var index = w.globals.events[name].indexOf(handler); if (index !== -1) { w.globals.events[name].splice(index, 1); } } }, { key: 'fireEvent', value: function fireEvent(name, args) { var w = this.w; if (!w.globals.events.hasOwnProperty(name)) { return; } if (!args || !args.length) { args = []; } var evs = w.globals.events[name]; var l = evs.length; for (var i = 0; i < l; i++) { evs[i].apply(null, args); } } }, { key: 'create', value: function create(ser) { var w = this.w; this.initModules(); var gl = this.w.globals; gl.noData = false; this.responsive.checkResponsiveConfig(); if (this.el === null) { return null; } this.core.setupElements(); if (ser.length === 0 || ser.length === 1 && ser[0].data && ser[0].data.length === 0) { this.series.handleNoData(); } this.setupEventHandlers(); this.core.parseData(ser); // this is a good time to set theme colors first this.theme.init(); // labelFormatters should be called before dimensions as in dimensions we need text labels width this.formatters.setLabelFormatters(); this.titleSubtitle.draw(); // legend is calculated here before coreCalculations because it affects the plottable area this.legend.init(); // coreCalculations will give the min/max range and yaxis/axis values. It should be called here to set series variable from config to globals if (gl.axisCharts) { this.core.coreCalculations(); // as we have minX and maxX values, determine the default DateTimeFormat for time series this.formatters.setLabelFormatters(); } // we need to generate yaxis for heatmap separately as we are not showing numerics there, but seriesNames. There are some tweaks which are required for heatmap to align labels correctly which are done in below function // Also we need to do this before calcuting Dimentions plotCoords() method of Dimensions this.formatters.heatmapLabelFormatters(); // We got plottable area here, next task would be to calculate axis areas this.dimensions.plotCoords(); var xyRatios = this.core.xySettings(); this.core.createGridMask(); var elGraph = this.core.plotChartType(ser, xyRatios); // after all the drawing calculations, shift the graphical area (actual charts/bars) excluding legends this.core.shiftGraphPosition(); var dim = { plot: { left: w.globals.translateX, top: w.globals.translateY, width: w.globals.gridWidth, height: w.globals.gridHeight } }; return { elGraph: elGraph, xyRatios: xyRatios, elInner: w.globals.dom.elGraphical, dimensions: dim }; } }, { key: 'mount', value: function mount() { var graphData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var me = this; var w = me.w; return new Promise(function (resolve, reject) { // no data to display if (me.el === null) { return reject(new Error('Not enough data to display or target element not found')); } else if (graphData === null || w.globals.allSeriesCollapsed) { me.series.handleNoData(); } me.core.drawAxis(w.config.chart.type, graphData.xyRatios); if (w.config.grid.position === 'back') { me.core.drawGrid(); } if (w.config.annotations.position === 'back') { me.annotations.drawAnnotations(); } if (graphData.elGraph instanceof Array) { for (var g = 0; g < graphData.elGraph.length; g++) { w.globals.dom.elGraphical.add(graphData.elGraph[g]); } } else { w.globals.dom.elGraphical.add(graphData.elGraph); } if (w.config.grid.position === 'front') { me.core.drawGrid(); } if (w.config.xaxis.crosshairs.position === 'front') { me.crosshairs.drawXCrosshairs(); } if (w.config.yaxis[0].crosshairs.position === 'front') { me.crosshairs.drawYCrosshairs(); } if (w.config.annotations.position === 'front') { me.annotations.drawAnnotations(); } if (!w.globals.noData) { // draw tooltips at the end if (w.config.tooltip.enabled && !w.globals.noData) { me.w.globals.tooltip.drawTooltip(graphData.xyRatios); } if (w.globals.axisCharts && w.globals.isXNumeric) { if (w.config.chart.zoom.enabled || w.config.chart.selection.enabled || w.config.chart.pan.enabled) { me.zoomPanSelection.init({ xyRatios: graphData.xyRatios }); } } else { var tools = w.config.chart.toolbar.tools; tools.zoom = false; tools.zoomin = false; tools.zoomout = false; tools.selection = false; tools.pan = false; tools.reset = false; } if (w.config.chart.toolbar.show && !w.globals.allSeriesCollapsed) { me.toolbar.createToolbar(); } } if (w.globals.memory.methodsToExec.length > 0) { var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = w.globals.memory.methodsToExec[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var fn = _step.value; fn.method(fn.params, false, fn.context); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } } resolve(me); }); } /** * Allows users to update Options after the chart has rendered. * * @param {object} options - A new config object can be passed which will be merged with the existing config object * @param {boolean} redraw - should redraw from beginning or should use existing paths and redraw from there * @param {boolean} animate - should animate or not on updating Options */ }, { key: 'updateOptions', value: function updateOptions(options) { var redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var animate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; var overwriteInitialConfig = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; if (options.series) { // user updated the series via updateOptions() function. // Hence, we need to reset axis min/max to avoid zooming issues this.revertDefaultAxisMinMax(); } // user has set x-axis min/max externally - hence we need to forcefully set the xaxis min/max if (options.xaxis && (options.xaxis.min || options.xaxis.max)) { this.forceXAxisUpdate(options); } return this.updateOptionsInternal(options, redraw, animate, overwriteInitialConfig); } /** * private method to update Options. * * @param {object} options - A new config object can be passed which will be merged with the existing config object * @param {boolean} redraw - should redraw from beginning or should use existing paths and redraw from there * @param {boolean} animate - should animate or not on updating Options * @param {boolean} overwriteInitialConfig - should update the initial config or not */ }, { key: 'updateOptionsInternal', value: function updateOptionsInternal(options) { var redraw = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var animate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; var overwriteInitialConfig = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; var charts = this.getSyncedCharts(); charts.forEach(function (ch) { var w = ch.w; w.globals.shouldAnimate = animate; if (!redraw) { w.globals.resized = true; w.globals.dataChanged = true; if (animate) { ch.series.getPreviousPaths(); } } if (options && (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') { ch.config = new _Config2.default(options); options = _CoreUtils2.default.extendArrayProps(ch.config, options); w.config = _Utils2.default.extend(w.config, options); if (overwriteInitialConfig) { // we need to forget the lastXAxis and lastYAxis is user forcefully overwriteInitialConfig. If we do not do this, and next time when user zooms the chart after setting yaxis.min/max or xaxis.min/max - the stored lastXAxis will never allow the chart to use the updated min/max by user. w.globals.lastXAxis = []; w.globals.lastYAxis = []; // After forgetting lastAxes, we need to restore the new config in initialConfig/initialSeries w.globals.initialConfig = _Utils2.default.extend({}, w.config); w.globals.initialSeries = JSON.parse(JSON.stringify(w.config.series)); } } return ch.update(); }); } /** * Allows users to update Series after the chart has rendered. * * @param {array} series - New series which will override the existing */ }, { key: 'updateSeries', value: function updateSeries() { var newSeries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var animate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; this.revertDefaultAxisMinMax(); return this.updateSeriesInternal(newSeries, animate, overwriteInitialSeries); } /** * Private method to update Series. * * @param {array} series - New series which will override the existing */ }, { key: 'updateSeriesInternal', value: function updateSeriesInternal(newSeries, animate) { var overwriteInitialSeries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; var w = this.w; this.w.globals.shouldAnimate = animate; w.globals.dataChanged = true; if (animate) { this.series.getPreviousPaths(); } w.config.series = newSeries.slice(); if (overwriteInitialSeries) { w.globals.initialConfig.series = JSON.parse(JSON.stringify(w.config.series)); w.globals.initialSeries = JSON.parse(JSON.stringify(w.config.series)); } return this.update(); } /** * Get all charts in the same "group" (including the instance which is called upon) to sync them when user zooms in/out or pan. */ }, { key: 'getSyncedCharts', value: function getSyncedCharts() { var chartGroups = this.getGroupedCharts(); var allCharts = [this]; if (chartGroups.length) { allCharts = []; chartGroups.forEach(function (ch) { allCharts.push(ch); }); } return allCharts; } /** * Get charts in the same "group" (excluding the instance which is called upon) to perform operations on the other charts of the same group (eg., tooltip hovering) */ }, { key: 'getGroupedCharts', value: function getGroupedCharts() { var _this2 = this; return Apex._chartInstances.filter(function (ch) { if (ch.group) { return true; } }).map(function (ch) { return _this2.w.config.chart.group === ch.group ? ch.chart : null; }); } /** * Allows users to append Data to series. * * @param {array} newData - New data in the same format as series */ }, { key: 'appendData', value: function appendData(newData) { var overwriteInitialSeries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var me = this; me.w.globals.dataChanged = true; me.series.getPreviousPaths(); var newSeries = me.w.config.series.slice(); for (var i = 0; i < newSeries.length; i++) { if (typeof newData[i] !== 'undefined') { for (var j = 0; j < newData[i].data.length; j++) { newSeries[i].data.push(newData[i].data[j]); } } } me.w.config.series = newSeries; if (overwriteInitialSeries) { me.w.globals.initialSeries = JSON.parse(JSON.stringify(me.w.config.series)); } return this.update(); } }, { key: 'update', value: function update() { var _this3 = this; var me = this; return new Promise(function (resolve, reject) { me.clear(); var graphData = me.create(me.w.config.series); if (!graphData) return resolve(me); me.mount(graphData).then(function () { if (typeof me.w.config.chart.events.updated === 'function') { me.w.config.chart.events.updated(me, me.w); } me.fireEvent('updated', [_this3, _this3.w]); me.w.globals.isDirty = true; resolve(me); }).catch(function (e) { reject(e); }); }); } }, { key: 'forceXAxisUpdate', value: function forceXAxisUpdate(options) { var w = this.w; if (typeof options.xaxis.min !== 'undefined') { w.config.xaxis.min = options.xaxis.min; w.globals.lastXAxis.min = options.xaxis.min; } if (typeof options.xaxis.max !== 'undefined') { w.config.xaxis.max = options.xaxis.max; w.globals.lastXAxis.max = options.xaxis.max; } } /** * This function reverts the yaxis and xaxis min/max values to what it was when the chart was defined. * This function fixes an important bug where a user might load a new series after zooming in/out of previous series which resulted in wrong min/max * Also, this should never be called internally on zoom/pan - the reset should only happen when user calls the updateSeries() function externally */ }, { key: 'revertDefaultAxisMinMax', value: function revertDefaultAxisMinMax() { var w = this.w; w.config.xaxis.min = w.globals.lastXAxis.min; w.config.xaxis.max = w.globals.lastXAxis.max; w.config.yaxis.map(function (yaxe, index) { if (w.globals.zoomed) { // if user has zoomed, and this function is called // then we need to get the lastAxis min and max if (typeof w.globals.lastYAxis[index] !== 'undefined') { yaxe.min = w.globals.lastYAxis[index].min; yaxe.max = w.globals.lastYAxis[index].max; } } }); } }, { key: 'clear', value: function clear() { this.zoomPanSelection.destroy(); if (this.toolbar) { this.toolbar.destroy(); } this.animations = null; this.annotations = null; this.core = null; this.series = null; this.responsive = null; this.theme = null; this.formatters = null; this.titleSubtitle = null; this.legend = null; this.dimensions = null; this.options = null; this.crosshairs = null; this.zoomPanSelection = null; this.toolbar = null; this.w.globals.tooltip = null; this.clearDomElements(); } }, { key: 'killSVG', value: function killSVG(draw) { return new Promise(function (resolve, reject) { draw.each(function (i, children) { this.removeClass('*'); this.off(); this.stop(); }, true); draw.ungroup(); draw.clear(); resolve('done'); }); } }, { key: 'clearDomElements', value: function clearDomElements() { var domEls = this.w.globals.dom; if (this.el !== null) { // remove all child elements - resetting the whole chart while (this.el.firstChild) { this.el.removeChild(this.el.firstChild); } } this.killSVG(domEls.Paper); domEls.Paper.remove(); domEls.elWrap = null; domEls.elGraphical = null; domEls.elLegendWrap = null; domEls.baseEl = null; domEls.elGridRect = null; domEls.elGridRectMask = null; domEls.elDefs = null; } /** * Destroy the chart instance by removing all elements which also clean up event listeners on those elements. */ }, { key: 'destroy', value: function destroy() { this.clear(); window.removeEventListener('resize', this.windowResizeHandler); } /** * Allows the user to provide data attrs in the element and the chart will render automatically when this method is called by searching for the elements containing 'data-apexcharts' attribute */ }, { key: 'toggleSeries', value: function toggleSeries(seriesName) { var targetElement = this.series.getSeriesByName(seriesName); var seriesCnt = parseInt(targetElement.getAttribute('data:realIndex')); var isHidden = targetElement.classList.contains('apexcharts-series-collapsed'); this.legend.toggleDataSeries(seriesCnt, isHidden); } }, { key: 'setupBrushHandler', value: function setupBrushHandler() { var _this4 = this; var w = this.w; // only for brush charts if (!w.config.chart.brush.enabled) { return; } // if user has not defined a custom function for selection - we handle the brush chart // otherwise we leave it to the user to define the functionality for selection if (typeof w.config.chart.events.selection !== 'function') { var targetChart = ApexCharts.getChartByID(w.config.chart.brush.target); targetChart.w.globals.brushSource = this; var updateSourceChart = function updateSourceChart() { _this4.updateOptionsInternal({ chart: { selection: { xaxis: { min: targetChart.w.globals.minX, max: targetChart.w.globals.maxX } } } }, false, false); }; if (typeof targetChart.w.config.chart.events.zoomed !== 'function') { targetChart.w.config.chart.events.zoomed = function () { updateSourceChart(); }; } if (typeof targetChart.w.config.chart.events.scrolled !== 'function') { targetChart.w.config.chart.events.scrolled = function () { updateSourceChart(); }; } w.config.chart.events.selection = function (chart, e) { targetChart.updateOptionsInternal({ xaxis: { min: e.xaxis.min, max: e.xaxis.max } }, false, false); }; } } }, { key: 'setupEventHandlers', value: function setupEventHandlers() { var w = this.w; var me = this; var clickableArea = w.globals.dom.baseEl.querySelector(w.globals.chartClass); var eventList = ['mousedown', 'mousemove', 'touchstart', 'touchmove', 'mouseup', 'touchend']; var _iteratorNormalCompletion2 = true; var _didIteratorError2 = false; var _iteratorError2 = undefined; try { for (var _iterator2 = eventList[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { var event = _step2.value; clickableArea.addEventListener(event, function (e) { if (e.type === 'mousedown' && e.which === 1) { // todo - provide a mousedown event too } else if (e.type === 'mouseup' && e.which === 1 || e.type === 'touchend') { if (typeof w.config.chart.events.click === 'function') { w.config.chart.events.click(e, me, w); } me.fireEvent('click', [e, me, w]); } }, { capture: false, passive: true }); } } catch (err) { _didIteratorError2 = true; _iteratorError2 = err; } finally { try { if (!_iteratorNormalCompletion2 && _iterator2.return) { _iterator2.return(); } } finally { if (_didIteratorError2) { throw _iteratorError2; } } } this.setupBrushHandler(); } }, { key: 'addXaxisAnnotation', value: function addXaxisAnnotation(opts) { var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; var me = this; if (context) { me = context; } me.annotations.addXaxisAnnotationExternal(opts, pushToMemory, me); } }, { key: 'addYaxisAnnotation', value: function addYaxisAnnotation(opts) { var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; var me = this; if (context) { me = context; } me.annotations.addYaxisAnnotationExternal(opts, pushToMemory, me); } }, { key: 'addPointAnnotation', value: function addPointAnnotation(opts) { var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; var me = this; if (context) { me = context; } me.annotations.addPointAnnotationExternal(opts, pushToMemory, me); } // This method is never used internally and will be only called externally on the chart instance. // Hence, we need to keep all these elements in memory when the chart gets updated and redraw again }, { key: 'addText', value: function addText(options) { var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; var me = this; if (context) { me = context; } me.annotations.addText(options, pushToMemory, me); } }, { key: 'getChartArea', value: function getChartArea() { var paper = this.paper(); var el = paper.select('.apexcharts-inner'); return el; } }, { key: 'getSeriesTotalXRange', value: function getSeriesTotalXRange(minX, maxX) { return this.coreUtils.getSeriesTotalsXRange(minX, maxX); } }, { key: 'getSeriesTotal', value: function getSeriesTotal() { return this.w.globals.seriesTotals; } }, { key: 'setLocale', value: function setLocale(localeName) { this.setCurrentLocaleValues(localeName); } }, { key: 'setCurrentLocaleValues', value: function setCurrentLocaleValues(localeName) { var locales = this.w.config.chart.locales; // check if user has specified locales in global Apex variable // if yes - then extend those with local chart's locale if (window.Apex.chart && window.Apex.chart.locales && window.Apex.chart.locales.length > 0) { locales = this.w.config.chart.locales.concat(window.Apex.chart.locales); } // find the locale from the array of locales which user has set (either by chart.defaultLocale or by calling setLocale() method.) var selectedLocale = locales.find(function (c) { return c.name === localeName; }); if (selectedLocale) { // create a complete locale object by extending defaults so you don't get undefined errors. var ret = _Utils2.default.extend(en, selectedLocale); // store these locale options in global var for ease access this.w.globals.locale = ret.options; } else { throw new Error('Wrong locale name provided. Please make sure you set the correct locale name in options'); } } }, { key: 'paper', value: function paper() { return this.w.globals.dom.Paper; } }, { key: 'windowResize', /** * Handle window resize and re-draw the whole chart. */ value: function windowResize() { var _this5 = this; clearTimeout(this.w.globals.resizeTimer); this.w.globals.resizeTimer = window.setTimeout(function () { _this5.w.globals.resized = true; _this5.w.globals.dataChanged = false; // we need to redraw the whole chart on window resize (with a small delay). _this5.update(); }, 150); } }], [{ key: 'initOnLoad', value: function initOnLoad() { var els = document.querySelectorAll('[data-apexcharts]'); for (var i = 0; i < els.length; i++) { var el = els[i]; var options = JSON.parse(els[i].getAttribute('data-options')); var apexChart = new ApexCharts(el, options); apexChart.render(); } } /** * This static method allows users to call chart methods without necessarily from the * instance of the chart in case user has assigned chartID to the targetted chart. * The chartID is used for mapping the instance stored in Apex._chartInstances global variable * * This is helpful in cases when you don't have reference of the chart instance * easily and need to call the method from anywhere. * For eg, in React/Vue applications when you have many parent/child components, * and need easy reference to other charts for performing dynamic operations * * @param {string} chartID - The unique identifier which will be used to call methods * on that chart instance * @param {function} fn - The method name to call * @param {object} opts - The parameters which are accepted in the original method will be passed here in the same order. */ }, { key: 'exec', value: function exec(chartID, fn) { var chart = this.getChartByID(chartID); if (!chart) return; for (var _len = arguments.length, opts = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { opts[_key - 2] = arguments[_key]; } switch (fn) { case 'updateOptions': { return chart.updateOptions.apply(chart, opts); } case 'updateSeries': { return chart.updateSeries.apply(chart, opts); } case 'appendData': { return chart.appendData.apply(chart, opts); } case 'addXaxisAnnotation': { return chart.addXaxisAnnotation.apply(chart, opts); } case 'addYaxisAnnotation': { return chart.addYaxisAnnotation.apply(chart, opts); } case 'addPointAnnotation': { return chart.addPointAnnotation.apply(chart, opts); } case 'destroy': { return chart.destroy(); } } } }, { key: 'merge', value: function merge(target, source) { return _Utils2.default.extend(target, source); } }, { key: 'getChartByID', value: function getChartByID(chartID) { var c = Apex._chartInstances.find(function (ch) { return ch.id === chartID; }); return c.chart; } }]); return ApexCharts; }(); module.exports = ApexCharts; /***/ }), /* 89 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = function (it, Constructor, name, forbiddenField) { if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) { throw TypeError(name + ': incorrect invocation!'); }return it; }; /***/ }), /* 90 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 0 -> Array#forEach // 1 -> Array#map // 2 -> Array#filter // 3 -> Array#some // 4 -> Array#every // 5 -> Array#find // 6 -> Array#findIndex var ctx = __webpack_require__(14); var IObject = __webpack_require__(36); var toObject = __webpack_require__(29); var toLength = __webpack_require__(23); var asc = __webpack_require__(93); module.exports = function (TYPE, $create) { var IS_MAP = TYPE == 1; var IS_FILTER = TYPE == 2; var IS_SOME = TYPE == 3; var IS_EVERY = TYPE == 4; var IS_FIND_INDEX = TYPE == 6; var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; var create = $create || asc; return function ($this, callbackfn, that) { var O = toObject($this); var self = IObject(O); var f = ctx(callbackfn, that, 3); var length = toLength(self.length); var index = 0; var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; var val, res; for (; length > index; index++) { if (NO_HOLES || index in self) { val = self[index]; res = f(val, index, O); if (TYPE) { if (IS_MAP) result[index] = res; // map else if (res) switch (TYPE) { case 3: return true; // some case 5: return val; // find case 6: return index; // findIndex case 2: result.push(val); // filter } else if (IS_EVERY) return false; // every } } }return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; }; }; /***/ }), /* 91 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var aFunction = __webpack_require__(17); var toObject = __webpack_require__(29); var IObject = __webpack_require__(36); var toLength = __webpack_require__(23); module.exports = function (that, callbackfn, aLen, memo, isRight) { aFunction(callbackfn); var O = toObject(that); var self = IObject(O); var length = toLength(O.length); var index = isRight ? length - 1 : 0; var i = isRight ? -1 : 1; if (aLen < 2) for (;;) { if (index in self) { memo = self[index]; index += i; break; } index += i; if (isRight ? index < 0 : length <= index) { throw TypeError('Reduce of empty array with no initial value'); } } for (; isRight ? index >= 0 : length > index; index += i) { if (index in self) { memo = callbackfn(memo, self[index], index, O); } }return memo; }; /***/ }), /* 92 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var isObject = __webpack_require__(8); var isArray = __webpack_require__(57); var SPECIES = __webpack_require__(2)('species'); module.exports = function (original) { var C; if (isArray(original)) { C = original.constructor; // cross-realm fallback if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined; if (isObject(C)) { C = C[SPECIES]; if (C === null) C = undefined; } }return C === undefined ? Array : C; }; /***/ }), /* 93 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 9.4.2.3 ArraySpeciesCreate(originalArray, length) var speciesConstructor = __webpack_require__(92); module.exports = function (original, length) { return new (speciesConstructor(original))(length); }; /***/ }), /* 94 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var $defineProperty = __webpack_require__(9); var createDesc = __webpack_require__(22); module.exports = function (object, index, value) { if (index in object) $defineProperty.f(object, index, createDesc(0, value));else object[index] = value; }; /***/ }), /* 95 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // all enumerable object keys, includes symbols var getKeys = __webpack_require__(27); var gOPS = __webpack_require__(63); var pIE = __webpack_require__(38); module.exports = function (it) { var result = getKeys(it); var getSymbols = gOPS.f; if (getSymbols) { var symbols = getSymbols(it); var isEnum = pIE.f; var i = 0; var key; while (symbols.length > i) { if (isEnum.call(it, key = symbols[i++])) result.push(key); } }return result; }; /***/ }), /* 96 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var ctx = __webpack_require__(14); var call = __webpack_require__(58); var isArrayIter = __webpack_require__(56); var anObject = __webpack_require__(7); var toLength = __webpack_require__(23); var getIterFn = __webpack_require__(70); var BREAK = {}; var RETURN = {}; var _exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable); var f = ctx(fn, that, entries ? 2 : 1); var index = 0; var length, step, iterator, result; if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); // fast case for arrays with default iterator if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) { result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); if (result === BREAK || result === RETURN) return result; } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) { result = call(iterator, f, step.value, entries); if (result === BREAK || result === RETURN) return result; } }; _exports.BREAK = BREAK; _exports.RETURN = RETURN; /***/ }), /* 97 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // fast apply, http://jsperf.lnkit.com/fast-apply/5 module.exports = function (fn, args, that) { var un = that === undefined; switch (args.length) { case 0: return un ? fn() : fn.call(that); case 1: return un ? fn(args[0]) : fn.call(that, args[0]); case 2: return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]); case 3: return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]); case 4: return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]); }return fn.apply(that, args); }; /***/ }), /* 98 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var create = __webpack_require__(61); var descriptor = __webpack_require__(22); var setToStringTag = __webpack_require__(28); var IteratorPrototype = {}; // 25.1.2.1.1 %IteratorPrototype%[@@iterator]() __webpack_require__(12)(IteratorPrototype, __webpack_require__(2)('iterator'), function () { return this; }); module.exports = function (Constructor, NAME, next) { Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) }); setToStringTag(Constructor, NAME + ' Iterator'); }; /***/ }), /* 99 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = function (done, value) { return { value: value, done: !!done }; }; /***/ }), /* 100 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var META = __webpack_require__(24)('meta'); var isObject = __webpack_require__(8); var has = __webpack_require__(11); var setDesc = __webpack_require__(9).f; var id = 0; var isExtensible = Object.isExtensible || function () { return true; }; var FREEZE = !__webpack_require__(19)(function () { return isExtensible(Object.preventExtensions({})); }); var setMeta = function setMeta(it) { setDesc(it, META, { value: { i: 'O' + ++id, // object ID w: {} // weak collections IDs } }); }; var fastKey = function fastKey(it, create) { // return primitive with prefix if (!isObject(it)) return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; if (!has(it, META)) { // can't set metadata to uncaught frozen object if (!isExtensible(it)) return 'F'; // not necessary to add metadata if (!create) return 'E'; // add missing metadata setMeta(it); // return object ID }return it[META].i; }; var getWeak = function getWeak(it, create) { if (!has(it, META)) { // can't set metadata to uncaught frozen object if (!isExtensible(it)) return true; // not necessary to add metadata if (!create) return false; // add missing metadata setMeta(it); // return hash weak collections IDs }return it[META].w; }; // add metadata on freeze-family methods calling var onFreeze = function onFreeze(it) { if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it); return it; }; var meta = module.exports = { KEY: META, NEED: false, fastKey: fastKey, getWeak: getWeak, onFreeze: onFreeze }; /***/ }), /* 101 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var global = __webpack_require__(3); var macrotask = __webpack_require__(68).set; var Observer = global.MutationObserver || global.WebKitMutationObserver; var process = global.process; var Promise = global.Promise; var isNode = __webpack_require__(18)(process) == 'process'; module.exports = function () { var head, last, notify; var flush = function flush() { var parent, fn; if (isNode && (parent = process.domain)) parent.exit(); while (head) { fn = head.fn; head = head.next; try { fn(); } catch (e) { if (head) notify();else last = undefined; throw e; } }last = undefined; if (parent) parent.enter(); }; // Node.js if (isNode) { notify = function notify() { process.nextTick(flush); }; // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339 } else if (Observer && !(global.navigator && global.navigator.standalone)) { var toggle = true; var node = document.createTextNode(''); new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new notify = function notify() { node.data = toggle = !toggle; }; // environments with maybe non-completely correct, but existent Promise } else if (Promise && Promise.resolve) { // Promise.resolve without an argument throws an error in LG WebOS 2 var promise = Promise.resolve(undefined); notify = function notify() { promise.then(flush); }; // for other environments - macrotask based on: // - setImmediate // - MessageChannel // - window.postMessag // - onreadystatechange // - setTimeout } else { notify = function notify() { // strange IE + webpack dev server bug - use .call(global) macrotask.call(global, flush); }; } return function (fn) { var task = { fn: fn, next: undefined }; if (last) last.next = task; if (!head) { head = task; notify(); }last = task; }; }; /***/ }), /* 102 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var dP = __webpack_require__(9); var anObject = __webpack_require__(7); var getKeys = __webpack_require__(27); module.exports = __webpack_require__(10) ? Object.defineProperties : function defineProperties(O, Properties) { anObject(O); var keys = getKeys(Properties); var length = keys.length; var i = 0; var P; while (length > i) { dP.f(O, P = keys[i++], Properties[P]); }return O; }; /***/ }), /* 103 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var pIE = __webpack_require__(38); var createDesc = __webpack_require__(22); var toIObject = __webpack_require__(16); var toPrimitive = __webpack_require__(42); var has = __webpack_require__(11); var IE8_DOM_DEFINE = __webpack_require__(55); var gOPD = Object.getOwnPropertyDescriptor; exports.f = __webpack_require__(10) ? gOPD : function getOwnPropertyDescriptor(O, P) { O = toIObject(O); P = toPrimitive(P, true); if (IE8_DOM_DEFINE) try { return gOPD(O, P); } catch (e) {/* empty */} if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]); }; /***/ }), /* 104 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window var toIObject = __webpack_require__(16); var gOPN = __webpack_require__(62).f; var toString = {}.toString; var windowNames = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : []; var getWindowNames = function getWindowNames(it) { try { return gOPN(it); } catch (e) { return windowNames.slice(); } }; module.exports.f = function getOwnPropertyNames(it) { return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); }; /***/ }), /* 105 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) var has = __webpack_require__(11); var toObject = __webpack_require__(29); var IE_PROTO = __webpack_require__(39)('IE_PROTO'); var ObjectProto = Object.prototype; module.exports = Object.getPrototypeOf || function (O) { O = toObject(O); if (has(O, IE_PROTO)) return O[IE_PROTO]; if (typeof O.constructor == 'function' && O instanceof O.constructor) { return O.constructor.prototype; }return O instanceof Object ? ObjectProto : null; }; /***/ }), /* 106 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var redefine = __webpack_require__(15); module.exports = function (target, src, safe) { for (var key in src) { redefine(target, key, src[key], safe); }return target; }; /***/ }), /* 107 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var global = __webpack_require__(3); var dP = __webpack_require__(9); var DESCRIPTORS = __webpack_require__(10); var SPECIES = __webpack_require__(2)('species'); module.exports = function (KEY) { var C = global[KEY]; if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, { configurable: true, get: function get() { return this; } }); }; /***/ }), /* 108 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var fails = __webpack_require__(19); module.exports = function (method, arg) { return !!method && fails(function () { // eslint-disable-next-line no-useless-call arg ? method.call(null, function () {/* empty */}, 1) : method.call(null); }); }; /***/ }), /* 109 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var toInteger = __webpack_require__(41); var defined = __webpack_require__(33); // true -> String#at // false -> String#codePointAt module.exports = function (TO_STRING) { return function (that, pos) { var s = String(defined(that)); var i = toInteger(pos); var l = s.length; var a, b; if (i < 0 || i >= l) return TO_STRING ? '' : undefined; a = s.charCodeAt(i); return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; }; }; /***/ }), /* 110 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var toInteger = __webpack_require__(41); var max = Math.max; var min = Math.min; module.exports = function (index, length) { index = toInteger(index); return index < 0 ? max(index + length, 0) : min(index, length); }; /***/ }), /* 111 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var global = __webpack_require__(3); var navigator = global.navigator; module.exports = navigator && navigator.userAgent || ''; /***/ }), /* 112 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined) var $export = __webpack_require__(5); var $find = __webpack_require__(90)(5); var KEY = 'find'; var forced = true; // Shouldn't skip holes if (KEY in []) Array(1)[KEY](function () { forced = false; }); $export($export.P + $export.F * forced, 'Array', { find: function find(callbackfn /* , that = undefined */) { return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); } }); __webpack_require__(31)(KEY); /***/ }), /* 113 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var ctx = __webpack_require__(14); var $export = __webpack_require__(5); var toObject = __webpack_require__(29); var call = __webpack_require__(58); var isArrayIter = __webpack_require__(56); var toLength = __webpack_require__(23); var createProperty = __webpack_require__(94); var getIterFn = __webpack_require__(70); $export($export.S + $export.F * !__webpack_require__(60)(function (iter) { Array.from(iter); }), 'Array', { // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { var O = toObject(arrayLike); var C = typeof this == 'function' ? this : Array; var aLen = arguments.length; var mapfn = aLen > 1 ? arguments[1] : undefined; var mapping = mapfn !== undefined; var index = 0; var iterFn = getIterFn(O); var length, result, step, iterator; if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); // if object isn't iterable or it's array with default iterator - use simple case if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) { for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) { createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value); } } else { length = toLength(O.length); for (result = new C(length); length > index; index++) { createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); } } result.length = index; return result; } }); /***/ }), /* 114 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var addToUnscopables = __webpack_require__(31); var step = __webpack_require__(99); var Iterators = __webpack_require__(20); var toIObject = __webpack_require__(16); // 22.1.3.4 Array.prototype.entries() // 22.1.3.13 Array.prototype.keys() // 22.1.3.29 Array.prototype.values() // 22.1.3.30 Array.prototype[@@iterator]() module.exports = __webpack_require__(59)(Array, 'Array', function (iterated, kind) { this._t = toIObject(iterated); // target this._i = 0; // next index this._k = kind; // kind // 22.1.5.2.1 %ArrayIteratorPrototype%.next() }, function () { var O = this._t; var kind = this._k; var index = this._i++; if (!O || index >= O.length) { this._t = undefined; return step(1); } if (kind == 'keys') return step(0, index); if (kind == 'values') return step(0, O[index]); return step(0, [index, O[index]]); }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) Iterators.Arguments = Iterators.Array; addToUnscopables('keys'); addToUnscopables('values'); addToUnscopables('entries'); /***/ }), /* 115 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var $export = __webpack_require__(5); var $reduce = __webpack_require__(91); $export($export.P + $export.F * !__webpack_require__(108)([].reduce, true), 'Array', { // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue]) reduce: function reduce(callbackfn /* , initialValue */) { return $reduce(this, callbackfn, arguments.length, arguments[1], false); } }); /***/ }), /* 116 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var LIBRARY = __webpack_require__(21); var global = __webpack_require__(3); var ctx = __webpack_require__(14); var classof = __webpack_require__(32); var $export = __webpack_require__(5); var isObject = __webpack_require__(8); var aFunction = __webpack_require__(17); var anInstance = __webpack_require__(89); var forOf = __webpack_require__(96); var speciesConstructor = __webpack_require__(67); var task = __webpack_require__(68).set; var microtask = __webpack_require__(101)(); var newPromiseCapabilityModule = __webpack_require__(37); var perform = __webpack_require__(65); var userAgent = __webpack_require__(111); var promiseResolve = __webpack_require__(66); var PROMISE = 'Promise'; var TypeError = global.TypeError; var process = global.process; var versions = process && process.versions; var v8 = versions && versions.v8 || ''; var $Promise = global[PROMISE]; var isNode = classof(process) == 'process'; var empty = function empty() {/* empty */}; var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper; var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f; var USE_NATIVE = !!function () { try { // correct subclassing with @@species support var promise = $Promise.resolve(1); var FakePromise = (promise.constructor = {})[__webpack_require__(2)('species')] = function (exec) { exec(empty, empty); }; // unhandled rejections tracking support, NodeJS Promise without it fails @@species test return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 // we can't detect it synchronously, so just check versions && v8.indexOf('6.6') !== 0 && userAgent.indexOf('Chrome/66') === -1; } catch (e) {/* empty */} }(); // helpers var isThenable = function isThenable(it) { var then; return isObject(it) && typeof (then = it.then) == 'function' ? then : false; }; var notify = function notify(promise, isReject) { if (promise._n) return; promise._n = true; var chain = promise._c; microtask(function () { var value = promise._v; var ok = promise._s == 1; var i = 0; var run = function run(reaction) { var handler = ok ? reaction.ok : reaction.fail; var resolve = reaction.resolve; var reject = reaction.reject; var domain = reaction.domain; var result, then, exited; try { if (handler) { if (!ok) { if (promise._h == 2) onHandleUnhandled(promise); promise._h = 1; } if (handler === true) result = value;else { if (domain) domain.enter(); result = handler(value); // may throw if (domain) { domain.exit(); exited = true; } } if (result === reaction.promise) { reject(TypeError('Promise-chain cycle')); } else if (then = isThenable(result)) { then.call(result, resolve, reject); } else resolve(result); } else reject(value); } catch (e) { if (domain && !exited) domain.exit(); reject(e); } }; while (chain.length > i) { run(chain[i++]); } // variable length - can't use forEach promise._c = []; promise._n = false; if (isReject && !promise._h) onUnhandled(promise); }); }; var onUnhandled = function onUnhandled(promise) { task.call(global, function () { var value = promise._v; var unhandled = isUnhandled(promise); var result, handler, console; if (unhandled) { result = perform(function () { if (isNode) { process.emit('unhandledRejection', value, promise); } else if (handler = global.onunhandledrejection) { handler({ promise: promise, reason: value }); } else if ((console = global.console) && console.error) { console.error('Unhandled promise rejection', value); } }); // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should promise._h = isNode || isUnhandled(promise) ? 2 : 1; }promise._a = undefined; if (unhandled && result.e) throw result.v; }); }; var isUnhandled = function isUnhandled(promise) { return promise._h !== 1 && (promise._a || promise._c).length === 0; }; var onHandleUnhandled = function onHandleUnhandled(promise) { task.call(global, function () { var handler; if (isNode) { process.emit('rejectionHandled', promise); } else if (handler = global.onrejectionhandled) { handler({ promise: promise, reason: promise._v }); } }); }; var $reject = function $reject(value) { var promise = this; if (promise._d) return; promise._d = true; promise = promise._w || promise; // unwrap promise._v = value; promise._s = 2; if (!promise._a) promise._a = promise._c.slice(); notify(promise, true); }; var $resolve = function $resolve(value) { var promise = this; var then; if (promise._d) return; promise._d = true; promise = promise._w || promise; // unwrap try { if (promise === value) throw TypeError("Promise can't be resolved itself"); if (then = isThenable(value)) { microtask(function () { var wrapper = { _w: promise, _d: false }; // wrap try { then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1)); } catch (e) { $reject.call(wrapper, e); } }); } else { promise._v = value; promise._s = 1; notify(promise, false); } } catch (e) { $reject.call({ _w: promise, _d: false }, e); // wrap } }; // constructor polyfill if (!USE_NATIVE) { // 25.4.3.1 Promise(executor) $Promise = function Promise(executor) { anInstance(this, $Promise, PROMISE, '_h'); aFunction(executor); Internal.call(this); try { executor(ctx($resolve, this, 1), ctx($reject, this, 1)); } catch (err) { $reject.call(this, err); } }; // eslint-disable-next-line no-unused-vars Internal = function Promise(executor) { this._c = []; // <- awaiting reactions this._a = undefined; // <- checked in isUnhandled reactions this._s = 0; // <- state this._d = false; // <- done this._v = undefined; // <- value this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled this._n = false; // <- notify }; Internal.prototype = __webpack_require__(106)($Promise.prototype, { // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) then: function then(onFulfilled, onRejected) { var reaction = newPromiseCapability(speciesConstructor(this, $Promise)); reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; reaction.fail = typeof onRejected == 'function' && onRejected; reaction.domain = isNode ? process.domain : undefined; this._c.push(reaction); if (this._a) this._a.push(reaction); if (this._s) notify(this, false); return reaction.promise; }, // 25.4.5.1 Promise.prototype.catch(onRejected) 'catch': function _catch(onRejected) { return this.then(undefined, onRejected); } }); OwnPromiseCapability = function OwnPromiseCapability() { var promise = new Internal(); this.promise = promise; this.resolve = ctx($resolve, promise, 1); this.reject = ctx($reject, promise, 1); }; newPromiseCapabilityModule.f = newPromiseCapability = function newPromiseCapability(C) { return C === $Promise || C === Wrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C); }; } $export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise }); __webpack_require__(28)($Promise, PROMISE); __webpack_require__(107)(PROMISE); Wrapper = __webpack_require__(4)[PROMISE]; // statics $export($export.S + $export.F * !USE_NATIVE, PROMISE, { // 25.4.4.5 Promise.reject(r) reject: function reject(r) { var capability = newPromiseCapability(this); var $$reject = capability.reject; $$reject(r); return capability.promise; } }); $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, { // 25.4.4.6 Promise.resolve(x) resolve: function resolve(x) { return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x); } }); $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(60)(function (iter) { $Promise.all(iter)['catch'](empty); })), PROMISE, { // 25.4.4.1 Promise.all(iterable) all: function all(iterable) { var C = this; var capability = newPromiseCapability(C); var resolve = capability.resolve; var reject = capability.reject; var result = perform(function () { var values = []; var index = 0; var remaining = 1; forOf(iterable, false, function (promise) { var $index = index++; var alreadyCalled = false; values.push(undefined); remaining++; C.resolve(promise).then(function (value) { if (alreadyCalled) return; alreadyCalled = true; values[$index] = value; --remaining || resolve(values); }, reject); }); --remaining || resolve(values); }); if (result.e) reject(result.v); return capability.promise; }, // 25.4.4.4 Promise.race(iterable) race: function race(iterable) { var C = this; var capability = newPromiseCapability(C); var reject = capability.reject; var result = perform(function () { forOf(iterable, false, function (promise) { C.resolve(promise).then(capability.resolve, reject); }); }); if (result.e) reject(result.v); return capability.promise; } }); /***/ }), /* 117 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // ECMAScript 6 symbols shim var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var global = __webpack_require__(3); var has = __webpack_require__(11); var DESCRIPTORS = __webpack_require__(10); var $export = __webpack_require__(5); var redefine = __webpack_require__(15); var META = __webpack_require__(100).KEY; var $fails = __webpack_require__(19); var shared = __webpack_require__(40); var setToStringTag = __webpack_require__(28); var uid = __webpack_require__(24); var wks = __webpack_require__(2); var wksExt = __webpack_require__(69); var wksDefine = __webpack_require__(43); var enumKeys = __webpack_require__(95); var isArray = __webpack_require__(57); var anObject = __webpack_require__(7); var isObject = __webpack_require__(8); var toIObject = __webpack_require__(16); var toPrimitive = __webpack_require__(42); var createDesc = __webpack_require__(22); var _create = __webpack_require__(61); var gOPNExt = __webpack_require__(104); var $GOPD = __webpack_require__(103); var $DP = __webpack_require__(9); var $keys = __webpack_require__(27); var gOPD = $GOPD.f; var dP = $DP.f; var gOPN = gOPNExt.f; var $Symbol = global.Symbol; var $JSON = global.JSON; var _stringify = $JSON && $JSON.stringify; var PROTOTYPE = 'prototype'; var HIDDEN = wks('_hidden'); var TO_PRIMITIVE = wks('toPrimitive'); var isEnum = {}.propertyIsEnumerable; var SymbolRegistry = shared('symbol-registry'); var AllSymbols = shared('symbols'); var OPSymbols = shared('op-symbols'); var ObjectProto = Object[PROTOTYPE]; var USE_NATIVE = typeof $Symbol == 'function'; var QObject = global.QObject; // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 var setSymbolDesc = DESCRIPTORS && $fails(function () { return _create(dP({}, 'a', { get: function get() { return dP(this, 'a', { value: 7 }).a; } })).a != 7; }) ? function (it, key, D) { var protoDesc = gOPD(ObjectProto, key); if (protoDesc) delete ObjectProto[key]; dP(it, key, D); if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc); } : dP; var wrap = function wrap(tag) { var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]); sym._k = tag; return sym; }; var isSymbol = USE_NATIVE && _typeof($Symbol.iterator) == 'symbol' ? function (it) { return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol'; } : function (it) { return it instanceof $Symbol; }; var $defineProperty = function defineProperty(it, key, D) { if (it === ObjectProto) $defineProperty(OPSymbols, key, D); anObject(it); key = toPrimitive(key, true); anObject(D); if (has(AllSymbols, key)) { if (!D.enumerable) { if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {})); it[HIDDEN][key] = true; } else { if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false; D = _create(D, { enumerable: createDesc(0, false) }); }return setSymbolDesc(it, key, D); }return dP(it, key, D); }; var $defineProperties = function defineProperties(it, P) { anObject(it); var keys = enumKeys(P = toIObject(P)); var i = 0; var l = keys.length; var key; while (l > i) { $defineProperty(it, key = keys[i++], P[key]); }return it; }; var $create = function create(it, P) { return P === undefined ? _create(it) : $defineProperties(_create(it), P); }; var $propertyIsEnumerable = function propertyIsEnumerable(key) { var E = isEnum.call(this, key = toPrimitive(key, true)); if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false; return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true; }; var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) { it = toIObject(it); key = toPrimitive(key, true); if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return; var D = gOPD(it, key); if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true; return D; }; var $getOwnPropertyNames = function getOwnPropertyNames(it) { var names = gOPN(toIObject(it)); var result = []; var i = 0; var key; while (names.length > i) { if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key); }return result; }; var $getOwnPropertySymbols = function getOwnPropertySymbols(it) { var IS_OP = it === ObjectProto; var names = gOPN(IS_OP ? OPSymbols : toIObject(it)); var result = []; var i = 0; var key; while (names.length > i) { if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]); }return result; }; // 19.4.1.1 Symbol([description]) if (!USE_NATIVE) { $Symbol = function _Symbol() { if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!'); var tag = uid(arguments.length > 0 ? arguments[0] : undefined); var $set = function $set(value) { if (this === ObjectProto) $set.call(OPSymbols, value); if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; setSymbolDesc(this, tag, createDesc(1, value)); }; if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set }); return wrap(tag); }; redefine($Symbol[PROTOTYPE], 'toString', function toString() { return this._k; }); $GOPD.f = $getOwnPropertyDescriptor; $DP.f = $defineProperty; __webpack_require__(62).f = gOPNExt.f = $getOwnPropertyNames; __webpack_require__(38).f = $propertyIsEnumerable; __webpack_require__(63).f = $getOwnPropertySymbols; if (DESCRIPTORS && !__webpack_require__(21)) { redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); } wksExt.f = function (name) { return wrap(wks(name)); }; } $export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol }); for (var es6Symbols = // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'.split(','), j = 0; es6Symbols.length > j;) { wks(es6Symbols[j++]); }for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) { wksDefine(wellKnownSymbols[k++]); }$export($export.S + $export.F * !USE_NATIVE, 'Symbol', { // 19.4.2.1 Symbol.for(key) 'for': function _for(key) { return has(SymbolRegistry, key += '') ? SymbolRegistry[key] : SymbolRegistry[key] = $Symbol(key); }, // 19.4.2.5 Symbol.keyFor(sym) keyFor: function keyFor(sym) { if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!'); for (var key in SymbolRegistry) { if (SymbolRegistry[key] === sym) return key; } }, useSetter: function useSetter() { setter = true; }, useSimple: function useSimple() { setter = false; } }); $export($export.S + $export.F * !USE_NATIVE, 'Object', { // 19.1.2.2 Object.create(O [, Properties]) create: $create, // 19.1.2.4 Object.defineProperty(O, P, Attributes) defineProperty: $defineProperty, // 19.1.2.3 Object.defineProperties(O, Properties) defineProperties: $defineProperties, // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) getOwnPropertyDescriptor: $getOwnPropertyDescriptor, // 19.1.2.7 Object.getOwnPropertyNames(O) getOwnPropertyNames: $getOwnPropertyNames, // 19.1.2.8 Object.getOwnPropertySymbols(O) getOwnPropertySymbols: $getOwnPropertySymbols }); // 24.3.2 JSON.stringify(value [, replacer [, space]]) $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () { var S = $Symbol(); // MS Edge converts symbol values to JSON as {} // WebKit converts symbol values to JSON as null // V8 throws on boxed symbols return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}'; })), 'JSON', { stringify: function stringify(it) { var args = [it]; var i = 1; var replacer, $replacer; while (arguments.length > i) { args.push(arguments[i++]); }$replacer = replacer = args[1]; if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined if (!isArray(replacer)) replacer = function replacer(key, value) { if (typeof $replacer == 'function') value = $replacer.call(this, key, value); if (!isSymbol(value)) return value; }; args[1] = replacer; return _stringify.apply($JSON, args); } }); // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint) $Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(12)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf); // 19.4.3.5 Symbol.prototype[@@toStringTag] setToStringTag($Symbol, 'Symbol'); // 20.2.1.9 Math[@@toStringTag] setToStringTag(Math, 'Math', true); // 24.3.3 JSON[@@toStringTag] setToStringTag(global.JSON, 'JSON', true); /***/ }), /* 118 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // https://github.com/tc39/Array.prototype.includes var $export = __webpack_require__(5); var $includes = __webpack_require__(53)(true); $export($export.P, 'Array', { includes: function includes(el /* , fromIndex = 0 */) { return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); } }); __webpack_require__(31)('includes'); /***/ }), /* 119 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // https://github.com/tc39/proposal-promise-finally var $export = __webpack_require__(5); var core = __webpack_require__(4); var global = __webpack_require__(3); var speciesConstructor = __webpack_require__(67); var promiseResolve = __webpack_require__(66); $export($export.P + $export.R, 'Promise', { 'finally': function _finally(onFinally) { var C = speciesConstructor(this, core.Promise || global.Promise); var isFunction = typeof onFinally == 'function'; return this.then(isFunction ? function (x) { return promiseResolve(C, onFinally()).then(function () { return x; }); } : onFinally, isFunction ? function (e) { return promiseResolve(C, onFinally()).then(function () { throw e; }); } : onFinally); } }); /***/ }), /* 120 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; // https://github.com/tc39/proposal-promise-try var $export = __webpack_require__(5); var newPromiseCapability = __webpack_require__(37); var perform = __webpack_require__(65); $export($export.S, 'Promise', { 'try': function _try(callbackfn) { var promiseCapability = newPromiseCapability.f(this); var result = perform(callbackfn); (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v); return promiseCapability.promise; } }); /***/ }), /* 121 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; __webpack_require__(43)('asyncIterator'); /***/ }), /* 122 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; __webpack_require__(43)('observable'); /***/ }), /* 123 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var $iterators = __webpack_require__(114); var getKeys = __webpack_require__(27); var redefine = __webpack_require__(15); var global = __webpack_require__(3); var hide = __webpack_require__(12); var Iterators = __webpack_require__(20); var wks = __webpack_require__(2); var ITERATOR = wks('iterator'); var TO_STRING_TAG = wks('toStringTag'); var ArrayValues = Iterators.Array; var DOMIterables = { CSSRuleList: true, // TODO: Not spec compliant, should be false. CSSStyleDeclaration: false, CSSValueList: false, ClientRectList: false, DOMRectList: false, DOMStringList: false, DOMTokenList: true, DataTransferItemList: false, FileList: false, HTMLAllCollection: false, HTMLCollection: false, HTMLFormElement: false, HTMLSelectElement: false, MediaList: true, // TODO: Not spec compliant, should be false. MimeTypeArray: false, NamedNodeMap: false, NodeList: true, PaintRequestList: false, Plugin: false, PluginArray: false, SVGLengthList: false, SVGNumberList: false, SVGPathSegList: false, SVGPointList: false, SVGStringList: false, SVGTransformList: false, SourceBufferList: false, StyleSheetList: true, // TODO: Not spec compliant, should be false. TextTrackCueList: false, TextTrackList: false, TouchList: false }; for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) { var NAME = collections[i]; var explicit = DOMIterables[NAME]; var Collection = global[NAME]; var proto = Collection && Collection.prototype; var key; if (proto) { if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues); if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME); Iterators[NAME] = ArrayValues; if (explicit) for (key in $iterators) { if (!proto[key]) redefine(proto, key, $iterators[key], true); } } } /***/ }), /* 124 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ // css base code, injected by the css-loader module.exports = function (useSourceMap) { var list = []; // return the list of modules as css string list.toString = function toString() { return this.map(function (item) { var content = cssWithMappingToString(item, useSourceMap); if (item[2]) { return "@media " + item[2] + "{" + content + "}"; } else { return content; } }).join(""); }; // import a list of modules into the list list.i = function (modules, mediaQuery) { if (typeof modules === "string") modules = [[null, modules, ""]]; var alreadyImportedModules = {}; for (var i = 0; i < this.length; i++) { var id = this[i][0]; if (typeof id === "number") alreadyImportedModules[id] = true; } for (i = 0; i < modules.length; i++) { var item = modules[i]; // skip already imported module // this implementation is not 100% perfect for weird media query combinations // when a module is imported multiple times with different media queries. // I hope this will never occur (Hey this way we have smaller bundles) if (typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { if (mediaQuery && !item[2]) { item[2] = mediaQuery; } else if (mediaQuery) { item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; } list.push(item); } } }; return list; }; function cssWithMappingToString(item, useSourceMap) { var content = item[1] || ''; var cssMapping = item[3]; if (!cssMapping) { return content; } if (useSourceMap && typeof btoa === 'function') { var sourceMapping = toComment(cssMapping); var sourceURLs = cssMapping.sources.map(function (source) { return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'; }); return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); } return [content].join('\n'); } // Adapted from convert-source-map (MIT) function toComment(sourceMap) { // eslint-disable-next-line no-undef var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))); var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; return '/*# ' + data + ' */'; } /***/ }), /* 125 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Bar2 = __webpack_require__(44); var _Bar3 = _interopRequireDefault(_Bar2); var _Fill = __webpack_require__(13); var _Fill2 = _interopRequireDefault(_Fill); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * ApexCharts BarStacked Class responsible for drawing both Stacked Columns and Bars. * * @module BarStacked * The whole calculation for stacked bar/column is different from normal bar/column, * hence it makes sense to derive a new class for it extending most of the props of Parent Bar **/ var BarStacked = function (_Bar) { _inherits(BarStacked, _Bar); function BarStacked() { _classCallCheck(this, BarStacked); return _possibleConstructorReturn(this, (BarStacked.__proto__ || Object.getPrototypeOf(BarStacked)).apply(this, arguments)); } _createClass(BarStacked, [{ key: 'draw', value: function draw(series) { var _this2 = this; var w = this.w; this.graphics = new _Graphics2.default(this.ctx); this.fill = new _Fill2.default(this.ctx); this.bar = new _Bar3.default(this.ctx, this.xyRatios); this.series = series; if (w.config.chart.stackType === '100%') { this.series = w.globals.seriesPercent.slice(); series = this.series; } this.totalItems = 0; this.prevY = []; // y position on chart this.prevX = []; // x position on chart this.prevYF = []; // y position including shapes on chart this.prevXF = []; // x position including shapes on chart this.prevYVal = []; // y values (series[i][j]) in columns this.prevXVal = []; // x values (series[i][j]) in bars this.xArrj = []; // xj indicates x position on graph in bars this.xArrjF = []; // xjF indicates bar's x position + endingshape's positions in bars this.xArrjVal = []; // x val means the actual series's y values in horizontal/bars this.yArrj = []; // yj indicates y position on graph in columns this.yArrjF = []; // yjF indicates bar's y position + endingshape's positions in columns this.yArrjVal = []; // y val means the actual series's y values in columns for (var sl = 0; sl < series.length; sl++) { if (series[sl].length > 0) { this.totalItems += series[sl].length; } } this.zeroSerieses = []; this.endingShapeOnSeriesNumber = series.length - 1; // which series to draw ending shape on this.checkZeroSeries({ series: series }); var ret = this.graphics.group({ class: 'apexcharts-bar-series apexcharts-plot-series' }); ret.attr('clip-path', 'url(#gridRectMask' + w.globals.cuid + ')'); var x = 0; var y = 0; var _loop = function _loop(i, bc) { var pathTo = void 0, pathFrom = void 0; var xDivision = void 0; // xDivision is the GRIDWIDTH divided by number of datapoints (columns) var yDivision = void 0; // yDivision is the GRIDHEIGHT divided by number of datapoints (bars) var zeroH = void 0; // zeroH is the baseline where 0 meets y axis var zeroW = void 0; // zeroW is the baseline where 0 meets x axis var xArrValues = []; var yArrValues = []; var realIndex = i; if (_this2.yRatio.length > 1) { _this2.yaxisIndex = realIndex; } // el to which series will be drawn var elSeries = _this2.graphics.group({ class: 'apexcharts-series ' + w.globals.seriesNames[realIndex].replace(/ /g, '-'), 'rel': i + 1, 'data:realIndex': i }); // eldatalabels var elDataLabelsWrap = _this2.graphics.group({ class: 'apexcharts-datalabels' }); var strokeWidth = 0; var barHeight = 0; var barWidth = 0; var initPositions = _this2.initialPositions(x, y, xDivision, yDivision, zeroH, zeroW); y = initPositions.y; barHeight = initPositions.barHeight; yDivision = initPositions.yDivision; zeroW = initPositions.zeroW; x = initPositions.x; barWidth = initPositions.barWidth; xDivision = initPositions.xDivision; zeroH = initPositions.zeroH; _this2.yArrj = []; _this2.yArrjF = []; _this2.yArrjVal = []; _this2.xArrj = []; _this2.xArrjF = []; _this2.xArrjVal = []; // if (!this.horizontal) { // this.xArrj.push(x + barWidth / 2) // } var _loop2 = function _loop2(j) { if (w.config.stroke.show) { if (series[i][j] === null || series[i][j] === 0) { strokeWidth = 0; } else { strokeWidth = Array.isArray(_this2.strokeWidth) ? _this2.strokeWidth[realIndex] : _this2.strokeWidth; } } var paths = null; if (_this2.isHorizontal) { paths = _this2.drawBarPaths({ indexes: { i: i, j: j, realIndex: realIndex, bc: bc }, barHeight: barHeight, strokeWidth: strokeWidth, pathTo: pathTo, pathFrom: pathFrom, zeroW: zeroW, x: x, y: y, yDivision: yDivision, elSeries: elSeries }); } else { paths = _this2.drawColumnPaths({ indexes: { i: i, j: j, realIndex: realIndex, bc: bc }, x: x, y: y, xDivision: xDivision, pathTo: pathTo, pathFrom: pathFrom, barWidth: barWidth, zeroH: zeroH, strokeWidth: strokeWidth, elSeries: elSeries }); } pathTo = paths.pathTo; pathFrom = paths.pathFrom; y = paths.y; x = paths.x; xArrValues.push(x); yArrValues.push(y); var seriesNumber = w.config.plotOptions.bar.distributed ? j : i; var fillColor = null; if (_this2.barOptions.colors.ranges.length > 0) { var colorRange = _this2.barOptions.colors.ranges; colorRange.map(function (range, index) { if (series[i][j] >= range.from && series[i][j] <= range.to) { fillColor = range.color; } }); } var pathFill = _this2.fill.fillPath(elSeries, { seriesNumber: seriesNumber, color: fillColor }); elSeries = _this2.renderSeries({ realIndex: realIndex, pathFill: pathFill, j: j, i: i, pathFrom: pathFrom, pathTo: pathTo, strokeWidth: strokeWidth, elSeries: elSeries, x: x, y: y, series: series, barHeight: barHeight, barWidth: barWidth, elDataLabelsWrap: elDataLabelsWrap, type: 'bar', visibleSeries: 0 }); }; for (var j = 0; j < w.globals.dataPoints; j++) { _loop2(j); } // push all x val arrays into main xArr w.globals.seriesXvalues[realIndex] = xArrValues; w.globals.seriesYvalues[realIndex] = yArrValues; // push all current y values array to main PrevY Array _this2.prevY.push(_this2.yArrj); _this2.prevYF.push(_this2.yArrjF); _this2.prevYVal.push(_this2.yArrjVal); _this2.prevX.push(_this2.xArrj); _this2.prevXF.push(_this2.xArrjF); _this2.prevXVal.push(_this2.xArrjVal); ret.add(elSeries); }; for (var i = 0, bc = 0; i < series.length; i++, bc++) { _loop(i, bc); } return ret; } }, { key: 'initialPositions', value: function initialPositions(x, y, xDivision, yDivision, zeroH, zeroW) { var w = this.w; var barHeight = void 0, barWidth = void 0; if (this.isHorizontal) { // height divided into equal parts yDivision = w.globals.gridHeight / w.globals.dataPoints; barHeight = yDivision; barHeight = barHeight * parseInt(w.config.plotOptions.bar.barHeight) / 100; zeroW = this.baseLineInvertedY + w.globals.padHorizontal; // initial y position is half of barHeight * half of number of Bars y = (yDivision - barHeight) / 2; } else { // width divided into equal parts xDivision = w.globals.gridWidth / w.globals.dataPoints; barWidth = xDivision; if (w.globals.isXNumeric) { xDivision = w.globals.gridWidth / (this.totalItems / w.globals.series.length); barWidth = xDivision / 1.8; } else { barWidth = barWidth * parseInt(w.config.plotOptions.bar.columnWidth) / 100; } zeroH = this.baseLineY[this.yaxisIndex] + 1; // initial x position is one third of barWidth x = w.globals.padHorizontal + (xDivision - barWidth) / 2; } return { x: x, y: y, yDivision: yDivision, xDivision: xDivision, barHeight: barHeight, barWidth: barWidth, zeroH: zeroH, zeroW: zeroW }; } }, { key: 'drawBarPaths', value: function drawBarPaths(_ref) { var indexes = _ref.indexes, barHeight = _ref.barHeight, strokeWidth = _ref.strokeWidth, pathTo = _ref.pathTo, pathFrom = _ref.pathFrom, zeroW = _ref.zeroW, x = _ref.x, y = _ref.y, yDivision = _ref.yDivision, elSeries = _ref.elSeries; var w = this.w; var barYPosition = y; var barXPosition = void 0; var i = indexes.i; var j = indexes.j; var realIndex = indexes.realIndex; var bc = indexes.bc; var prevBarW = 0; for (var k = 0; k < this.prevXF.length; k++) { prevBarW = prevBarW + this.prevXF[k][j]; } if (i > 0) { var bXP = zeroW; if (this.prevXVal[i - 1][j] < 0) { if (this.series[i][j] >= 0) { bXP = this.prevX[i - 1][j] + prevBarW; } else { bXP = this.prevX[i - 1][j]; } } else if (this.prevXVal[i - 1][j] >= 0) { if (this.series[i][j] >= 0) { bXP = this.prevX[i - 1][j]; } else { bXP = this.prevX[i - 1][j] - prevBarW; } } barXPosition = bXP; } else { // the first series will not have prevX values barXPosition = zeroW; } if (this.series[i][j] === null) { x = barXPosition; } else { x = barXPosition + this.series[i][j] / this.invertedYRatio; } var endingShapeOpts = { barHeight: barHeight, strokeWidth: strokeWidth, invertedYRatio: this.invertedYRatio, barYPosition: barYPosition, x: x }; var endingShape = this.bar.barEndingShape(w, endingShapeOpts, this.series, i, j); if (this.series.length > 1 && i !== this.endingShapeOnSeriesNumber) { // revert back to flat shape if not last series endingShape.path = this.graphics.line(endingShape.newX, barYPosition + barHeight - strokeWidth); } this.xArrj.push(endingShape.newX); this.xArrjF.push(Math.abs(barXPosition - endingShape.newX)); this.xArrjVal.push(this.series[i][j]); pathTo = this.graphics.move(barXPosition, barYPosition); pathFrom = this.graphics.move(barXPosition, barYPosition); if (w.globals.previousPaths.length > 0) { pathFrom = this.bar.getPathFrom(realIndex, j, false); } pathTo = pathTo + this.graphics.line(endingShape.newX, barYPosition) + endingShape.path + this.graphics.line(barXPosition, barYPosition + barHeight - strokeWidth) + this.graphics.line(barXPosition, barYPosition); pathFrom = pathFrom + this.graphics.line(barXPosition, barYPosition) + this.graphics.line(barXPosition, barYPosition + barHeight - strokeWidth) + this.graphics.line(barXPosition, barYPosition + barHeight - strokeWidth) + this.graphics.line(barXPosition, barYPosition + barHeight - strokeWidth) + this.graphics.line(barXPosition, barYPosition); if (w.config.plotOptions.bar.colors.backgroundBarColors.length > 0 && i === 0) { if (bc >= w.config.plotOptions.bar.colors.backgroundBarColors.length) { bc = 0; } var bcolor = w.config.plotOptions.bar.colors.backgroundBarColors[bc]; var rect = this.graphics.drawRect(0, barYPosition, w.globals.gridWidth, barHeight, 0, bcolor, w.config.plotOptions.bar.colors.backgroundBarOpacity); elSeries.add(rect); rect.node.classList.add('apexcharts-backgroundBar'); } y = y + yDivision; return { pathTo: pathTo, pathFrom: pathFrom, x: x, y: y }; } }, { key: 'drawColumnPaths', value: function drawColumnPaths(_ref2) { var indexes = _ref2.indexes, x = _ref2.x, y = _ref2.y, xDivision = _ref2.xDivision, pathTo = _ref2.pathTo, pathFrom = _ref2.pathFrom, barWidth = _ref2.barWidth, zeroH = _ref2.zeroH, strokeWidth = _ref2.strokeWidth, elSeries = _ref2.elSeries; var w = this.w; var i = indexes.i; var j = indexes.j; var realIndex = indexes.realIndex; var bc = indexes.bc; if (w.globals.isXNumeric) { var seriesVal = w.globals.seriesX[i][j]; if (!seriesVal) seriesVal = 0; x = (seriesVal - w.globals.minX) / this.xRatio - barWidth / 2; } var barXPosition = x; var barYPosition = void 0; var prevBarH = 0; for (var k = 0; k < this.prevYF.length; k++) { prevBarH = prevBarH + this.prevYF[k][j]; } if (i > 0) { var bYP = void 0; var prevYValue = this.prevY[i - 1][j]; if (this.prevYVal[i - 1][j] < 0) { if (this.series[i][j] >= 0) { bYP = prevYValue - prevBarH; } else { bYP = prevYValue; } } else { if (this.series[i][j] >= 0) { bYP = prevYValue; } else { bYP = prevYValue + prevBarH; } } barYPosition = bYP; } else { // the first series will not have prevY values barYPosition = w.globals.gridHeight - zeroH; } if (this.series[i][j] === null) { y = barYPosition - this.series[i][j] / this.yRatio[this.yaxisIndex]; } else { y = barYPosition - this.series[i][j] / this.yRatio[this.yaxisIndex]; } var endingShapeOpts = { barWidth: barWidth, strokeWidth: strokeWidth, yRatio: this.yRatio[this.yaxisIndex], barXPosition: barXPosition, y: y }; var endingShape = this.bar.barEndingShape(w, endingShapeOpts, this.series, i, j); if (this.series.length > 1 && i !== this.endingShapeOnSeriesNumber) { /* if(this.zeroSerieses) {} */ // revert back to flat shape if not last series endingShape.path = this.graphics.line(barXPosition + barWidth - strokeWidth, endingShape.newY); } this.yArrj.push(endingShape.newY); this.yArrjF.push(Math.abs(barYPosition - endingShape.newY)); this.yArrjVal.push(this.series[i][j]); pathTo = this.graphics.move(barXPosition, barYPosition); pathFrom = this.graphics.move(barXPosition, barYPosition); if (w.globals.previousPaths.length > 0) { pathFrom = this.bar.getPathFrom(realIndex, j, false); } pathTo = pathTo + this.graphics.line(barXPosition, endingShape.newY) + endingShape.path + this.graphics.line(barXPosition + barWidth - strokeWidth, barYPosition) + this.graphics.line(barXPosition, barYPosition); pathFrom = pathFrom + this.graphics.line(barXPosition, barYPosition) + this.graphics.line(barXPosition + barWidth - strokeWidth, barYPosition) + this.graphics.line(barXPosition + barWidth - strokeWidth, barYPosition) + this.graphics.line(barXPosition + barWidth - strokeWidth, barYPosition) + this.graphics.line(barXPosition, barYPosition); if (w.config.plotOptions.bar.colors.backgroundBarColors.length > 0 && i === 0) { if (bc >= w.config.plotOptions.bar.colors.backgroundBarColors.length) { bc = 0; } var bcolor = w.config.plotOptions.bar.colors.backgroundBarColors[bc]; var rect = this.graphics.drawRect(barXPosition, 0, barWidth, w.globals.gridHeight, 0, bcolor, w.config.plotOptions.bar.colors.backgroundBarOpacity); elSeries.add(rect); rect.node.classList.add('apexcharts-backgroundBar'); } x = x + xDivision; return { pathTo: pathTo, pathFrom: pathFrom, x: w.globals.isXNumeric ? x - xDivision : x, y: y }; } /* * When user clicks on legends, the collapsed series will be filled with [0,0,0,...,0] * We need to make sure, that the last series is not [0,0,0,...,0] * as we need to draw shapes on the last series (for stacked bars/columns only) * Hence, we are collecting all inner arrays in series which has [0,0,0...,0] **/ }, { key: 'checkZeroSeries', value: function checkZeroSeries(_ref3) { var series = _ref3.series; var w = this.w; for (var zs = 0; zs < series.length; zs++) { var total = 0; for (var zsj = 0; zsj < series[w.globals.maxValsInArrayIndex].length; zsj++) { total += series[zs][zsj]; } if (total === 0) { this.zeroSerieses.push(zs); } } // After getting all zeroserieses, we need to ensure whether endingshapeonSeries is not in that zeroseries array for (var s = series.length - 1; s >= 0; s--) { if (this.zeroSerieses.indexOf(s) > -1 && s === this.endingShapeOnSeriesNumber) { this.endingShapeOnSeriesNumber -= 1; } } } }]); return BarStacked; }(_Bar3.default); exports.default = BarStacked; /***/ }), /* 126 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Bar2 = __webpack_require__(44); var _Bar3 = _interopRequireDefault(_Bar2); var _Fill = __webpack_require__(13); var _Fill2 = _interopRequireDefault(_Fill); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * ApexCharts CandleStick Class responsible for drawing both Stacked Columns and Bars. * * @module CandleStick * The whole calculation for stacked bar/column is different from normal bar/column, * hence it makes sense to derive a new class for it extending most of the props of Parent Bar **/ var CandleStick = function (_Bar) { _inherits(CandleStick, _Bar); function CandleStick() { _classCallCheck(this, CandleStick); return _possibleConstructorReturn(this, (CandleStick.__proto__ || Object.getPrototypeOf(CandleStick)).apply(this, arguments)); } _createClass(CandleStick, [{ key: 'draw', value: function draw(series, seriesIndex) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var fill = new _Fill2.default(this.ctx); this.candlestickOptions = this.w.config.plotOptions.candlestick; this.initVariables(series); var ret = graphics.group({ class: 'apexcharts-candlestick-series apexcharts-plot-series' }); ret.attr('clip-path', 'url(#gridRectMask' + w.globals.cuid + ')'); for (var i = 0, bc = 0; i < series.length; i++, bc++) { var pathTo = void 0, pathFrom = void 0; var x = void 0, y = void 0, xDivision = void 0, // xDivision is the GRIDWIDTH divided by number of datapoints (columns) zeroH = void 0; // zeroH is the baseline where 0 meets y axis var yArrj = []; // hold y values of current iterating series var xArrj = []; // hold x values of current iterating series var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; // el to which series will be drawn var elSeries = graphics.group({ class: 'apexcharts-series ' + w.globals.seriesNames[realIndex].replace(/ /g, '-'), 'rel': i + 1, 'data:realIndex': realIndex }); if (series[i].length > 0) { this.visibleI = this.visibleI + 1; } var strokeWidth = 0; var barHeight = 0; var barWidth = 0; if (this.yRatio.length > 1) { this.yaxisIndex = realIndex; } var initPositions = this.initialPositions(); y = initPositions.y; barHeight = initPositions.barHeight; x = initPositions.x; barWidth = initPositions.barWidth; xDivision = initPositions.xDivision; zeroH = initPositions.zeroH; xArrj.push(x + barWidth / 2); // eldatalabels var elDataLabelsWrap = graphics.group({ class: 'apexcharts-datalabels' }); for (var j = 0, tj = w.globals.dataPoints; j < w.globals.dataPoints; j++, tj--) { if (typeof this.series[i][j] === 'undefined' || series[i][j] === null) { this.isNullValue = true; } else { this.isNullValue = false; } if (w.config.stroke.show) { if (this.isNullValue) { strokeWidth = 0; } else { strokeWidth = Array.isArray(this.strokeWidth) ? this.strokeWidth[realIndex] : this.strokeWidth; } } var color = void 0; var paths = this.drawCandleStickPaths({ indexes: { i: i, j: j, realIndex: realIndex, bc: bc }, x: x, y: y, xDivision: xDivision, pathTo: pathTo, pathFrom: pathFrom, barWidth: barWidth, zeroH: zeroH, strokeWidth: strokeWidth, elSeries: elSeries }); pathTo = paths.pathTo; pathFrom = paths.pathFrom; y = paths.y; x = paths.x; color = paths.color; // push current X if (j > 0) { xArrj.push(x + barWidth / 2); } yArrj.push(y); var pathFill = fill.fillPath(elSeries, { seriesNumber: realIndex, color: color }); var lineFill = this.candlestickOptions.wick.useFillColor ? color : undefined; elSeries = this.renderSeries({ realIndex: realIndex, pathFill: pathFill, lineFill: lineFill, j: j, i: i, pathFrom: pathFrom, pathTo: pathTo, strokeWidth: strokeWidth, elSeries: elSeries, x: x, y: y, series: series, barHeight: barHeight, barWidth: barWidth, elDataLabelsWrap: elDataLabelsWrap, visibleSeries: this.visibleI, type: 'candlestick' }); } // push all x val arrays into main xArr w.globals.seriesXvalues[realIndex] = xArrj; w.globals.seriesYvalues[realIndex] = yArrj; ret.add(elSeries); } return ret; } }, { key: 'drawCandleStickPaths', value: function drawCandleStickPaths(_ref) { var indexes = _ref.indexes, x = _ref.x, y = _ref.y, xDivision = _ref.xDivision, pathTo = _ref.pathTo, pathFrom = _ref.pathFrom, barWidth = _ref.barWidth, zeroH = _ref.zeroH, strokeWidth = _ref.strokeWidth; var w = this.w; var graphics = new _Graphics2.default(this.ctx); var i = indexes.i; var j = indexes.j; var isPositive = true; var colorPos = w.config.plotOptions.candlestick.colors.upward; var colorNeg = w.config.plotOptions.candlestick.colors.downward; var yRatio = this.yRatio[this.yaxisIndex]; var realIndex = indexes.realIndex; var ohlc = this.getOHLCValue(realIndex, j); var l1 = zeroH;var l2 = zeroH; if (ohlc.o > ohlc.c) { isPositive = false; } var y1 = Math.min(ohlc.o, ohlc.c); var y2 = Math.max(ohlc.o, ohlc.c); if (w.globals.isXNumeric) { x = (w.globals.seriesX[i][j] - w.globals.minX) / this.xRatio - barWidth / 2; } var barXPosition = x + barWidth * this.visibleI; pathTo = graphics.move(barXPosition, zeroH); pathFrom = graphics.move(barXPosition, zeroH); if (w.globals.previousPaths.length > 0) { pathFrom = this.getPathFrom(realIndex, j, true); } if (typeof this.series[i][j] === 'undefined' || this.series[i][j] === null) { y1 = zeroH; } else { y1 = zeroH - y1 / yRatio; y2 = zeroH - y2 / yRatio; l1 = zeroH - ohlc.h / yRatio; l2 = zeroH - ohlc.l / yRatio; } pathTo = graphics.move(barXPosition, y2) + graphics.line(barXPosition + barWidth / 2, y2) + graphics.line(barXPosition + barWidth / 2, l1) + graphics.line(barXPosition + barWidth / 2, y2) + graphics.line(barXPosition + barWidth, y2) + graphics.line(barXPosition + barWidth, y1) + graphics.line(barXPosition + barWidth / 2, y1) + graphics.line(barXPosition + barWidth / 2, l2) + graphics.line(barXPosition + barWidth / 2, y1) + graphics.line(barXPosition, y1) + graphics.line(barXPosition, y2 - strokeWidth / 2); if (!w.globals.isXNumeric) { x = x + xDivision; } return { pathTo: pathTo, pathFrom: pathFrom, x: x, y: y2, barXPosition: barXPosition, color: isPositive ? colorPos : colorNeg }; } }, { key: 'getOHLCValue', value: function getOHLCValue(i, j) { var w = this.w; return { o: w.globals.seriesCandleO[i][j], h: w.globals.seriesCandleH[i][j], l: w.globals.seriesCandleL[i][j], c: w.globals.seriesCandleC[i][j] }; } }]); return CandleStick; }(_Bar3.default); exports.default = CandleStick; /***/ }), /* 127 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _DataLabels = __webpack_require__(45); var _DataLabels2 = _interopRequireDefault(_DataLabels); var _Animations = __webpack_require__(25); var _Animations2 = _interopRequireDefault(_Animations); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); var _Filters = __webpack_require__(6); var _Filters2 = _interopRequireDefault(_Filters); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts HeatMap Class. * @module HeatMap **/ var HeatMap = function () { function HeatMap(ctx, xyRatios) { _classCallCheck(this, HeatMap); this.ctx = ctx; this.w = ctx.w; this.xRatio = xyRatios.xRatio; this.yRatio = xyRatios.yRatio; this.dynamicAnim = this.w.config.chart.animations.dynamicAnimation; this.rectRadius = this.w.config.plotOptions.heatmap.radius; this.strokeWidth = this.w.config.stroke.width; } _createClass(HeatMap, [{ key: 'draw', value: function draw(series) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var ret = graphics.group({ class: 'apexcharts-heatmap' }); ret.attr('clip-path', 'url(#gridRectMask' + w.globals.cuid + ')'); // width divided into equal parts var xDivision = w.globals.gridWidth / w.globals.dataPoints; var yDivision = w.globals.gridHeight / w.globals.series.length; var y1 = 0; for (var i = series.length - 1; i >= 0; i--) { // el to which series will be drawn var elSeries = graphics.group({ class: 'apexcharts-series apexcharts-heatmap-series ' + w.globals.seriesNames[i].replace(/ /g, '-'), 'rel': i + 1, 'data:realIndex': i }); if (w.config.chart.dropShadow.enabled) { var shadow = w.config.chart.dropShadow; var filters = new _Filters2.default(this.ctx); filters.dropShadow(elSeries, shadow); } var x1 = 0; for (var j = 0; j < series[i].length; j++) { var colorShadePercent = 1; var heatColorProps = this.determineHeatColor(i, j); if (w.globals.hasNegs) { var shadeIntensity = w.config.plotOptions.heatmap.shadeIntensity; if (heatColorProps.percent < 0) { colorShadePercent = 1 - (1 + heatColorProps.percent / 100) * shadeIntensity; } else { colorShadePercent = (1 - heatColorProps.percent / 100) * shadeIntensity; } } else { colorShadePercent = 1 - heatColorProps.percent / 100; } var color = heatColorProps.color; if (w.config.plotOptions.heatmap.enableShades) { var utils = new _Utils2.default(); color = _Utils2.default.hexToRgba(utils.shadeColor(colorShadePercent, heatColorProps.color), w.config.fill.opacity); } var radius = this.rectRadius; var rect = graphics.drawRect(x1, y1, xDivision, yDivision, radius); rect.attr({ cx: x1, cy: y1 }); rect.node.classList.add('apexcharts-heatmap-rect'); elSeries.add(rect); rect.attr({ fill: color, i: i, j: j, val: series[i][j], 'stroke-width': this.strokeWidth, stroke: w.globals.stroke.colors[0], color: color }); if (w.config.chart.animations.enabled && !w.globals.dataChanged) { var speed = 1; if (!w.globals.resized) { speed = w.config.chart.animations.speed; } this.animateHeatMap(rect, x1, y1, xDivision, yDivision, speed); } if (w.globals.dataChanged) { var _speed = 1; if (this.dynamicAnim.enabled) { _speed = this.dynamicAnim.speed; } var colorFrom = w.globals.previousPaths[i][j].color; this.animateHeatColor(rect, _Utils2.default.rgb2hex(colorFrom), _Utils2.default.rgb2hex(color), _speed); } var dataLabels = this.calculateHeatmapDataLabels({ x: x1, y: y1, i: i, j: j, series: series, rectHeight: yDivision, rectWidth: xDivision }); if (dataLabels !== null) { elSeries.add(dataLabels); } x1 = x1 + xDivision; } y1 = y1 + yDivision; ret.add(elSeries); } // adjust yaxis labels for heatmap w.globals.yAxisScale[0].result.push(''); var divisor = w.globals.gridHeight / w.globals.series.length; w.config.yaxis[0].labels.offsetY = -(divisor / 2); return ret; } }, { key: 'determineHeatColor', value: function determineHeatColor(i, j) { var w = this.w; var val = w.globals.series[i][j]; var color = w.globals.colors[i]; var min = Math.min.apply(Math, _toConsumableArray(w.globals.series[i])); var max = Math.max.apply(Math, _toConsumableArray(w.globals.series[i])); var total = Math.abs(max) + Math.abs(min); var percent = 100 * val / (total === 0 ? total - 0.000001 : total); if (w.config.plotOptions.heatmap.colorScale.ranges.length > 0) { var colorRange = w.config.plotOptions.heatmap.colorScale.ranges; colorRange.map(function (range, index) { if (val >= range.from && val <= range.to) { color = range.color; min = range.from; max = range.to; total = Math.abs(max) + Math.abs(min); percent = 100 * val / total; } }); } return { color: color, percent: percent }; } }, { key: 'calculateHeatmapDataLabels', value: function calculateHeatmapDataLabels(_ref) { var x = _ref.x, y = _ref.y, i = _ref.i, j = _ref.j, series = _ref.series, rectHeight = _ref.rectHeight, rectWidth = _ref.rectWidth; var w = this.w; // let graphics = new Graphics(this.ctx) var dataLabelsConfig = w.config.dataLabels; var graphics = new _Graphics2.default(this.ctx); var dataLabels = new _DataLabels2.default(this.ctx); var formatter = dataLabelsConfig.formatter; var elDataLabelsWrap = null; if (dataLabelsConfig.enabled) { elDataLabelsWrap = graphics.group({ class: 'apexcharts-data-labels' }); var offX = dataLabelsConfig.offsetX; var offY = dataLabelsConfig.offsetY; var dataLabelsX = x + rectWidth / 2 + offX; var dataLabelsY = y + rectHeight / 2 + parseInt(dataLabelsConfig.style.fontSize) / 3 + offY; var text = formatter(w.globals.series[i][j], { seriesIndex: i, dataPointIndex: j, globals: w.globals }); dataLabels.plotDataLabelsText(dataLabelsX, dataLabelsY, text, i, j, elDataLabelsWrap, dataLabelsConfig); } return elDataLabelsWrap; } }, { key: 'animateHeatMap', value: function animateHeatMap(el, x, y, width, height, speed) { var animations = new _Animations2.default(this.ctx); animations.animateRect(el, { x: x + width / 2, y: y + height / 2, width: 0, height: 0 }, { x: x, y: y, width: width, height: height }, speed); } }, { key: 'animateHeatColor', value: function animateHeatColor(el, colorFrom, colorTo, speed) { el.attr({ fill: colorFrom }).animate(speed).attr({ fill: colorTo }); } }]); return HeatMap; }(); module.exports = HeatMap; /***/ }), /* 128 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Fill = __webpack_require__(13); var _Fill2 = _interopRequireDefault(_Fill); var _DataLabels = __webpack_require__(45); var _DataLabels2 = _interopRequireDefault(_DataLabels); var _Markers = __webpack_require__(47); var _Markers2 = _interopRequireDefault(_Markers); var _Scatter = __webpack_require__(74); var _Scatter2 = _interopRequireDefault(_Scatter); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Line Class responsible for drawing Line / Area Charts. * This class is also responsible for generating values for Bubble/Scatter charts, so need to rename it to Axis Charts to avoid confusions * @module Line **/ var Line = function () { function Line(ctx, xyRatios) { _classCallCheck(this, Line); this.ctx = ctx; this.w = ctx.w; this.xyRatios = xyRatios; this.pointsChart = !(this.w.config.chart.type !== 'bubble' && this.w.config.chart.type !== 'scatter'); if (this.pointsChart) { this.scatter = new _Scatter2.default(this.ctx); } this.noNegatives = this.w.globals.minX === Number.MAX_VALUE; this.yaxisIndex = 0; } _createClass(Line, [{ key: 'draw', value: function draw(series, ptype, seriesIndex) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var fill = new _Fill2.default(this.ctx); var type = w.globals.comboCharts ? ptype : w.config.chart.type; var ret = graphics.group({ class: 'apexcharts-' + type + '-series apexcharts-plot-series', 'clip-path': 'url(#gridRectMask' + w.globals.cuid + ')' }); var yRatio = this.xyRatios.yRatio; var zRatio = this.xyRatios.zRatio; var xRatio = this.xyRatios.xRatio; var baseLineY = this.xyRatios.baseLineY; // push all series in an array, so we can draw in reverse order (for stacked charts) var allSeries = []; var prevSeriesY = []; var categoryAxisCorrection = 0; for (var i = 0; i < series.length; i++) { // width divided into equal parts var xDivision = w.globals.gridWidth / w.globals.dataPoints; var realIndex = w.globals.comboCharts ? seriesIndex[i] : i; if (yRatio.length > 1) { this.yaxisIndex = realIndex; } var yArrj = []; // hold y values of current iterating series var xArrj = []; // hold x values of current iterating series // zeroY is the 0 value in y series which can be used in negative charts var zeroY = w.globals.gridHeight - baseLineY[this.yaxisIndex]; var areaBottomY = zeroY; if (zeroY > w.globals.gridHeight) { areaBottomY = w.globals.gridHeight; } categoryAxisCorrection = xDivision / 2; var x = w.globals.padHorizontal + categoryAxisCorrection; var y = 1; if (w.globals.isXNumeric) { x = (w.globals.seriesX[realIndex][0] - w.globals.minX) / xRatio; } xArrj.push(x); var linePath = void 0, areaPath = void 0, pathFromLine = void 0, pathFromArea = void 0; var linePaths = []; var areaPaths = []; // el to which series will be drawn var elSeries = graphics.group({ class: 'apexcharts-series ' + w.globals.seriesNames[realIndex].replace(/ /g, '-') }); // points var elPointsMain = graphics.group({ class: 'apexcharts-series-markers-wrap' }); // eldatalabels var elDataLabelsWrap = graphics.group({ class: 'apexcharts-datalabels' }); this.ctx.series.addCollapsedClassToSeries(elSeries, realIndex); var longestSeries = series[i].length === w.globals.dataPoints; elSeries.attr({ 'data:longestSeries': longestSeries, 'rel': i + 1, 'data:realIndex': realIndex }); this.appendPathFrom = true; var pX = x; var pY = void 0; var prevX = pX; var prevY = zeroY; // w.globals.svgHeight; var lineYPosition = 0; // the first value in the current series is not null or undefined var firstPrevY = this.determineFirstPrevY({ i: i, series: series, yRatio: yRatio[this.yaxisIndex], zeroY: zeroY, prevY: prevY, prevSeriesY: prevSeriesY, lineYPosition: lineYPosition }); prevY = firstPrevY.prevY; yArrj.push(prevY); pY = prevY; if (series[i][0] === null) { // when the first value itself is null, we need to move the pointer to a location where a null value is not found for (var s = 0; s < series[i].length; s++) { if (series[i][s] !== null) { prevX = xDivision * s; prevY = zeroY - series[i][s] / yRatio[this.yaxisIndex]; linePath = graphics.move(prevX, prevY); areaPath = graphics.move(prevX, areaBottomY); break; } } } else { linePath = graphics.move(prevX, prevY); areaPath = graphics.move(prevX, areaBottomY) + graphics.line(prevX, prevY); } pathFromLine = graphics.move(-1, zeroY) + graphics.line(-1, zeroY); pathFromArea = graphics.move(-1, zeroY) + graphics.line(-1, zeroY); if (w.globals.previousPaths.length > 0) { var pathFrom = this.checkPreviousPaths({ pathFromLine: pathFromLine, pathFromArea: pathFromArea, realIndex: realIndex }); pathFromLine = pathFrom.pathFromLine; pathFromArea = pathFrom.pathFromArea; } for (var j = 0; j < w.globals.dataPoints - 1; j++) { if (w.globals.isXNumeric) { x = (w.globals.seriesX[realIndex][j + 1] - w.globals.minX) / xRatio; } else { x = x + xDivision; } if (w.config.chart.stacked) { if (i > 0 && w.globals.collapsedSeries.length < w.config.series.length - 1) { lineYPosition = prevSeriesY[i - 1][j + 1]; } else { // the first series will not have prevY values lineYPosition = zeroY; } if (typeof series[i][j + 1] === 'undefined' || series[i][j + 1] === null) { y = lineYPosition - w.globals.minYArr[realIndex] / yRatio[this.yaxisIndex]; } else { y = lineYPosition - series[i][j + 1] / yRatio[this.yaxisIndex]; } } else { if (typeof series[i][j + 1] === 'undefined' || series[i][j + 1] === null) { y = zeroY - w.globals.minYArr[realIndex] / yRatio[this.yaxisIndex]; } else { y = zeroY - series[i][j + 1] / yRatio[this.yaxisIndex]; } } // push current X xArrj.push(x); // push current Y that will be used as next series's bottom position yArrj.push(y); var calculatedPaths = this.createPaths({ series: series, i: i, j: j, x: x, y: y, xDivision: xDivision, pX: pX, pY: pY, areaBottomY: areaBottomY, linePath: linePath, areaPath: areaPath, linePaths: linePaths, areaPaths: areaPaths }); areaPaths = calculatedPaths.areaPaths; linePaths = calculatedPaths.linePaths; pX = calculatedPaths.pX; pY = calculatedPaths.pY; areaPath = calculatedPaths.areaPath; linePath = calculatedPaths.linePath; if (this.appendPathFrom) { pathFromLine = pathFromLine + graphics.line(x, zeroY); pathFromArea = pathFromArea + graphics.line(x, zeroY); } var pointsPos = this.calculatePoints({ series: series, x: x, y: y, realIndex: realIndex, i: i, j: j, prevY: prevY, categoryAxisCorrection: categoryAxisCorrection, xRatio: xRatio }); if (!this.pointsChart) { var markers = new _Markers2.default(this.ctx); elPointsMain.node.classList.add('hidden'); var elPointsWrap = markers.plotChartMarkers(pointsPos, realIndex, j + 1); if (elPointsWrap !== null) { elPointsMain.add(elPointsWrap); } } else { // scatter / bubble chart points creation this.scatter.draw(elSeries, j, { realIndex: realIndex, pointsPos: pointsPos, zRatio: zRatio, elParent: elPointsMain }); } var dataLabels = new _DataLabels2.default(this.ctx); var drawnLabels = dataLabels.drawDataLabel(pointsPos, realIndex, j + 1); if (drawnLabels !== null) { elDataLabelsWrap.add(drawnLabels); } } // push all current y values array to main PrevY Array prevSeriesY.push(yArrj); // push all x val arrays into main xArr w.globals.seriesXvalues[realIndex] = xArrj; w.globals.seriesYvalues[realIndex] = yArrj; // these elements will be shown after area path animation completes if (!this.pointsChart) { w.globals.delayedElements.push({ el: elPointsMain.node, index: realIndex }); } var defaultRenderedPathOptions = { i: i, realIndex: realIndex, animationDelay: i, initialSpeed: w.config.chart.animations.speed, dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed, className: 'apexcharts-' + type, id: 'apexcharts-' + type }; if (w.config.stroke.show && !this.pointsChart) { var lineFill = null; if (type === 'line') { // fillable lines only for lineChart lineFill = fill.fillPath(elSeries, { seriesNumber: realIndex, i: i }); } else { lineFill = w.globals.stroke.colors[realIndex]; } for (var p = 0; p < linePaths.length; p++) { var renderedPath = graphics.renderPaths(_extends({}, defaultRenderedPathOptions, { pathFrom: pathFromLine, pathTo: linePaths[p], stroke: lineFill, strokeWidth: Array.isArray(w.config.stroke.width) ? w.config.stroke.width[realIndex] : w.config.stroke.width, strokeLineCap: w.config.stroke.lineCap, fill: 'none' })); elSeries.add(renderedPath); } } // we have drawn the lines, now if it is area chart, we need to fill paths if (type === 'area') { var pathFill = fill.fillPath(elSeries, { seriesNumber: realIndex }); for (var _p = 0; _p < areaPaths.length; _p++) { var _renderedPath = graphics.renderPaths(_extends({}, defaultRenderedPathOptions, { pathFrom: pathFromArea, pathTo: areaPaths[_p], stroke: 'none', strokeWidth: 0, strokeLineCap: null, fill: pathFill })); elSeries.add(_renderedPath); } } elSeries.add(elPointsMain); elSeries.add(elDataLabelsWrap); allSeries.push(elSeries); } for (var _s = allSeries.length; _s > 0; _s--) { ret.add(allSeries[_s - 1]); } return ret; } }, { key: 'createPaths', value: function createPaths(_ref) { var series = _ref.series, i = _ref.i, j = _ref.j, x = _ref.x, y = _ref.y, pX = _ref.pX, pY = _ref.pY, xDivision = _ref.xDivision, areaBottomY = _ref.areaBottomY, linePath = _ref.linePath, areaPath = _ref.areaPath, linePaths = _ref.linePaths, areaPaths = _ref.areaPaths; var w = this.w; var graphics = new _Graphics2.default(this.ctx); // logic of smooth curve derived from chartist // CREDITS: https://gionkunz.github.io/chartist-js/ if (w.config.stroke.curve === 'smooth') { var length = (x - pX) * 0.35; if (w.globals.hasNullValues) { if (series[i][j] !== null) { if (series[i][j + 1] !== null) { linePath = graphics.move(pX, pY) + graphics.curve(pX + length, pY, x - length, y, x + 1, y); areaPath = graphics.move(pX + 1, pY) + graphics.curve(pX + length, pY, x - length, y, x + 1, y) + graphics.line(x, areaBottomY) + graphics.line(pX, areaBottomY) + 'z'; } else { linePath = graphics.move(pX, pY); areaPath = graphics.move(pX, pY) + 'z'; } } linePaths.push(linePath); areaPaths.push(areaPath); } else { linePath = linePath + graphics.curve(pX + length, pY, x - length, y, x, y); areaPath = areaPath + graphics.curve(pX + length, pY, x - length, y, x, y); } pX = x; pY = y; if (j === series[i].length - 2) { // last loop, close path areaPath = areaPath + graphics.curve(pX, areaBottomY, x, areaBottomY, x, areaBottomY) + 'z'; if (!w.globals.hasNullValues) { linePaths.push(linePath); areaPaths.push(areaPath); } } } else { if (series[i][j + 1] === null) { linePath = linePath + graphics.move(x, y); areaPath = areaPath + graphics.line(x - xDivision, areaBottomY) + graphics.move(x, y); } if (series[i][j] === null) { linePath = linePath + graphics.move(x, y); areaPath = areaPath + graphics.move(x, areaBottomY); } linePath = linePath + graphics.line(x, y); areaPath = areaPath + graphics.line(x, y); if (j === series[i].length - 2) { // last loop, close path areaPath = areaPath + graphics.line(x, areaBottomY) + 'z'; linePaths.push(linePath); areaPaths.push(areaPath); } } return { linePaths: linePaths, areaPaths: areaPaths, pX: pX, pY: pY, linePath: linePath, areaPath: areaPath }; } }, { key: 'calculatePoints', value: function calculatePoints(_ref2) { var series = _ref2.series, realIndex = _ref2.realIndex, x = _ref2.x, y = _ref2.y, i = _ref2.i, j = _ref2.j, prevY = _ref2.prevY, categoryAxisCorrection = _ref2.categoryAxisCorrection, xRatio = _ref2.xRatio; var w = this.w; var ptX = []; var ptY = []; if (j === 0) { var xPT1st = categoryAxisCorrection + w.config.markers.offsetX; // the first point for line series // we need to check whether it's not a time series, because a time series may // start from the middle of the x axis if (w.globals.isXNumeric) { xPT1st = (w.globals.seriesX[realIndex][0] - w.globals.minX) / xRatio + w.config.markers.offsetX; } // push 2 points for the first data values ptX.push(xPT1st); ptY.push(series[i][0] !== null ? prevY + w.config.markers.offsetY : null); ptX.push(x + w.config.markers.offsetX); ptY.push(series[i][j + 1] !== null ? y + w.config.markers.offsetY : null); } else { ptX.push(x + w.config.markers.offsetX); ptY.push(series[i][j + 1] !== null ? y + w.config.markers.offsetY : null); } var pointsPos = { x: ptX, y: ptY }; return pointsPos; } }, { key: 'checkPreviousPaths', value: function checkPreviousPaths(_ref3) { var pathFromLine = _ref3.pathFromLine, pathFromArea = _ref3.pathFromArea, realIndex = _ref3.realIndex; var w = this.w; for (var pp = 0; pp < w.globals.previousPaths.length; pp++) { var gpp = w.globals.previousPaths[pp]; if ((gpp.type === 'line' || gpp.type === 'area') && gpp.paths.length > 0 && parseInt(gpp.realIndex) === parseInt(realIndex)) { if (gpp.type === 'line') { this.appendPathFrom = false; pathFromLine = w.globals.previousPaths[pp].paths[0].d; } else if (gpp.type === 'area') { this.appendPathFrom = false; pathFromLine = w.globals.previousPaths[pp].paths[0].d; pathFromArea = w.globals.previousPaths[pp].paths[1].d; } } } return { pathFromLine: pathFromLine, pathFromArea: pathFromArea }; } }, { key: 'determineFirstPrevY', value: function determineFirstPrevY(_ref4) { var i = _ref4.i, series = _ref4.series, yRatio = _ref4.yRatio, zeroY = _ref4.zeroY, prevY = _ref4.prevY, prevSeriesY = _ref4.prevSeriesY, lineYPosition = _ref4.lineYPosition; var w = this.w; if (typeof series[i][0] !== 'undefined') { if (w.config.chart.stacked) { if (i > 0) { // 1st y value of previous series lineYPosition = prevSeriesY[i - 1][0]; } else { // the first series will not have prevY values lineYPosition = zeroY; } prevY = lineYPosition - series[i][0] / yRatio; } else { prevY = zeroY - series[i][0] / yRatio; } } else { // the first value in the current series is null if (w.config.chart.stacked && i > 0 && typeof series[i][0] === 'undefined') { // check for undefined value (undefined value will occur when we clear the series while user clicks on legend to hide serieses) for (var s = i - 1; s >= 0; s--) { // for loop to get to 1st previous value until we get it if (series[s][0] !== null && typeof series[s][0] !== 'undefined') { lineYPosition = prevSeriesY[s][0]; prevY = lineYPosition; break; } } } } return { prevY: prevY, lineYPosition: lineYPosition }; } }]); return Line; }(); exports.default = Line; /***/ }), /* 129 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Pie2 = __webpack_require__(73); var _Pie3 = _interopRequireDefault(_Pie2); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); var _Fill = __webpack_require__(13); var _Fill2 = _interopRequireDefault(_Fill); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Filters = __webpack_require__(6); var _Filters2 = _interopRequireDefault(_Filters); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * ApexCharts Radial Class for drawing Circle / Semi Circle Charts. * @module Radial **/ var Radial = function (_Pie) { _inherits(Radial, _Pie); function Radial(ctx) { _classCallCheck(this, Radial); var _this = _possibleConstructorReturn(this, (Radial.__proto__ || Object.getPrototypeOf(Radial)).call(this, ctx)); _this.ctx = ctx; _this.w = ctx.w; _this.animBeginArr = [0]; _this.animDur = 0; var w = _this.w; _this.startAngle = w.config.plotOptions.radialBar.startAngle; _this.endAngle = w.config.plotOptions.radialBar.endAngle; _this.trackStartAngle = w.config.plotOptions.radialBar.track.startAngle; _this.trackEndAngle = w.config.plotOptions.radialBar.track.endAngle; _this.radialDataLabels = w.config.plotOptions.radialBar.dataLabels; if (!_this.trackStartAngle) _this.trackStartAngle = _this.startAngle; if (!_this.trackEndAngle) _this.trackEndAngle = _this.endAngle; if (_this.endAngle === 360) _this.endAngle = 359.99; _this.fullAngle = 360 - w.config.plotOptions.radialBar.endAngle - w.config.plotOptions.radialBar.startAngle; _this.margin = parseInt(w.config.plotOptions.radialBar.track.margin); return _this; } _createClass(Radial, [{ key: 'draw', value: function draw(series) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var ret = graphics.group({ class: 'apexcharts-radialbar' }); var elSeries = graphics.group(); var centerY = this.defaultSize / 2; var centerX = w.globals.gridWidth / 2; var size = this.defaultSize / 2.05 - w.config.stroke.width - w.config.chart.dropShadow.blur; if (w.config.plotOptions.radialBar.size !== undefined) { size = w.config.plotOptions.radialBar.size; } var colorArr = w.globals.fill.colors; if (w.config.plotOptions.radialBar.track.show) { var elTracks = this.drawTracks({ size: size, centerX: centerX, centerY: centerY, colorArr: colorArr, series: series }); elSeries.add(elTracks); } var elG = this.drawArcs({ size: size, centerX: centerX, centerY: centerY, colorArr: colorArr, series: series }); elSeries.add(elG.g); if (w.config.plotOptions.radialBar.hollow.position === 'front') { elG.g.add(elG.elHollow); elG.g.add(elG.dataLabels); } ret.add(elSeries); return ret; } }, { key: 'drawTracks', value: function drawTracks(opts) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var g = graphics.group(); var filters = new _Filters2.default(this.ctx); var fill = new _Fill2.default(this.ctx); var strokeWidth = this.getStrokeWidth(opts); opts.size = opts.size - strokeWidth / 2; for (var i = 0; i < opts.series.length; i++) { var elRadialBarTrack = graphics.group({ class: 'apexcharts-radialbar-track apexcharts-track' }); g.add(elRadialBarTrack); elRadialBarTrack.attr({ id: 'apexcharts-track-' + i, 'rel': i + 1 }); opts.size = opts.size - strokeWidth - this.margin; var trackConfig = w.config.plotOptions.radialBar.track; var pathFill = fill.fillPath(elRadialBarTrack, { seriesNumber: 0, size: opts.size, fillColors: trackConfig.background, solid: true }); var startAngle = this.trackStartAngle; var endAngle = this.trackEndAngle; if (Math.abs(endAngle) + Math.abs(startAngle) >= 360) endAngle = 360 - Math.abs(this.startAngle) - 0.1; var elPath = graphics.drawPath({ d: '', stroke: pathFill, strokeWidth: strokeWidth * parseInt(trackConfig.strokeWidth) / 100, fill: 'none', strokeOpacity: trackConfig.opacity, classes: 'apexcharts-radialbar-area' }); if (trackConfig.dropShadow.enabled) { var shadow = trackConfig.dropShadow; filters.dropShadow(elPath, shadow); } elRadialBarTrack.add(elPath); elPath.attr('id', 'apexcharts-radialbarTrack-' + i); var pie = new _Pie3.default(this.ctx); pie.animatePaths(elPath, { centerX: opts.centerX, centerY: opts.centerY, endAngle: endAngle, startAngle: startAngle, size: opts.size, i: i, totalItems: 2, animBeginArr: 0, dur: 0, easing: w.globals.easing }); } return g; } }, { key: 'drawArcs', value: function drawArcs(opts) { var w = this.w; var self = this; // size, donutSize, centerX, centerY, colorArr, lineColorArr, sectorAngleArr, series var graphics = new _Graphics2.default(this.ctx); var fill = new _Fill2.default(this.ctx); var filters = new _Filters2.default(this.ctx); var g = graphics.group(); var strokeWidth = this.getStrokeWidth(opts); opts.size = opts.size - strokeWidth / 2; var hollowFillID = w.config.plotOptions.radialBar.hollow.background; var hollowSize = opts.size - strokeWidth * opts.series.length - this.margin * opts.series.length - strokeWidth * parseInt(w.config.plotOptions.radialBar.track.strokeWidth) / 100 / 2; var hollowRadius = hollowSize - w.config.plotOptions.radialBar.hollow.margin; if (w.config.plotOptions.radialBar.hollow.image !== undefined) { hollowFillID = this.drawHollowImage(opts, g, hollowSize, hollowFillID); } var elHollow = this.drawHollow({ size: hollowRadius, centerX: opts.centerX, centerY: opts.centerY, fill: hollowFillID }); if (w.config.plotOptions.radialBar.hollow.dropShadow.enabled) { var shadow = w.config.plotOptions.radialBar.hollow.dropShadow; filters.dropShadow(elHollow, shadow); } var shown = 1; if (this.radialDataLabels.showOn === 'hover' || w.globals.series.length > 1) { shown = 0; } var dataLabels = this.renderDataLabels({ hollowSize: hollowSize, centerX: opts.centerX, centerY: opts.centerY, opacity: shown }); if (w.config.plotOptions.radialBar.hollow.position === 'back') { g.add(elHollow); g.add(dataLabels); } var reverseLoop = false; if (w.config.plotOptions.radialBar.inverseOrder) { reverseLoop = true; } for (var i = reverseLoop ? opts.series.length - 1 : 0; reverseLoop ? i >= 0 : i < opts.series.length; reverseLoop ? i-- : i++) { var elRadialBarArc = graphics.group({ class: 'apexcharts-series apexcharts-radial-series ' + w.globals.seriesNames[i].replace(/ /g, '-') }); g.add(elRadialBarArc); elRadialBarArc.attr({ id: 'apexcharts-series-' + i, 'rel': i + 1 }); this.ctx.series.addCollapsedClassToSeries(elRadialBarArc, i); opts.size = opts.size - strokeWidth - this.margin; var pathFill = fill.fillPath(elRadialBarArc, { seriesNumber: i, size: opts.size }); var startAngle = this.startAngle; var prevStartAngle = void 0; var totalAngle = Math.abs(w.config.plotOptions.radialBar.endAngle - w.config.plotOptions.radialBar.startAngle); var endAngle = Math.round(totalAngle * _Utils2.default.negToZero(opts.series[i]) / 100) + this.startAngle; var prevEndAngle = void 0; if (w.globals.dataChanged) { prevStartAngle = this.startAngle; prevEndAngle = Math.round(totalAngle * _Utils2.default.negToZero(w.globals.previousPaths[i]) / 100) + prevStartAngle; } var currFullAngle = Math.abs(endAngle) + Math.abs(startAngle); if (currFullAngle >= 360) { endAngle = endAngle - 0.01; } var prevFullAngle = Math.abs(prevEndAngle) + Math.abs(prevStartAngle); if (prevFullAngle >= 360) { prevEndAngle = prevEndAngle - 0.01; } var angle = endAngle - startAngle; var elPath = graphics.drawPath({ d: '', stroke: pathFill, strokeWidth: strokeWidth, fill: 'none', fillOpacity: w.config.fill.opacity, classes: 'apexcharts-radialbar-area', strokeDashArray: w.config.stroke.dashArray }); _Graphics2.default.setAttrs(elPath.node, { 'data:angle': angle, 'data:value': opts.series[i] }); if (w.config.chart.dropShadow.enabled) { var _shadow = w.config.chart.dropShadow; filters.dropShadow(elPath, _shadow); } this.addListeners(elPath); elPath.node.addEventListener('mouseenter', self.dataLabelsMouseIn.bind(this, elPath.node)); elPath.node.addEventListener('mouseleave', self.dataLabelsMouseout.bind(this, elPath.node)); elRadialBarArc.add(elPath); elPath.attr('id', 'apexcharts-radialArc-' + i); var pie = new _Pie3.default(this.ctx); var dur = 0; if (pie.initialAnim && !w.globals.resized && !w.globals.dataChanged) { dur = (endAngle - startAngle) / 360 * w.config.chart.animations.speed; this.animDur = dur / (opts.series.length * 1.2) + this.animDur; this.animBeginArr.push(this.animDur); } if (w.globals.dataChanged) { dur = (endAngle - startAngle) / 360 * w.config.chart.animations.dynamicAnimation.speed; this.animDur = dur / (opts.series.length * 1.2) + this.animDur; this.animBeginArr.push(this.animDur); } pie.animatePaths(elPath, { centerX: opts.centerX, centerY: opts.centerY, endAngle: endAngle, startAngle: startAngle, prevEndAngle: prevEndAngle, prevStartAngle: prevStartAngle, size: opts.size, i: i, totalItems: 2, animBeginArr: this.animBeginArr, dur: dur, shouldSetPrevPaths: true, easing: w.globals.easing }); } return { g: g, elHollow: elHollow, dataLabels: dataLabels }; } }, { key: 'drawHollow', value: function drawHollow(opts) { var graphics = new _Graphics2.default(this.ctx); var circle = graphics.drawCircle(opts.size * 2); circle.attr({ class: 'apexcharts-radialbar-hollow', cx: opts.centerX, cy: opts.centerY, r: opts.size, fill: opts.fill }); return circle; } }, { key: 'drawHollowImage', value: function drawHollowImage(opts, g, hollowSize, hollowFillID) { var w = this.w; var fill = new _Fill2.default(this.ctx); var randID = (Math.random() + 1).toString(36).substring(4); var hollowFillImg = w.config.plotOptions.radialBar.hollow.image; if (w.config.plotOptions.radialBar.hollow.imageClipped) { fill.clippedImgArea({ width: hollowSize, height: hollowSize, image: hollowFillImg, patternID: 'pattern' + w.globals.cuid + randID }); hollowFillID = 'url(#pattern' + w.globals.cuid + randID + ')'; } else { var imgWidth = w.config.plotOptions.radialBar.hollow.imageWidth; var imgHeight = w.config.plotOptions.radialBar.hollow.imageHeight; if (imgWidth === undefined && imgHeight === undefined) { var image = w.globals.dom.Paper.image(hollowFillImg).loaded(function (loader) { this.move(opts.centerX - loader.width / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetX, opts.centerY - loader.height / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetY); }); g.add(image); } else { var _image = w.globals.dom.Paper.image(hollowFillImg).loaded(function (loader) { this.move(opts.centerX - imgWidth / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetX, opts.centerY - imgHeight / 2 + w.config.plotOptions.radialBar.hollow.imageOffsetY); this.size(imgWidth, imgHeight); }); g.add(_image); } } return hollowFillID; } }, { key: 'dataLabelsMouseIn', value: function dataLabelsMouseIn(el) { var w = this.w; var val = el.getAttribute('data:value'); var labelColor = void 0; var name = w.globals.seriesNames[parseInt(el.parentNode.getAttribute('rel')) - 1]; var elLabel = w.globals.dom.baseEl.querySelector('.apexcharts-datalabel-label'); var elValue = w.globals.dom.baseEl.querySelector('.apexcharts-datalabel-value'); var lbFormatter = this.radialDataLabels.value.formatter; val = lbFormatter(val); if (elLabel !== null) { elLabel.textContent = name; } if (elValue !== null) { elValue.textContent = val; } if (this.radialDataLabels.name.color === undefined) { labelColor = w.globals.colors[parseInt(el.parentNode.getAttribute('rel')) - 1]; } else { labelColor = this.radialDataLabels.name.color; } var dataLabelsGroup = w.globals.dom.baseEl.querySelector('.apexcharts-datalabels-group'); if (dataLabelsGroup !== null) { dataLabelsGroup.style.opacity = 1; } if (elLabel !== null) { elLabel.style.fill = labelColor; } } }, { key: 'dataLabelsMouseout', value: function dataLabelsMouseout(el) { var w = this.w; var dataLabelsGroup = w.globals.dom.baseEl.querySelector('.apexcharts-datalabels-group'); if (this.radialDataLabels.showOn !== 'always' || w.globals.series.length > 1) { if (dataLabelsGroup !== null) { dataLabelsGroup.style.opacity = 0; } } } }, { key: 'getStrokeWidth', value: function getStrokeWidth(opts) { var w = this.w; return opts.size * (100 - parseInt(w.config.plotOptions.radialBar.hollow.size)) / 100 / (opts.series.length + 1) - this.margin; } }, { key: 'renderDataLabels', value: function renderDataLabels(opts) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var g = graphics.group({ class: 'apexcharts-datalabels-group' }); g.node.style.opacity = opts.opacity; var x = opts.centerX; var y = opts.centerY; var labelColor = void 0, valueColor = void 0; if (this.radialDataLabels.name.color === undefined) { labelColor = w.globals.colors[0]; } else { labelColor = this.radialDataLabels.name.color; } if (this.radialDataLabels.value.color === undefined) { valueColor = w.config.chart.foreColor; } else { valueColor = this.radialDataLabels.value.color; } var lbFormatter = this.radialDataLabels.value.formatter; var val = lbFormatter(w.globals.series[0]); if (this.radialDataLabels.name.show) { var elLabel = graphics.drawText({ x: x, y: y + parseInt(this.radialDataLabels.name.offsetY), text: w.globals.seriesNames[0], textAnchor: 'middle', foreColor: labelColor, fontSize: this.radialDataLabels.name.fontSize, fontFamily: this.radialDataLabels.name.fontFamily }); elLabel.node.classList.add('apexcharts-datalabel-label'); g.add(elLabel); } if (this.radialDataLabels.value.show) { var valOffset = this.radialDataLabels.name.show ? parseInt(this.radialDataLabels.value.offsetY) + 16 : this.radialDataLabels.value.offsetY; var elValue = graphics.drawText({ x: x, y: y + valOffset, text: val, textAnchor: 'middle', foreColor: valueColor, fontSize: this.radialDataLabels.value.fontSize, fontFamily: this.radialDataLabels.value.fontFamily }); elValue.node.classList.add('apexcharts-datalabel-value'); g.add(elValue); } return g; } }]); return Radial; }(_Pie3.default); exports.default = Radial; /***/ }), /* 130 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Options = __webpack_require__(51); var _Options2 = _interopRequireDefault(_Options); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Annotations Class for drawing lines/rects on both xaxis and yaxis. * * @module Annotations **/ var Annotations = function () { function Annotations(ctx) { _classCallCheck(this, Annotations); this.ctx = ctx; this.w = ctx.w; this.graphics = new _Graphics2.default(this.ctx); this.xDivision = this.w.globals.gridWidth / this.w.globals.dataPoints; } _createClass(Annotations, [{ key: 'drawAnnotations', value: function drawAnnotations() { var w = this.w; if (w.globals.axisCharts) { var yAnnotations = this.drawYAxisAnnotations(); var xAnnotations = this.drawXAxisAnnotations(); var pointAnnotations = this.drawPointAnnotations(); var annoArray = [yAnnotations, xAnnotations, pointAnnotations]; var annoElArray = [xAnnotations.node, yAnnotations.node, pointAnnotations.node]; for (var i = 0; i < 3; i++) { w.globals.dom.elGraphical.add(annoArray[i]); annoElArray[i].classList.add('hidden'); w.globals.delayedElements.push({ el: annoElArray[i], index: 0 }); } // after placing the annotations on svg, set any vertically placed annotations this.setOrientations(w.config.annotations.xaxis); // background sizes needs to be calculated after text is drawn, so calling them last this.annotationsBackground(); } } }, { key: 'addXaxisAnnotation', value: function addXaxisAnnotation(anno, parent, index) { var w = this.w; var strokeDashArray = anno.strokeDashArray; var x1 = (anno.x - w.globals.minX) / (w.globals.xRange / w.globals.gridWidth); var line = this.graphics.drawLine(x1 + anno.offsetX, 0 + anno.offsetY, x1 + anno.offsetX, w.globals.gridHeight + anno.offsetY, anno.borderColor, strokeDashArray); parent.appendChild(line.node); var textY = anno.label.position === 'top' ? -3 : w.globals.gridHeight; var text = anno.label.text ? anno.label.text : ''; var elText = this.graphics.drawText({ x: x1 + anno.label.offsetX, y: textY + anno.label.offsetY, text: text, textAnchor: anno.label.textAnchor, fontSize: anno.label.style.fontSize, fontFamily: anno.label.style.fontFamily, foreColor: anno.label.style.color, cssClass: 'apexcharts-xaxis-annotation-label ' + anno.label.style.cssClass }); elText.attr({ rel: index }); parent.appendChild(elText.node); } }, { key: 'drawXAxisAnnotations', value: function drawXAxisAnnotations() { var _this = this; var w = this.w; var elg = this.graphics.group({ class: 'apexcharts-xaxis-annotations' }); w.config.annotations.xaxis.map(function (anno, index) { _this.addXaxisAnnotation(anno, elg.node, index); }); return elg; } }, { key: 'addYaxisAnnotation', value: function addYaxisAnnotation(anno, parent, index) { var w = this.w; var strokeDashArray = anno.strokeDashArray; var y1 = w.globals.gridHeight - (anno.y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight); var text = anno.label.text ? anno.label.text : ''; var line = this.graphics.drawLine(0 + anno.offsetX, y1 + anno.offsetY, w.globals.gridWidth + anno.offsetX, y1 + anno.offsetY, anno.borderColor, strokeDashArray); parent.appendChild(line.node); var textX = anno.label.position === 'right' ? w.globals.gridWidth : 0; var elText = this.graphics.drawText({ x: textX + anno.label.offsetX, y: y1 + anno.label.offsetY - 3, text: text, textAnchor: anno.label.textAnchor, fontSize: anno.label.style.fontSize, fontFamily: anno.label.style.fontFamily, foreColor: anno.label.style.color, cssClass: 'apexcharts-yaxis-annotation-label ' + anno.label.style.cssClass }); elText.attr({ rel: index }); parent.appendChild(elText.node); } }, { key: 'drawYAxisAnnotations', value: function drawYAxisAnnotations() { var _this2 = this; var w = this.w; var elg = this.graphics.group({ class: 'apexcharts-yaxis-annotations' }); w.config.annotations.yaxis.map(function (anno, index) { _this2.addYaxisAnnotation(anno, elg.node, index); }); return elg; } }, { key: 'addPointAnnotation', value: function addPointAnnotation(anno, parent, index) { var w = this.w; var x = 0; var y = 0; var pointY = 0; if (typeof anno.x === 'string') { if (w.config.chart.type === 'bar' && w.config.plotOptions.bar.horizontal) { // todo } var catIndex = w.globals.labels.indexOf(anno.x); var xLabel = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-texts-g text:nth-child(' + (catIndex + 1) + ')'); var xPos = parseInt(xLabel.getAttribute('x')); x = xPos; var annoY = anno.y; if (anno.y === null) { annoY = w.globals.series[anno.seriesIndex][catIndex]; } y = w.globals.gridHeight - (annoY - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight) - parseInt(anno.label.style.fontSize) - anno.marker.size; pointY = w.globals.gridHeight - (annoY - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight); } else { x = (anno.x - w.globals.minX) / (w.globals.xRange / w.globals.gridWidth); y = w.globals.gridHeight - (parseInt(anno.y) - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight) - parseInt(anno.label.style.fontSize) - anno.marker.size; pointY = w.globals.gridHeight - (anno.y - w.globals.minYArr[anno.yAxisIndex]) / (w.globals.yRange[anno.yAxisIndex] / w.globals.gridHeight); } var optsPoints = { pSize: anno.marker.size, pWidth: anno.marker.strokeWidth, pointFillColor: anno.marker.fillColor, pointStrokeColor: anno.marker.strokeColor, shape: anno.marker.shape, radius: anno.marker.radius }; var point = this.graphics.drawMarker(x, pointY, optsPoints); parent.appendChild(point.node); var text = anno.label.text ? anno.label.text : ''; var elText = this.graphics.drawText({ x: x + anno.label.offsetX, y: y + anno.label.offsetY, text: text, textAnchor: anno.label.textAnchor, fontSize: anno.label.style.fontSize, fontFamily: anno.label.style.fontFamily, foreColor: anno.label.style.color, cssClass: 'apexcharts-point-annotation-label ' + anno.label.style.cssClass }); elText.attr({ rel: index }); parent.appendChild(elText.node); } }, { key: 'drawPointAnnotations', value: function drawPointAnnotations() { var _this3 = this; var w = this.w; var elg = this.graphics.group({ class: 'apexcharts-point-annotations' }); w.config.annotations.points.map(function (anno, index) { _this3.addPointAnnotation(anno, elg.node, index); }); return elg; } }, { key: 'setOrientations', value: function setOrientations(annos) { var _this4 = this; var annoIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var w = this.w; annos.map(function (anno, index) { if (anno.label.orientation === 'vertical') { var i = annoIndex !== null ? annoIndex : index; var xAnno = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-annotations .apexcharts-xaxis-annotation-label[rel=\'' + i + '\']'); if (xAnno !== null) { var xAnnoCoord = xAnno.getBoundingClientRect(); xAnno.setAttribute('x', parseInt(xAnno.getAttribute('x')) - xAnnoCoord.height + 4); if (anno.label.position === 'top') { xAnno.setAttribute('y', parseInt(xAnno.getAttribute('y')) + xAnnoCoord.width); } else { xAnno.setAttribute('y', parseInt(xAnno.getAttribute('y')) - xAnnoCoord.width); } var annoRotatingCenter = _this4.graphics.rotateAroundCenter(xAnno); var x = annoRotatingCenter.x; var y = annoRotatingCenter.y; xAnno.setAttribute('transform', 'rotate(-90 ' + x + ' ' + y + ')'); } } }); } }, { key: 'addBackgroundToAnno', value: function addBackgroundToAnno(annoEl, anno) { var w = this.w; var elGridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid').getBoundingClientRect(); var coords = annoEl.getBoundingClientRect(); var pleft = anno.label.style.padding.left; var pright = anno.label.style.padding.right; var ptop = anno.label.style.padding.top; var pbottom = anno.label.style.padding.bottom; if (anno.label.orientation === 'vertical') { ptop = anno.label.style.padding.left; pbottom = anno.label.style.padding.right; pleft = anno.label.style.padding.top; pright = anno.label.style.padding.bottom; } var x1 = coords.left - elGridRect.left - pleft; var y1 = coords.top - elGridRect.top - ptop; var elRect = this.graphics.drawRect(x1, y1, coords.width + pleft + pright, coords.height + ptop + pbottom, 0, anno.label.style.background, 1, anno.label.borderWidth, anno.label.borderColor, 0); return elRect; } }, { key: 'annotationsBackground', value: function annotationsBackground() { var _this5 = this; var w = this.w; var add = function add(anno, i, type) { var annoLabel = w.globals.dom.baseEl.querySelector('.apexcharts-' + type + '-annotations .apexcharts-' + type + '-annotation-label[rel=\'' + i + '\']'); var parent = annoLabel.parentNode; var elRect = _this5.addBackgroundToAnno(annoLabel, anno); parent.insertBefore(elRect.node, annoLabel); }; w.config.annotations.xaxis.map(function (anno, i) { add(anno, i, 'xaxis'); }); w.config.annotations.yaxis.map(function (anno, i) { add(anno, i, 'yaxis'); }); w.config.annotations.points.map(function (anno, i) { add(anno, i, 'point'); }); } }, { key: 'addText', value: function addText(params, pushToMemory, context) { var x = params.x, y = params.y, text = params.text, textAnchor = params.textAnchor, _params$appendTo = params.appendTo, appendTo = _params$appendTo === undefined ? '.apexcharts-inner' : _params$appendTo, foreColor = params.foreColor, fontSize = params.fontSize, fontFamily = params.fontFamily, cssClass = params.cssClass, backgroundColor = params.backgroundColor, borderWidth = params.borderWidth, strokeDashArray = params.strokeDashArray, radius = params.radius, borderColor = params.borderColor, _params$paddingLeft = params.paddingLeft, paddingLeft = _params$paddingLeft === undefined ? 4 : _params$paddingLeft, _params$paddingRight = params.paddingRight, paddingRight = _params$paddingRight === undefined ? 4 : _params$paddingRight, _params$paddingBottom = params.paddingBottom, paddingBottom = _params$paddingBottom === undefined ? 2 : _params$paddingBottom, _params$paddingTop = params.paddingTop, paddingTop = _params$paddingTop === undefined ? 2 : _params$paddingTop; var me = context; var w = me.w; var parentNode = w.globals.dom.baseEl.querySelector(appendTo); var elText = this.graphics.drawText({ x: x, y: y, text: text, textAnchor: textAnchor || 'start', fontSize: fontSize || '12px', fontFamily: fontFamily || 'Arial', foreColor: foreColor || w.config.chart.foreColor, cssClass: true ? cssClass : '' }); parentNode.appendChild(elText.node); var textRect = elText.bbox(); var elRect = this.graphics.drawRect(textRect.x - paddingLeft, textRect.y - paddingTop, textRect.width + paddingLeft + paddingRight, textRect.height + paddingBottom + paddingTop, radius, backgroundColor, 1, borderWidth, borderColor, strokeDashArray); elText.before(elRect); if (pushToMemory) { w.globals.memory.methodsToExec.push({ context: me, method: me.addText, params: { x: x, y: y, text: text, textAnchor: textAnchor, appendTo: appendTo, foreColor: foreColor, fontSize: fontSize, cssClass: cssClass, backgroundColor: backgroundColor, borderWidth: borderWidth, strokeDashArray: strokeDashArray, radius: radius, borderColor: borderColor, paddingLeft: paddingLeft, paddingRight: paddingRight, paddingBottom: paddingBottom, paddingTop: paddingTop } }); } return context; } }, { key: 'addPointAnnotationExternal', value: function addPointAnnotationExternal(params, pushToMemory, context) { this.addAnnotationExternal({ params: params, pushToMemory: pushToMemory, context: context, type: 'point', contextMethod: context.addPointAnnotation }); return context; } }, { key: 'addYaxisAnnotationExternal', value: function addYaxisAnnotationExternal(params, pushToMemory, context) { this.addAnnotationExternal({ params: params, pushToMemory: pushToMemory, context: context, type: 'yaxis', contextMethod: context.addYaxisAnnotation }); return context; } // The addXaxisAnnotation method requires a parent class, and user calling this method externally on the chart instance may not specify parent, hence a different method }, { key: 'addXaxisAnnotationExternal', value: function addXaxisAnnotationExternal(params, pushToMemory, context) { this.addAnnotationExternal({ params: params, pushToMemory: pushToMemory, context: context, type: 'xaxis', contextMethod: context.addXaxisAnnotation }); return context; } }, { key: 'addAnnotationExternal', value: function addAnnotationExternal(_ref) { var params = _ref.params, pushToMemory = _ref.pushToMemory, context = _ref.context, type = _ref.type, contextMethod = _ref.contextMethod; var me = context; var w = me.w; var parent = w.globals.dom.baseEl.querySelector('.apexcharts-' + type + '-annotations'); var index = parent.childNodes.length + 1; var opt = new _Options2.default(); var axesAnno = Object.assign({}, type === 'xaxis' ? opt.xAxisAnnotation : type === 'yaxis' ? opt.yAxisAnnotation : opt.pointAnnotation); var anno = _Utils2.default.extend(axesAnno, params); switch (type) { case 'xaxis': this.addXaxisAnnotation(anno, parent, index); break; case 'yaxis': this.addYaxisAnnotation(anno, parent, index); break; case 'point': this.addPointAnnotation(anno, parent, index); break; } // add background var axesAnnoLabel = w.globals.dom.baseEl.querySelector('.apexcharts-' + type + '-annotations .apexcharts-' + type + '-annotation-label[rel=\'' + index + '\']'); var elRect = this.addBackgroundToAnno(axesAnnoLabel, anno); parent.insertBefore(elRect.node, axesAnnoLabel); if (pushToMemory) { w.globals.memory.methodsToExec.push({ context: me, method: contextMethod, params: params }); } return context; } }]); return Annotations; }(); module.exports = Annotations; /***/ }), /* 131 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Config = __webpack_require__(50); var _Config2 = _interopRequireDefault(_Config); var _Globals = __webpack_require__(142); var _Globals2 = _interopRequireDefault(_Globals); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Base Class for extending user options with pre-defined ApexCharts config. * * @module Base **/ var Base = function () { function Base(opts) { _classCallCheck(this, Base); this.opts = opts; } _createClass(Base, [{ key: 'init', value: function init() { var config = new _Config2.default(this.opts).init(); var globals = new _Globals2.default().init(config); var w = { config: config, globals: globals }; return w; } }]); return Base; }(); module.exports = Base; /***/ }), /* 132 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Bar = __webpack_require__(44); var _Bar2 = _interopRequireDefault(_Bar); var _BarStacked = __webpack_require__(125); var _BarStacked2 = _interopRequireDefault(_BarStacked); var _CandleStick = __webpack_require__(126); var _CandleStick2 = _interopRequireDefault(_CandleStick); var _CoreUtils = __webpack_require__(75); var _CoreUtils2 = _interopRequireDefault(_CoreUtils); var _Crosshairs = __webpack_require__(76); var _Crosshairs2 = _interopRequireDefault(_Crosshairs); var _DateTime = __webpack_require__(52); var _DateTime2 = _interopRequireDefault(_DateTime); var _HeatMap = __webpack_require__(127); var _HeatMap2 = _interopRequireDefault(_HeatMap); var _Pie = __webpack_require__(73); var _Pie2 = _interopRequireDefault(_Pie); var _Radial = __webpack_require__(129); var _Radial2 = _interopRequireDefault(_Radial); var _Line = __webpack_require__(128); var _Line2 = _interopRequireDefault(_Line); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Grid = __webpack_require__(140); var _Grid2 = _interopRequireDefault(_Grid); var _XAxis = __webpack_require__(48); var _XAxis2 = _interopRequireDefault(_XAxis); var _YAxis = __webpack_require__(49); var _YAxis2 = _interopRequireDefault(_YAxis); var _Range = __webpack_require__(135); var _Range2 = _interopRequireDefault(_Range); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); var _Series = __webpack_require__(26); var _Series2 = _interopRequireDefault(_Series); var _TimeScale = __webpack_require__(77); var _TimeScale2 = _interopRequireDefault(_TimeScale); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Core Class responsible for major calculations and creating elements. * * @module Core **/ var Core = function () { function Core(el, ctx) { _classCallCheck(this, Core); this.ctx = ctx; this.w = ctx.w; this.el = el; this.coreUtils = new _CoreUtils2.default(this.ctx); this.twoDSeries = []; this.threeDSeries = []; this.twoDSeriesX = []; } // get data and store into appropriate vars _createClass(Core, [{ key: 'setupElements', value: function setupElements() { var gl = this.w.globals; var cnf = this.w.config; var graphics = new _Graphics2.default(this.ctx); var ct = cnf.chart.type; var axisChartsArrTypes = ['line', 'area', 'bar', 'candlestick', 'scatter', 'bubble', 'heatmap']; var xyChartsArrTypes = ['line', 'area', 'bar', 'candlestick', 'scatter', 'bubble']; gl.axisCharts = axisChartsArrTypes.indexOf(ct) > -1; gl.xyCharts = xyChartsArrTypes.indexOf(ct) > -1; gl.chartClass = '.apexcharts' + gl.cuid; gl.dom.baseEl = this.el; gl.dom.elWrap = document.createElement('div'); _Graphics2.default.setAttrs(gl.dom.elWrap, { id: gl.chartClass.substring(1), class: 'apexcharts-canvas ' + gl.chartClass.substring(1) }); this.el.appendChild(gl.dom.elWrap); gl.dom.Paper = new window.SVG.Doc(gl.dom.elWrap); gl.dom.Paper.attr({ class: 'apexcharts-svg', 'xmlns:data': 'ApexChartsNS', transform: 'translate(' + cnf.chart.offsetX + ', ' + cnf.chart.offsetY + ')' }); gl.dom.Paper.node.style.background = cnf.chart.background; this.setSVGDimensions(); gl.dom.elGraphical = gl.dom.Paper.group().attr({ class: 'apexcharts-inner apexcharts-graphical' }); gl.dom.elDefs = gl.dom.Paper.defs(); // this element is required for hovering over virtual rect to determine x/y position in line and area charts. let's call this element hovering rect gl.dom.elLegendWrap = graphics.group({ class: 'apexcharts-legend' }); gl.dom.Paper.add(gl.dom.elLegendWrap); gl.dom.Paper.add(gl.dom.elGraphical); gl.dom.elGraphical.add(gl.dom.elDefs); } }, { key: 'plotChartType', value: function plotChartType(ser, xyRatios) { var w = this.w; var cnf = w.config; var gl = w.globals; var lineSeries = { series: [], i: [] }; var areaSeries = { series: [], i: [] }; var columnSeries = { series: [], i: [] }; var candlestickSeries = { series: [], i: [] }; gl.series.map(function (series, st) { // if user has specified a particular type for particular series if (typeof ser[st].type !== 'undefined') { if (ser[st].type === 'column' || ser[st].type === 'bar') { w.config.plotOptions.bar.horizontal = false; // bar not supported in mixed charts columnSeries.series.push(series); columnSeries.i.push(st); } else if (ser[st].type === 'area') { areaSeries.series.push(series); areaSeries.i.push(st); } else if (ser[st].type === 'line') { lineSeries.series.push(series); lineSeries.i.push(st); } else if (ser[st].type === 'candlestick') { candlestickSeries.series.push(series); candlestickSeries.i.push(st); } else { // user has specified type, but it is not valid (other than line/area/column) throw new Error('You have specified an unrecognized chart type. Available types for this propery are line/area/column/bar'); } gl.comboCharts = true; } else { lineSeries.series.push(series); lineSeries.i.push(st); } }); var line = new _Line2.default(this.ctx, xyRatios); var candlestick = new _CandleStick2.default(this.ctx, xyRatios); var pie = new _Pie2.default(this.ctx); var radialBar = new _Radial2.default(this.ctx); var elGraph = []; if (gl.comboCharts) { if (areaSeries.series.length > 0) { elGraph.push(line.draw(areaSeries.series, 'area', areaSeries.i)); } if (columnSeries.series.length > 0) { var bar = new _Bar2.default(this.ctx, xyRatios); elGraph.push(bar.draw(columnSeries.series, columnSeries.i)); } if (lineSeries.series.length > 0) { elGraph.push(line.draw(lineSeries.series, 'line', lineSeries.i)); } if (candlestickSeries.series.length > 0) { elGraph.push(candlestick.draw(candlestickSeries.series, candlestickSeries.i)); } } else { switch (cnf.chart.type) { case 'line': elGraph = line.draw(gl.series, 'line'); break; case 'area': elGraph = line.draw(gl.series, 'area'); break; case 'bar': if (cnf.chart.stacked) { var barStacked = new _BarStacked2.default(this.ctx, xyRatios); elGraph = barStacked.draw(gl.series); } else { var _bar = new _Bar2.default(this.ctx, xyRatios); elGraph = _bar.draw(gl.series); } break; case 'candlestick': var candleStick = new _CandleStick2.default(this.ctx, xyRatios); elGraph = candleStick.draw(gl.series); break; case 'heatmap': var heatmap = new _HeatMap2.default(this.ctx, xyRatios); elGraph = heatmap.draw(gl.series); break; case 'pie': case 'donut': elGraph = pie.draw(gl.series); break; case 'radialBar': elGraph = radialBar.draw(gl.series); break; default: elGraph = line.draw(gl.series); } } return elGraph; } }, { key: 'setSVGDimensions', value: function setSVGDimensions() { var gl = this.w.globals; var cnf = this.w.config; gl.svgWidth = cnf.chart.width; gl.svgHeight = cnf.chart.height; var elDim = _Utils2.default.getDimensions(this.el); var widthUnit = cnf.chart.width.toString().split(/[0-9]+/g).pop(); if (widthUnit === '%') { gl.svgWidth = elDim[0] * parseInt(cnf.chart.width) / 100; } else if (widthUnit === 'px' || widthUnit === '') { gl.svgWidth = parseInt(cnf.chart.width); } if (gl.svgHeight !== 'auto' && gl.svgHeight !== '') { var heightUnit = cnf.chart.height.toString().split(/[0-9]+/g).pop(); if (heightUnit === '%') { var elParentDim = _Utils2.default.getDimensions(this.el.parentNode); gl.svgHeight = elParentDim[1] * parseInt(cnf.chart.height) / 100; } else { gl.svgHeight = parseInt(cnf.chart.height); } } else { if (gl.axisCharts) { gl.svgHeight = gl.svgWidth / 1.61; } else { gl.svgHeight = gl.svgWidth; } } _Graphics2.default.setAttrs(gl.dom.Paper.node, { width: gl.svgWidth, height: gl.svgHeight }); // gl.dom.Paper.node.parentNode.parentNode.style.minWidth = gl.svgWidth + "px"; var offsetY = cnf.chart.sparkline.enabled ? 0 : 14; gl.dom.Paper.node.parentNode.parentNode.style.minHeight = gl.svgHeight + offsetY + 'px'; gl.dom.elWrap.style.width = gl.svgWidth + 'px'; gl.dom.elWrap.style.height = gl.svgHeight + 'px'; } }, { key: 'shiftGraphPosition', value: function shiftGraphPosition() { var gl = this.w.globals; var tY = gl.translateY; var tX = gl.translateX; var scalingAttrs = { transform: 'translate(' + tX + ', ' + tY + ')' }; _Graphics2.default.setAttrs(gl.dom.elGraphical.node, scalingAttrs); } /* ** All the calculations for setting range in charts will be done here */ }, { key: 'coreCalculations', value: function coreCalculations() { var range = new _Range2.default(this.ctx); range.init(); } }, { key: 'resetGlobals', value: function resetGlobals() { var _this = this; var gl = this.w.globals; gl.series = []; gl.seriesCandleO = []; gl.seriesCandleH = []; gl.seriesCandleL = []; gl.seriesCandleC = []; gl.seriesPercent = []; gl.seriesX = []; gl.seriesZ = []; gl.seriesNames = []; gl.seriesTotals = []; gl.stackedSeriesTotals = []; gl.labels = []; gl.timelineLabels = []; gl.noLabelsProvided = false; gl.timescaleTicks = []; gl.resizeTimer = null; gl.selectionResizeTimer = null; gl.seriesXvalues = function () { return _this.w.config.series.map(function (s) { return []; }); }(); gl.seriesYvalues = function () { return _this.w.config.series.map(function (s) { return []; }); }(); gl.delayedElements = []; gl.pointsArray = []; gl.dataLabelsRects = []; gl.isXNumeric = false; gl.isDataXYZ = false; gl.maxY = -Number.MAX_VALUE; gl.minY = Number.MIN_VALUE; gl.minYArr = []; gl.maxYArr = []; gl.maxX = -Number.MAX_VALUE; gl.minX = Number.MAX_VALUE; gl.initialmaxX = -Number.MAX_VALUE; gl.initialminX = Number.MAX_VALUE; gl.maxDate = 0; gl.minDate = Number.MAX_VALUE; gl.minZ = Number.MAX_VALUE; gl.maxZ = -Number.MAX_VALUE; gl.yAxisScale = []; gl.xAxisScale = null; gl.xAxisTicksPositions = []; gl.yLabelsCoords = []; gl.yTitleCoords = []; gl.xRange = 0; gl.yRange = []; gl.zRange = 0; gl.dataPoints = 0; } }, { key: 'isMultipleY', value: function isMultipleY() { // user has supplied an array in yaxis property. So, turn on multipleYAxis flag if (this.w.config.yaxis.constructor === Array && this.w.config.yaxis.length > 1) { // first, turn off stacking if multiple y axis this.w.config.chart.stacked = false; this.w.globals.isMultipleYAxis = true; return true; } } }, { key: 'excludeCollapsedSeriesInYAxis', value: function excludeCollapsedSeriesInYAxis() { var _this2 = this; var w = this.w; w.globals.ignoreYAxisIndexes = w.globals.collapsedSeries.map(function (collapsed, i) { if (_this2.w.globals.isMultipleYAxis) { return collapsed.index; } }); } }, { key: 'isMultiFormat', value: function isMultiFormat() { return this.isFormatXY() || this.isFormat2DArray(); } // given format is [{x, y}, {x, y}] }, { key: 'isFormatXY', value: function isFormatXY() { var series = this.w.config.series.slice(); var sr = new _Series2.default(this.ctx); var activeSeriesIndex = sr.getActiveConfigSeriesIndex(); if (typeof series[activeSeriesIndex].data !== 'undefined' && series[activeSeriesIndex].data.length > 0 && series[activeSeriesIndex].data[0] !== null && typeof series[activeSeriesIndex].data[0].x !== 'undefined' && series[activeSeriesIndex].data[0] !== null) { return true; } } // given format is [[x, y], [x, y]] }, { key: 'isFormat2DArray', value: function isFormat2DArray() { var series = this.w.config.series.slice(); var sr = new _Series2.default(this.ctx); var activeSeriesIndex = sr.getActiveConfigSeriesIndex(); if (typeof series[activeSeriesIndex].data !== 'undefined' && series[activeSeriesIndex].data.length > 0 && typeof series[activeSeriesIndex].data[0] !== 'undefined' && series[activeSeriesIndex].data[0] !== null && series[activeSeriesIndex].data[0].constructor === Array) { return true; } } }, { key: 'handleFormat2DArray', value: function handleFormat2DArray(ser, i) { var cnf = this.w.config; var gl = this.w.globals; for (var j = 0; j < ser[i].data.length; j++) { if (typeof ser[i].data[j][1] !== 'undefined') { if (Array.isArray(ser[i].data[j][1]) && ser[i].data[j][1].length === 4) { this.twoDSeries.push(ser[i].data[j][1][3]); } else { this.twoDSeries.push(ser[i].data[j][1]); } } if (cnf.xaxis.type === 'datetime') { // if timestamps are provided and xaxis type is datettime, var ts = new Date(ser[i].data[j][0]); ts = new Date(ts).getTime(); this.twoDSeriesX.push(ts); } else { this.twoDSeriesX.push(ser[i].data[j][0]); } } for (var _j = 0; _j < ser[i].data.length; _j++) { if (typeof ser[i].data[_j][2] !== 'undefined') { this.threeDSeries.push(ser[i].data[_j][2]); gl.isDataXYZ = true; } } } }, { key: 'handleFormatXY', value: function handleFormatXY(ser, i) { var cnf = this.w.config; var gl = this.w.globals; var series = this.w.config.series.slice(); var dt = new _DateTime2.default(this.ctx); for (var j = 0; j < ser[i].data.length; j++) { if (typeof ser[i].data[j].y !== 'undefined') { if (Array.isArray(ser[i].data[j].y) && ser[i].data[j].y.length === 4) { this.twoDSeries.push(ser[i].data[j].y[3]); } else { this.twoDSeries.push(ser[i].data[j].y); } } var isXString = typeof ser[i].data[j].x === 'string'; var isXDate = !!dt.isValidDate(ser[i].data[j].x.toString()); if (isXString || isXDate) { // user supplied '01/01/2017' or a date string (a JS date object is not supported) if (isXString) { if (cnf.xaxis.type === 'datetime') { this.twoDSeriesX.push(dt.parseDate(ser[i].data[j].x)); } else { // a category and not a numeric x value this.fallbackToCategory = true; this.twoDSeriesX.push(ser[i].data[j].x); } } else { if (cnf.xaxis.type === 'datetime') { this.twoDSeriesX.push(dt.parseDate(ser[i].data[j].x.toString())); } else { this.twoDSeriesX.push(parseFloat(ser[i].data[j].x)); } } } else { // a numeric value in x property this.twoDSeriesX.push(ser[i].data[j].x); } } if (series[i].data[0] && typeof series[i].data[0].z !== 'undefined') { for (var t = 0; t < series[i].data.length; t++) { this.threeDSeries.push(series[i].data[t].z); } gl.isDataXYZ = true; } } }, { key: 'handleCandleStickData', value: function handleCandleStickData(ser, i) { var gl = this.w.globals; var ohlc = {}; if (this.isFormat2DArray()) { ohlc = this.handleCandleStickDataFormat('array', ser, i); } else if (this.isFormatXY()) { ohlc = this.handleCandleStickDataFormat('xy', ser, i); } gl.seriesCandleO.push(ohlc.o); gl.seriesCandleH.push(ohlc.h); gl.seriesCandleL.push(ohlc.l); gl.seriesCandleC.push(ohlc.c); return ohlc; } }, { key: 'handleCandleStickDataFormat', value: function handleCandleStickDataFormat(format, ser, i) { var serO = []; var serH = []; var serL = []; var serC = []; var err = 'Please provide [Open, High, Low and Close] values in valid format. Read more https://apexcharts.com/docs/series/#candlestick'; if (format === 'array') { if (ser[i].data[0][1].length !== 4) { throw new Error(err); } for (var j = 0; j < ser[i].data.length; j++) { serO.push(ser[i].data[j][1][0]); serH.push(ser[i].data[j][1][1]); serL.push(ser[i].data[j][1][2]); serC.push(ser[i].data[j][1][3]); } } else if (format === 'xy') { if (ser[i].data[0].y.length !== 4) { throw new Error(err); } for (var _j2 = 0; _j2 < ser[i].data.length; _j2++) { serO.push(ser[i].data[_j2].y[0]); serH.push(ser[i].data[_j2].y[1]); serL.push(ser[i].data[_j2].y[2]); serC.push(ser[i].data[_j2].y[3]); } } return { o: serO, h: serH, l: serL, c: serC }; } }, { key: 'parseDataAxisCharts', value: function parseDataAxisCharts(ser, series) { var ctx = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.ctx; var cnf = this.w.config; var gl = this.w.globals; var dt = new _DateTime2.default(ctx); for (var i = 0; i < series.length; i++) { this.twoDSeries = []; this.twoDSeriesX = []; this.threeDSeries = []; if (typeof series[i].data === 'undefined') { console.error("It is a possibility that you may have not included 'data' property in series."); return; } if (this.isMultiFormat()) { if (this.isFormat2DArray()) { this.handleFormat2DArray(ser, i); } else if (this.isFormatXY()) { this.handleFormatXY(ser, i); } if (cnf.chart.type === 'candlestick' || ser[i].type === 'candlestick') { this.handleCandleStickData(ser, i); } gl.series.push(this.twoDSeries); gl.labels.push(this.twoDSeriesX); gl.seriesX.push(this.twoDSeriesX); if (!this.fallbackToCategory) { gl.isXNumeric = true; } } else { if (cnf.xaxis.type === 'datetime') { // user didn't supplied [{x,y}] or [[x,y]], but single array in data. // Also labels/categories were supplied differently gl.isXNumeric = true; var dates = cnf.labels.length > 0 ? cnf.labels.slice() : cnf.xaxis.categories.slice(); for (var j = 0; j < dates.length; j++) { if (typeof dates[j] === 'string') { var isDate = dt.isValidDate(dates[j]); if (isDate) { this.twoDSeriesX.push(dt.parseDate(dates[j])); } else { throw new Error('You have provided invalid Date format. Please provide a valid JavaScript Date'); } } } gl.seriesX.push(this.twoDSeriesX); } else if (cnf.xaxis.type === 'numeric') { gl.isXNumeric = true; var x = cnf.labels.length > 0 ? cnf.labels.slice() : cnf.xaxis.categories.slice(); if (x.length > 0) { this.twoDSeriesX = x; gl.seriesX.push(this.twoDSeriesX); } } gl.labels.push(this.twoDSeriesX); gl.series.push(ser[i].data); } gl.seriesZ.push(this.threeDSeries); // gl.series.push(ser[i].data) if (ser[i].name !== undefined) { gl.seriesNames.push(ser[i].name); } else { gl.seriesNames.push('series-' + parseInt(i + 1)); } } return this.w; } }, { key: 'parseDataNonAxisCharts', value: function parseDataNonAxisCharts(ser) { var gl = this.w.globals; var cnf = this.w.config; gl.series = ser.slice(); gl.seriesNames = cnf.labels.slice(); for (var i = 0; i < gl.series.length; i++) { if (gl.seriesNames[i] === undefined) { gl.seriesNames.push('series-' + (i + 1)); } } return this.w; } }, { key: 'handleExternalLabelsData', value: function handleExternalLabelsData(ser) { var cnf = this.w.config; var gl = this.w.globals; // user provided labels in category axis if (cnf.xaxis.categories.length > 0) { gl.labels = cnf.xaxis.categories; } else if (cnf.labels.length > 0) { gl.labels = cnf.labels.slice(); } else if (this.fallbackToCategory) { gl.labels = gl.labels[0]; } else { // user didn't provided labels, fallback to 1-2-3-4-5 var labelArr = []; if (gl.axisCharts) { for (var i = 0; i < gl.series[gl.maxValsInArrayIndex].length; i++) { labelArr.push(i + 1); } for (var _i = 0; _i < ser.length; _i++) { gl.seriesX.push(labelArr); } gl.isXNumeric = true; } // no series to pull labels from, put a 0-10 series if (labelArr.length === 0) { labelArr = [0, 10]; for (var _i2 = 0; _i2 < ser.length; _i2++) { gl.seriesX.push(labelArr); } } gl.labels = labelArr; gl.noLabelsProvided = true; } } // Segregate user provided data into appropriate vars }, { key: 'parseData', value: function parseData(ser) { var w = this.w; var cnf = w.config; var gl = w.globals; this.excludeCollapsedSeriesInYAxis(); // to determine whether data is in XY format or array format, we use original config var configSeries = cnf.series.slice(); this.fallbackToCategory = false; this.resetGlobals(); this.isMultipleY(); if (gl.axisCharts) { this.parseDataAxisCharts(ser, configSeries); } else { this.parseDataNonAxisCharts(ser); } this.coreUtils.getLargestSeries(); // set Null values to 0 in all series when user hides/shows some series if (cnf.chart.type === 'bar' && cnf.chart.stacked) { var series = new _Series2.default(this.ctx); gl.series = series.setNullSeriesToZeroValues(gl.series); } this.coreUtils.getSeriesTotals(); if (gl.axisCharts) { this.coreUtils.getStackedSeriesTotals(); } this.coreUtils.getPercentSeries(); // user didn't provide a [[x,y],[x,y]] series, but a named series if (!gl.isXNumeric || cnf.xaxis.type === 'numeric' && cnf.labels.length === 0 && cnf.xaxis.categories.length === 0) { this.handleExternalLabelsData(ser); } } }, { key: 'xySettings', value: function xySettings() { var xyRatios = null; var w = this.w; if (w.globals.axisCharts) { if (w.config.xaxis.crosshairs.position === 'back') { var crosshairs = new _Crosshairs2.default(this.ctx); crosshairs.drawXCrosshairs(); } if (w.config.yaxis[0].crosshairs.position === 'back') { var _crosshairs = new _Crosshairs2.default(this.ctx); _crosshairs.drawYCrosshairs(); } xyRatios = this.getCalculatedRatios(); if (w.config.xaxis.type === 'datetime' && w.config.xaxis.labels.formatter === undefined && isFinite(w.globals.minX) && isFinite(w.globals.maxX)) { var ts = new _TimeScale2.default(this.ctx); var formattedTimeScale = ts.calculateTimeScaleTicks(w.globals.minX, w.globals.maxX); ts.recalcDimensionsBasedOnFormat(formattedTimeScale); } } return xyRatios; } }, { key: 'getCalculatedRatios', value: function getCalculatedRatios() { var gl = this.w.globals; var yRatio = []; var invertedYRatio = 0; var xRatio = 0; var initialXRatio = 0; var invertedXRatio = 0; var zRatio = 0; var baseLineY = []; var baseLineInvertedY = 0.1; var baseLineX = 0; gl.yRange = []; if (gl.isMultipleYAxis) { for (var i = 0; i < gl.minYArr.length; i++) { gl.yRange.push(Math.abs(gl.minYArr[i] - gl.maxYArr[i])); baseLineY.push(0); } } else { gl.yRange.push(Math.abs(gl.minY - gl.maxY)); } gl.xRange = Math.abs(gl.maxX - gl.minX); gl.zRange = Math.abs(gl.maxZ - gl.minZ); // multiple y axis for (var _i3 = 0; _i3 < gl.yRange.length; _i3++) { yRatio.push(gl.yRange[_i3] / gl.gridHeight); } xRatio = gl.xRange / gl.gridWidth; initialXRatio = Math.abs(gl.initialmaxX - gl.initialminX) / gl.gridWidth; invertedYRatio = gl.yRange / gl.gridWidth; invertedXRatio = gl.xRange / gl.gridHeight; zRatio = gl.zRange / gl.gridHeight * 16; if (gl.minY !== Number.MIN_VALUE && Math.abs(gl.minY) !== 0) { // Negative numbers present in series gl.hasNegs = true; baseLineY = []; // baseline variables is the 0 of the yaxis which will be needed when there are negatives if (gl.isMultipleYAxis) { for (var _i4 = 0; _i4 < yRatio.length; _i4++) { baseLineY.push(-gl.minYArr[_i4] / yRatio[_i4]); } } else { baseLineY.push(-gl.minY / yRatio[0]); } baseLineInvertedY = -gl.minY / invertedYRatio; // this is for bar chart baseLineX = gl.minX / xRatio; } else { baseLineY.push(0); } return { yRatio: yRatio, invertedYRatio: invertedYRatio, zRatio: zRatio, xRatio: xRatio, initialXRatio: initialXRatio, invertedXRatio: invertedXRatio, baseLineInvertedY: baseLineInvertedY, baseLineY: baseLineY, baseLineX: baseLineX }; } }, { key: 'checkComboCharts', value: function checkComboCharts() { var w = this.w; var cnf = w.config; cnf.series.map(function (series) { if (typeof series.type !== 'undefined') { w.globals.comboCharts = true; } }); } }, { key: 'drawAxis', value: function drawAxis(type, xyRatios) { var gl = this.w.globals; var cnf = this.w.config; var xAxis = new _XAxis2.default(this.ctx); var yAxis = new _YAxis2.default(this.ctx); if (gl.axisCharts) { var elXaxis = void 0, elYaxis = void 0; if (type === 'bar' && cnf.plotOptions.bar.horizontal) { elYaxis = yAxis.drawYaxisInversed(0); elXaxis = xAxis.drawXaxisInversed(0); gl.dom.elGraphical.add(elXaxis); gl.dom.elGraphical.add(elYaxis); } else { elXaxis = xAxis.drawXaxis(); gl.dom.elGraphical.add(elXaxis); cnf.yaxis.map(function (yaxe, index) { if (!gl.ignoreYAxisIndexes.indexOf(index) > -1) { elYaxis = yAxis.drawYaxis(xyRatios, index); gl.dom.Paper.add(elYaxis); } }); } } cnf.yaxis.map(function (yaxe, index) { if (!gl.ignoreYAxisIndexes.indexOf(index) > -1) { yAxis.yAxisTitleRotate(index, yaxe.opposite); } }); } }, { key: 'drawGrid', value: function drawGrid() { var w = this.w; var grid = new _Grid2.default(this.ctx); var xAxis = new _XAxis2.default(this.ctx); var gl = this.w.globals; var elgrid = null; if (gl.axisCharts) { if (w.config.grid.show) { // grid is drawn after xaxis and yaxis are drawn elgrid = grid.renderGrid(); gl.dom.elGraphical.add(elgrid.el); grid.drawGridArea(elgrid.el); } else { var elgridArea = grid.drawGridArea(); gl.dom.elGraphical.add(elgridArea); } if (elgrid !== null) { xAxis.xAxisLabelCorrections(elgrid.xAxisTickWidth); } } } // This mask will clip off overflowing graphics from the drawable area }, { key: 'createGridMask', value: function createGridMask() { var w = this.w; var graphics = new _Graphics2.default(this.ctx); w.globals.dom.elGridRectMask = document.createElementNS(w.globals.svgNS, 'clipPath'); w.globals.dom.elGridRectMask.setAttribute('id', 'gridRectMask' + w.globals.cuid); var markerSize = 0; if (!w.config.grid.clipMarkers) { markerSize = w.config.markers.size > w.config.markers.hover.size ? w.config.markers.size : w.config.markers.hover.size; } w.globals.dom.elGridRect = graphics.drawRect(0, 0 - markerSize * 1.2, w.globals.gridWidth, w.globals.gridHeight + markerSize * 2.4, 0, '#fff'); w.globals.dom.elGridRectMask.appendChild(w.globals.dom.elGridRect.node); var defs = w.globals.dom.baseEl.querySelector('defs'); defs.appendChild(w.globals.dom.elGridRectMask); } }]); return Core; }(); module.exports = Core; /***/ }), /* 133 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Exports = function () { function Exports(ctx) { _classCallCheck(this, Exports); this.ctx = ctx; this.w = ctx.w; } _createClass(Exports, [{ key: 'getSvgString', value: function getSvgString() { return this.w.globals.dom.Paper.svg(); } }, { key: 'exportToSVG', value: function exportToSVG() { var w = this.w; // hide some elements to avoid printing them on exported svg var xcrosshairs = w.globals.dom.baseEl.querySelector('.apexcharts-xcrosshairs'); var ycrosshairs = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs'); if (xcrosshairs) { xcrosshairs.setAttribute('x', -500); } if (ycrosshairs) { ycrosshairs.setAttribute('y1', -100); ycrosshairs.setAttribute('y2', -100); } var svgData = this.getSvgString(); var svgBlob = new Blob([svgData], { type: 'image/svg+xml;charset=utf-8' }); var svgUrl = URL.createObjectURL(svgBlob); var downloadLink = document.createElement('a'); downloadLink.href = svgUrl; downloadLink.download = this.w.globals.chartID + '.svg'; document.body.appendChild(downloadLink); downloadLink.click(); document.body.removeChild(downloadLink); } }]); return Exports; }(); exports.default = Exports; /***/ }), /* 134 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Dimensions = __webpack_require__(46); var _Dimensions2 = _interopRequireDefault(_Dimensions); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Series = __webpack_require__(26); var _Series2 = _interopRequireDefault(_Series); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Legend Class to draw legend. * * @module Legend **/ var Legend = function () { function Legend(ctx, opts) { _classCallCheck(this, Legend); this.ctx = ctx; this.w = ctx.w; this.existingWidth = 0; this.existingHeight = 0; this.rowHeight = 20; this.maxTextWidth = 0; this.padding = 0; this.noOfLegendColumns = 1; this.textMaxWidthArr = []; this.legendsArray = []; this.onLegendClick = this.onLegendClick.bind(this); this.onLegendHovered = this.onLegendHovered.bind(this); } _createClass(Legend, [{ key: 'init', value: function init() { var w = this.w; var gl = w.globals; var cnf = w.config; if ((gl.series.length > 1 || !gl.axisCharts) && cnf.legend.show) { while (gl.dom.elLegendWrap.firstChild) { gl.dom.elLegendWrap.removeChild(gl.dom.elLegendWrap.firstChild); } this.drawLegends(cnf.chart.type, gl.series.length); if (cnf.legend.position === 'bottom' || cnf.legend.position === 'top') { this.legendAlignCenterHorz(); } else if (cnf.legend.position === 'right' || cnf.legend.position === 'left') { this.legendAlignVertical(); } } } }, { key: 'drawLegends', value: function drawLegends(type, seriesLength) { var self = this; var w = this.w; var graphics = new _Graphics2.default(this.ctx); var pSize = w.config.legend.markers.size; var fontSize = w.config.legend.fontSize; var fontFamily = w.config.legend.fontFamily; var marginHorz = w.config.legend.itemMargin.horizontal; var marginVert = w.config.legend.itemMargin.vertical; this.padding = pSize + w.config.legend.markers.strokeWidth; var padding = this.padding; // To get text's actual rect before it is rendered. // We append this text to some place and then we will delete this text after we are done var totalWidth = 0; var currentRow = 1; var currentCol = 0; var legendNames = w.globals.seriesNames; var fillcolor = w.globals.colors.slice(); if (w.config.chart.type === 'heatmap') { var ranges = w.config.plotOptions.heatmap.colorScale.ranges; legendNames = ranges.map(function (colorScale, index) { return colorScale.name ? colorScale.name : colorScale.from + ' - ' + colorScale.to; }); fillcolor = ranges.map(function (color, index) { return color.color; }); } var legendFormatter = w.globals.legendFormatter; for (var i = 0; i <= legendNames.length - 1; i++) { var horizontal = !!(w.config.legend.position === 'top' || w.config.legend.position === 'bottom'); var y = 0; var x = 0; var width = void 0; var text = legendFormatter(legendNames[i], { globals: w.globals, seriesIndex: i }); var collapsedSeries = false; if (w.globals.collapsedSeries.length > 0) { for (var c = 0; c < w.globals.collapsedSeries.length; c++) { if (w.globals.collapsedSeries[c].index === i) { collapsedSeries = true; } } } if (horizontal) { var rect = graphics.getTextRects(text, fontSize); width = rect.width; this.rowHeight = rect.height + marginVert; x = this.existingWidth + padding + marginHorz; if (this.existingWidth + width + padding + marginHorz > w.globals.svgWidth) { currentRow = currentRow + 1; this.existingWidth = 0; x = this.existingWidth + padding + marginHorz; } if (w.config.legend.position === 'bottom') { y = w.globals.svgHeight - this.rowHeight; } y = y + this.rowHeight * currentRow; } else { var _rect = graphics.getTextRects(text, fontSize); var height = _rect.height; this.rowHeight = height + marginVert; this.textMaxWidthArr.push(_rect.width); var _width = this.getTextMaxWidth() + marginHorz; currentRow = i + 1; if (this.existingHeight + height + padding > w.globals.svgHeight) { currentCol = currentCol + 1; this.existingHeight = 0; } x = padding + currentCol * _width; y = this.existingHeight + height; } var elPointOptions = { pSize: pSize, pRadius: w.config.legend.markers.radius, pWidth: w.config.legend.markers.strokeWidth, shape: w.config.legend.markers.shape, pointStrokeColor: w.config.legend.markers.strokeColor, pointFillColor: fillcolor[i], pointStrokeOpacity: 1, pointFillOpacity: 1, class: 'apexcharts-legend-point' }; var offsetYPt = pSize / 2 - 1 + w.config.legend.markers.strokeWidth; var elColor = graphics.drawMarker(x - padding + w.config.legend.markers.offsetX - 4, y - padding + offsetYPt + w.config.legend.markers.offsetY - 1, elPointOptions).attr({ 'rel': i + 1, 'data:collapsed': collapsedSeries }); if (collapsedSeries) { elColor.node.classList.add('inactive-legend'); } var elTextOpts = { x: x, y: y, foreColor: w.config.legend.labels.useSeriesColors ? w.globals.colors[i] : w.config.legend.labels.color, text: text, textAnchor: w.config.legend.textAnchor, fontSize: fontSize, fontFamily: fontFamily, cssClass: 'apexcharts-legend-text' }; this.existingWidth = this.existingWidth + width + marginHorz + padding + 5; this.existingHeight = this.existingHeight + this.rowHeight + padding / 4; totalWidth = totalWidth + width + padding + marginHorz; var elLegend = graphics.drawText(elTextOpts); w.globals.dom.elLegendWrap.add(elLegend); w.globals.dom.elLegendWrap.add(elColor); elLegend.node.classList.add('apexcharts-legend-series'); elLegend.attr({ 'rel': i + 1, 'data:collapsed': collapsedSeries }); if (collapsedSeries) { elLegend.node.classList.add('inactive-legend'); } if (!w.config.legend.onItemClick.toggleDataSeries) { elLegend.node.classList.add('no-click'); } } // for now - just prevent click on heatmap legend - and allow hover only var clickAllowed = w.config.chart.type !== 'heatmap'; if (clickAllowed && w.config.legend.onItemClick.toggleDataSeries) { w.globals.dom.elWrap.addEventListener('click', self.onLegendClick, true); } if (w.config.legend.onItemHover.highlightDataSeries) { w.globals.dom.elWrap.addEventListener('mousemove', self.onLegendHovered, true); w.globals.dom.elWrap.addEventListener('mouseout', self.onLegendHovered, true); } } }, { key: 'getTextMaxWidth', value: function getTextMaxWidth() { var largestWidth = 0; for (var i = 0; i < this.textMaxWidthArr.length; i++) { largestWidth = Math.max(largestWidth, this.textMaxWidthArr[i]); } this.maxTextWidth = largestWidth; return largestWidth; } }, { key: 'getLegendBBox', value: function getLegendBBox() { var w = this.w; var currLegendsWrapRect = w.globals.dom.baseEl.querySelector('.apexcharts-legend').getBBox(); var currLegendsWrapWidth = currLegendsWrapRect.width; var currLegendsWrapHeight = currLegendsWrapRect.height; return { clwh: currLegendsWrapHeight, clww: currLegendsWrapWidth }; } }, { key: 'translateLegendPoints', value: function translateLegendPoints(offsetX) { var offsetY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var w = this.w; var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-legend-point'); for (var lp = 0; lp < points.length; lp++) { if (offsetY === null) { var y = points[lp].getAttribute('transform'); if (y.indexOf(',') > -1) { offsetY = parseFloat(y.split(',')[1]); } else if (y.indexOf(' ') > -1) { offsetY = parseFloat(y.split(' ')[1]); } if (!offsetY) { offsetY = 0; } } points[lp].setAttribute('transform', 'translate(' + offsetX + ',' + offsetY + ')'); } } }, { key: 'setLegendXY', value: function setLegendXY(offsetX, offsetY) { var w = this.w; var legends = w.globals.dom.baseEl.querySelectorAll('.apexcharts-legend-series'); for (var l = 0; l < legends.length; l++) { var currX = parseInt(legends[l].getAttribute('x')); var currY = parseInt(legends[l].getAttribute('y')); _Graphics2.default.setAttrs(legends[l], { x: currX + offsetX, y: currY + offsetY }); } this.setLegendWrapXY(); } }, { key: 'setLegendWrapXY', value: function setLegendWrapXY() { var w = this.w; var elLegendWrap = w.globals.dom.baseEl.querySelector('.apexcharts-legend'); var legendRect = elLegendWrap.getBBox(); var legendTopPlusHeight = legendRect.y + legendRect.height; var x = w.config.legend.containerMargin.left - w.config.legend.containerMargin.right; var y = w.config.legend.containerMargin.top - w.config.legend.markers.size - 3; if (w.config.legend.position === 'bottom') { if (legendTopPlusHeight - 10 > w.globals.svgHeight) { y = y - (w.globals.svgHeight - legendRect.y + legendRect.height) / 8; } } if (w.config.legend.position === 'top') { var dim = new _Dimensions2.default(this.ctx); var titleH = dim.getTitleSubtitleCoords('title').height; var subtitleH = dim.getTitleSubtitleCoords('subtitle').height; y = y + (titleH > 0 ? titleH - 10 : 0) + (subtitleH > 0 ? subtitleH - 10 : 0); } if (w.config.legend.position === 'right' || w.config.legend.position === 'left') { if (y < w.config.legend.markers.size) y = w.config.legend.markers.size; } elLegendWrap.setAttribute('transform', 'translate(' + x + ', ' + y + ')'); } }, { key: 'legendAlignCenterHorz', value: function legendAlignCenterHorz() { var w = this.w; var lRect = this.getLegendBBox(); var dimensions = new _Dimensions2.default(this.ctx); var titleRect = dimensions.getTitleSubtitleCoords('title'); var subtitleRect = dimensions.getTitleSubtitleCoords('subtitle'); var offsetX = 20; var offsetY = 0; if (w.config.legend.horizontalAlign === 'right') { offsetX = w.globals.svgWidth - lRect.clww - offsetX; } else if (w.config.legend.horizontalAlign === 'center') { offsetX = (w.globals.svgWidth - lRect.clww) / 2; } // the whole legend box is set to bottom if (w.config.legend.position === 'bottom') { offsetY = -lRect.clwh / 1.8; } else if (w.config.legend.position === 'top') { offsetY = titleRect.height + subtitleRect.height + w.config.title.margin + w.config.subtitle.margin - 15; } offsetX = offsetX + w.config.legend.offsetX; offsetY = offsetY + w.config.legend.offsetY; this.setLegendXY(offsetX, offsetY); this.translateLegendPoints(offsetX, offsetY); } }, { key: 'legendAlignVertical', value: function legendAlignVertical() { var w = this.w; var lRect = this.getLegendBBox(); var offsetCorrection = lRect.clwh + this.rowHeight * 1.2 < w.globals.svgHeight ? this.rowHeight : this.rowHeight / 2; var offsetY = 20; var offsetX = 0; if (w.config.legend.position === 'left') { offsetX = w.config.legend.markers.size + 10; } if (w.config.legend.verticalAlign === 'bottom') { offsetY = w.globals.svgHeight - lRect.clwh - offsetY; } else if (w.config.legend.verticalAlign === 'middle') { offsetY = (w.globals.svgHeight - lRect.clwh) / 2 - offsetCorrection; } offsetX = offsetX + w.config.legend.offsetX; offsetY = offsetY + w.config.legend.offsetY; this.setLegendXY(offsetX, offsetY); this.translateLegendPoints(offsetX, offsetY); if (w.config.legend.position === 'right') { this.moveLegendsToRight(); } } }, { key: 'moveLegendsToRight', value: function moveLegendsToRight() { var w = this.w; var lRect = this.getLegendBBox(); var offsetX = w.globals.svgWidth - lRect.clww - this.padding / 2; this.setLegendXY(offsetX, 0); this.translateLegendPoints(offsetX + w.config.legend.offsetX, null); } }, { key: 'onLegendHovered', value: function onLegendHovered(e) { var w = this.w; var hoverOverLegend = e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-point'); if (w.config.chart.type !== 'heatmap') { if (!e.target.classList.contains('inactive-legend') && hoverOverLegend) { var series = new _Series2.default(this.ctx); series.toggleSeriesOnHover(e, e.target); } } else { // for heatmap handling if (hoverOverLegend) { var _series = new _Series2.default(this.ctx); _series.highlightRangeInSeries(e, e.target); } } } }, { key: 'onLegendClick', value: function onLegendClick(e) { if (e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-point')) { var seriesCnt = parseInt(e.target.getAttribute('rel')) - 1; var isHidden = e.target.getAttribute('data:collapsed') === 'true'; this.toggleDataSeries(seriesCnt, isHidden); } } }, { key: 'toggleDataSeries', value: function toggleDataSeries(seriesCnt, isHidden) { var w = this.w; if (w.globals.axisCharts || w.config.chart.type === 'radialBar') { w.globals.resized = true; // we don't want initial animations again var seriesEl = null; var realIndex = null; // yes, make it null. 1 series will rise at a time w.globals.risingSeries = []; if (w.globals.axisCharts) { seriesEl = w.globals.dom.baseEl.querySelector('.apexcharts-series[data\\:realIndex=\'' + seriesCnt + '\']'); realIndex = parseInt(seriesEl.getAttribute('data:realIndex')); } else { seriesEl = w.globals.dom.baseEl.querySelector('.apexcharts-series[rel=\'' + (seriesCnt + 1) + '\']'); realIndex = parseInt(seriesEl.getAttribute('rel')) - 1; } if (isHidden) { if (w.globals.collapsedSeries.length > 0) { for (var c = 0; c < w.globals.collapsedSeries.length; c++) { if (w.globals.collapsedSeries[c].index === realIndex) { if (w.globals.axisCharts) { w.config.series[realIndex].data = w.globals.collapsedSeries[c].data.slice(); w.globals.collapsedSeries.splice(c, 1); w.globals.collapsedSeriesIndices.splice(c, 1); w.globals.risingSeries.push(realIndex); } else { w.config.series[realIndex] = w.globals.collapsedSeries[c].data; w.globals.collapsedSeries.splice(c, 1); w.globals.collapsedSeriesIndices.splice(c, 1); w.globals.risingSeries.push(realIndex); } this.ctx.updateSeriesInternal(w.config.series, w.config.chart.animations.dynamicAnimation.enabled); } } } } else { if (w.globals.axisCharts) { w.globals.collapsedSeries.push({ index: realIndex, data: w.config.series[realIndex].data.slice(), type: seriesEl.parentNode.className.baseVal.split('-')[1] }); w.globals.collapsedSeriesIndices.push(realIndex); var removeIndexOfRising = w.globals.risingSeries.indexOf(realIndex); w.globals.risingSeries.splice(removeIndexOfRising, 1); // mutating the user's config object here w.config.series[realIndex].data = []; } else { w.globals.collapsedSeries.push({ index: realIndex, data: w.config.series[realIndex] }); w.globals.collapsedSeriesIndices.push(realIndex); w.config.series[realIndex] = 0; } var seriesChildren = seriesEl.childNodes; for (var sc = 0; sc < seriesChildren.length; sc++) { if (seriesChildren[sc].classList.contains('apexcharts-series-markers-wrap')) { if (seriesChildren[sc].classList.contains('apexcharts-hide')) { seriesChildren[sc].classList.remove('apexcharts-hide'); } else { seriesChildren[sc].classList.add('apexcharts-hide'); } } } w.globals.allSeriesCollapsed = w.globals.collapsedSeries.length === w.globals.series.length; this.ctx.updateSeriesInternal(w.config.series, w.config.chart.animations.dynamicAnimation.enabled); } } else { // for non-axis charts i.e pie / donuts var _seriesEl = w.globals.dom.Paper.select(' .apexcharts-series[rel=\'' + (seriesCnt + 1) + '\'] path'); _seriesEl.fire('click'); } } }]); return Legend; }(); exports.default = Legend; /***/ }), /* 135 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Range is used to generates values between min and max. * * @module Range **/ var Range = function () { function Range(ctx) { _classCallCheck(this, Range); this.ctx = ctx; this.w = ctx.w; } _createClass(Range, [{ key: 'init', value: function init() { this.handleMinYMaxY(); this.handleMinXMaxX(); this.handleMinZMaxZ(); } // http://stackoverflow.com/questions/326679/choosing-an-attractive-linear-scale-for-a-graphs-y-axiss // This routine creates the Y axis values for a graph. }, { key: 'niceScale', value: function niceScale(yMin, yMax) { var ticks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10; if (yMin === Number.MIN_VALUE && yMax === 0 || !_Utils2.default.isNumber(yMin) && !_Utils2.default.isNumber(yMax)) { // when all values are 0 yMin = 0; yMax = 1; ticks = 1; var justRange = this.justRange(yMin, yMax, ticks); return justRange; } if (yMin > yMax) { // if somehow due to some wrong config, user sent max less than min, // adjust the min/max again console.warn('yaxis.min cannot be greater than yaxis.max'); yMax = yMin + 0.1; } else if (yMin === yMax) { // If yMin and yMax are identical, then // adjust the yMin and yMax values to actually // make a graph. Also avoids division by zero errors. yMin = yMin - 0.1; // some small value yMax = yMax + 0.1; // some small value } // Calculate Min amd Max graphical labels and graph // increments. The number of ticks defaults to // 10 which is the SUGGESTED value. Any tick value // entered is used as a suggested value which is // adjusted to be a 'pretty' value. // // Output will be an array of the Y axis values that // encompass the Y values. var result = []; // Determine Range var range = yMax - yMin; var tiks = ticks + 1; // Adjust ticks if needed if (tiks < 2) { tiks = 2; } else if (tiks > 2) { tiks -= 2; } // Get raw step value var tempStep = range / tiks; // Calculate pretty step value var mag = Math.floor(this.log10(tempStep)); var magPow = Math.pow(10, mag); var magMsd = parseInt(tempStep / magPow); var stepSize = magMsd * magPow; // build Y label array. // Lower and upper bounds calculations var lb = stepSize * Math.floor(yMin / stepSize); var ub = stepSize * Math.ceil(yMax / stepSize); // Build array var val = lb; while (1) { result.push(val); val += stepSize; if (val > ub) { break; } } // TODO: need to remove this condition below which makes this function tightly coupled with w. if (this.w.config.yaxis[0].max === undefined && this.w.config.yaxis[0].min === undefined) { return { result: result, niceMin: result[0], niceMax: result[result.length - 1] }; } else { result = []; var v = yMin; result.push(v); var valuesDivider = Math.abs(yMax - yMin) / ticks; for (var i = 0; i <= ticks - 1; i++) { v = v + valuesDivider; result.push(v); } return { result: result, niceMin: result[0], niceMax: result[result.length - 1] }; } } }, { key: 'justRange', value: function justRange(yMin, yMax) { var ticks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10; var range = Math.abs(yMax - yMin); var step = range / ticks; if (ticks === Number.MAX_VALUE) { ticks = 10;step = 1; } var result = []; var v = yMin; while (ticks >= 0) { result.push(v); v = v + step; ticks -= 1; } return { result: result, niceMin: result[0], niceMax: result[result.length - 1] }; } }, { key: 'getMinYMaxY', value: function getMinYMaxY(startingIndex, minValInSeries, len) { var gl = this.w.globals; var maxY = -Number.MAX_VALUE; var minY = Number.MIN_VALUE; var series = gl.series; var seriesMin = series; var seriesMax = series; if (this.w.config.chart.type === 'candlestick') { seriesMin = gl.seriesCandleL; seriesMax = gl.seriesCandleH; } for (var i = startingIndex; i < len; i++) { gl.dataPoints = Math.max(gl.dataPoints, series[i].length); if (_Utils2.default.isIE()) { minY = Math.min.apply(Math, _toConsumableArray(seriesMin[i]).concat([0])); } for (var j = 0; j < gl.series[i].length; j++) { if (series[i][j] !== null && _Utils2.default.isNumber(series[i][j])) { maxY = Math.max(maxY, seriesMax[i][j]); minValInSeries = Math.min(minValInSeries, seriesMin[i][j]); if (_Utils2.default.isFloat(series[i][j])) { gl.yValueDecimal = Math.max(gl.yValueDecimal, series[i][j].toString().split('.')[1].length); } if (minY > seriesMin[i][j] && seriesMin[i][j] < 0) { minY = seriesMin[i][j]; } } else { gl.hasNullValues = true; } } } return { minY: minY, maxY: maxY, minValInSeries: minValInSeries }; } }, { key: 'handleMinYMaxY', value: function handleMinYMaxY() { var _this = this; var gl = this.w.globals; var cnf = this.w.config; gl.maxY = -Number.MAX_VALUE; gl.minY = Number.MIN_VALUE; var yaxis = cnf.yaxis; var minValInSeries = Number.MAX_VALUE; if (gl.isMultipleYAxis) { // we need to get minY and maxY for multiple y axis for (var i = 0; i < gl.series.length; i++) { var minYMaxYArr = this.getMinYMaxY(i, minValInSeries, i + 1); gl.minYArr.push(minYMaxYArr.minY); gl.maxYArr.push(minYMaxYArr.maxY); minValInSeries = minYMaxYArr.minValInSeries; } } // and then, get the minY and maxY from all series var minYMaxY = this.getMinYMaxY(0, minValInSeries, gl.series.length); gl.minY = minYMaxY.minY;gl.maxY = minYMaxY.maxY; minValInSeries = minYMaxY.minValInSeries; if (cnf.chart.stacked) { // for stacked charts, we calculate each series's parallel values. i.e, series[0][j] + series[1][j] .... [series[i.length][j]] and get the max out of it var stackedPoss = []; var stackedNegs = []; for (var j = 0; j < gl.series[gl.maxValsInArrayIndex].length; j++) { var poss = 0; var negs = 0; for (var _i = 0; _i < gl.series.length; _i++) { if (gl.series[_i][j] !== null && _Utils2.default.isNumber(gl.series[_i][j])) { if (gl.series[_i][j] > 0) { poss = poss + parseInt(gl.series[_i][j]) + 1; } else { negs = negs + parseInt(gl.series[_i][j]); } } if (_i === gl.series.length - 1) { // push all the totals to the array for future use stackedPoss.push(poss); stackedNegs.push(negs); } } } // get the max/min out of the added parallel values for (var z = 0; z < stackedPoss.length; z++) { gl.maxY = Math.max(gl.maxY, stackedPoss[z]); gl.minY = Math.min(gl.minY, stackedNegs[z]); } } // if the numbers are too big, reduce the range // for eg, if number is between 100000-110000, putting 0 as the lowest value is not so good idea. So change the gl.minY for line/area/candlesticks if (cnf.chart.type === 'line' || cnf.chart.type === 'area' || cnf.chart.type === 'candlestick') { if (gl.minY === Number.MIN_VALUE && minValInSeries !== Number.MAX_SAFE_INTEGER) { var diff = gl.maxY - minValInSeries; if (minValInSeries >= 0 && minValInSeries <= 10) { // if minY is already 0/low value, we don't want to go negatives here - so this check is essential. diff = 0; } gl.minY = minValInSeries - diff * 5 / 100; gl.maxY = gl.maxY + diff * 5 / 100; } } cnf.yaxis.map(function (yaxe, index) { // override all min/max values by user defined values (y axis) if (yaxe.max !== undefined && typeof yaxe.max === 'number') { gl.maxYArr[index] = yaxe.max; // gl.maxY is for single y-axis chart, it will be ignored in multi-yaxis gl.maxY = yaxis[0].max; } if (yaxe.min !== undefined && typeof yaxe.min === 'number') { gl.minYArr[index] = yaxe.min; // gl.minY is for single y-axis chart, it will be ignored in multi-yaxis gl.minY = yaxis[0].min; } }); // after getting the yAxisScale, we need to call this function to recalculate the minYmaxY var reCalculateMinMaxY = function reCalculateMinMaxY(startingIndex, minY, maxY) { // user didn't provide tickAmount as well as y values are in small range var ticksY = yaxis[startingIndex]; if (typeof ticksY !== 'undefined') { ticksY = ticksY.tickAmount; } else { ticksY = 8; } if (maxY === -Number.MAX_VALUE || !_Utils2.default.isNumber(maxY)) { // no value in series. draw blank grid gl.yAxisScale.push(_this.justRange(0, 5, 5)); } else { gl.allSeriesCollapsed = false; gl.yAxisScale.push(_this.niceScale(minY, maxY, ticksY)); } }; // for multi y-axis we need different scales for each if (gl.isMultipleYAxis) { var minYArr = gl.minYArr.concat([]); var maxYArr = gl.maxYArr.concat([]); // here, we loop through the yaxis array and find the item which has "seriesName" property cnf.yaxis.forEach(function (yaxe, i) { var index = i; cnf.series.forEach(function (s, si) { // if seriesName matches and that series is not collapsed, we use that scale if (s.name === yaxe.seriesName && !gl.collapsedSeriesIndices.indexOf(si) > -1) { index = si; } }); var minY = minYArr[index]; var maxY = maxYArr[index]; if (yaxe.min !== undefined) { minY = yaxe.min; } if (yaxe.max !== undefined) { maxY = yaxe.max; } reCalculateMinMaxY(i, minY, maxY); gl.minYArr[i] = gl.yAxisScale[i].niceMin; gl.maxYArr[i] = gl.yAxisScale[i].niceMax; }); } else { reCalculateMinMaxY(0, gl.minY, gl.maxY); gl.minY = gl.yAxisScale[0].niceMin; gl.maxY = gl.yAxisScale[0].niceMax; gl.minYArr[0] = gl.yAxisScale[0].niceMin; gl.maxYArr[0] = gl.yAxisScale[0].niceMax; } } }, { key: 'handleMinXMaxX', value: function handleMinXMaxX() { var gl = this.w.globals;var cnf = this.w.config; // minX maxX starts here if (gl.isXNumeric) { for (var i = 0; i < gl.series.length; i++) { if (gl.labels[i]) { for (var j = 0; j < gl.labels[i].length; j++) { if (gl.labels[i][j] !== null && _Utils2.default.isNumber(gl.labels[i][j])) { gl.maxX = Math.max(gl.maxX, gl.labels[i][j]); gl.initialmaxX = Math.max(gl.maxX, gl.labels[i][j]); gl.minX = Math.min(gl.minX, gl.labels[i][j]); gl.initialminX = Math.min(gl.minX, gl.labels[i][j]); } } } } } if (gl.noLabelsProvided) { gl.maxX = gl.labels[gl.labels.length - 1]; gl.initialmaxX = gl.labels[gl.labels.length - 1]; gl.minX = 1; gl.initialminX = 1; } // for datetime xaxis, we need to adjust some padding left and right as it cuts the markers and dataLabels when it's drawn over egde. // If user willingly disables this option, then skip if (cnf.grid.padding.left !== 0 && cnf.grid.padding.right !== 0) { if (cnf.xaxis.type !== 'category') { var minX = gl.minX - gl.svgWidth / gl.dataPoints * (Math.abs(gl.maxX - gl.minX) / gl.svgWidth) / 3; gl.minX = minX; gl.initialminX = minX; var maxX = gl.maxX + gl.svgWidth / gl.dataPoints * (Math.abs(gl.maxX - gl.minX) / gl.svgWidth) / 3; gl.maxX = maxX; gl.initialmaxX = maxX; } } var niceXRange = new Range(this.ctx); if (gl.isXNumeric || gl.noLabelsProvided) { var ticks = void 0; if (cnf.xaxis.tickAmount === undefined) { ticks = Math.round(gl.svgWidth / 150); // no labels provided and total number of dataPoints is less than 20 if (cnf.xaxis.type === 'numeric' && gl.dataPoints < 20) { ticks = gl.dataPoints - 1; } // this check is for when ticks exceeds total datapoints and that would result in duplicate labels if (ticks > gl.dataPoints && gl.dataPoints !== 0) { ticks = gl.dataPoints - 1; } } else if (cnf.xaxis.tickAmount === 'dataPoints') { ticks = gl.series[gl.maxValsInArrayIndex].length - 1; } else { ticks = cnf.xaxis.tickAmount; } // override all min/max values by user defined values (x axis) if (cnf.xaxis.max !== undefined && typeof cnf.xaxis.max === 'number') { gl.maxX = cnf.xaxis.max; } if (cnf.xaxis.min !== undefined && typeof cnf.xaxis.min === 'number') { gl.minX = cnf.xaxis.min; } // if range is provided, adjust the new minX if (cnf.xaxis.range !== undefined) { gl.minX = gl.maxX - cnf.xaxis.range; } if (gl.minX !== Number.MAX_VALUE && gl.maxX !== -Number.MAX_VALUE) { gl.xAxisScale = niceXRange.justRange(gl.minX, gl.maxX, ticks); // we will still store these labels as the count for this will be different (to draw grid and labels placement) gl.labels = gl.xAxisScale.result.slice(); } else { gl.xAxisScale = niceXRange.justRange(1, ticks, ticks); if (gl.noLabelsProvided && gl.labels.length > 0) { gl.xAxisScale = niceXRange.justRange(1, gl.labels.length, ticks - 1); gl.seriesX = gl.labels.slice(); } gl.labels = gl.xAxisScale.result.slice(); } } } }, { key: 'handleMinZMaxZ', value: function handleMinZMaxZ() { var gl = this.w.globals; // minZ, maxZ starts here if (gl.isDataXYZ) { for (var i = 0; i < gl.series.length; i++) { if (typeof gl.seriesZ[i] !== 'undefined') { for (var j = 0; j < gl.seriesZ[i].length; j++) { if (gl.seriesZ[i][j] !== null && _Utils2.default.isNumber(gl.seriesZ[i][j])) { gl.maxZ = Math.max(gl.maxZ, gl.seriesZ[i][j]); gl.minZ = Math.min(gl.minZ, gl.seriesZ[i][j]); } } } } } } }, { key: 'log10', value: function log10(x) { return Math.log(x) / Math.LN10; } }]); return Range; }(); exports.default = Range; /***/ }), /* 136 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Config = __webpack_require__(50); var _Config2 = _interopRequireDefault(_Config); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Responsive Class to override options for different screen sizes. * * @module Responsive **/ var Responsive = function () { function Responsive(ctx) { _classCallCheck(this, Responsive); this.ctx = ctx; this.w = ctx.w; } _createClass(Responsive, [{ key: 'checkResponsiveConfig', value: function checkResponsiveConfig() { var w = this.w; var cnf = w.config; // check if responsive config exists if (cnf.responsive === undefined) return; var newOptions = {}; for (var i = 0; i < cnf.responsive.length; i++) { var width = window.innerWidth > 0 ? window.innerWidth : screen.width; if (width < cnf.responsive[i].breakpoint) { newOptions = _Utils2.default.extend(w.config, cnf.responsive[i].options); this.overrideResponsiveOptions(newOptions); break; } else { newOptions = _Utils2.default.extend(w.config, w.globals.initialConfig); this.overrideResponsiveOptions(newOptions); } } } }, { key: 'overrideResponsiveOptions', value: function overrideResponsiveOptions(newOptions) { var newConfig = new _Config2.default(newOptions).init(); this.w.config = newConfig; } }]); return Responsive; }(); module.exports = Responsive; /***/ }), /* 137 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Theme Class for setting the colors and palettes. * * @module Theme **/ var Theme = function () { function Theme(ctx) { _classCallCheck(this, Theme); this.ctx = ctx; this.w = ctx.w; this.colors = []; } _createClass(Theme, [{ key: 'init', value: function init() { this.setDefaultColors(); } }, { key: 'setDefaultColors', value: function setDefaultColors() { var w = this.w; var utils = new _Utils2.default(); if (w.config.colors === undefined) { w.globals.colors = this.predefined(); } else { w.globals.colors = w.config.colors; } if (w.config.theme.monochrome.enabled) { var monoArr = []; var glsCnt = w.globals.series.length; if (w.config.plotOptions.bar.distributed && w.config.chart.type === 'bar') { glsCnt = w.globals.series[0].length * w.globals.series.length; } var mainColor = w.config.theme.monochrome.color; var part = 1 / (glsCnt / w.config.theme.monochrome.shadeIntensity); var shade = w.config.theme.monochrome.shadeTo; var percent = 0; for (var gsl = 0; gsl < glsCnt; gsl++) { var newColor = void 0; if (shade === 'dark') { newColor = utils.shadeColor(percent * -1, mainColor); percent = percent + part; } else { newColor = utils.shadeColor(percent, mainColor); percent = percent + part; } monoArr.push(newColor); } w.globals.colors = monoArr.slice(); } var defaultColors = w.globals.colors.slice(); // if user specfied less colors than no. of series, push the same colors again this.pushExtraColors(w.globals.colors); // The Border colors if (w.config.stroke.colors === undefined) { w.globals.stroke.colors = defaultColors; } else { w.globals.stroke.colors = w.config.stroke.colors; } this.pushExtraColors(w.globals.stroke.colors); // The FILL colors if (w.config.fill.colors === undefined) { w.globals.fill.colors = defaultColors; } else { w.globals.fill.colors = w.config.fill.colors; } this.pushExtraColors(w.globals.fill.colors); if (w.config.dataLabels.style.colors === undefined) { w.globals.dataLabels.style.colors = defaultColors; } else { w.globals.dataLabels.style.colors = w.config.dataLabels.style.colors; } this.pushExtraColors(w.globals.dataLabels.style.colors); // The point colors if (w.config.markers.colors === undefined) { w.globals.markers.colors = defaultColors; } else { w.globals.markers.colors = w.config.markers.colors; } this.pushExtraColors(w.globals.markers.colors); } // When the number of colors provided is less than the number of series, this method // will push same colors to the list // params: // distributed is only valid for distributed column/bar charts }, { key: 'pushExtraColors', value: function pushExtraColors(colorSeries) { var distributed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; var w = this.w; var len = w.globals.series.length; if (distributed === null) { distributed = w.config.chart.type === 'bar' && w.config.plotOptions.bar.distributed; } else { distributed = false; } if (distributed) { len = w.globals.series[0].length * w.globals.series.length; } if (colorSeries.length < len) { var diff = len - colorSeries.length; for (var i = 0; i < diff; i++) { colorSeries.push(colorSeries[i]); } } } }, { key: 'predefined', value: function predefined() { var palette = this.w.config.theme.palette; // D6E3F8, FCEFEF, DCE0D9, A5978B, EDDDD4, D6E3F8, FEF5EF switch (palette) { case 'palette1': this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0']; break; case 'palette2': this.colors = ['#3f51b5', '#03a9f4', '#4caf50', '#f9ce1d', '#FF9800']; break; case 'palette3': this.colors = ['#33b2df', '#546E7A', '#d4526e', '#13d8aa', '#A5978B']; break; case 'palette4': this.colors = ['#546E7A', '#4ecdc4', '#c7f464', '#81D4FA', '#fd6a6a']; break; case 'palette5': this.colors = ['#2b908f', '#f9a3a4', '#90ee7e', '#fa4443', '#69d2e7']; break; case 'palette6': this.colors = ['#449DD1', '#F86624', '#EA3546', '#662E9B', '#C5D86D']; break; case 'palette7': this.colors = ['#D7263D', '#1B998B', '#2E294E', '#F46036', '#C5D86D']; break; case 'palette8': this.colors = ['#662E9B', '#F86624', '#F9C80E', '#EA3546', '#43BCCD']; break; case 'palette9': this.colors = ['#5fba7d', '#f48024', '#8884d8', '#c34459', '#f9ee45']; break; case 'palette10': this.colors = ['#5C4742', '#A5978B', '#8D5B4C', '#5A2A27', '#C4BBAF']; break; case 'palette11': this.colors = ['#A300D6', '#7D02EB', '#5653FE', '#2983FF', '#00B1F2']; break; default: this.colors = ['#008FFB', '#00E396', '#FEB019', '#FF4560', '#775DD0']; break; } return this.colors; } }]); return Theme; }(); module.exports = Theme; /***/ }), /* 138 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var TitleSubtitle = function () { function TitleSubtitle(ctx) { _classCallCheck(this, TitleSubtitle); this.ctx = ctx; this.w = ctx.w; } _createClass(TitleSubtitle, [{ key: 'draw', value: function draw() { this.drawTitleSubtitle('title'); this.drawTitleSubtitle('subtitle'); } }, { key: 'drawTitleSubtitle', value: function drawTitleSubtitle(type) { var w = this.w; var tsConfig = type === 'title' ? w.config.title : w.config.subtitle; var x = w.globals.svgWidth / 2; var y = tsConfig.offsetY; var textAnchor = 'middle'; if (tsConfig.align === 'left') { x = 10; textAnchor = 'start'; } else if (tsConfig.align === 'right') { x = w.globals.svgWidth - 10; textAnchor = 'end'; } x = x + tsConfig.offsetX; y = y + parseInt(tsConfig.style.fontSize) + 2; if (tsConfig.text !== undefined) { var graphics = new _Graphics2.default(this.ctx); var titleText = graphics.drawText({ x: x, y: y, text: tsConfig.text, textAnchor: textAnchor, fontSize: tsConfig.style.fontSize, fontFamily: tsConfig.style.fontFamily, foreColor: tsConfig.style.color, opacity: 1 }); titleText.node.setAttribute('class', 'apexcharts-' + type + '-text'); w.globals.dom.Paper.add(titleText); } } }]); return TitleSubtitle; }(); exports.default = TitleSubtitle; /***/ }), /* 139 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); var _Toolbar2 = __webpack_require__(78); var _Toolbar3 = _interopRequireDefault(_Toolbar2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * ApexCharts Zoom Class for handling zooming and panning on axes based charts. * * @module ZoomPanSelection **/ var ZoomPanSelection = function (_Toolbar) { _inherits(ZoomPanSelection, _Toolbar); function ZoomPanSelection(ctx) { _classCallCheck(this, ZoomPanSelection); var _this = _possibleConstructorReturn(this, (ZoomPanSelection.__proto__ || Object.getPrototypeOf(ZoomPanSelection)).call(this, ctx)); _this.ctx = ctx; _this.w = ctx.w; _this.dragged = false; _this.graphics = new _Graphics2.default(_this.ctx); _this.eventList = ['mousedown', 'mousemove', 'touchstart', 'touchmove', 'mouseup', 'touchend']; _this.clientX = 0; _this.clientY = 0; _this.startX = 0; _this.endX = 0; _this.dragX = 0; _this.startY = 0; _this.endY = 0; _this.dragY = 0; return _this; } _createClass(ZoomPanSelection, [{ key: 'init', value: function init(_ref) { var xyRatios = _ref.xyRatios; var w = this.w; var me = this; this.xyRatios = xyRatios; this.zoomRect = this.graphics.drawRect(0, 0, 0, 0); this.selectionRect = this.graphics.drawRect(0, 0, 0, 0); this.gridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid'); this.zoomRect.node.classList.add('apexcharts-zoom-rect'); this.selectionRect.node.classList.add('apexcharts-selection-rect'); w.globals.dom.elGraphical.add(this.zoomRect); w.globals.dom.elGraphical.add(this.selectionRect); if (w.config.chart.selection.type === 'x') { this.slDraggableRect = this.selectionRect.draggable({ minX: 0, minY: 0, maxX: w.globals.gridWidth, maxY: w.globals.gridHeight }).on('dragmove', this.selectionDragging.bind(this, 'dragging')); } else if (w.config.chart.selection.type === 'y') { this.slDraggableRect = this.selectionRect.draggable({ minX: 0, maxX: w.globals.gridWidth }).on('dragmove', this.selectionDragging.bind(this, 'dragging')); } else { this.slDraggableRect = this.selectionRect.draggable().on('dragmove', this.selectionDragging.bind(this, 'dragging')); } this.preselectedSelection(); this.hoverArea = w.globals.dom.baseEl.querySelector(w.globals.chartClass); this.hoverArea.classList.add('zoomable'); var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = this.eventList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var event = _step.value; this.hoverArea.addEventListener(event, me.svgMouseEvents.bind(me, xyRatios), { capture: false, passive: true }); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } } // remove the event listeners which were previously added on hover area }, { key: 'destroy', value: function destroy() { var me = this; var _iteratorNormalCompletion2 = true; var _didIteratorError2 = false; var _iteratorError2 = undefined; try { for (var _iterator2 = this.eventList[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { var event = _step2.value; if (this.hoverArea) { this.hoverArea.removeEventListener(event, me.svgMouseEvents.bind(me, me.xyRatios), { capture: false, passive: true }); } } } catch (err) { _didIteratorError2 = true; _iteratorError2 = err; } finally { try { if (!_iteratorNormalCompletion2 && _iterator2.return) { _iterator2.return(); } } finally { if (_didIteratorError2) { throw _iteratorError2; } } } if (this.slDraggableRect) { this.slDraggableRect.draggable(false); this.slDraggableRect.off(); this.selectionRect.off(); } this.selectionRect = null; this.zoomRect = null; this.gridRect = null; } }, { key: 'svgMouseEvents', value: function svgMouseEvents(xyRatios, e) { var w = this.w; var me = this; var toolbar = this.ctx.toolbar; var zoomtype = w.globals.zoomEnabled ? w.config.chart.zoom.type : w.config.chart.selection.type; if (e.shiftKey) { this.shiftWasPressed = true; toolbar.enablePanning(); } else { if (this.shiftWasPressed) { toolbar.enableZooming(); this.shiftWasPressed = false; } } var falsePositives = e.target.classList.contains('apexcharts-selection-rect') || e.target.parentNode.classList.contains('apexcharts-toolbar'); if (falsePositives) return; me.clientX = e.type === 'touchmove' || e.type === 'touchstart' ? e.touches[0].clientX : e.type === 'touchend' ? e.changedTouches[0].clientX : e.clientX; me.clientY = e.type === 'touchmove' || e.type === 'touchstart' ? e.touches[0].clientY : e.type === 'touchend' ? e.changedTouches[0].clientY : e.clientY; if (e.type === 'mousedown' && e.which === 1) { var gridRectDim = me.gridRect.getBoundingClientRect(); me.startX = me.clientX - gridRectDim.left; me.startY = me.clientY - gridRectDim.top; me.dragged = false; me.w.globals.mousedown = true; } if (e.type === 'mousemove' && e.which === 1 || e.type === 'touchmove') { me.dragged = true; if (w.globals.panEnabled) { w.globals.selection = null; if (me.w.globals.mousedown) { me.panDragging({ context: me, zoomtype: zoomtype, xyRatios: xyRatios }); } } else { if (me.w.globals.mousedown && w.globals.zoomEnabled || me.w.globals.mousedown && w.globals.selectionEnabled) { me.selection = me.selectionDrawing({ context: me, zoomtype: zoomtype }); } } } if (e.type === 'mouseup' || e.type === 'touchend') { // we will be calling getBoundingClientRect on each mousedown/mousemove/mouseup var _gridRectDim = me.gridRect.getBoundingClientRect(); if (me.w.globals.mousedown) { // user released the drag, now do all the calculations me.endX = me.clientX - _gridRectDim.left; me.endY = me.clientY - _gridRectDim.top; me.dragX = Math.abs(me.endX - me.startX); me.dragY = Math.abs(me.endY - me.startY); if (w.globals.zoomEnabled || w.globals.selectionEnabled) { me.selectionDrawn({ context: me, zoomtype: zoomtype }); } } if (w.globals.zoomEnabled) { me.hideSelectionRect(this.selectionRect); } me.dragged = false; me.w.globals.mousedown = false; } this.makeSelectionRectDraggable(); } }, { key: 'makeSelectionRectDraggable', value: function makeSelectionRectDraggable() { var w = this.w; if (!this.selectionRect) return; var rectDim = this.selectionRect.node.getBoundingClientRect(); if (rectDim.width > 0 && rectDim.height > 0) { this.slDraggableRect.selectize().resize({ constraint: { minX: 0, minY: 0, maxX: w.globals.gridWidth, maxY: w.globals.gridHeight } }).on('resizing', this.selectionDragging.bind(this, 'resizing')); } } }, { key: 'preselectedSelection', value: function preselectedSelection() { var w = this.w; var xyRatios = this.xyRatios; if (!w.globals.zoomEnabled) { if (typeof w.globals.selection !== 'undefined' && w.globals.selection !== null) { this.drawSelectionRect(w.globals.selection); } else { if (w.config.chart.selection.xaxis.min !== undefined && w.config.chart.selection.xaxis.max !== undefined) { var x = (w.config.chart.selection.xaxis.min - w.globals.minX) / xyRatios.xRatio; var width = w.globals.gridWidth - (w.globals.maxX - w.config.chart.selection.xaxis.max) / xyRatios.xRatio - x; var selectionRect = { x: x, y: 0, width: width, height: w.globals.gridHeight, translateX: 0, translateY: 0, selectionEnabled: true }; this.drawSelectionRect(selectionRect); this.makeSelectionRectDraggable(); if (typeof w.config.chart.events.selection === 'function') { w.config.chart.events.selection(this.ctx, { xaxis: { min: w.config.chart.selection.xaxis.min, max: w.config.chart.selection.xaxis.max }, yaxis: {} }); } } } } } }, { key: 'drawSelectionRect', value: function drawSelectionRect(_ref2) { var x = _ref2.x, y = _ref2.y, width = _ref2.width, height = _ref2.height, translateX = _ref2.translateX, translateY = _ref2.translateY; var w = this.w; var zoomRect = this.zoomRect; var selectionRect = this.selectionRect; if (this.dragged || w.globals.selection !== null) { var scalingAttrs = { transform: 'translate(' + translateX + ', ' + translateY + ')' // change styles based on zoom or selection // zoom is Enabled and user has dragged, so draw blue rect };if (w.globals.zoomEnabled && this.dragged) { zoomRect.attr({ x: x, y: y, width: width, height: height, fill: w.config.chart.zoom.zoomedArea.fill.color, 'fill-opacity': w.config.chart.zoom.zoomedArea.fill.opacity, stroke: w.config.chart.zoom.zoomedArea.stroke.color, 'stroke-width': w.config.chart.zoom.zoomedArea.stroke.width, 'stroke-opacity': w.config.chart.zoom.zoomedArea.stroke.opacity }); _Graphics2.default.setAttrs(zoomRect.node, scalingAttrs); } // selection is enabled if (w.globals.selectionEnabled) { selectionRect.attr({ x: x, y: y, width: width, height: height, fill: w.config.chart.selection.fill.color, 'fill-opacity': w.config.chart.selection.fill.opacity, stroke: w.config.chart.selection.stroke.color, 'stroke-width': w.config.chart.selection.stroke.width, 'stroke-dasharray': w.config.chart.selection.stroke.dashArray, 'stroke-opacity': w.config.chart.selection.stroke.opacity }); _Graphics2.default.setAttrs(selectionRect.node, scalingAttrs); } } } }, { key: 'hideSelectionRect', value: function hideSelectionRect(rect) { if (rect) { rect.attr({ x: 0, y: 0, width: 0, height: 0 }); } } }, { key: 'selectionDrawing', value: function selectionDrawing(_ref3) { var context = _ref3.context, zoomtype = _ref3.zoomtype; var w = this.w; var me = context; var gridRectDim = this.gridRect.getBoundingClientRect(); var startX = me.startX - 1; var startY = me.startY; var selectionWidth = me.clientX - gridRectDim.left - startX; var selectionHeight = me.clientY - gridRectDim.top - startY; var translateX = 0; var translateY = 0; var selectionRect = {}; if (Math.abs(selectionWidth + startX) > w.globals.gridWidth || me.clientX - gridRectDim.left < 0) { // user dragged the mouse outside drawing area // TODO: test the selectionRect and make sure it doesn't crosses drawing area me.hideSelectionRect(this.zoomRect); me.dragged = false; me.w.globals.mousedown = false; } // inverse selection X if (startX > me.clientX - gridRectDim.left) { selectionWidth = Math.abs(selectionWidth); translateX = -selectionWidth; } // inverse selection Y if (startY > me.clientY - gridRectDim.top) { selectionHeight = Math.abs(selectionHeight); translateY = -selectionHeight; } if (zoomtype === 'x') { selectionRect = { x: startX, y: 0, width: selectionWidth, height: w.globals.gridHeight, translateX: translateX, translateY: 0 }; } else if (zoomtype === 'y') { selectionRect = { x: 0, y: startY, width: w.globals.gridWidth, height: selectionHeight, translateX: 0, translateY: translateY }; } else { selectionRect = { x: startX, y: startY, width: selectionWidth, height: selectionHeight, translateX: translateX, translateY: translateY }; } me.drawSelectionRect(selectionRect); return selectionRect; } }, { key: 'selectionDragging', value: function selectionDragging(type, e) { var _this2 = this; var w = this.w; var xyRatios = this.xyRatios; var selRect = this.selectionRect; var timerInterval = 0; if (type === 'resizing') { timerInterval = 30; } if (typeof w.config.chart.events.selection === 'function') { // a small debouncer is required when resizing to avoid freezing the chart clearTimeout(this.w.globals.selectionResizeTimer); this.w.globals.selectionResizeTimer = window.setTimeout(function () { var gridRectDim = _this2.gridRect.getBoundingClientRect(); var selectionRect = selRect.node.getBoundingClientRect(); var minX = w.globals.xAxisScale.niceMin + (selectionRect.left - gridRectDim.left) * xyRatios.xRatio; var maxX = w.globals.xAxisScale.niceMin + (selectionRect.right - gridRectDim.left) * xyRatios.xRatio; var minY = w.globals.yAxisScale[0].niceMin + (gridRectDim.bottom - selectionRect.bottom) * xyRatios.yRatio[0]; var maxY = w.globals.yAxisScale[0].niceMax - (selectionRect.top - gridRectDim.top) * xyRatios.yRatio[0]; w.config.chart.events.selection(_this2.ctx, { xaxis: { min: minX, max: maxX }, yaxis: { min: minY, max: maxY } }); }, timerInterval); } } }, { key: 'selectionDrawn', value: function selectionDrawn(_ref4) { var context = _ref4.context, zoomtype = _ref4.zoomtype; var w = this.w; var me = context; var xyRatios = this.xyRatios; var toolbar = this.ctx.toolbar; if (me.startX > me.endX) { var tempX = me.startX; me.startX = me.endX; me.endX = tempX; } if (me.startY > me.endY) { var tempY = me.startY; me.startY = me.endY; me.endY = tempY; } var xLowestValue = w.globals.xAxisScale.niceMin + me.startX * xyRatios.xRatio; var xHighestValue = w.globals.xAxisScale.niceMin + me.endX * xyRatios.xRatio; // TODO: we will consider the 1st y axis values here for getting highest and lowest y var yHighestValue = []; var yLowestValue = []; w.config.yaxis.forEach(function (yaxe, index) { yHighestValue.push(Math.floor(w.globals.yAxisScale[index].niceMax - xyRatios.yRatio[index] * me.startY)); yLowestValue.push(Math.floor(w.globals.yAxisScale[index].niceMax - xyRatios.yRatio[index] * me.endY)); }); if (me.dragged && (me.dragX > 10 || me.dragY > 10) && xLowestValue !== xHighestValue) { if (w.globals.zoomEnabled) { var yaxis = _Utils2.default.clone(w.config.yaxis); // before zooming in/out, store the last yaxis and xaxis range, so that when user hits the RESET button, we get the original range // also - make sure user is not already zoomed in/out - otherwise we will store zoomed values in lastAxis if (!w.globals.zoomed) { w.globals.lastXAxis = _Utils2.default.clone(w.config.xaxis); w.globals.lastYAxis = _Utils2.default.clone(w.config.yaxis); } var xaxis = { min: xLowestValue, max: xHighestValue }; if (zoomtype === 'xy' || zoomtype === 'y') { yaxis.forEach(function (yaxe, index) { yaxis[index].min = yLowestValue[index]; yaxis[index].max = yHighestValue[index]; }); } if (toolbar) { var beforeZoomRange = toolbar.getBeforeZoomRange(xaxis, yaxis); if (beforeZoomRange) { xaxis = beforeZoomRange.xaxis ? beforeZoomRange.xaxis : xaxis; yaxis = beforeZoomRange.yaxis ? beforeZoomRange.yaxe : yaxis; } } if (zoomtype === 'x') { me.ctx.updateOptionsInternal({ xaxis: xaxis }, false, me.w.config.chart.animations.dynamicAnimation.enabled); } else if (zoomtype === 'y') { me.ctx.updateOptionsInternal({ yaxis: yaxis }, false, me.w.config.chart.animations.dynamicAnimation.enabled); } else { me.ctx.updateOptionsInternal({ xaxis: xaxis, yaxis: yaxis }, false, me.w.config.chart.animations.dynamicAnimation.enabled); } if (typeof w.config.chart.events.zoomed === 'function') { toolbar.zoomCallback(xaxis, yaxis); } w.globals.zoomed = true; } else if (w.globals.selectionEnabled) { var _yaxis = null;var _xaxis = null; _xaxis = { min: xLowestValue, max: xHighestValue }; if (zoomtype === 'xy' || zoomtype === 'y') { _yaxis = _Utils2.default.clone(w.config.yaxis); _yaxis.forEach(function (yaxe, index) { _yaxis[index].min = yLowestValue[index]; _yaxis[index].max = yHighestValue[index]; }); } w.globals.selection = me.selection; if (typeof w.config.chart.events.selection === 'function') { w.config.chart.events.selection(me.ctx, { xaxis: _xaxis, yaxis: _yaxis }); } } } } }, { key: 'panDragging', value: function panDragging(_ref5) { var context = _ref5.context, zoomtype = _ref5.zoomtype; var w = this.w; var me = context; var moveDirection = void 0; // check to make sure there is data to compare against if (typeof w.globals.lastClientPosition.x !== 'undefined') { // get the change from last position to this position var deltaX = w.globals.lastClientPosition.x - me.clientX; var deltaY = w.globals.lastClientPosition.y - me.clientY; // check which direction had the highest amplitude and then figure out direction by checking if the value is greater or less than zero if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 0) { moveDirection = 'left'; } else if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX < 0) { moveDirection = 'right'; } else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY > 0) { moveDirection = 'up'; } else if (Math.abs(deltaY) > Math.abs(deltaX) && deltaY < 0) { moveDirection = 'down'; } } // set the new last position to the current for next time (to get the position of drag) w.globals.lastClientPosition = { x: me.clientX, y: me.clientY }; var xLowestValue = w.globals.minX; var xHighestValue = w.globals.maxX; this.panScrolled(moveDirection, xLowestValue, xHighestValue); } }, { key: 'panScrolled', value: function panScrolled(moveDirection, xLowestValue, xHighestValue) { var w = this.w; var xyRatios = this.xyRatios; if (moveDirection === 'left') { xLowestValue = w.globals.minX + w.globals.gridWidth / 15 * xyRatios.xRatio; xHighestValue = w.globals.maxX + w.globals.gridWidth / 15 * xyRatios.xRatio; } else if (moveDirection === 'right') { xLowestValue = w.globals.minX - w.globals.gridWidth / 15 * xyRatios.xRatio; xHighestValue = w.globals.maxX - w.globals.gridWidth / 15 * xyRatios.xRatio; } if (xLowestValue < w.globals.initialminX || xHighestValue > w.globals.initialmaxX) { xLowestValue = w.globals.minX; xHighestValue = w.globals.maxX; } this.ctx.updateOptionsInternal({ xaxis: { min: xLowestValue, max: xHighestValue } }, false, false); if (typeof w.config.chart.events.scrolled === 'function') { w.config.chart.events.scrolled(this.ctx, { xaxis: { min: xLowestValue, max: xHighestValue } }); } } }]); return ZoomPanSelection; }(_Toolbar3.default); module.exports = ZoomPanSelection; /***/ }), /* 140 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Animations = __webpack_require__(25); var _Animations2 = _interopRequireDefault(_Animations); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _XAxis = __webpack_require__(48); var _XAxis2 = _interopRequireDefault(_XAxis); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Grid Class for drawing Cartesian Grid. * * @module Grid **/ var Grid = function () { function Grid(ctx) { _classCallCheck(this, Grid); this.ctx = ctx; this.w = ctx.w; var w = this.w; this.anim = new _Animations2.default(this.ctx); this.xaxisLabels = w.globals.labels.slice(); this.animX = w.config.grid.xaxis.lines.animate && w.config.chart.animations.enabled; this.animY = w.config.grid.yaxis.lines.animate && w.config.chart.animations.enabled; if (w.globals.timelineLabels.length > 0) { // timeline labels are there this.xaxisLabels = w.globals.timelineLabels.slice(); } } // .when using sparklines or when showing no grid, we need to have a grid area which is reused at many places for other calculations as well _createClass(Grid, [{ key: 'drawGridArea', value: function drawGridArea() { var elGrid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var w = this.w; var graphics = new _Graphics2.default(this.ctx); if (elGrid === null) { elGrid = graphics.group({ 'class': 'apexcharts-grid' }); } var elVerticalLine = graphics.drawLine(w.globals.padHorizontal, 1, w.globals.padHorizontal, w.globals.gridHeight, 'transparent'); var elHorzLine = graphics.drawLine(w.globals.padHorizontal, w.globals.gridHeight, w.globals.gridWidth, w.globals.gridHeight, 'transparent'); elGrid.add(elHorzLine); elGrid.add(elVerticalLine); return elGrid; } // actual grid }, { key: 'renderGrid', value: function renderGrid() { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var strokeDashArray = w.config.grid.strokeDashArray; var elg = graphics.group({ 'class': 'apexcharts-grid' }); var tickAmount = 8; for (var i = 0; i < w.globals.series.length; i++) { if (typeof w.globals.yAxisScale[i] !== 'undefined') { tickAmount = w.globals.yAxisScale[i].result.length - 1; } if (tickAmount > 2) break; } var xCount = void 0; var inversedGrid = !!(w.config.plotOptions.bar.horizontal && w.config.chart.type === 'bar'); if (!inversedGrid) { xCount = this.xaxisLabels.length; // draw vertical lines if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) { var x1 = w.globals.padHorizontal; var y1 = 0; var x2 = void 0; var y2 = w.globals.gridHeight; if (w.globals.timelineLabels.length > 0) { for (var _i = 0; _i < xCount; _i++) { x1 = this.xaxisLabels[_i].position;x2 = this.xaxisLabels[_i].position; if (w.config.grid.xaxis.lines.show && x1 > 0 && x1 < w.globals.gridWidth) { var line = graphics.drawLine(x1, y1, x2, y2, w.config.grid.borderColor, strokeDashArray); line.node.classList.add('apexcharts-gridline'); elg.add(line); if (this.animX) { this.animateLine(line, { x1: 0, x2: 0 }, { x1: x1, x2: x2 }); } } var xAxis = new _XAxis2.default(this.ctx); xAxis.drawXaxisTicks(x1, elg); } } else { var xCountForCategoryCharts = xCount; for (var _i2 = 0; _i2 < xCountForCategoryCharts; _i2++) { var x1Count = xCountForCategoryCharts; if (w.globals.isXNumeric && w.config.chart.type !== 'bar') { x1Count -= 1; } x1 = x1 + w.globals.gridWidth / x1Count; x2 = x1; // skip the last line if (_i2 === x1Count - 1) break; if (w.config.grid.xaxis.lines.show) { var _line = graphics.drawLine(x1, y1, x2, y2, w.config.grid.borderColor, strokeDashArray); _line.node.classList.add('apexcharts-gridline'); elg.add(_line); if (this.animX) { this.animateLine(_line, { x1: 0, x2: 0 }, { x1: x1, x2: x2 }); } } var _xAxis = new _XAxis2.default(this.ctx); _xAxis.drawXaxisTicks(x1, elg); } } } // draw horizontal lines if (w.config.grid.yaxis.lines.show) { var _x2 = 0; var _y = 0; var _y2 = 0; var _x3 = w.globals.gridWidth; for (var _i3 = 0; _i3 < tickAmount + 1; _i3++) { var _line2 = graphics.drawLine(_x2, _y, _x3, _y2, w.config.grid.borderColor, strokeDashArray); elg.add(_line2); _line2.node.classList.add('apexcharts-gridline'); if (this.animY) { this.animateLine(_line2, { y1: _y + 20, y2: _y2 + 20 }, { y1: _y, y2: _y2 }); } _y = _y + w.globals.gridHeight / tickAmount; _y2 = _y; } } } else { xCount = tickAmount; // draw vertical lines if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) { var _x4 = w.globals.padHorizontal; var _y3 = 0; var _x5 = void 0; var _y4 = w.globals.gridHeight; for (var _i4 = 0; _i4 < xCount + 1; _i4++) { _x4 = _x4 + w.globals.gridWidth / xCount + 0.3; _x5 = _x4; // skip the last vertical line if (_i4 === xCount - 1) break; if (w.config.grid.xaxis.lines.show) { var _line3 = graphics.drawLine(_x4, _y3, _x5, _y4, w.config.grid.borderColor, strokeDashArray); _line3.node.classList.add('apexcharts-gridline'); elg.add(_line3); if (this.animX) { this.animateLine(_line3, { x1: 0, x2: 0 }, { x1: _x4, x2: _x5 }); } } // skip the first vertical line var _xAxis2 = new _XAxis2.default(this.ctx); _xAxis2.drawXaxisTicks(_x4, elg); } } // draw horizontal lines if (w.config.grid.yaxis.lines.show) { var _x6 = 0; var _y5 = 0; var _y6 = 0; var _x7 = w.globals.gridWidth; for (var _i5 = 0; _i5 < w.globals.dataPoints + 1; _i5++) { var _line4 = graphics.drawLine(_x6, _y5, _x7, _y6, w.config.grid.borderColor, strokeDashArray); elg.add(_line4); _line4.node.classList.add('apexcharts-gridline'); if (this.animY) { this.animateLine(_line4, { y1: _y5 + 20, y2: _y6 + 20 }, { y1: _y5, y2: _y6 }); } _y5 = _y5 + w.globals.gridHeight / w.globals.dataPoints; _y6 = _y5; } } } this.drawGridBands(elg, xCount, tickAmount); return { el: elg, xAxisTickWidth: w.globals.gridWidth / xCount }; } }, { key: 'drawGridBands', value: function drawGridBands(elg, xCount, tickAmount) { var w = this.w; var graphics = new _Graphics2.default(this.ctx); // rows background bands if (w.config.grid.row.colors !== undefined && w.config.grid.row.colors.length > 0) { var x1 = 0; var y1 = 0; var y2 = w.globals.gridHeight / tickAmount; var x2 = w.globals.gridWidth; for (var i = 0, c = 0; i < tickAmount; i++, c++) { if (c >= w.config.grid.row.colors.length) { c = 0; } var color = w.config.grid.row.colors[c]; var rect = graphics.drawRect(x1, y1, x2, y2, 0, color, w.config.grid.row.opacity); elg.add(rect); rect.node.classList.add('apexcharts-gridRow'); y1 = y1 + w.globals.gridHeight / tickAmount; } } // columns background bands if (w.config.grid.column.colors !== undefined && w.config.grid.column.colors.length > 0) { var _x8 = w.globals.padHorizontal; var _y7 = 0; var _x9 = w.globals.padHorizontal + w.globals.gridWidth / xCount; var _y8 = w.globals.gridHeight; for (var _i6 = 0, _c = 0; _i6 < xCount; _i6++, _c++) { if (_c >= w.config.grid.column.colors.length) { _c = 0; } var _color = w.config.grid.column.colors[_c]; var _rect = graphics.drawRect(_x8, _y7, _x9, _y8, 0, _color, w.config.grid.column.opacity); _rect.node.classList.add('apexcharts-gridColumn'); elg.add(_rect); _x8 = _x8 + w.globals.gridWidth / xCount; } } } }, { key: 'animateLine', value: function animateLine(line, from, to) { var w = this.w; var initialAnim = w.config.chart.animations; if (initialAnim && !w.globals.resized && !w.globals.dataChanged) { var speed = initialAnim.speed; this.anim.animateLine(line, from, to, speed); } } }]); return Grid; }(); exports.default = Grid; /***/ }), /* 141 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Default Class for setting default options for all chart types. * * @module Defaults **/ var Defaults = function () { function Defaults(opts) { _classCallCheck(this, Defaults); this.opts = opts; } _createClass(Defaults, [{ key: 'line', value: function line() { return { chart: { animations: { easing: 'swing' } }, dataLabels: { enabled: false }, stroke: { width: 5, curve: 'straight' }, markers: { size: 5 }, xaxis: { crosshairs: { width: 1 } } }; } }, { key: 'sparkline', value: function sparkline(defaults) { this.opts.yaxis[0].labels.show = false; this.opts.yaxis[0].floating = true; var ret = { grid: { show: false, padding: { left: 0, right: 0, top: 0, bottom: 0 } }, legend: { show: false }, xaxis: { labels: { show: false }, tooltip: { enabled: false }, axisBorder: { show: false } }, chart: { toolbar: { show: false }, zoom: { enabled: false } }, dataLabels: { enabled: false } }; return _Utils2.default.extend(defaults, ret); } }, { key: 'bar', value: function bar() { return { chart: { stacked: false, toolbar: { show: false }, animations: { easing: 'swing' } }, plotOptions: { bar: { dataLabels: { position: 'center' } } }, dataLabels: { style: { colors: ['#fff'] } }, stroke: { width: 0 }, fill: { opacity: 0.85 }, legend: { markers: { shape: 'square', radius: 2, size: 8 } }, tooltip: { shared: false }, xaxis: { tooltip: { enabled: false }, crosshairs: { width: 'barWidth', position: 'back', fill: { type: 'gradient' }, dropShadow: { enabled: false } } } }; } }, { key: 'candlestick', value: function candlestick() { return { stroke: { width: 1, colors: ['#333'] }, dataLabels: { enabled: false }, tooltip: { shared: true, custom: function custom(_ref) { var seriesIndex = _ref.seriesIndex, dataPointIndex = _ref.dataPointIndex, w = _ref.w; var o = w.globals.seriesCandleO[seriesIndex][dataPointIndex]; var h = w.globals.seriesCandleH[seriesIndex][dataPointIndex]; var l = w.globals.seriesCandleL[seriesIndex][dataPointIndex]; var c = w.globals.seriesCandleC[seriesIndex][dataPointIndex]; return '<div class="apexcharts-tooltip-candlestick">' + '<div>Open: <span class="value">' + o + '</span></div>' + '<div>High: <span class="value">' + h + '</span></div>' + '<div>Low: <span class="value">' + l + '</span></div>' + '<div>Close: <span class="value">' + c + '</span></div>' + '</div>'; } }, states: { active: { filter: { type: 'none' } } }, xaxis: { crosshairs: { width: 1 } } }; } }, { key: 'area', value: function area() { return { stroke: { width: 4 }, fill: { type: 'gradient', gradient: { inverseColors: false, shade: 'light', type: 'vertical', opacityFrom: 0.65, opacityTo: 0.5, stops: [0, 100, 100] } }, tooltip: { followCursor: false } }; } }, { key: 'brush', value: function brush(defaults) { var ret = { chart: { toolbar: { autoSelected: 'selection', show: false }, zoom: { enabled: false } }, dataLabels: { enabled: false }, stroke: { width: 1 }, tooltip: { enabled: false }, xaxis: { tooltip: { enabled: false } } }; return _Utils2.default.extend(defaults, ret); } }, { key: 'stacked100', value: function stacked100() { var _this = this; this.opts.dataLabels = this.opts.dataLabels || {}; this.opts.dataLabels.formatter = this.opts.dataLabels.formatter || undefined; var existingDataLabelFormatter = this.opts.dataLabels.formatter; this.opts.yaxis.forEach(function (yaxe, index) { _this.opts.yaxis[index].min = 0; _this.opts.yaxis[index].max = 100; }); var isBar = !!(this.opts.chart.type === 'bar'); if (isBar) { this.opts.dataLabels.formatter = existingDataLabelFormatter || function (val) { if (typeof val === 'number') { return val ? val.toFixed(0) + '%' : val; } return val; }; } } }, { key: 'bubble', value: function bubble() { return { dataLabels: { style: { colors: ['#fff'] } }, tooltip: { shared: false, intersect: true }, xaxis: { crosshairs: { width: 0 } }, fill: { type: 'solid', gradient: { shade: 'light', inverse: true, shadeIntensity: 0.55, opacityFrom: 0.4, opacityTo: 0.8 } } }; } }, { key: 'scatter', value: function scatter() { return { dataLabels: { enabled: false }, tooltip: { shared: false, intersect: true }, markers: { size: 6, strokeWidth: 2, hover: { size: 8 } } }; } }, { key: 'heatmap', value: function heatmap() { return { chart: { zoom: { enabled: false }, toolbar: { show: false } }, fill: { opacity: 1 }, dataLabels: { style: { colors: ['#fff'] } }, stroke: { colors: ['#fff'] }, tooltip: { followCursor: true, marker: { show: false } }, legend: { position: 'top', markers: { shape: 'square', size: 10, offsetY: 2 } } }; } }, { key: 'pie', value: function pie() { return { chart: { toolbar: { show: false } }, dataLabels: { formatter: function formatter(val) { return val.toFixed(1) + '%'; }, style: { colors: ['#fff'] }, dropShadow: { enabled: true } }, stroke: { colors: ['#fff'] }, fill: { opacity: 1, gradient: { shade: 'dark', shadeIntensity: 0.35, inverseColors: false, stops: [0, 100, 100] } }, tooltip: { theme: 'dark', fillSeriesColor: true }, legend: { position: 'right' } }; } }, { key: 'donut', value: function donut() { return { chart: { toolbar: { show: false } }, dataLabels: { formatter: function formatter(val) { return val.toFixed(1) + '%'; }, style: { colors: ['#fff'] }, dropShadow: { enabled: true } }, stroke: { colors: ['#fff'] }, fill: { opacity: 1, gradient: { shade: 'dark', shadeIntensity: 0.4, inverseColors: false, type: 'vertical', opacityFrom: 1, opacityTo: 1, stops: [70, 98, 100] } }, tooltip: { theme: 'dark', fillSeriesColor: true }, legend: { position: 'right' } }; } }, { key: 'radialBar', value: function radialBar() { return { chart: { animations: { dynamicAnimation: { enabled: true, speed: 800 } }, toolbar: { show: false } }, fill: { gradient: { shade: 'dark', shadeIntensity: 0.4, inverseColors: false, type: 'diagonal2', opacityFrom: 1, opacityTo: 1, stops: [70, 98, 100] } }, legend: { show: false }, tooltip: { enabled: false, fillSeriesColor: true } }; } }]); return Defaults; }(); module.exports = Defaults; /***/ }), /* 142 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Globals = function () { function Globals() { _classCallCheck(this, Globals); } _createClass(Globals, [{ key: 'globalVars', value: function globalVars(config) { return { chartID: null, // chart ID - apexcharts-cuid cuid: null, // chart ID - random numbers excluding "apexcharts" part events: { beforeMount: [], mounted: [], updated: [], clicked: [], selection: [], dataPointSelection: [], zoomed: [], scrolled: [] }, colors: [], fill: { colors: [] }, stroke: { colors: [] }, dataLabels: { style: { colors: [] } }, markers: { colors: [] }, isDirty: false, // chart has been updated after the initial render. This is different than dataChanged property. isDirty means user manually called some method to update initialConfig: null, // we will store the first config user has set to go back when user finishes interactions like zooming and come out of it lastXAxis: [], lastYAxis: [], series: [], // the MAIN series array (y values) seriesPercent: [], // the percentage values of the given series seriesTotals: [], stackedSeriesTotals: [], seriesX: [], // store the numeric x values in this array (x values) seriesZ: [], // The 3rd "Z" dimension for bubbles chart (z values) labels: [], // store the text to draw on x axis // Don't mutate the labels, many things including tooltips depends on it! timelineLabels: [], // store the timeline Labels in another variable seriesNames: [], // same as labels, used in non axis charts noLabelsProvided: false, // if user didn't provide any categories/labels or x values, fallback to 1,2,3,4... collapsedSeries: [], // when user collapses a series, it goes into this array collapsedSeriesIndices: [], // this just stores the index of the collapsedSeries instead of whole object risingSeries: [], // when user re-opens a collapsed series, it goes here selectedDataPoints: [], ignoreYAxisIndexes: [], // when series are being collapsed in multiple y axes, ignore certain index padHorizontal: 0, maxValsInArrayIndex: 0, zoomEnabled: config.chart.toolbar.autoSelected === 'zoom' && config.chart.toolbar.tools.zoom && config.chart.zoom.enabled, panEnabled: config.chart.toolbar.autoSelected === 'pan' && config.chart.toolbar.tools.pan, selectionEnabled: config.chart.toolbar.autoSelected === 'selection' && config.chart.toolbar.tools.selection, yaxis: null, minY: Number.MIN_VALUE, // is 5e-324, i.e. the smallest positive number // NOTE: If there are multiple y axis, the first yaxis array element will be considered for all y values calculations. Rest all will be calculated based on that maxY: -Number.MAX_VALUE, // is -1.7976931348623157e+308 // NOTE: The above note for minY apllies here as well minYArr: [], maxYArr: [], maxX: -Number.MAX_VALUE, // is -1.7976931348623157e+308 initialmaxX: -Number.MAX_VALUE, minX: Number.MAX_VALUE, // is 5e-324, i.e. the smallest positive number initialminX: Number.MAX_VALUE, minZ: Number.MAX_VALUE, // Max Z value in charts with Z axis maxZ: -Number.MAX_VALUE, // Max Z value in charts with Z axis mousedown: false, lastClientPosition: {}, // don't reset this variable this the chart is destroyed. It is used to detect right or left mousemove in panning visibleXRange: undefined, yRange: [], // this property is the absolute sum of positive and negative values [eg (-100 + 200 = 300)] - yAxis zRange: 0, // zAxis Range (for bubble charts) xRange: 0, // xAxis range yValueDecimal: 0, // are there floating numbers in the series. If yes, this represent the len of the decimals total: 0, svgNS: 'http://www.w3.org/2000/svg', // svg namespace svgWidth: 0, // the whole svg width svgHeight: 0, // the whole svg height noData: false, // whether there is any data to display or not locale: {}, // the current locale values will be preserved here for global access dom: {}, // for storing all dom nodes in this particular property // elWrap: null, // the element that wraps everything // elGraphical: null, // this contains lines/areas/bars/pies // elGridRect: null, // paths going outside this area will be clipped // elGridRectMask: null, // clipping will happen with this mask // elLegendWrap: null, // the whole legend area // elDefs: null, // [defs] element memory: { methodsToExec: [] }, shouldAnimate: true, delayedElements: [], // element which appear after animation has finished axisCharts: true, // chart type = line or area or bar // (refer them also as plot charts in the code) isXNumeric: false, // bool: data was provided in a {[x,y], [x,y]} pattern isDataXYZ: false, // bool: data was provided in a {[x,y,z]} pattern resized: false, // bool: user has resized resizeTimer: null, // timeout function to make a small delay before // drawing when user resized comboCharts: false, // bool: whether it's a combination of line/column dataChanged: false, // bool: has data changed dynamically previousPaths: [], // array: when data is changed, it will animate from // previous paths seriesXvalues: [], // we will need this in tooltip (it's x position) // when we will have unequal x values, we will need // some way to get x value depending on mouse pointer seriesYvalues: [], // we will need this when deciding which series // user hovered on seriesCandleO: [], // candle stick open values seriesCandleH: [], // candle stick high values seriesCandleL: [], // candle stick low values seriesCandleC: [], // candle stick close values dataPoints: 0, // the longest series length pointsArray: [], // store the points positions here to draw later on hover // format is - [[x,y],[x,y]... [x,y]] dataLabelsRects: [], // store the positions of datalabels to prevent collision lastDrawnDataLabelsIndexes: [], hasNullValues: false, // bool: whether series contains null values easing: null, // function: animation effect to apply zoomed: false, // whether user has zoomed or not gridWidth: 0, // drawable width of actual graphs (series paths) gridHeight: 0, // drawable height of actual graphs (series paths) yAxisScale: [], xAxisScale: null, xAxisTicksPositions: [], timescaleTicks: [], rotateXLabels: false, defaultLabels: false, xLabelFormatter: undefined, // formatter for x axis labels yLabelFormatters: [], xaxisTooltipFormatter: undefined, // formatter for x axis tooltip ttKeyFormatter: undefined, ttVal: undefined, ttZFormatter: undefined, lineHeightRatio: 1.618, xAxisLabelsHeight: 0, yAxisLabelsWidth: 0, scaleX: 1, scaleY: 1, translateX: 0, translateY: 0, translateYAxisX: [], yLabelsCoords: [], yTitleCoords: [], yAxisWidths: [], translateXAxisY: 0, translateXAxisX: 0, tooltip: null, tooltipOpts: null }; } }, { key: 'init', value: function init(config) { var globals = this.globalVars(config); globals.initialConfig = _Utils2.default.extend({}, config); globals.initialSeries = JSON.parse(JSON.stringify(globals.initialConfig.series)); globals.lastXAxis = JSON.parse(JSON.stringify(globals.initialConfig.xaxis)); globals.lastYAxis = JSON.parse(JSON.stringify(globals.initialConfig.yaxis)); return globals; } }]); return Globals; }(); exports.default = Globals; /***/ }), /* 143 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Tooltip.AxesTooltip Class. * * @module Tooltip.AxesTooltip **/ var AxesTooltip = function () { function AxesTooltip(tooltipContext) { _classCallCheck(this, AxesTooltip); this.w = tooltipContext.w; this.ttCtx = tooltipContext; } /** * This method adds the secondary tooltip which appears below x axis * @memberof Tooltip **/ _createClass(AxesTooltip, [{ key: 'drawXaxisTooltip', value: function drawXaxisTooltip() { var w = this.w; var ttCtx = this.ttCtx; var isBottom = w.config.xaxis.position === 'bottom'; ttCtx.xaxisOffY = isBottom ? w.globals.gridHeight + 1 : 1; var tooltipCssClass = isBottom ? 'apexcharts-xaxistooltip apexcharts-xaxistooltip-bottom' : 'apexcharts-xaxistooltip apexcharts-xaxistooltip-top'; var renderTo = w.globals.dom.elWrap; if (ttCtx.blxaxisTooltip) { var xaxisTooltip = w.globals.dom.baseEl.querySelector('.apexcharts-xaxistooltip'); if (xaxisTooltip === null) { ttCtx.xaxisTooltip = document.createElement('div'); ttCtx.xaxisTooltip.setAttribute('class', tooltipCssClass); renderTo.appendChild(ttCtx.xaxisTooltip); ttCtx.xaxisTooltipText = document.createElement('div'); ttCtx.xaxisTooltipText.classList.add('apexcharts-xaxistooltip-text'); ttCtx.xaxisTooltip.appendChild(ttCtx.xaxisTooltipText); } } } /** * This method adds the secondary tooltip which appears below x axis * @memberof Tooltip **/ }, { key: 'drawYaxisTooltip', value: function drawYaxisTooltip() { var w = this.w; var ttCtx = this.ttCtx; for (var i = 0; i < w.config.yaxis.length; i++) { var isRight = w.config.yaxis[i].opposite || w.config.yaxis[i].crosshairs.opposite; ttCtx.yaxisOffX = isRight ? w.globals.gridWidth + 1 : 1; var tooltipCssClass = isRight ? 'apexcharts-yaxistooltip apexcharts-yaxistooltip-' + i + ' apexcharts-yaxistooltip-right' : 'apexcharts-yaxistooltip apexcharts-yaxistooltip-' + i + ' apexcharts-yaxistooltip-left'; var renderTo = w.globals.dom.elWrap; if (ttCtx.blyaxisTooltip) { var yaxisTooltip = w.globals.dom.baseEl.querySelector('.apexcharts-yaxistooltip apexcharts-yaxistooltip-' + i); if (yaxisTooltip === null) { ttCtx.yaxisTooltip = document.createElement('div'); ttCtx.yaxisTooltip.setAttribute('class', tooltipCssClass); renderTo.appendChild(ttCtx.yaxisTooltip); if (i === 0) ttCtx.yaxisTooltipText = []; ttCtx.yaxisTooltipText.push(document.createElement('div')); ttCtx.yaxisTooltipText[i].classList.add('apexcharts-yaxistooltip-text'); ttCtx.yaxisTooltip.appendChild(ttCtx.yaxisTooltipText[i]); } } } } /** * @memberof Tooltip **/ }, { key: 'setXCrosshairWidth', value: function setXCrosshairWidth() { var w = this.w; var ttCtx = this.ttCtx; // set xcrosshairs width var xcrosshairs = ttCtx.getElXCrosshairs(); ttCtx.xcrosshairsWidth = parseInt(w.config.xaxis.crosshairs.width); if (!w.globals.comboCharts) { if (w.config.xaxis.crosshairs.width === 'tickWidth') { var count = w.globals.labels.length; ttCtx.xcrosshairsWidth = w.globals.gridWidth / count; } else if (w.config.xaxis.crosshairs.width === 'barWidth') { var bar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-area'); if (bar !== null) { var barWidth = parseFloat(bar.getAttribute('barWidth')); ttCtx.xcrosshairsWidth = barWidth; } else { ttCtx.xcrosshairsWidth = 1; } } } else { var _bar = w.globals.dom.baseEl.querySelector('.apexcharts-bar-area'); if (_bar !== null && w.config.xaxis.crosshairs.width === 'barWidth') { var _barWidth = parseFloat(_bar.getAttribute('barWidth')); ttCtx.xcrosshairsWidth = _barWidth; } else { if (w.config.xaxis.crosshairs.width === 'tickWidth') { var _count = w.globals.labels.length; ttCtx.xcrosshairsWidth = w.globals.gridWidth / _count; } } } if (w.config.chart.type === 'bar' && w.config.plotOptions.bar.horizontal) { ttCtx.xcrosshairsWidth = 0; } if (xcrosshairs !== null) { xcrosshairs.setAttribute('width', ttCtx.xcrosshairsWidth); } } }, { key: 'handleYCrosshair', value: function handleYCrosshair() { var w = this.w; var ttCtx = this.ttCtx; // set ycrosshairs height ttCtx.ycrosshairs = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs'); ttCtx.ycrosshairsHidden = w.globals.dom.baseEl.querySelector('.apexcharts-ycrosshairs-hidden'); } }, { key: 'drawYaxisTooltipText', value: function drawYaxisTooltipText(index, clientY, xyRatios) { var ttCtx = this.ttCtx; var w = this.w; var lbFormatter = w.globals.yLabelFormatters[index]; if (ttCtx.blyaxisTooltip) { var elGrid = ttCtx.getElGrid(); var seriesBound = elGrid.getBoundingClientRect(); var hoverY = (clientY - seriesBound.top) * xyRatios.yRatio[index]; var height = w.globals.maxYArr[index] - w.globals.minYArr[index]; var val = w.globals.minYArr[index] + (height - hoverY); ttCtx.tooltipPosition.moveYCrosshairs(clientY - seriesBound.top); ttCtx.yaxisTooltipText[index].innerHTML = lbFormatter(val); ttCtx.tooltipPosition.moveYAxisTooltip(index); } } }]); return AxesTooltip; }(); exports.default = AxesTooltip; /***/ }), /* 144 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Utils = __webpack_require__(1); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Tooltip.Intersect Class. * * @module Tooltip.Intersect **/ var Intersect = function () { function Intersect(tooltipContext) { _classCallCheck(this, Intersect); this.getAttr = function (e, attr) { return parseFloat(e.target.getAttribute(attr)); }; this.w = tooltipContext.w; this.ttCtx = tooltipContext; } _createClass(Intersect, [{ key: 'handleHeatTooltip', value: function handleHeatTooltip(_ref) { var e = _ref.e, opt = _ref.opt, x = _ref.x, y = _ref.y; var ttCtx = this.ttCtx; var w = this.w; if (e.target.classList.contains('apexcharts-heatmap-rect')) { var i = this.getAttr(e, 'i'); var j = this.getAttr(e, 'j'); var cx = this.getAttr(e, 'cx'); var cy = this.getAttr(e, 'cy'); var width = this.getAttr(e, 'width'); var height = this.getAttr(e, 'height'); ttCtx.tooltipLabels.drawSeriesTexts({ ttItems: opt.ttItems, i: i, j: j, shared: false }); x = cx + ttCtx.tooltipRect.ttWidth / 2 + width / 2; y = cy + ttCtx.tooltipRect.ttHeight / 2 - height / 2; if (x > w.globals.gridWidth / 2) { x = cx - ttCtx.tooltipRect.ttWidth / 2 + width; } if (ttCtx.w.config.tooltip.followCursor) { var elGrid = ttCtx.getElGrid(); var seriesBound = elGrid.getBoundingClientRect(); // x = ttCtx.e.clientX - seriesBound.left y = ttCtx.e.clientY - seriesBound.top; } } return { x: x, y: y }; } }, { key: 'handleMarkerTooltip', value: function handleMarkerTooltip(_ref2) { var e = _ref2.e, opt = _ref2.opt, x = _ref2.x, y = _ref2.y; var w = this.w; var ttCtx = this.ttCtx; var i = void 0; var j = void 0; if (e.target.classList.contains('apexcharts-marker')) { var cx = parseInt(opt.paths.getAttribute('cx')); var cy = parseInt(opt.paths.getAttribute('cy')); var val = parseFloat(opt.paths.getAttribute('val')); j = parseInt(opt.paths.getAttribute('rel')); i = parseInt(opt.paths.parentNode.parentNode.parentNode.getAttribute('rel')) - 1; if (ttCtx.intersect) { var el = _Utils2.default.findAncestor(opt.paths, 'apexcharts-series'); if (el) { i = parseInt(el.getAttribute('data:realIndex')); } } ttCtx.tooltipLabels.drawSeriesTexts({ ttItems: opt.ttItems, i: i, j: j, shared: ttCtx.intersect ? false : w.config.tooltip.shared }); ttCtx.marker.enlargeCurrentPoint(j, opt.paths); // let dataPointsDividedWidth = w.globals.gridWidth/(w.globals.dataPoints + 1); x = cx; y = cy - ttCtx.tooltipRect.ttHeight * 1.4; if (ttCtx.w.config.tooltip.followCursor) { var elGrid = ttCtx.getElGrid(); var seriesBound = elGrid.getBoundingClientRect(); y = ttCtx.e.clientY - seriesBound.top; } if (val < 0) { y = cy; } } return { x: x, y: y }; } }, { key: 'handleBarTooltip', value: function handleBarTooltip(_ref3) { var e = _ref3.e, opt = _ref3.opt; var w = this.w; var ttCtx = this.ttCtx; var tooltipEl = ttCtx.getElTooltip(); var bx = 0; var x = 0; var y = 0; if (ttCtx.isBarHorizontal && ttCtx.hasBars() || !w.config.tooltip.shared) { var barXY = this.getBarTooltipXY({ e: e, opt: opt }); x = barXY.x; y = barXY.y; bx = x; } else { if (!w.globals.comboCharts && !w.config.tooltip.shared) { bx = bx / 2; } } // y is NaN, make it touch the bottom of grid area if (isNaN(y)) { y = w.globals.svgHeight - ttCtx.tooltipRect.ttHeight; } // x exceeds gridWidth if (x + ttCtx.tooltipRect.ttWidth > w.globals.gridWidth) { x = x - ttCtx.tooltipRect.ttWidth; } else if (x < 0) { x = x + ttCtx.tooltipRect.ttWidth; } if (ttCtx.w.config.tooltip.followCursor) { var elGrid = ttCtx.getElGrid(); var seriesBound = elGrid.getBoundingClientRect(); y = ttCtx.e.clientY - seriesBound.top; } // if tooltip is still null, querySelector if (ttCtx.tooltip === null) { ttCtx.tooltip = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip'); } if (!w.globals.comboCharts && !w.config.tooltip.shared) { ttCtx.tooltipPosition.moveXCrosshairs(bx); } // move tooltip here if (!ttCtx.fixedTooltip && (!w.config.tooltip.shared || ttCtx.isBarHorizontal && ttCtx.hasBars())) { tooltipEl.style.left = x + w.globals.translateX + 'px'; if (ttCtx.tooltipRect.ttHeight + y > w.globals.gridHeight) { y = w.globals.gridHeight - ttCtx.tooltipRect.ttHeight + w.globals.translateY; tooltipEl.style.top = y + 'px'; } else { tooltipEl.style.top = y + w.globals.translateY - ttCtx.tooltipRect.ttHeight / 2 + 'px'; } } } }, { key: 'getBarTooltipXY', value: function getBarTooltipXY(_ref4) { var e = _ref4.e, opt = _ref4.opt; var w = this.w; var j = null; var ttCtx = this.ttCtx; var x = 0; var y = 0; var cl = e.target.classList; if (cl.contains('apexcharts-bar-area') || cl.contains('apexcharts-candlestick-area')) { var bar = e.target; var barRect = bar.getBoundingClientRect(); var seriesBound = opt.elGrid.getBoundingClientRect(); var bh = barRect.height; var bw = barRect.width; var cx = parseInt(bar.getAttribute('cx')); var cy = parseInt(bar.getAttribute('cy')); var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX; j = parseInt(bar.getAttribute('j')); var i = parseInt(bar.parentNode.getAttribute('rel')) - 1; if (w.globals.comboCharts) { i = parseInt(bar.parentNode.getAttribute('data:realIndex')); } // if (w.config.tooltip.shared) { // this check not needed at the moment // const yDivisor = w.globals.gridHeight / (w.globals.series.length) // const hoverY = ttCtx.clientY - ttCtx.seriesBound.top // j = Math.ceil(hoverY / yDivisor) // } ttCtx.tooltipLabels.drawSeriesTexts({ ttItems: opt.ttItems, i: i, j: j, shared: ttCtx.showOnIntersect ? false : w.config.tooltip.shared }); if (w.config.tooltip.followCursor) { if (w.config.plotOptions.bar.horizontal) { x = clientX - seriesBound.left + 15; y = cy - ttCtx.dataPointsDividedHeight + bh / 2 - ttCtx.tooltipRect.ttHeight / 2; } else { if (w.globals.isXNumeric) { x = cx - bw / 2; } else { x = cx - ttCtx.dataPointsDividedWidth + bw / 2; } y = e.clientY - seriesBound.top - ttCtx.tooltipRect.ttHeight / 2 - 15; } } else { if (w.config.plotOptions.bar.horizontal) { x = cx; if (x < ttCtx.xyRatios.baseLineInvertedY) { x = cx - ttCtx.tooltipRect.ttWidth; } y = cy - ttCtx.dataPointsDividedHeight + bh / 2 - ttCtx.tooltipRect.ttHeight / 2; } else { // if columns if (w.globals.isXNumeric) { x = cx - bw / 2; } else { x = cx - ttCtx.dataPointsDividedWidth + bw / 2; } y = cy; // - ttCtx.tooltipRect.ttHeight / 2 + 10 } } } return { x: x, y: y, j: j }; } }]); return Intersect; }(); exports.default = Intersect; /***/ }), /* 145 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Formatters = __webpack_require__(30); var _Formatters2 = _interopRequireDefault(_Formatters); var _Utils = __webpack_require__(80); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Tooltip.Labels Class to draw texts on the tooltip. * * @module Tooltip.Labels **/ var Labels = function () { function Labels(tooltipContext) { _classCallCheck(this, Labels); this.w = tooltipContext.w; this.ctx = tooltipContext.ctx; this.ttCtx = tooltipContext; this.tooltipUtil = new _Utils2.default(tooltipContext); } _createClass(Labels, [{ key: 'drawSeriesTexts', value: function drawSeriesTexts(_ref) { var _ref$shared = _ref.shared, shared = _ref$shared === undefined ? true : _ref$shared, ttItems = _ref.ttItems, _ref$i = _ref.i, i = _ref$i === undefined ? 0 : _ref$i, _ref$j = _ref.j, j = _ref$j === undefined ? null : _ref$j; var w = this.w; if (w.config.tooltip.custom !== undefined) { this.handleCustomTooltip({ i: i, j: j }); } else { this.toggleActiveInactiveSeries(shared); } var values = this.getValuesToPrint({ i: i, j: j }); this.printLabels({ i: i, j: j, values: values, ttItems: ttItems, shared: shared }); } }, { key: 'printLabels', value: function printLabels(_ref2) { var i = _ref2.i, j = _ref2.j, values = _ref2.values, ttItems = _ref2.ttItems, shared = _ref2.shared; var w = this.w; var val = void 0; var xVal = values.xVal, zVal = values.zVal, xAxisTTVal = values.xAxisTTVal; var seriesName = ''; var pColor = w.globals.colors[i]; if (j !== null && w.config.plotOptions.bar.distributed) { pColor = w.globals.colors[j]; } for (var t = 0, inverset = w.globals.series.length - 1; t < w.globals.series.length; t++, inverset--) { var f = this.getFormatters(i); seriesName = this.getSeriesName({ fn: f.yLbTitleFormatter, index: i, seriesIndex: i, j: j }); if (shared) { var tIndex = w.config.tooltip.inverseOrder ? inverset : t; f = this.getFormatters(tIndex); seriesName = this.getSeriesName({ fn: f.yLbTitleFormatter, index: tIndex, seriesIndex: i, j: j }); pColor = w.globals.colors[tIndex]; // for plot charts, not for pie/donuts val = f.yLbFormatter(w.globals.series[tIndex][j], { series: w.globals.series, seriesIndex: i, dataPointIndex: j, w: w }); // discard 0 values in BARS if (this.ttCtx.hasBars() && w.config.chart.stacked && w.globals.series[tIndex][j] === 0 || typeof w.globals.series[tIndex][j] === 'undefined') { val = undefined; } } else { val = f.yLbFormatter(w.globals.series[i][j], w); } // for pie / donuts if (j === null) { val = f.yLbFormatter(w.globals.series[i], w); } this.DOMHandling({ t: t, ttItems: ttItems, values: { val: val, xVal: xVal, xAxisTTVal: xAxisTTVal, zVal: zVal }, seriesName: seriesName, shared: shared, pColor: pColor }); } } }, { key: 'getFormatters', value: function getFormatters(i) { var w = this.w; var yLbFormatter = w.globals.yLabelFormatters[i]; var yLbTitleFormatter = void 0; if (w.globals.ttVal !== undefined) { if (Array.isArray(w.globals.ttVal)) { yLbFormatter = w.globals.ttVal[i] && w.globals.ttVal[i].formatter; yLbTitleFormatter = w.globals.ttVal[i] && w.globals.ttVal[i].title && w.globals.ttVal[i].title.formatter; } else { yLbFormatter = w.globals.ttVal.formatter; if (typeof w.globals.ttVal.title.formatter === 'function') { yLbTitleFormatter = w.globals.ttVal.title.formatter; } } } else { yLbTitleFormatter = w.config.tooltip.y.title.formatter; } if (typeof yLbFormatter !== 'function') { if (w.globals.yLabelFormatters[0]) { yLbFormatter = w.globals.yLabelFormatters[0]; } else { yLbFormatter = function yLbFormatter(label) { return label; }; } } if (typeof yLbTitleFormatter !== 'function') { yLbTitleFormatter = function yLbTitleFormatter(label) { return label; }; } return { yLbFormatter: yLbFormatter, yLbTitleFormatter: yLbTitleFormatter }; } }, { key: 'getSeriesName', value: function getSeriesName(_ref3) { var fn = _ref3.fn, index = _ref3.index, seriesIndex = _ref3.seriesIndex, j = _ref3.j; var w = this.w; return fn(String(w.globals.seriesNames[index]), { series: w.globals.series, seriesIndex: seriesIndex, dataPointIndex: j, w: w }); } }, { key: 'DOMHandling', value: function DOMHandling(_ref4) { var t = _ref4.t, ttItems = _ref4.ttItems, values = _ref4.values, seriesName = _ref4.seriesName, shared = _ref4.shared, pColor = _ref4.pColor; var w = this.w; var ttCtx = this.ttCtx; var val = values.val, xVal = values.xVal, xAxisTTVal = values.xAxisTTVal, zVal = values.zVal; var ttItemsChildren = null; ttItemsChildren = ttItems[t].children; if (w.config.tooltip.fillSeriesColor) { // elTooltip.style.backgroundColor = pColor ttItems[t].style.backgroundColor = pColor; ttItemsChildren[0].style.display = 'none'; } if (ttCtx.showTooltipTitle) { if (ttCtx.tooltipTitle === null) { // get it once if null, and store it in class property ttCtx.tooltipTitle = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip-title'); } ttCtx.tooltipTitle.innerHTML = xVal; } // if xaxis tooltip is constructed, we need to replace the innerHTML if (ttCtx.blxaxisTooltip) { ttCtx.xaxisTooltipText.innerHTML = xAxisTTVal !== '' ? xAxisTTVal : xVal; } var ttYLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-label'); if (ttYLabel) { ttYLabel.innerHTML = seriesName ? seriesName + ': ' : ''; } var ttYVal = ttItems[t].querySelector('.apexcharts-tooltip-text-value'); if (ttYVal) { ttYVal.innerHTML = val; } if (ttItemsChildren[0] && ttItemsChildren[0].classList.contains('apexcharts-tooltip-marker')) { ttItemsChildren[0].style.backgroundColor = pColor; } if (!w.config.tooltip.marker.show) { ttItemsChildren[0].style.display = 'none'; } if (zVal !== null) { var ttZLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-z-label'); ttZLabel.innerHTML = w.config.tooltip.z.title; var ttZVal = ttItems[t].querySelector('.apexcharts-tooltip-text-z-value'); ttZVal.innerHTML = zVal; } if (shared && ttItemsChildren[0]) { // hide when no Val if (typeof val === 'undefined' || val === null) { ttItemsChildren[0].parentNode.style.display = 'none'; } else { ttItemsChildren[0].parentNode.style.display = w.config.tooltip.items.display; } } } }, { key: 'toggleActiveInactiveSeries', value: function toggleActiveInactiveSeries(shared) { var w = this.w; if (shared) { // make all tooltips active this.tooltipUtil.toggleAllTooltipSeriesGroups('enable'); } else { // disable all tooltip text groups this.tooltipUtil.toggleAllTooltipSeriesGroups('disable'); // enable the first tooltip text group var firstTooltipSeriesGroup = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip-series-group'); if (firstTooltipSeriesGroup) { firstTooltipSeriesGroup.classList.add('active'); firstTooltipSeriesGroup.style.display = w.config.tooltip.items.display; } } } }, { key: 'getValuesToPrint', value: function getValuesToPrint(_ref5) { var i = _ref5.i, j = _ref5.j; var w = this.w; var filteredSeriesX = this.tooltipUtil.filteredSeriesX(); var xVal = ''; var xAxisTTVal = ''; var zVal = null; var val = null; var customFormatterOpts = { series: w.globals.series, seriesIndex: i, dataPointIndex: j, w: w }; var zFormatter = w.globals.ttZFormatter; if (j === null) { val = w.globals.series[i]; } else { if (w.globals.isXNumeric) { xVal = filteredSeriesX[i][j]; if (filteredSeriesX[i].length === 0) { // a series (possibly the first one) might be collapsed, so get the next active index var firstActiveSeriesIndex = this.tooltipUtil.getFirstActiveXArray(filteredSeriesX); xVal = filteredSeriesX[firstActiveSeriesIndex][j]; } } else { xVal = typeof w.globals.labels[j] !== 'undefined' ? w.globals.labels[j] : ''; } } var bufferXVal = xVal; if (w.globals.isXNumeric && w.config.xaxis.type === 'datetime') { var xFormat = new _Formatters2.default(this.ctx); xVal = xFormat.xLabelFormat(w.globals.ttKeyFormatter, bufferXVal); } else { xVal = w.globals.xLabelFormatter(bufferXVal, customFormatterOpts); } // override default x-axis formatter with tooltip formatter if (w.config.tooltip.x.formatter !== undefined) { xVal = w.globals.ttKeyFormatter(bufferXVal, customFormatterOpts); } if (w.globals.seriesZ.length > 0 && w.globals.seriesZ[0].length > 0) { zVal = zFormatter(w.globals.seriesZ[i][j], w); } if (typeof w.config.xaxis.tooltip.formatter === 'function') { xAxisTTVal = w.globals.xaxisTooltipFormatter(bufferXVal, customFormatterOpts); } else { xAxisTTVal = xVal; } return { val: val, xVal: xVal, xAxisTTVal: xAxisTTVal, zVal: zVal }; } }, { key: 'handleCustomTooltip', value: function handleCustomTooltip(_ref6) { var i = _ref6.i, j = _ref6.j; var w = this.w; var tooltipEl = this.ttCtx.getElTooltip(); // override everything with a custom html tooltip and replace it tooltipEl.innerHTML = w.config.tooltip.custom({ series: w.globals.series, seriesIndex: i, dataPointIndex: j, w: w }); } }]); return Labels; }(); module.exports = Labels; /***/ }), /* 146 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Position = __webpack_require__(79); var _Position2 = _interopRequireDefault(_Position); var _Markers = __webpack_require__(47); var _Markers2 = _interopRequireDefault(_Markers); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Tooltip.Marker Class to draw texts on the tooltip. * * @module Tooltip.Marker **/ var Marker = function () { function Marker(tooltipContext) { _classCallCheck(this, Marker); this.w = tooltipContext.w; this.ttCtx = tooltipContext; this.ctx = tooltipContext.ctx; this.tooltipPosition = new _Position2.default(tooltipContext); } _createClass(Marker, [{ key: 'drawDynamicPoints', value: function drawDynamicPoints() { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var marker = new _Markers2.default(this.ctx); var elsSeries = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series'); for (var i = 0; i < elsSeries.length; i++) { var seriesIndex = parseInt(elsSeries[i].getAttribute('data:realIndex')); var pointsMain = w.globals.dom.baseEl.querySelector('.apexcharts-series[data\\:realIndex=\'' + seriesIndex + '\'] .apexcharts-series-markers-wrap'); if (pointsMain !== null) { // it can be null as we have tooltips in donut/bar charts var point = void 0; var PointClasses = 'apexcharts-marker w' + (Math.random() + 1).toString(36).substring(4); if ((w.config.chart.type === 'line' || w.config.chart.type === 'area') && !w.globals.comboCharts && !w.config.tooltip.intersect) { PointClasses += ' no-pointer-events'; } var elPointOptions = marker.getMarkerConfig(PointClasses, seriesIndex); point = graphics.drawMarker(0, 0, elPointOptions); var elPointsG = document.createElementNS(w.globals.svgNS, 'g'); elPointsG.classList.add('apexcharts-series-markers'); elPointsG.appendChild(point.node); pointsMain.appendChild(elPointsG); } } } }, { key: 'enlargeCurrentPoint', value: function enlargeCurrentPoint(rel, point) { var w = this.w; if (w.config.chart.type !== 'bubble') { this.newPointSize(rel, point); } var cx = point.getAttribute('cx'); var cy = point.getAttribute('cy'); this.tooltipPosition.moveXCrosshairs(cx); if (!this.fixedTooltip) { this.tooltipPosition.moveTooltip(cx, cy, w.config.markers.hover.size); } } }, { key: 'enlargePoints', value: function enlargePoints(j) { var w = this.w; var me = this; var ttCtx = this.ttCtx; var col = j; var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker'); var newSize = w.config.markers.hover.size; for (var p = 0; p < points.length; p++) { var rel = points[p].getAttribute('rel'); if (col === parseInt(rel)) { me.newPointSize(col, points[p]); var cx = points[p].getAttribute('cx'); var cy = points[p].getAttribute('cy'); me.tooltipPosition.moveXCrosshairs(cx); if (!ttCtx.fixedTooltip) { me.tooltipPosition.moveTooltip(cx, cy, newSize); } } else { me.oldPointSize(points[p]); } } } }, { key: 'newPointSize', value: function newPointSize(rel, point) { var w = this.w; var newSize = w.config.markers.hover.size; var elPoint = null; if (rel === 0) { elPoint = point.parentNode.firstChild; } else { elPoint = point.parentNode.lastChild; } elPoint.setAttribute('r', newSize); // elPoint.style.opacity = w.config.markers.hover.opacity } }, { key: 'oldPointSize', value: function oldPointSize(point) { var w = this.w; var currSize = w.config.markers.size; point.setAttribute('r', currSize); // point.style.opacity = w.config.markers.opacity } }, { key: 'resetPointsSize', value: function resetPointsSize() { var w = this.w; var currSize = w.config.markers.size; var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-marker'); for (var p = 0; p < points.length; p++) { points[p].setAttribute('r', currSize); // points[p].style.opacity = w.config.markers.opacity; } } }]); return Marker; }(); module.exports = Marker; /***/ }), /* 147 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _Labels = __webpack_require__(145); var _Labels2 = _interopRequireDefault(_Labels); var _Position = __webpack_require__(79); var _Position2 = _interopRequireDefault(_Position); var _Marker = __webpack_require__(146); var _Marker2 = _interopRequireDefault(_Marker); var _Intersect = __webpack_require__(144); var _Intersect2 = _interopRequireDefault(_Intersect); var _AxesTooltip = __webpack_require__(143); var _AxesTooltip2 = _interopRequireDefault(_AxesTooltip); var _Graphics = __webpack_require__(0); var _Graphics2 = _interopRequireDefault(_Graphics); var _Series = __webpack_require__(26); var _Series2 = _interopRequireDefault(_Series); var _XAxis = __webpack_require__(48); var _XAxis2 = _interopRequireDefault(_XAxis); var _Utils = __webpack_require__(80); var _Utils2 = _interopRequireDefault(_Utils); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * ApexCharts Core Tooltip Class to handle the tooltip generation. * * @module Tooltip **/ var Tooltip = function () { function Tooltip(ctx) { _classCallCheck(this, Tooltip); this.ctx = ctx; this.w = ctx.w; var w = this.w; this.tooltipUtil = new _Utils2.default(this); this.tooltipLabels = new _Labels2.default(this); this.tooltipPosition = new _Position2.default(this); this.marker = new _Marker2.default(this); this.intersect = new _Intersect2.default(this); this.axesTooltip = new _AxesTooltip2.default(this); this.showOnIntersect = w.config.tooltip.intersect; this.showTooltipTitle = w.config.tooltip.x.show; this.fixedTooltip = w.config.tooltip.fixed.enabled; this.xaxisTooltip = null; this.yaxisTTEls = null; this.isBarHorizontal = w.config.plotOptions.bar.horizontal; this.isBarShared = !w.config.plotOptions.bar.horizontal && w.config.tooltip.shared; } _createClass(Tooltip, [{ key: 'getElTooltip', value: function getElTooltip(ctx) { if (!ctx) ctx = this; return ctx.w.globals.dom.baseEl.querySelector('.apexcharts-tooltip'); } }, { key: 'getElXCrosshairs', value: function getElXCrosshairs() { return this.w.globals.dom.baseEl.querySelector('.apexcharts-xcrosshairs'); } }, { key: 'getElGrid', value: function getElGrid() { return this.w.globals.dom.baseEl.querySelector('.apexcharts-grid'); } }, { key: 'drawTooltip', value: function drawTooltip(xyRatios) { var w = this.w; this.xyRatios = xyRatios; this.blxaxisTooltip = w.config.xaxis.tooltip.enabled && w.globals.axisCharts; this.blyaxisTooltip = w.config.yaxis[0].tooltip.enabled && w.globals.axisCharts; this.allTooltipSeriesGroups = []; if (!w.globals.axisCharts) { this.showTooltipTitle = false; } var tooltipEl = document.createElement('div'); tooltipEl.classList.add('apexcharts-tooltip'); tooltipEl.classList.add(w.config.tooltip.theme); w.globals.dom.elWrap.appendChild(tooltipEl); if (w.globals.axisCharts) { this.axesTooltip.drawXaxisTooltip(); this.axesTooltip.drawYaxisTooltip(); this.axesTooltip.setXCrosshairWidth(); this.axesTooltip.handleYCrosshair(); var xAxis = new _XAxis2.default(this.ctx); this.xAxisTicksPositions = xAxis.getXAxisTicksPositions(); } // we forcefully set intersect true for these conditions if (w.globals.comboCharts && !w.config.tooltip.shared || w.config.tooltip.intersect && !w.config.tooltip.shared || w.config.chart.type === 'bar' && !w.config.tooltip.shared) { this.showOnIntersect = true; } if (w.config.markers.size === 0) { // when user don't want to show points all the time, but only on when hovering on series this.marker.drawDynamicPoints(this); } // no visible series, exit if (w.globals.collapsedSeries.length === w.globals.series.length) return; this.dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints; this.dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints; if (this.showTooltipTitle) { this.tooltipTitle = document.createElement('div'); this.tooltipTitle.classList.add('apexcharts-tooltip-title'); tooltipEl.appendChild(this.tooltipTitle); } var ttItemsCnt = w.globals.series.length; // whether shared or not, default is shared if ((w.globals.xyCharts || w.globals.comboCharts) && w.config.tooltip.shared) { if (!this.showOnIntersect) { ttItemsCnt = w.globals.series.length; } else { ttItemsCnt = 1; } } this.ttItems = this.createTTElements(ttItemsCnt); this.addSVGEvents(); } }, { key: 'createTTElements', value: function createTTElements(ttItemsCnt) { var w = this.w; var ttItems = []; var tooltipEl = this.getElTooltip(); for (var i = 0; i < ttItemsCnt; i++) { var gTxt = document.createElement('div'); gTxt.classList.add('apexcharts-tooltip-series-group'); var point = document.createElement('span'); point.classList.add('apexcharts-tooltip-marker'); point.style.backgroundColor = w.globals.colors[i]; gTxt.appendChild(point); var gYZ = document.createElement('div'); gYZ.classList.add('apexcharts-tooltip-text'); // y values group var gYValText = document.createElement('div'); gYValText.classList.add('apexcharts-tooltip-y-group'); var txtLabel = document.createElement('span'); txtLabel.classList.add('apexcharts-tooltip-text-label'); gYValText.appendChild(txtLabel); var txtValue = document.createElement('span'); txtValue.classList.add('apexcharts-tooltip-text-value'); gYValText.appendChild(txtValue); // z values group var gZValText = document.createElement('div'); gZValText.classList.add('apexcharts-tooltip-z-group'); var txtZLabel = document.createElement('span'); txtZLabel.classList.add('apexcharts-tooltip-text-z-label'); gZValText.appendChild(txtZLabel); var txtZValue = document.createElement('span'); txtZValue.classList.add('apexcharts-tooltip-text-z-value'); gZValText.appendChild(txtZValue); gYZ.appendChild(gYValText); gYZ.appendChild(gZValText); gTxt.appendChild(gYZ); tooltipEl.appendChild(gTxt); ttItems.push(gTxt); } return ttItems; } }, { key: 'addSVGEvents', value: function addSVGEvents() { var w = this.w; var type = w.config.chart.type; var tooltipEl = this.getElTooltip(); var barOrCandlestick = !!(type === 'bar' || type === 'candlestick'); var hoverArea = w.globals.dom.Paper.node; var elGrid = this.getElGrid(); if (elGrid) { this.seriesBound = elGrid.getBoundingClientRect(); } var tooltipY = []; var tooltipX = []; var seriesHoverParams = { hoverArea: hoverArea, elGrid: elGrid, tooltipEl: tooltipEl, tooltipY: tooltipY, tooltipX: tooltipX, ttItems: this.ttItems }; var points = void 0; if (w.globals.axisCharts) { if (type === 'area' || type === 'line' || type === 'scatter' || type === 'bubble') { points = w.globals.dom.baseEl.querySelectorAll(".apexcharts-series[data\\:longestSeries='true'] .apexcharts-marker"); } else if (barOrCandlestick) { points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-bar-area', '.apexcharts-series .apexcharts-candlestick-area'); } else if (type === 'heatmap') { points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-heatmap'); } if (points && points.length) { for (var p = 0; p < points.length; p++) { tooltipY.push(points[p].getAttribute('cy')); tooltipX.push(points[p].getAttribute('cx')); } } } if (w.globals.xyCharts && !this.showOnIntersect || w.globals.comboCharts && !this.showOnIntersect || barOrCandlestick && !this.isBarHorizontal && this.hasBars() && w.config.tooltip.shared) { this.addPathsEventListeners([hoverArea], seriesHoverParams); } else if (barOrCandlestick && !w.globals.comboCharts) { this.addBarsEventListeners(seriesHoverParams); } else if (type === 'bubble' || type === 'scatter' || this.showOnIntersect && (type === 'area' || type === 'line')) { this.addPointsEventsListeners(seriesHoverParams); } else if (!w.globals.axisCharts || type === 'heatmap') { var seriesAll = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series'); this.addPathsEventListeners(seriesAll, seriesHoverParams); } if (this.showOnIntersect) { var linePoints = w.globals.dom.baseEl.querySelectorAll('.apexcharts-line-series .apexcharts-marker'); if (linePoints.length > 0) { // if we find any lineSeries, addEventListeners for them this.addPathsEventListeners(linePoints, seriesHoverParams); } var areaPoints = w.globals.dom.baseEl.querySelectorAll('.apexcharts-area-series .apexcharts-marker'); if (areaPoints.length > 0) { // if we find any areaSeries, addEventListeners for them this.addPathsEventListeners(areaPoints, seriesHoverParams); } // combo charts may have bars, so add event listeners here too if (this.hasBars() && !w.config.tooltip.shared) { this.addBarsEventListeners(seriesHoverParams); } } } }, { key: 'drawFixedTooltipRect', value: function drawFixedTooltipRect() { var w = this.w; var tooltipEl = this.getElTooltip(); var tooltipRect = tooltipEl.getBoundingClientRect(); var ttWidth = tooltipRect.width + 10; var ttHeight = tooltipRect.height + 10; var x = w.config.tooltip.fixed.offsetX; var y = w.config.tooltip.fixed.offsetY; if (w.config.tooltip.fixed.position.toLowerCase().indexOf('right') > -1) { x = x + w.globals.svgWidth - ttWidth + 10; } if (w.config.tooltip.fixed.position.toLowerCase().indexOf('bottom') > -1) { y = y + w.globals.svgHeight - ttHeight - 10; } tooltipEl.style.left = x + 'px'; tooltipEl.style.top = y + 'px'; return { x: x, y: y, ttWidth: ttWidth, ttHeight: ttHeight }; } }, { key: 'addPointsEventsListeners', value: function addPointsEventsListeners(seriesHoverParams) { var w = this.w; var points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers .apexcharts-marker'); this.addPathsEventListeners(points, seriesHoverParams); } }, { key: 'addBarsEventListeners', value: function addBarsEventListeners(seriesHoverParams) { var w = this.w; var bars = w.globals.dom.baseEl.querySelectorAll('.apexcharts-bar-area, .apexcharts-candlestick-area'); this.addPathsEventListeners(bars, seriesHoverParams); } }, { key: 'addPathsEventListeners', value: function addPathsEventListeners(paths, opts) { var _this = this; var self = this; var _loop = function _loop(p) { var extendedOpts = { paths: paths[p], tooltipEl: opts.tooltipEl, tooltipY: opts.tooltipY, tooltipX: opts.tooltipX, elGrid: opts.elGrid, hoverArea: opts.hoverArea, ttItems: opts.ttItems }; _this.w.globals.tooltipOpts = extendedOpts; var events = ['mousemove', 'touchmove', 'mouseout', 'touchend']; events.map(function (ev) { return paths[p].addEventListener(ev, self.seriesHover.bind(self, extendedOpts), { capture: false, passive: true }); }); }; for (var p = 0; p < paths.length; p++) { _loop(p); } } /* ** The actual series hover function */ }, { key: 'seriesHover', value: function seriesHover(opt, e) { var _this2 = this; var chartGroups = []; if (this.w.config.chart.group) { chartGroups = this.ctx.getGroupedCharts(); } if (chartGroups.length) { chartGroups.forEach(function (ch) { var tooltipEl = _this2.getElTooltip(ch); var newOpts = { paths: opt.paths, tooltipEl: tooltipEl, tooltipY: opt.tooltipY, tooltipX: opt.tooltipX, elGrid: opt.elGrid, hoverArea: opt.hoverArea, ttItems: ch.w.globals.tooltip.ttItems // all the charts should have the same minX and maxX (same xaxis) for multiple tooltips to work correctly };if (ch.w.globals.minX === _this2.w.globals.minX && ch.w.globals.maxX === _this2.w.globals.maxX) { ch.w.globals.tooltip.seriesHoverByContext({ chartCtx: ch, ttCtx: ch.w.globals.tooltip, opt: newOpts, e: e }); } }); } else { this.seriesHoverByContext({ chartCtx: this.ctx, ttCtx: this.w.globals.tooltip, opt: opt, e: e }); } } }, { key: 'seriesHoverByContext', value: function seriesHoverByContext(_ref) { var chartCtx = _ref.chartCtx, ttCtx = _ref.ttCtx, opt = _ref.opt, e = _ref.e; var w = chartCtx.w; var tooltipEl = this.getElTooltip(); // tooltipRect is calculated on every mousemove, because the text is dynamic ttCtx.tooltipRect = { x: 0, y: 0, ttWidth: tooltipEl.getBoundingClientRect().width, ttHeight: tooltipEl.getBoundingClientRect().height }; ttCtx.e = e; // highlight the current hovered bars if (ttCtx.hasBars() && !w.globals.comboCharts && !ttCtx.isBarShared) { if (w.config.tooltip.onDatasetHover.highlightDataSeries) { var series = new _Series2.default(chartCtx); series.toggleSeriesOnHover(e, e.target.parentNode); } } if (ttCtx.fixedTooltip) { ttCtx.drawFixedTooltipRect(); } if (w.globals.axisCharts) { ttCtx.axisChartsTooltips({ e: e, opt: opt, tooltipRect: ttCtx.tooltipRect }); } else { // non-plot charts i.e pie/donut/circle ttCtx.nonAxisChartsTooltips({ e: e, opt: opt, tooltipRect: ttCtx.tooltipRect }); } } // tooltip handling for line/area/bar/columns/scatter }, { key: 'axisChartsTooltips', value: function axisChartsTooltips(_ref2) { var e = _ref2.e, opt = _ref2.opt; var w = this.w; var j = void 0, x = void 0, y = void 0; var self = this; var capj = null; var tooltipEl = this.getElTooltip(); var xcrosshairs = this.getElXCrosshairs(); var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX; var clientY = e.type === 'touchmove' ? e.touches[0].clientY : e.clientY; this.clientY = clientY; this.clientX = clientX; var isStickyTooltip = w.globals.xyCharts || w.config.chart.type === 'bar' && !this.isBarHorizontal && this.hasBars() && w.config.tooltip.shared || w.globals.comboCharts && this.hasBars; if (w.config.chart.type === 'bar' && this.isBarHorizontal && this.hasBars()) { isStickyTooltip = false; } if (e.type === 'mousemove' || e.type === 'touchmove') { if (xcrosshairs !== null) { xcrosshairs.classList.add('active'); } if (self.ycrosshairs !== null && self.blyaxisTooltip) { self.ycrosshairs.classList.add('active'); } if (isStickyTooltip && !self.showOnIntersect) { capj = self.tooltipUtil.getNearestValues({ context: self, hoverArea: opt.hoverArea, elGrid: opt.elGrid, clientX: clientX, clientY: clientY, hasBars: self.hasBars }); j = capj.j; var capturedSeries = capj.capturedSeries; if (capj.hoverX < 0 || capj.hoverX > w.globals.gridWidth) { // capj.hoverY causing issues in grouped charts, so commented out that condition for now // if (capj.hoverX < 0 || capj.hoverX > w.globals.gridWidth || capj.hoverY < 0 || capj.hoverY > w.globals.gridHeight) { self.handleMouseOut(opt); return; } if (capturedSeries !== null) { var ignoreNull = w.globals.series[capturedSeries][j] === null; if (ignoreNull) { opt.tooltipEl.classList.remove('active'); return; } if (typeof w.globals.series[capturedSeries][j] !== 'undefined') { if (w.config.tooltip.shared && this.tooltipUtil.isXoverlap(j) && this.tooltipUtil.isinitialSeriesSameLen()) { this.create(self, capturedSeries, j, opt.ttItems); } else { this.create(self, capturedSeries, j, opt.ttItems, false); } } else { if (this.tooltipUtil.isXoverlap(j)) { self.create(self, 0, j, opt.ttItems); } } } else { // couldn't capture any series. check if shared X is same, // if yes, draw a grouped tooltip if (this.tooltipUtil.isXoverlap(j)) { self.create(self, 0, j, opt.ttItems); } } } else { if (w.config.chart.type === 'heatmap') { var markerXY = this.intersect.handleHeatTooltip({ e: e, opt: opt, x: x, y: y }); x = markerXY.x; y = markerXY.y; tooltipEl.style.left = x + 'px'; tooltipEl.style.top = y + 'px'; } else { if (this.hasBars) { this.intersect.handleBarTooltip({ e: e, opt: opt }); } if (this.hasMarkers) { // intersect - line/area/scatter/bubble this.intersect.handleMarkerTooltip({ e: e, opt: opt, x: x, y: y }); } } } if (this.blyaxisTooltip) { for (var yt = 0; yt < w.config.yaxis.length; yt++) { self.axesTooltip.drawYaxisTooltipText(yt, clientY, self.xyRatios); } } opt.tooltipEl.classList.add('active'); } else if (e.type === 'mouseout' || e.type === 'touchend') { this.handleMouseOut(opt); } } // tooltip handling for pie/donuts }, { key: 'nonAxisChartsTooltips', value: function nonAxisChartsTooltips(_ref3) { var e = _ref3.e, opt = _ref3.opt, tooltipRect = _ref3.tooltipRect; var w = this.w; var rel = opt.paths.getAttribute('rel'); var tooltipEl = this.getElTooltip(); var trX = 0; var trY = 0; var elPie = null; var clientX = e.type === 'touchmove' ? e.touches[0].clientX : e.clientX; if (w.config.chart.type === 'radialBar') { elPie = w.globals.dom.baseEl.querySelector('.apexcharts-radialbar'); } else { elPie = w.globals.dom.baseEl.querySelector('.apexcharts-pie'); trX = parseInt(elPie.getAttribute('data:innerTranslateX')); trY = parseInt(elPie.getAttribute('data:innerTranslateY')); } var seriesBound = elPie.getBoundingClientRect(); if (e.type === 'mousemove' || e.type === 'touchmove') { tooltipEl.classList.add('active'); this.tooltipLabels.drawSeriesTexts({ ttItems: opt.ttItems, i: parseInt(rel) - 1, shared: false }); var x = clientX - seriesBound.left - tooltipRect.ttWidth / 2.2 + trX; var y = e.clientY - seriesBound.top - tooltipRect.ttHeight / 2 - 15 + trY; if (x < 0) { x = 0; } else if (x + tooltipRect.ttWidth > w.globals.gridWidth) { x = clientX - seriesBound.left - tooltipRect.ttWidth + trX; } if (y < 0) y = tooltipRect.ttHeight + 20; tooltipEl.style.left = x + w.globals.translateX + 'px'; tooltipEl.style.top = y + 'px'; } else if (e.type === 'mouseout' || e.type === 'touchend') { tooltipEl.classList.remove('active'); } } }, { key: 'deactivateHoverFilter', value: function deactivateHoverFilter() { var w = this.w; var graphics = new _Graphics2.default(this.ctx); var allPaths = w.globals.dom.Paper.select('.apexcharts-bar-area'); for (var b = 0; b < allPaths.length; b++) { graphics.pathMouseLeave(allPaths[b]); } } }, { key: 'handleMouseOut', value: function handleMouseOut(opt) { var w = this.w; var xcrosshairs = this.getElXCrosshairs(); opt.tooltipEl.classList.remove('active'); this.deactivateHoverFilter(); if (w.config.chart.type !== 'bubble') { this.marker.resetPointsSize(); } if (xcrosshairs !== null) { xcrosshairs.classList.remove('active'); } if (this.ycrosshairs !== null) { this.ycrosshairs.classList.remove('active'); } if (this.blxaxisTooltip) { this.xaxisTooltip.classList.remove('active'); } if (this.blyaxisTooltip) { if (this.yaxisTTEls === null) { this.yaxisTTEls = w.globals.dom.baseEl.querySelectorAll('.apexcharts-yaxistooltip'); } for (var i = 0; i < this.yaxisTTEls.length; i++) { this.yaxisTTEls[i].classList.remove('active'); } } } }, { key: 'getElMarkers', value: function getElMarkers() { return this.w.globals.dom.baseEl.querySelectorAll(' .apexcharts-series-markers'); } }, { key: 'getAllMarkers', value: function getAllMarkers() { return this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers .apexcharts-marker'); } }, { key: 'hasMarkers', value: function hasMarkers() { var markers = this.getElMarkers(); return markers.length > 0; } }, { key: 'getElBars', value: function getElBars() { return this.w.globals.dom.baseEl.querySelectorAll('.apexcharts-bar-series, .apexcharts-candlestick-series'); } }, { key: 'hasBars', value: function hasBars() { var bars = this.getElBars(); return bars.length > 0; } }, { key: 'create', value: function create(context, capturedSeries, j, ttItems) { var shared = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; var w = this.w; var self = context; if (shared === null) shared = w.config.tooltip.shared; var hasMarkers = this.hasMarkers(); var bars = this.getElBars(); if (shared) { self.tooltipLabels.drawSeriesTexts({ ttItems: ttItems, i: capturedSeries, j: j, shared: this.showOnIntersect ? false : w.config.tooltip.shared }); if (hasMarkers) { if (w.config.markers.size > 0) { self.marker.enlargePoints(j); } else { self.tooltipPosition.moveDynamicPointsOnHover(j); } } if (this.hasBars()) { this.barSeriesHeight = this.tooltipUtil.getBarsHeight(bars); if (this.barSeriesHeight > 0) { // hover state, activate snap filter var graphics = new _Graphics2.default(this.ctx); var paths = w.globals.dom.Paper.select('.apexcharts-bar-area[j=\'' + j + '\']'); // de-activate first this.deactivateHoverFilter(); this.tooltipPosition.moveStickyTooltipOverBars(j); for (var b = 0; b < paths.length; b++) { graphics.pathMouseEnter(paths[b]); } } } } else { self.tooltipLabels.drawSeriesTexts({ shared: false, ttItems: ttItems, i: capturedSeries, j: j }); self.tooltipPosition.moveMarkers(capturedSeries, j); } } }]); return Tooltip; }(); module.exports = Tooltip; /***/ }), /* 148 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * When source maps are enabled, `style-loader` uses a link element with a data-uri to * embed the css on the page. This breaks all relative urls because now they are relative to a * bundle instead of the current page. * * One solution is to only use full urls, but that may be impossible. * * Instead, this function "fixes" the relative urls to be absolute according to the current page location. * * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command. * */ module.exports = function (css) { // get current location var location = typeof window !== "undefined" && window.location; if (!location) { throw new Error("fixUrls requires window.location"); } // blank or null? if (!css || typeof css !== "string") { return css; } var baseUrl = location.protocol + "//" + location.host; var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/"); // convert each url(...) /* This regular expression is just a way to recursively match brackets within a string. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens ( = Start a capturing group (?: = Start a non-capturing group [^)(] = Match anything that isn't a parentheses | = OR \( = Match a start parentheses (?: = Start another non-capturing groups [^)(]+ = Match anything that isn't a parentheses | = OR \( = Match a start parentheses [^)(]* = Match anything that isn't a parentheses \) = Match a end parentheses ) = End Group *\) = Match anything and then a close parens ) = Close non-capturing group * = Match anything ) = Close capturing group \) = Match a close parens /gi = Get all matches, not the first. Be case insensitive. */ var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function (fullMatch, origUrl) { // strip quotes (if they exist) var unquotedOrigUrl = origUrl.trim().replace(/^"(.*)"$/, function (o, $1) { return $1; }).replace(/^'(.*)'$/, function (o, $1) { return $1; }); // already a full url? no change if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) { return fullMatch; } // convert the url to a full url var newUrl; if (unquotedOrigUrl.indexOf("//") === 0) { //TODO: should we add protocol? newUrl = unquotedOrigUrl; } else if (unquotedOrigUrl.indexOf("/") === 0) { // path should be relative to the base url newUrl = baseUrl + unquotedOrigUrl; // already starts with '/' } else { // path should be relative to current directory newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './' } // send back the fixed url(...) return "url(" + JSON.stringify(newUrl) + ")"; }); // send back the fixed css return fixedCss; }; /***/ }), /* 149 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /*! svg.draggable.js - v2.2.1 - 2016-08-25 * https://github.com/wout/svg.draggable.js * Copyright (c) 2016 Wout Fierens; Licensed MIT */ ;(function () { // creates handler, saves it function DragHandler(el) { el.remember('_draggable', this); this.el = el; } // Sets new parameter, starts dragging DragHandler.prototype.init = function (constraint, val) { var _this = this; this.constraint = constraint; this.value = val; this.el.on('mousedown.drag', function (e) { _this.start(e); }); this.el.on('touchstart.drag', function (e) { _this.start(e); }); }; // transforms one point from screen to user coords DragHandler.prototype.transformPoint = function (event, offset) { event = event || window.event; var touches = event.changedTouches && event.changedTouches[0] || event; this.p.x = touches.pageX - (offset || 0); this.p.y = touches.pageY; return this.p.matrixTransform(this.m); }; // gets elements bounding box with special handling of groups, nested and use DragHandler.prototype.getBBox = function () { var box = this.el.bbox(); if (this.el instanceof SVG.Nested) box = this.el.rbox(); if (this.el instanceof SVG.G || this.el instanceof SVG.Use || this.el instanceof SVG.Nested) { box.x = this.el.x(); box.y = this.el.y(); } return box; }; // start dragging DragHandler.prototype.start = function (e) { // check for left button if (e.type == 'click' || e.type == 'mousedown' || e.type == 'mousemove') { if ((e.which || e.buttons) != 1) { return; } } var _this = this; // fire beforedrag event this.el.fire('beforedrag', { event: e, handler: this }); // search for parent on the fly to make sure we can call // draggable() even when element is not in the dom currently this.parent = this.parent || this.el.parent(SVG.Nested) || this.el.parent(SVG.Doc); this.p = this.parent.node.createSVGPoint(); // save current transformation matrix this.m = this.el.node.getScreenCTM().inverse(); var box = this.getBBox(); var anchorOffset; // fix text-anchor in text-element (#37) if (this.el instanceof SVG.Text) { anchorOffset = this.el.node.getComputedTextLength(); switch (this.el.attr('text-anchor')) { case 'middle': anchorOffset /= 2; break; case 'start': anchorOffset = 0; break; } } this.startPoints = { // We take absolute coordinates since we are just using a delta here point: this.transformPoint(e, anchorOffset), box: box, transform: this.el.transform() // add drag and end events to window };SVG.on(window, 'mousemove.drag', function (e) { _this.drag(e); }); SVG.on(window, 'touchmove.drag', function (e) { _this.drag(e); }); SVG.on(window, 'mouseup.drag', function (e) { _this.end(e); }); SVG.on(window, 'touchend.drag', function (e) { _this.end(e); }); // fire dragstart event this.el.fire('dragstart', { event: e, p: this.startPoints.point, m: this.m, handler: this }); // prevent browser drag behavior e.preventDefault(); // prevent propagation to a parent that might also have dragging enabled e.stopPropagation(); }; // while dragging DragHandler.prototype.drag = function (e) { var box = this.getBBox(), p = this.transformPoint(e), x = this.startPoints.box.x + p.x - this.startPoints.point.x, y = this.startPoints.box.y + p.y - this.startPoints.point.y, c = this.constraint, gx = p.x - this.startPoints.point.x, gy = p.y - this.startPoints.point.y; var event = new CustomEvent('dragmove', { detail: { event: e, p: p, m: this.m, handler: this }, cancelable: true }); this.el.fire(event); if (event.defaultPrevented) return p; // move the element to its new position, if possible by constraint if (typeof c == 'function') { var coord = c.call(this.el, x, y, this.m); // bool, just show us if movement is allowed or not if (typeof coord == 'boolean') { coord = { x: coord, y: coord }; } // if true, we just move. If !false its a number and we move it there if (coord.x === true) { this.el.x(x); } else if (coord.x !== false) { this.el.x(coord.x); } if (coord.y === true) { this.el.y(y); } else if (coord.y !== false) { this.el.y(coord.y); } } else if ((typeof c === 'undefined' ? 'undefined' : _typeof(c)) == 'object') { // keep element within constrained box if (c.minX != null && x < c.minX) x = c.minX;else if (c.maxX != null && x > c.maxX - box.width) { x = c.maxX - box.width; }if (c.minY != null && y < c.minY) y = c.minY;else if (c.maxY != null && y > c.maxY - box.height) y = c.maxY - box.height; if (this.el instanceof SVG.G) this.el.matrix(this.startPoints.transform).transform({ x: gx, y: gy }, true);else this.el.move(x, y); } // so we can use it in the end-method, too return p; }; DragHandler.prototype.end = function (e) { // final drag var p = this.drag(e); // fire dragend event this.el.fire('dragend', { event: e, p: p, m: this.m, handler: this }); // unbind events SVG.off(window, 'mousemove.drag'); SVG.off(window, 'touchmove.drag'); SVG.off(window, 'mouseup.drag'); SVG.off(window, 'touchend.drag'); }; SVG.extend(SVG.Element, { // Make element draggable // Constraint might be an object (as described in readme.md) or a function in the form "function (x, y)" that gets called before every move. // The function can return a boolean or an object of the form {x, y}, to which the element will be moved. "False" skips moving, true moves to raw x, y. draggable: function draggable(value, constraint) { // Check the parameters and reassign if needed if (typeof value == 'function' || (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object') { constraint = value; value = true; } var dragHandler = this.remember('_draggable') || new DragHandler(this); // When no parameter is given, value is true value = typeof value === 'undefined' ? true : value; if (value) dragHandler.init(constraint || {}, value);else { this.off('mousedown.drag'); this.off('touchstart.drag'); } return this; } }); }).call(undefined); /***/ }), /* 150 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*! svg.filter.js - v2.0.2 - 2016-02-24 * https://github.com/wout/svg.filter.js * Copyright (c) 2016 Wout Fierens; Licensed MIT */ ;(function () { // Main filter class SVG.Filter = SVG.invent({ create: 'filter', inherit: SVG.Parent, extend: { // Static strings source: 'SourceGraphic', sourceAlpha: 'SourceAlpha', background: 'BackgroundImage', backgroundAlpha: 'BackgroundAlpha', fill: 'FillPaint', stroke: 'StrokePaint', autoSetIn: true, // Custom put method for leaner code put: function put(element, i) { this.add(element, i); if (!element.attr('in') && this.autoSetIn) { element.attr('in', this.source); } if (!element.attr('result')) { element.attr('result', element); } return element; }, // Blend effect blend: function blend(in1, in2, mode) { return this.put(new SVG.BlendEffect(in1, in2, mode)); }, // ColorMatrix effect colorMatrix: function colorMatrix(type, values) { return this.put(new SVG.ColorMatrixEffect(type, values)); }, // ConvolveMatrix effect convolveMatrix: function convolveMatrix(matrix) { return this.put(new SVG.ConvolveMatrixEffect(matrix)); }, // ComponentTransfer effect componentTransfer: function componentTransfer(components) { return this.put(new SVG.ComponentTransferEffect(components)); }, // Composite effect composite: function composite(in1, in2, operator) { return this.put(new SVG.CompositeEffect(in1, in2, operator)); }, // Flood effect flood: function flood(color, opacity) { return this.put(new SVG.FloodEffect(color, opacity)); }, // Offset effect offset: function offset(x, y) { return this.put(new SVG.OffsetEffect(x, y)); }, // Image effect image: function image(src) { return this.put(new SVG.ImageEffect(src)); }, // Merge effect merge: function merge() { //pass the array of arguments to the constructor because we dont know if the user gave us an array as the first arguemnt or wether they listed the effects in the arguments var args = [undefined]; for (var i in arguments) { args.push(arguments[i]); }return this.put(new (SVG.MergeEffect.bind.apply(SVG.MergeEffect, args))()); }, // Gaussian Blur effect gaussianBlur: function gaussianBlur(x, y) { return this.put(new SVG.GaussianBlurEffect(x, y)); }, // Morphology effect morphology: function morphology(operator, radius) { return this.put(new SVG.MorphologyEffect(operator, radius)); }, // DiffuseLighting effect diffuseLighting: function diffuseLighting(surfaceScale, diffuseConstant, kernelUnitLength) { return this.put(new SVG.DiffuseLightingEffect(surfaceScale, diffuseConstant, kernelUnitLength)); }, // DisplacementMap effect displacementMap: function displacementMap(in1, in2, scale, xChannelSelector, yChannelSelector) { return this.put(new SVG.DisplacementMapEffect(in1, in2, scale, xChannelSelector, yChannelSelector)); }, // SpecularLighting effect specularLighting: function specularLighting(surfaceScale, diffuseConstant, specularExponent, kernelUnitLength) { return this.put(new SVG.SpecularLightingEffect(surfaceScale, diffuseConstant, specularExponent, kernelUnitLength)); }, // Tile effect tile: function tile() { return this.put(new SVG.TileEffect()); }, // Turbulence effect turbulence: function turbulence(baseFrequency, numOctaves, seed, stitchTiles, type) { return this.put(new SVG.TurbulenceEffect(baseFrequency, numOctaves, seed, stitchTiles, type)); }, // Default string value toString: function toString() { return 'url(#' + this.attr('id') + ')'; } } }); //add .filter function SVG.extend(SVG.Defs, { // Define filter filter: function filter(block) { var filter = this.put(new SVG.Filter()); /* invoke passed block */ if (typeof block === 'function') block.call(filter, filter); return filter; } }); SVG.extend(SVG.Container, { // Define filter on defs filter: function filter(block) { return this.defs().filter(block); } }); SVG.extend(SVG.Element, SVG.G, SVG.Nested, { // Create filter element in defs and store reference filter: function filter(block) { this.filterer = block instanceof SVG.Element ? block : this.doc().filter(block); if (this.doc() && this.filterer.doc() !== this.doc()) { this.doc().defs().add(this.filterer); } this.attr('filter', this.filterer); return this.filterer; }, // Remove filter unfilter: function unfilter(remove) { /* also remove the filter node */ if (this.filterer && remove === true) this.filterer.remove(); /* delete reference to filterer */ delete this.filterer; /* remove filter attribute */ return this.attr('filter', null); } }); // Create SVG.Effect class SVG.Effect = SVG.invent({ create: function create() { this.constructor.call(this); }, inherit: SVG.Element, extend: { // Set in attribute in: function _in(effect) { return effect == null ? this.parent() && this.parent().select('[result="' + this.attr('in') + '"]').get(0) || this.attr('in') : this.attr('in', effect); }, // Named result result: function result(_result) { return _result == null ? this.attr('result') : this.attr('result', _result); }, // Stringification toString: function toString() { return this.result(); } } }); // create class for parent effects like merge // Inherit from SVG.Parent SVG.ParentEffect = SVG.invent({ create: function create() { this.constructor.call(this); }, inherit: SVG.Parent, extend: { // Set in attribute in: function _in(effect) { return effect == null ? this.parent() && this.parent().select('[result="' + this.attr('in') + '"]').get(0) || this.attr('in') : this.attr('in', effect); }, // Named result result: function result(_result2) { return _result2 == null ? this.attr('result') : this.attr('result', _result2); }, // Stringification toString: function toString() { return this.result(); } } }); //chaining var chainingEffects = { // Blend effect blend: function blend(in2, mode) { return this.parent() && this.parent().blend(this, in2, mode); //pass this as the first input }, // ColorMatrix effect colorMatrix: function colorMatrix(type, values) { return this.parent() && this.parent().colorMatrix(type, values).in(this); }, // ConvolveMatrix effect convolveMatrix: function convolveMatrix(matrix) { return this.parent() && this.parent().convolveMatrix(matrix).in(this); }, // ComponentTransfer effect componentTransfer: function componentTransfer(components) { return this.parent() && this.parent().componentTransfer(components).in(this); }, // Composite effect composite: function composite(in2, operator) { return this.parent() && this.parent().composite(this, in2, operator); //pass this as the first input }, // Flood effect flood: function flood(color, opacity) { return this.parent() && this.parent().flood(color, opacity); //this effect dont have inputs }, // Offset effect offset: function offset(x, y) { return this.parent() && this.parent().offset(x, y).in(this); }, // Image effect image: function image(src) { return this.parent() && this.parent().image(src); //this effect dont have inputs }, // Merge effect merge: function merge() { return this.parent() && this.parent().merge.apply(this.parent(), [this].concat(arguments)); //pass this as the first argument }, // Gaussian Blur effect gaussianBlur: function gaussianBlur(x, y) { return this.parent() && this.parent().gaussianBlur(x, y).in(this); }, // Morphology effect morphology: function morphology(operator, radius) { return this.parent() && this.parent().morphology(operator, radius).in(this); }, // DiffuseLighting effect diffuseLighting: function diffuseLighting(surfaceScale, diffuseConstant, kernelUnitLength) { return this.parent() && this.parent().diffuseLighting(surfaceScale, diffuseConstant, kernelUnitLength).in(this); }, // DisplacementMap effect displacementMap: function displacementMap(in2, scale, xChannelSelector, yChannelSelector) { return this.parent() && this.parent().displacementMap(this, in2, scale, xChannelSelector, yChannelSelector); //pass this as the first input }, // SpecularLighting effect specularLighting: function specularLighting(surfaceScale, diffuseConstant, specularExponent, kernelUnitLength) { return this.parent() && this.parent().specularLighting(surfaceScale, diffuseConstant, specularExponent, kernelUnitLength).in(this); }, // Tile effect tile: function tile() { return this.parent() && this.parent().tile().in(this); }, // Turbulence effect turbulence: function turbulence(baseFrequency, numOctaves, seed, stitchTiles, type) { return this.parent() && this.parent().turbulence(baseFrequency, numOctaves, seed, stitchTiles, type).in(this); } }; SVG.extend(SVG.Effect, chainingEffects); SVG.extend(SVG.ParentEffect, chainingEffects); //crea class for child effects, like MergeNode, FuncR and lights SVG.ChildEffect = SVG.invent({ create: function create() { this.constructor.call(this); }, inherit: SVG.Element, extend: { in: function _in(effect) { this.attr('in', effect); } //dont include any "result" functions because these types of nodes dont have them } }); // Create all different effects var effects = { blend: function blend(in1, in2, mode) { this.attr({ in: in1, in2: in2, mode: mode || 'normal' }); }, colorMatrix: function colorMatrix(type, values) { if (type == 'matrix') values = normaliseMatrix(values); this.attr({ type: type, values: typeof values == 'undefined' ? null : values }); }, convolveMatrix: function convolveMatrix(matrix) { matrix = normaliseMatrix(matrix); this.attr({ order: Math.sqrt(matrix.split(' ').length), kernelMatrix: matrix }); }, composite: function composite(in1, in2, operator) { this.attr({ in: in1, in2: in2, operator: operator }); }, flood: function flood(color, opacity) { this.attr('flood-color', color); if (opacity != null) this.attr('flood-opacity', opacity); }, offset: function offset(x, y) { this.attr({ dx: x, dy: y }); }, image: function image(src) { this.attr('href', src, SVG.xlink); }, displacementMap: function displacementMap(in1, in2, scale, xChannelSelector, yChannelSelector) { this.attr({ in: in1, in2: in2, scale: scale, xChannelSelector: xChannelSelector, yChannelSelector: yChannelSelector }); }, gaussianBlur: function gaussianBlur(x, y) { if (x != null || y != null) this.attr('stdDeviation', listString(Array.prototype.slice.call(arguments)));else this.attr('stdDeviation', '0 0'); }, morphology: function morphology(operator, radius) { this.attr({ operator: operator, radius: radius }); }, tile: function tile() {}, turbulence: function turbulence(baseFrequency, numOctaves, seed, stitchTiles, type) { this.attr({ numOctaves: numOctaves, seed: seed, stitchTiles: stitchTiles, baseFrequency: baseFrequency, type: type }); } // Create all parent effects };var parentEffects = { merge: function merge() { var children; //test to see if we have a set if (arguments[0] instanceof SVG.Set) { var that = this; arguments[0].each(function (i) { if (this instanceof SVG.MergeNode) that.put(this);else if (this instanceof SVG.Effect || this instanceof SVG.ParentEffect) that.put(new SVG.MergeNode(this)); }); } else { //if the first argument is an array use it if (Array.isArray(arguments[0])) children = arguments[0];else children = arguments; for (var i = 0; i < children.length; i++) { if (children[i] instanceof SVG.MergeNode) { this.put(children[i]); } else this.put(new SVG.MergeNode(children[i])); } } }, componentTransfer: function componentTransfer(compontents) { /* create rgb set */ this.rgb = new SVG.Set() /* create components */ ;['r', 'g', 'b', 'a'].forEach(function (c) { /* create component */ this[c] = new SVG['Func' + c.toUpperCase()]('identity'); /* store component in set */ this.rgb.add(this[c]); /* add component node */ this.node.appendChild(this[c].node); }.bind(this)); //lost context in foreach /* set components */ if (compontents) { if (compontents.rgb) { /* set bundled components */ ;['r', 'g', 'b'].forEach(function (c) { this[c].attr(compontents.rgb); }.bind(this)); delete compontents.rgb; } /* set individual components */ for (var c in compontents) { this[c].attr(compontents[c]); } } }, diffuseLighting: function diffuseLighting(surfaceScale, diffuseConstant, kernelUnitLength) { this.attr({ surfaceScale: surfaceScale, diffuseConstant: diffuseConstant, kernelUnitLength: kernelUnitLength }); }, specularLighting: function specularLighting(surfaceScale, diffuseConstant, specularExponent, kernelUnitLength) { this.attr({ surfaceScale: surfaceScale, diffuseConstant: diffuseConstant, specularExponent: specularExponent, kernelUnitLength: kernelUnitLength }); } // Create child effects like PointLight and MergeNode };var childEffects = { distantLight: function distantLight(azimuth, elevation) { this.attr({ azimuth: azimuth, elevation: elevation }); }, pointLight: function pointLight(x, y, z) { this.attr({ x: x, y: y, z: z }); }, spotLight: function spotLight(x, y, z, pointsAtX, pointsAtY, pointsAtZ) { this.attr({ x: x, y: y, z: z, pointsAtX: pointsAtX, pointsAtY: pointsAtY, pointsAtZ: pointsAtZ }); }, mergeNode: function mergeNode(in1) { this.attr('in', in1); } // Create compontent functions };['r', 'g', 'b', 'a'].forEach(function (c) { /* create class */ childEffects['Func' + c.toUpperCase()] = function (type) { this.attr('type', type); // take diffent arguments based on the type switch (type) { case 'table': this.attr('tableValues', arguments[1]); break; case 'linear': this.attr('slope', arguments[1]); this.attr('intercept', arguments[2]); break; case 'gamma': this.attr('amplitude', arguments[1]); this.attr('exponent', arguments[2]); this.attr('offset', arguments[2]); break; } }; }); //create effects foreach(effects, function (effect, i) { /* capitalize name */ var name = i.charAt(0).toUpperCase() + i.slice(1); var proto = {}; /* create class */ SVG[name + 'Effect'] = SVG.invent({ create: function create() { //call super this.constructor.call(this, SVG.create('fe' + name)); //call constructor for this effect effect.apply(this, arguments); //set the result this.result(this.attr('id') + 'Out'); }, inherit: SVG.Effect, extend: proto }); }); //create parent effects foreach(parentEffects, function (effect, i) { /* capitalize name */ var name = i.charAt(0).toUpperCase() + i.slice(1); var proto = {}; /* create class */ SVG[name + 'Effect'] = SVG.invent({ create: function create() { //call super this.constructor.call(this, SVG.create('fe' + name)); //call constructor for this effect effect.apply(this, arguments); //set the result this.result(this.attr('id') + 'Out'); }, inherit: SVG.ParentEffect, extend: proto }); }); //create child effects foreach(childEffects, function (effect, i) { /* capitalize name */ var name = i.charAt(0).toUpperCase() + i.slice(1); var proto = {}; /* create class */ SVG[name] = SVG.invent({ create: function create() { //call super this.constructor.call(this, SVG.create('fe' + name)); //call constructor for this effect effect.apply(this, arguments); }, inherit: SVG.ChildEffect, extend: proto }); }); // Effect-specific extensions SVG.extend(SVG.MergeEffect, { in: function _in(effect) { if (effect instanceof SVG.MergeNode) this.add(effect, 0);else this.add(new SVG.MergeNode(effect), 0); return this; } }); SVG.extend(SVG.CompositeEffect, SVG.BlendEffect, SVG.DisplacementMapEffect, { in2: function in2(effect) { return effect == null ? this.parent() && this.parent().select('[result="' + this.attr('in2') + '"]').get(0) || this.attr('in2') : this.attr('in2', effect); } }); // Presets SVG.filter = { sepiatone: [.343, .669, .119, 0, 0, .249, .626, .130, 0, 0, .172, .334, .111, 0, 0, .000, .000, .000, 1, 0] // Helpers };function normaliseMatrix(matrix) { /* convert possible array value to string */ if (Array.isArray(matrix)) matrix = new SVG.Array(matrix); /* ensure there are no leading, tailing or double spaces */ return matrix.toString().replace(/^\s+/, '').replace(/\s+$/, '').replace(/\s+/g, ' '); } function listString(list) { if (!Array.isArray(list)) return list; for (var i = 0, l = list.length, s = []; i < l; i++) { s.push(list[i]); }return s.join(' '); } function foreach() { //loops through mutiple objects var fn = function fn() {}; if (typeof arguments[arguments.length - 1] == 'function') { fn = arguments[arguments.length - 1]; Array.prototype.splice.call(arguments, arguments.length - 1, 1); } for (var k in arguments) { for (var i in arguments[k]) { fn(arguments[k][i], i, arguments[k]); } } } }).call(undefined); /***/ }), /* 151 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*! * svg.pathmorphing.js - Enables pathmorphing / path animation in svg.js * @version 0.1.3 * * * @copyright (c) 2018 Ulrich-Matthias Schäfer * @license MIT */; ;(function () { "use strict"; SVG.extend(SVG.PathArray, { morph: function morph(array) { var startArr = this.value, destArr = this.parse(array); var startOffsetM = 0, destOffsetM = 0; var startOffsetNextM = false, destOffsetNextM = false; while (true) { // stop if there is no M anymore if (startOffsetM === false && destOffsetM === false) break; // find the next M in path array startOffsetNextM = findNextM(startArr, startOffsetM === false ? false : startOffsetM + 1); destOffsetNextM = findNextM(destArr, destOffsetM === false ? false : destOffsetM + 1); // We have to add one M to the startArray if (startOffsetM === false) { var bbox = new SVG.PathArray(result.start).bbox(); // when the last block had no bounding box we simply take the first M we got if (bbox.height == 0 || bbox.width == 0) { startOffsetM = startArr.push(startArr[0]) - 1; } else { // we take the middle of the bbox instead when we got one startOffsetM = startArr.push(['M', bbox.x + bbox.width / 2, bbox.y + bbox.height / 2]) - 1; } } // We have to add one M to the destArray if (destOffsetM === false) { var bbox = new SVG.PathArray(result.dest).bbox(); if (bbox.height == 0 || bbox.width == 0) { destOffsetM = destArr.push(destArr[0]) - 1; } else { destOffsetM = destArr.push(['M', bbox.x + bbox.width / 2, bbox.y + bbox.height / 2]) - 1; } } // handle block from M to next M var result = handleBlock(startArr, startOffsetM, startOffsetNextM, destArr, destOffsetM, destOffsetNextM); // update the arrays to their new values startArr = startArr.slice(0, startOffsetM).concat(result.start, startOffsetNextM === false ? [] : startArr.slice(startOffsetNextM)); destArr = destArr.slice(0, destOffsetM).concat(result.dest, destOffsetNextM === false ? [] : destArr.slice(destOffsetNextM)); // update offsets startOffsetM = startOffsetNextM === false ? false : startOffsetM + result.start.length; destOffsetM = destOffsetNextM === false ? false : destOffsetM + result.dest.length; } // copy back arrays this.value = startArr; this.destination = new SVG.PathArray(); this.destination.value = destArr; return this; } }); // sorry for the long declaration // slices out one block (from M to M) and syncronize it so the types and length match function handleBlock(startArr, startOffsetM, startOffsetNextM, destArr, destOffsetM, destOffsetNextM, undefined) { // slice out the block we need var startArrTemp = startArr.slice(startOffsetM, startOffsetNextM || undefined), destArrTemp = destArr.slice(destOffsetM, destOffsetNextM || undefined); var i = 0, posStart = { pos: [0, 0], start: [0, 0] }, posDest = { pos: [0, 0], start: [0, 0] }; do { // convert shorthand types to long form startArrTemp[i] = simplyfy.call(posStart, startArrTemp[i]); destArrTemp[i] = simplyfy.call(posDest, destArrTemp[i]); // check if both shape types match // 2 elliptical arc curve commands ('A'), are considered different if the // flags (large-arc-flag, sweep-flag) don't match if (startArrTemp[i][0] != destArrTemp[i][0] || startArrTemp[i][0] == 'M' || startArrTemp[i][0] == 'A' && (startArrTemp[i][4] != destArrTemp[i][4] || startArrTemp[i][5] != destArrTemp[i][5])) { // if not, convert shapes to beziere Array.prototype.splice.apply(startArrTemp, [i, 1].concat(toBeziere.call(posStart, startArrTemp[i]))); Array.prototype.splice.apply(destArrTemp, [i, 1].concat(toBeziere.call(posDest, destArrTemp[i]))); } else { // only update positions otherwise startArrTemp[i] = setPosAndReflection.call(posStart, startArrTemp[i]); destArrTemp[i] = setPosAndReflection.call(posDest, destArrTemp[i]); } // we are at the end at both arrays. stop here if (++i == startArrTemp.length && i == destArrTemp.length) break; // destArray is longer. Add one element if (i == startArrTemp.length) { startArrTemp.push(['C', posStart.pos[0], posStart.pos[1], posStart.pos[0], posStart.pos[1], posStart.pos[0], posStart.pos[1]]); } // startArr is longer. Add one element if (i == destArrTemp.length) { destArrTemp.push(['C', posDest.pos[0], posDest.pos[1], posDest.pos[0], posDest.pos[1], posDest.pos[0], posDest.pos[1]]); } } while (true); // return the updated block return { start: startArrTemp, dest: destArrTemp }; } // converts shorthand types to long form function simplyfy(val) { switch (val[0]) { case 'z': // shorthand line to start case 'Z': val[0] = 'L'; val[1] = this.start[0]; val[2] = this.start[1]; break; case 'H': // shorthand horizontal line val[0] = 'L'; val[2] = this.pos[1]; break; case 'V': // shorthand vertical line val[0] = 'L'; val[2] = val[1]; val[1] = this.pos[0]; break; case 'T': // shorthand quadratic beziere val[0] = 'Q'; val[3] = val[1]; val[4] = val[2]; val[1] = this.reflection[1]; val[2] = this.reflection[0]; break; case 'S': // shorthand cubic beziere val[0] = 'C'; val[6] = val[4]; val[5] = val[3]; val[4] = val[2]; val[3] = val[1]; val[2] = this.reflection[1]; val[1] = this.reflection[0]; break; } return val; } // updates reflection point and current position function setPosAndReflection(val) { var len = val.length; this.pos = [val[len - 2], val[len - 1]]; if ('SCQT'.indexOf(val[0]) != -1) this.reflection = [2 * this.pos[0] - val[len - 4], 2 * this.pos[1] - val[len - 3]]; return val; } // converts all types to cubic beziere function toBeziere(val) { var retVal = [val]; switch (val[0]) { case 'M': // special handling for M this.pos = this.start = [val[1], val[2]]; return retVal; case 'L': val[5] = val[3] = val[1]; val[6] = val[4] = val[2]; val[1] = this.pos[0]; val[2] = this.pos[1]; break; case 'Q': val[6] = val[4]; val[5] = val[3]; val[4] = val[4] * 1 / 3 + val[2] * 2 / 3; val[3] = val[3] * 1 / 3 + val[1] * 2 / 3; val[2] = this.pos[1] * 1 / 3 + val[2] * 2 / 3; val[1] = this.pos[0] * 1 / 3 + val[1] * 2 / 3; break; case 'A': retVal = arcToBeziere(this.pos, val); val = retVal[0]; break; } val[0] = 'C'; this.pos = [val[5], val[6]]; this.reflection = [2 * val[5] - val[3], 2 * val[6] - val[4]]; return retVal; } // finds the next position of type M function findNextM(arr, offset) { if (offset === false) return false; for (var i = offset, len = arr.length; i < len; ++i) { if (arr[i][0] == 'M') return i; } return false; } // Convert an arc segment into equivalent cubic Bezier curves // Depending on the arc, up to 4 curves might be used to represent it since a // curve gives a good approximation for only a quarter of an ellipse // The curves are returned as an array of SVG curve commands: // [ ['C', x1, y1, x2, y2, x, y] ... ] function arcToBeziere(pos, val) { // Parameters extraction, handle out-of-range parameters as specified in the SVG spec // See: https://www.w3.org/TR/SVG11/implnote.html#ArcOutOfRangeParameters var rx = Math.abs(val[1]), ry = Math.abs(val[2]), xAxisRotation = val[3] % 360, largeArcFlag = val[4], sweepFlag = val[5], x = val[6], y = val[7], A = new SVG.Point(pos), B = new SVG.Point(x, y), primedCoord, lambda, mat, k, c, cSquare, t, O, OA, OB, tetaStart, tetaEnd, deltaTeta, nbSectors, f, arcSegPoints, angle, sinAngle, cosAngle, pt, i, il, retVal = [], x1, y1, x2, y2; // Ensure radii are non-zero if (rx === 0 || ry === 0 || A.x === B.x && A.y === B.y) { // treat this arc as a straight line segment return [['C', A.x, A.y, B.x, B.y, B.x, B.y]]; } // Ensure radii are large enough using the algorithm provided in the SVG spec // See: https://www.w3.org/TR/SVG11/implnote.html#ArcCorrectionOutOfRangeRadii primedCoord = new SVG.Point((A.x - B.x) / 2, (A.y - B.y) / 2).transform(new SVG.Matrix().rotate(xAxisRotation)); lambda = primedCoord.x * primedCoord.x / (rx * rx) + primedCoord.y * primedCoord.y / (ry * ry); if (lambda > 1) { lambda = Math.sqrt(lambda); rx = lambda * rx; ry = lambda * ry; } // To simplify calculations, we make the arc part of a unit circle (rayon is 1) instead of an ellipse mat = new SVG.Matrix().rotate(xAxisRotation).scale(1 / rx, 1 / ry).rotate(-xAxisRotation); A = A.transform(mat); B = B.transform(mat); // Calculate the horizontal and vertical distance between the initial and final point of the arc k = [B.x - A.x, B.y - A.y]; // Find the length of the chord formed by A and B cSquare = k[0] * k[0] + k[1] * k[1]; c = Math.sqrt(cSquare); // Calculate the ratios of the horizontal and vertical distance on the length of the chord k[0] /= c; k[1] /= c; // Calculate the distance between the circle center and the chord midpoint // using this formula: t = sqrt(r^2 - c^2 / 4) // where t is the distance between the cirle center and the chord midpoint, // r is the rayon of the circle and c is the chord length // From: http://www.ajdesigner.com/phpcircle/circle_segment_chord_t.php // Because of the imprecision of floating point numbers, cSquare might end // up being slightly above 4 which would result in a negative radicand // To prevent that, a test is made before computing the square root t = cSquare < 4 ? Math.sqrt(1 - cSquare / 4) : 0; // For most situations, there are actually two different ellipses that // satisfy the constraints imposed by the points A and B, the radii rx and ry, // and the xAxisRotation // When the flags largeArcFlag and sweepFlag are equal, it means that the // second ellipse is used as a solution // See: https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands if (largeArcFlag === sweepFlag) { t *= -1; } // Calculate the coordinates of the center of the circle from the midpoint of the chord // This is done by multiplying the ratios calculated previously by the distance between // the circle center and the chord midpoint and using these values to go from the midpoint // to the center of the circle // The negative of the vertical distance ratio is used to modify the x coordinate while // the horizontal distance ratio is used to modify the y coordinate // That is because the center of the circle is perpendicular to the chord and perpendicular // lines are negative reciprocals O = new SVG.Point((B.x + A.x) / 2 + t * -k[1], (B.y + A.y) / 2 + t * k[0]); // Move the center of the circle at the origin OA = new SVG.Point(A.x - O.x, A.y - O.y); OB = new SVG.Point(B.x - O.x, B.y - O.y); // Calculate the start and end angle tetaStart = Math.acos(OA.x / Math.sqrt(OA.x * OA.x + OA.y * OA.y)); if (OA.y < 0) { tetaStart *= -1; } tetaEnd = Math.acos(OB.x / Math.sqrt(OB.x * OB.x + OB.y * OB.y)); if (OB.y < 0) { tetaEnd *= -1; } // If sweep-flag is '1', then the arc will be drawn in a "positive-angle" direction, // make sure that the end angle is above the start angle if (sweepFlag && tetaStart > tetaEnd) { tetaEnd += 2 * Math.PI; } // If sweep-flag is '0', then the arc will be drawn in a "negative-angle" direction, // make sure that the end angle is below the start angle if (!sweepFlag && tetaStart < tetaEnd) { tetaEnd -= 2 * Math.PI; } // Find the number of Bezier curves that are required to represent the arc // A cubic Bezier curve gives a good enough approximation when representing at most a quarter of a circle nbSectors = Math.ceil(Math.abs(tetaStart - tetaEnd) * 2 / Math.PI); // Calculate the coordinates of the points of all the Bezier curves required to represent the arc // For an in-depth explanation of this part see: http://pomax.github.io/bezierinfo/#circles_cubic arcSegPoints = []; angle = tetaStart; deltaTeta = (tetaEnd - tetaStart) / nbSectors; f = 4 * Math.tan(deltaTeta / 4) / 3; for (i = 0; i <= nbSectors; i++) { // The <= is because a Bezier curve have a start and a endpoint cosAngle = Math.cos(angle); sinAngle = Math.sin(angle); pt = new SVG.Point(O.x + cosAngle, O.y + sinAngle); arcSegPoints[i] = [new SVG.Point(pt.x + f * sinAngle, pt.y - f * cosAngle), pt, new SVG.Point(pt.x - f * sinAngle, pt.y + f * cosAngle)]; angle += deltaTeta; } // Remove the first control point of the first segment point and remove the second control point of the last segment point // These two control points are not used in the approximation of the arc, that is why they are removed arcSegPoints[0][0] = arcSegPoints[0][1].clone(); arcSegPoints[arcSegPoints.length - 1][2] = arcSegPoints[arcSegPoints.length - 1][1].clone(); // Revert the transformation that was applied to make the arc part of a unit circle instead of an ellipse mat = new SVG.Matrix().rotate(xAxisRotation).scale(rx, ry).rotate(-xAxisRotation); for (i = 0, il = arcSegPoints.length; i < il; i++) { arcSegPoints[i][0] = arcSegPoints[i][0].transform(mat); arcSegPoints[i][1] = arcSegPoints[i][1].transform(mat); arcSegPoints[i][2] = arcSegPoints[i][2].transform(mat); } // Convert the segments points to SVG curve commands for (i = 1, il = arcSegPoints.length; i < il; i++) { pt = arcSegPoints[i - 1][2]; x1 = pt.x; y1 = pt.y; pt = arcSegPoints[i][0]; x2 = pt.x; y2 = pt.y; pt = arcSegPoints[i][1]; x = pt.x; y = pt.y; retVal.push(['C', x1, y1, x2, y2, x, y]); } return retVal; } })(); /***/ }), /* 152 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /*! * svg.resize.js - An extension for svg.js which allows to resize elements which are selected * @version 1.4.2 * https://github.com/svgdotjs/svg.resize.js * * @copyright [object Object] * @license MIT */; ;(function () { "use strict"; ;(function () { function ResizeHandler(el) { el.remember('_resizeHandler', this); this.el = el; this.parameters = {}; this.lastUpdateCall = null; this.p = el.doc().node.createSVGPoint(); } ResizeHandler.prototype.transformPoint = function (x, y, m) { this.p.x = x - (this.offset.x - window.pageXOffset); this.p.y = y - (this.offset.y - window.pageYOffset); return this.p.matrixTransform(m || this.m); }; ResizeHandler.prototype._extractPosition = function (event) { // Extract a position from a mouse/touch event. // Returns { x: .., y: .. } return { x: event.clientX != null ? event.clientX : event.touches[0].clientX, y: event.clientY != null ? event.clientY : event.touches[0].clientY }; }; ResizeHandler.prototype.init = function (options) { var _this = this; this.stop(); if (options === 'stop') { return; } this.options = {}; // Merge options and defaults for (var i in this.el.resize.defaults) { this.options[i] = this.el.resize.defaults[i]; if (typeof options[i] !== 'undefined') { this.options[i] = options[i]; } } // We listen to all these events which are specifying different edges this.el.on('lt.resize', function (e) { _this.resize(e || window.event); }); // Left-Top this.el.on('rt.resize', function (e) { _this.resize(e || window.event); }); // Right-Top this.el.on('rb.resize', function (e) { _this.resize(e || window.event); }); // Right-Bottom this.el.on('lb.resize', function (e) { _this.resize(e || window.event); }); // Left-Bottom this.el.on('t.resize', function (e) { _this.resize(e || window.event); }); // Top this.el.on('r.resize', function (e) { _this.resize(e || window.event); }); // Right this.el.on('b.resize', function (e) { _this.resize(e || window.event); }); // Bottom this.el.on('l.resize', function (e) { _this.resize(e || window.event); }); // Left this.el.on('rot.resize', function (e) { _this.resize(e || window.event); }); // Rotation this.el.on('point.resize', function (e) { _this.resize(e || window.event); }); // Point-Moving // This call ensures, that the plugin reacts to a change of snapToGrid immediately this.update(); }; ResizeHandler.prototype.stop = function () { this.el.off('lt.resize'); this.el.off('rt.resize'); this.el.off('rb.resize'); this.el.off('lb.resize'); this.el.off('t.resize'); this.el.off('r.resize'); this.el.off('b.resize'); this.el.off('l.resize'); this.el.off('rot.resize'); this.el.off('point.resize'); return this; }; ResizeHandler.prototype.resize = function (event) { var _this = this; this.m = this.el.node.getScreenCTM().inverse(); this.offset = { x: window.pageXOffset, y: window.pageYOffset }; var txPt = this._extractPosition(event.detail.event); this.parameters = { type: this.el.type, // the type of element p: this.transformPoint(txPt.x, txPt.y), x: event.detail.x, // x-position of the mouse when resizing started y: event.detail.y, // y-position of the mouse when resizing started box: this.el.bbox(), // The bounding-box of the element rotation: this.el.transform().rotation // The current rotation of the element }; // Add font-size parameter if the element type is text if (this.el.type === "text") { this.parameters.fontSize = this.el.attr()["font-size"]; } // the i-param in the event holds the index of the point which is moved, when using `deepSelect` if (event.detail.i !== undefined) { // get the point array var array = this.el.array().valueOf(); // Save the index and the point which is moved this.parameters.i = event.detail.i; this.parameters.pointCoords = [array[event.detail.i][0], array[event.detail.i][1]]; } // Lets check which edge of the bounding-box was clicked and resize the this.el according to this switch (event.type) { // Left-Top-Edge case 'lt': // We build a calculating function for every case which gives us the new position of the this.el this.calc = function (diffX, diffY) { // The procedure is always the same // First we snap the edge to the given grid (snapping to 1px grid is normal resizing) var snap = this.snapToGrid(diffX, diffY); // Now we check if the new height and width still valid (> 0) if (this.parameters.box.width - snap[0] > 0 && this.parameters.box.height - snap[1] > 0) { // ...if valid, we resize the this.el (which can include moving because the coord-system starts at the left-top and this edge is moving sometimes when resized) /* * but first check if the element is text box, so we can change the font size instead of * the width and height */ if (this.parameters.type === "text") { this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y); this.el.attr("font-size", this.parameters.fontSize - snap[0]); return; } snap = this.checkAspectRatio(snap); this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y + snap[1]).size(this.parameters.box.width - snap[0], this.parameters.box.height - snap[1]); } }; break; // Right-Top case 'rt': // s.a. this.calc = function (diffX, diffY) { var snap = this.snapToGrid(diffX, diffY, 1 << 1); if (this.parameters.box.width + snap[0] > 0 && this.parameters.box.height - snap[1] > 0) { if (this.parameters.type === "text") { this.el.move(this.parameters.box.x - snap[0], this.parameters.box.y); this.el.attr("font-size", this.parameters.fontSize + snap[0]); return; } snap = this.checkAspectRatio(snap); this.el.move(this.parameters.box.x, this.parameters.box.y + snap[1]).size(this.parameters.box.width + snap[0], this.parameters.box.height - snap[1]); } }; break; // Right-Bottom case 'rb': // s.a. this.calc = function (diffX, diffY) { var snap = this.snapToGrid(diffX, diffY, 0); if (this.parameters.box.width + snap[0] > 0 && this.parameters.box.height + snap[1] > 0) { if (this.parameters.type === "text") { this.el.move(this.parameters.box.x - snap[0], this.parameters.box.y); this.el.attr("font-size", this.parameters.fontSize + snap[0]); return; } snap = this.checkAspectRatio(snap); this.el.move(this.parameters.box.x, this.parameters.box.y).size(this.parameters.box.width + snap[0], this.parameters.box.height + snap[1]); } }; break; // Left-Bottom case 'lb': // s.a. this.calc = function (diffX, diffY) { var snap = this.snapToGrid(diffX, diffY, 1); if (this.parameters.box.width - snap[0] > 0 && this.parameters.box.height + snap[1] > 0) { if (this.parameters.type === "text") { this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y); this.el.attr("font-size", this.parameters.fontSize - snap[0]); return; } snap = this.checkAspectRatio(snap); this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y).size(this.parameters.box.width - snap[0], this.parameters.box.height + snap[1]); } }; break; // Top case 't': // s.a. this.calc = function (diffX, diffY) { var snap = this.snapToGrid(diffX, diffY, 1 << 1); if (this.parameters.box.height - snap[1] > 0) { // Disable the font-resizing if it is not from the corner of bounding-box if (this.parameters.type === "text") { return; } this.el.move(this.parameters.box.x, this.parameters.box.y + snap[1]).height(this.parameters.box.height - snap[1]); } }; break; // Right case 'r': // s.a. this.calc = function (diffX, diffY) { var snap = this.snapToGrid(diffX, diffY, 0); if (this.parameters.box.width + snap[0] > 0) { if (this.parameters.type === "text") { return; } this.el.move(this.parameters.box.x, this.parameters.box.y).width(this.parameters.box.width + snap[0]); } }; break; // Bottom case 'b': // s.a. this.calc = function (diffX, diffY) { var snap = this.snapToGrid(diffX, diffY, 0); if (this.parameters.box.height + snap[1] > 0) { if (this.parameters.type === "text") { return; } this.el.move(this.parameters.box.x, this.parameters.box.y).height(this.parameters.box.height + snap[1]); } }; break; // Left case 'l': // s.a. this.calc = function (diffX, diffY) { var snap = this.snapToGrid(diffX, diffY, 1); if (this.parameters.box.width - snap[0] > 0) { if (this.parameters.type === "text") { return; } this.el.move(this.parameters.box.x + snap[0], this.parameters.box.y).width(this.parameters.box.width - snap[0]); } }; break; // Rotation case 'rot': // s.a. this.calc = function (diffX, diffY) { // yes this is kinda stupid but we need the mouse coords back... var current = { x: diffX + this.parameters.p.x, y: diffY + this.parameters.p.y }; // start minus middle var sAngle = Math.atan2(this.parameters.p.y - this.parameters.box.y - this.parameters.box.height / 2, this.parameters.p.x - this.parameters.box.x - this.parameters.box.width / 2); // end minus middle var pAngle = Math.atan2(current.y - this.parameters.box.y - this.parameters.box.height / 2, current.x - this.parameters.box.x - this.parameters.box.width / 2); var angle = (pAngle - sAngle) * 180 / Math.PI; // We have to move the element to the center of the box first and change the rotation afterwards // because rotation always works around a rotation-center, which is changed when moving the element // We also set the new rotation center to the center of the box. this.el.center(this.parameters.box.cx, this.parameters.box.cy).rotate(this.parameters.rotation + angle - angle % this.options.snapToAngle, this.parameters.box.cx, this.parameters.box.cy); }; break; // Moving one single Point (needed when an element is deepSelected which means you can move every single point of the object) case 'point': this.calc = function (diffX, diffY) { // Snapping the point to the grid var snap = this.snapToGrid(diffX, diffY, this.parameters.pointCoords[0], this.parameters.pointCoords[1]); // Get the point array var array = this.el.array().valueOf(); // Changing the moved point in the array array[this.parameters.i][0] = this.parameters.pointCoords[0] + snap[0]; array[this.parameters.i][1] = this.parameters.pointCoords[1] + snap[1]; // And plot the new this.el this.el.plot(array); }; } this.el.fire('resizestart', { dx: this.parameters.x, dy: this.parameters.y, event: event }); // When resizing started, we have to register events for... // Touches. SVG.on(window, 'touchmove.resize', function (e) { _this.update(e || window.event); }); SVG.on(window, 'touchend.resize', function () { _this.done(); }); // Mouse. SVG.on(window, 'mousemove.resize', function (e) { _this.update(e || window.event); }); SVG.on(window, 'mouseup.resize', function () { _this.done(); }); }; // The update-function redraws the element every time the mouse is moving ResizeHandler.prototype.update = function (event) { if (!event) { if (this.lastUpdateCall) { this.calc(this.lastUpdateCall[0], this.lastUpdateCall[1]); } return; } // Calculate the difference between the mouseposition at start and now var txPt = this._extractPosition(event); var p = this.transformPoint(txPt.x, txPt.y); var diffX = p.x - this.parameters.p.x, diffY = p.y - this.parameters.p.y; this.lastUpdateCall = [diffX, diffY]; // Calculate the new position and height / width of the element this.calc(diffX, diffY); // Emit an event to say we have changed. this.el.fire('resizing', { dx: diffX, dy: diffY, event: event }); }; // Is called on mouseup. // Removes the update-function from the mousemove event ResizeHandler.prototype.done = function () { this.lastUpdateCall = null; SVG.off(window, 'mousemove.resize'); SVG.off(window, 'mouseup.resize'); SVG.off(window, 'touchmove.resize'); SVG.off(window, 'touchend.resize'); this.el.fire('resizedone'); }; // The flag is used to determine whether the resizing is used with a left-Point (first bit) and top-point (second bit) // In this cases the temp-values are calculated differently ResizeHandler.prototype.snapToGrid = function (diffX, diffY, flag, pointCoordsY) { var temp; // If `pointCoordsY` is given, a single Point has to be snapped (deepSelect). That's why we need a different temp-value if (typeof pointCoordsY !== 'undefined') { // Note that flag = pointCoordsX in this case temp = [(flag + diffX) % this.options.snapToGrid, (pointCoordsY + diffY) % this.options.snapToGrid]; } else { // We check if the flag is set and if not we set a default-value (both bits set - which means upper-left-edge) flag = flag == null ? 1 | 1 << 1 : flag; temp = [(this.parameters.box.x + diffX + (flag & 1 ? 0 : this.parameters.box.width)) % this.options.snapToGrid, (this.parameters.box.y + diffY + (flag & 1 << 1 ? 0 : this.parameters.box.height)) % this.options.snapToGrid]; } diffX -= Math.abs(temp[0]) < this.options.snapToGrid / 2 ? temp[0] : temp[0] - (diffX < 0 ? -this.options.snapToGrid : this.options.snapToGrid); diffY -= Math.abs(temp[1]) < this.options.snapToGrid / 2 ? temp[1] : temp[1] - (diffY < 0 ? -this.options.snapToGrid : this.options.snapToGrid); return this.constraintToBox(diffX, diffY, flag, pointCoordsY); }; // keep element within constrained box ResizeHandler.prototype.constraintToBox = function (diffX, diffY, flag, pointCoordsY) { //return [diffX, diffY] var c = this.options.constraint || {}; var orgX, orgY; if (typeof pointCoordsY !== 'undefined') { orgX = flag; orgY = pointCoordsY; } else { orgX = this.parameters.box.x + (flag & 1 ? 0 : this.parameters.box.width); orgY = this.parameters.box.y + (flag & 1 << 1 ? 0 : this.parameters.box.height); } if (typeof c.minX !== 'undefined' && orgX + diffX < c.minX) { diffX = c.minX - orgX; } if (typeof c.maxX !== 'undefined' && orgX + diffX > c.maxX) { diffX = c.maxX - orgX; } if (typeof c.minY !== 'undefined' && orgY + diffY < c.minY) { diffY = c.minY - orgY; } if (typeof c.maxY !== 'undefined' && orgY + diffY > c.maxY) { diffY = c.maxY - orgY; } return [diffX, diffY]; }; ResizeHandler.prototype.checkAspectRatio = function (snap) { if (!this.options.saveAspectRatio) { return snap; } var updatedSnap = snap.slice(); var aspectRatio = this.parameters.box.width / this.parameters.box.height; var newW = this.parameters.box.width + snap[0]; var newH = this.parameters.box.height - snap[1]; var newAspectRatio = newW / newH; if (newAspectRatio < aspectRatio) { // Height is too big. Adapt it updatedSnap[1] = newW / aspectRatio - this.parameters.box.height; } else if (newAspectRatio > aspectRatio) { // Width is too big. Adapt it updatedSnap[0] = this.parameters.box.width - newH * aspectRatio; } return updatedSnap; }; SVG.extend(SVG.Element, { // Resize element with mouse resize: function resize(options) { (this.remember('_resizeHandler') || new ResizeHandler(this)).init(options || {}); return this; } }); SVG.Element.prototype.resize.defaults = { snapToAngle: 0.1, // Specifies the speed the rotation is happening when moving the mouse snapToGrid: 1, // Snaps to a grid of `snapToGrid` Pixels constraint: {}, // keep element within constrained box saveAspectRatio: false // Save aspect ratio when resizing using lt, rt, rb or lb points }; }).call(this); })(); /***/ }), /* 153 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /*! * svg.select.js - An extension of svg.js which allows to select elements with mouse * @version 2.1.2 * https://github.com/svgdotjs/svg.select.js * * @copyright Ulrich-Matthias Schäfer * @license MIT */; ;(function () { "use strict"; function SelectHandler(el) { this.el = el; el.remember('_selectHandler', this); this.pointSelection = { isSelected: false }; this.rectSelection = { isSelected: false }; } SelectHandler.prototype.init = function (value, options) { var bbox = this.el.bbox(); this.options = {}; // Merging the defaults and the options-object together for (var i in this.el.selectize.defaults) { this.options[i] = this.el.selectize.defaults[i]; if (options[i] !== undefined) { this.options[i] = options[i]; } } this.parent = this.el.parent(); this.nested = this.nested || this.parent.group(); this.nested.matrix(new SVG.Matrix(this.el).translate(bbox.x, bbox.y)); // When deepSelect is enabled and the element is a line/polyline/polygon, draw only points for moving if (this.options.deepSelect && ['line', 'polyline', 'polygon'].indexOf(this.el.type) !== -1) { this.selectPoints(value); } else { this.selectRect(value); } this.observe(); this.cleanup(); }; SelectHandler.prototype.selectPoints = function (value) { this.pointSelection.isSelected = value; // When set is already there we dont have to create one if (this.pointSelection.set) { return this; } // Create our set of elements this.pointSelection.set = this.parent.set(); // draw the circles and mark the element as selected this.drawCircles(); return this; }; // create the point-array which contains the 2 points of a line or simply the points-array of polyline/polygon SelectHandler.prototype.getPointArray = function () { var bbox = this.el.bbox(); return this.el.array().valueOf().map(function (el) { return [el[0] - bbox.x, el[1] - bbox.y]; }); }; // The function to draw the circles SelectHandler.prototype.drawCircles = function () { var _this = this, array = this.getPointArray(); // go through the array of points for (var i = 0, len = array.length; i < len; ++i) { var curriedEvent = function (k) { return function (ev) { ev = ev || window.event; ev.preventDefault ? ev.preventDefault() : ev.returnValue = false; ev.stopPropagation(); var x = ev.pageX || ev.touches[0].pageX; var y = ev.pageY || ev.touches[0].pageY; _this.el.fire('point', { x: x, y: y, i: k, event: ev }); }; }(i); // add every point to the set this.pointSelection.set.add( // a circle with our css-classes and a touchstart-event which fires our event for moving points this.nested.circle(this.options.radius).center(array[i][0], array[i][1]).addClass(this.options.classPoints).addClass(this.options.classPoints + '_point').on('touchstart', curriedEvent).on('mousedown', curriedEvent)); } }; // every time a circle is moved, we have to update the positions of our circle SelectHandler.prototype.updatePointSelection = function () { var array = this.getPointArray(); this.pointSelection.set.each(function (i) { if (this.cx() === array[i][0] && this.cy() === array[i][1]) { return; } this.center(array[i][0], array[i][1]); }); }; SelectHandler.prototype.updateRectSelection = function () { var bbox = this.el.bbox(); this.rectSelection.set.get(0).attr({ width: bbox.width, height: bbox.height }); // set.get(1) is always in the upper left corner. no need to move it if (this.options.points) { this.rectSelection.set.get(2).center(bbox.width, 0); this.rectSelection.set.get(3).center(bbox.width, bbox.height); this.rectSelection.set.get(4).center(0, bbox.height); this.rectSelection.set.get(5).center(bbox.width / 2, 0); this.rectSelection.set.get(6).center(bbox.width, bbox.height / 2); this.rectSelection.set.get(7).center(bbox.width / 2, bbox.height); this.rectSelection.set.get(8).center(0, bbox.height / 2); } if (this.options.rotationPoint) { if (this.options.points) { this.rectSelection.set.get(9).center(bbox.width / 2, 20); } else { this.rectSelection.set.get(1).center(bbox.width / 2, 20); } } }; SelectHandler.prototype.selectRect = function (value) { var _this = this, bbox = this.el.bbox(); this.rectSelection.isSelected = value; // when set is already p this.rectSelection.set = this.rectSelection.set || this.parent.set(); // helperFunction to create a mouse-down function which triggers the event specified in `eventName` function getMoseDownFunc(eventName) { return function (ev) { ev = ev || window.event; ev.preventDefault ? ev.preventDefault() : ev.returnValue = false; ev.stopPropagation(); var x = ev.pageX || ev.touches[0].pageX; var y = ev.pageY || ev.touches[0].pageY; _this.el.fire(eventName, { x: x, y: y, event: ev }); }; } // create the selection-rectangle and add the css-class if (!this.rectSelection.set.get(0)) { this.rectSelection.set.add(this.nested.rect(bbox.width, bbox.height).addClass(this.options.classRect)); } // Draw Points at the edges, if enabled if (this.options.points && !this.rectSelection.set.get(1)) { var ename = "touchstart", mname = "mousedown"; this.rectSelection.set.add(this.nested.circle(this.options.radius).center(0, 0).attr('class', this.options.classPoints + '_lt').on(mname, getMoseDownFunc('lt')).on(ename, getMoseDownFunc('lt'))); this.rectSelection.set.add(this.nested.circle(this.options.radius).center(bbox.width, 0).attr('class', this.options.classPoints + '_rt').on(mname, getMoseDownFunc('rt')).on(ename, getMoseDownFunc('rt'))); this.rectSelection.set.add(this.nested.circle(this.options.radius).center(bbox.width, bbox.height).attr('class', this.options.classPoints + '_rb').on(mname, getMoseDownFunc('rb')).on(ename, getMoseDownFunc('rb'))); this.rectSelection.set.add(this.nested.circle(this.options.radius).center(0, bbox.height).attr('class', this.options.classPoints + '_lb').on(mname, getMoseDownFunc('lb')).on(ename, getMoseDownFunc('lb'))); this.rectSelection.set.add(this.nested.circle(this.options.radius).center(bbox.width / 2, 0).attr('class', this.options.classPoints + '_t').on(mname, getMoseDownFunc('t')).on(ename, getMoseDownFunc('t'))); this.rectSelection.set.add(this.nested.circle(this.options.radius).center(bbox.width, bbox.height / 2).attr('class', this.options.classPoints + '_r').on(mname, getMoseDownFunc('r')).on(ename, getMoseDownFunc('r'))); this.rectSelection.set.add(this.nested.circle(this.options.radius).center(bbox.width / 2, bbox.height).attr('class', this.options.classPoints + '_b').on(mname, getMoseDownFunc('b')).on(ename, getMoseDownFunc('b'))); this.rectSelection.set.add(this.nested.circle(this.options.radius).center(0, bbox.height / 2).attr('class', this.options.classPoints + '_l').on(mname, getMoseDownFunc('l')).on(ename, getMoseDownFunc('l'))); this.rectSelection.set.each(function () { this.addClass(_this.options.classPoints); }); } // draw rotationPint, if enabled if (this.options.rotationPoint && (this.options.points && !this.rectSelection.set.get(9) || !this.options.points && !this.rectSelection.set.get(1))) { var curriedEvent = function curriedEvent(ev) { ev = ev || window.event; ev.preventDefault ? ev.preventDefault() : ev.returnValue = false; ev.stopPropagation(); var x = ev.pageX || ev.touches[0].pageX; var y = ev.pageY || ev.touches[0].pageY; _this.el.fire('rot', { x: x, y: y, event: ev }); }; this.rectSelection.set.add(this.nested.circle(this.options.radius).center(bbox.width / 2, 20).attr('class', this.options.classPoints + '_rot').on("touchstart", curriedEvent).on("mousedown", curriedEvent)); } }; SelectHandler.prototype.handler = function () { var bbox = this.el.bbox(); this.nested.matrix(new SVG.Matrix(this.el).translate(bbox.x, bbox.y)); if (this.rectSelection.isSelected) { this.updateRectSelection(); } if (this.pointSelection.isSelected) { this.updatePointSelection(); } }; SelectHandler.prototype.observe = function () { var _this = this; if (MutationObserver) { if (this.rectSelection.isSelected || this.pointSelection.isSelected) { this.observerInst = this.observerInst || new MutationObserver(function () { _this.handler(); }); this.observerInst.observe(this.el.node, { attributes: true }); } else { try { this.observerInst.disconnect(); delete this.observerInst; } catch (e) {} } } else { this.el.off('DOMAttrModified.select'); if (this.rectSelection.isSelected || this.pointSelection.isSelected) { this.el.on('DOMAttrModified.select', function () { _this.handler(); }); } } }; SelectHandler.prototype.cleanup = function () { //var _this = this; if (!this.rectSelection.isSelected && this.rectSelection.set) { // stop watching the element, remove the selection this.rectSelection.set.each(function () { this.remove(); }); this.rectSelection.set.clear(); delete this.rectSelection.set; } if (!this.pointSelection.isSelected && this.pointSelection.set) { // Remove all points, clear the set, stop watching the element this.pointSelection.set.each(function () { this.remove(); }); this.pointSelection.set.clear(); delete this.pointSelection.set; } if (!this.pointSelection.isSelected && !this.rectSelection.isSelected) { this.nested.remove(); delete this.nested; } }; SVG.extend(SVG.Element, { // Select element with mouse selectize: function selectize(value, options) { // Check the parameters and reassign if needed if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { options = value; value = true; } var selectHandler = this.remember('_selectHandler') || new SelectHandler(this); selectHandler.init(value === undefined ? true : value, options || {}); return this; } }); SVG.Element.prototype.selectize.defaults = { points: true, // If true, points at the edges are drawn. Needed for resize! classRect: 'svg_select_boundingRect', // Css-class added to the rect classPoints: 'svg_select_points', // Css-class added to the points radius: 7, // radius of the points rotationPoint: true, // If true, rotation point is drawn. Needed for rotation! deepSelect: false // If true, moving of single points is possible (only line, polyline, polyon) }; })(); /***/ }), /* 154 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __WEBPACK_AMD_DEFINE_RESULT__; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /*! * svg.js - A lightweight library for manipulating and animating SVG. * @version 2.6.6 * https://svgdotjs.github.io/ * * @copyright Wout Fierens <wout@mick-wout.com> * @license MIT * * BUILT: Thu Aug 30 2018 11:37:58 GMT+0200 (GMT+02:00) */; (function (root, factory) { /* istanbul ignore next */ if (true) { !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { return factory(root, root.document); }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') { module.exports = root.document ? factory(root, root.document) : function (w) { return factory(w, w.document); }; } else { root.SVG = factory(root, root.document); } })(typeof window !== 'undefined' ? window : undefined, function (window, document) { // Find global reference - uses 'this' by default when available, // falls back to 'window' otherwise (for bundlers like Webpack) var globalRef = typeof this !== 'undefined' ? this : window; // The main wrapping element var SVG = globalRef.SVG = function (element) { if (SVG.supported) { element = new SVG.Doc(element); if (!SVG.parser.draw) { SVG.prepare(); } return element; } }; // Default namespaces SVG.ns = 'http://www.w3.org/2000/svg'; SVG.xmlns = 'http://www.w3.org/2000/xmlns/'; SVG.xlink = 'http://www.w3.org/1999/xlink'; SVG.svgjs = 'http://svgjs.com/svgjs'; // Svg support test SVG.supported = function () { return true; // !!document.createElementNS && // !! document.createElementNS(SVG.ns,'svg').createSVGRect }(); // Don't bother to continue if SVG is not supported if (!SVG.supported) return false; // Element id sequence SVG.did = 1000; // Get next named element id SVG.eid = function (name) { return 'Svgjs' + capitalize(name) + SVG.did++; }; // Method for element creation SVG.create = function (name) { // create element var element = document.createElementNS(this.ns, name); // apply unique id element.setAttribute('id', this.eid(name)); return element; }; // Method for extending objects SVG.extend = function () { var modules, methods, key, i; // Get list of modules modules = [].slice.call(arguments); // Get object with extensions methods = modules.pop(); for (i = modules.length - 1; i >= 0; i--) { if (modules[i]) { for (key in methods) { modules[i].prototype[key] = methods[key]; } } } // Make sure SVG.Set inherits any newly added methods if (SVG.Set && SVG.Set.inherit) { SVG.Set.inherit(); } }; // Invent new element SVG.invent = function (config) { // Create element initializer var initializer = typeof config.create === 'function' ? config.create : function () { this.constructor.call(this, SVG.create(config.create)); }; // Inherit prototype if (config.inherit) { initializer.prototype = new config.inherit(); } // Extend with methods if (config.extend) { SVG.extend(initializer, config.extend); } // Attach construct method to parent if (config.construct) { SVG.extend(config.parent || SVG.Container, config.construct); } return initializer; }; // Adopt existing svg elements SVG.adopt = function (node) { // check for presence of node if (!node) return null; // make sure a node isn't already adopted if (node.instance) return node.instance; // initialize variables var element; // adopt with element-specific settings if (node.nodeName == 'svg') { element = node.parentNode instanceof window.SVGElement ? new SVG.Nested() : new SVG.Doc(); } else if (node.nodeName == 'linearGradient') { element = new SVG.Gradient('linear'); } else if (node.nodeName == 'radialGradient') { element = new SVG.Gradient('radial'); } else if (SVG[capitalize(node.nodeName)]) { element = new SVG[capitalize(node.nodeName)](); } else { element = new SVG.Element(node); } // ensure references element.type = node.nodeName; element.node = node; node.instance = element; // SVG.Class specific preparations if (element instanceof SVG.Doc) { element.namespace().defs(); } // pull svgjs data from the dom (getAttributeNS doesn't work in html5) element.setData(JSON.parse(node.getAttribute('svgjs:data')) || {}); return element; }; // Initialize parsing element SVG.prepare = function () { // Select document body and create invisible svg element var body = document.getElementsByTagName('body')[0], draw = (body ? new SVG.Doc(body) : SVG.adopt(document.documentElement).nested()).size(2, 0); // Create parser object SVG.parser = { body: body || document.documentElement, draw: draw.style('opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden').node, poly: draw.polyline().node, path: draw.path().node, native: SVG.create('svg') }; }; SVG.parser = { native: SVG.create('svg') }; document.addEventListener('DOMContentLoaded', function () { if (!SVG.parser.draw) { SVG.prepare(); } }, false); // Storage for regular expressions SVG.regex = { // Parse unit value numberAndUnit: /^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i, // Parse hex value hex: /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i, // Parse rgb value rgb: /rgb\((\d+),(\d+),(\d+)\)/, // Parse reference id reference: /#([a-z0-9\-_]+)/i, // splits a transformation chain transforms: /\)\s*,?\s*/, // Whitespace whitespace: /\s/g, // Test hex value isHex: /^#[a-f0-9]{3,6}$/i, // Test rgb value isRgb: /^rgb\(/, // Test css declaration isCss: /[^:]+:[^;]+;?/, // Test for blank string isBlank: /^(\s+)?$/, // Test for numeric string isNumber: /^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, // Test for percent value isPercent: /^-?[\d\.]+%$/, // Test for image url isImage: /\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i, // split at whitespace and comma delimiter: /[\s,]+/, // The following regex are used to parse the d attribute of a path // Matches all hyphens which are not after an exponent hyphen: /([^e])\-/gi, // Replaces and tests for all path letters pathLetters: /[MLHVCSQTAZ]/gi, // yes we need this one, too isPathLetter: /[MLHVCSQTAZ]/i, // matches 0.154.23.45 numbersWithDots: /((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi, // matches . dots: /\./g }; SVG.utils = { // Map function map: function map(array, block) { var i, il = array.length, result = []; for (i = 0; i < il; i++) { result.push(block(array[i])); } return result; }, // Filter function filter: function filter(array, block) { var i, il = array.length, result = []; for (i = 0; i < il; i++) { if (block(array[i])) { result.push(array[i]); } } return result; }, // Degrees to radians radians: function radians(d) { return d % 360 * Math.PI / 180; }, // Radians to degrees degrees: function degrees(r) { return r * 180 / Math.PI % 360; }, filterSVGElements: function filterSVGElements(nodes) { return this.filter(nodes, function (el) { return el instanceof window.SVGElement; }); } }; SVG.defaults = { // Default attribute values attrs: { // fill and stroke 'fill-opacity': 1, 'stroke-opacity': 1, 'stroke-width': 0, 'stroke-linejoin': 'miter', 'stroke-linecap': 'butt', fill: '#000000', stroke: '#000000', opacity: 1, // position x: 0, y: 0, cx: 0, cy: 0, // size width: 0, height: 0, // radius r: 0, rx: 0, ry: 0, // gradient offset: 0, 'stop-opacity': 1, 'stop-color': '#000000', // text 'font-size': 16, 'font-family': 'Helvetica, Arial, sans-serif', 'text-anchor': 'start' } // Module for color convertions };SVG.Color = function (color) { var match; // initialize defaults this.r = 0; this.g = 0; this.b = 0; if (!color) return; // parse color if (typeof color === 'string') { if (SVG.regex.isRgb.test(color)) { // get rgb values match = SVG.regex.rgb.exec(color.replace(SVG.regex.whitespace, '')); // parse numeric values this.r = parseInt(match[1]); this.g = parseInt(match[2]); this.b = parseInt(match[3]); } else if (SVG.regex.isHex.test(color)) { // get hex values match = SVG.regex.hex.exec(fullHex(color)); // parse numeric values this.r = parseInt(match[1], 16); this.g = parseInt(match[2], 16); this.b = parseInt(match[3], 16); } } else if ((typeof color === 'undefined' ? 'undefined' : _typeof(color)) === 'object') { this.r = color.r; this.g = color.g; this.b = color.b; } }; SVG.extend(SVG.Color, { // Default to hex conversion toString: function toString() { return this.toHex(); }, // Build hex value toHex: function toHex() { return '#' + compToHex(this.r) + compToHex(this.g) + compToHex(this.b); }, // Build rgb value toRgb: function toRgb() { return 'rgb(' + [this.r, this.g, this.b].join() + ')'; }, // Calculate true brightness brightness: function brightness() { return this.r / 255 * 0.30 + this.g / 255 * 0.59 + this.b / 255 * 0.11; }, // Make color morphable morph: function morph(color) { this.destination = new SVG.Color(color); return this; }, // Get morphed color at given position at: function at(pos) { // make sure a destination is defined if (!this.destination) return this; // normalise pos pos = pos < 0 ? 0 : pos > 1 ? 1 : pos; // generate morphed color return new SVG.Color({ r: ~~(this.r + (this.destination.r - this.r) * pos), g: ~~(this.g + (this.destination.g - this.g) * pos), b: ~~(this.b + (this.destination.b - this.b) * pos) }); } }); // Testers // Test if given value is a color string SVG.Color.test = function (color) { color += ''; return SVG.regex.isHex.test(color) || SVG.regex.isRgb.test(color); }; // Test if given value is a rgb object SVG.Color.isRgb = function (color) { return color && typeof color.r === 'number' && typeof color.g === 'number' && typeof color.b === 'number'; }; // Test if given value is a color SVG.Color.isColor = function (color) { return SVG.Color.isRgb(color) || SVG.Color.test(color); }; // Module for array conversion SVG.Array = function (array, fallback) { array = (array || []).valueOf(); // if array is empty and fallback is provided, use fallback if (array.length == 0 && fallback) { array = fallback.valueOf(); } // parse array this.value = this.parse(array); }; SVG.extend(SVG.Array, { // Make array morphable morph: function morph(array) { this.destination = this.parse(array); // normalize length of arrays if (this.value.length != this.destination.length) { var lastValue = this.value[this.value.length - 1], lastDestination = this.destination[this.destination.length - 1]; while (this.value.length > this.destination.length) { this.destination.push(lastDestination); } while (this.value.length < this.destination.length) { this.value.push(lastValue); } } return this; }, // Clean up any duplicate points settle: function settle() { // find all unique values for (var i = 0, il = this.value.length, seen = []; i < il; i++) { if (seen.indexOf(this.value[i]) == -1) { seen.push(this.value[i]); } } // set new value return this.value = seen; }, // Get morphed array at given position at: function at(pos) { // make sure a destination is defined if (!this.destination) return this; // generate morphed array for (var i = 0, il = this.value.length, array = []; i < il; i++) { array.push(this.value[i] + (this.destination[i] - this.value[i]) * pos); } return new SVG.Array(array); }, // Convert array to string toString: function toString() { return this.value.join(' '); }, // Real value valueOf: function valueOf() { return this.value; }, // Parse whitespace separated string parse: function parse(array) { array = array.valueOf(); // if already is an array, no need to parse it if (Array.isArray(array)) return array; return this.split(array); }, // Strip unnecessary whitespace split: function split(string) { return string.trim().split(SVG.regex.delimiter).map(parseFloat); }, // Reverse array reverse: function reverse() { this.value.reverse(); return this; }, clone: function clone() { var clone = new this.constructor(); clone.value = array_clone(this.value); return clone; } }); // Poly points array SVG.PointArray = function (array, fallback) { SVG.Array.call(this, array, fallback || [[0, 0]]); }; // Inherit from SVG.Array SVG.PointArray.prototype = new SVG.Array(); SVG.PointArray.prototype.constructor = SVG.PointArray; SVG.extend(SVG.PointArray, { // Convert array to string toString: function toString() { // convert to a poly point string for (var i = 0, il = this.value.length, array = []; i < il; i++) { array.push(this.value[i].join(',')); } return array.join(' '); }, // Convert array to line object toLine: function toLine() { return { x1: this.value[0][0], y1: this.value[0][1], x2: this.value[1][0], y2: this.value[1][1] }; }, // Get morphed array at given position at: function at(pos) { // make sure a destination is defined if (!this.destination) return this; // generate morphed point string for (var i = 0, il = this.value.length, array = []; i < il; i++) { array.push([this.value[i][0] + (this.destination[i][0] - this.value[i][0]) * pos, this.value[i][1] + (this.destination[i][1] - this.value[i][1]) * pos]); } return new SVG.PointArray(array); }, // Parse point string and flat array parse: function parse(array) { var points = []; array = array.valueOf(); // if it is an array if (Array.isArray(array)) { // and it is not flat, there is no need to parse it if (Array.isArray(array[0])) { // make sure to use a clone return array.map(function (el) { return el.slice(); }); } else if (array[0].x != null) { // allow point objects to be passed return array.map(function (el) { return [el.x, el.y]; }); } } else { // Else, it is considered as a string // parse points array = array.trim().split(SVG.regex.delimiter).map(parseFloat); } // validate points - https://svgwg.org/svg2-draft/shapes.html#DataTypePoints // Odd number of coordinates is an error. In such cases, drop the last odd coordinate. if (array.length % 2 !== 0) array.pop(); // wrap points in two-tuples and parse points as floats for (var i = 0, len = array.length; i < len; i = i + 2) { points.push([array[i], array[i + 1]]); } return points; }, // Move point string move: function move(x, y) { var box = this.bbox(); // get relative offset x -= box.x; y -= box.y; // move every point if (!isNaN(x) && !isNaN(y)) { for (var i = this.value.length - 1; i >= 0; i--) { this.value[i] = [this.value[i][0] + x, this.value[i][1] + y]; } } return this; }, // Resize poly string size: function size(width, height) { var i, box = this.bbox(); // recalculate position of all points according to new size for (i = this.value.length - 1; i >= 0; i--) { if (box.width) this.value[i][0] = (this.value[i][0] - box.x) * width / box.width + box.x; if (box.height) this.value[i][1] = (this.value[i][1] - box.y) * height / box.height + box.y; } return this; }, // Get bounding box of points bbox: function bbox() { SVG.parser.poly.setAttribute('points', this.toString()); return SVG.parser.poly.getBBox(); } }); var pathHandlers = { M: function M(c, p, p0) { p.x = p0.x = c[0]; p.y = p0.y = c[1]; return ['M', p.x, p.y]; }, L: function L(c, p) { p.x = c[0]; p.y = c[1]; return ['L', c[0], c[1]]; }, H: function H(c, p) { p.x = c[0]; return ['H', c[0]]; }, V: function V(c, p) { p.y = c[0]; return ['V', c[0]]; }, C: function C(c, p) { p.x = c[4]; p.y = c[5]; return ['C', c[0], c[1], c[2], c[3], c[4], c[5]]; }, S: function S(c, p) { p.x = c[2]; p.y = c[3]; return ['S', c[0], c[1], c[2], c[3]]; }, Q: function Q(c, p) { p.x = c[2]; p.y = c[3]; return ['Q', c[0], c[1], c[2], c[3]]; }, T: function T(c, p) { p.x = c[0]; p.y = c[1]; return ['T', c[0], c[1]]; }, Z: function Z(c, p, p0) { p.x = p0.x; p.y = p0.y; return ['Z']; }, A: function A(c, p) { p.x = c[5]; p.y = c[6]; return ['A', c[0], c[1], c[2], c[3], c[4], c[5], c[6]]; } }; var mlhvqtcsa = 'mlhvqtcsaz'.split(''); for (var i = 0, il = mlhvqtcsa.length; i < il; ++i) { pathHandlers[mlhvqtcsa[i]] = function (i) { return function (c, p, p0) { if (i == 'H') c[0] = c[0] + p.x;else if (i == 'V') c[0] = c[0] + p.y;else if (i == 'A') { c[5] = c[5] + p.x, c[6] = c[6] + p.y; } else { for (var j = 0, jl = c.length; j < jl; ++j) { c[j] = c[j] + (j % 2 ? p.y : p.x); } } return pathHandlers[i](c, p, p0); }; }(mlhvqtcsa[i].toUpperCase()); } // Path points array SVG.PathArray = function (array, fallback) { SVG.Array.call(this, array, fallback || [['M', 0, 0]]); }; // Inherit from SVG.Array SVG.PathArray.prototype = new SVG.Array(); SVG.PathArray.prototype.constructor = SVG.PathArray; SVG.extend(SVG.PathArray, { // Convert array to string toString: function toString() { return arrayToString(this.value); }, // Move path string move: function move(x, y) { // get bounding box of current situation var box = this.bbox(); // get relative offset x -= box.x; y -= box.y; if (!isNaN(x) && !isNaN(y)) { // move every point for (var l, i = this.value.length - 1; i >= 0; i--) { l = this.value[i][0]; if (l == 'M' || l == 'L' || l == 'T') { this.value[i][1] += x; this.value[i][2] += y; } else if (l == 'H') { this.value[i][1] += x; } else if (l == 'V') { this.value[i][1] += y; } else if (l == 'C' || l == 'S' || l == 'Q') { this.value[i][1] += x; this.value[i][2] += y; this.value[i][3] += x; this.value[i][4] += y; if (l == 'C') { this.value[i][5] += x; this.value[i][6] += y; } } else if (l == 'A') { this.value[i][6] += x; this.value[i][7] += y; } } } return this; }, // Resize path string size: function size(width, height) { // get bounding box of current situation var i, l, box = this.bbox(); // recalculate position of all points according to new size for (i = this.value.length - 1; i >= 0; i--) { l = this.value[i][0]; if (l == 'M' || l == 'L' || l == 'T') { this.value[i][1] = (this.value[i][1] - box.x) * width / box.width + box.x; this.value[i][2] = (this.value[i][2] - box.y) * height / box.height + box.y; } else if (l == 'H') { this.value[i][1] = (this.value[i][1] - box.x) * width / box.width + box.x; } else if (l == 'V') { this.value[i][1] = (this.value[i][1] - box.y) * height / box.height + box.y; } else if (l == 'C' || l == 'S' || l == 'Q') { this.value[i][1] = (this.value[i][1] - box.x) * width / box.width + box.x; this.value[i][2] = (this.value[i][2] - box.y) * height / box.height + box.y; this.value[i][3] = (this.value[i][3] - box.x) * width / box.width + box.x; this.value[i][4] = (this.value[i][4] - box.y) * height / box.height + box.y; if (l == 'C') { this.value[i][5] = (this.value[i][5] - box.x) * width / box.width + box.x; this.value[i][6] = (this.value[i][6] - box.y) * height / box.height + box.y; } } else if (l == 'A') { // resize radii this.value[i][1] = this.value[i][1] * width / box.width; this.value[i][2] = this.value[i][2] * height / box.height; // move position values this.value[i][6] = (this.value[i][6] - box.x) * width / box.width + box.x; this.value[i][7] = (this.value[i][7] - box.y) * height / box.height + box.y; } } return this; }, // Test if the passed path array use the same path data commands as this path array equalCommands: function equalCommands(pathArray) { var i, il, equalCommands; pathArray = new SVG.PathArray(pathArray); equalCommands = this.value.length === pathArray.value.length; for (i = 0, il = this.value.length; equalCommands && i < il; i++) { equalCommands = this.value[i][0] === pathArray.value[i][0]; } return equalCommands; }, // Make path array morphable morph: function morph(pathArray) { pathArray = new SVG.PathArray(pathArray); if (this.equalCommands(pathArray)) { this.destination = pathArray; } else { this.destination = null; } return this; }, // Get morphed path array at given position at: function at(pos) { // make sure a destination is defined if (!this.destination) return this; var sourceArray = this.value, destinationArray = this.destination.value, array = [], pathArray = new SVG.PathArray(), i, il, j, jl; // Animate has specified in the SVG spec // See: https://www.w3.org/TR/SVG11/paths.html#PathElement for (i = 0, il = sourceArray.length; i < il; i++) { array[i] = [sourceArray[i][0]]; for (j = 1, jl = sourceArray[i].length; j < jl; j++) { array[i][j] = sourceArray[i][j] + (destinationArray[i][j] - sourceArray[i][j]) * pos; } // For the two flags of the elliptical arc command, the SVG spec say: // Flags and booleans are interpolated as fractions between zero and one, with any non-zero value considered to be a value of one/true // Elliptical arc command as an array followed by corresponding indexes: // ['A', rx, ry, x-axis-rotation, large-arc-flag, sweep-flag, x, y] // 0 1 2 3 4 5 6 7 if (array[i][0] === 'A') { array[i][4] = +(array[i][4] != 0); array[i][5] = +(array[i][5] != 0); } } // Directly modify the value of a path array, this is done this way for performance pathArray.value = array; return pathArray; }, // Absolutize and parse path to array parse: function parse(array) { // if it's already a patharray, no need to parse it if (array instanceof SVG.PathArray) return array.valueOf(); // prepare for parsing var i, x0, y0, s, seg, arr, x = 0, y = 0, paramCnt = { 'M': 2, 'L': 2, 'H': 1, 'V': 1, 'C': 6, 'S': 4, 'Q': 4, 'T': 2, 'A': 7, 'Z': 0 }; if (typeof array === 'string') { array = array.replace(SVG.regex.numbersWithDots, pathRegReplace) // convert 45.123.123 to 45.123 .123 .replace(SVG.regex.pathLetters, ' $& ') // put some room between letters and numbers .replace(SVG.regex.hyphen, '$1 -') // add space before hyphen .trim() // trim .split(SVG.regex.delimiter); // split into array } else { array = array.reduce(function (prev, curr) { return [].concat.call(prev, curr); }, []); } // array now is an array containing all parts of a path e.g. ['M', '0', '0', 'L', '30', '30' ...] var arr = [], p = new SVG.Point(), p0 = new SVG.Point(), index = 0, len = array.length; do { // Test if we have a path letter if (SVG.regex.isPathLetter.test(array[index])) { s = array[index]; ++index; // If last letter was a move command and we got no new, it defaults to [L]ine } else if (s == 'M') { s = 'L'; } else if (s == 'm') { s = 'l'; } arr.push(pathHandlers[s].call(null, array.slice(index, index = index + paramCnt[s.toUpperCase()]).map(parseFloat), p, p0)); } while (len > index); return arr; }, // Get bounding box of path bbox: function bbox() { SVG.parser.path.setAttribute('d', this.toString()); return SVG.parser.path.getBBox(); } }); // Module for unit convertions SVG.Number = SVG.invent({ // Initialize create: function create(value, unit) { // initialize defaults this.value = 0; this.unit = unit || ''; // parse value if (typeof value === 'number') { // ensure a valid numeric value this.value = isNaN(value) ? 0 : !isFinite(value) ? value < 0 ? -3.4e+38 : +3.4e+38 : value; } else if (typeof value === 'string') { unit = value.match(SVG.regex.numberAndUnit); if (unit) { // make value numeric this.value = parseFloat(unit[1]); // normalize if (unit[5] == '%') { this.value /= 100; } else if (unit[5] == 's') { this.value *= 1000; } // store unit this.unit = unit[5]; } } else { if (value instanceof SVG.Number) { this.value = value.valueOf(); this.unit = value.unit; } } }, // Add methods extend: { // Stringalize toString: function toString() { return (this.unit == '%' ? ~~(this.value * 1e8) / 1e6 : this.unit == 's' ? this.value / 1e3 : this.value) + this.unit; }, toJSON: function toJSON() { return this.toString(); }, // Convert to primitive valueOf: function valueOf() { return this.value; }, // Add number plus: function plus(number) { number = new SVG.Number(number); return new SVG.Number(this + number, this.unit || number.unit); }, // Subtract number minus: function minus(number) { number = new SVG.Number(number); return new SVG.Number(this - number, this.unit || number.unit); }, // Multiply number times: function times(number) { number = new SVG.Number(number); return new SVG.Number(this * number, this.unit || number.unit); }, // Divide number divide: function divide(number) { number = new SVG.Number(number); return new SVG.Number(this / number, this.unit || number.unit); }, // Convert to different unit to: function to(unit) { var number = new SVG.Number(this); if (typeof unit === 'string') { number.unit = unit; } return number; }, // Make number morphable morph: function morph(number) { this.destination = new SVG.Number(number); if (number.relative) { this.destination.value += this.value; } return this; }, // Get morphed number at given position at: function at(pos) { // Make sure a destination is defined if (!this.destination) return this; // Generate new morphed number return new SVG.Number(this.destination).minus(this).times(pos).plus(this); } } }); SVG.Element = SVG.invent({ // Initialize node create: function create(node) { // make stroke value accessible dynamically this._stroke = SVG.defaults.attrs.stroke; this._event = null; // initialize data object this.dom = {}; // create circular reference if (this.node = node) { this.type = node.nodeName; this.node.instance = this; // store current attribute value this._stroke = node.getAttribute('stroke') || this._stroke; } }, // Add class methods extend: { // Move over x-axis x: function x(_x) { return this.attr('x', _x); }, // Move over y-axis y: function y(_y) { return this.attr('y', _y); }, // Move by center over x-axis cx: function cx(x) { return x == null ? this.x() + this.width() / 2 : this.x(x - this.width() / 2); }, // Move by center over y-axis cy: function cy(y) { return y == null ? this.y() + this.height() / 2 : this.y(y - this.height() / 2); }, // Move element to given x and y values move: function move(x, y) { return this.x(x).y(y); }, // Move element by its center center: function center(x, y) { return this.cx(x).cy(y); }, // Set width of element width: function width(_width) { return this.attr('width', _width); }, // Set height of element height: function height(_height) { return this.attr('height', _height); }, // Set element size to given width and height size: function size(width, height) { var p = proportionalSize(this, width, height); return this.width(new SVG.Number(p.width)).height(new SVG.Number(p.height)); }, // Clone element clone: function clone(parent) { // write dom data to the dom so the clone can pickup the data this.writeDataToDom(); // clone element and assign new id var clone = assignNewId(this.node.cloneNode(true)); // insert the clone in the given parent or after myself if (parent) parent.add(clone);else this.after(clone); return clone; }, // Remove element remove: function remove() { if (this.parent()) { this.parent().removeElement(this); } return this; }, // Replace element replace: function replace(element) { this.after(element).remove(); return element; }, // Add element to given container and return self addTo: function addTo(parent) { return parent.put(this); }, // Add element to given container and return container putIn: function putIn(parent) { return parent.add(this); }, // Get / set id id: function id(_id) { return this.attr('id', _id); }, // Checks whether the given point inside the bounding box of the element inside: function inside(x, y) { var box = this.bbox(); return x > box.x && y > box.y && x < box.x + box.width && y < box.y + box.height; }, // Show element show: function show() { return this.style('display', ''); }, // Hide element hide: function hide() { return this.style('display', 'none'); }, // Is element visible? visible: function visible() { return this.style('display') != 'none'; }, // Return id on string conversion toString: function toString() { return this.attr('id'); }, // Return array of classes on the node classes: function classes() { var attr = this.attr('class'); return attr == null ? [] : attr.trim().split(SVG.regex.delimiter); }, // Return true if class exists on the node, false otherwise hasClass: function hasClass(name) { return this.classes().indexOf(name) != -1; }, // Add class to the node addClass: function addClass(name) { if (!this.hasClass(name)) { var array = this.classes(); array.push(name); this.attr('class', array.join(' ')); } return this; }, // Remove class from the node removeClass: function removeClass(name) { if (this.hasClass(name)) { this.attr('class', this.classes().filter(function (c) { return c != name; }).join(' ')); } return this; }, // Toggle the presence of a class on the node toggleClass: function toggleClass(name) { return this.hasClass(name) ? this.removeClass(name) : this.addClass(name); }, // Get referenced element form attribute value reference: function reference(attr) { return SVG.get(this.attr(attr)); }, // Returns the parent element instance parent: function parent(type) { var parent = this; // check for parent if (!parent.node.parentNode) return null; // get parent element parent = SVG.adopt(parent.node.parentNode); if (!type) return parent; // loop trough ancestors if type is given while (parent && parent.node instanceof window.SVGElement) { if (typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent; if (!parent.node.parentNode || parent.node.parentNode.nodeName == '#document') return null; // #759, #720 parent = SVG.adopt(parent.node.parentNode); } }, // Get parent document doc: function doc() { return this instanceof SVG.Doc ? this : this.parent(SVG.Doc); }, // return array of all ancestors of given type up to the root svg parents: function parents(type) { var parents = [], parent = this; do { parent = parent.parent(type); if (!parent || !parent.node) break; parents.push(parent); } while (parent.parent); return parents; }, // matches the element vs a css selector matches: function matches(selector) { return _matches(this.node, selector); }, // Returns the svg node to call native svg methods on it native: function native() { return this.node; }, // Import raw svg svg: function svg(_svg) { // create temporary holder var well = document.createElement('svg'); // act as a setter if svg is given if (_svg && this instanceof SVG.Parent) { // dump raw svg well.innerHTML = '<svg>' + _svg.replace(/\n/, '').replace(/<([\w:-]+)([^<]+?)\/>/g, '<$1$2></$1>') + '</svg>'; // transplant nodes for (var i = 0, il = well.firstChild.childNodes.length; i < il; i++) { this.node.appendChild(well.firstChild.firstChild); } // otherwise act as a getter } else { // create a wrapping svg element in case of partial content well.appendChild(_svg = document.createElement('svg')); // write svgjs data to the dom this.writeDataToDom(); // insert a copy of this node _svg.appendChild(this.node.cloneNode(true)); // return target element return well.innerHTML.replace(/^<svg>/, '').replace(/<\/svg>$/, ''); } return this; }, // write svgjs data to the dom writeDataToDom: function writeDataToDom() { // dump variables recursively if (this.each || this.lines) { var fn = this.each ? this : this.lines(); fn.each(function () { this.writeDataToDom(); }); } // remove previously set data this.node.removeAttribute('svgjs:data'); if (Object.keys(this.dom).length) { this.node.setAttribute('svgjs:data', JSON.stringify(this.dom)); } // see #428 return this; }, // set given data to the elements data property setData: function setData(o) { this.dom = o; return this; }, is: function is(obj) { return _is(this, obj); } } }); SVG.easing = { '-': function _(pos) { return pos; }, '<>': function _(pos) { return -Math.cos(pos * Math.PI) / 2 + 0.5; }, '>': function _(pos) { return Math.sin(pos * Math.PI / 2); }, '<': function _(pos) { return -Math.cos(pos * Math.PI / 2) + 1; } }; SVG.morph = function (pos) { return function (from, to) { return new SVG.MorphObj(from, to).at(pos); }; }; SVG.Situation = SVG.invent({ create: function create(o) { this.init = false; this.reversed = false; this.reversing = false; this.duration = new SVG.Number(o.duration).valueOf(); this.delay = new SVG.Number(o.delay).valueOf(); this.start = +new Date() + this.delay; this.finish = this.start + this.duration; this.ease = o.ease; // this.loop is incremented from 0 to this.loops // it is also incremented when in an infinite loop (when this.loops is true) this.loop = 0; this.loops = false; this.animations = { // functionToCall: [list of morphable objects] // e.g. move: [SVG.Number, SVG.Number] }; this.attrs = { // holds all attributes which are not represented from a function svg.js provides // e.g. someAttr: SVG.Number }; this.styles = { // holds all styles which should be animated // e.g. fill-color: SVG.Color }; this.transforms = [ // holds all transformations as transformation objects // e.g. [SVG.Rotate, SVG.Translate, SVG.Matrix] ]; this.once = { // functions to fire at a specific position // e.g. "0.5": function foo(){} }; } }); SVG.FX = SVG.invent({ create: function create(element) { this._target = element; this.situations = []; this.active = false; this.situation = null; this.paused = false; this.lastPos = 0; this.pos = 0; // The absolute position of an animation is its position in the context of its complete duration (including delay and loops) // When performing a delay, absPos is below 0 and when performing a loop, its value is above 1 this.absPos = 0; this._speed = 1; }, extend: { /** * sets or returns the target of this animation * @param o object || number In case of Object it holds all parameters. In case of number its the duration of the animation * @param ease function || string Function which should be used for easing or easing keyword * @param delay Number indicating the delay before the animation starts * @return target || this */ animate: function animate(o, ease, delay) { if ((typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object') { ease = o.ease; delay = o.delay; o = o.duration; } var situation = new SVG.Situation({ duration: o || 1000, delay: delay || 0, ease: SVG.easing[ease || '-'] || ease }); this.queue(situation); return this; }, /** * sets a delay before the next element of the queue is called * @param delay Duration of delay in milliseconds * @return this.target() */ delay: function delay(_delay) { // The delay is performed by an empty situation with its duration // attribute set to the duration of the delay var situation = new SVG.Situation({ duration: _delay, delay: 0, ease: SVG.easing['-'] }); return this.queue(situation); }, /** * sets or returns the target of this animation * @param null || target SVG.Element which should be set as new target * @return target || this */ target: function target(_target) { if (_target && _target instanceof SVG.Element) { this._target = _target; return this; } return this._target; }, // returns the absolute position at a given time timeToAbsPos: function timeToAbsPos(timestamp) { return (timestamp - this.situation.start) / (this.situation.duration / this._speed); }, // returns the timestamp from a given absolute positon absPosToTime: function absPosToTime(absPos) { return this.situation.duration / this._speed * absPos + this.situation.start; }, // starts the animationloop startAnimFrame: function startAnimFrame() { this.stopAnimFrame(); this.animationFrame = window.requestAnimationFrame(function () { this.step(); }.bind(this)); }, // cancels the animationframe stopAnimFrame: function stopAnimFrame() { window.cancelAnimationFrame(this.animationFrame); }, // kicks off the animation - only does something when the queue is currently not active and at least one situation is set start: function start() { // dont start if already started if (!this.active && this.situation) { this.active = true; this.startCurrent(); } return this; }, // start the current situation startCurrent: function startCurrent() { this.situation.start = +new Date() + this.situation.delay / this._speed; this.situation.finish = this.situation.start + this.situation.duration / this._speed; return this.initAnimations().step(); }, /** * adds a function / Situation to the animation queue * @param fn function / situation to add * @return this */ queue: function queue(fn) { if (typeof fn === 'function' || fn instanceof SVG.Situation) { this.situations.push(fn); } if (!this.situation) this.situation = this.situations.shift(); return this; }, /** * pulls next element from the queue and execute it * @return this */ dequeue: function dequeue() { // stop current animation this.stop(); // get next animation from queue this.situation = this.situations.shift(); if (this.situation) { if (this.situation instanceof SVG.Situation) { this.start(); } else { // If it is not a SVG.Situation, then it is a function, we execute it this.situation.call(this); } } return this; }, // updates all animations to the current state of the element // this is important when one property could be changed from another property initAnimations: function initAnimations() { var i, j, source; var s = this.situation; if (s.init) return this; for (i in s.animations) { source = this.target()[i](); if (!Array.isArray(source)) { source = [source]; } if (!Array.isArray(s.animations[i])) { s.animations[i] = [s.animations[i]]; } // if(s.animations[i].length > source.length) { // source.concat = source.concat(s.animations[i].slice(source.length, s.animations[i].length)) // } for (j = source.length; j--;) { // The condition is because some methods return a normal number instead // of a SVG.Number if (s.animations[i][j] instanceof SVG.Number) { source[j] = new SVG.Number(source[j]); } s.animations[i][j] = source[j].morph(s.animations[i][j]); } } for (i in s.attrs) { s.attrs[i] = new SVG.MorphObj(this.target().attr(i), s.attrs[i]); } for (i in s.styles) { s.styles[i] = new SVG.MorphObj(this.target().style(i), s.styles[i]); } s.initialTransformation = this.target().matrixify(); s.init = true; return this; }, clearQueue: function clearQueue() { this.situations = []; return this; }, clearCurrent: function clearCurrent() { this.situation = null; return this; }, /** stops the animation immediately * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately. * @param clearQueue A Boolean indicating whether to remove queued animation as well. * @return this */ stop: function stop(jumpToEnd, clearQueue) { var active = this.active; this.active = false; if (clearQueue) { this.clearQueue(); } if (jumpToEnd && this.situation) { // initialize the situation if it was not !active && this.startCurrent(); this.atEnd(); } this.stopAnimFrame(); return this.clearCurrent(); }, /** resets the element to the state where the current element has started * @return this */ reset: function reset() { if (this.situation) { var temp = this.situation; this.stop(); this.situation = temp; this.atStart(); } return this; }, // Stop the currently-running animation, remove all queued animations, and complete all animations for the element. finish: function finish() { this.stop(true, false); while (this.dequeue().situation && this.stop(true, false)) {} this.clearQueue().clearCurrent(); return this; }, // set the internal animation pointer at the start position, before any loops, and updates the visualisation atStart: function atStart() { return this.at(0, true); }, // set the internal animation pointer at the end position, after all the loops, and updates the visualisation atEnd: function atEnd() { if (this.situation.loops === true) { // If in a infinite loop, we end the current iteration this.situation.loops = this.situation.loop + 1; } if (typeof this.situation.loops === 'number') { // If performing a finite number of loops, we go after all the loops return this.at(this.situation.loops, true); } else { // If no loops, we just go at the end return this.at(1, true); } }, // set the internal animation pointer to the specified position and updates the visualisation // if isAbsPos is true, pos is treated as an absolute position at: function at(pos, isAbsPos) { var durDivSpd = this.situation.duration / this._speed; this.absPos = pos; // If pos is not an absolute position, we convert it into one if (!isAbsPos) { if (this.situation.reversed) this.absPos = 1 - this.absPos; this.absPos += this.situation.loop; } this.situation.start = +new Date() - this.absPos * durDivSpd; this.situation.finish = this.situation.start + durDivSpd; return this.step(true); }, /** * sets or returns the speed of the animations * @param speed null || Number The new speed of the animations * @return Number || this */ speed: function speed(_speed) { if (_speed === 0) return this.pause(); if (_speed) { this._speed = _speed; // We use an absolute position here so that speed can affect the delay before the animation return this.at(this.absPos, true); } else return this._speed; }, // Make loopable loop: function loop(times, reverse) { var c = this.last(); // store total loops c.loops = times != null ? times : true; c.loop = 0; if (reverse) c.reversing = true; return this; }, // pauses the animation pause: function pause() { this.paused = true; this.stopAnimFrame(); return this; }, // unpause the animation play: function play() { if (!this.paused) return this; this.paused = false; // We use an absolute position here so that the delay before the animation can be paused return this.at(this.absPos, true); }, /** * toggle or set the direction of the animation * true sets direction to backwards while false sets it to forwards * @param reversed Boolean indicating whether to reverse the animation or not (default: toggle the reverse status) * @return this */ reverse: function reverse(reversed) { var c = this.last(); if (typeof reversed === 'undefined') c.reversed = !c.reversed;else c.reversed = reversed; return this; }, /** * returns a float from 0-1 indicating the progress of the current animation * @param eased Boolean indicating whether the returned position should be eased or not * @return number */ progress: function progress(easeIt) { return easeIt ? this.situation.ease(this.pos) : this.pos; }, /** * adds a callback function which is called when the current animation is finished * @param fn Function which should be executed as callback * @return number */ after: function after(fn) { var c = this.last(), wrapper = function wrapper(e) { if (e.detail.situation == c) { fn.call(this, c); this.off('finished.fx', wrapper); // prevent memory leak } }; this.target().on('finished.fx', wrapper); return this._callStart(); }, // adds a callback which is called whenever one animation step is performed during: function during(fn) { var c = this.last(), wrapper = function wrapper(e) { if (e.detail.situation == c) { fn.call(this, e.detail.pos, SVG.morph(e.detail.pos), e.detail.eased, c); } }; // see above this.target().off('during.fx', wrapper).on('during.fx', wrapper); this.after(function () { this.off('during.fx', wrapper); }); return this._callStart(); }, // calls after ALL animations in the queue are finished afterAll: function afterAll(fn) { var wrapper = function wrapper(e) { fn.call(this); this.off('allfinished.fx', wrapper); }; // see above this.target().off('allfinished.fx', wrapper).on('allfinished.fx', wrapper); return this._callStart(); }, // calls on every animation step for all animations duringAll: function duringAll(fn) { var wrapper = function wrapper(e) { fn.call(this, e.detail.pos, SVG.morph(e.detail.pos), e.detail.eased, e.detail.situation); }; this.target().off('during.fx', wrapper).on('during.fx', wrapper); this.afterAll(function () { this.off('during.fx', wrapper); }); return this._callStart(); }, last: function last() { return this.situations.length ? this.situations[this.situations.length - 1] : this.situation; }, // adds one property to the animations add: function add(method, args, type) { this.last()[type || 'animations'][method] = args; return this._callStart(); }, /** perform one step of the animation * @param ignoreTime Boolean indicating whether to ignore time and use position directly or recalculate position based on time * @return this */ step: function step(ignoreTime) { // convert current time to an absolute position if (!ignoreTime) this.absPos = this.timeToAbsPos(+new Date()); // This part convert an absolute position to a position if (this.situation.loops !== false) { var absPos, absPosInt, lastLoop; // If the absolute position is below 0, we just treat it as if it was 0 absPos = Math.max(this.absPos, 0); absPosInt = Math.floor(absPos); if (this.situation.loops === true || absPosInt < this.situation.loops) { this.pos = absPos - absPosInt; lastLoop = this.situation.loop; this.situation.loop = absPosInt; } else { this.absPos = this.situation.loops; this.pos = 1; // The -1 here is because we don't want to toggle reversed when all the loops have been completed lastLoop = this.situation.loop - 1; this.situation.loop = this.situation.loops; } if (this.situation.reversing) { // Toggle reversed if an odd number of loops as occured since the last call of step this.situation.reversed = this.situation.reversed != Boolean((this.situation.loop - lastLoop) % 2); } } else { // If there are no loop, the absolute position must not be above 1 this.absPos = Math.min(this.absPos, 1); this.pos = this.absPos; } // while the absolute position can be below 0, the position must not be below 0 if (this.pos < 0) this.pos = 0; if (this.situation.reversed) this.pos = 1 - this.pos; // apply easing var eased = this.situation.ease(this.pos); // call once-callbacks for (var i in this.situation.once) { if (i > this.lastPos && i <= eased) { this.situation.once[i].call(this.target(), this.pos, eased); delete this.situation.once[i]; } } // fire during callback with position, eased position and current situation as parameter if (this.active) this.target().fire('during', { pos: this.pos, eased: eased, fx: this, situation: this.situation }); // the user may call stop or finish in the during callback // so make sure that we still have a valid situation if (!this.situation) { return this; } // apply the actual animation to every property this.eachAt(); // do final code when situation is finished if (this.pos == 1 && !this.situation.reversed || this.situation.reversed && this.pos == 0) { // stop animation callback this.stopAnimFrame(); // fire finished callback with current situation as parameter this.target().fire('finished', { fx: this, situation: this.situation }); if (!this.situations.length) { this.target().fire('allfinished'); // Recheck the length since the user may call animate in the afterAll callback if (!this.situations.length) { this.target().off('.fx'); // there shouldnt be any binding left, but to make sure... this.active = false; } } // start next animation if (this.active) this.dequeue();else this.clearCurrent(); } else if (!this.paused && this.active) { // we continue animating when we are not at the end this.startAnimFrame(); } // save last eased position for once callback triggering this.lastPos = eased; return this; }, // calculates the step for every property and calls block with it eachAt: function eachAt() { var i, len, at, self = this, target = this.target(), s = this.situation; // apply animations which can be called trough a method for (i in s.animations) { at = [].concat(s.animations[i]).map(function (el) { return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el; }); target[i].apply(target, at); } // apply animation which has to be applied with attr() for (i in s.attrs) { at = [i].concat(s.attrs[i]).map(function (el) { return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el; }); target.attr.apply(target, at); } // apply animation which has to be applied with style() for (i in s.styles) { at = [i].concat(s.styles[i]).map(function (el) { return typeof el !== 'string' && el.at ? el.at(s.ease(self.pos), self.pos) : el; }); target.style.apply(target, at); } // animate initialTransformation which has to be chained if (s.transforms.length) { // get initial initialTransformation at = s.initialTransformation; for (i = 0, len = s.transforms.length; i < len; i++) { // get next transformation in chain var a = s.transforms[i]; // multiply matrix directly if (a instanceof SVG.Matrix) { if (a.relative) { at = at.multiply(new SVG.Matrix().morph(a).at(s.ease(this.pos))); } else { at = at.morph(a).at(s.ease(this.pos)); } continue; } // when transformation is absolute we have to reset the needed transformation first if (!a.relative) { a.undo(at.extract()); } // and reapply it after at = at.multiply(a.at(s.ease(this.pos))); } // set new matrix on element target.matrix(at); } return this; }, // adds an once-callback which is called at a specific position and never again once: function once(pos, fn, isEased) { var c = this.last(); if (!isEased) pos = c.ease(pos); c.once[pos] = fn; return this; }, _callStart: function _callStart() { setTimeout(function () { this.start(); }.bind(this), 0); return this; } }, parent: SVG.Element, // Add method to parent elements construct: { // Get fx module or create a new one, then animate with given duration and ease animate: function animate(o, ease, delay) { return (this.fx || (this.fx = new SVG.FX(this))).animate(o, ease, delay); }, delay: function delay(_delay2) { return (this.fx || (this.fx = new SVG.FX(this))).delay(_delay2); }, stop: function stop(jumpToEnd, clearQueue) { if (this.fx) { this.fx.stop(jumpToEnd, clearQueue); } return this; }, finish: function finish() { if (this.fx) { this.fx.finish(); } return this; }, // Pause current animation pause: function pause() { if (this.fx) { this.fx.pause(); } return this; }, // Play paused current animation play: function play() { if (this.fx) { this.fx.play(); } return this; }, // Set/Get the speed of the animations speed: function speed(_speed2) { if (this.fx) { if (_speed2 == null) { return this.fx.speed(); } else { this.fx.speed(_speed2); } } return this; } } }); // MorphObj is used whenever no morphable object is given SVG.MorphObj = SVG.invent({ create: function create(from, to) { // prepare color for morphing if (SVG.Color.isColor(to)) return new SVG.Color(from).morph(to); // check if we have a list of values if (SVG.regex.delimiter.test(from)) { // prepare path for morphing if (SVG.regex.pathLetters.test(from)) return new SVG.PathArray(from).morph(to); // prepare value list for morphing else return new SVG.Array(from).morph(to); } // prepare number for morphing if (SVG.regex.numberAndUnit.test(to)) return new SVG.Number(from).morph(to); // prepare for plain morphing this.value = from; this.destination = to; }, extend: { at: function at(pos, real) { return real < 1 ? this.value : this.destination; }, valueOf: function valueOf() { return this.value; } } }); SVG.extend(SVG.FX, { // Add animatable attributes attr: function attr(a, v, relative) { // apply attributes individually if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'object') { for (var key in a) { this.attr(key, a[key]); } } else { this.add(a, v, 'attrs'); } return this; }, // Add animatable styles style: function style(s, v) { if ((typeof s === 'undefined' ? 'undefined' : _typeof(s)) === 'object') { for (var key in s) { this.style(key, s[key]); } } else { this.add(s, v, 'styles'); } return this; }, // Animatable x-axis x: function x(_x2, relative) { if (this.target() instanceof SVG.G) { this.transform({ x: _x2 }, relative); return this; } var num = new SVG.Number(_x2); num.relative = relative; return this.add('x', num); }, // Animatable y-axis y: function y(_y2, relative) { if (this.target() instanceof SVG.G) { this.transform({ y: _y2 }, relative); return this; } var num = new SVG.Number(_y2); num.relative = relative; return this.add('y', num); }, // Animatable center x-axis cx: function cx(x) { return this.add('cx', new SVG.Number(x)); }, // Animatable center y-axis cy: function cy(y) { return this.add('cy', new SVG.Number(y)); }, // Add animatable move move: function move(x, y) { return this.x(x).y(y); }, // Add animatable center center: function center(x, y) { return this.cx(x).cy(y); }, // Add animatable size size: function size(width, height) { if (this.target() instanceof SVG.Text) { // animate font size for Text elements this.attr('font-size', width); } else { // animate bbox based size for all other elements var box; if (!width || !height) { box = this.target().bbox(); } if (!width) { width = box.width / box.height * height; } if (!height) { height = box.height / box.width * width; } this.add('width', new SVG.Number(width)).add('height', new SVG.Number(height)); } return this; }, // Add animatable width width: function width(_width2) { return this.add('width', new SVG.Number(_width2)); }, // Add animatable height height: function height(_height2) { return this.add('height', new SVG.Number(_height2)); }, // Add animatable plot plot: function plot(a, b, c, d) { // Lines can be plotted with 4 arguments if (arguments.length == 4) { return this.plot([a, b, c, d]); } return this.add('plot', new (this.target().morphArray)(a)); }, // Add leading method leading: function leading(value) { return this.target().leading ? this.add('leading', new SVG.Number(value)) : this; }, // Add animatable viewbox viewbox: function viewbox(x, y, width, height) { if (this.target() instanceof SVG.Container) { this.add('viewbox', new SVG.ViewBox(x, y, width, height)); } return this; }, update: function update(o) { if (this.target() instanceof SVG.Stop) { if (typeof o === 'number' || o instanceof SVG.Number) { return this.update({ offset: arguments[0], color: arguments[1], opacity: arguments[2] }); } if (o.opacity != null) this.attr('stop-opacity', o.opacity); if (o.color != null) this.attr('stop-color', o.color); if (o.offset != null) this.attr('offset', o.offset); } return this; } }); SVG.Box = SVG.invent({ create: function create(x, y, width, height) { if ((typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && !(x instanceof SVG.Element)) { // chromes getBoundingClientRect has no x and y property return SVG.Box.call(this, x.left != null ? x.left : x.x, x.top != null ? x.top : x.y, x.width, x.height); } else if (arguments.length == 4) { this.x = x; this.y = y; this.width = width; this.height = height; } // add center, right, bottom... fullBox(this); }, extend: { // Merge rect box with another, return a new instance merge: function merge(box) { var b = new this.constructor(); // merge boxes b.x = Math.min(this.x, box.x); b.y = Math.min(this.y, box.y); b.width = Math.max(this.x + this.width, box.x + box.width) - b.x; b.height = Math.max(this.y + this.height, box.y + box.height) - b.y; return fullBox(b); }, transform: function transform(m) { var xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, p, bbox; var pts = [new SVG.Point(this.x, this.y), new SVG.Point(this.x2, this.y), new SVG.Point(this.x, this.y2), new SVG.Point(this.x2, this.y2)]; pts.forEach(function (p) { p = p.transform(m); xMin = Math.min(xMin, p.x); xMax = Math.max(xMax, p.x); yMin = Math.min(yMin, p.y); yMax = Math.max(yMax, p.y); }); bbox = new this.constructor(); bbox.x = xMin; bbox.width = xMax - xMin; bbox.y = yMin; bbox.height = yMax - yMin; fullBox(bbox); return bbox; } } }); SVG.BBox = SVG.invent({ // Initialize create: function create(element) { SVG.Box.apply(this, [].slice.call(arguments)); // get values if element is given if (element instanceof SVG.Element) { var box; // yes this is ugly, but Firefox can be a pain when it comes to elements that are not yet rendered try { if (!document.documentElement.contains) { // This is IE - it does not support contains() for top-level SVGs var topParent = element.node; while (topParent.parentNode) { topParent = topParent.parentNode; } if (topParent != document) throw new Error('Element not in the dom'); } else {} // the element is NOT in the dom, throw error // disabling the check below which fixes issue #76 // if (!document.documentElement.contains(element.node)) throw new Exception('Element not in the dom') // find native bbox box = element.node.getBBox(); } catch (e) { if (element instanceof SVG.Shape) { if (!SVG.parser.draw) { // fixes apexcharts/vue-apexcharts #14 SVG.prepare(); } var clone = element.clone(SVG.parser.draw.instance).show(); box = clone.node.getBBox(); clone.remove(); } else { box = { x: element.node.clientLeft, y: element.node.clientTop, width: element.node.clientWidth, height: element.node.clientHeight }; } } SVG.Box.call(this, box); } }, // Define ancestor inherit: SVG.Box, // Define Parent parent: SVG.Element, // Constructor construct: { // Get bounding box bbox: function bbox() { return new SVG.BBox(this); } } }); SVG.BBox.prototype.constructor = SVG.BBox; SVG.extend(SVG.Element, { tbox: function tbox() { console.warn('Use of TBox is deprecated and mapped to RBox. Use .rbox() instead.'); return this.rbox(this.doc()); } }); SVG.RBox = SVG.invent({ // Initialize create: function create(element) { SVG.Box.apply(this, [].slice.call(arguments)); if (element instanceof SVG.Element) { SVG.Box.call(this, element.node.getBoundingClientRect()); } }, inherit: SVG.Box, // define Parent parent: SVG.Element, extend: { addOffset: function addOffset() { // offset by window scroll position, because getBoundingClientRect changes when window is scrolled this.x += window.pageXOffset; this.y += window.pageYOffset; return this; } }, // Constructor construct: { // Get rect box rbox: function rbox(el) { if (el) return new SVG.RBox(this).transform(el.screenCTM().inverse()); return new SVG.RBox(this).addOffset(); } } }); SVG.RBox.prototype.constructor = SVG.RBox; SVG.Matrix = SVG.invent({ // Initialize create: function create(source) { var i, base = arrayToMatrix([1, 0, 0, 1, 0, 0]); // ensure source as object source = source instanceof SVG.Element ? source.matrixify() : typeof source === 'string' ? arrayToMatrix(source.split(SVG.regex.delimiter).map(parseFloat)) : arguments.length == 6 ? arrayToMatrix([].slice.call(arguments)) : Array.isArray(source) ? arrayToMatrix(source) : (typeof source === 'undefined' ? 'undefined' : _typeof(source)) === 'object' ? source : base; // merge source for (i = abcdef.length - 1; i >= 0; --i) { this[abcdef[i]] = source[abcdef[i]] != null ? source[abcdef[i]] : base[abcdef[i]]; } }, // Add methods extend: { // Extract individual transformations extract: function extract() { // find delta transform points var px = deltaTransformPoint(this, 0, 1), py = deltaTransformPoint(this, 1, 0), skewX = 180 / Math.PI * Math.atan2(px.y, px.x) - 90; return { // translation x: this.e, y: this.f, transformedX: (this.e * Math.cos(skewX * Math.PI / 180) + this.f * Math.sin(skewX * Math.PI / 180)) / Math.sqrt(this.a * this.a + this.b * this.b), transformedY: (this.f * Math.cos(skewX * Math.PI / 180) + this.e * Math.sin(-skewX * Math.PI / 180)) / Math.sqrt(this.c * this.c + this.d * this.d), // skew skewX: -skewX, skewY: 180 / Math.PI * Math.atan2(py.y, py.x), // scale scaleX: Math.sqrt(this.a * this.a + this.b * this.b), scaleY: Math.sqrt(this.c * this.c + this.d * this.d), // rotation rotation: skewX, a: this.a, b: this.b, c: this.c, d: this.d, e: this.e, f: this.f, matrix: new SVG.Matrix(this) }; }, // Clone matrix clone: function clone() { return new SVG.Matrix(this); }, // Morph one matrix into another morph: function morph(matrix) { // store new destination this.destination = new SVG.Matrix(matrix); return this; }, // Get morphed matrix at a given position at: function at(pos) { // make sure a destination is defined if (!this.destination) return this; // calculate morphed matrix at a given position var matrix = new SVG.Matrix({ a: this.a + (this.destination.a - this.a) * pos, b: this.b + (this.destination.b - this.b) * pos, c: this.c + (this.destination.c - this.c) * pos, d: this.d + (this.destination.d - this.d) * pos, e: this.e + (this.destination.e - this.e) * pos, f: this.f + (this.destination.f - this.f) * pos }); return matrix; }, // Multiplies by given matrix multiply: function multiply(matrix) { return new SVG.Matrix(this.native().multiply(parseMatrix(matrix).native())); }, // Inverses matrix inverse: function inverse() { return new SVG.Matrix(this.native().inverse()); }, // Translate matrix translate: function translate(x, y) { return new SVG.Matrix(this.native().translate(x || 0, y || 0)); }, // Scale matrix scale: function scale(x, y, cx, cy) { // support uniformal scale if (arguments.length == 1) { y = x; } else if (arguments.length == 3) { cy = cx; cx = y; y = x; } return this.around(cx, cy, new SVG.Matrix(x, 0, 0, y, 0, 0)); }, // Rotate matrix rotate: function rotate(r, cx, cy) { // convert degrees to radians r = SVG.utils.radians(r); return this.around(cx, cy, new SVG.Matrix(Math.cos(r), Math.sin(r), -Math.sin(r), Math.cos(r), 0, 0)); }, // Flip matrix on x or y, at a given offset flip: function flip(a, o) { return a == 'x' ? this.scale(-1, 1, o, 0) : a == 'y' ? this.scale(1, -1, 0, o) : this.scale(-1, -1, a, o != null ? o : a); }, // Skew skew: function skew(x, y, cx, cy) { // support uniformal skew if (arguments.length == 1) { y = x; } else if (arguments.length == 3) { cy = cx; cx = y; y = x; } // convert degrees to radians x = SVG.utils.radians(x); y = SVG.utils.radians(y); return this.around(cx, cy, new SVG.Matrix(1, Math.tan(y), Math.tan(x), 1, 0, 0)); }, // SkewX skewX: function skewX(x, cx, cy) { return this.skew(x, 0, cx, cy); }, // SkewY skewY: function skewY(y, cx, cy) { return this.skew(0, y, cx, cy); }, // Transform around a center point around: function around(cx, cy, matrix) { return this.multiply(new SVG.Matrix(1, 0, 0, 1, cx || 0, cy || 0)).multiply(matrix).multiply(new SVG.Matrix(1, 0, 0, 1, -cx || 0, -cy || 0)); }, // Convert to native SVGMatrix native: function native() { // create new matrix var matrix = SVG.parser.native.createSVGMatrix(); // update with current values for (var i = abcdef.length - 1; i >= 0; i--) { matrix[abcdef[i]] = this[abcdef[i]]; } return matrix; }, // Convert matrix to string toString: function toString() { // Construct the matrix directly, avoid values that are too small return 'matrix(' + float32String(this.a) + ',' + float32String(this.b) + ',' + float32String(this.c) + ',' + float32String(this.d) + ',' + float32String(this.e) + ',' + float32String(this.f) + ')'; } }, // Define parent parent: SVG.Element, // Add parent method construct: { // Get current matrix ctm: function ctm() { return new SVG.Matrix(this.node.getCTM()); }, // Get current screen matrix screenCTM: function screenCTM() { /* https://bugzilla.mozilla.org/show_bug.cgi?id=1344537 This is needed because FF does not return the transformation matrix for the inner coordinate system when getScreenCTM() is called on nested svgs. However all other Browsers do that */ if (this instanceof SVG.Nested) { var rect = this.rect(1, 1); var m = rect.node.getScreenCTM(); rect.remove(); return new SVG.Matrix(m); } return new SVG.Matrix(this.node.getScreenCTM()); } } }); SVG.Point = SVG.invent({ // Initialize create: function create(x, y) { var i, source, base = { x: 0, y: 0 // ensure source as object };source = Array.isArray(x) ? { x: x[0], y: x[1] } : (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' ? { x: x.x, y: x.y } : x != null ? { x: x, y: y != null ? y : x } : base; // If y has no value, then x is used has its value // merge source this.x = source.x; this.y = source.y; }, // Add methods extend: { // Clone point clone: function clone() { return new SVG.Point(this); }, // Morph one point into another morph: function morph(x, y) { // store new destination this.destination = new SVG.Point(x, y); return this; }, // Get morphed point at a given position at: function at(pos) { // make sure a destination is defined if (!this.destination) return this; // calculate morphed matrix at a given position var point = new SVG.Point({ x: this.x + (this.destination.x - this.x) * pos, y: this.y + (this.destination.y - this.y) * pos }); return point; }, // Convert to native SVGPoint native: function native() { // create new point var point = SVG.parser.native.createSVGPoint(); // update with current values point.x = this.x; point.y = this.y; return point; }, // transform point with matrix transform: function transform(matrix) { return new SVG.Point(this.native().matrixTransform(matrix.native())); } } }); SVG.extend(SVG.Element, { // Get point point: function point(x, y) { return new SVG.Point(x, y).transform(this.screenCTM().inverse()); } }); SVG.extend(SVG.Element, { // Set svg element attribute attr: function attr(a, v, n) { // act as full getter if (a == null) { // get an object of attributes a = {}; v = this.node.attributes; for (n = v.length - 1; n >= 0; n--) { a[v[n].nodeName] = SVG.regex.isNumber.test(v[n].nodeValue) ? parseFloat(v[n].nodeValue) : v[n].nodeValue; } return a; } else if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'object') { // apply every attribute individually if an object is passed for (v in a) { this.attr(v, a[v]); } } else if (v === null) { // remove value this.node.removeAttribute(a); } else if (v == null) { // act as a getter if the first and only argument is not an object v = this.node.getAttribute(a); return v == null ? SVG.defaults.attrs[a] : SVG.regex.isNumber.test(v) ? parseFloat(v) : v; } else { // BUG FIX: some browsers will render a stroke if a color is given even though stroke width is 0 if (a == 'stroke-width') { this.attr('stroke', parseFloat(v) > 0 ? this._stroke : null); } else if (a == 'stroke') { this._stroke = v; } // convert image fill and stroke to patterns if (a == 'fill' || a == 'stroke') { if (SVG.regex.isImage.test(v)) { v = this.doc().defs().image(v, 0, 0); } if (v instanceof SVG.Image) { v = this.doc().defs().pattern(0, 0, function () { this.add(v); }); } } // ensure correct numeric values (also accepts NaN and Infinity) if (typeof v === 'number') { v = new SVG.Number(v); } // ensure full hex color else if (SVG.Color.isColor(v)) { v = new SVG.Color(v); } // parse array values else if (Array.isArray(v)) { v = new SVG.Array(v); } // if the passed attribute is leading... if (a == 'leading') { // ... call the leading method instead if (this.leading) { this.leading(v); } } else { // set given attribute on node typeof n === 'string' ? this.node.setAttributeNS(n, a, v.toString()) : this.node.setAttribute(a, v.toString()); } // rebuild if required if (this.rebuild && (a == 'font-size' || a == 'x')) { this.rebuild(a, v); } } return this; } }); SVG.extend(SVG.Element, { // Add transformations transform: function transform(o, relative) { // get target in case of the fx module, otherwise reference this var target = this, matrix, bbox; // act as a getter if ((typeof o === 'undefined' ? 'undefined' : _typeof(o)) !== 'object') { // get current matrix matrix = new SVG.Matrix(target).extract(); return typeof o === 'string' ? matrix[o] : matrix; } // get current matrix matrix = new SVG.Matrix(target); // ensure relative flag relative = !!relative || !!o.relative; // act on matrix if (o.a != null) { matrix = relative // relative ? matrix.multiply(new SVG.Matrix(o)) // absolute : new SVG.Matrix(o); // act on rotation } else if (o.rotation != null) { // ensure centre point ensureCentre(o, target); // apply transformation matrix = relative // relative ? matrix.rotate(o.rotation, o.cx, o.cy) // absolute : matrix.rotate(o.rotation - matrix.extract().rotation, o.cx, o.cy); // act on scale } else if (o.scale != null || o.scaleX != null || o.scaleY != null) { // ensure centre point ensureCentre(o, target); // ensure scale values on both axes o.scaleX = o.scale != null ? o.scale : o.scaleX != null ? o.scaleX : 1; o.scaleY = o.scale != null ? o.scale : o.scaleY != null ? o.scaleY : 1; if (!relative) { // absolute; multiply inversed values var e = matrix.extract(); o.scaleX = o.scaleX * 1 / e.scaleX; o.scaleY = o.scaleY * 1 / e.scaleY; } matrix = matrix.scale(o.scaleX, o.scaleY, o.cx, o.cy); // act on skew } else if (o.skew != null || o.skewX != null || o.skewY != null) { // ensure centre point ensureCentre(o, target); // ensure skew values on both axes o.skewX = o.skew != null ? o.skew : o.skewX != null ? o.skewX : 0; o.skewY = o.skew != null ? o.skew : o.skewY != null ? o.skewY : 0; if (!relative) { // absolute; reset skew values var e = matrix.extract(); matrix = matrix.multiply(new SVG.Matrix().skew(e.skewX, e.skewY, o.cx, o.cy).inverse()); } matrix = matrix.skew(o.skewX, o.skewY, o.cx, o.cy); // act on flip } else if (o.flip) { if (o.flip == 'x' || o.flip == 'y') { o.offset = o.offset == null ? target.bbox()['c' + o.flip] : o.offset; } else { if (o.offset == null) { bbox = target.bbox(); o.flip = bbox.cx; o.offset = bbox.cy; } else { o.flip = o.offset; } } matrix = new SVG.Matrix().flip(o.flip, o.offset); // act on translate } else if (o.x != null || o.y != null) { if (relative) { // relative matrix = matrix.translate(o.x, o.y); } else { // absolute if (o.x != null) matrix.e = o.x; if (o.y != null) matrix.f = o.y; } } return this.attr('transform', matrix); } }); SVG.extend(SVG.FX, { transform: function transform(o, relative) { // get target in case of the fx module, otherwise reference this var target = this.target(), matrix, bbox; // act as a getter if ((typeof o === 'undefined' ? 'undefined' : _typeof(o)) !== 'object') { // get current matrix matrix = new SVG.Matrix(target).extract(); return typeof o === 'string' ? matrix[o] : matrix; } // ensure relative flag relative = !!relative || !!o.relative; // act on matrix if (o.a != null) { matrix = new SVG.Matrix(o); // act on rotation } else if (o.rotation != null) { // ensure centre point ensureCentre(o, target); // apply transformation matrix = new SVG.Rotate(o.rotation, o.cx, o.cy); // act on scale } else if (o.scale != null || o.scaleX != null || o.scaleY != null) { // ensure centre point ensureCentre(o, target); // ensure scale values on both axes o.scaleX = o.scale != null ? o.scale : o.scaleX != null ? o.scaleX : 1; o.scaleY = o.scale != null ? o.scale : o.scaleY != null ? o.scaleY : 1; matrix = new SVG.Scale(o.scaleX, o.scaleY, o.cx, o.cy); // act on skew } else if (o.skewX != null || o.skewY != null) { // ensure centre point ensureCentre(o, target); // ensure skew values on both axes o.skewX = o.skewX != null ? o.skewX : 0; o.skewY = o.skewY != null ? o.skewY : 0; matrix = new SVG.Skew(o.skewX, o.skewY, o.cx, o.cy); // act on flip } else if (o.flip) { if (o.flip == 'x' || o.flip == 'y') { o.offset = o.offset == null ? target.bbox()['c' + o.flip] : o.offset; } else { if (o.offset == null) { bbox = target.bbox(); o.flip = bbox.cx; o.offset = bbox.cy; } else { o.flip = o.offset; } } matrix = new SVG.Matrix().flip(o.flip, o.offset); // act on translate } else if (o.x != null || o.y != null) { matrix = new SVG.Translate(o.x, o.y); } if (!matrix) return this; matrix.relative = relative; this.last().transforms.push(matrix); return this._callStart(); } }); SVG.extend(SVG.Element, { // Reset all transformations untransform: function untransform() { return this.attr('transform', null); }, // merge the whole transformation chain into one matrix and returns it matrixify: function matrixify() { var matrix = (this.attr('transform') || ''). // split transformations split(SVG.regex.transforms).slice(0, -1).map(function (str) { // generate key => value pairs var kv = str.trim().split('('); return [kv[0], kv[1].split(SVG.regex.delimiter).map(function (str) { return parseFloat(str); })]; }) // merge every transformation into one matrix .reduce(function (matrix, transform) { if (transform[0] == 'matrix') return matrix.multiply(arrayToMatrix(transform[1])); return matrix[transform[0]].apply(matrix, transform[1]); }, new SVG.Matrix()); return matrix; }, // add an element to another parent without changing the visual representation on the screen toParent: function toParent(parent) { if (this == parent) return this; var ctm = this.screenCTM(); var pCtm = parent.screenCTM().inverse(); this.addTo(parent).untransform().transform(pCtm.multiply(ctm)); return this; }, // same as above with parent equals root-svg toDoc: function toDoc() { return this.toParent(this.doc()); } }); SVG.Transformation = SVG.invent({ create: function create(source, inversed) { if (arguments.length > 1 && typeof inversed !== 'boolean') { return this.constructor.call(this, [].slice.call(arguments)); } if (Array.isArray(source)) { for (var i = 0, len = this.arguments.length; i < len; ++i) { this[this.arguments[i]] = source[i]; } } else if ((typeof source === 'undefined' ? 'undefined' : _typeof(source)) === 'object') { for (var i = 0, len = this.arguments.length; i < len; ++i) { this[this.arguments[i]] = source[this.arguments[i]]; } } this.inversed = false; if (inversed === true) { this.inversed = true; } }, extend: { arguments: [], method: '', at: function at(pos) { var params = []; for (var i = 0, len = this.arguments.length; i < len; ++i) { params.push(this[this.arguments[i]]); } var m = this._undo || new SVG.Matrix(); m = new SVG.Matrix().morph(SVG.Matrix.prototype[this.method].apply(m, params)).at(pos); return this.inversed ? m.inverse() : m; }, undo: function undo(o) { for (var i = 0, len = this.arguments.length; i < len; ++i) { o[this.arguments[i]] = typeof this[this.arguments[i]] === 'undefined' ? 0 : o[this.arguments[i]]; } // The method SVG.Matrix.extract which was used before calling this // method to obtain a value for the parameter o doesn't return a cx and // a cy so we use the ones that were provided to this object at its creation o.cx = this.cx; o.cy = this.cy; this._undo = new SVG[capitalize(this.method)](o, true).at(1); return this; } } }); SVG.Translate = SVG.invent({ parent: SVG.Matrix, inherit: SVG.Transformation, create: function create(source, inversed) { this.constructor.apply(this, [].slice.call(arguments)); }, extend: { arguments: ['transformedX', 'transformedY'], method: 'translate' } }); SVG.Rotate = SVG.invent({ parent: SVG.Matrix, inherit: SVG.Transformation, create: function create(source, inversed) { this.constructor.apply(this, [].slice.call(arguments)); }, extend: { arguments: ['rotation', 'cx', 'cy'], method: 'rotate', at: function at(pos) { var m = new SVG.Matrix().rotate(new SVG.Number().morph(this.rotation - (this._undo ? this._undo.rotation : 0)).at(pos), this.cx, this.cy); return this.inversed ? m.inverse() : m; }, undo: function undo(o) { this._undo = o; return this; } } }); SVG.Scale = SVG.invent({ parent: SVG.Matrix, inherit: SVG.Transformation, create: function create(source, inversed) { this.constructor.apply(this, [].slice.call(arguments)); }, extend: { arguments: ['scaleX', 'scaleY', 'cx', 'cy'], method: 'scale' } }); SVG.Skew = SVG.invent({ parent: SVG.Matrix, inherit: SVG.Transformation, create: function create(source, inversed) { this.constructor.apply(this, [].slice.call(arguments)); }, extend: { arguments: ['skewX', 'skewY', 'cx', 'cy'], method: 'skew' } }); SVG.extend(SVG.Element, { // Dynamic style generator style: function style(s, v) { if (arguments.length == 0) { // get full style return this.node.style.cssText || ''; } else if (arguments.length < 2) { // apply every style individually if an object is passed if ((typeof s === 'undefined' ? 'undefined' : _typeof(s)) === 'object') { for (v in s) { this.style(v, s[v]); } } else if (SVG.regex.isCss.test(s)) { // parse css string s = s.split(/\s*;\s*/) // filter out suffix ; and stuff like ;; .filter(function (e) { return !!e; }).map(function (e) { return e.split(/\s*:\s*/); }); // apply every definition individually while (v = s.pop()) { this.style(v[0], v[1]); } } else { // act as a getter if the first and only argument is not an object return this.node.style[camelCase(s)]; } } else { this.node.style[camelCase(s)] = v === null || SVG.regex.isBlank.test(v) ? '' : v; } return this; } }); SVG.Parent = SVG.invent({ // Initialize node create: function create(element) { this.constructor.call(this, element); }, // Inherit from inherit: SVG.Element, // Add class methods extend: { // Returns all child elements children: function children() { return SVG.utils.map(SVG.utils.filterSVGElements(this.node.childNodes), function (node) { return SVG.adopt(node); }); }, // Add given element at a position add: function add(element, i) { if (i == null) { this.node.appendChild(element.node); } else if (element.node != this.node.childNodes[i]) { this.node.insertBefore(element.node, this.node.childNodes[i]); } return this; }, // Basically does the same as `add()` but returns the added element instead put: function put(element, i) { this.add(element, i); return element; }, // Checks if the given element is a child has: function has(element) { return this.index(element) >= 0; }, // Gets index of given element index: function index(element) { return [].slice.call(this.node.childNodes).indexOf(element.node); }, // Get a element at the given index get: function get(i) { return SVG.adopt(this.node.childNodes[i]); }, // Get first child first: function first() { return this.get(0); }, // Get the last child last: function last() { return this.get(this.node.childNodes.length - 1); }, // Iterates over all children and invokes a given block each: function each(block, deep) { var i, il, children = this.children(); for (i = 0, il = children.length; i < il; i++) { if (children[i] instanceof SVG.Element) { block.apply(children[i], [i, children]); } if (deep && children[i] instanceof SVG.Container) { children[i].each(block, deep); } } return this; }, // Remove a given child removeElement: function removeElement(element) { this.node.removeChild(element.node); return this; }, // Remove all elements in this container clear: function clear() { // remove children while (this.node.hasChildNodes()) { this.node.removeChild(this.node.lastChild); } // remove defs reference delete this._defs; return this; }, // Get defs defs: function defs() { return this.doc().defs(); } } }); SVG.extend(SVG.Parent, { ungroup: function ungroup(parent, depth) { if (depth === 0 || this instanceof SVG.Defs || this.node == SVG.parser.draw) return this; parent = parent || (this instanceof SVG.Doc ? this : this.parent(SVG.Parent)); depth = depth || Infinity; this.each(function () { if (this instanceof SVG.Defs) return this; if (this instanceof SVG.Parent) return this.ungroup(parent, depth - 1); return this.toParent(parent); }); this.node.firstChild || this.remove(); return this; }, flatten: function flatten(parent, depth) { return this.ungroup(parent, depth); } }); SVG.Container = SVG.invent({ // Initialize node create: function create(element) { this.constructor.call(this, element); }, // Inherit from inherit: SVG.Parent }); SVG.ViewBox = SVG.invent({ create: function create(source) { var i, base = [0, 0, 0, 0]; var x, y, width, height, box, view, we, he, wm = 1, // width multiplier hm = 1, // height multiplier reg = /[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/gi; if (source instanceof SVG.Element) { we = source; he = source; view = (source.attr('viewBox') || '').match(reg); box = source.bbox; // get dimensions of current node width = new SVG.Number(source.width()); height = new SVG.Number(source.height()); // find nearest non-percentual dimensions while (width.unit == '%') { wm *= width.value; width = new SVG.Number(we instanceof SVG.Doc ? we.parent().offsetWidth : we.parent().width()); we = we.parent(); } while (height.unit == '%') { hm *= height.value; height = new SVG.Number(he instanceof SVG.Doc ? he.parent().offsetHeight : he.parent().height()); he = he.parent(); } // ensure defaults this.x = 0; this.y = 0; this.width = width * wm; this.height = height * hm; this.zoom = 1; if (view) { // get width and height from viewbox x = parseFloat(view[0]); y = parseFloat(view[1]); width = parseFloat(view[2]); height = parseFloat(view[3]); // calculate zoom accoring to viewbox this.zoom = this.width / this.height > width / height ? this.height / height : this.width / width; // calculate real pixel dimensions on parent SVG.Doc element this.x = x; this.y = y; this.width = width; this.height = height; } } else { // ensure source as object source = typeof source === 'string' ? source.match(reg).map(function (el) { return parseFloat(el); }) : Array.isArray(source) ? source : (typeof source === 'undefined' ? 'undefined' : _typeof(source)) === 'object' ? [source.x, source.y, source.width, source.height] : arguments.length == 4 ? [].slice.call(arguments) : base; this.x = source[0]; this.y = source[1]; this.width = source[2]; this.height = source[3]; } }, extend: { toString: function toString() { return this.x + ' ' + this.y + ' ' + this.width + ' ' + this.height; }, morph: function morph(x, y, width, height) { this.destination = new SVG.ViewBox(x, y, width, height); return this; }, at: function at(pos) { if (!this.destination) return this; return new SVG.ViewBox([this.x + (this.destination.x - this.x) * pos, this.y + (this.destination.y - this.y) * pos, this.width + (this.destination.width - this.width) * pos, this.height + (this.destination.height - this.height) * pos]); } }, // Define parent parent: SVG.Container, // Add parent method construct: { // get/set viewbox viewbox: function viewbox(x, y, width, height) { if (arguments.length == 0) // act as a getter if there are no arguments { return new SVG.ViewBox(this); } // otherwise act as a setter return this.attr('viewBox', new SVG.ViewBox(x, y, width, height)); } } }) // Add events to elements ;['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout', 'mousemove', // , 'mouseenter' -> not supported by IE // , 'mouseleave' -> not supported by IE 'touchstart', 'touchmove', 'touchleave', 'touchend', 'touchcancel'].forEach(function (event) { // add event to SVG.Element SVG.Element.prototype[event] = function (f) { // bind event to element rather than element node SVG.on(this.node, event, f); return this; }; }); // Initialize listeners stack SVG.listeners = []; SVG.handlerMap = []; SVG.listenerId = 0; // Add event binder in the SVG namespace SVG.on = function (node, event, listener, binding, options) { // create listener, get object-index var l = listener.bind(binding || node.instance || node), index = (SVG.handlerMap.indexOf(node) + 1 || SVG.handlerMap.push(node)) - 1, ev = event.split('.')[0], ns = event.split('.')[1] || '*'; // ensure valid object SVG.listeners[index] = SVG.listeners[index] || {}; SVG.listeners[index][ev] = SVG.listeners[index][ev] || {}; SVG.listeners[index][ev][ns] = SVG.listeners[index][ev][ns] || {}; if (!listener._svgjsListenerId) { listener._svgjsListenerId = ++SVG.listenerId; } // reference listener SVG.listeners[index][ev][ns][listener._svgjsListenerId] = l; // add listener node.addEventListener(ev, l, options || false); }; // Add event unbinder in the SVG namespace SVG.off = function (node, event, listener) { var index = SVG.handlerMap.indexOf(node), ev = event && event.split('.')[0], ns = event && event.split('.')[1], namespace = ''; if (index == -1) return; if (listener) { if (typeof listener === 'function') listener = listener._svgjsListenerId; if (!listener) return; // remove listener reference if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns || '*']) { // remove listener node.removeEventListener(ev, SVG.listeners[index][ev][ns || '*'][listener], false); delete SVG.listeners[index][ev][ns || '*'][listener]; } } else if (ns && ev) { // remove all listeners for a namespaced event if (SVG.listeners[index][ev] && SVG.listeners[index][ev][ns]) { for (listener in SVG.listeners[index][ev][ns]) { SVG.off(node, [ev, ns].join('.'), listener); } delete SVG.listeners[index][ev][ns]; } } else if (ns) { // remove all listeners for a specific namespace for (event in SVG.listeners[index]) { for (namespace in SVG.listeners[index][event]) { if (ns === namespace) { SVG.off(node, [event, ns].join('.')); } } } } else if (ev) { // remove all listeners for the event if (SVG.listeners[index][ev]) { for (namespace in SVG.listeners[index][ev]) { SVG.off(node, [ev, namespace].join('.')); } delete SVG.listeners[index][ev]; } } else { // remove all listeners on a given node for (event in SVG.listeners[index]) { SVG.off(node, event); } delete SVG.listeners[index]; delete SVG.handlerMap[index]; } }; // SVG.extend(SVG.Element, { // Bind given event to listener on: function on(event, listener, binding, options) { SVG.on(this.node, event, listener, binding, options); return this; }, // Unbind event from listener off: function off(event, listener) { SVG.off(this.node, event, listener); return this; }, // Fire given event fire: function fire(event, data) { // Dispatch event if (event instanceof window.Event) { this.node.dispatchEvent(event); } else { this.node.dispatchEvent(event = new SVG.CustomEvent(event, { detail: data, cancelable: true })); } this._event = event; return this; }, event: function event() { return this._event; } }); SVG.Defs = SVG.invent({ // Initialize node create: 'defs', // Inherit from inherit: SVG.Container }); SVG.G = SVG.invent({ // Initialize node create: 'g', // Inherit from inherit: SVG.Container, // Add class methods extend: { // Move over x-axis x: function x(_x3) { return _x3 == null ? this.transform('x') : this.transform({ x: _x3 - this.x() }, true); }, // Move over y-axis y: function y(_y3) { return _y3 == null ? this.transform('y') : this.transform({ y: _y3 - this.y() }, true); }, // Move by center over x-axis cx: function cx(x) { return x == null ? this.gbox().cx : this.x(x - this.gbox().width / 2); }, // Move by center over y-axis cy: function cy(y) { return y == null ? this.gbox().cy : this.y(y - this.gbox().height / 2); }, gbox: function gbox() { var bbox = this.bbox(), trans = this.transform(); bbox.x += trans.x; bbox.x2 += trans.x; bbox.cx += trans.x; bbox.y += trans.y; bbox.y2 += trans.y; bbox.cy += trans.y; return bbox; } }, // Add parent method construct: { // Create a group element group: function group() { return this.put(new SVG.G()); } } }); SVG.Doc = SVG.invent({ // Initialize node create: function create(element) { if (element) { // ensure the presence of a dom element element = typeof element === 'string' ? document.getElementById(element) : element; // If the target is an svg element, use that element as the main wrapper. // This allows svg.js to work with svg documents as well. if (element.nodeName == 'svg') { this.constructor.call(this, element); } else { this.constructor.call(this, SVG.create('svg')); element.appendChild(this.node); this.size('100%', '100%'); } // set svg element attributes and ensure defs node this.namespace().defs(); } }, // Inherit from inherit: SVG.Container, // Add class methods extend: { // Add namespaces namespace: function namespace() { return this.attr({ xmlns: SVG.ns, version: '1.1' }).attr('xmlns:xlink', SVG.xlink, SVG.xmlns).attr('xmlns:svgjs', SVG.svgjs, SVG.xmlns); }, // Creates and returns defs element defs: function defs() { if (!this._defs) { var defs; // Find or create a defs element in this instance if (defs = this.node.getElementsByTagName('defs')[0]) { this._defs = SVG.adopt(defs); } else { this._defs = new SVG.Defs(); } // Make sure the defs node is at the end of the stack this.node.appendChild(this._defs.node); } return this._defs; }, // custom parent method parent: function parent() { if (!this.node.parentNode || this.node.parentNode.nodeName == '#document') return null; return this.node.parentNode; }, // Fix for possible sub-pixel offset. See: // https://bugzilla.mozilla.org/show_bug.cgi?id=608812 spof: function spof() { var pos = this.node.getScreenCTM(); if (pos) { this.style('left', -pos.e % 1 + 'px').style('top', -pos.f % 1 + 'px'); } return this; }, // Removes the doc from the DOM remove: function remove() { if (this.parent()) { this.parent().removeChild(this.node); } return this; }, clear: function clear() { // remove children while (this.node.hasChildNodes()) { this.node.removeChild(this.node.lastChild); } // remove defs reference delete this._defs; // add back parser if (!SVG.parser.draw.parentNode) { this.node.appendChild(SVG.parser.draw); } return this; }, clone: function clone(parent) { // write dom data to the dom so the clone can pickup the data this.writeDataToDom(); // get reference to node var node = this.node; // clone element and assign new id var clone = assignNewId(node.cloneNode(true)); // insert the clone in the given parent or after myself if (parent) { (parent.node || parent).appendChild(clone.node); } else { node.parentNode.insertBefore(clone.node, node.nextSibling); } return clone; } } }); // ### This module adds backward / forward functionality to elements. // SVG.extend(SVG.Element, { // Get all siblings, including myself siblings: function siblings() { return this.parent().children(); }, // Get the curent position siblings position: function position() { return this.parent().index(this); }, // Get the next element (will return null if there is none) next: function next() { return this.siblings()[this.position() + 1]; }, // Get the next element (will return null if there is none) previous: function previous() { return this.siblings()[this.position() - 1]; }, // Send given element one step forward forward: function forward() { var i = this.position() + 1, p = this.parent(); // move node one step forward p.removeElement(this).add(this, i); // make sure defs node is always at the top if (p instanceof SVG.Doc) { p.node.appendChild(p.defs().node); } return this; }, // Send given element one step backward backward: function backward() { var i = this.position(); if (i > 0) { this.parent().removeElement(this).add(this, i - 1); } return this; }, // Send given element all the way to the front front: function front() { var p = this.parent(); // Move node forward p.node.appendChild(this.node); // Make sure defs node is always at the top if (p instanceof SVG.Doc) { p.node.appendChild(p.defs().node); } return this; }, // Send given element all the way to the back back: function back() { if (this.position() > 0) { this.parent().removeElement(this).add(this, 0); } return this; }, // Inserts a given element before the targeted element before: function before(element) { element.remove(); var i = this.position(); this.parent().add(element, i); return this; }, // Insters a given element after the targeted element after: function after(element) { element.remove(); var i = this.position(); this.parent().add(element, i + 1); return this; } }); SVG.Mask = SVG.invent({ // Initialize node create: function create() { this.constructor.call(this, SVG.create('mask')); // keep references to masked elements this.targets = []; }, // Inherit from inherit: SVG.Container, // Add class methods extend: { // Unmask all masked elements and remove itself remove: function remove() { // unmask all targets for (var i = this.targets.length - 1; i >= 0; i--) { if (this.targets[i]) { this.targets[i].unmask(); } } this.targets = []; // remove mask from parent SVG.Element.prototype.remove.call(this); return this; } }, // Add parent method construct: { // Create masking element mask: function mask() { return this.defs().put(new SVG.Mask()); } } }); SVG.extend(SVG.Element, { // Distribute mask to svg element maskWith: function maskWith(element) { // use given mask or create a new one this.masker = element instanceof SVG.Mask ? element : this.parent().mask().add(element); // store reverence on self in mask this.masker.targets.push(this); // apply mask return this.attr('mask', 'url("#' + this.masker.attr('id') + '")'); }, // Unmask element unmask: function unmask() { delete this.masker; return this.attr('mask', null); } }); SVG.ClipPath = SVG.invent({ // Initialize node create: function create() { this.constructor.call(this, SVG.create('clipPath')); // keep references to clipped elements this.targets = []; }, // Inherit from inherit: SVG.Container, // Add class methods extend: { // Unclip all clipped elements and remove itself remove: function remove() { // unclip all targets for (var i = this.targets.length - 1; i >= 0; i--) { if (this.targets[i]) { this.targets[i].unclip(); } } this.targets = []; // remove clipPath from parent this.parent().removeElement(this); return this; } }, // Add parent method construct: { // Create clipping element clip: function clip() { return this.defs().put(new SVG.ClipPath()); } } }); // SVG.extend(SVG.Element, { // Distribute clipPath to svg element clipWith: function clipWith(element) { // use given clip or create a new one this.clipper = element instanceof SVG.ClipPath ? element : this.parent().clip().add(element); // store reverence on self in mask this.clipper.targets.push(this); // apply mask return this.attr('clip-path', 'url("#' + this.clipper.attr('id') + '")'); }, // Unclip element unclip: function unclip() { delete this.clipper; return this.attr('clip-path', null); } }); SVG.Gradient = SVG.invent({ // Initialize node create: function create(type) { this.constructor.call(this, SVG.create(type + 'Gradient')); // store type this.type = type; }, // Inherit from inherit: SVG.Container, // Add class methods extend: { // Add a color stop at: function at(offset, color, opacity) { return this.put(new SVG.Stop()).update(offset, color, opacity); }, // Update gradient update: function update(block) { // remove all stops this.clear(); // invoke passed block if (typeof block === 'function') { block.call(this, this); } return this; }, // Return the fill id fill: function fill() { return 'url(#' + this.id() + ')'; }, // Alias string convertion to fill toString: function toString() { return this.fill(); }, // custom attr to handle transform attr: function attr(a, b, c) { if (a == 'transform') a = 'gradientTransform'; return SVG.Container.prototype.attr.call(this, a, b, c); } }, // Add parent method construct: { // Create gradient element in defs gradient: function gradient(type, block) { return this.defs().gradient(type, block); } } }); // Add animatable methods to both gradient and fx module SVG.extend(SVG.Gradient, SVG.FX, { // From position from: function from(x, y) { return (this._target || this).type == 'radial' ? this.attr({ fx: new SVG.Number(x), fy: new SVG.Number(y) }) : this.attr({ x1: new SVG.Number(x), y1: new SVG.Number(y) }); }, // To position to: function to(x, y) { return (this._target || this).type == 'radial' ? this.attr({ cx: new SVG.Number(x), cy: new SVG.Number(y) }) : this.attr({ x2: new SVG.Number(x), y2: new SVG.Number(y) }); } }); // Base gradient generation SVG.extend(SVG.Defs, { // define gradient gradient: function gradient(type, block) { return this.put(new SVG.Gradient(type)).update(block); } }); SVG.Stop = SVG.invent({ // Initialize node create: 'stop', // Inherit from inherit: SVG.Element, // Add class methods extend: { // add color stops update: function update(o) { if (typeof o === 'number' || o instanceof SVG.Number) { o = { offset: arguments[0], color: arguments[1], opacity: arguments[2] }; } // set attributes if (o.opacity != null) this.attr('stop-opacity', o.opacity); if (o.color != null) this.attr('stop-color', o.color); if (o.offset != null) this.attr('offset', new SVG.Number(o.offset)); return this; } } }); SVG.Pattern = SVG.invent({ // Initialize node create: 'pattern', // Inherit from inherit: SVG.Container, // Add class methods extend: { // Return the fill id fill: function fill() { return 'url(#' + this.id() + ')'; }, // Update pattern by rebuilding update: function update(block) { // remove content this.clear(); // invoke passed block if (typeof block === 'function') { block.call(this, this); } return this; }, // Alias string convertion to fill toString: function toString() { return this.fill(); }, // custom attr to handle transform attr: function attr(a, b, c) { if (a == 'transform') a = 'patternTransform'; return SVG.Container.prototype.attr.call(this, a, b, c); } }, // Add parent method construct: { // Create pattern element in defs pattern: function pattern(width, height, block) { return this.defs().pattern(width, height, block); } } }); SVG.extend(SVG.Defs, { // Define gradient pattern: function pattern(width, height, block) { return this.put(new SVG.Pattern()).update(block).attr({ x: 0, y: 0, width: width, height: height, patternUnits: 'userSpaceOnUse' }); } }); SVG.Shape = SVG.invent({ // Initialize node create: function create(element) { this.constructor.call(this, element); }, // Inherit from inherit: SVG.Element }); SVG.Bare = SVG.invent({ // Initialize create: function create(element, inherit) { // construct element this.constructor.call(this, SVG.create(element)); // inherit custom methods if (inherit) { for (var method in inherit.prototype) { if (typeof inherit.prototype[method] === 'function') { this[method] = inherit.prototype[method]; } } } }, // Inherit from inherit: SVG.Element, // Add methods extend: { // Insert some plain text words: function words(text) { // remove contents while (this.node.hasChildNodes()) { this.node.removeChild(this.node.lastChild); } // create text node this.node.appendChild(document.createTextNode(text)); return this; } } }); SVG.extend(SVG.Parent, { // Create an element that is not described by SVG.js element: function element(_element, inherit) { return this.put(new SVG.Bare(_element, inherit)); } }); SVG.Symbol = SVG.invent({ // Initialize node create: 'symbol', // Inherit from inherit: SVG.Container, construct: { // create symbol symbol: function symbol() { return this.put(new SVG.Symbol()); } } }); SVG.Use = SVG.invent({ // Initialize node create: 'use', // Inherit from inherit: SVG.Shape, // Add class methods extend: { // Use element as a reference element: function element(_element2, file) { // Set lined element return this.attr('href', (file || '') + '#' + _element2, SVG.xlink); } }, // Add parent method construct: { // Create a use element use: function use(element, file) { return this.put(new SVG.Use()).element(element, file); } } }); SVG.Rect = SVG.invent({ // Initialize node create: 'rect', // Inherit from inherit: SVG.Shape, // Add parent method construct: { // Create a rect element rect: function rect(width, height) { return this.put(new SVG.Rect()).size(width, height); } } }); SVG.Circle = SVG.invent({ // Initialize node create: 'circle', // Inherit from inherit: SVG.Shape, // Add parent method construct: { // Create circle element, based on ellipse circle: function circle(size) { return this.put(new SVG.Circle()).rx(new SVG.Number(size).divide(2)).move(0, 0); } } }); SVG.extend(SVG.Circle, SVG.FX, { // Radius x value rx: function rx(_rx) { return this.attr('r', _rx); }, // Alias radius x value ry: function ry(_ry) { return this.rx(_ry); } }); SVG.Ellipse = SVG.invent({ // Initialize node create: 'ellipse', // Inherit from inherit: SVG.Shape, // Add parent method construct: { // Create an ellipse ellipse: function ellipse(width, height) { return this.put(new SVG.Ellipse()).size(width, height).move(0, 0); } } }); SVG.extend(SVG.Ellipse, SVG.Rect, SVG.FX, { // Radius x value rx: function rx(_rx2) { return this.attr('rx', _rx2); }, // Radius y value ry: function ry(_ry2) { return this.attr('ry', _ry2); } }); // Add common method SVG.extend(SVG.Circle, SVG.Ellipse, { // Move over x-axis x: function x(_x4) { return _x4 == null ? this.cx() - this.rx() : this.cx(_x4 + this.rx()); }, // Move over y-axis y: function y(_y4) { return _y4 == null ? this.cy() - this.ry() : this.cy(_y4 + this.ry()); }, // Move by center over x-axis cx: function cx(x) { return x == null ? this.attr('cx') : this.attr('cx', x); }, // Move by center over y-axis cy: function cy(y) { return y == null ? this.attr('cy') : this.attr('cy', y); }, // Set width of element width: function width(_width3) { return _width3 == null ? this.rx() * 2 : this.rx(new SVG.Number(_width3).divide(2)); }, // Set height of element height: function height(_height3) { return _height3 == null ? this.ry() * 2 : this.ry(new SVG.Number(_height3).divide(2)); }, // Custom size function size: function size(width, height) { var p = proportionalSize(this, width, height); return this.rx(new SVG.Number(p.width).divide(2)).ry(new SVG.Number(p.height).divide(2)); } }); SVG.Line = SVG.invent({ // Initialize node create: 'line', // Inherit from inherit: SVG.Shape, // Add class methods extend: { // Get array array: function array() { return new SVG.PointArray([[this.attr('x1'), this.attr('y1')], [this.attr('x2'), this.attr('y2')]]); }, // Overwrite native plot() method plot: function plot(x1, y1, x2, y2) { if (x1 == null) { return this.array(); } else if (typeof y1 !== 'undefined') { x1 = { x1: x1, y1: y1, x2: x2, y2: y2 }; } else { x1 = new SVG.PointArray(x1).toLine(); } return this.attr(x1); }, // Move by left top corner move: function move(x, y) { return this.attr(this.array().move(x, y).toLine()); }, // Set element size to given width and height size: function size(width, height) { var p = proportionalSize(this, width, height); return this.attr(this.array().size(p.width, p.height).toLine()); } }, // Add parent method construct: { // Create a line element line: function line(x1, y1, x2, y2) { // make sure plot is called as a setter // x1 is not necessarily a number, it can also be an array, a string and a SVG.PointArray return SVG.Line.prototype.plot.apply(this.put(new SVG.Line()), x1 != null ? [x1, y1, x2, y2] : [0, 0, 0, 0]); } } }); SVG.Polyline = SVG.invent({ // Initialize node create: 'polyline', // Inherit from inherit: SVG.Shape, // Add parent method construct: { // Create a wrapped polyline element polyline: function polyline(p) { // make sure plot is called as a setter return this.put(new SVG.Polyline()).plot(p || new SVG.PointArray()); } } }); SVG.Polygon = SVG.invent({ // Initialize node create: 'polygon', // Inherit from inherit: SVG.Shape, // Add parent method construct: { // Create a wrapped polygon element polygon: function polygon(p) { // make sure plot is called as a setter return this.put(new SVG.Polygon()).plot(p || new SVG.PointArray()); } } }); // Add polygon-specific functions SVG.extend(SVG.Polyline, SVG.Polygon, { // Get array array: function array() { return this._array || (this._array = new SVG.PointArray(this.attr('points'))); }, // Plot new path plot: function plot(p) { return p == null ? this.array() : this.clear().attr('points', typeof p === 'string' ? p : this._array = new SVG.PointArray(p)); }, // Clear array cache clear: function clear() { delete this._array; return this; }, // Move by left top corner move: function move(x, y) { return this.attr('points', this.array().move(x, y)); }, // Set element size to given width and height size: function size(width, height) { var p = proportionalSize(this, width, height); return this.attr('points', this.array().size(p.width, p.height)); } }); // unify all point to point elements SVG.extend(SVG.Line, SVG.Polyline, SVG.Polygon, { // Define morphable array morphArray: SVG.PointArray, // Move by left top corner over x-axis x: function x(_x5) { return _x5 == null ? this.bbox().x : this.move(_x5, this.bbox().y); }, // Move by left top corner over y-axis y: function y(_y5) { return _y5 == null ? this.bbox().y : this.move(this.bbox().x, _y5); }, // Set width of element width: function width(_width4) { var b = this.bbox(); return _width4 == null ? b.width : this.size(_width4, b.height); }, // Set height of element height: function height(_height4) { var b = this.bbox(); return _height4 == null ? b.height : this.size(b.width, _height4); } }); SVG.Path = SVG.invent({ // Initialize node create: 'path', // Inherit from inherit: SVG.Shape, // Add class methods extend: { // Define morphable array morphArray: SVG.PathArray, // Get array array: function array() { return this._array || (this._array = new SVG.PathArray(this.attr('d'))); }, // Plot new path plot: function plot(d) { return d == null ? this.array() : this.clear().attr('d', typeof d === 'string' ? d : this._array = new SVG.PathArray(d)); }, // Clear array cache clear: function clear() { delete this._array; return this; }, // Move by left top corner move: function move(x, y) { return this.attr('d', this.array().move(x, y)); }, // Move by left top corner over x-axis x: function x(_x6) { return _x6 == null ? this.bbox().x : this.move(_x6, this.bbox().y); }, // Move by left top corner over y-axis y: function y(_y6) { return _y6 == null ? this.bbox().y : this.move(this.bbox().x, _y6); }, // Set element size to given width and height size: function size(width, height) { var p = proportionalSize(this, width, height); return this.attr('d', this.array().size(p.width, p.height)); }, // Set width of element width: function width(_width5) { return _width5 == null ? this.bbox().width : this.size(_width5, this.bbox().height); }, // Set height of element height: function height(_height5) { return _height5 == null ? this.bbox().height : this.size(this.bbox().width, _height5); } }, // Add parent method construct: { // Create a wrapped path element path: function path(d) { // make sure plot is called as a setter return this.put(new SVG.Path()).plot(d || new SVG.PathArray()); } } }); SVG.Image = SVG.invent({ // Initialize node create: 'image', // Inherit from inherit: SVG.Shape, // Add class methods extend: { // (re)load image load: function load(url) { if (!url) return this; var self = this, img = new window.Image(); // preload image SVG.on(img, 'load', function () { SVG.off(img); var p = self.parent(SVG.Pattern); if (p === null) return; // ensure image size if (self.width() == 0 && self.height() == 0) { self.size(img.width, img.height); } // ensure pattern size if not set if (p && p.width() == 0 && p.height() == 0) { p.size(self.width(), self.height()); } // callback if (typeof self._loaded === 'function') { self._loaded.call(self, { width: img.width, height: img.height, ratio: img.width / img.height, url: url }); } }); SVG.on(img, 'error', function (e) { SVG.off(img); if (typeof self._error === 'function') { self._error.call(self, e); } }); return this.attr('href', img.src = this.src = url, SVG.xlink); }, // Add loaded callback loaded: function loaded(_loaded) { this._loaded = _loaded; return this; }, error: function error(_error) { this._error = _error; return this; } }, // Add parent method construct: { // create image element, load image and set its size image: function image(source, width, height) { return this.put(new SVG.Image()).load(source).size(width || 0, height || width || 0); } } }); SVG.Text = SVG.invent({ // Initialize node create: function create() { this.constructor.call(this, SVG.create('text')); this.dom.leading = new SVG.Number(1.3); // store leading value for rebuilding this._rebuild = true; // enable automatic updating of dy values this._build = false; // disable build mode for adding multiple lines // set default font this.attr('font-family', SVG.defaults.attrs['font-family']); }, // Inherit from inherit: SVG.Shape, // Add class methods extend: { // Move over x-axis x: function x(_x7) { // act as getter if (_x7 == null) { return this.attr('x'); } return this.attr('x', _x7); }, // Move over y-axis y: function y(_y7) { var oy = this.attr('y'), o = typeof oy === 'number' ? oy - this.bbox().y : 0; // act as getter if (_y7 == null) { return typeof oy === 'number' ? oy - o : oy; } return this.attr('y', typeof _y7.valueOf() === 'number' ? _y7 + o : _y7); }, // Move center over x-axis cx: function cx(x) { return x == null ? this.bbox().cx : this.x(x - this.bbox().width / 2); }, // Move center over y-axis cy: function cy(y) { return y == null ? this.bbox().cy : this.y(y - this.bbox().height / 2); }, // Set the text content text: function text(text) { // act as getter if (typeof text === 'undefined') { var text = ''; var children = this.node.childNodes; for (var i = 0, len = children.length; i < len; ++i) { // add newline if its not the first child and newLined is set to true if (i != 0 && children[i].nodeType != 3 && SVG.adopt(children[i]).dom.newLined == true) { text += '\n'; } // add content of this node text += children[i].textContent; } return text; } // remove existing content this.clear().build(true); if (typeof text === 'function') { // call block text.call(this, this); } else { // store text and make sure text is not blank text = text.split('\n'); // build new lines for (var i = 0, il = text.length; i < il; i++) { this.tspan(text[i]).newLine(); } } // disable build mode and rebuild lines return this.build(false).rebuild(); }, // Set font size size: function size(_size) { return this.attr('font-size', _size).rebuild(); }, // Set / get leading leading: function leading(value) { // act as getter if (value == null) { return this.dom.leading; } // act as setter this.dom.leading = new SVG.Number(value); return this.rebuild(); }, // Get all the first level lines lines: function lines() { var node = (this.textPath && this.textPath() || this).node; // filter tspans and map them to SVG.js instances var lines = SVG.utils.map(SVG.utils.filterSVGElements(node.childNodes), function (el) { return SVG.adopt(el); }); // return an instance of SVG.set return new SVG.Set(lines); }, // Rebuild appearance type rebuild: function rebuild(_rebuild) { // store new rebuild flag if given if (typeof _rebuild === 'boolean') { this._rebuild = _rebuild; } // define position of all lines if (this._rebuild) { var self = this, blankLineOffset = 0, dy = this.dom.leading * new SVG.Number(this.attr('font-size')); this.lines().each(function () { if (this.dom.newLined) { if (!self.textPath()) { this.attr('x', self.attr('x')); } if (this.text() == '\n') { blankLineOffset += dy; } else { this.attr('dy', dy + blankLineOffset); blankLineOffset = 0; } } }); this.fire('rebuild'); } return this; }, // Enable / disable build mode build: function build(_build) { this._build = !!_build; return this; }, // overwrite method from parent to set data properly setData: function setData(o) { this.dom = o; this.dom.leading = new SVG.Number(o.leading || 1.3); return this; } }, // Add parent method construct: { // Create text element text: function text(_text) { return this.put(new SVG.Text()).text(_text); }, // Create plain text element plain: function plain(text) { return this.put(new SVG.Text()).plain(text); } } }); SVG.Tspan = SVG.invent({ // Initialize node create: 'tspan', // Inherit from inherit: SVG.Shape, // Add class methods extend: { // Set text content text: function text(_text2) { if (_text2 == null) return this.node.textContent + (this.dom.newLined ? '\n' : ''); typeof _text2 === 'function' ? _text2.call(this, this) : this.plain(_text2); return this; }, // Shortcut dx dx: function dx(_dx) { return this.attr('dx', _dx); }, // Shortcut dy dy: function dy(_dy) { return this.attr('dy', _dy); }, // Create new line newLine: function newLine() { // fetch text parent var t = this.parent(SVG.Text); // mark new line this.dom.newLined = true; // apply new hy¡n return this.dy(t.dom.leading * t.attr('font-size')).attr('x', t.x()); } } }); SVG.extend(SVG.Text, SVG.Tspan, { // Create plain text node plain: function plain(text) { // clear if build mode is disabled if (this._build === false) { this.clear(); } // create text node this.node.appendChild(document.createTextNode(text)); return this; }, // Create a tspan tspan: function tspan(text) { var node = (this.textPath && this.textPath() || this).node, tspan = new SVG.Tspan(); // clear if build mode is disabled if (this._build === false) { this.clear(); } // add new tspan node.appendChild(tspan.node); return tspan.text(text); }, // Clear all lines clear: function clear() { var node = (this.textPath && this.textPath() || this).node; // remove existing child nodes while (node.hasChildNodes()) { node.removeChild(node.lastChild); } return this; }, // Get length of text element length: function length() { return this.node.getComputedTextLength(); } }); SVG.TextPath = SVG.invent({ // Initialize node create: 'textPath', // Inherit from inherit: SVG.Parent, // Define parent class parent: SVG.Text, // Add parent method construct: { morphArray: SVG.PathArray, // Create path for text to run on path: function path(d) { // create textPath element var path = new SVG.TextPath(), track = this.doc().defs().path(d); // move lines to textpath while (this.node.hasChildNodes()) { path.node.appendChild(this.node.firstChild); } // add textPath element as child node this.node.appendChild(path.node); // link textPath to path and add content path.attr('href', '#' + track, SVG.xlink); return this; }, // return the array of the path track element array: function array() { var track = this.track(); return track ? track.array() : null; }, // Plot path if any plot: function plot(d) { var track = this.track(), pathArray = null; if (track) { pathArray = track.plot(d); } return d == null ? pathArray : this; }, // Get the path track element track: function track() { var path = this.textPath(); if (path) { return path.reference('href'); } }, // Get the textPath child textPath: function textPath() { if (this.node.firstChild && this.node.firstChild.nodeName == 'textPath') { return SVG.adopt(this.node.firstChild); } } } }); SVG.Nested = SVG.invent({ // Initialize node create: function create() { this.constructor.call(this, SVG.create('svg')); this.style('overflow', 'visible'); }, // Inherit from inherit: SVG.Container, // Add parent method construct: { // Create nested svg document nested: function nested() { return this.put(new SVG.Nested()); } } }); SVG.A = SVG.invent({ // Initialize node create: 'a', // Inherit from inherit: SVG.Container, // Add class methods extend: { // Link url to: function to(url) { return this.attr('href', url, SVG.xlink); }, // Link show attribute show: function show(target) { return this.attr('show', target, SVG.xlink); }, // Link target attribute target: function target(_target2) { return this.attr('target', _target2); } }, // Add parent method construct: { // Create a hyperlink element link: function link(url) { return this.put(new SVG.A()).to(url); } } }); SVG.extend(SVG.Element, { // Create a hyperlink element linkTo: function linkTo(url) { var link = new SVG.A(); if (typeof url === 'function') { url.call(link, link); } else { link.to(url); } return this.parent().put(link).put(this); } }); SVG.Marker = SVG.invent({ // Initialize node create: 'marker', // Inherit from inherit: SVG.Container, // Add class methods extend: { // Set width of element width: function width(_width6) { return this.attr('markerWidth', _width6); }, // Set height of element height: function height(_height6) { return this.attr('markerHeight', _height6); }, // Set marker refX and refY ref: function ref(x, y) { return this.attr('refX', x).attr('refY', y); }, // Update marker update: function update(block) { // remove all content this.clear(); // invoke passed block if (typeof block === 'function') { block.call(this, this); } return this; }, // Return the fill id toString: function toString() { return 'url(#' + this.id() + ')'; } }, // Add parent method construct: { marker: function marker(width, height, block) { // Create marker element in defs return this.defs().marker(width, height, block); } } }); SVG.extend(SVG.Defs, { // Create marker marker: function marker(width, height, block) { // Set default viewbox to match the width and height, set ref to cx and cy and set orient to auto return this.put(new SVG.Marker()).size(width, height).ref(width / 2, height / 2).viewbox(0, 0, width, height).attr('orient', 'auto').update(block); } }); SVG.extend(SVG.Line, SVG.Polyline, SVG.Polygon, SVG.Path, { // Create and attach markers marker: function marker(_marker, width, height, block) { var attr = ['marker']; // Build attribute name if (_marker != 'all') attr.push(_marker); attr = attr.join('-'); // Set marker attribute _marker = arguments[1] instanceof SVG.Marker ? arguments[1] : this.doc().marker(width, height, block); return this.attr(attr, _marker); } }); // Define list of available attributes for stroke and fill var sugar = { stroke: ['color', 'width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset'], fill: ['color', 'opacity', 'rule'], prefix: function prefix(t, a) { return a == 'color' ? t : t + '-' + a; } // Add sugar for fill and stroke };['fill', 'stroke'].forEach(function (m) { var i, extension = {}; extension[m] = function (o) { if (typeof o === 'undefined') { return this; } if (typeof o === 'string' || SVG.Color.isRgb(o) || o && typeof o.fill === 'function') { this.attr(m, o); } else // set all attributes from sugar.fill and sugar.stroke list { for (i = sugar[m].length - 1; i >= 0; i--) { if (o[sugar[m][i]] != null) { this.attr(sugar.prefix(m, sugar[m][i]), o[sugar[m][i]]); } } } return this; }; SVG.extend(SVG.Element, SVG.FX, extension); }); SVG.extend(SVG.Element, SVG.FX, { // Map rotation to transform rotate: function rotate(d, cx, cy) { return this.transform({ rotation: d, cx: cx, cy: cy }); }, // Map skew to transform skew: function skew(x, y, cx, cy) { return arguments.length == 1 || arguments.length == 3 ? this.transform({ skew: x, cx: y, cy: cx }) : this.transform({ skewX: x, skewY: y, cx: cx, cy: cy }); }, // Map scale to transform scale: function scale(x, y, cx, cy) { return arguments.length == 1 || arguments.length == 3 ? this.transform({ scale: x, cx: y, cy: cx }) : this.transform({ scaleX: x, scaleY: y, cx: cx, cy: cy }); }, // Map translate to transform translate: function translate(x, y) { return this.transform({ x: x, y: y }); }, // Map flip to transform flip: function flip(a, o) { o = typeof a === 'number' ? a : o; return this.transform({ flip: a || 'both', offset: o }); }, // Map matrix to transform matrix: function matrix(m) { return this.attr('transform', new SVG.Matrix(arguments.length == 6 ? [].slice.call(arguments) : m)); }, // Opacity opacity: function opacity(value) { return this.attr('opacity', value); }, // Relative move over x axis dx: function dx(x) { return this.x(new SVG.Number(x).plus(this instanceof SVG.FX ? 0 : this.x()), true); }, // Relative move over y axis dy: function dy(y) { return this.y(new SVG.Number(y).plus(this instanceof SVG.FX ? 0 : this.y()), true); }, // Relative move over x and y axes dmove: function dmove(x, y) { return this.dx(x).dy(y); } }); SVG.extend(SVG.Rect, SVG.Ellipse, SVG.Circle, SVG.Gradient, SVG.FX, { // Add x and y radius radius: function radius(x, y) { var type = (this._target || this).type; return type == 'radial' || type == 'circle' ? this.attr('r', new SVG.Number(x)) : this.rx(x).ry(y == null ? x : y); } }); SVG.extend(SVG.Path, { // Get path length length: function length() { return this.node.getTotalLength(); }, // Get point at length pointAt: function pointAt(length) { return this.node.getPointAtLength(length); } }); SVG.extend(SVG.Parent, SVG.Text, SVG.Tspan, SVG.FX, { // Set font font: function font(a, v) { if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'object') { for (v in a) { this.font(v, a[v]); } } return a == 'leading' ? this.leading(v) : a == 'anchor' ? this.attr('text-anchor', v) : a == 'size' || a == 'family' || a == 'weight' || a == 'stretch' || a == 'variant' || a == 'style' ? this.attr('font-' + a, v) : this.attr(a, v); } }); SVG.Set = SVG.invent({ // Initialize create: function create(members) { // Set initial state Array.isArray(members) ? this.members = members : this.clear(); }, // Add class methods extend: { // Add element to set add: function add() { var i, il, elements = [].slice.call(arguments); for (i = 0, il = elements.length; i < il; i++) { this.members.push(elements[i]); } return this; }, // Remove element from set remove: function remove(element) { var i = this.index(element); // remove given child if (i > -1) { this.members.splice(i, 1); } return this; }, // Iterate over all members each: function each(block) { for (var i = 0, il = this.members.length; i < il; i++) { block.apply(this.members[i], [i, this.members]); } return this; }, // Restore to defaults clear: function clear() { // initialize store this.members = []; return this; }, // Get the length of a set length: function length() { return this.members.length; }, // Checks if a given element is present in set has: function has(element) { return this.index(element) >= 0; }, // retuns index of given element in set index: function index(element) { return this.members.indexOf(element); }, // Get member at given index get: function get(i) { return this.members[i]; }, // Get first member first: function first() { return this.get(0); }, // Get last member last: function last() { return this.get(this.members.length - 1); }, // Default value valueOf: function valueOf() { return this.members; }, // Get the bounding box of all members included or empty box if set has no items bbox: function bbox() { // return an empty box of there are no members if (this.members.length == 0) { return new SVG.RBox(); } // get the first rbox and update the target bbox var rbox = this.members[0].rbox(this.members[0].doc()); this.each(function () { // user rbox for correct position and visual representation rbox = rbox.merge(this.rbox(this.doc())); }); return rbox; } }, // Add parent method construct: { // Create a new set set: function set(members) { return new SVG.Set(members); } } }); SVG.FX.Set = SVG.invent({ // Initialize node create: function create(set) { // store reference to set this.set = set; } }); // Alias methods SVG.Set.inherit = function () { var m, methods = []; // gather shape methods for (var m in SVG.Shape.prototype) { if (typeof SVG.Shape.prototype[m] === 'function' && typeof SVG.Set.prototype[m] !== 'function') { methods.push(m); } } // apply shape aliasses methods.forEach(function (method) { SVG.Set.prototype[method] = function () { for (var i = 0, il = this.members.length; i < il; i++) { if (this.members[i] && typeof this.members[i][method] === 'function') { this.members[i][method].apply(this.members[i], arguments); } } return method == 'animate' ? this.fx || (this.fx = new SVG.FX.Set(this)) : this; }; }); // clear methods for the next round methods = []; // gather fx methods for (var m in SVG.FX.prototype) { if (typeof SVG.FX.prototype[m] === 'function' && typeof SVG.FX.Set.prototype[m] !== 'function') { methods.push(m); } } // apply fx aliasses methods.forEach(function (method) { SVG.FX.Set.prototype[method] = function () { for (var i = 0, il = this.set.members.length; i < il; i++) { this.set.members[i].fx[method].apply(this.set.members[i].fx, arguments); } return this; }; }); }; SVG.extend(SVG.Element, { // Store data values on svg nodes data: function data(a, v, r) { if ((typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'object') { for (v in a) { this.data(v, a[v]); } } else if (arguments.length < 2) { try { return JSON.parse(this.attr('data-' + a)); } catch (e) { return this.attr('data-' + a); } } else { this.attr('data-' + a, v === null ? null : r === true || typeof v === 'string' || typeof v === 'number' ? v : JSON.stringify(v)); } return this; } }); SVG.extend(SVG.Element, { // Remember arbitrary data remember: function remember(k, v) { // remember every item in an object individually if (_typeof(arguments[0]) === 'object') { for (var v in k) { this.remember(v, k[v]); } } // retrieve memory else if (arguments.length == 1) { return this.memory()[k]; } // store memory else { this.memory()[k] = v; } return this; }, // Erase a given memory forget: function forget() { if (arguments.length == 0) { this._memory = {}; } else { for (var i = arguments.length - 1; i >= 0; i--) { delete this.memory()[arguments[i]]; } } return this; }, // Initialize or return local memory object memory: function memory() { return this._memory || (this._memory = {}); } }); // Method for getting an element by id SVG.get = function (id) { var node = document.getElementById(idFromReference(id) || id); return SVG.adopt(node); }; // Select elements by query string SVG.select = function (query, parent) { return new SVG.Set(SVG.utils.map((parent || document).querySelectorAll(query), function (node) { return SVG.adopt(node); })); }; SVG.extend(SVG.Parent, { // Scoped select method select: function select(query) { return SVG.select(query, this.node); } }); function pathRegReplace(a, b, c, d) { return c + d.replace(SVG.regex.dots, ' .'); } // creates deep clone of array function array_clone(arr) { var clone = arr.slice(0); for (var i = clone.length; i--;) { if (Array.isArray(clone[i])) { clone[i] = array_clone(clone[i]); } } return clone; } // tests if a given element is instance of an object function _is(el, obj) { return el instanceof obj; } // tests if a given selector matches an element function _matches(el, selector) { return (el.matches || el.matchesSelector || el.msMatchesSelector || el.mozMatchesSelector || el.webkitMatchesSelector || el.oMatchesSelector).call(el, selector); } // Convert dash-separated-string to camelCase function camelCase(s) { return s.toLowerCase().replace(/-(.)/g, function (m, g) { return g.toUpperCase(); }); } // Capitalize first letter of a string function capitalize(s) { return s.charAt(0).toUpperCase() + s.slice(1); } // Ensure to six-based hex function fullHex(hex) { return hex.length == 4 ? ['#', hex.substring(1, 2), hex.substring(1, 2), hex.substring(2, 3), hex.substring(2, 3), hex.substring(3, 4), hex.substring(3, 4)].join('') : hex; } // Component to hex value function compToHex(comp) { var hex = comp.toString(16); return hex.length == 1 ? '0' + hex : hex; } // Calculate proportional width and height values when necessary function proportionalSize(element, width, height) { if (width == null || height == null) { var box = element.bbox(); if (width == null) { width = box.width / box.height * height; } else if (height == null) { height = box.height / box.width * width; } } return { width: width, height: height }; } // Delta transform point function deltaTransformPoint(matrix, x, y) { return { x: x * matrix.a + y * matrix.c + 0, y: x * matrix.b + y * matrix.d + 0 }; } // Map matrix array to object function arrayToMatrix(a) { return { a: a[0], b: a[1], c: a[2], d: a[3], e: a[4], f: a[5] }; } // Parse matrix if required function parseMatrix(matrix) { if (!(matrix instanceof SVG.Matrix)) { matrix = new SVG.Matrix(matrix); } return matrix; } // Add centre point to transform object function ensureCentre(o, target) { o.cx = o.cx == null ? target.bbox().cx : o.cx; o.cy = o.cy == null ? target.bbox().cy : o.cy; } // PathArray Helpers function arrayToString(a) { for (var i = 0, il = a.length, s = ''; i < il; i++) { s += a[i][0]; if (a[i][1] != null) { s += a[i][1]; if (a[i][2] != null) { s += ' '; s += a[i][2]; if (a[i][3] != null) { s += ' '; s += a[i][3]; s += ' '; s += a[i][4]; if (a[i][5] != null) { s += ' '; s += a[i][5]; s += ' '; s += a[i][6]; if (a[i][7] != null) { s += ' '; s += a[i][7]; } } } } } } return s + ' '; } // Deep new id assignment function assignNewId(node) { // do the same for SVG child nodes as well for (var i = node.childNodes.length - 1; i >= 0; i--) { if (node.childNodes[i] instanceof window.SVGElement) { assignNewId(node.childNodes[i]); } } return SVG.adopt(node).id(SVG.eid(node.nodeName)); } // Add more bounding box properties function fullBox(b) { if (b.x == null) { b.x = 0; b.y = 0; b.width = 0; b.height = 0; } b.w = b.width; b.h = b.height; b.x2 = b.x + b.width; b.y2 = b.y + b.height; b.cx = b.x + b.width / 2; b.cy = b.y + b.height / 2; return b; } // Get id from reference string function idFromReference(url) { var m = (url || '').toString().match(SVG.regex.reference); if (m) return m[1]; } // If values like 1e-88 are passed, this is not a valid 32 bit float, // but in those cases, we are so close to 0 that 0 works well! function float32String(v) { return Math.abs(v) > 1e-37 ? v : 0; } // Create matrix array for looping var abcdef = 'abcdef'.split(''); // Add CustomEvent to IE9 and IE10 if (typeof window.CustomEvent !== 'function') { // Code from: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent var CustomEventPoly = function CustomEventPoly(event, options) { options = options || { bubbles: false, cancelable: false, detail: undefined }; var e = document.createEvent('CustomEvent'); e.initCustomEvent(event, options.bubbles, options.cancelable, options.detail); return e; }; CustomEventPoly.prototype = window.Event.prototype; SVG.CustomEvent = CustomEventPoly; } else { SVG.CustomEvent = window.CustomEvent; } // requestAnimationFrame / cancelAnimationFrame Polyfill with fallback based on Paul Irish (function (w) { var lastTime = 0; var vendors = ['moz', 'webkit']; for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { w.requestAnimationFrame = w[vendors[x] + 'RequestAnimationFrame']; w.cancelAnimationFrame = w[vendors[x] + 'CancelAnimationFrame'] || w[vendors[x] + 'CancelRequestAnimationFrame']; } w.requestAnimationFrame = w.requestAnimationFrame || function (callback) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); var id = w.setTimeout(function () { callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; }; w.cancelAnimationFrame = w.cancelAnimationFrame || w.clearTimeout; })(window); return SVG; }); /***/ }), /* 155 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* * classList.js: Cross-browser full element.classList implementation. * 1.2.20171210 * * By Eli Grey, http://eligrey.com * License: Dedicated to the public domain. * See https://github.com/eligrey/classList.js/blob/master/LICENSE.md */ /*global self, document, DOMException */ /*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */ if ("document" in self) { // Full polyfill for browsers with no classList support // Including IE < Edge missing SVGElement.classList if (!("classList" in document.createElement("_")) || document.createElementNS && !("classList" in document.createElementNS("http://www.w3.org/2000/svg", "g"))) { (function (view) { "use strict"; if (!('Element' in view)) return; var classListProp = "classList", protoProp = "prototype", elemCtrProto = view.Element[protoProp], objCtr = Object, strTrim = String[protoProp].trim || function () { return this.replace(/^\s+|\s+$/g, ""); }, arrIndexOf = Array[protoProp].indexOf || function (item) { var i = 0, len = this.length; for (; i < len; i++) { if (i in this && this[i] === item) { return i; } } return -1; } // Vendors: please allow content code to instantiate DOMExceptions , DOMEx = function DOMEx(type, message) { this.name = type; this.code = DOMException[type]; this.message = message; }, checkTokenAndGetIndex = function checkTokenAndGetIndex(classList, token) { if (token === "") { throw new DOMEx("SYNTAX_ERR", "The token must not be empty."); } if (/\s/.test(token)) { throw new DOMEx("INVALID_CHARACTER_ERR", "The token must not contain space characters."); } return arrIndexOf.call(classList, token); }, ClassList = function ClassList(elem) { var trimmedClasses = strTrim.call(elem.getAttribute("class") || ""), classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [], i = 0, len = classes.length; for (; i < len; i++) { this.push(classes[i]); } this._updateClassName = function () { elem.setAttribute("class", this.toString()); }; }, classListProto = ClassList[protoProp] = [], classListGetter = function classListGetter() { return new ClassList(this); }; // Most DOMException implementations don't allow calling DOMException's toString() // on non-DOMExceptions. Error's toString() is sufficient here. DOMEx[protoProp] = Error[protoProp]; classListProto.item = function (i) { return this[i] || null; }; classListProto.contains = function (token) { return ~checkTokenAndGetIndex(this, token + ""); }; classListProto.add = function () { var tokens = arguments, i = 0, l = tokens.length, token, updated = false; do { token = tokens[i] + ""; if (!~checkTokenAndGetIndex(this, token)) { this.push(token); updated = true; } } while (++i < l); if (updated) { this._updateClassName(); } }; classListProto.remove = function () { var tokens = arguments, i = 0, l = tokens.length, token, updated = false, index; do { token = tokens[i] + ""; index = checkTokenAndGetIndex(this, token); while (~index) { this.splice(index, 1); updated = true; index = checkTokenAndGetIndex(this, token); } } while (++i < l); if (updated) { this._updateClassName(); } }; classListProto.toggle = function (token, force) { var result = this.contains(token), method = result ? force !== true && "remove" : force !== false && "add"; if (method) { this[method](token); } if (force === true || force === false) { return force; } else { return !result; } }; classListProto.replace = function (token, replacement_token) { var index = checkTokenAndGetIndex(token + ""); if (~index) { this.splice(index, 1, replacement_token); this._updateClassName(); } }; classListProto.toString = function () { return this.join(" "); }; if (objCtr.defineProperty) { var classListPropDesc = { get: classListGetter, enumerable: true, configurable: true }; try { objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); } catch (ex) { // IE 8 doesn't support enumerable:true // adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36 // modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected if (ex.number === undefined || ex.number === -0x7FF5EC54) { classListPropDesc.enumerable = false; objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); } } } else if (objCtr[protoProp].__defineGetter__) { elemCtrProto.__defineGetter__(classListProp, classListGetter); } })(self); } // There is full or partial native classList support, so just check if we need // to normalize the add/remove and toggle APIs. (function () { "use strict"; var testElement = document.createElement("_"); testElement.classList.add("c1", "c2"); // Polyfill for IE 10/11 and Firefox <26, where classList.add and // classList.remove exist but support only one argument at a time. if (!testElement.classList.contains("c2")) { var createMethod = function createMethod(method) { var original = DOMTokenList.prototype[method]; DOMTokenList.prototype[method] = function (token) { var i, len = arguments.length; for (i = 0; i < len; i++) { token = arguments[i]; original.call(this, token); } }; }; createMethod('add'); createMethod('remove'); } testElement.classList.toggle("c3", false); // Polyfill for IE 10 and Firefox <24, where classList.toggle does not // support the second argument. if (testElement.classList.contains("c3")) { var _toggle = DOMTokenList.prototype.toggle; DOMTokenList.prototype.toggle = function (token, force) { if (1 in arguments && !this.contains(token) === !force) { return force; } else { return _toggle.call(this, token); } }; } // replace() polyfill if (!("replace" in document.createElement("_").classList)) { DOMTokenList.prototype.replace = function (token, replacement_token) { var tokens = this.toString().split(" "), index = tokens.indexOf(token + ""); if (~index) { tokens = tokens.slice(index); this.remove.apply(this, tokens); this.add(replacement_token); this.add.apply(this, tokens.slice(1)); } }; } testElement = null; })(); } /***/ }), /* 156 */ /***/ (function(module, exports, __webpack_require__) { exports = module.exports = __webpack_require__(124)(false); // imports // module exports.push([module.i, ".apexcharts-canvas {\n position: relative;\n user-select: none;\n /* cannot give overflow: hidden as it will crop tooltips which overflow outside chart are */\n /* overflow: hidden; */\n}\n\n.apexcharts-inner {\n position: relative;\n}\n\n.apexcharts-legend-series {\n cursor: pointer;\n}\n\n.apexcharts-legend-series.no-click {\n cursor: auto;\n}\n\n.inactive-legend {\n opacity: 0.45;\n}\n\n.legend-mouseover-inactive {\n transition: 0.15s ease all;\n opacity: 0.20;\n}\n\n.apexcharts-series-collapsed {\n opacity: 0;\n}\n\n.apexcharts-gridline, .apexcharts-text {\n pointer-events: none;\n}\n\n.apexcharts-tooltip {\n border-radius: 5px;\n box-shadow: 2px 2px 6px -4px #999;\n cursor: default;\n font-size: 14px;\n left: 62px;\n opacity: 0;\n pointer-events: none;\n position: absolute;\n top: 20px;\n overflow: hidden;\n white-space: nowrap;\n z-index: 12;\n transition: 0.15s ease all;\n}\n.apexcharts-tooltip.light {\n border: 1px solid #e3e3e3;\n background: rgba(255, 255, 255, 0.96);\n}\n.apexcharts-tooltip.dark {\n color: #fff;\n background: rgba(30,30,30, 0.8);\n}\n\n.apexcharts-tooltip .apexcharts-marker,\n.apexcharts-area-series .apexcharts-area,\n.apexcharts-line {\n pointer-events: none;\n}\n\n.apexcharts-tooltip.active {\n opacity: 1;\n transition: 0.15s ease all;\n}\n\n.apexcharts-tooltip-title {\n padding: 6px;\n font-size: 15px;\n margin-bottom: 4px;\n}\n.apexcharts-tooltip.light .apexcharts-tooltip-title {\n background: #ECEFF1;\n border-bottom: 1px solid #ddd;\n}\n.apexcharts-tooltip.dark .apexcharts-tooltip-title {\n background: rgba(0, 0, 0, 0.7);\n border-bottom: 1px solid #222;\n}\n\n.apexcharts-tooltip-text-value,\n.apexcharts-tooltip-text-z-value {\n display: inline-block;\n font-weight: 600;\n margin-left: 5px;\n}\n\n.apexcharts-tooltip-text-z-label:empty,\n.apexcharts-tooltip-text-z-value:empty {\n display: none;\n}\n\n.apexcharts-tooltip-text-value, \n.apexcharts-tooltip-text-z-value {\n font-weight: 600;\n}\n\n.apexcharts-tooltip-marker {\n width: 12px;\n height: 12px;\n position: relative;\n top: 1px;\n margin-right: 10px;\n border-radius: 50%;\n}\n\n.apexcharts-tooltip-series-group {\n padding: 0 10px;\n display: none;\n text-align: left;\n justify-content: left;\n align-items: center;\n}\n\n.apexcharts-tooltip-series-group.active .apexcharts-tooltip-marker {\n opacity: 1;\n}\n.apexcharts-tooltip-series-group.active, .apexcharts-tooltip-series-group:last-child {\n padding-bottom: 4px;\n}\n.apexcharts-tooltip-y-group {\n padding: 6px 0 5px;\n}\n.apexcharts-tooltip-candlestick {\n padding: 4px 8px;\n}\n.apexcharts-tooltip-candlestick > div {\n margin: 4px 0;\n}\n.apexcharts-tooltip-candlestick span.value {\n font-weight: bold;\n}\n\n.apexcharts-xaxistooltip {\n opacity: 0;\n padding: 9px 10px;\n pointer-events: none;\n color: #373d3f;\n font-size: 13px;\n text-align: center;\n border-radius: 2px;\n position: absolute;\n z-index: 10;\n\tbackground: #ECEFF1;\n border: 1px solid #90A4AE;\n transition: 0.15s ease all;\n}\n\n.apexcharts-xaxistooltip:after, .apexcharts-xaxistooltip:before {\n\tleft: 50%;\n\tborder: solid transparent;\n\tcontent: \" \";\n\theight: 0;\n\twidth: 0;\n\tposition: absolute;\n\tpointer-events: none;\n}\n\n.apexcharts-xaxistooltip:after {\n\tborder-color: rgba(236, 239, 241, 0);\n\tborder-width: 6px;\n\tmargin-left: -6px;\n}\n.apexcharts-xaxistooltip:before {\n\tborder-color: rgba(144, 164, 174, 0);\n\tborder-width: 7px;\n\tmargin-left: -7px;\n}\n\n.apexcharts-xaxistooltip-bottom:after, .apexcharts-xaxistooltip-bottom:before {\n bottom: 100%;\n}\n\n.apexcharts-xaxistooltip-bottom:after {\n border-bottom-color: #ECEFF1;\n}\n.apexcharts-xaxistooltip-bottom:before {\n border-bottom-color: #90A4AE;\n}\n\n.apexcharts-xaxistooltip-top:after, .apexcharts-xaxistooltip-top:before {\n top: 100%;\n}\n.apexcharts-xaxistooltip-top:after {\n border-top-color: #ECEFF1;\n}\n.apexcharts-xaxistooltip-top:before {\n border-top-color: #90A4AE;\n}\n\n.apexcharts-xaxistooltip.active {\n opacity: 1;\n transition: 0.15s ease all;\n}\n\n.apexcharts-yaxistooltip {\n opacity: 0;\n padding: 4px 10px;\n pointer-events: none;\n color: #373d3f;\n font-size: 13px;\n text-align: center;\n border-radius: 2px;\n position: absolute;\n z-index: 10;\n\tbackground: #ECEFF1;\n border: 1px solid #90A4AE;\n}\n\n.apexcharts-yaxistooltip:after, .apexcharts-yaxistooltip:before {\n\ttop: 50%;\n\tborder: solid transparent;\n\tcontent: \" \";\n\theight: 0;\n\twidth: 0;\n\tposition: absolute;\n\tpointer-events: none;\n}\n.apexcharts-yaxistooltip:after {\n\tborder-color: rgba(236, 239, 241, 0);\n\tborder-width: 6px;\n\tmargin-top: -6px;\n}\n.apexcharts-yaxistooltip:before {\n\tborder-color: rgba(144, 164, 174, 0);\n\tborder-width: 7px;\n\tmargin-top: -7px;\n}\n\n.apexcharts-yaxistooltip-left:after, .apexcharts-yaxistooltip-left:before {\n left: 100%;\n}\n.apexcharts-yaxistooltip-left:after {\n border-left-color: #ECEFF1;\n}\n.apexcharts-yaxistooltip-left:before {\n border-left-color: #90A4AE;\n}\n\n.apexcharts-yaxistooltip-right:after, .apexcharts-yaxistooltip-right:before {\n right: 100%;\n}\n.apexcharts-yaxistooltip-right:after {\n border-right-color: #ECEFF1;\n}\n.apexcharts-yaxistooltip-right:before {\n border-right-color: #90A4AE;\n}\n\n.apexcharts-yaxistooltip.active {\n opacity: 1;\n}\n\n.apexcharts-xcrosshairs, .apexcharts-ycrosshairs {\n pointer-events: none;\n opacity: 0;\n transition: 0.15s ease all;\n}\n\n.apexcharts-xcrosshairs.active, .apexcharts-ycrosshairs.active {\n opacity: 1;\n transition: 0.15s ease all;\n}\n\n.apexcharts-ycrosshairs-hidden {\n opacity: 0;\n}\n\n.apexcharts-zoom-rect {\n pointer-events: none;\n}\n.apexcharts-selection-rect {\n cursor: move;\n}\n\n.svg_select_points, .svg_select_points_rot {\n opacity: 0;\n visibility: hidden;\n}\n.svg_select_points_l, .svg_select_points_r {\n cursor: ew-resize;\n opacity: 1;\n visibility: visible;\n fill: #888;\n}\n.zoomable .hovering-zoom {\n cursor: crosshair\n}\n.zoomable .hovering-pan {\n cursor: move\n}\n\n.apexcharts-xaxis,\n.apexcharts-yaxis {\n pointer-events: none;\n}\n\n.apexcharts-zoom-icon, \n.apexcharts-zoom-in-icon,\n.apexcharts-zoom-out-icon,\n.apexcharts-reset-zoom-icon, \n.apexcharts-pan-icon, \n.apexcharts-selection-icon,\n.apexcharts-download-icon {\n cursor: pointer;\n width: 20px;\n height: 20px;\n text-align: center;\n}\n\n\n.apexcharts-zoom-icon svg, \n.apexcharts-zoom-in-icon svg,\n.apexcharts-zoom-out-icon svg,\n.apexcharts-reset-zoom-icon svg,\n.apexcharts-download-icon svg {\n fill: #6E8192;\n}\n.apexcharts-selection-icon svg {\n fill: #444;\n transform: scale(0.86)\n}\n.apexcharts-zoom-icon.selected svg, \n.apexcharts-selection-icon.selected svg, \n.apexcharts-reset-zoom-icon.selected svg {\n fill: #008FFB;\n}\n.apexcharts-selection-icon:not(.selected):hover svg,\n.apexcharts-zoom-icon:not(.selected):hover svg, \n.apexcharts-zoom-in-icon:hover svg, \n.apexcharts-zoom-out-icon:hover svg, \n.apexcharts-reset-zoom-icon:hover svg {\n fill: #333;\n}\n\n.apexcharts-selection-icon, .apexcharts-download-icon {\n margin-right: 3px;\n position: relative;\n top: 1px;\n}\n.apexcharts-reset-zoom-icon {\n margin-left: 7px;\n}\n.apexcharts-zoom-icon {\n transform: scale(1);\n}\n.apexcharts-download-icon {\n transform: scale(0.9)\n}\n\n.apexcharts-zoom-in-icon, .apexcharts-zoom-out-icon {\n transform: scale(0.8)\n}\n\n.apexcharts-zoom-out-icon {\n margin-right: 3px;\n}\n\n.apexcharts-pan-icon {\n transform: scale(0.72);\n position: relative;\n left: 1px;\n top: 0px;\n}\n.apexcharts-pan-icon svg {\n fill: #fff;\n stroke: #6E8192;\n stroke-width: 2;\n}\n.apexcharts-pan-icon.selected svg {\n stroke: #008FFB;\n}\n.apexcharts-pan-icon:not(.selected):hover svg {\n stroke: #333;\n}\n\n.apexcharts-toolbar {\n position: absolute;\n z-index: 11;\n top: 0px;\n right: 3px;\n max-width: 176px;\n text-align: right;\n border-radius: 3px;\n padding: 5px 6px 2px 6px;\n display: flex;\n justify-content: space-between;\n align-items: center; \n}\n\n.apexcharts-toolbar svg {\n pointer-events: none;\n}\n\n@media screen and (min-width: 768px) {\n .apexcharts-toolbar {\n /*opacity: 0;*/\n }\n\n .apexcharts-canvas:hover .apexcharts-toolbar {\n opacity: 1;\n } \n}\n\n.apexcharts-datalabel.hidden {\n opacity: 0;\n}\n\n.apexcharts-pie-label,\n.apexcharts-datalabel, .apexcharts-datalabel-label, .apexcharts-datalabel-value {\n cursor: default;\n pointer-events: none;\n}\n\n.apexcharts-pie-label-delay {\n opacity: 0;\n animation-name: opaque;\n animation-duration: 0.3s;\n animation-fill-mode: forwards;\n animation-timing-function: ease;\n}\n\n.hidden {\n opacity: 0;\n}\n\n.apexcharts-hide .apexcharts-series-points {\n opacity: 0;\n}\n\n.apexcharts-area-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events,\n.apexcharts-line-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events {\n pointer-events: none;\n}\n\n\n/* markers */\n\n.apexcharts-marker {\n transition: 0.15s ease all;\n}\n\n@keyframes opaque {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}", ""]); // exports /***/ }), /* 157 */ /***/ (function(module, exports, __webpack_require__) { var content = __webpack_require__(156); if(typeof content === 'string') content = [[module.i, content, '']]; var transform; var insertInto; var options = {"hmr":true} options.transform = transform options.insertInto = undefined; var update = __webpack_require__(158)(content, options); if(content.locals) module.exports = content.locals; if(false) { module.hot.accept("!!../../node_modules/css-loader/index.js!./apexcharts.css", function() { var newContent = require("!!../../node_modules/css-loader/index.js!./apexcharts.css"); if(typeof newContent === 'string') newContent = [[module.id, newContent, '']]; var locals = (function(a, b) { var key, idx = 0; for(key in a) { if(!b || a[key] !== b[key]) return false; idx++; } for(key in b) idx--; return idx === 0; }(content.locals, newContent.locals)); if(!locals) throw new Error('Aborting CSS HMR due to changed css-modules locals.'); update(newContent); }); module.hot.dispose(function() { update(); }); } /***/ }), /* 158 */ /***/ (function(module, exports, __webpack_require__) { /* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ var stylesInDom = {}; var memoize = function (fn) { var memo; return function () { if (typeof memo === "undefined") memo = fn.apply(this, arguments); return memo; }; }; var isOldIE = memoize(function () { // Test for IE <= 9 as proposed by Browserhacks // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805 // Tests for existence of standard globals is to allow style-loader // to operate correctly into non-standard environments // @see https://github.com/webpack-contrib/style-loader/issues/177 return window && document && document.all && !window.atob; }); var getTarget = function (target) { return document.querySelector(target); }; var getElement = (function (fn) { var memo = {}; return function(target) { // If passing function in options, then use it for resolve "head" element. // Useful for Shadow Root style i.e // { // insertInto: function () { return document.querySelector("#foo").shadowRoot } // } if (typeof target === 'function') { return target(); } if (typeof memo[target] === "undefined") { var styleTarget = getTarget.call(this, target); // Special case to return head of iframe instead of iframe itself if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) { try { // This will throw an exception if access to iframe is blocked // due to cross-origin restrictions styleTarget = styleTarget.contentDocument.head; } catch(e) { styleTarget = null; } } memo[target] = styleTarget; } return memo[target] }; })(); var singleton = null; var singletonCounter = 0; var stylesInsertedAtTop = []; var fixUrls = __webpack_require__(148); module.exports = function(list, options) { if (typeof DEBUG !== "undefined" && DEBUG) { if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment"); } options = options || {}; options.attrs = typeof options.attrs === "object" ? options.attrs : {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style> // tags it will allow on a page if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE(); // By default, add <style> tags to the <head> element if (!options.insertInto) options.insertInto = "head"; // By default, add <style> tags to the bottom of the target if (!options.insertAt) options.insertAt = "bottom"; var styles = listToStyles(list, options); addStylesToDom(styles, options); return function update (newList) { var mayRemove = []; for (var i = 0; i < styles.length; i++) { var item = styles[i]; var domStyle = stylesInDom[item.id]; domStyle.refs--; mayRemove.push(domStyle); } if(newList) { var newStyles = listToStyles(newList, options); addStylesToDom(newStyles, options); } for (var i = 0; i < mayRemove.length; i++) { var domStyle = mayRemove[i]; if(domStyle.refs === 0) { for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j](); delete stylesInDom[domStyle.id]; } } }; }; function addStylesToDom (styles, options) { for (var i = 0; i < styles.length; i++) { var item = styles[i]; var domStyle = stylesInDom[item.id]; if(domStyle) { domStyle.refs++; for(var j = 0; j < domStyle.parts.length; j++) { domStyle.parts[j](item.parts[j]); } for(; j < item.parts.length; j++) { domStyle.parts.push(addStyle(item.parts[j], options)); } } else { var parts = []; for(var j = 0; j < item.parts.length; j++) { parts.push(addStyle(item.parts[j], options)); } stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts}; } } } function listToStyles (list, options) { var styles = []; var newStyles = {}; for (var i = 0; i < list.length; i++) { var item = list[i]; var id = options.base ? item[0] + options.base : item[0]; var css = item[1]; var media = item[2]; var sourceMap = item[3]; var part = {css: css, media: media, sourceMap: sourceMap}; if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]}); else newStyles[id].parts.push(part); } return styles; } function insertStyleElement (options, style) { var target = getElement(options.insertInto) if (!target) { throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid."); } var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1]; if (options.insertAt === "top") { if (!lastStyleElementInsertedAtTop) { target.insertBefore(style, target.firstChild); } else if (lastStyleElementInsertedAtTop.nextSibling) { target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling); } else { target.appendChild(style); } stylesInsertedAtTop.push(style); } else if (options.insertAt === "bottom") { target.appendChild(style); } else if (typeof options.insertAt === "object" && options.insertAt.before) { var nextSibling = getElement(options.insertInto + " " + options.insertAt.before); target.insertBefore(style, nextSibling); } else { throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n"); } } function removeStyleElement (style) { if (style.parentNode === null) return false; style.parentNode.removeChild(style); var idx = stylesInsertedAtTop.indexOf(style); if(idx >= 0) { stylesInsertedAtTop.splice(idx, 1); } } function createStyleElement (options) { var style = document.createElement("style"); options.attrs.type = "text/css"; addAttrs(style, options.attrs); insertStyleElement(options, style); return style; } function createLinkElement (options) { var link = document.createElement("link"); options.attrs.type = "text/css"; options.attrs.rel = "stylesheet"; addAttrs(link, options.attrs); insertStyleElement(options, link); return link; } function addAttrs (el, attrs) { Object.keys(attrs).forEach(function (key) { el.setAttribute(key, attrs[key]); }); } function addStyle (obj, options) { var style, update, remove, result; // If a transform function was defined, run it on the css if (options.transform && obj.css) { result = options.transform(obj.css); if (result) { // If transform returns a value, use that instead of the original css. // This allows running runtime transformations on the css. obj.css = result; } else { // If the transform function returns a falsy value, don't add this css. // This allows conditional loading of css return function() { // noop }; } } if (options.singleton) { var styleIndex = singletonCounter++; style = singleton || (singleton = createStyleElement(options)); update = applyToSingletonTag.bind(null, style, styleIndex, false); remove = applyToSingletonTag.bind(null, style, styleIndex, true); } else if ( obj.sourceMap && typeof URL === "function" && typeof URL.createObjectURL === "function" && typeof URL.revokeObjectURL === "function" && typeof Blob === "function" && typeof btoa === "function" ) { style = createLinkElement(options); update = updateLink.bind(null, style, options); remove = function () { removeStyleElement(style); if(style.href) URL.revokeObjectURL(style.href); }; } else { style = createStyleElement(options); update = applyToTag.bind(null, style); remove = function () { removeStyleElement(style); }; } update(obj); return function updateStyle (newObj) { if (newObj) { if ( newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap ) { return; } update(obj = newObj); } else { remove(); } }; } var replaceText = (function () { var textStore = []; return function (index, replacement) { textStore[index] = replacement; return textStore.filter(Boolean).join('\n'); }; })(); function applyToSingletonTag (style, index, remove, obj) { var css = remove ? "" : obj.css; if (style.styleSheet) { style.styleSheet.cssText = replaceText(index, css); } else { var cssNode = document.createTextNode(css); var childNodes = style.childNodes; if (childNodes[index]) style.removeChild(childNodes[index]); if (childNodes.length) { style.insertBefore(cssNode, childNodes[index]); } else { style.appendChild(cssNode); } } } function applyToTag (style, obj) { var css = obj.css; var media = obj.media; if(media) { style.setAttribute("media", media) } if(style.styleSheet) { style.styleSheet.cssText = css; } else { while(style.firstChild) { style.removeChild(style.firstChild); } style.appendChild(document.createTextNode(css)); } } function updateLink (link, options, obj) { var css = obj.css; var sourceMap = obj.sourceMap; /* If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled and there is no publicPath defined then lets turn convertToAbsoluteUrls on by default. Otherwise default to the convertToAbsoluteUrls option directly */ var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap; if (options.convertToAbsoluteUrls || autoFixUrls) { css = fixUrls(css); } if (sourceMap) { // http://stackoverflow.com/a/26603875 css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */"; } var blob = new Blob([css], { type: "text/css" }); var oldSrc = link.href; link.href = URL.createObjectURL(blob); if(oldSrc) URL.revokeObjectURL(oldSrc); } /***/ }), /* 159 */ /***/ (function(module, exports) { module.exports = "<svg fill=\"#000000\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"12\" cy=\"12\" r=\"3.2\"></circle><path d=\"M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z\"></path><path d=\"M0 0h24v24H0z\" fill=\"none\"></path></svg>" /***/ }), /* 160 */ /***/ (function(module, exports) { module.exports = "<svg fill=\"#000000\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z\"></path><path d=\"M0 0h24v24H0z\" fill=\"none\"></path></svg>" /***/ }), /* 161 */ /***/ (function(module, exports) { module.exports = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M0 0h24v24H0z\" fill=\"none\"></path><path d=\"M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z\"></path></svg>" /***/ }), /* 162 */ /***/ (function(module, exports) { module.exports = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" fill=\"#000000\" viewBox=\"0 0 24 24\"><defs><path d=\"M0 0h24v24H0z\" id=\"a\"></path></defs><clipPath id=\"b\"><use overflow=\"visible\" xlink:href=\"#a\"></use></clipPath><path clip-path=\"url(#b)\" d=\"M23 5.5V20c0 2.2-1.8 4-4 4h-7.3c-1.08 0-2.1-.43-2.85-1.19L1 14.83s1.26-1.23 1.3-1.25c.22-.19.49-.29.79-.29.22 0 .42.06.6.16.04.01 4.31 2.46 4.31 2.46V4c0-.83.67-1.5 1.5-1.5S11 3.17 11 4v7h1V1.5c0-.83.67-1.5 1.5-1.5S15 .67 15 1.5V11h1V2.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5V11h1V5.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5z\"></path></svg>" /***/ }), /* 163 */ /***/ (function(module, exports) { module.exports = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M0 0h24v24H0z\" fill=\"none\"></path><path d=\"M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z\"></path></svg>" /***/ }), /* 164 */ /***/ (function(module, exports) { module.exports = "<svg fill=\"#6E8192\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M0 0h24v24H0z\" fill=\"none\"></path><path d=\"M3 5h2V3c-1.1 0-2 .9-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2c0-1.1-.9-2-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2z\"></path></svg>" /***/ }), /* 165 */ /***/ (function(module, exports) { module.exports = "<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"#000000\" viewBox=\"0 0 24 24\"><path d=\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z\"></path><path d=\"M0 0h24v24H0V0z\" fill=\"none\"></path><path d=\"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z\"></path></svg>" /***/ }), /* 166 */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(86); __webpack_require__(84); __webpack_require__(85); __webpack_require__(83); __webpack_require__(82); __webpack_require__(87); module.exports = __webpack_require__(88); /***/ }) /******/ ]); });
💾 Kaydet
İptal
📝 Yeniden Adlandır
İptal
Kaydet
🔐 Dosya İzinleri (chmod)
İzin Değeri:
Hızlı Seçim:
777
755
644
600
777
= Herkes okur/yazar/çalıştırır
755
= Sahip tam, diğerleri okur/çalıştırır
644
= Sahip okur/yazar, diğerleri okur
600
= Sadece sahip okur/yazar
İptal
Uygula