From 28fc8a10d97c48d93a5631dac8e44c80d30c34c5 Mon Sep 17 00:00:00 2001 From: pvictor Date: Mon, 3 Sep 2018 19:57:23 +0200 Subject: [PATCH] update ApexCharts to 1.4.2 --- inst/htmlwidgets/apexcharter.yaml | 4 +- .../lib/{apexcharts-1.0.4 => }/Options.js | 0 .../lib/apexcharts-1.0.4/apexcharts.min.js | 27849 ---------------- .../lib/apexcharts-1.4/apexcharts.min.js | 2 + 4 files changed, 4 insertions(+), 27851 deletions(-) rename inst/htmlwidgets/lib/{apexcharts-1.0.4 => }/Options.js (100%) delete mode 100644 inst/htmlwidgets/lib/apexcharts-1.0.4/apexcharts.min.js create mode 100644 inst/htmlwidgets/lib/apexcharts-1.4/apexcharts.min.js diff --git a/inst/htmlwidgets/apexcharter.yaml b/inst/htmlwidgets/apexcharter.yaml index 5e312fa..447858f 100644 --- a/inst/htmlwidgets/apexcharter.yaml +++ b/inst/htmlwidgets/apexcharter.yaml @@ -1,5 +1,5 @@ dependencies: - name: apexcharts - version: 1.3.14 - src: htmlwidgets/lib/apexcharts-1.3 + version: 1.4.2 + src: htmlwidgets/lib/apexcharts-1.4 script: apexcharts.min.js diff --git a/inst/htmlwidgets/lib/apexcharts-1.0.4/Options.js b/inst/htmlwidgets/lib/Options.js similarity index 100% rename from inst/htmlwidgets/lib/apexcharts-1.0.4/Options.js rename to inst/htmlwidgets/lib/Options.js diff --git a/inst/htmlwidgets/lib/apexcharts-1.0.4/apexcharts.min.js b/inst/htmlwidgets/lib/apexcharts-1.0.4/apexcharts.min.js deleted file mode 100644 index d2e568b..0000000 --- a/inst/htmlwidgets/lib/apexcharts-1.0.4/apexcharts.min.js +++ /dev/null @@ -1,27849 +0,0 @@ -(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 = 138); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (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); - -var _Filters = __webpack_require__(4); - -var _Filters2 = _interopRequireDefault(_Filters); - -var _Animations = __webpack_require__(14); - -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, - realIndex = _ref2.realIndex, - pathFrom = _ref2.pathFrom, - pathTo = _ref2.pathTo, - stroke = _ref2.stroke, - strokeWidth = _ref2.strokeWidth, - 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); - - 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: 'butt', - 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)); - - el.attr({ - pathTo: pathTo, - pathFrom: pathFrom - }); - - if (initialAnim && !w.globals.resized && !w.globals.dataChanged) { - anim.animatePathsGradually({ - el: el, - pathFrom: pathFrom, - pathTo: pathTo, - speed: initialSpeed, - delay: animationDelay, - strokeWidth: strokeWidth - }); - } - - if (dynamicAnim && w.globals.dataChanged) { - anim.animatePathsGradually({ - el: el, - pathFrom: pathFrom, - pathTo: pathTo, - speed: dataChangeSpeed, - strokeWidth: strokeWidth - }); - } - - return el; - } - }, { - key: 'drawPattern', - value: function drawPattern(style, width, height) { - var stroke = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#a8a8a8'; - var strokeWidth = arguments[4]; - var opacity = arguments[5]; - - 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 = 1; - - 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 : 1; - } - - 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); - stop.at(stop4, gfrom, opacityTo); - }); - - 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, - foreColor = opts.foreColor, - opacity = opts.opacity; - - - if (!textAnchor) textAnchor = 'start'; - - if (typeof foreColor === 'undefined' || foreColor === undefined) foreColor = w.config.chart.foreColor; - - var elText = w.globals.dom.Paper.plain(text).attr({ - x: x, - y: y, - 'text-anchor': textAnchor, - 'dominate-baseline': 'central', - class: true ? opts.cssClass : '' - }); - - elText.node.style.fontSize = fontSize; - elText.node.style.fill = foreColor; - 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 : 1, - 'stroke-opacity': opts.pointStrokeOpacity ? opts.pointStrokeOpacity : 1 - }); - - elPoint = p; - } else if (opts.shape === 'circle') { - if (!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) { - var w = this.w; - var filters = new _Filters2.default(this.ctx); - - 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) { - var w = this.w; - var filters = new _Filters2.default(this.ctx); - - 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')); - - // if (w.config.states.active.filter.type !== 'none') { - // toggle selection - - var selected = 'false'; - if (path.node.getAttribute('selected') === 'true') { - path.node.setAttribute('selected', 'false'); - - if (w.globals.selectedDataPoints[i].includes(j)) { - 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); - - 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 }]); - } - } 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) { - var w = this.w; - var virtualText = this.drawText({ - x: -200, - y: -200, - text: text, - textAnchor: 'start', - fontSize: fontSize, - foreColor: '#fff', - opacity: 0 - }); - - w.globals.dom.Paper.add(virtualText); - - var rect = virtualText.bbox(); - - virtualText.node.parentNode.removeChild(virtualText.node); - - 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) { - console.log(textObj, 'text'); - 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: '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: 'isInt', - value: function isInt(value) { - return !isNaN(value) && parseFloat(Number(value)) === value && !isNaN(parseInt(value, 10)); - } - }, { - 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; -}(); - -Utils.isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); -exports.default = Utils; - -/***/ }), -/* 2 */ -/***/ (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 - -/***/ }), -/* 3 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var store = __webpack_require__(48)('wks'); -var uid = __webpack_require__(32); -var _Symbol = __webpack_require__(2).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; - -/***/ }), -/* 4 */ -/***/ (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"); } } - -__webpack_require__(62); -__webpack_require__(61); - -/** - * 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; - - - 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; - - - 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, { - intensity: intensity - }); - 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) { - // safari has weird issues with 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; - -/***/ }), -/* 5 */ -/***/ (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 - -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var isObject = __webpack_require__(11); -module.exports = function (it) { - if (!isObject(it)) throw TypeError(it + ' is not an object!'); - return it; -}; - -/***/ }), -/* 7 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var dP = __webpack_require__(20); -var createDesc = __webpack_require__(47); -module.exports = __webpack_require__(9) ? function (object, key, value) { - return dP.f(object, key, createDesc(1, value)); -} : function (object, key, value) { - object[key] = value; - return object; -}; - -/***/ }), -/* 8 */ -/***/ (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; - } - - _createClass(Fill, [{ - key: 'clippedImgArea', - value: function clippedImgArea(opts) { - 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 = opts.image; - - var imgWidth = 0; - var imgHeight = 0; - if (typeof opts.width === 'undefined' && typeof opts.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 = opts.width; - imgHeight = opts.height; - } - - var elPattern = document.createElementNS(w.globals.svgNS, 'pattern'); - - _Graphics2.default.setAttrs(elPattern, { - id: opts.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 = opts.opacity; - - w.globals.dom.elDefs.node.appendChild(elPattern); - } - }, { - key: 'fillPath', - value: function fillPath(elSeries, opts) { - var w = this.w; - - var cnf = this.w.config; - var graphics = new _Graphics2.default(this.ctx); - var utils = new _Utils2.default(); - - var patternFill = void 0, - gradientFill = void 0; - - var fillColors = []; - - var seriesIndex = function seriesIndex() { - if (w.config.chart.type === 'bar' && w.config.plotOptions.bar.distributed || w.config.chart.type === 'heatmap') { - return opts.seriesNumber; - } else { - return opts.seriesNumber % w.globals.series.length; - } - }; - - var fillOpacity = Array.isArray(cnf.fill.opacity) ? cnf.fill.opacity[seriesIndex()] : cnf.fill.opacity; - - if (w.globals.comboCharts) { - if (w.config.series[seriesIndex()].type === 'line') { - if (cnf.stroke.colors instanceof Array) { - fillColors = cnf.stroke.colors; - } else { - fillColors.push(cnf.stroke.colors); - } - } else { - if (cnf.fill.colors instanceof Array) { - fillColors = cnf.fill.colors; - } else { - fillColors.push(cnf.fill.colors); - } - } - } else { - if (cnf.chart.type === 'line') { - if (cnf.stroke.colors instanceof Array) { - fillColors = cnf.stroke.colors; - } else { - fillColors.push(cnf.stroke.colors); - } - } else { - if (cnf.fill.colors instanceof Array) { - fillColors = cnf.fill.colors; - } else { - fillColors.push(cnf.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); - } - } - - var defaultColor = _Utils2.default.hexToRgba(fillColors[seriesIndex()], fillOpacity); - - var fillColor = fillColors[seriesIndex()]; - - if (cnf.fill.type === 'pattern') { - var patternStrokeWidth = cnf.fill.pattern.strokeWidth === undefined ? Array.isArray(cnf.stroke.width) ? cnf.stroke.width[seriesIndex] : cnf.stroke.width : Array.isArray(cnf.fill.pattern.strokeWidth) ? cnf.fill.pattern.strokeWidth[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); - } - } - - if (cnf.fill.type === 'gradient') { - 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); - } - - var pathFill = 'none'; - - 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; - } - }]); - - return Fill; -}(); - -exports.default = Fill; - -/***/ }), -/* 9 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// Thank's IE8 for his funny defineProperty -module.exports = !__webpack_require__(41)(function () { - return Object.defineProperty({}, 'a', { get: function get() { - return 7; - } }).a != 7; -}); - -/***/ }), -/* 10 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var global = __webpack_require__(2); -var core = __webpack_require__(5); -var hide = __webpack_require__(7); -var redefine = __webpack_require__(13); -var ctx = __webpack_require__(18); -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; - -/***/ }), -/* 11 */ -/***/ (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'; -}; - -/***/ }), -/* 12 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = {}; - -/***/ }), -/* 13 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var global = __webpack_require__(2); -var hide = __webpack_require__(7); -var has = __webpack_require__(19); -var SRC = __webpack_require__(32)('src'); -var TO_STRING = 'toString'; -var $toString = Function[TO_STRING]; -var TPL = ('' + $toString).split(TO_STRING); - -__webpack_require__(5).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); -}); - -/***/ }), -/* 14 */ -/***/ (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 _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 = '<>'; - - 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; - } - 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) { - if (!from) from = 0; - - el.attr({ - r: from - }).animate(speed).attr({ - r: to - }); - } - - /* - ** Animate radius and position of a circle element - */ - - }, { - key: 'animateCircle', - value: function animateCircle(el, from, to, speed) { - el.attr({ - r: from.r, - cx: from.cx, - cy: from.cy - }).animate(speed).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, - 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, pathFrom, pathTo, speed, strokeWidth, delay * delayFactor); - } - - // SVG.js animation for morphing one path to another - - }, { - key: 'morphSVG', - value: function morphSVG(el, pathFrom, pathTo, speed, strokeWidth, delay) { - 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; - } - - el.plot(pathFrom).animate(1, w.globals.easing, delay).plot(pathFrom).animate(speed, w.globals.easing, delay).plot(pathTo); - } - - /* This function is called when initial animation ends. - ** as we are delaying some elements on axis chart types and showing after initialAnim - */ - - }, { - key: 'showDelayedElements', - value: function showDelayedElements() { - var w = this.w; - - var anim = w.config.chart.animations; - var speed = anim.speed; - var gradualAnimate = anim.animateGradually.enabled; - var gradualDelay = anim.animateGradually.delay; - - if (anim.enabled && !w.globals.resized) { - for (var i = 0; i < w.globals.series.length; i++) { - var delay = 0; - if (gradualAnimate) { - delay = (i + 1) * (gradualDelay / 1000); - } - - for (var z = 0; z < w.globals.delayedElements.length; z++) { - if (w.globals.delayedElements[z].index === i) { - var ele = w.globals.delayedElements[z].el; - ele.classList.add('apexcharts-showAfterDelay'); - ele.style.animationDelay = speed / 950 + delay + 's'; - } - } - } - } - - if (w.config.chart.animations.dynamicAnimation.enabled && w.globals.dataChanged) { - for (var _z = 0; _z < w.globals.delayedElements.length; _z++) { - var _ele = w.globals.delayedElements[_z].el; - _ele.classList.add('apexcharts-showAfterDelay'); - _ele.style.animationDelay = w.config.chart.animations.dynamicAnimation.speed / 950 + 's'; - } - } - } - }]); - - return Animations; -}(); - -module.exports = Animations; - -/***/ }), -/* 15 */ -/***/ (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: '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')) { - dArr.paths.push({ - d: d - }); - } else if (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 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(_ref) { - var _ref$appendToRoot = _ref.appendToRoot, - appendToRoot = _ref$appendToRoot === undefined ? false : _ref$appendToRoot, - rootEl = _ref.rootEl; - - 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'; - - 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, - 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; - -/***/ }), -/* 16 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = function (it) { - if (typeof it != 'function') throw TypeError(it + ' is not a function!'); - return it; -}; - -/***/ }), -/* 17 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var toString = {}.toString; - -module.exports = function (it) { - return toString.call(it).slice(8, -1); -}; - -/***/ }), -/* 18 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// optional / simple context binding -var aFunction = __webpack_require__(16); -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); - }; -}; - -/***/ }), -/* 19 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var hasOwnProperty = {}.hasOwnProperty; -module.exports = function (it, key) { - return hasOwnProperty.call(it, key); -}; - -/***/ }), -/* 20 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var anObject = __webpack_require__(6); -var IE8_DOM_DEFINE = __webpack_require__(68); -var toPrimitive = __webpack_require__(86); -var dP = Object.defineProperty; - -exports.f = __webpack_require__(9) ? 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; -}; - -/***/ }), -/* 21 */ -/***/ (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__(22); - -var _Formatters2 = _interopRequireDefault(_Formatters); - -var _Utils = __webpack_require__(1); - -var _Utils2 = _interopRequireDefault(_Utils); - -var _YAxis = __webpack_require__(36); - -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.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: 'setGridCoordsForAxisCharts', - value: function setGridCoordsForAxisCharts(lgRect) { - var w = this.w; - var gl = w.globals; - - var xPad = 0; - - var xtitleCoords = { - width: 0, - height: 0 - }; - var ytitleCoords = []; - var yaxisLabelCoords = { - width: 0, - height: 0 - }; - var xaxisLabelCoords = { - width: 0, - height: 0 - }; - - yaxisLabelCoords = this.getyAxisLabelsCoords(); - xaxisLabelCoords = this.getxAxisLabelsCoords(); - - if (w.globals.timelineLabels.length > 0) { - xaxisLabelCoords = this.getxAxisTimeScaleLabelsCoords(); - } - - xtitleCoords = this.getxAxisTitleCoords(); - ytitleCoords = this.getyAxisTitleCoords(); - - if (this.isBarHorizontal) {} - // move x with y for horizontal bars - // let tempObj = Object.assign({}, yaxisLabelCoords) - // yaxisLabelCoords = Object.assign({}, xaxisLabelCoords) - // xaxisLabelCoords = Object.assign({}, tempObj) - - - // no x labels, make w=0,h=0 - if (!w.config.xaxis.labels.show) { - xaxisLabelCoords = { - height: 0, - width: 0 - }; - } - - 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.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.floating) { - this.xAxisHeight = 0; - } - - gl.xAxisLabelsHeight = this.xAxisHeight; - - gl.translateXAxisY = w.globals.rotateXLabels ? this.xAxisHeight / 8 : -4; - gl.translateXAxisX = w.globals.rotateXLabels && w.globals.dataXY && 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; - - if (!this.isBarHorizontal) { - this.yAxisWidth = this.getTotalYAxisWidth(); - } else { - this.yAxisWidth = w.globals.yLabelsCoords[0].width + w.globals.yTitleCoords[0].width + 15; - if (this.yAxisWidth > w.config.yaxis[0].labels.maxWidth) { - this.yAxisWidth = w.config.yaxis[0].labels.maxWidth; - } - } - - var yAxisWidth = this.yAxisWidth; - var xAxisHeight = this.xAxisHeight; - var translateY = 10; - - if (!w.config.grid.show) { - yAxisWidth = 0; - xAxisHeight = 35; - } - - if (w.config.chart.sparkline.enabled) { - lgRect = { - height: 0, - width: 0 - }; - xPad = 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 - (w.globals.rotateXLabels ? 10 : 15); - gl.gridWidth = gl.svgWidth - xPad - yAxisWidth; - break; - case 'top': - gl.translateY = lgRect.height + translateY; - gl.translateX = yAxisWidth; - gl.gridHeight = gl.svgHeight - lgRect.height - xAxisHeight - (w.globals.rotateXLabels ? 10 : 15); - gl.gridWidth = gl.svgWidth - xPad - yAxisWidth; - break; - case 'left': - gl.translateY = translateY; - gl.translateX = lgRect.width + yAxisWidth; - gl.gridHeight = gl.svgHeight - xAxisHeight; - gl.gridWidth = gl.svgWidth - lgRect.width - xPad - yAxisWidth; - break; - case 'right': - gl.translateY = translateY; - gl.translateX = yAxisWidth; - gl.gridHeight = gl.svgHeight - xAxisHeight; - gl.gridWidth = gl.svgWidth - lgRect.width - xPad - yAxisWidth; - break; - default: - gl.translateY = translateY; - gl.translateX = yAxisWidth; - gl.gridHeight = gl.svgHeight - lgRect.height - xAxisHeight; - gl.gridWidth = gl.svgWidth - xPad; - break; - } - - var scrollerHeight = 0; - if (w.config.chart.scroller.enabled && w.globals.dataXY) { - scrollerHeight = w.config.chart.scroller.height; - } - - gl.gridHeight = gl.gridHeight - w.config.grid.padding.top - w.config.grid.padding.bottom - scrollerHeight; - - 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 - this.setYAxisXPosition(yaxisLabelCoords, ytitleCoords); - } - }, { - key: 'setGridCoordsForNonAxisCharts', - value: function setGridCoordsForNonAxisCharts(lgRect) { - var w = this.w; - var gl = w.globals; - var xPad = w.config.legend.markers.size * 4 + w.config.legend.itemMargin.horizontal; - - var offY = 15; - - 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; - 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: - gl.gridHeight = gl.svgHeight - lgRect.height - 30; - gl.gridWidth = gl.gridHeight; - - gl.translateY = offY; - gl.translateX = (gl.svgWidth - gl.gridWidth) / 2; - break; - } - } - }, { - key: 'setGridXPosForDualYAxis', - value: function setGridXPosForDualYAxis(ytitleCoords, yaxisLabelCoords) { - var w = this.w; - // if(w.config.yaxis.length > 1) { - w.config.yaxis.map(function (yaxe, index) { - if (!w.globals.ignoreYAxisIndexes.includes(index) && !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; - } - } - }); - // } - } - }, { - key: 'titleSubtitleOffset', - value: function titleSubtitleOffset() { - var w = this.w; - var gl = w.globals; - var gridShrinkOffset = 10; - - if (w.config.title.text !== undefined) { - gridShrinkOffset += w.config.title.margin; - } else { - gridShrinkOffset += 5; - } - - if (w.config.subtitle.text !== undefined) { - gridShrinkOffset += w.config.subtitle.margin; - } else { - gridShrinkOffset += 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.getMainTitleCoords(); - var subtitleCoords = this.getSubTitleCoords(); - - 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; - - w.globals.yLabelsCoords.map(function (yLabelCoord, index) { - var floating = w.config.yaxis[index].floating; - if (yLabelCoord.width > 0 && !floating) { - yAxisWidth = yAxisWidth + yLabelCoord.width; - if (w.globals.ignoreYAxisIndexes.includes(index)) { - yAxisWidth = yAxisWidth - yLabelCoord.width; - } - } else { - yAxisWidth = yAxisWidth + (floating ? 0 : 5); - } - }); - - w.globals.yTitleCoords.map(function (yTitleCoord, index) { - var floating = w.config.yaxis[index].floating; - if (yTitleCoord.width > 0 && !floating) { - yAxisWidth = yAxisWidth + yTitleCoord.width + parseInt(w.config.yaxis[index].title.style.fontSize); - if (w.globals.ignoreYAxisIndexes.includes(index)) { - yAxisWidth = yAxisWidth - yTitleCoord.width; - } - } else { - yAxisWidth = yAxisWidth + (floating ? 0 : 5); - } - }); - - return yAxisWidth; - } - }, { - key: 'getxAxisTimeScaleLabelsCoords', - value: function getxAxisTimeScaleLabelsCoords() { - var w = this.w; - - 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') { - throw new Error('You have possibly supplied invalid Date format. Please supply a valid JavaScript Date'); - } - return a.length > b.length ? a : b; - }); - - var graphics = new _Graphics2.default(this.ctx); - var virtualText = graphics.drawText({ - x: -200, - y: -200, - text: val, - textAnchor: 'start', - fontSize: w.config.xaxis.labels.style.fontSize, - foreColor: '#fff', - opacity: 0 - }); - - w.globals.dom.Paper.add(virtualText); - - var rect = virtualText.node.getBoundingClientRect(); - - var totalWidthRotated = rect.width * 1.05 * labels.length; - - if (totalWidthRotated > w.globals.gridWidth && w.config.xaxis.labels.rotate !== 0) { - w.globals.overlappingXLabels = true; - } else { - w.globals.overlappingXLabels = true; - } - - virtualText.node.parentNode.removeChild(virtualText.node); - - return { - width: rect.width, - height: rect.height - }; - } - - /** - * 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 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; - }); - - 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 virtualText = graphics.drawText({ - x: -200, - y: -200, - text: val, - textAnchor: 'start', - fontSize: w.config.xaxis.labels.style.fontSize, - foreColor: '#fff', - opacity: 0 - }); - - w.globals.dom.Paper.add(virtualText); - - var xLabelrect = virtualText.node.getBoundingClientRect(); - - var 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; - virtualText.attr('transform', 'rotate(' + w.config.xaxis.labels.rotate + ' 0 0)'); - - xLabelrect = virtualText.node.getBoundingClientRect(); - rect.height = xLabelrect.height / 1.65; - } - } else { - w.globals.rotateXLabels = false; - } - - virtualText.node.parentNode.removeChild(virtualText.node); - - return { - width: rect.width, - height: rect.height - }; - } - }, { - 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 = 4; // already drawn y axis on right side - var multipleYPadd = 5; - 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 objyAxis = new _YAxis2.default(_this.ctx); - - var paddingForYAxisTitle = objyAxis.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; - if (w.globals.ignoreYAxisIndexes.includes(index)) { - 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 + 5; - } else { - xLeft = w.globals.translateX - yAxisWidth + yaxisLabelCoords[index].width + yaxe.labels.offsetX + 2; - } - - leftDrawnYs = leftDrawnYs + offset; - w.globals.translateYAxisX[index] = xLeft; - } else { - // right side y axis - xRight = w.globals.gridWidth + w.globals.translateX + rightDrawnYs + 26 + (w.globals.series.length - w.globals.collapsedSeries.length); - - rightDrawnYs = rightDrawnYs + yAxisWidth; - w.globals.translateYAxisX[index] = xRight - yaxe.labels.offsetX; - } - - // w.globals.yAxisWidths.push(yAxisWidth) - }); - } - - /** - * Get Y Axis Dimensions - * @memberof Dimensions - * @return {{width, height}} - **/ - - }, { - key: 'getyAxisLabelsCoords', - value: function getyAxisLabelsCoords() { - var _this2 = 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.labels.show && w.globals.yAxisScale[index].result.length) { - var lbFormatter = yaxe.labels.formatter; - var val = lbFormatter(w.globals.yAxisScale[index].niceMax); - - if (_this2.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; - }); - - val = lbFormatter(val); - } - - var graphics = new _Graphics2.default(_this2.ctx); - var virtualText = graphics.drawText({ - x: 0, - y: 0, - text: val, - textAnchor: 'start', - fontSize: yaxe.labels.style.fontSize, - foreColor: '#fff', - opacity: 0 - }); - - w.globals.dom.Paper.add(virtualText); - - var rect = virtualText.node.getBoundingClientRect(); - - virtualText.node.parentNode.removeChild(virtualText.node); - - 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 virtualText = graphics.drawText({ - x: 0, - y: 0, - text: w.config.xaxis.title.text, - textAnchor: 'start', - fontSize: w.config.xaxis.title.style.fontSize, - foreColor: '#fff', - opacity: 0 - }); - - w.globals.dom.Paper.add(virtualText); - - var rect = virtualText.node.getBoundingClientRect(); - - width = rect.width; - height = rect.height; - - virtualText.node.parentNode.removeChild(virtualText.node); - } - - return { - width: width, - height: height - }; - } - - /** - * Get Y Axis Dimensions - * @memberof Dimensions - * @return {{width, height}} - **/ - - }, { - key: 'getyAxisTitleCoords', - value: function getyAxisTitleCoords() { - var _this3 = this; - - var w = this.w; - var ret = []; - - w.config.yaxis.map(function (yaxe, index) { - if (yaxe.title.text !== undefined) { - var graphics = new _Graphics2.default(_this3.ctx); - var virtualText = graphics.drawText({ - x: 0, - y: 0, - text: yaxe.title.text, - textAnchor: 'middle', - fontSize: yaxe.title.style.fontSize, - foreColor: '#fff', - opacity: 0 - }); - - virtualText.attr('transform', 'rotate(-90 0 0)'); - - w.globals.dom.Paper.add(virtualText); - - var rect = virtualText.node.getBoundingClientRect(); - - ret.push({ - width: rect.width, - height: rect.height - }); - - virtualText.node.parentNode.removeChild(virtualText.node); - } else { - ret.push({ - width: 0, - height: 0 - }); - } - }); - - return ret; - } - - /** - * Get Chart Title Dimensions - * @memberof Dimensions - * @return {{width, height}} - **/ - - }, { - key: 'getMainTitleCoords', - value: function getMainTitleCoords() { - var w = this.w; - var width = 0; - var height = 0; - - var elTitle = w.globals.dom.baseEl.querySelector('.apexcharts-title-text'); - - if (elTitle !== null && !w.config.title.floating) { - var titleCoords = elTitle.getBoundingClientRect(); - width = titleCoords.width; - height = titleCoords.height + 5; - } - - return { - width: width, - height: height - }; - } - - /** - * Get Chart Title Dimensions - * @memberof Dimensions - * @return {{width, height}} - **/ - - }, { - key: 'getSubTitleCoords', - value: function getSubTitleCoords() { - var w = this.w; - var width = 0; - var height = 0; - - var elSubTitle = w.globals.dom.baseEl.querySelector('.apexcharts-subtitle-text'); - - if (elSubTitle !== null && !w.config.subtitle.floating) { - var subtitleCoords = elSubTitle.getBoundingClientRect(); - width = subtitleCoords.width; - height = subtitleCoords.height + 5; - } - - 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) { - this.lgRect = lgRect; - } else { - this.lgRect = { - x: 0, - y: 0, - height: 0, - width: 0 - }; - } - - return this.lgRect; - } - }]); - - return Dimensions; -}(); - -module.exports = Dimensions; - -/***/ }), -/* 22 */ -/***/ (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__(37); - -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'; - } - - // xLabelFormat is the formatter function which is used - - - _createClass(Formatters, [{ - key: 'xLabelFormat', - value: function xLabelFormat(fn, val) { - var w = this.w; - - // if datetime series - if (w.config.xaxis.type === 'datetime') { - // if user has not specified a custom formatter, use the - 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); - } - } - - return fn(val); - } - }, { - key: 'setLabelFormatters', - value: function setLabelFormatters() { - var w = this.w; - - w.globals.xLabelFormatter = function (val, opts) { - return val; - }; - - // this is commented for now, can be give as a customization to user later - // w.globals.xaxisTooltipLabelFormatter = function (val) { - // return val - // } - - w.globals.ttKeyFormatter = function (val, opts) { - return val; - }; - - w.globals.ttZFormatter = function (val, opts) { - return val; - }; - - w.globals.legendFormatter = function (val, opts) { - return val; - }; - - if (w.config.tooltip.x.formatter !== undefined) { - w.globals.ttKeyFormatter = w.config.tooltip.x.formatter; - } - - if (w.config.tooltip.y.formatter !== undefined) { - w.globals.ttValFormatter = w.config.tooltip.y.formatter; - } - - 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, opts) { - if (_Utils2.default.isInt(val)) { - return val.toFixed(0); - } - return val; - }; - } - } - }]); - - return Formatters; -}(); - -exports.default = Formatters; - -/***/ }), -/* 23 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// getting tag from 19.1.3.6 Object.prototype.toString() -var cof = __webpack_require__(17); -var TAG = __webpack_require__(3)('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; -}; - -/***/ }), -/* 24 */ -/***/ (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; -}; - -/***/ }), -/* 25 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var isObject = __webpack_require__(11); -var document = __webpack_require__(2).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) : {}; -}; - -/***/ }), -/* 26 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = false; - -/***/ }), -/* 27 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -// 25.4.1.5 NewPromiseCapability(C) - -var aFunction = __webpack_require__(16); - -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); -}; - -/***/ }), -/* 28 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var def = __webpack_require__(20).f; -var has = __webpack_require__(19); -var TAG = __webpack_require__(3)('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"; - - -var shared = __webpack_require__(48)('keys'); -var uid = __webpack_require__(32); -module.exports = function (key) { - return shared[key] || (shared[key] = uid(key)); -}; - -/***/ }), -/* 30 */ -/***/ (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); -}; - -/***/ }), -/* 31 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// to indexed object, toObject with fallback for non-array-like ES3 strings -var IObject = __webpack_require__(70); -var defined = __webpack_require__(24); -module.exports = function (it) { - return IObject(defined(it)); -}; - -/***/ }), -/* 32 */ -/***/ (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)); -}; - -/***/ }), -/* 33 */ -/***/ (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__(54); - -var _Scatter2 = _interopRequireDefault(_Scatter); - -var _Graphics = __webpack_require__(0); - -var _Graphics2 = _interopRequireDefault(_Graphics); - -var _Filters = __webpack_require__(4); - -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) { - var _this = this; - - _classCallCheck(this, DataLabels); - - this.plotDataLabelsText = function (x, y, text, i, j, elToAppendTo, dataLabelsConfig) { - var w = _this.w; - var graphics = new _Graphics2.default(_this.ctx); - - var correctedLabels = _this.dataLabelsCorrection(x, y, text, i, j, 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: dataLabelsConfig.style.colors[i], - textAnchor: dataLabelsConfig.textAnchor, - text: text, - fontSize: dataLabelsConfig.style.fontSize - }); - - 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); - } - }; - - 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, 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) { - 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) { - elDataLabelsWrap = graphics.group({ - class: 'apexcharts-data-labels' - }); - - if (pos.x instanceof Array) { - 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 (val) { - 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; - } - }]); - - return DataLabels; -}(); - -exports.default = DataLabels; - -/***/ }), -/* 34 */ -/***/ (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__(4); - -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); - - 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)); - } - }, { - key: 'setSelectedPointFilter', - value: function setSelectedPointFilter(circle, realIndex, realIndexP) { - var w = this.w; - if (typeof w.globals.selectedDataPoints[realIndex] !== 'undefined') { - if (w.globals.selectedDataPoints[realIndex].includes(realIndexP)) { - 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.config.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; - -/***/ }), -/* 35 */ -/***/ (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__(36); - -var _YAxis2 = _interopRequireDefault(_YAxis); - -var _Formatters = __webpack_require__(22); - -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(); - } - if (w.config.xaxis.position === 'top') { - this.offY = 0; - } else { - this.offY = w.globals.gridHeight + 1; - } - - this.xaxisFontSize = w.config.xaxis.labels.style.fontSize; - this.xaxisForeColors = w.config.xaxis.labels.style.colors; - - // 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.dataXY) { - colWidth = w.globals.gridWidth / (labels.length - 1); - xPos = xPos + colWidth / 2 + w.config.xaxis.labels.offsetX; - } else { - // no dataXY, 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.dataXY) { - 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 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); - - 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; - } - - 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, - foreColor: this.xaxisForeColors[_i], - cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass - }); - - elXaxisTexts.add(elTick); - - elTick.tspan(label); - - var elTooltipTitle = document.createElementNS(w.globals.svgNS, 'title'); - elTooltipTitle.textContent = label; - elTick.node.appendChild(elTooltipTitle); - - // console.log(elText, elTooltipTitle, elTick.node, label, 'xaxis-text') - - 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, - 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.dataXY) { - lineCorrection = lineCorrection - 15; - } - var elHorzLine = graphics.drawLine(w.globals.padHorizontal + lineCorrection + w.config.xaxis.axisBorder.offsetX, this.offY, w.globals.gridWidth, this.offY, w.config.xaxis.axisBorder.color); - - 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.config.yaxis[0].labels.formatter; - - 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, - 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, - 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, w.globals.gridWidth, this.offY, this.yaxis.axisBorder.color); - - 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.dataXY && 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 (xAxisTexts.length > 0) { - var firstLabelPos = xAxisTexts[0].getBBox(); - var lastLabelPos = xAxisTexts[xAxisTexts.length - 1].getBBox(); - - if (firstLabelPos.x < -25) { - xAxisTexts[0].parentNode.removeChild(xAxisTexts[0]); - } - - if (lastLabelPos.x + lastLabelPos.width > w.globals.gridWidth) { - xAxisTexts[xAxisTexts.length - 1].parentNode.removeChild(xAxisTexts[xAxisTexts.length - 1]); - } - } - - if (yAxisTextsInversed.length > 0) { - // truncate y axis in bar chart - 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 y axis in bar chart - 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; - -/***/ }), -/* 36 */ -/***/ (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.isBarHorizontal = !!(this.w.config.chart.type === 'bar' && this.w.config.plotOptions.bar.horizontal); - - 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 elYaxis = graphics.group({ - class: 'apexcharts-yaxis', - 'rel': realIndex, - 'transform': 'translate(' + w.globals.translateYAxisX[realIndex] + ', 0)' - }); - - 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.config.yaxis[realIndex].labels.formatter; - - 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, - 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, - 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', - fontSize: this.xaxisFontSize, - 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, - 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); - } - - 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; - - if (oppositeAxisCount === 0) { - x = x - 15; - } - oppositeAxisCount += 1; - } 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 }; - } - }]); - - return YAxis; -}(); - -module.exports = YAxis; - -/***/ }), -/* 37 */ -/***/ (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__(55); - -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"); } } - -/** - * 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]; - - this.MMMM = ['\x00', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; - } - - _createClass(DateTime, [{ - key: 'isValidDate', - value: function isValidDate(date) { - return !isNaN(Date.parse(date)); - } - - // 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 MMMM = ['\x00', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; - var MMM = ['\x01', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; - var dddd = ['\x02', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; - var ddd = ['\x03', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; - - function ii(i, len) { - var s = i + ''; - len = len || 2; - while (s.length < len) { - s = '0' + s; - }return s; - } - - 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; - -/***/ }), -/* 38 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// 22.1.3.31 Array.prototype[@@unscopables] -var UNSCOPABLES = __webpack_require__(3)('unscopables'); -var ArrayProto = Array.prototype; -if (ArrayProto[UNSCOPABLES] == undefined) __webpack_require__(7)(ArrayProto, UNSCOPABLES, {}); -module.exports = function (key) { - ArrayProto[UNSCOPABLES][key] = true; -}; - -/***/ }), -/* 39 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// false -> Array#indexOf -// true -> Array#includes -var toIObject = __webpack_require__(31); -var toLength = __webpack_require__(51); -var toAbsoluteIndex = __webpack_require__(84); -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; - }; -}; - -/***/ }), -/* 40 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// IE 8- don't enum bug keys -module.exports = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(','); - -/***/ }), -/* 41 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = function (exec) { - try { - return !!exec(); - } catch (e) { - return true; - } -}; - -/***/ }), -/* 42 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var document = __webpack_require__(2).document; -module.exports = document && document.documentElement; - -/***/ }), -/* 43 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var LIBRARY = __webpack_require__(26); -var $export = __webpack_require__(10); -var redefine = __webpack_require__(13); -var hide = __webpack_require__(7); -var Iterators = __webpack_require__(12); -var $iterCreate = __webpack_require__(73); -var setToStringTag = __webpack_require__(28); -var getPrototypeOf = __webpack_require__(79); -var ITERATOR = __webpack_require__(3)('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; -}; - -/***/ }), -/* 44 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// 19.1.2.14 / 15.2.3.14 Object.keys(O) -var $keys = __webpack_require__(80); -var enumBugKeys = __webpack_require__(40); - -module.exports = Object.keys || function keys(O) { - return $keys(O, enumBugKeys); -}; - -/***/ }), -/* 45 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = function (exec) { - try { - return { e: false, v: exec() }; - } catch (e) { - return { e: true, v: e }; - } -}; - -/***/ }), -/* 46 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var anObject = __webpack_require__(6); -var isObject = __webpack_require__(11); -var newPromiseCapability = __webpack_require__(27); - -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; -}; - -/***/ }), -/* 47 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = function (bitmap, value) { - return { - enumerable: !(bitmap & 1), - configurable: !(bitmap & 2), - writable: !(bitmap & 4), - value: value - }; -}; - -/***/ }), -/* 48 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var core = __webpack_require__(5); -var global = __webpack_require__(2); -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__(26) ? 'pure' : 'global', - copyright: '© 2018 Denis Pushkarev (zloirock.ru)' -}); - -/***/ }), -/* 49 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// 7.3.20 SpeciesConstructor(O, defaultConstructor) -var anObject = __webpack_require__(6); -var aFunction = __webpack_require__(16); -var SPECIES = __webpack_require__(3)('species'); -module.exports = function (O, D) { - var C = anObject(O).constructor; - var S; - return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); -}; - -/***/ }), -/* 50 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var ctx = __webpack_require__(18); -var invoke = __webpack_require__(69); -var html = __webpack_require__(42); -var cel = __webpack_require__(25); -var global = __webpack_require__(2); -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__(17)(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 -}; - -/***/ }), -/* 51 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// 7.1.15 ToLength -var toInteger = __webpack_require__(30); -var min = Math.min; -module.exports = function (it) { - return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 -}; - -/***/ }), -/* 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 _Fill = __webpack_require__(8); - -var _Fill2 = _interopRequireDefault(_Fill); - -var _Filters = __webpack_require__(4); - -var _Filters2 = _interopRequireDefault(_Filters); - -var _Graphics = __webpack_require__(0); - -var _Graphics2 = _interopRequireDefault(_Graphics); - -var _DataLabels = __webpack_require__(33); - -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.xRatio = xyRatios.xRatio; - this.yRatio = xyRatios.yRatio; - this.invertedXRatio = xyRatios.invertedXRatio; - this.invertedYRatio = xyRatios.invertedYRatio; - this.baseLineY = xyRatios.baseLineY; - this.baseLineInvertedY = xyRatios.baseLineInvertedY; - this.isHorizontal = this.barOptions.horizontal; - this.strokeWidth = w.config.stroke.width; - this.isNullValue = false; - - this.xyRatios = xyRatios; - 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.series = series; - this.totalItems = 0; - this.seriesLen = 0; - this.visibleI = -1; - - for (var sl = 0; sl < series.length; sl++) { - if (series[sl].length > 0) { - this.seriesLen = this.seriesLen + 1; - this.totalItems += series[sl].length; - } - } - - if (this.seriesLen === 0) { - // A small adjustment when combo charts are used - this.seriesLen = 1; - } - - 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', - '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; - 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, index) { - 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 - }); - - var lineFill = w.config.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, - realIndex: realIndex, - pathFrom: pathFrom, - pathTo: pathTo, - stroke: lineFill, - strokeWidth: strokeWidth, - fill: pathFill, - animationDelay: delay, - initialSpeed: w.config.chart.animations.speed, - dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed, - className: 'apexcharts-bar-area', - id: 'apexcharts-bar-area' - }); - - _this.setSelectedBarFilter(renderedPath, realIndex, j); - - elSeries.add(renderedPath); - - var dataLabels = _this.calculateBarDataLabels({ x: x, y: y, i: i, j: j, series: series, realIndex: realIndex, barHeight: barHeight, barWidth: barWidth, renderedPath: renderedPath, visibleSeries: _this.visibleI }); - - if (dataLabels !== null) { - elDataLabelsWrap.add(dataLabels); - } - - elSeries.add(elDataLabelsWrap); - }; - - 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: '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.dataXY) { - 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 / w.globals.dataPoints; - barWidth = xDivision / this.seriesLen; - - if (w.globals.dataXY) { - xDivision = w.globals.gridWidth / (this.totalItems / 2); - barWidth = xDivision / (this.seriesLen + 1) * (parseInt(this.barOptions.columnWidth) / 100); - } else { - barWidth = barWidth * 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(_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 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.dataXY) { - 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.dataXY) { - 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(_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 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.dataXY) { - 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.dataXY) { - 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: 'calculateBarDataLabels', - value: function calculateBarDataLabels(_ref3) { - var x = _ref3.x, - y = _ref3.y, - i = _ref3.i, - j = _ref3.j, - realIndex = _ref3.realIndex, - series = _ref3.series, - barHeight = _ref3.barHeight, - barWidth = _ref3.barWidth, - visibleSeries = _ref3.visibleSeries, - renderedPath = _ref3.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); - - var offX = w.config.dataLabels.offsetX; - var offY = w.config.dataLabels.offsetY; - - if (w.globals.dataXY) { - bcx = x + parseFloat(barWidth * (visibleSeries + 1)) - strokeWidth; - - bcy = y + parseFloat(barHeight * (visibleSeries + 1)) - strokeWidth; - } - - var dataLabels = null; - var dataLabelsX = x; - var dataLabelsY = y; - var dataLabelsConfig = w.config.dataLabels; - var barDataLabelsConfig = this.barOptions.dataLabels; - - var dataPointsDividedHeight = w.globals.gridHeight / w.globals.dataPoints; - var dataPointsDividedWidth = w.globals.gridWidth / w.globals.dataPoints; - - var negValuesPresent = Math.abs(w.globals.minY) !== 0; - - var textRects = graphics.getTextRects(w.globals.series[i][j], parseInt(dataLabelsConfig.style.fontSize)); - - if (this.isHorizontal) { - dataLabelsY = bcy - dataPointsDividedHeight + barHeight / 2 + textRects.height / 2 + offY - 3; - - var baseline = w.globals.gridWidth - this.baseLineInvertedY; - var _barWidth = series[i][j] / this.invertedYRatio; - - var emptySpaceBackwards = w.globals.gridWidth - baseline; - - var valIsNegative = !!(x < emptySpaceBackwards && Math.abs(this.baseLineInvertedY) !== 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; - } - - renderedPath.attr({ - cy: bcy, - cx: x, - j: j, - val: series[i][j], - barHeight: barHeight - }); - - dataLabels = this.drawCalculatedBarDataLabels({ x: dataLabelsX, y: dataLabelsY, val: series[i][j], i: realIndex, j: j, dataLabelsConfig: dataLabelsConfig }); - } else { - // columns - var _barHeight = series[i][j] / this.yRatio[this.yaxisIndex]; - bcx = bcx - strokeWidth / 2; - - if (w.globals.dataXY) { - 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); - - 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; - } - - renderedPath.attr({ - cy: y, - cx: bcx, - j: j, - val: series[i][j], - barWidth: barWidth - }); - - dataLabels = this.drawCalculatedBarDataLabels({ x: dataLabelsX, y: dataLabelsY, val: series[i][j], i: realIndex, j: j, dataLabelsConfig: dataLabelsConfig }); - } - - return dataLabels; - } - }, { - key: 'drawCalculatedBarDataLabels', - value: function drawCalculatedBarDataLabels(_ref4) { - var x = _ref4.x, - y = _ref4.y, - val = _ref4.val, - i = _ref4.i, - j = _ref4.j, - dataLabelsConfig = _ref4.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; - - if (dataLabelsConfig.enabled) { - elDataLabelsWrap = graphics.group({ - class: 'apexcharts-data-labels' - }); - - var text = ''; - if (val) { - text = formatter(val, { seriesIndex: i, dataPointIndex: j, globals: w.globals }); - } - dataLabels.plotDataLabelsText(x, y, text, i, j, elDataLabelsWrap, dataLabelsConfig); - } - - 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; - default: - endingShape = graphics.line(_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; - default: - _endingShape = graphics.line(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].includes(j)) { - 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; - -/***/ }), -/* 53 */ -/***/ (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__(8); - -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__(4); - -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.centerY = w.globals.gridHeight / 2; - this.centerX = w.globals.gridWidth / 2; - - if (w.config.chart.type === 'radialBar') { - this.fullAngle = 360 - w.config.plotOptions.radialBar.endAngle - w.config.plotOptions.radialBar.startAngle; - } else { - 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 colorArr = w.config.fill.colors; - - var lineColorArr = w.config.stroke.colors !== undefined ? w.config.stroke.colors : w.config.colors; - - 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 = Math.round(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 = Math.round(this.fullAngle * _Utils2.default.negToZero(w.globals.previousPaths[_i]) / prevTotal); - this.prevSectorAngleArr.push(previousAngle); - } - } - - this.size = w.globals.gridWidth / 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(colorArr, lineColorArr, sectorAngleArr, series); - - elSeries.attr({ - 'transform': 'translate(' + translateX + ', ' + translateY + ') scale(' + scaleSize + ')' - }); - - ret.attr({ - 'data:innerTranslateX': translateX, - 'data:innerTranslateY': translateY - }); - - elSeries.add(elG); - - ret.add(elSeries); - - return ret; - } - - // core function for drawing pie arcs - - }, { - key: 'drawArcs', - value: function drawArcs(colorArr, lineColorArr, 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', - 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 elPath = graphics.drawPath({ - d: '', - stroke: lineColorArr instanceof Array ? lineColorArr[i] : lineColorArr, - strokeWidth: this.strokeWidth, - fill: pathFill, - fillOpacity: w.config.fill.opacity, - classes: 'apexcharts-pie-area' - }); - - elPath.attr({ - id: 'apexcharts-pieSlice-' + i - }); - - if (w.config.chart.dropShadow.enabled) { - var shadow = w.config.chart.dropShadow; - filters.dropShadow(elPath, shadow); - } - - // append filters on mouseenter and mouseleave - elPath.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, elPath)); - elPath.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, 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); - } - - this.animatePaths(elPath, { - endAngle: endAngle, - startAngle: startAngle, - i: i, - totalItems: sectorAngleArr.length - 1, - animBeginArr: this.animBeginArr, - dur: dur - }); - - if (this.dynamicAnim && w.globals.dataChanged) { - this.animatePaths(elPath, { - endAngle: endAngle, - startAngle: startAngle, - prevStartAngle: prevStartAngle, - prevEndAngle: prevEndAngle, - i: i, - animateStartingPos: true, - animBeginArr: this.animBeginArr, - dur: w.config.chart.animations.dynamicAnimation.speed - }); - } - - // 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 = Math.round(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.config.dataLabels.style.colors[i]; - - var elPieLabel = graphics.drawText({ - x: xPos, - y: yPos, - text: text, - textAnchor: 'middle', - fontSize: w.config.dataLabels.style.fontSize, - 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; - } - - // 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; - - var currAngle = angle; - var startAngle = toStartAngle; - var fromAngle = fromStartAngle - toStartAngle; - - if (w.globals.dataChanged) { - // 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) { - startAngle = fromAngle + (toStartAngle - fromAngle) * pos; - currAngle = fromStartAngle + (angle - fromStartAngle) * pos; - } - path = me.getPiePath({ - me: me, - startAngle: startAngle, - angle: currAngle, - size: size - }); - - el.node.setAttribute('data:pathOrig', path); - - if (w.config.chart.type === 'pie' || w.config.chart.type === 'donut') { - el.attr({ - 'stroke-width': 0 - }); - } - - 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') { - size = me.size; - 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 - }); - - elPath.plot(path).animate(1).plot(pathFrom).animate(100).plot(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; - -/***/ }), -/* 54 */ -/***/ (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__(14); - -var _Animations2 = _interopRequireDefault(_Animations); - -var _Fill = __webpack_require__(8); - -var _Fill2 = _interopRequireDefault(_Fill); - -var _Filters = __webpack_require__(4); - -var _Filters2 = _interopRequireDefault(_Filters); - -var _Graphics = __webpack_require__(0); - -var _Graphics2 = _interopRequireDefault(_Graphics); - -var _Markers = __webpack_require__(34); - -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); - } - - 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; - - if (!w.globals.risingSeries.includes(realIndex)) { - anim.animateCircle(circle, { - cx: prevX, cy: prevY, r: prevR - }, { - cx: x, cy: y, r: finishRadius - }, _speed); - } else { - anim.animateCircle(circle, { - cx: prevX, cy: prevY, r: prevR - }, { - cx: x, cy: y, r: finishRadius - }, _speed); - } - } 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; - -/***/ }), -/* 55 */ -/***/ (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__(37); - -var _DateTime2 = _interopRequireDefault(_DateTime); - -var _Dimensions = __webpack_require__(21); - -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() { - 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 = (w.globals.maxX - w.globals.minX) / (1000 * 60 * 60 * 24); - this.determineInterval(daysDiff); - - var timeIntervals = dt.getTimeUnitsfromTimestamp(w.globals.minX, w.globals.maxX); - - var daysWidthOnXAxis = w.globals.gridWidth / daysDiff; - var hoursWidthOnXAxis = daysWidthOnXAxis / 24; - var minutesWidthOnXAxis = hoursWidthOnXAxis / 60; - - var numberOfHours = Math.floor(daysDiff * 24); - // let 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 - - // let currentHour = firstVal.minHour - };var currentMonthDate = firstVal.minDate; - var currentDate = firstVal.minDate; - var currentMonth = firstVal.minMonth; - var currentYear = firstVal.minYear; - - var params = { - firstVal: firstVal, - currentMonthDate: currentMonthDate, - currentDate: currentDate, - currentMonth: currentMonth, - currentYear: currentYear, - daysWidthOnXAxis: daysWidthOnXAxis, - hoursWidthOnXAxis: hoursWidthOnXAxis, - minutesWidthOnXAxis: minutesWidthOnXAxis, - 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': - // TODO - 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) { - if (ts.unit === 'month') { - return { - position: ts.position, - value: ts.value + 1, - unit: ts.unit, - year: ts.year, - month: ts.month + 1 - }; - } else if (ts.unit === 'day' || ts.unit === 'hour') { - return { - position: ts.position, - value: ts.value, - unit: ts.unit, - year: ts.year, - month: ts.month + 1 - }; - } - - return ts; - }); - - var filteredTimeScale = adjustedMonthInTimeScaleArray.filter(function (ts, index) { - 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; - default: - shouldNotSkipUnit = false; - break; - } - - if ((value % modulo === 0 || shouldNotSkipUnit) && !shouldNotPrint) { - return true; - } - }); - - 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(); - - return filteredTimeScale; - } - }, { - 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 <= 2: - // less than 2 days - this.tickInterval = 'hours'; - 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 yrCounter = 0; - - var changeMonth = function changeMonth(dateVal, month, year) { - var monthdays = dt.determineDaysOfMonths(month + 1, year); - - if (dateVal > monthdays) { - month = month + 1; - date = 1; - unit = 'month'; - return month; - } - - return month; - }; - - var remainingHours = 24 - firstVal.minHour; - - // calculate the first tick position - var firstTickPosition = remainingHours * hoursWidthOnXAxis; - var firstTickValue = firstVal.minDate + 1; - - var date = firstTickValue; - var month = changeMonth(date, currentMonth, currentYear); - - // push the first tick in the array - this.timeScaleArray.push({ position: firstTickPosition, value: firstTickValue, unit: unit, year: currentYear, month: this.monthMod(month) }); - - 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) }); - } - } - }, { - 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, 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 = 60 * minutesWidthOnXAxis + pos; - var val = hour === 0 ? date : hour; - this.timeScaleArray.push({ position: pos, value: val, unit: unit, day: date, year: year, month: this.monthMod(month) }); - - hour++; - } - } - }, { - 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 dateString = ts.year; - dateString += '-' + ('0' + ts.month.toString()).slice(-2); - dateString += ts.unit === 'day' ? '-' + ('0' + value).slice(-2) : '-01'; - dateString += ts.unit === 'hour' ? 'T' + ('0' + value).slice(-2) + ':00:00' : 'T00:00:00'; - dateString = new Date(Date.parse(dateString)); - - 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; - - value = dt.formatDate(dateString, customFormat); - } else { - value = dt.formatDate(dateString, w.config.xaxis.labels.format); - } - - return { - position: ts.position, - value: value, - unit: ts.unit, - year: ts.year, - month: ts.month - }; - }); - - return reformattedTimescaleArray; - } - }, { - key: 'removeOverlappingTS', - value: function removeOverlappingTS(arr) { - var graphics = new _Graphics2.default(this.ctx); - var lastDrawnIndex = 0; - - var filteredArray = arr.map(function (item, index) { - if (index > 0) { - 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; - -/***/ }), -/* 56 */ -/***/ (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__(106); - -var _Exports2 = _interopRequireDefault(_Exports); - -var _icoPanHand = __webpack_require__(134); - -var _icoPanHand2 = _interopRequireDefault(_icoPanHand); - -var _icoZoomIn = __webpack_require__(137); - -var _icoZoomIn2 = _interopRequireDefault(_icoZoomIn); - -var _icoHome = __webpack_require__(132); - -var _icoHome2 = _interopRequireDefault(_icoHome); - -var _icoPlus = __webpack_require__(135); - -var _icoPlus2 = _interopRequireDefault(_icoPlus); - -var _icoMinus = __webpack_require__(133); - -var _icoMinus2 = _interopRequireDefault(_icoMinus); - -var _icoSelect = __webpack_require__(136); - -var _icoSelect2 = _interopRequireDefault(_icoSelect); - -var _icoCamera = __webpack_require__(131); - -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; - } - - _createClass(Toolbar, [{ - key: 'createToolbar', - value: function createToolbar() { - var w = this.w; - - this.elToolbarWrap = document.createElement('div'); - this.elToolbarWrap.setAttribute('class', 'apexcharts-toolbar'); - w.globals.dom.elWrap.appendChild(this.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: 'Download SVG', - class: 'apexcharts-download-icon' - }); - } - - if (w.config.chart.toolbar.tools.selection) { - toolbarControls.push({ - el: this.elSelection, - icon: _icoSelect2.default, - title: 'Select', - 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: 'Zoom In', - 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: 'Zoom Out', - 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: 'Zoom', - class: 'apexcharts-zoom-icon' - }); - } - - if (w.config.chart.toolbar.tools.pan && (w.config.chart.zoom.enabled || w.config.chart.scroller.enabled)) { - toolbarControls.push({ - el: this.elPan, - icon: _icoPanHand2.default, - title: 'Panning', - class: 'apexcharts-pan-icon' - }); - } - - if (w.config.chart.toolbar.tools.reset) { - toolbarControls.push({ - el: this.elZoomReset, - icon: _icoHome2.default, - title: 'Reset Zoom', - 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; - this.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: '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.elPan.classList.remove('selected'); - this.elSelection.classList.remove('selected'); - 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; - - this.ctx.updateOptions({ - xaxis: { - min: newMinX, - max: newMaxX - } - }, false, w.globals.initialConfig.chart.animations.dynamicAnimation.enabled); - } - }, { - key: 'handleZoomOut', - value: function handleZoomOut() { - var w = this.w; - - 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 (newMinX < w.globals.initialminX / 1.00001) { - return; - } - - this.ctx.updateOptions({ - xaxis: { - min: newMinX, - max: newMaxX - } - }, false, w.globals.initialConfig.chart.animations.dynamicAnimation.enabled); - } - }, { - key: 'downloadSVG', - value: function downloadSVG() { - // const w = this.w - var downloadSVG = new _Exports2.default(this.ctx); - - downloadSVG.exportToSVG(); - } - }, { - key: 'handleZoomReset', - value: function handleZoomReset(e) { - var w = this.w; - - var me = this; - var yaxis = w.config.yaxis; - var xaxis = w.config.xaxis; - w.globals.zoomed = false; - - if (w.globals.minX === w.globals.initialminX && w.globals.maxX === w.globals.initialmaxX) return; - - w.config.yaxis.map(function (yaxe, index) { - yaxis[index].min = undefined; - yaxis[index].max = undefined; - }); - xaxis.min = undefined; - xaxis.max = undefined; - - me.ctx.updateOptions(w.globals.initialConfig, false, w.globals.initialConfig.chart.animations.dynamicAnimation.enabled); - } - }]); - - return Toolbar; -}(); - -module.exports = Toolbar; - -/***/ }), -/* 57 */ -/***/ (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__(15); - -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 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 (ttCtx.isBarShared) { - if (x + ttCtx.xcrosshairsWidth > w.globals.gridWidth) { - x = w.globals.gridWidth - ttCtx.xcrosshairsWidth; - } - } else { - if (x + ttCtx.xcrosshairsWidth > w.globals.gridWidth) { - x = w.globals.gridWidth - ttCtx.xcrosshairsWidth; - } - } - - if (x < 0) { - x = 0; - } - } else { - if (j !== null) { - x = x + w.globals.gridWidth / tickAmount / 2; - } - } - - if (ttCtx.xcrosshairs !== null) { - ttCtx.xcrosshairs.setAttribute('x', x); - ttCtx.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 ycrosshairsHiddenRect = parseInt(ttCtx.ycrosshairsHidden.getAttribute('y1')); - var cy = w.globals.translateY + ycrosshairsHiddenRect; - - 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.includes(index)) { - 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 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) { - y = ttCtx.e.clientY - ttCtx.seriesBound.top - tooltipRect.ttHeight / 2; - } - - if (tooltipRect.ttHeight + y > w.globals.gridHeight) { - y = w.globals.gridHeight - tooltipRect.ttHeight / 2 - pointR; - } - - if (!isNaN(x)) { - x = x + w.globals.translateX; - - ttCtx.tooltip.style.left = x + 'px'; - ttCtx.tooltip.style.top = y + 'px'; - } - } - }, { - 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 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; - if (ttCtx.allPoints !== null) { - points = ttCtx.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 && typeof pointArr !== 'undefined') { - 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 + '\']'); - - var bcx = jBar ? parseFloat(jBar.getAttribute('cx')) : 0; - var bcy = 0; - var bw = jBar ? parseFloat(jBar.getAttribute('barWidth')) : 0; - - if (w.globals.dataXY) { - bcx = bcx - bw / 2; - } else { - bcx = ttCtx.xAxisTicksPositions[j - 1] + ttCtx.dataPointsDividedWidth / 2; - if (Number.isNaN(bcx)) { - bcx = ttCtx.xAxisTicksPositions[j] - ttCtx.dataPointsDividedWidth / 2; - } - } - - // tooltip will move vertically along with mouse as it is a shared tooltip - var elGrid = w.globals.dom.baseEl.querySelector('.apexcharts-grid'); - 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; - -/***/ }), -/* 58 */ -/***/ (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 context = _ref.context, - hoverArea = _ref.hoverArea, - elGrid = _ref.elGrid, - clientX = _ref.clientX, - clientY = _ref.clientY, - plotSeriesWidth = _ref.plotSeriesWidth, - hasBars = _ref.hasBars; - - var w = this.w; - - var hoverWidth = w.globals.gridWidth; // - (w.globals.gridWidth - plotSeriesWidth) - - 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.dataXY) { - 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; - -/***/ }), -/* 59 */ -/***/ (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__(120); - -var _Defaults2 = _interopRequireDefault(_Defaults); - -var _Utils = __webpack_require__(1); - -var _Utils2 = _interopRequireDefault(_Utils); - -var _Options = __webpack_require__(60); - -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); - - if (typeof opts.yaxis === 'undefined') { - opts.yaxis = {}; - } - - this.chartType = opts.chart.type; - - if (this.chartType === 'histogram') { - opts.chart.type = 'bar'; - opts = _Utils2.default.extend({ - plotOptions: { - bar: { - columnWidth: '99.99%' - } - } - }, opts); - } - - if (typeof opts.annotations === 'undefined') { - opts.annotations = {}; - opts.annotations.yaxis = []; - opts.annotations.xaxis = []; - } - - var extendArray = function extendArray(arrToExtend, resultArr) { - var extendedArr = []; - arrToExtend.map(function (item) { - extendedArr.push(_Utils2.default.extend(resultArr, item)); - }); - arrToExtend = extendedArr; - return arrToExtend; - }; - - // 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 = extendArray(opts.yaxis, _Options.yAxis); - } - - // annotations also accepts array, so we need to extend them manually - opts.annotations.xaxis = extendArray(typeof opts.annotations.xaxis !== 'undefined' ? opts.annotations.xaxis : [], _Options.xAxisAnnotation); - opts.annotations.yaxis = extendArray(typeof opts.annotations.yaxis !== 'undefined' ? opts.annotations.yaxis : [], _Options.yAxisAnnotation); - opts.annotations.points = extendArray(typeof opts.annotations.points !== 'undefined' ? opts.annotations.points : [], _Options.pointAnnotation); - - 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 '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.stacked && opts.chart.stackType === '100%') { - defaults.stacked100(); - } - newDefaults = _Utils2.default.extend(config, chartDefaults); - } - - // config should override 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: '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.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 bars - } - - if (config.chart.type === 'bar') { - if (config.tooltip.shared) { - if (config.xaxis.crosshairs.width === 'barWidth' && config.series.length > 1) { - console.warn('barWidth is only supported in single series, not 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; - -/***/ }), -/* 60 */ -/***/ (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 xAxisAnnotation = exports.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: '#777', - fontSize: '12px', - cssClass: 'apexcharts-xaxis-annotation-label', - padding: { - left: 5, - right: 5, - top: 2, - bottom: 2 - } - } - } -}; - -var pointAnnotation = exports.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: '#777', - fontSize: '12px', - cssClass: 'apexcharts-point-annotation-label', - padding: { - left: 5, - right: 5, - top: 0, - bottom: 2 - } - } - } -}; - -var yAxisAnnotation = exports.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: '#777', - fontSize: '12px', - cssClass: 'apexcharts-yaxis-annotation-label', - padding: { - left: 5, - right: 5, - top: 0, - bottom: 2 - } - } - } -}; - -var yAxis = exports.yAxis = { - opposite: false, - tickAmount: 6, - max: undefined, - min: undefined, - floating: false, - labels: { - show: true, - maxWidth: 160, - offsetX: 0, - offsetY: 0, - style: { - colors: [], - fontSize: '12px', - cssClass: 'apexcharts-yaxis-label' - }, - formatter: function formatter(val) { - if (typeof val === 'number') { - return val ? val.toFixed(0) : val; - } - return val; - } - }, - 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: '12px', - cssClass: 'apexcharts-yaxis-title' - } - }, - tooltip: { - enabled: false, - offsetX: 0 - }, - crosshairs: { - show: true, - position: 'front', - stroke: { - color: '#b6b6b6', - width: 1, - dashArray: 0 - } - } -}; - -var Options = function () { - function Options() { - _classCallCheck(this, Options); - } - - _createClass(Options, [{ - key: 'init', - value: function init() { - return { - annotations: { - position: 'front', - yaxis: [yAxisAnnotation], - xaxis: [xAxisAnnotation], - points: [pointAnnotation] - }, - chart: { - animations: { - enabled: true, - easing: 'easeinout', // linear, easeout, easein, easeinout - speed: 800, - animateGradually: { - delay: 150, - enabled: true - }, - dynamicAnimation: { - enabled: true, - speed: 350 - } - }, - background: 'transparent', - foreColor: '#373d3f', - dropShadow: { - enabled: false, - enabledSeries: undefined, - top: 2, - left: 2, - blur: 4, - opacity: 0.35 - }, - events: { - beforeMount: undefined, - mounted: undefined, - updated: undefined, - clicked: undefined, - selection: undefined, - dataPointSelection: undefined, - zoomed: undefined, - scrolled: undefined - }, - height: 'auto', - offsetX: 0, - offsetY: 0, - scroller: { - enabled: false, - height: 30, - track: { - height: 2, - background: '#e0e0e0' - }, - thumb: { - height: 2, - background: '#008FFB' - }, - scrollButtons: { - enabled: true, - size: 6, - borderWidth: 2, - borderColor: '#c3c3c3', - fillColor: '#fff' - }, - padding: { - left: 10, - right: 10 - }, - offsetX: 0, - offsetY: 0 - }, - selection: { - enabled: true, - type: 'x', - selectedPoints: undefined, - 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 - }, - stacked: false, - stackType: 'normal', - toolbar: { - show: true, - tools: { - download: true, - selection: true, - zoom: true, - zoomin: true, - zoomout: true, - pan: true, - reset: true - } - }, - 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 - - // stackedLabels: 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: '22px', - color: undefined, - offsetY: -10 - }, - value: { - show: true, - fontSize: '16px', - 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: '22px', - // color: undefined, - // offsetY: -10 - // }, - // value: { - // show: true, - // offsetY: 16, - // fontSize: '16px', - // 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: '14px', - colors: undefined - }, - dropShadow: { - enabled: false, - top: 1, - left: 1, - blur: 1, - opacity: 0.45 - } - }, - fill: { - type: 'solid', - colors: undefined, // array of colors, - opacity: 0.9, - 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', - 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: '14px', - textAnchor: 'start', - offsetY: 0, - offsetX: 0, - formatter: undefined, - labels: { - color: 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: 5, - top: 4, - right: 0, - 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: '#888', - fontSize: '16px' - } - }, - 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: '16px', - color: '#263238' - } - }, - subtitle: { - text: undefined, - align: 'left', - margin: 10, - offsetX: 0, - offsetY: 0, - floating: false, - style: { - fontSize: '14px', - color: '#9699a2' - } - }, - 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: -100, - offsetY: 0 - } - }, - xaxis: { - type: 'category', - categories: [], - labels: { - show: true, - rotate: -45, - rotateAlways: false, - trim: true, - maxHeight: 120, - style: { - colors: [], - fontSize: '12px', - 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' - } - }, - axisBorder: { - show: true, - color: '#78909C', - 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', - 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 - } - }, - yaxis: yAxis, - theme: { - palette: 'palette1', // If defined, it will overwrite config.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; - -/***/ }), -/* 61 */ -/***/ (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); - -/***/ }), -/* 62 */ -/***/ (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.5 -* https://svgdotjs.github.io/ -* -* @copyright Wout Fierens -* @license MIT -* -* BUILT: Sat May 26 2018 22:47:07 GMT+0200 (Mitteleuropäische Sommerzeit) -*/; -(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) { - - // The main wrapping element - var SVG = (this || window).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 !!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.replace(/\n/, '').replace(/<([\w:-]+)([^<]+?)\/>/g, '<$1$2>') + ''; - - // 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(/^/, '').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 Exception('Element not in the dom'); - } else { - // the element is NOT in the dom, throw error - 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) { - 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(text2) { - // act as getter - if (typeof text2 === 'undefined') { - var text2 = ''; - 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) { - text2 += '\n'; - } - - // add content of this node - text2 += children[i].textContent; - } - - return text2; - } - - // 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; -}); - -/***/ }), -/* 63 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -__webpack_require__(93); -module.exports = __webpack_require__(5).Array.includes; - -/***/ }), -/* 64 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -__webpack_require__(90); -__webpack_require__(92); -__webpack_require__(96); -__webpack_require__(91); -__webpack_require__(94); -__webpack_require__(95); -module.exports = __webpack_require__(5).Promise; - -/***/ }), -/* 65 */ -/***/ (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__(102); - -var _Annotations2 = _interopRequireDefault(_Annotations); - -var _Animations = __webpack_require__(14); - -var _Animations2 = _interopRequireDefault(_Animations); - -var _Base = __webpack_require__(103); - -var _Base2 = _interopRequireDefault(_Base); - -var _Config = __webpack_require__(59); - -var _Config2 = _interopRequireDefault(_Config); - -var _Core = __webpack_require__(104); - -var _Core2 = _interopRequireDefault(_Core); - -var _Crosshairs = __webpack_require__(105); - -var _Crosshairs2 = _interopRequireDefault(_Crosshairs); - -var _Dimensions = __webpack_require__(21); - -var _Dimensions2 = _interopRequireDefault(_Dimensions); - -var _Formatters = __webpack_require__(22); - -var _Formatters2 = _interopRequireDefault(_Formatters); - -var _Legend = __webpack_require__(107); - -var _Legend2 = _interopRequireDefault(_Legend); - -var _Series = __webpack_require__(15); - -var _Series2 = _interopRequireDefault(_Series); - -var _TimeScale = __webpack_require__(55); - -var _TimeScale2 = _interopRequireDefault(_TimeScale); - -var _Theme = __webpack_require__(111); - -var _Theme2 = _interopRequireDefault(_Theme); - -var _Tooltip = __webpack_require__(117); - -var _Tooltip2 = _interopRequireDefault(_Tooltip); - -var _Utils = __webpack_require__(1); - -var _Utils2 = _interopRequireDefault(_Utils); - -var _ZoomPanSelection = __webpack_require__(118); - -var _ZoomPanSelection2 = _interopRequireDefault(_ZoomPanSelection); - -var _Scroller = __webpack_require__(109); - -var _Scroller2 = _interopRequireDefault(_Scroller); - -var _Title = __webpack_require__(112); - -var _Title2 = _interopRequireDefault(_Title); - -var _Toolbar = __webpack_require__(56); - -var _Toolbar2 = _interopRequireDefault(_Toolbar); - -var _SubTitle = __webpack_require__(110); - -var _SubTitle2 = _interopRequireDefault(_SubTitle); - -var _Options = __webpack_require__(60); - -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"); } } - -__webpack_require__(129); - -// 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; - - // 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(this.opts).init(); - this.ctx = this; - - this.el = el; - this.core = new _Core2.default(el, this.ctx); - - 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.responsiveConfigOverrided = false; - - this.create = _Utils2.default.bind(this.create, 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, chart: _this }); - } - var beforeMount = _this.w.config.chart.events.beforeMount; - if (typeof beforeMount === 'function') { - beforeMount(_this, _this.w); - } - - _this.fireEvent('beforeMount', [_this, _this.w]); - - var graphData = _this.create(_this.w.config.series); - _this.mount(graphData).then(function () { - var animations = new _Animations2.default(_this.ctx); - animations.showDelayedElements(); - 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) { - // handle error in case no data or element not found - }); - window.addEventListener('resize', _this.windowResize.bind(_this)); - } else { - reject(new Error('Element not found')); - } - }); - } - }, { - 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; - - var gl = this.w.globals; - var cnf = this.w.config; - - if (!this.responsiveConfigOverrided) { - this.checkResponsiveConfig(); - } - - if (this.el === null) { - return null; - } - - this.destroy(); - - this.core.setupElements(); - - if (ser.length === 0) { - var series = new _Series2.default(this.ctx); - series.handleNoData({ appendToRoot: true }); - return null; - } - - this.core.parseData(ser); - this.core.setSparkLineOptions(); - - // this is a good time to set theme colors first - var theme = new _Theme2.default(this.ctx); - theme.init(); - - // labelFormatters should be called before dimensions as in dimensions we need text labels width - var formatters = new _Formatters2.default(this.ctx); - formatters.setLabelFormatters(); - - var title = new _Title2.default(this.ctx); - title.drawTitle(); - - var subtitle = new _SubTitle2.default(this.ctx); - subtitle.drawSubtitle(); - - // legend is calculated here before coreCalculations because it affects the plottable area - new _Legend2.default(this.ctx).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 - 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 - if (w.config.chart.type === 'heatmap') { - gl.yAxisScale[0].result = gl.seriesNames.slice(); - - // get the longest string from the labels array and also apply label formatter to it - var longest = gl.seriesNames.reduce(function (a, b) { - return a.length > b.length ? a : b; - }); - gl.yAxisScale[0].niceMax = longest; - gl.yAxisScale[0].niceMin = longest; - - cnf.yaxis[0].labels.formatter = function (val) { - return val; - }; - } - - // We got plottable area here, next task would be to calculate axis areas - var dimensions = new _Dimensions2.default(this.ctx); - dimensions.plotCoords(); - - if (w.config.chart.type === 'heatmap') { - // adjust yaxis labels for heatmap - gl.yAxisScale[0].result.push(''); - var yDivision = w.globals.gridHeight / w.globals.series.length; - cnf.yaxis[0].labels.offsetY = -(yDivision / 2); - } - - var xyRatios = null; - - if (gl.axisCharts) { - if (cnf.xaxis.crosshairs.position === 'back') { - var crosshairs = new _Crosshairs2.default(this.ctx); - crosshairs.drawXCrosshairs(); - } - if (cnf.yaxis[0].crosshairs.position === 'back') { - var _crosshairs = new _Crosshairs2.default(this.ctx); - _crosshairs.drawYCrosshairs(); - } - - xyRatios = this.core.getCalculatedRatios(); - - if (cnf.xaxis.type === 'datetime') { - var ts = new _TimeScale2.default(this.ctx); - ts.calculateTimeScaleTicks(); - } - } - - 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(); - - return { - elGraph: elGraph, - xyRatios: xyRatios, - elInner: w.globals.dom.elGraphical, - dimensions: { - plot: { - left: w.globals.translateX, - top: w.globals.translateY, - width: w.globals.gridWidth, - height: w.globals.gridHeight - } - } - }; - } - }, { - key: 'mount', - value: function mount() { - var graphData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; - - var w = this.w; - var me = this; - var series = new _Series2.default(me.ctx); - - return new Promise(function (resolve, reject) { - // no data to display - if (me.el === null || graphData === null) { - return reject(new Error('Not enough data to display or element not found')); - } - - var drawAnnotations = function drawAnnotations() { - if (me.w.globals.axisCharts) { - var annotations = new _Annotations2.default(me.ctx); - var yAnnotations = annotations.drawYAxisAnnotations(); - var xAnnotations = annotations.drawXAxisAnnotations(); - var pointAnnotations = annotations.drawPointAnnotations(); - - w.globals.dom.elGraphical.add(yAnnotations); - w.globals.dom.elGraphical.add(xAnnotations); - w.globals.dom.elGraphical.add(pointAnnotations); - - w.globals.delayedElements.push({ el: xAnnotations.node, index: 0 }); - w.globals.delayedElements.push({ el: yAnnotations.node, index: 0 }); - w.globals.delayedElements.push({ el: pointAnnotations.node, index: 0 }); - - // after placing the annotations on svg, set any vertically placed annotations - annotations.setOrientations(w.config.annotations.xaxis); - - // background sizes needs to be calculated after text is drawn, so calling them last - annotations.annotationsBackground(); - } - }; - - me.core.drawAxis(w.config.chart.type, graphData.xyRatios); - - if (w.config.grid.position === 'back') { - me.core.drawGrid(); - } - - if (w.config.annotations.position === 'back') { - drawAnnotations(); - } - - var animations = new _Animations2.default(me.ctx); - animations.showDelayedElements(); - - 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') { - var crosshairs = new _Crosshairs2.default(me.ctx); - crosshairs.drawXCrosshairs(); - } - - if (w.config.yaxis[0].crosshairs.position === 'front') { - var _crosshairs2 = new _Crosshairs2.default(me.ctx); - _crosshairs2.drawYCrosshairs(); - } - - if (w.config.annotations.position === 'front') { - drawAnnotations(); - } - - if (w.globals.allSeriesCollapsed) { - series.handleNoData(); - } else { - // draw tooltips at the end - if (w.config.tooltip.enabled) { - var tooltip = new _Tooltip2.default(me.ctx); - tooltip.drawTooltip(graphData.xyRatios); - } - - if (w.globals.axisCharts && w.globals.dataXY) { - if (w.config.chart.zoom.enabled || w.config.chart.scroller.enabled || w.config.chart.selection.enabled) { - var zoomPanSelection = new _ZoomPanSelection2.default(me.ctx); - zoomPanSelection.init({ - xyRatios: graphData.xyRatios - }); - } - - if (w.config.chart.scroller.enabled) { - var scroller = new _Scroller2.default(me.ctx); - scroller.init(graphData.xyRatios); - } - } else { - w.config.chart.toolbar.tools.zoom = false; - w.config.chart.toolbar.tools.zoomin = false; - w.config.chart.toolbar.tools.zoomout = false; - w.config.chart.toolbar.tools.selection = false; - w.config.chart.toolbar.tools.pan = false; - w.config.chart.toolbar.tools.reset = false; - } - - if (w.config.chart.toolbar.show && !w.globals.allSeriesCollapsed) { - var toolbar = new _Toolbar2.default(me.ctx); - 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 me = this; - var w = this.w; - - me.w.config.chart.animations.dynamicAnimation.enabled = animate; - - if (!redraw) { - w.globals.resized = true; - var series = new _Series2.default(me.ctx); - - me.w.globals.dataChanged = true; - - if (animate && me.w.globals.initialConfig.chart.animations.dynamicAnimation.enabled) { - series.getPreviousPaths(); - } - } - - if (options && (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object') { - this.checkResponsiveConfig(); - this.responsiveConfigOverrided = true; - w.config = _Utils2.default.extend(w.config, options); - } - - return this.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 me = this; - - me.w.config.chart.animations.dynamicAnimation.enabled = animate; - - var series = new _Series2.default(me.ctx); - - me.w.globals.dataChanged = true; - - if (animate) { - series.getPreviousPaths(); - } - - me.w.config.series = newSeries.slice(); - - return this.update(); - } - - /** - * 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 me = this; - - var series = new _Series2.default(me.ctx); - - me.w.globals.dataChanged = true; - - 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; - - return this.update(); - } - }, { - key: 'update', - value: function update() { - var _this2 = this; - - var me = this; - return new Promise(function (resolve, reject) { - var graphData = me.create(me.w.config.series); - - 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', [_this2, _this2.w]); - - resolve(me); - }).catch(function () { - // - }); - }); - } - - /** - * Destroy the chart instance by removing all elements which also clean up event listeners on those elements. - */ - - }, { - key: 'destroy', - value: function destroy() { - if (this.el !== null) { - // remove all child elements - resetting the whole chart - while (this.el.firstChild) { - this.el.removeChild(this.el.firstChild); - } - } - window.removeEventListener('resize', this.windowResize); - this.w.globals.dom = {}; // empty the property which contains all DOM nodes - } - - /** - * 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 same arguments of the fn which are used directly even when calling the methods on class instance - */ - - }, { - key: 'addXaxisAnnotation', - value: function addXaxisAnnotation(opts) { - var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; - var context = arguments[2]; - - var me = this; - if (context) { - me = context; - } - var w = me.w; - var annotations = new _Annotations2.default(me.ctx); - - var parent = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-annotations'); - var index = parent.childNodes.length + 1; - - var xAxisAnno = Object.assign({}, _Options.xAxisAnnotation); - var anno = _Utils2.default.extend(xAxisAnno, opts); - - annotations.addXAxisAnnotation(anno, parent, index); - - // set if orientation changed for xaxis - annotations.setOrientations([anno], index); - - // add background - var xAnnoLabel = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-annotations .apexcharts-xaxis-annotation-label[rel=\'' + index + '\']'); - var elRect = annotations.addBackgroundToAnno(xAnnoLabel, anno, index); - parent.insertBefore(elRect.node, xAnnoLabel); - - if (pushToMemory) { - w.globals.memory.methodsToExec.push({ - context: me, - method: me.addXaxisAnnotation, - params: opts - }); - } - - return context; - } - }, { - key: 'addYaxisAnnotation', - value: function addYaxisAnnotation(opts) { - var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; - var context = arguments[2]; - - var me = this; - if (context) { - me = context; - } - var w = me.w; - var annotations = new _Annotations2.default(me.ctx); - - var parent = w.globals.dom.baseEl.querySelector('.apexcharts-yaxis-annotations'); - var index = parent.childNodes.length + 1; - - var yAxisAnno = Object.assign({}, _Options.yAxisAnnotation); - var anno = _Utils2.default.extend(yAxisAnno, opts); - - annotations.addYAxisAnnotation(anno, parent, index); - - // add background - var yAnnoLabel = w.globals.dom.baseEl.querySelector('.apexcharts-yaxis-annotations .apexcharts-yaxis-annotation-label[rel=\'' + index + '\']'); - var elRect = annotations.addBackgroundToAnno(yAnnoLabel, anno, index); - parent.insertBefore(elRect.node, yAnnoLabel); - - if (pushToMemory) { - w.globals.memory.methodsToExec.push({ - context: me, - method: me.addYaxisAnnotation, - params: opts - }); - } - - return context; - } - }, { - key: 'addPointAnnotation', - value: function addPointAnnotation(opts) { - var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; - var context = arguments[2]; - - var me = this; - if (context) { - me = context; - } - var w = me.w; - var annotations = new _Annotations2.default(me.ctx); - - var parent = w.globals.dom.baseEl.querySelector('.apexcharts-point-annotations'); - var index = parent.childNodes.length + 1; - - var pointAnno = Object.assign({}, _Options.pointAnnotation); - var anno = _Utils2.default.extend(pointAnno, opts); - - annotations.addPointAnnotation(anno, parent, index); - - // add background - var pointLabel = w.globals.dom.baseEl.querySelector('.apexcharts-point-annotations .apexcharts-point-annotation-label[rel=\'' + index + '\']'); - var elRect = annotations.addBackgroundToAnno(pointLabel, anno, index); - parent.insertBefore(elRect.node, pointLabel); - - if (pushToMemory) { - w.globals.memory.methodsToExec.push({ - context: me, - method: me.addPointAnnotation, - params: opts - }); - } - - return context; - } - - // 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(_ref) { - var x = _ref.x, - y = _ref.y, - text = _ref.text, - textAnchor = _ref.textAnchor, - _ref$appendTo = _ref.appendTo, - appendTo = _ref$appendTo === undefined ? '.apexcharts-inner' : _ref$appendTo, - foreColor = _ref.foreColor, - fontSize = _ref.fontSize, - cssClass = _ref.cssClass, - backgroundColor = _ref.backgroundColor, - borderWidth = _ref.borderWidth, - strokeDashArray = _ref.strokeDashArray, - radius = _ref.radius, - borderColor = _ref.borderColor, - _ref$paddingLeft = _ref.paddingLeft, - paddingLeft = _ref$paddingLeft === undefined ? 4 : _ref$paddingLeft, - _ref$paddingRight = _ref.paddingRight, - paddingRight = _ref$paddingRight === undefined ? 4 : _ref$paddingRight, - _ref$paddingBottom = _ref.paddingBottom, - paddingBottom = _ref$paddingBottom === undefined ? 2 : _ref$paddingBottom, - _ref$paddingTop = _ref.paddingTop, - paddingTop = _ref$paddingTop === undefined ? 2 : _ref$paddingTop; - var pushToMemory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; - var context = arguments[2]; - - var me = this; - if (context) { - me = context; - } - var w = me.w; - - var graphics = new _Graphics2.default(me.ctx); - var parentNode = w.globals.dom.baseEl.querySelector(appendTo); - - var elText = graphics.drawText({ - x: x, - y: y, - text: text, - textAnchor: textAnchor || 'start', - fontSize: fontSize || '12px', - foreColor: foreColor || w.config.chart.foreColor, - cssClass: true ? cssClass : '' - }); - - parentNode.appendChild(elText.node); - - var textRect = elText.bbox(); - var elRect = 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: 'checkResponsiveConfig', - value: function checkResponsiveConfig() { - var w = this.w; - var cnf = w.config; - - // check if responsive config exists - if (cnf.responsive !== undefined) { - 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; - } - }, { - 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.core.getSeriesTotalsXRange(minX, maxX); - } - }, { - key: 'getSeriesTotal', - value: function getSeriesTotal() { - return this.w.globals.seriesTotals; - } - }, { - 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 _this3 = this; - - clearTimeout(this.w.globals.resizeTimer); - this.w.globals.resizeTimer = window.setTimeout(function () { - _this3.w.globals.resized = true; - _this3.w.globals.dataChanged = false; - - // we need to redraw the whole chart on window resize (with a small delay). - var graphData = _this3.create(_this3.w.config.series); - _this3.mount(graphData); - }, 150); - } - }], [{ - key: 'exec', - value: function exec(chartID, fn, opts) { - var chart = this.getChartByID(chartID); - - if (chart) { - switch (fn) { - case 'updateOptions': - { - return chart.updateOptions(opts); - } - case 'updateSeries': - { - return chart.updateSeries(opts); - } - case 'appendData': - { - return chart.appendData(opts); - } - case 'addXaxisAnnotation': - { - return chart.addXaxisAnnotation(opts); - } - case 'addYaxisAnnotation': - { - return chart.addYaxisAnnotation(opts); - } - case 'addPointAnnotation': - { - return chart.addPointAnnotation(opts); - } - case 'destroy': - { - return chart.destroy(); - } - } - } - } - }, { - 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; - -/***/ }), -/* 66 */ -/***/ (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; -}; - -/***/ }), -/* 67 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var ctx = __webpack_require__(18); -var call = __webpack_require__(72); -var isArrayIter = __webpack_require__(71); -var anObject = __webpack_require__(6); -var toLength = __webpack_require__(51); -var getIterFn = __webpack_require__(88); -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; - -/***/ }), -/* 68 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = !__webpack_require__(9) && !__webpack_require__(41)(function () { - return Object.defineProperty(__webpack_require__(25)('div'), 'a', { get: function get() { - return 7; - } }).a != 7; -}); - -/***/ }), -/* 69 */ -/***/ (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); -}; - -/***/ }), -/* 70 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// fallback for non-array-like ES3 and non-enumerable old V8 strings -var cof = __webpack_require__(17); -// eslint-disable-next-line no-prototype-builtins -module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { - return cof(it) == 'String' ? it.split('') : Object(it); -}; - -/***/ }), -/* 71 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// check on default Array iterator -var Iterators = __webpack_require__(12); -var ITERATOR = __webpack_require__(3)('iterator'); -var ArrayProto = Array.prototype; - -module.exports = function (it) { - return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); -}; - -/***/ }), -/* 72 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// call something on iterator step with safe closing on error -var anObject = __webpack_require__(6); -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; - } -}; - -/***/ }), -/* 73 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var create = __webpack_require__(77); -var descriptor = __webpack_require__(47); -var setToStringTag = __webpack_require__(28); -var IteratorPrototype = {}; - -// 25.1.2.1.1 %IteratorPrototype%[@@iterator]() -__webpack_require__(7)(IteratorPrototype, __webpack_require__(3)('iterator'), function () { - return this; -}); - -module.exports = function (Constructor, NAME, next) { - Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) }); - setToStringTag(Constructor, NAME + ' Iterator'); -}; - -/***/ }), -/* 74 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var ITERATOR = __webpack_require__(3)('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; -}; - -/***/ }), -/* 75 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -module.exports = function (done, value) { - return { value: value, done: !!done }; -}; - -/***/ }), -/* 76 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var global = __webpack_require__(2); -var macrotask = __webpack_require__(50).set; -var Observer = global.MutationObserver || global.WebKitMutationObserver; -var process = global.process; -var Promise = global.Promise; -var isNode = __webpack_require__(17)(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; - }; -}; - -/***/ }), -/* 77 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) -var anObject = __webpack_require__(6); -var dPs = __webpack_require__(78); -var enumBugKeys = __webpack_require__(40); -var IE_PROTO = __webpack_require__(29)('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__(25)('iframe'); - var i = enumBugKeys.length; - var lt = '<'; - var gt = '>'; - var iframeDocument; - iframe.style.display = 'none'; - __webpack_require__(42).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); -}; - -/***/ }), -/* 78 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var dP = __webpack_require__(20); -var anObject = __webpack_require__(6); -var getKeys = __webpack_require__(44); - -module.exports = __webpack_require__(9) ? 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; -}; - -/***/ }), -/* 79 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) -var has = __webpack_require__(19); -var toObject = __webpack_require__(85); -var IE_PROTO = __webpack_require__(29)('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; -}; - -/***/ }), -/* 80 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var has = __webpack_require__(19); -var toIObject = __webpack_require__(31); -var arrayIndexOf = __webpack_require__(39)(false); -var IE_PROTO = __webpack_require__(29)('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; -}; - -/***/ }), -/* 81 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var redefine = __webpack_require__(13); -module.exports = function (target, src, safe) { - for (var key in src) { - redefine(target, key, src[key], safe); - }return target; -}; - -/***/ }), -/* 82 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var global = __webpack_require__(2); -var dP = __webpack_require__(20); -var DESCRIPTORS = __webpack_require__(9); -var SPECIES = __webpack_require__(3)('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; - } - }); -}; - -/***/ }), -/* 83 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var toInteger = __webpack_require__(30); -var defined = __webpack_require__(24); -// 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; - }; -}; - -/***/ }), -/* 84 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var toInteger = __webpack_require__(30); -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); -}; - -/***/ }), -/* 85 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// 7.1.13 ToObject(argument) -var defined = __webpack_require__(24); -module.exports = function (it) { - return Object(defined(it)); -}; - -/***/ }), -/* 86 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -// 7.1.1 ToPrimitive(input [, PreferredType]) -var isObject = __webpack_require__(11); -// 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"); -}; - -/***/ }), -/* 87 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var global = __webpack_require__(2); -var navigator = global.navigator; - -module.exports = navigator && navigator.userAgent || ''; - -/***/ }), -/* 88 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var classof = __webpack_require__(23); -var ITERATOR = __webpack_require__(3)('iterator'); -var Iterators = __webpack_require__(12); -module.exports = __webpack_require__(5).getIteratorMethod = function (it) { - if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)]; -}; - -/***/ }), -/* 89 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var addToUnscopables = __webpack_require__(38); -var step = __webpack_require__(75); -var Iterators = __webpack_require__(12); -var toIObject = __webpack_require__(31); - -// 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__(43)(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'); - -/***/ }), -/* 90 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -// 19.1.3.6 Object.prototype.toString() - -var classof = __webpack_require__(23); -var test = {}; -test[__webpack_require__(3)('toStringTag')] = 'z'; -if (test + '' != '[object z]') { - __webpack_require__(13)(Object.prototype, 'toString', function toString() { - return '[object ' + classof(this) + ']'; - }, true); -} - -/***/ }), -/* 91 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var LIBRARY = __webpack_require__(26); -var global = __webpack_require__(2); -var ctx = __webpack_require__(18); -var classof = __webpack_require__(23); -var $export = __webpack_require__(10); -var isObject = __webpack_require__(11); -var aFunction = __webpack_require__(16); -var anInstance = __webpack_require__(66); -var forOf = __webpack_require__(67); -var speciesConstructor = __webpack_require__(49); -var task = __webpack_require__(50).set; -var microtask = __webpack_require__(76)(); -var newPromiseCapabilityModule = __webpack_require__(27); -var perform = __webpack_require__(45); -var userAgent = __webpack_require__(87); -var promiseResolve = __webpack_require__(46); -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__(3)('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__(81)($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__(82)(PROMISE); -Wrapper = __webpack_require__(5)[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__(74)(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; - } -}); - -/***/ }), -/* 92 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var $at = __webpack_require__(83)(true); - -// 21.1.3.27 String.prototype[@@iterator]() -__webpack_require__(43)(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 }; -}); - -/***/ }), -/* 93 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -// https://github.com/tc39/Array.prototype.includes - -var $export = __webpack_require__(10); -var $includes = __webpack_require__(39)(true); - -$export($export.P, 'Array', { - includes: function includes(el /* , fromIndex = 0 */) { - return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -__webpack_require__(38)('includes'); - -/***/ }), -/* 94 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -// https://github.com/tc39/proposal-promise-finally - - -var $export = __webpack_require__(10); -var core = __webpack_require__(5); -var global = __webpack_require__(2); -var speciesConstructor = __webpack_require__(49); -var promiseResolve = __webpack_require__(46); - -$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); - } }); - -/***/ }), -/* 95 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -// https://github.com/tc39/proposal-promise-try - -var $export = __webpack_require__(10); -var newPromiseCapability = __webpack_require__(27); -var perform = __webpack_require__(45); - -$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; - } }); - -/***/ }), -/* 96 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var $iterators = __webpack_require__(89); -var getKeys = __webpack_require__(44); -var redefine = __webpack_require__(13); -var global = __webpack_require__(2); -var hide = __webpack_require__(7); -var Iterators = __webpack_require__(12); -var wks = __webpack_require__(3); -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); - } - } -} - -/***/ }), -/* 97 */ -/***/ (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 + ' */'; -} - -/***/ }), -/* 98 */ -/***/ (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__(52); - -var _Bar3 = _interopRequireDefault(_Bar2); - -var _Fill = __webpack_require__(8); - -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', - '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 - }); - - var lineFill = w.config.stroke.colors[realIndex]; - - var delay = j / w.config.chart.animations.animateGradually.delay * (w.config.chart.animations.speed / w.globals.dataPoints) / 2.4; - - var renderedPath = _this2.graphics.renderPaths({ - i: i, - realIndex: realIndex, - pathFrom: pathFrom, - pathTo: pathTo, - stroke: lineFill, - strokeWidth: strokeWidth, - fill: pathFill, - animationDelay: delay, - initialSpeed: w.config.chart.animations.speed, - dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed, - className: 'apexcharts-bar-area', - id: 'apexcharts-bar-area' - }); - - elSeries.add(renderedPath); - - _this2.setSelectedBarFilter(renderedPath, realIndex, j); - - var dataLabels = _this2.bar.calculateBarDataLabels({ x: x, y: y, i: i, j: j, realIndex: realIndex, series: series, barHeight: barHeight, barWidth: barWidth, visibleSeries: 0, renderedPath: renderedPath }); - - if (dataLabels !== null) { - elDataLabelsWrap.add(dataLabels); - } - - elSeries.add(elDataLabelsWrap); - }; - - 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.dataXY) { - xDivision = w.globals.gridWidth / this.totalItems; - barWidth = xDivision / 2; - } 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 = zeroW; - 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.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.dataXY) { - 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 = w.globals.gridHeight - zeroH; - 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.classList.add('apexcharts-backgroundBar'); - } - - x = x + xDivision; - - return { - pathTo: pathTo, - pathFrom: pathFrom, - x: 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.includes(s) && s === this.endingShapeOnSeriesNumber) { - this.endingShapeOnSeriesNumber -= 1; - } - } - } - }]); - - return BarStacked; -}(_Bar3.default); - -exports.default = BarStacked; - -/***/ }), -/* 99 */ -/***/ (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__(33); - -var _DataLabels2 = _interopRequireDefault(_DataLabels); - -var _Animations = __webpack_require__(14); - -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__(4); - -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', - '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.config.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); - } - - return ret; - } - }, { - key: 'determineHeatColor', - value: function determineHeatColor(i, j) { - var w = this.w; - - var val = w.globals.series[i][j]; - - var color = w.config.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; - - 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; - -/***/ }), -/* 100 */ -/***/ (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 _Fill = __webpack_require__(8); - -var _Fill2 = _interopRequireDefault(_Fill); - -var _DataLabels = __webpack_require__(33); - -var _DataLabels2 = _interopRequireDefault(_DataLabels); - -var _Markers = __webpack_require__(34); - -var _Markers2 = _interopRequireDefault(_Markers); - -var _Scatter = __webpack_require__(54); - -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 - * @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]; - - categoryAxisCorrection = xDivision / 2; - - var x = w.globals.padHorizontal + categoryAxisCorrection; - var y = 1; - if (w.globals.dataXY) { - 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' - }); - - // points - var elPointsMain = graphics.group({ - class: 'apexcharts-series-markers-wrap' - }); - - // eldatalabels - var elDataLabelsWrap = graphics.group({ - class: 'apexcharts-datalabels' - }); - - for (var cs = 0; cs < w.globals.collapsedSeries.length; cs++) { - if (w.globals.collapsedSeries[cs].index === realIndex) { - elSeries.node.classList.add('apexcharts-series-collapsed'); - } - } - - 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 = zeroY; - - 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; - lineYPosition = firstPrevY.lineYPosition; - - 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, zeroY); - break; - } - } - } else { - linePath = graphics.move(prevX, prevY); - areaPath = graphics.move(prevX, zeroY) + 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.dataXY) { - 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 - 1 / 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 - 1 / 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, - zeroY: zeroY, - 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); - 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 }); - } - - 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.config.stroke.colors[realIndex]; - } - - for (var p = 0; p < linePaths.length; p++) { - var renderedPath = graphics.renderPaths({ - i: i, - realIndex: realIndex, - pathFrom: pathFromLine, - pathTo: linePaths[p], - stroke: lineFill, - strokeWidth: Array.isArray(w.config.stroke.width) ? w.config.stroke.width[realIndex] : w.config.stroke.width, - fill: 'none', - animationDelay: i, - initialSpeed: w.config.chart.animations.speed, - dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed, - className: 'apexcharts-line', - id: 'apexcharts-line' - }); - - 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({ - i: i, - realIndex: realIndex, - pathFrom: pathFromArea, - pathTo: areaPaths[_p], - stroke: 'none', - strokeWidth: 0, - fill: pathFill, - animationDelay: i, - initialSpeed: w.config.chart.animations.speed, - dataChangeSpeed: w.config.chart.animations.dynamicAnimation.speed, - className: 'apexcharts-area', - id: 'apexcharts-area' - }); - - 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, - zeroY = _ref.zeroY, - 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, pY) + graphics.curve(pX + length, pY, x - length, y, x + 1, y) + graphics.line(x + 1, zeroY) + graphics.line(pX, zeroY) + '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, zeroY, x, zeroY, x, zeroY) + '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, zeroY) + graphics.move(x, y); - } - if (series[i][j] === null) { - linePath = linePath + graphics.move(x, y); - areaPath = areaPath + graphics.move(x, zeroY); - } - 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, zeroY) + '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.dataXY) { - 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) { - if (i > 0) { - // check again for undefined value (undefined value will occur when we clear the series while user clicks on legend to hide serieses) - if (typeof series[i][0] === 'undefined') { - 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; - -/***/ }), -/* 101 */ -/***/ (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__(53); - -var _Pie3 = _interopRequireDefault(_Pie2); - -var _Utils = __webpack_require__(1); - -var _Utils2 = _interopRequireDefault(_Utils); - -var _Fill = __webpack_require__(8); - -var _Fill2 = _interopRequireDefault(_Fill); - -var _Graphics = __webpack_require__(0); - -var _Graphics2 = _interopRequireDefault(_Graphics); - -var _Filters = __webpack_require__(4); - -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; - - 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 = void 0, - centerX = void 0; - centerY = w.globals.gridHeight / 2; - centerX = w.globals.gridWidth / 2; - - var size = w.globals.gridWidth / 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.config.fill.colors; - - var lineColorArr = w.config.stroke.colors !== undefined ? w.config.stroke.colors : w.config.colors; - - if (w.config.plotOptions.radialBar.track.show) { - var elTracks = this.drawTracks({ - size: size, - centerX: centerX, - centerY: centerY, - colorArr: colorArr, - lineColorArr: lineColorArr, - series: series - }); - elSeries.add(elTracks); - } - - var elG = this.drawArcs({ - size: size, - centerX: centerX, - centerY: centerY, - colorArr: colorArr, - lineColorArr: lineColorArr, - 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 = opts.size * (100 - parseInt(w.config.plotOptions.radialBar.hollow.size)) / 100 / (opts.series.length + 1) - this.margin; - 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 = opts.size * (100 - parseInt(w.config.plotOptions.radialBar.hollow.size)) / 100 / (opts.series.length + 1) - this.margin; - opts.size = opts.size - strokeWidth / 2; - - var hollowFillImg = w.config.plotOptions.radialBar.hollow.image; - 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 randID = (Math.random() + 1).toString(36).substring(4); - var hollowRadius = hollowSize - w.config.plotOptions.radialBar.hollow.margin; - - if (w.config.plotOptions.radialBar.hollow.image !== undefined) { - 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); - } - } - } - - 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 (w.config.plotOptions.radialBar.dataLabels.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-radial-series apexcharts-series' - }); - g.add(elRadialBarArc); - - elRadialBarArc.attr({ - id: 'apexcharts-series-' + i, - 'rel': i + 1 - }); - - 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); - } - - elPath.node.addEventListener('mouseenter', graphics.pathMouseEnter.bind(this, elPath)); - elPath.node.addEventListener('mouseleave', graphics.pathMouseLeave.bind(this, 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, - 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: '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 = w.config.plotOptions.radialBar.dataLabels.value.formatter; - val = lbFormatter(val); - - if (elLabel !== null) { - elLabel.textContent = name; - } - - if (elValue !== null) { - elValue.textContent = val; - } - - if (w.config.plotOptions.radialBar.dataLabels.name.color === undefined) { - labelColor = w.config.colors[parseInt(el.parentNode.getAttribute('rel')) - 1]; - } else { - labelColor = w.config.plotOptions.radialBar.dataLabels.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 (w.config.plotOptions.radialBar.dataLabels.showOn !== 'always' || w.globals.series.length > 1) { - if (dataLabelsGroup !== null) { - dataLabelsGroup.style.opacity = 0; - } - } - } - }, { - 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 (w.config.plotOptions.radialBar.dataLabels.name.color === undefined) { - labelColor = w.config.colors[0]; - } else { - labelColor = w.config.plotOptions.radialBar.dataLabels.name.color; - } - - if (w.config.plotOptions.radialBar.dataLabels.value.color === undefined) { - valueColor = w.config.chart.foreColor; - } else { - valueColor = w.config.plotOptions.radialBar.dataLabels.value.color; - } - - var lbFormatter = w.config.plotOptions.radialBar.dataLabels.value.formatter; - var val = lbFormatter(w.globals.series[0]); - - if (w.config.plotOptions.radialBar.dataLabels.name.show) { - var elLabel = graphics.drawText({ - x: x, - y: y + parseInt(w.config.plotOptions.radialBar.dataLabels.name.offsetY), - text: w.globals.seriesNames[0], - textAnchor: 'middle', - foreColor: labelColor, - fontSize: w.config.plotOptions.radialBar.dataLabels.name.fontSize - }); - elLabel.node.classList.add('apexcharts-datalabel-label'); - g.add(elLabel); - } - - if (w.config.plotOptions.radialBar.dataLabels.value.show) { - var valOffset = w.config.plotOptions.radialBar.dataLabels.name.show ? parseInt(w.config.plotOptions.radialBar.dataLabels.value.offsetY) + 16 : w.config.plotOptions.radialBar.dataLabels.value.offsetY; - - var elValue = graphics.drawText({ - x: x, - y: y + valOffset, - text: val, - textAnchor: 'middle', - foreColor: valueColor, - fontSize: w.config.plotOptions.radialBar.dataLabels.value.fontSize - }); - elValue.node.classList.add('apexcharts-datalabel-value'); - g.add(elValue); - } - - return g; - } - }]); - - return Radial; -}(_Pie3.default); - -exports.default = Radial; - -/***/ }), -/* 102 */ -/***/ (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 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.xDivision = this.w.globals.gridWidth / this.w.globals.dataPoints; - } - - _createClass(Annotations, [{ - key: 'addXAxisAnnotation', - value: function addXAxisAnnotation(anno, parent, index) { - var w = this.w; - var graphics = new _Graphics2.default(this.ctx); - - var strokeDashArray = anno.strokeDashArray; - - var x1 = (anno.x - w.globals.minX) / (w.globals.xRange / w.globals.gridWidth); - - var line = 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 = graphics.drawText({ - x: x1 + anno.label.offsetX, - y: textY + anno.label.offsetY, - text: text, - textAnchor: anno.label.textAnchor, - fontSize: anno.label.style.fontSize, - 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 graphics = new _Graphics2.default(this.ctx); - - var elg = 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 graphics = new _Graphics2.default(this.ctx); - - 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 = 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 = graphics.drawText({ - x: textX + anno.label.offsetX, - y: y1 + anno.label.offsetY - 3, - text: text, - textAnchor: anno.label.textAnchor, - fontSize: anno.label.style.fontSize, - 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 graphics = new _Graphics2.default(this.ctx); - - var elg = 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 graphics = new _Graphics2.default(this.ctx); - - 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 = graphics.drawMarker(x, pointY, optsPoints); - parent.appendChild(point.node); - - var text = anno.label.text ? anno.label.text : ''; - - var elText = graphics.drawText({ - x: x + anno.label.offsetX, - y: y + anno.label.offsetY, - text: text, - textAnchor: anno.label.textAnchor, - fontSize: anno.label.style.fontSize, - 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 graphics = new _Graphics2.default(this.ctx); - - var elg = 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 annoIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - - var w = this.w; - var graphics = new _Graphics2.default(this.ctx); - - 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 = 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 graphics = new _Graphics2.default(this.ctx); - - 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 = 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 _this4 = this; - - var w = this.w; - - w.config.annotations.xaxis.map(function (anno, i) { - var xAnnoLabel = w.globals.dom.baseEl.querySelector('.apexcharts-xaxis-annotations .apexcharts-xaxis-annotation-label[rel=\'' + i + '\']'); - - var parent = xAnnoLabel.parentNode; - var elRect = _this4.addBackgroundToAnno(xAnnoLabel, anno, i); - - parent.insertBefore(elRect.node, xAnnoLabel); - }); - - w.config.annotations.yaxis.map(function (anno, i) { - var yAnnoLabel = w.globals.dom.baseEl.querySelector('.apexcharts-yaxis-annotations .apexcharts-yaxis-annotation-label[rel=\'' + i + '\']'); - - var parent = yAnnoLabel.parentNode; - var elRect = _this4.addBackgroundToAnno(yAnnoLabel, anno, i); - - parent.insertBefore(elRect.node, yAnnoLabel); - }); - - w.config.annotations.points.map(function (anno, i) { - var pointAnnoLabel = w.globals.dom.baseEl.querySelector('.apexcharts-point-annotations .apexcharts-point-annotation-label[rel=\'' + i + '\']'); - - var parent = pointAnnoLabel.parentNode; - var elRect = _this4.addBackgroundToAnno(pointAnnoLabel, anno, i); - - parent.insertBefore(elRect.node, pointAnnoLabel); - }); - } - }]); - - return Annotations; -}(); - -module.exports = Annotations; - -/***/ }), -/* 103 */ -/***/ (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__(59); - -var _Config2 = _interopRequireDefault(_Config); - -var _Globals = __webpack_require__(121); - -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; - -/***/ }), -/* 104 */ -/***/ (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__(52); - -var _Bar2 = _interopRequireDefault(_Bar); - -var _BarStacked = __webpack_require__(98); - -var _BarStacked2 = _interopRequireDefault(_BarStacked); - -var _HeatMap = __webpack_require__(99); - -var _HeatMap2 = _interopRequireDefault(_HeatMap); - -var _Pie = __webpack_require__(53); - -var _Pie2 = _interopRequireDefault(_Pie); - -var _Radial = __webpack_require__(101); - -var _Radial2 = _interopRequireDefault(_Radial); - -var _Line = __webpack_require__(100); - -var _Line2 = _interopRequireDefault(_Line); - -var _Graphics = __webpack_require__(0); - -var _Graphics2 = _interopRequireDefault(_Graphics); - -var _DateTime = __webpack_require__(37); - -var _DateTime2 = _interopRequireDefault(_DateTime); - -var _Grid = __webpack_require__(119); - -var _Grid2 = _interopRequireDefault(_Grid); - -var _XAxis = __webpack_require__(35); - -var _XAxis2 = _interopRequireDefault(_XAxis); - -var _YAxis = __webpack_require__(36); - -var _YAxis2 = _interopRequireDefault(_YAxis); - -var _Range = __webpack_require__(108); - -var _Range2 = _interopRequireDefault(_Range); - -var _Utils = __webpack_require__(1); - -var _Utils2 = _interopRequireDefault(_Utils); - -var _ClassListPolyfill = __webpack_require__(127); - -var _ClassListPolyfill2 = _interopRequireDefault(_ClassListPolyfill); - -var _Series = __webpack_require__(15); - -var _Series2 = _interopRequireDefault(_Series); - -var _svg = __webpack_require__(62); - -var SVG = _interopRequireWildcard(_svg); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -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__(61); -__webpack_require__(124); -__webpack_require__(123); -__webpack_require__(126); -__webpack_require__(125); -/** - * 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; - } - - // 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 axisChartsArryTypes = ['line', 'bar', 'area', 'scatter', 'bubble', 'heatmap']; - - var xyChartsArrTypes = ['line', 'bar', 'area', 'scatter', 'bubble']; - - gl.axisCharts = axisChartsArryTypes.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) - }); - gl.dom.elWrap.style.background = cnf.chart.background; - this.el.appendChild(gl.dom.elWrap); - - gl.dom.Paper = new SVG.Doc(gl.dom.elWrap); - gl.dom.Paper.attr({ - class: 'apexcharts-svg', - 'xmlns:data': 'ApexChartsNS', - transform: 'translate(' + cnf.chart.offsetX + ', ' + cnf.chart.offsetY + ')' - }); - - 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); - - if (_Utils2.default.isIE()) { - _ClassListPolyfill2.default.fnClassList(); - } - } - }, { - 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: [] - }; - - 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 { - // user has specified type, but it is not valid (other than line/area/column) - // make default to line - lineSeries.series.push(series); - lineSeries.i.push(st); - } - gl.comboCharts = true; - } else { - lineSeries.series.push(series); - lineSeries.i.push(st); - } - }); - - var line = new _Line2.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)); - } - } 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 '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: 'setSparkLineOptions', - value: function setSparkLineOptions() { - var w = this.w; - var cnf = w.config; - - if (w.config.chart.sparkline.enabled) { - cnf.grid.show = false; - cnf.xaxis.labels.show = false; - cnf.legend.show = false; - cnf.chart.toolbar.show = false; - cnf.chart.zoom.enabled = false; - cnf.xaxis.tooltip.enabled = false; - cnf.xaxis.axisBorder.show = false; - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = cnf.yaxis[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var yaxe = _step.value; - - yaxe.tooltip.enabled = false; - yaxe.labels.show = false; - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - cnf.chart.scroller.enabled = false; - cnf.dataLabels.enabled = false; - } - } - }, { - 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 === '%') { - gl.svgHeight = elDim[1] * parseInt(cnf.chart.height) / 100; - } else { - gl.svgHeight = parseInt(cnf.chart.height); - } - } else { - if (gl.axisCharts) { - gl.svgHeight = gl.svgWidth / 1.5; - } 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); - } - }, { - key: 'resetGlobals', - value: function resetGlobals() { - var _this = this; - - var gl = this.w.globals; - gl.series = []; - gl.seriesPercent = []; - gl.seriesX = []; - gl.seriesZ = []; - gl.seriesNames = []; - gl.seriesTotals = []; - gl.stackedSeriesTotals = []; - gl.labels = []; - gl.timelineLabels = []; - gl.noLabelsProvided = false; - gl.timescaleTicks = []; - 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.dataXY = false; - gl.dataXYZ = 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; - } - } - - // Segregate user provided data into appropriate vars - - }, { - key: 'parseData', - value: function parseData(ser) { - var _this2 = this; - - var w = this.w; - var cnf = w.config; - var gl = w.globals; - - var sr = new _Series2.default(this.ctx); - - gl.ignoreYAxisIndexes = gl.collapsedSeries.map(function (collapsed, i) { - if (_this2.w.globals.isMultipleYAxis) { - return collapsed.index; - } - }); - - // to determine whether data is in XY format or array format, we use original config - var series = cnf.series.slice(); - var activeSeriesIndex = sr.getActiveConfigSeriesIndex(); - - // given format is [{x, y}, {x, y}] - var isFormatXY = function isFormatXY() { - 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]] - var isFormat2DArray = function isFormat2DArray() { - 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; - } - }; - - var dt = new _DateTime2.default(this.ctx); - - var fallbackToCategory = false; - - this.resetGlobals(); - this.isMultipleY(); - - if (gl.axisCharts) { - for (var i = 0; i < series.length; i++) { - var twoDSeries = []; - var threeDSeries = []; - var twoDseriesX = []; - - if (typeof series[i].data === 'undefined') { - console.warn("It is a possibility that you may have not included 'data' property in series."); - return; - } - - var isMultiFormat = function isMultiFormat() { - return isFormatXY() || isFormat2DArray(); - }; - - if (isMultiFormat()) { - if (isFormat2DArray()) { - for (var j = 0; j < ser[i].data.length; j++) { - if (typeof ser[i].data[j][1] !== 'undefined') { - 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(); - twoDseriesX.push(ts); - } else { - 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') { - threeDSeries.push(ser[i].data[_j][2]); - gl.dataXYZ = true; - } - } - } else if (isFormatXY()) { - for (var _j2 = 0; _j2 < ser[i].data.length; _j2++) { - if (typeof ser[i].data[_j2].y !== 'undefined') { - twoDSeries.push(ser[i].data[_j2].y); - } - - var isXString = typeof ser[i].data[_j2].x === 'string'; - var isXDate = dt.isValidDate(ser[i].data[_j2].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') { - twoDseriesX.push(new Date(ser[i].data[_j2].x).getTime()); - } else { - // a category and not a numeric x value - fallbackToCategory = true; - twoDseriesX.push(ser[i].data[_j2].x); - } - } else if (isXDate) { - if (cnf.xaxis.type === 'datetime') { - twoDseriesX.push(new Date(ser[i].data[_j2].x.toString()).getTime()); - } else { - twoDseriesX.push(parseInt(ser[i].data[_j2].x)); - } - } else { - fallbackToCategory = true; - twoDseriesX.push(parseInt(ser[i].data[_j2].x)); - } - } else { - // a numeric value in x property - twoDseriesX.push(ser[i].data[_j2].x); - } - } - - if (typeof series[i].data[0].z !== 'undefined') { - for (var t = 0; t < series[i].data.length; t++) { - threeDSeries.push(series[i].data[t].z); - } - gl.dataXYZ = true; - } - } - - gl.series.push(twoDSeries); - gl.labels.push(twoDseriesX); - gl.seriesX.push(twoDseriesX); - - if (!fallbackToCategory) { - gl.dataXY = true; - } - } else { - if (cnf.xaxis.type === 'datetime') { - // user didn't supplied [{x,y}] or [[x,y]], but single array in data. - // Also labels were supplied differently - gl.dataXY = true; - var dates = cnf.labels.length > 0 ? cnf.labels.slice() : cnf.xaxis.categories.slice(); - - for (var _j3 = 0; _j3 < dates.length; _j3++) { - if (typeof dates[_j3] === 'string') { - var isDate = dt.isValidDate(dates[_j3]); - if (isDate) { - twoDseriesX.push(new Date(dates[_j3]).getTime()); - } - } - } - - gl.seriesX.push(twoDseriesX); - } - gl.labels.push(twoDseriesX); - gl.series.push(ser[i].data); - } - gl.seriesZ.push(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)); - } - } - } else { - 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)); - } - } - } - - // maxValsInArrayIndex is the index of series[] which has the largest number of items - gl.maxValsInArrayIndex = gl.series.map(function (a) { - return a.length; - }).indexOf(Math.max.apply(Math, gl.series.map(function (a) { - return a.length; - }))); - - // 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.getSeriesTotals(); - if (gl.axisCharts) { - this.getStackedSeriesTotals(); - } - - this.getPercentSeries(); - - // user didn't provide a [[x,y],[x,y]] series, but a named series - if (!gl.dataXY) { - // 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 (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 _i2 = 0; _i2 < gl.series[gl.maxValsInArrayIndex].length; _i2++) { - labelArr.push(_i2 + 1); - } - - for (var _i3 = 0; _i3 < ser.length; _i3++) { - gl.seriesX.push(labelArr); - } - - gl.dataXY = true; - } - - // no series to pull labels from, put a 0-10 series - if (labelArr.length === 0) { - labelArr = [0, 10]; - for (var _i4 = 0; _i4 < ser.length; _i4++) { - gl.seriesX.push(labelArr); - } - } - - gl.labels = labelArr; - gl.noLabelsProvided = true; - } - } - } - - /** - * @memberof Core - * 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] - **/ - - }, { - 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; - } - - // 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; - }); - } else { - // axis charts - supporting multiple series - return this.w.config.series[index].data.reduce(function (acc, cur) { - return acc + cur; - }); - } - } - - /** - * @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 Core - * 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; - }); - var _percent = 100 * ser / _total; - seriesPercent.push(_percent); - } - - return seriesPercent; - }); - } - - /* - ** All the calculations for setting range in charts will be done here - */ - - }, { - key: 'coreCalculations', - value: function coreCalculations() { - var range = new _Range2.default(this.ctx, this.checkComboCharts); - range.init(); - } - }, { - 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 _i5 = 0; _i5 < gl.yRange.length; _i5++) { - yRatio.push(gl.yRange[_i5] / 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 _i6 = 0; _i6 < yRatio.length; _i6++) { - baseLineY.push(-gl.minYArr[_i6] / yRatio[_i6]); - } - } 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, st) { - 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.includes(index)) { - elYaxis = yAxis.drawYaxis(xyRatios, index); - gl.dom.Paper.add(elYaxis); - } - }); - } - } - - cnf.yaxis.map(function (yaxe, index) { - if (!gl.ignoreYAxisIndexes.includes(index)) { - 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); - - w.globals.dom.elGridRect = graphics.drawRect(0, 0, w.globals.gridWidth, w.globals.gridHeight + 1, 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; - -/***/ }), -/* 105 */ -/***/ (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__(4); - -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; - -/***/ }), -/* 106 */ -/***/ (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 = 'apexcharts-' + w.globals.cuid + '.svg'; - document.body.appendChild(downloadLink); - downloadLink.click(); - document.body.removeChild(downloadLink); - } - }]); - - return Exports; -}(); - -exports.default = Exports; - -/***/ }), -/* 107 */ -/***/ (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__(21); - -var _Dimensions2 = _interopRequireDefault(_Dimensions); - -var _Graphics = __webpack_require__(0); - -var _Graphics2 = _interopRequireDefault(_Graphics); - -var _Series = __webpack_require__(15); - -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 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.config.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; - - var virtualText = void 0; - - 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) { - virtualText = graphics.drawText({ - x: this.existingWidth, - y: 0, - foreColor: 'transparent', - opacity: 0, - text: text, - cssClass: 'apexcharts-virtual-text', - fontSize: fontSize - }); - - w.globals.dom.Paper.add(virtualText); - var rect = virtualText.bbox(); - - 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; - } else if (w.config.legend.position === 'top') { - y = 0; - } - - y = y + this.rowHeight * currentRow; - } else { - virtualText = graphics.drawText({ - x: 0, - y: this.existingHeight, - foreColor: 'transparent', - opacity: 0, - text: text, - textAnchor: 'start', - cssClass: 'apexcharts-virtual-text', - fontSize: fontSize - }); - - w.globals.dom.Paper.add(virtualText); - - var _rect = virtualText.bbox(); - - 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; - } - - // we are done with virtual texts, remove it - virtualText.node.parentNode.removeChild(virtualText.node); - - 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.useSeriesColors ? w.config.colors[i] : w.config.legend.labels.color, - text: text, - textAnchor: w.config.legend.textAnchor, - fontSize: fontSize, - 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'); - } - } - - 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 x = w.config.legend.containerMargin.left - w.config.legend.containerMargin.right; - var y = w.config.legend.containerMargin.top - w.config.legend.markers.size - 2; - - if (w.config.legend.position === 'bottom') { - if (w.globals.dataXY && w.config.chart.scroller.enabled) { - y = y - w.config.chart.scroller.height + 1; - } - } - - if (w.config.legend.position === 'top') { - var dim = new _Dimensions2.default(this.ctx); - var titleH = dim.getMainTitleCoords().height; - var subtitleH = dim.getSubTitleCoords().height; - - y = y + (titleH > 0 ? titleH - 10 : 0) + (subtitleH > 0 ? subtitleH - 10 : 0); - } - - 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.getMainTitleCoords(); - var subtitleRect = dimensions.getSubTitleCoords(); - - 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) { - var w = this.w; - var me = this; - if (e.target.classList.contains('apexcharts-legend-text') || e.target.classList.contains('apexcharts-legend-point')) { - var seriesCnt = parseInt(e.target.getAttribute('rel')) - 1; - - if (w.globals.axisCharts || w.config.chart.type === 'radialBar') { - w.globals.resized = true; // we don't want initial animations again - - var seriesEl = null; - - var isHidden = e.target.getAttribute('data:collapsed'); - - 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 === 'true') { - 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.risingSeries.push(realIndex); - } else { - w.config.series[realIndex] = w.globals.collapsedSeries[c].data; - w.globals.collapsedSeries.splice(c, 1); - w.globals.risingSeries.push(realIndex); - } - me.ctx.updateSeries(w.config.series, w.globals.initialConfig.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] - }); - - 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.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; - - me.ctx.updateSeries(w.config.series, w.globals.initialConfig.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; - -/***/ }), -/* 108 */ -/***/ (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, checkComboCharts) { - _classCallCheck(this, Range); - - this.ctx = ctx; - this.w = ctx.w; - this.checkComboCharts = checkComboCharts; - } - - _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; - var toFixed = arguments[3]; - - if (yMin === Number.MIN_VALUE && yMax === 0) { - // when all values are 0 - yMin = 0; - yMax = 1; - var justRange = this.justRange(yMin, yMax, 2); - return justRange; - } - - // 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 = []; - // If yMin and yMax are identical, then - // adjust the yMin and yMax values to actually - // make a graph. Also avoids division by zero errors. - if (yMin === yMax) { - yMin = yMin - 10; // some small value - yMax = yMax + 10; // some small value - } - // 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 stupid condition below which makes this function tightly coupled. - 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; - if (v % 1 !== 0 && typeof toFixed !== 'undefined') { - v = parseFloat(v.toFixed(toFixed)); - } - 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) { - range = 10;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: '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; - - var getMinYMaxY = function getMinYMaxY(startingIndex, len) { - var maxY = -Number.MAX_VALUE; - var minY = Number.MIN_VALUE; - for (var i = startingIndex; i < len; i++) { - gl.dataPoints = Math.max(gl.dataPoints, gl.series[i].length); - if (_Utils2.default.isIE()) { - minY = Math.min.apply(Math, _toConsumableArray(gl.series[i])); - } - - for (var j = 0; j < gl.series[i].length; j++) { - if (gl.series[i][j] !== null && _Utils2.default.isInt(gl.series[i][j])) { - maxY = Math.max(maxY, gl.series[i][j]); - minValInSeries = Math.min(minValInSeries, gl.series[i][j]); - if (minY > gl.series[i][j] && gl.series[i][j] < 0) { - minY = gl.series[i][j]; - } - } else { - gl.hasNullValues = true; - } - } - } - return { minY: minY, maxY: maxY }; - }; - - 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 = getMinYMaxY(i, i + 1); - gl.minYArr.push(minYMaxYArr.minY); - gl.maxYArr.push(minYMaxYArr.maxY); - } - } - - // and then, get the minY and maxY from all series - var minYMaxY = getMinYMaxY(0, gl.series.length); - gl.minY = minYMaxY.minY;gl.maxY = minYMaxY.maxY; - - 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.isInt(gl.series[_i][j])) { - if (gl.series[_i][j] > 0) { - poss = poss + parseInt(gl.series[_i][j]); - } 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 10000-12000, putting 0 as the lowest value is not so good idea - if (cnf.chart.type === 'line' || cnf.chart.type === 'area') { - if (gl.minY === Number.MIN_VALUE && minValInSeries !== Number.MAX_SAFE_INTEGER) { - gl.minY = Math.round(minValInSeries - minValInSeries * 2 / 100); - gl.maxY = Math.round(gl.maxY + gl.maxY * 2 / 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 = yaxis[0].max; - } - if (yaxis[0].min !== undefined && typeof yaxis[0].min === 'number') { - gl.minYArr[index] = yaxe.min; - gl.minY = yaxis[0].min; - } - }); - - 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 < 8) { - ticksY = Math.floor(maxY); - } - - if (maxY === -Number.MAX_VALUE) { - // no value in series. draw blank grid - gl.yAxisScale.push(_this.justRange(0, 2, 2)); - } else { - gl.allSeriesCollapsed = false; - gl.yAxisScale.push(_this.niceScale(minY, maxY, ticksY)); - } - }; - - if (gl.isMultipleYAxis) { - for (var _i2 = 0; _i2 < gl.series.length; _i2++) { - reCalculateMinMaxY(_i2, gl.minYArr[_i2], gl.maxYArr[_i2]); - gl.minYArr[_i2] = gl.yAxisScale[_i2].niceMin; - gl.maxYArr[_i2] = gl.yAxisScale[_i2].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.dataXY) { - 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.isInt(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; - } - - this.checkComboCharts(); - - // for bars in numeric xaxis, we need to adjust some padding left and right - if ((gl.comboCharts || cnf.chart.type === 'bar') && (cnf.xaxis.type === 'datetime' || gl.dataXY)) { - var minX = gl.minX - gl.svgWidth / gl.dataPoints * (Math.abs(gl.maxX - gl.minX) / gl.svgWidth); - gl.minX = minX; - gl.initialminX = minX; - var maxX = gl.maxX + gl.svgWidth / gl.dataPoints * (Math.abs(gl.maxX - gl.minX) / gl.svgWidth); - gl.maxX = maxX; - gl.initialmaxX = maxX; - } - - var niceXRange = new Range(this.ctx); - if (gl.dataXY || gl.noLabelsProvided) { - var ticks = 8; - - if (cnf.xaxis.tickAmount === undefined) { - ticks = Math.round(gl.svgWidth / 150); - - if (ticks > gl.dataPoints && gl.dataPoints !== 0) { - ticks = gl.dataPoints - 1; - } - } else { - ticks = cnf.xaxis.tickAmount; - if (!gl.noLabelsProvided) { - ticks = cnf.xaxis.tickAmount - 3; - } - } - - // 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.dataXYZ) { - 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.isInt(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; - -/***/ }), -/* 109 */ -/***/ (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 _Dimensions = __webpack_require__(21); - -var _Dimensions2 = _interopRequireDefault(_Dimensions); - -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 Scroller Class for drawing the horizontal scrolling for panning into charts. - * - * @module Scroller - **/ - -var Scroller = function () { - function Scroller(ctx) { - _classCallCheck(this, Scroller); - - this.ctx = ctx; - this.w = ctx.w; - } - - _createClass(Scroller, [{ - key: 'init', - value: function init(xyRatios) { - this.xyRatios = xyRatios; - - this.elScroller = null; - - this.scrollerButtonLeft = null; - this.scrollerButtonRight = null; - this.scrollerArea = null; - - this.gridRect = null; - - this.scrollerConfig = this.w.config.chart.scroller; - this.scrollBtnSize = this.scrollerConfig.scrollButtons.size; - - if (!this.w.globals.allSeriesCollapsed) { - this.renderScroller(); - } - } - }, { - key: 'renderScroller', - value: function renderScroller() { - var w = this.w; - var graphics = new _Graphics2.default(this.ctx); - - this.elScroller = graphics.group({ - class: 'apexcharts-scroller' - }); - - var dim = new _Dimensions2.default(this.ctx); - var lgRectHeight = dim.getLegendsRect().height - (w.config.legend.position === 'bottom' ? w.config.legend.containerMargin.top : 0) - this.scrollBtnSize / 3; - var titleHeight = dim.getMainTitleCoords().height; - var subtitleHeight = dim.getSubTitleCoords().height; - - var scrollerOffsetY = w.config.legend.position === 'top' || w.config.legend.position === 'bottom' ? lgRectHeight + 15 : 15; - - scrollerOffsetY = scrollerOffsetY + titleHeight + subtitleHeight; - - this.elScroller.attr({ - transform: 'translate(' + (this.scrollerConfig.offsetX + this.scrollerConfig.padding.left) + ', ' + (w.globals.svgHeight - this.scrollerConfig.height - this.scrollBtnSize + this.scrollerConfig.offsetY - scrollerOffsetY) + ')' - }); - - this.renderScrollerTrack(); - this.renderScrollerThumb(); - - w.globals.dom.elGraphical.add(this.elScroller); - } - }, { - key: 'renderScrollerTrack', - value: function renderScrollerTrack() { - var w = this.w; - var graphics = new _Graphics2.default(this.ctx); - - var track = graphics.drawRect(0, 0, 0, 0, 4); - - var x = 0; - var y = -this.scrollerConfig.track.height / 2; - this.scrollerWidth = w.globals.gridWidth - this.scrollerConfig.padding.left - this.scrollerConfig.padding.right; - var height = this.scrollerConfig.track.height; - - track.attr({ - id: 'apexcharts-scroller-track', - class: 'apexcharts-scroller-track', - x: x, - y: y, - width: this.scrollerWidth, - height: height, - fill: this.scrollerConfig.track.background, - 'fill-opacity': 1 - }); - - this.elScroller.add(track); - } - }, { - key: 'renderScrollerThumb', - value: function renderScrollerThumb() { - var w = this.w; - var graphics = new _Graphics2.default(this.ctx); - - var x = Math.abs(w.globals.initialminX - w.globals.minX) / this.xyRatios.initialXRatio; - var width = this.scrollerWidth - Math.abs(w.globals.initialmaxX - w.globals.maxX) / this.xyRatios.initialXRatio - x; - - if (x > this.scrollerWidth) { - x = this.scrollerWidth; - } else if (x < 0) { - x = 0; - } - if (width <= 1) { - width = 1; - } - this.scrollerThumb = graphics.drawRect(0, -this.scrollerConfig.thumb.height / 2, width, this.scrollerConfig.thumb.height, 4); - this.scrollerThumb.attr({ - x: x, - width: width, - id: 'apexcharts-scroller-thumb', - class: 'apexcharts-scroller-thumb', - fill: this.scrollerConfig.thumb.background, - fillOpacity: 1 - }); - - this.elScroller.add(this.scrollerThumb); - - var constraint = { - minY: -this.scrollerConfig.thumb.height / 2, - maxY: this.scrollerConfig.thumb.height / 2 - }; - - this.scrollerThumb.draggable(constraint).on('dragmove', this.scrollerDragging.bind(this)).selectize().resize({ - constraint: constraint - }).on('resizing', this.scrollerDragging.bind(this)); - - this.styleScrollerButtons(); - } - }, { - key: 'styleScrollerButtons', - value: function styleScrollerButtons() { - var w = this.w; - var scrollerButtonLeft = w.globals.dom.baseEl.querySelector('.apexcharts-scroller .svg_select_points_l'); - var scrollerButtonRight = w.globals.dom.baseEl.querySelector('.apexcharts-scroller .svg_select_points_r'); - var scrollerButtons = [scrollerButtonLeft, scrollerButtonRight]; - for (var i = 0; i < scrollerButtons.length; i++) { - var btn = scrollerButtons[i]; - _Graphics2.default.setAttrs(btn, { - class: 'apexcharts-scrollbutton', - r: this.scrollBtnSize, - fill: this.scrollerConfig.scrollButtons.fillColor, - stroke: this.scrollerConfig.scrollButtons.borderColor, - 'stroke-width': this.scrollerConfig.scrollButtons.borderWidth - }); - } - } - }, { - key: 'scrollerDragging', - value: function scrollerDragging() { - var w = this.w; - var xyRatios = this.xyRatios; - - var scrollerRect = this.scrollerThumb.bbox(); - - var minX = w.globals.initialminX + scrollerRect.x * xyRatios.initialXRatio; - var maxX = w.globals.initialminX + (scrollerRect.x + scrollerRect.width + this.scrollerConfig.padding.left + this.scrollerConfig.padding.right) * xyRatios.initialXRatio; - - if (scrollerRect.x < 0 || scrollerRect.x2 > this.scrollerWidth) return; - - this.ctx.updateOptions({ - xaxis: { - min: minX, - max: maxX - } - }, false, false); - } - }]); - - return Scroller; -}(); - -exports.default = Scroller; - -/***/ }), -/* 110 */ -/***/ (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 SubTitle = function () { - function SubTitle(ctx) { - _classCallCheck(this, SubTitle); - - this.ctx = ctx; - this.w = ctx.w; - } - - _createClass(SubTitle, [{ - key: 'drawSubtitle', - value: function drawSubtitle() { - var w = this.w; - - var x = w.globals.svgWidth / 2; - var y = w.config.subtitle.offsetY; - var textAnchor = 'middle'; - - if (w.config.subtitle.align === 'left') { - x = 10; - textAnchor = 'start'; - } else if (w.config.subtitle.align === 'right') { - x = w.globals.svgWidth - 10; - textAnchor = 'end'; - } - - x = x + w.config.subtitle.offsetX; - y = y + parseInt(w.config.subtitle.style.fontSize) + parseInt(w.config.title.style.fontSize) + 10; - - if (w.config.subtitle.text !== undefined) { - var graphics = new _Graphics2.default(this.ctx); - var subtitleText = graphics.drawText({ - x: x, - y: y, - text: w.config.subtitle.text, - textAnchor: textAnchor, - fontSize: w.config.subtitle.style.fontSize, - foreColor: w.config.subtitle.style.color, - opacity: 1 - }); - - subtitleText.attr('class', 'apexcharts-subtitle-text'); - - w.globals.dom.Paper.add(subtitleText); - } - } - }]); - - return SubTitle; -}(); - -exports.default = SubTitle; - -/***/ }), -/* 111 */ -/***/ (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.config.colors = this.predefined(); - } - - var defaultColors = w.config.colors.slice(); - - 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 = mainColor; - - 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.config.colors = monoArr.slice(); - } - - // if user specfied less colors than no. of series, push the same colors again - this.pushExtraColors(w.config.colors); - - // The Border colors - if (w.config.stroke.colors === undefined) { - w.config.stroke.colors = defaultColors; - } else { - this.pushExtraColors(w.config.stroke.colors); - } - - // The FILL colors - if (w.config.fill.colors === undefined) { - w.config.fill.colors = w.config.colors; - } else { - this.pushExtraColors(w.config.fill.colors); - } - - if (w.config.dataLabels.style.colors === undefined) { - w.config.dataLabels.style.colors = defaultColors; - } else { - this.pushExtraColors(w.config.dataLabels.style.colors); - } - - // The point colors - if (w.config.markers.colors === undefined) { - w.config.markers.colors = defaultColors; - } else { - this.pushExtraColors(w.config.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; - -/***/ }), -/* 112 */ -/***/ (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 Title = function () { - function Title(ctx) { - _classCallCheck(this, Title); - - this.ctx = ctx; - this.w = ctx.w; - } - - _createClass(Title, [{ - key: 'drawTitle', - value: function drawTitle() { - var w = this.w; - - var x = w.globals.svgWidth / 2; - var y = w.config.title.offsetY; - var textAnchor = 'middle'; - - if (w.config.title.align === 'left') { - x = 10; - textAnchor = 'start'; - } else if (w.config.title.align === 'right') { - x = w.globals.svgWidth - 10; - textAnchor = 'end'; - } - - x = x + w.config.title.offsetX; - y = y + parseInt(w.config.title.style.fontSize) + 2; - - if (w.config.title.text !== undefined) { - var graphics = new _Graphics2.default(this.ctx); - var titleText = graphics.drawText({ - x: x, - y: y, - text: w.config.title.text, - textAnchor: textAnchor, - fontSize: w.config.title.style.fontSize, - foreColor: w.config.title.style.foreColor, - opacity: 1 - }); - - titleText.node.setAttribute('class', 'apexcharts-title-text'); - - w.globals.dom.Paper.add(titleText); - } - } - }]); - - return Title; -}(); - -exports.default = Title; - -/***/ }), -/* 113 */ -/***/ (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 - ttCtx.xcrosshairs = w.globals.dom.baseEl.querySelector('.apexcharts-xcrosshairs'); - 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 (ttCtx.xcrosshairs !== null) { - ttCtx.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, seriesBound, xyRatios) { - var ttCtx = this.ttCtx; - var w = this.w; - - var lbFormatter = w.config.yaxis[index].labels.formatter; - - if (ttCtx.blyaxisTooltip) { - 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; - -/***/ }), -/* 114 */ -/***/ (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; - - 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; - y = cy + ttCtx.tooltipRect.ttHeight / 2 - height / 2; - - if (ttCtx.w.config.tooltip.followCursor) { - var elGrid = ttCtx.w.globals.dom.baseEl.querySelector('.apexcharts-grid'); - var seriesBound = elGrid.getBoundingClientRect(); - 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.getAttribute('rel')) - 1; - - if (ttCtx.intersect) { - i = parseInt(_Utils2.default.findAncestor(opt.paths, 'apexcharts-series').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) { - y = ttCtx.e.clientY - ttCtx.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, - x = _ref3.x, - y = _ref3.y; - - var w = this.w; - var ttCtx = this.ttCtx; - - var bx = 0; - var j = 0; - - if (ttCtx.isBarHorizontal || !w.config.tooltip.shared) { - var barXY = this.getBarTooltipXY({ - e: e, - opt: opt, - x: x, - y: y - }); - x = barXY.x; - y = barXY.y; - j = barXY.j; - bx = x; - } else { - if (!w.globals.comboCharts && !w.config.tooltip.shared) { - bx = bx / 2; - ttCtx.tooltipPosition.moveXCrosshairs(bx, j); - } - } - - // y is NaN, make it touch the bottom of grid area - if (isNaN(y)) { - y = w.globals.svgHeight - ttCtx.tooltipRect.ttHeight; - } - - // y exceeds gridHeight - // if (ttCtx.tooltipRect.ttHeight + y - 20 > w.globals.gridHeight) { - // y = w.globals.gridHeight - ttCtx.tooltipRect.ttHeight / 2 - // } else if (y < 0) { - // // y less than 0, touch the top of grid - // y = 0 - // } - - if (ttCtx.w.config.tooltip.followCursor) { - y = ttCtx.e.clientY - ttCtx.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 (!w.config.tooltip.shared || ttCtx.isBarHorizontal) { - ttCtx.tooltip.style.left = x + w.globals.translateX + 'px'; - ttCtx.tooltip.style.top = y + w.globals.translateY - ttCtx.tooltipRect.ttHeight / 2 + 'px'; - } - } - }, { - key: 'getBarTooltipXY', - value: function getBarTooltipXY(_ref4) { - var e = _ref4.e, - opt = _ref4.opt, - x = _ref4.x, - y = _ref4.y; - - var w = this.w; - var j = null; - var ttCtx = this.ttCtx; - - if (e.target.classList.contains('apexcharts-bar-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.dataXY) { - 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.dataXY) { - 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; - -/***/ }), -/* 115 */ -/***/ (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__(22); - -var _Formatters2 = _interopRequireDefault(_Formatters); - -var _Utils = __webpack_require__(58); - -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; - var ttCtx = this.ttCtx; - - var yLbFormatter = w.config.yaxis[0].labels.formatter; - - var zVal = null; - var zFormatter = w.globals.ttZFormatter; - - if (w.globals.isMultipleYAxis) { - yLbFormatter = w.config.yaxis[i].labels.formatter; - } - - if (w.globals.ttValFormatter !== undefined) { - yLbFormatter = w.globals.ttValFormatter; - } - - var xVal = ''; - var val = void 0; - - var pColor = w.config.colors[i]; - if (j !== null && w.config.plotOptions.bar.distributed) { - pColor = w.config.colors[j]; - } - - 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; - } - } - - var filteredSeriesX = this.tooltipUtil.filteredSeriesX(); - - if (j === null) { - val = w.globals.series[i]; - } else { - if (w.globals.dataXY) { - xVal = filteredSeriesX[i][j]; - } else { - xVal = typeof w.globals.labels[j] !== 'undefined' ? w.globals.labels[j] : ''; - } - } - - var bufferXVal = xVal; - - if (w.globals.dataXY && w.config.xaxis.type === 'datetime') { - var xFormat = new _Formatters2.default(this.ctx); - xVal = xFormat.xLabelFormat(w.globals.ttKeyFormatter, bufferXVal); - } else if (w.config.tooltip.x.formatter !== undefined) { - xVal = w.globals.ttKeyFormatter(bufferXVal, { series: w.globals.series, seriesIndex: i, dataPointIndex: j, w: w }); - } else { - xVal = w.globals.xLabelFormatter(bufferXVal, { series: w.globals.series, seriesIndex: i, dataPointIndex: j, w: w }); - } - - 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 (ttCtx.blxaxisTooltip) { - ttCtx.xaxisTooltipText.innerHTML = xVal; - } - - if (w.globals.seriesZ.length > 0 && w.globals.seriesZ[0].length > 0) { - zVal = zFormatter(w.globals.seriesZ[i][j], w); - } - - for (var t = 0, inverset = w.globals.series.length - 1; t < w.globals.series.length; t++, inverset--) { - var seriesName = w.config.tooltip.y.title.formatter(String(w.globals.seriesNames[i]), { series: w.globals.series, seriesIndex: i, dataPointIndex: j, w: w }); - - if (shared) { - var tIndex = w.config.tooltip.inverseOrder ? inverset : t; - - seriesName = w.config.tooltip.y.title.formatter(String(w.globals.seriesNames[tIndex]), { series: w.globals.series, seriesIndex: i, dataPointIndex: j, w: w }); - pColor = w.config.colors[tIndex]; - // for plot charts, not for pie/donuts - val = yLbFormatter(w.globals.series[tIndex][j], { series: w.globals.series, seriesIndex: i, dataPointIndex: j, w: w }); - - // discard 0 values in BARS - if (ttCtx.bars.length && w.config.chart.stacked && w.globals.series[tIndex][j] === 0 || typeof w.globals.series[tIndex][j] === 'undefined') { - val = undefined; - } - } - - // for pie/donuts - if (j !== null && !shared) { - val = yLbFormatter(w.globals.series[i][j], w); - } - - // override everything with a custom html tooltip and replace it - if (w.config.tooltip.custom !== undefined) { - ttCtx.tooltip.innerHTML = ''; - ttCtx.tooltip.innerHTML = w.config.tooltip.custom({ series: w.globals.series, seriesIndex: i, dataPointIndex: j, w: w }); - return; - } - - 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'; - } - - var ttYLabel = ttItems[t].querySelector('.apexcharts-tooltip-text-label'); - ttYLabel.innerHTML = seriesName ? seriesName + ': ' : ''; - var ttYVal = ttItems[t].querySelector('.apexcharts-tooltip-text-value'); - ttYVal.innerHTML = val; - - if (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) { - // hide when no Val - if (typeof val === 'undefined') { - ttItemsChildren[0].parentNode.style.display = 'none'; - } else { - ttItemsChildren[0].parentNode.style.display = w.config.tooltip.items.display; - } - } - } - } - }]); - - return Labels; -}(); - -module.exports = Labels; - -/***/ }), -/* 116 */ -/***/ (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__(57); - -var _Position2 = _interopRequireDefault(_Position); - -var _Markers = __webpack_require__(34); - -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 ttCtx = this.ttCtx; - 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); - - ttCtx.allPoints = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers .apexcharts-marker'); - } - } - } - }, { - 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-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; - -/***/ }), -/* 117 */ -/***/ (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__(115); - -var _Labels2 = _interopRequireDefault(_Labels); - -var _Position = __webpack_require__(57); - -var _Position2 = _interopRequireDefault(_Position); - -var _Marker = __webpack_require__(116); - -var _Marker2 = _interopRequireDefault(_Marker); - -var _Intersect = __webpack_require__(114); - -var _Intersect2 = _interopRequireDefault(_Intersect); - -var _AxesTooltip = __webpack_require__(113); - -var _AxesTooltip2 = _interopRequireDefault(_AxesTooltip); - -var _Graphics = __webpack_require__(0); - -var _Graphics2 = _interopRequireDefault(_Graphics); - -var _Series = __webpack_require__(15); - -var _Series2 = _interopRequireDefault(_Series); - -var _XAxis = __webpack_require__(35); - -var _XAxis2 = _interopRequireDefault(_XAxis); - -var _Utils = __webpack_require__(58); - -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 = false; - this.showTooltipTitle = w.config.tooltip.x.show; - this.fixedTooltip = w.config.tooltip.fixed.enabled; - this.blxaxisTooltip = w.config.xaxis.tooltip.enabled && w.globals.axisCharts; - this.blyaxisTooltip = w.config.yaxis[0].tooltip.enabled && w.globals.axisCharts; - this.xaxisTooltip = null; - this.yaxisTTEls = null; - this.bars = w.globals.dom.baseEl.querySelectorAll('.apexcharts-bar-series'); - this.hasBars = this.bars.length > 0; - this.isBarHorizontal = this.hasBars && w.config.plotOptions.bar.horizontal; - this.isBarShared = this.hasBars && !w.config.plotOptions.bar.horizontal && w.config.tooltip.shared; - } - - _createClass(Tooltip, [{ - key: 'drawTooltip', - value: function drawTooltip(xyRatios) { - var w = this.w; - this.xyRatios = xyRatios; - this.allTooltipSeriesGroups = []; - - if (!w.globals.axisCharts) { - this.showTooltipTitle = false; - } - - this.tooltip = document.createElement('div'); - this.tooltip.classList.add('apexcharts-tooltip'); - this.tooltip.classList.add(w.config.tooltip.theme); - w.globals.dom.elWrap.appendChild(this.tooltip); - - if (w.globals.axisCharts) { - this.plotSeries = w.globals.dom.baseEl.querySelector('.apexcharts-plot-series'); - if (this.plotSeries !== null) { - this.plotSeriesWidth = this.plotSeries.getBBox().width; - } - - this.axesTooltip.drawXaxisTooltip(); - this.axesTooltip.drawYaxisTooltip(); - this.axesTooltip.setXCrosshairWidth(); - this.axesTooltip.handleYCrosshair(); - - this.allPoints = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers .apexcharts-marker'); - - 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'); - this.tooltip.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; - } - } - - var ttItems = this.createTTElements(ttItemsCnt); - this.addSVGEvents(ttItems); - } - }, { - key: 'createTTElements', - value: function createTTElements(ttItemsCnt) { - var w = this.w; - var ttItems = []; - 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.config.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); - - this.tooltip.appendChild(gTxt); - - ttItems.push(gTxt); - } - - return ttItems; - } - }, { - key: 'addSVGEvents', - value: function addSVGEvents(ttItems) { - var w = this.w; - var type = w.config.chart.type; - - var hoverArea = w.globals.dom.Paper.node; - - var elGrid = w.globals.dom.baseEl.querySelector('.apexcharts-grid'); - if (elGrid) { - this.seriesBound = elGrid.getBoundingClientRect(); - } - - var tooltipY = []; - var tooltipX = []; - - var seriesHoverParams = { - hoverArea: hoverArea, - elGrid: elGrid, - tooltip: this.tooltip, - tooltipY: tooltipY, - tooltipX: tooltipX, - ttItems: 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 (type === 'bar') { - points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-bar-area'); - } else if (type === 'heatmap') { - points = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series .apexcharts-heatmap'); - } - - 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 || type === 'bar' && !this.isBarHorizontal && w.config.tooltip.shared) { - this.addPathsEventListeners([hoverArea], seriesHoverParams); - } else if (type === 'bar' && !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 tooltip = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip'); - - var tooltipRect = tooltip.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().includes('right')) { - x = x + w.globals.svgWidth - 10; - } - - if (w.config.tooltip.fixed.position.toLowerCase().includes('bottom')) { - y = y + w.globals.svgWidth - ttHeight - 10; - } - - this.tooltip.style.left = x + 'px'; - this.tooltip.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'); - - this.addPathsEventListeners(bars, seriesHoverParams); - } - }, { - key: 'addPathsEventListeners', - value: function addPathsEventListeners(paths, opts) { - var self = this; - - var _loop = function _loop(p) { - var extendedOpts = { - paths: paths[p], - tooltip: opts.tooltip, - tooltipY: opts.tooltipY, - tooltipX: opts.tooltipX, - elGrid: opts.elGrid, - hoverArea: opts.hoverArea, - ttItems: opts.ttItems - }; - - var events = ['mousemove', 'touchmove', 'mouseout', 'touchend']; - - events.map(function (ev) { - paths[p].addEventListener(ev, self.seriesHover.bind(self, extendedOpts), false); - }); - }; - - for (var p = 0; p < paths.length; p++) { - _loop(p); - } - } - - /* - ** The actual series hover function - */ - - }, { - key: 'seriesHover', - value: function seriesHover(opt, e) { - var w = this.w; - - // tooltipRect is calculated on every mousemove, because the text is dynamic - this.tooltipRect = { - x: 0, - y: 0, - ttWidth: this.tooltip.getBoundingClientRect().width, - ttHeight: this.tooltip.getBoundingClientRect().height - }; - this.e = e; - - // highlight the current hovered bars - if (this.hasBars && !w.globals.comboCharts && !this.isBarShared) { - if (w.config.tooltip.onDatasetHover.highlightDataSeries) { - var series = new _Series2.default(this.ctx); - series.toggleSeriesOnHover(e, e.target.parentNode); - } - } - - if (this.fixedTooltip) { - this.drawFixedTooltipRect(); - } - - if (w.globals.axisCharts) { - this.axisChartsTooltips({ - e: e, - opt: opt, - tooltipRect: this.tooltipRect - }); - } else { - // non-plot charts i.e pie/donut/circle - this.nonAxisChartsTooltips({ - e: e, - opt: opt, - tooltipRect: this.tooltipRect - }); - } - } - - // tooltip handling for line/area/bar/columns/scatter - - }, { - key: 'axisChartsTooltips', - value: function axisChartsTooltips(_ref) { - var e = _ref.e, - opt = _ref.opt, - tooltipRect = _ref.tooltipRect; - - var w = this.w; - var j = void 0, - x = void 0, - y = void 0; - - var self = this; - var capj = null; - - 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 && w.config.tooltip.shared || w.globals.comboCharts && this.hasBars; - - if (w.config.chart.type === 'bar' && this.isBarHorizontal) { - isStickyTooltip = false; - } - - if (e.type === 'mousemove' || e.type === 'touchmove') { - if (self.xcrosshairs !== null) { - self.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, - plotSeriesWidth: self.plotSeriesWidth, - hasBars: self.hasBars - }); - - j = capj.j; - var capturedSeries = capj.capturedSeries; - - // TODO: the hoverY is causing issues currently, hence commented out - 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.tooltip.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); - } - } - - x = parseInt(opt.tooltipX[j]) - tooltipRect.ttWidth / 2; - - if (w.globals.dataXY && capturedSeries !== null) { - x = (w.globals.seriesX[capturedSeries][j] - w.globals.minX) / self.xyRatios.xRatio; - } - if (w.config.tooltip.followCursor) { - y = clientY - this.seriesBound.top - tooltipRect.ttHeight / 2; - } else { - y = parseInt(opt.tooltipY[j]) - tooltipRect.ttHeight; - } - } 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; - - self.tooltip.style.left = x + 'px'; - self.tooltip.style.top = y + 'px'; - } else { - if (this.hasBars) { - this.intersect.handleBarTooltip({ - e: e, - opt: opt, - x: x, - y: y - }); - } - - var hasMarkers = w.globals.dom.baseEl.querySelectorAll(' .apexcharts-series-markers').length > 0; - - if (hasMarkers) { - // intersect - line/area/scatter/bubble - var _markerXY = this.intersect.handleMarkerTooltip({ - e: e, - opt: opt, - x: x, - y: y - }); - x = _markerXY.x; - y = _markerXY.y; - } - } - } - - if (this.blyaxisTooltip) { - for (var yt = 0; yt < w.config.yaxis.length; yt++) { - self.axesTooltip.drawYaxisTooltipText(yt, clientY, self.seriesBound, self.xyRatios); - } - } - - opt.tooltip.classList.add('active'); - } else if (e.type === 'mouseout' || e.type === 'touchend') { - this.handleMouseOut(opt); - } - } - - // tooltip handling for pie/donuts - - }, { - key: 'nonAxisChartsTooltips', - value: function nonAxisChartsTooltips(_ref2) { - var e = _ref2.e, - opt = _ref2.opt, - tooltipRect = _ref2.tooltipRect; - - var w = this.w; - var rel = opt.paths.getAttribute('rel'); - - 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') { - opt.tooltip.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; - - if (this.tooltip === null) { - this.tooltip = w.globals.dom.baseEl.querySelector('.apexcharts-tooltip'); - } - - this.tooltip.style.left = x + w.globals.translateX + 'px'; - this.tooltip.style.top = y + 'px'; - } else if (e.type === 'mouseout' || e.type === 'touchend') { - opt.tooltip.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; - - opt.tooltip.classList.remove('active'); - this.deactivateHoverFilter(); - if (w.config.chart.type !== 'bubble') { - this.marker.resetPointsSize(); - } - if (this.xcrosshairs !== null) { - this.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: '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; - - var hasMarkers = w.globals.dom.baseEl.querySelectorAll('.apexcharts-series-markers').length > 0; - - if (shared === null) shared = w.config.tooltip.shared; - - 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(this.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; - -/***/ }), -/* 118 */ -/***/ (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__(56); - -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.clicked = false; - - _this.clientX = 0; - _this.clientY = 0; - _this.startX = 0; - _this.endX = 0; - _this.dragX = 0; - _this.startY = 0; - _this.endY = 0; - _this.dragY = 0; - - _this.zoomResetIcon = null; - return _this; - } - - _createClass(ZoomPanSelection, [{ - key: 'init', - value: function init(_ref) { - var xyRatios = _ref.xyRatios; - - var w = this.w; - var self = this; - - this.xyRatios = xyRatios; - - this.gridRect = null; - var graphics = new _Graphics2.default(this.ctx); - - this.zoomRect = graphics.drawRect(0, 0, 0, 0); - this.selectionRect = graphics.drawRect(0, 0, 0, 0); - - 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(); - - var hoverArea = w.globals.dom.baseEl.querySelector(w.globals.chartClass); - hoverArea.classList.add('zoomable'); - - if (self.gridRect === null) { - self.gridRect = w.globals.dom.baseEl.querySelector('.apexcharts-grid'); - } - - var gridRectDim = self.gridRect.getBoundingClientRect(); - - var gridRectH = gridRectDim.height; - - // diffInH will help to give the actual height of clickable area. - // our eventHandler is bound to SVG, but SVG has axis/legends, we need to omit them. - var diffInH = (w.globals.svgHeight - gridRectH) * xyRatios.yRatio[0]; - - var opts = { - hoverArea: hoverArea, - hoverDimensions: gridRectDim, - diffInHeight: diffInH - }; - - var eventList = ['mousedown', 'mousemove', 'touchstart', 'touchmove', 'mouseup', 'touchend']; - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = eventList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var event = _step.value; - - hoverArea.addEventListener(event, self.svgMouseEvents.bind(self, opts, xyRatios), false); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } - }, { - key: 'svgMouseEvents', - value: function svgMouseEvents(opt, xyRatios, e) { - var w = this.w; - var me = this; - var zoomtype = w.globals.zoomEnabled ? w.config.chart.zoom.type : w.config.chart.selection.type; - - var isSelectionMouseDown = e.target.classList.contains('apexcharts-selection-rect'); - - if (isSelectionMouseDown) 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; - - var mouseDownOnZoomArea = function mouseDownOnZoomArea() { - // we will be calling getBoundingClientRect on each mousedown/mousemove/mouseup - var gridRectDim = me.gridRect.getBoundingClientRect(); - - me.startX = me.clientX - gridRectDim.left; - me.startY = me.clientY - gridRectDim.top; - - me.dragged = false; - me.clicked = true; - }; - - if (e.type === 'mousedown' && e.which === 1) { - mouseDownOnZoomArea(); - } else if (e.type === 'mousemove' && e.which === 1 || e.type === 'touchmove') { - me.dragged = true; - - if (w.globals.panEnabled) { - w.globals.selection = null; - me.panDragging({ - context: me, - zoomtype: zoomtype, - xyRatios: xyRatios - }); - } else { - if (me.clicked && w.globals.zoomEnabled || me.clicked && w.globals.selectionEnabled) { - me.selection = me.selectionDrawing({ - context: me, - zoomtype: zoomtype - }); - } - } - } else if (e.type === 'mouseup' && e.which === 1 || e.type === 'touchend') { - // we will be calling getBoundingClientRect on each mousedown/mousemove/mouseup - var gridRectDim = me.gridRect.getBoundingClientRect(); - - if (me.clicked) { - // 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(); - } - - if (typeof me.w.config.chart.events.click === 'function') { - me.w.config.chart.events.click(e, me.ctx); - } - me.ctx.fireEvent('click', [e, this.ctx, w]); - - me.dragged = false; - me.clicked = false; - me.w.globals.scrollerThumbDown = false; - } - - this.makeSelectionRectDraggable(); - } - }, { - key: 'makeSelectionRectDraggable', - value: function makeSelectionRectDraggable() { - var w = this.w; - 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, - selectionEnabled = _ref2.selectionEnabled; - - var w = this.w; - if (this.dragged || w.globals.selection !== null) { - var scalingAttrs = { - transform: 'translate(' + translateX + ', ' + translateY + ')' - - // change styles based on zoom or selection - };if (w.globals.zoomEnabled) { - this.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(this.zoomRect.node, scalingAttrs); - } - if (w.globals.selectionEnabled || selectionEnabled) { - this.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(this.selectionRect.node, scalingAttrs); - } - } - } - }, { - key: 'hideSelectionRect', - value: function hideSelectionRect() { - this.selectionRect.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 = me.gridRect.getBoundingClientRect(); - - var startX = me.startX - 1; - var startY = me.startY; - - var selectionWidth = me.clientX - gridRectDim.left - startX - 1; - var selectionHeight = me.clientY - gridRectDim.top - startY; - var translateX = 0; - var translateY = 0; - - var selectionRect = {}; - - // 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 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 = _this2.selectionRect.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; - - 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.map(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) { - w.globals.zoomed = true; - var yaxis = w.config.yaxis; - - if (zoomtype === 'xy' || zoomtype === 'y') { - yaxis.map(function (yaxe, index) { - yaxis[index].min = yLowestValue[index]; - yaxis[index].max = yHighestValue[index]; - }); - } - - if (zoomtype === 'x') { - me.ctx.updateOptions({ - xaxis: { - min: xLowestValue, - max: xHighestValue - } - }, false, w.globals.initialConfig.chart.animations.dynamicAnimation.enabled); - } else if (zoomtype === 'y') { - me.ctx.updateOptions({ - yaxis: yaxis - }, false, w.globals.initialConfig.chart.animations.dynamicAnimation.enabled); - } else { - me.ctx.updateOptions({ - xaxis: { - min: xLowestValue, - max: xHighestValue - }, - yaxis: yaxis - }, false, w.globals.initialConfig.chart.animations.dynamicAnimation.enabled); - } - - if (typeof w.config.chart.events.zoomed === 'function') { - w.config.chart.events.zoomed(me.ctx, { - xaxis: { - min: xLowestValue, - max: xHighestValue - }, - yaxis: yaxis - }); - } - } 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.map(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.updateOptions({ - 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; - -/***/ }), -/* 119 */ -/***/ (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__(14); - -var _Animations2 = _interopRequireDefault(_Animations); - -var _Graphics = __webpack_require__(0); - -var _Graphics2 = _interopRequireDefault(_Graphics); - -var _XAxis = __webpack_require__(35); - -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 = tickAmount; - - 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 = w.globals.padHorizontal; - 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) { - 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.dataXY && 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; - } - } - - // rows background bands - if (w.config.grid.row.colors !== undefined && w.config.grid.row.colors.length > 0) { - var _x4 = 0; - var _y3 = 0; - var _y4 = w.globals.gridHeight / tickAmount; - var _x5 = w.globals.gridWidth; - - for (var _i4 = 0, c = 0; _i4 < tickAmount; _i4++, c++) { - if (c >= w.config.grid.row.colors.length) { - c = 0; - } - var color = w.config.grid.row.colors[c]; - var rect = graphics.drawRect(_x4, _y3, _x5, _y4, 0, color, w.config.grid.row.opacity); - elg.add(rect); - rect.node.classList.add('apexcharts-gridRow'); - - _y3 = _y3 + w.globals.gridHeight / tickAmount; - } - } - - // columns background bands - if (w.config.grid.column.colors !== undefined && w.config.grid.column.colors.length > 0) { - var _x6 = w.globals.padHorizontal; - var _y5 = 0; - var _x7 = w.globals.padHorizontal + w.globals.gridWidth / xCount; - var _y6 = w.globals.gridHeight; - for (var _i5 = 0, _c = 0; _i5 < xCount; _i5++, _c++) { - if (_c >= w.config.grid.column.colors.length) { - _c = 0; - } - var _color = w.config.grid.column.colors[_c]; - var _rect = graphics.drawRect(_x6, _y5, _x7, _y6, 0, _color, w.config.grid.column.opacity); - _rect.node.classList.add('apexcharts-gridColumn'); - elg.add(_rect); - - _x6 = _x6 + w.globals.gridWidth / xCount; - } - } - } else { - xCount = tickAmount; - - // draw vertical lines - if (w.config.grid.xaxis.lines.show || w.config.xaxis.axisTicks.show) { - var _x8 = w.globals.padHorizontal; - var _y7 = 0; - var _x9 = w.globals.padHorizontal; - var _y8 = w.globals.gridHeight; - for (var _i6 = 0; _i6 < xCount + 1; _i6++) { - _x8 = _x8 + w.globals.gridWidth / xCount + 0.3; - _x9 = _x8; - - // skip the last vertical line - if (_i6 === xCount - 1) break; - - if (w.config.grid.xaxis.lines.show) { - var _line3 = graphics.drawLine(_x8, _y7, _x9, _y8, 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: _x8, x2: _x9 }); - } - } - - // skip the first vertical line - var _xAxis2 = new _XAxis2.default(this.ctx); - _xAxis2.drawXaxisTicks(_x8, elg); - } - } - - // draw horizontal lines - if (w.config.grid.yaxis.lines.show) { - var _x10 = 0; - var _y9 = 0; - var _y10 = 0; - var _x11 = w.globals.gridWidth; - for (var _i7 = 0; _i7 < w.globals.dataPoints + 1; _i7++) { - var _line4 = graphics.drawLine(_x10, _y9, _x11, _y10, w.config.grid.borderColor, strokeDashArray); - elg.add(_line4); - _line4.node.classList.add('apexcharts-gridline'); - - if (this.animY) { - this.animateLine(_line4, { y1: _y9 + 20, y2: _y10 + 20 }, { y1: _y9, y2: _y10 }); - } - - _y9 = _y9 + w.globals.gridHeight / w.globals.dataPoints; - _y10 = _y9; - } - } - } - - return { - el: elg, - xAxisTickWidth: 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; - -/***/ }), -/* 120 */ -/***/ (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 _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 { - dataLabels: { - enabled: false - }, - stroke: { - width: 5, - curve: 'straight' - }, - markers: { - size: 5 - }, - tooltip: { - // followCursor: true, - }, - xaxis: { - crosshairs: { - // TODO: make default 1 - width: 1 - } - } - - }; - } - }, { - key: 'bar', - value: function bar() { - return { - chart: { - stacked: false, - toolbar: { - show: true - }, - scroller: { - enabled: true - } - }, - 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: { - // TODO: make shared false - shared: false - }, - xaxis: { - tooltip: { - enabled: false - }, - crosshairs: { - width: 'barWidth', - position: 'back', - fill: { - type: 'gradient' - }, - dropShadow: { - enabled: false - } - } - }, - yaxis: { - tooltip: { - enabled: false - } - } - - }; - } - }, { - 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, 100] - } - }, - tooltip: { - followCursor: false - } - }; - } - }, { - key: 'stacked100', - value: function stacked100() { - this.opts.dataLabels = this.opts.dataLabels || {}; - this.opts.dataLabels.formatter = this.opts.dataLabels.formatter || undefined; - var existingDataLabelFormatter = this.opts.dataLabels.formatter; - - this.opts.yaxis[0].min = 0; - this.opts.yaxis[0].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 - }, - scroller: { - enabled: false - }, - toolbar: { - show: false - } - }, - fill: { - opacity: 1 - }, - 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 Math.ceil(val) + '%'; - }, - style: { - colors: ['#fff'] - }, - dropShadow: { - enabled: true - } - }, - stroke: { - colors: ['#fff'] - }, - fill: { - gradient: { - shade: 'dark', - shadeIntensity: 0.35, - inverseColors: false, - stops: [0, 100, 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 Math.ceil(val) + '%'; - }, - style: { - colors: ['#fff'] - }, - dropShadow: { - enabled: true - } - }, - stroke: { - colors: ['#fff'] - }, - fill: { - gradient: { - shade: 'dark', - shadeIntensity: 0.4, - inverseColors: false, - type: 'vertical', - opacityFrom: 1, - opacityTo: 1, - stops: [0, 50, 53, 91] - } - }, - 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: [0, 50, 53, 91] - } - }, - legend: { - show: false - }, - tooltip: { - enabled: false, - fillSeriesColor: true - } - }; - } - }]); - - return Defaults; -}(); - -module.exports = Defaults; - -/***/ }), -/* 121 */ -/***/ (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() { - 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: [] - }, - 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 - 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 - 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: false, - panEnabled: false, - 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 - 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 - total: 0, - svgNS: 'http://www.w3.org/2000/svg', // svg namespace - svgWidth: 0, // the whole svg width - svgHeight: 0, // the whole svg height - 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: [] - }, - 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) - dataXY: false, // bool: data was provided in a {[x,y], [x,y]} pattern - dataXYZ: 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 - 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 - xaxisTooltipLabelFormatter: undefined, // formatter for x axis tooltip - ttKeyFormatter: undefined, - ttValFormatter: 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 - }; - } - }, { - key: 'init', - value: function init(config) { - var globals = this.globalVars(); - - globals.initialConfig = _Utils2.default.extend({}, config); - globals.initialSeries = JSON.parse(JSON.stringify(globals.initialConfig.series)); - - return globals; - } - }]); - - return Globals; -}(); - -exports.default = Globals; - -/***/ }), -/* 122 */ -/***/ (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; -}; - -/***/ }), -/* 123 */ -/***/ (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); - -/***/ }), -/* 124 */ -/***/ (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; - } -})(); - -/***/ }), -/* 125 */ -/***/ (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); -})(); - -/***/ }), -/* 126 */ -/***/ (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) - }; -})(); - -/***/ }), -/* 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; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var ClassListPolyfill = function () { - function ClassListPolyfill() { - _classCallCheck(this, ClassListPolyfill); - } - - _createClass(ClassListPolyfill, null, [{ - key: 'fnClassList', - - /* - * classList.js: Cross-browser full element.classList implementation. - * 1.1.20150312 - * - * By Eli Grey, http://eligrey.com - * License: Dedicated to the public domain. - * See https://github.com/eligrey/classList.js/blob/master/LICENSE.md - */ - value: function fnClassList() { - /* 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', 'An invalid or illegal string was specified'); - } - if (/\s/.test(token)) { - throw new DOMEx('INVALID_CHARACTER_ERR', 'String contains an invalid character'); - } - 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) { - token += ''; - return checkTokenAndGetIndex(this, token) !== -1; - }; - classListProto.add = function () { - var tokens = arguments, - i = 0, - l = tokens.length, - token, - updated = false; - - do { - token = tokens[i] + ''; - if (checkTokenAndGetIndex(this, token) === -1) { - 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 !== -1) { - this.splice(index, 1); - updated = true; - index = checkTokenAndGetIndex(this, token); - } - } while (++i < l); - - if (updated) { - this._updateClassName(); - } - }; - classListProto.toggle = function (token, force) { - token += ''; - - 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.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 - if (ex.number === -0x7FF5EC54) { - classListPropDesc.enumerable = false; - objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); - } - } - } else if (objCtr[protoProp].__defineGetter__) { - elemCtrProto.__defineGetter__(classListProp, classListGetter); - } - })(self); - } else { - // 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 = void 0, - 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); - } - }; - } - - testElement = null; - })(); - } - } - } - }]); - - return ClassListPolyfill; -}(); - -module.exports = ClassListPolyfill; - -/***/ }), -/* 128 */ -/***/ (function(module, exports, __webpack_require__) { - -exports = module.exports = __webpack_require__(97)(false); -// imports - - -// module -exports.push([module.i, ".apexcharts-canvas {\r\n position: relative;\r\n user-select: none;\r\n}\r\n\r\n.apexcharts-inner {\r\n position: relative;\r\n}\r\n\r\n.apexcharts-legend-series {\r\n cursor: pointer;\r\n}\r\n\r\n.apexcharts-series-collapsed {\r\n opacity: 0;\r\n}\r\n\r\n.inactive-legend {\r\n opacity: 0.45;\r\n}\r\n\r\n.legend-mouseover-inactive {\r\n transition: 0.15s ease all;\r\n opacity: 0.20;\r\n}\r\n\r\n.apexcharts-gridline, .apexcharts-text {\r\n pointer-events: none;\r\n}\r\n\r\n.apexcharts-tooltip {\r\n border-radius: 5px;\r\n box-shadow: 2px 2px 6px -4px #999;\r\n cursor: default;\r\n font-size: 14px;\r\n left: 62px;\r\n opacity: 0;\r\n pointer-events: none;\r\n position: absolute;\r\n top: 20px;\r\n overflow: hidden;\r\n white-space: nowrap;\r\n z-index: 10;\r\n transition: 0.15s ease all;\r\n}\r\n.apexcharts-tooltip.light {\r\n border: 1px solid #e3e3e3;\r\n background: rgba(255, 255, 255, 0.96);\r\n}\r\n.apexcharts-tooltip.dark {\r\n color: #fff;\r\n background: rgba(30,30,30, 0.8);\r\n}\r\n\r\n.apexcharts-tooltip .apexcharts-marker,\r\n.apexcharts-area-series .apexcharts-area,\r\n.apexcharts-line {\r\n pointer-events: none;\r\n}\r\n\r\n.apexcharts-tooltip.active {\r\n opacity: 1;\r\n transition: 0.15s ease all;\r\n}\r\n\r\n.apexcharts-tooltip-title {\r\n padding: 6px;\r\n font-size: 15px;\r\n margin-bottom: 4px;\r\n}\r\n.apexcharts-tooltip.light .apexcharts-tooltip-title {\r\n background: #ECEFF1;\r\n border-bottom: 1px solid #ddd;\r\n}\r\n.apexcharts-tooltip.dark .apexcharts-tooltip-title {\r\n background: rgba(0, 0, 0, 0.7);\r\n border-bottom: 1px solid #222;\r\n}\r\n\r\n.apexcharts-tooltip-text-value,\r\n.apexcharts-tooltip-text-z-value {\r\n display: inline-block;\r\n font-weight: 600;\r\n margin-left: 5px;\r\n}\r\n\r\n.apexcharts-tooltip-text-z-label:empty,\r\n.apexcharts-tooltip-text-z-value:empty {\r\n display: none;\r\n}\r\n\r\n.apexcharts-tooltip-text-value, \r\n.apexcharts-tooltip-text-z-value {\r\n font-weight: 600;\r\n}\r\n\r\n.apexcharts-tooltip-marker {\r\n width: 12px;\r\n height: 12px;\r\n position: relative;\r\n top: 1px;\r\n margin-right: 10px;\r\n border-radius: 50%;\r\n}\r\n\r\n.apexcharts-tooltip-series-group {\r\n padding: 0 10px;\r\n display: none;\r\n text-align: left;\r\n justify-content: left;\r\n align-items: center;\r\n}\r\n\r\n.apexcharts-tooltip-series-group.active {\r\n display: flex;\r\n}\r\n\r\n.apexcharts-tooltip-series-group.active .apexcharts-tooltip-marker {\r\n opacity: 1;\r\n}\r\n.apexcharts-tooltip-series-group.active, .apexcharts-tooltip-series-group:last-child {\r\n padding-bottom: 4px;\r\n}\r\n.apexcharts-tooltip-y-group {\r\n padding: 6px 0 5px;\r\n}\r\n\r\n.apexcharts-xaxistooltip {\r\n opacity: 0;\r\n padding: 9px 10px;\r\n pointer-events: none;\r\n color: #373d3f;\r\n font-size: 13px;\r\n text-align: center;\r\n border-radius: 2px;\r\n position: absolute;\r\n z-index: 10;\r\n\tbackground: #ECEFF1;\r\n border: 1px solid #90A4AE;\r\n transition: 0.15s ease all;\r\n}\r\n\r\n.apexcharts-xaxistooltip:after, .apexcharts-xaxistooltip:before {\r\n\tleft: 50%;\r\n\tborder: solid transparent;\r\n\tcontent: \" \";\r\n\theight: 0;\r\n\twidth: 0;\r\n\tposition: absolute;\r\n\tpointer-events: none;\r\n}\r\n\r\n.apexcharts-xaxistooltip:after {\r\n\tborder-color: rgba(236, 239, 241, 0);\r\n\tborder-width: 6px;\r\n\tmargin-left: -6px;\r\n}\r\n.apexcharts-xaxistooltip:before {\r\n\tborder-color: rgba(144, 164, 174, 0);\r\n\tborder-width: 7px;\r\n\tmargin-left: -7px;\r\n}\r\n\r\n.apexcharts-xaxistooltip-bottom:after, .apexcharts-xaxistooltip-bottom:before {\r\n bottom: 100%;\r\n}\r\n\r\n.apexcharts-xaxistooltip-bottom:after {\r\n border-bottom-color: #ECEFF1;\r\n}\r\n.apexcharts-xaxistooltip-bottom:before {\r\n border-bottom-color: #90A4AE;\r\n}\r\n\r\n.apexcharts-xaxistooltip-top:after, .apexcharts-xaxistooltip-top:before {\r\n top: 100%;\r\n}\r\n.apexcharts-xaxistooltip-top:after {\r\n border-top-color: #ECEFF1;\r\n}\r\n.apexcharts-xaxistooltip-top:before {\r\n border-top-color: #90A4AE;\r\n}\r\n\r\n.apexcharts-xaxistooltip.active {\r\n opacity: 1;\r\n transition: 0.15s ease all;\r\n}\r\n\r\n.apexcharts-yaxistooltip {\r\n opacity: 0;\r\n padding: 4px 10px;\r\n pointer-events: none;\r\n color: #373d3f;\r\n font-size: 13px;\r\n text-align: center;\r\n border-radius: 2px;\r\n position: absolute;\r\n z-index: 10;\r\n\tbackground: #ECEFF1;\r\n border: 1px solid #90A4AE;\r\n}\r\n\r\n.apexcharts-yaxistooltip:after, .apexcharts-yaxistooltip:before {\r\n\ttop: 50%;\r\n\tborder: solid transparent;\r\n\tcontent: \" \";\r\n\theight: 0;\r\n\twidth: 0;\r\n\tposition: absolute;\r\n\tpointer-events: none;\r\n}\r\n.apexcharts-yaxistooltip:after {\r\n\tborder-color: rgba(236, 239, 241, 0);\r\n\tborder-width: 6px;\r\n\tmargin-top: -6px;\r\n}\r\n.apexcharts-yaxistooltip:before {\r\n\tborder-color: rgba(144, 164, 174, 0);\r\n\tborder-width: 7px;\r\n\tmargin-top: -7px;\r\n}\r\n\r\n.apexcharts-yaxistooltip-left:after, .apexcharts-yaxistooltip-left:before {\r\n left: 100%;\r\n}\r\n.apexcharts-yaxistooltip-left:after {\r\n border-left-color: #ECEFF1;\r\n}\r\n.apexcharts-yaxistooltip-left:before {\r\n border-left-color: #90A4AE;\r\n}\r\n\r\n.apexcharts-yaxistooltip-right:after, .apexcharts-yaxistooltip-right:before {\r\n right: 100%;\r\n}\r\n.apexcharts-yaxistooltip-right:after {\r\n border-right-color: #ECEFF1;\r\n}\r\n.apexcharts-yaxistooltip-right:before {\r\n border-right-color: #90A4AE;\r\n}\r\n\r\n.apexcharts-yaxistooltip.active {\r\n opacity: 1;\r\n}\r\n\r\n.apexcharts-xcrosshairs, .apexcharts-ycrosshairs {\r\n pointer-events: none;\r\n opacity: 0;\r\n transition: 0.15s ease all;\r\n}\r\n\r\n.apexcharts-xcrosshairs.active, .apexcharts-ycrosshairs.active {\r\n opacity: 1;\r\n transition: 0.15s ease all;\r\n}\r\n\r\n.apexcharts-ycrosshairs-hidden {\r\n opacity: 0;\r\n}\r\n\r\n.apexcharts-zoom-rect {\r\n pointer-events: none;\r\n}\r\n.apexcharts-selection-rect {\r\n cursor: move;\r\n}\r\n\r\n.svg_select_points, .svg_select_points_rot {\r\n opacity: 0;\r\n visibility: hidden;\r\n}\r\n.svg_select_points_l, .svg_select_points_r {\r\n cursor: ew-resize;\r\n opacity: 1;\r\n visibility: visible;\r\n fill: #888;\r\n}\r\n.zoomable .hovering-zoom {\r\n cursor: crosshair\r\n}\r\n.zoomable .hovering-pan {\r\n cursor: move\r\n}\r\n\r\n.apexcharts-xaxis,\r\n.apexcharts-yaxis {\r\n pointer-events: none;\r\n}\r\n\r\n.apexcharts-zoom-icon, \r\n.apexcharts-zoom-in-icon,\r\n.apexcharts-zoom-out-icon,\r\n.apexcharts-reset-zoom-icon, \r\n.apexcharts-pan-icon, \r\n.apexcharts-selection-icon,\r\n.apexcharts-download-icon {\r\n cursor: pointer;\r\n width: 20px;\r\n height: 20px;\r\n text-align: center;\r\n}\r\n\r\n\r\n.apexcharts-zoom-icon svg, \r\n.apexcharts-zoom-in-icon svg,\r\n.apexcharts-zoom-out-icon svg,\r\n.apexcharts-reset-zoom-icon svg,\r\n.apexcharts-download-icon svg {\r\n fill: #6E8192;\r\n}\r\n.apexcharts-selection-icon svg {\r\n fill: #444;\r\n transform: scale(0.86)\r\n}\r\n.apexcharts-zoom-icon.selected svg, \r\n.apexcharts-selection-icon.selected svg, \r\n.apexcharts-reset-zoom-icon.selected svg {\r\n fill: #008FFB;\r\n}\r\n.apexcharts-selection-icon:not(.selected):hover svg,\r\n.apexcharts-zoom-icon:not(.selected):hover svg, \r\n.apexcharts-zoom-in-icon:hover svg, \r\n.apexcharts-zoom-out-icon:hover svg, \r\n.apexcharts-reset-zoom-icon:hover svg {\r\n fill: #333;\r\n}\r\n\r\n.apexcharts-selection-icon, .apexcharts-download-icon {\r\n margin-right: 3px;\r\n position: relative;\r\n top: 1px;\r\n}\r\n.apexcharts-reset-zoom-icon {\r\n margin-left: 7px;\r\n}\r\n.apexcharts-zoom-icon {\r\n transform: scale(1);\r\n}\r\n.apexcharts-download-icon {\r\n transform: scale(0.9)\r\n}\r\n\r\n.apexcharts-zoom-in-icon, .apexcharts-zoom-out-icon {\r\n transform: scale(0.8)\r\n}\r\n\r\n.apexcharts-zoom-out-icon {\r\n margin-right: 3px;\r\n}\r\n\r\n.apexcharts-pan-icon {\r\n transform: scale(0.72);\r\n position: relative;\r\n left: 1px;\r\n top: 0px;\r\n}\r\n.apexcharts-pan-icon svg {\r\n fill: #fff;\r\n stroke: #6E8192;\r\n stroke-width: 2;\r\n}\r\n.apexcharts-pan-icon.selected svg {\r\n stroke: #008FFB;\r\n}\r\n.apexcharts-pan-icon:not(.selected):hover svg {\r\n stroke: #333;\r\n}\r\n\r\n.apexcharts-scroller-thumb, .apexcharts-scrollbutton {\r\n cursor: ew-resize;\r\n}\r\n\r\n.apexcharts-toolbar {\r\n position: absolute;\r\n z-index: 11;\r\n top: 0px;\r\n right: 3px;\r\n max-width: 176px;\r\n text-align: right;\r\n border-radius: 3px;\r\n padding: 5px 6px 2px 6px;\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center; \r\n}\r\n\r\n.apexcharts-toolbar svg {\r\n pointer-events: none;\r\n}\r\n\r\n@media screen and (min-width: 768px) {\r\n .apexcharts-toolbar {\r\n /*opacity: 0;*/\r\n }\r\n\r\n .apexcharts-canvas:hover .apexcharts-toolbar {\r\n opacity: 1;\r\n } \r\n}\r\n\r\n.apexcharts-datalabel.hidden {\r\n opacity: 0;\r\n}\r\n\r\n.apexcharts-pie-label,\r\n.apexcharts-datalabel, .apexcharts-datalabel-label, .apexcharts-datalabel-value {\r\n cursor: default;\r\n pointer-events: none;\r\n}\r\n\r\n.apexcharts-pie-label-delay {\r\n opacity: 0;\r\n animation-name: opaque;\r\n animation-duration: 0.3s;\r\n animation-fill-mode: forwards;\r\n animation-timing-function: ease;\r\n}\r\n\r\n.apexcharts-showAfterDelay {\r\n opacity: 0;\r\n animation-name: opaque;\r\n animation-duration: 0.3s;\r\n animation-fill-mode: forwards;\r\n}\r\n\r\n.apexcharts-hide .apexcharts-series-points {\r\n opacity: 0;\r\n}\r\n\r\n.apexcharts-area-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events,\r\n.apexcharts-line-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events {\r\n pointer-events: none;\r\n}\r\n\r\n\r\n/* markers */\r\n\r\n.apexcharts-marker {\r\n transition: 0.15s ease all;\r\n}\r\n\r\n@keyframes opaque {\r\n 0% {\r\n opacity: 0;\r\n }\r\n 100% {\r\n opacity: 1;\r\n }\r\n}", ""]); - -// exports - - -/***/ }), -/* 129 */ -/***/ (function(module, exports, __webpack_require__) { - - -var content = __webpack_require__(128); - -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__(130)(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(); }); -} - -/***/ }), -/* 130 */ -/***/ (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__(122); - -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 element - if (!options.insertInto) options.insertInto = "head"; - - // By default, add