(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["G2_3"] = factory(); else root["G2_3"] = factory(); })(typeof self !== 'undefined' ? self : 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; /******/ /******/ // 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 = 126); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview The util method based on the lodash. * @author dxq613@gmail.com * @see https://github.com/lodash/lodash */ var MAX_LEVEL = 5; function _mix(dist, obj) { for (var k in obj) { if (obj.hasOwnProperty(k) && k !== 'constructor' && obj[k] !== undefined) { dist[k] = obj[k]; } } } var Util = { each: __webpack_require__(127), map: __webpack_require__(142), isObject: __webpack_require__(7), isNumber: __webpack_require__(193), isString: __webpack_require__(89), isFunction: __webpack_require__(48), isFinite: __webpack_require__(194), isBoolean: __webpack_require__(195), isEmpty: __webpack_require__(196), lowerFirst: __webpack_require__(197), upperFirst: __webpack_require__(202), upperCase: __webpack_require__(203), isNil: __webpack_require__(93), isNull: __webpack_require__(212), isArray: __webpack_require__(3), isDate: __webpack_require__(213), isPlainObject: __webpack_require__(215), toArray: __webpack_require__(216), indexOf: __webpack_require__(220), assign: __webpack_require__(60), groupBy: __webpack_require__(231), cloneDeep: __webpack_require__(102), maxBy: __webpack_require__(256), minBy: __webpack_require__(258), round: __webpack_require__(260), filter: __webpack_require__(262), isEqualWith: __webpack_require__(264), isEqual: __webpack_require__(265), replace: __webpack_require__(266), union: __webpack_require__(267), pick: __webpack_require__(274), uniq: __webpack_require__(280), snapEqual: function snapEqual(v1, v2) { return Math.abs(v1 - v2) < 0.001; }, fixedBase: function fixedBase(v, base) { var str = base.toString(); var index = str.indexOf('.'); if (index === -1) { return Math.round(v); } var length = str.substr(index + 1).length; if (length > 20) { length = 20; } return parseFloat(v.toFixed(length)); }, mix: function mix(dist, obj1, obj2, obj3) { if (obj1) { _mix(dist, obj1); } if (obj2) { _mix(dist, obj2); } if (obj3) { _mix(dist, obj3); } return dist; }, inArray: function inArray(arr, value) { return arr.indexOf(value) >= 0; }, /** * 封装事件,便于使用上下文this,和便于解除事件时使用 * @protected * @param {Object} obj 对象 * @param {String} action 事件名称 * @return {Function} 返回事件处理函数 */ wrapBehavior: function wrapBehavior(obj, action) { if (obj['_wrap_' + action]) { return obj['_wrap_' + action]; } var method = function method(e) { obj[action](e); }; obj['_wrap_' + action] = method; return method; }, /** * 获取封装的事件 * @protected * @param {Object} obj 对象 * @param {String} action 事件名称 * @return {Function} 返回事件处理函数 */ getWrapBehavior: function getWrapBehavior(obj, action) { return obj['_wrap_' + action]; }, /** * 将用户输入的 padding 转换成 [top, right, bottom, right] 的模式 * @param {Number|Array} padding 输入的padding * @return {Array} 四个padding 值 */ toAllPadding: function toAllPadding(padding) { var top = 0; var left = 0; var right = 0; var bottom = 0; if (Util.isNumber(padding) || Util.isString(padding)) { top = left = right = bottom = padding; } else if (Util.isArray(padding)) { top = padding[0]; right = !Util.isNil(padding[1]) ? padding[1] : padding[0]; bottom = !Util.isNil(padding[2]) ? padding[2] : padding[0]; left = !Util.isNil(padding[3]) ? padding[3] : right; } else if (Util.isObject(padding)) { top = padding.top || 0; right = padding.right || 0; bottom = padding.bottom || 0; left = padding.left || 0; } return [top, right, bottom, left]; }, /** * 替换字符串中的字段. * @param {String} str 模版字符串 * @param {Object} o json data * @return {String} 替换后的字符串 */ substitute: function substitute(str, o) { if (!str || !o) { return str; } return str.replace(/\\?\{([^{}]+)\}/g, function (match, name) { if (match.charAt(0) === '\\') { return match.slice(1); } return o[name] === undefined ? '' : o[name]; }); } }; function deepMix(dst, src, level) { level = level || 0; for (var k in src) { if (src.hasOwnProperty(k)) { var value = src[k]; if (value !== null && Util.isPlainObject(value)) { if (!Util.isPlainObject(dst[k])) { dst[k] = {}; } if (level < MAX_LEVEL) { deepMix(dst[k], src[k], level + 1); } else { dst[k] = src[k]; } } else if (Util.isArray(value)) { dst[k] = []; dst[k] = dst[k].concat(value); } else if (value !== undefined) { dst[k] = src[k]; } } } } Util.deepMix = function () { var args = Util.toArray(arguments); var rst = args[0]; for (var i = 1; i < args.length; i++) { var source = args[i]; deepMix(rst, source); } return rst; }; Util.Array = { merge: function merge(dataArray) { var rst = []; for (var i = 0; i < dataArray.length; i++) { rst = rst.concat(dataArray[i]); } return rst; }, values: function values(data, name) { var rst = []; var tmpMap = {}; for (var i = 0; i < data.length; i++) { var obj = data[i]; var value = obj[name]; if (!Util.isNil(value)) { if (!Util.isArray(value)) { value = [value]; } Util.each(value, function (val) { if (!tmpMap[val]) { rst.push(val); tmpMap[val] = true; } }); } } return rst; }, getRange: function getRange(values) { if (!values.length) { // 如果没有数值则直接返回0 return { min: 0, max: 0 }; } if (Util.isArray(values[0])) { var tmp = []; for (var i = 0; i < values.length; i++) { tmp = tmp.concat(values[i]); } values = tmp; } var max = Math.max.apply(null, values); var min = Math.min.apply(null, values); return { min: min, max: max }; }, firstValue: function firstValue(data, name) { var rst = null; for (var i = 0; i < data.length; i++) { var obj = data[i]; var value = obj[name]; if (!Util.isNil(value)) { if (Util.isArray(value)) { rst = value[0]; } else { rst = value; } break; } } return rst; }, group: function group(data, condition) { if (!condition) { return [data]; } var groups = Util.Array.groupToMap(data, condition); var array = []; for (var i in groups) { array.push(groups[i]); } return array; }, groupToMap: function groupToMap(data, condition) { if (!condition) { return { 0: data }; } if (!Util.isFunction(condition)) { var paramsCondition = Util.isArray(condition) ? condition : condition.replace(/\s+/g, '').split('*'); condition = function condition(row) { var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序 for (var i = 0, l = paramsCondition.length; i < l; i++) { unique += row[paramsCondition[i]] && row[paramsCondition[i]].toString(); } return unique; }; } var groups = Util.groupBy(data, condition); return groups; }, remove: function remove(arr, obj) { var index = Util.indexOf(arr, obj); if (index !== -1) { arr.splice(index, 1); } } }; module.exports = Util; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 全局变量 * @author dxq613 */ var Util = __webpack_require__(0); var Theme = __webpack_require__(292); var Global = {}; var Default = { version: '3.0.2-beta.1', trackable: true, animate: true, snapArray: [0, 1, 2, 4, 5, 10], // 指定固定 tick 数的逼近值 snapCountArray: [0, 1, 1.2, 1.5, 1.6, 2, 2.2, 2.4, 3, 4, 5, 6, 7.5, 8, 10], widthRatio: { // 宽度所占的分类的比例 column: 1 / 2, // 一般的柱状图占比 1/2 rose: 0.9999999, // 玫瑰图柱状占比 1 multiplePie: 1 / 1.3 // 多层的饼图、环图 }, // 折线图、区域图、path 当只有一个数据时,是否显示成点 showSinglePoint: false, connectNulls: false, scales: {} }; function setTheme(theme) { for (var k in Global) { if (Global.hasOwnProperty(k)) { delete Global[k]; } } var newTheme = {}; if (Util.isObject(theme)) { newTheme = theme; } else if (Util.indexOf(Object.keys(Theme), theme) !== -1) { newTheme = Theme[theme]; } else { newTheme = Theme.default; } Util.deepMix(Global, Default, newTheme); Global.setTheme = setTheme; } setTheme('default'); module.exports = Global; /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof2 = 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; }; (function webpackUniversalModuleDefinition(root, factory) { if (( false ? 'undefined' : _typeof2(exports)) === 'object' && ( false ? 'undefined' : _typeof2(module)) === 'object') module.exports = factory();else if (true) !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else if ((typeof exports === 'undefined' ? 'undefined' : _typeof2(exports)) === 'object') exports["G"] = factory();else root["G"] = 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; /******/ /******/ // 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 = 112); /******/ }( /************************************************************************/ /******/[ /* 0 */ /***/function (module, exports, __webpack_require__) { var CommonUtil = __webpack_require__(31); var DomUtil = __webpack_require__(85); var Util = {}; CommonUtil.merge(Util, CommonUtil, DomUtil, { mixin: function mixin(c, mixins) { var Param = c.CFG ? 'CFG' : 'ATTRS'; if (c && mixins) { c._mixins = mixins; c[Param] = c[Param] || {}; var temp = {}; Util.each(mixins, function (mixin) { Util.augment(c, mixin); var attrs = mixin[Param]; if (attrs) { Util.merge(temp, attrs); } }); c[Param] = Util.merge(temp, c[Param]); } } }); module.exports = Util; /***/ }, /* 1 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Element = __webpack_require__(88); var Inside = __webpack_require__(2); var Shape = function Shape(cfg) { Shape.superclass.constructor.call(this, cfg); }; Shape.ATTRS = {}; Util.extend(Shape, Element); Util.augment(Shape, { isShape: true, createPath: function createPath() {}, drawInner: function drawInner(context) { var self = this; var attrs = self.__attrs; self.createPath(context); var originOpacity = context.globalAlpha; if (self.hasFill()) { var fillOpacity = attrs.fillOpacity; if (!Util.isNil(fillOpacity) && fillOpacity !== 1) { context.globalAlpha = fillOpacity; context.fill(); context.globalAlpha = originOpacity; } else { context.fill(); } } if (self.hasStroke()) { var lineWidth = self.__attrs.lineWidth; if (lineWidth > 0) { var strokeOpacity = attrs.strokeOpacity; if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) { context.globalAlpha = strokeOpacity; } context.stroke(); } } }, /** * 节点是否在图形中 * @param {Number} x x 坐标 * @param {Number} y y 坐标 * @return {Boolean} 是否在图形中 */ isPointInPath: function isPointInPath() { return false; }, /** * 击中图形时是否进行包围盒判断 * @return {Boolean} [description] */ isHitBox: function isHitBox() { return true; }, /** * 节点是否能够被击中 * @param {Number} x x坐标 * @param {Number} y y坐标 * @return {Boolean} 是否在图形中 */ isHit: function isHit(x, y) { var self = this; var v = [x, y, 1]; self.invert(v); // canvas if (self.isHitBox()) { var box = self.getBBox(); if (box && !Inside.box(box.minX, box.maxX, box.minY, box.maxY, v[0], v[1])) { return false; } } var clip = self.__attrs.clip; if (clip) { if (clip.inside(x, y)) { return self.isPointInPath(v[0], v[1]); } } else { return self.isPointInPath(v[0], v[1]); } return false; }, /** * @protected * 计算包围盒 * @return {Object} 包围盒 */ calculateBox: function calculateBox() { return null; }, // 清除当前的矩阵 clearTotalMatrix: function clearTotalMatrix() { this.__cfg.totalMatrix = null; this.__cfg.region = null; }, clearBBox: function clearBBox() { this.__cfg.box = null; this.__cfg.region = null; }, getBBox: function getBBox() { var box = this.__cfg.box; // 延迟计算 if (!box) { box = this.calculateBox(); if (box) { box.x = box.minX; box.y = box.minY; box.width = box.maxX - box.minX; box.height = box.maxY - box.minY; } this.__cfg.box = box; } return box; } }); module.exports = Shape; /***/ }, /* 2 */ /***/function (module, exports, __webpack_require__) { var Line = __webpack_require__(52); var Quadratic = __webpack_require__(53); var Cubic = __webpack_require__(30); var Arc = __webpack_require__(54); module.exports = { line: function line(x1, y1, x2, y2, lineWidth, x, y) { var box = Line.box(x1, y1, x2, y2, lineWidth); if (!this.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) { return false; } var d = Line.pointDistance(x1, y1, x2, y2, x, y); if (isNaN(d)) { return false; } return d <= lineWidth / 2; }, polyline: function polyline(points, lineWidth, x, y) { var l = points.length - 1; if (l < 1) { return false; } for (var i = 0; i < l; i++) { var x1 = points[i][0]; var y1 = points[i][1]; var x2 = points[i + 1][0]; var y2 = points[i + 1][1]; if (this.line(x1, y1, x2, y2, lineWidth, x, y)) { return true; } } return false; }, cubicline: function cubicline(x1, y1, x2, y2, x3, y3, x4, y4, lineWidth, x, y) { return Cubic.pointDistance(x1, y1, x2, y2, x3, y3, x4, y4, x, y) <= lineWidth / 2; }, quadraticline: function quadraticline(x1, y1, x2, y2, x3, y3, lineWidth, x, y) { return Quadratic.pointDistance(x1, y1, x2, y2, x3, y3, x, y) <= lineWidth / 2; }, arcline: function arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y) { return Arc.pointDistance(cx, cy, r, startAngle, endAngle, clockwise, x, y) <= lineWidth / 2; }, rect: function rect(rx, ry, width, height, x, y) { return rx <= x && x <= rx + width && ry <= y && y <= ry + height; }, circle: function circle(cx, cy, r, x, y) { return Math.pow(x - cx, 2) + Math.pow(y - cy, 2) <= Math.pow(r, 2); }, box: function box(minX, maxX, minY, maxY, x, y) { return minX <= x && x <= maxX && minY <= y && y <= maxY; } }; /***/ }, /* 3 */ /***/function (module, exports, __webpack_require__) { var CommonUtil = __webpack_require__(31); var mat3 = __webpack_require__(230); var vec3 = __webpack_require__(231); var vec2 = __webpack_require__(232); vec2.angle = function (v1, v2) { var theta = vec2.dot(v1, v2) / (vec2.length(v1) * vec2.length(v2)); return Math.acos(CommonUtil.clamp(theta, -1, 1)); }; /** * 向量 v1 到 向量 v2 夹角的方向 * @param {Array} v1 向量 * @param {Array} v2 向量 * @return {Boolean} >= 0 顺时针 < 0 逆时针 */ vec2.direction = function (v1, v2) { return v1[0] * v2[1] - v2[0] * v1[1]; }; vec2.angleTo = function (v1, v2, direct) { var angle = vec2.angle(v1, v2); var angleLargeThanPI = vec2.direction(v1, v2) >= 0; if (direct) { if (angleLargeThanPI) { return Math.PI * 2 - angle; } return angle; } if (angleLargeThanPI) { return angle; } return Math.PI * 2 - angle; }; vec2.vertical = function (out, v, flag) { if (flag) { out[0] = v[1]; out[1] = -1 * v[0]; } else { out[0] = -1 * v[1]; out[1] = v[0]; } return out; }; mat3.translate = function (out, a, v) { var transMat = new Array(9); mat3.fromTranslation(transMat, v); return mat3.multiply(out, transMat, a); }; mat3.rotate = function (out, a, rad) { var rotateMat = new Array(9); mat3.fromRotation(rotateMat, rad); return mat3.multiply(out, rotateMat, a); }; mat3.scale = function (out, a, v) { var scaleMat = new Array(9); mat3.fromScaling(scaleMat, v); return mat3.multiply(out, scaleMat, a); }; module.exports = { mat3: mat3, vec2: vec2, vec3: vec3, transform: function transform(m, ts) { m = CommonUtil.clone(m); CommonUtil.each(ts, function (t) { switch (t[0]) { case 't': mat3.translate(m, m, [t[1], t[2]]); break; case 's': mat3.scale(m, m, [t[1], t[2]]); break; case 'r': mat3.rotate(m, m, t[1]); break; case 'm': mat3.multiply(m, m, t[1]); break; default: return false; } }); return m; } }; /***/ }, /* 4 */ /***/function (module, exports, __webpack_require__) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; var freeGlobal = __webpack_require__(55); /** Detect free variable `self`. */ var freeSelf = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ var root = freeGlobal || freeSelf || Function('return this')(); module.exports = root; /***/ }, /* 5 */ /***/function (module, exports) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is object-like, else `false`. * @example * * _.isObjectLike({}); * // => true * * _.isObjectLike([1, 2, 3]); * // => true * * _.isObjectLike(_.noop); * // => false * * _.isObjectLike(null); * // => false */ function isObjectLike(value) { return value != null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object'; } module.exports = isObjectLike; /***/ }, /* 6 */ /***/function (module, exports) { /** * Checks if `value` is classified as an `Array` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array, else `false`. * @example * * _.isArray([1, 2, 3]); * // => true * * _.isArray(document.body.children); * // => false * * _.isArray('abc'); * // => false * * _.isArray(_.noop); * // => false */ var isArray = Array.isArray; module.exports = isArray; /***/ }, /* 7 */ /***/function (module, exports, __webpack_require__) { var _Symbol = __webpack_require__(11), getRawTag = __webpack_require__(115), objectToString = __webpack_require__(116); /** `Object#toString` result references. */ var nullTag = '[object Null]', undefinedTag = '[object Undefined]'; /** Built-in value references. */ var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; /** * The base implementation of `getTag` without fallbacks for buggy environments. * * @private * @param {*} value The value to query. * @returns {string} Returns the `toStringTag`. */ function baseGetTag(value) { if (value == null) { return value === undefined ? undefinedTag : nullTag; } return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); } module.exports = baseGetTag; /***/ }, /* 8 */ /***/function (module, exports) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; /** * Checks if `value` is the * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an object, else `false`. * @example * * _.isObject({}); * // => true * * _.isObject([1, 2, 3]); * // => true * * _.isObject(_.noop); * // => true * * _.isObject(null); * // => false */ function isObject(value) { var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); return value != null && (type == 'object' || type == 'function'); } module.exports = isObject; /***/ }, /* 9 */ /***/function (module, exports, __webpack_require__) { var isFunction = __webpack_require__(20), isLength = __webpack_require__(60); /** * Checks if `value` is array-like. A value is considered array-like if it's * not a function and has a `value.length` that's an integer greater than or * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is array-like, else `false`. * @example * * _.isArrayLike([1, 2, 3]); * // => true * * _.isArrayLike(document.body.children); * // => true * * _.isArrayLike('abc'); * // => true * * _.isArrayLike(_.noop); * // => false */ function isArrayLike(value) { return value != null && isLength(value.length) && !isFunction(value); } module.exports = isArrayLike; /***/ }, /* 10 */ /***/function (module, exports, __webpack_require__) { var baseIsNative = __webpack_require__(123), getValue = __webpack_require__(126); /** * Gets the native function at `key` of `object`. * * @private * @param {Object} object The object to query. * @param {string} key The key of the method to get. * @returns {*} Returns the function if it's native, else `undefined`. */ function getNative(object, key) { var value = getValue(object, key); return baseIsNative(value) ? value : undefined; } module.exports = getNative; /***/ }, /* 11 */ /***/function (module, exports, __webpack_require__) { var root = __webpack_require__(4); /** Built-in value references. */ var _Symbol = root.Symbol; module.exports = _Symbol; /***/ }, /* 12 */ /***/function (module, exports, __webpack_require__) { var assignValue = __webpack_require__(37), baseAssignValue = __webpack_require__(38); /** * Copies properties of `source` to `object`. * * @private * @param {Object} source The object to copy properties from. * @param {Array} props The property identifiers to copy. * @param {Object} [object={}] The object to copy properties to. * @param {Function} [customizer] The function to customize copied values. * @returns {Object} Returns `object`. */ function copyObject(source, props, object, customizer) { var isNew = !object; object || (object = {}); var index = -1, length = props.length; while (++index < length) { var key = props[index]; var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined; if (newValue === undefined) { newValue = source[key]; } if (isNew) { baseAssignValue(object, key, newValue); } else { assignValue(object, key, newValue); } } return object; } module.exports = copyObject; /***/ }, /* 13 */ /***/function (module, exports, __webpack_require__) { var arrayLikeKeys = __webpack_require__(66), baseKeys = __webpack_require__(57), isArrayLike = __webpack_require__(9); /** * Creates an array of the own enumerable property names of `object`. * * **Note:** Non-object values are coerced to objects. See the * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) * for more details. * * @static * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. * @example * * function Foo() { * this.a = 1; * this.b = 2; * } * * Foo.prototype.c = 3; * * _.keys(new Foo); * // => ['a', 'b'] (iteration order is not guaranteed) * * _.keys('hi'); * // => ['0', '1'] */ function keys(object) { return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } module.exports = keys; /***/ }, /* 14 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_color__ = __webpack_require__(49); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "a", function () { return __WEBPACK_IMPORTED_MODULE_0__src_color__["e"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "f", function () { return __WEBPACK_IMPORTED_MODULE_0__src_color__["g"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "d", function () { return __WEBPACK_IMPORTED_MODULE_0__src_color__["f"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__src_lab__ = __webpack_require__(249); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "e", function () { return __WEBPACK_IMPORTED_MODULE_1__src_lab__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "c", function () { return __WEBPACK_IMPORTED_MODULE_1__src_lab__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__src_cubehelix__ = __webpack_require__(250); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "b", function () { return __WEBPACK_IMPORTED_MODULE_2__src_cubehelix__["a"]; }); /***/ }, /* 15 */ /***/function (module, exports) { var PI = Math.PI; var sin = Math.sin; var cos = Math.cos; var atan2 = Math.atan2; var DEFAULT_LENGTH = 10; var DEFAULT_ANGLE = PI / 3; function _addArrow(ctx, attrs, x1, y1, x2, y2) { var leftX = void 0; var leftY = void 0; var rightX = void 0; var rightY = void 0; var offsetX = void 0; var offsetY = void 0; var angle = void 0; if (!attrs.fill) { // 闭合的不绘制箭头 var arrowLength = attrs.arrowLength || DEFAULT_LENGTH; var arrowAngle = attrs.arrowAngle ? attrs.arrowAngle * PI / 180 : DEFAULT_ANGLE; // 转换为弧度 // Calculate angle angle = atan2(y2 - y1, x2 - x1); // Adjust angle correctly angle -= PI; // Calculate offset to place arrow at edge of path offsetX = attrs.lineWidth * cos(angle); offsetY = attrs.lineWidth * sin(angle); // Calculate coordinates for left half of arrow leftX = x2 + arrowLength * cos(angle + arrowAngle / 2); leftY = y2 + arrowLength * sin(angle + arrowAngle / 2); // Calculate coordinates for right half of arrow rightX = x2 + arrowLength * cos(angle - arrowAngle / 2); rightY = y2 + arrowLength * sin(angle - arrowAngle / 2); // Draw left half of arrow ctx.moveTo(leftX - offsetX, leftY - offsetY); ctx.lineTo(x2 - offsetX, y2 - offsetY); // Draw right half of arrow ctx.lineTo(rightX - offsetX, rightY - offsetY); // Visually connect arrow to path ctx.moveTo(x2 - offsetX, y2 - offsetY); ctx.lineTo(x2 + offsetX, y2 + offsetY); // Move back to end of path ctx.moveTo(x2, y2); } } module.exports = { addStartArrow: function addStartArrow(ctx, attrs, x1, y1, x2, y2) { if (attrs.startArrow) { _addArrow(ctx, attrs, x1, y1, x2, y2); } }, addEndArrow: function addEndArrow(ctx, attrs, x1, y1, x2, y2) { if (attrs.endArrow) { _addArrow(ctx, attrs, x1, y1, x2, y2); } } }; /***/ }, /* 16 */ /***/function (module, exports) { /** Used for built-in method references. */ var objectProto = Object.prototype; /** * Checks if `value` is likely a prototype object. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. */ function isPrototype(value) { var Ctor = value && value.constructor, proto = typeof Ctor == 'function' && Ctor.prototype || objectProto; return value === proto; } module.exports = isPrototype; /***/ }, /* 17 */ /***/function (module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function (module) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; var root = __webpack_require__(4), stubFalse = __webpack_require__(131); /** Detect free variable `exports`. */ var freeExports = (false ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && (false ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; /** * Checks if `value` is a buffer. * * @static * @memberOf _ * @since 4.3.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. * @example * * _.isBuffer(new Buffer(2)); * // => true * * _.isBuffer(new Uint8Array(2)); * // => false */ var isBuffer = nativeIsBuffer || stubFalse; module.exports = isBuffer; /* WEBPACK VAR INJECTION */ }).call(exports, __webpack_require__(34)(module)); /***/ }, /* 18 */ /***/function (module, exports) { /** * Performs a * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * var object = { 'a': 1 }; * var other = { 'a': 1 }; * * _.eq(object, object); * // => true * * _.eq(object, other); * // => false * * _.eq('a', 'a'); * // => true * * _.eq('a', Object('a')); * // => false * * _.eq(NaN, NaN); * // => true */ function eq(value, other) { return value === other || value !== value && other !== other; } module.exports = eq; /***/ }, /* 19 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["c"] = hue; /* harmony export (immutable) */__webpack_exports__["b"] = gamma; /* harmony export (immutable) */__webpack_exports__["a"] = nogamma; /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__constant__ = __webpack_require__(92); function linear(a, d) { return function (t) { return a + t * d; }; } function exponential(a, b, y) { return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function (t) { return Math.pow(a + t * b, y); }; } function hue(a, b) { var d = b - a; return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a); } function gamma(y) { return (y = +y) === 1 ? nogamma : function (a, b) { return b - a ? exponential(a, b, y) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a); }; } function nogamma(a, b) { var d = b - a; return d ? linear(a, d) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a); } /***/ }, /* 20 */ /***/function (module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(7), isObject = __webpack_require__(8); /** `Object#toString` result references. */ var asyncTag = '[object AsyncFunction]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', proxyTag = '[object Proxy]'; /** * Checks if `value` is classified as a `Function` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a function, else `false`. * @example * * _.isFunction(_); * // => true * * _.isFunction(/abc/); * // => false */ function isFunction(value) { if (!isObject(value)) { return false; } // The use of `Object#toString` avoids issues with the `typeof` operator // in Safari 9 which returns 'object' for typed arrays and other constructors. var tag = baseGetTag(value); return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } module.exports = isFunction; /***/ }, /* 21 */ /***/function (module, exports, __webpack_require__) { var DataView = __webpack_require__(122), Map = __webpack_require__(32), Promise = __webpack_require__(127), Set = __webpack_require__(128), WeakMap = __webpack_require__(129), baseGetTag = __webpack_require__(7), toSource = __webpack_require__(59); /** `Object#toString` result references. */ var mapTag = '[object Map]', objectTag = '[object Object]', promiseTag = '[object Promise]', setTag = '[object Set]', weakMapTag = '[object WeakMap]'; var dataViewTag = '[object DataView]'; /** Used to detect maps, sets, and weakmaps. */ var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map), promiseCtorString = toSource(Promise), setCtorString = toSource(Set), weakMapCtorString = toSource(WeakMap); /** * Gets the `toStringTag` of `value`. * * @private * @param {*} value The value to query. * @returns {string} Returns the `toStringTag`. */ var getTag = baseGetTag; // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise && getTag(Promise.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) { getTag = function getTag(value) { var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : undefined, ctorString = Ctor ? toSource(Ctor) : ''; if (ctorString) { switch (ctorString) { case dataViewCtorString: return dataViewTag; case mapCtorString: return mapTag; case promiseCtorString: return promiseTag; case setCtorString: return setTag; case weakMapCtorString: return weakMapTag; } } return result; }; } module.exports = getTag; /***/ }, /* 22 */ /***/function (module, exports, __webpack_require__) { var baseIsTypedArray = __webpack_require__(132), baseUnary = __webpack_require__(61), nodeUtil = __webpack_require__(133); /* Node.js helper references. */ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; /** * Checks if `value` is classified as a typed array. * * @static * @memberOf _ * @since 3.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. * @example * * _.isTypedArray(new Uint8Array); * // => true * * _.isTypedArray([]); * // => false */ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; module.exports = isTypedArray; /***/ }, /* 23 */ /***/function (module, exports, __webpack_require__) { var listCacheClear = __webpack_require__(139), listCacheDelete = __webpack_require__(140), listCacheGet = __webpack_require__(141), listCacheHas = __webpack_require__(142), listCacheSet = __webpack_require__(143); /** * Creates an list cache object. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function ListCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `ListCache`. ListCache.prototype.clear = listCacheClear; ListCache.prototype['delete'] = listCacheDelete; ListCache.prototype.get = listCacheGet; ListCache.prototype.has = listCacheHas; ListCache.prototype.set = listCacheSet; module.exports = ListCache; /***/ }, /* 24 */ /***/function (module, exports, __webpack_require__) { var eq = __webpack_require__(18); /** * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private * @param {Array} array The array to inspect. * @param {*} key The key to search for. * @returns {number} Returns the index of the matched value, else `-1`. */ function assocIndexOf(array, key) { var length = array.length; while (length--) { if (eq(array[length][0], key)) { return length; } } return -1; } module.exports = assocIndexOf; /***/ }, /* 25 */ /***/function (module, exports, __webpack_require__) { var getNative = __webpack_require__(10); /* Built-in method references that are verified to be native. */ var nativeCreate = getNative(Object, 'create'); module.exports = nativeCreate; /***/ }, /* 26 */ /***/function (module, exports, __webpack_require__) { var isKeyable = __webpack_require__(157); /** * Gets the data for `map`. * * @private * @param {Object} map The map to query. * @param {string} key The reference key. * @returns {*} Returns the map data. */ function getMapData(map, key) { var data = map.__data__; return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map; } module.exports = getMapData; /***/ }, /* 27 */ /***/function (module, exports, __webpack_require__) { var arrayLikeKeys = __webpack_require__(66), baseKeysIn = __webpack_require__(164), isArrayLike = __webpack_require__(9); /** * Creates an array of the own and inherited enumerable property names of `object`. * * **Note:** Non-object values are coerced to objects. * * @static * @memberOf _ * @since 3.0.0 * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. * @example * * function Foo() { * this.a = 1; * this.b = 2; * } * * Foo.prototype.c = 3; * * _.keysIn(new Foo); * // => ['a', 'b', 'c'] (iteration order is not guaranteed) */ function keysIn(object) { return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); } module.exports = keysIn; /***/ }, /* 28 */ /***/function (module, exports) { /** * Copies the values of `source` to `array`. * * @private * @param {Array} source The array to copy values from. * @param {Array} [array=[]] The array to copy values to. * @returns {Array} Returns `array`. */ function copyArray(source, array) { var index = -1, length = source.length; array || (array = Array(length)); while (++index < length) { array[index] = source[index]; } return array; } module.exports = copyArray; /***/ }, /* 29 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony default export */ __webpack_exports__["a"] = function (a, b) { return a = +a, b -= a, function (t) { return a + b * t; }; }; /***/ }, /* 30 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var vec2 = __webpack_require__(3).vec2; function cubicAt(p0, p1, p2, p3, t) { var onet = 1 - t; return onet * onet * (onet * p3 + 3 * t * p2) + t * t * (t * p0 + 3 * onet * p1); } function cubicDerivativeAt(p0, p1, p2, p3, t) { var onet = 1 - t; return 3 * (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + (p3 - p2) * t * t); } function cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, out) { var t = void 0; var interval = 0.005; var d = Infinity; var _t = void 0; var v1 = void 0; var d1 = void 0; var d2 = void 0; var v2 = void 0; var prev = void 0; var next = void 0; var EPSILON = 0.0001; var v0 = [x, y]; for (_t = 0; _t < 1; _t += 0.05) { v1 = [cubicAt(x1, x2, x3, x4, _t), cubicAt(y1, y2, y3, y4, _t)]; d1 = vec2.squaredDistance(v0, v1); if (d1 < d) { t = _t; d = d1; } } d = Infinity; for (var i = 0; i < 32; i++) { if (interval < EPSILON) { break; } prev = t - interval; next = t + interval; v1 = [cubicAt(x1, x2, x3, x4, prev), cubicAt(y1, y2, y3, y4, prev)]; d1 = vec2.squaredDistance(v0, v1); if (prev >= 0 && d1 < d) { t = prev; d = d1; } else { v2 = [cubicAt(x1, x2, x3, x4, next), cubicAt(y1, y2, y3, y4, next)]; d2 = vec2.squaredDistance(v0, v2); if (next <= 1 && d2 < d) { t = next; d = d2; } else { interval *= 0.5; } } } if (out) { out.x = cubicAt(x1, x2, x3, x4, t); out.y = cubicAt(y1, y2, y3, y4, t); } return Math.sqrt(d); } function cubicExtrema(p0, p1, p2, p3) { var a = 3 * p0 - 9 * p1 + 9 * p2 - 3 * p3; var b = 6 * p1 - 12 * p2 + 6 * p3; var c = 3 * p2 - 3 * p3; var extrema = []; var t1 = void 0; var t2 = void 0; var discSqrt = void 0; if (Util.isNumberEqual(a, 0)) { if (!Util.isNumberEqual(b, 0)) { t1 = -c / b; if (t1 >= 0 && t1 <= 1) { extrema.push(t1); } } } else { var disc = b * b - 4 * a * c; if (Util.isNumberEqual(disc, 0)) { extrema.push(-b / (2 * a)); } else if (disc > 0) { discSqrt = Math.sqrt(disc); t1 = (-b + discSqrt) / (2 * a); t2 = (-b - discSqrt) / (2 * a); if (t1 >= 0 && t1 <= 1) { extrema.push(t1); } if (t2 >= 0 && t2 <= 1) { extrema.push(t2); } } } return extrema; } function base3(t, p1, p2, p3, p4) { var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4; var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3; return t * t2 - 3 * p1 + 3 * p2; } function cubiclLen(x1, y1, x2, y2, x3, y3, x4, y4, z) { if (Util.isNil(z)) { z = 1; } z = z > 1 ? 1 : z < 0 ? 0 : z; var z2 = z / 2; var n = 12; var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816]; var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472]; var sum = 0; for (var i = 0; i < n; i++) { var ct = z2 * Tvalues[i] + z2; var xbase = base3(ct, x1, x2, x3, x4); var ybase = base3(ct, y1, y2, y3, y4); var comb = xbase * xbase + ybase * ybase; sum += Cvalues[i] * Math.sqrt(comb); } return z2 * sum; } module.exports = { at: cubicAt, derivativeAt: cubicDerivativeAt, projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y) { var rst = {}; cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, rst); return rst; }, pointDistance: cubicProjectPoint, extrema: cubicExtrema, len: cubiclLen }; /***/ }, /* 31 */ /***/function (module, exports, __webpack_require__) { var PRECISION = 0.00001; // 常量,据的精度,小于这个精度认为是0 var RADIAN = Math.PI / 180; var DEGREE = 180 / Math.PI; module.exports = { isFunction: __webpack_require__(20), isObject: __webpack_require__(8), isBoolean: __webpack_require__(117), isNil: __webpack_require__(118), isString: __webpack_require__(56), isArray: __webpack_require__(6), isNumber: __webpack_require__(119), isEmpty: __webpack_require__(120), // isBlank uniqueId: __webpack_require__(134), clone: __webpack_require__(137), assign: __webpack_require__(180), // simpleMix merge: __webpack_require__(188), // mix upperFirst: __webpack_require__(195), // ucfirst remove: __webpack_require__(201), each: __webpack_require__(209), isEqual: __webpack_require__(214), toArray: __webpack_require__(224), extend: function extend(subclass, superclass, overrides, staticOverrides) { // 如果只提供父类构造函数,则自动生成子类构造函数 if (!this.isFunction(superclass)) { overrides = superclass; superclass = subclass; subclass = function subclass() {}; } var create = Object.create ? function (proto, c) { return Object.create(proto, { constructor: { value: c } }); } : function (proto, c) { function F() {} F.prototype = proto; var o = new F(); o.constructor = c; return o; }; var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype subclass.prototype = this.merge(superObj, subclass.prototype); // 指定子类的prototype subclass.superclass = create(superclass.prototype, superclass); this.merge(superObj, overrides); this.merge(subclass, staticOverrides); return subclass; }, augment: function augment(c) { var args = this.toArray(arguments); for (var i = 1; i < args.length; i++) { var obj = args[i]; if (this.isFunction(obj)) { obj = obj.prototype; } this.merge(c.prototype, obj); } }, /** * 判断两个数是否相等 * @param {Number} a 数 * @param {Number} b 数 * @return {Boolean} 是否相等 **/ isNumberEqual: function isNumberEqual(a, b) { return Math.abs(a - b) < PRECISION; }, /** * 获取角度对应的弧度 * @param {Number} degree 角度 * @return {Number} 弧度 **/ toRadian: function toRadian(degree) { return RADIAN * degree; }, /** * 获取弧度对应的角度 * @param {Number} radian 弧度 * @return {Number} 角度 **/ toDegree: function toDegree(radian) { return DEGREE * radian; }, /** * 广义取模运算 * @param {Number} n 被取模的值 * @param {Number} m 模 * @return {Number} 返回n 被 m 取模的结果 */ mod: function mod(n, m) { return (n % m + m) % m; }, /** * 把a夹在min,max中间, 低于min的返回min,高于max的返回max,否则返回自身 * @param {Number} a 数 * @param {Number} min 下限 * @param {Number} max 上限 * @return {Number} 返回结果值 **/ clamp: function clamp(a, min, max) { if (a < min) { return min; } else if (a > max) { return max; } return a; } }; /***/ }, /* 32 */ /***/function (module, exports, __webpack_require__) { var getNative = __webpack_require__(10), root = __webpack_require__(4); /* Built-in method references that are verified to be native. */ var Map = getNative(root, 'Map'); module.exports = Map; /***/ }, /* 33 */ /***/function (module, exports, __webpack_require__) { var baseIsArguments = __webpack_require__(130), isObjectLike = __webpack_require__(5); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** Built-in value references. */ var propertyIsEnumerable = objectProto.propertyIsEnumerable; /** * Checks if `value` is likely an `arguments` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an `arguments` object, * else `false`. * @example * * _.isArguments(function() { return arguments; }()); * // => true * * _.isArguments([1, 2, 3]); * // => false */ var isArguments = baseIsArguments(function () { return arguments; }()) ? baseIsArguments : function (value) { return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); }; module.exports = isArguments; /***/ }, /* 34 */ /***/function (module, exports) { module.exports = function (module) { if (!module.webpackPolyfill) { module.deprecate = function () {}; module.paths = []; // module.parent = undefined by default if (!module.children) module.children = []; Object.defineProperty(module, "loaded", { enumerable: true, get: function get() { return module.l; } }); Object.defineProperty(module, "id", { enumerable: true, get: function get() { return module.i; } }); module.webpackPolyfill = 1; } return module; }; /***/ }, /* 35 */ /***/function (module, exports) { /** * A specialized version of `_.map` for arrays without support for iteratee * shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the new mapped array. */ function arrayMap(array, iteratee) { var index = -1, length = array == null ? 0 : array.length, result = Array(length); while (++index < length) { result[index] = iteratee(array[index], index, array); } return result; } module.exports = arrayMap; /***/ }, /* 36 */ /***/function (module, exports, __webpack_require__) { var ListCache = __webpack_require__(23), stackClear = __webpack_require__(144), stackDelete = __webpack_require__(145), stackGet = __webpack_require__(146), stackHas = __webpack_require__(147), stackSet = __webpack_require__(148); /** * Creates a stack cache object to store key-value pairs. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function Stack(entries) { var data = this.__data__ = new ListCache(entries); this.size = data.size; } // Add methods to `Stack`. Stack.prototype.clear = stackClear; Stack.prototype['delete'] = stackDelete; Stack.prototype.get = stackGet; Stack.prototype.has = stackHas; Stack.prototype.set = stackSet; module.exports = Stack; /***/ }, /* 37 */ /***/function (module, exports, __webpack_require__) { var baseAssignValue = __webpack_require__(38), eq = __webpack_require__(18); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Assigns `value` to `key` of `object` if the existing value is not equivalent * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ function assignValue(object, key, value) { var objValue = object[key]; if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) { baseAssignValue(object, key, value); } } module.exports = assignValue; /***/ }, /* 38 */ /***/function (module, exports, __webpack_require__) { var defineProperty = __webpack_require__(65); /** * The base implementation of `assignValue` and `assignMergeValue` without * value checks. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ function baseAssignValue(object, key, value) { if (key == '__proto__' && defineProperty) { defineProperty(object, key, { 'configurable': true, 'enumerable': true, 'value': value, 'writable': true }); } else { object[key] = value; } } module.exports = baseAssignValue; /***/ }, /* 39 */ /***/function (module, exports, __webpack_require__) { var arrayFilter = __webpack_require__(167), stubArray = __webpack_require__(69); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Built-in value references. */ var propertyIsEnumerable = objectProto.propertyIsEnumerable; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeGetSymbols = Object.getOwnPropertySymbols; /** * Creates an array of the own enumerable symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ var getSymbols = !nativeGetSymbols ? stubArray : function (object) { if (object == null) { return []; } object = Object(object); return arrayFilter(nativeGetSymbols(object), function (symbol) { return propertyIsEnumerable.call(object, symbol); }); }; module.exports = getSymbols; /***/ }, /* 40 */ /***/function (module, exports, __webpack_require__) { var overArg = __webpack_require__(58); /** Built-in value references. */ var getPrototype = overArg(Object.getPrototypeOf, Object); module.exports = getPrototype; /***/ }, /* 41 */ /***/function (module, exports, __webpack_require__) { var Uint8Array = __webpack_require__(74); /** * Creates a clone of `arrayBuffer`. * * @private * @param {ArrayBuffer} arrayBuffer The array buffer to clone. * @returns {ArrayBuffer} Returns the cloned array buffer. */ function cloneArrayBuffer(arrayBuffer) { var result = new arrayBuffer.constructor(arrayBuffer.byteLength); new Uint8Array(result).set(new Uint8Array(arrayBuffer)); return result; } module.exports = cloneArrayBuffer; /***/ }, /* 42 */ /***/function (module, exports) { /** * Converts `map` to its key-value pairs. * * @private * @param {Object} map The map to convert. * @returns {Array} Returns the key-value pairs. */ function mapToArray(map) { var index = -1, result = Array(map.size); map.forEach(function (value, key) { result[++index] = [key, value]; }); return result; } module.exports = mapToArray; /***/ }, /* 43 */ /***/function (module, exports) { /** * Converts `set` to an array of its values. * * @private * @param {Object} set The set to convert. * @returns {Array} Returns the values. */ function setToArray(set) { var index = -1, result = Array(set.size); set.forEach(function (value) { result[++index] = value; }); return result; } module.exports = setToArray; /***/ }, /* 44 */ /***/function (module, exports) { /** * This method returns the first argument it receives. * * @static * @since 0.1.0 * @memberOf _ * @category Util * @param {*} value Any value. * @returns {*} Returns `value`. * @example * * var object = { 'a': 1 }; * * console.log(_.identity(object) === object); * // => true */ function identity(value) { return value; } module.exports = identity; /***/ }, /* 45 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function () { return EPSILON; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "a", function () { return ARRAY_TYPE; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () { return RANDOM; }); /* unused harmony export setMatrixArrayType */ /* unused harmony export toRadian */ /* unused harmony export equals */ /* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** * Common utilities * @module glMatrix */ // Configuration Constants var EPSILON = 0.000001; var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array; var RANDOM = Math.random; /** * Sets the type of array used when creating new vectors and matrices * * @param {Type} type Array type, such as Float32Array or Array */ function setMatrixArrayType(type) { ARRAY_TYPE = type; } var degree = Math.PI / 180; /** * Convert Degree To Radian * * @param {Number} a Angle in Degrees */ function toRadian(a) { return a * degree; } /** * Tests whether or not the arguments have approximately the same value, within an absolute * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less * than or equal to 1.0, and a relative tolerance is used for larger values) * * @param {Number} a The first number to test. * @param {Number} b The second number to test. * @returns {Boolean} True if the numbers are approximately equal, false otherwise. */ function equals(a, b) { return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b)); } /***/ }, /* 46 */ /***/function (module, exports, __webpack_require__) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; var Util = __webpack_require__(31); var SPACES = '\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029'; var PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig'); var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig'); // Parses given path string into an array of arrays of path segments var parsePathString = function parsePathString(pathString) { if (!pathString) { return null; } if ((typeof pathString === 'undefined' ? 'undefined' : _typeof(pathString)) === _typeof([])) { return pathString; } var paramCounts = { a: 7, c: 6, o: 2, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, u: 3, z: 0 }; var data = []; String(pathString).replace(PATH_COMMAND, function (a, b, c) { var params = []; var name = b.toLowerCase(); c.replace(PATH_VALUES, function (a, b) { b && params.push(+b); }); if (name === 'm' && params.length > 2) { data.push([b].concat(params.splice(0, 2))); name = 'l'; b = b === 'm' ? 'l' : 'L'; } if (name === 'o' && params.length === 1) { data.push([b, params[0]]); } if (name === 'r') { data.push([b].concat(params)); } else { while (params.length >= paramCounts[name]) { data.push([b].concat(params.splice(0, paramCounts[name]))); if (!paramCounts[name]) { break; } } } }); return data; }; // http://schepers.cc/getting-to-the-point var catmullRom2bezier = function catmullRom2bezier(crp, z) { var d = []; for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) { var p = [{ x: +crp[i - 2], y: +crp[i - 1] }, { x: +crp[i], y: +crp[i + 1] }, { x: +crp[i + 2], y: +crp[i + 3] }, { x: +crp[i + 4], y: +crp[i + 5] }]; if (z) { if (!i) { p[0] = { x: +crp[iLen - 2], y: +crp[iLen - 1] }; } else if (iLen - 4 === i) { p[3] = { x: +crp[0], y: +crp[1] }; } else if (iLen - 2 === i) { p[2] = { x: +crp[0], y: +crp[1] }; p[3] = { x: +crp[2], y: +crp[3] }; } } else { if (iLen - 4 === i) { p[3] = p[2]; } else if (!i) { p[0] = { x: +crp[i], y: +crp[i + 1] }; } } d.push(['C', (-p[0].x + 6 * p[1].x + p[2].x) / 6, (-p[0].y + 6 * p[1].y + p[2].y) / 6, (p[1].x + 6 * p[2].x - p[3].x) / 6, (p[1].y + 6 * p[2].y - p[3].y) / 6, p[2].x, p[2].y]); } return d; }; var ellipsePath = function ellipsePath(x, y, rx, ry, a) { var res = []; if (a === null && ry === null) { ry = rx; } x = +x; y = +y; rx = +rx; ry = +ry; if (a !== null) { var rad = Math.PI / 180; var x1 = x + rx * Math.cos(-ry * rad); var x2 = x + rx * Math.cos(-a * rad); var y1 = y + rx * Math.sin(-ry * rad); var y2 = y + rx * Math.sin(-a * rad); res = [['M', x1, y1], ['A', rx, rx, 0, +(a - ry > 180), 0, x2, y2]]; } else { res = [['M', x, y], ['m', 0, -ry], ['a', rx, ry, 0, 1, 1, 0, 2 * ry], ['a', rx, ry, 0, 1, 1, 0, -2 * ry], ['z']]; } return res; }; var pathToAbsolute = function pathToAbsolute(pathArray) { pathArray = parsePathString(pathArray); if (!pathArray || !pathArray.length) { return [['M', 0, 0]]; } var res = []; var x = 0; var y = 0; var mx = 0; var my = 0; var start = 0; var pa0 = void 0; var dots = void 0; if (pathArray[0][0] === 'M') { x = +pathArray[0][1]; y = +pathArray[0][2]; mx = x; my = y; start++; res[0] = ['M', x, y]; } var crz = pathArray.length === 3 && pathArray[0][0] === 'M' && pathArray[1][0].toUpperCase() === 'R' && pathArray[2][0].toUpperCase() === 'Z'; for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) { res.push(r = []); pa = pathArray[i]; pa0 = pa[0]; if (pa0 !== pa0.toUpperCase()) { r[0] = pa0.toUpperCase(); switch (r[0]) { case 'A': r[1] = pa[1]; r[2] = pa[2]; r[3] = pa[3]; r[4] = pa[4]; r[5] = pa[5]; r[6] = +pa[6] + x; r[7] = +pa[7] + y; break; case 'V': r[1] = +pa[1] + y; break; case 'H': r[1] = +pa[1] + x; break; case 'R': dots = [x, y].concat(pa.slice(1)); for (var j = 2, jj = dots.length; j < jj; j++) { dots[j] = +dots[j] + x; dots[++j] = +dots[j] + y; } res.pop(); res = res.concat(catmullRom2bezier(dots, crz)); break; case 'O': res.pop(); dots = ellipsePath(x, y, pa[1], pa[2]); dots.push(dots[0]); res = res.concat(dots); break; case 'U': res.pop(); res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3])); r = ['U'].concat(res[res.length - 1].slice(-2)); break; case 'M': mx = +pa[1] + x; my = +pa[2] + y; break; // for lint default: for (var _j = 1, _jj = pa.length; _j < _jj; _j++) { r[_j] = +pa[_j] + (_j % 2 ? x : y); } } } else if (pa0 === 'R') { dots = [x, y].concat(pa.slice(1)); res.pop(); res = res.concat(catmullRom2bezier(dots, crz)); r = ['R'].concat(pa.slice(-2)); } else if (pa0 === 'O') { res.pop(); dots = ellipsePath(x, y, pa[1], pa[2]); dots.push(dots[0]); res = res.concat(dots); } else if (pa0 === 'U') { res.pop(); res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3])); r = ['U'].concat(res[res.length - 1].slice(-2)); } else { for (var k = 0, kk = pa.length; k < kk; k++) { r[k] = pa[k]; } } pa0 = pa0.toUpperCase(); if (pa0 !== 'O') { switch (r[0]) { case 'Z': x = +mx; y = +my; break; case 'H': x = r[1]; break; case 'V': y = r[1]; break; case 'M': mx = r[r.length - 2]; my = r[r.length - 1]; break; // for lint default: x = r[r.length - 2]; y = r[r.length - 1]; } } } return res; }; var l2c = function l2c(x1, y1, x2, y2) { return [x1, y1, x2, y2, x2, y2]; }; var q2c = function q2c(x1, y1, ax, ay, x2, y2) { var _13 = 1 / 3; var _23 = 2 / 3; return [_13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2]; }; var a2c = function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) { // for more information of where this math came from visit: // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes if (rx === ry) { rx += 1; } var _120 = Math.PI * 120 / 180; var rad = Math.PI / 180 * (+angle || 0); var res = []; var xy = void 0; var f1 = void 0; var f2 = void 0; var cx = void 0; var cy = void 0; var rotate = function rotate(x, y, rad) { var X = x * Math.cos(rad) - y * Math.sin(rad); var Y = x * Math.sin(rad) + y * Math.cos(rad); return { x: X, y: Y }; }; if (!recursive) { xy = rotate(x1, y1, -rad); x1 = xy.x; y1 = xy.y; xy = rotate(x2, y2, -rad); x2 = xy.x; y2 = xy.y; if (x1 === x2 && y1 === y2) { // 若弧的起始点和终点重叠则错开一点 x2 += 1; y2 += 1; } // const cos = Math.cos(Math.PI / 180 * angle); // const sin = Math.sin(Math.PI / 180 * angle); var x = (x1 - x2) / 2; var y = (y1 - y2) / 2; var h = x * x / (rx * rx) + y * y / (ry * ry); if (h > 1) { h = Math.sqrt(h); rx = h * rx; ry = h * ry; } var rx2 = rx * rx; var ry2 = ry * ry; var k = (large_arc_flag === sweep_flag ? -1 : 1) * Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))); cx = k * rx * y / ry + (x1 + x2) / 2; cy = k * -ry * x / rx + (y1 + y2) / 2; f1 = Math.asin(((y1 - cy) / ry).toFixed(9)); f2 = Math.asin(((y2 - cy) / ry).toFixed(9)); f1 = x1 < cx ? Math.PI - f1 : f1; f2 = x2 < cx ? Math.PI - f2 : f2; f1 < 0 && (f1 = Math.PI * 2 + f1); f2 < 0 && (f2 = Math.PI * 2 + f2); if (sweep_flag && f1 > f2) { f1 = f1 - Math.PI * 2; } if (!sweep_flag && f2 > f1) { f2 = f2 - Math.PI * 2; } } else { f1 = recursive[0]; f2 = recursive[1]; cx = recursive[2]; cy = recursive[3]; } var df = f2 - f1; if (Math.abs(df) > _120) { var f2old = f2; var x2old = x2; var y2old = y2; f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1); x2 = cx + rx * Math.cos(f2); y2 = cy + ry * Math.sin(f2); res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]); } df = f2 - f1; var c1 = Math.cos(f1); var s1 = Math.sin(f1); var c2 = Math.cos(f2); var s2 = Math.sin(f2); var t = Math.tan(df / 4); var hx = 4 / 3 * rx * t; var hy = 4 / 3 * ry * t; var m1 = [x1, y1]; var m2 = [x1 + hx * s1, y1 - hy * c1]; var m3 = [x2 + hx * s2, y2 - hy * c2]; var m4 = [x2, y2]; m2[0] = 2 * m1[0] - m2[0]; m2[1] = 2 * m1[1] - m2[1]; if (recursive) { return [m2, m3, m4].concat(res); } res = [m2, m3, m4].concat(res).join().split(','); var newres = []; for (var i = 0, ii = res.length; i < ii; i++) { newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x; } return newres; }; var pathTocurve = function pathTocurve(path, path2) { var pcoms1 = []; // path commands of original path p var pcoms2 = []; // path commands of original path p2 var p = pathToAbsolute(path); var p2 = path2 && pathToAbsolute(path2); var attrs = { x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null }; var attrs2 = { x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null }; var processPath = function processPath(path, d, pcom) { var nx = void 0; var ny = void 0; if (!path) { return ['C', d.x, d.y, d.x, d.y, d.x, d.y]; }!(path[0] in { T: 1, Q: 1 }) && (d.qx = d.qy = null); switch (path[0]) { case 'M': d.X = path[1]; d.Y = path[2]; break; case 'A': path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1)))); break; case 'S': if (pcom === 'C' || pcom === 'S') { // In "S" case we have to take into account, if the previous command is C/S. nx = d.x * 2 - d.bx; // And reflect the previous ny = d.y * 2 - d.by; // command's control point relative to the current point. } else { // or some else or nothing nx = d.x; ny = d.y; } path = ['C', nx, ny].concat(path.slice(1)); break; case 'T': if (pcom === 'Q' || pcom === 'T') { // In "T" case we have to take into account, if the previous command is Q/T. d.qx = d.x * 2 - d.qx; // And make a reflection similar d.qy = d.y * 2 - d.qy; // to case "S". } else { // or something else or nothing d.qx = d.x; d.qy = d.y; } path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2])); break; case 'Q': d.qx = path[1]; d.qy = path[2]; path = ['C'].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4])); break; case 'L': path = ['C'].concat(l2c(d.x, d.y, path[1], path[2])); break; case 'H': path = ['C'].concat(l2c(d.x, d.y, path[1], d.y)); break; case 'V': path = ['C'].concat(l2c(d.x, d.y, d.x, path[1])); break; case 'Z': path = ['C'].concat(l2c(d.x, d.y, d.X, d.Y)); break; default: path = []; // for lint } return path; }; var fixArc = function fixArc(pp, i) { if (pp[i].length > 7) { pp[i].shift(); var pi = pp[i]; while (pi.length) { pcoms1[i] = 'A'; // if created multiple C:s, their original seg is saved p2 && (pcoms2[i] = 'A'); // the same as above pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6))); } pp.splice(i, 1); // ii = Math.max(p.length, p2 && p2.length || 0); } }; var fixM = function fixM(path1, path2, a1, a2, i) { if (path1 && path2 && path1[i][0] === 'M' && path2[i][0] !== 'M') { path2.splice(i, 0, ['M', a2.x, a2.y]); a1.bx = 0; a1.by = 0; a1.x = path1[i][1]; a1.y = path1[i][2]; // ii = Math.max(p.length, p2 && p2.length || 0); } }; var pfirst = ''; // temporary holder for original path command var pcom = ''; // holder for previous path command of original path for (var i = 0, ii = Math.max(p.length, p2 && p2.length || 0); i < ii; i++) { p[i] && (pfirst = p[i][0]); // save current path command if (pfirst !== 'C') { // C is not saved yet, because it may be result of conversion pcoms1[i] = pfirst; // Save current path command i && (pcom = pcoms1[i - 1]); // Get previous path command pcom } p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath if (pcoms1[i] !== 'A' && pfirst === 'C') pcoms1[i] = 'C'; // A is the only command // which may produce multiple C:s // so we have to make sure that C is also C in original path fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1 if (p2) { // the same procedures is done to p2 p2[i] && (pfirst = p2[i][0]); if (pfirst !== 'C') { pcoms2[i] = pfirst; i && (pcom = pcoms2[i - 1]); } p2[i] = processPath(p2[i], attrs2, pcom); if (pcoms2[i] !== 'A' && pfirst === 'C') { pcoms2[i] = 'C'; } fixArc(p2, i); } fixM(p, p2, attrs, attrs2, i); fixM(p2, p, attrs2, attrs, i); var seg = p[i]; var seg2 = p2 && p2[i]; var seglen = seg.length; var seg2len = p2 && seg2.length; attrs.x = seg[seglen - 2]; attrs.y = seg[seglen - 1]; attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x; attrs.by = parseFloat(seg[seglen - 3]) || attrs.y; attrs2.bx = p2 && (parseFloat(seg2[seg2len - 4]) || attrs2.x); attrs2.by = p2 && (parseFloat(seg2[seg2len - 3]) || attrs2.y); attrs2.x = p2 && seg2[seg2len - 2]; attrs2.y = p2 && seg2[seg2len - 1]; } return p2 ? [p, p2] : p; }; var p2s = /,?([a-z]),?/gi; var parsePathArray = function parsePathArray(path) { return path.join(',').replace(p2s, '$1'); }; var base3 = function base3(t, p1, p2, p3, p4) { var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4; var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3; return t * t2 - 3 * p1 + 3 * p2; }; var bezlen = function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) { if (z === null) { z = 1; } z = z > 1 ? 1 : z < 0 ? 0 : z; var z2 = z / 2; var n = 12; var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816]; var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472]; var sum = 0; for (var i = 0; i < n; i++) { var ct = z2 * Tvalues[i] + z2; var xbase = base3(ct, x1, x2, x3, x4); var ybase = base3(ct, y1, y2, y3, y4); var comb = xbase * xbase + ybase * ybase; sum += Cvalues[i] * Math.sqrt(comb); } return z2 * sum; }; var curveDim = function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) { var tvalues = []; var bounds = [[], []]; var a = void 0; var b = void 0; var c = void 0; var t = void 0; for (var i = 0; i < 2; ++i) { if (i === 0) { b = 6 * x0 - 12 * x1 + 6 * x2; a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3; c = 3 * x1 - 3 * x0; } else { b = 6 * y0 - 12 * y1 + 6 * y2; a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3; c = 3 * y1 - 3 * y0; } if (Math.abs(a) < 1e-12) { if (Math.abs(b) < 1e-12) { continue; } t = -c / b; if (t > 0 && t < 1) { tvalues.push(t); } continue; } var b2ac = b * b - 4 * c * a; var sqrtb2ac = Math.sqrt(b2ac); if (b2ac < 0) { continue; } var t1 = (-b + sqrtb2ac) / (2 * a); if (t1 > 0 && t1 < 1) { tvalues.push(t1); } var t2 = (-b - sqrtb2ac) / (2 * a); if (t2 > 0 && t2 < 1) { tvalues.push(t2); } } var j = tvalues.length; var jlen = j; var mt = void 0; while (j--) { t = tvalues[j]; mt = 1 - t; bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3; bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3; } bounds[0][jlen] = x0; bounds[1][jlen] = y0; bounds[0][jlen + 1] = x3; bounds[1][jlen + 1] = y3; bounds[0].length = bounds[1].length = jlen + 2; return { min: { x: Math.min.apply(0, bounds[0]), y: Math.min.apply(0, bounds[1]) }, max: { x: Math.max.apply(0, bounds[0]), y: Math.max.apply(0, bounds[1]) } }; }; var intersect = function intersect(x1, y1, x2, y2, x3, y3, x4, y4) { if (Math.max(x1, x2) < Math.min(x3, x4) || Math.min(x1, x2) > Math.max(x3, x4) || Math.max(y1, y2) < Math.min(y3, y4) || Math.min(y1, y2) > Math.max(y3, y4)) { return; } var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4); var ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4); var denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); if (!denominator) { return; } var px = nx / denominator; var py = ny / denominator; var px2 = +px.toFixed(2); var py2 = +py.toFixed(2); if (px2 < +Math.min(x1, x2).toFixed(2) || px2 > +Math.max(x1, x2).toFixed(2) || px2 < +Math.min(x3, x4).toFixed(2) || px2 > +Math.max(x3, x4).toFixed(2) || py2 < +Math.min(y1, y2).toFixed(2) || py2 > +Math.max(y1, y2).toFixed(2) || py2 < +Math.min(y3, y4).toFixed(2) || py2 > +Math.max(y3, y4).toFixed(2)) { return; } return { x: px, y: py }; }; var isPointInsideBBox = function isPointInsideBBox(bbox, x, y) { return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height; }; var rectPath = function rectPath(x, y, w, h, r) { if (r) { return [['M', +x + +r, y], ['l', w - r * 2, 0], ['a', r, r, 0, 0, 1, r, r], ['l', 0, h - r * 2], ['a', r, r, 0, 0, 1, -r, r], ['l', r * 2 - w, 0], ['a', r, r, 0, 0, 1, -r, -r], ['l', 0, r * 2 - h], ['a', r, r, 0, 0, 1, r, -r], ['z']]; } var res = [['M', x, y], ['l', w, 0], ['l', 0, h], ['l', -w, 0], ['z']]; res.parsePathArray = parsePathArray; return res; }; var box = function box(x, y, width, height) { if (x === null) { x = y = width = height = 0; } if (y === null) { y = x.y; width = x.width; height = x.height; x = x.x; } return { x: x, y: y, width: width, w: width, height: height, h: height, x2: x + width, y2: y + height, cx: x + width / 2, cy: y + height / 2, r1: Math.min(width, height) / 2, r2: Math.max(width, height) / 2, r0: Math.sqrt(width * width + height * height) / 2, path: rectPath(x, y, width, height), vb: [x, y, width, height].join(' ') }; }; var isBBoxIntersect = function isBBoxIntersect(bbox1, bbox2) { bbox1 = box(bbox1); bbox2 = box(bbox2); return isPointInsideBBox(bbox2, bbox1.x, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x, bbox1.y2) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y2) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y2) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y2) || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x) && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y); }; var bezierBBox = function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { if (!Util.isArray(p1x)) { p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y]; } var bbox = curveDim.apply(null, p1x); return box(bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y); }; var findDotsAtSegment = function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { var t1 = 1 - t; var t13 = Math.pow(t1, 3); var t12 = Math.pow(t1, 2); var t2 = t * t; var t3 = t2 * t; var x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x; var y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y; var mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x); var my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y); var nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x); var ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y); var ax = t1 * p1x + t * c1x; var ay = t1 * p1y + t * c1y; var cx = t1 * c2x + t * p2x; var cy = t1 * c2y + t * p2y; var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI; // (mx > nx || my < ny) && (alpha += 180); return { x: x, y: y, m: { x: mx, y: my }, n: { x: nx, y: ny }, start: { x: ax, y: ay }, end: { x: cx, y: cy }, alpha: alpha }; }; var interHelper = function interHelper(bez1, bez2, justCount) { var bbox1 = bezierBBox(bez1); var bbox2 = bezierBBox(bez2); if (!isBBoxIntersect(bbox1, bbox2)) { return justCount ? 0 : []; } var l1 = bezlen.apply(0, bez1); var l2 = bezlen.apply(0, bez2); var n1 = ~~(l1 / 8); var n2 = ~~(l2 / 8); var dots1 = []; var dots2 = []; var xy = {}; var res = justCount ? 0 : []; for (var i = 0; i < n1 + 1; i++) { var d = findDotsAtSegment.apply(0, bez1.concat(i / n1)); dots1.push({ x: d.x, y: d.y, t: i / n1 }); } for (var _i = 0; _i < n2 + 1; _i++) { var _d = findDotsAtSegment.apply(0, bez2.concat(_i / n2)); dots2.push({ x: _d.x, y: _d.y, t: _i / n2 }); } for (var _i2 = 0; _i2 < n1; _i2++) { for (var j = 0; j < n2; j++) { var di = dots1[_i2]; var di1 = dots1[_i2 + 1]; var dj = dots2[j]; var dj1 = dots2[j + 1]; var ci = Math.abs(di1.x - di.x) < 0.001 ? 'y' : 'x'; var cj = Math.abs(dj1.x - dj.x) < 0.001 ? 'y' : 'x'; var is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y); if (is) { if (xy[is.x.toFixed(4)] === is.y.toFixed(4)) { continue; } xy[is.x.toFixed(4)] = is.y.toFixed(4); var t1 = di.t + Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t); var t2 = dj.t + Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t); if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) { if (justCount) { res++; } else { res.push({ x: is.x, y: is.y, t1: t1, t2: t2 }); } } } } } return res; }; var interPathHelper = function interPathHelper(path1, path2, justCount) { path1 = pathTocurve(path1); path2 = pathTocurve(path2); var x1 = void 0; var y1 = void 0; var x2 = void 0; var y2 = void 0; var x1m = void 0; var y1m = void 0; var x2m = void 0; var y2m = void 0; var bez1 = void 0; var bez2 = void 0; var res = justCount ? 0 : []; for (var i = 0, ii = path1.length; i < ii; i++) { var pi = path1[i]; if (pi[0] === 'M') { x1 = x1m = pi[1]; y1 = y1m = pi[2]; } else { if (pi[0] === 'C') { bez1 = [x1, y1].concat(pi.slice(1)); x1 = bez1[6]; y1 = bez1[7]; } else { bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m]; x1 = x1m; y1 = y1m; } for (var j = 0, jj = path2.length; j < jj; j++) { var pj = path2[j]; if (pj[0] === 'M') { x2 = x2m = pj[1]; y2 = y2m = pj[2]; } else { if (pj[0] === 'C') { bez2 = [x2, y2].concat(pj.slice(1)); x2 = bez2[6]; y2 = bez2[7]; } else { bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m]; x2 = x2m; y2 = y2m; } var intr = interHelper(bez1, bez2, justCount); if (justCount) { res += intr; } else { for (var k = 0, kk = intr.length; k < kk; k++) { intr[k].segment1 = i; intr[k].segment2 = j; intr[k].bez1 = bez1; intr[k].bez2 = bez2; } res = res.concat(intr); } } } } } return res; }; var pathIntersection = function pathIntersection(path1, path2) { return interPathHelper(path1, path2); }; module.exports = { parsePathString: parsePathString, parsePathArray: parsePathArray, pathTocurve: pathTocurve, pathToAbsolute: pathToAbsolute, catmullRomToBezier: catmullRom2bezier, rectPath: rectPath, intersection: pathIntersection }; /***/ }, /* 47 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["b"] = now; /* harmony export (immutable) */__webpack_exports__["a"] = Timer; /* harmony export (immutable) */__webpack_exports__["c"] = timer; /* harmony export (immutable) */__webpack_exports__["d"] = timerFlush; var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; var frame = 0, // is an animation frame pending? timeout = 0, // is a timeout pending? interval = 0, // are any timers active? pokeDelay = 1000, // how frequently we check for clock skew taskHead, taskTail, clockLast = 0, clockNow = 0, clockSkew = 0, clock = (typeof performance === "undefined" ? "undefined" : _typeof(performance)) === "object" && performance.now ? performance : Date, setFrame = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function (f) { setTimeout(f, 17); }; function now() { return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew); } function clearNow() { clockNow = 0; } function Timer() { this._call = this._time = this._next = null; } Timer.prototype = timer.prototype = { constructor: Timer, restart: function restart(callback, delay, time) { if (typeof callback !== "function") throw new TypeError("callback is not a function"); time = (time == null ? now() : +time) + (delay == null ? 0 : +delay); if (!this._next && taskTail !== this) { if (taskTail) taskTail._next = this;else taskHead = this; taskTail = this; } this._call = callback; this._time = time; sleep(); }, stop: function stop() { if (this._call) { this._call = null; this._time = Infinity; sleep(); } } }; function timer(callback, delay, time) { var t = new Timer(); t.restart(callback, delay, time); return t; } function timerFlush() { now(); // Get the current time, if not already set. ++frame; // Pretend we’ve set an alarm, if we haven’t already. var t = taskHead, e; while (t) { if ((e = clockNow - t._time) >= 0) t._call.call(null, e); t = t._next; } --frame; } function wake() { clockNow = (clockLast = clock.now()) + clockSkew; frame = timeout = 0; try { timerFlush(); } finally { frame = 0; nap(); clockNow = 0; } } function poke() { var now = clock.now(), delay = now - clockLast; if (delay > pokeDelay) clockSkew -= delay, clockLast = now; } function nap() { var t0, t1 = taskHead, t2, time = Infinity; while (t1) { if (t1._call) { if (time > t1._time) time = t1._time; t0 = t1, t1 = t1._next; } else { t2 = t1._next, t1._next = null; t1 = t0 ? t0._next = t2 : taskHead = t2; } } taskTail = t0; sleep(time); } function sleep(time) { if (frame) return; // Soonest alarm already set, or will be. if (timeout) timeout = clearTimeout(timeout); var delay = time - clockNow; // Strictly less than if we recomputed clockNow. if (delay > 24) { if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew); if (interval) interval = clearInterval(interval); } else { if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay); frame = 1, setFrame(wake); } } /***/ }, /* 48 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(14); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__rgb__ = __webpack_require__(90); /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__array__ = __webpack_require__(93); /* harmony import */var __WEBPACK_IMPORTED_MODULE_3__date__ = __webpack_require__(94); /* harmony import */var __WEBPACK_IMPORTED_MODULE_4__number__ = __webpack_require__(29); /* harmony import */var __WEBPACK_IMPORTED_MODULE_5__object__ = __webpack_require__(95); /* harmony import */var __WEBPACK_IMPORTED_MODULE_6__string__ = __webpack_require__(96); /* harmony import */var __WEBPACK_IMPORTED_MODULE_7__constant__ = __webpack_require__(92); var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; /* harmony default export */__webpack_exports__["a"] = function (a, b) { var t = typeof b === "undefined" ? "undefined" : _typeof(b), c; return b == null || t === "boolean" ? Object(__WEBPACK_IMPORTED_MODULE_7__constant__["a" /* default */])(b) : (t === "number" ? __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */] : t === "string" ? (c = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* color */])(b)) ? (b = c, __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */]) : __WEBPACK_IMPORTED_MODULE_6__string__["a" /* default */] : b instanceof __WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* color */] ? __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */] : b instanceof Date ? __WEBPACK_IMPORTED_MODULE_3__date__["a" /* default */] : Array.isArray(b) ? __WEBPACK_IMPORTED_MODULE_2__array__["a" /* default */] : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? __WEBPACK_IMPORTED_MODULE_5__object__["a" /* default */] : __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */])(a, b); }; /***/ }, /* 49 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = Color; /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "d", function () { return _darker; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () { return _brighter; }); /* harmony export (immutable) */__webpack_exports__["e"] = color; /* harmony export (immutable) */__webpack_exports__["h"] = rgbConvert; /* harmony export (immutable) */__webpack_exports__["g"] = rgb; /* harmony export (immutable) */__webpack_exports__["b"] = Rgb; /* unused harmony export hslConvert */ /* harmony export (immutable) */__webpack_exports__["f"] = hsl; /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(50); function Color() {} var _darker = 0.7; var _brighter = 1 / _darker; var reI = "\\s*([+-]?\\d+)\\s*", reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*", reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*", reHex3 = /^#([0-9a-f]{3})$/, reHex6 = /^#([0-9a-f]{6})$/, reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"), reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"), reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"), reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"), reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"), reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$"); var named = { aliceblue: 0xf0f8ff, antiquewhite: 0xfaebd7, aqua: 0x00ffff, aquamarine: 0x7fffd4, azure: 0xf0ffff, beige: 0xf5f5dc, bisque: 0xffe4c4, black: 0x000000, blanchedalmond: 0xffebcd, blue: 0x0000ff, blueviolet: 0x8a2be2, brown: 0xa52a2a, burlywood: 0xdeb887, cadetblue: 0x5f9ea0, chartreuse: 0x7fff00, chocolate: 0xd2691e, coral: 0xff7f50, cornflowerblue: 0x6495ed, cornsilk: 0xfff8dc, crimson: 0xdc143c, cyan: 0x00ffff, darkblue: 0x00008b, darkcyan: 0x008b8b, darkgoldenrod: 0xb8860b, darkgray: 0xa9a9a9, darkgreen: 0x006400, darkgrey: 0xa9a9a9, darkkhaki: 0xbdb76b, darkmagenta: 0x8b008b, darkolivegreen: 0x556b2f, darkorange: 0xff8c00, darkorchid: 0x9932cc, darkred: 0x8b0000, darksalmon: 0xe9967a, darkseagreen: 0x8fbc8f, darkslateblue: 0x483d8b, darkslategray: 0x2f4f4f, darkslategrey: 0x2f4f4f, darkturquoise: 0x00ced1, darkviolet: 0x9400d3, deeppink: 0xff1493, deepskyblue: 0x00bfff, dimgray: 0x696969, dimgrey: 0x696969, dodgerblue: 0x1e90ff, firebrick: 0xb22222, floralwhite: 0xfffaf0, forestgreen: 0x228b22, fuchsia: 0xff00ff, gainsboro: 0xdcdcdc, ghostwhite: 0xf8f8ff, gold: 0xffd700, goldenrod: 0xdaa520, gray: 0x808080, green: 0x008000, greenyellow: 0xadff2f, grey: 0x808080, honeydew: 0xf0fff0, hotpink: 0xff69b4, indianred: 0xcd5c5c, indigo: 0x4b0082, ivory: 0xfffff0, khaki: 0xf0e68c, lavender: 0xe6e6fa, lavenderblush: 0xfff0f5, lawngreen: 0x7cfc00, lemonchiffon: 0xfffacd, lightblue: 0xadd8e6, lightcoral: 0xf08080, lightcyan: 0xe0ffff, lightgoldenrodyellow: 0xfafad2, lightgray: 0xd3d3d3, lightgreen: 0x90ee90, lightgrey: 0xd3d3d3, lightpink: 0xffb6c1, lightsalmon: 0xffa07a, lightseagreen: 0x20b2aa, lightskyblue: 0x87cefa, lightslategray: 0x778899, lightslategrey: 0x778899, lightsteelblue: 0xb0c4de, lightyellow: 0xffffe0, lime: 0x00ff00, limegreen: 0x32cd32, linen: 0xfaf0e6, magenta: 0xff00ff, maroon: 0x800000, mediumaquamarine: 0x66cdaa, mediumblue: 0x0000cd, mediumorchid: 0xba55d3, mediumpurple: 0x9370db, mediumseagreen: 0x3cb371, mediumslateblue: 0x7b68ee, mediumspringgreen: 0x00fa9a, mediumturquoise: 0x48d1cc, mediumvioletred: 0xc71585, midnightblue: 0x191970, mintcream: 0xf5fffa, mistyrose: 0xffe4e1, moccasin: 0xffe4b5, navajowhite: 0xffdead, navy: 0x000080, oldlace: 0xfdf5e6, olive: 0x808000, olivedrab: 0x6b8e23, orange: 0xffa500, orangered: 0xff4500, orchid: 0xda70d6, palegoldenrod: 0xeee8aa, palegreen: 0x98fb98, paleturquoise: 0xafeeee, palevioletred: 0xdb7093, papayawhip: 0xffefd5, peachpuff: 0xffdab9, peru: 0xcd853f, pink: 0xffc0cb, plum: 0xdda0dd, powderblue: 0xb0e0e6, purple: 0x800080, rebeccapurple: 0x663399, red: 0xff0000, rosybrown: 0xbc8f8f, royalblue: 0x4169e1, saddlebrown: 0x8b4513, salmon: 0xfa8072, sandybrown: 0xf4a460, seagreen: 0x2e8b57, seashell: 0xfff5ee, sienna: 0xa0522d, silver: 0xc0c0c0, skyblue: 0x87ceeb, slateblue: 0x6a5acd, slategray: 0x708090, slategrey: 0x708090, snow: 0xfffafa, springgreen: 0x00ff7f, steelblue: 0x4682b4, tan: 0xd2b48c, teal: 0x008080, thistle: 0xd8bfd8, tomato: 0xff6347, turquoise: 0x40e0d0, violet: 0xee82ee, wheat: 0xf5deb3, white: 0xffffff, whitesmoke: 0xf5f5f5, yellow: 0xffff00, yellowgreen: 0x9acd32 }; Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Color, color, { displayable: function displayable() { return this.rgb().displayable(); }, toString: function toString() { return this.rgb() + ""; } }); function color(format) { var m; format = (format + "").trim().toLowerCase(); return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), new Rgb(m >> 8 & 0xf | m >> 4 & 0x0f0, m >> 4 & 0xf | m & 0xf0, (m & 0xf) << 4 | m & 0xf, 1) // #f00 ) : (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000 : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0) : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%) : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1) : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1) : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%) : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1) : named.hasOwnProperty(format) ? rgbn(named[format]) : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null; } function rgbn(n) { return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1); } function rgba(r, g, b, a) { if (a <= 0) r = g = b = NaN; return new Rgb(r, g, b, a); } function rgbConvert(o) { if (!(o instanceof Color)) o = color(o); if (!o) return new Rgb(); o = o.rgb(); return new Rgb(o.r, o.g, o.b, o.opacity); } function rgb(r, g, b, opacity) { return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity); } function Rgb(r, g, b, opacity) { this.r = +r; this.g = +g; this.b = +b; this.opacity = +opacity; } Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Rgb, rgb, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, { brighter: function brighter(k) { k = k == null ? _brighter : Math.pow(_brighter, k); return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); }, darker: function darker(k) { k = k == null ? _darker : Math.pow(_darker, k); return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity); }, rgb: function rgb() { return this; }, displayable: function displayable() { return 0 <= this.r && this.r <= 255 && 0 <= this.g && this.g <= 255 && 0 <= this.b && this.b <= 255 && 0 <= this.opacity && this.opacity <= 1; }, toString: function toString() { var a = this.opacity;a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a)); return (a === 1 ? "rgb(" : "rgba(") + Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.b) || 0)) + (a === 1 ? ")" : ", " + a + ")"); } })); function hsla(h, s, l, a) { if (a <= 0) h = s = l = NaN;else if (l <= 0 || l >= 1) h = s = NaN;else if (s <= 0) h = NaN; return new Hsl(h, s, l, a); } function hslConvert(o) { if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); if (!(o instanceof Color)) o = color(o); if (!o) return new Hsl(); if (o instanceof Hsl) return o; o = o.rgb(); var r = o.r / 255, g = o.g / 255, b = o.b / 255, min = Math.min(r, g, b), max = Math.max(r, g, b), h = NaN, s = max - min, l = (max + min) / 2; if (s) { if (r === max) h = (g - b) / s + (g < b) * 6;else if (g === max) h = (b - r) / s + 2;else h = (r - g) / s + 4; s /= l < 0.5 ? max + min : 2 - max - min; h *= 60; } else { s = l > 0 && l < 1 ? 0 : h; } return new Hsl(h, s, l, o.opacity); } function hsl(h, s, l, opacity) { return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); } function Hsl(h, s, l, opacity) { this.h = +h; this.s = +s; this.l = +l; this.opacity = +opacity; } Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hsl, hsl, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, { brighter: function brighter(k) { k = k == null ? _brighter : Math.pow(_brighter, k); return new Hsl(this.h, this.s, this.l * k, this.opacity); }, darker: function darker(k) { k = k == null ? _darker : Math.pow(_darker, k); return new Hsl(this.h, this.s, this.l * k, this.opacity); }, rgb: function rgb() { var h = this.h % 360 + (this.h < 0) * 360, s = isNaN(h) || isNaN(this.s) ? 0 : this.s, l = this.l, m2 = l + (l < 0.5 ? l : 1 - l) * s, m1 = 2 * l - m2; return new Rgb(hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), hsl2rgb(h, m1, m2), hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), this.opacity); }, displayable: function displayable() { return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1; } })); /* From FvD 13.37, CSS Color Module Level 3 */ function hsl2rgb(h, m1, m2) { return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255; } /***/ }, /* 50 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["b"] = extend; /* harmony default export */__webpack_exports__["a"] = function (constructor, factory, prototype) { constructor.prototype = factory.prototype = prototype; prototype.constructor = constructor; }; function extend(parent, definition) { var prototype = Object.create(parent.prototype); for (var key in definition) { prototype[key] = definition[key]; }return prototype; } /***/ }, /* 51 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = basis; function basis(t1, v0, v1, v2, v3) { var t2 = t1 * t1, t3 = t2 * t1; return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6; } /* harmony default export */__webpack_exports__["b"] = function (values) { var n = values.length - 1; return function (t) { var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n), v1 = values[i], v2 = values[i + 1], v0 = i > 0 ? values[i - 1] : 2 * v1 - v2, v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1; return basis((t - i / n) * n, v0, v1, v2, v3); }; }; /***/ }, /* 52 */ /***/function (module, exports, __webpack_require__) { var vec2 = __webpack_require__(3).vec2; module.exports = { at: function at(p1, p2, t) { return (p2 - p1) * t + p1; }, pointDistance: function pointDistance(x1, y1, x2, y2, x, y) { var d = [x2 - x1, y2 - y1]; if (vec2.exactEquals(d, [0, 0])) { return NaN; } var u = [-d[1], d[0]]; vec2.normalize(u, u); var a = [x - x1, y - y1]; return Math.abs(vec2.dot(a, u)); }, box: function box(x1, y1, x2, y2, lineWidth) { var halfWidth = lineWidth / 2; var minX = Math.min(x1, x2); var maxX = Math.max(x1, x2); var minY = Math.min(y1, y2); var maxY = Math.max(y1, y2); return { minX: minX - halfWidth, minY: minY - halfWidth, maxX: maxX + halfWidth, maxY: maxY + halfWidth }; }, len: function len(x1, y1, x2, y2) { return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); } }; /***/ }, /* 53 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var vec2 = __webpack_require__(3).vec2; function quadraticAt(p0, p1, p2, t) { var onet = 1 - t; return onet * (onet * p0 + 2 * t * p1) + t * t * p2; } function quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, out) { var t = void 0; var interval = 0.005; var d = Infinity; var d1 = void 0; var v1 = void 0; var v2 = void 0; var _t = void 0; var d2 = void 0; var i = void 0; var EPSILON = 0.0001; var v0 = [x, y]; for (_t = 0; _t < 1; _t += 0.05) { v1 = [quadraticAt(x1, x2, x3, _t), quadraticAt(y1, y2, y3, _t)]; d1 = vec2.squaredDistance(v0, v1); if (d1 < d) { t = _t; d = d1; } } d = Infinity; for (i = 0; i < 32; i++) { if (interval < EPSILON) { break; } var prev = t - interval; var next = t + interval; v1 = [quadraticAt(x1, x2, x3, prev), quadraticAt(y1, y2, y3, prev)]; d1 = vec2.squaredDistance(v0, v1); if (prev >= 0 && d1 < d) { t = prev; d = d1; } else { v2 = [quadraticAt(x1, x2, x3, next), quadraticAt(y1, y2, y3, next)]; d2 = vec2.squaredDistance(v0, v2); if (next <= 1 && d2 < d) { t = next; d = d2; } else { interval *= 0.5; } } } if (out) { out.x = quadraticAt(x1, x2, x3, t); out.y = quadraticAt(y1, y2, y3, t); } return Math.sqrt(d); } function quadraticExtrema(p0, p1, p2) { var a = p0 + p2 - 2 * p1; if (Util.isNumberEqual(a, 0)) { return [0.5]; } var rst = (p0 - p1) / a; if (rst <= 1 && rst >= 0) { return [rst]; } return []; } module.exports = { at: quadraticAt, projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x, y) { var rst = {}; quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, rst); return rst; }, pointDistance: quadraticProjectPoint, extrema: quadraticExtrema }; /***/ }, /* 54 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var vec2 = __webpack_require__(3).vec2; function circlePoint(cx, cy, r, angle) { return { x: Math.cos(angle) * r + cx, y: Math.sin(angle) * r + cy }; } function angleNearTo(angle, min, max, out) { var v1 = void 0; var v2 = void 0; if (out) { if (angle < min) { v1 = min - angle; v2 = Math.PI * 2 - max + angle; } else if (angle > max) { v1 = Math.PI * 2 - angle + min; v2 = angle - max; } } else { v1 = angle - min; v2 = max - angle; } return v1 > v2 ? max : min; } function nearAngle(angle, startAngle, endAngle, clockwise) { var plus = 0; if (endAngle - startAngle >= Math.PI * 2) { plus = Math.PI * 2; } startAngle = Util.mod(startAngle, Math.PI * 2); endAngle = Util.mod(endAngle, Math.PI * 2) + plus; angle = Util.mod(angle, Math.PI * 2); if (clockwise) { if (startAngle >= endAngle) { if (angle > endAngle && angle < startAngle) { return angle; } return angleNearTo(angle, endAngle, startAngle, true); } if (angle < startAngle || angle > endAngle) { return angle; } return angleNearTo(angle, startAngle, endAngle); } if (startAngle <= endAngle) { if (startAngle < angle && angle < endAngle) { return angle; } return angleNearTo(angle, startAngle, endAngle, true); } if (angle > startAngle || angle < endAngle) { return angle; } return angleNearTo(angle, endAngle, startAngle); } function arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, out) { var v = [x, y]; var v0 = [cx, cy]; var v1 = [1, 0]; var subv = vec2.subtract([], v, v0); var angle = vec2.angleTo(v1, subv); angle = nearAngle(angle, startAngle, endAngle, clockwise); var vpoint = [r * Math.cos(angle) + cx, r * Math.sin(angle) + cy]; if (out) { out.x = vpoint[0]; out.y = vpoint[1]; } var d = vec2.distance(vpoint, v); return d; } function arcBox(cx, cy, r, startAngle, endAngle, clockwise) { var angleRight = 0; var angleBottom = Math.PI / 2; var angleLeft = Math.PI; var angleTop = Math.PI * 3 / 2; var points = []; var angle = nearAngle(angleRight, startAngle, endAngle, clockwise); if (angle === angleRight) { points.push(circlePoint(cx, cy, r, angleRight)); } angle = nearAngle(angleBottom, startAngle, endAngle, clockwise); if (angle === angleBottom) { points.push(circlePoint(cx, cy, r, angleBottom)); } angle = nearAngle(angleLeft, startAngle, endAngle, clockwise); if (angle === angleLeft) { points.push(circlePoint(cx, cy, r, angleLeft)); } angle = nearAngle(angleTop, startAngle, endAngle, clockwise); if (angle === angleTop) { points.push(circlePoint(cx, cy, r, angleTop)); } points.push(circlePoint(cx, cy, r, startAngle)); points.push(circlePoint(cx, cy, r, endAngle)); var minX = Infinity; var maxX = -Infinity; var minY = Infinity; var maxY = -Infinity; Util.each(points, function (point) { if (minX > point.x) { minX = point.x; } if (maxX < point.x) { maxX = point.x; } if (minY > point.y) { minY = point.y; } if (maxY < point.y) { maxY = point.y; } }); return { minX: minX, minY: minY, maxX: maxX, maxY: maxY }; } module.exports = { nearAngle: nearAngle, projectPoint: function projectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y) { var rst = {}; arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, rst); return rst; }, pointDistance: arcProjectPoint, box: arcBox }; /***/ }, /* 55 */ /***/function (module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function (global) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; /** Detect free variable `global` from Node.js. */ var freeGlobal = (typeof global === 'undefined' ? 'undefined' : _typeof(global)) == 'object' && global && global.Object === Object && global; module.exports = freeGlobal; /* WEBPACK VAR INJECTION */ }).call(exports, __webpack_require__(114)); /***/ }, /* 56 */ /***/function (module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(7), isArray = __webpack_require__(6), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var stringTag = '[object String]'; /** * Checks if `value` is classified as a `String` primitive or object. * * @static * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a string, else `false`. * @example * * _.isString('abc'); * // => true * * _.isString(1); * // => false */ function isString(value) { return typeof value == 'string' || !isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag; } module.exports = isString; /***/ }, /* 57 */ /***/function (module, exports, __webpack_require__) { var isPrototype = __webpack_require__(16), nativeKeys = __webpack_require__(121); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function baseKeys(object) { if (!isPrototype(object)) { return nativeKeys(object); } var result = []; for (var key in Object(object)) { if (hasOwnProperty.call(object, key) && key != 'constructor') { result.push(key); } } return result; } module.exports = baseKeys; /***/ }, /* 58 */ /***/function (module, exports) { /** * Creates a unary function that invokes `func` with its argument transformed. * * @private * @param {Function} func The function to wrap. * @param {Function} transform The argument transform. * @returns {Function} Returns the new function. */ function overArg(func, transform) { return function (arg) { return func(transform(arg)); }; } module.exports = overArg; /***/ }, /* 59 */ /***/function (module, exports) { /** Used for built-in method references. */ var funcProto = Function.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** * Converts `func` to its source code. * * @private * @param {Function} func The function to convert. * @returns {string} Returns the source code. */ function toSource(func) { if (func != null) { try { return funcToString.call(func); } catch (e) {} try { return func + ''; } catch (e) {} } return ''; } module.exports = toSource; /***/ }, /* 60 */ /***/function (module, exports) { /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; /** * Checks if `value` is a valid array-like length. * * **Note:** This method is loosely based on * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. * @example * * _.isLength(3); * // => true * * _.isLength(Number.MIN_VALUE); * // => false * * _.isLength(Infinity); * // => false * * _.isLength('3'); * // => false */ function isLength(value) { return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } module.exports = isLength; /***/ }, /* 61 */ /***/function (module, exports) { /** * The base implementation of `_.unary` without support for storing metadata. * * @private * @param {Function} func The function to cap arguments for. * @returns {Function} Returns the new capped function. */ function baseUnary(func) { return function (value) { return func(value); }; } module.exports = baseUnary; /***/ }, /* 62 */ /***/function (module, exports, __webpack_require__) { var baseToString = __webpack_require__(135); /** * Converts `value` to a string. An empty string is returned for `null` * and `undefined` values. The sign of `-0` is preserved. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {string} Returns the converted string. * @example * * _.toString(null); * // => '' * * _.toString(-0); * // => '-0' * * _.toString([1, 2, 3]); * // => '1,2,3' */ function toString(value) { return value == null ? '' : baseToString(value); } module.exports = toString; /***/ }, /* 63 */ /***/function (module, exports, __webpack_require__) { var mapCacheClear = __webpack_require__(149), mapCacheDelete = __webpack_require__(156), mapCacheGet = __webpack_require__(158), mapCacheHas = __webpack_require__(159), mapCacheSet = __webpack_require__(160); /** * Creates a map cache object to store key-value pairs. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function MapCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `MapCache`. MapCache.prototype.clear = mapCacheClear; MapCache.prototype['delete'] = mapCacheDelete; MapCache.prototype.get = mapCacheGet; MapCache.prototype.has = mapCacheHas; MapCache.prototype.set = mapCacheSet; module.exports = MapCache; /***/ }, /* 64 */ /***/function (module, exports) { /** * A specialized version of `_.forEach` for arrays without support for * iteratee shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns `array`. */ function arrayEach(array, iteratee) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (iteratee(array[index], index, array) === false) { break; } } return array; } module.exports = arrayEach; /***/ }, /* 65 */ /***/function (module, exports, __webpack_require__) { var getNative = __webpack_require__(10); var defineProperty = function () { try { var func = getNative(Object, 'defineProperty'); func({}, '', {}); return func; } catch (e) {} }(); module.exports = defineProperty; /***/ }, /* 66 */ /***/function (module, exports, __webpack_require__) { var baseTimes = __webpack_require__(162), isArguments = __webpack_require__(33), isArray = __webpack_require__(6), isBuffer = __webpack_require__(17), isIndex = __webpack_require__(67), isTypedArray = __webpack_require__(22); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Creates an array of the enumerable property names of the array-like `value`. * * @private * @param {*} value The value to query. * @param {boolean} inherited Specify returning inherited property names. * @returns {Array} Returns the array of property names. */ function arrayLikeKeys(value, inherited) { var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; for (var key in value) { if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode. key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == 'offset' || key == 'parent') || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || // Skip index properties. isIndex(key, length)))) { result.push(key); } } return result; } module.exports = arrayLikeKeys; /***/ }, /* 67 */ /***/function (module, exports) { /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; /** Used to detect unsigned integer values. */ var reIsUint = /^(?:0|[1-9]\d*)$/; /** * Checks if `value` is a valid array-like index. * * @private * @param {*} value The value to check. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ function isIndex(value, length) { length = length == null ? MAX_SAFE_INTEGER : length; return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length; } module.exports = isIndex; /***/ }, /* 68 */ /***/function (module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function (module) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; var root = __webpack_require__(4); /** Detect free variable `exports`. */ var freeExports = (false ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && (false ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined, allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined; /** * Creates a clone of `buffer`. * * @private * @param {Buffer} buffer The buffer to clone. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Buffer} Returns the cloned buffer. */ function cloneBuffer(buffer, isDeep) { if (isDeep) { return buffer.slice(); } var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); buffer.copy(result); return result; } module.exports = cloneBuffer; /* WEBPACK VAR INJECTION */ }).call(exports, __webpack_require__(34)(module)); /***/ }, /* 69 */ /***/function (module, exports) { /** * This method returns a new empty array. * * @static * @memberOf _ * @since 4.13.0 * @category Util * @returns {Array} Returns the new empty array. * @example * * var arrays = _.times(2, _.stubArray); * * console.log(arrays); * // => [[], []] * * console.log(arrays[0] === arrays[1]); * // => false */ function stubArray() { return []; } module.exports = stubArray; /***/ }, /* 70 */ /***/function (module, exports, __webpack_require__) { var arrayPush = __webpack_require__(71), getPrototype = __webpack_require__(40), getSymbols = __webpack_require__(39), stubArray = __webpack_require__(69); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeGetSymbols = Object.getOwnPropertySymbols; /** * Creates an array of the own and inherited enumerable symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ var getSymbolsIn = !nativeGetSymbols ? stubArray : function (object) { var result = []; while (object) { arrayPush(result, getSymbols(object)); object = getPrototype(object); } return result; }; module.exports = getSymbolsIn; /***/ }, /* 71 */ /***/function (module, exports) { /** * Appends the elements of `values` to `array`. * * @private * @param {Array} array The array to modify. * @param {Array} values The values to append. * @returns {Array} Returns `array`. */ function arrayPush(array, values) { var index = -1, length = values.length, offset = array.length; while (++index < length) { array[offset + index] = values[index]; } return array; } module.exports = arrayPush; /***/ }, /* 72 */ /***/function (module, exports, __webpack_require__) { var baseGetAllKeys = __webpack_require__(73), getSymbols = __webpack_require__(39), keys = __webpack_require__(13); /** * Creates an array of own enumerable property names and symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names and symbols. */ function getAllKeys(object) { return baseGetAllKeys(object, keys, getSymbols); } module.exports = getAllKeys; /***/ }, /* 73 */ /***/function (module, exports, __webpack_require__) { var arrayPush = __webpack_require__(71), isArray = __webpack_require__(6); /** * The base implementation of `getAllKeys` and `getAllKeysIn` which uses * `keysFunc` and `symbolsFunc` to get the enumerable property names and * symbols of `object`. * * @private * @param {Object} object The object to query. * @param {Function} keysFunc The function to get the keys of `object`. * @param {Function} symbolsFunc The function to get the symbols of `object`. * @returns {Array} Returns the array of property names and symbols. */ function baseGetAllKeys(object, keysFunc, symbolsFunc) { var result = keysFunc(object); return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); } module.exports = baseGetAllKeys; /***/ }, /* 74 */ /***/function (module, exports, __webpack_require__) { var root = __webpack_require__(4); /** Built-in value references. */ var Uint8Array = root.Uint8Array; module.exports = Uint8Array; /***/ }, /* 75 */ /***/function (module, exports) { /** * A specialized version of `_.reduce` for arrays without support for * iteratee shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initAccum] Specify using the first element of `array` as * the initial value. * @returns {*} Returns the accumulated value. */ function arrayReduce(array, iteratee, accumulator, initAccum) { var index = -1, length = array == null ? 0 : array.length; if (initAccum && length) { accumulator = array[++index]; } while (++index < length) { accumulator = iteratee(accumulator, array[index], index, array); } return accumulator; } module.exports = arrayReduce; /***/ }, /* 76 */ /***/function (module, exports, __webpack_require__) { var cloneArrayBuffer = __webpack_require__(41); /** * Creates a clone of `typedArray`. * * @private * @param {Object} typedArray The typed array to clone. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned typed array. */ function cloneTypedArray(typedArray, isDeep) { var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); } module.exports = cloneTypedArray; /***/ }, /* 77 */ /***/function (module, exports, __webpack_require__) { var baseCreate = __webpack_require__(179), getPrototype = __webpack_require__(40), isPrototype = __webpack_require__(16); /** * Initializes an object clone. * * @private * @param {Object} object The object to clone. * @returns {Object} Returns the initialized clone. */ function initCloneObject(object) { return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {}; } module.exports = initCloneObject; /***/ }, /* 78 */ /***/function (module, exports, __webpack_require__) { var baseRest = __webpack_require__(79), isIterateeCall = __webpack_require__(187); /** * Creates a function like `_.assign`. * * @private * @param {Function} assigner The function to assign values. * @returns {Function} Returns the new assigner function. */ function createAssigner(assigner) { return baseRest(function (object, sources) { var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined, guard = length > 2 ? sources[2] : undefined; customizer = assigner.length > 3 && typeof customizer == 'function' ? (length--, customizer) : undefined; if (guard && isIterateeCall(sources[0], sources[1], guard)) { customizer = length < 3 ? undefined : customizer; length = 1; } object = Object(object); while (++index < length) { var source = sources[index]; if (source) { assigner(object, source, index, customizer); } } return object; }); } module.exports = createAssigner; /***/ }, /* 79 */ /***/function (module, exports, __webpack_require__) { var identity = __webpack_require__(44), overRest = __webpack_require__(181), setToString = __webpack_require__(183); /** * The base implementation of `_.rest` which doesn't validate or coerce arguments. * * @private * @param {Function} func The function to apply a rest parameter to. * @param {number} [start=func.length-1] The start position of the rest parameter. * @returns {Function} Returns the new function. */ function baseRest(func, start) { return setToString(overRest(func, start, identity), func + ''); } module.exports = baseRest; /***/ }, /* 80 */ /***/function (module, exports, __webpack_require__) { var baseAssignValue = __webpack_require__(38), eq = __webpack_require__(18); /** * This function is like `assignValue` except that it doesn't assign * `undefined` values. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ function assignMergeValue(object, key, value) { if (value !== undefined && !eq(object[key], value) || value === undefined && !(key in object)) { baseAssignValue(object, key, value); } } module.exports = assignMergeValue; /***/ }, /* 81 */ /***/function (module, exports, __webpack_require__) { var createBaseFor = __webpack_require__(190); /** * The base implementation of `baseForOwn` which iterates over `object` * properties returned by `keysFunc` and invokes `iteratee` for each property. * Iteratee functions may exit iteration early by explicitly returning `false`. * * @private * @param {Object} object The object to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ var baseFor = createBaseFor(); module.exports = baseFor; /***/ }, /* 82 */ /***/function (module, exports) { /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', rsComboMarksRange = '\\u0300-\\u036f', reComboHalfMarksRange = '\\ufe20-\\ufe2f', rsComboSymbolsRange = '\\u20d0-\\u20ff', rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = '\\ufe0e\\ufe0f'; /** Used to compose unicode capture groups. */ var rsZWJ = '\\u200d'; /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); /** * Checks if `string` contains Unicode symbols. * * @private * @param {string} string The string to inspect. * @returns {boolean} Returns `true` if a symbol is found, else `false`. */ function hasUnicode(string) { return reHasUnicode.test(string); } module.exports = hasUnicode; /***/ }, /* 83 */ /***/function (module, exports, __webpack_require__) { var asciiToArray = __webpack_require__(199), hasUnicode = __webpack_require__(82), unicodeToArray = __webpack_require__(200); /** * Converts `string` to an array. * * @private * @param {string} string The string to convert. * @returns {Array} Returns the converted array. */ function stringToArray(string) { return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string); } module.exports = stringToArray; /***/ }, /* 84 */ /***/function (module, exports, __webpack_require__) { var SetCache = __webpack_require__(217), arraySome = __webpack_require__(220), cacheHas = __webpack_require__(221); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** * A specialized version of `baseIsEqualDeep` for arrays with support for * partial deep comparisons. * * @private * @param {Array} array The array to compare. * @param {Array} other The other array to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} stack Tracks traversed `array` and `other` objects. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length; if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } // Assume cyclic values are equal. var stacked = stack.get(array); if (stacked && stack.get(other)) { return stacked == other; } var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : undefined; stack.set(array, other); stack.set(other, array); // Ignore non-index properties. while (++index < arrLength) { var arrValue = array[index], othValue = other[index]; if (customizer) { var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); } if (compared !== undefined) { if (compared) { continue; } result = false; break; } // Recursively compare arrays (susceptible to call stack limits). if (seen) { if (!arraySome(other, function (othValue, othIndex) { if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { return seen.push(othIndex); } })) { result = false; break; } } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { result = false; break; } } stack['delete'](array); stack['delete'](other); return result; } module.exports = equalArrays; /***/ }, /* 85 */ /***/function (module, exports) { var TABLE = document.createElement('table'); var TABLE_TR = document.createElement('tr'); var FRAGMENT_REG = /^\s*<(\w+|!)[^>]*>/; var CONTAINERS = { tr: document.createElement('tbody'), tbody: TABLE, thead: TABLE, tfoot: TABLE, td: TABLE_TR, th: TABLE_TR, '*': document.createElement('div') }; module.exports = { getBoundingClientRect: function getBoundingClientRect(node) { var rect = node.getBoundingClientRect(); var top = document.documentElement.clientTop; var left = document.documentElement.clientLeft; return { top: rect.top - top, bottom: rect.bottom - top, left: rect.left - left, right: rect.right - left }; }, /** * 获取样式 * @param {Object} dom DOM节点 * @param {String} name 样式名 * @return {String} 属性值 */ getStyle: function getStyle(dom, name) { if (window.getComputedStyle) { return window.getComputedStyle(dom, null)[name]; } return dom.currentStyle[name]; }, modifyCSS: function modifyCSS(dom, css) { for (var key in css) { if (css.hasOwnProperty(key)) { dom.style[key] = css[key]; } } return dom; }, /** * 创建DOM 节点 * @param {String} str Dom 字符串 * @return {HTMLElement} DOM 节点 */ createDom: function createDom(str) { var name = FRAGMENT_REG.test(str) && RegExp.$1; if (!(name in CONTAINERS)) { name = '*'; } var container = CONTAINERS[name]; str = str.replace(/(^\s*)|(\s*$)/g, ''); container.innerHTML = '' + str; return container.childNodes[0]; }, getRatio: function getRatio() { return window.devicePixelRatio ? window.devicePixelRatio : 2; }, /** * 获取宽度 * @param {HTMLElement} el dom节点 * @return {Number} 宽度 */ getWidth: function getWidth(el) { var width = this.getStyle(el, 'width'); if (width === 'auto') { width = el.offsetWidth; } return parseFloat(width); }, /** * 获取高度 * @param {HTMLElement} el dom节点 * @return {Number} 高度 */ getHeight: function getHeight(el) { var height = this.getStyle(el, 'height'); if (height === 'auto') { height = el.offsetHeight; } return parseFloat(height); }, /** * 获取外层高度 * @param {HTMLElement} el dom节点 * @return {Number} 高度 */ getOuterHeight: function getOuterHeight(el) { var height = this.getHeight(el); var bTop = parseFloat(this.getStyle(el, 'borderTopWidth')) || 0; var pTop = parseFloat(this.getStyle(el, 'paddingTop')); var pBottom = parseFloat(this.getStyle(el, 'paddingBottom')); var bBottom = parseFloat(this.getStyle(el, 'borderBottomWidth')) || 0; return height + bTop + bBottom + pTop + pBottom; }, /** * 获取外层宽度 * @param {HTMLElement} el dom节点 * @return {Number} 宽度 */ getOuterWidth: function getOuterWidth(el) { var width = this.getWidth(el); var bLeft = parseFloat(this.getStyle(el, 'borderLeftWidth')) || 0; var pLeft = parseFloat(this.getStyle(el, 'paddingLeft')); var pRight = parseFloat(this.getStyle(el, 'paddingRight')); var bRight = parseFloat(this.getStyle(el, 'borderRightWidth')) || 0; return width + bLeft + bRight + pLeft + pRight; }, /** * 添加事件监听器 * @param {Object} target DOM对象 * @param {String} eventType 事件名 * @param {Funtion} callback 回调函数 * @return {Object} 返回对象 */ addEventListener: function addEventListener(target, eventType, callback) { if (target.addEventListener) { target.addEventListener(eventType, callback, false); return { remove: function remove() { target.removeEventListener(eventType, callback, false); } }; } else if (target.attachEvent) { target.attachEvent('on' + eventType, callback); return { remove: function remove() { target.detachEvent('on' + eventType, callback); } }; } }, requestAnimationFrame: function requestAnimationFrame(fn) { var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) { return setTimeout(fn, 16); }; return method(fn); } }; /***/ }, /* 86 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Event = function Event(type, event, bubbles, cancelable) { this.type = type; // 事件类型 this.target = null; // 目标 this.currentTarget = null; // 当前目标 this.bubbles = bubbles; // 冒泡 this.cancelable = cancelable; // 是否能够阻止 this.timeStamp = new Date().getTime(); // 时间戳 this.defaultPrevented = false; // 阻止默认 this.propagationStopped = false; // 阻止冒泡 this.removed = false; // 是否被移除 this.event = event; // 触发的原生事件 }; Util.augment(Event, { preventDefault: function preventDefault() { this.defaultPrevented = this.cancelable && true; }, stopPropagation: function stopPropagation() { this.propagationStopped = true; }, remove: function remove() { this.remove = true; }, clone: function clone() { return Util.clone(this); }, toString: function toString() { return '[Event (type=' + this.type + ')]'; } }); module.exports = Event; /***/ }, /* 87 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Element = __webpack_require__(88); var Shape = __webpack_require__(262); var SHAPE_MAP = {}; // 缓存图形类型 var INDEX = '_INDEX'; function find(children, x, y) { var rst = void 0; for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; if (child.__cfg.visible && child.__cfg.capture) { if (child.isGroup) { rst = child.getShape(x, y); } else if (child.isHit(x, y)) { rst = child; } } if (rst) { break; } } return rst; } function getComparer(compare) { return function (left, right) { var result = compare(left, right); return result === 0 ? left[INDEX] - right[INDEX] : result; }; } var Group = function Group(cfg) { Group.superclass.constructor.call(this, cfg); this.set('children', []); this._beforeRenderUI(); this._renderUI(); this._bindUI(); }; function initClassCfgs(c) { if (c.__cfg || c === Group) { return; } var superCon = c.superclass.constructor; if (superCon && !superCon.__cfg) { initClassCfgs(superCon); } c.__cfg = {}; Util.merge(c.__cfg, superCon.__cfg); Util.merge(c.__cfg, c.CFG); } Util.extend(Group, Element); Util.augment(Group, { isGroup: true, canFill: true, canStroke: true, getDefaultCfg: function getDefaultCfg() { initClassCfgs(this.constructor); return Util.merge({}, this.constructor.__cfg); }, _beforeRenderUI: function _beforeRenderUI() {}, _renderUI: function _renderUI() {}, _bindUI: function _bindUI() {}, addShape: function addShape(type, cfg) { var canvas = this.get('canvas'); cfg = cfg || {}; var shapeType = SHAPE_MAP[type]; if (!shapeType) { shapeType = Util.upperFirst(type); SHAPE_MAP[type] = shapeType; } if (cfg.attrs) { var attrs = cfg.attrs; if (type === 'text') { // 临时解决 var topFontFamily = canvas.get('fontFamily'); if (topFontFamily) { attrs.fontFamily = attrs.fontFamily ? attrs.fontFamily : topFontFamily; } } } cfg.canvas = canvas; cfg.type = type; var rst = new Shape[shapeType](cfg); this.add(rst); return rst; }, /** 添加图组 * @param {Function|Object|undefined} param 图组类 * @param {Object} cfg 配置项 * @return {Object} rst 图组 */ addGroup: function addGroup(param, cfg) { var canvas = this.get('canvas'); var rst = void 0; cfg = Util.merge({}, cfg); if (Util.isFunction(param)) { if (cfg) { cfg.canvas = canvas; cfg.parent = this; rst = new param(cfg); } else { rst = new param({ canvas: canvas, parent: this }); } this.add(rst); } else if (Util.isObject(param)) { param.canvas = canvas; rst = new Group(param); this.add(rst); } else if (param === undefined) { rst = new Group(); this.add(rst); } else { return false; } return rst; }, /** 绘制背景 * @param {Array} padding 内边距 * @param {Attrs} attrs 图形属性 * @param {Shape} backShape 背景图形 * @return {Object} 背景层对象 */ renderBack: function renderBack(padding, attrs) { var backShape = this.get('backShape'); var innerBox = this.getBBox(); // const parent = this.get('parent'); // getParent Util.merge(attrs, { x: innerBox.minX - padding[3], y: innerBox.minY - padding[0], width: innerBox.width + padding[1] + padding[3], height: innerBox.height + padding[0] + padding[2] }); if (backShape) { backShape.attr(attrs); } else { backShape = this.addShape('rect', { zIndex: -1, attrs: attrs }); } this.set('backShape', backShape); this.sort(); return backShape; }, removeChild: function removeChild(item, destroy) { if (arguments.length >= 2) { if (this.contain(item)) { item.remove(destroy); } } else { if (arguments.length === 1) { if (Util.isBoolean(item)) { destroy = item; } else { if (this.contain(item)) { item.remove(true); } return this; } } if (arguments.length === 0) { destroy = true; } Group.superclass.remove.call(this, destroy); } return this; }, /** * 向组中添加shape或者group * @param {Object} items 图形或者分组 * @return {Object} group 本尊 */ add: function add(items) { var self = this; var children = self.get('children'); if (Util.isArray(items)) { Util.each(items, function (item) { var parent = item.get('parent'); if (parent) { parent.removeChild(item, false); } self.__setEvn(item); }); children.push.apply(children, items); } else { var item = items; var parent = item.get('parent'); if (parent) { parent.removeChild(item, false); } self.__setEvn(item); children.push(item); } return self; }, contain: function contain(item) { var children = this.get('children'); return children.indexOf(item) > -1; }, getChildByIndex: function getChildByIndex(index) { var children = this.get('children'); return children[index]; }, getFirst: function getFirst() { return this.getChildByIndex(0); }, getLast: function getLast() { var lastIndex = this.get('children').length - 1; return this.getChildByIndex(lastIndex); }, __setEvn: function __setEvn(item) { var self = this; item.__cfg.parent = self; item.__cfg.context = self.__cfg.context; item.__cfg.canvas = self.__cfg.canvas; var clip = item.__attrs.clip; if (clip) { clip.setSilent('parent', self); clip.setSilent('context', self.get('context')); } var children = item.__cfg.children; if (children) { Util.each(children, function (child) { item.__setEvn(child); }); } }, getBBox: function getBBox() { var self = this; var minX = Infinity; var maxX = -Infinity; var minY = Infinity; var maxY = -Infinity; var children = self.get('children'); Util.each(children, function (child) { if (child.get('visible')) { var _box = child.getBBox(); if (!_box) { return true; } var leftTop = [_box.minX, _box.minY, 1]; var leftBottom = [_box.minX, _box.maxY, 1]; var rightTop = [_box.maxX, _box.minY, 1]; var rightBottom = [_box.maxX, _box.maxY, 1]; child.apply(leftTop); child.apply(leftBottom); child.apply(rightTop); child.apply(rightBottom); var boxMinX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]); var boxMaxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]); var boxMinY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]); var boxMaxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]); if (boxMinX < minX) { minX = boxMinX; } if (boxMaxX > maxX) { maxX = boxMaxX; } if (boxMinY < minY) { minY = boxMinY; } if (boxMaxY > maxY) { maxY = boxMaxY; } } }); var box = { minX: minX, minY: minY, maxX: maxX, maxY: maxY }; box.x = box.minX; box.y = box.minY; box.width = box.maxX - box.minX; box.height = box.maxY - box.minY; return box; }, drawInner: function drawInner(context) { var children = this.get('children'); for (var i = 0; i < children.length; i++) { var child = children[i]; child.draw(context); } return this; }, getCount: function getCount() { return this.get('children').length; }, sort: function sort() { var children = this.get('children'); // 稳定排序 Util.each(children, function (child, index) { child[INDEX] = index; return child; }); children.sort(getComparer(function (obj1, obj2) { return obj1.get('zIndex') - obj2.get('zIndex'); })); return this; }, find: function find(id) { return this.findBy(function (item) { return item.get('id') === id; }); }, /** * 根据查找函数查找分组或者图形 * @param {Function} fn 匹配函数 * @return {Canvas.Base} 分组或者图形 */ findBy: function findBy(fn) { var children = this.get('children'); var rst = null; Util.each(children, function (item) { if (fn(item)) { rst = item; } else if (item.findBy) { rst = item.findBy(fn); } if (rst) { return false; } }); return rst; }, findAllBy: function findAllBy(fn) { var children = this.get('children'); var rst = []; var childRst = []; Util.each(children, function (item) { if (fn(item)) { rst.push(item); } if (item.findAllBy) { childRst = item.findAllBy(fn); rst = rst.concat(childRst); } }); return rst; }, /** * 根据x,y轴坐标获取对应的图形 * @param {Number} x x坐标 * @param {Number} y y坐标 * @return {Object} 最上面的图形 */ getShape: function getShape(x, y) { var self = this; var clip = self.__attrs.clip; var children = self.__cfg.children; var rst = void 0; if (clip) { if (clip.inside(x, y)) { rst = find(children, x, y); } } else { rst = find(children, x, y); } return rst; }, clearTotalMatrix: function clearTotalMatrix() { var m = this.get('totalMatrix'); if (m) { this.setSilent('totalMatrix', null); var children = this.__cfg.children; for (var i = 0; i < children.length; i++) { var child = children[i]; child.clearTotalMatrix(); } } }, clear: function clear() { var children = this.get('children'); while (children.length !== 0) { children[children.length - 1].remove(); } return this; }, destroy: function destroy() { if (this.get('destroyed')) { return; } this.clear(); Group.superclass.destroy.call(this); } }); module.exports = Group; /***/ }, /* 88 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Attribute = __webpack_require__(228); var Transform = __webpack_require__(229); var Animate = __webpack_require__(233); var Format = __webpack_require__(97); var EventEmitter = __webpack_require__(261); var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash']; var Element = function Element(cfg) { this.__cfg = { zIndex: 0, capture: true, visible: true, destroyed: false }; // 配置存放地 Util.assign(this.__cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置 this.initAttrs(this.__cfg.attrs); // 初始化绘图属性 this.initTransform(); // 初始化变换 this.init(); // 类型初始化 }; Element.CFG = { /** * 唯一标示 * @type {Number} */ id: null, /** * Z轴的层叠关系,Z值越大离用户越近 * @type {Number} */ zIndex: 0, /** * Canvas对象 * @type: {Object} */ canvas: null, /** * 父元素指针 * @type {Object} */ parent: null, /** * 用来设置当前对象是否能被捕捉 * true 能 * false 不能 * 对象默认是都可以被捕捉的, 当capture为false时,group.getShape(x, y)方法无法获得该元素 * 通过将不必要捕捉的元素的该属性设置成false, 来提高捕捉性能 * @type {Boolean} **/ capture: true, /** * 画布的上下文 * @type {Object} */ context: null, /** * 是否显示 * @type {Boolean} */ visible: true, /** * 是否被销毁 * @type: {Boolean} */ destroyed: false }; Util.augment(Element, Attribute, Transform, EventEmitter, Animate, { init: function init() { this.setSilent('animable', true); this.setSilent('animating', false); // 初始时不处于动画状态 var attrs = this.__attrs; if (attrs && attrs.rotate) { this.rotateAtStart(attrs.rotate); } }, getParent: function getParent() { return this.get('parent'); }, /** * 获取默认的配置信息 * @protected * @return {Object} 默认的属性 */ getDefaultCfg: function getDefaultCfg() { return {}; }, set: function set(name, value) { var m = '__set' + Util.upperFirst(name); if (this[m]) { value = this[m](value); } this.__cfg[name] = value; return this; }, setSilent: function setSilent(name, value) { this.__cfg[name] = value; }, get: function get(name) { return this.__cfg[name]; }, draw: function draw(context) { if (this.get('destroyed')) { return; } if (this.get('visible')) { this.setContext(context); this.drawInner(context); this.restoreContext(context); } }, setContext: function setContext(context) { var clip = this.__attrs.clip; context.save(); if (clip) { // context.save(); clip.resetTransform(context); clip.createPath(context); context.clip(); // context.restore(); } this.resetContext(context); this.resetTransform(context); }, restoreContext: function restoreContext(context) { context.restore(); }, resetContext: function resetContext(context) { var elAttrs = this.__attrs; // var canvas = this.get('canvas'); if (!this.isGroup) { // canvas.registShape(this); // 快速拾取方案暂时不执行 for (var k in elAttrs) { if (SHAPE_ATTRS.indexOf(k) > -1) { // 非canvas属性不附加 var v = elAttrs[k]; if (k === 'fillStyle') { v = Format.parseStyle(v, this); } if (k === 'strokeStyle') { v = Format.parseStyle(v, this); } if (k === 'lineDash' && context.setLineDash) { if (Util.isArray(v)) { context.setLineDash(v); } else if (Util.isString(v)) { context.setLineDash(v.split(' ')); } } else { context[k] = v; } } } } }, drawInner: function drawInner() /* context */{}, show: function show() { this.set('visible', true); return this; }, hide: function hide() { this.set('visible', false); return this; }, remove: function remove(destroy) { if (destroy === undefined) { destroy = true; } if (this.get('parent')) { var parent = this.get('parent'); var children = parent.get('children'); Util.remove(children, this); } if (destroy) { this.destroy(); } return this; }, destroy: function destroy() { var destroyed = this.get('destroyed'); if (destroyed) { return; } this.__cfg = {}; this.__attrs = null; this.removeEvent(); // 移除所有的事件 this.set('destroyed', true); }, __setZIndex: function __setZIndex(zIndex) { this.__cfg.zIndex = zIndex; if (!Util.isNil(this.get('parent'))) { this.get('parent').sort(); } return zIndex; }, __setAttrs: function __setAttrs(attrs) { this.attr(attrs); return attrs; }, setZIndex: function setZIndex(zIndex) { this.__cfg.zIndex = zIndex; return zIndex; }, clone: function clone() { return Util.clone(this); }, getBBox: function getBBox() { return { minX: 0, maxX: 0, minY: 0, maxY: 0 }; } }); module.exports = Element; /***/ }, /* 89 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function () { return deg2rad; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "b", function () { return rad2deg; }); var deg2rad = Math.PI / 180; var rad2deg = 180 / Math.PI; /***/ }, /* 90 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function () { return rgbBasis; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () { return rgbBasisClosed; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(14); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__basis__ = __webpack_require__(51); /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__basisClosed__ = __webpack_require__(91); /* harmony import */var __WEBPACK_IMPORTED_MODULE_3__color__ = __webpack_require__(19); /* harmony default export */__webpack_exports__["a"] = function rgbGamma(y) { var color = Object(__WEBPACK_IMPORTED_MODULE_3__color__["b" /* gamma */])(y); function rgb(start, end) { var r = color((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(start)).r, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(end)).r), g = color(start.g, end.g), b = color(start.b, end.b), opacity = Object(__WEBPACK_IMPORTED_MODULE_3__color__["a" /* default */])(start.opacity, end.opacity); return function (t) { start.r = r(t); start.g = g(t); start.b = b(t); start.opacity = opacity(t); return start + ""; }; } rgb.gamma = rgbGamma; return rgb; }(1); function rgbSpline(spline) { return function (colors) { var n = colors.length, r = new Array(n), g = new Array(n), b = new Array(n), i, color; for (i = 0; i < n; ++i) { color = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(colors[i]); r[i] = color.r || 0; g[i] = color.g || 0; b[i] = color.b || 0; } r = spline(r); g = spline(g); b = spline(b); color.opacity = 1; return function (t) { color.r = r(t); color.g = g(t); color.b = b(t); return color + ""; }; }; } var rgbBasis = rgbSpline(__WEBPACK_IMPORTED_MODULE_1__basis__["b" /* default */]); var rgbBasisClosed = rgbSpline(__WEBPACK_IMPORTED_MODULE_2__basisClosed__["a" /* default */]); /***/ }, /* 91 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__basis__ = __webpack_require__(51); /* harmony default export */__webpack_exports__["a"] = function (values) { var n = values.length; return function (t) { var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n), v0 = values[(i + n - 1) % n], v1 = values[i % n], v2 = values[(i + 1) % n], v3 = values[(i + 2) % n]; return Object(__WEBPACK_IMPORTED_MODULE_0__basis__["a" /* basis */])((t - i / n) * n, v0, v1, v2, v3); }; }; /***/ }, /* 92 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony default export */ __webpack_exports__["a"] = function (x) { return function () { return x; }; }; /***/ }, /* 93 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(48); /* harmony default export */__webpack_exports__["a"] = function (a, b) { var nb = b ? b.length : 0, na = a ? Math.min(nb, a.length) : 0, x = new Array(na), c = new Array(nb), i; for (i = 0; i < na; ++i) { x[i] = Object(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[i], b[i]); }for (; i < nb; ++i) { c[i] = b[i]; }return function (t) { for (i = 0; i < na; ++i) { c[i] = x[i](t); }return c; }; }; /***/ }, /* 94 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony default export */ __webpack_exports__["a"] = function (a, b) { var d = new Date(); return a = +a, b -= a, function (t) { return d.setTime(a + b * t), d; }; }; /***/ }, /* 95 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(48); var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; /* harmony default export */__webpack_exports__["a"] = function (a, b) { var i = {}, c = {}, k; if (a === null || (typeof a === "undefined" ? "undefined" : _typeof(a)) !== "object") a = {}; if (b === null || (typeof b === "undefined" ? "undefined" : _typeof(b)) !== "object") b = {}; for (k in b) { if (k in a) { i[k] = Object(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[k], b[k]); } else { c[k] = b[k]; } } return function (t) { for (k in i) { c[k] = i[k](t); }return c; }; }; /***/ }, /* 96 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(29); var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, reB = new RegExp(reA.source, "g"); function zero(b) { return function () { return b; }; } function one(b) { return function (t) { return b(t) + ""; }; } /* harmony default export */__webpack_exports__["a"] = function (a, b) { var bi = reA.lastIndex = reB.lastIndex = 0, // scan index for next number in b am, // current match in a bm, // current match in b bs, // string preceding current number in b, if any i = -1, // index in s s = [], // string constants and placeholders q = []; // number interpolators // Coerce inputs to strings. a = a + "", b = b + ""; // Interpolate pairs of numbers in a & b. while ((am = reA.exec(a)) && (bm = reB.exec(b))) { if ((bs = bm.index) > bi) { // a string precedes the next number in b bs = b.slice(bi, bs); if (s[i]) s[i] += bs; // coalesce with previous string else s[++i] = bs; } if ((am = am[0]) === (bm = bm[0])) { // numbers in a & b match if (s[i]) s[i] += bm; // coalesce with previous string else s[++i] = bm; } else { // interpolate non-matching numbers s[++i] = null; q.push({ i: i, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(am, bm) }); } bi = reB.lastIndex; } // Add remains of b. if (bi < b.length) { bs = b.slice(bi); if (s[i]) s[i] += bs; // coalesce with previous string else s[++i] = bs; } // Special optimization for only a single match. // Otherwise, interpolate each of the numbers and rejoin the string. return s.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function (t) { for (var i = 0, o; i < b; ++i) { s[(o = q[i]).i] = o.x(t); }return s.join(""); }); }; /***/ }, /* 97 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig; var regexDot = /[^\s\,]+/ig; var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i; var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i; var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i; var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig; var numColorCache = {}; function addStop(steps, gradient) { var arr = steps.match(regexColorStop); Util.each(arr, function (item) { item = item.split(':'); gradient.addColorStop(item[0], item[1]); }); } function parseLineGradient(color, self) { var arr = regexLG.exec(color); var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2); var steps = arr[2]; var box = self.getBBox(); var start = void 0; var end = void 0; if (angle >= 0 && angle < 0.5 * Math.PI) { start = { x: box.minX, y: box.minY }; end = { x: box.maxX, y: box.maxY }; } else if (0.5 * Math.PI <= angle && angle < Math.PI) { start = { x: box.maxX, y: box.minY }; end = { x: box.minX, y: box.maxY }; } else if (Math.PI <= angle && angle < 1.5 * Math.PI) { start = { x: box.maxX, y: box.maxY }; end = { x: box.minX, y: box.minY }; } else { start = { x: box.minX, y: box.maxY }; end = { x: box.maxX, y: box.minY }; } var tanTheta = Math.tan(angle); var tanTheta2 = tanTheta * tanTheta; var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x; var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y; var context = self.get('context'); var gradient = context.createLinearGradient(start.x, start.y, x, y); addStop(steps, gradient); return gradient; } function parseRadialGradient(color, self) { var arr = regexRG.exec(color); var fx = parseFloat(arr[1]); var fy = parseFloat(arr[2]); var fr = parseFloat(arr[3]); var steps = arr[4]; var box = self.getBBox(); var context = self.get('context'); var width = box.maxX - box.minX; var height = box.maxY - box.minY; var r = Math.sqrt(width * width + height * height) / 2; var gradient = context.createRadialGradient(box.minX + width * fx, box.minY + height * fy, fr * r, box.minX + width / 2, box.minY + height / 2, r); addStop(steps, gradient); return gradient; } function parsePattern(color, self) { if (self.get('patternSource') && self.get('patternSource') === color) { return self.get('pattern'); } var pattern = void 0; var img = void 0; var arr = regexPR.exec(color); var repeat = arr[1]; var source = arr[2]; // Function to be called when pattern loads function onload() { // Create pattern var context = self.get('context'); pattern = context.createPattern(img, repeat); self.setSilent('pattern', pattern); // be a cache self.setSilent('patternSource', color); } switch (repeat) { case 'a': repeat = 'repeat'; break; case 'x': repeat = 'repeat-x'; break; case 'y': repeat = 'repeat-y'; break; case 'n': repeat = 'no-repeat'; break; default: repeat = 'no-repeat'; } img = new Image(); // If source URL is not a data URL if (!source.match(/^data:/i)) { // Set crossOrigin for this image img.crossOrigin = 'Anonymous'; } img.src = source; if (img.complete) { onload(); } else { img.onload = onload; // Fix onload() bug in IE9 img.src = img.src; } return pattern; } module.exports = { parsePath: function parsePath(path) { path = path || []; if (Util.isArray(path)) { return path; } if (Util.isString(path)) { path = path.match(regexTags); Util.each(path, function (item, index) { item = item.match(regexDot); if (item[0].length > 1) { var tag = item[0].charAt(0); item.splice(1, 0, item[0].substr(1)); item[0] = tag; } Util.each(item, function (sub, i) { if (!isNaN(sub)) { item[i] = +sub; } }); path[index] = item; }); return path; } }, parseStyle: function parseStyle(color, self) { if (Util.isString(color)) { if (color[1] === '(' || color[2] === '(') { if (color[0] === 'l') { // regexLG.test(color) return parseLineGradient(color, self); } else if (color[0] === 'r') { // regexRG.test(color) return parseRadialGradient(color, self); } else if (color[0] === 'p') { // regexPR.test(color) return parsePattern(color, self); } } return color; } }, numberToColor: function numberToColor(num) { // 增加缓存 var color = numColorCache[num]; if (!color) { var str = num.toString(16); for (var i = str.length; i < 6; i++) { str = '0' + str; } color = '#' + str; numColorCache[num] = color; } return color; } }; /***/ }, /* 98 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var Rect = function Rect(cfg) { Rect.superclass.constructor.call(this, cfg); }; Rect.ATTRS = { x: 0, y: 0, width: 0, height: 0, radius: 0, lineWidth: 1 }; Util.extend(Rect, Shape); Util.augment(Rect, { canFill: true, canStroke: true, type: 'rect', getDefaultAttrs: function getDefaultAttrs() { return { lineWidth: 1, radius: 0 }; }, calculateBox: function calculateBox() { var self = this; var attrs = self.__attrs; var x = attrs.x; var y = attrs.y; var width = attrs.width; var height = attrs.height; var lineWidth = attrs.lineWidth; var halfWidth = lineWidth / 2; return { minX: x - halfWidth, minY: y - halfWidth, maxX: x + width + halfWidth, maxY: y + height + halfWidth }; }, isPointInPath: function isPointInPath(x, y) { var self = this; var fill = self.hasFill(); var stroke = self.hasStroke(); if (fill && stroke) { return self.__isPointInFill(x, y) || self.__isPointInStroke(x, y); } if (fill) { return self.__isPointInFill(x, y); } if (stroke) { return self.__isPointInStroke(x, y); } return false; }, __isPointInFill: function __isPointInFill(x, y) { var context = this.get('context'); if (!context) return false; this.createPath(); return context.isPointInPath(x, y); }, __isPointInStroke: function __isPointInStroke(x, y) { var self = this; var attrs = self.__attrs; var rx = attrs.x; var ry = attrs.y; var width = attrs.width; var height = attrs.height; var radius = attrs.radius; var lineWidth = attrs.lineWidth; if (radius === 0) { var halfWidth = lineWidth / 2; return Inside.line(rx - halfWidth, ry, rx + width + halfWidth, ry, lineWidth, x, y) || Inside.line(rx + width, ry - halfWidth, rx + width, ry + height + halfWidth, lineWidth, x, y) || Inside.line(rx + width + halfWidth, ry + height, rx - halfWidth, ry + height, lineWidth, x, y) || Inside.line(rx, ry + height + halfWidth, rx, ry - halfWidth, lineWidth, x, y); } return Inside.line(rx + radius, ry, rx + width - radius, ry, lineWidth, x, y) || Inside.line(rx + width, ry + radius, rx + width, ry + height - radius, lineWidth, x, y) || Inside.line(rx + width - radius, ry + height, rx + radius, ry + height, lineWidth, x, y) || Inside.line(rx, ry + height - radius, rx, ry + radius, lineWidth, x, y) || Inside.arcline(rx + width - radius, ry + radius, radius, 1.5 * Math.PI, 2 * Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + width - radius, ry + height - radius, radius, 0, 0.5 * Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + radius, ry + height - radius, radius, 0.5 * Math.PI, Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + radius, ry + radius, radius, Math.PI, 1.5 * Math.PI, false, lineWidth, x, y); }, createPath: function createPath(context) { var self = this; var attrs = self.__attrs; var x = attrs.x; var y = attrs.y; var width = attrs.width; var height = attrs.height; var radius = attrs.radius; context = context || self.get('context'); context.beginPath(); if (radius === 0) { // 改成原生的rect方法 context.rect(x, y, width, height); } else { context.moveTo(x + radius, y); context.lineTo(x + width - radius, y); context.arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0, false); context.lineTo(x + width, y + height - radius); context.arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2, false); context.lineTo(x + radius, y + height); context.arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI, false); context.lineTo(x, y + radius); context.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 3 / 2, false); context.closePath(); } } }); module.exports = Rect; /***/ }, /* 99 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var Circle = function Circle(cfg) { Circle.superclass.constructor.call(this, cfg); }; Circle.ATTRS = { x: 0, y: 0, r: 0, lineWidth: 1 }; Util.extend(Circle, Shape); Util.augment(Circle, { canFill: true, canStroke: true, type: 'circle', getDefaultAttrs: function getDefaultAttrs() { return { lineWidth: 1 }; }, calculateBox: function calculateBox() { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var r = attrs.r; var lineWidth = attrs.lineWidth; var halfWidth = lineWidth / 2 + r; return { minX: cx - halfWidth, minY: cy - halfWidth, maxX: cx + halfWidth, maxY: cy + halfWidth }; }, isPointInPath: function isPointInPath(x, y) { var fill = this.hasFill(); var stroke = this.hasStroke(); if (fill && stroke) { return this.__isPointInFill(x, y) || this.__isPointInStroke(x, y); } if (fill) { return this.__isPointInFill(x, y); } if (stroke) { return this.__isPointInStroke(x, y); } return false; }, __isPointInFill: function __isPointInFill(x, y) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var r = attrs.r; return Inside.circle(cx, cy, r, x, y); }, __isPointInStroke: function __isPointInStroke(x, y) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var r = attrs.r; var lineWidth = attrs.lineWidth; return Inside.arcline(cx, cy, r, 0, Math.PI * 2, false, lineWidth, x, y); }, createPath: function createPath(context) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var r = attrs.r; context = context || self.get('context'); context.beginPath(); context.arc(cx, cy, r, 0, Math.PI * 2, false); } }); module.exports = Circle; /***/ }, /* 100 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var mat3 = __webpack_require__(3).mat3; var vec3 = __webpack_require__(3).vec3; var Ellipse = function Ellipse(cfg) { Ellipse.superclass.constructor.call(this, cfg); }; Ellipse.ATTRS = { x: 0, y: 0, rx: 1, ry: 1, lineWidth: 1 }; Util.extend(Ellipse, Shape); Util.augment(Ellipse, { canFill: true, canStroke: true, type: 'ellipse', getDefaultAttrs: function getDefaultAttrs() { return { lineWidth: 1 }; }, calculateBox: function calculateBox() { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var rx = attrs.rx; var ry = attrs.ry; var lineWidth = attrs.lineWidth; var halfXWidth = rx + lineWidth / 2; var halfYWidth = ry + lineWidth / 2; return { minX: cx - halfXWidth, minY: cy - halfYWidth, maxX: cx + halfXWidth, maxY: cy + halfYWidth }; }, isPointInPath: function isPointInPath(x, y) { var fill = this.hasFill(); var stroke = this.hasStroke(); if (fill && stroke) { return this.__isPointInFill(x, y) || this.__isPointInStroke(x, y); } if (fill) { return this.__isPointInFill(x, y); } if (stroke) { return this.__isPointInStroke(x, y); } return false; }, __isPointInFill: function __isPointInFill(x, y) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var rx = attrs.rx; var ry = attrs.ry; var r = rx > ry ? rx : ry; var scaleX = rx > ry ? 1 : rx / ry; var scaleY = rx > ry ? ry / rx : 1; var p = [x, y, 1]; var m = [1, 0, 0, 0, 1, 0, 0, 0, 1]; mat3.scale(m, m, [scaleX, scaleY]); mat3.translate(m, m, [cx, cy]); var inm = mat3.invert([], m); vec3.transformMat3(p, p, inm); return Inside.circle(0, 0, r, p[0], p[1]); }, __isPointInStroke: function __isPointInStroke(x, y) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var rx = attrs.rx; var ry = attrs.ry; var lineWidth = attrs.lineWidth; var r = rx > ry ? rx : ry; var scaleX = rx > ry ? 1 : rx / ry; var scaleY = rx > ry ? ry / rx : 1; var p = [x, y, 1]; var m = [1, 0, 0, 0, 1, 0, 0, 0, 1]; mat3.scale(m, m, [scaleX, scaleY]); mat3.translate(m, m, [cx, cy]); var inm = mat3.invert([], m); vec3.transformMat3(p, p, inm); return Inside.arcline(0, 0, r, 0, Math.PI * 2, false, lineWidth, p[0], p[1]); }, createPath: function createPath(context) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var rx = attrs.rx; var ry = attrs.ry; context = context || self.get('context'); var r = rx > ry ? rx : ry; var scaleX = rx > ry ? 1 : rx / ry; var scaleY = rx > ry ? ry / rx : 1; var m = [1, 0, 0, 0, 1, 0, 0, 0, 1]; mat3.scale(m, m, [scaleX, scaleY]); mat3.translate(m, m, [cx, cy]); context.beginPath(); context.save(); context.transform(m[0], m[1], m[3], m[4], m[6], m[7]); context.arc(0, 0, r, 0, Math.PI * 2); context.restore(); context.closePath(); } }); module.exports = Ellipse; /***/ }, /* 101 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var PathSegment = __webpack_require__(263); var Format = __webpack_require__(97); var Arrow = __webpack_require__(15); var PathUtil = __webpack_require__(46); var CubicMath = __webpack_require__(30); var Path = function Path(cfg) { Path.superclass.constructor.call(this, cfg); }; Path.ATTRS = { path: null, lineWidth: 1, curve: null, // 曲线path tCache: null, startArrow: false, endArrow: false }; Util.extend(Path, Shape); Util.augment(Path, { canFill: true, canStroke: true, type: 'path', getDefaultAttrs: function getDefaultAttrs() { return { lineWidth: 1, startArrow: false, endArrow: false }; }, __afterSetAttrPath: function __afterSetAttrPath(path) { var self = this; if (Util.isNil(path)) { self.setSilent('segments', null); self.setSilent('box', undefined); return; } var pathArray = Format.parsePath(path); var preSegment = void 0; var segments = []; if (!Util.isArray(pathArray) || pathArray.length === 0 || pathArray[0][0] !== 'M' && pathArray[0][0] !== 'm') { return; } var count = pathArray.length; for (var i = 0; i < pathArray.length; i++) { var item = pathArray[i]; preSegment = new PathSegment(item, preSegment, i === count - 1); segments.push(preSegment); } self.setSilent('segments', segments); self.set('tCache', null); this.setSilent('box', null); }, __afterSetAttrAll: function __afterSetAttrAll(objs) { if (objs.path) { this.__afterSetAttrPath(objs.path); } }, calculateBox: function calculateBox() { var self = this; var attrs = self.__attrs; var lineWidth = attrs.lineWidth; var lineAppendWidth = attrs.lineAppendWidth || 0; var segments = self.get('segments'); if (!segments) { return null; } lineWidth += lineAppendWidth; var minX = Infinity; var maxX = -Infinity; var minY = Infinity; var maxY = -Infinity; Util.each(segments, function (segment) { segment.getBBox(lineWidth); var box = segment.box; if (box) { if (box.minX < minX) { minX = box.minX; } if (box.maxX > maxX) { maxX = box.maxX; } if (box.minY < minY) { minY = box.minY; } if (box.maxY > maxY) { maxY = box.maxY; } } }); return { minX: minX, minY: minY, maxX: maxX, maxY: maxY }; }, isPointInPath: function isPointInPath(x, y) { var self = this; var fill = self.hasFill(); var stroke = self.hasStroke(); if (fill && stroke) { return self.__isPointInFill(x, y) || self.__isPointInStroke(x, y); } if (fill) { return self.__isPointInFill(x, y); } if (stroke) { return self.__isPointInStroke(x, y); } return false; }, __isPointInFill: function __isPointInFill(x, y) { var self = this; var context = self.get('context'); if (!context) return undefined; self.createPath(); return context.isPointInPath(x, y); }, __isPointInStroke: function __isPointInStroke(x, y) { var self = this; var segments = self.get('segments'); if (!Util.isEmpty(segments)) { var attrs = self.__attrs; var lineWidth = attrs.lineWidth; var appendWidth = attrs.lineAppendWidth || 0; lineWidth += appendWidth; for (var i = 0, l = segments.length; i < l; i++) { if (segments[i].isInside(x, y, lineWidth)) { return true; } } } return false; }, __setTcache: function __setTcache() { var totalLength = 0; var tempLength = 0; var tCache = []; var segmentT = void 0; var segmentL = void 0; var segmentN = void 0; var l = void 0; var curve = this.curve; if (!curve) { return; } Util.each(curve, function (segment, i) { segmentN = curve[i + 1]; l = segment.length; if (segmentN) { totalLength += CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]); } }); Util.each(curve, function (segment, i) { segmentN = curve[i + 1]; l = segment.length; if (segmentN) { segmentT = []; segmentT[0] = tempLength / totalLength; segmentL = CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]); tempLength += segmentL; segmentT[1] = tempLength / totalLength; tCache.push(segmentT); } }); this.tCache = tCache; }, __calculateCurve: function __calculateCurve() { var self = this; var attrs = self.__attrs; var path = attrs.path; this.curve = PathUtil.pathTocurve(path); }, getPoint: function getPoint(t) { var tCache = this.tCache; var subt = void 0; var index = void 0; if (!tCache) { this.__calculateCurve(); this.__setTcache(); tCache = this.tCache; } var curve = this.curve; if (!tCache) { if (curve) { return { x: curve[0][1], y: curve[0][2] }; } return null; } Util.each(tCache, function (v, i) { if (t >= v[0] && t <= v[1]) { subt = (t - v[0]) / (v[1] - v[0]); index = i; } }); var seg = curve[index]; if (Util.isNil(seg) || Util.isNil(index)) { return null; } var l = seg.length; var nextSeg = curve[index + 1]; return { x: CubicMath.at(seg[l - 2], nextSeg[1], nextSeg[3], nextSeg[5], 1 - subt), y: CubicMath.at(seg[l - 1], nextSeg[2], nextSeg[4], nextSeg[6], 1 - subt) }; }, createPath: function createPath(context) { var self = this; var attrs = self.__attrs; var segments = self.get('segments'); if (!Util.isArray(segments)) return; context = context || self.get('context'); context.beginPath(); var path = attrs.path; var startPoint = void 0; var endPoint = void 0; var closed = false; if (path[path.length - 1] === 'z' || path[path.length - 1] === 'Z' || attrs.fill) { // 闭合路径不绘制箭头 closed = true; } var segmentsLen = segments.length; if (segmentsLen > 1 && !closed) { startPoint = segments[0].endPoint; endPoint = segments[1].endPoint; Arrow.addStartArrow(context, attrs, endPoint.x, endPoint.y, startPoint.x, startPoint.y); } for (var i = 0, l = segmentsLen; i < l; i++) { segments[i].draw(context); } if (segmentsLen > 1 && !closed) { startPoint = segments[segmentsLen - 2].endPoint; endPoint = segments[segmentsLen - 1].endPoint; Arrow.addEndArrow(context, attrs, startPoint.x, startPoint.y, endPoint.x, endPoint.y); } } }); module.exports = Path; /***/ }, /* 102 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var CText = function CText(cfg) { CText.superclass.constructor.call(this, cfg); }; CText.ATTRS = { x: 0, y: 0, text: null, fontSize: 12, fontFamily: 'sans-serif', fontStyle: 'normal', fontWeight: 'normal', fontVariant: 'normal', textAlign: 'start', textBaseline: 'bottom', lineHeight: null, textArr: null }; Util.extend(CText, Shape); Util.augment(CText, { canFill: true, canStroke: true, type: 'text', getDefaultAttrs: function getDefaultAttrs() { return { lineWidth: 1, lineCount: 1, fontSize: 12, fontFamily: 'sans-serif', fontStyle: 'normal', fontWeight: 'normal', fontVariant: 'normal', textAlign: 'start', textBaseline: 'bottom' }; }, initTransform: function initTransform() { this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]); var fontSize = this.__attrs.fontSize; if (fontSize && +fontSize < 12) { // 小于 12 像素的文本进行 scale 处理 this.transform([['t', -1 * this.__attrs.x, -1 * this.__attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', this.__attrs.x, this.__attrs.y]]); } }, __assembleFont: function __assembleFont() { // var self = this; var attrs = this.__attrs; var fontSize = attrs.fontSize; var fontFamily = attrs.fontFamily; var fontWeight = attrs.fontWeight; var fontStyle = attrs.fontStyle; // self.attr('fontStyle'); var fontVariant = attrs.fontVariant; // self.attr('fontVariant'); // self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ')); attrs.font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '); }, __afterSetAttrFontSize: function __afterSetAttrFontSize() { /* this.attr({ height: this.__getTextHeight() }); */ this.__assembleFont(); }, __afterSetAttrFontFamily: function __afterSetAttrFontFamily() { this.__assembleFont(); }, __afterSetAttrFontWeight: function __afterSetAttrFontWeight() { this.__assembleFont(); }, __afterSetAttrFontStyle: function __afterSetAttrFontStyle() { this.__assembleFont(); }, __afterSetAttrFontVariant: function __afterSetAttrFontVariant() { this.__assembleFont(); }, __afterSetAttrFont: function __afterSetAttrFont() { // this.attr('width', this.measureText()); }, __afterSetAttrText: function __afterSetAttrText() { var attrs = this.__attrs; var text = attrs.text; var textArr = void 0; if (Util.isString(text) && text.indexOf('\n') !== -1) { textArr = text.split('\n'); var lineCount = textArr.length; attrs.lineCount = lineCount; attrs.textArr = textArr; } // attrs.height = this.__getTextHeight(); // attrs.width = this.measureText(); }, __getTextHeight: function __getTextHeight() { var attrs = this.__attrs; var lineCount = attrs.lineCount; var fontSize = attrs.fontSize * 1; if (lineCount > 1) { var spaceingY = this.__getSpaceingY(); return fontSize * lineCount + spaceingY * (lineCount - 1); } return fontSize; }, // 计算浪费,效率低,待优化 __afterSetAttrAll: function __afterSetAttrAll(objs) { var self = this; if ('fontSize' in objs || 'fontWeight' in objs || 'fontStyle' in objs || 'fontVariant' in objs || 'fontFamily' in objs) { self.__assembleFont(); } if ('text' in objs) { self.__afterSetAttrText(objs.text); } }, isHitBox: function isHitBox() { return false; }, calculateBox: function calculateBox() { var self = this; var attrs = self.__attrs; var x = attrs.x; var y = attrs.y; var width = self.measureText(); // attrs.width if (!width) { // 如果width不存在,四点共其实点 return { minX: x, minY: y, maxX: x, maxY: y }; } var height = self.__getTextHeight(); // attrs.height var textAlign = attrs.textAlign; var textBaseline = attrs.textBaseline; var lineWidth = attrs.lineWidth; var point = { x: x, y: y - height }; if (textAlign) { if (textAlign === 'end' || textAlign === 'right') { point.x -= width; } else if (textAlign === 'center') { point.x -= width / 2; } } if (textBaseline) { if (textBaseline === 'top') { point.y += height; } else if (textBaseline === 'middle') { point.y += height / 2; } } this.set('startPoint', point); var halfWidth = lineWidth / 2; return { minX: point.x - halfWidth, minY: point.y - halfWidth, maxX: point.x + width + halfWidth, maxY: point.y + height + halfWidth }; }, __getSpaceingY: function __getSpaceingY() { var attrs = this.__attrs; var lineHeight = attrs.lineHeight; var fontSize = attrs.fontSize * 1; return lineHeight ? lineHeight - fontSize : fontSize * 0.14; }, isPointInPath: function isPointInPath(x, y) { var self = this; var box = self.getBBox(); if (self.hasFill() || self.hasStroke()) { return Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y); } }, drawInner: function drawInner(context) { var self = this; var attrs = self.__attrs; var text = attrs.text; if (!text) { return; } var textArr = attrs.textArr; var fontSize = attrs.fontSize * 1; var spaceingY = self.__getSpaceingY(); var x = attrs.x; var y = attrs.y; var textBaseline = attrs.textBaseline; var height = void 0; if (textArr) { var box = self.getBBox(); height = box.maxY - box.minY; } var subY = void 0; context.beginPath(); if (self.hasFill()) { var fillOpacity = attrs.fillOpacity; if (!Util.isNil(fillOpacity) && fillOpacity !== 1) { context.globalAlpha = fillOpacity; } if (textArr) { Util.each(textArr, function (subText, index) { subY = y + index * (spaceingY + fontSize) - height + fontSize; // bottom; if (textBaseline === 'middle') subY += height - fontSize - (height - fontSize) / 2; if (textBaseline === 'top') subY += height - fontSize; context.fillText(subText, x, subY); }); } else { context.fillText(text, x, y); } } if (self.hasStroke()) { if (textArr) { Util.each(textArr, function (subText, index) { subY = y + index * (spaceingY + fontSize) - height + fontSize; // bottom; if (textBaseline === 'middle') subY += height - fontSize - (height - fontSize) / 2; if (textBaseline === 'top') subY += height - fontSize; context.strokeText(subText, x, subY); }); } else { context.strokeText(text, x, y); } } }, measureText: function measureText() { var self = this; var attrs = self.__attrs; var text = attrs.text; var font = attrs.font; var textArr = attrs.textArr; var measureWidth = void 0; var width = 0; if (Util.isNil(text)) return undefined; var context = document.createElement('canvas').getContext('2d'); context.save(); context.font = font; if (textArr) { Util.each(textArr, function (subText) { measureWidth = context.measureText(subText).width; if (width < measureWidth) { width = measureWidth; } context.restore(); }); } else { width = context.measureText(text).width; context.restore(); } return width; } }); module.exports = CText; /***/ }, /* 103 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var Arrow = __webpack_require__(15); var LineMath = __webpack_require__(52); var Line = function Line(cfg) { Line.superclass.constructor.call(this, cfg); }; Line.ATTRS = { x1: 0, y1: 0, x2: 0, y2: 0, lineWidth: 1, startArrow: false, endArrow: false }; Util.extend(Line, Shape); Util.augment(Line, { canStroke: true, type: 'line', getDefaultAttrs: function getDefaultAttrs() { return { lineWidth: 1, startArrow: false, endArrow: false }; }, calculateBox: function calculateBox() { var attrs = this.__attrs; var x1 = attrs.x1, y1 = attrs.y1, x2 = attrs.x2, y2 = attrs.y2, lineWidth = attrs.lineWidth; return LineMath.box(x1, y1, x2, y2, lineWidth); }, isPointInPath: function isPointInPath(x, y) { var attrs = this.__attrs; var x1 = attrs.x1, y1 = attrs.y1, x2 = attrs.x2, y2 = attrs.y2, lineWidth = attrs.lineWidth; if (this.hasStroke()) { return Inside.line(x1, y1, x2, y2, lineWidth, x, y); } return false; }, createPath: function createPath(context) { var attrs = this.__attrs; var x1 = attrs.x1, y1 = attrs.y1, x2 = attrs.x2, y2 = attrs.y2; context = context || self.get('context'); context.beginPath(); Arrow.addStartArrow(context, attrs, x1, y1, x2, y2); context.moveTo(x1, y1); context.lineTo(x2, y2); Arrow.addEndArrow(context, attrs, x2, y2, x1, y1); }, getPoint: function getPoint(t) { var attrs = this.__attrs; return { x: LineMath.at(attrs.x1, attrs.x2, t), y: LineMath.at(attrs.y1, attrs.y2, t) }; } }); module.exports = Line; /***/ }, /* 104 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var CImage = function CImage(cfg) { CImage.superclass.constructor.call(this, cfg); }; CImage.ATTRS = { x: 0, y: 0, img: undefined, width: 0, height: 0, sx: null, sy: null, swidth: null, sheight: null }; Util.extend(CImage, Shape); Util.augment(CImage, { type: 'image', __afterSetAttrImg: function __afterSetAttrImg(img) { this.__setAttrImg(img); }, __afterSetAttrAll: function __afterSetAttrAll(params) { if (params.img) { this.__setAttrImg(params.img); } }, isHitBox: function isHitBox() { return false; }, calculateBox: function calculateBox() { var attrs = this.__attrs; var x = attrs.x; var y = attrs.y; var width = attrs.width; var height = attrs.height; return { minX: x, minY: y, maxX: x + width, maxY: y + height }; }, isPointInPath: function isPointInPath(x, y) { var attrs = this.__attrs; if (this.get('toDraw') || !attrs.img) { return false; } var rx = attrs.x; var ry = attrs.y; var width = attrs.width; var height = attrs.height; return Inside.rect(rx, ry, width, height, x, y); }, __setLoading: function __setLoading(loading) { var canvas = this.get('canvas'); if (loading === false && this.get('toDraw') === true) { this.__cfg.loading = false; canvas.draw(); } return loading; }, __setAttrImg: function __setAttrImg(img) { var self = this; var attrs = self.__attrs; if (Util.isString(img)) { var image = new Image(); image.onload = function () { if (self.get('destroyed')) return false; self.attr('imgSrc', img); self.attr('img', image); var callback = self.get('callback'); if (callback) { callback.call(self); } self.set('loading', false); }; image.src = img; self.set('loading', true); } else if (img instanceof Image) { if (!attrs.width) { self.attr('width', img.width); } if (!attrs.height) { self.attr('height', img.height); } return img; } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') { if (!attrs.width) { self.attr('width', Number(img.getAttribute('width'))); } if (!attrs.height) { self.attr('height', Number(img.getAttribute('height'))); } return img; } else if (img instanceof ImageData) { if (!attrs.width) { self.attr('width', img.width); } if (!attrs.height) { self.attr('height', img.height); } return img; } else { return null; } }, drawInner: function drawInner(context) { if (this.get('loading')) { this.set('toDraw', true); return; } this.__drawImage(context); }, __drawImage: function __drawImage(context) { var attrs = this.__attrs; var x = attrs.x; var y = attrs.y; var img = attrs.img; var width = attrs.width; var height = attrs.height; var sx = attrs.sx; var sy = attrs.sy; var swidth = attrs.swidth; var sheight = attrs.sheight; this.set('toDraw', false); if (img instanceof Image || img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') { if (Util.isNil(sx) || Util.isNil(sy) || Util.isNil(swidth) || Util.isNil(sheight)) { context.drawImage(img, x, y, width, height); return; } if (!Util.isNil(sx) && !Util.isNil(sy) && !Util.isNil(swidth) && !Util.isNil(sheight)) { context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height); return; } } else if (img instanceof ImageData) { context.putImageData(img, x, y, sx || 0, sy || 0, swidth || width, sheight || height); return; } return; } }); module.exports = CImage; /***/ }, /* 105 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var Polygon = function Polygon(cfg) { Polygon.superclass.constructor.call(this, cfg); }; Polygon.ATTRS = { points: null, lineWidth: 1 }; Util.extend(Polygon, Shape); Util.augment(Polygon, { canFill: true, canStroke: true, type: 'polygon', getDefaultAttrs: function getDefaultAttrs() { return { lineWidth: 1 }; }, calculateBox: function calculateBox() { var self = this; var attrs = self.__attrs; var points = attrs.points; var lineWidth = attrs.lineWidth; if (!points || points.length === 0) { return null; } var minX = Infinity; var minY = Infinity; var maxX = -Infinity; var maxY = -Infinity; Util.each(points, function (point) { var x = point[0]; var y = point[1]; if (x < minX) { minX = x; } if (x > maxX) { maxX = x; } if (y < minY) { minY = y; } if (y > maxY) { maxY = y; } }); var halfWidth = lineWidth / 2; return { minX: minX - halfWidth, minY: minY - halfWidth, maxX: maxX + halfWidth, maxY: maxY + halfWidth }; }, isPointInPath: function isPointInPath(x, y) { var self = this; var fill = self.hasFill(); var stroke = self.hasStroke(); if (fill && stroke) { return self.__isPointInFill(x, y) || self.__isPointInStroke(x, y); } if (fill) { return self.__isPointInFill(x, y); } if (stroke) { return self.__isPointInStroke(x, y); } return false; }, __isPointInFill: function __isPointInFill(x, y) { var self = this; var context = self.get('context'); self.createPath(); return context.isPointInPath(x, y); }, __isPointInStroke: function __isPointInStroke(x, y) { var self = this; var attrs = self.__attrs; var points = attrs.points; if (points.length < 2) { return false; } var lineWidth = attrs.lineWidth; var outPoints = points.slice(0); if (points.length >= 3) { outPoints.push(points[0]); } return Inside.polyline(outPoints, lineWidth, x, y); }, createPath: function createPath(context) { var self = this; var attrs = self.__attrs; var points = attrs.points; if (points.length < 2) { return; } context = context || self.get('context'); context.beginPath(); Util.each(points, function (point, index) { if (index === 0) { context.moveTo(point[0], point[1]); } else { context.lineTo(point[0], point[1]); } }); context.closePath(); } }); module.exports = Polygon; /***/ }, /* 106 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var Arrow = __webpack_require__(15); var LineMath = __webpack_require__(52); var Polyline = function Polyline(cfg) { Polyline.superclass.constructor.call(this, cfg); }; Polyline.ATTRS = { points: null, lineWidth: 1, startArrow: false, endArrow: false, tCache: null }; Util.extend(Polyline, Shape); Util.augment(Polyline, { canStroke: true, type: 'polyline', tCache: null, // 缓存各点的t getDefaultAttrs: function getDefaultAttrs() { return { lineWidth: 1, startArrow: false, endArrow: false }; }, calculateBox: function calculateBox() { var self = this; var attrs = self.__attrs; var lineWidth = attrs.lineWidth; var points = attrs.points; if (!points || points.length === 0) { return null; } var minX = Infinity; var minY = Infinity; var maxX = -Infinity; var maxY = -Infinity; Util.each(points, function (point) { var x = point[0]; var y = point[1]; if (x < minX) { minX = x; } if (x > maxX) { maxX = x; } if (y < minY) { minY = y; } if (y > maxY) { maxY = y; } }); var halfWidth = lineWidth / 2; return { minX: minX - halfWidth, minY: minY - halfWidth, maxX: maxX + halfWidth, maxY: maxY + halfWidth }; }, __setTcache: function __setTcache() { var self = this; var attrs = self.__attrs; var points = attrs.points; var totalLength = 0; var tempLength = 0; var tCache = []; var segmentT = void 0; var segmentL = void 0; if (!points || points.length === 0) { return; } Util.each(points, function (p, i) { if (points[i + 1]) { totalLength += LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]); } }); if (totalLength <= 0) { return; } Util.each(points, function (p, i) { if (points[i + 1]) { segmentT = []; segmentT[0] = tempLength / totalLength; segmentL = LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]); tempLength += segmentL; segmentT[1] = tempLength / totalLength; tCache.push(segmentT); } }); this.tCache = tCache; }, isPointInPath: function isPointInPath(x, y) { var self = this; var attrs = self.__attrs; if (self.hasStroke()) { var points = attrs.points; if (points.length < 2) { return false; } var lineWidth = attrs.lineWidth; return Inside.polyline(points, lineWidth, x, y); } return false; }, createPath: function createPath(context) { var self = this; var attrs = self.__attrs; var points = attrs.points; var l = void 0; var i = void 0; if (points.length < 2) { return; } context = context || self.get('context'); context.beginPath(); Arrow.addStartArrow(context, attrs, points[1][0], points[1][1], points[0][0], points[0][1]); context.moveTo(points[0][0], points[0][1]); for (i = 1, l = points.length - 1; i < l; i++) { context.lineTo(points[i][0], points[i][1]); } context.lineTo(points[l][0], points[l][1]); Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]); }, getPoint: function getPoint(t) { var attrs = this.__attrs; var points = attrs.points; var tCache = this.tCache; var subt = void 0; var index = void 0; if (!tCache) { this.__setTcache(); tCache = this.tCache; } Util.each(tCache, function (v, i) { if (t >= v[0] && t <= v[1]) { subt = (t - v[0]) / (v[1] - v[0]); index = i; } }); return { x: LineMath.at(points[index][0], points[index + 1][0], subt), y: LineMath.at(points[index][1], points[index + 1][1], subt) }; } }); module.exports = Polyline; /***/ }, /* 107 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var ArcMath = __webpack_require__(54); var Arrow = __webpack_require__(15); function _getArcX(x, radius, angle) { return x + radius * Math.cos(angle); } function _getArcY(y, radius, angle) { return y + radius * Math.sin(angle); } var Arc = function Arc(cfg) { Arc.superclass.constructor.call(this, cfg); }; Arc.ATTRS = { x: 0, y: 0, r: 0, startAngle: 0, endAngle: 0, clockwise: false, lineWidth: 1, startArrow: false, endArrow: false }; Util.extend(Arc, Shape); Util.augment(Arc, { canStroke: true, type: 'arc', getDefaultAttrs: function getDefaultAttrs() { return { x: 0, y: 0, r: 0, startAngle: 0, endAngle: 0, clockwise: false, lineWidth: 1, startArrow: false, endArrow: false }; }, calculateBox: function calculateBox() { var attrs = this.__attrs; var x = attrs.x, y = attrs.y, r = attrs.r, startAngle = attrs.startAngle, endAngle = attrs.endAngle, clockwise = attrs.clockwise, lineWidth = attrs.lineWidth; var halfWidth = lineWidth / 2; var box = ArcMath.box(x, y, r, startAngle, endAngle, clockwise); box.minX -= halfWidth; box.minY -= halfWidth; box.maxX += halfWidth; box.maxY += halfWidth; return box; }, isPointInPath: function isPointInPath(x, y) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var r = attrs.r, startAngle = attrs.startAngle, endAngle = attrs.endAngle, clockwise = attrs.clockwise, lineWidth = attrs.lineWidth; if (this.hasStroke()) { return Inside.arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y); } return false; }, createPath: function createPath(context) { var attrs = this.__attrs; var x = attrs.x, y = attrs.y, r = attrs.r, startAngle = attrs.startAngle, endAngle = attrs.endAngle, clockwise = attrs.clockwise; var diff = void 0; var x1 = void 0; var y1 = void 0; var x2 = void 0; var y2 = void 0; context = context || self.get('context'); context.beginPath(); if (attrs.startArrow) { diff = Math.PI / 180; if (clockwise) { diff *= -1; } // Calculate coordinates for start arrow x1 = _getArcX(x, r, startAngle + diff); y1 = _getArcY(y, r, startAngle + diff); x2 = _getArcX(x, r, startAngle); y2 = _getArcY(y, r, startAngle); Arrow.addStartArrow(context, attrs, x1, y1, x2, y2); } context.arc(x, y, r, startAngle, endAngle, clockwise); if (attrs.endArrow) { diff = Math.PI / 180; if (clockwise) { diff *= -1; } // Calculate coordinates for start arrow x1 = _getArcX(x, r, endAngle + diff); y1 = _getArcY(y, r, endAngle + diff); x2 = _getArcX(x, r, endAngle); y2 = _getArcY(y, r, endAngle); Arrow.addEndArrow(context, attrs, x2, y2, x1, y1); } } }); module.exports = Arc; /***/ }, /* 108 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var ArcMath = __webpack_require__(54); var vec2 = __webpack_require__(3).vec2; var Fan = function Fan(cfg) { Fan.superclass.constructor.call(this, cfg); }; Fan.ATTRS = { x: 0, y: 0, rs: 0, re: 0, startAngle: 0, endAngle: 0, clockwise: false, lineWidth: 1 }; Util.extend(Fan, Shape); Util.augment(Fan, { canFill: true, canStroke: true, type: 'fan', getDefaultAttrs: function getDefaultAttrs() { return { clockwise: false, lineWidth: 1, rs: 0, re: 0 }; }, calculateBox: function calculateBox() { var self = this; var attrs = self.__attrs; var cx = attrs.x; var cy = attrs.y; var rs = attrs.rs; var re = attrs.re; var startAngle = attrs.startAngle; var endAngle = attrs.endAngle; var clockwise = attrs.clockwise; var lineWidth = attrs.lineWidth; var boxs = ArcMath.box(cx, cy, rs, startAngle, endAngle, clockwise); var boxe = ArcMath.box(cx, cy, re, startAngle, endAngle, clockwise); var minX = Math.min(boxs.minX, boxe.minX); var minY = Math.min(boxs.minY, boxe.minY); var maxX = Math.max(boxs.maxX, boxe.maxX); var maxY = Math.max(boxs.maxY, boxe.maxY); var halfWidth = lineWidth / 2; return { minX: minX - halfWidth, minY: minY - halfWidth, maxX: maxX + halfWidth, maxY: maxY + halfWidth }; }, isPointInPath: function isPointInPath(x, y) { var fill = this.hasFill(); var stroke = this.hasStroke(); if (fill && stroke) { return this.__isPointInFill(x, y) || this.__isPointInStroke(x, y); } if (fill) { return this.__isPointInFill(x, y); } if (stroke) { return this.__isPointInStroke(x, y); } return false; }, __isPointInFill: function __isPointInFill(x, y) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var rs = attrs.rs; var re = attrs.re; var startAngle = attrs.startAngle; var endAngle = attrs.endAngle; var clockwise = attrs.clockwise; var v1 = [1, 0]; var subv = [x - cx, y - cy]; var angle = vec2.angleTo(v1, subv); var angle1 = ArcMath.nearAngle(angle, startAngle, endAngle, clockwise); if (Util.isNumberEqual(angle, angle1)) { var ls = vec2.squaredLength(subv); if (rs * rs <= ls && ls <= re * re) { return true; } } return false; }, __isPointInStroke: function __isPointInStroke(x, y) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var rs = attrs.rs; var re = attrs.re; var startAngle = attrs.startAngle; var endAngle = attrs.endAngle; var clockwise = attrs.clockwise; var lineWidth = attrs.lineWidth; var ssp = { x: Math.cos(startAngle) * rs + cx, y: Math.sin(startAngle) * rs + cy }; var sep = { x: Math.cos(startAngle) * re + cx, y: Math.sin(startAngle) * re + cy }; var esp = { x: Math.cos(endAngle) * rs + cx, y: Math.sin(endAngle) * rs + cy }; var eep = { x: Math.cos(endAngle) * re + cx, y: Math.sin(endAngle) * re + cy }; if (Inside.line(ssp.x, ssp.y, sep.x, sep.y, lineWidth, x, y)) { return true; } if (Inside.line(esp.x, esp.y, eep.x, eep.y, lineWidth, x, y)) { return true; } if (Inside.arcline(cx, cy, rs, startAngle, endAngle, clockwise, lineWidth, x, y)) { return true; } if (Inside.arcline(cx, cy, re, startAngle, endAngle, clockwise, lineWidth, x, y)) { return true; } return false; }, createPath: function createPath(context) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var rs = attrs.rs; var re = attrs.re; var startAngle = attrs.startAngle; var endAngle = attrs.endAngle; var clockwise = attrs.clockwise; var ssp = { x: Math.cos(startAngle) * rs + cx, y: Math.sin(startAngle) * rs + cy }; var sep = { x: Math.cos(startAngle) * re + cx, y: Math.sin(startAngle) * re + cy }; var esp = { x: Math.cos(endAngle) * rs + cx, y: Math.sin(endAngle) * rs + cy }; context = context || self.get('context'); context.beginPath(); context.moveTo(ssp.x, ssp.y); context.lineTo(sep.x, sep.y); context.arc(cx, cy, re, startAngle, endAngle, clockwise); context.lineTo(esp.x, esp.y); context.arc(cx, cy, rs, endAngle, startAngle, !clockwise); context.closePath(); } }); module.exports = Fan; /***/ }, /* 109 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var Arrow = __webpack_require__(15); var CubicMath = __webpack_require__(30); var Cubic = function Cubic(cfg) { Cubic.superclass.constructor.call(this, cfg); }; Cubic.ATTRS = { p1: null, // 起始点 p2: null, // 第一个控制点 p3: null, // 第二个控制点 p4: null, // 终点 lineWidth: 1, startArrow: false, endArrow: false }; Util.extend(Cubic, Shape); Util.augment(Cubic, { canStroke: true, type: 'cubic', getDefaultAttrs: function getDefaultAttrs() { return { lineWidth: 1, startArrow: false, endArrow: false }; }, calculateBox: function calculateBox() { var attrs = this.__attrs; var p1 = attrs.p1, p2 = attrs.p2, p3 = attrs.p3, p4 = attrs.p4, lineWidth = attrs.lineWidth; var i = void 0; var l = void 0; if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3) || Util.isNil(p4)) { return null; } var halfWidth = lineWidth / 2; var xDim = CubicMath.extrema(p1[0], p2[0], p3[0], p4[0]); for (i = 0, l = xDim.length; i < l; i++) { xDim[i] = CubicMath.at(p1[0], p2[0], p3[0], p4[0], xDim[i]); } var yDim = CubicMath.extrema(p1[1], p2[1], p3[1], p4[1]); for (i = 0, l = yDim.length; i < l; i++) { yDim[i] = CubicMath.at(p1[1], p2[1], p3[1], p4[1], yDim[i]); } xDim.push(p1[0], p4[0]); yDim.push(p1[1], p4[1]); return { minX: Math.min.apply(Math, xDim) - halfWidth, maxX: Math.max.apply(Math, xDim) + halfWidth, minY: Math.min.apply(Math, yDim) - halfWidth, maxY: Math.max.apply(Math, yDim) + halfWidth }; }, isPointInPath: function isPointInPath(x, y) { var attrs = this.__attrs; var p1 = attrs.p1, p2 = attrs.p2, p3 = attrs.p3, p4 = attrs.p4, lineWidth = attrs.lineWidth; return Inside.cubicline(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], p4[0], p4[1], lineWidth, x, y); }, createPath: function createPath(context) { var attrs = this.__attrs; var p1 = attrs.p1, p2 = attrs.p2, p3 = attrs.p3, p4 = attrs.p4; context = context || self.get('context'); if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3) || Util.isNil(p4)) { return; } context.beginPath(); Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]); context.moveTo(p1[0], p1[1]); context.bezierCurveTo(p2[0], p2[1], p3[0], p3[1], p4[0], p4[1]); Arrow.addEndArrow(context, attrs, p3[0], p3[1], p4[0], p4[1]); }, getPoint: function getPoint(t) { var attrs = this.__attrs; return { x: CubicMath.at(attrs.p4[0], attrs.p3[0], attrs.p2[0], attrs.p1[0], t), y: CubicMath.at(attrs.p4[1], attrs.p3[1], attrs.p2[1], attrs.p1[1], t) }; } }); module.exports = Cubic; /***/ }, /* 110 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var Arrow = __webpack_require__(15); var QuadraticMath = __webpack_require__(53); var Quadratic = function Quadratic(cfg) { Quadratic.superclass.constructor.call(this, cfg); }; Quadratic.ATTRS = { p1: null, // 起始点 p2: null, // 控制点 p3: null, // 结束点 lineWidth: 1, startArrow: false, endArrow: false }; Util.extend(Quadratic, Shape); Util.augment(Quadratic, { canStroke: true, type: 'quadratic', getDefaultAttrs: function getDefaultAttrs() { return { lineWidth: 1, startArrow: false, endArrow: false }; }, calculateBox: function calculateBox() { var self = this; var attrs = self.__attrs; var p1 = attrs.p1, p2 = attrs.p2, p3 = attrs.p3, lineWidth = attrs.lineWidth; var i = void 0; var l = void 0; if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3)) { return null; } var halfWidth = lineWidth / 2; var xDims = QuadraticMath.extrema(p1[0], p2[0], p3[0]); for (i = 0, l = xDims.length; i < l; i++) { xDims[i] = QuadraticMath.at(p1[0], p2[0], p3[0], xDims[i]); } xDims.push(p1[0], p3[0]); var yDims = QuadraticMath.extrema(p1[1], p2[1], p3[1]); for (i = 0, l = yDims.length; i < l; i++) { yDims[i] = QuadraticMath.at(p1[1], p2[1], p3[1], yDims[i]); } yDims.push(p1[1], p3[1]); return { minX: Math.min.apply(Math, xDims) - halfWidth, maxX: Math.max.apply(Math, xDims) + halfWidth, minY: Math.min.apply(Math, yDims) - halfWidth, maxY: Math.max.apply(Math, yDims) + halfWidth }; }, isPointInPath: function isPointInPath(x, y) { var self = this; var attrs = self.__attrs; var p1 = attrs.p1, p2 = attrs.p2, p3 = attrs.p3, lineWidth = attrs.lineWidth; return Inside.quadraticline(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], lineWidth, x, y); }, createPath: function createPath(context) { var self = this; var attrs = self.__attrs; var p1 = attrs.p1, p2 = attrs.p2, p3 = attrs.p3; if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3)) { return; } context = context || self.get('context'); context.beginPath(); Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]); context.moveTo(p1[0], p1[1]); context.quadraticCurveTo(p2[0], p2[1], p3[0], p3[1]); Arrow.addEndArrow(context, attrs, p2[0], p2[1], p3[0], p3[1]); }, getPoint: function getPoint(t) { var attrs = this.__attrs; return { x: QuadraticMath.at(attrs.p1[0], attrs.p2[0], attrs.p3[0], t), y: QuadraticMath.at(attrs.p1[1], attrs.p2[1], attrs.p3[1], t) }; } }); module.exports = Quadratic; /***/ }, /* 111 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Shape = __webpack_require__(1); var Inside = __webpack_require__(2); var Marker = function Marker(cfg) { Marker.superclass.constructor.call(this, cfg); }; Marker.Symbols = { // 圆 circle: function circle(x, y, r, ctx) { ctx.arc(x, y, r, 0, Math.PI * 2, false); }, // 正方形 square: function square(x, y, r, ctx) { ctx.moveTo(x - r, y - r); ctx.lineTo(x + r, y - r); ctx.lineTo(x + r, y + r); ctx.lineTo(x - r, y + r); ctx.closePath(); }, // 菱形 diamond: function diamond(x, y, r, ctx) { ctx.moveTo(x - r, y); ctx.lineTo(x, y - r); ctx.lineTo(x + r, y); ctx.lineTo(x, y + r); ctx.closePath(); }, // 三角形 triangle: function triangle(x, y, r, ctx) { var diffY = r * Math.sin(1 / 3 * Math.PI); ctx.moveTo(x - r, y + diffY); ctx.lineTo(x, y - diffY); ctx.lineTo(x + r, y + diffY); ctx.closePath(); }, // 倒三角形 'triangle-down': function triangleDown(x, y, r, ctx) { var diffY = r * Math.sin(1 / 3 * Math.PI); ctx.moveTo(x - r, y - diffY); ctx.lineTo(x + r, y - diffY); ctx.lineTo(x, y + diffY); ctx.closePath(); } }; Marker.ATTRS = { path: null, lineWidth: 1 }; Util.extend(Marker, Shape); Util.augment(Marker, { type: 'marker', canFill: true, canStroke: true, getDefaultAttrs: function getDefaultAttrs() { return { x: 0, y: 0, lineWidth: 1 }; }, calculateBox: function calculateBox() { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var r = attrs.radius; var lineWidth = attrs.lineWidth; var halfWidth = lineWidth / 2 + r; return { minX: cx - halfWidth, minY: cy - halfWidth, maxX: cx + halfWidth, maxY: cy + halfWidth }; }, isPointInPath: function isPointInPath(x, y) { var attrs = this.__attrs; var cx = attrs.x; var cy = attrs.y; var r = attrs.radius; return Inside.circle(cx, cy, r, x, y); }, createPath: function createPath(context) { var attrs = this.__attrs; var x = attrs.x; var y = attrs.y; var r = attrs.radius; var symbol = attrs.symbol || 'circle'; var method = void 0; if (Util.isFunction(symbol)) { method = symbol; } else { method = Marker.Symbols[symbol]; } context.beginPath(); method(x, y, r, context, this); } }); module.exports = Marker; /***/ }, /* 112 */ /***/function (module, exports, __webpack_require__) { module.exports = { Canvas: __webpack_require__(113), Group: __webpack_require__(87), Shape: __webpack_require__(1), Rect: __webpack_require__(98), Circle: __webpack_require__(99), Ellipse: __webpack_require__(100), Path: __webpack_require__(101), Text: __webpack_require__(102), Line: __webpack_require__(103), Image: __webpack_require__(104), Polygon: __webpack_require__(105), Polyline: __webpack_require__(106), Arc: __webpack_require__(107), Fan: __webpack_require__(108), Cubic: __webpack_require__(109), Quadratic: __webpack_require__(110), Marker: __webpack_require__(111), PathUtil: __webpack_require__(46), MatrixUtil: __webpack_require__(3), DomUtil: __webpack_require__(85), Event: __webpack_require__(86) }; /***/ }, /* 113 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Event = __webpack_require__(86); var Group = __webpack_require__(87); function requestAnimationFrame(fn) { var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) { return setTimeout(fn, 16); }; return method(fn); } var Canvas = function Canvas(cfg) { Canvas.superclass.constructor.call(this, cfg); }; Canvas.CFG = { eventEnable: true, /** * 像素宽度 * @type {Number} */ width: null, /** * 像素高度 * @type {Number} */ height: null, /** * 画布宽度 * @type {Number} */ widthCanvas: null, /** * 画布高度 * @type {Number} */ heightCanvas: null, /** * CSS宽 * @type {String} */ widthStyle: null, /** * CSS高 * @type {String} */ heightStyle: null, /** * 容器DOM * @type {Object} */ containerDOM: null, /** * 当前Canvas的DOM * @type {Object} */ canvasDOM: null, /** * 屏幕像素比 * @type {Number} */ pixelRatio: null }; Util.extend(Canvas, Group); Util.augment(Canvas, { init: function init() { Canvas.superclass.init.call(this); this._setGlobalParam(); this._setDOM(); this._setInitSize(); this._setCanvas(); this._scale(); if (this.get('eventEnable')) { this._registEvents(); } }, getEmitter: function getEmitter(element, event) { if (element) { if (Util.isEmpty(element._getEvents())) { var parent = element.get('parent'); if (parent && !event.propagationStopped) { return this.getEmitter(parent, event); } } else { return element; } } }, _getEventObj: function _getEventObj(type, e, point, target) { var event = new Event(type, e, true, true); event.x = point.x; event.y = point.y; event.clientX = e.clientX; event.clientY = e.clientY; event.currentTarget = target; event.target = target; return event; }, _triggerEvent: function _triggerEvent(type, e) { var point = this.getPointByClient(e.clientX, e.clientY); var shape = this.getShape(point.x, point.y); var emitObj = void 0; if (type === 'mousemove') { var canvasmousemove = this._getEventObj('mousemove', e, point, this); this.emit('mousemove', canvasmousemove); var preShape = this.get('preShape'); if (preShape && preShape !== shape) { var mouseleave = this._getEventObj('mouseleave', e, point, preShape); emitObj = this.getEmitter(preShape, e); emitObj && emitObj.emit('mouseleave', mouseleave); } if (shape) { var mousemove = this._getEventObj('mousemove', e, point, shape); emitObj = this.getEmitter(shape, e); emitObj && emitObj.emit('mousemove', mousemove); if (preShape !== shape) { var mouseenter = this._getEventObj('mouseenter', e, point, shape); emitObj && emitObj.emit('mouseenter', mouseenter, e); } } this.set('preShape', shape); } else { var event = this._getEventObj(type, e, point, shape || this); emitObj = this.getEmitter(shape, e); if (emitObj && emitObj !== this) { emitObj.emit(type, event); } this.emit(type, event); } var el = this.get('el'); if (shape && !shape.get('destroyed')) { el.style.cursor = shape.attr('cursor') || 'default'; } }, _registEvents: function _registEvents() { var self = this; var el = self.get('el'); el.addEventListener('mouseout', function (e) { self._triggerEvent('mouseleave', e); }, false); el.addEventListener('mouseover', function (e) { self._triggerEvent('mouseenter', e); }, false); el.addEventListener('mousemove', function (e) { self._triggerEvent('mousemove', e); }, false); el.addEventListener('mousedown', function (e) { self._triggerEvent('mousedown', e); }, false); el.addEventListener('mouseup', function (e) { self._triggerEvent('mouseup', e); }, false); el.addEventListener('click', function (e) { self._triggerEvent('click', e); }, false); el.addEventListener('dblclick', function (e) { self._triggerEvent('dblclick', e); }, false); el.addEventListener('touchstart', function (e) { if (!Util.isEmpty(e.touches)) { self._triggerEvent('touchstart', e.touches[0]); } }, false); el.addEventListener('touchmove', function (e) { if (!Util.isEmpty(e.touches)) { self._triggerEvent('touchmove', e.touches[0]); } }, false); el.addEventListener('touchend', function (e) { if (!Util.isEmpty(e.changedTouches)) { self._triggerEvent('touchend', e.changedTouches[0]); } }, false); }, _scale: function _scale() { var pixelRatio = this.get('pixelRatio'); this.scale(pixelRatio, pixelRatio); }, _setCanvas: function _setCanvas() { var canvasDOM = this.get('canvasDOM'); this.set('el', canvasDOM); this.set('context', canvasDOM.getContext('2d')); this.set('canvas', this); }, _setGlobalParam: function _setGlobalParam() { var pixelRatio = this.get('pixelRatio'); if (!pixelRatio) { this.set('pixelRatio', Util.getRatio()); } return; }, _setDOM: function _setDOM() { this._setContainer(); this._setLayer(); }, _setContainer: function _setContainer() { var containerId = this.get('containerId'); var containerDOM = this.get('containerDOM'); if (!containerDOM) { containerDOM = document.getElementById(containerId); this.set('containerDOM', containerDOM); } Util.modifyCSS(containerDOM, { position: 'relative' }); }, _setLayer: function _setLayer() { var containerDOM = this.get('containerDOM'); var canvasId = Util.uniqueId('canvas_'); if (containerDOM) { var canvasDOM = Util.createDom(''); containerDOM.appendChild(canvasDOM); this.set('canvasDOM', canvasDOM); } }, _setInitSize: function _setInitSize() { this.changeSize(this.get('width'), this.get('height')); }, _reSize: function _reSize() { var canvasDOM = this.get('canvasDOM'); var widthCanvas = this.get('widthCanvas'); var heightCanvas = this.get('heightCanvas'); var widthStyle = this.get('widthStyle'); var heightStyle = this.get('heightStyle'); canvasDOM.style.width = widthStyle; canvasDOM.style.height = heightStyle; canvasDOM.setAttribute('width', widthCanvas); canvasDOM.setAttribute('height', heightCanvas); }, getWidth: function getWidth() { var pixelRatio = this.get('pixelRatio'); var width = this.get('width'); return width * pixelRatio; }, getHeight: function getHeight() { var pixelRatio = this.get('pixelRatio'); var height = this.get('height'); return height * pixelRatio; }, changeSize: function changeSize(width, height) { var pixelRatio = this.get('pixelRatio'); var widthCanvas = width * pixelRatio; var heightCanvas = height * pixelRatio; this.set('widthCanvas', widthCanvas); this.set('heightCanvas', heightCanvas); this.set('widthStyle', width + 'px'); this.set('heightStyle', height + 'px'); this.set('width', width); this.set('height', height); this._reSize(); }, /** * 将窗口坐标转变成 canvas 坐标 * @param {Number} clientX 窗口x坐标 * @param {Number} clientY 窗口y坐标 * @return {Object} canvas坐标 */ getPointByClient: function getPointByClient(clientX, clientY) { var el = this.get('el'); var bbox = el.getBoundingClientRect(); var width = bbox.right - bbox.left; var height = bbox.bottom - bbox.top; return { x: (clientX - bbox.left) * (el.width / width), y: (clientY - bbox.top) * (el.height / height) }; }, getClientByPoint: function getClientByPoint(x, y) { var el = this.get('el'); var bbox = el.getBoundingClientRect(); var width = bbox.right - bbox.left; var height = bbox.bottom - bbox.top; return { clientX: x / (el.width / width) + bbox.left, clientY: y / (el.height / height) + bbox.top }; }, beforeDraw: function beforeDraw() { var context = this.get('context'); var el = this.get('el'); context && context.clearRect(0, 0, el.width, el.height); }, _beginDraw: function _beginDraw() { this.setSilent('toDraw', true); }, _endDraw: function _endDraw() { this.setSilent('toDraw', false); }, draw: function draw() { var self = this; function drawInner() { self.setSilent('animateHandler', requestAnimationFrame(function () { self.setSilent('animateHandler', undefined); if (self.get('toDraw')) { drawInner(); } })); self.beforeDraw(); try { var context = self.get('context'); Canvas.superclass.draw.call(self, context); // self._drawCanvas(); } catch (ev) { // 绘制时异常,中断重绘 console.warn('error in draw canvas, detail as:'); console.warn(ev); self._endDraw(); } self._endDraw(); } if (self.get('destroyed')) { return; } if (self.get('animateHandler')) { this._beginDraw(); } else { drawInner(); } }, destroy: function destroy() { var containerDOM = this.get('containerDOM'); var canvasDOM = this.get('canvasDOM'); if (canvasDOM && containerDOM) { containerDOM.removeChild(canvasDOM); } Canvas.superclass.destroy.call(this); } }); module.exports = Canvas; /***/ }, /* 114 */ /***/function (module, exports) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; var g; // This works in non-strict mode g = function () { return this; }(); try { // This works if eval is allowed (see CSP) g = g || Function("return this")() || (1, eval)("this"); } catch (e) { // This works if the window reference is available if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }, /* 115 */ /***/function (module, exports, __webpack_require__) { var _Symbol = __webpack_require__(11); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString = objectProto.toString; /** Built-in value references. */ var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; /** * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. * * @private * @param {*} value The value to query. * @returns {string} Returns the raw `toStringTag`. */ function getRawTag(value) { var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; try { value[symToStringTag] = undefined; var unmasked = true; } catch (e) {} var result = nativeObjectToString.call(value); if (unmasked) { if (isOwn) { value[symToStringTag] = tag; } else { delete value[symToStringTag]; } } return result; } module.exports = getRawTag; /***/ }, /* 116 */ /***/function (module, exports) { /** Used for built-in method references. */ var objectProto = Object.prototype; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString = objectProto.toString; /** * Converts `value` to a string using `Object.prototype.toString`. * * @private * @param {*} value The value to convert. * @returns {string} Returns the converted string. */ function objectToString(value) { return nativeObjectToString.call(value); } module.exports = objectToString; /***/ }, /* 117 */ /***/function (module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(7), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var boolTag = '[object Boolean]'; /** * Checks if `value` is classified as a boolean primitive or object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. * @example * * _.isBoolean(false); * // => true * * _.isBoolean(null); * // => false */ function isBoolean(value) { return value === true || value === false || isObjectLike(value) && baseGetTag(value) == boolTag; } module.exports = isBoolean; /***/ }, /* 118 */ /***/function (module, exports) { /** * Checks if `value` is `null` or `undefined`. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is nullish, else `false`. * @example * * _.isNil(null); * // => true * * _.isNil(void 0); * // => true * * _.isNil(NaN); * // => false */ function isNil(value) { return value == null; } module.exports = isNil; /***/ }, /* 119 */ /***/function (module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(7), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var numberTag = '[object Number]'; /** * Checks if `value` is classified as a `Number` primitive or object. * * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are * classified as numbers, use the `_.isFinite` method. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a number, else `false`. * @example * * _.isNumber(3); * // => true * * _.isNumber(Number.MIN_VALUE); * // => true * * _.isNumber(Infinity); * // => true * * _.isNumber('3'); * // => false */ function isNumber(value) { return typeof value == 'number' || isObjectLike(value) && baseGetTag(value) == numberTag; } module.exports = isNumber; /***/ }, /* 120 */ /***/function (module, exports, __webpack_require__) { var baseKeys = __webpack_require__(57), getTag = __webpack_require__(21), isArguments = __webpack_require__(33), isArray = __webpack_require__(6), isArrayLike = __webpack_require__(9), isBuffer = __webpack_require__(17), isPrototype = __webpack_require__(16), isTypedArray = __webpack_require__(22); /** `Object#toString` result references. */ var mapTag = '[object Map]', setTag = '[object Set]'; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Checks if `value` is an empty object, collection, map, or set. * * Objects are considered empty if they have no own enumerable string keyed * properties. * * Array-like values such as `arguments` objects, arrays, buffers, strings, or * jQuery-like collections are considered empty if they have a `length` of `0`. * Similarly, maps and sets are considered empty if they have a `size` of `0`. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is empty, else `false`. * @example * * _.isEmpty(null); * // => true * * _.isEmpty(true); * // => true * * _.isEmpty(1); * // => true * * _.isEmpty([1, 2, 3]); * // => false * * _.isEmpty({ 'a': 1 }); * // => false */ function isEmpty(value) { if (value == null) { return true; } if (isArrayLike(value) && (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || isBuffer(value) || isTypedArray(value) || isArguments(value))) { return !value.length; } var tag = getTag(value); if (tag == mapTag || tag == setTag) { return !value.size; } if (isPrototype(value)) { return !baseKeys(value).length; } for (var key in value) { if (hasOwnProperty.call(value, key)) { return false; } } return true; } module.exports = isEmpty; /***/ }, /* 121 */ /***/function (module, exports, __webpack_require__) { var overArg = __webpack_require__(58); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeKeys = overArg(Object.keys, Object); module.exports = nativeKeys; /***/ }, /* 122 */ /***/function (module, exports, __webpack_require__) { var getNative = __webpack_require__(10), root = __webpack_require__(4); /* Built-in method references that are verified to be native. */ var DataView = getNative(root, 'DataView'); module.exports = DataView; /***/ }, /* 123 */ /***/function (module, exports, __webpack_require__) { var isFunction = __webpack_require__(20), isMasked = __webpack_require__(124), isObject = __webpack_require__(8), toSource = __webpack_require__(59); /** * Used to match `RegExp` * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; /** Used to detect host constructors (Safari). */ var reIsHostCtor = /^\[object .+?Constructor\]$/; /** Used for built-in method references. */ var funcProto = Function.prototype, objectProto = Object.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** Used to detect if a method is native. */ var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'); /** * The base implementation of `_.isNative` without bad shim checks. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a native function, * else `false`. */ function baseIsNative(value) { if (!isObject(value) || isMasked(value)) { return false; } var pattern = isFunction(value) ? reIsNative : reIsHostCtor; return pattern.test(toSource(value)); } module.exports = baseIsNative; /***/ }, /* 124 */ /***/function (module, exports, __webpack_require__) { var coreJsData = __webpack_require__(125); /** Used to detect methods masquerading as native. */ var maskSrcKey = function () { var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); return uid ? 'Symbol(src)_1.' + uid : ''; }(); /** * Checks if `func` has its source masked. * * @private * @param {Function} func The function to check. * @returns {boolean} Returns `true` if `func` is masked, else `false`. */ function isMasked(func) { return !!maskSrcKey && maskSrcKey in func; } module.exports = isMasked; /***/ }, /* 125 */ /***/function (module, exports, __webpack_require__) { var root = __webpack_require__(4); /** Used to detect overreaching core-js shims. */ var coreJsData = root['__core-js_shared__']; module.exports = coreJsData; /***/ }, /* 126 */ /***/function (module, exports) { /** * Gets the value at `key` of `object`. * * @private * @param {Object} [object] The object to query. * @param {string} key The key of the property to get. * @returns {*} Returns the property value. */ function getValue(object, key) { return object == null ? undefined : object[key]; } module.exports = getValue; /***/ }, /* 127 */ /***/function (module, exports, __webpack_require__) { var getNative = __webpack_require__(10), root = __webpack_require__(4); /* Built-in method references that are verified to be native. */ var Promise = getNative(root, 'Promise'); module.exports = Promise; /***/ }, /* 128 */ /***/function (module, exports, __webpack_require__) { var getNative = __webpack_require__(10), root = __webpack_require__(4); /* Built-in method references that are verified to be native. */ var Set = getNative(root, 'Set'); module.exports = Set; /***/ }, /* 129 */ /***/function (module, exports, __webpack_require__) { var getNative = __webpack_require__(10), root = __webpack_require__(4); /* Built-in method references that are verified to be native. */ var WeakMap = getNative(root, 'WeakMap'); module.exports = WeakMap; /***/ }, /* 130 */ /***/function (module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(7), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var argsTag = '[object Arguments]'; /** * The base implementation of `_.isArguments`. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an `arguments` object, */ function baseIsArguments(value) { return isObjectLike(value) && baseGetTag(value) == argsTag; } module.exports = baseIsArguments; /***/ }, /* 131 */ /***/function (module, exports) { /** * This method returns `false`. * * @static * @memberOf _ * @since 4.13.0 * @category Util * @returns {boolean} Returns `false`. * @example * * _.times(2, _.stubFalse); * // => [false, false] */ function stubFalse() { return false; } module.exports = stubFalse; /***/ }, /* 132 */ /***/function (module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(7), isLength = __webpack_require__(60), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', weakMapTag = '[object WeakMap]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; /** Used to identify `toStringTag` values of typed arrays. */ var typedArrayTags = {}; typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; /** * The base implementation of `_.isTypedArray` without Node.js optimizations. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. */ function baseIsTypedArray(value) { return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; } module.exports = baseIsTypedArray; /***/ }, /* 133 */ /***/function (module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function (module) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; var freeGlobal = __webpack_require__(55); /** Detect free variable `exports`. */ var freeExports = (false ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && (false ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Detect free variable `process` from Node.js. */ var freeProcess = moduleExports && freeGlobal.process; /** Used to access faster Node.js helpers. */ var nodeUtil = function () { try { return freeProcess && freeProcess.binding && freeProcess.binding('util'); } catch (e) {} }(); module.exports = nodeUtil; /* WEBPACK VAR INJECTION */ }).call(exports, __webpack_require__(34)(module)); /***/ }, /* 134 */ /***/function (module, exports, __webpack_require__) { var toString = __webpack_require__(62); /** Used to generate unique IDs. */ var idCounter = 0; /** * Generates a unique ID. If `prefix` is given, the ID is appended to it. * * @static * @since 0.1.0 * @memberOf _ * @category Util * @param {string} [prefix=''] The value to prefix the ID with. * @returns {string} Returns the unique ID. * @example * * _.uniqueId('contact_'); * // => 'contact_104' * * _.uniqueId(); * // => '105' */ function uniqueId(prefix) { var id = ++idCounter; return toString(prefix) + id; } module.exports = uniqueId; /***/ }, /* 135 */ /***/function (module, exports, __webpack_require__) { var _Symbol = __webpack_require__(11), arrayMap = __webpack_require__(35), isArray = __webpack_require__(6), isSymbol = __webpack_require__(136); /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0; /** Used to convert symbols to primitives and strings. */ var symbolProto = _Symbol ? _Symbol.prototype : undefined, symbolToString = symbolProto ? symbolProto.toString : undefined; /** * The base implementation of `_.toString` which doesn't convert nullish * values to empty strings. * * @private * @param {*} value The value to process. * @returns {string} Returns the string. */ function baseToString(value) { // Exit early for strings to avoid a performance hit in some environments. if (typeof value == 'string') { return value; } if (isArray(value)) { // Recursively convert values (susceptible to call stack limits). return arrayMap(value, baseToString) + ''; } if (isSymbol(value)) { return symbolToString ? symbolToString.call(value) : ''; } var result = value + ''; return result == '0' && 1 / value == -INFINITY ? '-0' : result; } module.exports = baseToString; /***/ }, /* 136 */ /***/function (module, exports, __webpack_require__) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; var baseGetTag = __webpack_require__(7), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var symbolTag = '[object Symbol]'; /** * Checks if `value` is classified as a `Symbol` primitive or object. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. * @example * * _.isSymbol(Symbol.iterator); * // => true * * _.isSymbol('abc'); * // => false */ function isSymbol(value) { return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag; } module.exports = isSymbol; /***/ }, /* 137 */ /***/function (module, exports, __webpack_require__) { var baseClone = __webpack_require__(138); /** Used to compose bitmasks for cloning. */ var CLONE_SYMBOLS_FLAG = 4; /** * Creates a shallow clone of `value`. * * **Note:** This method is loosely based on the * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) * and supports cloning arrays, array buffers, booleans, date objects, maps, * numbers, `Object` objects, regexes, sets, strings, symbols, and typed * arrays. The own enumerable properties of `arguments` objects are cloned * as plain objects. An empty object is returned for uncloneable values such * as error objects, functions, DOM nodes, and WeakMaps. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to clone. * @returns {*} Returns the cloned value. * @see _.cloneDeep * @example * * var objects = [{ 'a': 1 }, { 'b': 2 }]; * * var shallow = _.clone(objects); * console.log(shallow[0] === objects[0]); * // => true */ function clone(value) { return baseClone(value, CLONE_SYMBOLS_FLAG); } module.exports = clone; /***/ }, /* 138 */ /***/function (module, exports, __webpack_require__) { var Stack = __webpack_require__(36), arrayEach = __webpack_require__(64), assignValue = __webpack_require__(37), baseAssign = __webpack_require__(161), baseAssignIn = __webpack_require__(163), cloneBuffer = __webpack_require__(68), copyArray = __webpack_require__(28), copySymbols = __webpack_require__(166), copySymbolsIn = __webpack_require__(168), getAllKeys = __webpack_require__(72), getAllKeysIn = __webpack_require__(169), getTag = __webpack_require__(21), initCloneArray = __webpack_require__(170), initCloneByTag = __webpack_require__(171), initCloneObject = __webpack_require__(77), isArray = __webpack_require__(6), isBuffer = __webpack_require__(17), isObject = __webpack_require__(8), keys = __webpack_require__(13); /** Used to compose bitmasks for cloning. */ var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4; /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', symbolTag = '[object Symbol]', weakMapTag = '[object WeakMap]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; /** Used to identify `toStringTag` values supported by `_.clone`. */ var cloneableTags = {}; cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false; /** * The base implementation of `_.clone` and `_.cloneDeep` which tracks * traversed objects. * * @private * @param {*} value The value to clone. * @param {boolean} bitmask The bitmask flags. * 1 - Deep clone * 2 - Flatten inherited properties * 4 - Clone symbols * @param {Function} [customizer] The function to customize cloning. * @param {string} [key] The key of `value`. * @param {Object} [object] The parent object of `value`. * @param {Object} [stack] Tracks traversed objects and their clone counterparts. * @returns {*} Returns the cloned value. */ function baseClone(value, bitmask, customizer, key, object, stack) { var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG; if (customizer) { result = object ? customizer(value, key, object, stack) : customizer(value); } if (result !== undefined) { return result; } if (!isObject(value)) { return value; } var isArr = isArray(value); if (isArr) { result = initCloneArray(value); if (!isDeep) { return copyArray(value, result); } } else { var tag = getTag(value), isFunc = tag == funcTag || tag == genTag; if (isBuffer(value)) { return cloneBuffer(value, isDeep); } if (tag == objectTag || tag == argsTag || isFunc && !object) { result = isFlat || isFunc ? {} : initCloneObject(value); if (!isDeep) { return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value)); } } else { if (!cloneableTags[tag]) { return object ? value : {}; } result = initCloneByTag(value, tag, baseClone, isDeep); } } // Check for circular references and return its corresponding clone. stack || (stack = new Stack()); var stacked = stack.get(value); if (stacked) { return stacked; } stack.set(value, result); var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys; var props = isArr ? undefined : keysFunc(value); arrayEach(props || value, function (subValue, key) { if (props) { key = subValue; subValue = value[key]; } // Recursively populate clone (susceptible to call stack limits). assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); }); return result; } module.exports = baseClone; /***/ }, /* 139 */ /***/function (module, exports) { /** * Removes all key-value entries from the list cache. * * @private * @name clear * @memberOf ListCache */ function listCacheClear() { this.__data__ = []; this.size = 0; } module.exports = listCacheClear; /***/ }, /* 140 */ /***/function (module, exports, __webpack_require__) { var assocIndexOf = __webpack_require__(24); /** Used for built-in method references. */ var arrayProto = Array.prototype; /** Built-in value references. */ var splice = arrayProto.splice; /** * Removes `key` and its value from the list cache. * * @private * @name delete * @memberOf ListCache * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function listCacheDelete(key) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { return false; } var lastIndex = data.length - 1; if (index == lastIndex) { data.pop(); } else { splice.call(data, index, 1); } --this.size; return true; } module.exports = listCacheDelete; /***/ }, /* 141 */ /***/function (module, exports, __webpack_require__) { var assocIndexOf = __webpack_require__(24); /** * Gets the list cache value for `key`. * * @private * @name get * @memberOf ListCache * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function listCacheGet(key) { var data = this.__data__, index = assocIndexOf(data, key); return index < 0 ? undefined : data[index][1]; } module.exports = listCacheGet; /***/ }, /* 142 */ /***/function (module, exports, __webpack_require__) { var assocIndexOf = __webpack_require__(24); /** * Checks if a list cache value for `key` exists. * * @private * @name has * @memberOf ListCache * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function listCacheHas(key) { return assocIndexOf(this.__data__, key) > -1; } module.exports = listCacheHas; /***/ }, /* 143 */ /***/function (module, exports, __webpack_require__) { var assocIndexOf = __webpack_require__(24); /** * Sets the list cache `key` to `value`. * * @private * @name set * @memberOf ListCache * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the list cache instance. */ function listCacheSet(key, value) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { ++this.size; data.push([key, value]); } else { data[index][1] = value; } return this; } module.exports = listCacheSet; /***/ }, /* 144 */ /***/function (module, exports, __webpack_require__) { var ListCache = __webpack_require__(23); /** * Removes all key-value entries from the stack. * * @private * @name clear * @memberOf Stack */ function stackClear() { this.__data__ = new ListCache(); this.size = 0; } module.exports = stackClear; /***/ }, /* 145 */ /***/function (module, exports) { /** * Removes `key` and its value from the stack. * * @private * @name delete * @memberOf Stack * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function stackDelete(key) { var data = this.__data__, result = data['delete'](key); this.size = data.size; return result; } module.exports = stackDelete; /***/ }, /* 146 */ /***/function (module, exports) { /** * Gets the stack value for `key`. * * @private * @name get * @memberOf Stack * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function stackGet(key) { return this.__data__.get(key); } module.exports = stackGet; /***/ }, /* 147 */ /***/function (module, exports) { /** * Checks if a stack value for `key` exists. * * @private * @name has * @memberOf Stack * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function stackHas(key) { return this.__data__.has(key); } module.exports = stackHas; /***/ }, /* 148 */ /***/function (module, exports, __webpack_require__) { var ListCache = __webpack_require__(23), Map = __webpack_require__(32), MapCache = __webpack_require__(63); /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; /** * Sets the stack `key` to `value`. * * @private * @name set * @memberOf Stack * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the stack cache instance. */ function stackSet(key, value) { var data = this.__data__; if (data instanceof ListCache) { var pairs = data.__data__; if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) { pairs.push([key, value]); this.size = ++data.size; return this; } data = this.__data__ = new MapCache(pairs); } data.set(key, value); this.size = data.size; return this; } module.exports = stackSet; /***/ }, /* 149 */ /***/function (module, exports, __webpack_require__) { var Hash = __webpack_require__(150), ListCache = __webpack_require__(23), Map = __webpack_require__(32); /** * Removes all key-value entries from the map. * * @private * @name clear * @memberOf MapCache */ function mapCacheClear() { this.size = 0; this.__data__ = { 'hash': new Hash(), 'map': new (Map || ListCache)(), 'string': new Hash() }; } module.exports = mapCacheClear; /***/ }, /* 150 */ /***/function (module, exports, __webpack_require__) { var hashClear = __webpack_require__(151), hashDelete = __webpack_require__(152), hashGet = __webpack_require__(153), hashHas = __webpack_require__(154), hashSet = __webpack_require__(155); /** * Creates a hash object. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function Hash(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `Hash`. Hash.prototype.clear = hashClear; Hash.prototype['delete'] = hashDelete; Hash.prototype.get = hashGet; Hash.prototype.has = hashHas; Hash.prototype.set = hashSet; module.exports = Hash; /***/ }, /* 151 */ /***/function (module, exports, __webpack_require__) { var nativeCreate = __webpack_require__(25); /** * Removes all key-value entries from the hash. * * @private * @name clear * @memberOf Hash */ function hashClear() { this.__data__ = nativeCreate ? nativeCreate(null) : {}; this.size = 0; } module.exports = hashClear; /***/ }, /* 152 */ /***/function (module, exports) { /** * Removes `key` and its value from the hash. * * @private * @name delete * @memberOf Hash * @param {Object} hash The hash to modify. * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function hashDelete(key) { var result = this.has(key) && delete this.__data__[key]; this.size -= result ? 1 : 0; return result; } module.exports = hashDelete; /***/ }, /* 153 */ /***/function (module, exports, __webpack_require__) { var nativeCreate = __webpack_require__(25); /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Gets the hash value for `key`. * * @private * @name get * @memberOf Hash * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function hashGet(key) { var data = this.__data__; if (nativeCreate) { var result = data[key]; return result === HASH_UNDEFINED ? undefined : result; } return hasOwnProperty.call(data, key) ? data[key] : undefined; } module.exports = hashGet; /***/ }, /* 154 */ /***/function (module, exports, __webpack_require__) { var nativeCreate = __webpack_require__(25); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Checks if a hash value for `key` exists. * * @private * @name has * @memberOf Hash * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function hashHas(key) { var data = this.__data__; return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); } module.exports = hashHas; /***/ }, /* 155 */ /***/function (module, exports, __webpack_require__) { var nativeCreate = __webpack_require__(25); /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; /** * Sets the hash `key` to `value`. * * @private * @name set * @memberOf Hash * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the hash instance. */ function hashSet(key, value) { var data = this.__data__; this.size += this.has(key) ? 0 : 1; data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value; return this; } module.exports = hashSet; /***/ }, /* 156 */ /***/function (module, exports, __webpack_require__) { var getMapData = __webpack_require__(26); /** * Removes `key` and its value from the map. * * @private * @name delete * @memberOf MapCache * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function mapCacheDelete(key) { var result = getMapData(this, key)['delete'](key); this.size -= result ? 1 : 0; return result; } module.exports = mapCacheDelete; /***/ }, /* 157 */ /***/function (module, exports) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; /** * Checks if `value` is suitable for use as unique object key. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is suitable, else `false`. */ function isKeyable(value) { var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null; } module.exports = isKeyable; /***/ }, /* 158 */ /***/function (module, exports, __webpack_require__) { var getMapData = __webpack_require__(26); /** * Gets the map value for `key`. * * @private * @name get * @memberOf MapCache * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function mapCacheGet(key) { return getMapData(this, key).get(key); } module.exports = mapCacheGet; /***/ }, /* 159 */ /***/function (module, exports, __webpack_require__) { var getMapData = __webpack_require__(26); /** * Checks if a map value for `key` exists. * * @private * @name has * @memberOf MapCache * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function mapCacheHas(key) { return getMapData(this, key).has(key); } module.exports = mapCacheHas; /***/ }, /* 160 */ /***/function (module, exports, __webpack_require__) { var getMapData = __webpack_require__(26); /** * Sets the map `key` to `value`. * * @private * @name set * @memberOf MapCache * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the map cache instance. */ function mapCacheSet(key, value) { var data = getMapData(this, key), size = data.size; data.set(key, value); this.size += data.size == size ? 0 : 1; return this; } module.exports = mapCacheSet; /***/ }, /* 161 */ /***/function (module, exports, __webpack_require__) { var copyObject = __webpack_require__(12), keys = __webpack_require__(13); /** * The base implementation of `_.assign` without support for multiple sources * or `customizer` functions. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. * @returns {Object} Returns `object`. */ function baseAssign(object, source) { return object && copyObject(source, keys(source), object); } module.exports = baseAssign; /***/ }, /* 162 */ /***/function (module, exports) { /** * The base implementation of `_.times` without support for iteratee shorthands * or max array length checks. * * @private * @param {number} n The number of times to invoke `iteratee`. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the array of results. */ function baseTimes(n, iteratee) { var index = -1, result = Array(n); while (++index < n) { result[index] = iteratee(index); } return result; } module.exports = baseTimes; /***/ }, /* 163 */ /***/function (module, exports, __webpack_require__) { var copyObject = __webpack_require__(12), keysIn = __webpack_require__(27); /** * The base implementation of `_.assignIn` without support for multiple sources * or `customizer` functions. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. * @returns {Object} Returns `object`. */ function baseAssignIn(object, source) { return object && copyObject(source, keysIn(source), object); } module.exports = baseAssignIn; /***/ }, /* 164 */ /***/function (module, exports, __webpack_require__) { var isObject = __webpack_require__(8), isPrototype = __webpack_require__(16), nativeKeysIn = __webpack_require__(165); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function baseKeysIn(object) { if (!isObject(object)) { return nativeKeysIn(object); } var isProto = isPrototype(object), result = []; for (var key in object) { if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { result.push(key); } } return result; } module.exports = baseKeysIn; /***/ }, /* 165 */ /***/function (module, exports) { /** * This function is like * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) * except that it includes inherited enumerable properties. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function nativeKeysIn(object) { var result = []; if (object != null) { for (var key in Object(object)) { result.push(key); } } return result; } module.exports = nativeKeysIn; /***/ }, /* 166 */ /***/function (module, exports, __webpack_require__) { var copyObject = __webpack_require__(12), getSymbols = __webpack_require__(39); /** * Copies own symbols of `source` to `object`. * * @private * @param {Object} source The object to copy symbols from. * @param {Object} [object={}] The object to copy symbols to. * @returns {Object} Returns `object`. */ function copySymbols(source, object) { return copyObject(source, getSymbols(source), object); } module.exports = copySymbols; /***/ }, /* 167 */ /***/function (module, exports) { /** * A specialized version of `_.filter` for arrays without support for * iteratee shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {Array} Returns the new filtered array. */ function arrayFilter(array, predicate) { var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = []; while (++index < length) { var value = array[index]; if (predicate(value, index, array)) { result[resIndex++] = value; } } return result; } module.exports = arrayFilter; /***/ }, /* 168 */ /***/function (module, exports, __webpack_require__) { var copyObject = __webpack_require__(12), getSymbolsIn = __webpack_require__(70); /** * Copies own and inherited symbols of `source` to `object`. * * @private * @param {Object} source The object to copy symbols from. * @param {Object} [object={}] The object to copy symbols to. * @returns {Object} Returns `object`. */ function copySymbolsIn(source, object) { return copyObject(source, getSymbolsIn(source), object); } module.exports = copySymbolsIn; /***/ }, /* 169 */ /***/function (module, exports, __webpack_require__) { var baseGetAllKeys = __webpack_require__(73), getSymbolsIn = __webpack_require__(70), keysIn = __webpack_require__(27); /** * Creates an array of own and inherited enumerable property names and * symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names and symbols. */ function getAllKeysIn(object) { return baseGetAllKeys(object, keysIn, getSymbolsIn); } module.exports = getAllKeysIn; /***/ }, /* 170 */ /***/function (module, exports) { /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Initializes an array clone. * * @private * @param {Array} array The array to clone. * @returns {Array} Returns the initialized clone. */ function initCloneArray(array) { var length = array.length, result = array.constructor(length); // Add properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; } return result; } module.exports = initCloneArray; /***/ }, /* 171 */ /***/function (module, exports, __webpack_require__) { var cloneArrayBuffer = __webpack_require__(41), cloneDataView = __webpack_require__(172), cloneMap = __webpack_require__(173), cloneRegExp = __webpack_require__(175), cloneSet = __webpack_require__(176), cloneSymbol = __webpack_require__(178), cloneTypedArray = __webpack_require__(76); /** `Object#toString` result references. */ var boolTag = '[object Boolean]', dateTag = '[object Date]', mapTag = '[object Map]', numberTag = '[object Number]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', symbolTag = '[object Symbol]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; /** * Initializes an object clone based on its `toStringTag`. * * **Note:** This function only supports cloning values with tags of * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. * * @private * @param {Object} object The object to clone. * @param {string} tag The `toStringTag` of the object to clone. * @param {Function} cloneFunc The function to clone values. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the initialized clone. */ function initCloneByTag(object, tag, cloneFunc, isDeep) { var Ctor = object.constructor; switch (tag) { case arrayBufferTag: return cloneArrayBuffer(object); case boolTag: case dateTag: return new Ctor(+object); case dataViewTag: return cloneDataView(object, isDeep); case float32Tag:case float64Tag: case int8Tag:case int16Tag:case int32Tag: case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag: return cloneTypedArray(object, isDeep); case mapTag: return cloneMap(object, isDeep, cloneFunc); case numberTag: case stringTag: return new Ctor(object); case regexpTag: return cloneRegExp(object); case setTag: return cloneSet(object, isDeep, cloneFunc); case symbolTag: return cloneSymbol(object); } } module.exports = initCloneByTag; /***/ }, /* 172 */ /***/function (module, exports, __webpack_require__) { var cloneArrayBuffer = __webpack_require__(41); /** * Creates a clone of `dataView`. * * @private * @param {Object} dataView The data view to clone. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned data view. */ function cloneDataView(dataView, isDeep) { var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); } module.exports = cloneDataView; /***/ }, /* 173 */ /***/function (module, exports, __webpack_require__) { var addMapEntry = __webpack_require__(174), arrayReduce = __webpack_require__(75), mapToArray = __webpack_require__(42); /** Used to compose bitmasks for cloning. */ var CLONE_DEEP_FLAG = 1; /** * Creates a clone of `map`. * * @private * @param {Object} map The map to clone. * @param {Function} cloneFunc The function to clone values. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned map. */ function cloneMap(map, isDeep, cloneFunc) { var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map); return arrayReduce(array, addMapEntry, new map.constructor()); } module.exports = cloneMap; /***/ }, /* 174 */ /***/function (module, exports) { /** * Adds the key-value `pair` to `map`. * * @private * @param {Object} map The map to modify. * @param {Array} pair The key-value pair to add. * @returns {Object} Returns `map`. */ function addMapEntry(map, pair) { // Don't return `map.set` because it's not chainable in IE 11. map.set(pair[0], pair[1]); return map; } module.exports = addMapEntry; /***/ }, /* 175 */ /***/function (module, exports) { /** Used to match `RegExp` flags from their coerced string values. */ var reFlags = /\w*$/; /** * Creates a clone of `regexp`. * * @private * @param {Object} regexp The regexp to clone. * @returns {Object} Returns the cloned regexp. */ function cloneRegExp(regexp) { var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); result.lastIndex = regexp.lastIndex; return result; } module.exports = cloneRegExp; /***/ }, /* 176 */ /***/function (module, exports, __webpack_require__) { var addSetEntry = __webpack_require__(177), arrayReduce = __webpack_require__(75), setToArray = __webpack_require__(43); /** Used to compose bitmasks for cloning. */ var CLONE_DEEP_FLAG = 1; /** * Creates a clone of `set`. * * @private * @param {Object} set The set to clone. * @param {Function} cloneFunc The function to clone values. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned set. */ function cloneSet(set, isDeep, cloneFunc) { var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set); return arrayReduce(array, addSetEntry, new set.constructor()); } module.exports = cloneSet; /***/ }, /* 177 */ /***/function (module, exports) { /** * Adds `value` to `set`. * * @private * @param {Object} set The set to modify. * @param {*} value The value to add. * @returns {Object} Returns `set`. */ function addSetEntry(set, value) { // Don't return `set.add` because it's not chainable in IE 11. set.add(value); return set; } module.exports = addSetEntry; /***/ }, /* 178 */ /***/function (module, exports, __webpack_require__) { var _Symbol = __webpack_require__(11); /** Used to convert symbols to primitives and strings. */ var symbolProto = _Symbol ? _Symbol.prototype : undefined, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; /** * Creates a clone of the `symbol` object. * * @private * @param {Object} symbol The symbol object to clone. * @returns {Object} Returns the cloned symbol object. */ function cloneSymbol(symbol) { return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; } module.exports = cloneSymbol; /***/ }, /* 179 */ /***/function (module, exports, __webpack_require__) { var isObject = __webpack_require__(8); /** Built-in value references. */ var objectCreate = Object.create; /** * The base implementation of `_.create` without support for assigning * properties to the created object. * * @private * @param {Object} proto The object to inherit from. * @returns {Object} Returns the new object. */ var baseCreate = function () { function object() {} return function (proto) { if (!isObject(proto)) { return {}; } if (objectCreate) { return objectCreate(proto); } object.prototype = proto; var result = new object(); object.prototype = undefined; return result; }; }(); module.exports = baseCreate; /***/ }, /* 180 */ /***/function (module, exports, __webpack_require__) { var assignValue = __webpack_require__(37), copyObject = __webpack_require__(12), createAssigner = __webpack_require__(78), isArrayLike = __webpack_require__(9), isPrototype = __webpack_require__(16), keys = __webpack_require__(13); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Assigns own enumerable string keyed properties of source objects to the * destination object. Source objects are applied from left to right. * Subsequent sources overwrite property assignments of previous sources. * * **Note:** This method mutates `object` and is loosely based on * [`Object.assign`](https://mdn.io/Object/assign). * * @static * @memberOf _ * @since 0.10.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. * @returns {Object} Returns `object`. * @see _.assignIn * @example * * function Foo() { * this.a = 1; * } * * function Bar() { * this.c = 3; * } * * Foo.prototype.b = 2; * Bar.prototype.d = 4; * * _.assign({ 'a': 0 }, new Foo, new Bar); * // => { 'a': 1, 'c': 3 } */ var assign = createAssigner(function (object, source) { if (isPrototype(source) || isArrayLike(source)) { copyObject(source, keys(source), object); return; } for (var key in source) { if (hasOwnProperty.call(source, key)) { assignValue(object, key, source[key]); } } }); module.exports = assign; /***/ }, /* 181 */ /***/function (module, exports, __webpack_require__) { var apply = __webpack_require__(182); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeMax = Math.max; /** * A specialized version of `baseRest` which transforms the rest array. * * @private * @param {Function} func The function to apply a rest parameter to. * @param {number} [start=func.length-1] The start position of the rest parameter. * @param {Function} transform The rest array transform. * @returns {Function} Returns the new function. */ function overRest(func, start, transform) { start = nativeMax(start === undefined ? func.length - 1 : start, 0); return function () { var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length); while (++index < length) { array[index] = args[start + index]; } index = -1; var otherArgs = Array(start + 1); while (++index < start) { otherArgs[index] = args[index]; } otherArgs[start] = transform(array); return apply(func, this, otherArgs); }; } module.exports = overRest; /***/ }, /* 182 */ /***/function (module, exports) { /** * A faster alternative to `Function#apply`, this function invokes `func` * with the `this` binding of `thisArg` and the arguments of `args`. * * @private * @param {Function} func The function to invoke. * @param {*} thisArg The `this` binding of `func`. * @param {Array} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ function apply(func, thisArg, args) { switch (args.length) { case 0: return func.call(thisArg); case 1: return func.call(thisArg, args[0]); case 2: return func.call(thisArg, args[0], args[1]); case 3: return func.call(thisArg, args[0], args[1], args[2]); } return func.apply(thisArg, args); } module.exports = apply; /***/ }, /* 183 */ /***/function (module, exports, __webpack_require__) { var baseSetToString = __webpack_require__(184), shortOut = __webpack_require__(186); /** * Sets the `toString` method of `func` to return `string`. * * @private * @param {Function} func The function to modify. * @param {Function} string The `toString` result. * @returns {Function} Returns `func`. */ var setToString = shortOut(baseSetToString); module.exports = setToString; /***/ }, /* 184 */ /***/function (module, exports, __webpack_require__) { var constant = __webpack_require__(185), defineProperty = __webpack_require__(65), identity = __webpack_require__(44); /** * The base implementation of `setToString` without support for hot loop shorting. * * @private * @param {Function} func The function to modify. * @param {Function} string The `toString` result. * @returns {Function} Returns `func`. */ var baseSetToString = !defineProperty ? identity : function (func, string) { return defineProperty(func, 'toString', { 'configurable': true, 'enumerable': false, 'value': constant(string), 'writable': true }); }; module.exports = baseSetToString; /***/ }, /* 185 */ /***/function (module, exports) { /** * Creates a function that returns `value`. * * @static * @memberOf _ * @since 2.4.0 * @category Util * @param {*} value The value to return from the new function. * @returns {Function} Returns the new constant function. * @example * * var objects = _.times(2, _.constant({ 'a': 1 })); * * console.log(objects); * // => [{ 'a': 1 }, { 'a': 1 }] * * console.log(objects[0] === objects[1]); * // => true */ function constant(value) { return function () { return value; }; } module.exports = constant; /***/ }, /* 186 */ /***/function (module, exports) { /** Used to detect hot functions by number of calls within a span of milliseconds. */ var HOT_COUNT = 800, HOT_SPAN = 16; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeNow = Date.now; /** * Creates a function that'll short out and invoke `identity` instead * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` * milliseconds. * * @private * @param {Function} func The function to restrict. * @returns {Function} Returns the new shortable function. */ function shortOut(func) { var count = 0, lastCalled = 0; return function () { var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled); lastCalled = stamp; if (remaining > 0) { if (++count >= HOT_COUNT) { return arguments[0]; } } else { count = 0; } return func.apply(undefined, arguments); }; } module.exports = shortOut; /***/ }, /* 187 */ /***/function (module, exports, __webpack_require__) { var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; var eq = __webpack_require__(18), isArrayLike = __webpack_require__(9), isIndex = __webpack_require__(67), isObject = __webpack_require__(8); /** * Checks if the given arguments are from an iteratee call. * * @private * @param {*} value The potential iteratee value argument. * @param {*} index The potential iteratee index or key argument. * @param {*} object The potential iteratee object argument. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, * else `false`. */ function isIterateeCall(value, index, object) { if (!isObject(object)) { return false; } var type = typeof index === 'undefined' ? 'undefined' : _typeof(index); if (type == 'number' ? isArrayLike(object) && isIndex(index, object.length) : type == 'string' && index in object) { return eq(object[index], value); } return false; } module.exports = isIterateeCall; /***/ }, /* 188 */ /***/function (module, exports, __webpack_require__) { var baseMerge = __webpack_require__(189), createAssigner = __webpack_require__(78); /** * This method is like `_.assign` except that it recursively merges own and * inherited enumerable string keyed properties of source objects into the * destination object. Source properties that resolve to `undefined` are * skipped if a destination value exists. Array and plain object properties * are merged recursively. Other objects and value types are overridden by * assignment. Source objects are applied from left to right. Subsequent * sources overwrite property assignments of previous sources. * * **Note:** This method mutates `object`. * * @static * @memberOf _ * @since 0.5.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. * @returns {Object} Returns `object`. * @example * * var object = { * 'a': [{ 'b': 2 }, { 'd': 4 }] * }; * * var other = { * 'a': [{ 'c': 3 }, { 'e': 5 }] * }; * * _.merge(object, other); * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } */ var merge = createAssigner(function (object, source, srcIndex) { baseMerge(object, source, srcIndex); }); module.exports = merge; /***/ }, /* 189 */ /***/function (module, exports, __webpack_require__) { var Stack = __webpack_require__(36), assignMergeValue = __webpack_require__(80), baseFor = __webpack_require__(81), baseMergeDeep = __webpack_require__(191), isObject = __webpack_require__(8), keysIn = __webpack_require__(27); /** * The base implementation of `_.merge` without support for multiple sources. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. * @param {number} srcIndex The index of `source`. * @param {Function} [customizer] The function to customize merged values. * @param {Object} [stack] Tracks traversed source values and their merged * counterparts. */ function baseMerge(object, source, srcIndex, customizer, stack) { if (object === source) { return; } baseFor(source, function (srcValue, key) { if (isObject(srcValue)) { stack || (stack = new Stack()); baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); } else { var newValue = customizer ? customizer(object[key], srcValue, key + '', object, source, stack) : undefined; if (newValue === undefined) { newValue = srcValue; } assignMergeValue(object, key, newValue); } }, keysIn); } module.exports = baseMerge; /***/ }, /* 190 */ /***/function (module, exports) { /** * Creates a base function for methods like `_.forIn` and `_.forOwn`. * * @private * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {Function} Returns the new base function. */ function createBaseFor(fromRight) { return function (object, iteratee, keysFunc) { var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length; while (length--) { var key = props[fromRight ? length : ++index]; if (iteratee(iterable[key], key, iterable) === false) { break; } } return object; }; } module.exports = createBaseFor; /***/ }, /* 191 */ /***/function (module, exports, __webpack_require__) { var assignMergeValue = __webpack_require__(80), cloneBuffer = __webpack_require__(68), cloneTypedArray = __webpack_require__(76), copyArray = __webpack_require__(28), initCloneObject = __webpack_require__(77), isArguments = __webpack_require__(33), isArray = __webpack_require__(6), isArrayLikeObject = __webpack_require__(192), isBuffer = __webpack_require__(17), isFunction = __webpack_require__(20), isObject = __webpack_require__(8), isPlainObject = __webpack_require__(193), isTypedArray = __webpack_require__(22), toPlainObject = __webpack_require__(194); /** * A specialized version of `baseMerge` for arrays and objects which performs * deep merges and tracks traversed objects enabling objects with circular * references to be merged. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. * @param {string} key The key of the value to merge. * @param {number} srcIndex The index of `source`. * @param {Function} mergeFunc The function to merge values. * @param {Function} [customizer] The function to customize assigned values. * @param {Object} [stack] Tracks traversed source values and their merged * counterparts. */ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { var objValue = object[key], srcValue = source[key], stacked = stack.get(srcValue); if (stacked) { assignMergeValue(object, key, stacked); return; } var newValue = customizer ? customizer(objValue, srcValue, key + '', object, source, stack) : undefined; var isCommon = newValue === undefined; if (isCommon) { var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue); newValue = srcValue; if (isArr || isBuff || isTyped) { if (isArray(objValue)) { newValue = objValue; } else if (isArrayLikeObject(objValue)) { newValue = copyArray(objValue); } else if (isBuff) { isCommon = false; newValue = cloneBuffer(srcValue, true); } else if (isTyped) { isCommon = false; newValue = cloneTypedArray(srcValue, true); } else { newValue = []; } } else if (isPlainObject(srcValue) || isArguments(srcValue)) { newValue = objValue; if (isArguments(objValue)) { newValue = toPlainObject(objValue); } else if (!isObject(objValue) || srcIndex && isFunction(objValue)) { newValue = initCloneObject(srcValue); } } else { isCommon = false; } } if (isCommon) { // Recursively merge objects and arrays (susceptible to call stack limits). stack.set(srcValue, newValue); mergeFunc(newValue, srcValue, srcIndex, customizer, stack); stack['delete'](srcValue); } assignMergeValue(object, key, newValue); } module.exports = baseMergeDeep; /***/ }, /* 192 */ /***/function (module, exports, __webpack_require__) { var isArrayLike = __webpack_require__(9), isObjectLike = __webpack_require__(5); /** * This method is like `_.isArrayLike` except that it also checks if `value` * is an object. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array-like object, * else `false`. * @example * * _.isArrayLikeObject([1, 2, 3]); * // => true * * _.isArrayLikeObject(document.body.children); * // => true * * _.isArrayLikeObject('abc'); * // => false * * _.isArrayLikeObject(_.noop); * // => false */ function isArrayLikeObject(value) { return isObjectLike(value) && isArrayLike(value); } module.exports = isArrayLikeObject; /***/ }, /* 193 */ /***/function (module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(7), getPrototype = __webpack_require__(40), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var objectTag = '[object Object]'; /** Used for built-in method references. */ var funcProto = Function.prototype, objectProto = Object.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** Used to infer the `Object` constructor. */ var objectCtorString = funcToString.call(Object); /** * Checks if `value` is a plain object, that is, an object created by the * `Object` constructor or one with a `[[Prototype]]` of `null`. * * @static * @memberOf _ * @since 0.8.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. * @example * * function Foo() { * this.a = 1; * } * * _.isPlainObject(new Foo); * // => false * * _.isPlainObject([1, 2, 3]); * // => false * * _.isPlainObject({ 'x': 0, 'y': 0 }); * // => true * * _.isPlainObject(Object.create(null)); * // => true */ function isPlainObject(value) { if (!isObjectLike(value) || baseGetTag(value) != objectTag) { return false; } var proto = getPrototype(value); if (proto === null) { return true; } var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString; } module.exports = isPlainObject; /***/ }, /* 194 */ /***/function (module, exports, __webpack_require__) { var copyObject = __webpack_require__(12), keysIn = __webpack_require__(27); /** * Converts `value` to a plain object flattening inherited enumerable string * keyed properties of `value` to own properties of the plain object. * * @static * @memberOf _ * @since 3.0.0 * @category Lang * @param {*} value The value to convert. * @returns {Object} Returns the converted plain object. * @example * * function Foo() { * this.b = 2; * } * * Foo.prototype.c = 3; * * _.assign({ 'a': 1 }, new Foo); * // => { 'a': 1, 'b': 2 } * * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); * // => { 'a': 1, 'b': 2, 'c': 3 } */ function toPlainObject(value) { return copyObject(value, keysIn(value)); } module.exports = toPlainObject; /***/ }, /* 195 */ /***/function (module, exports, __webpack_require__) { var createCaseFirst = __webpack_require__(196); /** * Converts the first character of `string` to upper case. * * @static * @memberOf _ * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the converted string. * @example * * _.upperFirst('fred'); * // => 'Fred' * * _.upperFirst('FRED'); * // => 'FRED' */ var upperFirst = createCaseFirst('toUpperCase'); module.exports = upperFirst; /***/ }, /* 196 */ /***/function (module, exports, __webpack_require__) { var castSlice = __webpack_require__(197), hasUnicode = __webpack_require__(82), stringToArray = __webpack_require__(83), toString = __webpack_require__(62); /** * Creates a function like `_.lowerFirst`. * * @private * @param {string} methodName The name of the `String` case method to use. * @returns {Function} Returns the new case function. */ function createCaseFirst(methodName) { return function (string) { string = toString(string); var strSymbols = hasUnicode(string) ? stringToArray(string) : undefined; var chr = strSymbols ? strSymbols[0] : string.charAt(0); var trailing = strSymbols ? castSlice(strSymbols, 1).join('') : string.slice(1); return chr[methodName]() + trailing; }; } module.exports = createCaseFirst; /***/ }, /* 197 */ /***/function (module, exports, __webpack_require__) { var baseSlice = __webpack_require__(198); /** * Casts `array` to a slice if it's needed. * * @private * @param {Array} array The array to inspect. * @param {number} start The start position. * @param {number} [end=array.length] The end position. * @returns {Array} Returns the cast slice. */ function castSlice(array, start, end) { var length = array.length; end = end === undefined ? length : end; return !start && end >= length ? array : baseSlice(array, start, end); } module.exports = castSlice; /***/ }, /* 198 */ /***/function (module, exports) { /** * The base implementation of `_.slice` without an iteratee call guard. * * @private * @param {Array} array The array to slice. * @param {number} [start=0] The start position. * @param {number} [end=array.length] The end position. * @returns {Array} Returns the slice of `array`. */ function baseSlice(array, start, end) { var index = -1, length = array.length; if (start < 0) { start = -start > length ? 0 : length + start; } end = end > length ? length : end; if (end < 0) { end += length; } length = start > end ? 0 : end - start >>> 0; start >>>= 0; var result = Array(length); while (++index < length) { result[index] = array[index + start]; } return result; } module.exports = baseSlice; /***/ }, /* 199 */ /***/function (module, exports) { /** * Converts an ASCII `string` to an array. * * @private * @param {string} string The string to convert. * @returns {Array} Returns the converted array. */ function asciiToArray(string) { return string.split(''); } module.exports = asciiToArray; /***/ }, /* 200 */ /***/function (module, exports) { /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', rsComboMarksRange = '\\u0300-\\u036f', reComboHalfMarksRange = '\\ufe20-\\ufe2f', rsComboSymbolsRange = '\\u20d0-\\u20ff', rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = '\\ufe0e\\ufe0f'; /** Used to compose unicode capture groups. */ var rsAstral = '[' + rsAstralRange + ']', rsCombo = '[' + rsComboRange + ']', rsFitz = '\\ud83c[\\udffb-\\udfff]', rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', rsNonAstral = '[^' + rsAstralRange + ']', rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', rsZWJ = '\\u200d'; /** Used to compose unicode regexes. */ var reOptMod = rsModifier + '?', rsOptVar = '[' + rsVarRange + ']?', rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', rsSeq = rsOptVar + reOptMod + rsOptJoin, rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); /** * Converts a Unicode `string` to an array. * * @private * @param {string} string The string to convert. * @returns {Array} Returns the converted array. */ function unicodeToArray(string) { return string.match(reUnicode) || []; } module.exports = unicodeToArray; /***/ }, /* 201 */ /***/function (module, exports, __webpack_require__) { var baseRest = __webpack_require__(79), pullAll = __webpack_require__(202); /** * Removes all given values from `array` using * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` * to remove elements from an array by predicate. * * @static * @memberOf _ * @since 2.0.0 * @category Array * @param {Array} array The array to modify. * @param {...*} [values] The values to remove. * @returns {Array} Returns `array`. * @example * * var array = ['a', 'b', 'c', 'a', 'b', 'c']; * * _.pull(array, 'a', 'c'); * console.log(array); * // => ['b', 'b'] */ var pull = baseRest(pullAll); module.exports = pull; /***/ }, /* 202 */ /***/function (module, exports, __webpack_require__) { var basePullAll = __webpack_require__(203); /** * This method is like `_.pull` except that it accepts an array of values to remove. * * **Note:** Unlike `_.difference`, this method mutates `array`. * * @static * @memberOf _ * @since 4.0.0 * @category Array * @param {Array} array The array to modify. * @param {Array} values The values to remove. * @returns {Array} Returns `array`. * @example * * var array = ['a', 'b', 'c', 'a', 'b', 'c']; * * _.pullAll(array, ['a', 'c']); * console.log(array); * // => ['b', 'b'] */ function pullAll(array, values) { return array && array.length && values && values.length ? basePullAll(array, values) : array; } module.exports = pullAll; /***/ }, /* 203 */ /***/function (module, exports, __webpack_require__) { var arrayMap = __webpack_require__(35), baseIndexOf = __webpack_require__(204), baseIndexOfWith = __webpack_require__(208), baseUnary = __webpack_require__(61), copyArray = __webpack_require__(28); /** Used for built-in method references. */ var arrayProto = Array.prototype; /** Built-in value references. */ var splice = arrayProto.splice; /** * The base implementation of `_.pullAllBy` without support for iteratee * shorthands. * * @private * @param {Array} array The array to modify. * @param {Array} values The values to remove. * @param {Function} [iteratee] The iteratee invoked per element. * @param {Function} [comparator] The comparator invoked per element. * @returns {Array} Returns `array`. */ function basePullAll(array, values, iteratee, comparator) { var indexOf = comparator ? baseIndexOfWith : baseIndexOf, index = -1, length = values.length, seen = array; if (array === values) { values = copyArray(values); } if (iteratee) { seen = arrayMap(array, baseUnary(iteratee)); } while (++index < length) { var fromIndex = 0, value = values[index], computed = iteratee ? iteratee(value) : value; while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { if (seen !== array) { splice.call(seen, fromIndex, 1); } splice.call(array, fromIndex, 1); } } return array; } module.exports = basePullAll; /***/ }, /* 204 */ /***/function (module, exports, __webpack_require__) { var baseFindIndex = __webpack_require__(205), baseIsNaN = __webpack_require__(206), strictIndexOf = __webpack_require__(207); /** * The base implementation of `_.indexOf` without `fromIndex` bounds checks. * * @private * @param {Array} array The array to inspect. * @param {*} value The value to search for. * @param {number} fromIndex The index to search from. * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex); } module.exports = baseIndexOf; /***/ }, /* 205 */ /***/function (module, exports) { /** * The base implementation of `_.findIndex` and `_.findLastIndex` without * support for iteratee shorthands. * * @private * @param {Array} array The array to inspect. * @param {Function} predicate The function invoked per iteration. * @param {number} fromIndex The index to search from. * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {number} Returns the index of the matched value, else `-1`. */ function baseFindIndex(array, predicate, fromIndex, fromRight) { var length = array.length, index = fromIndex + (fromRight ? 1 : -1); while (fromRight ? index-- : ++index < length) { if (predicate(array[index], index, array)) { return index; } } return -1; } module.exports = baseFindIndex; /***/ }, /* 206 */ /***/function (module, exports) { /** * The base implementation of `_.isNaN` without support for number objects. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. */ function baseIsNaN(value) { return value !== value; } module.exports = baseIsNaN; /***/ }, /* 207 */ /***/function (module, exports) { /** * A specialized version of `_.indexOf` which performs strict equality * comparisons of values, i.e. `===`. * * @private * @param {Array} array The array to inspect. * @param {*} value The value to search for. * @param {number} fromIndex The index to search from. * @returns {number} Returns the index of the matched value, else `-1`. */ function strictIndexOf(array, value, fromIndex) { var index = fromIndex - 1, length = array.length; while (++index < length) { if (array[index] === value) { return index; } } return -1; } module.exports = strictIndexOf; /***/ }, /* 208 */ /***/function (module, exports) { /** * This function is like `baseIndexOf` except that it accepts a comparator. * * @private * @param {Array} array The array to inspect. * @param {*} value The value to search for. * @param {number} fromIndex The index to search from. * @param {Function} comparator The comparator invoked per element. * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOfWith(array, value, fromIndex, comparator) { var index = fromIndex - 1, length = array.length; while (++index < length) { if (comparator(array[index], value)) { return index; } } return -1; } module.exports = baseIndexOfWith; /***/ }, /* 209 */ /***/function (module, exports, __webpack_require__) { var arrayEach = __webpack_require__(64), baseEach = __webpack_require__(210), castFunction = __webpack_require__(213), isArray = __webpack_require__(6); /** * Iterates over elements of `collection` and invokes `iteratee` for each element. * The iteratee is invoked with three arguments: (value, index|key, collection). * Iteratee functions may exit iteration early by explicitly returning `false`. * * **Note:** As with other "Collections" methods, objects with a "length" * property are iterated like arrays. To avoid this behavior use `_.forIn` * or `_.forOwn` for object iteration. * * @static * @memberOf _ * @since 0.1.0 * @alias each * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. * @returns {Array|Object} Returns `collection`. * @see _.forEachRight * @example * * _.forEach([1, 2], function(value) { * console.log(value); * }); * // => Logs `1` then `2`. * * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { * console.log(key); * }); * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forEach(collection, iteratee) { var func = isArray(collection) ? arrayEach : baseEach; return func(collection, castFunction(iteratee)); } module.exports = forEach; /***/ }, /* 210 */ /***/function (module, exports, __webpack_require__) { var baseForOwn = __webpack_require__(211), createBaseEach = __webpack_require__(212); /** * The base implementation of `_.forEach` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array|Object} Returns `collection`. */ var baseEach = createBaseEach(baseForOwn); module.exports = baseEach; /***/ }, /* 211 */ /***/function (module, exports, __webpack_require__) { var baseFor = __webpack_require__(81), keys = __webpack_require__(13); /** * The base implementation of `_.forOwn` without support for iteratee shorthands. * * @private * @param {Object} object The object to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Object} Returns `object`. */ function baseForOwn(object, iteratee) { return object && baseFor(object, iteratee, keys); } module.exports = baseForOwn; /***/ }, /* 212 */ /***/function (module, exports, __webpack_require__) { var isArrayLike = __webpack_require__(9); /** * Creates a `baseEach` or `baseEachRight` function. * * @private * @param {Function} eachFunc The function to iterate over a collection. * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {Function} Returns the new base function. */ function createBaseEach(eachFunc, fromRight) { return function (collection, iteratee) { if (collection == null) { return collection; } if (!isArrayLike(collection)) { return eachFunc(collection, iteratee); } var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection); while (fromRight ? index-- : ++index < length) { if (iteratee(iterable[index], index, iterable) === false) { break; } } return collection; }; } module.exports = createBaseEach; /***/ }, /* 213 */ /***/function (module, exports, __webpack_require__) { var identity = __webpack_require__(44); /** * Casts `value` to `identity` if it's not a function. * * @private * @param {*} value The value to inspect. * @returns {Function} Returns cast function. */ function castFunction(value) { return typeof value == 'function' ? value : identity; } module.exports = castFunction; /***/ }, /* 214 */ /***/function (module, exports, __webpack_require__) { var baseIsEqual = __webpack_require__(215); /** * Performs a deep comparison between two values to determine if they are * equivalent. * * **Note:** This method supports comparing arrays, array buffers, booleans, * date objects, error objects, maps, numbers, `Object` objects, regexes, * sets, strings, symbols, and typed arrays. `Object` objects are compared * by their own, not inherited, enumerable properties. Functions and DOM * nodes are compared by strict equality, i.e. `===`. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * var object = { 'a': 1 }; * var other = { 'a': 1 }; * * _.isEqual(object, other); * // => true * * object === other; * // => false */ function isEqual(value, other) { return baseIsEqual(value, other); } module.exports = isEqual; /***/ }, /* 215 */ /***/function (module, exports, __webpack_require__) { var baseIsEqualDeep = __webpack_require__(216), isObjectLike = __webpack_require__(5); /** * The base implementation of `_.isEqual` which supports partial comparisons * and tracks traversed objects. * * @private * @param {*} value The value to compare. * @param {*} other The other value to compare. * @param {boolean} bitmask The bitmask flags. * 1 - Unordered comparison * 2 - Partial comparison * @param {Function} [customizer] The function to customize comparisons. * @param {Object} [stack] Tracks traversed `value` and `other` objects. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ function baseIsEqual(value, other, bitmask, customizer, stack) { if (value === other) { return true; } if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) { return value !== value && other !== other; } return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); } module.exports = baseIsEqual; /***/ }, /* 216 */ /***/function (module, exports, __webpack_require__) { var Stack = __webpack_require__(36), equalArrays = __webpack_require__(84), equalByTag = __webpack_require__(222), equalObjects = __webpack_require__(223), getTag = __webpack_require__(21), isArray = __webpack_require__(6), isBuffer = __webpack_require__(17), isTypedArray = __webpack_require__(22); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1; /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', objectTag = '[object Object]'; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * A specialized version of `baseIsEqual` for arrays and objects which performs * deep comparisons and tracks traversed objects enabling objects with circular * references to be compared. * * @private * @param {Object} object The object to compare. * @param {Object} other The other object to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} [stack] Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other); objTag = objTag == argsTag ? objectTag : objTag; othTag = othTag == argsTag ? objectTag : othTag; var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; if (isSameTag && isBuffer(object)) { if (!isBuffer(other)) { return false; } objIsArr = true; objIsObj = false; } if (isSameTag && !objIsObj) { stack || (stack = new Stack()); return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); } if (!(bitmask & COMPARE_PARTIAL_FLAG)) { var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); if (objIsWrapped || othIsWrapped) { var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other; stack || (stack = new Stack()); return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); } } if (!isSameTag) { return false; } stack || (stack = new Stack()); return equalObjects(object, other, bitmask, customizer, equalFunc, stack); } module.exports = baseIsEqualDeep; /***/ }, /* 217 */ /***/function (module, exports, __webpack_require__) { var MapCache = __webpack_require__(63), setCacheAdd = __webpack_require__(218), setCacheHas = __webpack_require__(219); /** * * Creates an array cache object to store unique values. * * @private * @constructor * @param {Array} [values] The values to cache. */ function SetCache(values) { var index = -1, length = values == null ? 0 : values.length; this.__data__ = new MapCache(); while (++index < length) { this.add(values[index]); } } // Add methods to `SetCache`. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; SetCache.prototype.has = setCacheHas; module.exports = SetCache; /***/ }, /* 218 */ /***/function (module, exports) { /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; /** * Adds `value` to the array cache. * * @private * @name add * @memberOf SetCache * @alias push * @param {*} value The value to cache. * @returns {Object} Returns the cache instance. */ function setCacheAdd(value) { this.__data__.set(value, HASH_UNDEFINED); return this; } module.exports = setCacheAdd; /***/ }, /* 219 */ /***/function (module, exports) { /** * Checks if `value` is in the array cache. * * @private * @name has * @memberOf SetCache * @param {*} value The value to search for. * @returns {number} Returns `true` if `value` is found, else `false`. */ function setCacheHas(value) { return this.__data__.has(value); } module.exports = setCacheHas; /***/ }, /* 220 */ /***/function (module, exports) { /** * A specialized version of `_.some` for arrays without support for iteratee * shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. */ function arraySome(array, predicate) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (predicate(array[index], index, array)) { return true; } } return false; } module.exports = arraySome; /***/ }, /* 221 */ /***/function (module, exports) { /** * Checks if a `cache` value for `key` exists. * * @private * @param {Object} cache The cache to query. * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function cacheHas(cache, key) { return cache.has(key); } module.exports = cacheHas; /***/ }, /* 222 */ /***/function (module, exports, __webpack_require__) { var _Symbol = __webpack_require__(11), Uint8Array = __webpack_require__(74), eq = __webpack_require__(18), equalArrays = __webpack_require__(84), mapToArray = __webpack_require__(42), setToArray = __webpack_require__(43); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** `Object#toString` result references. */ var boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', mapTag = '[object Map]', numberTag = '[object Number]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', symbolTag = '[object Symbol]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]'; /** Used to convert symbols to primitives and strings. */ var symbolProto = _Symbol ? _Symbol.prototype : undefined, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; /** * A specialized version of `baseIsEqualDeep` for comparing objects of * the same `toStringTag`. * * **Note:** This function only supports comparing values with tags of * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. * * @private * @param {Object} object The object to compare. * @param {Object} other The other object to compare. * @param {string} tag The `toStringTag` of the objects to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { switch (tag) { case dataViewTag: if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { return false; } object = object.buffer; other = other.buffer; case arrayBufferTag: if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) { return false; } return true; case boolTag: case dateTag: case numberTag: // Coerce booleans to `1` or `0` and dates to milliseconds. // Invalid dates are coerced to `NaN`. return eq(+object, +other); case errorTag: return object.name == other.name && object.message == other.message; case regexpTag: case stringTag: // Coerce regexes to strings and treat strings, primitives and objects, // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring // for more details. return object == other + ''; case mapTag: var convert = mapToArray; case setTag: var isPartial = bitmask & COMPARE_PARTIAL_FLAG; convert || (convert = setToArray); if (object.size != other.size && !isPartial) { return false; } // Assume cyclic values are equal. var stacked = stack.get(object); if (stacked) { return stacked == other; } bitmask |= COMPARE_UNORDERED_FLAG; // Recursively compare objects (susceptible to call stack limits). stack.set(object, other); var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); stack['delete'](object); return result; case symbolTag: if (symbolValueOf) { return symbolValueOf.call(object) == symbolValueOf.call(other); } } return false; } module.exports = equalByTag; /***/ }, /* 223 */ /***/function (module, exports, __webpack_require__) { var getAllKeys = __webpack_require__(72); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * A specialized version of `baseIsEqualDeep` for objects with support for * partial deep comparisons. * * @private * @param {Object} object The object to compare. * @param {Object} other The other object to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length; if (objLength != othLength && !isPartial) { return false; } var index = objLength; while (index--) { var key = objProps[index]; if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { return false; } } // Assume cyclic values are equal. var stacked = stack.get(object); if (stacked && stack.get(other)) { return stacked == other; } var result = true; stack.set(object, other); stack.set(other, object); var skipCtor = isPartial; while (++index < objLength) { key = objProps[index]; var objValue = object[key], othValue = other[key]; if (customizer) { var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); } // Recursively compare objects (susceptible to call stack limits). if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) { result = false; break; } skipCtor || (skipCtor = key == 'constructor'); } if (result && !skipCtor) { var objCtor = object.constructor, othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { result = false; } } stack['delete'](object); stack['delete'](other); return result; } module.exports = equalObjects; /***/ }, /* 224 */ /***/function (module, exports, __webpack_require__) { var _Symbol = __webpack_require__(11), copyArray = __webpack_require__(28), getTag = __webpack_require__(21), isArrayLike = __webpack_require__(9), isString = __webpack_require__(56), iteratorToArray = __webpack_require__(225), mapToArray = __webpack_require__(42), setToArray = __webpack_require__(43), stringToArray = __webpack_require__(83), values = __webpack_require__(226); /** `Object#toString` result references. */ var mapTag = '[object Map]', setTag = '[object Set]'; /** Built-in value references. */ var symIterator = _Symbol ? _Symbol.iterator : undefined; /** * Converts `value` to an array. * * @static * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to convert. * @returns {Array} Returns the converted array. * @example * * _.toArray({ 'a': 1, 'b': 2 }); * // => [1, 2] * * _.toArray('abc'); * // => ['a', 'b', 'c'] * * _.toArray(1); * // => [] * * _.toArray(null); * // => [] */ function toArray(value) { if (!value) { return []; } if (isArrayLike(value)) { return isString(value) ? stringToArray(value) : copyArray(value); } if (symIterator && value[symIterator]) { return iteratorToArray(value[symIterator]()); } var tag = getTag(value), func = tag == mapTag ? mapToArray : tag == setTag ? setToArray : values; return func(value); } module.exports = toArray; /***/ }, /* 225 */ /***/function (module, exports) { /** * Converts `iterator` to an array. * * @private * @param {Object} iterator The iterator to convert. * @returns {Array} Returns the converted array. */ function iteratorToArray(iterator) { var data, result = []; while (!(data = iterator.next()).done) { result.push(data.value); } return result; } module.exports = iteratorToArray; /***/ }, /* 226 */ /***/function (module, exports, __webpack_require__) { var baseValues = __webpack_require__(227), keys = __webpack_require__(13); /** * Creates an array of the own enumerable string keyed property values of `object`. * * **Note:** Non-object values are coerced to objects. * * @static * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property values. * @example * * function Foo() { * this.a = 1; * this.b = 2; * } * * Foo.prototype.c = 3; * * _.values(new Foo); * // => [1, 2] (iteration order is not guaranteed) * * _.values('hi'); * // => ['h', 'i'] */ function values(object) { return object == null ? [] : baseValues(object, keys(object)); } module.exports = values; /***/ }, /* 227 */ /***/function (module, exports, __webpack_require__) { var arrayMap = __webpack_require__(35); /** * The base implementation of `_.values` and `_.valuesIn` which creates an * array of `object` property values corresponding to the property names * of `props`. * * @private * @param {Object} object The object to query. * @param {Array} props The property names to get values for. * @returns {Object} Returns the array of property values. */ function baseValues(object, props) { return arrayMap(props, function (key) { return object[key]; }); } module.exports = baseValues; /***/ }, /* 228 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var ALIAS_ATTRS = ['strokeStyle', 'fillStyle', 'globalAlpha']; var CLIP_SHAPES = ['circle', 'ellipse', 'fan', 'polygon', 'rect', 'path']; var CAPITALIZED_ATTRS_MAP = { r: 'R', opacity: 'Opacity', lineWidth: 'LineWidth', clip: 'Clip', stroke: 'Stroke', fill: 'Fill', strokeOpacity: 'Stroke', fillOpacity: 'Fill', x: 'X', y: 'Y', rx: 'Rx', ry: 'Ry', re: 'Re', rs: 'Rs', width: 'Width', height: 'Height', img: 'Img', x1: 'X1', x2: 'X2', y1: 'Y1', y2: 'Y2', points: 'Points', p1: 'P1', p2: 'P2', p3: 'P3', p4: 'P4', text: 'Text', radius: 'Radius', textAlign: 'TextAlign', textBaseline: 'TextBaseline', font: 'Font', fontSize: 'FontSize', fontStyle: 'FontStyle', fontVariant: 'FontVariant', fontWeight: 'FontWeight', fontFamily: 'FontFamily', clockwise: 'Clockwise', startAngle: 'StartAngle', endAngle: 'EndAngle', path: 'Path' }; var ALIAS_ATTRS_MAP = { stroke: 'strokeStyle', fill: 'fillStyle', opacity: 'globalAlpha' }; module.exports = { canFill: false, canStroke: false, initAttrs: function initAttrs(attrs) { this.__attrs = { opacity: 1, fillOpacity: 1, strokeOpacity: 1 }; this.attr(Util.assign(this.getDefaultAttrs(), attrs)); return this; }, getDefaultAttrs: function getDefaultAttrs() { return {}; }, /** * 设置或者设置属性,有以下 4 种情形: * - name 不存在, 则返回属性集合 * - name 为字符串,value 为空,获取属性值 * - name 为字符串,value 不为空,设置属性值,返回 this * - name 为键值对,value 为空,设置属性值 * * @param {String | Object} name 属性名 * @param {*} value 属性值 * @return {*} 属性值 */ attr: function attr(name, value) { var self = this; if (arguments.length === 0) { return self.__attrs; } if (Util.isObject(name)) { for (var k in name) { if (ALIAS_ATTRS.indexOf(k) === -1) { var v = name[k]; self._setAttr(k, v); } } if (self.__afterSetAttrAll) { self.__afterSetAttrAll(name); } // self.setSilent('box', null); self.clearBBox(); return self; } if (arguments.length === 2) { if (self._setAttr(name, value) !== false) { var m = '__afterSetAttr' + CAPITALIZED_ATTRS_MAP[name]; if (self[m]) { self[m](value); } } // self.setSilent('box', null); self.clearBBox(); return self; } return self._getAttr(name); }, clearBBox: function clearBBox() { this.setSilent('box', null); }, __afterSetAttrAll: function __afterSetAttrAll() {}, // 属性获取触发函数 _getAttr: function _getAttr(name) { return this.__attrs[name]; }, // 属性设置触发函数 _setAttr: function _setAttr(name, value) { var self = this; if (name === 'clip') { self.__setAttrClip(value); self.__attrs.clip = value; } else if (name === 'transform') { self.__setAttrTrans(value); } else { self.__attrs[name] = value; var alias = ALIAS_ATTRS_MAP[name]; if (alias) { self.__attrs[alias] = value; } } return self; }, hasFill: function hasFill() { return this.canFill && this.__attrs.fillStyle; }, hasStroke: function hasStroke() { return this.canStroke && this.__attrs.strokeStyle; }, // 设置透明度 __setAttrOpacity: function __setAttrOpacity(v) { this.__attrs.globalAlpha = v; return v; }, __setAttrClip: function __setAttrClip(clip) { var self = this; if (clip && CLIP_SHAPES.indexOf(clip.type) > -1) { if (clip.get('canvas') === null) { clip = Util.clone(clip); } clip.set('parent', self.get('parent')); clip.set('context', self.get('context')); clip.inside = function (x, y) { var v = [x, y, 1]; clip.invert(v, self.get('canvas')); // 已经在外面转换 return clip.__isPointInFill(v[0], v[1]); }; return clip; } return null; }, __setAttrTrans: function __setAttrTrans(value) { return this.transform(value); } }; /***/ }, /* 229 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var mat3 = __webpack_require__(3).mat3; var vec3 = __webpack_require__(3).vec3; // 是否未改变 function isUnchanged(m) { return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0; } // 是否仅仅是scale function isScale(m) { return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0; } function multiple(m1, m2) { if (!isUnchanged(m2)) { if (isScale(m2)) { m1[0] *= m2[0]; m1[4] *= m2[4]; } else { mat3.multiply(m1, m1, m2); } } } module.exports = { initTransform: function initTransform() { this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]); }, translate: function translate(tx, ty) { var matrix = this.attr('matrix'); mat3.translate(matrix, matrix, [tx, ty]); this.clearTotalMatrix(); this.attr('matrix', matrix); return this; }, rotate: function rotate(radian) { var matrix = this.attr('matrix'); mat3.rotate(matrix, matrix, radian); this.clearTotalMatrix(); this.attr('matrix', matrix); return this; }, scale: function scale(s1, s2) { var matrix = this.attr('matrix'); mat3.scale(matrix, matrix, [s1, s2]); this.clearTotalMatrix(); this.attr('matrix', matrix); return this; }, /** * 绕起始点旋转 * @param {Number} rotate 0~360 */ rotateAtStart: function rotateAtStart(rotate) { var x = this.attr('x'); var y = this.attr('y'); if (Math.abs(rotate) > Math.PI * 2) { rotate = rotate / 180 * Math.PI; } this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]); }, /** * 移动的到位置 * @param {Number} x 移动到x * @param {Number} y 移动到y */ move: function move(x, y) { var cx = this.get('x') || 0; // 当前的x var cy = this.get('y') || 0; // 当前的y this.translate(x - cx, y - cy); this.set('x', x); this.set('y', y); }, transform: function transform(ts) { var self = this; var matrix = self.attr('matrix'); Util.each(ts, function (t) { switch (t[0]) { case 't': self.translate(t[1], t[2]); break; case 's': self.scale(t[1], t[2]); break; case 'r': self.rotate(t[1]); break; case 'm': self.attr('matrix', mat3.multiply([], matrix, t[1])); self.clearTotalMatrix(); break; default: break; } }); return self; }, setTransform: function setTransform(ts) { this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]); return this.transform(ts); }, getMatrix: function getMatrix() { return this.attr('matrix'); }, setMatrix: function setMatrix(m) { this.attr('matrix', m); this.clearTotalMatrix(); return this; }, apply: function apply(v, root) { var m = void 0; if (root) { m = this._getMatrixByRoot(root); } else { m = this.attr('matrix'); } vec3.transformMat3(v, v, m); return this; }, // 获取到达指定根节点的矩阵 _getMatrixByRoot: function _getMatrixByRoot(root) { var self = this; root = root || self; var parent = self; var parents = []; while (parent !== root) { parents.unshift(parent); parent = parent.get('parent'); } parents.unshift(parent); var m = [1, 0, 0, 0, 1, 0, 0, 0, 1]; Util.each(parents, function (child) { mat3.multiply(m, child.attr('matrix'), m); }); return m; }, /** * 应用到当前元素上的总的矩阵 * @return {Matrix} 矩阵 */ getTotalMatrix: function getTotalMatrix() { var m = this.__cfg.totalMatrix; if (!m) { m = [1, 0, 0, 0, 1, 0, 0, 0, 1]; var parent = this.__cfg.parent; if (parent) { var pm = parent.getTotalMatrix(); multiple(m, pm); } multiple(m, this.attr('matrix')); this.__cfg.totalMatrix = m; } return m; }, // 清除当前的矩阵 clearTotalMatrix: function clearTotalMatrix() { // this.__cfg.totalMatrix = null; }, invert: function invert(v) { var m = this.getTotalMatrix(); // 单精屏幕下大多数矩阵没变化 if (isScale(m)) { v[0] /= m[0]; v[1] /= m[4]; } else { var inm = mat3.invert([], m); vec3.transformMat3(v, v, inm); } return this; }, resetTransform: function resetTransform(context) { var mo = this.attr('matrix'); // 不改变时 if (!isUnchanged(mo)) { context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]); } } }; /***/ }, /* 230 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony export (immutable) */__webpack_exports__["create"] = create; /* harmony export (immutable) */__webpack_exports__["fromMat4"] = fromMat4; /* harmony export (immutable) */__webpack_exports__["clone"] = clone; /* harmony export (immutable) */__webpack_exports__["copy"] = copy; /* harmony export (immutable) */__webpack_exports__["fromValues"] = fromValues; /* harmony export (immutable) */__webpack_exports__["set"] = set; /* harmony export (immutable) */__webpack_exports__["identity"] = identity; /* harmony export (immutable) */__webpack_exports__["transpose"] = transpose; /* harmony export (immutable) */__webpack_exports__["invert"] = invert; /* harmony export (immutable) */__webpack_exports__["adjoint"] = adjoint; /* harmony export (immutable) */__webpack_exports__["determinant"] = determinant; /* harmony export (immutable) */__webpack_exports__["multiply"] = multiply; /* harmony export (immutable) */__webpack_exports__["translate"] = translate; /* harmony export (immutable) */__webpack_exports__["rotate"] = rotate; /* harmony export (immutable) */__webpack_exports__["scale"] = scale; /* harmony export (immutable) */__webpack_exports__["fromTranslation"] = fromTranslation; /* harmony export (immutable) */__webpack_exports__["fromRotation"] = fromRotation; /* harmony export (immutable) */__webpack_exports__["fromScaling"] = fromScaling; /* harmony export (immutable) */__webpack_exports__["fromMat2d"] = fromMat2d; /* harmony export (immutable) */__webpack_exports__["fromQuat"] = fromQuat; /* harmony export (immutable) */__webpack_exports__["normalFromMat4"] = normalFromMat4; /* harmony export (immutable) */__webpack_exports__["projection"] = projection; /* harmony export (immutable) */__webpack_exports__["str"] = str; /* harmony export (immutable) */__webpack_exports__["frob"] = frob; /* harmony export (immutable) */__webpack_exports__["add"] = add; /* harmony export (immutable) */__webpack_exports__["subtract"] = subtract; /* harmony export (immutable) */__webpack_exports__["multiplyScalar"] = multiplyScalar; /* harmony export (immutable) */__webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd; /* harmony export (immutable) */__webpack_exports__["exactEquals"] = exactEquals; /* harmony export (immutable) */__webpack_exports__["equals"] = equals; /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "mul", function () { return mul; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sub", function () { return sub; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(45); /* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** * 3x3 Matrix * @module mat3 */ /** * Creates a new identity mat3 * * @returns {mat3} a new 3x3 matrix */ function create() { var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* ARRAY_TYPE */](9); out[0] = 1; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = 1; out[5] = 0; out[6] = 0; out[7] = 0; out[8] = 1; return out; } /** * Copies the upper-left 3x3 values into the given mat3. * * @param {mat3} out the receiving 3x3 matrix * @param {mat4} a the source 4x4 matrix * @returns {mat3} out */ function fromMat4(out, a) { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[4]; out[4] = a[5]; out[5] = a[6]; out[6] = a[8]; out[7] = a[9]; out[8] = a[10]; return out; } /** * Creates a new mat3 initialized with values from an existing matrix * * @param {mat3} a matrix to clone * @returns {mat3} a new 3x3 matrix */ function clone(a) { var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* ARRAY_TYPE */](9); out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; out[4] = a[4]; out[5] = a[5]; out[6] = a[6]; out[7] = a[7]; out[8] = a[8]; return out; } /** * Copy the values from one mat3 to another * * @param {mat3} out the receiving matrix * @param {mat3} a the source matrix * @returns {mat3} out */ function copy(out, a) { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3]; out[4] = a[4]; out[5] = a[5]; out[6] = a[6]; out[7] = a[7]; out[8] = a[8]; return out; } /** * Create a new mat3 with the given values * * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m02 Component in column 0, row 2 position (index 2) * @param {Number} m10 Component in column 1, row 0 position (index 3) * @param {Number} m11 Component in column 1, row 1 position (index 4) * @param {Number} m12 Component in column 1, row 2 position (index 5) * @param {Number} m20 Component in column 2, row 0 position (index 6) * @param {Number} m21 Component in column 2, row 1 position (index 7) * @param {Number} m22 Component in column 2, row 2 position (index 8) * @returns {mat3} A new mat3 */ function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) { var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* ARRAY_TYPE */](9); out[0] = m00; out[1] = m01; out[2] = m02; out[3] = m10; out[4] = m11; out[5] = m12; out[6] = m20; out[7] = m21; out[8] = m22; return out; } /** * Set the components of a mat3 to the given values * * @param {mat3} out the receiving matrix * @param {Number} m00 Component in column 0, row 0 position (index 0) * @param {Number} m01 Component in column 0, row 1 position (index 1) * @param {Number} m02 Component in column 0, row 2 position (index 2) * @param {Number} m10 Component in column 1, row 0 position (index 3) * @param {Number} m11 Component in column 1, row 1 position (index 4) * @param {Number} m12 Component in column 1, row 2 position (index 5) * @param {Number} m20 Component in column 2, row 0 position (index 6) * @param {Number} m21 Component in column 2, row 1 position (index 7) * @param {Number} m22 Component in column 2, row 2 position (index 8) * @returns {mat3} out */ function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) { out[0] = m00; out[1] = m01; out[2] = m02; out[3] = m10; out[4] = m11; out[5] = m12; out[6] = m20; out[7] = m21; out[8] = m22; return out; } /** * Set a mat3 to the identity matrix * * @param {mat3} out the receiving matrix * @returns {mat3} out */ function identity(out) { out[0] = 1; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = 1; out[5] = 0; out[6] = 0; out[7] = 0; out[8] = 1; return out; } /** * Transpose the values of a mat3 * * @param {mat3} out the receiving matrix * @param {mat3} a the source matrix * @returns {mat3} out */ function transpose(out, a) { // If we are transposing ourselves we can skip a few steps but have to cache some values if (out === a) { var a01 = a[1], a02 = a[2], a12 = a[5]; out[1] = a[3]; out[2] = a[6]; out[3] = a01; out[5] = a[7]; out[6] = a02; out[7] = a12; } else { out[0] = a[0]; out[1] = a[3]; out[2] = a[6]; out[3] = a[1]; out[4] = a[4]; out[5] = a[7]; out[6] = a[2]; out[7] = a[5]; out[8] = a[8]; } return out; } /** * Inverts a mat3 * * @param {mat3} out the receiving matrix * @param {mat3} a the source matrix * @returns {mat3} out */ function invert(out, a) { var a00 = a[0], a01 = a[1], a02 = a[2]; var a10 = a[3], a11 = a[4], a12 = a[5]; var a20 = a[6], a21 = a[7], a22 = a[8]; var b01 = a22 * a11 - a12 * a21; var b11 = -a22 * a10 + a12 * a20; var b21 = a21 * a10 - a11 * a20; // Calculate the determinant var det = a00 * b01 + a01 * b11 + a02 * b21; if (!det) { return null; } det = 1.0 / det; out[0] = b01 * det; out[1] = (-a22 * a01 + a02 * a21) * det; out[2] = (a12 * a01 - a02 * a11) * det; out[3] = b11 * det; out[4] = (a22 * a00 - a02 * a20) * det; out[5] = (-a12 * a00 + a02 * a10) * det; out[6] = b21 * det; out[7] = (-a21 * a00 + a01 * a20) * det; out[8] = (a11 * a00 - a01 * a10) * det; return out; } /** * Calculates the adjugate of a mat3 * * @param {mat3} out the receiving matrix * @param {mat3} a the source matrix * @returns {mat3} out */ function adjoint(out, a) { var a00 = a[0], a01 = a[1], a02 = a[2]; var a10 = a[3], a11 = a[4], a12 = a[5]; var a20 = a[6], a21 = a[7], a22 = a[8]; out[0] = a11 * a22 - a12 * a21; out[1] = a02 * a21 - a01 * a22; out[2] = a01 * a12 - a02 * a11; out[3] = a12 * a20 - a10 * a22; out[4] = a00 * a22 - a02 * a20; out[5] = a02 * a10 - a00 * a12; out[6] = a10 * a21 - a11 * a20; out[7] = a01 * a20 - a00 * a21; out[8] = a00 * a11 - a01 * a10; return out; } /** * Calculates the determinant of a mat3 * * @param {mat3} a the source matrix * @returns {Number} determinant of a */ function determinant(a) { var a00 = a[0], a01 = a[1], a02 = a[2]; var a10 = a[3], a11 = a[4], a12 = a[5]; var a20 = a[6], a21 = a[7], a22 = a[8]; return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); } /** * Multiplies two mat3's * * @param {mat3} out the receiving matrix * @param {mat3} a the first operand * @param {mat3} b the second operand * @returns {mat3} out */ function multiply(out, a, b) { var a00 = a[0], a01 = a[1], a02 = a[2]; var a10 = a[3], a11 = a[4], a12 = a[5]; var a20 = a[6], a21 = a[7], a22 = a[8]; var b00 = b[0], b01 = b[1], b02 = b[2]; var b10 = b[3], b11 = b[4], b12 = b[5]; var b20 = b[6], b21 = b[7], b22 = b[8]; out[0] = b00 * a00 + b01 * a10 + b02 * a20; out[1] = b00 * a01 + b01 * a11 + b02 * a21; out[2] = b00 * a02 + b01 * a12 + b02 * a22; out[3] = b10 * a00 + b11 * a10 + b12 * a20; out[4] = b10 * a01 + b11 * a11 + b12 * a21; out[5] = b10 * a02 + b11 * a12 + b12 * a22; out[6] = b20 * a00 + b21 * a10 + b22 * a20; out[7] = b20 * a01 + b21 * a11 + b22 * a21; out[8] = b20 * a02 + b21 * a12 + b22 * a22; return out; } /** * Translate a mat3 by the given vector * * @param {mat3} out the receiving matrix * @param {mat3} a the matrix to translate * @param {vec2} v vector to translate by * @returns {mat3} out */ function translate(out, a, v) { var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], x = v[0], y = v[1]; out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a10; out[4] = a11; out[5] = a12; out[6] = x * a00 + y * a10 + a20; out[7] = x * a01 + y * a11 + a21; out[8] = x * a02 + y * a12 + a22; return out; } /** * Rotates a mat3 by the given angle * * @param {mat3} out the receiving matrix * @param {mat3} a the matrix to rotate * @param {Number} rad the angle to rotate the matrix by * @returns {mat3} out */ function rotate(out, a, rad) { var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], s = Math.sin(rad), c = Math.cos(rad); out[0] = c * a00 + s * a10; out[1] = c * a01 + s * a11; out[2] = c * a02 + s * a12; out[3] = c * a10 - s * a00; out[4] = c * a11 - s * a01; out[5] = c * a12 - s * a02; out[6] = a20; out[7] = a21; out[8] = a22; return out; }; /** * Scales the mat3 by the dimensions in the given vec2 * * @param {mat3} out the receiving matrix * @param {mat3} a the matrix to rotate * @param {vec2} v the vec2 to scale the matrix by * @returns {mat3} out **/ function scale(out, a, v) { var x = v[0], y = v[1]; out[0] = x * a[0]; out[1] = x * a[1]; out[2] = x * a[2]; out[3] = y * a[3]; out[4] = y * a[4]; out[5] = y * a[5]; out[6] = a[6]; out[7] = a[7]; out[8] = a[8]; return out; } /** * Creates a matrix from a vector translation * This is equivalent to (but much faster than): * * mat3.identity(dest); * mat3.translate(dest, dest, vec); * * @param {mat3} out mat3 receiving operation result * @param {vec2} v Translation vector * @returns {mat3} out */ function fromTranslation(out, v) { out[0] = 1; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = 1; out[5] = 0; out[6] = v[0]; out[7] = v[1]; out[8] = 1; return out; } /** * Creates a matrix from a given angle * This is equivalent to (but much faster than): * * mat3.identity(dest); * mat3.rotate(dest, dest, rad); * * @param {mat3} out mat3 receiving operation result * @param {Number} rad the angle to rotate the matrix by * @returns {mat3} out */ function fromRotation(out, rad) { var s = Math.sin(rad), c = Math.cos(rad); out[0] = c; out[1] = s; out[2] = 0; out[3] = -s; out[4] = c; out[5] = 0; out[6] = 0; out[7] = 0; out[8] = 1; return out; } /** * Creates a matrix from a vector scaling * This is equivalent to (but much faster than): * * mat3.identity(dest); * mat3.scale(dest, dest, vec); * * @param {mat3} out mat3 receiving operation result * @param {vec2} v Scaling vector * @returns {mat3} out */ function fromScaling(out, v) { out[0] = v[0]; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = v[1]; out[5] = 0; out[6] = 0; out[7] = 0; out[8] = 1; return out; } /** * Copies the values from a mat2d into a mat3 * * @param {mat3} out the receiving matrix * @param {mat2d} a the matrix to copy * @returns {mat3} out **/ function fromMat2d(out, a) { out[0] = a[0]; out[1] = a[1]; out[2] = 0; out[3] = a[2]; out[4] = a[3]; out[5] = 0; out[6] = a[4]; out[7] = a[5]; out[8] = 1; return out; } /** * Calculates a 3x3 matrix from the given quaternion * * @param {mat3} out mat3 receiving operation result * @param {quat} q Quaternion to create matrix from * * @returns {mat3} out */ function fromQuat(out, q) { var x = q[0], y = q[1], z = q[2], w = q[3]; var x2 = x + x; var y2 = y + y; var z2 = z + z; var xx = x * x2; var yx = y * x2; var yy = y * y2; var zx = z * x2; var zy = z * y2; var zz = z * z2; var wx = w * x2; var wy = w * y2; var wz = w * z2; out[0] = 1 - yy - zz; out[3] = yx - wz; out[6] = zx + wy; out[1] = yx + wz; out[4] = 1 - xx - zz; out[7] = zy - wx; out[2] = zx - wy; out[5] = zy + wx; out[8] = 1 - xx - yy; return out; } /** * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix * * @param {mat3} out mat3 receiving operation result * @param {mat4} a Mat4 to derive the normal matrix from * * @returns {mat3} out */ function normalFromMat4(out, a) { var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; var b00 = a00 * a11 - a01 * a10; var b01 = a00 * a12 - a02 * a10; var b02 = a00 * a13 - a03 * a10; var b03 = a01 * a12 - a02 * a11; var b04 = a01 * a13 - a03 * a11; var b05 = a02 * a13 - a03 * a12; var b06 = a20 * a31 - a21 * a30; var b07 = a20 * a32 - a22 * a30; var b08 = a20 * a33 - a23 * a30; var b09 = a21 * a32 - a22 * a31; var b10 = a21 * a33 - a23 * a31; var b11 = a22 * a33 - a23 * a32; // Calculate the determinant var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; if (!det) { return null; } det = 1.0 / det; out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; return out; } /** * Generates a 2D projection matrix with the given bounds * * @param {mat3} out mat3 frustum matrix will be written into * @param {number} width Width of your gl context * @param {number} height Height of gl context * @returns {mat3} out */ function projection(out, width, height) { out[0] = 2 / width; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = -2 / height; out[5] = 0; out[6] = -1; out[7] = 1; out[8] = 1; return out; } /** * Returns a string representation of a mat3 * * @param {mat3} a matrix to represent as a string * @returns {String} string representation of the matrix */ function str(a) { return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')'; } /** * Returns Frobenius norm of a mat3 * * @param {mat3} a the matrix to calculate Frobenius norm of * @returns {Number} Frobenius norm */ function frob(a) { return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2)); } /** * Adds two mat3's * * @param {mat3} out the receiving matrix * @param {mat3} a the first operand * @param {mat3} b the second operand * @returns {mat3} out */ function add(out, a, b) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; out[2] = a[2] + b[2]; out[3] = a[3] + b[3]; out[4] = a[4] + b[4]; out[5] = a[5] + b[5]; out[6] = a[6] + b[6]; out[7] = a[7] + b[7]; out[8] = a[8] + b[8]; return out; } /** * Subtracts matrix b from matrix a * * @param {mat3} out the receiving matrix * @param {mat3} a the first operand * @param {mat3} b the second operand * @returns {mat3} out */ function subtract(out, a, b) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; out[2] = a[2] - b[2]; out[3] = a[3] - b[3]; out[4] = a[4] - b[4]; out[5] = a[5] - b[5]; out[6] = a[6] - b[6]; out[7] = a[7] - b[7]; out[8] = a[8] - b[8]; return out; } /** * Multiply each element of the matrix by a scalar. * * @param {mat3} out the receiving matrix * @param {mat3} a the matrix to scale * @param {Number} b amount to scale the matrix's elements by * @returns {mat3} out */ function multiplyScalar(out, a, b) { out[0] = a[0] * b; out[1] = a[1] * b; out[2] = a[2] * b; out[3] = a[3] * b; out[4] = a[4] * b; out[5] = a[5] * b; out[6] = a[6] * b; out[7] = a[7] * b; out[8] = a[8] * b; return out; } /** * Adds two mat3's after multiplying each element of the second operand by a scalar value. * * @param {mat3} out the receiving vector * @param {mat3} a the first operand * @param {mat3} b the second operand * @param {Number} scale the amount to scale b's elements by before adding * @returns {mat3} out */ function multiplyScalarAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; out[1] = a[1] + b[1] * scale; out[2] = a[2] + b[2] * scale; out[3] = a[3] + b[3] * scale; out[4] = a[4] + b[4] * scale; out[5] = a[5] + b[5] * scale; out[6] = a[6] + b[6] * scale; out[7] = a[7] + b[7] * scale; out[8] = a[8] + b[8] * scale; return out; } /** * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===) * * @param {mat3} a The first matrix. * @param {mat3} b The second matrix. * @returns {Boolean} True if the matrices are equal, false otherwise. */ function exactEquals(a, b) { return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8]; } /** * Returns whether or not the matrices have approximately the same elements in the same position. * * @param {mat3} a The first matrix. * @param {mat3} b The second matrix. * @returns {Boolean} True if the matrices are equal, false otherwise. */ function equals(a, b) { var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8]; var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8]; return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a8), Math.abs(b8)); } /** * Alias for {@link mat3.multiply} * @function */ var mul = multiply; /** * Alias for {@link mat3.subtract} * @function */ var sub = subtract; /***/ }, /* 231 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony export (immutable) */__webpack_exports__["create"] = create; /* harmony export (immutable) */__webpack_exports__["clone"] = clone; /* harmony export (immutable) */__webpack_exports__["length"] = length; /* harmony export (immutable) */__webpack_exports__["fromValues"] = fromValues; /* harmony export (immutable) */__webpack_exports__["copy"] = copy; /* harmony export (immutable) */__webpack_exports__["set"] = set; /* harmony export (immutable) */__webpack_exports__["add"] = add; /* harmony export (immutable) */__webpack_exports__["subtract"] = subtract; /* harmony export (immutable) */__webpack_exports__["multiply"] = multiply; /* harmony export (immutable) */__webpack_exports__["divide"] = divide; /* harmony export (immutable) */__webpack_exports__["ceil"] = ceil; /* harmony export (immutable) */__webpack_exports__["floor"] = floor; /* harmony export (immutable) */__webpack_exports__["min"] = min; /* harmony export (immutable) */__webpack_exports__["max"] = max; /* harmony export (immutable) */__webpack_exports__["round"] = round; /* harmony export (immutable) */__webpack_exports__["scale"] = scale; /* harmony export (immutable) */__webpack_exports__["scaleAndAdd"] = scaleAndAdd; /* harmony export (immutable) */__webpack_exports__["distance"] = distance; /* harmony export (immutable) */__webpack_exports__["squaredDistance"] = squaredDistance; /* harmony export (immutable) */__webpack_exports__["squaredLength"] = squaredLength; /* harmony export (immutable) */__webpack_exports__["negate"] = negate; /* harmony export (immutable) */__webpack_exports__["inverse"] = inverse; /* harmony export (immutable) */__webpack_exports__["normalize"] = normalize; /* harmony export (immutable) */__webpack_exports__["dot"] = dot; /* harmony export (immutable) */__webpack_exports__["cross"] = cross; /* harmony export (immutable) */__webpack_exports__["lerp"] = lerp; /* harmony export (immutable) */__webpack_exports__["hermite"] = hermite; /* harmony export (immutable) */__webpack_exports__["bezier"] = bezier; /* harmony export (immutable) */__webpack_exports__["random"] = random; /* harmony export (immutable) */__webpack_exports__["transformMat4"] = transformMat4; /* harmony export (immutable) */__webpack_exports__["transformMat3"] = transformMat3; /* harmony export (immutable) */__webpack_exports__["transformQuat"] = transformQuat; /* harmony export (immutable) */__webpack_exports__["rotateX"] = rotateX; /* harmony export (immutable) */__webpack_exports__["rotateY"] = rotateY; /* harmony export (immutable) */__webpack_exports__["rotateZ"] = rotateZ; /* harmony export (immutable) */__webpack_exports__["angle"] = angle; /* harmony export (immutable) */__webpack_exports__["str"] = str; /* harmony export (immutable) */__webpack_exports__["exactEquals"] = exactEquals; /* harmony export (immutable) */__webpack_exports__["equals"] = equals; /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sub", function () { return sub; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "mul", function () { return mul; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "div", function () { return div; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "dist", function () { return dist; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sqrDist", function () { return sqrDist; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "len", function () { return len; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sqrLen", function () { return sqrLen; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "forEach", function () { return forEach; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(45); /* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** * 3 Dimensional Vector * @module vec3 */ /** * Creates a new, empty vec3 * * @returns {vec3} a new 3D vector */ function create() { var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* ARRAY_TYPE */](3); out[0] = 0; out[1] = 0; out[2] = 0; return out; } /** * Creates a new vec3 initialized with values from an existing vector * * @param {vec3} a vector to clone * @returns {vec3} a new 3D vector */ function clone(a) { var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* ARRAY_TYPE */](3); out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; return out; } /** * Calculates the length of a vec3 * * @param {vec3} a vector to calculate length of * @returns {Number} length of a */ function length(a) { var x = a[0]; var y = a[1]; var z = a[2]; return Math.sqrt(x * x + y * y + z * z); } /** * Creates a new vec3 initialized with the given values * * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component * @returns {vec3} a new 3D vector */ function fromValues(x, y, z) { var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* ARRAY_TYPE */](3); out[0] = x; out[1] = y; out[2] = z; return out; } /** * Copy the values from one vec3 to another * * @param {vec3} out the receiving vector * @param {vec3} a the source vector * @returns {vec3} out */ function copy(out, a) { out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; return out; } /** * Set the components of a vec3 to the given values * * @param {vec3} out the receiving vector * @param {Number} x X component * @param {Number} y Y component * @param {Number} z Z component * @returns {vec3} out */ function set(out, x, y, z) { out[0] = x; out[1] = y; out[2] = z; return out; } /** * Adds two vec3's * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @returns {vec3} out */ function add(out, a, b) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; out[2] = a[2] + b[2]; return out; } /** * Subtracts vector b from vector a * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @returns {vec3} out */ function subtract(out, a, b) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; out[2] = a[2] - b[2]; return out; } /** * Multiplies two vec3's * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @returns {vec3} out */ function multiply(out, a, b) { out[0] = a[0] * b[0]; out[1] = a[1] * b[1]; out[2] = a[2] * b[2]; return out; } /** * Divides two vec3's * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @returns {vec3} out */ function divide(out, a, b) { out[0] = a[0] / b[0]; out[1] = a[1] / b[1]; out[2] = a[2] / b[2]; return out; } /** * Math.ceil the components of a vec3 * * @param {vec3} out the receiving vector * @param {vec3} a vector to ceil * @returns {vec3} out */ function ceil(out, a) { out[0] = Math.ceil(a[0]); out[1] = Math.ceil(a[1]); out[2] = Math.ceil(a[2]); return out; } /** * Math.floor the components of a vec3 * * @param {vec3} out the receiving vector * @param {vec3} a vector to floor * @returns {vec3} out */ function floor(out, a) { out[0] = Math.floor(a[0]); out[1] = Math.floor(a[1]); out[2] = Math.floor(a[2]); return out; } /** * Returns the minimum of two vec3's * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @returns {vec3} out */ function min(out, a, b) { out[0] = Math.min(a[0], b[0]); out[1] = Math.min(a[1], b[1]); out[2] = Math.min(a[2], b[2]); return out; } /** * Returns the maximum of two vec3's * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @returns {vec3} out */ function max(out, a, b) { out[0] = Math.max(a[0], b[0]); out[1] = Math.max(a[1], b[1]); out[2] = Math.max(a[2], b[2]); return out; } /** * Math.round the components of a vec3 * * @param {vec3} out the receiving vector * @param {vec3} a vector to round * @returns {vec3} out */ function round(out, a) { out[0] = Math.round(a[0]); out[1] = Math.round(a[1]); out[2] = Math.round(a[2]); return out; } /** * Scales a vec3 by a scalar number * * @param {vec3} out the receiving vector * @param {vec3} a the vector to scale * @param {Number} b amount to scale the vector by * @returns {vec3} out */ function scale(out, a, b) { out[0] = a[0] * b; out[1] = a[1] * b; out[2] = a[2] * b; return out; } /** * Adds two vec3's after scaling the second operand by a scalar value * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @param {Number} scale the amount to scale b by before adding * @returns {vec3} out */ function scaleAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; out[1] = a[1] + b[1] * scale; out[2] = a[2] + b[2] * scale; return out; } /** * Calculates the euclidian distance between two vec3's * * @param {vec3} a the first operand * @param {vec3} b the second operand * @returns {Number} distance between a and b */ function distance(a, b) { var x = b[0] - a[0]; var y = b[1] - a[1]; var z = b[2] - a[2]; return Math.sqrt(x * x + y * y + z * z); } /** * Calculates the squared euclidian distance between two vec3's * * @param {vec3} a the first operand * @param {vec3} b the second operand * @returns {Number} squared distance between a and b */ function squaredDistance(a, b) { var x = b[0] - a[0]; var y = b[1] - a[1]; var z = b[2] - a[2]; return x * x + y * y + z * z; } /** * Calculates the squared length of a vec3 * * @param {vec3} a vector to calculate squared length of * @returns {Number} squared length of a */ function squaredLength(a) { var x = a[0]; var y = a[1]; var z = a[2]; return x * x + y * y + z * z; } /** * Negates the components of a vec3 * * @param {vec3} out the receiving vector * @param {vec3} a vector to negate * @returns {vec3} out */ function negate(out, a) { out[0] = -a[0]; out[1] = -a[1]; out[2] = -a[2]; return out; } /** * Returns the inverse of the components of a vec3 * * @param {vec3} out the receiving vector * @param {vec3} a vector to invert * @returns {vec3} out */ function inverse(out, a) { out[0] = 1.0 / a[0]; out[1] = 1.0 / a[1]; out[2] = 1.0 / a[2]; return out; } /** * Normalize a vec3 * * @param {vec3} out the receiving vector * @param {vec3} a vector to normalize * @returns {vec3} out */ function normalize(out, a) { var x = a[0]; var y = a[1]; var z = a[2]; var len = x * x + y * y + z * z; if (len > 0) { //TODO: evaluate use of glm_invsqrt here? len = 1 / Math.sqrt(len); out[0] = a[0] * len; out[1] = a[1] * len; out[2] = a[2] * len; } return out; } /** * Calculates the dot product of two vec3's * * @param {vec3} a the first operand * @param {vec3} b the second operand * @returns {Number} dot product of a and b */ function dot(a, b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } /** * Computes the cross product of two vec3's * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @returns {vec3} out */ function cross(out, a, b) { var ax = a[0], ay = a[1], az = a[2]; var bx = b[0], by = b[1], bz = b[2]; out[0] = ay * bz - az * by; out[1] = az * bx - ax * bz; out[2] = ax * by - ay * bx; return out; } /** * Performs a linear interpolation between two vec3's * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @param {Number} t interpolation amount between the two inputs * @returns {vec3} out */ function lerp(out, a, b, t) { var ax = a[0]; var ay = a[1]; var az = a[2]; out[0] = ax + t * (b[0] - ax); out[1] = ay + t * (b[1] - ay); out[2] = az + t * (b[2] - az); return out; } /** * Performs a hermite interpolation with two control points * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @param {vec3} c the third operand * @param {vec3} d the fourth operand * @param {Number} t interpolation amount between the two inputs * @returns {vec3} out */ function hermite(out, a, b, c, d, t) { var factorTimes2 = t * t; var factor1 = factorTimes2 * (2 * t - 3) + 1; var factor2 = factorTimes2 * (t - 2) + t; var factor3 = factorTimes2 * (t - 1); var factor4 = factorTimes2 * (3 - 2 * t); out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; return out; } /** * Performs a bezier interpolation with two control points * * @param {vec3} out the receiving vector * @param {vec3} a the first operand * @param {vec3} b the second operand * @param {vec3} c the third operand * @param {vec3} d the fourth operand * @param {Number} t interpolation amount between the two inputs * @returns {vec3} out */ function bezier(out, a, b, c, d, t) { var inverseFactor = 1 - t; var inverseFactorTimesTwo = inverseFactor * inverseFactor; var factorTimes2 = t * t; var factor1 = inverseFactorTimesTwo * inverseFactor; var factor2 = 3 * t * inverseFactorTimesTwo; var factor3 = 3 * factorTimes2 * inverseFactor; var factor4 = factorTimes2 * t; out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4; out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4; out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4; return out; } /** * Generates a random vector with the given scale * * @param {vec3} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned * @returns {vec3} out */ function random(out, scale) { scale = scale || 1.0; var r = __WEBPACK_IMPORTED_MODULE_0__common__["c" /* RANDOM */]() * 2.0 * Math.PI; var z = __WEBPACK_IMPORTED_MODULE_0__common__["c" /* RANDOM */]() * 2.0 - 1.0; var zScale = Math.sqrt(1.0 - z * z) * scale; out[0] = Math.cos(r) * zScale; out[1] = Math.sin(r) * zScale; out[2] = z * scale; return out; } /** * Transforms the vec3 with a mat4. * 4th vector component is implicitly '1' * * @param {vec3} out the receiving vector * @param {vec3} a the vector to transform * @param {mat4} m matrix to transform with * @returns {vec3} out */ function transformMat4(out, a, m) { var x = a[0], y = a[1], z = a[2]; var w = m[3] * x + m[7] * y + m[11] * z + m[15]; w = w || 1.0; out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; return out; } /** * Transforms the vec3 with a mat3. * * @param {vec3} out the receiving vector * @param {vec3} a the vector to transform * @param {mat3} m the 3x3 matrix to transform with * @returns {vec3} out */ function transformMat3(out, a, m) { var x = a[0], y = a[1], z = a[2]; out[0] = x * m[0] + y * m[3] + z * m[6]; out[1] = x * m[1] + y * m[4] + z * m[7]; out[2] = x * m[2] + y * m[5] + z * m[8]; return out; } /** * Transforms the vec3 with a quat * * @param {vec3} out the receiving vector * @param {vec3} a the vector to transform * @param {quat} q quaternion to transform with * @returns {vec3} out */ function transformQuat(out, a, q) { // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations var x = a[0], y = a[1], z = a[2]; var qx = q[0], qy = q[1], qz = q[2], qw = q[3]; // calculate quat * vec var ix = qw * x + qy * z - qz * y; var iy = qw * y + qz * x - qx * z; var iz = qw * z + qx * y - qy * x; var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; return out; } /** * Rotate a 3D vector around the x-axis * @param {vec3} out The receiving vec3 * @param {vec3} a The vec3 point to rotate * @param {vec3} b The origin of the rotation * @param {Number} c The angle of rotation * @returns {vec3} out */ function rotateX(out, a, b, c) { var p = [], r = []; //Translate point to the origin p[0] = a[0] - b[0]; p[1] = a[1] - b[1]; p[2] = a[2] - b[2]; //perform rotation r[0] = p[0]; r[1] = p[1] * Math.cos(c) - p[2] * Math.sin(c); r[2] = p[1] * Math.sin(c) + p[2] * Math.cos(c); //translate to correct position out[0] = r[0] + b[0]; out[1] = r[1] + b[1]; out[2] = r[2] + b[2]; return out; } /** * Rotate a 3D vector around the y-axis * @param {vec3} out The receiving vec3 * @param {vec3} a The vec3 point to rotate * @param {vec3} b The origin of the rotation * @param {Number} c The angle of rotation * @returns {vec3} out */ function rotateY(out, a, b, c) { var p = [], r = []; //Translate point to the origin p[0] = a[0] - b[0]; p[1] = a[1] - b[1]; p[2] = a[2] - b[2]; //perform rotation r[0] = p[2] * Math.sin(c) + p[0] * Math.cos(c); r[1] = p[1]; r[2] = p[2] * Math.cos(c) - p[0] * Math.sin(c); //translate to correct position out[0] = r[0] + b[0]; out[1] = r[1] + b[1]; out[2] = r[2] + b[2]; return out; } /** * Rotate a 3D vector around the z-axis * @param {vec3} out The receiving vec3 * @param {vec3} a The vec3 point to rotate * @param {vec3} b The origin of the rotation * @param {Number} c The angle of rotation * @returns {vec3} out */ function rotateZ(out, a, b, c) { var p = [], r = []; //Translate point to the origin p[0] = a[0] - b[0]; p[1] = a[1] - b[1]; p[2] = a[2] - b[2]; //perform rotation r[0] = p[0] * Math.cos(c) - p[1] * Math.sin(c); r[1] = p[0] * Math.sin(c) + p[1] * Math.cos(c); r[2] = p[2]; //translate to correct position out[0] = r[0] + b[0]; out[1] = r[1] + b[1]; out[2] = r[2] + b[2]; return out; } /** * Get the angle between two 3D vectors * @param {vec3} a The first operand * @param {vec3} b The second operand * @returns {Number} The angle in radians */ function angle(a, b) { var tempA = fromValues(a[0], a[1], a[2]); var tempB = fromValues(b[0], b[1], b[2]); normalize(tempA, tempA); normalize(tempB, tempB); var cosine = dot(tempA, tempB); if (cosine > 1.0) { return 0; } else if (cosine < -1.0) { return Math.PI; } else { return Math.acos(cosine); } } /** * Returns a string representation of a vector * * @param {vec3} a vector to represent as a string * @returns {String} string representation of the vector */ function str(a) { return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')'; } /** * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===) * * @param {vec3} a The first vector. * @param {vec3} b The second vector. * @returns {Boolean} True if the vectors are equal, false otherwise. */ function exactEquals(a, b) { return a[0] === b[0] && a[1] === b[1] && a[2] === b[2]; } /** * Returns whether or not the vectors have approximately the same elements in the same position. * * @param {vec3} a The first vector. * @param {vec3} b The second vector. * @returns {Boolean} True if the vectors are equal, false otherwise. */ function equals(a, b) { var a0 = a[0], a1 = a[1], a2 = a[2]; var b0 = b[0], b1 = b[1], b2 = b[2]; return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a2), Math.abs(b2)); } /** * Alias for {@link vec3.subtract} * @function */ var sub = subtract; /** * Alias for {@link vec3.multiply} * @function */ var mul = multiply; /** * Alias for {@link vec3.divide} * @function */ var div = divide; /** * Alias for {@link vec3.distance} * @function */ var dist = distance; /** * Alias for {@link vec3.squaredDistance} * @function */ var sqrDist = squaredDistance; /** * Alias for {@link vec3.length} * @function */ var len = length; /** * Alias for {@link vec3.squaredLength} * @function */ var sqrLen = squaredLength; /** * Perform some operation over an array of vec3s. * * @param {Array} a the array of vectors to iterate over * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed * @param {Number} offset Number of elements to skip at the beginning of the array * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array * @param {Function} fn Function to call for each vector in the array * @param {Object} [arg] additional argument to pass to fn * @returns {Array} a * @function */ var forEach = function () { var vec = create(); return function (a, stride, offset, count, fn, arg) { var i = void 0, l = void 0; if (!stride) { stride = 3; } if (!offset) { offset = 0; } if (count) { l = Math.min(count * stride + offset, a.length); } else { l = a.length; } for (i = offset; i < l; i += stride) { vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2]; fn(vec, vec, arg); a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2]; } return a; }; }(); /***/ }, /* 232 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony export (immutable) */__webpack_exports__["create"] = create; /* harmony export (immutable) */__webpack_exports__["clone"] = clone; /* harmony export (immutable) */__webpack_exports__["fromValues"] = fromValues; /* harmony export (immutable) */__webpack_exports__["copy"] = copy; /* harmony export (immutable) */__webpack_exports__["set"] = set; /* harmony export (immutable) */__webpack_exports__["add"] = add; /* harmony export (immutable) */__webpack_exports__["subtract"] = subtract; /* harmony export (immutable) */__webpack_exports__["multiply"] = multiply; /* harmony export (immutable) */__webpack_exports__["divide"] = divide; /* harmony export (immutable) */__webpack_exports__["ceil"] = ceil; /* harmony export (immutable) */__webpack_exports__["floor"] = floor; /* harmony export (immutable) */__webpack_exports__["min"] = min; /* harmony export (immutable) */__webpack_exports__["max"] = max; /* harmony export (immutable) */__webpack_exports__["round"] = round; /* harmony export (immutable) */__webpack_exports__["scale"] = scale; /* harmony export (immutable) */__webpack_exports__["scaleAndAdd"] = scaleAndAdd; /* harmony export (immutable) */__webpack_exports__["distance"] = distance; /* harmony export (immutable) */__webpack_exports__["squaredDistance"] = squaredDistance; /* harmony export (immutable) */__webpack_exports__["length"] = length; /* harmony export (immutable) */__webpack_exports__["squaredLength"] = squaredLength; /* harmony export (immutable) */__webpack_exports__["negate"] = negate; /* harmony export (immutable) */__webpack_exports__["inverse"] = inverse; /* harmony export (immutable) */__webpack_exports__["normalize"] = normalize; /* harmony export (immutable) */__webpack_exports__["dot"] = dot; /* harmony export (immutable) */__webpack_exports__["cross"] = cross; /* harmony export (immutable) */__webpack_exports__["lerp"] = lerp; /* harmony export (immutable) */__webpack_exports__["random"] = random; /* harmony export (immutable) */__webpack_exports__["transformMat2"] = transformMat2; /* harmony export (immutable) */__webpack_exports__["transformMat2d"] = transformMat2d; /* harmony export (immutable) */__webpack_exports__["transformMat3"] = transformMat3; /* harmony export (immutable) */__webpack_exports__["transformMat4"] = transformMat4; /* harmony export (immutable) */__webpack_exports__["str"] = str; /* harmony export (immutable) */__webpack_exports__["exactEquals"] = exactEquals; /* harmony export (immutable) */__webpack_exports__["equals"] = equals; /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "len", function () { return len; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sub", function () { return sub; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "mul", function () { return mul; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "div", function () { return div; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "dist", function () { return dist; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sqrDist", function () { return sqrDist; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sqrLen", function () { return sqrLen; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "forEach", function () { return forEach; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(45); /* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** * 2 Dimensional Vector * @module vec2 */ /** * Creates a new, empty vec2 * * @returns {vec2} a new 2D vector */ function create() { var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* ARRAY_TYPE */](2); out[0] = 0; out[1] = 0; return out; } /** * Creates a new vec2 initialized with values from an existing vector * * @param {vec2} a vector to clone * @returns {vec2} a new 2D vector */ function clone(a) { var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* ARRAY_TYPE */](2); out[0] = a[0]; out[1] = a[1]; return out; } /** * Creates a new vec2 initialized with the given values * * @param {Number} x X component * @param {Number} y Y component * @returns {vec2} a new 2D vector */ function fromValues(x, y) { var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* ARRAY_TYPE */](2); out[0] = x; out[1] = y; return out; } /** * Copy the values from one vec2 to another * * @param {vec2} out the receiving vector * @param {vec2} a the source vector * @returns {vec2} out */ function copy(out, a) { out[0] = a[0]; out[1] = a[1]; return out; } /** * Set the components of a vec2 to the given values * * @param {vec2} out the receiving vector * @param {Number} x X component * @param {Number} y Y component * @returns {vec2} out */ function set(out, x, y) { out[0] = x; out[1] = y; return out; } /** * Adds two vec2's * * @param {vec2} out the receiving vector * @param {vec2} a the first operand * @param {vec2} b the second operand * @returns {vec2} out */ function add(out, a, b) { out[0] = a[0] + b[0]; out[1] = a[1] + b[1]; return out; } /** * Subtracts vector b from vector a * * @param {vec2} out the receiving vector * @param {vec2} a the first operand * @param {vec2} b the second operand * @returns {vec2} out */ function subtract(out, a, b) { out[0] = a[0] - b[0]; out[1] = a[1] - b[1]; return out; } /** * Multiplies two vec2's * * @param {vec2} out the receiving vector * @param {vec2} a the first operand * @param {vec2} b the second operand * @returns {vec2} out */ function multiply(out, a, b) { out[0] = a[0] * b[0]; out[1] = a[1] * b[1]; return out; }; /** * Divides two vec2's * * @param {vec2} out the receiving vector * @param {vec2} a the first operand * @param {vec2} b the second operand * @returns {vec2} out */ function divide(out, a, b) { out[0] = a[0] / b[0]; out[1] = a[1] / b[1]; return out; }; /** * Math.ceil the components of a vec2 * * @param {vec2} out the receiving vector * @param {vec2} a vector to ceil * @returns {vec2} out */ function ceil(out, a) { out[0] = Math.ceil(a[0]); out[1] = Math.ceil(a[1]); return out; }; /** * Math.floor the components of a vec2 * * @param {vec2} out the receiving vector * @param {vec2} a vector to floor * @returns {vec2} out */ function floor(out, a) { out[0] = Math.floor(a[0]); out[1] = Math.floor(a[1]); return out; }; /** * Returns the minimum of two vec2's * * @param {vec2} out the receiving vector * @param {vec2} a the first operand * @param {vec2} b the second operand * @returns {vec2} out */ function min(out, a, b) { out[0] = Math.min(a[0], b[0]); out[1] = Math.min(a[1], b[1]); return out; }; /** * Returns the maximum of two vec2's * * @param {vec2} out the receiving vector * @param {vec2} a the first operand * @param {vec2} b the second operand * @returns {vec2} out */ function max(out, a, b) { out[0] = Math.max(a[0], b[0]); out[1] = Math.max(a[1], b[1]); return out; }; /** * Math.round the components of a vec2 * * @param {vec2} out the receiving vector * @param {vec2} a vector to round * @returns {vec2} out */ function round(out, a) { out[0] = Math.round(a[0]); out[1] = Math.round(a[1]); return out; }; /** * Scales a vec2 by a scalar number * * @param {vec2} out the receiving vector * @param {vec2} a the vector to scale * @param {Number} b amount to scale the vector by * @returns {vec2} out */ function scale(out, a, b) { out[0] = a[0] * b; out[1] = a[1] * b; return out; }; /** * Adds two vec2's after scaling the second operand by a scalar value * * @param {vec2} out the receiving vector * @param {vec2} a the first operand * @param {vec2} b the second operand * @param {Number} scale the amount to scale b by before adding * @returns {vec2} out */ function scaleAndAdd(out, a, b, scale) { out[0] = a[0] + b[0] * scale; out[1] = a[1] + b[1] * scale; return out; }; /** * Calculates the euclidian distance between two vec2's * * @param {vec2} a the first operand * @param {vec2} b the second operand * @returns {Number} distance between a and b */ function distance(a, b) { var x = b[0] - a[0], y = b[1] - a[1]; return Math.sqrt(x * x + y * y); }; /** * Calculates the squared euclidian distance between two vec2's * * @param {vec2} a the first operand * @param {vec2} b the second operand * @returns {Number} squared distance between a and b */ function squaredDistance(a, b) { var x = b[0] - a[0], y = b[1] - a[1]; return x * x + y * y; }; /** * Calculates the length of a vec2 * * @param {vec2} a vector to calculate length of * @returns {Number} length of a */ function length(a) { var x = a[0], y = a[1]; return Math.sqrt(x * x + y * y); }; /** * Calculates the squared length of a vec2 * * @param {vec2} a vector to calculate squared length of * @returns {Number} squared length of a */ function squaredLength(a) { var x = a[0], y = a[1]; return x * x + y * y; }; /** * Negates the components of a vec2 * * @param {vec2} out the receiving vector * @param {vec2} a vector to negate * @returns {vec2} out */ function negate(out, a) { out[0] = -a[0]; out[1] = -a[1]; return out; }; /** * Returns the inverse of the components of a vec2 * * @param {vec2} out the receiving vector * @param {vec2} a vector to invert * @returns {vec2} out */ function inverse(out, a) { out[0] = 1.0 / a[0]; out[1] = 1.0 / a[1]; return out; }; /** * Normalize a vec2 * * @param {vec2} out the receiving vector * @param {vec2} a vector to normalize * @returns {vec2} out */ function normalize(out, a) { var x = a[0], y = a[1]; var len = x * x + y * y; if (len > 0) { //TODO: evaluate use of glm_invsqrt here? len = 1 / Math.sqrt(len); out[0] = a[0] * len; out[1] = a[1] * len; } return out; }; /** * Calculates the dot product of two vec2's * * @param {vec2} a the first operand * @param {vec2} b the second operand * @returns {Number} dot product of a and b */ function dot(a, b) { return a[0] * b[0] + a[1] * b[1]; }; /** * Computes the cross product of two vec2's * Note that the cross product must by definition produce a 3D vector * * @param {vec3} out the receiving vector * @param {vec2} a the first operand * @param {vec2} b the second operand * @returns {vec3} out */ function cross(out, a, b) { var z = a[0] * b[1] - a[1] * b[0]; out[0] = out[1] = 0; out[2] = z; return out; }; /** * Performs a linear interpolation between two vec2's * * @param {vec2} out the receiving vector * @param {vec2} a the first operand * @param {vec2} b the second operand * @param {Number} t interpolation amount between the two inputs * @returns {vec2} out */ function lerp(out, a, b, t) { var ax = a[0], ay = a[1]; out[0] = ax + t * (b[0] - ax); out[1] = ay + t * (b[1] - ay); return out; }; /** * Generates a random vector with the given scale * * @param {vec2} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned * @returns {vec2} out */ function random(out, scale) { scale = scale || 1.0; var r = __WEBPACK_IMPORTED_MODULE_0__common__["c" /* RANDOM */]() * 2.0 * Math.PI; out[0] = Math.cos(r) * scale; out[1] = Math.sin(r) * scale; return out; }; /** * Transforms the vec2 with a mat2 * * @param {vec2} out the receiving vector * @param {vec2} a the vector to transform * @param {mat2} m matrix to transform with * @returns {vec2} out */ function transformMat2(out, a, m) { var x = a[0], y = a[1]; out[0] = m[0] * x + m[2] * y; out[1] = m[1] * x + m[3] * y; return out; }; /** * Transforms the vec2 with a mat2d * * @param {vec2} out the receiving vector * @param {vec2} a the vector to transform * @param {mat2d} m matrix to transform with * @returns {vec2} out */ function transformMat2d(out, a, m) { var x = a[0], y = a[1]; out[0] = m[0] * x + m[2] * y + m[4]; out[1] = m[1] * x + m[3] * y + m[5]; return out; }; /** * Transforms the vec2 with a mat3 * 3rd vector component is implicitly '1' * * @param {vec2} out the receiving vector * @param {vec2} a the vector to transform * @param {mat3} m matrix to transform with * @returns {vec2} out */ function transformMat3(out, a, m) { var x = a[0], y = a[1]; out[0] = m[0] * x + m[3] * y + m[6]; out[1] = m[1] * x + m[4] * y + m[7]; return out; }; /** * Transforms the vec2 with a mat4 * 3rd vector component is implicitly '0' * 4th vector component is implicitly '1' * * @param {vec2} out the receiving vector * @param {vec2} a the vector to transform * @param {mat4} m matrix to transform with * @returns {vec2} out */ function transformMat4(out, a, m) { var x = a[0]; var y = a[1]; out[0] = m[0] * x + m[4] * y + m[12]; out[1] = m[1] * x + m[5] * y + m[13]; return out; } /** * Returns a string representation of a vector * * @param {vec2} a vector to represent as a string * @returns {String} string representation of the vector */ function str(a) { return 'vec2(' + a[0] + ', ' + a[1] + ')'; } /** * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===) * * @param {vec2} a The first vector. * @param {vec2} b The second vector. * @returns {Boolean} True if the vectors are equal, false otherwise. */ function exactEquals(a, b) { return a[0] === b[0] && a[1] === b[1]; } /** * Returns whether or not the vectors have approximately the same elements in the same position. * * @param {vec2} a The first vector. * @param {vec2} b The second vector. * @returns {Boolean} True if the vectors are equal, false otherwise. */ function equals(a, b) { var a0 = a[0], a1 = a[1]; var b0 = b[0], b1 = b[1]; return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1)); } /** * Alias for {@link vec2.length} * @function */ var len = length; /** * Alias for {@link vec2.subtract} * @function */ var sub = subtract; /** * Alias for {@link vec2.multiply} * @function */ var mul = multiply; /** * Alias for {@link vec2.divide} * @function */ var div = divide; /** * Alias for {@link vec2.distance} * @function */ var dist = distance; /** * Alias for {@link vec2.squaredDistance} * @function */ var sqrDist = squaredDistance; /** * Alias for {@link vec2.squaredLength} * @function */ var sqrLen = squaredLength; /** * Perform some operation over an array of vec2s. * * @param {Array} a the array of vectors to iterate over * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed * @param {Number} offset Number of elements to skip at the beginning of the array * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array * @param {Function} fn Function to call for each vector in the array * @param {Object} [arg] additional argument to pass to fn * @returns {Array} a * @function */ var forEach = function () { var vec = create(); return function (a, stride, offset, count, fn, arg) { var i = void 0, l = void 0; if (!stride) { stride = 2; } if (!offset) { offset = 0; } if (count) { l = Math.min(count * stride + offset, a.length); } else { l = a.length; } for (i = offset; i < l; i += stride) { vec[0] = a[i];vec[1] = a[i + 1]; fn(vec, vec, arg); a[i] = vec[0];a[i + 1] = vec[1]; } return a; }; }(); /***/ }, /* 233 */ /***/function (module, exports, __webpack_require__) { var MatrixUtil = __webpack_require__(3); var PathUtil = __webpack_require__(46); var Util = __webpack_require__(0); var d3Ease = __webpack_require__(234); var d3Timer = __webpack_require__(245); var _require = __webpack_require__(248), interpolate = _require.interpolate, interpolateArray = _require.interpolateArray; // 目前整体动画只需要数值和数组的差值计算 module.exports = { /** * 执行动画 * @param {Object} toProps 动画最终状态 * @param {Number} duration 动画执行时间 * @param {String} easing 动画缓动效果 * @param {Function} callback 动画执行后的回调 * @param {Number} delay 动画延迟时间 */ animate: function animate(toProps, duration, easing, callback) { var delay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; var self = this; var canvas = self.get('canvas'); var formatProps = getFormatProps(toProps); var toAttrs = formatProps.attrs; var toM = formatProps.M; var fromAttrs = getfromAttrs(toAttrs); var fromM = Util.clone(self.getMatrix()); easing = easing ? easing : 'easeLinear'; self.setSilent('animating', true); // 处于动画状态 // 执行动画 var timer = d3Timer.timer(function (elapsed) { var ratio = elapsed / duration; if (ratio < 1) { ratio = d3Ease[easing](ratio); update(ratio); } else { update(1); // 保证最后一帧的绘制 callback && callback(); self.setSilent('animating', false); // 动画停止 timer.stop(); } }, delay); function update(ratio) { var cProps = {}; // 此刻属性 if (self.get('destroyed')) { return; } var interf = void 0; // 差值函数 for (var k in toAttrs) { if (!Util.isEqual(fromAttrs[k], toAttrs[k])) { if (k === 'path') { var toPath = PathUtil.parsePathString(toAttrs[k]); // 终点状态 var fromPath = PathUtil.parsePathString(fromAttrs[k]); // 起始状态 cProps[k] = []; for (var i = 0; i < toPath.length; i++) { var toPathPoint = toPath[i]; var fromPathPoint = fromPath[i]; var cPathPoint = []; for (var j = 0; j < toPathPoint.length; j++) { if (Util.isNumber(toPathPoint[j]) && fromPathPoint) { interf = interpolate(fromPathPoint[j], toPathPoint[j]); cPathPoint.push(interf(ratio)); } else { cPathPoint.push(toPathPoint[j]); } } cProps[k].push(cPathPoint); } } else { interf = interpolate(fromAttrs[k], toAttrs[k]); cProps[k] = interf(ratio); } } } if (toM) { var mf = interpolateArray(fromM, toM); var cM = mf(ratio); self.setMatrix(cM); } self.attr(cProps); canvas.draw(); } function getFormatProps(props) { var rst = { M: null, attrs: {} }; for (var k in props) { if (k === 'transform') { rst.M = MatrixUtil.transform(self.getMatrix(), props[k]); } else if (k === 'matrix') { rst.M = props[k]; } else { rst.attrs[k] = props[k]; } } return rst; } function getfromAttrs(toAttrs) { var rst = {}; for (var k in toAttrs) { rst[k] = self.attr(k); } return rst; } } }; /***/ }, /* 234 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__src_linear__ = __webpack_require__(235); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeLinear", function () { return __WEBPACK_IMPORTED_MODULE_0__src_linear__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__src_quad__ = __webpack_require__(236); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeQuad", function () { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["b"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeQuadIn", function () { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeQuadOut", function () { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeQuadInOut", function () { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__src_cubic__ = __webpack_require__(237); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCubic", function () { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["b"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCubicIn", function () { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCubicOut", function () { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCubicInOut", function () { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_3__src_poly__ = __webpack_require__(238); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easePoly", function () { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["b"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easePolyIn", function () { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easePolyOut", function () { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easePolyInOut", function () { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_4__src_sin__ = __webpack_require__(239); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeSin", function () { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["b"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeSinIn", function () { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeSinOut", function () { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeSinInOut", function () { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_5__src_exp__ = __webpack_require__(240); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeExp", function () { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["b"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeExpIn", function () { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeExpOut", function () { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeExpInOut", function () { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_6__src_circle__ = __webpack_require__(241); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCircle", function () { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["b"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCircleIn", function () { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCircleOut", function () { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCircleInOut", function () { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_7__src_bounce__ = __webpack_require__(242); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBounce", function () { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBounceIn", function () { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBounceOut", function () { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBounceInOut", function () { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_8__src_back__ = __webpack_require__(243); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBack", function () { return __WEBPACK_IMPORTED_MODULE_8__src_back__["b"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBackIn", function () { return __WEBPACK_IMPORTED_MODULE_8__src_back__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBackOut", function () { return __WEBPACK_IMPORTED_MODULE_8__src_back__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBackInOut", function () { return __WEBPACK_IMPORTED_MODULE_8__src_back__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_9__src_elastic__ = __webpack_require__(244); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeElastic", function () { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeElasticIn", function () { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeElasticOut", function () { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeElasticInOut", function () { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["b"]; }); /***/ }, /* 235 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = linear; function linear(t) { return +t; } /***/ }, /* 236 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = quadIn; /* harmony export (immutable) */__webpack_exports__["c"] = quadOut; /* harmony export (immutable) */__webpack_exports__["b"] = quadInOut; function quadIn(t) { return t * t; } function quadOut(t) { return t * (2 - t); } function quadInOut(t) { return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2; } /***/ }, /* 237 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = cubicIn; /* harmony export (immutable) */__webpack_exports__["c"] = cubicOut; /* harmony export (immutable) */__webpack_exports__["b"] = cubicInOut; function cubicIn(t) { return t * t * t; } function cubicOut(t) { return --t * t * t + 1; } function cubicInOut(t) { return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2; } /***/ }, /* 238 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function () { return polyIn; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () { return polyOut; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "b", function () { return polyInOut; }); var exponent = 3; var polyIn = function custom(e) { e = +e; function polyIn(t) { return Math.pow(t, e); } polyIn.exponent = custom; return polyIn; }(exponent); var polyOut = function custom(e) { e = +e; function polyOut(t) { return 1 - Math.pow(1 - t, e); } polyOut.exponent = custom; return polyOut; }(exponent); var polyInOut = function custom(e) { e = +e; function polyInOut(t) { return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2; } polyInOut.exponent = custom; return polyInOut; }(exponent); /***/ }, /* 239 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = sinIn; /* harmony export (immutable) */__webpack_exports__["c"] = sinOut; /* harmony export (immutable) */__webpack_exports__["b"] = sinInOut; var pi = Math.PI, halfPi = pi / 2; function sinIn(t) { return 1 - Math.cos(t * halfPi); } function sinOut(t) { return Math.sin(t * halfPi); } function sinInOut(t) { return (1 - Math.cos(pi * t)) / 2; } /***/ }, /* 240 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = expIn; /* harmony export (immutable) */__webpack_exports__["c"] = expOut; /* harmony export (immutable) */__webpack_exports__["b"] = expInOut; function expIn(t) { return Math.pow(2, 10 * t - 10); } function expOut(t) { return 1 - Math.pow(2, -10 * t); } function expInOut(t) { return ((t *= 2) <= 1 ? Math.pow(2, 10 * t - 10) : 2 - Math.pow(2, 10 - 10 * t)) / 2; } /***/ }, /* 241 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = circleIn; /* harmony export (immutable) */__webpack_exports__["c"] = circleOut; /* harmony export (immutable) */__webpack_exports__["b"] = circleInOut; function circleIn(t) { return 1 - Math.sqrt(1 - t * t); } function circleOut(t) { return Math.sqrt(1 - --t * t); } function circleInOut(t) { return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2; } /***/ }, /* 242 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = bounceIn; /* harmony export (immutable) */__webpack_exports__["c"] = bounceOut; /* harmony export (immutable) */__webpack_exports__["b"] = bounceInOut; var b1 = 4 / 11, b2 = 6 / 11, b3 = 8 / 11, b4 = 3 / 4, b5 = 9 / 11, b6 = 10 / 11, b7 = 15 / 16, b8 = 21 / 22, b9 = 63 / 64, b0 = 1 / b1 / b1; function bounceIn(t) { return 1 - bounceOut(1 - t); } function bounceOut(t) { return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9; } function bounceInOut(t) { return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2; } /***/ }, /* 243 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function () { return backIn; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () { return backOut; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "b", function () { return backInOut; }); var overshoot = 1.70158; var backIn = function custom(s) { s = +s; function backIn(t) { return t * t * ((s + 1) * t - s); } backIn.overshoot = custom; return backIn; }(overshoot); var backOut = function custom(s) { s = +s; function backOut(t) { return --t * t * ((s + 1) * t + s) + 1; } backOut.overshoot = custom; return backOut; }(overshoot); var backInOut = function custom(s) { s = +s; function backInOut(t) { return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2; } backInOut.overshoot = custom; return backInOut; }(overshoot); /***/ }, /* 244 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function () { return elasticIn; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () { return elasticOut; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "b", function () { return elasticInOut; }); var tau = 2 * Math.PI, amplitude = 1, period = 0.3; var elasticIn = function custom(a, p) { var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau); function elasticIn(t) { return a * Math.pow(2, 10 * --t) * Math.sin((s - t) / p); } elasticIn.amplitude = function (a) { return custom(a, p * tau); }; elasticIn.period = function (p) { return custom(a, p); }; return elasticIn; }(amplitude, period); var elasticOut = function custom(a, p) { var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau); function elasticOut(t) { return 1 - a * Math.pow(2, -10 * (t = +t)) * Math.sin((t + s) / p); } elasticOut.amplitude = function (a) { return custom(a, p * tau); }; elasticOut.period = function (p) { return custom(a, p); }; return elasticOut; }(amplitude, period); var elasticInOut = function custom(a, p) { var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau); function elasticInOut(t) { return ((t = t * 2 - 1) < 0 ? a * Math.pow(2, 10 * t) * Math.sin((s - t) / p) : 2 - a * Math.pow(2, -10 * t) * Math.sin((s + t) / p)) / 2; } elasticInOut.amplitude = function (a) { return custom(a, p * tau); }; elasticInOut.period = function (p) { return custom(a, p); }; return elasticInOut; }(amplitude, period); /***/ }, /* 245 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__src_timer__ = __webpack_require__(47); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "now", function () { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["b"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "timer", function () { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["c"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "timerFlush", function () { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["d"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__src_timeout__ = __webpack_require__(246); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "timeout", function () { return __WEBPACK_IMPORTED_MODULE_1__src_timeout__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__src_interval__ = __webpack_require__(247); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interval", function () { return __WEBPACK_IMPORTED_MODULE_2__src_interval__["a"]; }); /***/ }, /* 246 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(47); /* harmony default export */__webpack_exports__["a"] = function (callback, delay, time) { var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["a" /* Timer */](); delay = delay == null ? 0 : +delay; t.restart(function (elapsed) { t.stop(); callback(elapsed + delay); }, delay, time); return t; }; /***/ }, /* 247 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(47); /* harmony default export */__webpack_exports__["a"] = function (callback, delay, time) { var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["a" /* Timer */](), total = delay; if (delay == null) return t.restart(callback, delay, time), t; delay = +delay, time = time == null ? Object(__WEBPACK_IMPORTED_MODULE_0__timer__["b" /* now */])() : +time; t.restart(function tick(elapsed) { elapsed += total; t.restart(tick, total += delay, time); callback(elapsed); }, delay, time); return t; }; /***/ }, /* 248 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__src_value__ = __webpack_require__(48); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolate", function () { return __WEBPACK_IMPORTED_MODULE_0__src_value__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__src_array__ = __webpack_require__(93); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateArray", function () { return __WEBPACK_IMPORTED_MODULE_1__src_array__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__src_basis__ = __webpack_require__(51); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateBasis", function () { return __WEBPACK_IMPORTED_MODULE_2__src_basis__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__ = __webpack_require__(91); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateBasisClosed", function () { return __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_4__src_date__ = __webpack_require__(94); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateDate", function () { return __WEBPACK_IMPORTED_MODULE_4__src_date__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_5__src_number__ = __webpack_require__(29); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateNumber", function () { return __WEBPACK_IMPORTED_MODULE_5__src_number__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_6__src_object__ = __webpack_require__(95); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateObject", function () { return __WEBPACK_IMPORTED_MODULE_6__src_object__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_7__src_round__ = __webpack_require__(251); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateRound", function () { return __WEBPACK_IMPORTED_MODULE_7__src_round__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_8__src_string__ = __webpack_require__(96); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateString", function () { return __WEBPACK_IMPORTED_MODULE_8__src_string__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_9__src_transform_index__ = __webpack_require__(252); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateTransformCss", function () { return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateTransformSvg", function () { return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_10__src_zoom__ = __webpack_require__(255); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateZoom", function () { return __WEBPACK_IMPORTED_MODULE_10__src_zoom__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_11__src_rgb__ = __webpack_require__(90); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateRgb", function () { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateRgbBasis", function () { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["b"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateRgbBasisClosed", function () { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["c"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_12__src_hsl__ = __webpack_require__(256); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateHsl", function () { return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateHslLong", function () { return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_13__src_lab__ = __webpack_require__(257); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateLab", function () { return __WEBPACK_IMPORTED_MODULE_13__src_lab__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_14__src_hcl__ = __webpack_require__(258); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateHcl", function () { return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["a"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateHclLong", function () { return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["b"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__ = __webpack_require__(259); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateCubehelix", function () { return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["b"]; }); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateCubehelixLong", function () { return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["a"]; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_16__src_quantize__ = __webpack_require__(260); /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "quantize", function () { return __WEBPACK_IMPORTED_MODULE_16__src_quantize__["a"]; }); /***/ }, /* 249 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = lab; /* unused harmony export Lab */ /* harmony export (immutable) */__webpack_exports__["b"] = hcl; /* unused harmony export Hcl */ /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(50); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(49); /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(89); var Kn = 18, Xn = 0.950470, // D65 standard referent Yn = 1, Zn = 1.088830, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1; function labConvert(o) { if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity); if (o instanceof Hcl) { var h = o.h * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* deg2rad */]; return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity); } if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */])) o = Object(__WEBPACK_IMPORTED_MODULE_1__color__["h" /* rgbConvert */])(o); var b = rgb2xyz(o.r), a = rgb2xyz(o.g), l = rgb2xyz(o.b), x = xyz2lab((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn), y = xyz2lab((0.2126729 * b + 0.7151522 * a + 0.0721750 * l) / Yn), z = xyz2lab((0.0193339 * b + 0.1191920 * a + 0.9503041 * l) / Zn); return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity); } function lab(l, a, b, opacity) { return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity); } function Lab(l, a, b, opacity) { this.l = +l; this.a = +a; this.b = +b; this.opacity = +opacity; } Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Lab, lab, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], { brighter: function brighter(k) { return new Lab(this.l + Kn * (k == null ? 1 : k), this.a, this.b, this.opacity); }, darker: function darker(k) { return new Lab(this.l - Kn * (k == null ? 1 : k), this.a, this.b, this.opacity); }, rgb: function rgb() { var y = (this.l + 16) / 116, x = isNaN(this.a) ? y : y + this.a / 500, z = isNaN(this.b) ? y : y - this.b / 200; y = Yn * lab2xyz(y); x = Xn * lab2xyz(x); z = Zn * lab2xyz(z); return new __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */](xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z), xyz2rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z), this.opacity); } })); function xyz2lab(t) { return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0; } function lab2xyz(t) { return t > t1 ? t * t * t : t2 * (t - t0); } function xyz2rgb(x) { return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); } function rgb2xyz(x) { return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); } function hclConvert(o) { if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity); if (!(o instanceof Lab)) o = labConvert(o); var h = Math.atan2(o.b, o.a) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* rad2deg */]; return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity); } function hcl(h, c, l, opacity) { return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity); } function Hcl(h, c, l, opacity) { this.h = +h; this.c = +c; this.l = +l; this.opacity = +opacity; } Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hcl, hcl, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], { brighter: function brighter(k) { return new Hcl(this.h, this.c, this.l + Kn * (k == null ? 1 : k), this.opacity); }, darker: function darker(k) { return new Hcl(this.h, this.c, this.l - Kn * (k == null ? 1 : k), this.opacity); }, rgb: function rgb() { return labConvert(this).rgb(); } })); /***/ }, /* 250 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = cubehelix; /* unused harmony export Cubehelix */ /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(50); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(49); /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(89); var A = -0.14861, B = +1.78277, C = -0.29227, D = -0.90649, E = +1.97294, ED = E * D, EB = E * B, BC_DA = B * C - D * A; function cubehelixConvert(o) { if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity); if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */])) o = Object(__WEBPACK_IMPORTED_MODULE_1__color__["h" /* rgbConvert */])(o); var r = o.r / 255, g = o.g / 255, b = o.b / 255, l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB), bl = b - l, k = (E * (g - l) - C * bl) / D, s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1 h = s ? Math.atan2(k, bl) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* rad2deg */] - 120 : NaN; return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity); } function cubehelix(h, s, l, opacity) { return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity); } function Cubehelix(h, s, l, opacity) { this.h = +h; this.s = +s; this.l = +l; this.opacity = +opacity; } Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Cubehelix, cubehelix, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], { brighter: function brighter(k) { k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["c" /* brighter */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* brighter */], k); return new Cubehelix(this.h, this.s, this.l * k, this.opacity); }, darker: function darker(k) { k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["d" /* darker */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["d" /* darker */], k); return new Cubehelix(this.h, this.s, this.l * k, this.opacity); }, rgb: function rgb() { var h = isNaN(this.h) ? 0 : (this.h + 120) * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* deg2rad */], l = +this.l, a = isNaN(this.s) ? 0 : this.s * l * (1 - l), cosh = Math.cos(h), sinh = Math.sin(h); return new __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */](255 * (l + a * (A * cosh + B * sinh)), 255 * (l + a * (C * cosh + D * sinh)), 255 * (l + a * (E * cosh)), this.opacity); } })); /***/ }, /* 251 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony default export */ __webpack_exports__["a"] = function (a, b) { return a = +a, b -= a, function (t) { return Math.round(a + b * t); }; }; /***/ }, /* 252 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function () { return interpolateTransformCss; }); /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "b", function () { return interpolateTransformSvg; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(29); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__parse__ = __webpack_require__(253); function interpolateTransform(parse, pxComma, pxParen, degParen) { function pop(s) { return s.length ? s.pop() + " " : ""; } function translate(xa, ya, xb, yb, s, q) { if (xa !== xb || ya !== yb) { var i = s.push("translate(", null, pxComma, null, pxParen); q.push({ i: i - 4, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb) }, { i: i - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb) }); } else if (xb || yb) { s.push("translate(" + xb + pxComma + yb + pxParen); } } function rotate(a, b, s, q) { if (a !== b) { if (a - b > 180) b += 360;else if (b - a > 180) a += 360; // shortest path q.push({ i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b) }); } else if (b) { s.push(pop(s) + "rotate(" + b + degParen); } } function skewX(a, b, s, q) { if (a !== b) { q.push({ i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b) }); } else if (b) { s.push(pop(s) + "skewX(" + b + degParen); } } function scale(xa, ya, xb, yb, s, q) { if (xa !== xb || ya !== yb) { var i = s.push(pop(s) + "scale(", null, ",", null, ")"); q.push({ i: i - 4, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb) }, { i: i - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb) }); } else if (xb !== 1 || yb !== 1) { s.push(pop(s) + "scale(" + xb + "," + yb + ")"); } } return function (a, b) { var s = [], // string constants and placeholders q = []; // number interpolators a = parse(a), b = parse(b); translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q); rotate(a.rotate, b.rotate, s, q); skewX(a.skewX, b.skewX, s, q); scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q); a = b = null; // gc return function (t) { var i = -1, n = q.length, o; while (++i < n) { s[(o = q[i]).i] = o.x(t); }return s.join(""); }; }; } var interpolateTransformCss = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["a" /* parseCss */], "px, ", "px)", "deg)"); var interpolateTransformSvg = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["b" /* parseSvg */], ", ", ")", ")"); /***/ }, /* 253 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = parseCss; /* harmony export (immutable) */__webpack_exports__["b"] = parseSvg; /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__decompose__ = __webpack_require__(254); var cssNode, cssRoot, cssView, svgNode; function parseCss(value) { if (value === "none") return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */]; if (!cssNode) cssNode = document.createElement("DIV"), cssRoot = document.documentElement, cssView = document.defaultView; cssNode.style.transform = value; value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform"); cssRoot.removeChild(cssNode); value = value.slice(7, -1).split(","); return Object(__WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* default */])(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]); } function parseSvg(value) { if (value == null) return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */]; if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g"); svgNode.setAttribute("transform", value); if (!(value = svgNode.transform.baseVal.consolidate())) return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */]; value = value.matrix; return Object(__WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* default */])(value.a, value.b, value.c, value.d, value.e, value.f); } /***/ }, /* 254 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function () { return identity; }); var degrees = 180 / Math.PI; var identity = { translateX: 0, translateY: 0, rotate: 0, skewX: 0, scaleX: 1, scaleY: 1 }; /* harmony default export */__webpack_exports__["a"] = function (a, b, c, d, e, f) { var scaleX, scaleY, skewX; if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX; if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX; if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY; if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX; return { translateX: e, translateY: f, rotate: Math.atan2(b, a) * degrees, skewX: Math.atan(skewX) * degrees, scaleX: scaleX, scaleY: scaleY }; }; /***/ }, /* 255 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; var rho = Math.SQRT2, rho2 = 2, rho4 = 4, epsilon2 = 1e-12; function cosh(x) { return ((x = Math.exp(x)) + 1 / x) / 2; } function sinh(x) { return ((x = Math.exp(x)) - 1 / x) / 2; } function tanh(x) { return ((x = Math.exp(2 * x)) - 1) / (x + 1); } // p0 = [ux0, uy0, w0] // p1 = [ux1, uy1, w1] /* harmony default export */__webpack_exports__["a"] = function (p0, p1) { var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i, S; // Special case for u0 ≅ u1. if (d2 < epsilon2) { S = Math.log(w1 / w0) / rho; i = function i(t) { return [ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(rho * t * S)]; }; } // General case. else { var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1), b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1); S = (r1 - r0) / rho; i = function i(t) { var s = t * S, coshr0 = cosh(r0), u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0)); return [ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / cosh(rho * s + r0)]; }; } i.duration = S * 1000; return i; }; /***/ }, /* 256 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function () { return hslLong; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(14); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(19); function hsl(hue) { return function (start, end) { var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(end)).h), s = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s), l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l), opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity); return function (t) { start.h = h(t); start.s = s(t); start.l = l(t); start.opacity = opacity(t); return start + ""; }; }; } /* harmony default export */__webpack_exports__["a"] = hsl(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]); var hslLong = hsl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]); /***/ }, /* 257 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["a"] = lab; /* harmony import */var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(14); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(19); function lab(start, end) { var l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* lab */])(start)).l, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* lab */])(end)).l), a = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.a, end.a), b = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.b, end.b), opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity); return function (t) { start.l = l(t); start.a = a(t); start.b = b(t); start.opacity = opacity(t); return start + ""; }; } /***/ }, /* 258 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function () { return hclLong; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(14); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(19); function hcl(hue) { return function (start, end) { var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* hcl */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* hcl */])(end)).h), c = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.c, end.c), l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l), opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity); return function (t) { start.h = h(t); start.c = c(t); start.l = l(t); start.opacity = opacity(t); return start + ""; }; }; } /* harmony default export */__webpack_exports__["a"] = hcl(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]); var hclLong = hcl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]); /***/ }, /* 259 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function () { return cubehelixLong; }); /* harmony import */var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(14); /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(19); function cubehelix(hue) { return function cubehelixGamma(y) { y = +y; function cubehelix(start, end) { var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* cubehelix */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* cubehelix */])(end)).h), s = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s), l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l), opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity); return function (t) { start.h = h(t); start.s = s(t); start.l = l(Math.pow(t, y)); start.opacity = opacity(t); return start + ""; }; } cubehelix.gamma = cubehelixGamma; return cubehelix; }(1); } /* harmony default export */__webpack_exports__["b"] = cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]); var cubehelixLong = cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]); /***/ }, /* 260 */ /***/function (module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony default export */ __webpack_exports__["a"] = function (interpolator, n) { var samples = new Array(n); for (var i = 0; i < n; ++i) { samples[i] = interpolator(i / (n - 1)); }return samples; }; /***/ }, /* 261 */ /***/function (module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); }; /*! * EventEmitter v5.2.4 - git.io/ee * Unlicense - http://unlicense.org/ * Oliver Caldwell - http://oli.me.uk/ * @preserve */ ;(function (exports) { 'use strict'; /** * Class for managing events. * Can be extended to provide event functionality in other classes. * * @class EventEmitter Manages event registering and emitting. */ function EventEmitter() {} // Shortcuts to improve speed and size var proto = EventEmitter.prototype; var originalGlobalValue = exports.EventEmitter; /** * Finds the index of the listener for the event in its storage array. * * @param {Function[]} listeners Array of listeners to search through. * @param {Function} listener Method to look for. * @return {Number} Index of the specified listener, -1 if not found * @api private */ function indexOfListener(listeners, listener) { var i = listeners.length; while (i--) { if (listeners[i].listener === listener) { return i; } } return -1; } /** * Alias a method while keeping the context correct, to allow for overwriting of target method. * * @param {String} name The name of the target method. * @return {Function} The aliased method * @api private */ function alias(name) { return function aliasClosure() { return this[name].apply(this, arguments); }; } /** * Returns the listener array for the specified event. * Will initialise the event object and listener arrays if required. * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them. * Each property in the object response is an array of listener functions. * * @param {String|RegExp} evt Name of the event to return the listeners from. * @return {Function[]|Object} All listener functions for the event. */ proto.getListeners = function getListeners(evt) { var events = this._getEvents(); var response; var key; // Return a concatenated array of all matching events if // the selector is a regular expression. if (evt instanceof RegExp) { response = {}; for (key in events) { if (events.hasOwnProperty(key) && evt.test(key)) { response[key] = events[key]; } } } else { response = events[evt] || (events[evt] = []); } return response; }; /** * Takes a list of listener objects and flattens it into a list of listener functions. * * @param {Object[]} listeners Raw listener objects. * @return {Function[]} Just the listener functions. */ proto.flattenListeners = function flattenListeners(listeners) { var flatListeners = []; var i; for (i = 0; i < listeners.length; i += 1) { flatListeners.push(listeners[i].listener); } return flatListeners; }; /** * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful. * * @param {String|RegExp} evt Name of the event to return the listeners from. * @return {Object} All listener functions for an event in an object. */ proto.getListenersAsObject = function getListenersAsObject(evt) { var listeners = this.getListeners(evt); var response; if (listeners instanceof Array) { response = {}; response[evt] = listeners; } return response || listeners; }; function isValidListener(listener) { if (typeof listener === 'function' || listener instanceof RegExp) { return true; } else if (listener && (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object') { return isValidListener(listener.listener); } else { return false; } } /** * Adds a listener function to the specified event. * The listener will not be added if it is a duplicate. * If the listener returns true then it will be removed after it is called. * If you pass a regular expression as the event name then the listener will be added to all events that match it. * * @param {String|RegExp} evt Name of the event to attach the listener to. * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. * @return {Object} Current instance of EventEmitter for chaining. */ proto.addListener = function addListener(evt, listener) { if (!isValidListener(listener)) { throw new TypeError('listener must be a function'); } var listeners = this.getListenersAsObject(evt); var listenerIsWrapped = (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object'; var key; for (key in listeners) { if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) { listeners[key].push(listenerIsWrapped ? listener : { listener: listener, once: false }); } } return this; }; /** * Alias of addListener */ proto.on = alias('addListener'); /** * Semi-alias of addListener. It will add a listener that will be * automatically removed after its first execution. * * @param {String|RegExp} evt Name of the event to attach the listener to. * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. * @return {Object} Current instance of EventEmitter for chaining. */ proto.addOnceListener = function addOnceListener(evt, listener) { return this.addListener(evt, { listener: listener, once: true }); }; /** * Alias of addOnceListener. */ proto.once = alias('addOnceListener'); /** * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad. * You need to tell it what event names should be matched by a regex. * * @param {String} evt Name of the event to create. * @return {Object} Current instance of EventEmitter for chaining. */ proto.defineEvent = function defineEvent(evt) { this.getListeners(evt); return this; }; /** * Uses defineEvent to define multiple events. * * @param {String[]} evts An array of event names to define. * @return {Object} Current instance of EventEmitter for chaining. */ proto.defineEvents = function defineEvents(evts) { for (var i = 0; i < evts.length; i += 1) { this.defineEvent(evts[i]); } return this; }; /** * Removes a listener function from the specified event. * When passed a regular expression as the event name, it will remove the listener from all events that match it. * * @param {String|RegExp} evt Name of the event to remove the listener from. * @param {Function} listener Method to remove from the event. * @return {Object} Current instance of EventEmitter for chaining. */ proto.removeListener = function removeListener(evt, listener) { var listeners = this.getListenersAsObject(evt); var index; var key; for (key in listeners) { if (listeners.hasOwnProperty(key)) { index = indexOfListener(listeners[key], listener); if (index !== -1) { listeners[key].splice(index, 1); } } } return this; }; /** * Alias of removeListener */ proto.off = alias('removeListener'); /** * Adds listeners in bulk using the manipulateListeners method. * If you pass an object as the first argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added. * You can also pass it a regular expression to add the array of listeners to all events that match it. * Yeah, this function does quite a bit. That's probably a bad thing. * * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once. * @param {Function[]} [listeners] An optional array of listener functions to add. * @return {Object} Current instance of EventEmitter for chaining. */ proto.addListeners = function addListeners(evt, listeners) { // Pass through to manipulateListeners return this.manipulateListeners(false, evt, listeners); }; /** * Removes listeners in bulk using the manipulateListeners method. * If you pass an object as the first argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. * You can also pass it an event name and an array of listeners to be removed. * You can also pass it a regular expression to remove the listeners from all events that match it. * * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once. * @param {Function[]} [listeners] An optional array of listener functions to remove. * @return {Object} Current instance of EventEmitter for chaining. */ proto.removeListeners = function removeListeners(evt, listeners) { // Pass through to manipulateListeners return this.manipulateListeners(true, evt, listeners); }; /** * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level. * The first argument will determine if the listeners are removed (true) or added (false). * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. * You can also pass it an event name and an array of listeners to be added/removed. * You can also pass it a regular expression to manipulate the listeners of all events that match it. * * @param {Boolean} remove True if you want to remove listeners, false if you want to add. * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once. * @param {Function[]} [listeners] An optional array of listener functions to add/remove. * @return {Object} Current instance of EventEmitter for chaining. */ proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) { var i; var value; var single = remove ? this.removeListener : this.addListener; var multiple = remove ? this.removeListeners : this.addListeners; // If evt is an object then pass each of its properties to this method if ((typeof evt === 'undefined' ? 'undefined' : _typeof(evt)) === 'object' && !(evt instanceof RegExp)) { for (i in evt) { if (evt.hasOwnProperty(i) && (value = evt[i])) { // Pass the single listener straight through to the singular method if (typeof value === 'function') { single.call(this, i, value); } else { // Otherwise pass back to the multiple function multiple.call(this, i, value); } } } } else { // So evt must be a string // And listeners must be an array of listeners // Loop over it and pass each one to the multiple method i = listeners.length; while (i--) { single.call(this, evt, listeners[i]); } } return this; }; /** * Removes all listeners from a specified event. * If you do not specify an event then all listeners will be removed. * That means every event will be emptied. * You can also pass a regex to remove all events that match it. * * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed. * @return {Object} Current instance of EventEmitter for chaining. */ proto.removeEvent = function removeEvent(evt) { var type = typeof evt === 'undefined' ? 'undefined' : _typeof(evt); var events = this._getEvents(); var key; // Remove different things depending on the state of evt if (type === 'string') { // Remove all listeners for the specified event delete events[evt]; } else if (evt instanceof RegExp) { // Remove all events matching the regex. for (key in events) { if (events.hasOwnProperty(key) && evt.test(key)) { delete events[key]; } } } else { // Remove all listeners in all events delete this._events; } return this; }; /** * Alias of removeEvent. * * Added to mirror the node API. */ proto.removeAllListeners = alias('removeEvent'); /** * Emits an event of your choice. * When emitted, every listener attached to that event will be executed. * If you pass the optional argument array then those arguments will be passed to every listener upon execution. * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately. * So they will not arrive within the array on the other side, they will be separate. * You can also pass a regular expression to emit to all events that match it. * * @param {String|RegExp} evt Name of the event to emit and execute listeners for. * @param {Array} [args] Optional array of arguments to be passed to each listener. * @return {Object} Current instance of EventEmitter for chaining. */ proto.emitEvent = function emitEvent(evt, args) { var listenersMap = this.getListenersAsObject(evt); var listeners; var listener; var i; var key; var response; for (key in listenersMap) { if (listenersMap.hasOwnProperty(key)) { listeners = listenersMap[key].slice(0); for (i = 0; i < listeners.length; i++) { // If the listener returns true then it shall be removed from the event // The function is executed either with a basic call or an apply if there is an args array listener = listeners[i]; if (listener.once === true) { this.removeListener(evt, listener.listener); } response = listener.listener.apply(this, args || []); if (response === this._getOnceReturnValue()) { this.removeListener(evt, listener.listener); } } } } return this; }; /** * Alias of emitEvent */ proto.trigger = alias('emitEvent'); /** * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on. * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it. * * @param {String|RegExp} evt Name of the event to emit and execute listeners for. * @param {...*} Optional additional arguments to be passed to each listener. * @return {Object} Current instance of EventEmitter for chaining. */ proto.emit = function emit(evt) { var args = Array.prototype.slice.call(arguments, 1); return this.emitEvent(evt, args); }; /** * Sets the current value to check against when executing listeners. If a * listeners return value matches the one set here then it will be removed * after execution. This value defaults to true. * * @param {*} value The new value to check for when executing listeners. * @return {Object} Current instance of EventEmitter for chaining. */ proto.setOnceReturnValue = function setOnceReturnValue(value) { this._onceReturnValue = value; return this; }; /** * Fetches the current value to check against when executing listeners. If * the listeners return value matches this one then it should be removed * automatically. It will return true by default. * * @return {*|Boolean} The current value to check for or the default, true. * @api private */ proto._getOnceReturnValue = function _getOnceReturnValue() { if (this.hasOwnProperty('_onceReturnValue')) { return this._onceReturnValue; } else { return true; } }; /** * Fetches the events object and creates one if required. * * @return {Object} The events storage object. * @api private */ proto._getEvents = function _getEvents() { return this._events || (this._events = {}); }; /** * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version. * * @return {Function} Non conflicting EventEmitter class. */ EventEmitter.noConflict = function noConflict() { exports.EventEmitter = originalGlobalValue; return EventEmitter; }; // Expose the class either via AMD, CommonJS or the global object if (true) { !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { return EventEmitter; }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object' && module.exports) { module.exports = EventEmitter; } else { exports.EventEmitter = EventEmitter; } })(this || {}); /***/ }, /* 262 */ /***/function (module, exports, __webpack_require__) { var Shape = { Rect: __webpack_require__(98), Circle: __webpack_require__(99), Ellipse: __webpack_require__(100), Path: __webpack_require__(101), Text: __webpack_require__(102), Line: __webpack_require__(103), Image: __webpack_require__(104), Polygon: __webpack_require__(105), Polyline: __webpack_require__(106), Arc: __webpack_require__(107), Fan: __webpack_require__(108), Cubic: __webpack_require__(109), Quadratic: __webpack_require__(110), Marker: __webpack_require__(111) }; module.exports = Shape; /***/ }, /* 263 */ /***/function (module, exports, __webpack_require__) { var Util = __webpack_require__(0); var Inside = __webpack_require__(2); var Cubic = __webpack_require__(30); var Quadratic = __webpack_require__(53); var Ellipse = __webpack_require__(264); var vec3 = __webpack_require__(3).vec3; var mat3 = __webpack_require__(3).mat3; var ARR_CMD = ['m', 'l', 'c', 'a', 'q', 'h', 'v', 't', 's', 'z']; function toAbsolute(x, y, curPoint) { // 获取绝对坐标 return { x: curPoint.x + x, y: curPoint.y + y }; } function toSymmetry(point, center) { // 点对称 return { x: center.x + (center.x - point.x), y: center.y + (center.y - point.y) }; } function vMag(v) { return Math.sqrt(v[0] * v[0] + v[1] * v[1]); } function vRatio(u, v) { return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v)); } function vAngle(u, v) { return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v)); } function getArcParams(point1, point2, fa, fs, rx, ry, psiDeg) { var psi = Util.mod(Util.toRadian(psiDeg), Math.PI * 2); var x1 = point1.x; var y1 = point1.y; var x2 = point2.x; var y2 = point2.y; var xp = Math.cos(psi) * (x1 - x2) / 2.0 + Math.sin(psi) * (y1 - y2) / 2.0; var yp = -1 * Math.sin(psi) * (x1 - x2) / 2.0 + Math.cos(psi) * (y1 - y2) / 2.0; var lambda = xp * xp / (rx * rx) + yp * yp / (ry * ry); if (lambda > 1) { rx *= Math.sqrt(lambda); ry *= Math.sqrt(lambda); } var f = Math.sqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) / (rx * rx * (yp * yp) + ry * ry * (xp * xp))); if (fa === fs) { f *= -1; } if (isNaN(f)) { f = 0; } var cxp = f * rx * yp / ry; var cyp = f * -ry * xp / rx; var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp; var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp; var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]); var u = [(xp - cxp) / rx, (yp - cyp) / ry]; var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry]; var dTheta = vAngle(u, v); if (vRatio(u, v) <= -1) { dTheta = Math.PI; } if (vRatio(u, v) >= 1) { dTheta = 0; } if (fs === 0 && dTheta > 0) { dTheta = dTheta - 2 * Math.PI; } if (fs === 1 && dTheta < 0) { dTheta = dTheta + 2 * Math.PI; } return [point1, cx, cy, rx, ry, theta, dTheta, psi, fs]; } var PathSegment = function PathSegment(item, preSegment, isLast) { this.preSegment = preSegment; this.isLast = isLast; this.init(item, preSegment); }; Util.augment(PathSegment, { init: function init(item, preSegment) { var command = item[0]; preSegment = preSegment || { endPoint: { x: 0, y: 0 } }; var relative = ARR_CMD.indexOf(command) >= 0; // /[a-z]/.test(command); var cmd = relative ? command.toUpperCase() : command; var p = item; var point1 = void 0; var point2 = void 0; var point3 = void 0; var point = void 0; var preEndPoint = preSegment.endPoint; var p1 = p[1]; var p2 = p[2]; switch (cmd) { default: break; case 'M': if (relative) { point = toAbsolute(p1, p2, preEndPoint); } else { point = { x: p1, y: p2 }; } this.command = 'M'; this.params = [preEndPoint, point]; this.subStart = point; this.endPoint = point; break; case 'L': if (relative) { point = toAbsolute(p1, p2, preEndPoint); } else { point = { x: p1, y: p2 }; } this.command = 'L'; this.params = [preEndPoint, point]; this.subStart = preSegment.subStart; this.endPoint = point; if (this.isLast) { this.endTangent = function () { return [point.x - preEndPoint.x, point.y - preEndPoint.y]; }; } break; case 'H': if (relative) { point = toAbsolute(p1, 0, preEndPoint); } else { point = { x: p1, y: preEndPoint.y }; } this.command = 'L'; this.params = [preEndPoint, point]; this.subStart = preSegment.subStart; this.endPoint = point; this.endTangent = function () { return [point.x - preEndPoint.x, point.y - preEndPoint.y]; }; break; case 'V': if (relative) { point = toAbsolute(0, p1, preEndPoint); } else { point = { x: preEndPoint.x, y: p1 }; } this.command = 'L'; this.params = [preEndPoint, point]; this.subStart = preSegment.subStart; this.endPoint = point; this.endTangent = function () { return [point.x - preEndPoint.x, point.y - preEndPoint.y]; }; break; case 'Q': if (relative) { point1 = toAbsolute(p1, p2, preEndPoint); point2 = toAbsolute(p[3], p[4], preEndPoint); } else { point1 = { x: p1, y: p2 }; point2 = { x: p[3], y: p[4] }; } this.command = 'Q'; this.params = [preEndPoint, point1, point2]; this.subStart = preSegment.subStart; this.endPoint = point2; this.endTangent = function () { return [point2.x - point1.x, point2.y - point1.y]; }; break; case 'T': if (relative) { point2 = toAbsolute(p1, p2, preEndPoint); } else { point2 = { x: p1, y: p2 }; } if (preSegment.command === 'Q') { point1 = toSymmetry(preSegment.params[1], preEndPoint); this.command = 'Q'; this.params = [preEndPoint, point1, point2]; this.subStart = preSegment.subStart; this.endPoint = point2; this.endTangent = function () { return [point2.x - point1.x, point2.y - point1.y]; }; } else { this.command = 'TL'; this.params = [preEndPoint, point2]; this.subStart = preSegment.subStart; this.endPoint = point2; this.endTangent = function () { return [point2.x - preEndPoint.x, point2.y - preEndPoint.y]; }; } break; case 'C': if (relative) { point1 = toAbsolute(p1, p2, preEndPoint); point2 = toAbsolute(p[3], p[4], preEndPoint); point3 = toAbsolute(p[5], p[6], preEndPoint); } else { point1 = { x: p1, y: p2 }; point2 = { x: p[3], y: p[4] }; point3 = { x: p[5], y: p[6] }; } this.command = 'C'; this.params = [preEndPoint, point1, point2, point3]; this.subStart = preSegment.subStart; this.endPoint = point3; this.endTangent = function () { return [point3.x - point2.x, point3.y - point2.y]; }; break; case 'S': if (relative) { point2 = toAbsolute(p1, p2, preEndPoint); point3 = toAbsolute(p[3], p[4], preEndPoint); } else { point2 = { x: p1, y: p2 }; point3 = { x: p[3], y: p[4] }; } if (preSegment.command === 'C') { point1 = toSymmetry(preSegment.params[2], preEndPoint); this.command = 'C'; this.params = [preEndPoint, point1, point2, point3]; this.subStart = preSegment.subStart; this.endPoint = point3; this.endTangent = function () { return [point3.x - point2.x, point3.y - point2.y]; }; } else { this.command = 'SQ'; this.params = [preEndPoint, point2, point3]; this.subStart = preSegment.subStart; this.endPoint = point3; this.endTangent = function () { return [point3.x - point2.x, point3.y - point2.y]; }; } break; case 'A': { var rx = p1; var ry = p2; var psi = p[3]; var fa = p[4]; var fs = p[5]; if (relative) { point = toAbsolute(p[6], p[7], preEndPoint); } else { point = { x: p[6], y: p[7] }; } this.command = 'A'; this.params = getArcParams(preEndPoint, point, fa, fs, rx, ry, psi); this.subStart = preSegment.subStart; this.endPoint = point; break; } case 'Z': { this.command = 'Z'; this.params = [preEndPoint, preSegment.subStart]; this.subStart = preSegment.subStart; this.endPoint = preSegment.subStart; } } }, isInside: function isInside(x, y, lineWidth) { var self = this; var command = self.command; var params = self.params; var box = self.box; if (box) { if (!Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) { return false; } } switch (command) { default: break; case 'M': return false; case 'TL': case 'L': case 'Z': return Inside.line(params[0].x, params[0].y, params[1].x, params[1].y, lineWidth, x, y); case 'SQ': case 'Q': return Inside.quadraticline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, lineWidth, x, y); case 'C': { return Inside.cubicline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, params[3].x, params[3].y, lineWidth, x, y); } case 'A': { var p = params; var cx = p[1]; var cy = p[2]; var rx = p[3]; var ry = p[4]; var theta = p[5]; var dTheta = p[6]; var psi = p[7]; var fs = p[8]; var r = rx > ry ? rx : ry; var scaleX = rx > ry ? 1 : rx / ry; var scaleY = rx > ry ? ry / rx : 1; p = [x, y, 1]; var m = [1, 0, 0, 0, 1, 0, 0, 0, 1]; mat3.translate(m, m, [-cx, -cy]); mat3.rotate(m, m, -psi); mat3.scale(m, m, [1 / scaleX, 1 / scaleY]); vec3.transformMat3(p, p, m); return Inside.arcline(0, 0, r, theta, theta + dTheta, 1 - fs, lineWidth, p[0], p[1]); } } return false; }, draw: function draw(context) { var command = this.command; var params = this.params; var point1 = void 0; var point2 = void 0; var point3 = void 0; switch (command) { default: break; case 'M': context.moveTo(params[1].x, params[1].y); break; case 'TL': case 'L': context.lineTo(params[1].x, params[1].y); break; case 'SQ': case 'Q': point1 = params[1]; point2 = params[2]; context.quadraticCurveTo(point1.x, point1.y, point2.x, point2.y); break; case 'C': point1 = params[1]; point2 = params[2]; point3 = params[3]; context.bezierCurveTo(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y); break; case 'A': { var p = params; var p1 = p[1]; var p2 = p[2]; var cx = p1; var cy = p2; var rx = p[3]; var ry = p[4]; var theta = p[5]; var dTheta = p[6]; var psi = p[7]; var fs = p[8]; var r = rx > ry ? rx : ry; var scaleX = rx > ry ? 1 : rx / ry; var scaleY = rx > ry ? ry / rx : 1; context.translate(cx, cy); context.rotate(psi); context.scale(scaleX, scaleY); context.arc(0, 0, r, theta, theta + dTheta, 1 - fs); context.scale(1 / scaleX, 1 / scaleY); context.rotate(-psi); context.translate(-cx, -cy); break; } case 'Z': context.closePath(); break; } }, getBBox: function getBBox(lineWidth) { var halfWidth = lineWidth / 2; var params = this.params; var yDims = void 0; var xDims = void 0; var i = void 0; var l = void 0; switch (this.command) { default: case 'M': case 'Z': break; case 'TL': case 'L': this.box = { minX: Math.min(params[0].x, params[1].x) - halfWidth, maxX: Math.max(params[0].x, params[1].x) + halfWidth, minY: Math.min(params[0].y, params[1].y) - halfWidth, maxY: Math.max(params[0].y, params[1].y) + halfWidth }; break; case 'SQ': case 'Q': xDims = Quadratic.extrema(params[0].x, params[1].x, params[2].x); for (i = 0, l = xDims.length; i < l; i++) { xDims[i] = Quadratic.at(params[0].x, params[1].x, params[2].x, xDims[i]); } xDims.push(params[0].x, params[2].x); yDims = Quadratic.extrema(params[0].y, params[1].y, params[2].y); for (i = 0, l = yDims.length; i < l; i++) { yDims[i] = Quadratic.at(params[0].y, params[1].y, params[2].y, yDims); } yDims.push(params[0].y, params[2].y); this.box = { minX: Math.min.apply(Math, xDims) - halfWidth, maxX: Math.max.apply(Math, xDims) + halfWidth, minY: Math.min.apply(Math, yDims) - halfWidth, maxY: Math.max.apply(Math, yDims) + halfWidth }; break; case 'C': xDims = Cubic.extrema(params[0].x, params[1].x, params[2].x, params[3].x); for (i = 0, l = xDims.length; i < l; i++) { xDims[i] = Cubic.at(params[0].x, params[1].x, params[2].x, params[3].x, xDims[i]); } yDims = Cubic.extrema(params[0].y, params[1].y, params[2].y, params[3].y); for (i = 0, l = yDims.length; i < l; i++) { yDims[i] = Cubic.at(params[0].y, params[1].y, params[2].y, params[3].y, yDims[i]); } xDims.push(params[0].x, params[3].x); yDims.push(params[0].y, params[3].y); this.box = { minX: Math.min.apply(Math, xDims) - halfWidth, maxX: Math.max.apply(Math, xDims) + halfWidth, minY: Math.min.apply(Math, yDims) - halfWidth, maxY: Math.max.apply(Math, yDims) + halfWidth }; break; case 'A': { // todo 待优化 var p = params; var cx = p[1]; var cy = p[2]; var rx = p[3]; var ry = p[4]; var theta = p[5]; var dTheta = p[6]; var psi = p[7]; var fs = p[8]; var start = theta; var end = theta + dTheta; var xDim = Ellipse.xExtrema(psi, rx, ry); var minX = Infinity; var maxX = -Infinity; var xs = [start, end]; for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) { var xAngle = xDim + i; if (fs === 1) { if (start < xAngle && xAngle < end) { xs.push(xAngle); } } else { if (end < xAngle && xAngle < start) { xs.push(xAngle); } } } for (i = 0, l = xs.length; i < l; i++) { var x = Ellipse.xAt(psi, rx, ry, cx, xs[i]); if (x < minX) { minX = x; } if (x > maxX) { maxX = x; } } var yDim = Ellipse.yExtrema(psi, rx, ry); var minY = Infinity; var maxY = -Infinity; var ys = [start, end]; for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) { var yAngle = yDim + i; if (fs === 1) { if (start < yAngle && yAngle < end) { ys.push(yAngle); } } else { if (end < yAngle && yAngle < start) { ys.push(yAngle); } } } for (i = 0, l = ys.length; i < l; i++) { var y = Ellipse.yAt(psi, rx, ry, cy, ys[i]); if (y < minY) { minY = y; } if (y > maxY) { maxY = y; } } this.box = { minX: minX - halfWidth, maxX: maxX + halfWidth, minY: minY - halfWidth, maxY: maxY + halfWidth }; break; } } } }); module.exports = PathSegment; /***/ }, /* 264 */ /***/function (module, exports) { module.exports = { xAt: function xAt(psi, rx, ry, cx, t) { return rx * Math.cos(psi) * Math.cos(t) - ry * Math.sin(psi) * Math.sin(t) + cx; }, yAt: function yAt(psi, rx, ry, cy, t) { return rx * Math.sin(psi) * Math.cos(t) + ry * Math.cos(psi) * Math.sin(t) + cy; }, xExtrema: function xExtrema(psi, rx, ry) { return Math.atan(-ry / rx * Math.tan(psi)); }, yExtrema: function yExtrema(psi, rx, ry) { return Math.atan(ry / (rx * Math.tan(psi))); } }; /***/ }] /******/) ); }); /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(26)(module))) /***/ }), /* 3 */ /***/ (function(module, exports) { /** * Checks if `value` is classified as an `Array` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array, else `false`. * @example * * _.isArray([1, 2, 3]); * // => true * * _.isArray(document.body.children); * // => false * * _.isArray('abc'); * // => false * * _.isArray(_.noop); * // => false */ var isArray = Array.isArray; module.exports = isArray; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { 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 freeGlobal = __webpack_require__(71); /** Detect free variable `self`. */ var freeSelf = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ var root = freeGlobal || freeSelf || Function('return this')(); module.exports = root; /***/ }), /* 5 */ /***/ (function(module, exports) { 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; }; /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is object-like, else `false`. * @example * * _.isObjectLike({}); * // => true * * _.isObjectLike([1, 2, 3]); * // => true * * _.isObjectLike(_.noop); * // => false * * _.isObjectLike(null); * // => false */ function isObjectLike(value) { return value != null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object'; } module.exports = isObjectLike; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { var _Symbol = __webpack_require__(12), getRawTag = __webpack_require__(135), objectToString = __webpack_require__(136); /** `Object#toString` result references. */ var nullTag = '[object Null]', undefinedTag = '[object Undefined]'; /** Built-in value references. */ var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; /** * The base implementation of `getTag` without fallbacks for buggy environments. * * @private * @param {*} value The value to query. * @returns {string} Returns the `toStringTag`. */ function baseGetTag(value) { if (value == null) { return value === undefined ? undefinedTag : nullTag; } return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); } module.exports = baseGetTag; /***/ }), /* 7 */ /***/ (function(module, exports) { 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; }; /** * Checks if `value` is the * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an object, else `false`. * @example * * _.isObject({}); * // => true * * _.isObject([1, 2, 3]); * // => true * * _.isObject(_.noop); * // => true * * _.isObject(null); * // => false */ function isObject(value) { var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); return value != null && (type == 'object' || type == 'function'); } module.exports = isObject; /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { var isFunction = __webpack_require__(48), isLength = __webpack_require__(47); /** * Checks if `value` is array-like. A value is considered array-like if it's * not a function and has a `value.length` that's an integer greater than or * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is array-like, else `false`. * @example * * _.isArrayLike([1, 2, 3]); * // => true * * _.isArrayLike(document.body.children); * // => true * * _.isArrayLike('abc'); * // => true * * _.isArrayLike(_.noop); * // => false */ function isArrayLike(value) { return value != null && isLength(value.length) && !isFunction(value); } module.exports = isArrayLike; /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 所有 Geometry 的基类 * @author dxq613@gmail.com */ var Base = __webpack_require__(63); var Attr = __webpack_require__(286); var Util = __webpack_require__(0); var Global = __webpack_require__(1); var Adjust = __webpack_require__(294); var Labels = __webpack_require__(299); var Shape = __webpack_require__(66); var TooltipMixin = __webpack_require__(310); var ActiveMixin = __webpack_require__(311); var SelectMixin = __webpack_require__(312); var GROUP_ATTRS = ['color', 'shape', 'size']; var FIELD_ORIGIN = '_origin'; function parseFields(field) { if (Util.isArray(field)) { return field; } if (Util.isString(field)) { return field.split('*'); } return [field]; } // 转换成对象的数组 [{type: 'adjust'}] function parseAdjusts(adjusts) { if (Util.isString(adjusts)) { adjusts = [adjusts]; } Util.each(adjusts, function (adjust, index) { if (!Util.isObject(adjust)) { adjusts[index] = { type: adjust }; } }); return adjusts; } /** * 几何标记 * @class Geom */ var GeomBase = function (_Base) { _inherits(GeomBase, _Base); /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ GeomBase.prototype.getDefaultCfg = function getDefaultCfg() { return { /** * 标记 _id 用于区分执行动画 * @type {String} */ _id: null, /** * 类型 * @type {String} */ type: 'base', /** * 坐标系 * @type {Object} */ coord: null, /** * 属性映射集 * @protected * @type {Object} */ attrs: {}, /** * 所属的View * @type {View} */ view: null, /** * 几何标记显示的数据 * @type {Array} */ data: [], /** * 相关的度量 * @type {Object} */ scales: {}, /** * 绘图容器 * @type {Object} */ container: null, /** * 文本容器 * @type {Object} */ labelContainer: null, /** * 图形容器 * @type {Object} */ shapeContainer: null, /** * 几何标记的一些配置项,用于延迟生成图表 * @type {Object} */ attrOptions: {}, styleOptions: null, selectedOptions: null, /** * 某些类存在默认的adjust,不能更改 adjust * @type {Boolean} */ hasDefaultAdjust: false, adjusts: null, /** * 使用形状的类型 * @protected * @type {String} */ shapeType: null, /** * 是否生成多个点来绘制图形 * @protected * @type {Boolean} */ generatePoints: false, /** * 数据是否进行排序 * @type {Boolean} */ sortable: false, labelCfg: null, /** * 是否共享 tooltip * @type {Boolean} */ shareTooltip: true, tooltipCfg: null, /** * 是否执行动画,默认执行 * @type {Boolean} */ animate: true, /** * 动画配置 * @type {[type]} */ animateCfg: null }; }; function GeomBase(cfg) { _classCallCheck(this, GeomBase); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); Util.assign(_this, TooltipMixin, ActiveMixin, SelectMixin); if (_this.get('container')) { _this._initContainer(); } _this._initOptions(); return _this; } // 初始化时对配置项的格式化 GeomBase.prototype._initOptions = function _initOptions() { var adjusts = this.get('adjusts'); if (adjusts) { adjusts = parseAdjusts(adjusts); this.set('adjusts', adjusts); } }; GeomBase.prototype._createScale = function _createScale(field) { var scales = this.get('scales'); var scale = scales[field]; if (!scale) { scale = this.get('view').createScale(field); scales[field] = scale; } return scale; }; GeomBase.prototype._setAttrOptions = function _setAttrOptions(attrName, attrCfg) { var options = this.get('attrOptions'); options[attrName] = attrCfg; }; GeomBase.prototype._createAttrOption = function _createAttrOption(attrName, field, cfg, defaultValues) { var attrCfg = {}; attrCfg.field = field; if (cfg) { if (Util.isFunction(cfg)) { attrCfg.callback = cfg; } else { attrCfg.values = cfg; } } else if (attrName !== 'color') { attrCfg.values = defaultValues; } this._setAttrOptions(attrName, attrCfg); }; /** * 位置属性映射 * @chainable * @param {String} field 字段名 * @return {Geom} geom 当前几何标记 */ GeomBase.prototype.position = function position(field) { this._setAttrOptions('position', { field: field }); return this; }; /** * 颜色属性映射 * @chainable * @param {String} field 字段名 * @param {Array|Function} values 颜色的数组或者回调函数 * @return {Geom} geom 当前几何标记 */ GeomBase.prototype.color = function color(field, values) { this._createAttrOption('color', field, values, Global.colors); return this; }; /** * 大小属性映射 * @chainable * @param {String} field 字段名 * @param {Array|Function} values 大小的数组或者回调函数 * @return {Geom} geom 当前几何标记 */ GeomBase.prototype.size = function size(field, values) { this._createAttrOption('size', field, values, Global.sizes); return this; }; /** * 形状属性映射 * @chainable * @param {String} field 字段名 * @param {Array|Function} values 大小的数组或者回调函数 * @return {Geom} geom 当前几何标记 */ GeomBase.prototype.shape = function shape(field, values) { var type = this.get('type'); var shapes = Global.shapes[type] || []; this._createAttrOption('shape', field, values, shapes); return this; }; /** * 透明度属性映射 * @chainable * @param {String} field 字段名 * @param {Array|Function} values 透明度的数组或者回调函数 * @return {Geom} geom 当前几何标记 */ GeomBase.prototype.opacity = function opacity(field, values) { this._createAttrOption('opacity', field, values, Global.opacities); return this; }; GeomBase.prototype.style = function style(field, cfg) { var styleOptions = this.get('styleOptions'); if (!styleOptions) { styleOptions = {}; this.set('styleOptions', styleOptions); } if (Util.isObject(field)) { cfg = field; field = null; } var fields = void 0; if (field) { fields = parseFields(field); } styleOptions.fields = fields; styleOptions.style = cfg; return this; }; GeomBase.prototype.label = function label(field, callback, cfg) { var self = this; var labelCfg = self.get('labelCfg'); // const scales = Util.map(self.get('labelCfg').fields, field => self._createScale(field)); if (!labelCfg) { labelCfg = {}; self.set('labelCfg', labelCfg); } var fields = void 0; if (field) { fields = parseFields(field); } labelCfg.fields = fields; // 如果存在回调函数 if (Util.isFunction(callback)) { if (!cfg) { cfg = {}; } cfg.content = callback; } else if (Util.isObject(callback)) { // 如果没有设置回调函数 cfg = callback; } labelCfg.cfg = cfg; return this; }; GeomBase.prototype.tooltip = function tooltip(field, cfg) { var tooltipCfg = this.get('tooltipCfg'); if (!tooltipCfg) { tooltipCfg = {}; } if (field === false) { // geom 关闭 tooltip this.set('tooltipCfg', false); } else { var tooltipFields = void 0; if (field) { tooltipFields = parseFields(field); } tooltipCfg.fields = tooltipFields; tooltipCfg.cfg = cfg; } this.set('tooltipCfg', tooltipCfg); return this; }; GeomBase.prototype.animate = function animate(cfg) { this.set('animateCfg', cfg); return this; }; /** * 是否允许使用默认的图形激活交互 * @param {Boolean} enable 是否允许激活开关 * @return {Geom} 返回 geom 自身 */ GeomBase.prototype.active = function active(enable) { this.set('allowActive', enable); return this; }; /** * 对 geometry 进行数据调整 * @chainable * @param {String|Array|null} adjusts 数据调整的类型 * @return {Object} geometry 对象 */ GeomBase.prototype.adjust = function adjust(adjusts) { if (!this.get('hasDefaultAdjust')) { if (adjusts) { adjusts = parseAdjusts(adjusts); } this.set('adjusts', adjusts); } return this; }; /** * 设置图形的选中模式 * @param {Boolean|Object} enable 布尔类型用于模式开关,对象类型用于配置 * @param {Object} cfg 选中配置项 * @return {Geom} 返回 geom 自身 */ GeomBase.prototype.select = function select(enable, cfg) { if (enable === false) { this.set('allowSelect', false); } else if (Util.isObject(enable)) { this.set('allowSelect', true); this.set('selectedOptions', enable); } else { this.set('allowSelect', true); this.set('selectedOptions', cfg); } return this; }; GeomBase.prototype.hasAdjust = function hasAdjust(adjustType) { var self = this; var adjusts = self.get('adjusts'); if (!adjustType) { return false; } var rst = false; Util.each(adjusts, function (adjust) { if (adjust.type === adjustType) { rst = true; return false; } }); return rst; }; GeomBase.prototype.hasStack = function hasStack() { var isStacked = this.get('isStacked'); if (Util.isNil(isStacked)) { isStacked = this.hasAdjust('stack'); this.set('isStacked', isStacked); } return isStacked; }; GeomBase.prototype.isInCircle = function isInCircle() { var coord = this.get('coord'); return coord && coord.isPolar; }; GeomBase.prototype._initContainer = function _initContainer() { var self = this; var shapeContainer = self.get('shapeContainer'); if (!shapeContainer) { var container = self.get('container'); var view = self.get('view'); var viewId = view && view.get('_id'); shapeContainer = container.addGroup({ viewId: viewId }); self.set('shapeContainer', shapeContainer); } }; GeomBase.prototype.init = function init() { var self = this; self._initContainer(); self._initAttrs(); if (self.get('tooltipCfg') && self.get('tooltipCfg').fields) { var tooltipFields = self.get('tooltipCfg').fields; Util.each(tooltipFields, function (field) { self._createScale(field); }); } var dataArray = self._processData(); if (self.get('adjusts')) { self._adjust(dataArray); } self.set('dataArray', dataArray); }; // step 1: init attrs GeomBase.prototype._initAttrs = function _initAttrs() { var self = this; var attrs = this.get('attrs'); var attrOptions = this.get('attrOptions'); var coord = self.get('coord'); var isPie = false; for (var type in attrOptions) { if (attrOptions.hasOwnProperty(type)) { var option = attrOptions[type]; var className = Util.upperFirst(type); var fields = parseFields(option.field); if (type === 'position') { option.coord = coord; // 饼图坐标系下,填充一维 if (fields.length === 1 && coord.type === 'theta') { fields.unshift('1'); isPie = true; } } var scales = []; for (var i = 0; i < fields.length; i++) { var field = fields[i]; var scale = self._createScale(field); if (type === 'color' && Util.isNil(option.values)) { // 设置 color 的默认色值 if (scale.values.length <= 8) { option.values = isPie ? Global.colors_pie : Global.colors; } else if (scale.values.length <= 16) { option.values = isPie ? Global.colors_pie_16 : Global.colors_16; } else { option.values = Global.colors_24; } if (Util.isNil(option.values)) { option.values = Global.colors; // 防止主题没有声明诸如 colors_pie 的属性 } } scales.push(scale); } // 饼图需要填充满整个空间 if (coord.type === 'theta' && type === 'position' && scales.length > 1) { var yScale = scales[1]; yScale.change({ nice: false, min: 0, max: Math.max.apply(null, yScale.values) }); } option.scales = scales; var attr = new Attr[className](option); attrs[type] = attr; } } }; // step 2: 处理数据 GeomBase.prototype._processData = function _processData() { var self = this; var data = this.get('data'); var dataArray = []; var groupedArray = this._groupData(data); for (var i = 0; i < groupedArray.length; i++) { var subData = groupedArray[i]; var tempData = self._saveOrigin(subData); self._numberic(tempData); dataArray.push(tempData); } return dataArray; }; // step 2.1 数据分组 GeomBase.prototype._groupData = function _groupData(data) { var groupScales = this._getGroupScales(); var fields = groupScales.map(function (scale) { return scale.field; }); return Util.Array.group(data, fields); }; // step 2.2 数据调整前保存原始数据 GeomBase.prototype._saveOrigin = function _saveOrigin(data) { var rst = []; for (var i = 0; i < data.length; i++) { var origin = data[i]; var obj = {}; for (var k in origin) { obj[k] = origin[k]; } // const obj = Util.mix({}, origin); obj[FIELD_ORIGIN] = origin; rst.push(obj); } return rst; }; // step 2.3 将分类数据翻译成数据, 仅对位置相关的度量进行数字化处理 GeomBase.prototype._numberic = function _numberic(data) { var positionAttr = this.getAttr('position'); var scales = positionAttr.scales; for (var j = 0; j < data.length; j++) { var obj = data[j]; for (var i = 0; i < Math.min(2, scales.length); i++) { var scale = scales[i]; if (scale.isCategory) { var field = scale.field; obj[field] = scale.translate(obj[field]); } } } }; GeomBase.prototype._getGroupScales = function _getGroupScales() { var self = this; var scales = self.get('groupScales'); if (!scales) { scales = []; var attrs = self.get('attrs'); Util.each(attrs, function (attr) { if (GROUP_ATTRS.indexOf(attr.type) !== -1) { var attrScales = attr.scales; Util.each(attrScales, function (scale) { if (scale.isCategory && Util.indexOf(scales, scale) === -1) { scales.push(scale); } }); } }); self.set('groupScales', scales); } return scales; }; GeomBase.prototype._updateStackRange = function _updateStackRange(field, scale, dataArray) { var mergeArray = Util.Array.merge(dataArray); var min = scale.min; var max = scale.max; for (var i = 0; i < mergeArray.length; i++) { var obj = mergeArray[i]; var tmpMin = Math.min.apply(null, obj[field]); var tmpMax = Math.max.apply(null, obj[field]); if (tmpMin < min) { min = tmpMin; } if (tmpMax > max) { max = tmpMax; } } if (min < scale.min || max > scale.max) { scale.change({ min: min, max: max }); } }; // step 2.2 调整数据 GeomBase.prototype._adjust = function _adjust(dataArray) { var self = this; var adjusts = self.get('adjusts'); var yScale = self.getYScale(); var xScale = self.getXScale(); var xField = xScale.field; var yField = yScale ? yScale.field : null; Util.each(adjusts, function (adjust) { var adjustCfg = Util.mix({ xField: xField, yField: yField }, adjust); var adjustType = Util.upperFirst(adjust.type); if (adjustType === 'Dodge') { var adjustNames = []; if (xScale.isCategory || xScale.isIdentity) { adjustNames.push('x'); } else if (!yScale) { adjustNames.push('y'); } else { throw new Error('dodge is not support linear attribute, please use category attribute!'); } adjustCfg.adjustNames = adjustNames; /* if (self.isInCircle()) { adjustCfg.dodgeRatio = 1; adjustCfg.marginRatio = 0; }*/ } else if (adjustType === 'Stack') { var coord = self.get('coord'); if (!yScale) { // 一维的情况下获取高度和默认size adjustCfg.height = coord.getHeight(); var size = self.getDefaultValue('size') || 3; adjustCfg.size = size; } if (!coord.isTransposed) { adjustCfg.reverseOrder = true; } } var adjustElement = new Adjust[adjustType](adjustCfg); adjustElement.processAdjust(dataArray); if (adjustType === 'Stack' && yScale) { self._updateStackRange(yField, yScale, dataArray); } }); }; /** * @internal 设置coord,通常外部容器变化时,coord 会发生变化 * @param {Object} coord 坐标系 */ GeomBase.prototype.setCoord = function setCoord(coord) { this.set('coord', coord); var position = this.getAttr('position'); var shapeContainer = this.get('shapeContainer'); shapeContainer.setMatrix(coord.matrix); if (position) { position.coord = coord; } }; // step 3 绘制 GeomBase.prototype.paint = function paint() { var self = this; var dataArray = self.get('dataArray'); var mappedArray = []; var shapeFactory = self.getShapeFactory(); shapeFactory.setCoord(self.get('coord')); var shapeContainer = self.get('shapeContainer'); self._beforeMapping(dataArray); for (var i = 0; i < dataArray.length; i++) { var data = dataArray[i]; var index = i; data = self._mapping(data); mappedArray.push(data); self.draw(data, shapeContainer, shapeFactory, index); } if (self.get('labelCfg')) { self._addLabels(Util.union.apply(null, mappedArray)); } if (!self.get('sortable')) { self._sort(mappedArray); // 便于数据的查找,需要对数据进行排序,用于 geom.findPoint() } else { self.set('dataArray', mappedArray); } }; GeomBase.prototype._sort = function _sort(mappedArray) { var self = this; var xScale = self.getXScale(); var xField = xScale.field; Util.each(mappedArray, function (itemArr) { itemArr.sort(function (obj1, obj2) { return xScale.translate(obj1[FIELD_ORIGIN][xField]) - xScale.translate(obj2[FIELD_ORIGIN][xField]); }); }); self.set('dataArray', mappedArray); }; // step 3.1 before mapping GeomBase.prototype._beforeMapping = function _beforeMapping(dataArray) { var self = this; if (self.get('sortable')) { var xScale = self.getXScale(); var field = xScale.field; Util.each(dataArray, function (data) { data.sort(function (v1, v2) { return xScale.translate(v1[field]) - xScale.translate(v2[field]); }); }); } if (self.get('generatePoints')) { Util.each(dataArray, function (data) { self._generatePoints(data); }); Util.each(dataArray, function (data, index) { var nextData = dataArray[index + 1]; if (nextData) { data[0].nextPoints = nextData[0].points; } }); } }; // step 3.2 add labels GeomBase.prototype._addLabels = function _addLabels(points) { var self = this; var type = self.get('type'); var coord = self.get('coord'); var C = Labels.getLabelsClass(coord.type, type); var container = self.get('container'); var scales = Util.map(self.get('labelCfg').fields, function (field) { return self._createScale(field); }); var labelContainer = container.addGroup(C, { _id: this.get('_id'), labelCfg: Util.mix({ scales: scales }, self.get('labelCfg')), coord: coord, geom: self, geomType: type }); labelContainer.showLabels(points); self.set('labelContainer', labelContainer); }; /** * @protected * 获取图形的工厂类 * @return {Object} 工厂类对象 */ GeomBase.prototype.getShapeFactory = function getShapeFactory() { var shapeFactory = this.get('shapeFactory'); if (!shapeFactory) { var shapeType = this.get('shapeType'); shapeFactory = Shape.getShapeFactory(shapeType); this.set('shapeFactory', shapeFactory); } return shapeFactory; }; // step 3.2 generate points GeomBase.prototype._generatePoints = function _generatePoints(data) { var self = this; var shapeFactory = self.getShapeFactory(); var shapeAttr = self.getAttr('shape'); for (var i = 0; i < data.length; i++) { var obj = data[i]; var cfg = self.createShapePointsCfg(obj); var shape = shapeAttr ? self._getAttrValues(shapeAttr, obj) : null; var points = shapeFactory.getShapePoints(shape, cfg); obj.points = points; } }; /** * 获取图形对应点的配置项 * @protected * @param {Object} obj 数据对象 * @return {Object} cfg 获取图形对应点的配置项 */ GeomBase.prototype.createShapePointsCfg = function createShapePointsCfg(obj) { var xScale = this.getXScale(); var yScale = this.getYScale(); var x = this._normalizeValues(obj[xScale.field], xScale); var y = void 0; // 存在没有 y 的情况 if (yScale) { y = this._normalizeValues(obj[yScale.field], yScale); } else { y = obj.y ? obj.y : 0.1; } return { x: x, y: y, y0: yScale ? yScale.scale(this.getYMinValue()) : undefined }; }; /** * @protected * 如果y轴的最小值小于0则返回0,否则返回最小值 * @return {Number} y轴上的最小值 */ GeomBase.prototype.getYMinValue = function getYMinValue() { var yScale = this.getYScale(); var min = yScale.min; var value = void 0; if (min >= 0) { value = min; } else { value = 0; } return value; }; // 将数据归一化 GeomBase.prototype._normalizeValues = function _normalizeValues(values, scale) { var rst = []; if (Util.isArray(values)) { for (var i = 0; i < values.length; i++) { var v = values[i]; rst.push(scale.scale(v)); } } else { rst = scale.scale(values); } return rst; }; // step 3.2 mapping GeomBase.prototype._mapping = function _mapping(data) { var self = this; var attrs = self.get('attrs'); var mappedData = []; for (var i = 0; i < data.length; i++) { var record = data[i]; var newRecord = {}; newRecord[FIELD_ORIGIN] = record[FIELD_ORIGIN]; newRecord.points = record.points; newRecord.nextPoints = record.nextPoints; for (var k in attrs) { if (attrs.hasOwnProperty(k)) { var attr = attrs[k]; var names = attr.names; var values = self._getAttrValues(attr, record); if (names.length > 1) { // position 之类的生成多个字段的属性 for (var j = 0; j < values.length; j++) { var val = values[j]; var name = names[j]; newRecord[name] = Util.isArray(val) && val.length === 1 ? val[0] : val; // 只有一个值时返回第一个属性值 } } else { newRecord[names[0]] = values.length === 1 ? values[0] : values; } } } mappedData.push(newRecord); } return mappedData; }; // 获取属性映射的值 GeomBase.prototype._getAttrValues = function _getAttrValues(attr, record) { var scales = attr.scales; var params = []; for (var i = 0; i < scales.length; i++) { var scale = scales[i]; var field = scale.field; if (scale.type === 'identity') { params.push(scale.value); } else { params.push(record[field]); } } var values = attr.mapping.apply(attr, params); return values; }; GeomBase.prototype.getAttrValue = function getAttrValue(attrName, record) { var attr = this.getAttr(attrName); var rst = null; if (attr) { var values = this._getAttrValues(attr, record); rst = values[0]; } return rst; }; GeomBase.prototype.getDefaultValue = function getDefaultValue(attrName) { var value = this.get(attrName); var attr = this.getAttr(attrName); if (attr) { var scale = attr.getScale(attrName); if (scale.type === 'identity') { value = scale.value; } } return value; }; /** * step 3.3 draw * @protected * @param {Array} data 绘制图形 * @param {Object} container 绘图容器 * @param {Object} shapeFactory 绘制图形的工厂类 * @param {Number} index 每个 shape 的索引值 */ GeomBase.prototype.draw = function draw(data, container, shapeFactory, index) { var self = this; for (var i = 0; i < data.length; i++) { var obj = data[i]; self.drawPoint(obj, container, shapeFactory, index + i); } }; GeomBase.prototype.getCallbackCfg = function getCallbackCfg(fields, cfg, origin) { if (!fields) { return cfg; } var tmpCfg = {}; var params = fields.map(function (field) { return origin[field]; }); Util.each(cfg, function (v, k) { if (Util.isFunction(v)) { tmpCfg[k] = v.apply(null, params); } else { tmpCfg[k] = v; } }); return tmpCfg; }; GeomBase.prototype._getShapeId = function _getShapeId(dataObj) { var id = this.get('_id'); var keyFields = this.get('keyFields'); if (keyFields && keyFields.length > 0) { Util.each(keyFields, function (key) { id += '-' + dataObj[key]; }); } else { var type = this.get('type'); var xScale = this.getXScale(); var yScale = this.getYScale(); var xField = xScale.field || 'x'; var yField = yScale.field || 'y'; var yVal = dataObj[yField]; var xVal = void 0; if (xScale.isIdentity) { xVal = xScale.value; } else { xVal = dataObj[xField]; } if (type === 'interval' || type === 'schema') { id += '-' + xVal; } else if (type === 'line' || type === 'area' || type === 'path') { id += '-' + type; } else { id += '-' + xVal + '-' + yVal; } var groupScales = this._getGroupScales(); if (!Util.isEmpty(groupScales)) { Util.each(groupScales, function (groupScale) { var field = groupScale.field; if (groupScale.type !== 'identity') { id += '-' + dataObj[field]; } }); } } return id; }; GeomBase.prototype.getDrawCfg = function getDrawCfg(obj) { var self = this; var cfg = { origin: obj, x: obj.x, y: obj.y, color: obj.color, size: obj.size, shape: obj.shape, isInCircle: self.isInCircle(), opacity: obj.opacity }; var styleOptions = self.get('styleOptions'); if (styleOptions && styleOptions.style) { cfg.style = self.getCallbackCfg(styleOptions.fields, styleOptions.style, obj[FIELD_ORIGIN]); } if (this.get('generatePoints')) { cfg.points = obj.points; cfg.nextPoints = obj.nextPoints; } if (this.get('animate')) { // _id 字段仅用于动画 cfg._id = self._getShapeId(obj[FIELD_ORIGIN]); } return cfg; }; GeomBase.prototype.drawPoint = function drawPoint(obj, container, shapeFactory, index) { var shape = obj.shape; var cfg = this.getDrawCfg(obj); var geomShape = shapeFactory.drawShape(shape, cfg, container); geomShape.setSilent('index', index); geomShape.setSilent('coord', this.get('coord')); if (this.get('animate') && this.get('animateCfg')) { geomShape.setSilent('animateCfg', this.get('animateCfg')); } }; /** * 获取属性 * @protected * @param {String} name 属性名 * @return {Scale} 度量 */ GeomBase.prototype.getAttr = function getAttr(name) { return this.get('attrs')[name]; }; /** * 获取 x 对应的度量 * @return {Scale} x 对应的度量 */ GeomBase.prototype.getXScale = function getXScale() { return this.getAttr('position').scales[0]; }; /** * 获取 y 对应的度量 * @return {Scale} y 对应的度量 */ GeomBase.prototype.getYScale = function getYScale() { return this.getAttr('position').scales[1]; }; GeomBase.prototype.getShapes = function getShapes() { var result = []; var shapeContainer = this.get('shapeContainer'); var children = shapeContainer.get('children'); Util.each(children, function (child) { if (child.get('origin')) { // 过滤 label result.push(child); } }); return result; }; GeomBase.prototype.getAttrsForLegend = function getAttrsForLegend() { var attrs = this.get('attrs'); var rst = []; Util.each(attrs, function (attr) { if (GROUP_ATTRS.indexOf(attr.type) !== -1) { rst.push(attr); } }); return rst; }; GeomBase.prototype.getFieldsForLegend = function getFieldsForLegend() { var fields = []; var attrOptions = this.get('attrOptions'); Util.each(GROUP_ATTRS, function (attrName) { var attrCfg = attrOptions[attrName]; if (attrCfg && attrCfg.field && Util.isString(attrCfg.field)) { fields = fields.concat(attrCfg.field.split('*')); } }); return Util.uniq(fields); }; GeomBase.prototype.changeVisible = function changeVisible(visible, stopDraw) { var shapeContainer = this.get('shapeContainer'); shapeContainer.set('visible', visible); var labelContainer = this.get('labelContainer'); if (labelContainer) { labelContainer.set('visible', visible); } if (!stopDraw) { var canvas = shapeContainer.get('canvas'); canvas.draw(); } }; GeomBase.prototype.reset = function reset() { this.set('attrOptions', {}); this.clearInner(); }; GeomBase.prototype.clearInner = function clearInner() { this.clearActivedShapes(); this.clearSelected(); var shapeContainer = this.get('shapeContainer'); shapeContainer && shapeContainer.clear(); // 由于 Labels 对应的模块需要生成group,所以这个地方需要删除 var labelContainer = this.get('labelContainer'); labelContainer && labelContainer.remove(); this.set('attrs', {}); this.set('groupScales', null); // if (!this.get('hasDefaultAdjust')) { // this.set('adjusts', null); // } this.set('labelContainer', null); this.set('xDistance', null); this.set('isStacked', null); }; GeomBase.prototype.clear = function clear() { this.clearInner(); this.set('scales', {}); }; GeomBase.prototype.destroy = function destroy() { this.clear(); var shapeContainer = this.get('shapeContainer'); shapeContainer && shapeContainer.remove(); this.offEvents(); _Base.prototype.destroy.call(this); }; GeomBase.prototype.bindEvents = function bindEvents() { if (this.get('view')) { this._bindActiveAction(); this._bindSelectedAction(); } }; GeomBase.prototype.offEvents = function offEvents() { if (this.get('view')) { this._offActiveAction(); this._offSelectedAction(); } }; return GeomBase; }(Base); module.exports = GeomBase; /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 工厂类,管理各种类型的 shape * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var PathUtil = __webpack_require__(14); var GPath = __webpack_require__(2).PathUtil; var Shape = {}; var ShapeBase = { _coord: null, /** * 绘制图形 * @param {Object} cfg 配置项 * @param {Object} container 容器 * @return {Object} shape 创建的 shape */ draw: function draw(cfg, container) { if (this.drawShape) { return this.drawShape(cfg, container); } return null; }, /** * 获取绘制图形需要的点, 可以不定义,则使用默认的 getPoints(cfg) { if (this.getShapePoints) { return this.getShapePoints(cfg); } return null; },*/ /** * 设置坐标系 * @param {Coord} coord 坐标系 */ setCoord: function setCoord(coord) { this._coord = coord; }, /** * 0~1 path 转 画布 path * @param {path} path 路径 * @param {Boolean} islineToArc 是否转换成圆弧 * @return {path} path 转换到画布坐标的path */ parsePath: function parsePath(path, islineToArc) { var coord = this._coord; path = GPath.parsePathString(path); if (coord.isPolar && islineToArc !== false) { path = PathUtil.convertPolarPath(coord, path); } else { path = PathUtil.convertNormalPath(coord, path); } return path; }, /** * 0~1 point 转 画布 point * @param {point} point 节点 * @return {point} point 转换后的点 */ parsePoint: function parsePoint(point) { var coord = this._coord; return coord.convertPoint(point); }, /** * 0~1 points 转 画布 points * @param {points} points 节点集合 * @return {points} points 转换后的多个节点 */ parsePoints: function parsePoints(points) { var coord = this._coord; var rst = []; Util.each(points, function (point) { rst.push(coord.convertPoint(point)); }); return rst; } }; var ShapeFactoryBase = { defaultShapeType: null, setCoord: function setCoord(coord) { this._coord = coord; }, getShape: function getShape(type) { var self = this; if (Util.isArray(type)) { type = type[0]; } var shape = self[type] || self[self.defaultShapeType]; shape._coord = self._coord; return shape; }, getShapePoints: function getShapePoints(type, cfg) { var shape = this.getShape(type); var fn = shape.getPoints || shape.getShapePoints || this.getDefaultPoints; var points = fn(cfg); return points; }, getDefaultPoints: function getDefaultPoints() /* cfg */{ return []; }, getMarkerCfg: function getMarkerCfg(type, cfg) { var shape = this.getShape(type); if (!shape.getMarkerCfg) { var defaultShapeType = this.defaultShapeType; shape = this.getShape(defaultShapeType); } return shape.getMarkerCfg(cfg); }, drawShape: function drawShape(type, cfg, container) { var shape = this.getShape(type); var gShape = shape.draw(cfg, container); if (gShape) { gShape.setSilent('origin', cfg.origin); gShape._id = cfg.yIndex ? cfg._id + cfg.yIndex : cfg._id; gShape.name = this.name; } return gShape; } }; // 注册 Geometry 获取图形的入口 Shape.registerFactory = function (factoryName, cfg) { var className = Util.upperFirst(factoryName); var geomObj = Util.assign({}, ShapeFactoryBase, cfg); Shape[className] = geomObj; geomObj.name = factoryName; return geomObj; }; // 注册图形 Shape.registerShape = function (factoryName, shapeType, cfg) { var className = Util.upperFirst(factoryName); var factory = Shape[className]; var shapeObj = Util.assign({}, ShapeBase, cfg); factory[shapeType] = shapeObj; return shapeObj; }; // 获得Geom 对应的 shapeFactory Shape.getShapeFactory = function (factoryName) { var self = this; factoryName = factoryName || 'point'; var className = Util.upperFirst(factoryName); return self[className]; }; module.exports = Shape; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { var arrayLikeKeys = __webpack_require__(70), baseKeys = __webpack_require__(74), isArrayLike = __webpack_require__(8); /** * Creates an array of the own enumerable property names of `object`. * * **Note:** Non-object values are coerced to objects. See the * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) * for more details. * * @static * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. * @example * * function Foo() { * this.a = 1; * this.b = 2; * } * * Foo.prototype.c = 3; * * _.keys(new Foo); * // => ['a', 'b'] (iteration order is not guaranteed) * * _.keys('hi'); * // => ['0', '1'] */ function keys(object) { return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } module.exports = keys; /***/ }), /* 12 */ /***/ (function(module, exports, __webpack_require__) { var root = __webpack_require__(4); /** Built-in value references. */ var _Symbol = root.Symbol; module.exports = _Symbol; /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { var baseIsNative = __webpack_require__(155), getValue = __webpack_require__(158); /** * Gets the native function at `key` of `object`. * * @private * @param {Object} object The object to query. * @param {string} key The key of the method to get. * @returns {*} Returns the function if it's native, else `undefined`. */ function getNative(object, key) { var value = getValue(object, key); return baseIsNative(value) ? value : undefined; } module.exports = getNative; /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 计算path 使用的工具方法 * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var Spline = __webpack_require__(301); function points2path(points, isInCircle) { if (!points.length) { return []; } var path = []; for (var i = 0, length = points.length; i < length; i++) { var item = points[i]; if (i === 0) { path.push(['M', item.x, item.y]); } else { path.push(['L', item.x, item.y]); } } if (isInCircle) { path.push(['Z']); } return path; } function _getPointRadius(coord, point) { var center = coord.getCenter(); var r = Math.sqrt(Math.pow(point.x - center.x, 2) + Math.pow(point.y - center.y, 2)); return r; } function convertArr(arr, coord) { var len = arr.length; var tmp = [arr[0]]; for (var i = 1; i < len; i = i + 2) { var point = coord.convertPoint({ x: arr[i], y: arr[i + 1] }); tmp.push(point.x, point.y); } return tmp; } function _convertPolarPath(pre, cur, coord) { // const radius = coord.getRadius(); // const inner = coord.innerRadius || 0; // let innerRadius = inner * radius; var transposed = coord.isTransposed; var startAngle = coord.startAngle; var endAngle = coord.endAngle; var prePoint = { x: pre[1], y: pre[2] }; var curPoint = { x: cur[1], y: cur[2] }; var rst = []; // innerRadius = innerRadius || 0; var xDim = transposed ? 'y' : 'x'; var angleRange = Math.abs(curPoint[xDim] - prePoint[xDim]) * (endAngle - startAngle); var direction = curPoint[xDim] >= prePoint[xDim] ? 1 : 0; // 圆弧的方向 var flag = angleRange > Math.PI ? 1 : 0; // 大弧还是小弧标志位 var convertPoint = coord.convertPoint(curPoint); var r = _getPointRadius(coord, convertPoint); if (r >= 0.5) { // 小于1像素的圆在图像上无法识别 if (angleRange === Math.PI * 2) { var middlePoint = { x: (curPoint.x + prePoint.x) / 2, y: (curPoint.y + prePoint.y) / 2 }; var middleConvertPoint = coord.convertPoint(middlePoint); rst.push(['A', r, r, 0, flag, direction, middleConvertPoint.x, middleConvertPoint.y]); rst.push(['A', r, r, 0, flag, direction, convertPoint.x, convertPoint.y]); } else { rst.push(['A', r, r, 0, flag, direction, convertPoint.x, convertPoint.y]); } } return rst; } // 当存在整体的圆时,去除圆前面和后面的线,防止出现直线穿过整个圆的情形 function filterFullCirleLine(path) { Util.each(path, function (subPath, index) { var cur = subPath; if (cur[0].toLowerCase() === 'a') { var pre = path[index - 1]; var next = path[index + 1]; if (next && next[0].toLowerCase() === 'a') { if (pre && pre[0].toLowerCase() === 'l') { pre[0] = 'M'; } } else if (pre && pre[0].toLowerCase() === 'a') { if (next && next[0].toLowerCase() === 'l') { next[0] = 'M'; } } } }); } var PathUtil = { // 线的path getLinePath: function getLinePath(points, isInCircle) { return points2path(points, isInCircle); }, // get spline: 限定了范围的平滑线 getSplinePath: function getSplinePath(points, isInCircle, constaint) { var data = []; var first = points[0]; var prePoint = null; if (points.length <= 2) { return PathUtil.getLinePath(points, isInCircle); } Util.each(points, function (point) { if (!prePoint || !(prePoint.x === point.x && prePoint.y === point.y)) { data.push(point.x); data.push(point.y); prePoint = point; } }); constaint = constaint || [// 范围 [0, 0], [1, 1]]; var splinePath = Spline.catmullRom2bezier(data, isInCircle, constaint); splinePath.unshift(['M', first.x, first.y]); return splinePath; }, getPointRadius: function getPointRadius(coord, point) { var result = _getPointRadius(coord, point); return result; }, getPointAngle: function getPointAngle(coord, point) { var center = coord.getCenter(); var angle = Math.atan2(point.y - center.y, point.x - center.x); return angle; }, convertNormalPath: function convertNormalPath(coord, path) { var tmp = []; Util.each(path, function (subPath) { var action = subPath[0]; switch (action.toLowerCase()) { case 'm': case 'l': case 'c': tmp.push(convertArr(subPath, coord)); break; case 'z': default: tmp.push(subPath); break; } }); return tmp; }, convertPolarPath: function convertPolarPath(coord, path) { var tmp = []; var pre = void 0; var cur = void 0; var transposed = void 0; var equals = void 0; Util.each(path, function (subPath, index) { var action = subPath[0]; switch (action.toLowerCase()) { case 'm': case 'c': case 'q': tmp.push(convertArr(subPath, coord)); break; case 'l': pre = path[index - 1]; cur = subPath; transposed = coord.isTransposed; // 是否半径相同,转换成圆弧 equals = transposed ? pre[pre.length - 2] === cur[1] : pre[pre.length - 1] === cur[2]; if (equals) { tmp = tmp.concat(_convertPolarPath(pre, cur, coord)); } else { // y 不相等,所以直接转换 tmp.push(convertArr(subPath, coord)); } break; case 'z': default: tmp.push(subPath); break; } }); filterFullCirleLine(tmp); // 过滤多余的直线 return tmp; } }; module.exports = PathUtil; /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { var baseToString = __webpack_require__(186); /** * Converts `value` to a string. An empty string is returned for `null` * and `undefined` values. The sign of `-0` is preserved. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {string} Returns the converted string. * @example * * _.toString(null); * // => '' * * _.toString(-0); * // => '-0' * * _.toString([1, 2, 3]); * // => '1,2,3' */ function toString(value) { return value == null ? '' : baseToString(value); } module.exports = toString; /***/ }), /* 16 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview the Attribute base class * @author huangtonger@aliyun.com */ var Util = __webpack_require__(0); function toScaleString(scale, value) { if (Util.isString(value)) { return value; } return scale.invert(scale.scale(value)); } /** * 所有视觉通道属性的基类 * @class Attr */ var AttributeBase = function () { function AttributeBase(cfg) { _classCallCheck(this, AttributeBase); /** * 属性的类型 * @type {String} */ this.type = 'base'; /** * 属性的名称 * @type {String} */ this.name = null; /** * 回调函数 * @type {Function} */ this.method = null; /** * 备选的值数组 * @type {Array} */ this.values = []; /** * 属性内部的度量 * @type {Array} */ this.scales = []; /** * 是否通过线性取值, 如果未指定,则根据数值的类型判定 * @type {Boolean} */ this.linear = null; Util.mix(this, cfg); } AttributeBase.prototype.get = function get(name) { return this[name]; }; AttributeBase.prototype.set = function set(name, value) { this[name] = value; }; // 获取属性值,将值映射到视觉通道 AttributeBase.prototype._getAttrValue = function _getAttrValue(scale, value) { var values = this.values; if (scale.isCategory && !this.linear) { var index = scale.translate(value); return values[index % values.length]; } var percent = scale.scale(value); return this.getLinearValue(percent); }; /** * 如果进行线性映射,返回对应的映射值 * @protected * @param {Number} percent 百分比 * @return {*} 颜色值、形状、大小等 */ AttributeBase.prototype.getLinearValue = function getLinearValue(percent) { var values = this.values; var steps = values.length - 1; var step = Math.floor(steps * percent); var leftPercent = steps * percent - step; var start = values[step]; var end = step === steps ? start : values[step + 1]; var rstValue = start + (end - start) * leftPercent; return rstValue; }; /** * 默认的回调函数 * @param {*} value 回调函数的值 * @type {Function} * @return {Array} 返回映射后的值 */ AttributeBase.prototype.callback = function callback(value) { var self = this; var scale = self.scales[0]; var rstValue = null; if (scale.type === 'identity') { rstValue = scale.value; } else { rstValue = self._getAttrValue(scale, value); } return rstValue; }; /** * 根据度量获取属性名 * @return {Array} dims of this Attribute */ AttributeBase.prototype.getNames = function getNames() { var scales = this.scales; var names = this.names; var length = Math.min(scales.length, names.length); var rst = []; for (var i = 0; i < length; i++) { rst.push(names[i]); } return rst; }; /** * 根据度量获取维度名 * @return {Array} dims of this Attribute */ AttributeBase.prototype.getFields = function getFields() { var scales = this.scales; var rst = []; Util.each(scales, function (scale) { rst.push(scale.field); }); return rst; }; /** * 根据名称获取度量 * @param {String} name the name of scale * @return {Scale} scale */ AttributeBase.prototype.getScale = function getScale(name) { var scales = this.scales; var names = this.names; var index = names.indexOf(name); return scales[index]; }; /** * 映射数据 * @param {*} param1...paramn 多个数值 * @return {Array} 映射的值组成的数组 */ AttributeBase.prototype.mapping = function mapping() { var scales = this.scales; var callback = this.callback; for (var _len = arguments.length, params = Array(_len), _key = 0; _key < _len; _key++) { params[_key] = arguments[_key]; } var values = params; if (callback) { for (var i = 0; i < params.length; i++) { params[i] = this._toOriginParam(params[i], scales[i]); } values = callback.apply(this, params); } if (!Util.isArray(values)) { values = [values]; } return values; }; // 原始的参数 AttributeBase.prototype._toOriginParam = function _toOriginParam(param, scale) { var rst = param; if (!scale.isLinear) { if (Util.isArray(param)) { rst = []; for (var i = 0; i < param.length; i++) { rst.push(toScaleString(scale, param[i])); } } else { rst = toScaleString(scale, param); } } return rst; }; return AttributeBase; }(); module.exports = AttributeBase; /***/ }), /* 17 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview the base class of guide * @author sima.zhang */ var Util = __webpack_require__(0); var KEYWORDS = ['min', 'max', 'median']; function getFirstScale(scales) { var firstScale = void 0; Util.each(scales, function (scale) { if (scale) { firstScale = scale; return false; } }); return firstScale; } var Base = function () { Base.prototype.getDefaultCfg = function getDefaultCfg() { return { zIndex: 1, xScales: null, yScales: null, el: null }; }; function Base(cfg) { _classCallCheck(this, Base); var defaultCfg = this.getDefaultCfg(); cfg = Util.deepMix({}, defaultCfg, cfg); Util.mix(this, cfg); } /** * 将原始数值归一化 * @param {string | number} val 原始值 * @param {Scale} scale 度量对象 * @return {Number} 返回归一化后的数值 */ Base.prototype._getNormalizedValue = function _getNormalizedValue(val, scale) { var result = void 0; if (Util.indexOf(KEYWORDS, val) !== -1) { // 分类则对应索引值 var scaleValue = void 0; if (val === 'median') { scaleValue = scale.isCategory ? (scale.values.length - 1) / 2 : (scale.min + scale.max) / 2; result = scale.scale(scaleValue); } else { if (scale.isCategory) { scaleValue = val === 'min' ? 0 : scale.values.length - 1; } else { scaleValue = scale[val]; } result = scale.scale(scaleValue); } } else { result = scale.scale(val); } return result; }; /** * 将原始数值转换成坐标系上的点 * @protected * @param {Coord} coord 坐标系 * @param {Object | Array | Function} position 位置点 * @return {Object} 转换成坐标系上的点 */ Base.prototype.parsePoint = function parsePoint(coord, position) { var self = this; var xScales = self.xScales; var yScales = self.yScales; if (Util.isFunction(position)) { position = position(xScales, yScales); // position 必须是对象 } var x = void 0; var y = void 0; // 如果数据格式是 ['50%', '50%'] 的格式 if (Util.isArray(position) && Util.isString(position[0]) && position[0].indexOf('%') !== -1) { return this.parsePercentPoint(coord, position); } if (Util.isArray(position)) { // 数组 [2, 1] x = self._getNormalizedValue(position[0], getFirstScale(xScales)); y = self._getNormalizedValue(position[1], getFirstScale(yScales)); } else { for (var field in position) { var value = position[field]; if (xScales[field]) { x = self._getNormalizedValue(value, xScales[field]); } if (yScales[field]) { y = self._getNormalizedValue(value, yScales[field]); } } } if (!Util.isNil(x) && !Util.isNil(y)) { return coord.convert({ x: x, y: y }); } }; // 如果传入的值是百分比的格式,根据坐标系的起始点和宽高计算 Base.prototype.parsePercentPoint = function parsePercentPoint(coord, position) { var xPercent = parseFloat(position[0]) / 100; var yPercent = parseFloat(position[1]) / 100; var start = coord.start; var end = coord.end; var topLeft = { x: Math.min(start.x, end.x), y: Math.min(start.y, end.y) }; var x = coord.width * xPercent + topLeft.x; var y = coord.height * yPercent + topLeft.y; return { x: x, y: y }; }; /** * 设置显示、隐藏 * @param {Boolean} visible 是否可见 */ Base.prototype.setVisible = function setVisible(visible) { var el = this.el; if (el) { if (el.set) { el.set('visible', visible); } else { el.style.display = visible ? '' : 'none'; } } }; /** * 渲染辅助元素 * @override */ Base.prototype.render = function render() {}; /** * 清理图形、元素 */ Base.prototype.remove = function remove() { var self = this; var el = self.el; if (el) { el.remove(); } }; return Base; }(); module.exports = Base; /***/ }), /* 18 */ /***/ (function(module, exports) { /** Used for built-in method references. */ var objectProto = Object.prototype; /** * Checks if `value` is likely a prototype object. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. */ function isPrototype(value) { var Ctor = value && value.constructor, proto = typeof Ctor == 'function' && Ctor.prototype || objectProto; return value === proto; } module.exports = isPrototype; /***/ }), /* 19 */ /***/ (function(module, exports, __webpack_require__) { 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 baseMatches = __webpack_require__(143), baseMatchesProperty = __webpack_require__(181), identity = __webpack_require__(31), isArray = __webpack_require__(3), property = __webpack_require__(189); /** * The base implementation of `_.iteratee`. * * @private * @param {*} [value=_.identity] The value to convert to an iteratee. * @returns {Function} Returns the iteratee. */ function baseIteratee(value) { // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. if (typeof value == 'function') { return value; } if (value == null) { return identity; } if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object') { return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value); } return property(value); } module.exports = baseIteratee; /***/ }), /* 20 */ /***/ (function(module, exports) { /** * Converts `set` to an array of its values. * * @private * @param {Object} set The set to convert. * @returns {Array} Returns the values. */ function setToArray(set) { var index = -1, result = Array(set.size); set.forEach(function (value) { result[++index] = value; }); return result; } module.exports = setToArray; /***/ }), /* 21 */ /***/ (function(module, exports, __webpack_require__) { 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 baseGetTag = __webpack_require__(6), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var symbolTag = '[object Symbol]'; /** * Checks if `value` is classified as a `Symbol` primitive or object. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. * @example * * _.isSymbol(Symbol.iterator); * // => true * * _.isSymbol('abc'); * // => false */ function isSymbol(value) { return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag; } module.exports = isSymbol; /***/ }), /* 22 */ /***/ (function(module, exports, __webpack_require__) { var isSymbol = __webpack_require__(21); /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0; /** * Converts `value` to a string key if it's not a string or symbol. * * @private * @param {*} value The value to inspect. * @returns {string|symbol} Returns the key. */ function toKey(value) { if (typeof value == 'string' || isSymbol(value)) { return value; } var result = value + ''; return result == '0' && 1 / value == -INFINITY ? '-0' : result; } module.exports = toKey; /***/ }), /* 23 */ /***/ (function(module, exports, __webpack_require__) { var assignValue = __webpack_require__(40), baseAssignValue = __webpack_require__(61); /** * Copies properties of `source` to `object`. * * @private * @param {Object} source The object to copy properties from. * @param {Array} props The property identifiers to copy. * @param {Object} [object={}] The object to copy properties to. * @param {Function} [customizer] The function to customize copied values. * @returns {Object} Returns `object`. */ function copyObject(source, props, object, customizer) { var isNew = !object; object || (object = {}); var index = -1, length = props.length; while (++index < length) { var key = props[index]; var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined; if (newValue === undefined) { newValue = source[key]; } if (isNew) { baseAssignValue(object, key, newValue); } else { assignValue(object, key, newValue); } } return object; } module.exports = copyObject; /***/ }), /* 24 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview adjust the points position * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var DEFAULT_Y = 0; // 默认的y的值 /** * 数据调整的基类 * @class Adjust */ var Adjust = function () { /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Adjust.prototype.getDefaultCfg = function getDefaultCfg() { return { /** * 调整对应的x方向对应的字段名称 * @type {Scale} */ xField: null, /** * 调整对应的y方向对应的字段名称 * @type {Scale} */ yField: null, /** * 调整的维度,默认,x,y都做调整 * @type {Array} */ adjustNames: ['x', 'y'], // 指x,y /** * 参与分组的数据维度 * @type {Array} */ groupFields: null }; }; function Adjust(cfg) { _classCallCheck(this, Adjust); var defaultCfg = this.getDefaultCfg(); Util.assign(this, defaultCfg, cfg); } /** * 对应的维度是否可以调整 * @protected * @param {String} dimName 可以调整的维度 x,y * @return {Boolean} 是否可以调整 */ Adjust.prototype.isAdjust = function isAdjust(dimName) { return this.adjustNames.indexOf(dimName) >= 0; }; /** * @protected * adjust data * @param {Array} dataArray data array */ Adjust.prototype.processAdjust = function processAdjust(dataArray) { var self = this; var mergeData = Util.Array.merge(dataArray); self.adjDataArray = dataArray; self.mergeData = mergeData; self.adjustData(dataArray, mergeData); self.adjFrames = null; self.mergeData = null; }; /** * @protected * 获取可调整度量对应的值 * @param {Frame} mergeData 数据 * @return {Object} 值的映射 */ Adjust.prototype._getDimValues = function _getDimValues(mergeData) { var self = this; var valuesMap = {}; var dims = []; if (self.xField && self.isAdjust('x')) { dims.push(self.xField); } if (self.yField && self.isAdjust('y')) { dims.push(self.yField); } Util.each(dims, function (dim) { var values = Util.Array.values(mergeData, dim); values.sort(function (v1, v2) { return v1 - v2; }); valuesMap[dim] = values; }); if (!self.yField && self.isAdjust('y')) { // 只有一维的情况下,同时调整y var dim = 'y'; var values = [DEFAULT_Y, 1]; // 默认分布在y轴的 0.1 与 0.2 之间 valuesMap[dim] = values; } return valuesMap; }; Adjust.prototype.adjustData = function adjustData(dataArray, mergeData) { var self = this; var valuesMap = self._getDimValues(mergeData); Util.each(dataArray, function (data, index) { // 遍历所有数据集合 Util.each(valuesMap, function (values, dim) { // 根据不同的度量分别调整位置 self.adjustDim(dim, values, data, dataArray.length, index); }); }); }; Adjust.prototype.adjustDim = function adjustDim() /* dim, values, data, length, index */{}; Adjust.prototype.getAdjustRange = function getAdjustRange(dim, key, values) { var self = this; var index = values.indexOf(key); var length = values.length; var pre = void 0; var next = void 0; if (!self.yField && self.isAdjust('y')) { pre = 0; next = 1; } else if (length > 1) { pre = index === 0 ? values[0] : values[index - 1]; next = index === length - 1 ? values[length - 1] : values[index + 1]; if (index !== 0) { pre += (key - pre) / 2; } else { pre -= (next - key) / 2; } if (index !== length - 1) { next -= (next - key) / 2; } else { next += (key - values[length - 2]) / 2; } } else { pre = key === 0 ? 0 : key - 0.5; next = key === 0 ? 1 : key + 0.5; } return { pre: pre, next: next }; }; /** * 对数据进行分组 * @param {Array} data 数据 * @param {String} dim 分组的字段 * @return {Object} 分组的键值对映射 */ Adjust.prototype.groupData = function groupData(data, dim) { var groups = {}; Util.each(data, function (record) { var value = record[dim]; if (value === undefined) { value = record[dim] = DEFAULT_Y; } if (!groups[value]) { groups[value] = []; } groups[value].push(record); }); return groups; }; return Adjust; }(); module.exports = Adjust; /***/ }), /* 25 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview chart component module * @author sima.zhang1990@gmail.com */ module.exports = { Axis: __webpack_require__(335), Guide: __webpack_require__(341), Label: __webpack_require__(65), Legend: __webpack_require__(348), Plot: __webpack_require__(353), Tooltip: __webpack_require__(354) }; /***/ }), /* 26 */ /***/ (function(module, exports) { module.exports = function (module) { if (!module.webpackPolyfill) { module.deprecate = function () {}; module.paths = []; // module.parent = undefined by default if (!module.children) module.children = []; Object.defineProperty(module, "loaded", { enumerable: true, get: function get() { return module.l; } }); Object.defineProperty(module, "id", { enumerable: true, get: function get() { return module.i; } }); module.webpackPolyfill = 1; } return module; }; /***/ }), /* 27 */ /***/ (function(module, exports, __webpack_require__) { var baseForOwn = __webpack_require__(129), createBaseEach = __webpack_require__(140); /** * The base implementation of `_.forEach` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array|Object} Returns `collection`. */ var baseEach = createBaseEach(baseForOwn); module.exports = baseEach; /***/ }), /* 28 */ /***/ (function(module, exports, __webpack_require__) { var baseIsArguments = __webpack_require__(133), isObjectLike = __webpack_require__(5); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** Built-in value references. */ var propertyIsEnumerable = objectProto.propertyIsEnumerable; /** * Checks if `value` is likely an `arguments` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an `arguments` object, * else `false`. * @example * * _.isArguments(function() { return arguments; }()); * // => true * * _.isArguments([1, 2, 3]); * // => false */ var isArguments = baseIsArguments(function () { return arguments; }()) ? baseIsArguments : function (value) { return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); }; module.exports = isArguments; /***/ }), /* 29 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(module) {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 root = __webpack_require__(4), stubFalse = __webpack_require__(137); /** Detect free variable `exports`. */ var freeExports = ( false ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && ( false ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; /** * Checks if `value` is a buffer. * * @static * @memberOf _ * @since 4.3.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. * @example * * _.isBuffer(new Buffer(2)); * // => true * * _.isBuffer(new Uint8Array(2)); * // => false */ var isBuffer = nativeIsBuffer || stubFalse; module.exports = isBuffer; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(26)(module))) /***/ }), /* 30 */ /***/ (function(module, exports) { /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; /** Used to detect unsigned integer values. */ var reIsUint = /^(?:0|[1-9]\d*)$/; /** * Checks if `value` is a valid array-like index. * * @private * @param {*} value The value to check. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ function isIndex(value, length) { length = length == null ? MAX_SAFE_INTEGER : length; return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length; } module.exports = isIndex; /***/ }), /* 31 */ /***/ (function(module, exports) { /** * This method returns the first argument it receives. * * @static * @since 0.1.0 * @memberOf _ * @category Util * @param {*} value Any value. * @returns {*} Returns `value`. * @example * * var object = { 'a': 1 }; * * console.log(_.identity(object) === object); * // => true */ function identity(value) { return value; } module.exports = identity; /***/ }), /* 32 */ /***/ (function(module, exports, __webpack_require__) { var listCacheClear = __webpack_require__(145), listCacheDelete = __webpack_require__(146), listCacheGet = __webpack_require__(147), listCacheHas = __webpack_require__(148), listCacheSet = __webpack_require__(149); /** * Creates an list cache object. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function ListCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `ListCache`. ListCache.prototype.clear = listCacheClear; ListCache.prototype['delete'] = listCacheDelete; ListCache.prototype.get = listCacheGet; ListCache.prototype.has = listCacheHas; ListCache.prototype.set = listCacheSet; module.exports = ListCache; /***/ }), /* 33 */ /***/ (function(module, exports, __webpack_require__) { var eq = __webpack_require__(34); /** * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private * @param {Array} array The array to inspect. * @param {*} key The key to search for. * @returns {number} Returns the index of the matched value, else `-1`. */ function assocIndexOf(array, key) { var length = array.length; while (length--) { if (eq(array[length][0], key)) { return length; } } return -1; } module.exports = assocIndexOf; /***/ }), /* 34 */ /***/ (function(module, exports) { /** * Performs a * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * var object = { 'a': 1 }; * var other = { 'a': 1 }; * * _.eq(object, object); * // => true * * _.eq(object, other); * // => false * * _.eq('a', 'a'); * // => true * * _.eq('a', Object('a')); * // => false * * _.eq(NaN, NaN); * // => true */ function eq(value, other) { return value === other || value !== value && other !== other; } module.exports = eq; /***/ }), /* 35 */ /***/ (function(module, exports, __webpack_require__) { var getNative = __webpack_require__(13); /* Built-in method references that are verified to be native. */ var nativeCreate = getNative(Object, 'create'); module.exports = nativeCreate; /***/ }), /* 36 */ /***/ (function(module, exports, __webpack_require__) { var isKeyable = __webpack_require__(167); /** * Gets the data for `map`. * * @private * @param {Object} map The map to query. * @param {string} key The reference key. * @returns {*} Returns the map data. */ function getMapData(map, key) { var data = map.__data__; return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map; } module.exports = getMapData; /***/ }), /* 37 */ /***/ (function(module, exports, __webpack_require__) { var baseIsEqualDeep = __webpack_require__(171), isObjectLike = __webpack_require__(5); /** * The base implementation of `_.isEqual` which supports partial comparisons * and tracks traversed objects. * * @private * @param {*} value The value to compare. * @param {*} other The other value to compare. * @param {boolean} bitmask The bitmask flags. * 1 - Unordered comparison * 2 - Partial comparison * @param {Function} [customizer] The function to customize comparisons. * @param {Object} [stack] Tracks traversed `value` and `other` objects. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ function baseIsEqual(value, other, bitmask, customizer, stack) { if (value === other) { return true; } if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) { return value !== value && other !== other; } return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); } module.exports = baseIsEqual; /***/ }), /* 38 */ /***/ (function(module, exports, __webpack_require__) { var DataView = __webpack_require__(177), Map = __webpack_require__(51), Promise = __webpack_require__(178), Set = __webpack_require__(85), WeakMap = __webpack_require__(179), baseGetTag = __webpack_require__(6), toSource = __webpack_require__(76); /** `Object#toString` result references. */ var mapTag = '[object Map]', objectTag = '[object Object]', promiseTag = '[object Promise]', setTag = '[object Set]', weakMapTag = '[object WeakMap]'; var dataViewTag = '[object DataView]'; /** Used to detect maps, sets, and weakmaps. */ var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map), promiseCtorString = toSource(Promise), setCtorString = toSource(Set), weakMapCtorString = toSource(WeakMap); /** * Gets the `toStringTag` of `value`. * * @private * @param {*} value The value to query. * @returns {string} Returns the `toStringTag`. */ var getTag = baseGetTag; // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map && getTag(new Map()) != mapTag || Promise && getTag(Promise.resolve()) != promiseTag || Set && getTag(new Set()) != setTag || WeakMap && getTag(new WeakMap()) != weakMapTag) { getTag = function getTag(value) { var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : undefined, ctorString = Ctor ? toSource(Ctor) : ''; if (ctorString) { switch (ctorString) { case dataViewCtorString: return dataViewTag; case mapCtorString: return mapTag; case promiseCtorString: return promiseTag; case setCtorString: return setTag; case weakMapCtorString: return weakMapTag; } } return result; }; } module.exports = getTag; /***/ }), /* 39 */ /***/ (function(module, exports, __webpack_require__) { var isArray = __webpack_require__(3), isKey = __webpack_require__(57), stringToPath = __webpack_require__(183), toString = __webpack_require__(15); /** * Casts `value` to a path array if it's not one. * * @private * @param {*} value The value to inspect. * @param {Object} [object] The object to query keys on. * @returns {Array} Returns the cast property path array. */ function castPath(value, object) { if (isArray(value)) { return value; } return isKey(value, object) ? [value] : stringToPath(toString(value)); } module.exports = castPath; /***/ }), /* 40 */ /***/ (function(module, exports, __webpack_require__) { var baseAssignValue = __webpack_require__(61), eq = __webpack_require__(34); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Assigns `value` to `key` of `object` if the existing value is not equivalent * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ function assignValue(object, key, value) { var objValue = object[key]; if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) { baseAssignValue(object, key, value); } } module.exports = assignValue; /***/ }), /* 41 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview the base class of scale * @author dxq613@gmail.com */ var Util = __webpack_require__(0); /** * 度量的构造函数 * @class Scale */ var Scale = function () { /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Scale.prototype.getDefaultCfg = function getDefaultCfg() { return { /** * type of the scale * @type {String} */ type: 'base', /** * 格式化函数,输出文本或者tick时的格式化函数 * @type {Function} */ formatter: null, /** * 输出的值域 * @type {Array} */ range: [0, 1], /** * 度量的标记 * @type {Array} */ ticks: null, /** * 参与度量计算的值,可选项 * @type {Array} */ values: [] }; }; function Scale(cfg) { _classCallCheck(this, Scale); var defaultCfg = this.getDefaultCfg(); Util.mix(this, defaultCfg, cfg); this.init(); } /** * 度量初始化 * @protected */ Scale.prototype.init = function init() {}; /** * 获取该度量的ticks,返回的是多个对象, * - text: tick 的文本 * - value: 对应的度量转换后的值 * * [ * {text: 0,value:0} * {text: 1,value:0.2} * {text: 2,value:0.4} * {text: 3,value:0.6} * {text: 4,value:0.8} * {text: 5,value:1} * ] * * @param {Number} count 输出tick的个数的近似值,默认是 10 * @return {Array} 返回 ticks 数组 */ Scale.prototype.getTicks = function getTicks() { var self = this; var ticks = self.ticks; var rst = []; Util.each(ticks, function (tick) { var obj = void 0; if (Util.isObject(tick)) { obj = tick; } else { obj = { text: self.getText(tick), tickValue: tick, value: self.scale(tick) }; } rst.push(obj); }); return rst; }; /** * 获取格式化后的文本 * @param {*} value 输入的数据 * @return {String} 格式化的文本 */ Scale.prototype.getText = function getText(value) { var formatter = this.formatter; value = formatter ? formatter(value) : value; if (Util.isNil(value) || !value.toString) { value = ''; } return value.toString(); }; /** * 输出的值域最小值 * @protected * @return {Number} 返回最小的值 */ Scale.prototype.rangeMin = function rangeMin() { return this.range[0]; }; /** * 输出的值域最大值 * @protected * @return {Number} 返回最大的值 */ Scale.prototype.rangeMax = function rangeMax() { var range = this.range; return range[range.length - 1]; }; /** * 度量转换后的结果,翻转回输入域 * @param {Number} value 需要翻转的数值 * @return {*} 度量的输入值 */ Scale.prototype.invert = function invert(value) { return value; }; /** * 将传入的值从非数值转换成数值格式,如分类字符串、时间字符串等 * @param {*} value 传入的值 * @return {Number} 转换的值 */ Scale.prototype.translate = function translate(value) { return value; }; /** * 进行度量转换 * @param {*} value 输入值 * @return {Number} 输出值,在设定的输出值域之间,默认[0,1] */ Scale.prototype.scale = function scale(value) { return value; }; /** * 克隆一个新的scale,拥有跟当前scale相同的输入域、输出域等 * @return {Scale} 克隆的度量 */ Scale.prototype.clone = function clone() { var self = this; var constr = self.constructor; var cfg = {}; Util.each(self, function (v, k) { cfg[k] = self[k]; }); return new constr(cfg); }; /** * 更改度量的属性信息 * @param {Object} info 属性信息 * @chainable * @return {Scale} 返回自身的引用 */ Scale.prototype.change = function change(info) { this.ticks = null; Util.mix(this, info); this.init(); return this; }; return Scale; }(); module.exports = Scale; /***/ }), /* 42 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The measurement of linear data scale function * @author dxq613@gmail.com */ var Base = __webpack_require__(41); var Util = __webpack_require__(0); var numberAuto = __webpack_require__(322); /** * 线性度量 * @class Scale.Linear */ var Linear = function (_Base) { _inherits(Linear, _Base); function Linear() { _classCallCheck(this, Linear); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } /** * @override */ Linear.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * type of the scale * @type {String} */ type: 'linear', /** * 是否线性 * @type {Boolean} * @readOnly * @default true */ isLinear: true, /** * min value of the scale * @type {Number} * @default null */ min: null, /** * min value limitted of the scale * @type {Number} * @default null */ minLimit: null, /** * max value of the scale * @type {Number} * @default null */ max: null, /** * max value limitted of the scale * @type {Number} * @default null */ maxLimit: null, /** * 是否为了用户习惯,优化min,max和ticks,如果进行优化,则会根据生成的ticks调整min,max,否则舍弃(min,max)范围之外的ticks * @type {Boolean} * @default false */ nice: false, /** * 自动生成标记时的个数 * @type {Number} * @default null */ tickCount: null, /** * 坐标轴点之间的间距,指的是真实数据的差值 * @type {Number} * @default null */ tickInterval: null, /** * 用于计算坐标点时逼近的数组 * @type {Array} */ snapArray: null }); }; /** * @protected * @override */ Linear.prototype.init = function init() { var self = this; if (!self.ticks) { self.min = self.translate(self.min); self.max = self.translate(self.max); self.initTicks(); } else { var ticks = self.ticks; var firstValue = self.translate(ticks[0]); var lastValue = self.translate(ticks[ticks.length - 1]); if (Util.isNil(self.min) || self.min > firstValue) { self.min = firstValue; } if (Util.isNil(self.max) || self.max < lastValue) { self.max = lastValue; } } }; /** * 计算坐标点 * @protected * @return {Array} 计算完成的坐标点 */ Linear.prototype.calculateTicks = function calculateTicks() { var self = this; var min = self.min; var max = self.max; var count = self.tickCount; var interval = self.tickInterval; if (max < min) { throw new Error('max: ' + max + ' should not be less than min: ' + min); } var tmp = numberAuto({ min: min, max: max, minLimit: self.minLimit, maxLimit: self.maxLimit, minCount: count, maxCount: count, interval: interval, snapArray: this.snapArray }); return tmp.ticks; }; // 初始化ticks Linear.prototype.initTicks = function initTicks() { var self = this; var calTicks = self.calculateTicks(); if (self.nice) { // 如果需要优化显示的tick self.ticks = calTicks; self.min = calTicks[0]; self.max = calTicks[calTicks.length - 1]; } else { var ticks = []; Util.each(calTicks, function (tick) { if (tick >= self.min && tick <= self.max) { ticks.push(tick); } }); self.ticks = ticks; } }; /** * @override */ Linear.prototype.scale = function scale(value) { if (value === null || value === undefined) { return NaN; } var max = this.max; var min = this.min; if (max === min) { return 0; } var percent = (value - min) / (max - min); var rangeMin = this.rangeMin(); var rangeMax = this.rangeMax(); return rangeMin + percent * (rangeMax - rangeMin); }; /** * @override */ Linear.prototype.invert = function invert(value) { var percent = (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin()); return this.min + percent * (this.max - this.min); }; return Linear; }(Base); module.exports = Linear; /***/ }), /* 43 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview the base class of Coordinate * @author sima.zhang */ var Util = __webpack_require__(0); var MatrixUtil = __webpack_require__(2).MatrixUtil; var mat3 = MatrixUtil.mat3; var vec3 = MatrixUtil.vec3; var Coord = function () { /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Coord.prototype.getDefaultCfg = function getDefaultCfg() { return { /** * Mark x y is transposed. * @type {Boolean} */ isTransposed: false, /** * The matrix of coordinate * @type {Array} */ matrix: [1, 0, 0, 0, 1, 0, 0, 0, 1] }; }; function Coord(cfg) { _classCallCheck(this, Coord); var defaultCfg = this.getDefaultCfg(); Util.mix(this, defaultCfg, cfg); this.init(); } Coord.prototype.init = function init() { var start = this.start; var end = this.end; var center = { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 }; this.center = center; this.width = Math.abs(end.x - start.x); this.height = Math.abs(end.y - start.y); }; Coord.prototype._swapDim = function _swapDim(dim) { var dimRange = this[dim]; if (dimRange) { var tmp = dimRange.start; dimRange.start = dimRange.end; dimRange.end = tmp; } }; Coord.prototype.getCenter = function getCenter() { return this.center; }; Coord.prototype.getWidth = function getWidth() { return this.width; }; Coord.prototype.getHeight = function getHeight() { return this.height; }; Coord.prototype.convertDim = function convertDim(percent, dim) { var _dim = this[dim], start = _dim.start, end = _dim.end; return start + percent * (end - start); }; Coord.prototype.invertDim = function invertDim(value, dim) { var _dim2 = this[dim], start = _dim2.start, end = _dim2.end; return (value - start) / (end - start); }; /** * 将归一化的坐标点数据转换为画布坐标 * @override * @param {Object} point 归一化的坐标点 * @return {Object} 返回画布坐标 */ Coord.prototype.convertPoint = function convertPoint(point) { return point; }; /** * 将画布坐标转换为归一化的坐标点数据 * @override * @param {Object} point 画布坐标点数据 * @return {Object} 归一化后的数据点 */ Coord.prototype.invertPoint = function invertPoint(point) { return point; }; /** * 将坐标点进行矩阵变换 * @param {Number} x 对应 x 轴画布坐标 * @param {Number} y 对应 y 轴画布坐标 * @param {Number} tag 默认为 0,可取值 0, 1 * @return {Array} 返回变换后的三阶向量 [x, y, z] */ Coord.prototype.applyMatrix = function applyMatrix(x, y) { var tag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var matrix = this.matrix; var vector = [x, y, tag]; vec3.transformMat3(vector, vector, matrix); return vector; }; /** * 将坐标点进行矩阵逆变换 * @param {Number} x 对应 x 轴画布坐标 * @param {Number} y 对应 y 轴画布坐标 * @param {Number} tag 默认为 0,可取值 0, 1 * @return {Array} 返回矩阵逆变换后的三阶向量 [x, y, z] */ Coord.prototype.invertMatrix = function invertMatrix(x, y) { var tag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var matrix = this.matrix; var inversedMatrix = mat3.invert([], matrix); var vector = [x, y, tag]; vec3.transformMat3(vector, vector, inversedMatrix); return vector; }; /** * 将归一化的坐标点数据转换为画布坐标,并根据坐标系当前矩阵进行变换 * @param {Object} point 归一化的坐标点 * @return {Object} 返回进行矩阵变换后的画布坐标 */ Coord.prototype.convert = function convert(point) { var _convertPoint = this.convertPoint(point), x = _convertPoint.x, y = _convertPoint.y; var vector = this.applyMatrix(x, y, 1); return { x: vector[0], y: vector[1] }; }; /** * 将进行过矩阵变换画布坐标转换为归一化坐标 * @param {Object} point 画布坐标 * @return {Object} 返回归一化的坐标点 */ Coord.prototype.invert = function invert(point) { var vector = this.invertMatrix(point.x, point.y, 1); return this.invertPoint({ x: vector[0], y: vector[1] }); }; /** * 坐标系旋转变换 * @param {Number} radian 旋转弧度 * @return {Object} 返回坐标系对象 */ Coord.prototype.rotate = function rotate(radian) { var matrix = this.matrix; var center = this.center; mat3.translate(matrix, matrix, [-center.x, -center.y]); mat3.rotate(matrix, matrix, radian); mat3.translate(matrix, matrix, [center.x, center.y]); return this; }; /** * 坐标系反射变换 * @param {String} dim 反射维度 * @return {Object} 返回坐标系对象 */ Coord.prototype.reflect = function reflect(dim) { switch (dim) { case 'x': this._swapDim('x'); break; case 'y': this._swapDim('y'); break; default: this._swapDim('y'); } return this; }; /** * 坐标系比例变换 * @param {Number} s1 x 方向缩放比例 * @param {Number} s2 y 方向缩放比例 * @return {Object} 返回坐标系对象 */ Coord.prototype.scale = function scale(s1, s2) { var matrix = this.matrix; var center = this.center; mat3.translate(matrix, matrix, [-center.x, -center.y]); mat3.scale(matrix, matrix, [s1, s2]); mat3.translate(matrix, matrix, [center.x, center.y]); return this; }; /** * 坐标系平移变换 * @param {Number} x x 方向平移像素 * @param {Number} y y 方向平移像素 * @return {Object} 返回坐标系对象 */ Coord.prototype.translate = function translate(x, y) { var matrix = this.matrix; mat3.translate(matrix, matrix, [x, y]); return this; }; /** * 将坐标系 x y 两个轴进行转置 * @return {Object} 返回坐标系对象 */ Coord.prototype.transpose = function transpose() { this.isTransposed = !this.isTransposed; return this; }; return Coord; }(); module.exports = Coord; /***/ }), /* 44 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the base class of Axis * @author sima.zhang */ var Util = __webpack_require__(0); var _require = __webpack_require__(65), LabelsRenderer = _require.LabelsRenderer; var _require2 = __webpack_require__(2), Group = _require2.Group; var Grid = __webpack_require__(337); var Global = __webpack_require__(1); var Base = function (_Group) { _inherits(Base, _Group); function Base() { _classCallCheck(this, Base); return _possibleConstructorReturn(this, _Group.apply(this, arguments)); } Base.prototype.getDefaultCfg = function getDefaultCfg() { return { /** * 用于动画,唯一标识的 id * @type {[type]} */ _id: null, zIndex: 4, /** * 坐标轴上的坐标点 * @type {Array} */ ticks: null, /** * 坐标轴线的配置信息,如果设置成null,则不显示轴线 * @type {Object} */ line: null, /** * 坐标轴刻度线的配置,如果设置成null,则不显示刻度线 * @type {Object} */ tickLine: null, /** * 次刻度线个数配置 * @type {Number} */ subTickCount: 0, /** * 次刻度线样式配置 * @type {Object} */ subTickLine: null, /** * 网格线配置,如果值为 null,则不显示 * @type {Object} */ grid: null, /** * 坐标轴文本配置 * @type {Object} */ label: { textStyle: {}, // 坐标轴文本样式 autoRotate: true, formatter: null // 坐标轴文本格式化回调函数 }, /** * 坐标轴标题配置 * @type {Object} */ title: { autoRotate: true, // 文本是否自动旋转 textStyle: {} // 坐标轴标题样式 }, autoPaint: true }; }; Base.prototype._beforeRenderUI = function _beforeRenderUI() { var title = this.get('title'); var label = this.get('label'); var grid = this.get('grid'); if (title) { this.setSilent('title', Util.deepMix({ autoRotate: true, textStyle: { fontSize: 12, fill: '#ccc', textBaseline: 'middle', fontFamily: Global.fontFamily, textAlign: 'center' }, offset: 48 }, title)); } if (label) { this.setSilent('label', Util.deepMix({ autoRotate: true, textStyle: { fontSize: 12, fill: '#ccc', textBaseline: 'middle', fontFamily: Global.fontFamily }, offset: 10 }, label)); } if (grid) { this.setSilent('grid', Util.deepMix({ lineStyle: { lineWidth: 1, stroke: '#C0D0E0' } }, grid)); } }; Base.prototype._renderUI = function _renderUI() { var labelCfg = this.get('label'); if (labelCfg) { this.renderLabels(); } if (this.get('autoPaint')) { this.paint(); } if (!Util.isNil(this.get('title'))) { this.renderTitle(); } this.sort(); }; Base.prototype._parseTicks = function _parseTicks(ticks) { ticks = ticks || []; var ticksLength = ticks.length; for (var i = 0; i < ticksLength; i++) { var item = ticks[i]; if (!Util.isObject(item)) { ticks[i] = this.parseTick(item, i, ticksLength); } } this.set('ticks', ticks); return ticks; }; Base.prototype._addTickItem = function _addTickItem(index, point, length) { var type = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ''; var tickItems = this.get('tickItems'); var subTickItems = this.get('subTickItems'); var end = this.getTickEnd(point, length, index); var cfg = { x1: point.x, y1: point.y, x2: end.x, y2: end.y }; if (!tickItems) { tickItems = []; } if (!subTickItems) { subTickItems = []; } if (type === 'sub') { subTickItems.push(cfg); } else { tickItems.push(cfg); } this.set('tickItems', tickItems); this.set('subTickItems', subTickItems); }; Base.prototype._renderLine = function _renderLine() { var lineCfg = this.get('line'); var path = void 0; if (lineCfg) { path = this.getLinePath(); lineCfg = Util.mix({ path: path }, lineCfg); var lineShape = this.addShape('path', { attrs: lineCfg }); lineShape.name = 'axis-line'; this.get('appendInfo') && lineShape.setSilent('appendInfo', this.get('appendInfo')); this.set('lineShape', lineShape); } }; Base.prototype._processTicks = function _processTicks() { var self = this; var labelCfg = self.get('label'); var subTickCount = self.get('subTickCount'); var tickLineCfg = self.get('tickLine'); var ticks = self.get('ticks'); ticks = self._parseTicks(ticks); Util.each(ticks, function (tick, index) { var tickPoint = self.getTickPoint(tick.value, index); if (tickLineCfg) { self._addTickItem(index, tickPoint, tickLineCfg.length); } if (labelCfg) { self.addLabel(tick, tickPoint, index); } }); if (subTickCount) { // 如果有设置次级分点,添加次级tick var subTickLineCfg = self.get('subTickLine'); Util.each(ticks, function (tick, index) { if (index > 0) { var diff = tick.value - ticks[index - 1].value; diff = diff / (self.get('subTickCount') + 1); for (var i = 1; i <= subTickCount; i++) { var subTick = { text: '', value: index ? ticks[index - 1].value + i * diff : i * diff }; var tickPoint = self.getTickPoint(subTick.value); var subTickLength = void 0; if (subTickLineCfg && subTickLineCfg.length) { subTickLength = subTickLineCfg.length; } else { subTickLength = parseInt(tickLineCfg.length * (3 / 5), 10); } self._addTickItem(i - 1, tickPoint, subTickLength, 'sub'); } } }); } }; Base.prototype._addTickLine = function _addTickLine(ticks, lineCfg) { var self = this; var cfg = Util.mix({}, lineCfg); var path = []; Util.each(ticks, function (item) { path.push(['M', item.x1, item.y1]); path.push(['L', item.x2, item.y2]); }); delete cfg.length; cfg.path = path; var tickShape = self.addShape('path', { attrs: cfg }); tickShape.name = 'axis-ticks'; tickShape._id = self.get('_id') + '-ticks'; tickShape.set('coord', self.get('coord')); self.get('appendInfo') && tickShape.setSilent('appendInfo', self.get('appendInfo')); }; Base.prototype._renderTicks = function _renderTicks() { var self = this; var tickItems = self.get('tickItems'); var subTickItems = self.get('subTickItems'); if (!Util.isEmpty(tickItems)) { var tickLineCfg = self.get('tickLine'); self._addTickLine(tickItems, tickLineCfg); } if (!Util.isEmpty(subTickItems)) { var subTickLineCfg = self.get('subTickLine') || self.get('tickLine'); self._addTickLine(subTickItems, subTickLineCfg); } }; Base.prototype._renderGrid = function _renderGrid() { var grid = this.get('grid'); if (!grid) { return; } grid.coord = this.get('coord'); grid.appendInfo = this.get('appendInfo'); this.set('gridGroup', this.addGroup(Grid, grid)); }; Base.prototype.paint = function paint() { this._renderLine(); this._processTicks(); this._renderTicks(); this._renderGrid(); var labelCfg = this.get('label'); if (labelCfg && labelCfg.autoRotate) { this.autoRotateLabels(); } }; Base.prototype.parseTick = function parseTick(tick, index, length) { return { text: tick, value: index / (length - 1) }; }; Base.prototype.getTextAnchor = function getTextAnchor(vector) { var ratio = Math.abs(vector[1] / vector[0]); var align = void 0; if (ratio >= 1) { // 上面或者下面 align = 'center'; } else { if (vector[0] > 0) { // 右侧 align = 'start'; } else { // 左侧 align = 'end'; } } return align; }; Base.prototype.getMaxLabelWidth = function getMaxLabelWidth(labelsGroup) { var labels = labelsGroup.get('children'); var max = 0; Util.each(labels, function (label) { var bbox = label.getBBox(); var width = bbox.width; if (max < width) { max = width; } }); return max; }; Base.prototype.remove = function remove() { _Group.prototype.remove.call(this); var gridGroup = this.get('gridGroup'); gridGroup && gridGroup.remove(); this.removeLabels(); }; /** * 旋转文本 * @abstract * @return {[type]} [description] */ Base.prototype.autoRotateLabels = function autoRotateLabels() {}; /** * 渲染标题 * @abstract * @return {[type]} [description] */ Base.prototype.renderTitle = function renderTitle() {}; /** * 获取坐标轴线的 path * @abstract * @return {[type]} [description] */ Base.prototype.getLinePath = function getLinePath() {}; /** * 获取 tick 在画布上的位置 * @abstract * @return {[type]} [description] */ Base.prototype.getTickPoint = function getTickPoint() {}; /** * 获取标示坐标点的线的终点 * @abstract * @return {[type]} [description] */ Base.prototype.getTickEnd = function getTickEnd() {}; /** * 获取距离坐标轴的向量 * @abstract * @return {[type]} [description] */ Base.prototype.getSideVector = function getSideVector() {}; return Base; }(Group); Util.assign(Base.prototype, LabelsRenderer, { addLabel: function addLabel(tick, point, index) { var labelsGroup = this.get('labelsGroup'); var label = {}; var rst = void 0; if (labelsGroup) { var offset = this.get('_labelOffset'); if (!Util.isNil(this.get('label').offset)) { offset = this.get('label').offset; } var vector = this.getSideVector(offset, point, index); point = { x: point.x + vector[0], y: point.y + vector[1] }; label.text = tick.text; label.x = point.x; label.y = point.y; label.textAlign = this.getTextAnchor(vector); rst = labelsGroup.addLabel(label); if (rst) { rst.name = 'axis-label'; rst._id = this.get('_id') + '-' + tick.tickValue; rst.set('coord', this.get('coord')); this.get('appendInfo') && rst.setSilent('appendInfo', this.get('appendInfo')); } } return rst; } }); module.exports = Base; /***/ }), /* 45 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview facets of chart * @author dxq613@gmail.com */ var assign = __webpack_require__(60); var isNil = __webpack_require__(93); var isArray = __webpack_require__(3); var cloneDeep = __webpack_require__(102); var Global = __webpack_require__(1); // 绑定事件 function wrapBehavior(obj, action) { if (obj['_wrap_' + action]) { return obj['_wrap_' + action]; } var method = function method(e) { obj[action](e); }; obj['_wrap_' + action] = method; return method; } // 获取绑定的事件 function getWrapBehavior(obj, action) { return obj['_wrap_' + action]; } var Base = function () { Base.prototype.getDefaultCfg = function getDefaultCfg() { return { chart: null, group: null, /** * 是否默认显示每个分面的title * @type {Boolean} */ showTitle: true, /** * 是否自动修改坐标轴的信息 * @type {Boolean} */ autoSetAxis: true, /** * View 的内边框 * @type {Number|Array} */ padding: 10, /** * 遍历每个view 的回调函数 * @type {Function} */ eachView: null, /** * 分面的字段名列表 * @type {Array} */ fields: [], /** * 列值的的标题 * @type {Object} */ colTitle: { offsetY: -15, style: { fontSize: 14, textAlign: 'center', fill: '#444', fontFamily: Global.fontFamily } }, rowTitle: { offsetX: 15, style: { fontSize: 14, textAlign: 'center', rotate: 90, fill: '#444', fontFamily: Global.fontFamily } } }; }; function Base(cfg) { _classCallCheck(this, Base); var defaultCfg = this.getDefaultCfg(); assign(this, defaultCfg, cfg); this.init(); } Base.prototype.init = function init() { if (!this.chart) { throw new Error('Facets Error: please specify the chart!'); } this._bindEvent(); this.initContainer(); if (this.chart.get('data')) { this.initViews(); } }; Base.prototype.initContainer = function initContainer() { var chart = this.chart; var frontPlot = chart.get('frontPlot'); var group = frontPlot.addGroup(); this.group = group; }; Base.prototype.initViews = function initViews() { var chart = this.chart; var data = chart.get('data'); var eachView = this.eachView; var facets = this.generateFacets(data); for (var i = 0; i < facets.length; i++) { var facet = facets[i]; var region = facet.region; var view = chart.view({ start: region.start, end: region.end, padding: this.padding }); view.source(facet.data); this.beforeProcessView(view, facet); if (eachView) { eachView(view, facet); } this.afterProcessView(view, facet); facet.view = view; } this.facets = facets; }; /** * 处理 view 前 * @protected */ Base.prototype.beforeProcessView = function beforeProcessView() /* view, facet */{}; /** * 处理view * @param {Object} view 视图 * @param {Object} facet 分面信息 * @protected */ Base.prototype.afterProcessView = function afterProcessView(view, facet) { if (this.autoSetAxis) { this.processAxis(view, facet); } }; Base.prototype.processAxis = function processAxis(view, facet) { var viewOptions = view.get('options'); var geoms = view.get('geoms'); if ((!viewOptions.coord.type || viewOptions.coord.type === 'rect') && geoms.length) { var field = geoms[0].get('attrOptions').position.field; var fields = isArray(field) ? field : field.split('*').map(function (str) { return str.trim(); }); var xField = fields[0]; var yField = fields[1]; if (isNil(viewOptions.axes)) { viewOptions.axes = {}; } var axes = viewOptions.axes; if (axes !== false) { if (xField && axes[xField] !== false) { axes[xField] = axes[xField] || {}; this.setXAxis(xField, axes, facet); } if (yField && axes[yField] !== false) { axes[yField] = axes[yField] || {}; this.setYAxis(yField, axes, facet); } } } }; Base.prototype.setXAxis = function setXAxis() /* xField, axes, facet */{}; Base.prototype.setYAxis = function setYAxis() /* yField, axes, facet */{}; // 默认显示各列的标题 Base.prototype.renderTitle = function renderTitle(view, facet) { this.drawColTitle(view, facet); }; Base.prototype.getScaleText = function getScaleText(field, value, view) { var rst = void 0; if (field) { var scales = view.get('scales'); var scale = scales[field]; if (!scale) { scale = view.createScale(field); } rst = scale.getText(value); } else { rst = value; } return rst; }; Base.prototype.drawColTitle = function drawColTitle(view, facet) { var text = this.getScaleText(facet.colField, facet.colValue, view); var colTextCfg = assign({ position: ['50%', '0%'], content: text }, this.colTitle); view.guide().text(colTextCfg); }; Base.prototype.drawRowTitle = function drawRowTitle(view, facet) { var text = this.getScaleText(facet.rowField, facet.rowValue, view); var rowTextCfg = assign({ position: ['100%', '50%'], content: text }, cloneDeep(this.rowTitle)); view.guide().text(rowTextCfg); }; /** * 数据过滤器 * @protected * @param {Array} conditions 过滤条件 * @return {Function} 过滤函数 */ Base.prototype.getFilter = function getFilter(conditions) { var filter = function filter(obj) { var filtered = true; conditions.forEach(function (cond) { var field = cond.field; var value = cond.value; // const values = cond.values; var tmp = true; if (!isNil(value) && field) { tmp = obj[field] === value; } filtered = filtered && tmp; }); return filtered; }; return filter; }; /** * 获取字段对应的值 * @protected * @param {String} field 字段名 * @param {Array} data 数据 * @return {Array} 字段对应的值 */ Base.prototype.getFieldValues = function getFieldValues(field, data) { var rst = []; var tmpMap = {}; for (var i = 0; i < data.length; i++) { var obj = data[i]; var value = obj[field]; if (!isNil(value) && !tmpMap[value]) { rst.push(value); tmpMap[value] = true; } } return rst; }; Base.prototype.getRegion = function getRegion(rows, cols, xIndex, yIndex) { var xWidth = 1 / cols; // x轴方向的每个分面的偏移 var yWidth = 1 / rows; // y轴方向的每个分面的偏移 var start = { x: xWidth * xIndex, y: yWidth * yIndex }; var end = { x: start.x + xWidth, y: start.y + yWidth }; return { start: start, end: end }; }; /** * 生成分面 * @protected * @return {Array} 多个分面集合 */ Base.prototype.generateFacets = function generateFacets() /* data */{ return []; }; Base.prototype._bindEvent = function _bindEvent() { var chart = this.chart; chart.on('afterchangedata', wrapBehavior(this, 'onDataChange')); chart.on('beforeclear', wrapBehavior(this, 'onClear')); chart.on('beforedestroy', wrapBehavior(this, 'destroy')); chart.on('beforepaint', wrapBehavior(this, 'onPaint')); chart.on('setdata', wrapBehavior(this, 'onDataChange')); }; Base.prototype._clearEvent = function _clearEvent() { var chart = this.chart; if (chart) { chart.off('afterchangedata', getWrapBehavior(this, 'onDataChange')); chart.off('beforeclear', getWrapBehavior(this, 'onClear')); chart.off('beforedestroy', getWrapBehavior(this, 'destroy')); chart.off('beforepaint', getWrapBehavior(this, 'onPaint')); chart.off('setdata', getWrapBehavior(this, 'onDataChange')); } }; Base.prototype._clearFacets = function _clearFacets() { var facets = this.facets; var chart = this.chart; if (facets) { for (var i = 0; i < facets.length; i++) { var facet = facets[i]; chart.removeView(facet.view); } } this.facets = null; }; Base.prototype.onClear = function onClear() { this.onRemove(); }; Base.prototype.onPaint = function onPaint() { if (this.showTitle) { var facets = this.facets; for (var i = 0; i < facets.length; i++) { var facet = facets[i]; var view = facet.view; this.renderTitle(view, facet); } } }; Base.prototype.onDataChange = function onDataChange() { this._clearFacets(); this.initViews(); }; Base.prototype.onRemove = function onRemove() { this._clearFacets(); this._clearEvent(); this.group && this.group.remove(); this.chart = null; this.facets = null; this.group = null; }; Base.prototype.destroy = function destroy() { this.onRemove(); this.destroyed = true; }; return Base; }(); module.exports = Base; /***/ }), /* 46 */ /***/ (function(module, exports, __webpack_require__) { var baseIsTypedArray = __webpack_require__(138), baseUnary = __webpack_require__(72), nodeUtil = __webpack_require__(73); /* Node.js helper references. */ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; /** * Checks if `value` is classified as a typed array. * * @static * @memberOf _ * @since 3.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. * @example * * _.isTypedArray(new Uint8Array); * // => true * * _.isTypedArray([]); * // => false */ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; module.exports = isTypedArray; /***/ }), /* 47 */ /***/ (function(module, exports) { /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; /** * Checks if `value` is a valid array-like length. * * **Note:** This method is loosely based on * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. * @example * * _.isLength(3); * // => true * * _.isLength(Number.MIN_VALUE); * // => false * * _.isLength(Infinity); * // => false * * _.isLength('3'); * // => false */ function isLength(value) { return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } module.exports = isLength; /***/ }), /* 48 */ /***/ (function(module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(6), isObject = __webpack_require__(7); /** `Object#toString` result references. */ var asyncTag = '[object AsyncFunction]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', proxyTag = '[object Proxy]'; /** * Checks if `value` is classified as a `Function` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a function, else `false`. * @example * * _.isFunction(_); * // => true * * _.isFunction(/abc/); * // => false */ function isFunction(value) { if (!isObject(value)) { return false; } // The use of `Object#toString` avoids issues with the `typeof` operator // in Safari 9 which returns 'object' for typed arrays and other constructors. var tag = baseGetTag(value); return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } module.exports = isFunction; /***/ }), /* 49 */ /***/ (function(module, exports) { /** * A specialized version of `_.map` for arrays without support for iteratee * shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the new mapped array. */ function arrayMap(array, iteratee) { var index = -1, length = array == null ? 0 : array.length, result = Array(length); while (++index < length) { result[index] = iteratee(array[index], index, array); } return result; } module.exports = arrayMap; /***/ }), /* 50 */ /***/ (function(module, exports, __webpack_require__) { var ListCache = __webpack_require__(32), stackClear = __webpack_require__(150), stackDelete = __webpack_require__(151), stackGet = __webpack_require__(152), stackHas = __webpack_require__(153), stackSet = __webpack_require__(154); /** * Creates a stack cache object to store key-value pairs. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function Stack(entries) { var data = this.__data__ = new ListCache(entries); this.size = data.size; } // Add methods to `Stack`. Stack.prototype.clear = stackClear; Stack.prototype['delete'] = stackDelete; Stack.prototype.get = stackGet; Stack.prototype.has = stackHas; Stack.prototype.set = stackSet; module.exports = Stack; /***/ }), /* 51 */ /***/ (function(module, exports, __webpack_require__) { var getNative = __webpack_require__(13), root = __webpack_require__(4); /* Built-in method references that are verified to be native. */ var Map = getNative(root, 'Map'); module.exports = Map; /***/ }), /* 52 */ /***/ (function(module, exports, __webpack_require__) { var mapCacheClear = __webpack_require__(159), mapCacheDelete = __webpack_require__(166), mapCacheGet = __webpack_require__(168), mapCacheHas = __webpack_require__(169), mapCacheSet = __webpack_require__(170); /** * Creates a map cache object to store key-value pairs. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function MapCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `MapCache`. MapCache.prototype.clear = mapCacheClear; MapCache.prototype['delete'] = mapCacheDelete; MapCache.prototype.get = mapCacheGet; MapCache.prototype.has = mapCacheHas; MapCache.prototype.set = mapCacheSet; module.exports = MapCache; /***/ }), /* 53 */ /***/ (function(module, exports) { /** * Converts `map` to its key-value pairs. * * @private * @param {Object} map The map to convert. * @returns {Array} Returns the key-value pairs. */ function mapToArray(map) { var index = -1, result = Array(map.size); map.forEach(function (value, key) { result[++index] = [key, value]; }); return result; } module.exports = mapToArray; /***/ }), /* 54 */ /***/ (function(module, exports) { /** * Appends the elements of `values` to `array`. * * @private * @param {Array} array The array to modify. * @param {Array} values The values to append. * @returns {Array} Returns `array`. */ function arrayPush(array, values) { var index = -1, length = values.length, offset = array.length; while (++index < length) { array[offset + index] = values[index]; } return array; } module.exports = arrayPush; /***/ }), /* 55 */ /***/ (function(module, exports, __webpack_require__) { var arrayFilter = __webpack_require__(83), stubArray = __webpack_require__(84); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Built-in value references. */ var propertyIsEnumerable = objectProto.propertyIsEnumerable; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeGetSymbols = Object.getOwnPropertySymbols; /** * Creates an array of the own enumerable symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ var getSymbols = !nativeGetSymbols ? stubArray : function (object) { if (object == null) { return []; } object = Object(object); return arrayFilter(nativeGetSymbols(object), function (symbol) { return propertyIsEnumerable.call(object, symbol); }); }; module.exports = getSymbols; /***/ }), /* 56 */ /***/ (function(module, exports, __webpack_require__) { var castPath = __webpack_require__(39), toKey = __webpack_require__(22); /** * The base implementation of `_.get` without support for default values. * * @private * @param {Object} object The object to query. * @param {Array|string} path The path of the property to get. * @returns {*} Returns the resolved value. */ function baseGet(object, path) { path = castPath(path, object); var index = 0, length = path.length; while (object != null && index < length) { object = object[toKey(path[index++])]; } return index && index == length ? object : undefined; } module.exports = baseGet; /***/ }), /* 57 */ /***/ (function(module, exports, __webpack_require__) { 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 isArray = __webpack_require__(3), isSymbol = __webpack_require__(21); /** Used to match property names within property paths. */ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/; /** * Checks if `value` is a property name and not a property path. * * @private * @param {*} value The value to check. * @param {Object} [object] The object to query keys on. * @returns {boolean} Returns `true` if `value` is a property name, else `false`. */ function isKey(value, object) { if (isArray(value)) { return false; } var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) { return true; } return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object); } module.exports = isKey; /***/ }), /* 58 */ /***/ (function(module, exports) { /** * A specialized version of `_.reduce` for arrays without support for * iteratee shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initAccum] Specify using the first element of `array` as * the initial value. * @returns {*} Returns the accumulated value. */ function arrayReduce(array, iteratee, accumulator, initAccum) { var index = -1, length = array == null ? 0 : array.length; if (initAccum && length) { accumulator = array[++index]; } while (++index < length) { accumulator = iteratee(accumulator, array[index], index, array); } return accumulator; } module.exports = arrayReduce; /***/ }), /* 59 */ /***/ (function(module, exports, __webpack_require__) { var overArg = __webpack_require__(75); /** Built-in value references. */ var getPrototype = overArg(Object.getPrototypeOf, Object); module.exports = getPrototype; /***/ }), /* 60 */ /***/ (function(module, exports, __webpack_require__) { var assignValue = __webpack_require__(40), copyObject = __webpack_require__(23), createAssigner = __webpack_require__(225), isArrayLike = __webpack_require__(8), isPrototype = __webpack_require__(18), keys = __webpack_require__(11); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Assigns own enumerable string keyed properties of source objects to the * destination object. Source objects are applied from left to right. * Subsequent sources overwrite property assignments of previous sources. * * **Note:** This method mutates `object` and is loosely based on * [`Object.assign`](https://mdn.io/Object/assign). * * @static * @memberOf _ * @since 0.10.0 * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. * @returns {Object} Returns `object`. * @see _.assignIn * @example * * function Foo() { * this.a = 1; * } * * function Bar() { * this.c = 3; * } * * Foo.prototype.b = 2; * Bar.prototype.d = 4; * * _.assign({ 'a': 0 }, new Foo, new Bar); * // => { 'a': 1, 'c': 3 } */ var assign = createAssigner(function (object, source) { if (isPrototype(source) || isArrayLike(source)) { copyObject(source, keys(source), object); return; } for (var key in source) { if (hasOwnProperty.call(source, key)) { assignValue(object, key, source[key]); } } }); module.exports = assign; /***/ }), /* 61 */ /***/ (function(module, exports, __webpack_require__) { var defineProperty = __webpack_require__(98); /** * The base implementation of `assignValue` and `assignMergeValue` without * value checks. * * @private * @param {Object} object The object to modify. * @param {string} key The key of the property to assign. * @param {*} value The value to assign. */ function baseAssignValue(object, key, value) { if (key == '__proto__' && defineProperty) { defineProperty(object, key, { 'configurable': true, 'enumerable': true, 'value': value, 'writable': true }); } else { object[key] = value; } } module.exports = baseAssignValue; /***/ }), /* 62 */ /***/ (function(module, exports, __webpack_require__) { var Uint8Array = __webpack_require__(80); /** * Creates a clone of `arrayBuffer`. * * @private * @param {ArrayBuffer} arrayBuffer The array buffer to clone. * @returns {ArrayBuffer} Returns the cloned array buffer. */ function cloneArrayBuffer(arrayBuffer) { var result = new arrayBuffer.constructor(arrayBuffer.byteLength); new Uint8Array(result).set(new Uint8Array(arrayBuffer)); return result; } module.exports = cloneArrayBuffer; /***/ }), /* 63 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview Chart、View、Geometry 的基类 * @author dxq613@gmail.com */ var EventEmitter = __webpack_require__(284); var Util = __webpack_require__(0); var Base = function (_EventEmitter) { _inherits(Base, _EventEmitter); Base.prototype.getDefaultCfg = function getDefaultCfg() { return {}; }; function Base(cfg) { _classCallCheck(this, Base); var _this = _possibleConstructorReturn(this, _EventEmitter.call(this)); var attrs = { visible: true }; var defaultCfg = _this.getDefaultCfg(); _this._attrs = attrs; Util.assign(attrs, defaultCfg, cfg); return _this; } Base.prototype.get = function get(name) { return this._attrs[name]; }; Base.prototype.set = function set(name, value) { this._attrs[name] = value; }; Base.prototype.show = function show() { var visible = this.get('visible'); if (!visible) { this.set('visible', true); this.changeVisible(true); } }; Base.prototype.hide = function hide() { var visible = this.get('visible'); if (visible) { this.set('visible', false); this.changeVisible(false); } }; /** * @protected * @param {Boolean} visible 是否可见 * 显示、隐藏 */ Base.prototype.changeVisible = function changeVisible() /* visible */{}; Base.prototype.destroy = function destroy() { this._attrs = {}; this.removeAllListeners(); this.destroyed = true; }; return Base; }(EventEmitter); module.exports = Base; /***/ }), /* 64 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 颜色计算的辅助方法 * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var RGB_REG = /rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/; // 创建辅助 tag 取颜色 function createTmp() { var i = document.createElement('i'); i.title = 'Web Colour Picker'; i.style.display = 'none'; document.body.appendChild(i); return i; } // 获取颜色之间的插值 function getValue(start, end, percent, index) { var value = start[index] + (end[index] - start[index]) * percent; return value; } // 数组转换成颜色 function arr2rgb(arr) { return '#' + toHex(arr[0]) + toHex(arr[1]) + toHex(arr[2]); } // 将数值从 0-255 转换成16进制字符串 function toHex(value) { value = Math.round(value); value = value.toString(16); if (value.length === 1) { value = '0' + value; } return value; } function calColor(colors, percent) { var steps = colors.length - 1; var step = Math.floor(steps * percent); var left = steps * percent - step; var start = colors[step]; var end = step === steps ? start : colors[step + 1]; var rgb = arr2rgb([getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2)]); return rgb; } // rgb 颜色转换成数组 function rgb2arr(str) { var arr = []; arr.push(parseInt(str.substr(1, 2), 16)); arr.push(parseInt(str.substr(3, 2), 16)); arr.push(parseInt(str.substr(5, 2), 16)); return arr; } var colorCache = {}; var iEl = null; var ColorUtil = { /** * 将颜色转换到 rgb 的格式 * @param {String} color 颜色 * @return {String} 将颜色转换到 '#ffffff' 的格式 */ toRGB: function toRGB(color) { // 如果已经是 rgb的格式 if (color[0] === '#' && color.length === 7) { return color; } if (!iEl) { // 防止防止在页头报错 iEl = createTmp(); } var rst = void 0; if (colorCache[color]) { rst = colorCache[color]; } else { iEl.style.color = color; rst = document.defaultView.getComputedStyle(iEl, '').getPropertyValue('color'); var cArray = RGB_REG.exec(rst); cArray.shift(); rst = arr2rgb(cArray); colorCache[color] = rst; } return rst; }, rgb2arr: rgb2arr, /** * 获取渐变函数 * @param {Array} colors 多个颜色 * @return {String} 颜色值 */ gradient: function gradient(colors) { var points = []; if (Util.isString(colors)) { colors = colors.split('-'); } Util.each(colors, function (color) { if (color.indexOf('#') === -1) { color = ColorUtil.toRGB(color); } points.push(rgb2arr(color)); }); return function (percent) { return calColor(points, percent); }; } }; module.exports = ColorUtil; /***/ }), /* 65 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview the entry of labels * @author sima.zhang */ var Labels = __webpack_require__(110); Labels.LabelsRenderer = __webpack_require__(300); module.exports = Labels; /***/ }), /* 66 */ /***/ (function(module, exports, __webpack_require__) { var Shape = __webpack_require__(10); __webpack_require__(303); __webpack_require__(304); __webpack_require__(305); __webpack_require__(306); __webpack_require__(307); __webpack_require__(308); __webpack_require__(309); module.exports = Shape; /***/ }), /* 67 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview shape 的辅助方法 * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var ShapeUtil = { splitPoints: function splitPoints(obj) { var points = []; var x = obj.x; var y = obj.y; y = Util.isArray(y) ? y : [y]; Util.each(y, function (yItem, index) { var point = { x: Util.isArray(x) ? x[index] : x, y: yItem }; points.push(point); }); return points; } }; module.exports = ShapeUtil; /***/ }), /* 68 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview Default animation configuration for geoms * @author sima.zhang */ var Util = __webpack_require__(0); var Action = __webpack_require__(281); var defaultAnimationCfg = { appear: { duration: 450, easing: 'easeQuadOut' }, // 初始入场动画配置 update: { duration: 450, easing: 'easeQuadInOut' }, // 更新时发生变更的动画配置 enter: { duration: 400, easing: 'easeQuadInOut', delay: 100 }, // 更新时新增元素的入场动画配置 leave: { duration: 350, easing: 'easeQuadIn' // 更新时销毁动画配置 } }; var Animate = { line: { appear: function appear() { return Action.appear.clipIn; }, enter: function enter() { return Action.enter.clipIn; }, leave: function leave() { return Action.leave.lineWidthOut; } }, path: { appear: function appear() { return Action.appear.clipIn; }, enter: function enter() { return Action.enter.clipIn; }, leave: function leave() { return Action.leave.lineWidthOut; } }, area: { appear: function appear() { return Action.appear.clipIn; }, enter: function enter() { return Action.enter.fadeIn; }, leave: function leave() { return Action.leave.fadeOut; }, cfg: { appear: { duration: 500, easing: 'easeQuadOut' }, update: { duration: 450, easing: 'easeQuadInOut' }, enter: { duration: 600, delay: 150, easing: 'easeQuadInOut' }, leave: { easing: 'easeQuadOut', duration: 350 } } }, polygon: { appear: function appear() { return Action.appear.zoomIn; }, enter: function enter() { return Action.enter.zoomIn; }, leave: function leave() { return Action.leave.zoomOut; } }, edge: { appear: function appear() { return Action.appear.pathIn; }, enter: function enter() { return Action.enter.pathIn; }, leave: function leave() { return Action.leave.pathOut; } }, interval: { appear: function appear(coord) { var result = void 0; if (coord.isPolar) { result = Action.appear.zoomIn; if (coord.isTransposed || coord.type === 'theta') { result = Action.appear.fanIn; } } else if (coord.isRect) { result = coord.isTransposed ? Action.appear.scaleInX : Action.appear.scaleInY; } else { result = Action.appear.zoomIn; } return result; }, enter: function enter(coord) { if (coord.isRect || coord.isTransposed || coord.type === 'theta') { return Action.enter.fadeIn; } return Action.enter.zoomIn; }, leave: function leave() { return Action.leave.fadeOut; }, update: function update(coord) { if (coord.type === 'theta') { return Action.update.fanIn; } } }, point: { appear: function appear() { return Action.appear.zoomIn; }, enter: function enter() { return Action.enter.zoomIn; }, leave: function leave() { return Action.leave.zoomOut; } }, schema: { appear: function appear() { return Action.appear.clipIn; }, enter: function enter() { return Action.enter.clipIn; }, leave: function leave() { return Action.leave.lineWidthOut; } }, contour: null, heatmap: null, label: { appear: function appear() { return Action.appear.fadeIn; }, enter: function enter() { return Action.enter.fadeIn; }, leave: function leave() { return Action.leave.fadeOut; }, cfg: { appear: { duration: 900 } } }, 'axis-label': { enter: function enter() { return Action.appear.fadeIn; }, leave: function leave() { return Action.leave.fadeOut; }, update: function update(coord) { if (coord.isPolar) { return Action.appear.fadeIn; } } }, 'axis-ticks': { enter: function enter() { return Action.appear.fadeIn; }, leave: function leave() { return Action.leave.fadeOut; }, update: function update(coord) { if (coord.isPolar) { return Action.appear.fadeIn; } } }, 'axis-grid': { enter: function enter() { return Action.appear.fadeIn; }, leave: function leave() { return Action.leave.fadeOut; }, update: function update(coord) { if (coord.isPolar) { return Action.appear.fadeIn; } } }, 'axis-grid-rect': { enter: function enter() { return Action.appear.fadeIn; }, leave: function leave() { return Action.leave.fadeOut; }, update: function update() { return Action.leave.fadeIn; } }, labelLine: { appear: function appear() { return Action.appear.pathIn; }, enter: function enter() { return Action.enter.pathIn; }, leave: function leave() { return Action.leave.pathOut; } } }; Animate.Action = Action; Animate.defaultCfg = defaultAnimationCfg; // 获取动画 Animate.getAnimation = function (geomType, coord, animationType) { var geomAnimateCfg = this[geomType]; if (geomAnimateCfg) { var animation = geomAnimateCfg[animationType]; if (Util.isFunction(animation)) { return animation(coord); } } return false; }; // 获取动画配置 Animate.getAnimateCfg = function (geomType, animationType) { var defaultCfg = defaultAnimationCfg[animationType]; if (this[geomType] && this[geomType].cfg && this[geomType].cfg[animationType]) { return Util.deepMix({}, defaultCfg, this[geomType].cfg[animationType]); } return defaultCfg; }; // 注册动画 Animate.registerAnimation = function (animationType, animationName, animationFun) { if (!this.Action[animationType]) { this.Action[animationType] = {}; } this.Action[animationType][animationName] = animationFun; }; module.exports = Animate; /***/ }), /* 69 */ /***/ (function(module, exports) { /** * A specialized version of `_.forEach` for arrays without support for * iteratee shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns `array`. */ function arrayEach(array, iteratee) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (iteratee(array[index], index, array) === false) { break; } } return array; } module.exports = arrayEach; /***/ }), /* 70 */ /***/ (function(module, exports, __webpack_require__) { var baseTimes = __webpack_require__(132), isArguments = __webpack_require__(28), isArray = __webpack_require__(3), isBuffer = __webpack_require__(29), isIndex = __webpack_require__(30), isTypedArray = __webpack_require__(46); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Creates an array of the enumerable property names of the array-like `value`. * * @private * @param {*} value The value to query. * @param {boolean} inherited Specify returning inherited property names. * @returns {Array} Returns the array of property names. */ function arrayLikeKeys(value, inherited) { var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length; for (var key in value) { if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode. key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers. isBuff && (key == 'offset' || key == 'parent') || // PhantomJS 2 has enumerable non-index properties on typed arrays. isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || // Skip index properties. isIndex(key, length)))) { result.push(key); } } return result; } module.exports = arrayLikeKeys; /***/ }), /* 71 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {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; }; /** Detect free variable `global` from Node.js. */ var freeGlobal = (typeof global === 'undefined' ? 'undefined' : _typeof(global)) == 'object' && global && global.Object === Object && global; module.exports = freeGlobal; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(134))) /***/ }), /* 72 */ /***/ (function(module, exports) { /** * The base implementation of `_.unary` without support for storing metadata. * * @private * @param {Function} func The function to cap arguments for. * @returns {Function} Returns the new capped function. */ function baseUnary(func) { return function (value) { return func(value); }; } module.exports = baseUnary; /***/ }), /* 73 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(module) {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 freeGlobal = __webpack_require__(71); /** Detect free variable `exports`. */ var freeExports = ( false ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && ( false ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Detect free variable `process` from Node.js. */ var freeProcess = moduleExports && freeGlobal.process; /** Used to access faster Node.js helpers. */ var nodeUtil = function () { try { return freeProcess && freeProcess.binding && freeProcess.binding('util'); } catch (e) {} }(); module.exports = nodeUtil; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(26)(module))) /***/ }), /* 74 */ /***/ (function(module, exports, __webpack_require__) { var isPrototype = __webpack_require__(18), nativeKeys = __webpack_require__(139); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function baseKeys(object) { if (!isPrototype(object)) { return nativeKeys(object); } var result = []; for (var key in Object(object)) { if (hasOwnProperty.call(object, key) && key != 'constructor') { result.push(key); } } return result; } module.exports = baseKeys; /***/ }), /* 75 */ /***/ (function(module, exports) { /** * Creates a unary function that invokes `func` with its argument transformed. * * @private * @param {Function} func The function to wrap. * @param {Function} transform The argument transform. * @returns {Function} Returns the new function. */ function overArg(func, transform) { return function (arg) { return func(transform(arg)); }; } module.exports = overArg; /***/ }), /* 76 */ /***/ (function(module, exports) { /** Used for built-in method references. */ var funcProto = Function.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** * Converts `func` to its source code. * * @private * @param {Function} func The function to convert. * @returns {string} Returns the source code. */ function toSource(func) { if (func != null) { try { return funcToString.call(func); } catch (e) {} try { return func + ''; } catch (e) {} } return ''; } module.exports = toSource; /***/ }), /* 77 */ /***/ (function(module, exports, __webpack_require__) { var SetCache = __webpack_require__(78), arraySome = __webpack_require__(174), cacheHas = __webpack_require__(79); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** * A specialized version of `baseIsEqualDeep` for arrays with support for * partial deep comparisons. * * @private * @param {Array} array The array to compare. * @param {Array} other The other array to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} stack Tracks traversed `array` and `other` objects. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length; if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } // Assume cyclic values are equal. var stacked = stack.get(array); if (stacked && stack.get(other)) { return stacked == other; } var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : undefined; stack.set(array, other); stack.set(other, array); // Ignore non-index properties. while (++index < arrLength) { var arrValue = array[index], othValue = other[index]; if (customizer) { var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); } if (compared !== undefined) { if (compared) { continue; } result = false; break; } // Recursively compare arrays (susceptible to call stack limits). if (seen) { if (!arraySome(other, function (othValue, othIndex) { if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { return seen.push(othIndex); } })) { result = false; break; } } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { result = false; break; } } stack['delete'](array); stack['delete'](other); return result; } module.exports = equalArrays; /***/ }), /* 78 */ /***/ (function(module, exports, __webpack_require__) { var MapCache = __webpack_require__(52), setCacheAdd = __webpack_require__(172), setCacheHas = __webpack_require__(173); /** * * Creates an array cache object to store unique values. * * @private * @constructor * @param {Array} [values] The values to cache. */ function SetCache(values) { var index = -1, length = values == null ? 0 : values.length; this.__data__ = new MapCache(); while (++index < length) { this.add(values[index]); } } // Add methods to `SetCache`. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; SetCache.prototype.has = setCacheHas; module.exports = SetCache; /***/ }), /* 79 */ /***/ (function(module, exports) { /** * Checks if a `cache` value for `key` exists. * * @private * @param {Object} cache The cache to query. * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function cacheHas(cache, key) { return cache.has(key); } module.exports = cacheHas; /***/ }), /* 80 */ /***/ (function(module, exports, __webpack_require__) { var root = __webpack_require__(4); /** Built-in value references. */ var Uint8Array = root.Uint8Array; module.exports = Uint8Array; /***/ }), /* 81 */ /***/ (function(module, exports, __webpack_require__) { var baseGetAllKeys = __webpack_require__(82), getSymbols = __webpack_require__(55), keys = __webpack_require__(11); /** * Creates an array of own enumerable property names and symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names and symbols. */ function getAllKeys(object) { return baseGetAllKeys(object, keys, getSymbols); } module.exports = getAllKeys; /***/ }), /* 82 */ /***/ (function(module, exports, __webpack_require__) { var arrayPush = __webpack_require__(54), isArray = __webpack_require__(3); /** * The base implementation of `getAllKeys` and `getAllKeysIn` which uses * `keysFunc` and `symbolsFunc` to get the enumerable property names and * symbols of `object`. * * @private * @param {Object} object The object to query. * @param {Function} keysFunc The function to get the keys of `object`. * @param {Function} symbolsFunc The function to get the symbols of `object`. * @returns {Array} Returns the array of property names and symbols. */ function baseGetAllKeys(object, keysFunc, symbolsFunc) { var result = keysFunc(object); return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); } module.exports = baseGetAllKeys; /***/ }), /* 83 */ /***/ (function(module, exports) { /** * A specialized version of `_.filter` for arrays without support for * iteratee shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {Array} Returns the new filtered array. */ function arrayFilter(array, predicate) { var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = []; while (++index < length) { var value = array[index]; if (predicate(value, index, array)) { result[resIndex++] = value; } } return result; } module.exports = arrayFilter; /***/ }), /* 84 */ /***/ (function(module, exports) { /** * This method returns a new empty array. * * @static * @memberOf _ * @since 4.13.0 * @category Util * @returns {Array} Returns the new empty array. * @example * * var arrays = _.times(2, _.stubArray); * * console.log(arrays); * // => [[], []] * * console.log(arrays[0] === arrays[1]); * // => false */ function stubArray() { return []; } module.exports = stubArray; /***/ }), /* 85 */ /***/ (function(module, exports, __webpack_require__) { var getNative = __webpack_require__(13), root = __webpack_require__(4); /* Built-in method references that are verified to be native. */ var Set = getNative(root, 'Set'); module.exports = Set; /***/ }), /* 86 */ /***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(7); /** * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` if suitable for strict * equality comparisons, else `false`. */ function isStrictComparable(value) { return value === value && !isObject(value); } module.exports = isStrictComparable; /***/ }), /* 87 */ /***/ (function(module, exports) { /** * A specialized version of `matchesProperty` for source values suitable * for strict equality comparisons, i.e. `===`. * * @private * @param {string} key The key of the property to get. * @param {*} srcValue The value to match. * @returns {Function} Returns the new spec function. */ function matchesStrictComparable(key, srcValue) { return function (object) { if (object == null) { return false; } return object[key] === srcValue && (srcValue !== undefined || key in Object(object)); }; } module.exports = matchesStrictComparable; /***/ }), /* 88 */ /***/ (function(module, exports, __webpack_require__) { var baseHasIn = __webpack_require__(187), hasPath = __webpack_require__(188); /** * Checks if `path` is a direct or inherited property of `object`. * * @static * @memberOf _ * @since 4.0.0 * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path to check. * @returns {boolean} Returns `true` if `path` exists, else `false`. * @example * * var object = _.create({ 'a': _.create({ 'b': 2 }) }); * * _.hasIn(object, 'a'); * // => true * * _.hasIn(object, 'a.b'); * // => true * * _.hasIn(object, ['a', 'b']); * // => true * * _.hasIn(object, 'b'); * // => false */ function hasIn(object, path) { return object != null && hasPath(object, path, baseHasIn); } module.exports = hasIn; /***/ }), /* 89 */ /***/ (function(module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(6), isArray = __webpack_require__(3), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var stringTag = '[object String]'; /** * Checks if `value` is classified as a `String` primitive or object. * * @static * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a string, else `false`. * @example * * _.isString('abc'); * // => true * * _.isString(1); * // => false */ function isString(value) { return typeof value == 'string' || !isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag; } module.exports = isString; /***/ }), /* 90 */ /***/ (function(module, exports, __webpack_require__) { var castSlice = __webpack_require__(198), hasUnicode = __webpack_require__(91), stringToArray = __webpack_require__(92), toString = __webpack_require__(15); /** * Creates a function like `_.lowerFirst`. * * @private * @param {string} methodName The name of the `String` case method to use. * @returns {Function} Returns the new case function. */ function createCaseFirst(methodName) { return function (string) { string = toString(string); var strSymbols = hasUnicode(string) ? stringToArray(string) : undefined; var chr = strSymbols ? strSymbols[0] : string.charAt(0); var trailing = strSymbols ? castSlice(strSymbols, 1).join('') : string.slice(1); return chr[methodName]() + trailing; }; } module.exports = createCaseFirst; /***/ }), /* 91 */ /***/ (function(module, exports) { /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', rsComboMarksRange = '\\u0300-\\u036f', reComboHalfMarksRange = '\\ufe20-\\ufe2f', rsComboSymbolsRange = '\\u20d0-\\u20ff', rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = '\\ufe0e\\ufe0f'; /** Used to compose unicode capture groups. */ var rsZWJ = '\\u200d'; /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); /** * Checks if `string` contains Unicode symbols. * * @private * @param {string} string The string to inspect. * @returns {boolean} Returns `true` if a symbol is found, else `false`. */ function hasUnicode(string) { return reHasUnicode.test(string); } module.exports = hasUnicode; /***/ }), /* 92 */ /***/ (function(module, exports, __webpack_require__) { var asciiToArray = __webpack_require__(200), hasUnicode = __webpack_require__(91), unicodeToArray = __webpack_require__(201); /** * Converts `string` to an array. * * @private * @param {string} string The string to convert. * @returns {Array} Returns the converted array. */ function stringToArray(string) { return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string); } module.exports = stringToArray; /***/ }), /* 93 */ /***/ (function(module, exports) { /** * Checks if `value` is `null` or `undefined`. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is nullish, else `false`. * @example * * _.isNil(null); * // => true * * _.isNil(void 0); * // => true * * _.isNil(NaN); * // => false */ function isNil(value) { return value == null; } module.exports = isNil; /***/ }), /* 94 */ /***/ (function(module, exports) { /** * Copies the values of `source` to `array`. * * @private * @param {Array} source The array to copy values from. * @param {Array} [array=[]] The array to copy values to. * @returns {Array} Returns `array`. */ function copyArray(source, array) { var index = -1, length = source.length; array || (array = Array(length)); while (++index < length) { array[index] = source[index]; } return array; } module.exports = copyArray; /***/ }), /* 95 */ /***/ (function(module, exports, __webpack_require__) { var baseFindIndex = __webpack_require__(221), baseIsNaN = __webpack_require__(222), strictIndexOf = __webpack_require__(223); /** * The base implementation of `_.indexOf` without `fromIndex` bounds checks. * * @private * @param {Array} array The array to inspect. * @param {*} value The value to search for. * @param {number} fromIndex The index to search from. * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex); } module.exports = baseIndexOf; /***/ }), /* 96 */ /***/ (function(module, exports, __webpack_require__) { var toFinite = __webpack_require__(224); /** * Converts `value` to an integer. * * **Note:** This method is loosely based on * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to convert. * @returns {number} Returns the converted integer. * @example * * _.toInteger(3.2); * // => 3 * * _.toInteger(Number.MIN_VALUE); * // => 0 * * _.toInteger(Infinity); * // => 1.7976931348623157e+308 * * _.toInteger('3.2'); * // => 3 */ function toInteger(value) { var result = toFinite(value), remainder = result % 1; return result === result ? remainder ? result - remainder : result : 0; } module.exports = toInteger; /***/ }), /* 97 */ /***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(7), isSymbol = __webpack_require__(21); /** Used as references for various `Number` constants. */ var NAN = 0 / 0; /** Used to match leading and trailing whitespace. */ var reTrim = /^\s+|\s+$/g; /** Used to detect bad signed hexadecimal string values. */ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; /** Used to detect binary string values. */ var reIsBinary = /^0b[01]+$/i; /** Used to detect octal string values. */ var reIsOctal = /^0o[0-7]+$/i; /** Built-in method references without a dependency on `root`. */ var freeParseInt = parseInt; /** * Converts `value` to a number. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to process. * @returns {number} Returns the number. * @example * * _.toNumber(3.2); * // => 3.2 * * _.toNumber(Number.MIN_VALUE); * // => 5e-324 * * _.toNumber(Infinity); * // => Infinity * * _.toNumber('3.2'); * // => 3.2 */ function toNumber(value) { if (typeof value == 'number') { return value; } if (isSymbol(value)) { return NAN; } if (isObject(value)) { var other = typeof value.valueOf == 'function' ? value.valueOf() : value; value = isObject(other) ? other + '' : other; } if (typeof value != 'string') { return value === 0 ? value : +value; } value = value.replace(reTrim, ''); var isBinary = reIsBinary.test(value); return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value; } module.exports = toNumber; /***/ }), /* 98 */ /***/ (function(module, exports, __webpack_require__) { var getNative = __webpack_require__(13); var defineProperty = function () { try { var func = getNative(Object, 'defineProperty'); func({}, '', {}); return func; } catch (e) {} }(); module.exports = defineProperty; /***/ }), /* 99 */ /***/ (function(module, exports, __webpack_require__) { var identity = __webpack_require__(31), overRest = __webpack_require__(100), setToString = __webpack_require__(101); /** * The base implementation of `_.rest` which doesn't validate or coerce arguments. * * @private * @param {Function} func The function to apply a rest parameter to. * @param {number} [start=func.length-1] The start position of the rest parameter. * @returns {Function} Returns the new function. */ function baseRest(func, start) { return setToString(overRest(func, start, identity), func + ''); } module.exports = baseRest; /***/ }), /* 100 */ /***/ (function(module, exports, __webpack_require__) { var apply = __webpack_require__(226); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeMax = Math.max; /** * A specialized version of `baseRest` which transforms the rest array. * * @private * @param {Function} func The function to apply a rest parameter to. * @param {number} [start=func.length-1] The start position of the rest parameter. * @param {Function} transform The rest array transform. * @returns {Function} Returns the new function. */ function overRest(func, start, transform) { start = nativeMax(start === undefined ? func.length - 1 : start, 0); return function () { var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length); while (++index < length) { array[index] = args[start + index]; } index = -1; var otherArgs = Array(start + 1); while (++index < start) { otherArgs[index] = args[index]; } otherArgs[start] = transform(array); return apply(func, this, otherArgs); }; } module.exports = overRest; /***/ }), /* 101 */ /***/ (function(module, exports, __webpack_require__) { var baseSetToString = __webpack_require__(227), shortOut = __webpack_require__(229); /** * Sets the `toString` method of `func` to return `string`. * * @private * @param {Function} func The function to modify. * @param {Function} string The `toString` result. * @returns {Function} Returns `func`. */ var setToString = shortOut(baseSetToString); module.exports = setToString; /***/ }), /* 102 */ /***/ (function(module, exports, __webpack_require__) { var baseClone = __webpack_require__(235); /** Used to compose bitmasks for cloning. */ var CLONE_DEEP_FLAG = 1, CLONE_SYMBOLS_FLAG = 4; /** * This method is like `_.clone` except that it recursively clones `value`. * * @static * @memberOf _ * @since 1.0.0 * @category Lang * @param {*} value The value to recursively clone. * @returns {*} Returns the deep cloned value. * @see _.clone * @example * * var objects = [{ 'a': 1 }, { 'b': 2 }]; * * var deep = _.cloneDeep(objects); * console.log(deep[0] === objects[0]); * // => false */ function cloneDeep(value) { return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); } module.exports = cloneDeep; /***/ }), /* 103 */ /***/ (function(module, exports, __webpack_require__) { var arrayLikeKeys = __webpack_require__(70), baseKeysIn = __webpack_require__(238), isArrayLike = __webpack_require__(8); /** * Creates an array of the own and inherited enumerable property names of `object`. * * **Note:** Non-object values are coerced to objects. * * @static * @memberOf _ * @since 3.0.0 * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. * @example * * function Foo() { * this.a = 1; * this.b = 2; * } * * Foo.prototype.c = 3; * * _.keysIn(new Foo); * // => ['a', 'b', 'c'] (iteration order is not guaranteed) */ function keysIn(object) { return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); } module.exports = keysIn; /***/ }), /* 104 */ /***/ (function(module, exports, __webpack_require__) { var arrayPush = __webpack_require__(54), getPrototype = __webpack_require__(59), getSymbols = __webpack_require__(55), stubArray = __webpack_require__(84); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeGetSymbols = Object.getOwnPropertySymbols; /** * Creates an array of the own and inherited enumerable symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ var getSymbolsIn = !nativeGetSymbols ? stubArray : function (object) { var result = []; while (object) { arrayPush(result, getSymbols(object)); object = getPrototype(object); } return result; }; module.exports = getSymbolsIn; /***/ }), /* 105 */ /***/ (function(module, exports, __webpack_require__) { var isSymbol = __webpack_require__(21); /** * The base implementation of methods like `_.max` and `_.min` which accepts a * `comparator` to determine the extremum value. * * @private * @param {Array} array The array to iterate over. * @param {Function} iteratee The iteratee invoked per iteration. * @param {Function} comparator The comparator used to compare values. * @returns {*} Returns the extremum value. */ function baseExtremum(array, iteratee, comparator) { var index = -1, length = array.length; while (++index < length) { var value = array[index], current = iteratee(value); if (current != null && (computed === undefined ? current === current && !isSymbol(current) : comparator(current, computed))) { var computed = current, result = value; } } return result; } module.exports = baseExtremum; /***/ }), /* 106 */ /***/ (function(module, exports, __webpack_require__) { var arrayPush = __webpack_require__(54), isFlattenable = __webpack_require__(268); /** * The base implementation of `_.flatten` with support for restricting flattening. * * @private * @param {Array} array The array to flatten. * @param {number} depth The maximum recursion depth. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. * @param {Array} [result=[]] The initial result value. * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, depth, predicate, isStrict, result) { var index = -1, length = array.length; predicate || (predicate = isFlattenable); result || (result = []); while (++index < length) { var value = array[index]; if (depth > 0 && predicate(value)) { if (depth > 1) { // Recursively flatten arrays (susceptible to call stack limits). baseFlatten(value, depth - 1, predicate, isStrict, result); } else { arrayPush(result, value); } } else if (!isStrict) { result[result.length] = value; } } return result; } module.exports = baseFlatten; /***/ }), /* 107 */ /***/ (function(module, exports, __webpack_require__) { var SetCache = __webpack_require__(78), arrayIncludes = __webpack_require__(269), arrayIncludesWith = __webpack_require__(270), cacheHas = __webpack_require__(79), createSet = __webpack_require__(271), setToArray = __webpack_require__(20); /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; /** * The base implementation of `_.uniqBy` without support for iteratee shorthands. * * @private * @param {Array} array The array to inspect. * @param {Function} [iteratee] The iteratee invoked per element. * @param {Function} [comparator] The comparator invoked per element. * @returns {Array} Returns the new duplicate free array. */ function baseUniq(array, iteratee, comparator) { var index = -1, includes = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result; if (comparator) { isCommon = false; includes = arrayIncludesWith; } else if (length >= LARGE_ARRAY_SIZE) { var set = iteratee ? null : createSet(array); if (set) { return setToArray(set); } isCommon = false; includes = cacheHas; seen = new SetCache(); } else { seen = iteratee ? [] : result; } outer: while (++index < length) { var value = array[index], computed = iteratee ? iteratee(value) : value; value = comparator || value !== 0 ? value : 0; if (isCommon && computed === computed) { var seenIndex = seen.length; while (seenIndex--) { if (seen[seenIndex] === computed) { continue outer; } } if (iteratee) { seen.push(computed); } result.push(value); } else if (!includes(seen, computed, comparator)) { if (seen !== result) { seen.push(computed); } result.push(value); } } return result; } module.exports = baseUniq; /***/ }), /* 108 */ /***/ (function(module, exports) { var _html, _tooltip; /** * @fileOverview G2 3.0 default theme * @author sima.zhang */ var DEFAULT_COLOR = '#1890FF'; var COLOR_PLATE_8 = ['#1890FF', '#2FC25B', '#FACC14', '#223273', '#8543E0', '#13C2C2', '#3436C7', '#F04864']; var COLOR_PLATE_16 = ['#1890FF', '#41D9C7', '#2FC25B', '#FACC14', '#E6965C', '#223273', '#7564CC', '#8543E0', '#5C8EE6', '#13C2C2', '#5CA3E6', '#3436C7', '#B381E6', '#F04864', '#D598D9']; var COLOR_PLATE_24 = ['#1890FF', '#66B5FF', '#41D9C7', '#2FC25B', '#6EDB8F', '#9AE65C', '#FACC14', '#E6965C', '#57AD71', '#223273', '#738AE6', '#7564CC', '#8543E0', '#A877ED', '#5C8EE6', '#13C2C2', '#70E0E0', '#5CA3E6', '#3436C7', '#8082FF', '#DD81E6', '#F04864', '#FA7D92', '#D598D9']; var COLOR_PIE = ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0', '#3436C7', '#223273']; var COLOR_PIE_16 = ['#1890FF', '#73C9E6', '#13C2C2', '#6CD9B3', '#2FC25B', '#9DD96C', '#FACC14', '#E6965C', '#F04864', '#D66BCA', '#8543E0', '#8E77ED', '#3436C7', '#737EE6', '#223273', '#7EA2E6']; var FONT_FAMILY = '"-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto,"Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",SimSun, "sans-serif"'; // tooltip 相关 dom 的 css 类名 var TOOLTIP_CONTAINER_CLASS = 'g2-tooltip'; var TOOLTIP_TITLE_CLASS = 'g2-tooltip-title'; var TOOLTIP_LIST_CLASS = 'g2-tooltip-list'; var TOOLTIP_LIST_ITEM_CLASS = 'g2-tooltip-list-item'; var TOOLTIP_MARKER_CLASS = 'g2-tooltip-marker'; // html 渲染的 legend 相关 dom 的 css 类型 var LEGEND_CONTAINER_CLASS = 'g2-legend'; var LEGEND_TITLE_CLASS = 'g2-legend-title'; var LEGEND_LIST_CLASS = 'g2-legend-list'; var LEGEND_LIST_ITEM_CLASS = 'g2-legend-list-item'; var LEGEND_MARKER_CLASS = 'g2-legend-marker'; var Theme = { defaultColor: DEFAULT_COLOR, // 默认主题色 plotCfg: { padding: [20, 20, 95, 80] }, fontFamily: FONT_FAMILY, defaultLegendPosition: 'bottom', // 默认图例的展示位置 colors: COLOR_PLATE_8, colors_16: COLOR_PLATE_16, colors_24: COLOR_PLATE_24, colors_pie: COLOR_PIE, colors_pie_16: COLOR_PIE_16, shapes: { point: ['hollowCircle', 'hollowSquare', 'hollowDiamond', 'hollowBowtie', 'hollowTriangle', 'hollowHexagon', 'cross', 'tick', 'plus', 'hyphen', 'line'], line: ['line', 'dash', 'dot'], area: ['area'] }, sizes: [1, 10], opacities: [0.1, 0.9], axis: { top: { // zIndex: 1, // 默认上下方向的坐标轴位于左右坐标轴的上方 position: 'top', title: null, label: { offset: 14, textStyle: { fill: '#545454', fontSize: 12, lineHeight: 20, textBaseline: 'middle', fontFamily: FONT_FAMILY }, autoRotate: true }, line: { lineWidth: 1, stroke: '#BFBFBF' }, tickLine: { lineWidth: 1, stroke: '#BFBFBF', length: 4 } }, bottom: { position: 'bottom', title: null, label: { offset: 22, autoRotate: true, textStyle: { fill: '#545454', fontSize: 12, lineHeight: 20, textBaseline: 'middle', fontFamily: FONT_FAMILY } }, line: { lineWidth: 1, stroke: '#BFBFBF' }, tickLine: { lineWidth: 1, stroke: '#BFBFBF', length: 4 } }, left: { position: 'left', title: null, label: { offset: 12, autoRotate: true, textStyle: { fill: '#545454', fontSize: 12, lineHeight: 20, textBaseline: 'middle', fontFamily: FONT_FAMILY } }, line: null, tickLine: null, grid: { lineStyle: { stroke: '#E9E9E9', lineWidth: 1, lineDash: [3, 3] }, hideFirstLine: true } }, right: { position: 'right', title: null, label: { offset: 12, autoRotate: true, textStyle: { fill: '#545454', fontSize: 12, lineHeight: 20, textBaseline: 'middle', fontFamily: FONT_FAMILY } }, line: null, tickLine: null, grid: { lineStyle: { stroke: '#E9E9E9', lineWidth: 1, lineDash: [3, 3] }, hideFirstLine: true } }, circle: { zIndex: 1, title: null, label: { offset: 12, textStyle: { fill: '#545454', fontSize: 12, lineHeight: 20, fontFamily: FONT_FAMILY } }, line: { lineWidth: 1, stroke: '#BFBFBF' }, tickLine: { lineWidth: 1, stroke: '#BFBFBF', length: 4 }, grid: { lineStyle: { stroke: '#E9E9E9', lineWidth: 1, lineDash: [3, 3] }, hideFirstLine: true } }, radius: { zIndex: 0, label: { offset: 12, textStyle: { fill: '#545454', fontSize: 12, textBaseline: 'middle', lineHeight: 20, fontFamily: FONT_FAMILY } }, line: { lineWidth: 1, stroke: '#BFBFBF' }, tickLine: { lineWidth: 1, stroke: '#BFBFBF', length: 4 }, grid: { lineStyle: { stroke: '#E9E9E9', lineWidth: 1, lineDash: [3, 3] }, type: 'circle' } }, helix: { grid: null, label: null, title: null, line: { lineWidth: 1, stroke: '#BFBFBF' }, tickLine: { lineWidth: 1, length: 4, stroke: '#BFBFBF' } } }, label: { offset: 20, textStyle: { fill: '#545454', fontSize: 12, textBaseline: 'middle', fontFamily: FONT_FAMILY } }, treemapLabels: { offset: 10, textStyle: { fill: '#fff', fontSize: 12, textBaseline: 'top', fontStyle: 'bold', fontFamily: FONT_FAMILY } }, innerLabels: { textStyle: { fill: '#fff', fontSize: 12, textBaseline: 'middle', fontFamily: FONT_FAMILY } }, // 在theta坐标系下的饼图文本内部的样式 thetaLabels: { labelLine: { lineWidth: 1 }, labelHeight: 14, offset: 30 // 在theta坐标系下的饼图文本的样式 }, legend: { right: { position: 'right', layout: 'vertical', itemMarginBottom: 8, // layout 为 vertical 时各个图例项的间距 width: 16, height: 156, title: null, textStyle: { fill: '#8C8C8C', fontSize: 12, textAlign: 'start', textBaseline: 'middle', lineHeight: 20, fontFamily: FONT_FAMILY }, // 图例项文本的样式 unCheckColor: '#bfbfbf' }, left: { position: 'left', layout: 'vertical', itemMarginBottom: 8, width: 16, height: 156, title: null, textStyle: { fill: '#8C8C8C', fontSize: 12, textAlign: 'start', textBaseline: 'middle', lineHeight: 20, fontFamily: FONT_FAMILY }, // 图例项文本的样式 unCheckColor: '#bfbfbf' }, top: { position: 'top', offset: 6, layout: 'horizontal', title: null, itemGap: 10, width: 156, height: 16, textStyle: { fill: '#8C8C8C', fontSize: 12, textAlign: 'start', textBaseline: 'middle', lineHeight: 20, fontFamily: FONT_FAMILY }, // 图例项文本的样式 unCheckColor: '#bfbfbf' }, bottom: { position: 'bottom', offset: 58, layout: 'horizontal', title: null, itemGap: 24, width: 156, height: 16, textStyle: { fill: '#8C8C8C', fontSize: 12, textAlign: 'start', textBaseline: 'middle', lineHeight: 20, fontFamily: FONT_FAMILY }, // 图例项文本的样式 unCheckColor: '#bfbfbf' }, // 定义 html 渲染图例的样式 html: (_html = {}, _html['' + LEGEND_CONTAINER_CLASS] = { height: 'auto', width: 'auto', position: 'absolute', overflow: 'scroll', fontSize: '12px', fontFamily: FONT_FAMILY, lineHeight: '20px', color: '#8C8C8C' }, _html['' + LEGEND_TITLE_CLASS] = { marginBottom: '4px' }, _html['' + LEGEND_LIST_CLASS] = { listStyleType: 'none', margin: 0, padding: 0 }, _html['' + LEGEND_LIST_ITEM_CLASS] = { cursor: 'pointer', marginBottom: '5px', marginRight: '24px' }, _html['' + LEGEND_MARKER_CLASS] = { width: '9px', height: '9px', borderRadius: '50%', display: 'inline-block', marginRight: '8px', verticalAlign: 'middle' }, _html), // 不能滑动的连续图例样式 gradient: { textStyle: { fill: '#8C8C8C', fontSize: 12, textAlign: 'center', textBaseline: 'middle', lineHeight: 20, fontFamily: FONT_FAMILY }, // 图例项文本的样式 lineStyle: { lineWidth: 1, stroke: '#fff' }, unCheckColor: '#bfbfbf' } }, tooltip: (_tooltip = { crosshairs: false, offset: 15 }, _tooltip['' + TOOLTIP_CONTAINER_CLASS] = { position: 'absolute', visibility: 'hidden', whiteSpace: 'nowrap', zIndex: 999, transition: 'visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)', backgroundColor: 'rgba(0, 0, 0, 0.65)', borderRadius: '4px', color: 'rgb(255, 255, 255)', fontSize: '12px', fontFamily: FONT_FAMILY, lineHeight: '20px', padding: '10px 10px 6px 10px' }, _tooltip['' + TOOLTIP_TITLE_CLASS] = { marginBottom: '4px' }, _tooltip['' + TOOLTIP_LIST_CLASS] = { margin: 0, listStyleType: 'none', padding: 0 }, _tooltip['' + TOOLTIP_LIST_ITEM_CLASS] = { marginBottom: '4px' }, _tooltip['' + TOOLTIP_MARKER_CLASS] = { width: '7px', height: '7px', borderRadius: '50%', border: '1px solid #fff', display: 'inline-block', marginRight: '8px' }, _tooltip), tooltipMarker: { symbol: function symbol(x, y, r, ctx, marker) { var color = marker.get('color'); ctx.fillStyle = color; ctx.lineWidth = 1; ctx.strokeStyle = '#fff'; ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2, false); ctx.fill(); ctx.stroke(); ctx.save(); ctx.beginPath(); ctx.fillStyle = '#fff'; ctx.strokeStyle = color; ctx.globalAlpha = 0.2; ctx.lineWidth = 3; ctx.arc(x, y, 6, 0, Math.PI * 2, false); ctx.stroke(); ctx.restore(); }, radius: 4 }, // 提示信息在折线图、区域图上形成点的样式 tooltipCrosshairsRect: { type: 'rect', style: { fill: '#CCD6EC', opacity: 0.3 } }, // tooltip 辅助背景框样式 tooltipCrosshairsLine: { style: { stroke: 'rgba(0, 0, 0, 0.25)', lineWidth: 1 } }, shape: { point: { lineWidth: 1, fill: DEFAULT_COLOR, radius: 4 }, hollowPoint: { fill: '#fff', lineWidth: 1, stroke: DEFAULT_COLOR, radius: 3 }, interval: { lineWidth: 0, fill: DEFAULT_COLOR, fillOpacity: 0.85 }, hollowInterval: { fill: '#fff', stroke: DEFAULT_COLOR, fillOpacity: 0, lineWidth: 2 }, area: { lineWidth: 0, fill: DEFAULT_COLOR, fillOpacity: 0.3 }, polygon: { lineWidth: 0, fill: DEFAULT_COLOR, fillOpacity: 1 }, hollowPolygon: { fill: '#fff', stroke: DEFAULT_COLOR, fillOpacity: 0, lineWidth: 2 }, hollowArea: { fill: '#fff', stroke: DEFAULT_COLOR, fillOpacity: 0, lineWidth: 2 }, line: { stroke: DEFAULT_COLOR, lineWidth: 2, fill: null }, edge: { stroke: DEFAULT_COLOR, lineWidth: 1, fill: null }, schema: { stroke: DEFAULT_COLOR, lineWidth: 1, fill: null } }, guide: { line: { lineStyle: { stroke: DEFAULT_COLOR, lineDash: [0, 2, 2], lineWidth: 1 }, text: { position: 'end', autoRotate: true, style: { fill: '#545454', fontSize: 12, textAlign: 'center', fontFamily: FONT_FAMILY } } }, text: { style: { fill: '#545454', fontSize: 12, textBaseline: 'middle', textAlign: 'start', fontFamily: FONT_FAMILY } }, region: { style: { lineWidth: 0, // 辅助框的边框宽度 fill: '#000', // 辅助框填充的颜色 fillOpacity: 0.04 // 辅助框的背景透明度 // 辅助框的图形样式属性 } }, html: { alignX: 'middle', alignY: 'middle' } }, pixelRatio: null }; module.exports = Theme; /***/ }), /* 109 */ /***/ (function(module, exports, __webpack_require__) { 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; } var _require = __webpack_require__(2), Group = _require.Group; var Labels = __webpack_require__(65); var Global = __webpack_require__(1); var Util = __webpack_require__(0); var IGNORE_ARR = ['line', 'point', 'path']; var ORIGIN = '_origin'; function avg(arr) { var sum = 0; Util.each(arr, function (value) { sum += value; }); return sum / arr.length; } var GeomLabels = function (_Group) { _inherits(GeomLabels, _Group); function GeomLabels() { _classCallCheck(this, GeomLabels); return _possibleConstructorReturn(this, _Group.apply(this, arguments)); } GeomLabels.prototype.getDefaultCfg = function getDefaultCfg() { return { label: Global.label, /** * 用户传入的文本配置信息 * @type {Object} */ labelCfg: null, /** * 所在的坐标系 * @type {Object} */ coord: null, /** * 图表的类型 * @type {String} */ geomType: null, zIndex: 6 }; }; GeomLabels.prototype._renderUI = function _renderUI() { _Group.prototype._renderUI.call(this); this.initLabelsCfg(); this.renderLabels(); // 调用入口文件 }; // 获取显示的 label 文本值 GeomLabels.prototype._getLabelValue = function _getLabelValue(record) { var self = this; var originRecord = record[ORIGIN]; var labelCfg = self.get('labelCfg'); var scales = labelCfg.scales; var callback = labelCfg.cfg && labelCfg.cfg.content; var value = void 0; if (callback) { var params = []; Util.each(scales, function (scale) { params.push(originRecord[scale.field]); }); value = callback.apply(null, params); } else { var scale = scales[0]; value = originRecord[scale.field]; if (Util.isArray(value)) { var tmp = []; Util.each(value, function (subVal) { tmp.push(scale.getText(subVal)); }); value = tmp; } else { value = scale.getText(value); } } return value; }; // 初始化labels的配置项 GeomLabels.prototype.initLabelsCfg = function initLabelsCfg() { var self = this; var labels = self.getDefaultLabelCfg(); var labelCfg = self.get('labelCfg'); // Util.merge(labels, labelCfg.cfg); Util.deepMix(labels, labelCfg.cfg); self.set('label', labels); }; /** * @protected * 默认的文本样式 * @return {Object} default label config */ GeomLabels.prototype.getDefaultLabelCfg = function getDefaultLabelCfg() { var self = this; var labelCfg = self.get('labelCfg').cfg; var geomType = self.get('geomType'); if (geomType === 'polygon' || labelCfg && labelCfg.offset < 0 && Util.indexOf(IGNORE_ARR, geomType) === -1) { // return Util.merge({}, self.get('label'), Global.innerLabels); return Util.deepMix({}, self.get('label'), Global.innerLabels); } // return Util.merge({}, Global.label, self.get('label')); return Util.deepMix({}, Global.label, self.get('label')); }; /** * @protected * 获取labels * @param {Array} points points * @return {Array} label items */ GeomLabels.prototype.getLabelsItems = function getLabelsItems(points) { var self = this; var items = []; var labels = self.get('label'); var geom = self.get('geom'); var origin = void 0; // 获取label相关的x,y的值,获取具体的x,y,防止存在数组 Util.each(points, function (point) { origin = point._origin; var label = self._getLabelValue(point); if (!Util.isArray(label)) { label = [label]; } var total = label.length; Util.each(label, function (sub, subIdx) { var obj = self.getLabelPoint(label, point, subIdx); if (obj) { obj = Util.mix({}, origin, obj); // 为了格式化输出 var align = void 0; if (labels && labels.label && labels.label.textAlign) { align = labels.label.textAlign; } else { align = self.getLabelAlign(obj, subIdx, total); } obj.textAlign = align; if (geom) { obj._id = geom._getShapeId(origin) + '-glabel-' + subIdx + '-' + obj.text; } obj.coord = self.get('coord'); items.push(obj); } }); }); return items; }; /** * @protected * 如果发生冲突则会调整文本的位置 * @param {Array} items 文本的集合 * @return {Array} adjusted items */ GeomLabels.prototype.adjustItems = function adjustItems(items) { return items; }; /** * drawing lines to labels * @param {Array} items labels * @param {Object} labelLine configuration for label lines */ GeomLabels.prototype.drawLines = function drawLines(items, labelLine) { var self = this; var offset = self.getDefaultOffset(); if (offset > 0) { Util.each(items, function (point) { self.lineToLabel(point, labelLine); }); } }; // 连接线 GeomLabels.prototype.lineToLabel = function lineToLabel(label, labelLine) { var self = this; var coord = self.get('coord'); var start = { x: label.x - label._offset.x, y: label.y - label._offset.y }; var inner = { x: (start.x + label.x) / 2, y: (start.y + label.y) / 2 }; var lineGroup = self.get('lineGroup'); // var lineShape; if (!lineGroup) { lineGroup = self.addGroup({ elCls: 'x-line-group' }); self.set('lineGroup', lineGroup); } var lineShape = lineGroup.addShape('path', { attrs: Util.mix({ path: ['M' + start.x, start.y + ' Q' + inner.x, inner.y + ' ' + label.x, label.y].join(','), fill: null, stroke: label.color }, labelLine) }); // label 对应线的动画关闭 lineShape.name = 'labelLine'; // generate labelLine id according to label id lineShape._id = label._id && label._id.replace('glabel', 'glabelline'); lineShape.set('coord', coord); }; /** * @protected * 获取文本的位置信息 * @param {Array} labels labels * @param {Object} point point * @param {Number} index index * @return {Object} point */ GeomLabels.prototype.getLabelPoint = function getLabelPoint(labels, point, index) { var self = this; var coord = self.get('coord'); function getDimValue(value, idx) { if (Util.isArray(value)) { if (labels.length === 1) { // 如果仅一个label,多个y,取最后一个y if (value.length <= 2) { value = value[value.length - 1]; // value = value[0]; } else { value = avg(value); } } else { value = value[idx]; } } return value; } var labelPoint = { x: getDimValue(point.x, index), y: getDimValue(point.y, index), text: labels[index] }; // get nearest point of the shape as the label line start point if (point && point.nextPoints && (point.shape === 'funnel' || point.shape === 'pyramid')) { var maxX = -Infinity; point.nextPoints.forEach(function (p) { p = coord.convert(p); if (p.x > maxX) { maxX = p.x; } }); labelPoint.x = (labelPoint.x + maxX) / 2; } // sharp edge of the pyramid if (point.shape === 'pyramid' && !point.nextPoints && point.points) { point.points.forEach(function (p) { p = coord.convert(p); if (point.x.indexOf(p.x) === -1) { labelPoint.x = (labelPoint.x + p.x) / 2; } }); } var offsetPoint = self.getLabelOffset(labelPoint, index, labels.length); self.transLabelPoint(labelPoint); labelPoint.x += offsetPoint.x; labelPoint.y += offsetPoint.y; labelPoint.color = point.color; labelPoint._offset = offsetPoint; return labelPoint; }; GeomLabels.prototype.transLabelPoint = function transLabelPoint(point) { var self = this; var coord = self.get('coord'); var tmpPoint = coord.applyMatrix(point.x, point.y, 1); point.x = tmpPoint[0]; point.y = tmpPoint[1]; }; GeomLabels.prototype.getOffsetVector = function getOffsetVector() { var self = this; var labelCfg = self.get('label'); var offset = labelCfg.offset || 0; var coord = self.get('coord'); var vector = void 0; if (coord.isTransposed) { // 如果x,y翻转,则偏移x vector = coord.applyMatrix(offset, 0); } else { // 否则,偏转y vector = coord.applyMatrix(0, offset); } return vector; }; // 获取默认的偏移量 GeomLabels.prototype.getDefaultOffset = function getDefaultOffset() { var self = this; var offset = 0; // Global.labels.offset; var coord = self.get('coord'); var vector = self.getOffsetVector(); if (coord.isTransposed) { // 如果x,y翻转,则偏移x offset = vector[0]; } else { // 否则,偏转y offset = vector[1]; } return offset; }; // 获取文本的偏移位置,x,y GeomLabels.prototype.getLabelOffset = function getLabelOffset(point, index, total) { var self = this; var offset = self.getDefaultOffset(); var coord = self.get('coord'); var transposed = coord.isTransposed; var yField = transposed ? 'x' : 'y'; var factor = transposed ? 1 : -1; // y 方向上越大,像素的坐标越小,所以transposed时将系数变成 var offsetPoint = { x: 0, y: 0 }; if (index > 0 || total === 1) { // 判断是否小于0 offsetPoint[yField] = offset * factor; } else { offsetPoint[yField] = offset * factor * -1; } return offsetPoint; }; GeomLabels.prototype.getLabelAlign = function getLabelAlign(point, index, total) { var self = this; var align = 'center'; var coord = self.get('coord'); if (coord.isTransposed) { var offset = self.getDefaultOffset(); // var vector = coord.applyMatrix(offset,0); if (offset < 0) { align = 'right'; } else if (offset === 0) { align = 'center'; } else { align = 'left'; } if (total > 1 && index === 0) { if (align === 'right') { align = 'left'; } else if (align === 'left') { align = 'right'; } } } return align; }; GeomLabels.prototype.showLabels = function showLabels(points) { var self = this; var items = self.getLabelsItems(points); var labels = self.get('label'); items = self.adjustItems(items); self.resetLabels(items); if (labels.labelLine) { self.drawLines(items, labels.labelLine); } }; GeomLabels.prototype.destroy = function destroy() { this.removeLabels(); // 清理文本 _Group.prototype.destroy.call(this); }; return GeomLabels; }(Group); Util.assign(GeomLabels.prototype, Labels.LabelsRenderer); module.exports = GeomLabels; /***/ }), /* 110 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The Label class * @author sima.zhang */ var Util = __webpack_require__(0); var _require = __webpack_require__(2), DomUtil = _require.DomUtil, Group = _require.Group; var Labels = function (_Group) { _inherits(Labels, _Group); function Labels() { _classCallCheck(this, Labels); return _possibleConstructorReturn(this, _Group.apply(this, arguments)); } Labels.prototype.getDefaultCfg = function getDefaultCfg() { return { zIndex: 6, /** * 显示的文本集合 * @type {Array} */ items: null, /** * 文本样式 * @type {(Object|Function)} */ textStyle: null, /** * 文本显示格式化回调函数 * @type {Function} */ formatter: null, /** * 使用 html 渲染文本 * @type {(String|Function)} */ htmlTemplate: null, /** * html 渲染时用的容器的模板,必须存在 class = "g-labels" * @type {String} */ _containerTpl: '
', /** * html 渲染时单个 label 的模板,必须存在 class = "g-label",如果 htmlTemplate 为字符串,则使用 htmlTemplate * @type {String} */ _itemTpl: '
{text}
' }; }; Labels.prototype._renderUI = function _renderUI() { this._drawLabels(); }; Labels.prototype._drawLabels = function _drawLabels() { var self = this; var items = self.get('items'); Util.each(items, function (item, index) { self._addLabel(item, index); }); }; Labels.prototype._addLabel = function _addLabel(item, index) { var cfg = this._getLabelCfg(item, index); return this._createText(cfg); }; Labels.prototype._getLabelCfg = function _getLabelCfg(item, index) { var textStyle = this.get('textStyle') || {}; var formatter = this.get('formatter'); var htmlTemplate = this.get('htmlTemplate'); if (!Util.isObject(item)) { var tmp = item; item = {}; item.text = tmp; } if (Util.isFunction(textStyle)) { textStyle = textStyle(item.text, item, index); } if (formatter) { item.text = formatter(item.text, item, index); } if (Util.isFunction(htmlTemplate)) { item.text = htmlTemplate(item.text, item, index); } if (Util.isNil(item.text)) { item.text = ''; } item.text = item.text + ''; // ? 为什么转换为字符串 var cfg = Util.mix({}, item, textStyle, { x: item.x || 0, y: item.y || 0 }); return cfg; }; Labels.prototype._createText = function _createText(cfg) { var htmlTemplate = this.get('htmlTemplate'); var customDiv = this.get('customDiv'); var labelShape = void 0; if (htmlTemplate) { if (!customDiv) { var containerTpl = this.get('_containerTpl'); var wrapper = this.get('canvas').get('el').parentNode; customDiv = DomUtil.createDom(containerTpl); wrapper.style.position = 'relative'; wrapper.appendChild(customDiv); this.set('customDiv', customDiv); } var node = this._createDom(cfg); customDiv.appendChild(node); this._setCustomPosition(cfg, node); } else { var origin = cfg.point; delete cfg.point; // 临时解决,否则影响动画 labelShape = this.addShape('text', { attrs: cfg }); labelShape.setSilent('origin', origin); labelShape.name = 'label'; // 用于事件标注 this.get('appendInfo') && labelShape.setSilent('appendInfo', this.get('appendInfo')); return labelShape; } }; Labels.prototype._setCustomPosition = function _setCustomPosition(cfg, htmlDom) { var textAlign = cfg.textAlign || 'left'; var top = cfg.y; var left = cfg.x; var width = DomUtil.getOuterWidth(htmlDom); var height = DomUtil.getOuterHeight(htmlDom); top = top - height / 2; if (textAlign === 'center') { left = left - width / 2; } else if (textAlign === 'right') { left = left - width; } htmlDom.style.top = parseInt(top, 10) + 'px'; htmlDom.style.left = parseInt(left, 10) + 'px'; }; Labels.prototype._createDom = function _createDom(cfg) { var itemTpl = this.get('_itemTpl'); var htmlTemplate = this.get('htmlTemplate'); if (Util.isString(htmlTemplate)) { cfg.text = Util.substitute(htmlTemplate, { text: cfg.text }); } var str = Util.substitute(itemTpl, { text: cfg.text }); return DomUtil.createDom(str); }; Labels.prototype.getLabels = function getLabels() { var customDiv = this.get('customDiv'); if (customDiv) { return Util.toArray(customDiv.childNodes); } return this.get('children'); }; Labels.prototype.addLabel = function addLabel(item) { var items = this.get('items'); var count = items.length; items.push(item); return this._addLabel(item, count); }; Labels.prototype.changeLabel = function changeLabel(oldLabel, newLabel) { if (!oldLabel) { return; } var htmlTemplate = this.get('htmlTemplate'); var index = Util.indexOf(this.getLabels(), oldLabel); var cfg = this._getLabelCfg(newLabel, index); if (htmlTemplate) { var node = this._createDom(cfg); oldLabel.innerHTML = node.innerHTML; this._setCustomPosition(cfg, oldLabel); } else { oldLabel._id = newLabel._id; oldLabel.attr('text', cfg.text); if (oldLabel.attr('x') !== cfg.x || oldLabel.attr('y') !== cfg.y) { var rotate = oldLabel.get('attrs').rotate; if (rotate) { oldLabel.rotateAtStart(-rotate); oldLabel.attr(cfg); oldLabel.rotateAtStart(rotate); } else { oldLabel.attr(cfg); } } } }; Labels.prototype.clear = function clear() { var customDiv = this.get('customDiv'); if (customDiv) { customDiv.innerHTML = ''; } _Group.prototype.clear.call(this); }; Labels.prototype.setItems = function setItems(items) { this.clear(); this.set('items', items); this._drawLabels(); }; Labels.prototype.remove = function remove() { var customDiv = this.get('customDiv'); if (customDiv) { customDiv.parentNode.removeChild(customDiv); } _Group.prototype.remove.call(this); }; return Labels; }(Group); module.exports = Labels; /***/ }), /* 111 */ /***/ (function(module, exports, __webpack_require__) { 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; } var Labels = __webpack_require__(109); var PathUtil = __webpack_require__(14); var Util = __webpack_require__(0); var PolarLabels = function (_Labels) { _inherits(PolarLabels, _Labels); function PolarLabels() { _classCallCheck(this, PolarLabels); return _possibleConstructorReturn(this, _Labels.apply(this, arguments)); } PolarLabels.prototype.getPointRauis = function getPointRauis(coord, point) { return PathUtil.getPointRadius(coord, point); }; PolarLabels.prototype.getCirclePoint = function getCirclePoint(angle, offset, point) { var self = this; var coord = self.get('coord'); var center = coord.getCenter(); var labelEmit = self._isEmitLabels(); var r = self.getPointRauis(coord, point); if (coord.isTransposed && r > offset && !labelEmit) { var appendAngle = Math.asin(offset / (2 * r)); angle = angle + appendAngle * 2; } else { r = r + offset; } return { x: center.x + r * Math.cos(angle), y: center.y + r * Math.sin(angle), angle: angle, r: r }; }; PolarLabels.prototype.getArcPoint = function getArcPoint(point, index) { var self = this; var outerPoint = void 0; // 圆弧上的中点 // var coord = self.get('coord'); index = index || 0; if (Util.isArray(point.x) || Util.isArray(point.y)) { outerPoint = { x: Util.isArray(point.x) ? point.x[index] : point.x, y: Util.isArray(point.y) ? point.y[index] : point.y }; } else { outerPoint = point; } self.transLabelPoint(outerPoint); return outerPoint; }; // 获取点所在的角度 PolarLabels.prototype.getPointAngle = function getPointAngle(point) { var self = this; var coord = self.get('coord'); return PathUtil.getPointAngle(coord, point); }; // 获取中心的位置 PolarLabels.prototype.getMiddlePoint = function getMiddlePoint(points) { var self = this; var coord = self.get('coord'); var count = points.length; var middlePoint = { x: 0, y: 0 }; Util.each(points, function (point) { middlePoint.x += point.x; middlePoint.y += point.y; }); middlePoint.x /= count; middlePoint.y /= count; middlePoint = coord.convert(middlePoint); return middlePoint; }; // 是否居中 PolarLabels.prototype._isToMiddle = function _isToMiddle(point) { return point.x.length > 2; }; /** * @protected * 获取文本的位置信息 * @param {Array} labels labels * @param {Object} point point * @param {Number} index index * @return {Object} point */ PolarLabels.prototype.getLabelPoint = function getLabelPoint(labels, point, index) { var self = this; var text = labels[index]; var factor = 1; var arcPoint = void 0; if (self._isToMiddle(point)) { arcPoint = self.getMiddlePoint(point.points); } else { if (labels.length === 1 && index === 0) { index = 1; } else if (index === 0) { factor = -1; } arcPoint = self.getArcPoint(point, index); } var offset = self.getDefaultOffset(); offset = offset * factor; var middleAngle = self.getPointAngle(arcPoint); var labelPoint = self.getCirclePoint(middleAngle, offset, arcPoint); labelPoint.text = text; labelPoint.angle = middleAngle; labelPoint.color = point.color; labelPoint.rotate = self.getLabelRotate(middleAngle, offset, point); return labelPoint; }; PolarLabels.prototype._isEmitLabels = function _isEmitLabels() { var labels = this.get('label'); return labels.labelEmit; }; /** * @protected * 获取文本旋转的方向 * @param {Number} angle angle * @return {Number} angle */ PolarLabels.prototype.getLabelRotate = function getLabelRotate(angle) { var self = this; var rotate = void 0; rotate = angle * 180 / Math.PI; rotate += 90; if (self._isEmitLabels()) { rotate -= 90; } if (rotate) { if (rotate > 90) { rotate = rotate - 180; } else if (rotate < -90) { rotate = rotate + 180; } } return rotate / 180 * Math.PI; }; // override PolarLabels.prototype.getLabelAlign = function getLabelAlign(point) { var self = this; var coord = self.get('coord'); var align = void 0; if (self._isEmitLabels()) { if (point.angle <= Math.PI / 2 && point.angle > -Math.PI / 2) { align = 'left'; } else { align = 'right'; } } else if (!coord.isTransposed) { align = 'center'; } else { var center = coord.getCenter(); var offset = self.getDefaultOffset(); if (Math.abs(point.x - center.x) < 1) { align = 'center'; } else if (point.angle > Math.PI || point.angle <= 0) { if (offset > 0) { align = 'left'; } else { align = 'right'; } } else { if (offset > 0) { align = 'right'; } else { align = 'left'; } } } return align; }; return PolarLabels; }(Labels); module.exports = PolarLabels; /***/ }), /* 112 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 路径图,无序的线图 * @author dxq613@gmail.com */ var GeomBase = __webpack_require__(9); var SplitMixin = __webpack_require__(113); var Util = __webpack_require__(0); var Path = function (_GeomBase) { _inherits(Path, _GeomBase); /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Path.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _GeomBase.prototype.getDefaultCfg.call(this); cfg.type = 'path'; cfg.shapeType = 'line'; return cfg; }; function Path(cfg) { _classCallCheck(this, Path); var _this = _possibleConstructorReturn(this, _GeomBase.call(this, cfg)); Util.assign(_this, SplitMixin); return _this; } Path.prototype.getDrawCfg = function getDrawCfg(obj) { var cfg = _GeomBase.prototype.getDrawCfg.call(this, obj); cfg.isStack = this.hasStack(); return cfg; }; Path.prototype.draw = function draw(data, container, shapeFactory, index) { var self = this; var splitArray = this.splitData(data); var cfg = this.getDrawCfg(data[0]); cfg.origin = data; // path,line 等图的origin 是整个序列 Util.each(splitArray, function (subData, splitedIndex) { if (!Util.isEmpty(subData)) { cfg.splitedIndex = splitedIndex; // 传入分割片段索引 用于生成id cfg.points = subData; var geomShape = shapeFactory.drawShape(cfg.shape, cfg, container); geomShape.setSilent('index', index + splitedIndex); geomShape.setSilent('coord', self.get('coord')); if (self.get('animate') && self.get('animateCfg')) { geomShape.setSilent('animateCfg', self.get('animateCfg')); } } }); }; return Path; }(GeomBase); module.exports = Path; /***/ }), /* 113 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 分割数据用于处理存在 null 值的折线图、区域图 * @author dxq613@gmail.com */ var Util = __webpack_require__(0); module.exports = { splitData: function splitData(data) { if (!data.length) return []; var arr = []; var tmp = []; var yScale = this.getYScale(); var yDim = yScale.field; var yValue = void 0; Util.each(data, function (obj) { yValue = obj._origin ? obj._origin[yDim] : obj[yDim]; if (Util.isArray(yValue) && Util.isNil(yValue[0]) || Util.isNil(yValue)) { if (tmp.length) { arr.push(tmp); tmp = []; } } else { tmp.push(obj); } }); if (tmp.length) { arr.push(tmp); } return arr; } }; /***/ }), /* 114 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 需要计算所占x轴上的宽度的辅助类 * @author sima.zhang1990@gmail.com * @author dxq613@gmail.com */ var Global = __webpack_require__(1); var Util = __webpack_require__(0); // 已经排序后的数据查找距离最小的 function findMinDistance(arr, scale) { var count = arr.length; // 日期类型的 values 经常上文本类型,所以需要转换一下 if (Util.isString(arr[0])) { arr = arr.map(function (v) { return scale.translate(v); }); } var distance = arr[1] - arr[0]; for (var i = 2; i < count; i++) { var tmp = arr[i] - arr[i - 1]; if (distance > tmp) { distance = tmp; } } return distance; } var SizeMixin = { getDefalutSize: function getDefalutSize() { var defaultSize = this.get('defaultSize'); if (!defaultSize) { var coord = this.get('coord'); var xScale = this.getXScale(); var xValues = xScale.values; var dataArray = this.get('dataArray'); var count = void 0; if (xScale.isLinear && xValues.length > 1) { xValues.sort(); var interval = findMinDistance(xValues, xScale); count = (xScale.max - xScale.min) / interval; if (xValues.length > count) { count = xValues.length; } } else { count = xValues.length; } var range = xScale.range; var normalizeSize = 1 / count; var widthRatio = 1; if (this.isInCircle()) { if (coord.isTransposed && count > 1) { // 极坐标下多层环图 widthRatio = Global.widthRatio.multiplePie; } else { widthRatio = Global.widthRatio.rose; } /* if (dataArray.length > 1) { normalizeSize *= (range[1] - range[0]); } */ } else { if (xScale.isLinear) { normalizeSize *= range[1] - range[0]; } widthRatio = Global.widthRatio.column; // 柱状图要除以2 } normalizeSize *= widthRatio; if (this.hasAdjust('dodge')) { var dodgeCount = this._getDodgeCount(dataArray); normalizeSize = normalizeSize / dodgeCount; } defaultSize = normalizeSize; this.set('defaultSize', defaultSize); } return defaultSize; }, _getDodgeCount: function _getDodgeCount(dataArray) { var adjusts = this.get('adjusts'); var dodgeBy = void 0; var count = dataArray.length; Util.each(adjusts, function (adjust) { if (adjust.type === 'dodge') { dodgeBy = adjust.dodgeBy; } }); if (dodgeBy) { var mergeData = Util.Array.merge(dataArray); var values = Util.Array.values(mergeData, dodgeBy); count = values.length; } return count; }, getDimWidth: function getDimWidth(dimName) { var coord = this.get('coord'); var start = coord.convertPoint({ x: 0, y: 0 }); var end = coord.convertPoint({ x: dimName === 'x' ? 1 : 0, y: dimName === 'x' ? 0 : 1 }); var width = 0; if (start && end) { width = Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2)); } return width; }, _getWidth: function _getWidth() { var coord = this.get('coord'); var width = void 0; // x轴的长度 if (this.isInCircle() && !coord.isTransposed) { // 极坐标下 width 为弧长 width = (coord.endAngle - coord.startAngle) * coord.radius; } else { width = this.getDimWidth('x'); // 不需要判断transpose } return width; }, _toNormalizedSize: function _toNormalizedSize(size) { var width = this._getWidth(); return size / width; }, _toCoordSize: function _toCoordSize(normalizeSize) { var width = this._getWidth(); return width * normalizeSize; }, getNormalizedSize: function getNormalizedSize(obj) { var size = this.getAttrValue('size', obj); if (Util.isNil(size)) { size = this.getDefalutSize(); } else { size = this._toNormalizedSize(size); } return size; }, getSize: function getSize(obj) { var size = this.getAttrValue('size', obj); if (Util.isNil(size)) { var normalizeSize = this.getDefalutSize(); size = this._toCoordSize(normalizeSize); } return size; } }; module.exports = SizeMixin; /***/ }), /* 115 */ /***/ (function(module, exports, __webpack_require__) { module.exports = { Scale: __webpack_require__(321), Coord: __webpack_require__(329), Axis: __webpack_require__(334), Guide: __webpack_require__(355), Legend: __webpack_require__(356), Tooltip: __webpack_require__(357), Event: __webpack_require__(358) }; /***/ }), /* 116 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview Scale entry, used to reference all the scales * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var Base = __webpack_require__(41); Base.Linear = __webpack_require__(42); Base.Identity = __webpack_require__(323); Base.Cat = __webpack_require__(118); Base.Time = __webpack_require__(324); Base.TimeCat = __webpack_require__(326); Base.Log = __webpack_require__(327); Base.Pow = __webpack_require__(328); var _loop = function _loop(k) { if (Base.hasOwnProperty(k)) { var methodName = Util.lowerFirst(k); Base[methodName] = function (cfg) { return new Base[k](cfg); }; } }; for (var k in Base) { _loop(k); } var CAT_ARR = ['cat', 'timeCat']; Base.isCategory = function (type) { return CAT_ARR.indexOf(type) >= 0; }; module.exports = Base; /***/ }), /* 117 */ /***/ (function(module, exports) { /** * @fileOverview 计算方法 * @author dxq613@gmail.com */ // 如果小数点后面超过 10 位浮点数时进行一下处理 var DECIMAL_LENGTH = 12; // 获取系数 function getFactor(v) { var factor = 1; if (v < 1) { var count = 0; while (v < 1) { factor = factor / 10; v = v * 10; count++; } // 浮点数计算出现问题 if (factor.toString().length > DECIMAL_LENGTH) { factor = parseFloat(factor.toFixed(count)); } } else { while (v > 10) { factor = factor * 10; v = v / 10; } } return factor; } // 取小于当前值的 function arrayFloor(values, value) { var length = values.length; if (length === 0) { return NaN; } var pre = values[0]; if (value < values[0]) { return NaN; } if (value >= values[length - 1]) { return values[length - 1]; } for (var i = 1; i < values.length; i++) { if (value < values[i]) { break; } pre = values[i]; } return pre; } // 大于当前值的第一个 function arrayCeiling(values, value) { var length = values.length; if (length === 0) { return NaN; } // var pre = values[0]; var rst = void 0; if (value > values[length - 1]) { return NaN; } if (value < values[0]) { return values[0]; } for (var i = 1; i < values.length; i++) { if (value <= values[i]) { rst = values[i]; break; } } return rst; } var Util = { // 获取逼近的数值 snapFactorTo: function snapFactorTo(v, arr, snapType) { // 假设 v = -512,isFloor = true if (isNaN(v)) { return NaN; } var factor = 1; // 计算系数 if (v !== 0) { if (v < 0) { factor = -1; } v = v * factor; // v = 512 var tmpFactor = getFactor(v); factor = factor * tmpFactor; // factor = -100 v = v / tmpFactor; // v = 5.12 } if (snapType === 'floor') { v = Util.snapFloor(arr, v); // v = 5 } else if (snapType === 'ceil') { v = Util.snapCeiling(arr, v); // v = 6 } else { v = Util.snapTo(arr, v); // 四舍五入 5 } var rst = v * factor; // 如果出现浮点数计算问题,需要处理一下 if (Math.abs(factor) < 1 && rst.toString().length > DECIMAL_LENGTH) { var decimalVal = parseInt(1 / factor); var symbol = factor > 0 ? 1 : -1; rst = v / decimalVal * symbol; } return rst; }, // 获取逼近的倍数 snapMultiple: function snapMultiple(v, base, snapType) { var div = void 0; if (snapType === 'ceil') { div = Math.ceil(v / base); } else if (snapType === 'floor') { div = Math.floor(v / base); } else { div = Math.round(v / base); } return div * base; }, /** * 获取逼近的值,用于对齐数据 * @param {Array} values 数据集合 * @param {Number} value 数值 * @return {Number} 逼近的值 */ snapTo: function snapTo(values, value) { // 这里假定values是升序排列 var floorVal = arrayFloor(values, value); var ceilingVal = arrayCeiling(values, value); if (isNaN(floorVal) || isNaN(ceilingVal)) { if (values[0] >= value) { return values[0]; } var last = values[values.length - 1]; if (last <= value) { return last; } } if (Math.abs(value - floorVal) < Math.abs(ceilingVal - value)) { return floorVal; } return ceilingVal; }, /** * 获取逼近的最小值,用于对齐数据 * @param {Array} values 数据集合 * @param {Number} value 数值 * @return {Number} 逼近的最小值 */ snapFloor: function snapFloor(values, value) { // 这里假定values是升序排列 return arrayFloor(values, value); }, /** * 获取逼近的最大值,用于对齐数据 * @param {Array} values 数据集合 * @param {Number} value 数值 * @return {Number} 逼近的最大值 */ snapCeiling: function snapCeiling(values, value) { // 这里假定values是升序排列 return arrayCeiling(values, value); } }; module.exports = Util; /***/ }), /* 118 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the scale function to process the categories * @author dxq613@gmail.com */ var Base = __webpack_require__(41); var Util = __webpack_require__(0); var catAuto = __webpack_require__(119); /** * 度量的构造函数 * @class Scale.Category */ var Category = function (_Base) { _inherits(Category, _Base); function Category() { _classCallCheck(this, Category); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } /** * @override */ Category.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * type of the scale * @type {String} */ type: 'cat', /** * 自动生成标记时的个数 * @type {Number} * @default null */ tickCount: null, /** * 是否分类度量 * @type {Boolean} */ isCategory: true }); }; /** * @override */ Category.prototype.init = function init() { var self = this; var values = self.values; var tickCount = self.tickCount; Util.each(values, function (v, i) { values[i] = v.toString(); }); if (!self.ticks) { var ticks = values; if (tickCount) { var temp = catAuto({ maxCount: tickCount, data: values }); ticks = temp.ticks; } this.ticks = ticks; } }; /** * @override */ Category.prototype.getText = function getText(value) { if (this.values.indexOf(value) === -1 && Util.isNumber(value)) { value = this.values[Math.round(value)]; } return _Base.prototype.getText.call(this, value); }; /** * @override */ Category.prototype.translate = function translate(value) { var index = this.values.indexOf(value); if (index === -1 && Util.isNumber(value)) { index = value; } else if (index === -1) { index = NaN; } return index; }; /** * @override */ Category.prototype.scale = function scale(value) { var rangeMin = this.rangeMin(); var rangeMax = this.rangeMax(); var percent = void 0; if (Util.isString(value) || this.values.indexOf(value) !== -1) { value = this.translate(value); } if (this.values.length > 1) { percent = value / (this.values.length - 1); } else { percent = value; } return rangeMin + percent * (rangeMax - rangeMin); }; /** * @override */ Category.prototype.invert = function invert(value) { if (Util.isString(value)) { // 如果已经是字符串 return value; } var min = this.rangeMin(); var max = this.rangeMax(); // 归一到 范围内 if (value < min) { value = min; } if (value > max) { value = max; } var percent = (value - min) / (max - min); var index = Math.round(percent * (this.values.length - 1)) % this.values.length; index = index || 0; return this.values[index]; }; return Category; }(Base); module.exports = Category; /***/ }), /* 119 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 计算分类的的坐标点 * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var MAX_COUNT = 8; function getSimpleArray(data) { var arr = []; Util.each(data, function (sub) { if (Util.isArray(sub)) { arr = arr.concat(sub); } else { arr.push(sub); } }); return arr; } module.exports = function (info) { var rst = {}; var ticks = []; var tickCount = info.maxCount || MAX_COUNT; var categories = getSimpleArray(info.data); if (categories.length <= tickCount + tickCount / 2) { ticks = [].concat(categories); } else { var length = categories.length; var step = parseInt(length / (tickCount - 1), 10); var groups = categories.map(function (e, i) { return i % step === 0 ? categories.slice(i, i + step) : null; }).filter(function (e) { return e; }); ticks.push(categories[0]); for (var i = 1; i < groups.length && i < tickCount - 1; i++) { ticks.push(groups[i][0]); } ticks.push(categories[length - 1]); } rst.categories = categories; rst.ticks = ticks; return rst; }; /***/ }), /* 120 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;(function (main) { 'use strict'; /** * Parse or format dates * @class fecha */ var fecha = {}; var token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g; var twoDigits = /\d\d?/; var threeDigits = /\d{3}/; var fourDigits = /\d{4}/; var word = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i; var literal = /\[([^]*?)\]/gm; var noop = function noop() {}; function shorten(arr, sLen) { var newArr = []; for (var i = 0, len = arr.length; i < len; i++) { newArr.push(arr[i].substr(0, sLen)); } return newArr; } function monthUpdate(arrName) { return function (d, v, i18n) { var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase()); if (~index) { d.month = index; } }; } function pad(val, len) { val = String(val); len = len || 2; while (val.length < len) { val = '0' + val; } return val; } var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; var monthNamesShort = shorten(monthNames, 3); var dayNamesShort = shorten(dayNames, 3); fecha.i18n = { dayNamesShort: dayNamesShort, dayNames: dayNames, monthNamesShort: monthNamesShort, monthNames: monthNames, amPm: ['am', 'pm'], DoFn: function DoFn(D) { return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10]; } }; var formatFlags = { D: function D(dateObj) { return dateObj.getDate(); }, DD: function DD(dateObj) { return pad(dateObj.getDate()); }, Do: function Do(dateObj, i18n) { return i18n.DoFn(dateObj.getDate()); }, d: function d(dateObj) { return dateObj.getDay(); }, dd: function dd(dateObj) { return pad(dateObj.getDay()); }, ddd: function ddd(dateObj, i18n) { return i18n.dayNamesShort[dateObj.getDay()]; }, dddd: function dddd(dateObj, i18n) { return i18n.dayNames[dateObj.getDay()]; }, M: function M(dateObj) { return dateObj.getMonth() + 1; }, MM: function MM(dateObj) { return pad(dateObj.getMonth() + 1); }, MMM: function MMM(dateObj, i18n) { return i18n.monthNamesShort[dateObj.getMonth()]; }, MMMM: function MMMM(dateObj, i18n) { return i18n.monthNames[dateObj.getMonth()]; }, YY: function YY(dateObj) { return String(dateObj.getFullYear()).substr(2); }, YYYY: function YYYY(dateObj) { return dateObj.getFullYear(); }, h: function h(dateObj) { return dateObj.getHours() % 12 || 12; }, hh: function hh(dateObj) { return pad(dateObj.getHours() % 12 || 12); }, H: function H(dateObj) { return dateObj.getHours(); }, HH: function HH(dateObj) { return pad(dateObj.getHours()); }, m: function m(dateObj) { return dateObj.getMinutes(); }, mm: function mm(dateObj) { return pad(dateObj.getMinutes()); }, s: function s(dateObj) { return dateObj.getSeconds(); }, ss: function ss(dateObj) { return pad(dateObj.getSeconds()); }, S: function S(dateObj) { return Math.round(dateObj.getMilliseconds() / 100); }, SS: function SS(dateObj) { return pad(Math.round(dateObj.getMilliseconds() / 10), 2); }, SSS: function SSS(dateObj) { return pad(dateObj.getMilliseconds(), 3); }, a: function a(dateObj, i18n) { return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1]; }, A: function A(dateObj, i18n) { return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase(); }, ZZ: function ZZ(dateObj) { var o = dateObj.getTimezoneOffset(); return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4); } }; var parseFlags = { D: [twoDigits, function (d, v) { d.day = v; }], Do: [new RegExp(twoDigits.source + word.source), function (d, v) { d.day = parseInt(v, 10); }], M: [twoDigits, function (d, v) { d.month = v - 1; }], YY: [twoDigits, function (d, v) { var da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2); d.year = '' + (v > 68 ? cent - 1 : cent) + v; }], h: [twoDigits, function (d, v) { d.hour = v; }], m: [twoDigits, function (d, v) { d.minute = v; }], s: [twoDigits, function (d, v) { d.second = v; }], YYYY: [fourDigits, function (d, v) { d.year = v; }], S: [/\d/, function (d, v) { d.millisecond = v * 100; }], SS: [/\d{2}/, function (d, v) { d.millisecond = v * 10; }], SSS: [threeDigits, function (d, v) { d.millisecond = v; }], d: [twoDigits, noop], ddd: [word, noop], MMM: [word, monthUpdate('monthNamesShort')], MMMM: [word, monthUpdate('monthNames')], a: [word, function (d, v, i18n) { var val = v.toLowerCase(); if (val === i18n.amPm[0]) { d.isPm = false; } else if (val === i18n.amPm[1]) { d.isPm = true; } }], ZZ: [/([\+\-]\d\d:?\d\d|Z)/, function (d, v) { if (v === 'Z') v = '+00:00'; var parts = (v + '').match(/([\+\-]|\d\d)/gi), minutes; if (parts) { minutes = +(parts[1] * 60) + parseInt(parts[2], 10); d.timezoneOffset = parts[0] === '+' ? minutes : -minutes; } }] }; parseFlags.dd = parseFlags.d; parseFlags.dddd = parseFlags.ddd; parseFlags.DD = parseFlags.D; parseFlags.mm = parseFlags.m; parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h; parseFlags.MM = parseFlags.M; parseFlags.ss = parseFlags.s; parseFlags.A = parseFlags.a; // Some common format strings fecha.masks = { default: 'ddd MMM DD YYYY HH:mm:ss', shortDate: 'M/D/YY', mediumDate: 'MMM D, YYYY', longDate: 'MMMM D, YYYY', fullDate: 'dddd, MMMM D, YYYY', shortTime: 'HH:mm', mediumTime: 'HH:mm:ss', longTime: 'HH:mm:ss.SSS' }; /*** * Format a date * @method format * @param {Date|number} dateObj * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate' */ fecha.format = function (dateObj, mask, i18nSettings) { var i18n = i18nSettings || fecha.i18n; if (typeof dateObj === 'number') { dateObj = new Date(dateObj); } if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) { throw new Error('Invalid Date in fecha.format'); } mask = fecha.masks[mask] || mask || fecha.masks['default']; var literals = []; // Make literals inactive by replacing them with ?? mask = mask.replace(literal, function ($0, $1) { literals.push($1); return '??'; }); // Apply formatting rules mask = mask.replace(token, function ($0) { return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1); }); // Inline literal values back into the formatted value return mask.replace(/\?\?/g, function () { return literals.shift(); }); }; /** * Parse a date string into an object, changes - into / * @method parse * @param {string} dateStr Date string * @param {string} format Date parse format * @returns {Date|boolean} */ fecha.parse = function (dateStr, format, i18nSettings) { var i18n = i18nSettings || fecha.i18n; if (typeof format !== 'string') { throw new Error('Invalid format in fecha.parse'); } format = fecha.masks[format] || format; // Avoid regular expression denial of service, fail early for really long strings // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS if (dateStr.length > 1000) { return false; } var isValid = true; var dateInfo = {}; format.replace(token, function ($0) { if (parseFlags[$0]) { var info = parseFlags[$0]; var index = dateStr.search(info[0]); if (!~index) { isValid = false; } else { dateStr.replace(info[0], function (result) { info[1](dateInfo, result, i18n); dateStr = dateStr.substr(index + result.length); return result; }); } } return parseFlags[$0] ? '' : $0.slice(1, $0.length - 1); }); if (!isValid) { return false; } var today = new Date(); if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) { dateInfo.hour = +dateInfo.hour + 12; } else if (dateInfo.isPm === false && +dateInfo.hour === 12) { dateInfo.hour = 0; } var date; if (dateInfo.timezoneOffset != null) { dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset; date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0)); } else { date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0); } return date; }; /* istanbul ignore next */ if (typeof module !== 'undefined' && module.exports) { module.exports = fecha; } else if (true) { !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return fecha; }).call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else { main.fecha = fecha; } })(this); /***/ }), /* 121 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 提取公共代码到util方法 * @author dxq613@gmail.com */ var Util = __webpack_require__(0); module.exports = { toTimeStamp: function toTimeStamp(value) { if (Util.isString(value)) { if (value.indexOf('T') > 0) { value = new Date(value).getTime(); } else { value = new Date(value.replace(/-/ig, '/')).getTime(); } } if (Util.isDate(value)) { value = value.getTime(); } return value; } }; /***/ }), /* 122 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The base class of legend * @author sima.zhang */ var Util = __webpack_require__(0); var Global = __webpack_require__(1); var _require = __webpack_require__(2), Group = _require.Group; var Base = function (_Group) { _inherits(Base, _Group); function Base() { _classCallCheck(this, Base); return _possibleConstructorReturn(this, _Group.apply(this, arguments)); } Base.prototype.getDefaultCfg = function getDefaultCfg() { return { /** * 图例标题配置 * @type {Object} */ title: { fill: '#333', textBaseline: 'middle' }, /** * 图例项文本格式化 * @type {Function} */ itemFormatter: null, /** * 是否使用 html 进行渲染 * @type {Boolean} */ useHtml: false, /** * 图例是否绘制在绘图区域内 * @type {Boolean} */ inPlot: false, /** * 鼠标 hover 到图例上的默认交互是否开启 * @type {Boolean} */ hoverable: true }; }; Base.prototype._beforeRenderUI = function _beforeRenderUI() { this.set('itemsGroup', this.addGroup()); }; Base.prototype._renderUI = function _renderUI() { this._renderTitle(); }; Base.prototype._renderTitle = function _renderTitle() { var title = this.get('title'); if (title && title.text) { var titleShape = this.addShape('text', { attrs: Util.mix({ x: 0, y: 0, fill: '#333', // 默认样式 textBaseline: 'middle', fontFamily: Global.fontFamily }, title) }); titleShape.name = 'legend-title'; this.get('appendInfo') && titleShape.setSilent('appendInfo', this.get('appendInfo')); this.set('titleShape', titleShape); } }; Base.prototype.getCheckedCount = function getCheckedCount() { var itemsGroup = this.get('itemsGroup'); var items = itemsGroup.get('children'); var checkedArr = Util.filter(items, function (item) { return item.get('checked'); }); return checkedArr.length; }; Base.prototype.setItems = function setItems(items) { this.set('items', items); this.clearItems(); this._renderUI(); }; Base.prototype.addItem = function addItem(item) { var items = this.get('items'); items.push(item); this.clearItems(); this._renderUI(); }; Base.prototype.clearItems = function clearItems() { var itemsGroup = this.get('itemsGroup'); itemsGroup.clear(); }; Base.prototype.getWidth = function getWidth() { var bbox = this.getBBox(); return bbox.width; }; Base.prototype.getHeight = function getHeight() { var bbox = this.getBBox(); return bbox.height; }; return Base; }(Group); module.exports = Base; /***/ }), /* 123 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The base class of continuous legend * @author sima.zhang */ var Util = __webpack_require__(0); var Global = __webpack_require__(1); var Base = __webpack_require__(122); var _require = __webpack_require__(2), Event = _require.Event, Group = _require.Group; var Slider = __webpack_require__(351); var TRIGGER_WIDTH = 12; var Continuous = function (_Base) { _inherits(Continuous, _Base); function Continuous() { _classCallCheck(this, Continuous); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Continuous.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * 类型 * @type {String} */ type: 'continuous-legend', /** * 子项 * @type {Array} */ items: null, /** * 布局方式 * horizontal 水平 * vertical 垂直 * @type {String} */ layout: 'vertical', /** * 宽度 * @type {Number} */ width: 156, /** * 高度 * @type {Number} */ height: 20, /** * 标题偏移量 * @type {Number} */ titleGap: 22, /** * 默认文本图形属性 * @type {ATTRS} */ textStyle: { fill: '#333', textAlign: 'center', textBaseline: 'middle', fontFamily: Global.fontFamily }, /** * 连续图例是否可滑动 * @type {Boolean} */ slidable: true, /** * 范围内颜色 * @type {ATTRS} */ inRange: { fill: '#4E7CCC' }, _range: [0, 100], /** * 中滑块属性 * @type {ATTRS} */ middleAttr: { fill: '#fff', fillOpacity: 0 }, outRangeStyle: { fill: '#D9D9D9' }, labelOffset: 10 // ToDO: 文本同渐变背景的距离 }); }; Continuous.prototype._calStartPoint = function _calStartPoint() { var start = { x: 0, y: this.get('titleGap') - TRIGGER_WIDTH }; var titleShape = this.get('titleShape'); if (titleShape) { var titleBox = titleShape.getBBox(); start.y += titleBox.height; } return start; }; Continuous.prototype._beforeRenderUI = function _beforeRenderUI() { var items = this.get('items'); if (!Util.isArray(items) || Util.isEmpty(items)) { return; } _Base.prototype._beforeRenderUI.call(this); this.set('firstItem', items[0]); this.set('lastItem', items[items.length - 1]); }; Continuous.prototype._formatItemValue = function _formatItemValue(value) { var formatter = this.get('itemFormatter'); if (formatter) { value = formatter.call(this, value); } return value; }; Continuous.prototype._renderUI = function _renderUI() { _Base.prototype._renderUI.call(this); if (this.get('slidable')) { this._renderSlider(); } else { this._renderBackground(); } }; Continuous.prototype._renderSlider = function _renderSlider() { var minHandleElement = new Group(); var maxHandleElement = new Group(); var backgroundElement = new Group(); var start = this._calStartPoint(); var slider = this.addGroup(Slider, { minHandleElement: minHandleElement, maxHandleElement: maxHandleElement, backgroundElement: backgroundElement, middleAttr: this.get('middleAttr'), layout: this.get('layout'), range: this.get('_range'), width: this.get('width'), height: this.get('height') }); slider.translate(start.x, start.y); this.set('slider', slider); var shape = this._renderSliderShape(); shape.attr('clip', slider.get('middleHandleElement')); this._renderTrigger(); }; Continuous.prototype._addBackground = function _addBackground(parent, name, attrs) { parent.addShape(name, { attrs: Util.mix({}, attrs, this.get('outRangeStyle')) }); return parent.addShape(name, { attrs: attrs }); }; Continuous.prototype._renderTrigger = function _renderTrigger() { var min = this.get('firstItem'); var max = this.get('lastItem'); var layout = this.get('layout'); var textStyle = this.get('textStyle'); var inRange = this.get('inRange'); var attrType = this.get('type'); var minBlockAttr = void 0; var maxBlockAttr = void 0; if (attrType === 'color-legend') { minBlockAttr = { fill: min.attrValue }; maxBlockAttr = { fill: max.attrValue }; } else { minBlockAttr = Util.mix({}, inRange); maxBlockAttr = Util.mix({}, inRange); } var minTextAttr = Util.mix({ text: this._formatItemValue(min.value) + '' }, textStyle); var maxTextAttr = Util.mix({ text: this._formatItemValue(max.value) + '' }, textStyle); if (layout === 'vertical') { this._addVerticalTrigger('min', minBlockAttr, minTextAttr); this._addVerticalTrigger('max', maxBlockAttr, maxTextAttr); } else { this._addHorizontalTrigger('min', minBlockAttr, minTextAttr); this._addHorizontalTrigger('max', maxBlockAttr, maxTextAttr); } }; Continuous.prototype._addVerticalTrigger = function _addVerticalTrigger(type, blockAttr, textAttr) { var slider = this.get('slider'); var trigger = slider.get(type + 'HandleElement'); var width = this.get('width'); var button = trigger.addShape('polygon', { attrs: Util.mix({ points: [[width / 2 + TRIGGER_WIDTH, 0], [width / 2 + 1, 0], [width / 2 + TRIGGER_WIDTH, type === 'min' ? TRIGGER_WIDTH : -TRIGGER_WIDTH]] }, blockAttr) }); var text = trigger.addShape('text', { attrs: Util.mix(textAttr, { x: width + 8, y: type === 'max' ? -4 : 4, textAlign: 'start', lineHeight: 1, textBaseline: 'middle' }) }); var layout = this.get('layout'); var trigerCursor = layout === 'vertical' ? 'ns-resize' : 'ew-resize'; button.attr('cursor', trigerCursor); text.attr('cursor', trigerCursor); this.set(type + 'ButtonElement', button); this.set(type + 'TextElement', text); }; Continuous.prototype._addHorizontalTrigger = function _addHorizontalTrigger(type, blockAttr, textAttr) { var slider = this.get('slider'); var trigger = slider.get(type + 'HandleElement'); var button = trigger.addShape('polygon', { attrs: Util.mix({ points: [[0, 0], [0, TRIGGER_WIDTH], [type === 'min' ? -TRIGGER_WIDTH : TRIGGER_WIDTH, TRIGGER_WIDTH]] }, blockAttr) }); var text = trigger.addShape('text', { attrs: Util.mix(textAttr, { x: type === 'min' ? -TRIGGER_WIDTH - 4 : TRIGGER_WIDTH + 4, y: TRIGGER_WIDTH / 2, textAlign: type === 'min' ? 'end' : 'start', textBaseline: 'middle' }) }); var layout = this.get('layout'); var trigerCursor = layout === 'vertical' ? 'ns-resize' : 'ew-resize'; button.attr('cursor', trigerCursor); text.attr('cursor', trigerCursor); this.set(type + 'ButtonElement', button); this.set(type + 'TextElement', text); }; Continuous.prototype._bindUI = function _bindUI() { var self = this; if (self.get('slidable')) { // const canvas = self.get('canvas'); var slider = self.get('slider'); slider.on('sliderchange', function (ev) { var range = ev.range; var firstItemValue = self.get('firstItem').value * 1; var lastItemValue = self.get('lastItem').value * 1; var minValue = firstItemValue + range[0] / 100 * (lastItemValue - firstItemValue); var maxValue = firstItemValue + range[1] / 100 * (lastItemValue - firstItemValue); self._updateElement(minValue, maxValue); var itemFiltered = new Event('itemfilter', ev, true, true); itemFiltered.range = [minValue, maxValue]; self.emit('itemfilter', itemFiltered); }); } }; Continuous.prototype._updateElement = function _updateElement(min, max) { var minTextElement = this.get('minTextElement'); var maxTextElement = this.get('maxTextElement'); if (max > 1) { // 对于大于 1 的值,默认显示为整数 min = parseInt(min, 10); max = parseInt(max, 10); } minTextElement.attr('text', this._formatItemValue(min) + ''); maxTextElement.attr('text', this._formatItemValue(max) + ''); if (this.get('type') === 'color-legend' && this.get('attr')) { var attr = this.get('attr'); // 图形属性,为了更新滑块颜色 var minButtonElement = this.get('minButtonElement'); var maxButtonElement = this.get('maxButtonElement'); minButtonElement.attr('fill', attr.mapping(min).join('')); maxButtonElement.attr('fill', attr.mapping(max).join('')); } }; return Continuous; }(Base); module.exports = Continuous; /***/ }), /* 124 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 分面的基类 * @author dxq613@gmail.com */ var Base = __webpack_require__(45); /** * 矩形的 facet 有以下属性: * - colField 列的字段 * - rowField 行的字段 * - colValue 列字段的值 * - rowValue 行字段的值 * - cols 列数 * - rows 行数 * - colIndex 列的序号 * - rowIndex 行的序号 */ /** * 用于生成分面的类 * @class Facets.Rect */ var Rect = function (_Base) { _inherits(Rect, _Base); function Rect() { _classCallCheck(this, Rect); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Rect.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); cfg.type = 'rect'; return cfg; }; Rect.prototype.generateFacets = function generateFacets(data) { var self = this; var fields = self.fields; // var defs = self.defs; var rst = []; var rows = 1; var cols = 1; var colField = fields[0]; var rowField = fields[1]; var colValues = ['']; var rowValues = ['']; if (colField) { colValues = self.getFieldValues(colField, data); cols = colValues.length; } if (rowField) { rowValues = self.getFieldValues(rowField, data); rows = rowValues.length; } // 获取每个维度对应的frame colValues.forEach(function (xVal, xIndex) { rowValues.forEach(function (yVal, yIndex) { var conditions = [{ field: colField, value: xVal, values: colValues }, { field: rowField, value: yVal, values: rowValues }]; var filter = self.getFilter(conditions); var subData = data.filter(filter); var facet = { type: self.type, colValue: xVal, rowValue: yVal, colField: colField, rowField: rowField, colIndex: xIndex, rowIndex: yIndex, cols: cols, rows: rows, data: subData, region: self.getRegion(rows, cols, xIndex, yIndex) }; rst.push(facet); }); }); return rst; }; // 设置 x 坐标轴的文本、title 是否显示 Rect.prototype.setXAxis = function setXAxis(xField, axes, facet) { if (facet.rowIndex !== facet.rows - 1) { axes[xField].title = null; axes[xField].label = null; } else if (facet.colIndex !== parseInt((facet.cols - 1) / 2)) { axes[xField].title = null; } }; // 设置 y 坐标轴的文本、title 是否显示 Rect.prototype.setYAxis = function setYAxis(yField, axes, facet) { if (facet.colIndex !== 0) { axes[yField].title = null; axes[yField].label = null; } else if (facet.rowIndex !== parseInt((facet.rows - 1) / 2)) { axes[yField].title = null; } }; Rect.prototype.renderTitle = function renderTitle(view, facet) { if (facet.rowIndex === 0) { this.drawColTitle(view, facet); } if (facet.colIndex === facet.cols - 1) { this.drawRowTitle(view, facet); } }; return Rect; }(Base); module.exports = Rect; /***/ }), /* 125 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview list facets, support cols */ var Base = __webpack_require__(45); /** * 用于生成分面的类 * @class Facets.List */ var List = function (_Base) { _inherits(List, _Base); function List() { _classCallCheck(this, List); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } List.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); cfg.type = 'list'; cfg.cols = null; // 用户不设置时就显示一行 return cfg; }; List.prototype.generateFacets = function generateFacets(data) { var self = this; var fields = self.fields; var colField = fields[0]; if (!colField) { throw 'Please specify for the field for facet!'; } var colValues = self.getFieldValues(colField, data); var count = colValues.length; var cols = self.cols || count; var rows = parseInt((count + cols - 1) / cols); var rst = []; colValues.forEach(function (xVal, index) { var row = parseInt(index / cols); var col = index % cols; var conditions = [{ field: colField, value: xVal, values: colValues }]; var filter = self.getFilter(conditions); var subData = data.filter(filter); var facet = { type: self.type, count: count, colValue: xVal, colField: colField, rowField: null, rowValue: xVal, colIndex: col, rowIndex: row, cols: cols, rows: rows, data: subData, region: self.getRegion(rows, cols, col, row) }; rst.push(facet); }); return rst; }; // 设置 x 坐标轴的文本、title 是否显示 List.prototype.setXAxis = function setXAxis(xField, axes, facet) { // 当是最后一行或者下面没有 view 时文本不显示 if (facet.rowIndex !== facet.rows - 1 && facet.cols * facet.rowIndex + facet.colIndex + 1 + facet.cols <= facet.count) { axes[xField].label = null; axes[xField].title = null; } }; // 设置 y 坐标轴的文本、title 是否显示 List.prototype.setYAxis = function setYAxis(yField, axes, facet) { if (facet.colIndex !== 0) { axes[yField].title = null; axes[yField].label = null; } }; return List; }(Base); module.exports = List; /***/ }), /* 126 */ /***/ (function(module, exports, __webpack_require__) { var G = __webpack_require__(2); var Animate = __webpack_require__(68); var Chart = __webpack_require__(282); var Global = __webpack_require__(1); var Scale = __webpack_require__(116); var Shape = __webpack_require__(66); var Util = __webpack_require__(0); var G2 = { // version version: Global.version, // visual encoding Animate: Animate, Chart: Chart, Global: Global, Scale: Scale, Shape: Shape, Util: Util, // render engine G: G, DomUtil: G.DomUtil, MatrixUtil: G.MatrixUtil, PathUtil: G.PathUtil }; G2.track = function (enable) { Global.trackable = enable; }; __webpack_require__(365); // 保证两个版本共存 if (typeof window !== 'undefined') { if (window.G2) { console.warn('There are multiple versions of G2. Version ' + G2.version + '\'s reference is \'window.G2_3\''); } else { window.G2 = G2; } } module.exports = G2; /***/ }), /* 127 */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(128); /***/ }), /* 128 */ /***/ (function(module, exports, __webpack_require__) { var arrayEach = __webpack_require__(69), baseEach = __webpack_require__(27), castFunction = __webpack_require__(141), isArray = __webpack_require__(3); /** * Iterates over elements of `collection` and invokes `iteratee` for each element. * The iteratee is invoked with three arguments: (value, index|key, collection). * Iteratee functions may exit iteration early by explicitly returning `false`. * * **Note:** As with other "Collections" methods, objects with a "length" * property are iterated like arrays. To avoid this behavior use `_.forIn` * or `_.forOwn` for object iteration. * * @static * @memberOf _ * @since 0.1.0 * @alias each * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. * @returns {Array|Object} Returns `collection`. * @see _.forEachRight * @example * * _.forEach([1, 2], function(value) { * console.log(value); * }); * // => Logs `1` then `2`. * * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { * console.log(key); * }); * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ function forEach(collection, iteratee) { var func = isArray(collection) ? arrayEach : baseEach; return func(collection, castFunction(iteratee)); } module.exports = forEach; /***/ }), /* 129 */ /***/ (function(module, exports, __webpack_require__) { var baseFor = __webpack_require__(130), keys = __webpack_require__(11); /** * The base implementation of `_.forOwn` without support for iteratee shorthands. * * @private * @param {Object} object The object to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Object} Returns `object`. */ function baseForOwn(object, iteratee) { return object && baseFor(object, iteratee, keys); } module.exports = baseForOwn; /***/ }), /* 130 */ /***/ (function(module, exports, __webpack_require__) { var createBaseFor = __webpack_require__(131); /** * The base implementation of `baseForOwn` which iterates over `object` * properties returned by `keysFunc` and invokes `iteratee` for each property. * Iteratee functions may exit iteration early by explicitly returning `false`. * * @private * @param {Object} object The object to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ var baseFor = createBaseFor(); module.exports = baseFor; /***/ }), /* 131 */ /***/ (function(module, exports) { /** * Creates a base function for methods like `_.forIn` and `_.forOwn`. * * @private * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {Function} Returns the new base function. */ function createBaseFor(fromRight) { return function (object, iteratee, keysFunc) { var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length; while (length--) { var key = props[fromRight ? length : ++index]; if (iteratee(iterable[key], key, iterable) === false) { break; } } return object; }; } module.exports = createBaseFor; /***/ }), /* 132 */ /***/ (function(module, exports) { /** * The base implementation of `_.times` without support for iteratee shorthands * or max array length checks. * * @private * @param {number} n The number of times to invoke `iteratee`. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the array of results. */ function baseTimes(n, iteratee) { var index = -1, result = Array(n); while (++index < n) { result[index] = iteratee(index); } return result; } module.exports = baseTimes; /***/ }), /* 133 */ /***/ (function(module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(6), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var argsTag = '[object Arguments]'; /** * The base implementation of `_.isArguments`. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an `arguments` object, */ function baseIsArguments(value) { return isObjectLike(value) && baseGetTag(value) == argsTag; } module.exports = baseIsArguments; /***/ }), /* 134 */ /***/ (function(module, exports) { 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 g; // This works in non-strict mode g = function () { return this; }(); try { // This works if eval is allowed (see CSP) g = g || Function("return this")() || (1, eval)("this"); } catch (e) { // This works if the window reference is available if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }), /* 135 */ /***/ (function(module, exports, __webpack_require__) { var _Symbol = __webpack_require__(12); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString = objectProto.toString; /** Built-in value references. */ var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; /** * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. * * @private * @param {*} value The value to query. * @returns {string} Returns the raw `toStringTag`. */ function getRawTag(value) { var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; try { value[symToStringTag] = undefined; var unmasked = true; } catch (e) {} var result = nativeObjectToString.call(value); if (unmasked) { if (isOwn) { value[symToStringTag] = tag; } else { delete value[symToStringTag]; } } return result; } module.exports = getRawTag; /***/ }), /* 136 */ /***/ (function(module, exports) { /** Used for built-in method references. */ var objectProto = Object.prototype; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString = objectProto.toString; /** * Converts `value` to a string using `Object.prototype.toString`. * * @private * @param {*} value The value to convert. * @returns {string} Returns the converted string. */ function objectToString(value) { return nativeObjectToString.call(value); } module.exports = objectToString; /***/ }), /* 137 */ /***/ (function(module, exports) { /** * This method returns `false`. * * @static * @memberOf _ * @since 4.13.0 * @category Util * @returns {boolean} Returns `false`. * @example * * _.times(2, _.stubFalse); * // => [false, false] */ function stubFalse() { return false; } module.exports = stubFalse; /***/ }), /* 138 */ /***/ (function(module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(6), isLength = __webpack_require__(47), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', weakMapTag = '[object WeakMap]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; /** Used to identify `toStringTag` values of typed arrays. */ var typedArrayTags = {}; typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; /** * The base implementation of `_.isTypedArray` without Node.js optimizations. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. */ function baseIsTypedArray(value) { return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; } module.exports = baseIsTypedArray; /***/ }), /* 139 */ /***/ (function(module, exports, __webpack_require__) { var overArg = __webpack_require__(75); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeKeys = overArg(Object.keys, Object); module.exports = nativeKeys; /***/ }), /* 140 */ /***/ (function(module, exports, __webpack_require__) { var isArrayLike = __webpack_require__(8); /** * Creates a `baseEach` or `baseEachRight` function. * * @private * @param {Function} eachFunc The function to iterate over a collection. * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {Function} Returns the new base function. */ function createBaseEach(eachFunc, fromRight) { return function (collection, iteratee) { if (collection == null) { return collection; } if (!isArrayLike(collection)) { return eachFunc(collection, iteratee); } var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection); while (fromRight ? index-- : ++index < length) { if (iteratee(iterable[index], index, iterable) === false) { break; } } return collection; }; } module.exports = createBaseEach; /***/ }), /* 141 */ /***/ (function(module, exports, __webpack_require__) { var identity = __webpack_require__(31); /** * Casts `value` to `identity` if it's not a function. * * @private * @param {*} value The value to inspect. * @returns {Function} Returns cast function. */ function castFunction(value) { return typeof value == 'function' ? value : identity; } module.exports = castFunction; /***/ }), /* 142 */ /***/ (function(module, exports, __webpack_require__) { var arrayMap = __webpack_require__(49), baseIteratee = __webpack_require__(19), baseMap = __webpack_require__(192), isArray = __webpack_require__(3); /** * Creates an array of values by running each element in `collection` thru * `iteratee`. The iteratee is invoked with three arguments: * (value, index|key, collection). * * Many lodash methods are guarded to work as iteratees for methods like * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. * * The guarded methods are: * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, * `template`, `trim`, `trimEnd`, `trimStart`, and `words` * * @static * @memberOf _ * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. * @returns {Array} Returns the new mapped array. * @example * * function square(n) { * return n * n; * } * * _.map([4, 8], square); * // => [16, 64] * * _.map({ 'a': 4, 'b': 8 }, square); * // => [16, 64] (iteration order is not guaranteed) * * var users = [ * { 'user': 'barney' }, * { 'user': 'fred' } * ]; * * // The `_.property` iteratee shorthand. * _.map(users, 'user'); * // => ['barney', 'fred'] */ function map(collection, iteratee) { var func = isArray(collection) ? arrayMap : baseMap; return func(collection, baseIteratee(iteratee, 3)); } module.exports = map; /***/ }), /* 143 */ /***/ (function(module, exports, __webpack_require__) { var baseIsMatch = __webpack_require__(144), getMatchData = __webpack_require__(180), matchesStrictComparable = __webpack_require__(87); /** * The base implementation of `_.matches` which doesn't clone `source`. * * @private * @param {Object} source The object of property values to match. * @returns {Function} Returns the new spec function. */ function baseMatches(source) { var matchData = getMatchData(source); if (matchData.length == 1 && matchData[0][2]) { return matchesStrictComparable(matchData[0][0], matchData[0][1]); } return function (object) { return object === source || baseIsMatch(object, source, matchData); }; } module.exports = baseMatches; /***/ }), /* 144 */ /***/ (function(module, exports, __webpack_require__) { var Stack = __webpack_require__(50), baseIsEqual = __webpack_require__(37); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** * The base implementation of `_.isMatch` without support for iteratee shorthands. * * @private * @param {Object} object The object to inspect. * @param {Object} source The object of property values to match. * @param {Array} matchData The property names, values, and compare flags to match. * @param {Function} [customizer] The function to customize comparisons. * @returns {boolean} Returns `true` if `object` is a match, else `false`. */ function baseIsMatch(object, source, matchData, customizer) { var index = matchData.length, length = index, noCustomizer = !customizer; if (object == null) { return !length; } object = Object(object); while (index--) { var data = matchData[index]; if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) { return false; } } while (++index < length) { data = matchData[index]; var key = data[0], objValue = object[key], srcValue = data[1]; if (noCustomizer && data[2]) { if (objValue === undefined && !(key in object)) { return false; } } else { var stack = new Stack(); if (customizer) { var result = customizer(objValue, srcValue, key, object, source, stack); } if (!(result === undefined ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) : result)) { return false; } } } return true; } module.exports = baseIsMatch; /***/ }), /* 145 */ /***/ (function(module, exports) { /** * Removes all key-value entries from the list cache. * * @private * @name clear * @memberOf ListCache */ function listCacheClear() { this.__data__ = []; this.size = 0; } module.exports = listCacheClear; /***/ }), /* 146 */ /***/ (function(module, exports, __webpack_require__) { var assocIndexOf = __webpack_require__(33); /** Used for built-in method references. */ var arrayProto = Array.prototype; /** Built-in value references. */ var splice = arrayProto.splice; /** * Removes `key` and its value from the list cache. * * @private * @name delete * @memberOf ListCache * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function listCacheDelete(key) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { return false; } var lastIndex = data.length - 1; if (index == lastIndex) { data.pop(); } else { splice.call(data, index, 1); } --this.size; return true; } module.exports = listCacheDelete; /***/ }), /* 147 */ /***/ (function(module, exports, __webpack_require__) { var assocIndexOf = __webpack_require__(33); /** * Gets the list cache value for `key`. * * @private * @name get * @memberOf ListCache * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function listCacheGet(key) { var data = this.__data__, index = assocIndexOf(data, key); return index < 0 ? undefined : data[index][1]; } module.exports = listCacheGet; /***/ }), /* 148 */ /***/ (function(module, exports, __webpack_require__) { var assocIndexOf = __webpack_require__(33); /** * Checks if a list cache value for `key` exists. * * @private * @name has * @memberOf ListCache * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function listCacheHas(key) { return assocIndexOf(this.__data__, key) > -1; } module.exports = listCacheHas; /***/ }), /* 149 */ /***/ (function(module, exports, __webpack_require__) { var assocIndexOf = __webpack_require__(33); /** * Sets the list cache `key` to `value`. * * @private * @name set * @memberOf ListCache * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the list cache instance. */ function listCacheSet(key, value) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { ++this.size; data.push([key, value]); } else { data[index][1] = value; } return this; } module.exports = listCacheSet; /***/ }), /* 150 */ /***/ (function(module, exports, __webpack_require__) { var ListCache = __webpack_require__(32); /** * Removes all key-value entries from the stack. * * @private * @name clear * @memberOf Stack */ function stackClear() { this.__data__ = new ListCache(); this.size = 0; } module.exports = stackClear; /***/ }), /* 151 */ /***/ (function(module, exports) { /** * Removes `key` and its value from the stack. * * @private * @name delete * @memberOf Stack * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function stackDelete(key) { var data = this.__data__, result = data['delete'](key); this.size = data.size; return result; } module.exports = stackDelete; /***/ }), /* 152 */ /***/ (function(module, exports) { /** * Gets the stack value for `key`. * * @private * @name get * @memberOf Stack * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function stackGet(key) { return this.__data__.get(key); } module.exports = stackGet; /***/ }), /* 153 */ /***/ (function(module, exports) { /** * Checks if a stack value for `key` exists. * * @private * @name has * @memberOf Stack * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function stackHas(key) { return this.__data__.has(key); } module.exports = stackHas; /***/ }), /* 154 */ /***/ (function(module, exports, __webpack_require__) { var ListCache = __webpack_require__(32), Map = __webpack_require__(51), MapCache = __webpack_require__(52); /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; /** * Sets the stack `key` to `value`. * * @private * @name set * @memberOf Stack * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the stack cache instance. */ function stackSet(key, value) { var data = this.__data__; if (data instanceof ListCache) { var pairs = data.__data__; if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) { pairs.push([key, value]); this.size = ++data.size; return this; } data = this.__data__ = new MapCache(pairs); } data.set(key, value); this.size = data.size; return this; } module.exports = stackSet; /***/ }), /* 155 */ /***/ (function(module, exports, __webpack_require__) { var isFunction = __webpack_require__(48), isMasked = __webpack_require__(156), isObject = __webpack_require__(7), toSource = __webpack_require__(76); /** * Used to match `RegExp` * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; /** Used to detect host constructors (Safari). */ var reIsHostCtor = /^\[object .+?Constructor\]$/; /** Used for built-in method references. */ var funcProto = Function.prototype, objectProto = Object.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** Used to detect if a method is native. */ var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'); /** * The base implementation of `_.isNative` without bad shim checks. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a native function, * else `false`. */ function baseIsNative(value) { if (!isObject(value) || isMasked(value)) { return false; } var pattern = isFunction(value) ? reIsNative : reIsHostCtor; return pattern.test(toSource(value)); } module.exports = baseIsNative; /***/ }), /* 156 */ /***/ (function(module, exports, __webpack_require__) { var coreJsData = __webpack_require__(157); /** Used to detect methods masquerading as native. */ var maskSrcKey = function () { var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); return uid ? 'Symbol(src)_1.' + uid : ''; }(); /** * Checks if `func` has its source masked. * * @private * @param {Function} func The function to check. * @returns {boolean} Returns `true` if `func` is masked, else `false`. */ function isMasked(func) { return !!maskSrcKey && maskSrcKey in func; } module.exports = isMasked; /***/ }), /* 157 */ /***/ (function(module, exports, __webpack_require__) { var root = __webpack_require__(4); /** Used to detect overreaching core-js shims. */ var coreJsData = root['__core-js_shared__']; module.exports = coreJsData; /***/ }), /* 158 */ /***/ (function(module, exports) { /** * Gets the value at `key` of `object`. * * @private * @param {Object} [object] The object to query. * @param {string} key The key of the property to get. * @returns {*} Returns the property value. */ function getValue(object, key) { return object == null ? undefined : object[key]; } module.exports = getValue; /***/ }), /* 159 */ /***/ (function(module, exports, __webpack_require__) { var Hash = __webpack_require__(160), ListCache = __webpack_require__(32), Map = __webpack_require__(51); /** * Removes all key-value entries from the map. * * @private * @name clear * @memberOf MapCache */ function mapCacheClear() { this.size = 0; this.__data__ = { 'hash': new Hash(), 'map': new (Map || ListCache)(), 'string': new Hash() }; } module.exports = mapCacheClear; /***/ }), /* 160 */ /***/ (function(module, exports, __webpack_require__) { var hashClear = __webpack_require__(161), hashDelete = __webpack_require__(162), hashGet = __webpack_require__(163), hashHas = __webpack_require__(164), hashSet = __webpack_require__(165); /** * Creates a hash object. * * @private * @constructor * @param {Array} [entries] The key-value pairs to cache. */ function Hash(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } // Add methods to `Hash`. Hash.prototype.clear = hashClear; Hash.prototype['delete'] = hashDelete; Hash.prototype.get = hashGet; Hash.prototype.has = hashHas; Hash.prototype.set = hashSet; module.exports = Hash; /***/ }), /* 161 */ /***/ (function(module, exports, __webpack_require__) { var nativeCreate = __webpack_require__(35); /** * Removes all key-value entries from the hash. * * @private * @name clear * @memberOf Hash */ function hashClear() { this.__data__ = nativeCreate ? nativeCreate(null) : {}; this.size = 0; } module.exports = hashClear; /***/ }), /* 162 */ /***/ (function(module, exports) { /** * Removes `key` and its value from the hash. * * @private * @name delete * @memberOf Hash * @param {Object} hash The hash to modify. * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function hashDelete(key) { var result = this.has(key) && delete this.__data__[key]; this.size -= result ? 1 : 0; return result; } module.exports = hashDelete; /***/ }), /* 163 */ /***/ (function(module, exports, __webpack_require__) { var nativeCreate = __webpack_require__(35); /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Gets the hash value for `key`. * * @private * @name get * @memberOf Hash * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function hashGet(key) { var data = this.__data__; if (nativeCreate) { var result = data[key]; return result === HASH_UNDEFINED ? undefined : result; } return hasOwnProperty.call(data, key) ? data[key] : undefined; } module.exports = hashGet; /***/ }), /* 164 */ /***/ (function(module, exports, __webpack_require__) { var nativeCreate = __webpack_require__(35); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Checks if a hash value for `key` exists. * * @private * @name has * @memberOf Hash * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function hashHas(key) { var data = this.__data__; return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); } module.exports = hashHas; /***/ }), /* 165 */ /***/ (function(module, exports, __webpack_require__) { var nativeCreate = __webpack_require__(35); /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; /** * Sets the hash `key` to `value`. * * @private * @name set * @memberOf Hash * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the hash instance. */ function hashSet(key, value) { var data = this.__data__; this.size += this.has(key) ? 0 : 1; data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value; return this; } module.exports = hashSet; /***/ }), /* 166 */ /***/ (function(module, exports, __webpack_require__) { var getMapData = __webpack_require__(36); /** * Removes `key` and its value from the map. * * @private * @name delete * @memberOf MapCache * @param {string} key The key of the value to remove. * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ function mapCacheDelete(key) { var result = getMapData(this, key)['delete'](key); this.size -= result ? 1 : 0; return result; } module.exports = mapCacheDelete; /***/ }), /* 167 */ /***/ (function(module, exports) { 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; }; /** * Checks if `value` is suitable for use as unique object key. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is suitable, else `false`. */ function isKeyable(value) { var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null; } module.exports = isKeyable; /***/ }), /* 168 */ /***/ (function(module, exports, __webpack_require__) { var getMapData = __webpack_require__(36); /** * Gets the map value for `key`. * * @private * @name get * @memberOf MapCache * @param {string} key The key of the value to get. * @returns {*} Returns the entry value. */ function mapCacheGet(key) { return getMapData(this, key).get(key); } module.exports = mapCacheGet; /***/ }), /* 169 */ /***/ (function(module, exports, __webpack_require__) { var getMapData = __webpack_require__(36); /** * Checks if a map value for `key` exists. * * @private * @name has * @memberOf MapCache * @param {string} key The key of the entry to check. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ function mapCacheHas(key) { return getMapData(this, key).has(key); } module.exports = mapCacheHas; /***/ }), /* 170 */ /***/ (function(module, exports, __webpack_require__) { var getMapData = __webpack_require__(36); /** * Sets the map `key` to `value`. * * @private * @name set * @memberOf MapCache * @param {string} key The key of the value to set. * @param {*} value The value to set. * @returns {Object} Returns the map cache instance. */ function mapCacheSet(key, value) { var data = getMapData(this, key), size = data.size; data.set(key, value); this.size += data.size == size ? 0 : 1; return this; } module.exports = mapCacheSet; /***/ }), /* 171 */ /***/ (function(module, exports, __webpack_require__) { var Stack = __webpack_require__(50), equalArrays = __webpack_require__(77), equalByTag = __webpack_require__(175), equalObjects = __webpack_require__(176), getTag = __webpack_require__(38), isArray = __webpack_require__(3), isBuffer = __webpack_require__(29), isTypedArray = __webpack_require__(46); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1; /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', objectTag = '[object Object]'; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * A specialized version of `baseIsEqual` for arrays and objects which performs * deep comparisons and tracks traversed objects enabling objects with circular * references to be compared. * * @private * @param {Object} object The object to compare. * @param {Object} other The other object to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} [stack] Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other); objTag = objTag == argsTag ? objectTag : objTag; othTag = othTag == argsTag ? objectTag : othTag; var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; if (isSameTag && isBuffer(object)) { if (!isBuffer(other)) { return false; } objIsArr = true; objIsObj = false; } if (isSameTag && !objIsObj) { stack || (stack = new Stack()); return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); } if (!(bitmask & COMPARE_PARTIAL_FLAG)) { var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); if (objIsWrapped || othIsWrapped) { var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other; stack || (stack = new Stack()); return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); } } if (!isSameTag) { return false; } stack || (stack = new Stack()); return equalObjects(object, other, bitmask, customizer, equalFunc, stack); } module.exports = baseIsEqualDeep; /***/ }), /* 172 */ /***/ (function(module, exports) { /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; /** * Adds `value` to the array cache. * * @private * @name add * @memberOf SetCache * @alias push * @param {*} value The value to cache. * @returns {Object} Returns the cache instance. */ function setCacheAdd(value) { this.__data__.set(value, HASH_UNDEFINED); return this; } module.exports = setCacheAdd; /***/ }), /* 173 */ /***/ (function(module, exports) { /** * Checks if `value` is in the array cache. * * @private * @name has * @memberOf SetCache * @param {*} value The value to search for. * @returns {number} Returns `true` if `value` is found, else `false`. */ function setCacheHas(value) { return this.__data__.has(value); } module.exports = setCacheHas; /***/ }), /* 174 */ /***/ (function(module, exports) { /** * A specialized version of `_.some` for arrays without support for iteratee * shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {boolean} Returns `true` if any element passes the predicate check, * else `false`. */ function arraySome(array, predicate) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (predicate(array[index], index, array)) { return true; } } return false; } module.exports = arraySome; /***/ }), /* 175 */ /***/ (function(module, exports, __webpack_require__) { var _Symbol = __webpack_require__(12), Uint8Array = __webpack_require__(80), eq = __webpack_require__(34), equalArrays = __webpack_require__(77), mapToArray = __webpack_require__(53), setToArray = __webpack_require__(20); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** `Object#toString` result references. */ var boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', mapTag = '[object Map]', numberTag = '[object Number]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', symbolTag = '[object Symbol]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]'; /** Used to convert symbols to primitives and strings. */ var symbolProto = _Symbol ? _Symbol.prototype : undefined, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; /** * A specialized version of `baseIsEqualDeep` for comparing objects of * the same `toStringTag`. * * **Note:** This function only supports comparing values with tags of * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. * * @private * @param {Object} object The object to compare. * @param {Object} other The other object to compare. * @param {string} tag The `toStringTag` of the objects to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { switch (tag) { case dataViewTag: if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { return false; } object = object.buffer; other = other.buffer; case arrayBufferTag: if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) { return false; } return true; case boolTag: case dateTag: case numberTag: // Coerce booleans to `1` or `0` and dates to milliseconds. // Invalid dates are coerced to `NaN`. return eq(+object, +other); case errorTag: return object.name == other.name && object.message == other.message; case regexpTag: case stringTag: // Coerce regexes to strings and treat strings, primitives and objects, // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring // for more details. return object == other + ''; case mapTag: var convert = mapToArray; case setTag: var isPartial = bitmask & COMPARE_PARTIAL_FLAG; convert || (convert = setToArray); if (object.size != other.size && !isPartial) { return false; } // Assume cyclic values are equal. var stacked = stack.get(object); if (stacked) { return stacked == other; } bitmask |= COMPARE_UNORDERED_FLAG; // Recursively compare objects (susceptible to call stack limits). stack.set(object, other); var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); stack['delete'](object); return result; case symbolTag: if (symbolValueOf) { return symbolValueOf.call(object) == symbolValueOf.call(other); } } return false; } module.exports = equalByTag; /***/ }), /* 176 */ /***/ (function(module, exports, __webpack_require__) { var getAllKeys = __webpack_require__(81); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * A specialized version of `baseIsEqualDeep` for objects with support for * partial deep comparisons. * * @private * @param {Object} object The object to compare. * @param {Object} other The other object to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. * @param {Function} customizer The function to customize comparisons. * @param {Function} equalFunc The function to determine equivalents of values. * @param {Object} stack Tracks traversed `object` and `other` objects. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length; if (objLength != othLength && !isPartial) { return false; } var index = objLength; while (index--) { var key = objProps[index]; if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { return false; } } // Assume cyclic values are equal. var stacked = stack.get(object); if (stacked && stack.get(other)) { return stacked == other; } var result = true; stack.set(object, other); stack.set(other, object); var skipCtor = isPartial; while (++index < objLength) { key = objProps[index]; var objValue = object[key], othValue = other[key]; if (customizer) { var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); } // Recursively compare objects (susceptible to call stack limits). if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) { result = false; break; } skipCtor || (skipCtor = key == 'constructor'); } if (result && !skipCtor) { var objCtor = object.constructor, othCtor = other.constructor; // Non `Object` object instances with different constructors are not equal. if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { result = false; } } stack['delete'](object); stack['delete'](other); return result; } module.exports = equalObjects; /***/ }), /* 177 */ /***/ (function(module, exports, __webpack_require__) { var getNative = __webpack_require__(13), root = __webpack_require__(4); /* Built-in method references that are verified to be native. */ var DataView = getNative(root, 'DataView'); module.exports = DataView; /***/ }), /* 178 */ /***/ (function(module, exports, __webpack_require__) { var getNative = __webpack_require__(13), root = __webpack_require__(4); /* Built-in method references that are verified to be native. */ var Promise = getNative(root, 'Promise'); module.exports = Promise; /***/ }), /* 179 */ /***/ (function(module, exports, __webpack_require__) { var getNative = __webpack_require__(13), root = __webpack_require__(4); /* Built-in method references that are verified to be native. */ var WeakMap = getNative(root, 'WeakMap'); module.exports = WeakMap; /***/ }), /* 180 */ /***/ (function(module, exports, __webpack_require__) { var isStrictComparable = __webpack_require__(86), keys = __webpack_require__(11); /** * Gets the property names, values, and compare flags of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the match data of `object`. */ function getMatchData(object) { var result = keys(object), length = result.length; while (length--) { var key = result[length], value = object[key]; result[length] = [key, value, isStrictComparable(value)]; } return result; } module.exports = getMatchData; /***/ }), /* 181 */ /***/ (function(module, exports, __webpack_require__) { var baseIsEqual = __webpack_require__(37), get = __webpack_require__(182), hasIn = __webpack_require__(88), isKey = __webpack_require__(57), isStrictComparable = __webpack_require__(86), matchesStrictComparable = __webpack_require__(87), toKey = __webpack_require__(22); /** Used to compose bitmasks for value comparisons. */ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2; /** * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. * * @private * @param {string} path The path of the property to get. * @param {*} srcValue The value to match. * @returns {Function} Returns the new spec function. */ function baseMatchesProperty(path, srcValue) { if (isKey(path) && isStrictComparable(srcValue)) { return matchesStrictComparable(toKey(path), srcValue); } return function (object) { var objValue = get(object, path); return objValue === undefined && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); }; } module.exports = baseMatchesProperty; /***/ }), /* 182 */ /***/ (function(module, exports, __webpack_require__) { var baseGet = __webpack_require__(56); /** * Gets the value at `path` of `object`. If the resolved value is * `undefined`, the `defaultValue` is returned in its place. * * @static * @memberOf _ * @since 3.7.0 * @category Object * @param {Object} object The object to query. * @param {Array|string} path The path of the property to get. * @param {*} [defaultValue] The value returned for `undefined` resolved values. * @returns {*} Returns the resolved value. * @example * * var object = { 'a': [{ 'b': { 'c': 3 } }] }; * * _.get(object, 'a[0].b.c'); * // => 3 * * _.get(object, ['a', '0', 'b', 'c']); * // => 3 * * _.get(object, 'a.b.c', 'default'); * // => 'default' */ function get(object, path, defaultValue) { var result = object == null ? undefined : baseGet(object, path); return result === undefined ? defaultValue : result; } module.exports = get; /***/ }), /* 183 */ /***/ (function(module, exports, __webpack_require__) { var memoizeCapped = __webpack_require__(184); /** Used to match property names within property paths. */ var reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; /** Used to match backslashes in property paths. */ var reEscapeChar = /\\(\\)?/g; /** * Converts `string` to a property path array. * * @private * @param {string} string The string to convert. * @returns {Array} Returns the property path array. */ var stringToPath = memoizeCapped(function (string) { var result = []; if (reLeadingDot.test(string)) { result.push(''); } string.replace(rePropName, function (match, number, quote, string) { result.push(quote ? string.replace(reEscapeChar, '$1') : number || match); }); return result; }); module.exports = stringToPath; /***/ }), /* 184 */ /***/ (function(module, exports, __webpack_require__) { var memoize = __webpack_require__(185); /** Used as the maximum memoize cache size. */ var MAX_MEMOIZE_SIZE = 500; /** * A specialized version of `_.memoize` which clears the memoized function's * cache when it exceeds `MAX_MEMOIZE_SIZE`. * * @private * @param {Function} func The function to have its output memoized. * @returns {Function} Returns the new memoized function. */ function memoizeCapped(func) { var result = memoize(func, function (key) { if (cache.size === MAX_MEMOIZE_SIZE) { cache.clear(); } return key; }); var cache = result.cache; return result; } module.exports = memoizeCapped; /***/ }), /* 185 */ /***/ (function(module, exports, __webpack_require__) { var MapCache = __webpack_require__(52); /** Error message constants. */ var FUNC_ERROR_TEXT = 'Expected a function'; /** * Creates a function that memoizes the result of `func`. If `resolver` is * provided, it determines the cache key for storing the result based on the * arguments provided to the memoized function. By default, the first argument * provided to the memoized function is used as the map cache key. The `func` * is invoked with the `this` binding of the memoized function. * * **Note:** The cache is exposed as the `cache` property on the memoized * function. Its creation may be customized by replacing the `_.memoize.Cache` * constructor with one whose instances implement the * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) * method interface of `clear`, `delete`, `get`, `has`, and `set`. * * @static * @memberOf _ * @since 0.1.0 * @category Function * @param {Function} func The function to have its output memoized. * @param {Function} [resolver] The function to resolve the cache key. * @returns {Function} Returns the new memoized function. * @example * * var object = { 'a': 1, 'b': 2 }; * var other = { 'c': 3, 'd': 4 }; * * var values = _.memoize(_.values); * values(object); * // => [1, 2] * * values(other); * // => [3, 4] * * object.a = 2; * values(object); * // => [1, 2] * * // Modify the result cache. * values.cache.set(object, ['a', 'b']); * values(object); * // => ['a', 'b'] * * // Replace `_.memoize.Cache`. * _.memoize.Cache = WeakMap; */ function memoize(func, resolver) { if (typeof func != 'function' || resolver != null && typeof resolver != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } var memoized = function memoized() { var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache; if (cache.has(key)) { return cache.get(key); } var result = func.apply(this, args); memoized.cache = cache.set(key, result) || cache; return result; }; memoized.cache = new (memoize.Cache || MapCache)(); return memoized; } // Expose `MapCache`. memoize.Cache = MapCache; module.exports = memoize; /***/ }), /* 186 */ /***/ (function(module, exports, __webpack_require__) { var _Symbol = __webpack_require__(12), arrayMap = __webpack_require__(49), isArray = __webpack_require__(3), isSymbol = __webpack_require__(21); /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0; /** Used to convert symbols to primitives and strings. */ var symbolProto = _Symbol ? _Symbol.prototype : undefined, symbolToString = symbolProto ? symbolProto.toString : undefined; /** * The base implementation of `_.toString` which doesn't convert nullish * values to empty strings. * * @private * @param {*} value The value to process. * @returns {string} Returns the string. */ function baseToString(value) { // Exit early for strings to avoid a performance hit in some environments. if (typeof value == 'string') { return value; } if (isArray(value)) { // Recursively convert values (susceptible to call stack limits). return arrayMap(value, baseToString) + ''; } if (isSymbol(value)) { return symbolToString ? symbolToString.call(value) : ''; } var result = value + ''; return result == '0' && 1 / value == -INFINITY ? '-0' : result; } module.exports = baseToString; /***/ }), /* 187 */ /***/ (function(module, exports) { /** * The base implementation of `_.hasIn` without support for deep paths. * * @private * @param {Object} [object] The object to query. * @param {Array|string} key The key to check. * @returns {boolean} Returns `true` if `key` exists, else `false`. */ function baseHasIn(object, key) { return object != null && key in Object(object); } module.exports = baseHasIn; /***/ }), /* 188 */ /***/ (function(module, exports, __webpack_require__) { var castPath = __webpack_require__(39), isArguments = __webpack_require__(28), isArray = __webpack_require__(3), isIndex = __webpack_require__(30), isLength = __webpack_require__(47), toKey = __webpack_require__(22); /** * Checks if `path` exists on `object`. * * @private * @param {Object} object The object to query. * @param {Array|string} path The path to check. * @param {Function} hasFunc The function to check properties. * @returns {boolean} Returns `true` if `path` exists, else `false`. */ function hasPath(object, path, hasFunc) { path = castPath(path, object); var index = -1, length = path.length, result = false; while (++index < length) { var key = toKey(path[index]); if (!(result = object != null && hasFunc(object, key))) { break; } object = object[key]; } if (result || ++index != length) { return result; } length = object == null ? 0 : object.length; return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object)); } module.exports = hasPath; /***/ }), /* 189 */ /***/ (function(module, exports, __webpack_require__) { var baseProperty = __webpack_require__(190), basePropertyDeep = __webpack_require__(191), isKey = __webpack_require__(57), toKey = __webpack_require__(22); /** * Creates a function that returns the value at `path` of a given object. * * @static * @memberOf _ * @since 2.4.0 * @category Util * @param {Array|string} path The path of the property to get. * @returns {Function} Returns the new accessor function. * @example * * var objects = [ * { 'a': { 'b': 2 } }, * { 'a': { 'b': 1 } } * ]; * * _.map(objects, _.property('a.b')); * // => [2, 1] * * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); * // => [1, 2] */ function property(path) { return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); } module.exports = property; /***/ }), /* 190 */ /***/ (function(module, exports) { /** * The base implementation of `_.property` without support for deep paths. * * @private * @param {string} key The key of the property to get. * @returns {Function} Returns the new accessor function. */ function baseProperty(key) { return function (object) { return object == null ? undefined : object[key]; }; } module.exports = baseProperty; /***/ }), /* 191 */ /***/ (function(module, exports, __webpack_require__) { var baseGet = __webpack_require__(56); /** * A specialized version of `baseProperty` which supports deep paths. * * @private * @param {Array|string} path The path of the property to get. * @returns {Function} Returns the new accessor function. */ function basePropertyDeep(path) { return function (object) { return baseGet(object, path); }; } module.exports = basePropertyDeep; /***/ }), /* 192 */ /***/ (function(module, exports, __webpack_require__) { var baseEach = __webpack_require__(27), isArrayLike = __webpack_require__(8); /** * The base implementation of `_.map` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the new mapped array. */ function baseMap(collection, iteratee) { var index = -1, result = isArrayLike(collection) ? Array(collection.length) : []; baseEach(collection, function (value, key, collection) { result[++index] = iteratee(value, key, collection); }); return result; } module.exports = baseMap; /***/ }), /* 193 */ /***/ (function(module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(6), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var numberTag = '[object Number]'; /** * Checks if `value` is classified as a `Number` primitive or object. * * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are * classified as numbers, use the `_.isFinite` method. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a number, else `false`. * @example * * _.isNumber(3); * // => true * * _.isNumber(Number.MIN_VALUE); * // => true * * _.isNumber(Infinity); * // => true * * _.isNumber('3'); * // => false */ function isNumber(value) { return typeof value == 'number' || isObjectLike(value) && baseGetTag(value) == numberTag; } module.exports = isNumber; /***/ }), /* 194 */ /***/ (function(module, exports, __webpack_require__) { var root = __webpack_require__(4); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeIsFinite = root.isFinite; /** * Checks if `value` is a finite primitive number. * * **Note:** This method is based on * [`Number.isFinite`](https://mdn.io/Number/isFinite). * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. * @example * * _.isFinite(3); * // => true * * _.isFinite(Number.MIN_VALUE); * // => true * * _.isFinite(Infinity); * // => false * * _.isFinite('3'); * // => false */ function isFinite(value) { return typeof value == 'number' && nativeIsFinite(value); } module.exports = isFinite; /***/ }), /* 195 */ /***/ (function(module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(6), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var boolTag = '[object Boolean]'; /** * Checks if `value` is classified as a boolean primitive or object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. * @example * * _.isBoolean(false); * // => true * * _.isBoolean(null); * // => false */ function isBoolean(value) { return value === true || value === false || isObjectLike(value) && baseGetTag(value) == boolTag; } module.exports = isBoolean; /***/ }), /* 196 */ /***/ (function(module, exports, __webpack_require__) { var baseKeys = __webpack_require__(74), getTag = __webpack_require__(38), isArguments = __webpack_require__(28), isArray = __webpack_require__(3), isArrayLike = __webpack_require__(8), isBuffer = __webpack_require__(29), isPrototype = __webpack_require__(18), isTypedArray = __webpack_require__(46); /** `Object#toString` result references. */ var mapTag = '[object Map]', setTag = '[object Set]'; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Checks if `value` is an empty object, collection, map, or set. * * Objects are considered empty if they have no own enumerable string keyed * properties. * * Array-like values such as `arguments` objects, arrays, buffers, strings, or * jQuery-like collections are considered empty if they have a `length` of `0`. * Similarly, maps and sets are considered empty if they have a `size` of `0`. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is empty, else `false`. * @example * * _.isEmpty(null); * // => true * * _.isEmpty(true); * // => true * * _.isEmpty(1); * // => true * * _.isEmpty([1, 2, 3]); * // => false * * _.isEmpty({ 'a': 1 }); * // => false */ function isEmpty(value) { if (value == null) { return true; } if (isArrayLike(value) && (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || isBuffer(value) || isTypedArray(value) || isArguments(value))) { return !value.length; } var tag = getTag(value); if (tag == mapTag || tag == setTag) { return !value.size; } if (isPrototype(value)) { return !baseKeys(value).length; } for (var key in value) { if (hasOwnProperty.call(value, key)) { return false; } } return true; } module.exports = isEmpty; /***/ }), /* 197 */ /***/ (function(module, exports, __webpack_require__) { var createCaseFirst = __webpack_require__(90); /** * Converts the first character of `string` to lower case. * * @static * @memberOf _ * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the converted string. * @example * * _.lowerFirst('Fred'); * // => 'fred' * * _.lowerFirst('FRED'); * // => 'fRED' */ var lowerFirst = createCaseFirst('toLowerCase'); module.exports = lowerFirst; /***/ }), /* 198 */ /***/ (function(module, exports, __webpack_require__) { var baseSlice = __webpack_require__(199); /** * Casts `array` to a slice if it's needed. * * @private * @param {Array} array The array to inspect. * @param {number} start The start position. * @param {number} [end=array.length] The end position. * @returns {Array} Returns the cast slice. */ function castSlice(array, start, end) { var length = array.length; end = end === undefined ? length : end; return !start && end >= length ? array : baseSlice(array, start, end); } module.exports = castSlice; /***/ }), /* 199 */ /***/ (function(module, exports) { /** * The base implementation of `_.slice` without an iteratee call guard. * * @private * @param {Array} array The array to slice. * @param {number} [start=0] The start position. * @param {number} [end=array.length] The end position. * @returns {Array} Returns the slice of `array`. */ function baseSlice(array, start, end) { var index = -1, length = array.length; if (start < 0) { start = -start > length ? 0 : length + start; } end = end > length ? length : end; if (end < 0) { end += length; } length = start > end ? 0 : end - start >>> 0; start >>>= 0; var result = Array(length); while (++index < length) { result[index] = array[index + start]; } return result; } module.exports = baseSlice; /***/ }), /* 200 */ /***/ (function(module, exports) { /** * Converts an ASCII `string` to an array. * * @private * @param {string} string The string to convert. * @returns {Array} Returns the converted array. */ function asciiToArray(string) { return string.split(''); } module.exports = asciiToArray; /***/ }), /* 201 */ /***/ (function(module, exports) { /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', rsComboMarksRange = '\\u0300-\\u036f', reComboHalfMarksRange = '\\ufe20-\\ufe2f', rsComboSymbolsRange = '\\u20d0-\\u20ff', rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = '\\ufe0e\\ufe0f'; /** Used to compose unicode capture groups. */ var rsAstral = '[' + rsAstralRange + ']', rsCombo = '[' + rsComboRange + ']', rsFitz = '\\ud83c[\\udffb-\\udfff]', rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', rsNonAstral = '[^' + rsAstralRange + ']', rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', rsZWJ = '\\u200d'; /** Used to compose unicode regexes. */ var reOptMod = rsModifier + '?', rsOptVar = '[' + rsVarRange + ']?', rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', rsSeq = rsOptVar + reOptMod + rsOptJoin, rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); /** * Converts a Unicode `string` to an array. * * @private * @param {string} string The string to convert. * @returns {Array} Returns the converted array. */ function unicodeToArray(string) { return string.match(reUnicode) || []; } module.exports = unicodeToArray; /***/ }), /* 202 */ /***/ (function(module, exports, __webpack_require__) { var createCaseFirst = __webpack_require__(90); /** * Converts the first character of `string` to upper case. * * @static * @memberOf _ * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the converted string. * @example * * _.upperFirst('fred'); * // => 'Fred' * * _.upperFirst('FRED'); * // => 'FRED' */ var upperFirst = createCaseFirst('toUpperCase'); module.exports = upperFirst; /***/ }), /* 203 */ /***/ (function(module, exports, __webpack_require__) { var createCompounder = __webpack_require__(204); /** * Converts `string`, as space separated words, to upper case. * * @static * @memberOf _ * @since 4.0.0 * @category String * @param {string} [string=''] The string to convert. * @returns {string} Returns the upper cased string. * @example * * _.upperCase('--foo-bar'); * // => 'FOO BAR' * * _.upperCase('fooBar'); * // => 'FOO BAR' * * _.upperCase('__foo_bar__'); * // => 'FOO BAR' */ var upperCase = createCompounder(function (result, word, index) { return result + (index ? ' ' : '') + word.toUpperCase(); }); module.exports = upperCase; /***/ }), /* 204 */ /***/ (function(module, exports, __webpack_require__) { var arrayReduce = __webpack_require__(58), deburr = __webpack_require__(205), words = __webpack_require__(208); /** Used to compose unicode capture groups. */ var rsApos = '[\'\u2019]'; /** Used to match apostrophes. */ var reApos = RegExp(rsApos, 'g'); /** * Creates a function like `_.camelCase`. * * @private * @param {Function} callback The function to combine each word. * @returns {Function} Returns the new compounder function. */ function createCompounder(callback) { return function (string) { return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); }; } module.exports = createCompounder; /***/ }), /* 205 */ /***/ (function(module, exports, __webpack_require__) { var deburrLetter = __webpack_require__(206), toString = __webpack_require__(15); /** Used to match Latin Unicode letters (excluding mathematical operators). */ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; /** Used to compose unicode character classes. */ var rsComboMarksRange = '\\u0300-\\u036f', reComboHalfMarksRange = '\\ufe20-\\ufe2f', rsComboSymbolsRange = '\\u20d0-\\u20ff', rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange; /** Used to compose unicode capture groups. */ var rsCombo = '[' + rsComboRange + ']'; /** * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). */ var reComboMark = RegExp(rsCombo, 'g'); /** * Deburrs `string` by converting * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) * letters to basic Latin letters and removing * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). * * @static * @memberOf _ * @since 3.0.0 * @category String * @param {string} [string=''] The string to deburr. * @returns {string} Returns the deburred string. * @example * * _.deburr('déjà vu'); * // => 'deja vu' */ function deburr(string) { string = toString(string); return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); } module.exports = deburr; /***/ }), /* 206 */ /***/ (function(module, exports, __webpack_require__) { var basePropertyOf = __webpack_require__(207); /** Used to map Latin Unicode letters to basic Latin letters. */ var deburredLetters = { // Latin-1 Supplement block. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', '\xc7': 'C', '\xe7': 'c', '\xd0': 'D', '\xf0': 'd', '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', '\xd1': 'N', '\xf1': 'n', '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', '\xc6': 'Ae', '\xe6': 'ae', '\xde': 'Th', '\xfe': 'th', '\xdf': 'ss', // Latin Extended-A block. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', '\u0106': 'C', '\u0108': 'C', '\u010A': 'C', '\u010C': 'C', '\u0107': 'c', '\u0109': 'c', '\u010B': 'c', '\u010D': 'c', '\u010E': 'D', '\u0110': 'D', '\u010F': 'd', '\u0111': 'd', '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011A': 'E', '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011B': 'e', '\u011C': 'G', '\u011E': 'G', '\u0120': 'G', '\u0122': 'G', '\u011D': 'g', '\u011F': 'g', '\u0121': 'g', '\u0123': 'g', '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', '\u0128': 'I', '\u012A': 'I', '\u012C': 'I', '\u012E': 'I', '\u0130': 'I', '\u0129': 'i', '\u012B': 'i', '\u012D': 'i', '\u012F': 'i', '\u0131': 'i', '\u0134': 'J', '\u0135': 'j', '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', '\u0139': 'L', '\u013B': 'L', '\u013D': 'L', '\u013F': 'L', '\u0141': 'L', '\u013A': 'l', '\u013C': 'l', '\u013E': 'l', '\u0140': 'l', '\u0142': 'l', '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014A': 'N', '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014B': 'n', '\u014C': 'O', '\u014E': 'O', '\u0150': 'O', '\u014D': 'o', '\u014F': 'o', '\u0151': 'o', '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', '\u015A': 'S', '\u015C': 'S', '\u015E': 'S', '\u0160': 'S', '\u015B': 's', '\u015D': 's', '\u015F': 's', '\u0161': 's', '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', '\u0163': 't', '\u0165': 't', '\u0167': 't', '\u0168': 'U', '\u016A': 'U', '\u016C': 'U', '\u016E': 'U', '\u0170': 'U', '\u0172': 'U', '\u0169': 'u', '\u016B': 'u', '\u016D': 'u', '\u016F': 'u', '\u0171': 'u', '\u0173': 'u', '\u0174': 'W', '\u0175': 'w', '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', '\u0179': 'Z', '\u017B': 'Z', '\u017D': 'Z', '\u017A': 'z', '\u017C': 'z', '\u017E': 'z', '\u0132': 'IJ', '\u0133': 'ij', '\u0152': 'Oe', '\u0153': 'oe', '\u0149': "'n", '\u017F': 's' }; /** * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A * letters to basic Latin letters. * * @private * @param {string} letter The matched letter to deburr. * @returns {string} Returns the deburred letter. */ var deburrLetter = basePropertyOf(deburredLetters); module.exports = deburrLetter; /***/ }), /* 207 */ /***/ (function(module, exports) { /** * The base implementation of `_.propertyOf` without support for deep paths. * * @private * @param {Object} object The object to query. * @returns {Function} Returns the new accessor function. */ function basePropertyOf(object) { return function (key) { return object == null ? undefined : object[key]; }; } module.exports = basePropertyOf; /***/ }), /* 208 */ /***/ (function(module, exports, __webpack_require__) { var asciiWords = __webpack_require__(209), hasUnicodeWord = __webpack_require__(210), toString = __webpack_require__(15), unicodeWords = __webpack_require__(211); /** * Splits `string` into an array of its words. * * @static * @memberOf _ * @since 3.0.0 * @category String * @param {string} [string=''] The string to inspect. * @param {RegExp|string} [pattern] The pattern to match words. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {Array} Returns the words of `string`. * @example * * _.words('fred, barney, & pebbles'); * // => ['fred', 'barney', 'pebbles'] * * _.words('fred, barney, & pebbles', /[^, ]+/g); * // => ['fred', 'barney', '&', 'pebbles'] */ function words(string, pattern, guard) { string = toString(string); pattern = guard ? undefined : pattern; if (pattern === undefined) { return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); } return string.match(pattern) || []; } module.exports = words; /***/ }), /* 209 */ /***/ (function(module, exports) { /** Used to match words composed of alphanumeric characters. */ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; /** * Splits an ASCII `string` into an array of its words. * * @private * @param {string} The string to inspect. * @returns {Array} Returns the words of `string`. */ function asciiWords(string) { return string.match(reAsciiWord) || []; } module.exports = asciiWords; /***/ }), /* 210 */ /***/ (function(module, exports) { /** Used to detect strings that need a more robust regexp to match words. */ var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; /** * Checks if `string` contains a word composed of Unicode symbols. * * @private * @param {string} string The string to inspect. * @returns {boolean} Returns `true` if a word is found, else `false`. */ function hasUnicodeWord(string) { return reHasUnicodeWord.test(string); } module.exports = hasUnicodeWord; /***/ }), /* 211 */ /***/ (function(module, exports) { /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', rsComboMarksRange = '\\u0300-\\u036f', reComboHalfMarksRange = '\\ufe20-\\ufe2f', rsComboSymbolsRange = '\\u20d0-\\u20ff', rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsDingbatRange = '\\u2700-\\u27bf', rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', rsPunctuationRange = '\\u2000-\\u206f', rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', rsVarRange = '\\ufe0e\\ufe0f', rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; /** Used to compose unicode capture groups. */ var rsApos = '[\'\u2019]', rsBreak = '[' + rsBreakRange + ']', rsCombo = '[' + rsComboRange + ']', rsDigits = '\\d+', rsDingbat = '[' + rsDingbatRange + ']', rsLower = '[' + rsLowerRange + ']', rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', rsFitz = '\\ud83c[\\udffb-\\udfff]', rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', rsNonAstral = '[^' + rsAstralRange + ']', rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', rsUpper = '[' + rsUpperRange + ']', rsZWJ = '\\u200d'; /** Used to compose unicode regexes. */ var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', reOptMod = rsModifier + '?', rsOptVar = '[' + rsVarRange + ']?', rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)', rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)', rsSeq = rsOptVar + reOptMod + rsOptJoin, rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq; /** Used to match complex or compound words. */ var reUnicodeWord = RegExp([rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, rsUpper + '+' + rsOptContrUpper, rsOrdUpper, rsOrdLower, rsDigits, rsEmoji].join('|'), 'g'); /** * Splits a Unicode `string` into an array of its words. * * @private * @param {string} The string to inspect. * @returns {Array} Returns the words of `string`. */ function unicodeWords(string) { return string.match(reUnicodeWord) || []; } module.exports = unicodeWords; /***/ }), /* 212 */ /***/ (function(module, exports) { /** * Checks if `value` is `null`. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is `null`, else `false`. * @example * * _.isNull(null); * // => true * * _.isNull(void 0); * // => false */ function isNull(value) { return value === null; } module.exports = isNull; /***/ }), /* 213 */ /***/ (function(module, exports, __webpack_require__) { var baseIsDate = __webpack_require__(214), baseUnary = __webpack_require__(72), nodeUtil = __webpack_require__(73); /* Node.js helper references. */ var nodeIsDate = nodeUtil && nodeUtil.isDate; /** * Checks if `value` is classified as a `Date` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a date object, else `false`. * @example * * _.isDate(new Date); * // => true * * _.isDate('Mon April 23 2012'); * // => false */ var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; module.exports = isDate; /***/ }), /* 214 */ /***/ (function(module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(6), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var dateTag = '[object Date]'; /** * The base implementation of `_.isDate` without Node.js optimizations. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a date object, else `false`. */ function baseIsDate(value) { return isObjectLike(value) && baseGetTag(value) == dateTag; } module.exports = baseIsDate; /***/ }), /* 215 */ /***/ (function(module, exports, __webpack_require__) { var baseGetTag = __webpack_require__(6), getPrototype = __webpack_require__(59), isObjectLike = __webpack_require__(5); /** `Object#toString` result references. */ var objectTag = '[object Object]'; /** Used for built-in method references. */ var funcProto = Function.prototype, objectProto = Object.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** Used to infer the `Object` constructor. */ var objectCtorString = funcToString.call(Object); /** * Checks if `value` is a plain object, that is, an object created by the * `Object` constructor or one with a `[[Prototype]]` of `null`. * * @static * @memberOf _ * @since 0.8.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. * @example * * function Foo() { * this.a = 1; * } * * _.isPlainObject(new Foo); * // => false * * _.isPlainObject([1, 2, 3]); * // => false * * _.isPlainObject({ 'x': 0, 'y': 0 }); * // => true * * _.isPlainObject(Object.create(null)); * // => true */ function isPlainObject(value) { if (!isObjectLike(value) || baseGetTag(value) != objectTag) { return false; } var proto = getPrototype(value); if (proto === null) { return true; } var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString; } module.exports = isPlainObject; /***/ }), /* 216 */ /***/ (function(module, exports, __webpack_require__) { var _Symbol = __webpack_require__(12), copyArray = __webpack_require__(94), getTag = __webpack_require__(38), isArrayLike = __webpack_require__(8), isString = __webpack_require__(89), iteratorToArray = __webpack_require__(217), mapToArray = __webpack_require__(53), setToArray = __webpack_require__(20), stringToArray = __webpack_require__(92), values = __webpack_require__(218); /** `Object#toString` result references. */ var mapTag = '[object Map]', setTag = '[object Set]'; /** Built-in value references. */ var symIterator = _Symbol ? _Symbol.iterator : undefined; /** * Converts `value` to an array. * * @static * @since 0.1.0 * @memberOf _ * @category Lang * @param {*} value The value to convert. * @returns {Array} Returns the converted array. * @example * * _.toArray({ 'a': 1, 'b': 2 }); * // => [1, 2] * * _.toArray('abc'); * // => ['a', 'b', 'c'] * * _.toArray(1); * // => [] * * _.toArray(null); * // => [] */ function toArray(value) { if (!value) { return []; } if (isArrayLike(value)) { return isString(value) ? stringToArray(value) : copyArray(value); } if (symIterator && value[symIterator]) { return iteratorToArray(value[symIterator]()); } var tag = getTag(value), func = tag == mapTag ? mapToArray : tag == setTag ? setToArray : values; return func(value); } module.exports = toArray; /***/ }), /* 217 */ /***/ (function(module, exports) { /** * Converts `iterator` to an array. * * @private * @param {Object} iterator The iterator to convert. * @returns {Array} Returns the converted array. */ function iteratorToArray(iterator) { var data, result = []; while (!(data = iterator.next()).done) { result.push(data.value); } return result; } module.exports = iteratorToArray; /***/ }), /* 218 */ /***/ (function(module, exports, __webpack_require__) { var baseValues = __webpack_require__(219), keys = __webpack_require__(11); /** * Creates an array of the own enumerable string keyed property values of `object`. * * **Note:** Non-object values are coerced to objects. * * @static * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The object to query. * @returns {Array} Returns the array of property values. * @example * * function Foo() { * this.a = 1; * this.b = 2; * } * * Foo.prototype.c = 3; * * _.values(new Foo); * // => [1, 2] (iteration order is not guaranteed) * * _.values('hi'); * // => ['h', 'i'] */ function values(object) { return object == null ? [] : baseValues(object, keys(object)); } module.exports = values; /***/ }), /* 219 */ /***/ (function(module, exports, __webpack_require__) { var arrayMap = __webpack_require__(49); /** * The base implementation of `_.values` and `_.valuesIn` which creates an * array of `object` property values corresponding to the property names * of `props`. * * @private * @param {Object} object The object to query. * @param {Array} props The property names to get values for. * @returns {Object} Returns the array of property values. */ function baseValues(object, props) { return arrayMap(props, function (key) { return object[key]; }); } module.exports = baseValues; /***/ }), /* 220 */ /***/ (function(module, exports, __webpack_require__) { var baseIndexOf = __webpack_require__(95), toInteger = __webpack_require__(96); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeMax = Math.max; /** * Gets the index at which the first occurrence of `value` is found in `array` * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. If `fromIndex` is negative, it's used as the * offset from the end of `array`. * * @static * @memberOf _ * @since 0.1.0 * @category Array * @param {Array} array The array to inspect. * @param {*} value The value to search for. * @param {number} [fromIndex=0] The index to search from. * @returns {number} Returns the index of the matched value, else `-1`. * @example * * _.indexOf([1, 2, 1, 2], 2); * // => 1 * * // Search from the `fromIndex`. * _.indexOf([1, 2, 1, 2], 2, 2); * // => 3 */ function indexOf(array, value, fromIndex) { var length = array == null ? 0 : array.length; if (!length) { return -1; } var index = fromIndex == null ? 0 : toInteger(fromIndex); if (index < 0) { index = nativeMax(length + index, 0); } return baseIndexOf(array, value, index); } module.exports = indexOf; /***/ }), /* 221 */ /***/ (function(module, exports) { /** * The base implementation of `_.findIndex` and `_.findLastIndex` without * support for iteratee shorthands. * * @private * @param {Array} array The array to inspect. * @param {Function} predicate The function invoked per iteration. * @param {number} fromIndex The index to search from. * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {number} Returns the index of the matched value, else `-1`. */ function baseFindIndex(array, predicate, fromIndex, fromRight) { var length = array.length, index = fromIndex + (fromRight ? 1 : -1); while (fromRight ? index-- : ++index < length) { if (predicate(array[index], index, array)) { return index; } } return -1; } module.exports = baseFindIndex; /***/ }), /* 222 */ /***/ (function(module, exports) { /** * The base implementation of `_.isNaN` without support for number objects. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. */ function baseIsNaN(value) { return value !== value; } module.exports = baseIsNaN; /***/ }), /* 223 */ /***/ (function(module, exports) { /** * A specialized version of `_.indexOf` which performs strict equality * comparisons of values, i.e. `===`. * * @private * @param {Array} array The array to inspect. * @param {*} value The value to search for. * @param {number} fromIndex The index to search from. * @returns {number} Returns the index of the matched value, else `-1`. */ function strictIndexOf(array, value, fromIndex) { var index = fromIndex - 1, length = array.length; while (++index < length) { if (array[index] === value) { return index; } } return -1; } module.exports = strictIndexOf; /***/ }), /* 224 */ /***/ (function(module, exports, __webpack_require__) { var toNumber = __webpack_require__(97); /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0, MAX_INTEGER = 1.7976931348623157e+308; /** * Converts `value` to a finite number. * * @static * @memberOf _ * @since 4.12.0 * @category Lang * @param {*} value The value to convert. * @returns {number} Returns the converted number. * @example * * _.toFinite(3.2); * // => 3.2 * * _.toFinite(Number.MIN_VALUE); * // => 5e-324 * * _.toFinite(Infinity); * // => 1.7976931348623157e+308 * * _.toFinite('3.2'); * // => 3.2 */ function toFinite(value) { if (!value) { return value === 0 ? value : 0; } value = toNumber(value); if (value === INFINITY || value === -INFINITY) { var sign = value < 0 ? -1 : 1; return sign * MAX_INTEGER; } return value === value ? value : 0; } module.exports = toFinite; /***/ }), /* 225 */ /***/ (function(module, exports, __webpack_require__) { var baseRest = __webpack_require__(99), isIterateeCall = __webpack_require__(230); /** * Creates a function like `_.assign`. * * @private * @param {Function} assigner The function to assign values. * @returns {Function} Returns the new assigner function. */ function createAssigner(assigner) { return baseRest(function (object, sources) { var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined, guard = length > 2 ? sources[2] : undefined; customizer = assigner.length > 3 && typeof customizer == 'function' ? (length--, customizer) : undefined; if (guard && isIterateeCall(sources[0], sources[1], guard)) { customizer = length < 3 ? undefined : customizer; length = 1; } object = Object(object); while (++index < length) { var source = sources[index]; if (source) { assigner(object, source, index, customizer); } } return object; }); } module.exports = createAssigner; /***/ }), /* 226 */ /***/ (function(module, exports) { /** * A faster alternative to `Function#apply`, this function invokes `func` * with the `this` binding of `thisArg` and the arguments of `args`. * * @private * @param {Function} func The function to invoke. * @param {*} thisArg The `this` binding of `func`. * @param {Array} args The arguments to invoke `func` with. * @returns {*} Returns the result of `func`. */ function apply(func, thisArg, args) { switch (args.length) { case 0: return func.call(thisArg); case 1: return func.call(thisArg, args[0]); case 2: return func.call(thisArg, args[0], args[1]); case 3: return func.call(thisArg, args[0], args[1], args[2]); } return func.apply(thisArg, args); } module.exports = apply; /***/ }), /* 227 */ /***/ (function(module, exports, __webpack_require__) { var constant = __webpack_require__(228), defineProperty = __webpack_require__(98), identity = __webpack_require__(31); /** * The base implementation of `setToString` without support for hot loop shorting. * * @private * @param {Function} func The function to modify. * @param {Function} string The `toString` result. * @returns {Function} Returns `func`. */ var baseSetToString = !defineProperty ? identity : function (func, string) { return defineProperty(func, 'toString', { 'configurable': true, 'enumerable': false, 'value': constant(string), 'writable': true }); }; module.exports = baseSetToString; /***/ }), /* 228 */ /***/ (function(module, exports) { /** * Creates a function that returns `value`. * * @static * @memberOf _ * @since 2.4.0 * @category Util * @param {*} value The value to return from the new function. * @returns {Function} Returns the new constant function. * @example * * var objects = _.times(2, _.constant({ 'a': 1 })); * * console.log(objects); * // => [{ 'a': 1 }, { 'a': 1 }] * * console.log(objects[0] === objects[1]); * // => true */ function constant(value) { return function () { return value; }; } module.exports = constant; /***/ }), /* 229 */ /***/ (function(module, exports) { /** Used to detect hot functions by number of calls within a span of milliseconds. */ var HOT_COUNT = 800, HOT_SPAN = 16; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeNow = Date.now; /** * Creates a function that'll short out and invoke `identity` instead * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` * milliseconds. * * @private * @param {Function} func The function to restrict. * @returns {Function} Returns the new shortable function. */ function shortOut(func) { var count = 0, lastCalled = 0; return function () { var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled); lastCalled = stamp; if (remaining > 0) { if (++count >= HOT_COUNT) { return arguments[0]; } } else { count = 0; } return func.apply(undefined, arguments); }; } module.exports = shortOut; /***/ }), /* 230 */ /***/ (function(module, exports, __webpack_require__) { 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 eq = __webpack_require__(34), isArrayLike = __webpack_require__(8), isIndex = __webpack_require__(30), isObject = __webpack_require__(7); /** * Checks if the given arguments are from an iteratee call. * * @private * @param {*} value The potential iteratee value argument. * @param {*} index The potential iteratee index or key argument. * @param {*} object The potential iteratee object argument. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, * else `false`. */ function isIterateeCall(value, index, object) { if (!isObject(object)) { return false; } var type = typeof index === 'undefined' ? 'undefined' : _typeof(index); if (type == 'number' ? isArrayLike(object) && isIndex(index, object.length) : type == 'string' && index in object) { return eq(object[index], value); } return false; } module.exports = isIterateeCall; /***/ }), /* 231 */ /***/ (function(module, exports, __webpack_require__) { var baseAssignValue = __webpack_require__(61), createAggregator = __webpack_require__(232); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Creates an object composed of keys generated from the results of running * each element of `collection` thru `iteratee`. The order of grouped values * is determined by the order they occur in `collection`. The corresponding * value of each key is an array of elements responsible for generating the * key. The iteratee is invoked with one argument: (value). * * @static * @memberOf _ * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * * _.groupBy([6.1, 4.2, 6.3], Math.floor); * // => { '4': [4.2], '6': [6.1, 6.3] } * * // The `_.property` iteratee shorthand. * _.groupBy(['one', 'two', 'three'], 'length'); * // => { '3': ['one', 'two'], '5': ['three'] } */ var groupBy = createAggregator(function (result, value, key) { if (hasOwnProperty.call(result, key)) { result[key].push(value); } else { baseAssignValue(result, key, [value]); } }); module.exports = groupBy; /***/ }), /* 232 */ /***/ (function(module, exports, __webpack_require__) { var arrayAggregator = __webpack_require__(233), baseAggregator = __webpack_require__(234), baseIteratee = __webpack_require__(19), isArray = __webpack_require__(3); /** * Creates a function like `_.groupBy`. * * @private * @param {Function} setter The function to set accumulator values. * @param {Function} [initializer] The accumulator object initializer. * @returns {Function} Returns the new aggregator function. */ function createAggregator(setter, initializer) { return function (collection, iteratee) { var func = isArray(collection) ? arrayAggregator : baseAggregator, accumulator = initializer ? initializer() : {}; return func(collection, setter, baseIteratee(iteratee, 2), accumulator); }; } module.exports = createAggregator; /***/ }), /* 233 */ /***/ (function(module, exports) { /** * A specialized version of `baseAggregator` for arrays. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} setter The function to set `accumulator` values. * @param {Function} iteratee The iteratee to transform keys. * @param {Object} accumulator The initial aggregated object. * @returns {Function} Returns `accumulator`. */ function arrayAggregator(array, setter, iteratee, accumulator) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { var value = array[index]; setter(accumulator, value, iteratee(value), array); } return accumulator; } module.exports = arrayAggregator; /***/ }), /* 234 */ /***/ (function(module, exports, __webpack_require__) { var baseEach = __webpack_require__(27); /** * Aggregates elements of `collection` on `accumulator` with keys transformed * by `iteratee` and values set by `setter`. * * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} setter The function to set `accumulator` values. * @param {Function} iteratee The iteratee to transform keys. * @param {Object} accumulator The initial aggregated object. * @returns {Function} Returns `accumulator`. */ function baseAggregator(collection, setter, iteratee, accumulator) { baseEach(collection, function (value, key, collection) { setter(accumulator, value, iteratee(value), collection); }); return accumulator; } module.exports = baseAggregator; /***/ }), /* 235 */ /***/ (function(module, exports, __webpack_require__) { var Stack = __webpack_require__(50), arrayEach = __webpack_require__(69), assignValue = __webpack_require__(40), baseAssign = __webpack_require__(236), baseAssignIn = __webpack_require__(237), cloneBuffer = __webpack_require__(240), copyArray = __webpack_require__(94), copySymbols = __webpack_require__(241), copySymbolsIn = __webpack_require__(242), getAllKeys = __webpack_require__(81), getAllKeysIn = __webpack_require__(243), getTag = __webpack_require__(38), initCloneArray = __webpack_require__(244), initCloneByTag = __webpack_require__(245), initCloneObject = __webpack_require__(254), isArray = __webpack_require__(3), isBuffer = __webpack_require__(29), isObject = __webpack_require__(7), keys = __webpack_require__(11); /** Used to compose bitmasks for cloning. */ var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4; /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', symbolTag = '[object Symbol]', weakMapTag = '[object WeakMap]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; /** Used to identify `toStringTag` values supported by `_.clone`. */ var cloneableTags = {}; cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false; /** * The base implementation of `_.clone` and `_.cloneDeep` which tracks * traversed objects. * * @private * @param {*} value The value to clone. * @param {boolean} bitmask The bitmask flags. * 1 - Deep clone * 2 - Flatten inherited properties * 4 - Clone symbols * @param {Function} [customizer] The function to customize cloning. * @param {string} [key] The key of `value`. * @param {Object} [object] The parent object of `value`. * @param {Object} [stack] Tracks traversed objects and their clone counterparts. * @returns {*} Returns the cloned value. */ function baseClone(value, bitmask, customizer, key, object, stack) { var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG; if (customizer) { result = object ? customizer(value, key, object, stack) : customizer(value); } if (result !== undefined) { return result; } if (!isObject(value)) { return value; } var isArr = isArray(value); if (isArr) { result = initCloneArray(value); if (!isDeep) { return copyArray(value, result); } } else { var tag = getTag(value), isFunc = tag == funcTag || tag == genTag; if (isBuffer(value)) { return cloneBuffer(value, isDeep); } if (tag == objectTag || tag == argsTag || isFunc && !object) { result = isFlat || isFunc ? {} : initCloneObject(value); if (!isDeep) { return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value)); } } else { if (!cloneableTags[tag]) { return object ? value : {}; } result = initCloneByTag(value, tag, baseClone, isDeep); } } // Check for circular references and return its corresponding clone. stack || (stack = new Stack()); var stacked = stack.get(value); if (stacked) { return stacked; } stack.set(value, result); var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys; var props = isArr ? undefined : keysFunc(value); arrayEach(props || value, function (subValue, key) { if (props) { key = subValue; subValue = value[key]; } // Recursively populate clone (susceptible to call stack limits). assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); }); return result; } module.exports = baseClone; /***/ }), /* 236 */ /***/ (function(module, exports, __webpack_require__) { var copyObject = __webpack_require__(23), keys = __webpack_require__(11); /** * The base implementation of `_.assign` without support for multiple sources * or `customizer` functions. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. * @returns {Object} Returns `object`. */ function baseAssign(object, source) { return object && copyObject(source, keys(source), object); } module.exports = baseAssign; /***/ }), /* 237 */ /***/ (function(module, exports, __webpack_require__) { var copyObject = __webpack_require__(23), keysIn = __webpack_require__(103); /** * The base implementation of `_.assignIn` without support for multiple sources * or `customizer` functions. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. * @returns {Object} Returns `object`. */ function baseAssignIn(object, source) { return object && copyObject(source, keysIn(source), object); } module.exports = baseAssignIn; /***/ }), /* 238 */ /***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(7), isPrototype = __webpack_require__(18), nativeKeysIn = __webpack_require__(239); /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function baseKeysIn(object) { if (!isObject(object)) { return nativeKeysIn(object); } var isProto = isPrototype(object), result = []; for (var key in object) { if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { result.push(key); } } return result; } module.exports = baseKeysIn; /***/ }), /* 239 */ /***/ (function(module, exports) { /** * This function is like * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) * except that it includes inherited enumerable properties. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function nativeKeysIn(object) { var result = []; if (object != null) { for (var key in Object(object)) { result.push(key); } } return result; } module.exports = nativeKeysIn; /***/ }), /* 240 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(module) {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 root = __webpack_require__(4); /** Detect free variable `exports`. */ var freeExports = ( false ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && ( false ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined, allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined; /** * Creates a clone of `buffer`. * * @private * @param {Buffer} buffer The buffer to clone. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Buffer} Returns the cloned buffer. */ function cloneBuffer(buffer, isDeep) { if (isDeep) { return buffer.slice(); } var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); buffer.copy(result); return result; } module.exports = cloneBuffer; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(26)(module))) /***/ }), /* 241 */ /***/ (function(module, exports, __webpack_require__) { var copyObject = __webpack_require__(23), getSymbols = __webpack_require__(55); /** * Copies own symbols of `source` to `object`. * * @private * @param {Object} source The object to copy symbols from. * @param {Object} [object={}] The object to copy symbols to. * @returns {Object} Returns `object`. */ function copySymbols(source, object) { return copyObject(source, getSymbols(source), object); } module.exports = copySymbols; /***/ }), /* 242 */ /***/ (function(module, exports, __webpack_require__) { var copyObject = __webpack_require__(23), getSymbolsIn = __webpack_require__(104); /** * Copies own and inherited symbols of `source` to `object`. * * @private * @param {Object} source The object to copy symbols from. * @param {Object} [object={}] The object to copy symbols to. * @returns {Object} Returns `object`. */ function copySymbolsIn(source, object) { return copyObject(source, getSymbolsIn(source), object); } module.exports = copySymbolsIn; /***/ }), /* 243 */ /***/ (function(module, exports, __webpack_require__) { var baseGetAllKeys = __webpack_require__(82), getSymbolsIn = __webpack_require__(104), keysIn = __webpack_require__(103); /** * Creates an array of own and inherited enumerable property names and * symbols of `object`. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names and symbols. */ function getAllKeysIn(object) { return baseGetAllKeys(object, keysIn, getSymbolsIn); } module.exports = getAllKeysIn; /***/ }), /* 244 */ /***/ (function(module, exports) { /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Initializes an array clone. * * @private * @param {Array} array The array to clone. * @returns {Array} Returns the initialized clone. */ function initCloneArray(array) { var length = array.length, result = array.constructor(length); // Add properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; } return result; } module.exports = initCloneArray; /***/ }), /* 245 */ /***/ (function(module, exports, __webpack_require__) { var cloneArrayBuffer = __webpack_require__(62), cloneDataView = __webpack_require__(246), cloneMap = __webpack_require__(247), cloneRegExp = __webpack_require__(249), cloneSet = __webpack_require__(250), cloneSymbol = __webpack_require__(252), cloneTypedArray = __webpack_require__(253); /** `Object#toString` result references. */ var boolTag = '[object Boolean]', dateTag = '[object Date]', mapTag = '[object Map]', numberTag = '[object Number]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', symbolTag = '[object Symbol]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; /** * Initializes an object clone based on its `toStringTag`. * * **Note:** This function only supports cloning values with tags of * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. * * @private * @param {Object} object The object to clone. * @param {string} tag The `toStringTag` of the object to clone. * @param {Function} cloneFunc The function to clone values. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the initialized clone. */ function initCloneByTag(object, tag, cloneFunc, isDeep) { var Ctor = object.constructor; switch (tag) { case arrayBufferTag: return cloneArrayBuffer(object); case boolTag: case dateTag: return new Ctor(+object); case dataViewTag: return cloneDataView(object, isDeep); case float32Tag:case float64Tag: case int8Tag:case int16Tag:case int32Tag: case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag: return cloneTypedArray(object, isDeep); case mapTag: return cloneMap(object, isDeep, cloneFunc); case numberTag: case stringTag: return new Ctor(object); case regexpTag: return cloneRegExp(object); case setTag: return cloneSet(object, isDeep, cloneFunc); case symbolTag: return cloneSymbol(object); } } module.exports = initCloneByTag; /***/ }), /* 246 */ /***/ (function(module, exports, __webpack_require__) { var cloneArrayBuffer = __webpack_require__(62); /** * Creates a clone of `dataView`. * * @private * @param {Object} dataView The data view to clone. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned data view. */ function cloneDataView(dataView, isDeep) { var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); } module.exports = cloneDataView; /***/ }), /* 247 */ /***/ (function(module, exports, __webpack_require__) { var addMapEntry = __webpack_require__(248), arrayReduce = __webpack_require__(58), mapToArray = __webpack_require__(53); /** Used to compose bitmasks for cloning. */ var CLONE_DEEP_FLAG = 1; /** * Creates a clone of `map`. * * @private * @param {Object} map The map to clone. * @param {Function} cloneFunc The function to clone values. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned map. */ function cloneMap(map, isDeep, cloneFunc) { var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map); return arrayReduce(array, addMapEntry, new map.constructor()); } module.exports = cloneMap; /***/ }), /* 248 */ /***/ (function(module, exports) { /** * Adds the key-value `pair` to `map`. * * @private * @param {Object} map The map to modify. * @param {Array} pair The key-value pair to add. * @returns {Object} Returns `map`. */ function addMapEntry(map, pair) { // Don't return `map.set` because it's not chainable in IE 11. map.set(pair[0], pair[1]); return map; } module.exports = addMapEntry; /***/ }), /* 249 */ /***/ (function(module, exports) { /** Used to match `RegExp` flags from their coerced string values. */ var reFlags = /\w*$/; /** * Creates a clone of `regexp`. * * @private * @param {Object} regexp The regexp to clone. * @returns {Object} Returns the cloned regexp. */ function cloneRegExp(regexp) { var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); result.lastIndex = regexp.lastIndex; return result; } module.exports = cloneRegExp; /***/ }), /* 250 */ /***/ (function(module, exports, __webpack_require__) { var addSetEntry = __webpack_require__(251), arrayReduce = __webpack_require__(58), setToArray = __webpack_require__(20); /** Used to compose bitmasks for cloning. */ var CLONE_DEEP_FLAG = 1; /** * Creates a clone of `set`. * * @private * @param {Object} set The set to clone. * @param {Function} cloneFunc The function to clone values. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned set. */ function cloneSet(set, isDeep, cloneFunc) { var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set); return arrayReduce(array, addSetEntry, new set.constructor()); } module.exports = cloneSet; /***/ }), /* 251 */ /***/ (function(module, exports) { /** * Adds `value` to `set`. * * @private * @param {Object} set The set to modify. * @param {*} value The value to add. * @returns {Object} Returns `set`. */ function addSetEntry(set, value) { // Don't return `set.add` because it's not chainable in IE 11. set.add(value); return set; } module.exports = addSetEntry; /***/ }), /* 252 */ /***/ (function(module, exports, __webpack_require__) { var _Symbol = __webpack_require__(12); /** Used to convert symbols to primitives and strings. */ var symbolProto = _Symbol ? _Symbol.prototype : undefined, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; /** * Creates a clone of the `symbol` object. * * @private * @param {Object} symbol The symbol object to clone. * @returns {Object} Returns the cloned symbol object. */ function cloneSymbol(symbol) { return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; } module.exports = cloneSymbol; /***/ }), /* 253 */ /***/ (function(module, exports, __webpack_require__) { var cloneArrayBuffer = __webpack_require__(62); /** * Creates a clone of `typedArray`. * * @private * @param {Object} typedArray The typed array to clone. * @param {boolean} [isDeep] Specify a deep clone. * @returns {Object} Returns the cloned typed array. */ function cloneTypedArray(typedArray, isDeep) { var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); } module.exports = cloneTypedArray; /***/ }), /* 254 */ /***/ (function(module, exports, __webpack_require__) { var baseCreate = __webpack_require__(255), getPrototype = __webpack_require__(59), isPrototype = __webpack_require__(18); /** * Initializes an object clone. * * @private * @param {Object} object The object to clone. * @returns {Object} Returns the initialized clone. */ function initCloneObject(object) { return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {}; } module.exports = initCloneObject; /***/ }), /* 255 */ /***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(7); /** Built-in value references. */ var objectCreate = Object.create; /** * The base implementation of `_.create` without support for assigning * properties to the created object. * * @private * @param {Object} proto The object to inherit from. * @returns {Object} Returns the new object. */ var baseCreate = function () { function object() {} return function (proto) { if (!isObject(proto)) { return {}; } if (objectCreate) { return objectCreate(proto); } object.prototype = proto; var result = new object(); object.prototype = undefined; return result; }; }(); module.exports = baseCreate; /***/ }), /* 256 */ /***/ (function(module, exports, __webpack_require__) { var baseExtremum = __webpack_require__(105), baseGt = __webpack_require__(257), baseIteratee = __webpack_require__(19); /** * This method is like `_.max` except that it accepts `iteratee` which is * invoked for each element in `array` to generate the criterion by which * the value is ranked. The iteratee is invoked with one argument: (value). * * @static * @memberOf _ * @since 4.0.0 * @category Math * @param {Array} array The array to iterate over. * @param {Function} [iteratee=_.identity] The iteratee invoked per element. * @returns {*} Returns the maximum value. * @example * * var objects = [{ 'n': 1 }, { 'n': 2 }]; * * _.maxBy(objects, function(o) { return o.n; }); * // => { 'n': 2 } * * // The `_.property` iteratee shorthand. * _.maxBy(objects, 'n'); * // => { 'n': 2 } */ function maxBy(array, iteratee) { return array && array.length ? baseExtremum(array, baseIteratee(iteratee, 2), baseGt) : undefined; } module.exports = maxBy; /***/ }), /* 257 */ /***/ (function(module, exports) { /** * The base implementation of `_.gt` which doesn't coerce arguments. * * @private * @param {*} value The value to compare. * @param {*} other The other value to compare. * @returns {boolean} Returns `true` if `value` is greater than `other`, * else `false`. */ function baseGt(value, other) { return value > other; } module.exports = baseGt; /***/ }), /* 258 */ /***/ (function(module, exports, __webpack_require__) { var baseExtremum = __webpack_require__(105), baseIteratee = __webpack_require__(19), baseLt = __webpack_require__(259); /** * This method is like `_.min` except that it accepts `iteratee` which is * invoked for each element in `array` to generate the criterion by which * the value is ranked. The iteratee is invoked with one argument: (value). * * @static * @memberOf _ * @since 4.0.0 * @category Math * @param {Array} array The array to iterate over. * @param {Function} [iteratee=_.identity] The iteratee invoked per element. * @returns {*} Returns the minimum value. * @example * * var objects = [{ 'n': 1 }, { 'n': 2 }]; * * _.minBy(objects, function(o) { return o.n; }); * // => { 'n': 1 } * * // The `_.property` iteratee shorthand. * _.minBy(objects, 'n'); * // => { 'n': 1 } */ function minBy(array, iteratee) { return array && array.length ? baseExtremum(array, baseIteratee(iteratee, 2), baseLt) : undefined; } module.exports = minBy; /***/ }), /* 259 */ /***/ (function(module, exports) { /** * The base implementation of `_.lt` which doesn't coerce arguments. * * @private * @param {*} value The value to compare. * @param {*} other The other value to compare. * @returns {boolean} Returns `true` if `value` is less than `other`, * else `false`. */ function baseLt(value, other) { return value < other; } module.exports = baseLt; /***/ }), /* 260 */ /***/ (function(module, exports, __webpack_require__) { var createRound = __webpack_require__(261); /** * Computes `number` rounded to `precision`. * * @static * @memberOf _ * @since 3.10.0 * @category Math * @param {number} number The number to round. * @param {number} [precision=0] The precision to round to. * @returns {number} Returns the rounded number. * @example * * _.round(4.006); * // => 4 * * _.round(4.006, 2); * // => 4.01 * * _.round(4060, -2); * // => 4100 */ var round = createRound('round'); module.exports = round; /***/ }), /* 261 */ /***/ (function(module, exports, __webpack_require__) { var toInteger = __webpack_require__(96), toNumber = __webpack_require__(97), toString = __webpack_require__(15); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeMin = Math.min; /** * Creates a function like `_.round`. * * @private * @param {string} methodName The name of the `Math` method to use when rounding. * @returns {Function} Returns the new round function. */ function createRound(methodName) { var func = Math[methodName]; return function (number, precision) { number = toNumber(number); precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); if (precision) { // Shift with exponential notation to avoid floating-point issues. // See [MDN](https://mdn.io/round#Examples) for more details. var pair = (toString(number) + 'e').split('e'), value = func(pair[0] + 'e' + (+pair[1] + precision)); pair = (toString(value) + 'e').split('e'); return +(pair[0] + 'e' + (+pair[1] - precision)); } return func(number); }; } module.exports = createRound; /***/ }), /* 262 */ /***/ (function(module, exports, __webpack_require__) { var arrayFilter = __webpack_require__(83), baseFilter = __webpack_require__(263), baseIteratee = __webpack_require__(19), isArray = __webpack_require__(3); /** * Iterates over elements of `collection`, returning an array of all elements * `predicate` returns truthy for. The predicate is invoked with three * arguments: (value, index|key, collection). * * **Note:** Unlike `_.remove`, this method returns a new array. * * @static * @memberOf _ * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. * @param {Function} [predicate=_.identity] The function invoked per iteration. * @returns {Array} Returns the new filtered array. * @see _.reject * @example * * var users = [ * { 'user': 'barney', 'age': 36, 'active': true }, * { 'user': 'fred', 'age': 40, 'active': false } * ]; * * _.filter(users, function(o) { return !o.active; }); * // => objects for ['fred'] * * // The `_.matches` iteratee shorthand. * _.filter(users, { 'age': 36, 'active': true }); * // => objects for ['barney'] * * // The `_.matchesProperty` iteratee shorthand. * _.filter(users, ['active', false]); * // => objects for ['fred'] * * // The `_.property` iteratee shorthand. * _.filter(users, 'active'); * // => objects for ['barney'] */ function filter(collection, predicate) { var func = isArray(collection) ? arrayFilter : baseFilter; return func(collection, baseIteratee(predicate, 3)); } module.exports = filter; /***/ }), /* 263 */ /***/ (function(module, exports, __webpack_require__) { var baseEach = __webpack_require__(27); /** * The base implementation of `_.filter` without support for iteratee shorthands. * * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {Array} Returns the new filtered array. */ function baseFilter(collection, predicate) { var result = []; baseEach(collection, function (value, index, collection) { if (predicate(value, index, collection)) { result.push(value); } }); return result; } module.exports = baseFilter; /***/ }), /* 264 */ /***/ (function(module, exports, __webpack_require__) { var baseIsEqual = __webpack_require__(37); /** * This method is like `_.isEqual` except that it accepts `customizer` which * is invoked to compare values. If `customizer` returns `undefined`, comparisons * are handled by the method instead. The `customizer` is invoked with up to * six arguments: (objValue, othValue [, index|key, object, other, stack]). * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. * @param {Function} [customizer] The function to customize comparisons. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * function isGreeting(value) { * return /^h(?:i|ello)$/.test(value); * } * * function customizer(objValue, othValue) { * if (isGreeting(objValue) && isGreeting(othValue)) { * return true; * } * } * * var array = ['hello', 'goodbye']; * var other = ['hi', 'goodbye']; * * _.isEqualWith(array, other, customizer); * // => true */ function isEqualWith(value, other, customizer) { customizer = typeof customizer == 'function' ? customizer : undefined; var result = customizer ? customizer(value, other) : undefined; return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; } module.exports = isEqualWith; /***/ }), /* 265 */ /***/ (function(module, exports, __webpack_require__) { var baseIsEqual = __webpack_require__(37); /** * Performs a deep comparison between two values to determine if they are * equivalent. * * **Note:** This method supports comparing arrays, array buffers, booleans, * date objects, error objects, maps, numbers, `Object` objects, regexes, * sets, strings, symbols, and typed arrays. `Object` objects are compared * by their own, not inherited, enumerable properties. Functions and DOM * nodes are compared by strict equality, i.e. `===`. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * var object = { 'a': 1 }; * var other = { 'a': 1 }; * * _.isEqual(object, other); * // => true * * object === other; * // => false */ function isEqual(value, other) { return baseIsEqual(value, other); } module.exports = isEqual; /***/ }), /* 266 */ /***/ (function(module, exports, __webpack_require__) { var toString = __webpack_require__(15); /** * Replaces matches for `pattern` in `string` with `replacement`. * * **Note:** This method is based on * [`String#replace`](https://mdn.io/String/replace). * * @static * @memberOf _ * @since 4.0.0 * @category String * @param {string} [string=''] The string to modify. * @param {RegExp|string} pattern The pattern to replace. * @param {Function|string} replacement The match replacement. * @returns {string} Returns the modified string. * @example * * _.replace('Hi Fred', 'Fred', 'Barney'); * // => 'Hi Barney' */ function replace() { var args = arguments, string = toString(args[0]); return args.length < 3 ? string : string.replace(args[1], args[2]); } module.exports = replace; /***/ }), /* 267 */ /***/ (function(module, exports, __webpack_require__) { var baseFlatten = __webpack_require__(106), baseRest = __webpack_require__(99), baseUniq = __webpack_require__(107), isArrayLikeObject = __webpack_require__(273); /** * Creates an array of unique values, in order, from all given arrays using * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @static * @memberOf _ * @since 0.1.0 * @category Array * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of combined values. * @example * * _.union([2], [1, 2]); * // => [2, 1] */ var union = baseRest(function (arrays) { return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); }); module.exports = union; /***/ }), /* 268 */ /***/ (function(module, exports, __webpack_require__) { var _Symbol = __webpack_require__(12), isArguments = __webpack_require__(28), isArray = __webpack_require__(3); /** Built-in value references. */ var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined; /** * Checks if `value` is a flattenable `arguments` object or array. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. */ function isFlattenable(value) { return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]); } module.exports = isFlattenable; /***/ }), /* 269 */ /***/ (function(module, exports, __webpack_require__) { var baseIndexOf = __webpack_require__(95); /** * A specialized version of `_.includes` for arrays without support for * specifying an index to search from. * * @private * @param {Array} [array] The array to inspect. * @param {*} target The value to search for. * @returns {boolean} Returns `true` if `target` is found, else `false`. */ function arrayIncludes(array, value) { var length = array == null ? 0 : array.length; return !!length && baseIndexOf(array, value, 0) > -1; } module.exports = arrayIncludes; /***/ }), /* 270 */ /***/ (function(module, exports) { /** * This function is like `arrayIncludes` except that it accepts a comparator. * * @private * @param {Array} [array] The array to inspect. * @param {*} target The value to search for. * @param {Function} comparator The comparator invoked per element. * @returns {boolean} Returns `true` if `target` is found, else `false`. */ function arrayIncludesWith(array, value, comparator) { var index = -1, length = array == null ? 0 : array.length; while (++index < length) { if (comparator(value, array[index])) { return true; } } return false; } module.exports = arrayIncludesWith; /***/ }), /* 271 */ /***/ (function(module, exports, __webpack_require__) { var Set = __webpack_require__(85), noop = __webpack_require__(272), setToArray = __webpack_require__(20); /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0; /** * Creates a set object of `values`. * * @private * @param {Array} values The values to add to the set. * @returns {Object} Returns the new set. */ var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY) ? noop : function (values) { return new Set(values); }; module.exports = createSet; /***/ }), /* 272 */ /***/ (function(module, exports) { /** * This method returns `undefined`. * * @static * @memberOf _ * @since 2.3.0 * @category Util * @example * * _.times(2, _.noop); * // => [undefined, undefined] */ function noop() { // No operation performed. } module.exports = noop; /***/ }), /* 273 */ /***/ (function(module, exports, __webpack_require__) { var isArrayLike = __webpack_require__(8), isObjectLike = __webpack_require__(5); /** * This method is like `_.isArrayLike` except that it also checks if `value` * is an object. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array-like object, * else `false`. * @example * * _.isArrayLikeObject([1, 2, 3]); * // => true * * _.isArrayLikeObject(document.body.children); * // => true * * _.isArrayLikeObject('abc'); * // => false * * _.isArrayLikeObject(_.noop); * // => false */ function isArrayLikeObject(value) { return isObjectLike(value) && isArrayLike(value); } module.exports = isArrayLikeObject; /***/ }), /* 274 */ /***/ (function(module, exports, __webpack_require__) { var basePick = __webpack_require__(275), flatRest = __webpack_require__(278); /** * Creates an object composed of the picked `object` properties. * * @static * @since 0.1.0 * @memberOf _ * @category Object * @param {Object} object The source object. * @param {...(string|string[])} [paths] The property paths to pick. * @returns {Object} Returns the new object. * @example * * var object = { 'a': 1, 'b': '2', 'c': 3 }; * * _.pick(object, ['a', 'c']); * // => { 'a': 1, 'c': 3 } */ var pick = flatRest(function (object, paths) { return object == null ? {} : basePick(object, paths); }); module.exports = pick; /***/ }), /* 275 */ /***/ (function(module, exports, __webpack_require__) { var basePickBy = __webpack_require__(276), hasIn = __webpack_require__(88); /** * The base implementation of `_.pick` without support for individual * property identifiers. * * @private * @param {Object} object The source object. * @param {string[]} paths The property paths to pick. * @returns {Object} Returns the new object. */ function basePick(object, paths) { return basePickBy(object, paths, function (value, path) { return hasIn(object, path); }); } module.exports = basePick; /***/ }), /* 276 */ /***/ (function(module, exports, __webpack_require__) { var baseGet = __webpack_require__(56), baseSet = __webpack_require__(277), castPath = __webpack_require__(39); /** * The base implementation of `_.pickBy` without support for iteratee shorthands. * * @private * @param {Object} object The source object. * @param {string[]} paths The property paths to pick. * @param {Function} predicate The function invoked per property. * @returns {Object} Returns the new object. */ function basePickBy(object, paths, predicate) { var index = -1, length = paths.length, result = {}; while (++index < length) { var path = paths[index], value = baseGet(object, path); if (predicate(value, path)) { baseSet(result, castPath(path, object), value); } } return result; } module.exports = basePickBy; /***/ }), /* 277 */ /***/ (function(module, exports, __webpack_require__) { var assignValue = __webpack_require__(40), castPath = __webpack_require__(39), isIndex = __webpack_require__(30), isObject = __webpack_require__(7), toKey = __webpack_require__(22); /** * The base implementation of `_.set`. * * @private * @param {Object} object The object to modify. * @param {Array|string} path The path of the property to set. * @param {*} value The value to set. * @param {Function} [customizer] The function to customize path creation. * @returns {Object} Returns `object`. */ function baseSet(object, path, value, customizer) { if (!isObject(object)) { return object; } path = castPath(path, object); var index = -1, length = path.length, lastIndex = length - 1, nested = object; while (nested != null && ++index < length) { var key = toKey(path[index]), newValue = value; if (index != lastIndex) { var objValue = nested[key]; newValue = customizer ? customizer(objValue, key, nested) : undefined; if (newValue === undefined) { newValue = isObject(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {}; } } assignValue(nested, key, newValue); nested = nested[key]; } return object; } module.exports = baseSet; /***/ }), /* 278 */ /***/ (function(module, exports, __webpack_require__) { var flatten = __webpack_require__(279), overRest = __webpack_require__(100), setToString = __webpack_require__(101); /** * A specialized version of `baseRest` which flattens the rest array. * * @private * @param {Function} func The function to apply a rest parameter to. * @returns {Function} Returns the new function. */ function flatRest(func) { return setToString(overRest(func, undefined, flatten), func + ''); } module.exports = flatRest; /***/ }), /* 279 */ /***/ (function(module, exports, __webpack_require__) { var baseFlatten = __webpack_require__(106); /** * Flattens `array` a single level deep. * * @static * @memberOf _ * @since 0.1.0 * @category Array * @param {Array} array The array to flatten. * @returns {Array} Returns the new flattened array. * @example * * _.flatten([1, [2, [3, [4]], 5]]); * // => [1, 2, [3, [4]], 5] */ function flatten(array) { var length = array == null ? 0 : array.length; return length ? baseFlatten(array, 1) : []; } module.exports = flatten; /***/ }), /* 280 */ /***/ (function(module, exports, __webpack_require__) { var baseUniq = __webpack_require__(107); /** * Creates a duplicate-free version of an array, using * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons, in which only the first occurrence of each element * is kept. The order of result values is determined by the order they occur * in the array. * * @static * @memberOf _ * @since 0.1.0 * @category Array * @param {Array} array The array to inspect. * @returns {Array} Returns the new duplicate free array. * @example * * _.uniq([2, 1, 2]); * // => [2, 1] */ function uniq(array) { return array && array.length ? baseUniq(array) : []; } module.exports = uniq; /***/ }), /* 281 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview Default animation funciton * @author sima.zhang */ var Util = __webpack_require__(0); var G = __webpack_require__(2); var PathUtil = G.PathUtil; function getClip(coord) { var start = coord.start; var end = coord.end; var width = coord.getWidth(); var height = coord.getHeight(); var margin = 200; var startAngle = void 0; var endAngle = void 0; var center = void 0; var radius = void 0; var clip = void 0; if (coord.isPolar) { radius = coord.getRadius(); center = coord.getCenter(); startAngle = coord.startAngle; endAngle = coord.endAngle; clip = new G.Fan({ attrs: { x: center.x, y: center.y, rs: 0, re: radius + margin, startAngle: startAngle, endAngle: startAngle } }); clip.endState = { endAngle: endAngle }; } else { clip = new G.Rect({ attrs: { x: start.x - margin, y: end.y - margin, width: coord.isTransposed ? width + margin * 2 : 0, height: coord.isTransposed ? 0 : height + margin * 2 } }); if (coord.isTransposed) { clip.endState = { height: height + margin * 2 }; } else { clip.endState = { width: width + margin * 2 }; } } clip.isClip = true; return clip; } // 获取图形的包围盒 function getPointsBox(points) { if (Util.isEmpty(points)) { return null; } var minX = points[0].x; var maxX = points[0].x; var minY = points[0].y; var maxY = points[0].y; Util.each(points, function (point) { minX = minX > point.x ? point.x : minX; maxX = maxX < point.x ? point.x : maxX; minY = minY > point.y ? point.y : minY; maxY = maxY < point.y ? point.y : maxY; }); return { minX: minX, maxX: maxX, minY: minY, maxY: maxY, centerX: (minX + maxX) / 2, centerY: (minY + maxY) / 2 }; } function getAngle(shape, coord) { var points = shape.points || shape.get('origin').points; var box = getPointsBox(points); var endAngle = void 0; var startAngle = void 0; var coordStartAngle = coord.startAngle; var coordEndAngle = coord.endAngle; var diffAngle = coordEndAngle - coordStartAngle; if (coord.isTransposed) { endAngle = box.maxY * diffAngle; startAngle = box.minY * diffAngle; } else { endAngle = box.maxX * diffAngle; startAngle = box.minX * diffAngle; } endAngle += coordStartAngle; startAngle += coordStartAngle; return { startAngle: startAngle, endAngle: endAngle }; } function getAnimateParam(animateCfg, index, id) { var result = {}; if (animateCfg.delay) { result.delay = Util.isFunction(animateCfg.delay) ? animateCfg.delay(index, id) : animateCfg.delay; } result.easing = Util.isFunction(animateCfg.easing) ? animateCfg.easing(index, id) : animateCfg.easing; result.duration = Util.isFunction(animateCfg.duration) ? animateCfg.duration(index, id) : animateCfg.duration; result.callback = animateCfg.callback; return result; } function scaleInY(shape, animateCfg) { var id = shape._id; var index = shape.get('index'); var box = shape.getBBox(); var points = shape.get('origin').points; var x = (box.minX + box.maxX) / 2; var y = void 0; if (points[0].y - points[1].y <= 0) { // 当顶点在零点之下 y = box.maxY; } else { y = box.minY; } var v = [x, y, 1]; shape.apply(v); shape.attr('transform', [['t', -x, -y], ['s', 1, 0.01], ['t', x, y]]); var endState = { transform: [['t', -x, -y], ['s', 1, 100], ['t', x, y]] }; var animateParam = getAnimateParam(animateCfg, index, id, endState); shape.animate(endState, animateParam.duration, animateParam.easing, animateParam.callback, animateParam.delay); } function scaleInX(shape, animateCfg) { var id = shape._id; var index = shape.get('index'); var box = shape.getBBox(); var points = shape.get('origin').points; var x = void 0; var y = (box.minY + box.maxY) / 2; if (points[0].y - points[1].y > 0) { // 当顶点在零点之下 x = box.maxX; } else { x = box.minX; } var v = [x, y, 1]; shape.apply(v); shape.attr({ transform: [['t', -x, -y], ['s', 0.01, 1], ['t', x, y]] }); var endState = { transform: [['t', -x, -y], ['s', 100, 1], ['t', x, y]] }; var animateParam = getAnimateParam(animateCfg, index, id, endState); shape.animate(endState, animateParam.duration, animateParam.easing, animateParam.callback, animateParam.delay); } function lineWidthOut(shape, animateCfg) { var endState = { lineWidth: 0, opacity: 0 }; var id = shape._id; var index = shape.get('index'); var animateParam = getAnimateParam(animateCfg, index, id, endState); shape.animate(endState, animateParam.duration, animateParam.easing, function () { shape.remove(); }, animateParam.delay); } function zoomIn(shape, animateCfg, coord) { var id = shape._id; var index = shape.get('index'); var x = void 0; var y = void 0; if (coord.isPolar && shape.name !== 'point') { x = coord.getCenter().x; y = coord.getCenter().y; } else { var box = shape.getBBox(); x = (box.minX + box.maxX) / 2; y = (box.minY + box.maxY) / 2; } var v = [x, y, 1]; shape.apply(v); shape.attr({ transform: [['t', -x, -y], ['s', 0.01, 0.01], ['t', x, y]] }); var endState = { transform: [['t', -x, -y], ['s', 100, 100], ['t', x, y]] }; var animateParam = getAnimateParam(animateCfg, index, id, endState); shape.animate(endState, animateParam.duration, animateParam.easing, animateParam.callback, animateParam.delay); } function zoomOut(shape, animateCfg, coord) { var id = shape._id; var index = shape.get('index'); var x = void 0; var y = void 0; if (coord.isPolar && shape.name !== 'point') { x = coord.getCenter().x; y = coord.getCenter().y; } else { var box = shape.getBBox(); x = (box.minX + box.maxX) / 2; y = (box.minY + box.maxY) / 2; } var v = [x, y, 1]; shape.apply(v); var endState = { transform: [['t', -x, -y], ['s', 0.01, 0.01], ['t', x, y]] }; var animateParam = getAnimateParam(animateCfg, index, id, endState); shape.animate(endState, animateParam.duration, animateParam.easing, function () { shape.remove(); }, animateParam.delay); } function pathIn(shape, animateCfg) { if (shape.get('type') !== 'path') return; var id = shape._id; var index = shape.get('index'); var path = PathUtil.pathToAbsolute(shape.attr('path')); shape.attr('path', [path[0]]); var endState = { path: path }; var animateParam = getAnimateParam(animateCfg, index, id, endState); shape.animate(endState, animateParam.duration, animateParam.easing, animateParam.callback, animateParam.delay); } function pathOut(shape, animateCfg) { if (shape.get('type') !== 'path') return; var id = shape._id; var index = shape.get('index'); var path = PathUtil.pathToAbsolute(shape.attr('path')); var endState = { path: [path[0]] }; var animateParam = getAnimateParam(animateCfg, index, id, endState); shape.animate(endState, animateParam.duration, animateParam.easing, function () { shape.remove(); }, animateParam.delay); } function clipIn(shape, animateCfg, coord, startAngle, endAngle) { var clip = getClip(coord); var canvas = shape.get('canvas'); var id = shape._id; var index = shape.get('index'); var endState = void 0; if (startAngle) { clip.attr('startAngle', startAngle); clip.attr('endAngle', startAngle); endState = { endAngle: endAngle }; } else { endState = clip.endState; } clip.set('canvas', canvas); shape.attr('clip', clip); shape.setSilent('animating', true); var animateParam = getAnimateParam(animateCfg, index, id, endState); clip.animate(endState, animateParam.duration, animateParam.easing, function () { if (shape && !shape.get('destroyed')) { shape.attr('clip', null); shape.setSilent('cacheShape', null); shape.setSilent('animating', false); clip.remove(); } }, animateParam.delay); } function fadeIn(shape, animateCfg) { var id = shape._id; var index = shape.get('index'); var fillOpacity = Util.isNil(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity'); var strokeOpacity = Util.isNil(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity'); shape.attr('fillOpacity', 0); shape.attr('strokeOpacity', 0); var endState = { fillOpacity: fillOpacity, strokeOpacity: strokeOpacity }; var animateParam = getAnimateParam(animateCfg, index, id, endState); shape.animate(endState, animateParam.duration, animateParam.easing, animateParam.callback, animateParam.delay); } function fadeOut(shape, animateCfg) { var id = shape._id; var index = shape.get('index'); var endState = { fillOpacity: 0, strokeOpacity: 0 }; var animateParam = getAnimateParam(animateCfg, index, id, endState); shape.animate(endState, animateParam.duration, animateParam.easing, function () { shape.remove(); }, animateParam.delay); } function fanIn(shape, animateCfg, coord) { var angle = getAngle(shape, coord); var endAngle = angle.endAngle; var startAngle = angle.startAngle; clipIn(shape, animateCfg, coord, startAngle, endAngle); } // 默认动画库 module.exports = { enter: { clipIn: clipIn, zoomIn: zoomIn, pathIn: pathIn, scaleInY: scaleInY, scaleInX: scaleInX, fanIn: fanIn, fadeIn: fadeIn }, leave: { lineWidthOut: lineWidthOut, zoomOut: zoomOut, pathOut: pathOut, fadeOut: fadeOut }, appear: { clipIn: clipIn, zoomIn: zoomIn, pathIn: pathIn, scaleInY: scaleInY, scaleInX: scaleInX, fanIn: fanIn, fadeIn: fadeIn }, update: { fadeIn: fadeIn, fanIn: fanIn } }; /***/ }), /* 282 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview G2 图表的入口文件 * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var View = __webpack_require__(283); var G = __webpack_require__(2); var Canvas = G.Canvas; var DomUtil = G.DomUtil; var Component = __webpack_require__(25); var Controller = __webpack_require__(115); var Facets = __webpack_require__(360); var Global = __webpack_require__(1); function _isScaleExist(scales, compareScale) { var flag = false; Util.each(scales, function (scale) { var scaleValues = [].concat(scale.values); var compareScaleValues = [].concat(compareScale.values); if (scale.type === compareScale.type && scale.field === compareScale.field && scaleValues.sort().toString() === compareScaleValues.sort().toString()) { flag = true; return; } }); return flag; } /** * 图表的入口 * @class Chart */ var Chart = function (_View) { _inherits(Chart, _View); function Chart() { _classCallCheck(this, Chart); return _possibleConstructorReturn(this, _View.apply(this, arguments)); } /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Chart.prototype.getDefaultCfg = function getDefaultCfg() { var viewCfg = _View.prototype.getDefaultCfg.call(this); return Util.mix(viewCfg, { id: null, forceFit: false, container: null, wrapperEl: null, canvas: null, width: 500, height: 500, pixelRatio: null, padding: Global.plotCfg.padding, backPlot: null, frontPlot: null, plotBackground: null, background: null, views: [] }); }; Chart.prototype.init = function init() { this._initCanvas(); this._initPlot(); this._initEvents(); _View.prototype.init.call(this); var tooltipController = new Controller.Tooltip({ chart: this, options: {} }); this.set('tooltipController', tooltipController); var legendController = new Controller.Legend({ chart: this }); this.set('legendController', legendController); this.set('_id', 'chart'); // 防止同用户设定的 id 同名 this.emit('afterinit'); // 初始化完毕 }; // 初始化画布 Chart.prototype._initCanvas = function _initCanvas() { var container = this.get('container'); var id = this.get('id'); // 如果未设置 container 使用 ID, 兼容 2.x 版本 if (!container && id) { container = id; this.set('container', id); } var width = this.get('width'); var height = this.get('height'); if (Util.isString(container)) { container = document.getElementById(container); if (!container) { throw new Error('Please specify the container for the chart!'); } this.set('container', container); } var wrapperEl = DomUtil.createDom('
'); container.appendChild(wrapperEl); this.set('wrapperEl', wrapperEl); if (this.get('forceFit')) { width = DomUtil.getWidth(container); this.set('width', width); } var canvas = new Canvas({ containerDOM: wrapperEl, width: width, height: height, pixelRatio: this.get('pixelRatio') }); this.set('canvas', canvas); }; // 初始化绘图区间 Chart.prototype._initPlot = function _initPlot() { this._initPlotBack(); // 最底层的是背景相关的 group var canvas = this.get('canvas'); var backPlot = canvas.addGroup({ zIndex: 1 }); // 图表最后面的容器 var plotContainer = canvas.addGroup({ zIndex: 2 }); // 图表所在的容器 var frontPlot = canvas.addGroup({ zIndex: 3 }); // 图表前面的容器 this.set('backPlot', backPlot); this.set('middlePlot', plotContainer); this.set('frontPlot', frontPlot); }; // 初始化背景 Chart.prototype._initPlotBack = function _initPlotBack() { var canvas = this.get('canvas'); var plot = canvas.addGroup(Component.Plot, { padding: this.get('padding'), plotBackground: Util.mix({}, Global.plotBackground, this.get('plotBackground')), background: Util.mix({}, Global.background, this.get('background')) }); this.set('plot', plot); this.set('plotRange', plot.get('plotRange')); }; Chart.prototype._initEvents = function _initEvents() { if (this.get('forceFit')) { window.addEventListener('resize', Util.wrapBehavior(this, '_initForceFitEvent')); } }; Chart.prototype._initForceFitEvent = function _initForceFitEvent() { var timer = setTimeout(Util.wrapBehavior(this, 'forceFit'), 200); clearTimeout(this.get('resizeTimer')); this.set('resizeTimer', timer); }; // 绘制图例 Chart.prototype._renderLegends = function _renderLegends() { var options = this.get('options'); var legendOptions = options.legends; if (Util.isNil(legendOptions) || legendOptions !== false) { // 没有关闭图例 var legendController = this.get('legendController'); legendController.options = legendOptions || {}; legendController.plotRange = this.get('plotRange'); if (legendOptions && legendOptions.custom) { // 用户自定义图例 legendController.addCustomLegend(); } else { var geoms = this.getAllGeoms(); var scales = []; Util.each(geoms, function (geom) { var view = geom.get('view'); var attrs = geom.getAttrsForLegend(); Util.each(attrs, function (attr) { var type = attr.type; var scale = attr.getScale(type); if (scale.type !== 'identity' && !_isScaleExist(scales, scale)) { scales.push(scale); var filteredValues = view.getFilteredValues(scale.field); legendController.addLegend(scale, attr, geom, filteredValues); } }); }); } legendController.alignLegends(); } }; // 绘制 tooltip Chart.prototype._renderTooltips = function _renderTooltips() { var options = this.get('options'); if (Util.isNil(options.tooltip) || options.tooltip !== false) { // 用户没有关闭 tooltip var tooltipController = this.get('tooltipController'); tooltipController.options = options.tooltip || {}; tooltipController.renderTooltip(); } }; /** * 获取所有的几何标记 * @return {Array} 所有的几何标记 */ Chart.prototype.getAllGeoms = function getAllGeoms() { var geoms = []; geoms = geoms.concat(this.get('geoms')); var views = this.get('views'); Util.each(views, function (view) { geoms = geoms.concat(view.get('geoms')); }); return geoms; }; /** * 自适应宽度 * @chainable * @return {Chart} 图表对象 */ Chart.prototype.forceFit = function forceFit() { var self = this; var container = self.get('container'); var width = DomUtil.getWidth(container); if (width !== this.get('width')) { var height = this.get('height'); this.changeSize(width, height); } return self; }; /** * 改变大小 * @param {Number} width 图表宽度 * @param {Number} height 图表高度 * @return {Chart} 图表对象 */ Chart.prototype.changeSize = function changeSize(width, height) { var self = this; var canvas = self.get('canvas'); canvas.changeSize(width, height); self.set('width', width); self.set('height', height); var plot = self.get('plot'); plot.repaint(); self.repaint(); this.emit('afterchangesize'); return self; }; /** * 改变宽度 * @param {Number} width 图表宽度 * @return {Chart} 图表对象 */ Chart.prototype.changeWidth = function changeWidth(width) { return this.changeSize(width, this.get('height')); }; /** * 改变宽度 * @param {Number} height 图表高度 * @return {Chart} 图表对象 */ Chart.prototype.changeHeight = function changeHeight(height) { return this.changeSize(this.get('width'), height); }; Chart.prototype.facet = function facet(type, cfg) { var cls = Facets[Util.upperFirst(type)]; if (!cls) { throw new Error('Not support such type of facets as: ' + type); } var preFacets = this.get('facets'); if (preFacets) { preFacets.destroy(); } cfg.chart = this; var facets = new cls(cfg); this.set('facets', facets); }; /** * 创建一个视图 * @param {Object} cfg 视图的配置项 * @return {View} 视图对象 */ Chart.prototype.view = function view(cfg) { cfg = cfg || {}; cfg.parent = this; cfg.backPlot = this.get('backPlot'); cfg.middlePlot = this.get('middlePlot'); cfg.frontPlot = this.get('frontPlot'); cfg.canvas = this.get('canvas'); if (Util.isNil(cfg.animate)) { cfg.animate = this.get('animate'); } cfg.options = Util.mix({}, this._getSharedOptions(), cfg.options); var view = new View(cfg); view.set('_id', 'view' + this.get('views').length); // 标识 ID,防止同用户设定的 id 重名 this.get('views').push(view); this.emit('addview', { view: view }); return view; }; Chart.prototype.isShapeInView = function isShapeInView() { return true; }; Chart.prototype.removeView = function removeView(view) { var views = this.get('views'); Util.Array.remove(views, view); view.destroy(); }; Chart.prototype._getSharedOptions = function _getSharedOptions() { var options = this.get('options'); var sharedOptions = {}; Util.each(['scales', 'coord', 'axes'], function (name) { sharedOptions[name] = Util.cloneDeep(options[name]); }); return sharedOptions; }; /** * @override * 当前chart 的范围 */ Chart.prototype.getViewRegion = function getViewRegion() { var plotRange = this.get('plotRange'); return { start: plotRange.bl, end: plotRange.tr }; }; /** * 设置图例配置信息 * @param {String|Object} field 字段名 * @param {Object} [cfg] 图例的配置项 * @return {Chart} 当前的图表对象 */ Chart.prototype.legend = function legend(field, cfg) { var options = this.get('options'); if (!options.legends) { options.legends = {}; } var legends = {}; if (field === false) { options.legends = false; } else if (Util.isObject(field)) { legends = field; } else if (Util.isString(field)) { legends[field] = cfg; } else { legends = cfg; } Util.mix(options.legends, legends); return this; }; /** * 设置提示信息 * @param {String|Object} visible 是否可见 * @param {Object} [cfg] 提示信息的配置项 * @return {Chart} 当前的图表对象 */ Chart.prototype.tooltip = function tooltip(visible, cfg) { var options = this.get('options'); if (!options.tooltip) { options.tooltip = {}; } if (visible === false) { options.tooltip = false; } else if (Util.isObject(visible)) { Util.mix(options.tooltip, visible); } else { Util.mix(options.tooltip, cfg); } return this; }; /** * 清空图表 * @return {Chart} 当前的图表对象 */ Chart.prototype.clear = function clear() { this.emit('beforeclear'); var views = this.get('views'); while (views.length > 0) { var view = views.shift(); view.destroy(); } _View.prototype.clear.call(this); var canvas = this.get('canvas'); canvas.draw(); this.emit('afterclear'); return this; }; Chart.prototype.clearInner = function clearInner() { var views = this.get('views'); Util.each(views, function (view) { view.clearInner(); }); var tooltipController = this.get('tooltipController'); tooltipController && tooltipController.clear(); if (!this.get('keepLegend')) { var legendController = this.get('legendController'); legendController && legendController.clear(); } _View.prototype.clearInner.call(this); }; /** * 绘制图表 * @override */ Chart.prototype.paint = function paint() { _View.prototype.paint.call(this); !this.get('keepLegend') && this._renderLegends(); // 渲染图例 this._renderTooltips(); // 渲染 tooltip this.set('keepLegend', false); }; /** * @override * 显示或者隐藏 */ Chart.prototype.changeVisible = function changeVisible(visible) { var wrapperEl = this.get('wrapperEl'); var visibleStr = visible ? '' : 'none'; wrapperEl.style.display = visibleStr; }; /** * 返回图表的 dataUrl 用于生成图片 * @return {String} dataUrl 路径 */ Chart.prototype.toDataURL = function toDataURL() { var canvas = this.get('canvas'); var canvasDom = canvas.get('el'); var dataURL = canvasDom.toDataURL('image/png'); return dataURL; }; /** * 图表导出功能 * @param {String} [name] 图片的名称,默认为 chart.png * @return {String} 返回生成图片的 dataUrl 路径 */ Chart.prototype.downloadImage = function downloadImage(name) { var dataURL = this.toDataURL(); var link = document.createElement('a'); link.download = (name || 'chart') + '.png'; link.href = dataURL.replace('image/png', 'image/octet-stream'); link.click(); return dataURL; }; /** * 根据坐标点显示对应的 tooltip * @param {Object} point 画布上的点 * @return {Chart} 返回 chart 实例 */ Chart.prototype.showTooltip = function showTooltip(point) { var views = this.getViewsByPoint(point); if (views.length) { var tooltipController = this.get('tooltipController'); tooltipController.showTooltip(point, views); } return this; }; /** * 隐藏 tooltip * @return {Chart} 返回 chart 实例 */ Chart.prototype.hideTooltip = function hideTooltip() { var tooltipController = this.get('tooltipController'); tooltipController.hideTooltip(); return this; }; /** * 根据传入的画布坐标,获取该处的 tooltip 上的记录信息 * @param {Object} point 画布坐标点 * @return {Array} 返回结果 */ Chart.prototype.getTooltipItems = function getTooltipItems(point) { var self = this; var views = self.getViewsByPoint(point); var rst = []; Util.each(views, function (view) { var geoms = view.get('geoms'); Util.each(geoms, function (geom) { var dataArray = geom.get('dataArray'); var items = []; Util.each(dataArray, function (data) { var tmpPoint = geom.findPoint(point, data); if (tmpPoint) { var subItems = geom.getTipItems(tmpPoint); items = items.concat(subItems); } }); rst = rst.concat(items); }); }); return rst; }; /** * @override * 销毁图表 */ Chart.prototype.destroy = function destroy() { this.emit('beforedestroy'); var canvas = this.get('canvas'); var wrapperEl = this.get('wrapperEl'); wrapperEl.parentNode.removeChild(wrapperEl); _View.prototype.destroy.call(this); canvas.destroy(); window.removeEventListener('resize', Util.getWrapBehavior(this, '_initForceFitEvent')); this.emit('afterdestroy'); }; return Chart; }(View); module.exports = Chart; /***/ }), /* 283 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview view * @author dxq613@gmail.com */ var Base = __webpack_require__(63); var Geom = __webpack_require__(285); var Util = __webpack_require__(0); var Controller = __webpack_require__(115); var Global = __webpack_require__(1); var FIELD_ORIGIN = '_origin'; var Animate = __webpack_require__(359); function isFullCircle(coord) { var startAngle = coord.startAngle; var endAngle = coord.endAngle; if (!Util.isNil(startAngle) && !Util.isNil(endAngle) && endAngle - startAngle < Math.PI * 2) { return false; } return true; } function isBetween(value, start, end) { var tmp = (value - start) / (end - start); return tmp >= 0 && tmp <= 1; } function isPointInCoord(coord, point) { var result = false; if (coord) { var type = coord.type; if (type === 'theta') { var start = coord.start; var end = coord.end; result = isBetween(point.x, start.x, end.x) && isBetween(point.y, start.y, end.y); } else { var invertPoint = coord.invert(point); result = invertPoint.x >= 0 && invertPoint.y >= 0 && invertPoint.x <= 1 && invertPoint.y <= 1; } } return result; } var ViewGeoms = {}; Util.each(Geom, function (geomConstructor, className) { var methodName = Util.lowerFirst(className); ViewGeoms[methodName] = function (cfg) { var geom = new geomConstructor(cfg); this.addGeom(geom); return geom; }; }); /** * 图表中的视图 * @class View */ var View = function (_Base) { _inherits(View, _Base); /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ View.prototype.getDefaultCfg = function getDefaultCfg() { return { viewContainer: null, coord: null, start: { x: 0, y: 0 }, end: { x: 1, y: 1 }, geoms: [], scales: {}, options: {}, scaleController: null, padding: 0, parent: null, tooltipEnable: true, // 是否展示 tooltip animate: true }; }; function View(cfg) { _classCallCheck(this, View); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); Util.mix(_this, ViewGeoms); _this.init(); return _this; } /** * @protected * 初始化 */ View.prototype.init = function init() { this._initViewPlot(); // 先创建容器 if (this.get('data')) { this._initData(this.get('data')); } this._initOptions(); this._initControllers(); this._bindEvents(); }; // 初始化配置项 View.prototype._initOptions = function _initOptions() { var self = this; var options = Util.mix({}, self.get('options')); // 防止修改原始值 if (!options.scales) { options.scales = {}; } if (!options.coord) { options.coord = {}; } if (options.animate === false) { this.set('animate', false); } if (options.tooltip === false || Util.isNull(options.tooltip)) { // 配置项方式关闭 tooltip this.set('tooltipEnable', false); } if (options.geoms && options.geoms.length) { Util.each(options.geoms, function (geomOption) { self._createGeom(geomOption); }); } var scaleController = self.get('scaleController'); if (scaleController) { scaleController.defs = options.scales; } var coordController = self.get('coordController'); if (coordController) { coordController.reset(options.coord); } this.set('options', options); }; View.prototype._createGeom = function _createGeom(cfg) { var type = cfg.type; var geom = void 0; if (this[type]) { geom = this[type](); Util.each(cfg, function (v, k) { if (geom[k]) { if (Util.isObject(v) && v.field) { // 配置项传入 if (v === 'label') { geom[k](v.field, v.callback, v.cfg); } else { var _cfg = void 0; Util.each(v, function (value, key) { if (key !== 'field') { _cfg = value; } }); geom[k](v.field, _cfg); } } else { geom[k](v); } } }); } }; // 初始化所有的控制器 View.prototype._initControllers = function _initControllers() { var options = this.get('options'); var scaleController = new Controller.Scale({ defs: options.scales }); var coordController = new Controller.Coord(options.coord); this.set('scaleController', scaleController); this.set('coordController', coordController); var axisController = new Controller.Axis(); this.set('axisController', axisController); var guideController = new Controller.Guide({ options: options.guides || [] }); this.set('guideController', guideController); }; View.prototype._initViewPlot = function _initViewPlot() { if (!this.get('viewContainer')) { // 用于 geom 的绘制 this.set('viewContainer', this.get('middlePlot')); } }; View.prototype._initGeoms = function _initGeoms() { var geoms = this.get('geoms'); var filteredData = this.get('filteredData'); var coord = this.get('coord'); var viewId = this.get('_id'); for (var i = 0; i < geoms.length; i++) { var geom = geoms[i]; geom.set('data', filteredData); geom.set('coord', coord); geom.set('_id', viewId + '-geom' + i); geom.set('keyFields', this.get('keyFields')); geom.init(); } }; View.prototype._clearGeoms = function _clearGeoms() { var self = this; var geoms = self.get('geoms'); for (var i = 0; i < geoms.length; i++) { var geom = geoms[i]; geom.clear(); } }; View.prototype._removeGeoms = function _removeGeoms() { var self = this; var geoms = self.get('geoms'); while (geoms.length > 0) { var geom = geoms.shift(); geom.destroy(); } }; View.prototype._drawGeoms = function _drawGeoms() { var geoms = this.get('geoms'); var coord = this.get('coord'); for (var i = 0; i < geoms.length; i++) { var geom = geoms[i]; geom.setCoord(coord); geom.paint(); } }; View.prototype.isShapeInView = function isShapeInView(shape) { var id = this.get('_id'); var shapeId = shape._id; if (!shapeId) { return shape.get('parent').get('viewId') === id; } return shapeId.split('-')[0] === id; }; /** * View 所在的范围 * @protected * @return {Object} View 所在的范围 */ View.prototype.getViewRegion = function getViewRegion() { var self = this; var parent = self.get('parent'); var start = void 0; var end = void 0; if (parent) { var region = parent.getViewRegion(); var viewRegion = self._getViewRegion(region.start, region.end); start = viewRegion.start; end = viewRegion.end; } else { start = self.get('start'); end = self.get('end'); } return { start: start, end: end }; }; // 获取 range 所在的范围 View.prototype._getViewRegion = function _getViewRegion(plotStart, plotEnd) { var start = this.get('start'); var end = this.get('end'); var startX = start.x; var startY = 1 - end.y; var endX = end.x; var endY = 1 - start.y; var padding = this.get('padding'); // 转换成 上、右、下、左的模式 var allPadding = Util.toAllPadding(padding); var top = allPadding[0]; var right = allPadding[1]; var bottom = allPadding[2]; var left = allPadding[3]; var startPoint = { x: startX * (plotEnd.x - plotStart.x) + plotStart.x + left, y: startY * (plotEnd.y - plotStart.y) + plotStart.y - bottom }; var endPoint = { x: endX * (plotEnd.x - plotStart.x) + plotStart.x - right, y: endY * (plotEnd.y - plotStart.y) + plotStart.y + top }; return { start: startPoint, end: endPoint }; }; View.prototype._createCoord = function _createCoord() { var coordController = this.get('coordController'); var region = this.getViewRegion(); var coord = coordController.createCoord(region.start, region.end); this.set('coord', coord); }; View.prototype._renderAxes = function _renderAxes() { var options = this.get('options'); var axesOptions = options.axes; if (axesOptions === false) { // 不渲染坐标轴 return; } var axisController = this.get('axisController'); axisController.container = this.get('backPlot'); axisController.coord = this.get('coord'); axisController.options = axesOptions || {}; var xScale = this.getXScale(); var yScales = this.getYScales(); var viewId = this.get('_id'); axisController.createAxis(xScale, yScales, viewId); }; View.prototype._renderGuides = function _renderGuides() { var guideController = this.get('guideController'); if (!Util.isEmpty(guideController.options)) { var coord = this.get('coord'); guideController.backContainer = this.get('backPlot'); guideController.frontContainer = this.get('frontPlot'); guideController.xScales = this._getScales('x'); guideController.yScales = this._getScales('y'); guideController.render(coord); } }; // 注册事件 View.prototype._bindEvents = function _bindEvents() { var eventController = new Controller.Event({ view: this, canvas: this.get('canvas') }); eventController.bindEvents(); this.set('eventController', eventController); }; // 清理时间 View.prototype._clearEvents = function _clearEvents() { var eventController = this.get('eventController'); eventController && eventController.clearEvents(); }; View.prototype._getScales = function _getScales(dimType) { var geoms = this.get('geoms'); var result = {}; for (var i = 0; i < geoms.length; i++) { var geom = geoms[i]; var scale = dimType === 'x' ? geom.getXScale() : geom.getYScale(); if (scale && !result[scale.field]) { result[scale.field] = scale; } } return result; }; View.prototype._adjustScale = function _adjustScale() { this._setCatScalesRange(); var geoms = this.get('geoms'); var scaleController = this.get('scaleController'); var colDefs = scaleController.defs; for (var i = 0; i < geoms.length; i++) { var geom = geoms[i]; if (geom.get('type') === 'interval') { var yScale = geom.getYScale(); var field = yScale.field; if (!(colDefs[field] && colDefs[field].min) && yScale.min > 0) { yScale.change({ min: 0 }); } } } }; View.prototype._setCatScalesRange = function _setCatScalesRange() { var self = this; var coord = self.get('coord'); var xScale = self.getXScale(); var yScales = self.getYScales(); var scales = []; xScale && scales.push(xScale); scales = scales.concat(yScales); var inFullCircle = coord.isPolar && isFullCircle(coord); var scaleController = self.get('scaleController'); var colDefs = scaleController.defs; Util.each(scales, function (scale) { if ((scale.isCategory || scale.isIdentity) && scale.values && !(colDefs[scale.field] && colDefs[scale.field].range)) { var count = scale.values.length; var range = void 0; if (count === 1) { range = [0.5, 1]; // 只有一个分类时,防止计算出现 [0.5,0.5]的状态 } else { var widthRatio = 1; var offset = 0; if (inFullCircle) { if (!coord.isTransposed) { range = [0, 1 - 1 / count]; } else { widthRatio = Global.widthRatio.multiplePie; offset = 1 / count * widthRatio; range = [offset / 2, 1 - offset / 2]; } } else { offset = 1 / count * 1 / 2; // 两边留下分类空间的一半 range = [offset, 1 - offset]; // 坐标轴最前面和最后面留下空白防止绘制柱状图时 } } scale.range = range; } }); }; View.prototype.getXScale = function getXScale() { var geoms = this.get('geoms').filter(function (geom) { return geom.get('visible'); }); var xScale = null; if (!Util.isEmpty(geoms)) { xScale = geoms[0].getXScale(); } return xScale; }; View.prototype.getYScales = function getYScales() { var geoms = this.get('geoms').filter(function (geom) { return geom.get('visible'); }); var rst = []; for (var i = 0; i < geoms.length; i++) { var geom = geoms[i]; var yScale = geom.getYScale(); if (yScale && Util.indexOf(rst, yScale) === -1) { rst.push(yScale); } } return rst; }; /** * 获取数据对应在画布空间的坐标 * @param {Object} item 原始数据 * @return {Object} 返回对应的画布上的坐标点 */ View.prototype.getXY = function getXY(item) { var self = this; var coord = self.get('coord'); var xScales = self._getScales('x'); var yScales = self._getScales('y'); var x = void 0; var y = void 0; for (var field in item) { if (xScales[field]) { x = xScales[field].scale(item[field]); } if (yScales[field]) { y = yScales[field].scale(item[field]); } } if (!Util.isNil(x) && !Util.isNil(y)) { return coord.convert({ x: x, y: y }); } return null; }; /** * 获取逼近的点的数据集合 * @param {Object} point 画布上的像素点 * @return {Array} 数据 */ View.prototype.getSnapRecords = function getSnapRecords(point) { var self = this; var geoms = self.get('geoms'); var rst = []; Util.each(geoms, function (geom) { var dataArray = geom.get('dataArray'); var record = void 0; Util.each(dataArray, function (data) { record = geom.findPoint(point, data); record && rst.push(record); }); }); return rst; }; /** * @protected * 添加几何标记 * @param {Geom} geom 几何标记 */ View.prototype.addGeom = function addGeom(geom) { var self = this; var geoms = self.get('geoms'); geoms.push(geom); geom.set('view', self); var container = self.get('viewContainer'); geom.set('container', container); geom.set('animate', self.get('animate')); geom.bindEvents(); }; /** * @protected * 移除几何标记 * @param {Geom} geom 几何标记 */ View.prototype.removeGeom = function removeGeom(geom) { var geoms = this.get('geoms'); Util.Array.remove(geoms, geom); geom.destroy(); }; View.prototype.createScale = function createScale(field, data) { var scales = this.get('scales'); var parent = this.get('parent'); var scale = scales[field]; // const filters = this._getFilters(); if (!data) { var filteredData = this.get('filteredData'); var legendFields = this._getFieldsForLegend(); // 过滤导致数据为空时,需要使用全局数据 // 参与过滤的字段的度量也根据全局数据来生成 if (filteredData.length && legendFields.indexOf(field) === -1) { data = filteredData; } else { data = this.get('data'); } } var scaleController = this.get('scaleController'); if (!scale) { scale = scaleController.createScale(field, data); if (scale.sync && parent) { var parentScale = parent.createScale(field, data); scale = this._getSyncScale(parentScale, scale); } scales[field] = scale; } else if (scale.sync) { // 防止 view 内部创建的scale,Chart 上的scale 范围更大 var newScale = scaleController.createScale(field, data); this._syncScale(scale, newScale); } return scale; }; View.prototype._getFieldsForLegend = function _getFieldsForLegend() { var fields = []; var geoms = this.get('geoms'); Util.each(geoms, function (geom) { var geomFields = geom.getFieldsForLegend(); fields = fields.concat(geomFields); }); return Util.uniq(fields); }; // 如果需要同步度量,则使得 values,min,max的范围最大 View.prototype._getSyncScale = function _getSyncScale(parentScale, scale) { if (parentScale.type !== scale.type) { return scale; } this._syncScale(parentScale, scale); return parentScale; }; View.prototype._syncScale = function _syncScale(distScale, sourceScale) { var mergeValues = Util.union(distScale.values, sourceScale.values); if (sourceScale.isLinear) { var max = Math.max(distScale.max, sourceScale.max); var min = Math.min(distScale.min, sourceScale.min); if (distScale.max !== max || distScale.min !== min) { distScale.change({ min: min, max: max, values: mergeValues }); } } if (mergeValues.length !== distScale.values.length) { distScale.change({ values: mergeValues }); } }; View.prototype.getFilteredValues = function getFilteredValues(field) { var scale = this.get('scales')[field]; var values = scale.values; var filters = this._getFilters(); var rst = void 0; if (filters && filters[field]) { rst = values.filter(filters[field]); } else { rst = values.slice(0); } return rst; }; View.prototype.filter = function filter(field, condition) { var options = this.get('options'); if (!options.filters) { options.filters = {}; } options.filters[field] = condition; }; // 获取 filters View.prototype._getFilters = function _getFilters() { var options = this.get('options'); return options.filters; }; // 执行 filter 数据 View.prototype.execFilter = function execFilter(data) { var self = this; var filters = self._getFilters(); if (filters) { data = data.filter(function (obj) { var rst = true; Util.each(filters, function (fn, k) { if (fn) { rst = fn(obj[k], obj); if (!rst) { return false; } } }); return rst; }); } return data; }; View.prototype.axis = function axis(field, cfg) { var options = this.get('options'); if (field === false) { options.axes = false; } else { if (!options.axes) { options.axes = {}; } var axisOptions = options.axes; axisOptions[field] = cfg; } return this; }; View.prototype.guide = function guide() { return this.get('guideController'); }; View.prototype._getKeyFields = function _getKeyFields(scaleDefs) { var keyFields = []; Util.each(scaleDefs, function (def, field) { if (def.key) { keyFields.push(field); } }); this.set('keyFields', keyFields); }; View.prototype.scale = function scale(field, cfg) { var options = this.get('options'); var scaleDefs = options.scales; if (Util.isObject(field)) { Util.mix(scaleDefs, field); } else { scaleDefs[field] = cfg; } this._getKeyFields(scaleDefs); return this; }; View.prototype.tooltip = function tooltip(visible) { this.set('tooltipEnable', visible); return this; }; View.prototype.animate = function animate(enable) { var options = this.get('options'); options.animate = enable; this.set('animate', enable); return this; }; View.prototype.changeOptions = function changeOptions(options) { this.set('options', options); this._initOptions(options); return this; }; /** * @internal 查找包含指定点的视图 * @param {Object} point 点的位置 * @return {Array} 多个视图 */ View.prototype.getViewsByPoint = function getViewsByPoint(point) { var rst = []; var views = this.get('views'); if (isPointInCoord(this.get('coord'), point)) { rst.push(this); } Util.each(views, function (view) { if (view.get('visible') && isPointInCoord(view.get('coord'), point)) { rst.push(view); } }); return rst; }; /** * 遍历所有的 shape ,用户更改 shape 后进行刷新 * @param {Function} fn 回调函数包含参数:record,shape,geom,view * @return {View} 当前视图 */ View.prototype.eachShape = function eachShape(fn) { var self = this; var views = self.get('views'); var canvas = self.get('canvas'); Util.each(views, function (view) { view.eachShape(fn); }); var geoms = this.get('geoms'); Util.each(geoms, function (geom) { var shapes = geom.getShapes(); Util.each(shapes, function (shape) { var origin = shape.get('origin'); if (Util.isArray(origin)) { var arr = origin.map(function (subOrigin) { return subOrigin[FIELD_ORIGIN]; }); fn(arr, shape, geom, self); } else { var obj = origin[FIELD_ORIGIN]; fn(obj, shape, geom, self); } }); }); canvas.draw(); return this; }; /** * 遍历所有的 shape ,回调函数中 true / false 控制图形是否显示 * @param {Function} fn 回调函数包含参数:record,shape,geom,view * @return {View} 当前视图 */ View.prototype.filterShape = function filterShape(fn) { var callback = function callback(record, shape, geom, view) { if (!fn(record, shape, geom, view)) { shape.set('visible', false); } else { shape.set('visible', true); } }; this.eachShape(callback); return this; }; View.prototype.clearInner = function clearInner() { this.set('scales', {}); var options = this.get('options'); options.geoms = null; this._clearGeoms(); // reset guide this.get('guideController') && this.get('guideController').reset(); // clear axis this.get('axisController') && this.get('axisController').clear(); }; /** * 清除视图内容,包括 geoms * @return {View} 当前视图 */ View.prototype.clear = function clear() { var options = this.get('options'); options.filters = null; this._removeGeoms(); // const container = this.get('viewContainer'); // container.clear(); this.clearInner(); this.get('guideController') && this.get('guideController').clear(); this.set('isUpdate', false); this.set('keyFields', []); return this; }; /** * 设置坐标系信息 * @param {String} type 类型 * @param {Object} cfg 配置项 * @return {Object} coordController 坐标系的管理器 */ View.prototype.coord = function coord(type, cfg) { var coordController = this.get('coordController'); coordController.reset({ type: type, cfg: cfg }); return coordController; }; /** * 当父元素边框发生改变时坐标系需要重新调整 * @protected */ View.prototype.resetCoord = function resetCoord() { this._createCoord(); }; /** * 绘制 geometry 前处理一些度量统一 * @protected */ View.prototype.beforeDraw = function beforeDraw() {}; View.prototype.source = function source(data, scales) { this._initData(data); if (scales) { this.scale(scales); } this.emit('setdata'); return this; }; View.prototype.changeData = function changeData(data) { this.emit('beforechangedata'); this._initData(data); this.emit('afterchangedata'); this.repaint(); return this; }; View.prototype._initData = function _initData(data) { var dataView = this.get('dataView'); if (dataView) { dataView.off('change', Util.getWrapBehavior(this, '_onViewChange')); this.set('dataView', null); } if (data && data.isDataView) { data.on('change', Util.wrapBehavior(this, '_onViewChange')); this.set('dataView', data); data = data.rows; } this.set('data', data); }; View.prototype._onViewChange = function _onViewChange() { this.emit('beforechangedata'); var dataView = this.get('dataView'); var rows = dataView.rows; this.set('data', rows); this.emit('afterchangedata'); this.repaint(); }; View.prototype.render = function render(stopDraw) { this.emit('beforerender'); var views = this.get('views'); var animate = this.get('animate'); // 初始化 View 的数据 Util.each(views, function (view) { view.initView(); }); this.initView(); this.emit('beforepaint'); // 绘制 Util.each(views, function (view) { view.paint(); }); this.paint(); this.emit('afterpaint'); if (!stopDraw) { var backPlot = this.get('backPlot'); backPlot.sort(); var canvas = this.get('canvas'); if (animate) { var isUpdate = this.get('isUpdate'); Util.each(views, function (view) { Animate.execAnimation(view, isUpdate); }); Animate.execAnimation(this, isUpdate); } else { canvas.draw(); } } this.emit('afterrender'); return this; }; View.prototype.initView = function initView() { var data = this.get('data') || []; var filteredData = this.execFilter(data); this.set('filteredData', filteredData); // if (!Util.isEmpty(data)) { this._createCoord(); // draw geometry 前绘制区域可能会发生改变 this._initGeoms(); this._adjustScale(); // } }; View.prototype.paint = function paint() { var data = this.get('data'); if (!Util.isEmpty(data)) { this.beforeDraw(); this._drawGeoms(); this._renderGuides(); } this._renderAxes(); }; View.prototype.changeVisible = function changeVisible(visible) { var geoms = this.get('geoms'); Util.each(geoms, function (geom) { if (geom.get('visible')) { // geom 隐藏时不受 geom.changeVisible(visible, true); } }); this.get('axisController') && this.get('axisController').changeVisible(visible); this.get('guideController') && this.get('guideController').changeVisible(visible); var canvas = this.get('canvas'); canvas.draw(); }; View.prototype.repaint = function repaint() { this.set('isUpdate', true); this.clearInner(); this.render(); }; View.prototype.destroy = function destroy() { this._clearEvents(); var dataView = this.get('dataView'); dataView && dataView.off('change', Util.getWrapBehavior(this, '_onViewChange')); this.clear(); _Base.prototype.destroy.call(this); }; return View; }(Base); module.exports = View; /***/ }), /* 284 */ /***/ (function(module, exports, __webpack_require__) { 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; }; /*! * EventEmitter v5.2.4 - git.io/ee * Unlicense - http://unlicense.org/ * Oliver Caldwell - http://oli.me.uk/ * @preserve */ ;(function (exports) { 'use strict'; /** * Class for managing events. * Can be extended to provide event functionality in other classes. * * @class EventEmitter Manages event registering and emitting. */ function EventEmitter() {} // Shortcuts to improve speed and size var proto = EventEmitter.prototype; var originalGlobalValue = exports.EventEmitter; /** * Finds the index of the listener for the event in its storage array. * * @param {Function[]} listeners Array of listeners to search through. * @param {Function} listener Method to look for. * @return {Number} Index of the specified listener, -1 if not found * @api private */ function indexOfListener(listeners, listener) { var i = listeners.length; while (i--) { if (listeners[i].listener === listener) { return i; } } return -1; } /** * Alias a method while keeping the context correct, to allow for overwriting of target method. * * @param {String} name The name of the target method. * @return {Function} The aliased method * @api private */ function alias(name) { return function aliasClosure() { return this[name].apply(this, arguments); }; } /** * Returns the listener array for the specified event. * Will initialise the event object and listener arrays if required. * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them. * Each property in the object response is an array of listener functions. * * @param {String|RegExp} evt Name of the event to return the listeners from. * @return {Function[]|Object} All listener functions for the event. */ proto.getListeners = function getListeners(evt) { var events = this._getEvents(); var response; var key; // Return a concatenated array of all matching events if // the selector is a regular expression. if (evt instanceof RegExp) { response = {}; for (key in events) { if (events.hasOwnProperty(key) && evt.test(key)) { response[key] = events[key]; } } } else { response = events[evt] || (events[evt] = []); } return response; }; /** * Takes a list of listener objects and flattens it into a list of listener functions. * * @param {Object[]} listeners Raw listener objects. * @return {Function[]} Just the listener functions. */ proto.flattenListeners = function flattenListeners(listeners) { var flatListeners = []; var i; for (i = 0; i < listeners.length; i += 1) { flatListeners.push(listeners[i].listener); } return flatListeners; }; /** * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful. * * @param {String|RegExp} evt Name of the event to return the listeners from. * @return {Object} All listener functions for an event in an object. */ proto.getListenersAsObject = function getListenersAsObject(evt) { var listeners = this.getListeners(evt); var response; if (listeners instanceof Array) { response = {}; response[evt] = listeners; } return response || listeners; }; function isValidListener(listener) { if (typeof listener === 'function' || listener instanceof RegExp) { return true; } else if (listener && (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object') { return isValidListener(listener.listener); } else { return false; } } /** * Adds a listener function to the specified event. * The listener will not be added if it is a duplicate. * If the listener returns true then it will be removed after it is called. * If you pass a regular expression as the event name then the listener will be added to all events that match it. * * @param {String|RegExp} evt Name of the event to attach the listener to. * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. * @return {Object} Current instance of EventEmitter for chaining. */ proto.addListener = function addListener(evt, listener) { if (!isValidListener(listener)) { throw new TypeError('listener must be a function'); } var listeners = this.getListenersAsObject(evt); var listenerIsWrapped = (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object'; var key; for (key in listeners) { if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) { listeners[key].push(listenerIsWrapped ? listener : { listener: listener, once: false }); } } return this; }; /** * Alias of addListener */ proto.on = alias('addListener'); /** * Semi-alias of addListener. It will add a listener that will be * automatically removed after its first execution. * * @param {String|RegExp} evt Name of the event to attach the listener to. * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. * @return {Object} Current instance of EventEmitter for chaining. */ proto.addOnceListener = function addOnceListener(evt, listener) { return this.addListener(evt, { listener: listener, once: true }); }; /** * Alias of addOnceListener. */ proto.once = alias('addOnceListener'); /** * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad. * You need to tell it what event names should be matched by a regex. * * @param {String} evt Name of the event to create. * @return {Object} Current instance of EventEmitter for chaining. */ proto.defineEvent = function defineEvent(evt) { this.getListeners(evt); return this; }; /** * Uses defineEvent to define multiple events. * * @param {String[]} evts An array of event names to define. * @return {Object} Current instance of EventEmitter for chaining. */ proto.defineEvents = function defineEvents(evts) { for (var i = 0; i < evts.length; i += 1) { this.defineEvent(evts[i]); } return this; }; /** * Removes a listener function from the specified event. * When passed a regular expression as the event name, it will remove the listener from all events that match it. * * @param {String|RegExp} evt Name of the event to remove the listener from. * @param {Function} listener Method to remove from the event. * @return {Object} Current instance of EventEmitter for chaining. */ proto.removeListener = function removeListener(evt, listener) { var listeners = this.getListenersAsObject(evt); var index; var key; for (key in listeners) { if (listeners.hasOwnProperty(key)) { index = indexOfListener(listeners[key], listener); if (index !== -1) { listeners[key].splice(index, 1); } } } return this; }; /** * Alias of removeListener */ proto.off = alias('removeListener'); /** * Adds listeners in bulk using the manipulateListeners method. * If you pass an object as the first argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added. * You can also pass it a regular expression to add the array of listeners to all events that match it. * Yeah, this function does quite a bit. That's probably a bad thing. * * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once. * @param {Function[]} [listeners] An optional array of listener functions to add. * @return {Object} Current instance of EventEmitter for chaining. */ proto.addListeners = function addListeners(evt, listeners) { // Pass through to manipulateListeners return this.manipulateListeners(false, evt, listeners); }; /** * Removes listeners in bulk using the manipulateListeners method. * If you pass an object as the first argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. * You can also pass it an event name and an array of listeners to be removed. * You can also pass it a regular expression to remove the listeners from all events that match it. * * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once. * @param {Function[]} [listeners] An optional array of listener functions to remove. * @return {Object} Current instance of EventEmitter for chaining. */ proto.removeListeners = function removeListeners(evt, listeners) { // Pass through to manipulateListeners return this.manipulateListeners(true, evt, listeners); }; /** * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level. * The first argument will determine if the listeners are removed (true) or added (false). * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. * You can also pass it an event name and an array of listeners to be added/removed. * You can also pass it a regular expression to manipulate the listeners of all events that match it. * * @param {Boolean} remove True if you want to remove listeners, false if you want to add. * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once. * @param {Function[]} [listeners] An optional array of listener functions to add/remove. * @return {Object} Current instance of EventEmitter for chaining. */ proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) { var i; var value; var single = remove ? this.removeListener : this.addListener; var multiple = remove ? this.removeListeners : this.addListeners; // If evt is an object then pass each of its properties to this method if ((typeof evt === 'undefined' ? 'undefined' : _typeof(evt)) === 'object' && !(evt instanceof RegExp)) { for (i in evt) { if (evt.hasOwnProperty(i) && (value = evt[i])) { // Pass the single listener straight through to the singular method if (typeof value === 'function') { single.call(this, i, value); } else { // Otherwise pass back to the multiple function multiple.call(this, i, value); } } } } else { // So evt must be a string // And listeners must be an array of listeners // Loop over it and pass each one to the multiple method i = listeners.length; while (i--) { single.call(this, evt, listeners[i]); } } return this; }; /** * Removes all listeners from a specified event. * If you do not specify an event then all listeners will be removed. * That means every event will be emptied. * You can also pass a regex to remove all events that match it. * * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed. * @return {Object} Current instance of EventEmitter for chaining. */ proto.removeEvent = function removeEvent(evt) { var type = typeof evt === 'undefined' ? 'undefined' : _typeof(evt); var events = this._getEvents(); var key; // Remove different things depending on the state of evt if (type === 'string') { // Remove all listeners for the specified event delete events[evt]; } else if (evt instanceof RegExp) { // Remove all events matching the regex. for (key in events) { if (events.hasOwnProperty(key) && evt.test(key)) { delete events[key]; } } } else { // Remove all listeners in all events delete this._events; } return this; }; /** * Alias of removeEvent. * * Added to mirror the node API. */ proto.removeAllListeners = alias('removeEvent'); /** * Emits an event of your choice. * When emitted, every listener attached to that event will be executed. * If you pass the optional argument array then those arguments will be passed to every listener upon execution. * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately. * So they will not arrive within the array on the other side, they will be separate. * You can also pass a regular expression to emit to all events that match it. * * @param {String|RegExp} evt Name of the event to emit and execute listeners for. * @param {Array} [args] Optional array of arguments to be passed to each listener. * @return {Object} Current instance of EventEmitter for chaining. */ proto.emitEvent = function emitEvent(evt, args) { var listenersMap = this.getListenersAsObject(evt); var listeners; var listener; var i; var key; var response; for (key in listenersMap) { if (listenersMap.hasOwnProperty(key)) { listeners = listenersMap[key].slice(0); for (i = 0; i < listeners.length; i++) { // If the listener returns true then it shall be removed from the event // The function is executed either with a basic call or an apply if there is an args array listener = listeners[i]; if (listener.once === true) { this.removeListener(evt, listener.listener); } response = listener.listener.apply(this, args || []); if (response === this._getOnceReturnValue()) { this.removeListener(evt, listener.listener); } } } } return this; }; /** * Alias of emitEvent */ proto.trigger = alias('emitEvent'); /** * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on. * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it. * * @param {String|RegExp} evt Name of the event to emit and execute listeners for. * @param {...*} Optional additional arguments to be passed to each listener. * @return {Object} Current instance of EventEmitter for chaining. */ proto.emit = function emit(evt) { var args = Array.prototype.slice.call(arguments, 1); return this.emitEvent(evt, args); }; /** * Sets the current value to check against when executing listeners. If a * listeners return value matches the one set here then it will be removed * after execution. This value defaults to true. * * @param {*} value The new value to check for when executing listeners. * @return {Object} Current instance of EventEmitter for chaining. */ proto.setOnceReturnValue = function setOnceReturnValue(value) { this._onceReturnValue = value; return this; }; /** * Fetches the current value to check against when executing listeners. If * the listeners return value matches this one then it should be removed * automatically. It will return true by default. * * @return {*|Boolean} The current value to check for or the default, true. * @api private */ proto._getOnceReturnValue = function _getOnceReturnValue() { if (this.hasOwnProperty('_onceReturnValue')) { return this._onceReturnValue; } else { return true; } }; /** * Fetches the events object and creates one if required. * * @return {Object} The events storage object. * @api private */ proto._getEvents = function _getEvents() { return this._events || (this._events = {}); }; /** * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version. * * @return {Function} Non conflicting EventEmitter class. */ EventEmitter.noConflict = function noConflict() { exports.EventEmitter = originalGlobalValue; return EventEmitter; }; // Expose the class either via AMD, CommonJS or the global object if (true) { !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { return EventEmitter; }).call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object' && module.exports) { module.exports = EventEmitter; } else { exports.EventEmitter = EventEmitter; } })(this || {}); /***/ }), /* 285 */ /***/ (function(module, exports, __webpack_require__) { var Geom = __webpack_require__(9); Geom.Point = __webpack_require__(313); Geom.PointJitter = Geom.Point.Jitter; Geom.Path = __webpack_require__(112); Geom.Line = __webpack_require__(314); Geom.LineStack = Geom.Line.Stack; Geom.Interval = __webpack_require__(315); Geom.IntervalStack = Geom.Interval.Stack; Geom.IntervalDodge = Geom.Interval.Dodge; Geom.IntervalSymmetric = Geom.Interval.Symmetric; Geom.Area = __webpack_require__(316); Geom.AreaStack = Geom.Area.Stack; Geom.Polygon = __webpack_require__(317); Geom.Schema = __webpack_require__(318); Geom.SchemaDodge = Geom.Schema.Dodge; Geom.Edge = __webpack_require__(319); Geom.Heatmap = __webpack_require__(320); module.exports = Geom; /***/ }), /* 286 */ /***/ (function(module, exports, __webpack_require__) { var Base = __webpack_require__(16); Base.Color = __webpack_require__(287); Base.Size = __webpack_require__(288); Base.Opacity = __webpack_require__(289); Base.Shape = __webpack_require__(290); Base.Position = __webpack_require__(291); module.exports = Base; /***/ }), /* 287 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the color attribute of core * @author huangtonger@aliyun.com */ var ColorUtil = __webpack_require__(64); var Base = __webpack_require__(16); var Util = __webpack_require__(0); /** * 视觉通道 color * @class Attr.Color */ var Color = function (_Base) { _inherits(Color, _Base); function Color(cfg) { _classCallCheck(this, Color); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); _this.names = ['color']; _this.type = 'color'; _this.gradient = null; if (Util.isString(_this.values)) { _this.linear = true; } return _this; } /** * @override */ Color.prototype.getLinearValue = function getLinearValue(percent) { var gradient = this.gradient; if (!gradient) { var values = this.values; gradient = ColorUtil.gradient(values); this.gradient = gradient; } return gradient(percent); }; return Color; }(Base); module.exports = Color; /***/ }), /* 288 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the size attribute of core * @author huangtonger@aliyun.com */ var Base = __webpack_require__(16); /** * 视觉通道 size * @class Attr.Size */ var Size = function (_Base) { _inherits(Size, _Base); function Size(cfg) { _classCallCheck(this, Size); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); _this.names = ['size']; _this.type = 'size'; _this.gradient = null; return _this; } return Size; }(Base); module.exports = Size; /***/ }), /* 289 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the opacity attribute of core * @author huangtonger@aliyun.com */ var Base = __webpack_require__(16); /** * 视觉通道 Opacity * @class Attr.Opacity */ var Opacity = function (_Base) { _inherits(Opacity, _Base); function Opacity(cfg) { _classCallCheck(this, Opacity); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); _this.names = ['opacity']; _this.type = 'opacity'; _this.gradient = null; return _this; } return Opacity; }(Base); module.exports = Opacity; /***/ }), /* 290 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the shape attribute of core * @author huangtonger@aliyun.com */ var Base = __webpack_require__(16); /** * 视觉通道 Shape * @class Attr.Shape */ var Shape = function (_Base) { _inherits(Shape, _Base); function Shape(cfg) { _classCallCheck(this, Shape); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); _this.names = ['shape']; _this.type = 'shape'; _this.gradient = null; return _this; } /** * @override */ Shape.prototype.getLinearValue = function getLinearValue(percent) { var values = this.values; var index = Math.round((values.length - 1) * percent); return values[index]; }; return Shape; }(Base); module.exports = Shape; /***/ }), /* 291 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the position attribute of core * @author huangtonger@aliyun.com */ var Util = __webpack_require__(0); var Base = __webpack_require__(16); var Position = function (_Base) { _inherits(Position, _Base); function Position(cfg) { _classCallCheck(this, Position); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); _this.names = ['x', 'y']; _this.type = 'position'; return _this; } Position.prototype.mapping = function mapping(x, y) { var scales = this.scales; var coord = this.coord; var scaleX = scales[0]; var scaleY = scales[1]; var rstX = void 0; var rstY = void 0; var obj = void 0; if (Util.isNil(x) || Util.isNil(y)) { return []; } if (Util.isArray(y) && Util.isArray(x)) { rstX = []; rstY = []; for (var i = 0, j = 0; i < x.length && j < y.length; i++, j++) { obj = coord.convertPoint({ x: scaleX.scale(x[i]), y: scaleY.scale(y[j]) }); rstX.push(obj.x); rstY.push(obj.y); } } else if (Util.isArray(y)) { x = scaleX.scale(x); rstY = []; Util.each(y, function (yVal) { yVal = scaleY.scale(yVal); obj = coord.convertPoint({ x: x, y: yVal }); if (rstX && rstX !== obj.x) { if (!Util.isArray(rstX)) { rstX = [rstX]; } rstX.push(obj.x); } else { rstX = obj.x; } rstY.push(obj.y); }); } else if (Util.isArray(x)) { y = scaleY.scale(y); rstX = []; Util.each(x, function (xVal) { xVal = scaleX.scale(xVal); obj = coord.convertPoint({ x: xVal, y: y }); if (rstY && rstY !== obj.y) { if (!Util.isArray(rstY)) { rstY = [rstY]; } rstY.push(obj.y); } else { rstY = obj.y; } rstX.push(obj.x); }); } else { x = scaleX.scale(x); y = scaleY.scale(y); var point = coord.convertPoint({ x: x, y: y }); rstX = point.x; rstY = point.y; } return [rstX, rstY]; }; return Position; }(Base); module.exports = Position; /***/ }), /* 292 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview Theme entry * @author sima.zhang */ var Theme = { default: __webpack_require__(108), dark: __webpack_require__(293) }; module.exports = Theme; /***/ }), /* 293 */ /***/ (function(module, exports, __webpack_require__) { var _html, _tooltip; /** * @fileOverview G2 3.0 dark theme * @author sima.zhang */ var Util = __webpack_require__(0); var BasicTheme = __webpack_require__(108); // tooltip 相关 dom 的 css 类名 var TOOLTIP_CONTAINER_CLASS = 'g2-tooltip'; var LEGEND_CONTAINER_CLASS = 'g2-legend'; var DarkTheme = Util.deepMix({}, BasicTheme, { background: { fill: '#1F1F1F', radius: 2 }, // 容器区域 plotBackground: { fill: '#1F1F1F' }, // 绘图区域 axis: { top: { label: { textStyle: { fill: '#A6A6A6' } }, line: { stroke: '#737373' }, tickLine: { stroke: '#737373' } }, bottom: { label: { textStyle: { fill: '#A6A6A6' } }, line: { stroke: '#737373' }, tickLine: { stroke: '#737373' } }, left: { label: { textStyle: { fill: '#A6A6A6' } }, grid: { lineStyle: { stroke: '#404040' } } }, right: { label: { textStyle: { fill: '#A6A6A6' } }, grid: { lineStyle: { stroke: '#404040' } } }, circle: { label: { textStyle: { fill: '#A6A6A6' } }, line: { stroke: '#737373' }, tickLine: { stroke: '#737373' }, grid: { lineStyle: { stroke: '#404040' } } }, radius: { label: { textStyle: { fill: '#A6A6A6' } }, line: { stroke: '#737373' }, tickLine: { stroke: '#737373' }, grid: { lineStyle: { stroke: '#404040' } } }, helix: { line: { stroke: '#737373' }, tickLine: { stroke: '#737373' } } }, label: { textStyle: { fill: '#A6A6A6' } }, legend: { right: { textStyle: { fill: '#737373' }, unCheckColor: '#bfbfbf' }, left: { textStyle: { fill: '#737373' }, // 图例项文本的样式 unCheckColor: '#bfbfbf' }, top: { textStyle: { fill: '#737373' }, // 图例项文本的样式 unCheckColor: '#bfbfbf' }, bottom: { textStyle: { fill: '#737373' }, // 图例项文本的样式 unCheckColor: '#bfbfbf' }, html: (_html = {}, _html['' + LEGEND_CONTAINER_CLASS] = { color: '#D9D9D9' }, _html), gradient: { textStyle: { fill: '#D9D9D9' }, lineStyle: { stroke: '#404040' } } }, tooltip: (_tooltip = {}, _tooltip['' + TOOLTIP_CONTAINER_CLASS] = { color: '#D9D9D9' }, _tooltip), tooltipCrosshairsRect: { type: 'rect', style: { fill: '#fff', opacity: 0.1 } }, // tooltip 辅助背景框样式 tooltipCrosshairsLine: { style: { stroke: 'rgba(255, 255, 255, 0.45)' } }, guide: { line: { text: { style: { fill: '#A6A6A6' } } }, text: { style: { fill: '#A6A6A6' } }, region: { // TODO style: { lineWidth: 0, // 辅助框的边框宽度 fill: '#000', // 辅助框填充的颜色 fillOpacity: 0.04 // 辅助框的背景透明度 // 辅助框的图形样式属性 } } } }); module.exports = DarkTheme; /***/ }), /* 294 */ /***/ (function(module, exports, __webpack_require__) { var Adjust = __webpack_require__(24); Adjust.Stack = __webpack_require__(295); Adjust.Jitter = __webpack_require__(296); Adjust.Symmetric = __webpack_require__(297); Adjust.Dodge = __webpack_require__(298); module.exports = Adjust; /***/ }), /* 295 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The extension function of stack ,which mixin to geom * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var Adjust = __webpack_require__(24); /** * 数据调整的基类 * @class Adjust.Stack */ var Stack = function (_Adjust) { _inherits(Stack, _Adjust); function Stack() { _classCallCheck(this, Stack); return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); } /** * @override */ Stack.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Adjust.prototype.getDefaultCfg.call(this); return Util.assign(cfg, { /** * 仅有一个维度调整时,总的高度 * @type {Number} */ height: null, /** * 单个点的大小 * @type {Number} */ size: 10, /** * 是否反序进行层叠 * @type {Boolean} */ reverseOrder: false, /** * @override */ adjustNames: ['y'] // Only support stack y }); }; Stack.prototype.processOneDimStack = function processOneDimStack(dataArray) { var self = this; var xField = self.xField; var yField = self.yField || 'y'; var height = self.height; var stackY = {}; // 如果层叠的顺序翻转 if (self.reverseOrder) { dataArray = dataArray.slice(0).reverse(); } for (var i = 0; i < dataArray.length; i++) { // var preY = stackHeight; var data = dataArray[i]; // cates for (var j = 0; j < data.length; j++) { var item = data[j]; var size = item.size || self.size; var stackHeight = size * 2 / height; var x = item[xField]; if (!stackY[x]) { stackY[x] = stackHeight / 2; } item[yField] = stackY[x]; stackY[x] += stackHeight; } } }; Stack.prototype.processAdjust = function processAdjust(dataArray) { var self = this; if (self.yField) { self.processStack(dataArray); } else { self.processOneDimStack(dataArray); } }; Stack.prototype.processStack = function processStack(dataArray) { var self = this; var xField = self.xField; var yField = self.yField; var count = dataArray.length; var stackCache = { positive: {}, negative: {} }; // 层叠顺序翻转 if (self.reverseOrder) { dataArray = dataArray.slice(0).reverse(); } for (var i = 0; i < count; i++) { var data = dataArray[i]; for (var j = 0; j < data.length; j++) { var item = data[j]; var x = item[xField] || 0; var y = item[yField] || 0; var xkey = x.toString(); y = Util.isArray(y) ? y[1] : y; var direction = y >= 0 ? 'positive' : 'negative'; if (!stackCache[direction][xkey]) { stackCache[direction][xkey] = 0; } item[yField] = [stackCache[direction][xkey], y + stackCache[direction][xkey]]; stackCache[direction][xkey] += y; } } }; return Stack; }(Adjust); module.exports = Stack; /***/ }), /* 296 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview Repositions graphic elements randomly using a normal or uniform distribution * @author dxq613@gmail.com * reference: http://www-01.ibm.com/support/knowledgecenter/SSLVMB_21.0.0/com.ibm.spss.statistics.help/gpl_statement_element_jitter.htm */ var Util = __webpack_require__(0); var Adjust = __webpack_require__(24); /** * 数据调整的基类 * @class Adjust.Jitter */ var Jitter = function (_Adjust) { _inherits(Jitter, _Adjust); function Jitter() { _classCallCheck(this, Jitter); return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); } Jitter.prototype.getAdjustOffset = function getAdjustOffset(pre, next) { var r = Math.random(); // 随机位置,均匀分布 var avg = next - pre; // * length var append = avg * 0.05; return pre + append + avg * 0.9 * r; }; // adjust group data Jitter.prototype._adjustGroup = function _adjustGroup(group, dim, key, values) { var self = this; var range = self.getAdjustRange(dim, key, values); Util.each(group, function (record) { record[dim] = self.getAdjustOffset(range.pre, range.next); // 获取调整的位置 }); }; Jitter.prototype.adjustDim = function adjustDim(dim, values, data) { var self = this; var groupData = self.groupData(data, dim); Util.each(groupData, function (group, key) { key = parseFloat(key); self._adjustGroup(group, dim, key, values); }); }; return Jitter; }(Adjust); module.exports = Jitter; /***/ }), /* 297 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The extension function of symmetric ,which mixin to geom * @author huangtonger@aliyun.com */ var Util = __webpack_require__(0); var Adjust = __webpack_require__(24); /** * 数据调整的基类 * @class Adjust.Symmetric */ var Symmetric = function (_Adjust) { _inherits(Symmetric, _Adjust); function Symmetric() { _classCallCheck(this, Symmetric); return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); } /** * @override */ Symmetric.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Adjust.prototype.getDefaultCfg.call(this); return Util.assign(cfg, { // 缓存的最大值 cacheMax: null, /** * @override */ adjustNames: ['y'] // Only support stack y }); }; // 获取最大的y值 Symmetric.prototype._getMax = function _getMax(dim) { var self = this; var mergeData = self.mergeData; var maxRecord = Util.maxBy(mergeData, function (obj) { var value = obj[dim]; if (Util.isArray(value)) { return Math.max.apply(null, value); } return value; }); var maxValue = maxRecord[dim]; var max = Util.isArray(maxValue) ? Math.max.apply(null, maxValue) : maxValue; return max; }; // 获取每个字段最大的值 Symmetric.prototype._getXValuesMax = function _getXValuesMax() { var self = this; var yField = self.yField; var xField = self.xField; var cache = {}; var mergeData = self.mergeData; Util.each(mergeData, function (obj) { var xValue = obj[xField]; var yValue = obj[yField]; var max = Util.isArray(yValue) ? Math.max.apply(null, yValue) : yValue; cache[xValue] = cache[xValue] || 0; if (cache[xValue] < max) { cache[xValue] = max; } }); return cache; }; // 入口函数 Symmetric.prototype.processAdjust = function processAdjust(dataArray) { var self = this; var mergeData = Util.Array.merge(dataArray); self.mergeData = mergeData; self._processSymmetric(dataArray); self.mergeData = null; }; // 处理对称 Symmetric.prototype._processSymmetric = function _processSymmetric(dataArray) { var self = this; var xField = self.xField; var yField = self.yField; var max = self._getMax(yField); var first = dataArray[0][0]; var cache = void 0; if (first && Util.isArray(first[yField])) { cache = self._getXValuesMax(); } Util.each(dataArray, function (data) { Util.each(data, function (obj) { var value = obj[yField]; var offset = void 0; if (Util.isArray(value)) { var xValue = obj[xField]; var valueMax = cache[xValue]; offset = (max - valueMax) / 2; var tmp = []; /* eslint-disable no-loop-func */ Util.each(value, function (subVal) { // 多个字段 tmp.push(offset + subVal); }); /* eslint-enable no-loop-func */ obj[yField] = tmp; } else { offset = (max - value) / 2; obj[yField] = [offset, value + offset]; } }); }); }; return Symmetric; }(Adjust); module.exports = Symmetric; /***/ }), /* 298 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview Moves graphic elements next to other graphic elements that appear at the same value, rather than superimposing them. * @fileOverview dxq613@gmail.com */ var Util = __webpack_require__(0); var Adjust = __webpack_require__(24); var Global = __webpack_require__(1); /** * 数据调整的基类 * @class Adjust.Dodge */ var Dodge = function (_Adjust) { _inherits(Dodge, _Adjust); function Dodge() { _classCallCheck(this, Dodge); return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); } Dodge.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Adjust.prototype.getDefaultCfg.call(this); return Util.assign(cfg, { /** * 调整过程中,2个数据的间距 * @type {Number} */ marginRatio: 1 / 2, /** * 调整占单位宽度的比例,例如:占2个分类间距的 1/2 * @type {Number} */ dodgeRatio: Global.widthRatio.column, dodgeBy: null }); }; /** * @protected * @override */ Dodge.prototype.processAdjust = function processAdjust(dataArray) { var self = this; var mergeData = Util.Array.merge(dataArray); var dodgeDim = self.dodgeBy; var adjDataArray = dataArray; if (dodgeDim) { // 如果指定了分组dim的字段 adjDataArray = Util.Array.group(mergeData, dodgeDim); } self.cacheMap = {}; self.adjDataArray = adjDataArray; self.mergeData = mergeData; self.adjustData(adjDataArray, mergeData); self.adjDataArray = null; self.mergeData = null; }; Dodge.prototype.getDistribution = function getDistribution(dim) { var self = this; var dataArray = self.adjDataArray; var cacheMap = self.cacheMap; var map = cacheMap[dim]; if (!map) { map = {}; Util.each(dataArray, function (data, index) { var values = Util.Array.values(data, dim); if (!values.length) { values.push(0); } Util.each(values, function (val) { if (!map[val]) { map[val] = []; } map[val].push(index); }); }); cacheMap[dim] = map; } return map; }; Dodge.prototype.adjustDim = function adjustDim(dim, values, data, frameCount, frameIndex) { var self = this; var map = self.getDistribution(dim); var groupData = self.groupData(data, dim); // 根据值分组 Util.each(groupData, function (group, key) { key = parseFloat(key); var range = void 0; if (values.length === 1) { range = { pre: values[0] - 1, next: values[0] + 1 }; } else { range = self.getAdjustRange(dim, key, values); } Util.each(group, function (record) { var value = record[dim]; var valueArr = map[value]; var valIndex = valueArr.indexOf(frameIndex); record[dim] = self.getDodgeOffset(range, valIndex, valueArr.length); }); }); }; Dodge.prototype.getDodgeOffset = function getDodgeOffset(range, index, count) { var self = this; var pre = range.pre; var next = range.next; var tickLength = next - pre; var dodgeRatio = self.dodgeRatio; var width = tickLength * dodgeRatio / count; var margin = self.marginRatio * width; var offset = 1 / 2 * (tickLength - count * width - (count - 1) * margin) + ((index + 1) * width + index * margin) - 1 / 2 * width - 1 / 2 * tickLength; return (pre + next) / 2 + offset; }; return Dodge; }(Adjust); module.exports = Dodge; /***/ }), /* 299 */ /***/ (function(module, exports, __webpack_require__) { var GeomLabels = __webpack_require__(109); var PolarLabels = __webpack_require__(111); var PieLabels = __webpack_require__(302); var Labels = { getLabelsClass: function getLabelsClass(coordType) { var rst = GeomLabels; if (coordType === 'polar') { rst = PolarLabels; } else if (coordType === 'theta') { // pie chart rst = PieLabels; } return rst; } }; module.exports = Labels; /***/ }), /* 300 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview The class that performs label rendering * @author sima.zhang */ var Util = __webpack_require__(0); var Labels = __webpack_require__(110); module.exports = { renderLabels: function renderLabels() { var labelCfg = this.get('label'); if (Util.isNil(labelCfg)) { return; } if (Util.isNil(labelCfg.items)) { labelCfg.items = []; } var labelsGroup = this.addGroup(Labels, labelCfg); this.set('labelsGroup', labelsGroup); }, resetLabels: function resetLabels(items) { var self = this; var labelCfg = self.get('label'); if (!labelCfg) { return; } var labelsGroup = self.get('labelsGroup'); var children = labelsGroup.getLabels(); var count = children.length; items = items || labelCfg.items; Util.each(items, function (item, index) { if (index < count) { var label = children[index]; labelsGroup.changeLabel(label, item); } else { var labelShape = self.addLabel(item.text, item); if (labelShape) { labelShape._id = item._id; labelShape.set('coord', item.coord); } } }); for (var i = count - 1; i >= items.length; i--) { children[i].remove(); } }, addLabel: function addLabel(value, offsetPoint) { var self = this; var labelsGroup = self.get('labelsGroup'); var label = {}; var rst = void 0; if (labelsGroup) { label.text = value; label.x = offsetPoint.x; label.y = offsetPoint.y; label.point = offsetPoint; label.textAlign = offsetPoint.textAlign; if (offsetPoint.rotate) { label.rotate = offsetPoint.rotate; } rst = labelsGroup.addLabel(label); } return rst; }, removeLabels: function removeLabels() { var labelsGroup = this.get('labelsGroup'); labelsGroup && labelsGroup.remove(); this.set('labelsGroup', null); } }; /***/ }), /* 301 */ /***/ (function(module, exports, __webpack_require__) { var MatrixUtil = __webpack_require__(2).MatrixUtil; var Vector2 = MatrixUtil.vec2; function smoothBezier(points, smooth, isLoop, constraint) { var cps = []; var prevPoint = void 0; var nextPoint = void 0; var hasConstraint = !!constraint; var min = void 0, max = void 0; if (hasConstraint) { min = [Infinity, Infinity]; max = [-Infinity, -Infinity]; for (var i = 0, l = points.length; i < l; i++) { var point = points[i]; min = Vector2.min([], min, point); max = Vector2.max([], max, point); } min = Vector2.min([], min, constraint[0]); max = Vector2.max([], max, constraint[1]); } for (var _i = 0, len = points.length; _i < len; _i++) { var _point = points[_i]; if (isLoop) { prevPoint = points[_i ? _i - 1 : len - 1]; nextPoint = points[(_i + 1) % len]; } else { if (_i === 0 || _i === len - 1) { cps.push(_point); continue; } else { prevPoint = points[_i - 1]; nextPoint = points[_i + 1]; } } var v = []; v = Vector2.sub(v, nextPoint, prevPoint); v = Vector2.scale(v, v, smooth); var d0 = Vector2.distance(_point, prevPoint); var d1 = Vector2.distance(_point, nextPoint); var sum = d0 + d1; if (sum !== 0) { d0 /= sum; d1 /= sum; } var v1 = Vector2.scale([], v, -d0); var v2 = Vector2.scale([], v, d1); var cp0 = Vector2.add([], _point, v1); var cp1 = Vector2.add([], _point, v2); if (hasConstraint) { cp0 = Vector2.max([], cp0, min); cp0 = Vector2.min([], cp0, max); cp1 = Vector2.max([], cp1, min); cp1 = Vector2.min([], cp1, max); } cps.push(cp0); cps.push(cp1); } if (isLoop) { cps.push(cps.shift()); } return cps; } function catmullRom2bezier(crp, z, constraint) { var isLoop = !!z; var pointList = []; for (var i = 0, l = crp.length; i < l; i += 2) { pointList.push([crp[i], crp[i + 1]]); } var controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint); var len = pointList.length; var d1 = []; var cp1 = void 0; var cp2 = void 0; var p = void 0; for (var _i2 = 0; _i2 < len - 1; _i2++) { cp1 = controlPointList[_i2 * 2]; cp2 = controlPointList[_i2 * 2 + 1]; p = pointList[_i2 + 1]; d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]]); } if (isLoop) { cp1 = controlPointList[len]; cp2 = controlPointList[len + 1]; p = pointList[0]; d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]]); } return d1; } module.exports = { catmullRom2bezier: catmullRom2bezier }; /***/ }), /* 302 */ /***/ (function(module, exports, __webpack_require__) { 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; } var Util = __webpack_require__(0); var PolarLabels = __webpack_require__(111); var PathUtil = __webpack_require__(14); var Global = __webpack_require__(1); var MARGIN = 5; function getEndPoint(center, angle, r) { return { x: center.x + r * Math.cos(angle), y: center.y + r * Math.sin(angle) }; } function antiCollision(labels, lineHeight, plotRange, center, isRight) { // adjust y position of labels to avoid overlapping var overlapping = true; var start = plotRange.start; var end = plotRange.end; var startY = Math.min(start.y, end.y); var totalHeight = Math.abs(start.y - end.y); var i = void 0; var maxY = 0; var minY = Number.MIN_VALUE; var boxes = labels.map(function (label) { if (label.y > maxY) { maxY = label.y; } if (label.y < minY) { minY = label.y; } return { size: lineHeight, targets: [label.y - startY] }; }); minY -= startY; if (maxY - startY > totalHeight) { totalHeight = maxY - startY; } while (overlapping) { /* eslint no-loop-func: 0 */ boxes.forEach(function (box) { var target = (Math.min.apply(minY, box.targets) + Math.max.apply(minY, box.targets)) / 2; box.pos = Math.min(Math.max(minY, target - box.size / 2), totalHeight - box.size); // box.pos = Math.max(0, target - box.size / 2); }); // detect overlapping and join boxes overlapping = false; i = boxes.length; while (i--) { if (i > 0) { var previousBox = boxes[i - 1]; var box = boxes[i]; if (previousBox.pos + previousBox.size > box.pos) { // overlapping previousBox.size += box.size; previousBox.targets = previousBox.targets.concat(box.targets); // overflow, shift up if (previousBox.pos + previousBox.size > totalHeight) { previousBox.pos = totalHeight - previousBox.size; } boxes.splice(i, 1); // removing box overlapping = true; } } } } i = 0; // step 4: normalize y and adjust x boxes.forEach(function (b) { var posInCompositeBox = startY + lineHeight / 2; // middle of the label b.targets.forEach(function () { labels[i].y = b.pos + posInCompositeBox; posInCompositeBox += lineHeight; i++; }); }); // (x - cx)^2 + (y - cy)^2 = totalR^2 labels.forEach(function (label) { var rPow2 = label.r * label.r; var dyPow2 = Math.pow(Math.abs(label.y - center.y), 2); if (rPow2 < dyPow2) { label.x = center.x; } else { var dx = Math.sqrt(rPow2 - dyPow2); if (!isRight) { // left label.x = center.x - dx; } else { // right label.x = center.x + dx; } } }); } var PieLabels = function (_PolarLabels) { _inherits(PieLabels, _PolarLabels); function PieLabels() { _classCallCheck(this, PieLabels); return _possibleConstructorReturn(this, _PolarLabels.apply(this, arguments)); } PieLabels.prototype.getDefaultCfg = function getDefaultCfg() { return { label: Global.thetaLabels }; }; /** * @protected * to avoid overlapping * @param {Array} items labels to be placed * @return {Array} items */ PieLabels.prototype.adjustItems = function adjustItems(items) { var self = this; var offset = self.getDefaultOffset(); if (offset > 0) { items = self._distribute(items, offset); } return items; }; /** * @private * distribute labels * @param {Array} labels labels * @param {Number} offset offset * @return {Array} labels */ PieLabels.prototype._distribute = function _distribute(labels, offset) { var self = this; var coord = self.get('coord'); // console.log(coord); var radius = coord.getRadius(); var lineHeight = self.get('label').labelHeight; var center = coord.getCenter(); var totalR = radius + offset; var totalHeight = totalR * 2 + lineHeight * 2; var plotRange = { start: coord.start, end: coord.end }; var geom = self.get('geom'); if (geom) { var view = geom.get('view'); plotRange = view.getViewRegion(); } // step 1: separate labels var halves = [[], // left [] // right ]; labels.forEach(function (label) { if (label.textAlign === 'right') { // left halves[0].push(label); } else { // right or center will be put on the right side halves[1].push(label); } }); halves.forEach(function (half, index) { // step 2: reduce labels var maxLabelsCountForOneSide = parseInt(totalHeight / lineHeight, 10); if (half.length > maxLabelsCountForOneSide) { half.sort(function (a, b) { // sort by percentage DESC return b['..percent'] - a['..percent']; }); half.splice(maxLabelsCountForOneSide, half.length - maxLabelsCountForOneSide); } // step 3: distribute position (x and y) half.sort(function (a, b) { // sort by y ASC return a.y - b.y; }); antiCollision(half, lineHeight, plotRange, center, index); }); return halves[0].concat(halves[1]); }; // 连接线 PieLabels.prototype.lineToLabel = function lineToLabel(label, labelLine) { var self = this; var coord = self.get('coord'); var r = coord.getRadius(); var distance = self.getDefaultOffset(); var angle = label.orignAngle || label.angle; var center = coord.getCenter(); var start = getEndPoint(center, angle, r + MARGIN / 2); var inner = getEndPoint(center, angle, r + distance / 2); var lineGroup = self.get('lineGroup'); // var lineShape; if (!lineGroup) { lineGroup = self.addGroup({ elCls: 'x-line-group' }); self.set('lineGroup', lineGroup); } // lineShape = var lineShape = lineGroup.addShape('path', { attrs: Util.mix({ path: ['M' + start.x, start.y + ' Q' + inner.x, inner.y + ' ' + label.x, label.y].join(','), fill: null, stroke: label.color }, labelLine) }); // label 对应线的动画关闭 lineShape.name = 'labelLine'; lineShape._id = label._id && label._id.replace('glabel', 'glabelline'); // generate labelLine id according to label id lineShape.set('coord', coord); }; /** * @protected * get rotation for label * @param {Number} angle angle * @param {Number} offset offset * @return {Number} rotate */ PieLabels.prototype.getLabelRotate = function getLabelRotate(angle, offset) { var rotate = void 0; if (offset < 0) { rotate = angle * 180 / Math.PI; if (rotate > 90) { rotate = rotate - 180; } if (rotate < -90) { rotate = rotate + 180; } } return rotate / 180 * Math.PI; }; /** * @protected * get text align for label * @param {Object} point point * @return {String} align */ PieLabels.prototype.getLabelAlign = function getLabelAlign(point) { var self = this; var coord = self.get('coord'); var center = coord.getCenter(); var align = void 0; if (point.angle <= Math.PI / 2 && point.x >= center.x) { align = 'left'; } else { align = 'right'; } var offset = self.getDefaultOffset(); if (offset <= 0) { if (align === 'right') { align = 'left'; } else { align = 'right'; } } return align; }; PieLabels.prototype.getArcPoint = function getArcPoint(point) { return point; }; PieLabels.prototype.getPointAngle = function getPointAngle(point) { var self = this; var coord = self.get('coord'); var startPoint = { x: Util.isArray(point.x) ? point.x[0] : point.x, y: point.y[0] }; var endPoint = { x: Util.isArray(point.x) ? point.x[1] : point.x, y: point.y[1] }; var angle = void 0; var startAngle = PathUtil.getPointAngle(coord, startPoint); if (point.points && point.points[0].y === point.points[1].y) { angle = startAngle; } else { var endAngle = PathUtil.getPointAngle(coord, endPoint); if (startAngle >= endAngle) { // 100% pie slice endAngle = endAngle + Math.PI * 2; } angle = startAngle + (endAngle - startAngle) / 2; } return angle; }; PieLabels.prototype.getCirclePoint = function getCirclePoint(angle, offset) { var self = this; var coord = self.get('coord'); var center = coord.getCenter(); var r = coord.getRadius() + offset; var point = getEndPoint(center, angle, r); point.angle = angle; point.r = r; return point; }; return PieLabels; }(PolarLabels); module.exports = PieLabels; /***/ }), /* 303 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview area shape * @author dxq613@gmail.com * @author sima.zhang1990@gmail.com */ var Util = __webpack_require__(0); var Shape = __webpack_require__(10); var PathUtil = __webpack_require__(14); var Global = __webpack_require__(1); function getLineAttrs(cfg) { var defaultAttrs = Global.shape.hollowArea; var lineAttrs = Util.mix({}, defaultAttrs, { stroke: cfg.color, lineWidth: cfg.size, strokeOpacity: cfg.opacity }, cfg.style); return lineAttrs; } function getFillAttrs(cfg) { var defaultAttrs = Global.shape.area; var areaAttrs = Util.mix({}, defaultAttrs, { fill: cfg.color, stroke: cfg.color, lineWidth: cfg.size, fillOpacity: cfg.opacity }, cfg.style); return areaAttrs; } function getPath(cfg, smooth, shape) { var path = []; var pointsArr = []; var topLinePoints = []; // area 区域上部分 var bottomLinePoints = []; // area 区域下部分 var isInCircle = cfg.isInCircle; Util.each(cfg.points, function (point) { topLinePoints.push(point[1]); bottomLinePoints.push(point[0]); }); if (!isInCircle) { bottomLinePoints = bottomLinePoints.reverse(); } pointsArr.push(topLinePoints, bottomLinePoints); Util.each(pointsArr, function (points, index) { var subPath = []; points = shape.parsePoints(points); var p1 = points[0]; if (isInCircle) { points.push({ x: p1.x, y: p1.y }); } if (smooth) { subPath = PathUtil.getSplinePath(points, false, cfg.constraint); } else { subPath = PathUtil.getLinePath(points, false); } if (!isInCircle && index > 0) { subPath[0][0] = 'L'; } path = path.concat(subPath); }); path.push(['Z']); return path; } // get marker cfg function _getMarkerCfg(cfg) { return { symbol: function symbol(x, y, r, ctx) { // 11px * 9px ctx.save(); ctx.lineWidth = 2; ctx.strokeStyle = ctx.fillStyle; ctx.moveTo(x - 5.5, y - 4); ctx.lineTo(x + 5.5, y - 4); ctx.stroke(); ctx.restore(); ctx.moveTo(x - 5.5, y - 4); ctx.lineTo(x + 5.5, y - 4); ctx.lineTo(x + 5.5, y + 4); ctx.lineTo(x - 5.5, y + 4); ctx.closePath(); }, radius: 5, fill: cfg.color, fillOpacity: 0.3 }; } // 鼠标悬浮触发active状态 function _getActiveCfg(type, cfg) { if (type === 'line' || type === 'smoothLine') { // 线加粗 var lineWidth = cfg.lineWidth || 0; return { lineWidth: lineWidth + 1 }; } var opacity = cfg.fillOpacity || cfg.opacity || 1; return { fillOpacity: opacity - 0.15, strokeOpacity: opacity - 0.15 }; } // 当只有一个数据时绘制点 function drawPointShape(shapeObj, cfg, container) { var coord = shapeObj._coord; var point = coord.convertPoint(cfg.points[0][1]); return container.addShape('circle', { attrs: Util.mix({ x: point.x, y: point.y, r: 2, fill: cfg.color }, cfg.style) }); } var Area = Shape.registerFactory('area', { defaultShapeType: 'area', /** * @override * @protected * 计算点 如果存在多个点,分割成单个的点, 不考虑多个x对应一个y的情况 * 单点则补上y0点 */ getDefaultPoints: function getDefaultPoints(pointInfo) { var points = []; var x = pointInfo.x; var y = pointInfo.y; var y0 = pointInfo.y0; y = Util.isArray(y) ? y : [y0, y]; Util.each(y, function (yItem) { points.push({ x: x, y: yItem }); }); return points; }, // 获取激活的图形属性 getActiveCfg: function getActiveCfg(type, cfg) { return _getActiveCfg(type, cfg); }, drawShape: function drawShape(type, cfg, container) { var shape = this.getShape(type); var gShape = void 0; if (cfg.points.length === 1 && Global.showSinglePoint) { gShape = drawPointShape(this, cfg, container); } else { gShape = shape.draw(cfg, container); } if (gShape) { gShape.set('origin', cfg.origin); gShape._id = cfg.splitedIndex ? cfg._id + cfg.splitedIndex : cfg._id; gShape.name = this.name; } return gShape; }, getSelectedCfg: function getSelectedCfg(type, cfg) { if (cfg && cfg.style) { return cfg.style; } return this.getActiveCfg(type, cfg); } }); // 默认:填充区域图 Shape.registerShape('area', 'area', { draw: function draw(cfg, container) { var attrs = getFillAttrs(cfg); var path = getPath(cfg, false, this); // path = this.parsePath(path, false); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return _getMarkerCfg(cfg); } }); // 填充平滑区域图 Shape.registerShape('area', 'smooth', { draw: function draw(cfg, container) { var attrs = getFillAttrs(cfg); var coord = this._coord; // 曲线的限制 cfg.constraint = [[coord.start.x, coord.end.y], [coord.end.x, coord.start.y]]; var path = getPath(cfg, true, this); // path = this.parsePath(path, false); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return _getMarkerCfg(cfg); } }); // 封闭的折线 Shape.registerShape('area', 'line', { draw: function draw(cfg, container) { var attrs = getLineAttrs(cfg); var path = getPath(cfg, false, this); // path = this.parsePath(path, false); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return _getMarkerCfg(cfg); } }); // 封闭的平滑线 Shape.registerShape('area', 'smoothLine', { draw: function draw(cfg, container) { var attrs = getLineAttrs(cfg); var path = getPath(cfg, true, this); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return _getMarkerCfg(cfg); } }); Area.spline = Area.smooth; module.exports = Area; /***/ }), /* 304 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 边的 shape * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var Shape = __webpack_require__(10); var ShapeUtil = __webpack_require__(67); var Global = __webpack_require__(1); var PathUtil = __webpack_require__(14); var CORNER_PERCENT = 1 / 3; function getAttrs(cfg) { var defaultCfg = Global.shape.edge; var shapeCfg = Util.mix({}, defaultCfg, { stroke: cfg.color, lineWidth: cfg.size, strokeOpacity: cfg.opacity, opacity: cfg.opacity }, cfg.style); return shapeCfg; } var Edge = Shape.registerFactory('edge', { defaultShapeType: 'line', getDefaultPoints: function getDefaultPoints(pointInfo) { return ShapeUtil.splitPoints(pointInfo); }, getActiveCfg: function getActiveCfg(type, cfg) { var lineWidth = cfg.lineWidth || 0; return { lineWidth: lineWidth + 1 }; } }); function getCPath(from, to) { var points = []; points.push({ x: from.x, y: from.y * (1 - 1 / 2) + to.y * 1 / 2 }); points.push({ y: from.y * (1 - 1 / 2) + to.y * 1 / 2, x: to.x }); points.push(to); var sub = ['C']; Util.each(points, function (point) { sub.push(point.x, point.y); }); return sub; } function getQPath(to, center) { var points = []; points.push({ x: center.x, y: center.y }); points.push(to); var sub = ['Q']; Util.each(points, function (point) { sub.push(point.x, point.y); }); return sub; } function createSmoothPath(from, to) { var sub = getCPath(from, to); var path = [['M', from.x, from.y]]; path.push(sub); return path; } function createArcPath(from, to, center) { var sub = getQPath(to, center); var path = [['M', from.x, from.y]]; path.push(sub); return path; } function createArcWeightPath(points, center) { var arc1 = getQPath(points[1], center); var arc2 = getQPath(points[3], center); var path = [['M', points[0].x, points[0].y]]; path.push(arc2); path.push(['L', points[3].x, points[3].y]); path.push(['L', points[2].x, points[2].y]); path.push(arc1); path.push(['L', points[1].x, points[1].y]); path.push(['L', points[0].x, points[0].y]); path.push(['Z']); return path; } function createRectPath(from, to) { var points = []; points.push({ y: from.y * (1 - CORNER_PERCENT) + to.y * CORNER_PERCENT, x: from.x }); points.push({ y: from.y * (1 - CORNER_PERCENT) + to.y * CORNER_PERCENT, x: to.x }); points.push(to); var path = [['M', from.x, from.y]]; Util.each(points, function (point) { path.push(['L', point.x, point.y]); }); return path; } Shape.registerShape('edge', 'line', { draw: function draw(cfg, container) { var points = this.parsePoints(cfg.points); var attrCfg = getAttrs(cfg); var path = PathUtil.getLinePath(points); var line = container.addShape('path', { attrs: Util.mix(attrCfg, { path: path }) }); return line; }, getMarkerCfg: function getMarkerCfg(cfg) { return Util.mix({ symbol: 'circle', radius: 4.5 }, getAttrs(cfg)); } }); Shape.registerShape('edge', 'vhv', { draw: function draw(cfg, container) { var points = cfg.points; var attrCfg = getAttrs(cfg); var path = createRectPath(points[0], points[1]); path = this.parsePath(path); var line = container.addShape('path', { attrs: Util.mix(attrCfg, { path: path }) }); return line; }, getMarkerCfg: function getMarkerCfg(cfg) { return Util.mix({ symbol: 'circle', radius: 4.5 }, getAttrs(cfg)); } }); Shape.registerShape('edge', 'smooth', { draw: function draw(cfg, container) { var points = cfg.points; var attrCfg = getAttrs(cfg); var path = createSmoothPath(points[0], points[1]); path = this.parsePath(path); var line = container.addShape('path', { attrs: Util.mix(attrCfg, { path: path }) }); return line; }, getMarkerCfg: function getMarkerCfg(cfg) { return Util.mix({ symbol: 'circle', radius: 4.5 }, getAttrs(cfg)); } }); // 弧线包括笛卡尔坐标系下的半圆弧线、极坐标系下以圆心为控制点的二阶曲线、笛卡尔坐标系下带权重的三阶曲线、极坐标系下带权重的以圆心为控制点的二阶曲线 Shape.registerShape('edge', 'arc', { draw: function draw(cfg, container) { var points = cfg.points; var type = points.length > 2 ? 'weight' : 'normal'; var attrCfg = getAttrs(cfg); var line = void 0; var path = void 0; if (cfg.isInCircle) { var center = { x: 0, y: 1 }; if (type === 'normal') { path = createArcPath(points[0], points[1], center); } else { attrCfg.fill = attrCfg.stroke; path = createArcWeightPath(points, center); } path = this.parsePath(path); line = container.addShape('path', { attrs: Util.mix(attrCfg, { path: path }) }); } else { if (type === 'normal') { points = this.parsePoints(points); line = container.addShape('arc', { attrs: Util.mix(attrCfg, { x: (points[1].x + points[0].x) / 2, y: points[0].y, r: Math.abs(points[1].x - points[0].x) / 2, startAngle: Math.PI, endAngle: Math.PI * 2 }) }); } else { path = [['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y]]; var c1 = getCPath(points[1], points[3]); var c2 = getCPath(points[2], points[0]); path.push(c1); path.push(['L', points[3].x, points[3].y]); path.push(['L', points[2].x, points[2].y]); path.push(c2); path.push(['Z']); path = this.parsePath(path); attrCfg.fill = attrCfg.stroke; line = container.addShape('path', { attrs: Util.mix(attrCfg, { path: path }) }); } } return line; }, getMarkerCfg: function getMarkerCfg(cfg) { return Util.mix({ symbol: 'circle', radius: 4.5 }, getAttrs(cfg)); } }); module.exports = Edge; /***/ }), /* 305 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview interval shapes * @author dxq613@gmail.com * @author sima.zhang1990@gmail.com * @author huangtonger@aliyun.com */ var Util = __webpack_require__(0); var Shape = __webpack_require__(10); var PathUtil = __webpack_require__(14); var Global = __webpack_require__(1); // 获取柱状图的几个点 function getRectPoints(cfg, isPyramid) { var x = cfg.x; var y = cfg.y; var y0 = cfg.y0; // 0 点的位置 var width = cfg.size; // 有3种情况, // 1. y,x都不是数组 // 2. y是数组,x不是 // 3. x是数组,y不是 var ymin = y0; var ymax = y; if (Util.isArray(y)) { ymax = y[1]; ymin = y[0]; } var xmin = void 0; var xmax = void 0; if (Util.isArray(x)) { xmin = x[0]; xmax = x[1]; } else { xmin = x - width / 2; xmax = x + width / 2; } var points = []; points.push({ x: xmin, y: ymin }, { x: xmin, y: ymax }); if (isPyramid) { points.push({ x: xmax, y: (ymax + ymin) / 2 }); } else { points.push({ x: xmax, y: ymax }, { x: xmax, y: ymin }); } return points; } function getRectPath(points) { var path = []; for (var i = 0; i < points.length; i++) { var point = points[i]; if (point) { var action = i === 0 ? 'M' : 'L'; path.push([action, point.x, point.y]); } } var first = points[0]; path.push(['L', first.x, first.y]); path.push(['z']); return path; } function getLinePoints(cfg) { var x = cfg.x; var y = cfg.y; var y0 = cfg.y0; // 0 点的位置 var points = []; if (Util.isArray(y)) { Util.each(y, function (yItem, idx) { points.push({ x: Util.isArray(x) ? x[idx] : x, y: yItem }); }); } else { points.push({ x: x, y: y }, { x: x, y: y0 }); } return points; } function getTickPoints(cfg) { var x = cfg.x; var y = Util.isArray(cfg.y) ? cfg.y[1] : cfg.y; var y0 = Util.isArray(cfg.y) ? cfg.y[0] : cfg.y0; var barWidth = cfg.size; var points = []; points.push({ x: x - barWidth / 2, y: y }, { x: x + barWidth / 2, y: y }, { x: x, y: y }, { x: x, y: y0 }, { x: x - barWidth / 2, y: y0 }, { x: x + barWidth / 2, y: y0 }); return points; } function getTickPath(points) { var path = []; path.push(['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['M', points[2].x, points[2].y], ['L', points[3].x, points[3].y], ['M', points[4].x, points[4].y], ['L', points[5].x, points[5].y]); return path; } function getFillAttrs(cfg) { var defaultAttrs = Global.shape.interval; var attrs = Util.mix({}, defaultAttrs, { fill: cfg.color, stroke: cfg.color, fillOpacity: cfg.opacity }, cfg.style); return attrs; } function getLineAttrs(cfg) { var defaultAttrs = Global.shape.hollowInterval; var attrs = Util.mix({}, defaultAttrs, { stroke: cfg.color, strokeOpacity: cfg.opacity }, cfg.style); return attrs; } function getFunnelPath(cfg, isFunnel) { var path = []; var points = cfg.points; var nextPoints = cfg.nextPoints; if (!Util.isNil(nextPoints)) { path.push(['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['L', nextPoints[1].x, nextPoints[1].y], ['L', nextPoints[0].x, nextPoints[0].y], ['Z']); } else if (isFunnel) { path.push(['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['L', points[2].x, points[2].y], ['L', points[3].x, points[3].y], ['Z']); } else { path.push(['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['L', points[2].x, points[2].y], ['Z']); } return path; } function getThetaCfg(point, coord) { var r = coord.getRadius(); var inner = coord.innerRadius; var startAngle = void 0; var endAngle = void 0; var ir = r * inner; var startPoint = void 0; var endPoint = void 0; if (!Util.isArray(point.x) && Util.isArray(point.y)) { point.x = [point.x, point.x]; // 如果x是一个值,y是数组,将x转成数组 } if (Util.isArray(point.x)) { startPoint = { x: point.x[0], y: point.y[0] }; endPoint = { x: point.x[1], y: point.y[1] }; startAngle = PathUtil.getPointAngle(coord, startPoint); endAngle = PathUtil.getPointAngle(coord, endPoint); if (endAngle <= startAngle) { // 考虑占比百分百的情形 endAngle = endAngle + Math.PI * 2; } } else { endPoint = point; startAngle = coord.startAngle; endAngle = PathUtil.getPointAngle(coord, endPoint); } return { r: r, ir: ir, startAngle: startAngle, endAngle: endAngle }; } // 获取选中时的样式,当前仅支持饼图 function _getSelectedCfg(type, cfg) { var geom = cfg.geom; var coord = geom.get('coord'); var point = cfg.point; var r = 7.5; var selectedCfg = void 0; if (coord && coord.type === 'theta') { var thetaCfg = getThetaCfg(point, coord); var middleAngle = (thetaCfg.endAngle - thetaCfg.startAngle) / 2 + thetaCfg.startAngle; var x = r * Math.cos(middleAngle); var y = r * Math.sin(middleAngle); selectedCfg = { transform: [['t', x, y]] }; } return Util.mix({}, selectedCfg); } var Interval = Shape.registerFactory('interval', { defaultShapeType: 'rect', getActiveCfg: function getActiveCfg(type, cfg) { if (!type || Util.inArray(['rect', 'funnel', 'pyramid'], type)) { // 透明度降低 0.15 var fillOpacity = cfg.fillOpacity || cfg.opacity || 1; return { fillOpacity: fillOpacity - 0.15 }; } var lineWidth = cfg.lineWidth || 0; return { lineWidth: lineWidth + 1 }; }, getDefaultPoints: function getDefaultPoints(pointInfo) { return getRectPoints(pointInfo); }, getSelectedCfg: function getSelectedCfg(type, cfg) { return _getSelectedCfg(type, cfg); } }); // 默认柱状图 Shape.registerShape('interval', 'rect', { draw: function draw(cfg, container) { var attrs = getFillAttrs(cfg); var path = getRectPath(cfg.points); path = this.parsePath(path); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var rectCfg = getFillAttrs(cfg); var isInCircle = cfg.isInCircle; return Util.mix({ symbol: isInCircle ? 'circle' : 'square', radius: isInCircle ? 4.5 : 4 }, rectCfg); } }); // 空心柱状图 Shape.registerShape('interval', 'hollowRect', { draw: function draw(cfg, container) { var attrs = getLineAttrs(cfg); var path = getRectPath(cfg.points); path = this.parsePath(path); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var rectCfg = getLineAttrs(cfg); var isInCircle = cfg.isInCircle; return Util.mix({ symbol: isInCircle ? 'circle' : 'square', radius: isInCircle ? 4.5 : 4 }, rectCfg); } }); // 线形柱状图 Shape.registerShape('interval', 'line', { getPoints: function getPoints(pointInfo) { return getLinePoints(pointInfo); }, draw: function draw(cfg, container) { var attrs = getLineAttrs(cfg); attrs.lineWidth = cfg.size || 1; // size 就是线的宽度 var path = getRectPath(cfg.points); path = this.parsePath(path); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var lineCfg = getLineAttrs(cfg); return Util.mix({ symbol: 'line', radius: 5 }, lineCfg); } }); // 钉子形的柱状图 Shape.registerShape('interval', 'tick', { getPoints: function getPoints(pointInfo) { return getTickPoints(pointInfo); }, draw: function draw(cfg, container) { var attrs = getLineAttrs(cfg); var path = getTickPath(cfg.points); path = this.parsePath(path); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var lineCfg = getLineAttrs(cfg); return Util.mix({ symbol: 'tick', radius: 5 }, lineCfg); } }); // 漏斗图 Shape.registerShape('interval', 'funnel', { getPoints: function getPoints(pointInfo) { pointInfo.size = pointInfo.size * 2; // 漏斗图的 size 是柱状图的两倍 return getRectPoints(pointInfo); }, draw: function draw(cfg, container) { var attrs = getFillAttrs(cfg); var path = getFunnelPath(cfg, true); path = this.parsePath(path); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var funnelCfg = getFillAttrs(cfg); return Util.mix({ symbol: 'square', radius: 4 }, funnelCfg); } }); // 金字塔图 Shape.registerShape('interval', 'pyramid', { getPoints: function getPoints(pointInfo) { pointInfo.size = pointInfo.size * 2; // 漏斗图的 size 是柱状图的两倍 return getRectPoints(pointInfo, true); }, draw: function draw(cfg, container) { var attrs = getFillAttrs(cfg); var path = getFunnelPath(cfg, false); path = this.parsePath(path); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var funnelCfg = getFillAttrs(cfg); return Util.mix({ symbol: 'square', radius: 4 }, funnelCfg); } }); module.exports = Interval; /***/ }), /* 306 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview line shapes * @author dxq613@gmail.com * @author sima.zhang1990@gmail.com * @author huangtonger@aliyun.com */ var Util = __webpack_require__(0); var PathUtil = __webpack_require__(14); var ShapeUtil = __webpack_require__(67); var Shape = __webpack_require__(10); var Global = __webpack_require__(1); var DOT_ARR = [1, 1]; var DASH_ARR = [5.5, 1]; function getAttrs(cfg) { var defaultCfg = Global.shape.line; var shapeCfg = Util.mix({}, defaultCfg, { stroke: cfg.color, lineWidth: cfg.size, strokeOpacity: cfg.opacity, opacity: cfg.opacity }, cfg.style); return shapeCfg; } function getMarkerAttrs(cfg) { var defaultCfg = Global.shape.line; var shapeCfg = Util.mix({}, defaultCfg, { stroke: cfg.color, lineWidth: 2, strokeOpacity: cfg.opacity, opacity: cfg.opacity, radius: 6 }, cfg.style); return shapeCfg; } // 获取带有上下区间的 path function getRangePath(points, smooth, isInCircle, cfg) { var topPoints = []; var isStack = cfg.isStack; var bottomPoints = []; for (var i = 0; i < points.length; i++) { var point = points[i]; var tmp = ShapeUtil.splitPoints(point); bottomPoints.push(tmp[0]); topPoints.push(tmp[1]); } var topPath = getSinglePath(topPoints, smooth, isInCircle, cfg); var bottomPath = getSinglePath(bottomPoints, smooth, isInCircle, cfg); if (isStack) { return topPath; } return topPath.concat(bottomPath); } // 单条 path function getSinglePath(points, smooth, isInCircle, cfg) { var path = void 0; if (!smooth) { path = PathUtil.getLinePath(points, false); if (isInCircle) { path.push(['Z']); } } else { // 直角坐标系下绘制曲线时限制最大值、最小值 var constraint = cfg.constraint; if (isInCircle && points.length) { points.push({ x: points[0].x, y: points[0].y }); } path = PathUtil.getSplinePath(points, false, constraint); } return path; } // get line path function getPath(cfg, smooth) { var path = void 0; var points = cfg.points; var isInCircle = cfg.isInCircle; var first = points[0]; if (Util.isArray(first.y)) { path = getRangePath(points, smooth, isInCircle, cfg); } else { path = getSinglePath(points, smooth, isInCircle, cfg); } return path; } function _interpPoints(points, fn) { var tmpPoints = []; Util.each(points, function (point, index) { var nextPoint = points[index + 1]; tmpPoints.push(point); if (nextPoint) { tmpPoints = tmpPoints.concat(fn(point, nextPoint)); } }); return tmpPoints; } // 插值的图形path,不考虑null function _getInterPath(points) { var path = []; Util.each(points, function (point, index) { var subPath = index === 0 ? ['M', point.x, point.y] : ['L', point.x, point.y]; path.push(subPath); }); return path; } // 插值的图形 function _getInterPointShapeCfg(cfg, fn) { var points = _interpPoints(cfg.points, fn); return _getInterPath(points); } function _markerFn(x, y, r, ctx) { ctx.moveTo(x - r, y); ctx.lineTo(x + r, y); } function _smoothMarkerFn(x, y, r, ctx) { ctx.moveTo(x - r, y); ctx.arcTo(x - r / 2, y - r / 2, x, y, r / 2); ctx.lineTo(x, y); ctx.arcTo(x + r / 2, y + r / 2, x + r, y - r / 2, r / 2); } // get marker cfg function _getMarkerCfg(cfg, smooth) { return Util.mix({ symbol: smooth ? _smoothMarkerFn : _markerFn }, getMarkerAttrs(cfg)); } function _getInterMarkerCfg(cfg, fn) { return Util.mix({ symbol: fn }, getMarkerAttrs(cfg)); } // 当只有一个数据时绘制点 function drawPointShape(shapeObj, cfg, container) { var point = cfg.points[0]; return container.addShape('circle', { attrs: Util.mix({ x: point.x, y: point.y, r: 2, fill: cfg.color }, cfg.style) }); } // regist line geom var Line = Shape.registerFactory('line', { // 默认的shape defaultShapeType: 'line', getMarkerCfg: function getMarkerCfg(type, cfg) { var lineObj = Line[type] || Line.line; return lineObj.getMarkerCfg(cfg); }, getActiveCfg: function getActiveCfg(type, cfg) { var lineWidth = cfg.lineWidth || 0; return { lineWidth: lineWidth + 1 }; }, // 计算点 如果存在多个点,分割成单个的点, 不考虑多个x对应一个y的情况 getDefaultPoints: function getDefaultPoints(pointInfo) { return ShapeUtil.splitPoints(pointInfo); }, drawShape: function drawShape(type, cfg, container) { var shape = this.getShape(type); var gShape = void 0; if (cfg.points.length === 1 && Global.showSinglePoint) { gShape = drawPointShape(this, cfg, container); } else { gShape = shape.draw(cfg, container); } if (gShape) { gShape.set('origin', cfg.origin); gShape._id = cfg.splitedIndex ? cfg._id + cfg.splitedIndex : cfg._id; gShape.name = this.name; } return gShape; } }); // draw line shape Shape.registerShape('line', 'line', { draw: function draw(cfg, container) { var attrs = getAttrs(cfg); var path = getPath(cfg, false); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return _getMarkerCfg(cfg); } }); // 点线 ··· Shape.registerShape('line', 'dot', { draw: function draw(cfg, container) { var attrs = getAttrs(cfg); var path = getPath(cfg, false); return container.addShape('path', { attrs: Util.mix(attrs, { path: path, lineDash: DOT_ARR }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var tmp = _getMarkerCfg(cfg, false); tmp.lineDash = DOT_ARR; return tmp; } }); // 断线 - - - Shape.registerShape('line', 'dash', { draw: function draw(cfg, container) { var attrs = getAttrs(cfg); var path = getPath(cfg, false); return container.addShape('path', { attrs: Util.mix(attrs, { path: path, lineDash: DASH_ARR }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var tmp = _getMarkerCfg(cfg, false); tmp.lineDash = DASH_ARR; return tmp; } }); // draw smooth line shape Shape.registerShape('line', 'smooth', { draw: function draw(cfg, container) { var attrs = getAttrs(cfg); var coord = this._coord; // 曲线的限制 cfg.constraint = [[coord.start.x, coord.end.y], [coord.end.x, coord.start.y]]; var path = getPath(cfg, true); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return _getMarkerCfg(cfg, true); } }); Shape.registerShape('line', 'hv', { draw: function draw(cfg, container) { var attrs = getAttrs(cfg); var path = _getInterPointShapeCfg(cfg, function (point, nextPoint) { var tmp = []; tmp.push({ x: nextPoint.x, y: point.y }); return tmp; }); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return _getInterMarkerCfg(cfg, function (x, y, r, ctx) { ctx.moveTo(x - r - 1, y - 2.5); ctx.lineTo(x, y - 2.5); ctx.lineTo(x, y + 2.5); ctx.lineTo(x + r + 1, y + 2.5); }); } }); Shape.registerShape('line', 'vh', { draw: function draw(cfg, container) { var attrs = getAttrs(cfg); var path = _getInterPointShapeCfg(cfg, function (point, nextPoint) { var tmp = []; tmp.push({ x: point.x, y: nextPoint.y }); return tmp; }); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return _getInterMarkerCfg(cfg, function (x, y, r, ctx) { ctx.moveTo(x - r - 1, y + 2.5); ctx.lineTo(x, y + 2.5); ctx.lineTo(x, y - 2.5); ctx.lineTo(x + r + 1, y - 2.5); }); } }); Shape.registerShape('line', 'hvh', { draw: function draw(cfg, container) { var attrs = getAttrs(cfg); var path = _getInterPointShapeCfg(cfg, function (point, nextPoint) { var tmp = []; var middlex = (nextPoint.x - point.x) / 2 + point.x; tmp.push({ x: middlex, y: point.y }); tmp.push({ x: middlex, y: nextPoint.y }); return tmp; }); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return _getInterMarkerCfg(cfg, function (x, y, r, ctx) { ctx.moveTo(x - (r + 1), y + 2.5); ctx.lineTo(x - r / 2, y + 2.5); ctx.lineTo(x - r / 2, y - 2.5); ctx.lineTo(x + r / 2, y - 2.5); ctx.lineTo(x + r / 2, y + 2.5); ctx.lineTo(x + r + 1, y + 2.5); }); } }); Shape.registerShape('line', 'vhv', { draw: function draw(cfg, container) { var attrs = getAttrs(cfg); var path = _getInterPointShapeCfg(cfg, function (point, nextPoint) { var tmp = []; var middley = (nextPoint.y - point.y) / 2 + point.y; tmp.push({ x: point.x, y: middley }); tmp.push({ x: nextPoint.x, y: middley }); return tmp; }); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return _getInterMarkerCfg(cfg, function (x, y, r, ctx) { // 宽 13px,高 8px ctx.moveTo(x - 5, y + 2.5); ctx.lineTo(x - 5, y); ctx.lineTo(x, y); ctx.lineTo(x, y - 3); ctx.lineTo(x, y + 3); ctx.lineTo(x + 6.5, y + 3); }); } }); Line.spline = Line.smooth; module.exports = Line; /***/ }), /* 307 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview point shapes * @author dxq613@gmail.com * @author sima.zhang1990@gmail.com * @author huangtonger@aliyun.com */ var Util = __webpack_require__(0); var ShapeUtil = __webpack_require__(67); var Marker = __webpack_require__(2).Marker; var Global = __webpack_require__(1); var Shape = __webpack_require__(10); var SHAPES = ['circle', 'square', 'bowtie', 'diamond', 'hexagon', 'triangle', 'triangle-down']; var HOLLOW_SHAPES = ['cross', 'tick', 'plus', 'hyphen', 'line', 'pointerLine', 'pointerArrow']; var SQRT_3 = Math.sqrt(3); // 增加marker Util.mix(Marker.Symbols, { hexagon: function hexagon(x, y, r, ctx) { var diffX = r / 2 * SQRT_3; ctx.moveTo(x, y - r); ctx.lineTo(x + diffX, y - r / 2); ctx.lineTo(x + diffX, y + r / 2); ctx.lineTo(x, y + r); ctx.lineTo(x - diffX, y + r / 2); ctx.lineTo(x - diffX, y - r / 2); ctx.closePath(); }, bowtie: function bowtie(x, y, r, ctx) { var diffY = r - 1.5; ctx.moveTo(x - r, y - diffY); ctx.lineTo(x + r, y + diffY); ctx.lineTo(x + r, y - diffY); ctx.lineTo(x - r, y + diffY); ctx.closePath(); }, cross: function cross(x, y, r, ctx) { ctx.moveTo(x - r, y - r); ctx.lineTo(x + r, y + r); ctx.moveTo(x + r, y - r); ctx.lineTo(x - r, y + r); }, tick: function tick(x, y, r, ctx) { ctx.moveTo(x - r / 2, y - r); ctx.lineTo(x + r / 2, y - r); ctx.moveTo(x, y - r); ctx.lineTo(x, y + r); ctx.moveTo(x - r / 2, y + r); ctx.lineTo(x + r / 2, y + r); }, plus: function plus(x, y, r, ctx) { ctx.moveTo(x - r, y); ctx.lineTo(x + r, y); ctx.moveTo(x, y - r); ctx.lineTo(x, y + r); }, hyphen: function hyphen(x, y, r, ctx) { ctx.moveTo(x - r, y); ctx.lineTo(x + r, y); }, line: function line(x, y, r, ctx) { ctx.moveTo(x, y - r); ctx.lineTo(x, y + r); } }); function getFillAttrs(cfg) { var defaultAttrs = Global.shape.point; var pointAttrs = Util.mix({}, defaultAttrs, { fill: cfg.color, fillOpacity: cfg.opacity, radius: cfg.size }, cfg.style); return pointAttrs; } function getLineAttrs(cfg) { var defaultAttrs = Global.shape.hollowPoint; var pointAttrs = Util.mix({}, defaultAttrs, { stroke: cfg.color, strokeOpacity: cfg.opacity, radius: cfg.size }, cfg.style); return pointAttrs; } var Point = Shape.registerFactory('point', { defaultShapeType: 'hollowCircle', getActiveCfg: function getActiveCfg(type, cfg) { // 点放大 + 颜色加亮 var radius = cfg.radius; var color = void 0; if (type && (type.indexOf('hollow') === 0 || Util.indexOf(HOLLOW_SHAPES, type) !== -1) || !type) { color = cfg.stroke || cfg.strokeStyle; } else { color = cfg.fill || cfg.fillStyle; } return { radius: radius + 1, shadowBlur: radius, shadowColor: color, stroke: color, strokeStyle: color, strokeOpacity: 1, lineWidth: 1 }; }, getDefaultPoints: function getDefaultPoints(pointInfo) { return ShapeUtil.splitPoints(pointInfo); } }); function getRectPath(cfg) { var x = cfg.points[0].x; var y = cfg.points[0].y; var w = cfg.size[0]; var h = cfg.size[1]; var path = [['M', x - 0.5 * w, y - 0.5 * h], ['L', x + 0.5 * w, y - 0.5 * h], ['L', x + 0.5 * w, y + 0.5 * h], ['L', x - 0.5 * w, y + 0.5 * h], ['z']]; return path; } // 用于桑基图的节点 Shape.registerShape('point', 'rect', { draw: function draw(cfg, container) { var rectAttrs = getFillAttrs(cfg); var path = getRectPath(cfg); path = this.parsePath(path); var gShape = container.addShape('path', { attrs: Util.mix(rectAttrs, { path: path }) }); return gShape; }, getMarkerCfg: function getMarkerCfg(cfg) { var attrs = getFillAttrs(cfg); attrs.symbol = 'rect'; attrs.radius = 4.5; return attrs; } }); // 添加shapes Util.each(SHAPES, function (shape) { Shape.registerShape('point', shape, { draw: function draw(cfg, container) { // cfg.points = this.parsePoints(cfg.points); var attrs = getFillAttrs(cfg); return container.addShape('Marker', { attrs: Util.mix(attrs, { symbol: shape, x: cfg.x, y: cfg.y }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var attrs = getFillAttrs(cfg); attrs.symbol = shape; attrs.radius = 4.5; return attrs; } }); // 添加该 shape 对应的 hollowShape Shape.registerShape('point', 'hollow' + Util.upperFirst(shape), { draw: function draw(cfg, container) { // cfg.points = this.parsePoints(cfg.points); var attrs = getLineAttrs(cfg); return container.addShape('Marker', { attrs: Util.mix(attrs, { symbol: shape, x: cfg.x, y: cfg.y }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var attrs = getLineAttrs(cfg); attrs.symbol = shape; attrs.radius = 4.5; return attrs; } }); }); // 添加 hollowShapes Util.each(HOLLOW_SHAPES, function (shape) { Shape.registerShape('point', shape, { draw: function draw(cfg, container) { var attrs = getLineAttrs(cfg); return container.addShape('Marker', { attrs: Util.mix(attrs, { symbol: shape, x: cfg.x, y: cfg.y }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { var attrs = getLineAttrs(cfg); attrs.symbol = shape; attrs.radius = 4.5; return attrs; } }); }); module.exports = Point; /***/ }), /* 308 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview line shapes * @author dxq613@gmail.com * @author sima.zhang1990@gmail.com * @author huangtonger@aliyun.com */ var Util = __webpack_require__(0); var Shape = __webpack_require__(10); var Global = __webpack_require__(1); function getAttrs(cfg) { var defaultCfg = Global.shape.polygon; var shapeCfg = Util.mix({}, defaultCfg, { stroke: cfg.color, fill: cfg.color, fillOpacity: cfg.opacity }, cfg.style); return shapeCfg; } function getHollowAttrs(cfg) { var defaultCfg = Global.shape.hollowPolygon; var shapeCfg = Util.mix({}, defaultCfg, { stroke: cfg.color, strokeOpacity: cfg.opacity }, cfg.style); return shapeCfg; } function getPath(points) { var path = []; var flag = [points[0].x, points[0].y]; var flagIndex = 0; var lastStartPoint = points[0]; Util.each(points, function (obj, index) { var subPath = index === 0 ? ['M', obj.x, obj.y] : ['L', obj.x, obj.y]; path.push(subPath); if (flagIndex !== index && index < points.length - 1 && Util.isEqualWith(flag, [obj.x, obj.y])) { var nextPoint = points[index + 1]; path.push(['Z']); path.push(['M', nextPoint.x, nextPoint.y]); lastStartPoint = nextPoint; flagIndex = index + 1; flag = [nextPoint.x, nextPoint.y]; } }); path.push(['L', lastStartPoint.x, lastStartPoint.y]); path.push(['Z']); // console.log(Util.map(path, points => points.join('')).join('')); return path; } // regist line geom var Polygon = Shape.registerFactory('polygon', { defaultShapeType: 'polygon', getDefaultPoints: function getDefaultPoints(pointInfo) { var points = []; Util.each(pointInfo.x, function (subX, index) { var subY = pointInfo.y[index]; points.push({ x: subX, y: subY }); }); return points; }, getActiveCfg: function getActiveCfg(type, cfg) { var lineWidth = cfg.lineWidth || 1; if (type === 'hollow') { return { lineWidth: lineWidth + 1 }; } var opacity = cfg.fillOpacity || cfg.opacity || 1; return { // lineWidth, fillOpacity: opacity - 0.08 }; }, getSelectedCfg: function getSelectedCfg(type, cfg) { if (cfg && cfg.style) { return cfg.style; } return this.getActiveCfg(type, cfg); } }); Shape.registerShape('polygon', 'polygon', { draw: function draw(cfg, container) { if (!Util.isEmpty(cfg.points)) { var attrs = getAttrs(cfg); var path = getPath(cfg.points); path = this.parsePath(path); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); } }, getMarkerCfg: function getMarkerCfg(cfg) { return Util.mix({ symbol: 'square', radius: 4 }, getAttrs(cfg)); } }); Shape.registerShape('polygon', 'hollow', { draw: function draw(cfg, container) { if (!Util.isEmpty(cfg.points)) { var attrs = getHollowAttrs(cfg); var path = getPath(cfg.points); path = this.parsePath(path); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); } }, getMarkerCfg: function getMarkerCfg(cfg) { return Util.mix({ symbol: 'square', radius: 4 }, getAttrs(cfg)); } }); module.exports = Polygon; /***/ }), /* 309 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 自定义的 shape * @author dxq613@gmail.com * @author sima.zhang1990@gmail.com */ var Util = __webpack_require__(0); var Shape = __webpack_require__(10); var Global = __webpack_require__(1); function _parseValue(value) { if (!Util.isArray(value)) { value = [value]; } var min = value[0]; // 最小值 var max = value[value.length - 1]; // 最大值 var min1 = value.length > 1 ? value[1] : min; var max1 = value.length > 3 ? value[3] : max; var median = value.length > 2 ? value[2] : min1; return { min: min, // 最小值 max: max, // 最大值 min1: min1, max1: max1, median: median }; } function addPoints(from, to) { Util.each(from, function (subArr) { to.push({ x: subArr[0], y: subArr[1] }); }); } function getAttrs(cfg) { var defaultAttrs = Global.shape.schema; var attrs = Util.mix({}, defaultAttrs, { stroke: cfg.color, strokeOpacity: cfg.opacity }, cfg.style); return attrs; } function getFillAttrs(cfg) { var defaultAttrs = Global.shape.schema; var attrs = Util.mix({}, defaultAttrs, { fill: cfg.color, stroke: cfg.color, fillOpacity: cfg.opacity }, cfg.style); return attrs; } function getBoxPoints(x, y, width) { var points = []; var pointsArray = void 0; var obj = void 0; if (Util.isArray(y)) { // 2维 obj = _parseValue(y); pointsArray = [[x - width / 2, obj.max], [x + width / 2, obj.max], [x, obj.max], [x, obj.max1], [x - width / 2, obj.min1], [x - width / 2, obj.max1], [x + width / 2, obj.max1], [x + width / 2, obj.min1], [x, obj.min1], [x, obj.min], [x - width / 2, obj.min], [x + width / 2, obj.min], [x - width / 2, obj.median], [x + width / 2, obj.median]]; } else { // 只有一个维度 y = y || 0.5; obj = _parseValue(x); pointsArray = [[obj.min, y - width / 2], [obj.min, y + width / 2], [obj.min, y], [obj.min1, y], [obj.min1, y - width / 2], [obj.min1, y + width / 2], [obj.max1, y + width / 2], [obj.max1, y - width / 2], [obj.max1, y], [obj.max, y], [obj.max, y - width / 2], [obj.max, y + width / 2], [obj.median, y - width / 2], [obj.median, y + width / 2]]; } addPoints(pointsArray, points); return points; } function _sortValue(value) { if (!Util.isArray(value)) { value = [value]; } // 从大到小排序 var sorted = value.sort(function (a, b) { return a < b ? 1 : -1; }); var length = sorted.length; if (length < 4) { var min = sorted[length - 1]; for (var i = 0; i < 4 - length; i++) { sorted.push(min); } } return sorted; } // 获取K线图的points function getCandlePoints(x, y, width) { var yValues = _sortValue(y); var points = [{ x: x, y: yValues[0] }, { x: x, y: yValues[1] }, { x: x - width / 2, y: yValues[2] }, { x: x - width / 2, y: yValues[1] }, { x: x + width / 2, y: yValues[1] }, { x: x + width / 2, y: yValues[2] }, { x: x, y: yValues[2] }, { x: x, y: yValues[3] }]; // 按照顺时针连接 return points; } function getBoxPath(points) { var path = [['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['M', points[2].x, points[2].y], ['L', points[3].x, points[3].y], ['M', points[4].x, points[4].y], ['L', points[5].x, points[5].y], ['L', points[6].x, points[6].y], ['L', points[7].x, points[7].y], ['L', points[4].x, points[4].y], // 封闭 z ['Z'], ['M', points[8].x, points[8].y], ['L', points[9].x, points[9].y], ['M', points[10].x, points[10].y], ['L', points[11].x, points[11].y], ['M', points[12].x, points[12].y], ['L', points[13].x, points[13].y]]; return path; } function getCandlePath(points) { var path = [['M', points[0].x, points[0].y], ['L', points[1].x, points[1].y], ['M', points[2].x, points[2].y], ['L', points[3].x, points[3].y], ['L', points[4].x, points[4].y], ['L', points[5].x, points[5].y], ['Z'], ['M', points[6].x, points[6].y], ['L', points[7].x, points[7].y]]; return path; } var Schema = Shape.registerFactory('schema', { defaultShapeType: '', getActiveCfg: function getActiveCfg(type, cfg) { if (type === 'box') { var lineWidth = cfg.lineWidth || 1; return { lineWidth: lineWidth + 1 }; } var opacity = cfg.fillOpacity || cfg.opacity || 1; return { fillOpacity: opacity - 0.15, strokeOpacity: opacity - 0.15 }; }, getSelectedCfg: function getSelectedCfg(type, cfg) { if (cfg && cfg.style) { return cfg.style; } return this.getActiveCfg(type, cfg); } }); // 箱线图 Shape.registerShape('schema', 'box', { getPoints: function getPoints(pointInfo) { return getBoxPoints(pointInfo.x, pointInfo.y, pointInfo.size); }, draw: function draw(cfg, container) { var attrs = getAttrs(cfg); var path = getBoxPath(cfg.points); path = this.parsePath(path); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return { symbol: function symbol(x, y, r, ctx) { var yValues = [y - 6, y - 3, y, y + 3, y + 6]; var points = getBoxPoints(x, yValues, r); ctx.moveTo(points[0].x + 1, points[0].y); ctx.lineTo(points[1].x - 1, points[1].y); ctx.moveTo(points[2].x, points[2].y); ctx.lineTo(points[3].x, points[3].y); ctx.moveTo(points[4].x, points[4].y); ctx.lineTo(points[5].x, points[5].y); ctx.lineTo(points[6].x, points[6].y); ctx.lineTo(points[7].x, points[7].y); ctx.lineTo(points[4].x, points[4].y); ctx.closePath(); ctx.moveTo(points[8].x, points[8].y); ctx.lineTo(points[9].x, points[9].y); ctx.moveTo(points[10].x + 1, points[10].y); ctx.lineTo(points[11].x - 1, points[11].y); ctx.moveTo(points[12].x, points[12].y); ctx.lineTo(points[13].x, points[13].y); }, radius: 6, lineWidth: 1, stroke: cfg.color }; } }); // K线 Shape.registerShape('schema', 'candle', { getPoints: function getPoints(pointInfo) { return getCandlePoints(pointInfo.x, pointInfo.y, pointInfo.size); }, draw: function draw(cfg, container) { var attrs = getFillAttrs(cfg); var path = getCandlePath(cfg.points); path = this.parsePath(path); return container.addShape('path', { attrs: Util.mix(attrs, { path: path }) }); }, getMarkerCfg: function getMarkerCfg(cfg) { return { symbol: function symbol(x, y, r, ctx) { y = [y + 7.5, y + 3, y - 3, y - 7.5]; var points = getCandlePoints(x, y, r); ctx.moveTo(points[0].x, points[0].y); ctx.lineTo(points[1].x, points[1].y); ctx.moveTo(points[2].x, points[2].y); ctx.lineTo(points[3].x, points[3].y); ctx.lineTo(points[4].x, points[4].y); ctx.lineTo(points[5].x, points[5].y); ctx.closePath(); ctx.moveTo(points[6].x, points[6].y); ctx.lineTo(points[7].x, points[7].y); }, lineWidth: 1, stroke: cfg.color, fill: cfg.color, radius: 6 }; } }); module.exports = Schema; /***/ }), /* 310 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview The tooltip handler * @author sima.zhang */ var Util = __webpack_require__(0); var _require = __webpack_require__(1), defaultColor = _require.defaultColor; var FIELD_ORIGIN = '_origin'; function getScaleName(scale) { return scale.alias || scale.field; } var TooltipMixin = { _snapEqual: function _snapEqual(v1, v2, scale) { var equals = void 0; v1 = scale.translate(v1); v2 = scale.translate(v2); if (scale.isCategory) { equals = v1 === v2; } else { equals = Util.snapEqual(v1, v2); } return equals; }, _getScaleValueByPoint: function _getScaleValueByPoint(point) { var result = 0; var coord = this.get('coord'); var xScale = this.getXScale(); var invertPoint = coord.invert(point); var xValue = invertPoint.x; if (this.isInCircle() && xValue > (1 + xScale.rangeMax()) / 2) { xValue = xScale.rangeMin(); // 极坐标下,scale 的 range 被做过特殊处理 see view.js#L88 } result = xScale.invert(xValue); if (xScale.isCategory) { result = xScale.translate(result); // 防止分类类型 } return result; }, _getOriginByPoint: function _getOriginByPoint(point) { var xScale = this.getXScale(); var yScale = this.getYScale(); var xField = xScale.field; var yField = yScale.field; var coord = this.get('coord'); var invertPoint = coord.invert(point); var xValue = xScale.invert(invertPoint.x); var yValue = yScale.invert(invertPoint.y); var result = {}; result[xField] = xValue; result[yField] = yValue; return result; }, _getScale: function _getScale(field) { var self = this; var scales = self.get('scales'); var rst = null; Util.each(scales, function (scale) { if (scale.field === field) { rst = scale; return false; } }); return rst; }, // 获取值对应的度量 _getTipValueScale: function _getTipValueScale() { var attrs = this.getAttrsForLegend(); var scale = void 0; Util.each(attrs, function (attr) { var tmpScale = attr.getScale(attr.type); if (tmpScale.isLinear) { // 如果指定字段是非position的,同时是连续的 scale = tmpScale; return false; } }); var xScale = this.getXScale(); var yScale = this.getYScale(); if (!scale && yScale && yScale.field === '..y') { return xScale; } return scale || yScale || xScale; }, _getTipTitleScale: function _getTipTitleScale(titleField) { var self = this; if (titleField) { return self._getScale(titleField); } var position = self.getAttr('position'); var fields = position.getFields(); var tmpField = void 0; Util.each(fields, function (field) { if (field.indexOf('..') === -1) { tmpField = field; return false; } }); return self._getScale(tmpField); }, _filterValue: function _filterValue(arr, point) { var coord = this.get('coord'); var yScale = this.getYScale(); var yField = yScale.field; var invertPoint = coord.invert(point); var yValue = invertPoint.y; yValue = yScale.invert(yValue); var rst = arr[arr.length - 1]; Util.each(arr, function (obj) { var origin = obj[FIELD_ORIGIN]; if (origin[yField][0] <= yValue && origin[yField][1] >= yValue) { rst = obj; return false; } }); return rst; }, getXDistance: function getXDistance() { var self = this; var distance = self.get('xDistance'); if (!distance) { var xScale = self.getXScale(); if (xScale.isCategory) { distance = 1; } else { var values = xScale.values; // values 是无序的 var min = xScale.translate(values[0]); var max = min; Util.each(values, function (value) { // 时间类型需要 translate value = xScale.translate(value); if (value < min) { min = value; } if (value > max) { max = value; } }); var length = values.length; // 应该是除以 length - 1 distance = (max - min) / (length - 1); } self.set('xDistance', distance); } return distance; }, findPoint: function findPoint(point, dataArray) { var self = this; var type = self.get('type'); var xScale = self.getXScale(); var yScale = self.getYScale(); var xField = xScale.field; var yField = yScale.field; var rst = null; if (Util.indexOf(['heatmap'], type) > -1) { var coord = self.get('coord'); var invertPoint = coord.invert(point); var xValue = xScale.invert(invertPoint.x); var yValue = yScale.invert(invertPoint.y); var min = Infinity; Util.each(dataArray, function (obj) { var distance = Math.pow(obj[FIELD_ORIGIN][xField] - xValue, 2) + Math.pow(obj[FIELD_ORIGIN][yField] - yValue, 2); if (distance < min) { min = distance; rst = obj; } }); return rst; } var first = dataArray[0]; var last = dataArray[dataArray.length - 1]; if (!first) { return rst; } var value = self._getScaleValueByPoint(point); // 根据该点获得对应度量后数据的值 var firstXValue = first[FIELD_ORIGIN][xField]; var firstYValue = first[FIELD_ORIGIN][yField]; var lastXValue = last[FIELD_ORIGIN][xField]; var isYRange = yScale.isLinear && Util.isArray(firstYValue); // 考虑 x 维度相同,y 是数组区间的情况 // 如果x的值是数组 if (Util.isArray(firstXValue)) { Util.each(dataArray, function (record) { var origin = record[FIELD_ORIGIN]; if (xScale.translate(origin[xField][0]) <= value && xScale.translate(origin[xField][1]) >= value) { if (isYRange) { if (!Util.isArray(rst)) { rst = []; } rst.push(record); } else { rst = record; return false; } } }); if (Util.isArray(rst)) { rst = this._filterValue(rst, point); } } else { var next = void 0; if (!xScale.isLinear && xScale.type !== 'timeCat') { Util.each(dataArray, function (record, index) { var origin = record[FIELD_ORIGIN]; if (self._snapEqual(origin[xField], value, xScale)) { if (isYRange) { if (!Util.isArray(rst)) { rst = []; } rst.push(record); } else { rst = record; return false; } } else if (xScale.translate(origin[xField]) <= value) { last = record; next = dataArray[index + 1]; } }); if (Util.isArray(rst)) { rst = this._filterValue(rst, point); } } else { if ((value > xScale.translate(lastXValue) || value < xScale.translate(firstXValue)) && (value > xScale.max || value < xScale.min)) { return null; } var firstIdx = 0; var lastIdx = dataArray.length - 1; var middleIdx = void 0; while (firstIdx <= lastIdx) { middleIdx = Math.floor((firstIdx + lastIdx) / 2); var item = dataArray[middleIdx][FIELD_ORIGIN][xField]; if (self._snapEqual(item, value, xScale)) { return dataArray[middleIdx]; } if (xScale.translate(item) <= xScale.translate(value)) { firstIdx = middleIdx + 1; last = dataArray[middleIdx]; next = dataArray[middleIdx + 1]; } else { if (lastIdx === 0) { last = dataArray[0]; } lastIdx = middleIdx - 1; } } } if (last && next) { // 计算最逼近的 if (Math.abs(xScale.translate(last[FIELD_ORIGIN][xField]) - value) > Math.abs(xScale.translate(next[FIELD_ORIGIN][xField]) - value)) { last = next; } } } var distance = self.getXDistance(); // 每个分类间的平均间距 if (!rst && Math.abs(xScale.translate(last[FIELD_ORIGIN][xField]) - value) <= distance / 2) { rst = last; } return rst; }, /** * @protected * 获取tooltip的标题 * @param {Object} origin 点的原始信息 * @param {String} titleField 标题的字段 * @return {String} 提示信息的标题 */ getTipTitle: function getTipTitle(origin, titleField) { var tipTitle = ''; var titleScale = this._getTipTitleScale(titleField); if (titleScale) { var value = origin[titleScale.field]; tipTitle = titleScale.getText(value); } else if (this.get('type') === 'heatmap') { // 热力图在不存在 title 的时候特殊处理 var xScale = this.getXScale(); var yScale = this.getYScale(); var xValue = xScale.getText(origin[xScale.field]); var yValue = yScale.getText(origin[yScale.field]); tipTitle = '( ' + xValue + ', ' + yValue + ' )'; } return tipTitle; }, getTipValue: function getTipValue(origin, valueScale) { var value = void 0; var field = valueScale.field; value = origin[field]; if (Util.isArray(value)) { var tmp = []; Util.each(value, function (sub) { tmp.push(valueScale.getText(sub)); }); value = tmp.join('-'); } else { value = valueScale.getText(value); } return value; }, /** * @protected * 获取tooltip的名称 * @param {Object} origin 点的原始信息 * @return {String} 提示信息的名称 */ getTipName: function getTipName(origin) { var name = void 0; var nameScale = void 0; var groupScales = this._getGroupScales(); if (groupScales.length) { // 如果存在分组类型,取第一个分组类型 Util.each(groupScales, function (scale) { nameScale = scale; return false; }); } if (nameScale) { var field = nameScale.field; name = nameScale.getText(origin[field]); } else { var valueScale = this._getTipValueScale(); name = getScaleName(valueScale); } return name; }, /** * 获取点对应tooltip的信息 * @protected * @param {Object} point 原始的数据记录 * @param {String} titleField tooltipTitle 配置信息 * @return {Array} 一条或者多条记录 */ getTipItems: function getTipItems(point, titleField) { var self = this; var origin = point[FIELD_ORIGIN]; var tipTitle = self.getTipTitle(origin, titleField); var tooltipCfg = self.get('tooltipCfg'); var items = []; var name = void 0; var value = void 0; function addItem(itemName, itemValue, cfg) { if (!Util.isNil(itemValue) && itemValue !== '') { // 值为null的时候,忽视 var item = { title: tipTitle, point: point, name: itemName || tipTitle, value: itemValue, color: point.color || defaultColor, marker: true }; if (self.get('type') === 'interval' || self.get('type') === 'schema') { item.size = self.getSize(); } items.push(Util.mix({}, item, cfg)); } } if (tooltipCfg) { var fields = tooltipCfg.fields; var cfg = tooltipCfg.cfg; var callbackParams = []; Util.each(fields, function (field) { callbackParams.push(origin[field]); }); if (cfg) { // 存在回调函数 if (Util.isFunction(cfg)) { cfg = cfg.apply(null, callbackParams); } var itemCfg = Util.mix({}, { point: point, title: tipTitle, color: point.color || defaultColor, marker: true // 默认展示 marker }, cfg); if (self.get('type') === 'interval' || self.get('type') === 'schema') { itemCfg.size = self.getSize(); } items.push(itemCfg); } else { Util.each(fields, function (field) { if (!Util.isNil(origin[field])) { // 字段数据为null ,undefined时不显示 var scale = self._getScale(field); name = getScaleName(scale); value = scale.getText(origin[field]); addItem(name, value); } }); } } else { var valueScale = self._getTipValueScale(); if (!Util.isNil(origin[valueScale.field])) { // 字段数据为null ,undefined时不显示 value = self.getTipValue(origin, valueScale); name = self.getTipName(origin); addItem(name, value); } } return items; }, isShareTooltip: function isShareTooltip() { var shareTooltip = this.get('shareTooltip'); var type = this.get('type'); var view = this.get('view'); var options = void 0; if (view.get('parent')) { options = view.get('parent').get('options'); } else { options = view.get('options'); } if (type === 'interval') { var coord = this.get('coord'); var coordType = coord.type; if (coordType === 'theta' || coordType === 'polar' && coord.isTransposed) { shareTooltip = false; } } else if (!this.getYScale() || Util.inArray(['contour', 'point', 'polygon', 'edge'], type)) { shareTooltip = false; } if (options.tooltip && Util.isBoolean(options.tooltip.shared)) { // 以用户设置的为准 shareTooltip = options.tooltip.shared; } return shareTooltip; } }; module.exports = TooltipMixin; /***/ }), /* 311 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview the interaction when geom was actived * @author sima.zhang */ var Util = __webpack_require__(0); var FIELD_ORIGIN = '_origin'; function isSameShape(shape1, shape2) { if (Util.isNil(shape1) || Util.isNil(shape2)) { return false; } var shape1Origin = shape1.get('origin'); var shape2Origin = shape2.get('origin'); return Util.isEqual(shape1Origin, shape2Origin); } function isChange(preShapes, shapes) { if (!preShapes) { return true; } if (preShapes.length !== shapes.length) { return true; } var rst = false; Util.each(shapes, function (shape, index) { if (!isSameShape(shape, preShapes[index])) { rst = true; return false; } }); return rst; } var ActiveMixin = { _isAllowActive: function _isAllowActive() { var allowActive = this.get('allowActive'); if (Util.isNil(allowActive)) { // 用户未设置,使用默认的策略 var view = this.get('view'); var isShareTooltip = this.isShareTooltip(); var options = view.get('options'); // 默认情况下,tooltip 关闭或者 tooltip 模式为 shared === false 的时候允许 active if (options.tooltip === false || !isShareTooltip) { return true; } } else { return allowActive; } return false; }, _onMouseenter: function _onMouseenter(ev) { var self = this; var shape = ev.shape; var shapeContainer = self.get('shapeContainer'); if (shape && !shape.get('animating') && shapeContainer.contain(shape) && self._isAllowActive()) { self.setShapesActived(shape); } }, _onMouseleave: function _onMouseleave() { var self = this; var view = self.get('view'); var canvas = view.get('canvas'); if (self.get('activeShapes')) { self.clearActivedShapes(); canvas.draw(); } }, _bindActiveAction: function _bindActiveAction() { var self = this; var view = self.get('view'); var type = self.get('type'); view.on(type + ':mouseenter', Util.wrapBehavior(self, '_onMouseenter')); view.on(type + ':mouseleave', Util.wrapBehavior(self, '_onMouseleave')); }, _offActiveAction: function _offActiveAction() { var self = this; var view = self.get('view'); var type = self.get('type'); view.off(type + ':mouseenter', Util.getWrapBehavior(self, '_onMouseenter')); view.off(type + ':mouseleave', Util.getWrapBehavior(self, '_onMouseleave')); }, _setActiveShape: function _setActiveShape(shape) { var self = this; var shapeData = shape.get('origin'); var shapeName = shapeData.shape || self.getDefaultValue('shape'); if (Util.isArray(shapeName)) { shapeName = shapeName[0]; } var shapeFactory = self.get('shapeFactory'); var shapeCfg = Util.mix({}, shape.__attrs, { origin: shapeData }); var activeCfg = shapeFactory.getActiveCfg(shapeName, shapeCfg); Util.mix(shape.__attrs, activeCfg); shape.setZIndex(1); // 提前 }, setShapesActived: function setShapesActived(shapes) { var self = this; var isStop = false; // 判断 shape 是否正在动画 if (!Util.isArray(shapes)) { shapes = [shapes]; } var preShapes = self.get('preShapes'); // 获取上次被激活的 shapes if (!isChange(preShapes, shapes)) { return; } if (preShapes) { self.clearActivedShapes(); // 先清除激活元素 } var view = self.get('view'); var canvas = view.get('canvas'); var shapeContainer = self.get('shapeContainer'); Util.each(shapes, function (shape) { if (shape.get('animating')) { isStop = true; return false; } if (!shape.get('_originAttrs')) { shape.set('_originAttrs', Util.cloneDeep(shape.__attrs)); // 缓存原来的属性,由于 __attrs.matrix 是数组,所以此处需要深度复制 } if (shape.get('visible') && !shape.get('selected')) { self._setActiveShape(shape); } }); if (isStop) { return; } self.set('activeShapes', shapes); self.set('preShapes', shapes); shapeContainer.sort(); canvas.draw(); }, clearActivedShapes: function clearActivedShapes() { var self = this; var shapeContainer = self.get('shapeContainer'); if (shapeContainer && !shapeContainer.get('destroyed')) { var activeShapes = self.get('activeShapes'); Util.each(activeShapes, function (activeShape) { if (!activeShape.get('selected')) { var originAttrs = activeShape.get('_originAttrs'); activeShape.__attrs = Util.cloneDeep(originAttrs); activeShape.setZIndex(0); activeShape.set('_originAttrs', null); } }); var preHighlightShapes = self.get('preHighlightShapes'); if (preHighlightShapes) { var shapes = shapeContainer.get('children'); Util.each(shapes, function (shape) { if (!shape.get('selected')) { var originAttrs = shape.get('_originAttrs'); if (originAttrs) { shape.__attrs = Util.cloneDeep(originAttrs); shape.setZIndex(0); shape.set('_originAttrs', null); } } }); } // 恢复原来排序 var children = shapeContainer.get('children'); children.sort(function (obj1, obj2) { return obj1._INDEX - obj2._INDEX; }); self.set('activeShapes', null); self.set('preShapes', null); self.set('preHighlightShapes', null); } }, getGroupShapesByPoint: function getGroupShapesByPoint(point) { var self = this; var shapeContainer = self.get('shapeContainer'); var activeShapes = []; if (shapeContainer) { var xField = self.getXScale().field; var shapes = self.getShapes(); var originObj = self._getOriginByPoint(point); Util.each(shapes, function (shape) { var origin = shape.get('origin'); if (shape.get('visible') && origin) { // 有可能不是图形,而是label文本,所以判断一下 var shapeXValue = origin[FIELD_ORIGIN][xField]; if (shapeXValue === originObj[xField]) { activeShapes.push(shape); } } }); } return activeShapes; }, getSingleShapeByPoint: function getSingleShapeByPoint(point) { var self = this; var shapeContainer = self.get('shapeContainer'); var canvas = shapeContainer.get('canvas'); var pixelRatio = canvas.get('pixelRatio'); var result = void 0; if (shapeContainer) { result = shapeContainer.getShape(point.x * pixelRatio, point.y * pixelRatio); } if (result && result.get('origin')) { return result; } }, highlightShapes: function highlightShapes(_highlightShapes, highlightCfg) { var self = this; if (!Util.isArray(_highlightShapes)) { _highlightShapes = [_highlightShapes]; } var preHighlightShapes = self.get('preHighlightShapes'); // 获取上次被激活的 shapes if (!isChange(preHighlightShapes, _highlightShapes)) { return; } if (preHighlightShapes) { self.clearActivedShapes(); } var shapes = self.getShapes(); Util.each(shapes, function (shape) { if (!shape.get('_originAttrs')) { shape.set('_originAttrs', Util.cloneDeep(shape.__attrs)); // 缓存原来的属性 } if (Util.indexOf(_highlightShapes, shape) !== -1) { shape.__attrs = Util.mix({}, shape.get('_originAttrs'), highlightCfg); shape.setZIndex(1); // 提前 } else { Util.mix(shape.__attrs, { fill: '#fff', fillOpacity: 0.3, strokeOpacity: 0.3, stroke: '#fff' }); shape.setZIndex(0); } }); self.set('preHighlightShapes', _highlightShapes); self.set('activeShapes', _highlightShapes); } }; module.exports = ActiveMixin; /***/ }), /* 312 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview the interaction when geom was selected * @author sima.zhang */ var Util = __webpack_require__(0); function isSameShape(shape1, shape2) { if (Util.isNil(shape1) || Util.isNil(shape2)) { return false; } var shape1Origin = shape1.get('origin'); var shape2Origin = shape2.get('origin'); return Util.isEqual(shape1Origin, shape2Origin); } var SelectMixin = { _isAllowSelect: function _isAllowSelect() { var isAllowSelect = this.get('allowSelect'); if (Util.isNil(isAllowSelect)) { var type = this.get('type'); var coord = this.get('coord'); var coordType = coord && coord.type; if (type === 'interval' && coordType === 'theta') { // 饼图默认可以进行选中 return true; } } else { // 用户设置了 select 配置 return isAllowSelect; } return false; }, _onClick: function _onClick(ev) { var self = this; if (self._isAllowSelect()) { // 允许选中下才执行 self.clearActivedShapes(); // 清除hover效果 var shape = ev.shape; var shapeContainer = self.get('shapeContainer'); if (shape && !shape.get('animating') && shapeContainer.contain(shape)) { self.setShapeSelected(shape); } } }, _bindSelectedAction: function _bindSelectedAction() { var self = this; var view = self.get('view'); var type = self.get('type'); view.on(type + ':click', Util.wrapBehavior(self, '_onClick')); }, _offSelectedAction: function _offSelectedAction() { var self = this; var view = self.get('view'); var type = self.get('type'); view.off(type + ':click', Util.getWrapBehavior(self, '_onClick')); }, _setShapeStatus: function _setShapeStatus(shape, status) { var self = this; var view = self.get('view'); var selectedOptions = self.get('selectedOptions') || {}; var animate = selectedOptions.animate !== false; // 默认允许动画 var canvas = view.get('canvas'); shape.set('selected', status); var shapeData = shape.get('origin'); if (status) { // 选中状态 var shapeName = shapeData.shape || self.getDefaultValue('shape'); if (Util.isArray(shapeName)) { shapeName = shapeName[0]; } var shapeFactory = self.get('shapeFactory'); var cfg = Util.mix({ geom: self, point: shapeData }, selectedOptions); var selectedStyle = shapeFactory.getSelectedCfg(shapeName, cfg); Util.mix(selectedStyle, cfg.style); // 用户设置的优先级更高 if (!shape.get('_originAttrs')) { // 缓存原有属性 shape.set('_originAttrs', Util.cloneDeep(shape.__attrs)); } if (animate) { shape.animate(selectedStyle, 300); } else { shape.attr(selectedStyle); canvas.draw(); } } else { var originAttrs = shape.get('_originAttrs'); if (animate) { shape.animate(originAttrs, 300); } else { shape.attr(originAttrs); canvas.draw(); } } }, setShapeSelected: function setShapeSelected(shape) { var self = this; var selectedShapes = self._getSelectedShapes(); var selectedOptions = self.get('selectedOptions') || {}; var cancelable = selectedOptions.cancelable !== false; // 选中状态是否允许取消,默认允许 if (selectedOptions.mode === 'multiple') { // 支持多选 if (Util.indexOf(selectedShapes, shape) === -1) { selectedShapes.push(shape); self._setShapeStatus(shape, true); } else if (cancelable) { // 图形已经被选中并且选中状态允许取消选中 Util.Array.remove(selectedShapes, shape); self._setShapeStatus(shape, false); } } else { var selectedShape = selectedShapes[0]; if (cancelable) { // 如果允许取消,则选中null shape = isSameShape(selectedShape, shape) ? null : shape; } if (!isSameShape(selectedShape, shape)) { if (selectedShape) { self._setShapeStatus(selectedShape, false); } if (shape) { self._setShapeStatus(shape, true); } } } }, clearSelected: function clearSelected() { var self = this; var shapeContainer = self.get('shapeContainer'); if (shapeContainer && !shapeContainer.get('destroyed')) { var selectedShapes = self._getSelectedShapes(); Util.each(selectedShapes, function (shape) { self._setShapeStatus(shape, false); shape.set('_originAttrs', null); }); } }, _getSelectedShapes: function _getSelectedShapes() { var self = this; var shapes = self.getShapes(); var selectedShapes = []; Util.each(shapes, function (shape) { if (shape.get('selected')) { selectedShapes.push(shape); } }); self.set('selectedShapes', selectedShapes); return selectedShapes; } }; module.exports = SelectMixin; /***/ }), /* 313 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 点图 * @author dxq613@gmail.com */ var GeomBase = __webpack_require__(9); var Util = __webpack_require__(0); var Point = function (_GeomBase) { _inherits(Point, _GeomBase); function Point() { _classCallCheck(this, Point); return _possibleConstructorReturn(this, _GeomBase.apply(this, arguments)); } /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Point.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _GeomBase.prototype.getDefaultCfg.call(this); cfg.type = 'point'; cfg.shapeType = 'point'; cfg.generatePoints = true; return cfg; }; Point.prototype.drawPoint = function drawPoint(obj, container, shapeFactory, index) { var self = this; var shape = obj.shape; var cfg = self.getDrawCfg(obj); var geomShape = void 0; if (Util.isArray(obj.y)) { var hasAdjust = self.hasStack(); Util.each(obj.y, function (y, idx) { cfg.y = y; cfg.yIndex = idx; if (!hasAdjust || idx !== 0) { geomShape = shapeFactory.drawShape(shape, cfg, container); geomShape.setSilent('index', index + idx); geomShape.setSilent('coord', self.get('coord')); if (self.get('animate') && self.get('animateCfg')) { geomShape.setSilent('animateCfg', self.get('animateCfg')); } } }); } else if (!Util.isNil(obj.y)) { geomShape = shapeFactory.drawShape(shape, cfg, container); geomShape.setSilent('index', index); geomShape.setSilent('coord', self.get('coord')); if (self.get('animate') && self.get('animateCfg')) { geomShape.setSilent('animateCfg', self.get('animateCfg')); } } }; return Point; }(GeomBase); var PointJitter = function (_Point) { _inherits(PointJitter, _Point); function PointJitter() { _classCallCheck(this, PointJitter); return _possibleConstructorReturn(this, _Point.apply(this, arguments)); } PointJitter.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Point.prototype.getDefaultCfg.call(this); cfg.hasDefaultAdjust = true; cfg.adjusts = [{ type: 'jitter' }]; return cfg; }; return PointJitter; }(Point); Point.Jitter = PointJitter; module.exports = Point; /***/ }), /* 314 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 线图 * @author dxq613@gmail.com */ var Path = __webpack_require__(112); var Line = function (_Path) { _inherits(Line, _Path); function Line() { _classCallCheck(this, Line); return _possibleConstructorReturn(this, _Path.apply(this, arguments)); } /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Line.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Path.prototype.getDefaultCfg.call(this); cfg.type = 'line'; cfg.sortable = true; return cfg; }; return Line; }(Path); var LineStack = function (_Line) { _inherits(LineStack, _Line); function LineStack() { _classCallCheck(this, LineStack); return _possibleConstructorReturn(this, _Line.apply(this, arguments)); } LineStack.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Line.prototype.getDefaultCfg.call(this); cfg.hasDefaultAdjust = true; cfg.adjusts = [{ type: 'stack' }]; return cfg; }; return LineStack; }(Line); Line.Stack = LineStack; module.exports = Line; /***/ }), /* 315 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview interval geometry * @author dxq613@gmail.com */ var GeomBase = __webpack_require__(9); var Util = __webpack_require__(0); var SizeMixin = __webpack_require__(114); var Interval = function (_GeomBase) { _inherits(Interval, _GeomBase); /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Interval.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _GeomBase.prototype.getDefaultCfg.call(this); cfg.type = 'interval'; cfg.shapeType = 'interval'; cfg.generatePoints = true; return cfg; }; function Interval(cfg) { _classCallCheck(this, Interval); var _this = _possibleConstructorReturn(this, _GeomBase.call(this, cfg)); Util.assign(_this, SizeMixin); return _this; } Interval.prototype.createShapePointsCfg = function createShapePointsCfg(obj) { var cfg = _GeomBase.prototype.createShapePointsCfg.call(this, obj); cfg.size = this.getNormalizedSize(obj); return cfg; }; Interval.prototype.clearInner = function clearInner() { _GeomBase.prototype.clearInner.call(this); this.set('defaultSize', null); }; return Interval; }(GeomBase); var IntervalStack = function (_Interval) { _inherits(IntervalStack, _Interval); function IntervalStack() { _classCallCheck(this, IntervalStack); return _possibleConstructorReturn(this, _Interval.apply(this, arguments)); } IntervalStack.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Interval.prototype.getDefaultCfg.call(this); cfg.hasDefaultAdjust = true; cfg.adjusts = [{ type: 'stack' }]; return cfg; }; return IntervalStack; }(Interval); var IntervalDodge = function (_Interval2) { _inherits(IntervalDodge, _Interval2); function IntervalDodge() { _classCallCheck(this, IntervalDodge); return _possibleConstructorReturn(this, _Interval2.apply(this, arguments)); } IntervalDodge.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Interval2.prototype.getDefaultCfg.call(this); cfg.hasDefaultAdjust = true; cfg.adjusts = [{ type: 'dodge' }]; return cfg; }; return IntervalDodge; }(Interval); var IntervalSymmetric = function (_Interval3) { _inherits(IntervalSymmetric, _Interval3); function IntervalSymmetric() { _classCallCheck(this, IntervalSymmetric); return _possibleConstructorReturn(this, _Interval3.apply(this, arguments)); } IntervalSymmetric.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Interval3.prototype.getDefaultCfg.call(this); cfg.hasDefaultAdjust = true; cfg.adjusts = [{ type: 'symmetric' }]; return cfg; }; return IntervalSymmetric; }(Interval); Interval.Stack = IntervalStack; Interval.Dodge = IntervalDodge; Interval.Symmetric = IntervalSymmetric; module.exports = Interval; /***/ }), /* 316 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 面积图 * @author dxq613@gmail.com */ var GeomBase = __webpack_require__(9); var SplitMixin = __webpack_require__(113); var Util = __webpack_require__(0); var Area = function (_GeomBase) { _inherits(Area, _GeomBase); /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Area.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _GeomBase.prototype.getDefaultCfg.call(this); cfg.type = 'area'; cfg.shapeType = 'area'; cfg.generatePoints = true; cfg.sortable = true; return cfg; }; function Area(cfg) { _classCallCheck(this, Area); var _this = _possibleConstructorReturn(this, _GeomBase.call(this, cfg)); Util.assign(_this, SplitMixin); return _this; } Area.prototype.draw = function draw(data, container, shapeFactory, index) { var self = this; var cfg = this.getDrawCfg(data[0]); var splitArray = this.splitData(data); cfg.origin = data; // path,line,area 等图的origin 是整个序列 Util.each(splitArray, function (subData, splitedIndex) { cfg.splitedIndex = splitedIndex; // 传入分割片段索引 用于生成id var points = subData.map(function (obj) { return obj.points; }); cfg.points = points; var geomShape = shapeFactory.drawShape(cfg.shape, cfg, container); geomShape.setSilent('index', index + splitedIndex); geomShape.setSilent('coord', self.get('coord')); if (self.get('animate') && self.get('animateCfg')) { geomShape.setSilent('animateCfg', self.get('animateCfg')); } }); }; return Area; }(GeomBase); var AreaStack = function (_Area) { _inherits(AreaStack, _Area); function AreaStack() { _classCallCheck(this, AreaStack); return _possibleConstructorReturn(this, _Area.apply(this, arguments)); } AreaStack.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Area.prototype.getDefaultCfg.call(this); cfg.hasDefaultAdjust = true; cfg.adjusts = [{ type: 'stack' }]; return cfg; }; return AreaStack; }(Area); Area.Stack = AreaStack; module.exports = Area; /***/ }), /* 317 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 多边形 * @author dxq613@gmail.com */ var GeomBase = __webpack_require__(9); var Util = __webpack_require__(0); var Polygon = function (_GeomBase) { _inherits(Polygon, _GeomBase); function Polygon() { _classCallCheck(this, Polygon); return _possibleConstructorReturn(this, _GeomBase.apply(this, arguments)); } /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Polygon.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _GeomBase.prototype.getDefaultCfg.call(this); cfg.type = 'polygon'; cfg.shapeType = 'polygon'; cfg.generatePoints = true; return cfg; }; Polygon.prototype.createShapePointsCfg = function createShapePointsCfg(obj) { var cfg = _GeomBase.prototype.createShapePointsCfg.call(this, obj); var self = this; var x = cfg.x; var y = cfg.y; var temp = void 0; if (!(Util.isArray(x) && Util.isArray(y))) { // x y 都是数组时,不做处理 var xScale = self.getXScale(); var yScale = self.getYScale(); var xCount = xScale.values ? xScale.values.length : xScale.ticks.length; var yCount = yScale.values ? yScale.values.length : yScale.ticks.length; var xOffset = 0.5 * 1 / xCount; var yOffset = 0.5 * 1 / yCount; if (xScale.isCategory && yScale.isCategory) { // 如果x,y都是分类 x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset]; y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset]; } else if (Util.isArray(x)) { // x 是数组 temp = x; x = [temp[0], temp[0], temp[1], temp[1]]; y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2]; } else if (Util.isArray(y)) { // y 是数组 temp = y; y = [temp[0], temp[1], temp[1], temp[0]]; x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2]; } cfg.x = x; cfg.y = y; } return cfg; }; return Polygon; }(GeomBase); module.exports = Polygon; /***/ }), /* 318 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 自定义图形 * @author dxq613@gmail.com */ var GeomBase = __webpack_require__(9); var Util = __webpack_require__(0); var SizeMixin = __webpack_require__(114); var Schema = function (_GeomBase) { _inherits(Schema, _GeomBase); /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Schema.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _GeomBase.prototype.getDefaultCfg.call(this); cfg.type = 'schema'; cfg.shapeType = 'schema'; cfg.generatePoints = true; return cfg; }; function Schema(cfg) { _classCallCheck(this, Schema); var _this = _possibleConstructorReturn(this, _GeomBase.call(this, cfg)); Util.assign(_this, SizeMixin); return _this; } Schema.prototype.createShapePointsCfg = function createShapePointsCfg(obj) { var cfg = _GeomBase.prototype.createShapePointsCfg.call(this, obj); cfg.size = this.getNormalizedSize(obj); return cfg; }; return Schema; }(GeomBase); var SchemaDodge = function (_Schema) { _inherits(SchemaDodge, _Schema); function SchemaDodge() { _classCallCheck(this, SchemaDodge); return _possibleConstructorReturn(this, _Schema.apply(this, arguments)); } SchemaDodge.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Schema.prototype.getDefaultCfg.call(this); cfg.hasDefaultAdjust = true; cfg.adjusts = [{ type: 'dodge' }]; return cfg; }; return SchemaDodge; }(Schema); Schema.Dodge = SchemaDodge; module.exports = Schema; /***/ }), /* 319 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 边,用于关系图的边 * @author dxq613@gmail.com */ var GeomBase = __webpack_require__(9); var Edge = function (_GeomBase) { _inherits(Edge, _GeomBase); function Edge() { _classCallCheck(this, Edge); return _possibleConstructorReturn(this, _GeomBase.apply(this, arguments)); } /** * 获取默认的配置属性 * @protected * @return {Object} 默认属性 */ Edge.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _GeomBase.prototype.getDefaultCfg.call(this); cfg.type = 'edge'; cfg.shapeType = 'edge'; cfg.generatePoints = true; return cfg; }; return Edge; }(GeomBase); module.exports = Edge; /***/ }), /* 320 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview heatmap * @author leungwensen@gmail.com */ var GeomBase = __webpack_require__(9); var colorUtil = __webpack_require__(64); var Util = __webpack_require__(0); var ORIGIN_FIELD = '_origin'; var SHADOW_CANVAS_CTX = 'shadowCanvasCtx'; var VALUE_RANGE = 'valueRange'; var IMAGE_SHAPE = 'imageShape'; var MAPPED_DATA = 'mappedData'; var GRAY_SCALE_BLURRED_CANVAS = 'grayScaleBlurredCanvas'; var HEATMAP_SIZE = 'heatmapSize'; var paletteCache = {}; var Heatmap = function (_GeomBase) { _inherits(Heatmap, _GeomBase); function Heatmap() { _classCallCheck(this, Heatmap); return _possibleConstructorReturn(this, _GeomBase.apply(this, arguments)); } /** * get default configuration * @protected * @return {Object} configuration */ Heatmap.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _GeomBase.prototype.getDefaultCfg.call(this); cfg.type = 'heatmap'; // cfg.shapeType = 'heatmap'; return cfg; }; Heatmap.prototype._prepareRange = function _prepareRange() { var self = this; var data = self.get(MAPPED_DATA); var colorAttr = self.getAttr('color'); var colorField = colorAttr.field; var min = Infinity; var max = -Infinity; data.forEach(function (row) { var value = row[ORIGIN_FIELD][colorField]; if (value > max) { max = value; } if (value < min) { min = value; } }); if (min === max) { min = max - 1; } var range = [min, max]; self.set(VALUE_RANGE, range); }; Heatmap.prototype._prepareSize = function _prepareSize() { var self = this; var radius = self.getDefaultValue('size'); if (!Util.isNumber(radius)) { radius = self._getDefaultSize(); } var styleOptions = self.get('styleOptions'); var blur = styleOptions && Util.isObject(styleOptions.style) ? styleOptions.style.blur : null; if (!Util.isFinite(blur)) { blur = radius / 2; } self.set(HEATMAP_SIZE, { blur: blur, radius: radius }); }; Heatmap.prototype._getDefaultSize = function _getDefaultSize() { var self = this; var position = self.getAttr('position'); var coord = self.get('coord'); var radius = Math.min(coord.width / (position.scales[0].ticks.length * 4), coord.height / (position.scales[1].ticks.length * 4)); return radius; }; Heatmap.prototype._colorize = function _colorize(img) { var self = this; var colorAttr = self.getAttr('color'); var pixels = img.data; for (var i = 3; i < pixels.length; i += 4) { var alpha = pixels[i]; // get gradient color from opacity value if (alpha) { var palette = void 0; if (paletteCache[alpha]) { palette = paletteCache[alpha]; } else { palette = colorUtil.rgb2arr(colorAttr.gradient(alpha / 256)); paletteCache[alpha] = palette; } // const palette = colorUtil.rgb2arr(colorAttr.gradient(alpha / 256)); pixels[i - 3] = palette[0]; pixels[i - 2] = palette[1]; pixels[i - 1] = palette[2]; pixels[i] = alpha; } } }; Heatmap.prototype._prepareGreyScaleBlurredCircle = function _prepareGreyScaleBlurredCircle(r, blur) { var self = this; var circleCanvas = self.get(GRAY_SCALE_BLURRED_CANVAS); if (!circleCanvas) { circleCanvas = document.createElement('canvas'); self.set(GRAY_SCALE_BLURRED_CANVAS, circleCanvas); } var r2 = r + blur; var ctx = circleCanvas.getContext('2d'); circleCanvas.width = circleCanvas.height = r2 * 2; ctx.clearRect(0, 0, circleCanvas.width, circleCanvas.height); ctx.shadowOffsetX = ctx.shadowOffsetY = r2 * 2; ctx.shadowBlur = blur; ctx.shadowColor = 'black'; ctx.beginPath(); ctx.arc(-r2, -r2, r, 0, Math.PI * 2, true); ctx.closePath(); ctx.fill(); }; Heatmap.prototype._drawGrayScaleBlurredCircle = function _drawGrayScaleBlurredCircle(x, y, r, alpha, ctx) { var circleCanvas = this.get(GRAY_SCALE_BLURRED_CANVAS); ctx.globalAlpha = alpha; ctx.drawImage(circleCanvas, x - r, y - r); }; Heatmap.prototype._getShadowCanvasCtx = function _getShadowCanvasCtx() { var self = this; var ctx = self.get(SHADOW_CANVAS_CTX); if (ctx) { return ctx; } var coord = self.get('coord'); var width = coord.x.end; var height = coord.y.start; var heatmapCanvas = document.createElement('canvas'); heatmapCanvas.width = width; heatmapCanvas.height = height; ctx = heatmapCanvas.getContext('2d'); self.set(SHADOW_CANVAS_CTX, ctx); return ctx; }; Heatmap.prototype._clearShadowCanvasCtx = function _clearShadowCanvasCtx() { var ctx = this.get(SHADOW_CANVAS_CTX); if (ctx) { ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); } }; Heatmap.prototype._getImageShape = function _getImageShape() { var self = this; var imageShape = self.get(IMAGE_SHAPE); if (imageShape) { return imageShape; } var container = self.get('container'); imageShape = container.addShape('Image', {}); self.set(IMAGE_SHAPE, imageShape); return imageShape; }; Heatmap.prototype.drawWithRange = function drawWithRange(range) { var self = this; // canvas size var coord = self.get('coord'); var width = coord.width; var height = coord.height; // value, range, etc var valueField = self.getAttr('color').field; var size = self.get(HEATMAP_SIZE); // prepare shadow canvas context self._clearShadowCanvasCtx(); var ctx = self._getShadowCanvasCtx(); // filter data var data = self.get(MAPPED_DATA); if (range) { data = data.filter(function (row) { return row[ORIGIN_FIELD][valueField] <= range[1] && row[ORIGIN_FIELD][valueField] >= range[0]; }); } // step1. draw points with shadow var scale = self._getScale(valueField); for (var i = 0; i < data.length; i++) { var obj = data[i]; var cfg = self.getDrawCfg(obj); var alpha = scale.scale(obj[ORIGIN_FIELD][valueField]); self._drawGrayScaleBlurredCircle(cfg.x, cfg.y, size.radius, alpha, ctx); } // step2. convert pixels var colored = ctx.getImageData(coord.start.x, coord.end.y, width + coord.start.x, height + coord.end.y); self._clearShadowCanvasCtx(); self._colorize(colored); ctx.putImageData(colored, 0, 0); var imageShape = self._getImageShape(); imageShape.attr('x', coord.start.x); imageShape.attr('y', coord.end.y); imageShape.attr('width', width + coord.start.x); imageShape.attr('height', height + coord.end.y); imageShape.attr('img', ctx.canvas); }; Heatmap.prototype.draw = function draw(data /* , container, shapeFactory, index */) { var self = this; self.set(MAPPED_DATA, data); self._prepareRange(); self._prepareSize(); var size = self.get(HEATMAP_SIZE); self._prepareGreyScaleBlurredCircle(size.radius, size.blur); var range = self.get(VALUE_RANGE); self.drawWithRange(range); // super.draw(data, container, shapeFactory, index); }; return Heatmap; }(GeomBase); module.exports = Heatmap; /***/ }), /* 321 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview 度量的控制器 * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var Global = __webpack_require__(1); var Scale = __webpack_require__(116); var dateRegex = /^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]?)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/; var TYPES = { LINEAR: 'linear', CAT: 'cat', TIME: 'time' }; var ScaleController = function () { function ScaleController(cfg) { _classCallCheck(this, ScaleController); // defs 列定义 this.defs = {}; Util.assign(this, cfg); } ScaleController.prototype._getDef = function _getDef(field) { var defs = this.defs; var def = null; if (Global.scales[field] || defs[field]) { def = Util.mix({}, Global.scales[field]); // 处理覆盖属性的问题 Util.each(defs[field], function (v, k) { if (Util.isNil(v)) { delete def[k]; } else { def[k] = v; } }); } return def; }; ScaleController.prototype._getDefaultType = function _getDefaultType(field, data) { var type = TYPES.LINEAR; var value = Util.Array.firstValue(data, field); if (Util.isArray(value)) { value = value[0]; } if (dateRegex.test(value)) { type = TYPES.TIME; } else if (Util.isString(value)) { type = TYPES.CAT; } return type; }; ScaleController.prototype._getScaleCfg = function _getScaleCfg(type, field, data) { var cfg = { field: field }; var values = Util.Array.values(data, field); cfg.values = values; if (!Scale.isCategory(type) && type !== 'time') { var range = Util.Array.getRange(values); cfg.min = range.min; cfg.max = range.max; cfg.nice = true; } if (type === 'time') { cfg.nice = false; } return cfg; }; ScaleController.prototype.createScale = function createScale(field, data) { var self = this; var def = self._getDef(field); var scale = void 0; // 如果数据为空直接返回常量度量 if (!data || !data.length) { if (def && def.type) { scale = Scale[def.type](def); } else { scale = Scale.identity({ value: field, field: field.toString(), values: [field] }); } return scale; } var firstValue = Util.Array.firstValue(data, field); if (Util.isNumber(field) || Util.isNil(firstValue) && !def) { scale = Scale.identity({ value: field, field: field.toString(), values: [field] }); } else { // 如果已经定义过这个度量 var type = void 0; if (def) { type = def.type; } type = type || self._getDefaultType(field, data); var cfg = self._getScaleCfg(type, field, data); if (def) { Util.mix(cfg, def); } scale = Scale[type](cfg); } return scale; }; return ScaleController; }(); module.exports = ScaleController; /***/ }), /* 322 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 自动计算数字坐标轴 * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var AutoUtil = __webpack_require__(117); var MIN_COUNT = 5; var MAX_COUNT = 7; var Global = __webpack_require__(1); module.exports = function (info) { var min = info.min; var max = info.max; var interval = info.interval; var ticks = []; var minCount = info.minCount || MIN_COUNT; var maxCount = info.maxCount || MAX_COUNT; var isFixedCount = minCount === maxCount; // 是否限定死了个数 var minLimit = Util.isNil(info.minLimit) ? -Infinity : info.minLimit; // 限定的最小值 var maxLimit = Util.isNil(info.maxLimit) ? Infinity : info.maxLimit; // 限定最大值 var avgCount = (minCount + maxCount) / 2; var count = avgCount; // 用户传入的逼近数组 var snapArray = info.snapArray ? info.snapArray : isFixedCount ? Global.snapCountArray : Global.snapArray; // 如果限定大小范围,同时大小范围等于用户传入的范围,同时限定了个数,interval 按照个数均分 if (min === minLimit && max === maxLimit && isFixedCount) { interval = (max - min) / (count - 1); } if (Util.isNil(min)) { min = 0; } if (Util.isNil(max)) { max = 0; } if (max === min) { if (min === 0) { max = 1; } else { if (min > 0) { min = 0; } else { max = 0; } } if (max - min < 5 && !interval && max - min >= 1) { interval = 1; } } if (Util.isNil(interval)) { // 计算间距 var temp = (max - min) / (avgCount - 1); interval = AutoUtil.snapFactorTo(temp, snapArray, 'ceil'); if (maxCount !== minCount) { count = parseInt((max - min) / interval, 10); if (count > maxCount) { count = maxCount; } if (count < minCount) { count = minCount; } // 不确定tick的个数时,使得tick偏小 interval = AutoUtil.snapFactorTo((max - min) / (count - 1), snapArray, 'floor'); } } if (info.interval || maxCount !== minCount) { // 校正 max 和 min max = Math.min(AutoUtil.snapMultiple(max, interval, 'ceil'), maxLimit); // 向上逼近 min = Math.max(AutoUtil.snapMultiple(min, interval, 'floor'), minLimit); // 向下逼近 count = Math.round((max - min) / interval); min = Util.fixedBase(min, interval); max = Util.fixedBase(max, interval); } else { avgCount = parseInt(avgCount, 10); // 取整 var avg = (max + min) / 2; var avgTick = AutoUtil.snapMultiple(avg, interval, 'ceil'); var sideCount = Math.floor((avgCount - 2) / 2); var maxTick = avgTick + sideCount * interval; var minTick = void 0; if (avgCount % 2 === 0) { minTick = avgTick - sideCount * interval; } else { minTick = avgTick - (sideCount + 1) * interval; } if (maxTick < max) { maxTick = maxTick + interval; } if (minTick > min) { minTick = minTick - interval; } max = Util.fixedBase(maxTick, interval); min = Util.fixedBase(minTick, interval); } max = Math.min(max, maxLimit); min = Math.max(min, minLimit); ticks.push(min); for (var i = 1; i < count; i++) { var tickValue = Util.fixedBase(interval * i + min, interval); if (tickValue < max) { ticks.push(tickValue); } } if (ticks[ticks.length - 1] < max) { ticks.push(max); } return { min: min, max: max, interval: interval, count: count, ticks: ticks }; }; /***/ }), /* 323 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The data is replaced with constant * @author dxq613@gmail.com */ var Base = __webpack_require__(41); var Util = __webpack_require__(0); var Identity = function (_Base) { _inherits(Identity, _Base); function Identity() { _classCallCheck(this, Identity); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } /** * @override */ Identity.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { isIdentity: true, /** * @override * @type {String} */ type: 'identity', /** * 常量值 * @type {*} */ value: null }); }; /** * @override */ Identity.prototype.getText = function getText() { return this.value.toString(); }; /** * @override */ Identity.prototype.scale = function scale(value) { if (this.value !== value && Util.isNumber(value)) { return value; } return this.range[0]; }; /** * @override */ Identity.prototype.invert = function invert() { return this.value; }; return Identity; }(Base); module.exports = Identity; /***/ }), /* 324 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The measurement of linear data scale function * @author dxq613@gmail.com */ var Linear = __webpack_require__(42); var Util = __webpack_require__(0); var timeAuto = __webpack_require__(325); var fecha = __webpack_require__(120); var TimeUtil = __webpack_require__(121); /** * 时间度量的构造函数 * @class Scale.Time */ var Time = function (_Linear) { _inherits(Time, _Linear); function Time() { _classCallCheck(this, Time); return _possibleConstructorReturn(this, _Linear.apply(this, arguments)); } /** * @override */ Time.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Linear.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * @override */ type: 'time', /** * 格式化符 * @type {String} */ mask: 'YYYY-MM-DD' }); }; /** * @override */ Time.prototype.init = function init() { var self = this; var values = self.values; if (values) { // 重新计算最大最小值 var timeStamps = []; var min = Infinity; // 最小值 var secondMin = min; // 次小值 var max = 0; // 使用一个循环,计算min,max,secondMin Util.each(values, function (v) { var timeStamp = self._toTimeStamp(v); if (min > timeStamp) { secondMin = min; min = timeStamp; } else if (secondMin > timeStamp) { secondMin = timeStamp; } if (max < timeStamp) { max = timeStamp; } timeStamps.push(timeStamp); }); // 存在多个值时,设置最小间距 if (values.length > 1) { self.minTickInterval = secondMin - min; } if (Util.isNil(self.min) || self._toTimeStamp(self.min) > min) { self.min = min; } if (Util.isNil(self.max) || self._toTimeStamp(self.max) < max) { self.max = max; } } _Linear.prototype.init.call(this); }; Time.prototype.calculateTicks = function calculateTicks() { var self = this; var min = self.min; var max = self.max; var count = self.tickCount; var interval = self.tickInterval; var tmp = timeAuto({ min: min, max: max, minCount: count, maxCount: count, interval: interval, minInterval: self.minTickInterval }); return tmp.ticks; }; /** * @override */ Time.prototype.getText = function getText(value) { var formatter = this.formatter; value = this.translate(value); value = formatter ? formatter(value) : fecha.format(value, this.mask); return value; }; /** * @override */ Time.prototype.scale = function scale(value) { if (Util.isString(value)) { value = this.translate(value); } return _Linear.prototype.scale.call(this, value); }; /** * @override */ Time.prototype.translate = function translate(value) { return this._toTimeStamp(value); }; // 将时间转换为时间戳 Time.prototype._toTimeStamp = function _toTimeStamp(value) { return TimeUtil.toTimeStamp(value); }; return Time; }(Linear); module.exports = Time; /***/ }), /* 325 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview 计算时间坐标轴 * @author dxq613@gmail.com */ var Util = __webpack_require__(0); var AutoUtil = __webpack_require__(117); var MAX_COUNT = 6; var SNAP_ARRAY = [1, 2, 4, 6, 8, 12]; var MINUTE_MS = 60 * 1000; var HOUR_MS = 3600 * 1000; var DAY_MS = 24 * 3600 * 1000; function getYear(date) { return new Date(date).getFullYear(); } function createYear(year) { return new Date(year, 0, 1).getTime(); } function getMonth(date) { return new Date(date).getMonth(); } function diffMonth(min, max) { var minYear = getYear(min); var maxYear = getYear(max); var minMonth = getMonth(min); var maxMonth = getMonth(max); return (maxYear - minYear) * 12 + (maxMonth - minMonth) % 12; } function creatMonth(year, month) { return new Date(year, month, 1).getTime(); } function diffDay(min, max) { return Math.ceil((max - min) / DAY_MS); } function diffHour(min, max) { return Math.ceil((max - min) / HOUR_MS); } function diffMinus(min, max) { return Math.ceil((max - min) / (60 * 1000)); } module.exports = function (info) { var minInterval = info.minInterval; var ticks = []; var min = info.min; var max = info.max; var interval = info.interval; var count = void 0; // 如果最大值和最小值相等,则设置最大值大于最小值一天 if (max === min) { max = min + DAY_MS; } // 计算间距 if (Util.isNil(interval)) { var innerTime = max - min; var dms = DAY_MS; // 天代表的秒 var yms = 365 * dms; // 年代表的秒 interval = parseInt(innerTime / (info.maxCount || MAX_COUNT), 10); if (minInterval && minInterval > interval) { interval = minInterval; } var yfactor = interval / yms; var minYear = getYear(min); // 大于半年 if (yfactor > 0.51) { var year = Math.ceil(yfactor); // interval = year * yms; var maxYear = getYear(max); for (var i = minYear; i <= maxYear + year; i = i + year) { ticks.push(createYear(i)); } interval = null; } else if (yfactor > 0.0834) { // 大于一个月 var month = Math.ceil(yfactor / 0.0834); var mmMoth = getMonth(min); var dMonths = diffMonth(min, max); for (var _i = 0; _i <= dMonths + month; _i = _i + month) { ticks.push(creatMonth(minYear, _i + mmMoth)); } interval = null; } else if (interval > dms * 0.5) { // 大于一天 var date = new Date(min); var _year = date.getFullYear(); var _month = date.getMonth(min); var mday = date.getDate(); var day = Math.ceil(interval / dms); var ddays = diffDay(min, max); interval = day * dms; for (var _i2 = 0; _i2 < ddays + day; _i2 = _i2 + day) { ticks.push(new Date(_year, _month, mday + _i2).getTime()); } } else if (interval > HOUR_MS) { // 大于一个小时 var _date = new Date(min); var _year2 = _date.getFullYear(); var _month2 = _date.getMonth(min); var _day = _date.getDate(); var hour = _date.getHours(); var hours = AutoUtil.snapTo(SNAP_ARRAY, Math.ceil(interval / HOUR_MS)); var dHours = diffHour(min, max); interval = hours * HOUR_MS; for (var _i3 = 0; _i3 <= dHours + hours; _i3 = _i3 + hours) { ticks.push(new Date(_year2, _month2, _day, hour + _i3).getTime()); } } else if (interval > MINUTE_MS) { // 最小单位是分钟 var dMinus = diffMinus(min, max); var minutes = Math.ceil(interval / MINUTE_MS); interval = minutes * MINUTE_MS; for (var _i4 = 0; _i4 <= dMinus + minutes; _i4 = _i4 + minutes) { ticks.push(min + _i4 * MINUTE_MS); } } else { if (interval < 1000) { interval = 1000; } min = Math.floor(min / 1000) * 1000; var dSeconds = Math.ceil((max - min) / 1000); var seconds = Math.ceil(interval / 1000); interval = seconds * 1000; for (var _i5 = 0; _i5 < dSeconds + seconds; _i5 = _i5 + seconds) { ticks.push(min + _i5 * 1000); } } } if (!ticks.length) { min = Math.floor(min / 1000) * 1000; max = Math.ceil(max / 1000) * 1000; count = (max - min) / interval; for (var _i6 = 0; _i6 <= count; _i6++) { ticks.push(Util.fixedBase(interval * _i6 + min, interval)); } } return { max: max, min: min, interval: interval, ticks: ticks, count: ticks.length }; }; /***/ }), /* 326 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 时间数据作为分类类型 * @author dxq613@gmail.com */ var Category = __webpack_require__(118); var Util = __webpack_require__(0); var fecha = __webpack_require__(120); var catAuto = __webpack_require__(119); var TimeUtil = __webpack_require__(121); /** * 度量的构造函数 * @class Scale.TimeCategory */ var TimeCategory = function (_Category) { _inherits(TimeCategory, _Category); function TimeCategory() { _classCallCheck(this, TimeCategory); return _possibleConstructorReturn(this, _Category.apply(this, arguments)); } /** * @override */ TimeCategory.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Category.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * @override */ type: 'timeCat', /** * 格式化符 * @type {String} */ mask: 'YYYY-MM-DD', /** * @override */ tickCount: 5 }); }; TimeCategory.prototype.init = function init() { var self = this; var values = this.values; // 针对时间分类类型,会将时间统一转换为时间戳 Util.each(values, function (v, i) { values[i] = self._toTimeStamp(v); }); values.sort(function (v1, v2) { return v1 - v2; }); if (!self.ticks) { self.ticks = this.calculateTicks(false); } }; /** * 计算 ticks * @param {boolean} formated 是否将 ticks 按照指定的 mask 格式化 * @return {array} 返回 ticks 数组 */ TimeCategory.prototype.calculateTicks = function calculateTicks(formated) { var self = this; var count = self.tickCount; var temp = catAuto({ maxCount: count, data: self.values }); var ticks = temp.ticks; if (formated) { Util.each(ticks, function (value, index) { ticks[index] = fecha.format(value, self.mask); }); } return ticks; }; /** * @override */ TimeCategory.prototype.translate = function translate(value) { value = this._toTimeStamp(value); var index = this.values.indexOf(value); if (index === -1) { if (Util.isNumber(value) && value < this.values.length) { index = value; } else { index = NaN; } } return index; }; /** * @override */ TimeCategory.prototype.scale = function scale(value) { var rangeMin = this.rangeMin(); var rangeMax = this.rangeMax(); var index = this.translate(value); var percent = void 0; if (this.values.length === 1) { percent = index; } else if (index > -1) { percent = index / (this.values.length - 1); } else { percent = 0; } return rangeMin + percent * (rangeMax - rangeMin); }; /** * @override */ TimeCategory.prototype.getText = function getText(value) { var result = ''; var index = this.translate(value); if (index > -1) { result = this.values[index]; } else { result = value; } var formatter = this.formatter; result = parseInt(result, 10); result = formatter ? formatter(result) : fecha.format(result, this.mask); return result; }; /** * @override */ TimeCategory.prototype.getTicks = function getTicks() { var self = this; var ticks = this.ticks; var rst = []; Util.each(ticks, function (tick) { var obj = void 0; if (Util.isObject(tick)) { obj = tick; } else { obj = { text: Util.isString(tick) ? tick : self.getText(tick), value: self.scale(tick) }; } rst.push(obj); }); return rst; }; // 将时间转换为时间戳 TimeCategory.prototype._toTimeStamp = function _toTimeStamp(value) { return TimeUtil.toTimeStamp(value); }; return TimeCategory; }(Category); module.exports = TimeCategory; /***/ }), /* 327 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 使用度量,进行log转换 * @author dxq613@gmail.com */ var Linear = __webpack_require__(42); var Util = __webpack_require__(0); // 计算log function log(a, b) { if (a === 1) { return 1; } return Math.log(b) / Math.log(a); } /** * 度量的log计算 * @class Scale.Log */ var Log = function (_Linear) { _inherits(Log, _Linear); function Log() { _classCallCheck(this, Log); return _possibleConstructorReturn(this, _Linear.apply(this, arguments)); } /** * @override */ Log.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Linear.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * @override */ type: 'log', /** * 进行log计算的基数 * @type {Number} */ base: 2, /** * @override * log 的坐标点的个数控制在10个以下 * @type {Number} */ tickCount: 10, // 最小的tick,仅内部使用 _minTick: null }); }; /** * @override */ Log.prototype.calculateTicks = function calculateTicks() { var self = this; var base = self.base; var minTick = void 0; if (self.min < 0) { throw new Error('The minimum value must be greater than zero!'); } var maxTick = log(base, self.max); if (self.min > 0) { minTick = Math.floor(log(base, self.min)); } else { var values = self.values; var positiveMin = self.max; // 查找大于0的第一个值, 如果都小于0,默认为1 Util.each(values, function (value) { if (value > 0 && value < positiveMin) { positiveMin = value; } }); if (positiveMin === self.max) { positiveMin = self.max / base; } if (positiveMin > 1) { positiveMin = 1; } minTick = Math.floor(log(base, positiveMin)); self._minTick = minTick; self.positiveMin = positiveMin; } var count = maxTick - minTick; var tickCount = self.tickCount; var avg = Math.ceil(count / tickCount); var ticks = []; for (var i = minTick; i < maxTick + avg; i = i + avg) { ticks.push(Math.pow(base, i)); } /**/ if (self.min === 0) { ticks.unshift(0); } return ticks; }; // 获取度量计算时,value占的定义域百分比 Log.prototype._getScalePercent = function _getScalePercent(value) { var max = this.max; var min = this.min; if (max === min) { return 0; } // 如果值小于等于0,则按照0处理 if (value <= 0) { return 0; } var base = this.base; var positiveMin = this.positiveMin; // 如果min == 0, 则根据比0大的最小值,计算比例关系。这个最小值作为坐标轴上的第二个tick,第一个是0但是不显示 if (positiveMin) { min = positiveMin * 1 / base; } var percent = void 0; // 如果数值小于次小值,那么就计算 value / 次小值 占整体的比例 if (value < positiveMin) { percent = value / positiveMin / (log(base, max) - log(base, min)); } else { percent = (log(base, value) - log(base, min)) / (log(base, max) - log(base, min)); } return percent; }; /** * @override */ Log.prototype.scale = function scale(value) { var percent = this._getScalePercent(value); var rangeMin = this.rangeMin(); var rangeMax = this.rangeMax(); return rangeMin + percent * (rangeMax - rangeMin); }; /** * @override */ Log.prototype.invert = function invert(value) { var base = this.base; var max = log(base, this.max); var rangeMin = this.rangeMin(); var range = this.rangeMax() - rangeMin; var min = void 0; var positiveMin = this.positiveMin; if (positiveMin) { if (value === 0) { return 0; } min = log(base, positiveMin / base); var appendPercent = 1 / (max - min) * range; // 0 到 positiveMin的占比 if (value < appendPercent) { // 落到 0 - positiveMin 之间 return value / appendPercent * positiveMin; } } else { min = log(base, this.min); } var percent = (value - rangeMin) / range; var tmp = percent * (max - min) + min; return Math.pow(base, tmp); }; return Log; }(Linear); module.exports = Log; /***/ }), /* 328 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview 使用pow进行度量计算 * @author dxq613@gmail.com */ var Linear = __webpack_require__(42); var Util = __webpack_require__(0); // 求以a为次幂,结果为b的基数,如 x^^a = b;求x function calBase(a, b) { var e = Math.E; var value = Math.pow(e, Math.log(b) / a); // 使用换底公式求底 return value; } /** * 度量的Pow计算 * @class Scale.Log */ var Pow = function (_Linear) { _inherits(Pow, _Linear); function Pow() { _classCallCheck(this, Pow); return _possibleConstructorReturn(this, _Linear.apply(this, arguments)); } /** * @override */ Pow.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Linear.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * @override */ type: 'pow', /** * 进行pow计算的基数 * @type {Number} */ exponent: 2, /** * @override * pow 的坐标点的个数控制在10个以下 * @type {Number} */ tickCount: 10 }); }; /** * @override */ Pow.prototype.calculateTicks = function calculateTicks() { var self = this; var exponent = self.exponent; var min = void 0; var max = Math.ceil(calBase(exponent, self.max)); if (self.min >= 0) { min = Math.floor(calBase(exponent, self.min)); } else { min = 0; } if (min > max) { var tmp = max; max = min; min = tmp; } var count = max - min; var tickCount = self.tickCount; var avg = Math.ceil(count / tickCount); var ticks = []; for (var i = min; i < max + avg; i = i + avg) { ticks.push(Math.pow(i, exponent)); } return ticks; }; // 获取度量计算时,value占的定义域百分比 Pow.prototype._getScalePercent = function _getScalePercent(value) { var max = this.max; var min = this.min; if (max === min) { return 0; } var exponent = this.exponent; var percent = (calBase(exponent, value) - calBase(exponent, min)) / (calBase(exponent, max) - calBase(exponent, min)); return percent; }; /** * @override */ Pow.prototype.scale = function scale(value) { var percent = this._getScalePercent(value); var rangeMin = this.rangeMin(); var rangeMax = this.rangeMax(); return rangeMin + percent * (rangeMax - rangeMin); }; /** * @override */ Pow.prototype.invert = function invert(value) { var percent = (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin()); var exponent = this.exponent; var max = calBase(exponent, this.max); var min = calBase(exponent, this.min); var tmp = percent * (max - min) + min; return Math.pow(tmp, exponent); }; return Pow; }(Linear); module.exports = Pow; /***/ }), /* 329 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview The controller of coordinate * @author sima.zhang */ var Util = __webpack_require__(0); var Coord = __webpack_require__(330); var CoordController = function () { function CoordController(option) { _classCallCheck(this, CoordController); this.type = 'rect'; this.actions = []; this.cfg = {}; Util.mix(this, option); this.option = option || {}; } CoordController.prototype.reset = function reset(coordOption) { this.actions = coordOption.actions || []; this.type = coordOption.type; this.cfg = coordOption.cfg; this.option.actions = this.actions; this.option.type = this.type; this.option.cfg = this.cfg; return this; }; CoordController.prototype._execActions = function _execActions(coord) { var actions = this.actions; Util.each(actions, function (action) { var m = action[0]; coord[m](action[1], action[2]); }); }; CoordController.prototype.hasAction = function hasAction(actionName) { var actions = this.actions; var rst = false; Util.each(actions, function (action) { if (actionName === action[0]) { rst = true; return false; } }); return rst; }; /** * 创建坐标系对象 * @param {Object} start 坐标系起始点 * @param {Object} end 坐标系结束点 * @return {Function} 坐标系的构造函数 */ CoordController.prototype.createCoord = function createCoord(start, end) { var self = this; var type = self.type; var cfg = self.cfg; var C = void 0; // 构造函数 var coord = void 0; var coordCfg = Util.mix({ start: start, end: end }, cfg); if (type === 'theta') { C = Coord.Polar; if (!self.hasAction('transpose')) { self.transpose(); // 极坐标,同时transpose } coord = new C(coordCfg); coord.type = type; } else { C = Coord[Util.upperFirst(type)] || Coord.Rect; coord = new C(coordCfg); } self._execActions(coord); return coord; }; CoordController.prototype.rotate = function rotate(angle) { angle = angle * Math.PI / 180; this.actions.push(['rotate', angle]); return this; }; CoordController.prototype.reflect = function reflect(dim) { this.actions.push(['reflect', dim]); return this; }; CoordController.prototype.scale = function scale(sx, sy) { this.actions.push(['scale', sx, sy]); return this; }; CoordController.prototype.transpose = function transpose() { this.actions.push(['transpose']); return this; }; return CoordController; }(); module.exports = CoordController; /***/ }), /* 330 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview the entry of coordinate * @author sima.zhang1990@gmail.com */ var Coord = __webpack_require__(43); Coord.Cartesian = __webpack_require__(331); Coord.Rect = Coord.Cartesian; Coord.Polar = __webpack_require__(332); Coord.Helix = __webpack_require__(333); module.exports = Coord; /***/ }), /* 331 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the class of Cartesian Coordinate * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(43); var Cartesian = function (_Base) { _inherits(Cartesian, _Base); /** * @override */ Cartesian.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { start: { x: 0, y: 0 }, end: { x: 0, y: 0 }, type: 'cartesian', isRect: true }); }; function Cartesian(cfg) { _classCallCheck(this, Cartesian); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); _this._init(); return _this; } Cartesian.prototype._init = function _init() { var start = this.start, end = this.end; var x = { start: start.x, end: end.x }; var y = { start: start.y, end: end.y }; this.x = x; this.y = y; }; Cartesian.prototype.convertPoint = function convertPoint(point) { var x = void 0; var y = void 0; if (this.isTransposed) { x = point.y; y = point.x; } else { x = point.x; y = point.y; } return { x: this.convertDim(x, 'x'), y: this.convertDim(y, 'y') }; }; Cartesian.prototype.invertPoint = function invertPoint(point) { var x = this.invertDim(point.x, 'x'); var y = this.invertDim(point.y, 'y'); if (this.isTransposed) { return { x: y, y: x }; } return { x: x, y: y }; }; return Cartesian; }(Base); module.exports = Cartesian; /***/ }), /* 332 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the class of Polar Coordinate * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(43); var MatrixUtil = __webpack_require__(2).MatrixUtil; var mat3 = MatrixUtil.mat3; var vec2 = MatrixUtil.vec2; var vec3 = MatrixUtil.vec3; var Polar = function (_Base) { _inherits(Polar, _Base); Polar.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { startAngle: -Math.PI / 2, endAngle: Math.PI * 3 / 2, innerRadius: 0, type: 'polar', isPolar: true }); }; function Polar(cfg) { _classCallCheck(this, Polar); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); _this._init(); return _this; } Polar.prototype._init = function _init() { var radius = this.radius; var innerRadius = this.innerRadius; var startAngle = this.startAngle; var endAngle = this.endAngle; var center = this.center; var oneBox = this.getOneBox(); var oneWidth = oneBox.maxX - oneBox.minX; var oneHeight = oneBox.maxY - oneBox.minY; var left = Math.abs(oneBox.minX) / oneWidth; var top = Math.abs(oneBox.minY) / oneHeight; var width = this.width; var height = this.height; var maxRadius = void 0; var circleCentre = void 0; if (height / oneHeight > width / oneWidth) { // width为主 maxRadius = width / oneWidth; circleCentre = { x: center.x - (0.5 - left) * width, y: center.y - (0.5 - top) * maxRadius * oneHeight }; } else { // height为主 maxRadius = height / oneHeight; circleCentre = { x: center.x - (0.5 - left) * maxRadius * oneWidth, y: center.y - (0.5 - top) * height }; } if (!radius) { radius = maxRadius; } else if (radius > 0 && radius <= 1) { radius = maxRadius * radius; } else if (radius <= 0 || radius > maxRadius) { radius = maxRadius; } var x = { start: startAngle, end: endAngle }; var y = { start: innerRadius * radius, end: radius }; this.x = x; this.y = y; this.radius = radius; this.circleCentre = circleCentre; this.center = circleCentre; }; Polar.prototype.getCenter = function getCenter() { return this.circleCentre; }; Polar.prototype.getOneBox = function getOneBox() { var startAngle = this.startAngle; var endAngle = this.endAngle; if (endAngle - startAngle >= Math.PI * 2) { return { minX: -1, maxX: 1, minY: -1, maxY: 1 }; } var xs = [0, Math.cos(startAngle), Math.cos(endAngle)]; var ys = [0, Math.sin(startAngle), Math.sin(endAngle)]; for (var i = -Math.PI * 5 / 2; i < Math.PI * 3 / 2; i += Math.PI / 2) { if (startAngle <= i && i <= endAngle) { xs.push(Math.cos(i)); ys.push(Math.sin(i)); } } return { minX: Math.min.apply(Math, xs), maxX: Math.max.apply(Math, xs), minY: Math.min.apply(Math, ys), maxY: Math.max.apply(Math, ys) }; }; Polar.prototype.getRadius = function getRadius() { return this.radius; }; Polar.prototype.convertPoint = function convertPoint(point) { var center = this.getCenter(); var x = this.isTransposed ? point.y : point.x; var y = this.isTransposed ? point.x : point.y; x = this.convertDim(x, 'x'); y = this.convertDim(y, 'y'); return { x: center.x + Math.cos(x) * y, y: center.y + Math.sin(x) * y }; }; Polar.prototype.invertPoint = function invertPoint(point) { var center = this.getCenter(); var vPoint = [point.x - center.x, point.y - center.y]; var x = this.x; var m = [1, 0, 0, 0, 1, 0, 0, 0, 1]; mat3.rotate(m, m, x.start); var vStart = [1, 0, 0]; vec3.transformMat3(vStart, vStart, m); vStart = [vStart[0], vStart[1]]; var angle = vec2.angleTo(vStart, vPoint, x.end < x.start); if (Util.snapEqual(angle, Math.PI * 2)) { angle = 0; } var radius = vec2.length(vPoint); var xPercent = angle / (x.end - x.start); xPercent = x.end - x.start > 0 ? xPercent : -xPercent; var yPercent = this.invertDim(radius, 'y'); var rst = {}; rst.x = this.isTransposed ? yPercent : xPercent; rst.y = this.isTransposed ? xPercent : yPercent; return rst; }; return Polar; }(Base); module.exports = Polar; /***/ }), /* 333 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the class of Helix Coordinate * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(43); var MatrixUtil = __webpack_require__(2).MatrixUtil; var vec2 = MatrixUtil.vec2; var Helix = function (_Base) { _inherits(Helix, _Base); Helix.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { startAngle: 1.25 * Math.PI, endAngle: 7.25 * Math.PI, innerRadius: 0, type: 'helix', isHelix: true }); }; function Helix(cfg) { _classCallCheck(this, Helix); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); _this._init(); return _this; } Helix.prototype._init = function _init() { var width = this.width; var height = this.height; var radius = this.radius; var innerRadius = this.innerRadius; var startAngle = this.startAngle; var endAngle = this.endAngle; var index = (endAngle - startAngle) / (2 * Math.PI) + 1; // 螺线圈数 var maxRadius = Math.min(width, height) / 2; if (radius && radius >= 0 && radius <= 1) { maxRadius = maxRadius * radius; } var d = Math.floor(maxRadius * (1 - innerRadius) / index); var a = d / (Math.PI * 2); // 螺线系数 var x = { start: startAngle, end: endAngle }; var y = { start: innerRadius * maxRadius, end: innerRadius * maxRadius + d * 0.99 }; this.a = a; this.d = d; this.x = x; this.y = y; }; Helix.prototype.getCenter = function getCenter() { return this.center; }; /** * 将百分比数据变成屏幕坐标 * @param {Object} point 归一化的点坐标 * @return {Object} 返回对应的屏幕坐标 */ Helix.prototype.convertPoint = function convertPoint(point) { var a = this.a; var center = this.center; var x = void 0; var y = void 0; if (this.isTransposed) { x = point.y; y = point.x; } else { x = point.x; y = point.y; } var thi = this.convertDim(x, 'x'); var r = a * thi; var newY = this.convertDim(y, 'y'); return { x: center.x + Math.cos(thi) * (r + newY), y: center.y + Math.sin(thi) * (r + newY) }; }; /** * 将屏幕坐标点还原成百分比数据 * @param {Object} point 屏幕坐标 * @return {Object} 返回对应的归一化后的数据 */ Helix.prototype.invertPoint = function invertPoint(point) { var center = this.center; var a = this.a; var d = this.d + this.y.start; var v = vec2.subtract([], [point.x, point.y], [center.x, center.y]); var thi = vec2.angleTo(v, [1, 0], true); var rMin = thi * a; // 坐标与原点的连线在第一圈上的交点,最小r值 if (vec2.length(v) < rMin) { // 坐标与原点的连线不可能小于最小r值,但不排除因小数计算产生的略小于rMin的情况 rMin = vec2.length(v); } var index = Math.floor((vec2.length(v) - rMin) / d); // 当前点位于第index圈 thi = 2 * index * Math.PI + thi; var r = a * thi; var newY = vec2.length(v) - r; newY = Util.snapEqual(newY, 0) ? 0 : newY; var x = this.invertDim(thi, 'x'); var y = this.invertDim(newY, 'y'); x = Util.snapEqual(x, 0) ? 0 : x; y = Util.snapEqual(y, 0) ? 0 : y; var rst = {}; rst.x = this.isTransposed ? y : x; rst.y = this.isTransposed ? x : y; return rst; }; return Helix; }(Base); module.exports = Helix; /***/ }), /* 334 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview The controller of axis * @author sima.zhang */ var Util = __webpack_require__(0); var _require = __webpack_require__(25), Axis = _require.Axis; var vec2 = __webpack_require__(2).MatrixUtil.vec2; var Global = __webpack_require__(1); function formatTicks(ticks) { var tmp = []; if (ticks.length > 0) { tmp = ticks.slice(0); var first = tmp[0]; var last = tmp[tmp.length - 1]; if (first.value !== 0) { tmp.unshift({ value: 0 }); } if (last.value !== 1) { tmp.push({ value: 1 }); } } return tmp; } var AxisController = function () { function AxisController(cfg) { _classCallCheck(this, AxisController); this.visible = true; this.container = null; this.coord = null; this.options = null; this.axes = []; Util.mix(this, cfg); } AxisController.prototype._isHide = function _isHide(field) { // 对应的坐标轴是否隐藏 var options = this.options; if (options && options[field] === false) { return true; } return false; }; AxisController.prototype._getMiddleValue = function _getMiddleValue(curValue, ticks, index) { var tickCount = ticks.length; if (index === tickCount - 1) { return null; } var nextValue = ticks[index + 1].value; return (curValue + nextValue) / 2; }; AxisController.prototype._getLineRange = function _getLineRange(coord, scale, dimType, index) { var start = void 0; var end = void 0; var isVertical = void 0; var field = scale.field; var options = this.options; var position = ''; if (options[field] && options[field].position) { position = options[field].position; } if (dimType === 'x') { // x轴的坐标轴,底部的横坐标 start = { x: 0, y: position === 'top' ? 1 : 0 }; end = { x: 1, y: position === 'top' ? 1 : 0 }; isVertical = false; } else { // y轴坐标轴 if (index) { // 多轴的情况 start = { x: position === 'left' ? 0 : 1, y: 0 }; end = { x: position === 'left' ? 0 : 1, y: 1 }; } else { // 单个y轴,或者第一个y轴 start = { x: position === 'right' ? 1 : 0, y: 0 }; end = { x: position === 'right' ? 1 : 0, y: 1 }; } isVertical = true; } start = coord.convert(start); end = coord.convert(end); return { start: start, end: end, isVertical: isVertical }; }; AxisController.prototype._getLineCfg = function _getLineCfg(coord, scale, dimType, index) { var factor = void 0; var range = this._getLineRange(coord, scale, dimType, index); var isVertical = range.isVertical; // 标识该坐标轴是否是纵坐标 var start = range.start; var end = range.end; var center = coord.center; if (coord.isTransposed) { isVertical = !isVertical; } if (isVertical && start.x > center.x || !isVertical && start.y > center.y) { factor = 1; } else { factor = -1; } return { isVertical: isVertical, factor: factor, start: start, end: end }; }; // 获取圆弧坐标轴配置项信息 AxisController.prototype._getCircleCfg = function _getCircleCfg(coord) { var circleCfg = {}; var rangeX = coord.x; var rangeY = coord.y; var isReflectY = rangeY.start > rangeY.end; var start = void 0; if (coord.isTransposed) { start = { x: isReflectY ? 0 : 1, y: 0 }; } else { start = { x: 0, y: isReflectY ? 0 : 1 }; } start = coord.convert(start); var center = coord.circleCentre; var startVector = [start.x - center.x, start.y - center.y]; var normalVector = [1, 0]; var startAngle = void 0; if (start.y > center.y) { startAngle = vec2.angle(startVector, normalVector); } else { startAngle = vec2.angle(startVector, normalVector) * -1; } var endAngle = startAngle + (rangeX.end - rangeX.start); circleCfg.startAngle = startAngle; circleCfg.endAngle = endAngle; circleCfg.center = center; circleCfg.radius = Math.sqrt(Math.pow(start.x - center.x, 2) + Math.pow(start.y - center.y, 2)); circleCfg.inner = coord.innerRadius || 0; return circleCfg; }; AxisController.prototype._getRadiusCfg = function _getRadiusCfg(coord) { var startAngle = coord.x.start; var factor = startAngle < 0 ? -1 : 1; var start = void 0; var end = void 0; if (coord.isTransposed) { start = { x: 0, y: 0 }; end = { x: 1, y: 0 }; } else { start = { x: 0, y: 0 }; end = { x: 0, y: 1 }; } return { factor: factor, start: coord.convert(start), end: coord.convert(end) }; }; // 确定坐标轴的位置 AxisController.prototype._getAxisPosition = function _getAxisPosition(coord, dimType, index, field) { var position = ''; // 用户自己定义了 position var options = this.options; if (options[field] && options[field].position) { position = options[field].position; } else { var coordType = coord.type; if (coord.isRect) { if (dimType === 'x') { position = 'bottom'; } else if (dimType === 'y') { if (index) { position = 'right'; } else { position = 'left'; } } } else if (coordType === 'helix') { position = 'helix'; } else if (dimType === 'x') { position = coord.isTransposed ? 'radius' : 'circle'; } else { position = coord.isTransposed ? 'circle' : 'radius'; } } return position; }; // 获取坐标轴构成的配置信息 AxisController.prototype._getAxisDefaultCfg = function _getAxisDefaultCfg(coord, scale, type, position) { var self = this; var cfg = {}; var options = self.options; var field = scale.field; var isShowTitle = !!(Global.axis[position] && Global.axis[position].title); // 用户全局禁用 title var titleCfg = void 0; // bugfix: title was set by chart.axis('field', { title: {} }) if (isShowTitle || options[field] && options[field].title) { titleCfg = { title: { text: scale.alias || field } }; } cfg = Util.deepMix({}, Global.axis[position], cfg, options[field]); Util.mix(cfg, titleCfg); cfg.ticks = scale.getTicks(); if (coord.isPolar && !scale.isCategory) { if (type === 'x' && Math.abs(coord.endAngle - coord.startAngle) === Math.PI * 2) { cfg.ticks.pop(); } } cfg.coord = coord; if (cfg.label && Util.isNil(cfg.label.autoRotate)) { cfg.label.autoRotate = true; // 允许自动旋转,避免重叠 } return cfg; }; // 确定坐标轴的配置信息 AxisController.prototype._getAxisCfg = function _getAxisCfg(coord, scale, verticalScale, dimType) { var index = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : ''; var viewId = arguments[5]; var self = this; var position = self._getAxisPosition(coord, dimType, index, scale.field); var cfg = self._getAxisDefaultCfg(coord, scale, dimType, position); if (!Util.isEmpty(cfg.grid) && verticalScale) { // 生成 gridPoints var gridPoints = []; var verticalTicks = formatTicks(verticalScale.getTicks()); // 没有垂直的坐标点时不会只栅格 if (verticalTicks.length) { var ticks = cfg.ticks; Util.each(ticks, function (tick, idx) { var subPoints = []; var value = tick.value; if (cfg.grid.align === 'center') { value = self._getMiddleValue(value, ticks, idx); } if (!Util.isNil(value)) { var rangeX = coord.x; var rangeY = coord.y; Util.each(verticalTicks, function (verticalTick) { var x = dimType === 'x' ? value : verticalTick.value; var y = dimType === 'x' ? verticalTick.value : value; var point = coord.convert({ x: x, y: y }); if (coord.isPolar) { var center = coord.circleCentre; if (rangeY.start > rangeY.end) { y = 1 - y; } point.flag = rangeX.start > rangeX.end ? 0 : 1; point.radius = Math.sqrt(Math.pow(point.x - center.x, 2) + Math.pow(point.y - center.y, 2)); } subPoints.push(point); }); gridPoints.push({ _id: viewId + '-' + dimType + index + '-grid-' + tick.tickValue, points: subPoints }); } }); // TODO: 临时解决,需要添加一条以满足最后一格能颜色交替 if (ticks.length % 2 === 0 && cfg.grid.align === 'center' && cfg.grid.alternateColor) { gridPoints.push({ points: [{ x: coord.end.x, y: coord.start.y }, { x: coord.end.x, y: coord.end.y }] }); } } cfg.grid.items = gridPoints; } return cfg; }; AxisController.prototype._getHelixCfg = function _getHelixCfg(coord) { var helixCfg = {}; var a = coord.a; var startAngle = coord.startAngle; var endAngle = coord.endAngle; var index = 100; var crp = []; for (var i = 0; i <= index; i++) { var point = coord.convert({ x: i / 100, y: 0 }); crp.push(point.x); crp.push(point.y); } var axisStart = coord.convert({ x: 0, y: 0 }); helixCfg.a = a; helixCfg.startAngle = startAngle; helixCfg.endAngle = endAngle; helixCfg.crp = crp; helixCfg.axisStart = axisStart; helixCfg.center = coord.center; helixCfg.inner = coord.y.start; // 内半径 return helixCfg; }; AxisController.prototype._drawAxis = function _drawAxis(coord, scale, verticalScale, dimType, viewId, xAxis, index) { var container = this.container; var C = void 0; // 坐标轴类 var appendCfg = void 0; // 每个坐标轴 start end 等绘制边界的信息 if (coord.type === 'cartesian') { C = Axis.Line; appendCfg = this._getLineCfg(coord, scale, dimType, index); } else if (coord.type === 'helix' && dimType === 'x') { C = Axis.Helix; appendCfg = this._getHelixCfg(coord); } else if (dimType === 'x') { C = Axis.Circle; appendCfg = this._getCircleCfg(coord); } else { C = Axis.Line; appendCfg = this._getRadiusCfg(coord); } var cfg = this._getAxisCfg(coord, scale, verticalScale, dimType, index, viewId); cfg = Util.mix({}, cfg, appendCfg); if (dimType === 'y' && xAxis && xAxis.get('type') === 'circle') { cfg.circle = xAxis; } cfg._id = viewId + '-' + dimType; if (!Util.isNil(index)) { cfg._id = viewId + '-' + dimType + index; } var axis = container.addGroup(C, cfg); this.axes.push(axis); return axis; }; AxisController.prototype.createAxis = function createAxis(xScale, yScales, viewId) { var self = this; var coord = this.coord; var coordType = coord.type; // theta坐标系默认不绘制坐标轴 if (coordType !== 'theta' && !(coordType === 'polar' && coord.isTransposed)) { var xAxis = void 0; if (xScale && !self._isHide(xScale.field)) { xAxis = self._drawAxis(coord, xScale, yScales[0], 'x', viewId); // 绘制 x 轴 } if (!Util.isEmpty(yScales) && coordType !== 'helix') { Util.each(yScales, function (yScale, index) { if (!self._isHide(yScale.field)) { self._drawAxis(coord, yScale, xScale, 'y', viewId, xAxis, index); } }); } } }; AxisController.prototype.changeVisible = function changeVisible(visible) { var axes = this.axes; Util.each(axes, function (axis) { axis.set('visible', visible); }); }; AxisController.prototype.clear = function clear() { var axes = this.axes; Util.each(axes, function (axis) { axis.remove(); }); this.axes = []; }; return AxisController; }(); module.exports = AxisController; /***/ }), /* 335 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview the entry of axis * @author sima.zhang */ module.exports = { Line: __webpack_require__(336), // 基础的直线坐标轴 Circle: __webpack_require__(338), // 极坐标下 Helix: __webpack_require__(339), // 螺旋坐标轴 PolyLine: __webpack_require__(340) // 多线段组成的坐标轴 }; /***/ }), /* 336 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the radius axis of polar coordinate and axis of cartesian coordinate * @author sima.zhang */ var Base = __webpack_require__(44); var Util = __webpack_require__(0); var _require = __webpack_require__(2), MatrixUtil = _require.MatrixUtil; var vec2 = MatrixUtil.vec2; var Line = function (_Base) { _inherits(Line, _Base); function Line() { _classCallCheck(this, Line); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Line.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { x: null, // @type {Number} 距离初始位置的x轴偏移量,仅对于左侧、右侧的纵向坐标有效 y: null, // @type {Number} 距离初始位置的y轴偏移量,仅对顶部、底部的横向坐标轴有效 line: { // @type {Attrs} 坐标轴线的图形属性,如果设置成null,则不显示轴线 lineWidth: 1, stroke: '#C0D0E0' }, tickLine: { // @type {Attrs} 标注坐标线的图形属性 lineWidth: 1, stroke: '#C0D0E0', length: 5 }, isVertical: false, start: null, // @type {Object} 起点 end: null // @type {Object} 终点 }); }; Line.prototype._getAvgLabelLength = function _getAvgLabelLength(labelsGroup) { var labels = labelsGroup.get('children'); return labels[1].attr('x') - labels[0].attr('x'); }; /** * 获取距离坐标轴的向量 * @override * @param {Number} offset 偏移值 * @return {Array} 返回二维向量 */ Line.prototype.getSideVector = function getSideVector(offset) { var self = this; var factor = self.get('factor'); var isVertical = self.get('isVertical'); var start = self.get('start'); var end = self.get('end'); var axisVector = self.getAxisVector(); var normal = vec2.normalize([], axisVector); var direction = false; if (isVertical && start.y < end.y || !isVertical && start.x > end.x) { direction = true; } var verticalVector = vec2.vertical([], normal, direction); return vec2.scale([], verticalVector, offset * factor); }; Line.prototype.getAxisVector = function getAxisVector() { var start = this.get('start'); var end = this.get('end'); return [end.x - start.x, end.y - start.y]; }; Line.prototype.getLinePath = function getLinePath() { var self = this; var start = self.get('start'); var end = self.get('end'); var path = []; path.push(['M', start.x, start.y]); path.push(['L', end.x, end.y]); return path; }; Line.prototype.getTickEnd = function getTickEnd(start, value) { var self = this; var offsetVector = self.getSideVector(value); return { x: start.x + offsetVector[0], y: start.y + offsetVector[1] }; }; Line.prototype.getTickPoint = function getTickPoint(tickValue) { var self = this; var start = self.get('start'); var end = self.get('end'); var rangeX = end.x - start.x; var rangeY = end.y - start.y; return { x: start.x + rangeX * tickValue, y: start.y + rangeY * tickValue }; }; Line.prototype.renderTitle = function renderTitle() { var self = this; var title = self.get('title'); var offsetPoint = self.getTickPoint(0.5); var titleOffset = title.offset; if (!titleOffset) { // 没有指定 offset 则自动计算 titleOffset = 20; var labelsGroup = self.get('labelsGroup'); if (labelsGroup) { var labelLength = self.getMaxLabelWidth(labelsGroup); var labelOffset = self.get('label').offset || self.get('_labelOffset'); titleOffset += labelLength + labelOffset; } } var textStyle = title.textStyle; var cfg = Util.mix({}, textStyle); if (title.text) { var vector = self.getAxisVector(); // 坐标轴方向的向量 if (title.autoRotate && !textStyle.rotate) { // 自动旋转并且用户没有指定标题的旋转角度 var angle = 0; if (!Util.snapEqual(vector[1], 0)) { // 所有水平坐标轴,文本不转置 var v1 = [1, 0]; var v2 = [vector[0], vector[1]]; angle = vec2.angleTo(v2, v1, true); } cfg.rotate = angle * (180 / Math.PI); } else if (textStyle.rotate) { // 用户设置了旋转角度就以用户设置的为准 cfg.rotate = textStyle.rotate / 180 * Math.PI; // 将角度转换为弧度 } var sideVector = self.getSideVector(titleOffset); var point = void 0; var position = title.position; if (position === 'start') { point = { x: this.get('start').x + sideVector[0], y: this.get('start').y + sideVector[1] }; } else if (position === 'end') { point = { x: this.get('end').x + sideVector[0], y: this.get('end').y + sideVector[1] }; } else { point = { x: offsetPoint.x + sideVector[0], y: offsetPoint.y + sideVector[1] }; } cfg.x = point.x; cfg.y = point.y; cfg.text = title.text; var titleShape = self.addShape('Text', { zIndex: 2, attrs: cfg }); titleShape.name = 'axis-title'; self.get('appendInfo') && titleShape.setSilent('appendInfo', self.get('appendInfo')); } }; Line.prototype.autoRotateLabels = function autoRotateLabels() { var self = this; var labelsGroup = self.get('labelsGroup'); var title = self.get('title'); if (labelsGroup) { var offset = self.get('label').offset; var append = 12; var titleOffset = title ? title.offset : 48; if (titleOffset < 0) { // 如果是负的的话就不旋转 return; } var vector = self.getAxisVector(); // 坐标轴的向量,仅处理水平或者垂直的场景 var angle = void 0; var maxWidth = void 0; if (Util.snapEqual(vector[0], 0) && title && title.text) { // 坐标轴垂直,由于不知道边距,只能防止跟title重合,如果title不存在,则不自动旋转 maxWidth = self.getMaxLabelWidth(labelsGroup); if (maxWidth > titleOffset - offset - append) { angle = Math.acos((titleOffset - offset - append) / maxWidth) * -1; } } else if (Util.snapEqual(vector[1], 0) && labelsGroup.getCount() > 1) { // 坐标轴水平,不考虑边距,根据最长的和平均值进行翻转 var avgWidth = Math.abs(self._getAvgLabelLength(labelsGroup)); maxWidth = self.getMaxLabelWidth(labelsGroup); if (maxWidth > avgWidth) { angle = Math.asin((titleOffset - offset - append) * 1.25 / maxWidth); } } if (angle) { var factor = self.get('factor'); Util.each(labelsGroup.get('children'), function (label) { label.rotateAtStart(angle); if (Util.snapEqual(vector[1], 0)) { if (factor > 0) { label.attr('textAlign', 'left'); } else { label.attr('textAlign', 'right'); } } }); } } }; return Line; }(Base); module.exports = Line; /***/ }), /* 337 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the grid of axis * @author sima.zhang */ var _require = __webpack_require__(2), Group = _require.Group; var Util = __webpack_require__(0); var Grid = function (_Group) { _inherits(Grid, _Group); function Grid() { _classCallCheck(this, Grid); return _possibleConstructorReturn(this, _Group.apply(this, arguments)); } Grid.prototype.getDefaultCfg = function getDefaultCfg() { return { zIndex: 1, /** * 栅格线的类型 * - line 不封闭的线 * - polygon 封闭的多边形 * @type {String} */ type: 'line', /** * 线的样式配置 * @type {Object} */ lineStyle: null, /** * 线集合的配置 * @type {Array} */ items: null, /** * 为网格设置交替的背景色,指定一个值则先渲染奇数层,两个值则交替渲染 * @type {String | Array} */ alternateColor: null, matrix: null, /** * 是否隐藏第一条网格线,默认为 false * @type {Boolean} */ hideFirstLine: false, /** * 是否隐藏最后一条网格线,默认为 false * @type {Boolean} */ hideLastLine: false }; }; Grid.prototype._renderUI = function _renderUI() { _Group.prototype._renderUI.call(this); this._drawLines(); }; Grid.prototype._drawLines = function _drawLines() { var self = this; var lineStyle = self.get('lineStyle'); var items = self.get('items'); if (items && items.length) { self._precessItems(items); self._drawGridLines(items, lineStyle); } }; Grid.prototype._precessItems = function _precessItems(items) { var self = this; var preItem = void 0; Util.each(items, function (item, index) { if (preItem && self.get('alternateColor')) { self._drawAlternativeBg(item, preItem, index); } preItem = item; }); }; Grid.prototype._drawGridLines = function _drawGridLines(items, lineStyle) { var self = this; var type = this.get('type'); var gridLine = void 0; var path = void 0; var cfg = void 0; var points = void 0; var itemsLength = items.length; if (type === 'line' || type === 'polygon') { Util.each(items, function (item, idx) { if (self.get('hideFirstLine') && idx === 0) { // 不展示第一条网格线 return; } if (self.get('hideLastLine') && idx === itemsLength - 1) { // 不展示最后一条网格线 return; } points = item.points; path = []; if (type === 'line') { path.push(['M', points[0].x, points[0].y]); path.push(['L', points[points.length - 1].x, points[points.length - 1].y]); } else { Util.each(points, function (point, index) { if (index === 0) { path.push(['M', point.x, point.y]); } else { path.push(['L', point.x, point.y]); } }); } cfg = Util.mix({}, lineStyle, { path: path }); gridLine = self.addShape('path', { attrs: cfg }); gridLine.name = 'axis-grid'; gridLine._id = item._id; gridLine.set('coord', self.get('coord')); self.get('appendInfo') && gridLine.setSilent('appendInfo', self.get('appendInfo')); }); } else { Util.each(items, function (item, idx) { if (self.get('hideFirstLine') && idx === 0) { // 不展示第一条网格线 return; } if (self.get('hideLastLine') && idx === itemsLength - 1) { // 不展示最后一条网格线 return; } points = item.points; path = []; Util.each(points, function (point, index) { var radius = point.radius; if (index === 0) { path.push(['M', point.x, point.y]); } else { path.push(['A', radius, radius, 0, 0, point.flag, point.x, point.y]); } }); cfg = Util.mix({}, lineStyle, { path: path }); gridLine = self.addShape('path', { attrs: cfg }); gridLine.name = 'axis-grid'; gridLine._id = item._id; gridLine.set('coord', self.get('coord')); self.get('appendInfo') && gridLine.setSilent('appendInfo', self.get('appendInfo')); }); } }; Grid.prototype._drawAlternativeBg = function _drawAlternativeBg(item, preItem, index) { var self = this; var alternateColor = self.get('alternateColor'); var attrs = void 0; var oddColor = void 0; var evenColor = void 0; if (Util.isString(alternateColor)) { oddColor = alternateColor; } else if (Util.isArray(alternateColor)) { oddColor = alternateColor[0]; evenColor = alternateColor[1]; } if (index % 2 === 0) { if (evenColor) { attrs = self._getBackItem(preItem.points, item.points, evenColor); } } else if (oddColor) { attrs = self._getBackItem(preItem.points, item.points, oddColor); } var shape = self.addShape('Path', { attrs: attrs }); shape.name = 'axis-grid-rect'; shape._id = item._id && item._id.replace('grid', 'grid-rect'); shape.set('coord', self.get('coord')); self.get('appendInfo') && shape.setSilent('appendInfo', self.get('appendInfo')); }; Grid.prototype._getBackItem = function _getBackItem(start, end, bgColor) { var path = []; var type = this.get('type'); if (type === 'line') { path.push(['M', start[0].x, start[0].y]); path.push(['L', start[start.length - 1].x, start[start.length - 1].y]); path.push(['L', end[end.length - 1].x, end[end.length - 1].y]); path.push(['L', end[0].x, end[0].y]); path.push(['Z']); } else if (type === 'polygon') { Util.each(start, function (subItem, index) { if (index === 0) { path.push(['M', subItem.x, subItem.y]); } else { path.push(['L', subItem.x, subItem.y]); } }); for (var i = end.length - 1; i >= 0; i--) { path.push(['L', end[i].x, end[i].y]); } path.push(['Z']); } else { var flag = start[0].flag; Util.each(start, function (subItem, index) { var radius = subItem.radius; if (index === 0) { path.push(['M', subItem.x, subItem.y]); } else { path.push(['A', radius, radius, 0, 0, subItem.flag, subItem.x, subItem.y]); } }); for (var j = end.length - 1; j >= 0; j--) { var endSubItem = end[j]; var endRadius = endSubItem.radius; if (j === end.length - 1) { path.push(['M', endSubItem.x, endSubItem.y]); } else { path.push(['A', endRadius, endRadius, 0, 0, flag === 1 ? 0 : 1, endSubItem.x, endSubItem.y]); } } } return { fill: bgColor, path: path }; }; return Grid; }(Group); module.exports = Grid; /***/ }), /* 338 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the circle axis of polar coordinate * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(44); var vec2 = __webpack_require__(2).MatrixUtil.vec2; var Circle = function (_Base) { _inherits(Circle, _Base); function Circle() { _classCallCheck(this, Circle); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Circle.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * 坐标轴的类型 * @type {String} */ type: 'circle', /** * 指定刻度之间的间距 * @type {Number} */ tickInterval: null, /** * 开始弧度 * @type {Number} */ startAngle: -Math.PI / 2, /** * 结束弧度 * @type {Number} */ endAngle: Math.PI * 3 / 2, line: { // @type {Attrs} 坐标轴线的图形属性,如果设置成null,则不显示轴线 lineWidth: 1, stroke: '#C0D0E0' }, tickLine: { // @type {Attrs} 标注坐标线的图形属性 lineWidth: 1, stroke: '#C0D0E0', length: 5 }, /** * 默认文本距离轴线的距离 * @type {Number} */ _labelOffset: 5 }); }; Circle.prototype.parseTick = function parseTick(tick, index, length) { return { text: tick, value: index / length }; }; Circle.prototype._getCirclePoint = function _getCirclePoint(angle, radius) { var self = this; var center = self.get('center'); radius = radius || self.get('radius'); return { x: center.x + Math.cos(angle) * radius, y: center.y + Math.sin(angle) * radius }; }; Circle.prototype.getTickPoint = function getTickPoint(value) { var self = this; var startAngle = self.get('startAngle'); var endAngle = self.get('endAngle'); var angle = startAngle + (endAngle - startAngle) * value; return self._getCirclePoint(angle); }; Circle.prototype.getSideVector = function getSideVector(offset, point) { var self = this; var center = self.get('center'); var vector = [point.x - center.x, point.y - center.y]; if (!Util.isNil(offset)) { var vecLen = vec2.length(vector); vec2.scale(vector, vector, offset / vecLen); } return vector; }; Circle.prototype.getSidePoint = function getSidePoint(point, offset) { var self = this; var vector = self.getSideVector(offset, point); return { x: point.x + vector[0], y: point.y + vector[1] }; }; Circle.prototype.getTickEnd = function getTickEnd(start, length) { var self = this; var tickLine = self.get('tickLine'); length = length ? length : tickLine.length; return self.getSidePoint(start, length); }; Circle.prototype.getTextAnchor = function getTextAnchor(vector) { var align = void 0; if (Util.snapEqual(vector[0], 0)) { align = 'center'; } else if (vector[0] > 0) { align = 'left'; } else if (vector[0] < 0) { align = 'right'; } return align; }; Circle.prototype.getLinePath = function getLinePath() { var self = this; var center = self.get('center'); var x = center.x; var y = center.y; var rx = self.get('radius'); var ry = rx; var startAngle = self.get('startAngle'); var endAngle = self.get('endAngle'); var inner = self.get('inner'); var path = []; if (Math.abs(endAngle - startAngle) === Math.PI * 2) { path = [['M', x, y], ['m', 0, -ry], ['a', rx, ry, 0, 1, 1, 0, 2 * ry], ['a', rx, ry, 0, 1, 1, 0, -2 * ry], ['z']]; } else { var startPoint = self._getCirclePoint(startAngle); var endPoint = self._getCirclePoint(endAngle); var large = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0; var sweep = startAngle > endAngle ? 0 : 1; if (!inner) { path = [['M', x, y], ['L', startPoint.x, startPoint.y], ['A', rx, ry, 0, large, sweep, endPoint.x, endPoint.y], ['L', x, y]]; } else { var innerStartVector = self.getSideVector(inner * rx, startPoint); var innerEndVector = self.getSideVector(inner * rx, endPoint); var innerStartPoint = { x: innerStartVector[0] + x, y: innerStartVector[1] + y }; var innerEndPoint = { x: innerEndVector[0] + x, y: innerEndVector[1] + y }; path = [['M', innerStartPoint.x, innerStartPoint.y], ['L', startPoint.x, startPoint.y], ['A', rx, ry, 0, large, sweep, endPoint.x, endPoint.y], ['L', innerEndPoint.x, innerEndPoint.y], ['A', rx * inner, ry * inner, 0, large, Math.abs(sweep - 1), innerStartPoint.x, innerStartPoint.y]]; } } return path; }; Circle.prototype.addLabel = function addLabel(tick, point, index) { var self = this; var offset = self.get('label').offset || self.get('_labelOffset') || 0.001; point = self.getSidePoint(point, offset); _Base.prototype.addLabel.call(this, tick, point, index); }; Circle.prototype.autoRotateLabels = function autoRotateLabels() { var self = this; var ticks = self.get('ticks'); var labelsGroup = self.get('labelsGroup'); if (labelsGroup && ticks.length > 12) { // 小于12个文本时文本不旋转 var radius = self.get('radius'); var startAngle = self.get('startAngle'); var endAngle = self.get('endAngle'); var totalAngle = endAngle - startAngle; var avgAngle = totalAngle / (ticks.length - 1); var avgWidth = Math.sin(avgAngle / 2) * radius * 2; var maxLength = self.getMaxLabelWidth(labelsGroup); Util.each(labelsGroup.get('children'), function (label, index) { var tick = ticks[index]; var angle = tick.value * totalAngle + startAngle; var mode = angle % (Math.PI * 2); if (maxLength < avgWidth) { // 文本的最大宽度大于 if (mode <= 0) { angle = angle + Math.PI; } if (mode > Math.PI) { angle = angle - Math.PI; } angle = angle - Math.PI / 2; label.attr('textAlign', 'center'); } else { if (mode > Math.PI / 2) { angle = angle - Math.PI; } else if (mode < Math.PI / 2 * -1) { angle = angle + Math.PI; } } label.rotateAtStart(angle); }); } }; return Circle; }(Base); module.exports = Circle; /***/ }), /* 339 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the helix axis of helix coordinate * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(44); var _require = __webpack_require__(2), MatrixUtil = _require.MatrixUtil, PathUtil = _require.PathUtil; var vec2 = MatrixUtil.vec2; var Helix = function (_Base) { _inherits(Helix, _Base); function Helix() { _classCallCheck(this, Helix); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Helix.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { type: 'helix', line: { // @type {Attrs} 坐标轴线的图形属性,如果设置成null,则不显示轴线 lineWidth: 1, stroke: '#C0D0E0' }, tickLine: { // @type {Attrs} 标注坐标线的图形属性 lineWidth: 1, stroke: '#C0D0E0', length: 5 }, startAngle: 1.25 * Math.PI, endAngle: 7.25 * Math.PI, // 螺旋系数 a: 0, // 画布中心坐标 center: null, // 坐标轴绘制起点 axisStart: null, // 坐标轴的n个坐标点 crp: [] }); }; Helix.prototype.getLinePath = function getLinePath() { var self = this; var crp = self.get('crp'); var axisStart = self.get('axisStart'); var path = PathUtil.catmullRomToBezier(crp); path.unshift(['M', axisStart.x, axisStart.y]); return path; }; Helix.prototype.getTickPoint = function getTickPoint(value) { var self = this; var startAngle = self.get('startAngle'); var endAngle = self.get('endAngle'); var angle = startAngle + (endAngle - startAngle) * value; return self._getHelixPoint(angle); }; Helix.prototype._getHelixPoint = function _getHelixPoint(angle) { var self = this; var center = self.get('center'); var a = self.get('a'); // 螺线系数 var radius = a * angle + self.get('inner'); // 螺线方程 return { x: center.x + Math.cos(angle) * radius, y: center.y + Math.sin(angle) * radius }; }; Helix.prototype.getSideVector = function getSideVector(offset, point) { var self = this; var center = self.get('center'); var vector = [point.x - center.x, point.y - center.y]; if (offset) { var vecLen = vec2.length(vector); vec2.scale(vector, vector, offset / vecLen); } return vector; }; Helix.prototype.getSidePoint = function getSidePoint(point, offset) { var self = this; var vector = self.getSideVector(offset, point); return { x: point.x + vector[0], y: point.y + vector[1] }; }; Helix.prototype.getTickEnd = function getTickEnd(start, length) { var self = this; var tickLine = self.get('tickLine'); length = length ? length : tickLine.length; return self.getSidePoint(start, length); }; return Helix; }(Base); module.exports = Helix; /***/ }), /* 340 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the axis of map coodinate * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(44); var _require = __webpack_require__(2), MatrixUtil = _require.MatrixUtil, PathUtil = _require.PathUtil; var vec2 = MatrixUtil.vec2; var Polyline = function (_Base) { _inherits(Polyline, _Base); function Polyline() { _classCallCheck(this, Polyline); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Polyline.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { type: 'polyline' }); }; Polyline.prototype.getLinePath = function getLinePath() { var self = this; var tickPoints = self.get('tickPoints'); var start = self.get('start'); var end = self.get('end'); var points = []; points.push(start.x); points.push(start.y); Util.each(tickPoints, function (tick) { points.push(tick.x); points.push(tick.y); }); points.push(end.x); points.push(end.y); var path = PathUtil.catmullRomToBezier(points); path.unshift(['M', start.x, start.y]); return path; }; Polyline.prototype.getTickPoint = function getTickPoint(value, index) { var tickPoints = this.get('tickPoints'); return tickPoints[index]; }; Polyline.prototype.getTickEnd = function getTickEnd(start, value, index) { var self = this; var lineAttrs = self.get('tickLine'); var tickLength = value ? value : lineAttrs.length; var offsetVector = self.getSideVector(tickLength, start, index); return { x: start.x + offsetVector[0], y: start.y + offsetVector[1] }; }; Polyline.prototype.getSideVector = function getSideVector(offset, point, index) { var self = this; var preTickPoint = void 0; if (index === 0) { preTickPoint = self.get('start'); } else { var tickPoints = self.get('tickPoints'); preTickPoint = tickPoints[index - 1]; } var vector = [point.x - preTickPoint.x, point.y - preTickPoint.y]; var normal = vec2.normalize([], vector); var verticalVector = vec2.vertical([], normal, false); return vec2.scale([], verticalVector, offset); }; return Polyline; }(Base); module.exports = Polyline; /***/ }), /* 341 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview the entry of guide * @author sima.zhang */ module.exports = { Line: __webpack_require__(342), Text: __webpack_require__(343), Image: __webpack_require__(344), Region: __webpack_require__(345), Html: __webpack_require__(346), Arc: __webpack_require__(347) }; /***/ }), /* 342 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the line guide * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(17); var vec2 = __webpack_require__(2).MatrixUtil.vec2; var Line = function (_Base) { _inherits(Line, _Base); function Line() { _classCallCheck(this, Line); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Line.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * 辅助元素类型 * @type {String} */ type: 'line', zIndex: 15, /** * 辅助线的起点位置 * @type {Object | Function | Array} */ start: null, /** * 辅助线的终点位置 * @type {Object | Function | Array} */ end: null, /** * 辅助线的图形样式 * @type {Object} */ lineStyle: { stroke: '#000', lineWidth: 1 }, /** * 辅助文本配置 * @type {Object} */ text: { position: 'end', // 文本的显示位置: start / center / end / 百分比 autoRotate: true, // 文本是否沿着辅助线的方向自动旋转 style: { fill: '#999', fontSize: 12, fontWeight: 500, fontFamily: 'sans-serif' }, // 辅助文本的样式 content: null // 辅助文本的文字 } }); }; Line.prototype.render = function render(coord, group) { var self = this; var start = self.parsePoint(coord, self.start); var end = self.parsePoint(coord, self.end); var guideLineGroup = group.addGroup(); self._drawLines(start, end, guideLineGroup); if (this.text && this.text.content) { self._drawText(start, end, guideLineGroup); } self.el = guideLineGroup; }; Line.prototype._drawLines = function _drawLines(start, end, group) { var path = [['M', start.x, start.y], ['L', end.x, end.y]]; var guideLine = group.addShape('Path', { attrs: Util.mix({ path: path }, this.lineStyle) }); guideLine.name = 'guide-line'; this.appendInfo && guideLine.setSilent('appendInfo', this.appendInfo); }; Line.prototype._drawText = function _drawText(start, end, group) { var textCfg = this.text; var position = textCfg.position; var textStyle = textCfg.style; var percent = void 0; if (position === 'start') { percent = 0; } else if (position === 'center') { percent = 0.5; } else if (Util.isString(position) && position.indexOf('%') !== -1) { percent = parseInt(position, 10) / 100; } else if (Util.isNumber(position)) { percent = position; } else { percent = 1; } if (percent > 1 || percent < 0) { percent = 1; } var cfg = { x: start.x + (end.x - start.x) * percent, y: start.y + (end.y - start.y) * percent }; if (textCfg.offsetX) { // 设置了偏移量 cfg.x += textCfg.offsetX; } if (textCfg.offsetY) { // 设置了偏移量 cfg.y += textCfg.offsetY; } cfg.text = textCfg.content; cfg = Util.mix({}, cfg, textStyle); if (textCfg.autoRotate && !textStyle.rotate) { var angle = vec2.angleTo([end.x - start.x, end.y - start.y], [1, 0], 1); cfg.rotate = angle; } else if (textStyle.rotate) { cfg.rotate = textStyle.rotate * Math.PI / 180; } var shape = group.addShape('Text', { attrs: cfg }); shape.name = 'guide-line-text'; this.appendInfo && shape.setSilent('appendInfo', this.appendInfo); }; return Line; }(Base); module.exports = Line; /***/ }), /* 343 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the text guide * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(17); var Text = function (_Base) { _inherits(Text, _Base); function Text() { _classCallCheck(this, Text); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Text.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * 辅助元素类型 * @type {String} */ type: 'text', // TODO 需要调整 zIndex: 15, /** * 辅助文本的位置 * @type {Object | Function | Array} */ position: null, /** * 辅助文本的显示文字 * @type {String} */ content: null, /** * 辅助文本的样式配置 * @type {Object} */ style: { fill: '#999', fontSize: 12, fontWeight: 500, textAlign: 'center' }, /** * x 方向的偏移量 * @type {Number} */ offsetX: null, /** * y 方向的偏移量 * @type {Number} */ offsetY: null }); }; Text.prototype.render = function render(coord, group) { var self = this; var position = self.position; var point = self.parsePoint(coord, position); var textStyle = Util.mix({}, this.style); if (self.offsetX) { point.x += self.offsetX; } if (self.offsetY) { point.y += self.offsetY; } if (textStyle.rotate) { textStyle.rotate = textStyle.rotate * Math.PI / 180; // 将角度转换为弧度 } var guideText = group.addShape('Text', { zIndex: self.zIndex, attrs: Util.mix({ text: self.content }, textStyle, point) }); guideText.name = 'guide-text'; self.appendInfo && guideText.setSilent('appendInfo', self.appendInfo); self.el = guideText; }; return Text; }(Base); module.exports = Text; /***/ }), /* 344 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the image guide * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(17); var Image = function (_Base) { _inherits(Image, _Base); function Image() { _classCallCheck(this, Image); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Image.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * 辅助元素类型 * @type {String} */ type: 'image', zIndex: 1, /** * 辅助图片的起点位置 * @type {Object | Function | Array} */ start: null, /** * 辅助图片的终点位置 * @type {Object | Function | Array} */ end: null, /** * 辅助图片的地址 * @type {Strinf} */ src: null, /** * x 方向的偏移量 * @type {Number} */ offsetX: null, /** * y 方向的偏移量 * @type {Number} */ offsetY: null }); }; Image.prototype.render = function render(coord, group) { var self = this; var start = self.parsePoint(coord, self.start); var cfg = { x: start.x, y: start.y }; cfg.img = self.src; if (!self.end) { // 如果咩有指定结束点,则 start 为图片的左上角坐标 if (self.width) { cfg.width = self.width; } if (self.height) { cfg.height = self.height; } } else { var end = self.parsePoint(coord, self.end); cfg.width = Math.abs(end.x - start.x); cfg.height = Math.abs(start.y - end.y); } if (self.offsetX) { cfg.x += self.offsetX; } if (self.offsetY) { cfg.y += self.offsetY; } var imgGuide = group.addShape('Image', { zIndex: 1, attrs: cfg }); imgGuide.name = 'guide-image'; self.appendInfo && imgGuide.setSilent('appendInfo', self.appendInfo); self.el = imgGuide; }; return Image; }(Base); module.exports = Image; /***/ }), /* 345 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the region guide * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(17); var Region = function (_Base) { _inherits(Region, _Base); function Region() { _classCallCheck(this, Region); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Region.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { type: 'region', zIndex: 1, start: null, end: null, style: { lineWidth: 0, fill: '#CCD7EB', opacity: 0.4 } }); }; Region.prototype.render = function render(coord, group) { var self = this; var rectStyle = self.style; var path = self._getPath(coord); var regionGroup = group.addShape('path', { zIndex: self.zIndex, attrs: Util.mix({ path: path }, rectStyle) }); regionGroup.name = 'guide-region'; self.appendInfo && regionGroup.setSilent('appendInfo', self.appendInfo); self.el = regionGroup; }; Region.prototype._getPath = function _getPath(coord) { var self = this; var start = self.parsePoint(coord, self.start); var end = self.parsePoint(coord, self.end); var path = []; path.push(['M', start.x, start.y]); path.push(['L', end.x, start.y]); path.push(['L', end.x, end.y]); path.push(['L', start.x, end.y]); path.push(['z']); return path; }; return Region; }(Base); module.exports = Region; /***/ }), /* 346 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the html guide * @author sima.zhang */ var Util = __webpack_require__(0); var _require = __webpack_require__(2), DomUtil = _require.DomUtil; var Base = __webpack_require__(17); var Html = function (_Base) { _inherits(Html, _Base); function Html() { _classCallCheck(this, Html); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Html.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * 辅助元素类型 * @type {String} */ type: 'html', zIndex: 15, /** * dom 显示位置点 * @type {Object | Array} */ position: null, /** * 水平方向对齐方式,可取值 'left'、'middle'、'right' * @type {String} */ alignX: 'middle', /** * 垂直方向对齐方式,可取值 'top'、'middle'、'bottom' * @type {String} */ alignY: 'middle', /** * x 方向的偏移量 * @type {Number} */ offsetX: null, /** * y 方向的偏移量 * @type {Number} */ offsetY: null, /** * html内容 *@type {String | Function} */ html: null }); }; Html.prototype.render = function render(coord, group) { var self = this; var position = self.parsePoint(coord, self.position); var parentNode = group.get('canvas').get('el').parentNode; var wrapperNode = DomUtil.createDom('
'); parentNode.appendChild(wrapperNode); var html = self.html; if (Util.isFunction(html)) { html = html(self.xScales, self.yScales); } var htmlNode = DomUtil.createDom(html); wrapperNode.appendChild(htmlNode); self._setDomPosition(wrapperNode, htmlNode, position); self.el = wrapperNode; }; Html.prototype._setDomPosition = function _setDomPosition(parentDom, childDom, point) { var self = this; var alignX = self.alignX; var alignY = self.alignY; var domWidth = DomUtil.getOuterWidth(childDom); var domHeight = DomUtil.getOuterHeight(childDom); var position = { x: point.x, y: point.y }; if (alignX === 'middle' && alignY === 'top') { position.x -= Util.round(domWidth / 2); } else if (alignX === 'middle' && alignY === 'bottom') { position.x -= Util.round(domWidth / 2); position.y -= Util.round(domHeight); } else if (alignX === 'left' && alignY === 'bottom') { position.y -= Util.round(domHeight); } else if (alignX === 'left' && alignY === 'middle') { position.y -= Util.round(domHeight / 2); } else if (alignX === 'left' && alignY === 'top') { position.x = point.x; position.y = point.y; } else if (alignX === 'right' && alignY === 'bottom') { position.x -= Util.round(domWidth); position.y -= Util.round(domHeight); } else if (alignX === 'right' && alignY === 'middle') { position.x -= Util.round(domWidth); position.y -= Util.round(domHeight / 2); } else if (alignX === 'right' && alignY === 'top') { position.x -= Util.round(domWidth); } else { // 默认位于中心点 position.x -= Util.round(domWidth / 2); position.y -= Util.round(domHeight / 2); } if (self.offsetX) { position.x += self.offsetX; } if (self.offsetY) { position.y += self.offsetY; } DomUtil.modifyCSS(parentDom, { position: 'absolute', top: Math.round(position.y) + 'px', left: Math.round(position.x) + 'px', visibility: 'visible', zIndex: self.zIndex }); }; Html.prototype.remove = function remove() { var self = this; var el = self.el; if (el) { el.parentNode.removeChild(el); } }; return Html; }(Base); module.exports = Html; /***/ }), /* 347 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview the arc guide * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(17); var Arc = function (_Base) { _inherits(Arc, _Base); function Arc() { _classCallCheck(this, Arc); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Arc.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * 辅助元素类型 * @type {String} */ type: 'arc', zIndex: 15, /** * 辅助弧线的起始点 * @type {Object | Function | Array} */ start: null, /** * 辅助弧线的终止点 * @type {Object | Function | Array} */ end: null, /** * 辅助文本的样式配置 * @type {Object} */ style: { stroke: '#999', lineWidth: 1 } }); }; Arc.prototype.render = function render(coord, group) { var self = this; var start = self.parsePoint(coord, self.start); var end = self.parsePoint(coord, self.end); var coordCenter = coord.getCenter(); var radius = Math.sqrt((start.x - coordCenter.x) * (start.x - coordCenter.x) + (start.y - coordCenter.y) * (start.y - coordCenter.y)); var startAngle = Math.atan2(start.y - coordCenter.y, start.x - coordCenter.x); var endAngle = Math.atan2(end.y - coordCenter.y, end.x - coordCenter.x); var arcShape = group.addShape('arc', { zIndex: self.zIndex, attrs: Util.mix({ x: coordCenter.x, y: coordCenter.y, r: radius, startAngle: startAngle, endAngle: endAngle }, self.style) }); arcShape.name = 'guide-arc'; self.appendInfo && arcShape.setSilent('appendInfo', self.appendInfo); self.el = arcShape; }; return Arc; }(Base); module.exports = Arc; /***/ }), /* 348 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview The entry of legend * @author sima.zhang */ module.exports = { Category: __webpack_require__(349), // 分类图例 Color: __webpack_require__(350), // 颜色图例 Size: __webpack_require__(352) // 大小图例 }; /***/ }), /* 349 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The class of category legend * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(122); var _require = __webpack_require__(2), DomUtil = _require.DomUtil, Event = _require.Event, Group = _require.Group; var Global = __webpack_require__(1); var LEGEND_STYLE = Global.legend.html; var CONTAINER_CLASS = 'g2-legend'; var TITLE_CLASS = 'g2-legend-title'; var LIST_CLASS = 'g2-legend-list'; var ITEM_CLASS = 'g2-legend-list-item'; var TEXT_CLASS = 'g2-legend-text'; var MARKER_CLASS = 'g2-legend-marker'; function findNodeByClass(node, className) { return node.getElementsByClassName(className)[0]; } function getParentNode(node, className) { var nodeClass = node.className; nodeClass = nodeClass.split(' '); if (nodeClass.indexOf(className) > -1) { return node; } if (node.parentNode) { if (node.parentNode.className === CONTAINER_CLASS) { return node.parentNode; } return getParentNode(node.parentNode, className); } return null; } function findItem(items, refer) { var rst = null; var value = refer instanceof Group ? refer.get('value') : refer; Util.each(items, function (item) { if (item.value === value) { rst = item; return false; } }); return rst; } function findShapeByName(group, name) { return group.findBy(function (node) { return node.name === name; }); } var Category = function (_Base) { _inherits(Category, _Base); function Category() { _classCallCheck(this, Category); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Category.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * type标识 * @type {String} */ type: 'category-legend', /** * 子项集合 * @type {Array} */ items: null, /** * TODO:rename * 图例项水平方向的间距 * @type {Number} */ itemGap: 5, /** * TODO:rename * 图例标题距离图例项的距离 * @type {Number} */ titleGap: 15, /** * TODO:rename * 图例项垂直方向的间距 * @type {Number} */ itemMarginBottom: 8, /** * 图例项图组 * @type {Group} */ itemsGroup: null, /** * 布局方式: horizontal,vertical * @type {String} */ layout: 'horizontal', /** * 是否允许全部取消,默认 false,即必须保留一个被选中 * @type {Boolean} */ allowAllCanceled: false, /** * 边框内边距 * @type {Array} */ backPadding: [0, 0, 0, 0], /** * 是否能被点击 * @type {Boolean} */ checkable: true, /** * 图例项取消选中的颜色 * @type {String} */ unCheckColor: '#ccc', /** * 图例背景层属性设置 * @type {Obejct} */ background: { fill: '#fff', fillOpacity: 0 }, /** * 图例项的宽度,当图例有很多图例项,并且用户想要这些图例项在同一平面内垂直对齐,此时这个属性可帮用户实现此效果 * @type {Number} */ itemWidth: null, textStyle: { fill: '#333', fontSize: 12, textAlign: 'start', textBaseline: 'middle', fontFamily: Global.fontFamily }, /** * marker 和文字的距离 * @type {Number} */ _wordSpaceing: 8, /** * 是否使用 html 进行渲染,默认为 false * @type {Boolean} */ useHtml: false, /** * useHtml 为 true 时生效,用于自动定位 * @type {[type]} */ autoPosition: true, container: null, /** * 使用html时的外层模板 * @type {String} */ containerTpl: '
' + '

' + '' + '
', /** * 默认的图例项 html 模板 * @type {String} */ _defaultItemTpl: '
  • ' + '' + '{value}
  • ', /** * 用户设置的图例项 html 模板 * @type {String|Function} */ itemTpl: null, /** * 图例项是否可点击,默认为 true * @type {Boolean} */ clickable: true, /** * TODO: rename * 图例项的选择模式,多选和单选 multiple、single * @type {String} */ selectedMode: 'multiple', /** * 图例项的顺序是否要逆序,默认为 false * @type {Boolean} */ reversed: false, /** * 是否自动换行 * @type {Boolean} */ autoWrap: true }); }; Category.prototype._beforeRenderUI = function _beforeRenderUI() { _Base.prototype._beforeRenderUI.call(this); }; Category.prototype._renderUI = function _renderUI() { if (!this.get('useHtml')) { _Base.prototype._renderUI.call(this); this._renderItems(); this.get('autoWrap') && this._adjustItems(); // 默认自动换行 this._renderBack(); } else { // 使用 html 渲染图例 this._renderHTML(); } }; Category.prototype._bindUI = function _bindUI() { if (this.get('hoverable')) { this.on('mousemove', Util.wrapBehavior(this, '_onMousemove')); this.on('mouseleave', Util.wrapBehavior(this, '_onMouseleave')); } if (this.get('clickable')) { this.on('click', Util.wrapBehavior(this, '_onClick')); } }; Category.prototype._getLegendItem = function _getLegendItem(target) { var item = target.get('parent'); if (item && item.name === 'legendGroup') { return item; } return null; }; Category.prototype._onMousemove = function _onMousemove(ev) { var item = this._getLegendItem(ev.currentTarget); if (item && item.get('checked')) { var items = this.get('items'); var itemhover = new Event('itemhover', ev, true, true); itemhover.item = findItem(items, item); itemhover.checked = item.get('checked'); this.emit('itemhover', itemhover); } else if (!item) { this.emit('itemunhover', ev); } return; }; Category.prototype._onMouseleave = function _onMouseleave(ev) { this.emit('itemunhover', ev); return; }; Category.prototype._onClick = function _onClick(ev) { var clickedItem = this._getLegendItem(ev.currentTarget); var items = this.get('items'); if (clickedItem && !clickedItem.get('destroyed')) { var checked = clickedItem.get('checked'); if (!this.get('allowAllCanceled') && checked && this.getCheckedCount() === 1) { return; } var mode = this.get('selectedMode'); var item = findItem(items, clickedItem); var itemclick = new Event('itemclick', ev, true, true); itemclick.item = item; itemclick.currentTarget = clickedItem; itemclick.checked = mode === 'single' ? true : !checked; var unCheckColor = this.get('unCheckColor'); var checkColor = this.get('textStyle').fill; var markerItem = void 0; var textItem = void 0; var legendItem = void 0; if (mode === 'single') { var itemsGroup = this.get('itemsGroup'); var children = itemsGroup.get('children'); Util.each(children, function (child) { markerItem = findShapeByName(child, 'legend-marker'); textItem = findShapeByName(child, 'legend-text'); legendItem = findShapeByName(child, 'legend-item'); if (child !== clickedItem) { if (markerItem.attr('fill')) { markerItem.attr('fill', unCheckColor); } if (markerItem.attr('stroke')) { markerItem.attr('stroke', unCheckColor); } textItem.attr('fill', unCheckColor); markerItem.setSilent('checked', false); textItem.setSilent('checked', false); legendItem.setSilent('checked', false); child.setSilent('checked', false); } else { if (markerItem.attr('fill')) { markerItem.attr('fill', item.marker.fill); } if (markerItem.attr('stroke')) { markerItem.attr('stroke', item.marker.stroke); } textItem.attr('fill', checkColor); markerItem.setSilent('checked', true); textItem.setSilent('checked', true); legendItem.setSilent('checked', true); child.setSilent('checked', true); } }); } else { markerItem = findShapeByName(clickedItem, 'legend-marker'); textItem = findShapeByName(clickedItem, 'legend-text'); legendItem = findShapeByName(clickedItem, 'legend-item'); if (markerItem.attr('fill')) { markerItem.attr('fill', checked ? unCheckColor : item.marker.fill); } if (markerItem.attr('stroke')) { markerItem.attr('stroke', checked ? unCheckColor : item.marker.stroke); } textItem.attr('fill', checked ? unCheckColor : checkColor); clickedItem.setSilent('checked', !checked); markerItem.setSilent('checked', !checked); textItem.setSilent('checked', !checked); legendItem.setSilent('checked', !checked); } this.emit('itemclick', itemclick); } return; }; Category.prototype._renderHTML = function _renderHTML() { var _this2 = this; var self = this; var canvas = self.get('canvas'); var outterNode = canvas.get('el').parentNode; var title = this.get('title'); var containerTpl = self.get('containerTpl'); var legendWrapper = DomUtil.createDom(containerTpl); var titleDom = findNodeByClass(legendWrapper, TITLE_CLASS); var itemListDom = findNodeByClass(legendWrapper, LIST_CLASS); var unCheckedColor = self.get('unCheckColor'); var mode = self.get('selectedMode'); DomUtil.modifyCSS(itemListDom, Util.mix({}, LEGEND_STYLE[LIST_CLASS], self.get(LIST_CLASS))); if (titleDom) { if (title && title.text) { titleDom.innerHTML = title.text; DomUtil.modifyCSS(titleDom, Util.mix({}, LEGEND_STYLE[TITLE_CLASS], self.get(TITLE_CLASS))); } else { legendWrapper.removeChild(titleDom); } } // 开始渲染图例项 var items = self.get('items'); var itemTpl = self.get('_defaultItemTpl'); var userItemTpl = self.get('itemTpl'); if (userItemTpl && userItemTpl !== itemTpl) { itemTpl = userItemTpl; } if (self.get('reversed')) { items.reverse(); } var position = self.get('position'); var itemStyle = Util.mix({}, LEGEND_STYLE[ITEM_CLASS], { display: position === 'right' || position === 'left' ? 'block' : 'inline-block' }, self.get(ITEM_CLASS)); var markerStyle = Util.mix({}, LEGEND_STYLE[MARKER_CLASS], self.get(MARKER_CLASS)); Util.each(items, function (item, index) { var checked = item.checked; var value = self._formatItemValue(item.value); var markerColor = item.marker.fill || item.marker.stroke; var color = checked ? markerColor : unCheckedColor; var domStr = void 0; if (Util.isFunction(itemTpl)) { domStr = itemTpl(value, color, checked, index); } else { domStr = itemTpl; } var itemDiv = Util.substitute(domStr, { index: index, checked: checked ? 'checked' : 'unChecked', value: value, color: color, originColor: markerColor, originValue: item.value }); var itemDom = DomUtil.createDom(itemDiv); var markerDom = findNodeByClass(itemDom, MARKER_CLASS); DomUtil.modifyCSS(itemDom, itemStyle); markerDom && DomUtil.modifyCSS(markerDom, markerStyle); if (!checked) { itemDom.style.color = unCheckedColor; if (markerDom) { markerDom.style.backgroundColor = unCheckedColor; } } itemListDom.appendChild(itemDom); }); if (self.get('clickable')) { var childNodes = itemListDom.childNodes; // 注册事件 legendWrapper.onclick = function (ev) { var target = ev.target; var targetClass = target.className; targetClass = targetClass.split(' '); if (targetClass.indexOf(CONTAINER_CLASS) > -1 || targetClass.indexOf(LIST_CLASS) > -1) { return; } var parentDom = getParentNode(target, ITEM_CLASS); var textDom = findNodeByClass(parentDom, TEXT_CLASS); var markerDom = findNodeByClass(parentDom, MARKER_CLASS); var clickedItem = findItem(items, parentDom.getAttribute('data-value')); if (!clickedItem) { return; } // update checked status clickedItem.checked = mode === 'single' ? true : !clickedItem.checked; var domClass = parentDom.className; var originColor = parentDom.getAttribute('data-color'); if (mode === 'single') { // 单选模式 // 其他图例项全部置灰 Util.each(childNodes, function (child) { if (child !== parentDom) { var childMarkerDom = findNodeByClass(child, MARKER_CLASS); childMarkerDom.style.backgroundColor = unCheckedColor; child.className = Util.replace(child.className, 'checked', 'unChecked'); child.style.color = unCheckedColor; var childItem = findItem(items, child.getAttribute('data-value')); childItem.checked = false; } else { if (textDom) { textDom.style.color = self.get('textStyle').fill; } if (markerDom) { markerDom.style.backgroundColor = originColor; } parentDom.className = Util.replace(domClass, 'unChecked', 'checked'); } }); } else { // 混合模式 var clickedItemChecked = domClass.includes('checked'); var count = 0; Util.each(childNodes, function (child) { if (child.className.includes('checked')) { count++; } }); if (!_this2.get('allowAllCanceled') && clickedItemChecked && count === 1) { return; } if (clickedItemChecked) { if (markerDom) { markerDom.style.backgroundColor = unCheckedColor; } parentDom.className = Util.replace(domClass, 'checked', 'unChecked'); parentDom.style.color = unCheckedColor; } else { if (markerDom) { markerDom.style.backgroundColor = originColor; } parentDom.className = Util.replace(domClass, 'unChecked', 'checked'); parentDom.style.color = self.get('textStyle').fill; } } self.emit('itemclick', { item: clickedItem, currentTarget: parentDom, checked: mode === 'single' ? true : clickedItem.checked }); }; } if (self.get('hoverable')) { legendWrapper.onmousemove = function (ev) { var target = ev.target; var targetClass = target.className; targetClass = targetClass.split(' '); if (targetClass.indexOf(CONTAINER_CLASS) > -1 || targetClass.indexOf(LIST_CLASS) > -1) { return; } var parentDom = getParentNode(target, ITEM_CLASS); var domClass = parentDom.className; var hoveredItem = findItem(items, parentDom.getAttribute('data-value')); if (hoveredItem && domClass.includes('checked')) { self.emit('itemhover', { item: hoveredItem, currentTarget: parentDom, checked: hoveredItem.checked }); } else if (!hoveredItem) { self.emit('itemunhover', ev); } }; legendWrapper.onmouseout = function (ev) { self.emit('itemunhover', ev); }; } var container = self.get('container'); if (/^\#/.test(container)) { // 如果传入 dom 节点的 id var id = container.replace('#', ''); container = document.getElementById(id); // container.style.position = 'relative'; container.appendChild(legendWrapper); } else { var _position = self.get('position'); var _canvas = self.get('canvas'); var rangeStyle = {}; if (_position === 'left' || _position === 'right') { rangeStyle = { maxHeight: (self.get('maxLength') || _canvas.get('height')) + 'px' }; } else { rangeStyle = { maxWidth: (self.get('maxLength') || _canvas.get('width')) + 'px' }; } DomUtil.modifyCSS(legendWrapper, Util.mix({}, LEGEND_STYLE[CONTAINER_CLASS], rangeStyle, self.get(CONTAINER_CLASS))); outterNode.appendChild(legendWrapper); } self.set('legendWrapper', legendWrapper); }; Category.prototype._renderItems = function _renderItems() { var self = this; var items = self.get('items'); if (self.get('reversed')) { items.reverse(); } Util.each(items, function (item, index) { self._addItem(item, index); }); }; Category.prototype._renderBack = function _renderBack() { var padding = this.get('backPadding'); var backAttrs = this.get('background'); this.renderBack(padding, backAttrs); }; Category.prototype._formatItemValue = function _formatItemValue(value) { var formatter = this.get('itemFormatter'); if (formatter) { value = formatter.call(this, value); } return value; }; Category.prototype._getNextX = function _getNextX() { var layout = this.get('layout'); var itemGap = this.get('itemGap'); var itemsGroup = this.get('itemsGroup'); var itemWidth = this.get('itemWidth'); var children = itemsGroup.get('children'); var nextX = 0; if (layout === 'horizontal') { // 水平布局 Util.each(children, function (v) { nextX += (itemWidth ? itemWidth : v.getBBox().width) + itemGap; }); } return nextX; }; Category.prototype._getNextY = function _getNextY() { var itemMarginBottom = this.get('itemMarginBottom'); var titleGap = this.get('titleShape') ? this.get('titleGap') : 0; var layout = this.get('layout'); var itemsGroup = this.get('itemsGroup'); var titleShape = this.get('titleShape'); var children = itemsGroup.get('children'); var nextY = titleGap; if (titleShape) { nextY += titleShape.getBBox().height; } if (layout === 'vertical') { // 竖直布局 Util.each(children, function (v) { nextY += v.getBBox().height + itemMarginBottom; }); } return nextY; }; Category.prototype._addItem = function _addItem(item) { var itemsGroup = this.get('itemsGroup'); var x = this._getNextX(); var y = this._getNextY(); var unCheckColor = this.get('unCheckColor'); var itemGroup = itemsGroup.addGroup({ x: x, y: y, value: item.value, checked: item.checked }); var textStyle = this.get('textStyle'); var wordSpace = this.get('_wordSpaceing'); var startX = 0; if (item.marker) { // 如果有marker添加marker var markerAttrs = Util.mix({}, item.marker, { x: item.marker.radius + x, y: y }); if (!item.checked) { if (markerAttrs.fill) { markerAttrs.fill = unCheckColor; } if (markerAttrs.stroke) { markerAttrs.stroke = unCheckColor; } } var markerShape = itemGroup.addShape('marker', { type: 'marker', attrs: markerAttrs }); markerShape.attr('cursor', 'pointer'); markerShape.name = 'legend-marker'; startX += markerShape.getBBox().width + wordSpace; } var textAttrs = Util.mix({}, textStyle, { x: startX + x, y: y, text: this._formatItemValue(item.value) }); if (!item.checked) { Util.mix(textAttrs, { fill: unCheckColor }); } var textShape = itemGroup.addShape('text', { attrs: textAttrs }); textShape.attr('cursor', 'pointer'); textShape.name = 'legend-text'; this.get('appendInfo') && textShape.setSilent('appendInfo', this.get('appendInfo')); // 添加一个包围矩形,用于事件支持 var bbox = itemGroup.getBBox(); var itemWidth = this.get('itemWidth'); var wrapperShape = itemGroup.addShape('rect', { attrs: { x: x, y: y - bbox.height / 2, fill: '#fff', fillOpacity: 0, width: itemWidth || bbox.width, height: bbox.height } }); wrapperShape.attr('cursor', 'pointer'); wrapperShape.setSilent('origin', item); // 保存图例项相关的数据,便于事件操作 wrapperShape.name = 'legend-item'; this.get('appendInfo') && wrapperShape.setSilent('appendInfo', this.get('appendInfo')); itemGroup.name = 'legendGroup'; return itemGroup; }; Category.prototype._adjustHorizontal = function _adjustHorizontal() { var itemsGroup = this.get('itemsGroup'); var children = itemsGroup.get('children'); var maxLength = this.get('maxLength'); var itemGap = this.get('itemGap'); var itemMarginBottom = this.get('itemMarginBottom'); var titleGap = this.get('titleShape') ? this.get('titleGap') : 0; var row = 0; var rowLength = 0; var width = void 0; var height = void 0; var box = void 0; var itemWidth = this.get('itemWidth'); if (itemsGroup.getBBox().width > maxLength) { Util.each(children, function (child) { box = child.getBBox(); width = itemWidth || box.width; height = box.height + itemMarginBottom; if (maxLength - rowLength < width) { row++; rowLength = 0; } child.move(rowLength, row * height + titleGap); rowLength += width + itemGap; }); } return; }; Category.prototype._adjustVertical = function _adjustVertical() { var itemsGroup = this.get('itemsGroup'); var titleShape = this.get('titleShape'); var children = itemsGroup.get('children'); var maxLength = this.get('maxLength'); // 垂直布局,则 maxLength 代表容器的高度 var itemGap = this.get('itemGap'); var itemMarginBottom = this.get('itemMarginBottom'); var titleGap = this.get('titleGap'); var titleHeight = titleShape ? titleShape.getBBox().height + titleGap : 0; var itemWidth = this.get('itemWidth'); var colLength = titleHeight; var width = void 0; var height = void 0; var box = void 0; var maxItemWidth = 0; var totalLength = 0; if (itemsGroup.getBBox().height > maxLength) { Util.each(children, function (v) { box = v.getBBox(); width = box.width; height = box.height; if (itemWidth) { maxItemWidth = itemWidth + itemGap; } else if (width > maxItemWidth) { maxItemWidth = width + itemGap; } if (maxLength - colLength < height) { colLength = titleHeight; totalLength += maxItemWidth; v.move(totalLength, titleHeight); } else { v.move(totalLength, colLength); } colLength += height + itemMarginBottom; }); } return; }; Category.prototype._adjustItems = function _adjustItems() { var layout = this.get('layout'); if (layout === 'horizontal') { this._adjustHorizontal(); } else { this._adjustVertical(); } }; Category.prototype.getWidth = function getWidth() { if (this.get('useHtml')) { return DomUtil.getOuterWidth(this.get('legendWrapper')); } return _Base.prototype.getWidth.call(this); }; Category.prototype.getHeight = function getHeight() { if (this.get('useHtml')) { return DomUtil.getOuterHeight(this.get('legendWrapper')); } return _Base.prototype.getHeight.call(this); }; Category.prototype.move = function move(x, y) { if (this.get('useHtml') && !/^\#/.test(this.get('container'))) { DomUtil.modifyCSS(this.get('legendWrapper'), { left: x + 'px', top: y + 'px' }); } else { _Base.prototype.move.call(this, x, y); } }; Category.prototype.remove = function remove() { if (this.get('useHtml')) { // 移除元素 var legendWrapper = this.get('legendWrapper'); if (legendWrapper && legendWrapper.parentNode) { legendWrapper.parentNode.removeChild(legendWrapper); } } _Base.prototype.remove.call(this); // must be called }; return Category; }(Base); module.exports = Category; /***/ }), /* 350 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The class of the gradient color legend * @author sima.zhang */ var Util = __webpack_require__(0); var Continuous = __webpack_require__(123); var ColorUtil = __webpack_require__(64); // TODO: 这个 Util 是否可换个位置 var Color = function (_Continuous) { _inherits(Color, _Continuous); function Color() { _classCallCheck(this, Color); return _possibleConstructorReturn(this, _Continuous.apply(this, arguments)); } Color.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Continuous.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * 类型 * @type {String} */ type: 'color-legend', /** * 布局方式 * horizontal 水平 * vertical 垂直 * @type {String} */ layout: 'vertical', labelOffset: 15, lineStyle: { lineWidth: 1, stroke: '#fff' } }); }; Color.prototype._renderSliderShape = function _renderSliderShape() { var slider = this.get('slider'); var backgroundElement = slider.get('backgroundElement'); var width = this.get('width'); var height = this.get('height'); var layout = this.get('layout'); var items = this.get('items'); var fill = ''; var rgbColor = void 0; if (layout === 'vertical') { fill += 'l (90) '; Util.each(items, function (v) { rgbColor = ColorUtil.toRGB(v.attrValue); fill += 1 - v.scaleValue + ':' + rgbColor + ' '; }); } else { fill += 'l (0) '; Util.each(items, function (v) { rgbColor = ColorUtil.toRGB(v.attrValue); fill += v.scaleValue + ':' + rgbColor + ' '; }); } return this._addBackground(backgroundElement, 'Rect', { x: 0, y: 0, width: width, height: height, fill: fill, strokeOpacity: 0 }); }; Color.prototype._renderBackground = function _renderBackground() { var self = this; var titleShape = this.get('titleShape'); var titleGap = this.get('titleGap'); titleGap = titleShape ? titleShape.getBBox().height + titleGap : titleGap; var width = this.get('width'); var height = this.get('height'); var layout = this.get('layout'); var items = this.get('items'); var fill = ''; var rgbColor = void 0; var path = []; var bgGroup = this.addGroup(); if (layout === 'vertical') { fill += 'l (90) '; Util.each(items, function (v, index) { if (index !== 0 && index !== items.length - 1) { path.push(['M', 0, height - v.scaleValue * height]); path.push(['L', width, height - v.scaleValue * height]); } rgbColor = ColorUtil.toRGB(v.attrValue); fill += 1 - v.scaleValue + ':' + rgbColor + ' '; bgGroup.addShape('text', { attrs: Util.mix({}, { x: width + self.get('labelOffset') / 2, y: height - v.scaleValue * height, text: self._formatItemValue(v.value) + '' // 以字符串格式展示 }, self.get('textStyle'), { textAlign: 'start' }) }); }); } else { fill += 'l (0) '; Util.each(items, function (v, index) { if (index !== 0 && index !== items.length - 1) { path.push(['M', v.scaleValue * width, 0]); path.push(['L', v.scaleValue * width, height]); } rgbColor = ColorUtil.toRGB(v.attrValue); fill += v.scaleValue + ':' + rgbColor + ' '; bgGroup.addShape('text', { attrs: Util.mix({}, { x: v.scaleValue * width, y: height + self.get('labelOffset'), text: self._formatItemValue(v.value) + '' // 以字符串格式展示 }, self.get('textStyle')) }); }); } bgGroup.addShape('rect', { attrs: { x: 0, y: 0, width: width, height: height, fill: fill, strokeOpacity: 0 } }); bgGroup.addShape('path', { attrs: Util.mix({ path: path }, this.get('lineStyle')) }); bgGroup.move(0, titleGap); }; return Color; }(Continuous); module.exports = Color; /***/ }), /* 351 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The class of slider * @author sima.zhang */ var Util = __webpack_require__(0); var _require = __webpack_require__(2), Group = _require.Group, DomUtil = _require.DomUtil; var Slider = function (_Group) { _inherits(Slider, _Group); function Slider() { _classCallCheck(this, Slider); return _possibleConstructorReturn(this, _Group.apply(this, arguments)); } Slider.prototype.getDefaultCfg = function getDefaultCfg() { return { /** * 范围 * @type {Array} */ range: null, /** * 中滑块属性 * @type {ATTRS} */ middleAttr: null, /** * 背景 * @type {G-Element} */ backgroundElement: null, /** * 下滑块 * @type {G-Element} */ minHandleElement: null, /** * 上滑块 * @type {G-Element} */ maxHandleElement: null, /** * 中块 * @type {G-Element} */ middleHandleElement: null, /** * 当前的激活的元素 * @type {G-Element} */ currentTarget: null, /** * 布局方式: horizontal,vertical * @type {String} */ layout: 'vertical', /** * 宽 * @type {Number} */ width: null, /** * 高 * @type {Number} */ height: null, /** * 当前的PageX * @type {Number} */ pageX: null, /** * 当前的PageY * @type {Number} */ pageY: null }; }; Slider.prototype._beforeRenderUI = function _beforeRenderUI() { var layout = this.get('layout'); var backgroundElement = this.get('backgroundElement'); var minHandleElement = this.get('minHandleElement'); var maxHandleElement = this.get('maxHandleElement'); var middleHandleElement = this.addShape('rect', { attrs: this.get('middleAttr') }); var trigerCursor = layout === 'vertical' ? 'ns-resize' : 'ew-resize'; this.add([backgroundElement, minHandleElement, maxHandleElement]); this.set('middleHandleElement', middleHandleElement); backgroundElement.set('zIndex', 0); middleHandleElement.set('zIndex', 1); minHandleElement.set('zIndex', 2); maxHandleElement.set('zIndex', 2); middleHandleElement.attr('cursor', 'move'); minHandleElement.attr('cursor', trigerCursor); maxHandleElement.attr('cursor', trigerCursor); this.sort(); }; Slider.prototype._renderUI = function _renderUI() { if (this.get('layout') === 'horizontal') { this._renderHorizontal(); } else { this._renderVertical(); } }; Slider.prototype._transform = function _transform(layout) { var range = this.get('range'); var minRatio = range[0] / 100; var maxRatio = range[1] / 100; var width = this.get('width'); var height = this.get('height'); var minHandleElement = this.get('minHandleElement'); var maxHandleElement = this.get('maxHandleElement'); var middleHandleElement = this.get('middleHandleElement'); minHandleElement.initTransform(); maxHandleElement.initTransform(); if (layout === 'horizontal') { middleHandleElement.attr({ x: width * minRatio, y: 0, width: (maxRatio - minRatio) * width, height: height }); minHandleElement.translate(minRatio * width, height); maxHandleElement.translate(maxRatio * width, height); } else { middleHandleElement.attr({ x: 0, y: height * (1 - maxRatio), width: width, height: (maxRatio - minRatio) * height }); minHandleElement.translate(width / 2, (1 - minRatio) * height); maxHandleElement.translate(width / 2, (1 - maxRatio) * height); } }; Slider.prototype._renderHorizontal = function _renderHorizontal() { this._transform('horizontal'); }; Slider.prototype._renderVertical = function _renderVertical() { this._transform('vertical'); }; Slider.prototype._bindUI = function _bindUI() { this.on('mousedown', Util.wrapBehavior(this, '_onMouseDown')); }; Slider.prototype._isElement = function _isElement(target, name) { // 判断是否是该元素 var element = this.get(name); if (target === element) { return true; } if (element.isGroup) { var elementChildren = element.get('children'); return elementChildren.indexOf(target) > -1; } return false; }; Slider.prototype._getRange = function _getRange(diff, range) { var rst = diff + range; rst = rst > 100 ? 100 : rst; rst = rst < 0 ? 0 : rst; return rst; }; Slider.prototype._updateStatus = function _updateStatus(dim, ev) { var totalLength = dim === 'x' ? this.get('width') : this.get('height'); dim = Util.upperFirst(dim); var range = this.get('range'); var page = this.get('page' + dim); var currentTarget = this.get('currentTarget'); var rangeStash = this.get('rangeStash'); var layout = this.get('layout'); var sign = layout === 'vertical' ? -1 : 1; var currentPage = ev['page' + dim]; var diffPage = currentPage - page; var diffRange = diffPage / totalLength * 100 * sign; var diffStashRange = void 0; if (range[1] <= range[0]) { if (this._isElement(currentTarget, 'minHandleElement') || this._isElement(currentTarget, 'maxHandleElement')) { range[0] = this._getRange(diffRange, range[0]); range[1] = this._getRange(diffRange, range[0]); } } else { if (this._isElement(currentTarget, 'minHandleElement')) { range[0] = this._getRange(diffRange, range[0]); } if (this._isElement(currentTarget, 'maxHandleElement')) { range[1] = this._getRange(diffRange, range[1]); } } if (this._isElement(currentTarget, 'middleHandleElement')) { diffStashRange = rangeStash[1] - rangeStash[0]; range[0] = this._getRange(diffRange, range[0]); range[1] = range[0] + diffStashRange; if (range[1] > 100) { range[1] = 100; range[0] = range[1] - diffStashRange; } } this.emit('sliderchange', { range: range }); this.set('page' + dim, currentPage); this._renderUI(); this.get('canvas').draw(); // need delete return; }; Slider.prototype._onMouseDown = function _onMouseDown(ev) { var currentTarget = ev.currentTarget; var originEvent = ev.event; var range = this.get('range'); originEvent.stopPropagation(); originEvent.preventDefault(); this.set('pageX', originEvent.pageX); this.set('pageY', originEvent.pageY); this.set('currentTarget', currentTarget); this.set('rangeStash', [range[0], range[1]]); this._bindCanvasEvents(); }; Slider.prototype._bindCanvasEvents = function _bindCanvasEvents() { var containerDOM = this.get('canvas').get('containerDOM'); this.onMouseMoveListener = DomUtil.addEventListener(containerDOM, 'mousemove', Util.wrapBehavior(this, '_onCanvasMouseMove')); this.onMouseUpListener = DomUtil.addEventListener(containerDOM, 'mouseup', Util.wrapBehavior(this, '_onCanvasMouseUp')); }; Slider.prototype._onCanvasMouseMove = function _onCanvasMouseMove(ev) { var layout = this.get('layout'); if (layout === 'horizontal') { this._updateStatus('x', ev); } else { this._updateStatus('y', ev); } }; Slider.prototype._onCanvasMouseUp = function _onCanvasMouseUp() { this._removeDocumentEvents(); }; Slider.prototype._removeDocumentEvents = function _removeDocumentEvents() { this.onMouseMoveListener.remove(); this.onMouseUpListener.remove(); }; return Slider; }(Group); module.exports = Slider; /***/ }), /* 352 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The class of the size legend * @author sima.zhang */ var Util = __webpack_require__(0); var Global = __webpack_require__(1); var Continuous = __webpack_require__(123); var CIRCLE_GAP = 8; var Size = function (_Continuous) { _inherits(Size, _Continuous); function Size() { _classCallCheck(this, Size); return _possibleConstructorReturn(this, _Continuous.apply(this, arguments)); } Size.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Continuous.prototype.getDefaultCfg.call(this); return Util.mix({}, cfg, { /** * 类型 * @type {String} */ type: 'size-legend', width: 100, height: 200, _circleStyle: { stroke: '#4E7CCC', fill: '#fff', fillOpacity: 0 }, textStyle: { fill: '#333', textAlign: 'start', textBaseline: 'middle', fontFamily: Global.fontFamily } }); }; Size.prototype._renderSliderShape = function _renderSliderShape() { var slider = this.get('slider'); var backgroundElement = slider.get('backgroundElement'); var width = this.get('width'); var height = this.get('height'); var inRange = this.get('inRange'); var layout = this.get('layout'); var points = layout === 'vertical' ? [[0, 0], [width, 0], [width, height]] : [[0, height], [width, 0], [width, height]]; return this._addBackground(backgroundElement, 'Polygon', Util.mix({ points: points }, inRange)); }; Size.prototype._addCircle = function _addCircle(x, y, r, text, maxWidth) { var group = this.addGroup(); var circleStyle = this.get('_circleStyle'); var textStyle = this.get('textStyle'); var titleShape = this.get('titleShape'); var titleGap = this.get('titleGap'); if (titleShape) { titleGap += titleShape.getBBox().height; } group.addShape('circle', { attrs: Util.mix({ x: x, y: y + titleGap, r: r === 0 ? 1 : r }, circleStyle) }); group.addShape('text', { attrs: Util.mix({ x: maxWidth + 5, y: y + titleGap, text: text === 0 ? '0' : text }, textStyle) }); }; Size.prototype._renderBackground = function _renderBackground() { var self = this; var minRadius = this.get('firstItem').attrValue * 1; var maxRadius = this.get('lastItem').attrValue * 1; var medianRadius = (minRadius + maxRadius) / 2; self._addCircle(maxRadius, maxRadius, maxRadius, medianRadius, 2 * maxRadius); self._addCircle(maxRadius, maxRadius * 2 + CIRCLE_GAP + medianRadius, medianRadius, (minRadius + medianRadius) / 2, 2 * maxRadius); self._addCircle(maxRadius, (maxRadius + CIRCLE_GAP + medianRadius) * 2 + minRadius, minRadius, minRadius, 2 * maxRadius); }; return Size; }(Continuous); module.exports = Size; /***/ }), /* 353 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The class of canvas plot * @author sima.zhang */ var Util = __webpack_require__(0); var _require = __webpack_require__(2), Group = _require.Group; var PlotBack = function (_Group) { _inherits(PlotBack, _Group); function PlotBack() { _classCallCheck(this, PlotBack); return _possibleConstructorReturn(this, _Group.apply(this, arguments)); } PlotBack.prototype.getDefaultCfg = function getDefaultCfg() { return { /** * 类型 * @type {String} */ type: 'plotBack', /** * 画布边距 * @type {Number | Array | Object | "auto"} */ padding: null, /** * 大背景 * @type {Object} */ background: null, /** * 绘图区域范围 * @type {Object} */ plotRange: null, /** * 绘图区域背景 * @type {Object} */ plotBackground: null }; }; PlotBack.prototype._beforeRenderUI = function _beforeRenderUI() { this._calculateRange(); }; PlotBack.prototype._renderUI = function _renderUI() { this._renderBackground(); this._renderPlotBackground(); }; PlotBack.prototype._renderBackground = function _renderBackground() { var self = this; var background = self.get('background'); if (background) { var canvas = this.get('canvas'); var width = self.get('width') || canvas.get('width'); var height = self.get('height') || canvas.get('height'); var cfg = { x: 0, y: 0, width: width, height: height }; var rect = self.get('backgroundShape'); if (!rect) { rect = this.addShape('rect', { attrs: Util.mix(cfg, background) }); this.set('backgroundShape', rect); } else { rect.attr(cfg); } } else { return; } }; PlotBack.prototype._renderPlotBackground = function _renderPlotBackground() { var self = this; var plotBackground = self.get('plotBackground'); if (plotBackground) { var plotRange = self.get('plotRange'); var width = plotRange.br.x - plotRange.bl.x; var height = plotRange.br.y - plotRange.tr.y; var tl = plotRange.tl; var cfg = { x: tl.x, y: tl.y, width: width, height: height }; var plotBackShape = self.get('plotBackShape'); if (!plotBackShape) { if (plotBackground.image) { cfg.img = plotBackground.image; plotBackShape = self.addShape('image', { attrs: cfg }); } else { // 矩形 Util.mix(cfg, plotBackground); plotBackShape = self.addShape('rect', { attrs: cfg }); } self.set('plotBackShape', plotBackShape); } else { plotBackShape.attr(cfg); } } else { return; } }; PlotBack.prototype._convert = function _convert(val, isHorizontal) { if (Util.isString(val) && val.indexOf('%') !== -1) { var canvas = this.get('canvas'); var width = this.get('width') || canvas.get('width'); var height = this.get('height') || canvas.get('height'); val = parseInt(val, 10) / 100; val = isHorizontal ? val * width : val * height; } return val; }; PlotBack.prototype._calculateRange = function _calculateRange() { var self = this; var plotRange = self.get('plotRange'); if (Util.isNil(plotRange)) { plotRange = {}; } var padding = self.get('padding'); var canvas = this.get('canvas'); var width = self.get('width') || canvas.get('width'); var height = self.get('height') || canvas.get('height'); var allPadding = Util.toAllPadding(padding); var top = self._convert(allPadding[0], false); var right = self._convert(allPadding[1], true); var bottom = self._convert(allPadding[2], false); var left = self._convert(allPadding[3], true); var minX = Math.min(left, width - right); var maxX = Math.max(left, width - right); var minY = Math.min(height - bottom, top); var maxY = Math.max(height - bottom, top); plotRange.tl = { x: minX, y: minY }; // top-left plotRange.tr = { x: maxX, y: minY }; // top-right plotRange.bl = { x: minX, y: maxY }; // bottom-left plotRange.br = { x: maxX, y: maxY }; // bottom-right plotRange.cc = { x: (maxX + minX) / 2, y: (maxY + minY) / 2 }; this.set('plotRange', plotRange); }; PlotBack.prototype.repaint = function repaint() { this._calculateRange(); this._renderBackground(); this._renderPlotBackground(); return this; }; return PlotBack; }(Group); module.exports = PlotBack; /***/ }), /* 354 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview The class of tooltip * @author sima.zhang */ var Util = __webpack_require__(0); var Base = __webpack_require__(63); var Global = __webpack_require__(1); var _require = __webpack_require__(2), DomUtil = _require.DomUtil; var CONTAINER_CLASS = 'g2-tooltip'; var TITLE_CLASS = 'g2-tooltip-title'; var LIST_CLASS = 'g2-tooltip-list'; var MARKER_CLASS = 'g2-tooltip-marker'; var LIST_ITEM_CLASS = 'g2-tooltip-list-item'; function find(dom, cls) { return dom.getElementsByClassName(cls)[0]; } function refixTooltipPosition(x, y, el, viewWidth, viewHeight) { var width = el.clientWidth; var height = el.clientHeight; var gap = 20; if (x + width + gap > viewWidth) { x -= width + gap; x = x < 0 ? 0 : x; } else { x += gap; } if (y + height + gap > viewHeight) { y -= height + gap; y = x < 0 ? 0 : y; } else { y += gap; } return [x, y]; } function calcTooltipPosition(x, y, position, dom, target) { var domWidth = dom.clientWidth; var domHeight = dom.clientHeight; var rectWidth = 0; var rectHeight = 0; var gap = 20; if (target) { var rect = target.getBBox(); rectWidth = rect.width; rectHeight = rect.height; x = rect.x; y = rect.y; gap = 5; } switch (position) { case 'inside': x = x + rectWidth / 2 - domWidth / 2; y = y + rectHeight / 2 - domHeight / 2; break; case 'top': x = x + rectWidth / 2 - domWidth / 2; y = y - domHeight - gap; break; case 'left': x = x - domWidth - gap; y = y + rectHeight / 2 - domHeight / 2; break; case 'right': x = x + rectWidth + gap; y = y + rectHeight / 2 - domHeight / 2; break; case 'bottom': default: x = x + rectWidth / 2 - domWidth / 2; y = y + rectHeight + gap; break; } return [x, y]; } function confineTooltipPosition(x, y, el, plotRange) { var gap = 20; var width = el.clientWidth; var height = el.clientHeight; if (x + width > plotRange.tr.x) { x -= width + 2 * gap; } if (x < plotRange.tl.x) { x = plotRange.tl.x; } if (y + height > plotRange.bl.y) { y -= height + 2 * gap; } if (y < plotRange.tl.y) { y = plotRange.tl.y; } return [x, y]; } var Tooltip = function (_Base) { _inherits(Tooltip, _Base); Tooltip.prototype.getDefaultCfg = function getDefaultCfg() { return { /** * 右下角坐标 * @type {Number} */ x: 0, /** * y 右下角坐标 * @type {Number} */ y: 0, /** * tooltip 记录项 * @type {Array} */ items: null, /** * 是否展示 title * @type {Boolean} */ showTitle: true, /** * tooltip 辅助线配置 * @type {Object} */ crosshairs: null, /** * 视图范围 * @type {Object} */ plotRange: null, /** * x轴上,移动到位置的偏移量 * @type {Number} */ offset: 10, /** * 时间戳 * @type {Number} */ timeStamp: 0, /** * tooltip 容器模板 * @type {String} */ containerTpl: '
    ' + '
    ' + '' + '
    ', /** * tooltip 列表项模板 * @type {String} */ itemTpl: '
  • ' + '' + '{name}: {value}
  • ', /** * 将 tooltip 展示在指定区域内 * @type {Boolean} */ inPlot: true, /** * tooltip 内容跟随鼠标移动 * @type {Boolean} */ follow: true, /** * 是否允许鼠标停留在 tooltip 上,默认不允许 * @type {Boolean} */ enterable: false }; }; Tooltip.prototype._initTooltipWrapper = function _initTooltipWrapper() { var self = this; var containerTpl = self.get('containerTpl'); var outterNode = self.get('canvas').get('el').parentNode; var container = void 0; if (/^\#/.test(containerTpl)) { // 如果传入 dom 节点的 id var id = containerTpl.replace('#', ''); container = document.getElementById(id); } else { container = DomUtil.createDom(containerTpl); DomUtil.modifyCSS(container, self.get(CONTAINER_CLASS)); outterNode.appendChild(container); outterNode.style.position = 'relative'; } self.set('container', container); }; Tooltip.prototype._init = function _init() { var crosshairs = this.get('crosshairs'); var frontPlot = this.get('frontPlot'); var backPlot = this.get('backPlot'); var crosshairsGroup = void 0; if (crosshairs) { if (crosshairs.type === 'rect') { this.set('crosshairs', Util.deepMix({}, Global.tooltipCrosshairsRect, crosshairs)); crosshairsGroup = backPlot.addGroup({ zIndex: 0 }); } else { this.set('crosshairs', Util.deepMix({}, Global.tooltipCrosshairsLine, crosshairs)); crosshairsGroup = frontPlot.addGroup(); } } this.set('crosshairsGroup', crosshairsGroup); this._initTooltipWrapper(); }; function Tooltip(cfg) { _classCallCheck(this, Tooltip); var _this = _possibleConstructorReturn(this, _Base.call(this, cfg)); _this._init(); // 初始化属性 if (_this.get('items')) { _this._renderTooltip(); } _this._renderCrosshairs(); return _this; } Tooltip.prototype._clearDom = function _clearDom() { var container = this.get('container'); var titleDom = find(container, TITLE_CLASS); var listDom = find(container, LIST_CLASS); if (titleDom) { titleDom.innerHTML = ''; } if (listDom) { listDom.innerHTML = ''; } }; Tooltip.prototype._addItem = function _addItem(item, index) { var itemTpl = this.get('itemTpl'); // TODO: 有可能是个回调函数 var itemDiv = Util.substitute(itemTpl, Util.mix({ index: index }, item)); var itemDOM = DomUtil.createDom(itemDiv); DomUtil.modifyCSS(itemDOM, this.get(LIST_ITEM_CLASS)); var markerDom = find(itemDOM, MARKER_CLASS); if (markerDom) { DomUtil.modifyCSS(markerDom, this.get(MARKER_CLASS)); } return itemDOM; }; Tooltip.prototype._renderTooltip = function _renderTooltip() { var self = this; var showTitle = self.get('showTitle'); var titleContent = self.get('titleContent'); var container = self.get('container'); var titleDom = find(container, TITLE_CLASS); var listDom = find(container, LIST_CLASS); var items = self.get('items'); self._clearDom(); if (titleDom && showTitle) { DomUtil.modifyCSS(titleDom, self.get(TITLE_CLASS)); titleDom.innerHTML = titleContent; } if (listDom) { DomUtil.modifyCSS(listDom, self.get(LIST_CLASS)); Util.each(items, function (item, index) { listDom.appendChild(self._addItem(item, index)); }); } }; Tooltip.prototype._clearCrosshairsGroup = function _clearCrosshairsGroup() { var crosshairsGroup = this.get('crosshairsGroup'); this.set('crossLineShapeX', null); this.set('crossLineShapeY', null); this.set('crosshairsRectShape', null); crosshairsGroup.clear(); }; Tooltip.prototype._renderCrosshairs = function _renderCrosshairs() { var crosshairs = this.get('crosshairs'); var canvas = this.get('canvas'); var plotRange = this.get('plotRange'); var isTransposed = this.get('isTransposed'); if (crosshairs) { this._clearCrosshairsGroup(); switch (crosshairs.type) { case 'x': this._renderHorizontalLine(canvas, plotRange); break; case 'y': this._renderVerticalLine(canvas, plotRange); break; case 'cross': this._renderHorizontalLine(canvas, plotRange); this._renderVerticalLine(canvas, plotRange); break; case 'rect': this._renderBackground(canvas, plotRange); break; default: isTransposed ? this._renderHorizontalLine(canvas, plotRange) : this._renderVerticalLine(canvas, plotRange); } } }; Tooltip.prototype._addCrossLineShape = function _addCrossLineShape(attrs, type) { var crosshairsGroup = this.get('crosshairsGroup'); var shape = crosshairsGroup.addShape('line', { attrs: attrs }); shape.hide(); this.set('crossLineShape' + type, shape); return shape; }; Tooltip.prototype._renderVerticalLine = function _renderVerticalLine(canvas, plotRange) { var _get = this.get('crosshairs'), style = _get.style; var attrs = Util.mix({ x1: 0, y1: plotRange ? plotRange.bl.y : canvas.get('height'), x2: 0, y2: plotRange ? plotRange.tl.y : 0 }, style); this._addCrossLineShape(attrs, 'Y'); }; Tooltip.prototype._renderHorizontalLine = function _renderHorizontalLine(canvas, plotRange) { var _get2 = this.get('crosshairs'), style = _get2.style; var attrs = Util.mix({ x1: plotRange ? plotRange.bl.x : canvas.get('width'), y1: 0, x2: plotRange ? plotRange.br.x : 0, y2: 0 }, style); this._addCrossLineShape(attrs, 'X'); }; Tooltip.prototype._renderBackground = function _renderBackground(canvas, plotRange) { var _get3 = this.get('crosshairs'), style = _get3.style; var crosshairsGroup = this.get('crosshairsGroup'); var attrs = Util.mix({ x: plotRange ? plotRange.tl.x : 0, y: plotRange ? plotRange.tl.y : canvas.get('height'), width: plotRange ? plotRange.br.x - plotRange.bl.x : canvas.get('width'), height: plotRange ? Math.abs(plotRange.tl.y - plotRange.bl.y) : canvas.get('height') }, style); var shape = crosshairsGroup.addShape('rect', { attrs: attrs }); shape.hide(); this.set('crosshairsRectShape', shape); return shape; }; Tooltip.prototype._isContentChange = function _isContentChange(title, items) { var titleContent = this.get('titleContent'); var lastItems = this.get('items'); var isChanged = !(title === titleContent && lastItems.length === items.length); if (!isChanged) { Util.each(items, function (item, index) { var preItem = lastItems[index]; isChanged = item.value !== preItem.value || item.color !== preItem.color || item.name !== preItem.name || item.title !== preItem.title; if (isChanged) { return false; } }); } return isChanged; }; Tooltip.prototype.setContent = function setContent(title, items) { var isChange = this._isContentChange(title, items); if (isChange) { var timeStamp = +new Date(); this.set('items', items); this.set('titleContent', title); this.set('timeStamp', timeStamp); this._renderTooltip(); } return this; }; Tooltip.prototype.setMarkers = function setMarkers(markerItems, markerCfg) { var self = this; var markerGroup = self.get('markerGroup'); var frontPlot = self.get('frontPlot'); if (!markerGroup) { markerGroup = frontPlot.addGroup({ zIndex: 1 }); self.set('markerGroup', markerGroup); } else { markerGroup.clear(); } Util.each(markerItems, function (item) { markerGroup.addShape('marker', { color: item.color, attrs: Util.mix({}, markerCfg, { x: item.x, y: item.y }) }); }); this.set('markerItems', markerItems); }; Tooltip.prototype.clearMarkers = function clearMarkers() { var markerGroup = this.get('markerGroup'); markerGroup && markerGroup.clear(); }; Tooltip.prototype.setPosition = function setPosition(x, y, target) { var container = this.get('container'); var crossLineShapeX = this.get('crossLineShapeX'); var crossLineShapeY = this.get('crossLineShapeY'); var crosshairsRectShape = this.get('crosshairsRectShape'); var endx = x; var endy = y; // const outterNode = this.get('canvas').get('el').parentNode; var outterNode = this.get('canvas').get('el'); var viewWidth = DomUtil.getWidth(outterNode); var viewHeight = DomUtil.getHeight(outterNode); var offset = this.get('offset'); var position = void 0; if (this.get('position')) { position = calcTooltipPosition(x, y, this.get('position'), container, target); x = position[0]; y = position[1]; } else if (!this.get('position')) { position = refixTooltipPosition(x, y, container, viewWidth, viewHeight); x = position[0]; y = position[1]; } if (this.get('inPlot')) { // tooltip 必须限制在绘图区域内 var plotRange = this.get('plotRange'); position = confineTooltipPosition(x, y, container, plotRange); x = position[0]; y = position[1]; } if (this.get('x') !== x || this.get('y') !== y) { var markerItems = this.get('markerItems'); if (!Util.isEmpty(markerItems)) { endx = markerItems[0].x; endy = markerItems[0].y; } if (crossLineShapeY) { // 第一次进入时,画布需要单独绘制,所以需要先设定corss的位置 crossLineShapeY.move(endx, 0); } if (crossLineShapeX) { crossLineShapeX.move(0, endy); } if (crosshairsRectShape) { var isTransposed = this.get('isTransposed'); var items = this.get('items'); var firstItem = items[0]; var lastItem = items[items.length - 1]; var dim = isTransposed ? 'y' : 'x'; var attr = isTransposed ? 'height' : 'width'; var startDim = firstItem[dim]; if (items.length > 1 && firstItem[dim] > lastItem[dim]) { startDim = lastItem[dim]; } if (this.get('crosshairs').width) { // 用户定义了 width crosshairsRectShape.attr(dim, startDim - this.get('crosshairs').width / 2); crosshairsRectShape.attr(attr, this.get('crosshairs').width); } else { offset = firstItem.size / 2 + firstItem.size / 4 || 10; crosshairsRectShape.attr(dim, startDim - offset); if (items.length === 1) { crosshairsRectShape.attr(attr, firstItem.size + firstItem.size / 2); } else { var _lastItem = items[items.length - 1]; crosshairsRectShape.attr(attr, Math.abs(_lastItem[dim] - firstItem[dim]) + 2 * offset); } } } var follow = this.get('follow'); container.style.left = follow ? x + 'px' : 0; container.style.top = follow ? y + 'px' : 0; } }; Tooltip.prototype.show = function show() { var crossLineShapeX = this.get('crossLineShapeX'); var crossLineShapeY = this.get('crossLineShapeY'); var crosshairsRectShape = this.get('crosshairsRectShape'); var markerGroup = this.get('markerGroup'); var container = this.get('container'); var canvas = this.get('canvas'); crossLineShapeX && crossLineShapeX.show(); crossLineShapeY && crossLineShapeY.show(); crosshairsRectShape && crosshairsRectShape.show(); markerGroup && markerGroup.show(); _Base.prototype.show.call(this); container.style.visibility = 'visible'; // canvas.sort(); canvas.draw(); }; Tooltip.prototype.hide = function hide() { var self = this; var container = self.get('container'); var crossLineShapeX = self.get('crossLineShapeX'); var crossLineShapeY = self.get('crossLineShapeY'); var crosshairsRectShape = this.get('crosshairsRectShape'); var markerGroup = self.get('markerGroup'); var canvas = self.get('canvas'); container.style.visibility = 'hidden'; crossLineShapeX && crossLineShapeX.hide(); crossLineShapeY && crossLineShapeY.hide(); crosshairsRectShape && crosshairsRectShape.hide(); markerGroup && markerGroup.hide(); _Base.prototype.hide.call(this); canvas.draw(); }; Tooltip.prototype.destroy = function destroy() { var self = this; var crossLineShapeX = self.get('crossLineShapeX'); var crossLineShapeY = self.get('crossLineShapeY'); var markerGroup = self.get('markerGroup'); var crosshairsRectShape = self.get('crosshairsRectShape'); var container = self.get('container'); var containerTpl = self.get('containerTpl'); if (container && !/^\#/.test(containerTpl)) { container.parentNode.removeChild(container); } crossLineShapeX && crossLineShapeX.remove(); crossLineShapeY && crossLineShapeY.remove(); markerGroup && markerGroup.remove(); crosshairsRectShape && crosshairsRectShape.remove(); // super.remove(); _Base.prototype.destroy.call(this); }; return Tooltip; }(Base); module.exports = Tooltip; /***/ }), /* 355 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview The controller of guide * @author sima.zhang */ var Util = __webpack_require__(0); var _require = __webpack_require__(25), Guide = _require.Guide; var Global = __webpack_require__(1); var GuideController = function () { function GuideController(cfg) { _classCallCheck(this, GuideController); this.guides = []; this.options = []; this.xScales = null; this.yScales = null; this.container = null; Util.mix(this, cfg); } GuideController.prototype._creatGuides = function _creatGuides() { var self = this; var options = this.options; var xScales = this.xScales; var yScales = this.yScales; options.forEach(function (option) { var type = option.type; var config = Util.deepMix({ xScales: xScales, yScales: yScales }, Global.guide[type], option); type = Util.upperFirst(type); var guide = new Guide[type](config); self.guides.push(guide); }); return self.guides; }; GuideController.prototype.line = function line() { var cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.options.push(Util.mix({ type: 'line' }, cfg)); return this; }; GuideController.prototype.arc = function arc() { var cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.options.push(Util.mix({ type: 'arc' }, cfg)); return this; }; GuideController.prototype.text = function text() { var cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.options.push(Util.mix({ type: 'text' }, cfg)); return this; }; GuideController.prototype.image = function image() { var cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.options.push(Util.mix({ type: 'image' }, cfg)); return this; }; GuideController.prototype.region = function region() { var cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.options.push(Util.mix({ type: 'region' }, cfg)); return this; }; GuideController.prototype.html = function html() { var cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; this.options.push(Util.mix({ type: 'html' }, cfg)); return this; }; GuideController.prototype.render = function render(coord) { var self = this; var guides = self._creatGuides(); var container = self.backContainer; Util.each(guides, function (guide) { if (guide.top) { // 默认 guide 绘制到 backPlot,用户也可以声明 top: true,显示在最上层 container = self.frontContainer; } guide.render(coord, container); }); }; GuideController.prototype.clear = function clear() { this.options = []; this.reset(); }; GuideController.prototype.changeVisible = function changeVisible(visible) { var guides = this.guides; Util.each(guides, function (guide) { guide.setVisible(visible); }); }; GuideController.prototype.reset = function reset() { var guides = this.guides; Util.each(guides, function (guide) { guide.remove(); }); this.guides = []; }; return GuideController; }(); module.exports = GuideController; /***/ }), /* 356 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Util = __webpack_require__(0); var Global = __webpack_require__(1); var _require = __webpack_require__(25), Legend = _require.Legend; var Shape = __webpack_require__(66); var FIELD_ORIGIN = '_origin'; var MARGIN = 24; var MARGIN_LEGEND = 24; var requireAnimationFrameFn = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; function _snapEqual(v1, v2, scale) { var isEqual = void 0; if (Util.isNil(scale)) { return false; } v1 = scale.translate(v1); v2 = scale.translate(v2); if (scale.isCategory) { isEqual = v1 === v2; } else { isEqual = Math.abs(v1 - v2) <= 1; } return isEqual; } function findGeom(geoms, value) { var rst = void 0; Util.each(geoms, function (geom) { if (geom.get('visible')) { var yScale = geom.getYScale(); if (yScale.field === value) { rst = geom; return; } } }); return rst; } var LegendController = function () { function LegendController(cfg) { _classCallCheck(this, LegendController); this.options = {}; Util.mix(this, cfg); this.clear(); var chart = this.chart; this.container = chart.get('frontPlot'); this.plotRange = chart.get('plotRange'); } LegendController.prototype.clear = function clear() { var legends = this.legends; Util.each(legends, function (legendItems) { Util.each(legendItems, function (legend) { legend.remove(); }); }); this.legends = {}; }; LegendController.prototype._isFieldInView = function _isFieldInView(field, value, view) { var flag = false; var scales = view.get('scales'); var fieldScale = scales[field]; if (fieldScale && fieldScale.values) { flag = Util.inArray(fieldScale.values, value); } return flag; }; LegendController.prototype._bindClickEvent = function _bindClickEvent(legend, scale, filterVals) { var self = this; var chart = self.chart; var views = chart.get('views'); var field = scale.field; var options = self.options; legend.on('itemclick', function (ev) { if (options.onClick) { // 用户自定义了图例点击事件 options.onClick(ev); } else { var item = ev.item; var checked = ev.checked; var isSingeSelected = legend.get('selectedMode') === 'single'; // 图例的选中模式 var clickedValue = item.dataValue; // import: 需要取该图例项原始的数值 if (checked) { filterVals.push(clickedValue); if (self._isFieldInView(field, clickedValue, chart)) { chart.filter(field, function (field) { return isSingeSelected ? field === clickedValue : Util.inArray(filterVals, field); }); } Util.each(views, function (view) { if (self._isFieldInView(field, clickedValue, view)) { view.filter(field, function (field) { return isSingeSelected ? field === clickedValue : Util.inArray(filterVals, field); }); } }); } else if (!isSingeSelected) { Util.Array.remove(filterVals, clickedValue); if (self._isFieldInView(field, clickedValue, chart)) { chart.filter(field, function (field) { return Util.inArray(filterVals, field); }); } Util.each(views, function (view) { if (self._isFieldInView(field, clickedValue, view)) { view.filter(field, function (field) { return Util.inArray(filterVals, field); }); } }); } chart.set('keepLegend', true); // 图例不重新渲染 chart.repaint(); } }); }; LegendController.prototype._filterLabels = function _filterLabels(shape, geom, visible) { if (shape.get('gLabel')) { shape.get('gLabel').set('visible', visible); } else { var labelCfg = geom.get('labelCfg'); if (labelCfg && labelCfg.fields && labelCfg.fields.length > 0) { var xScale = geom.getXScale(); var yScale = geom.getYScale(); var xField = xScale.field; var yField = yScale.field; var shapeData = shape.get('origin')._origin; var labelContainer = geom.get('labelContainer'); var labels = labelContainer.get('labelsGroup').get('children'); Util.each(labels, function (label) { var labelData = label.get('origin') || []; if (labelData[xField] === shapeData[xField] && labelData[yField] === shapeData[yField]) { label.set('visible', visible); shape.set('gLabel', label); } }); } } }; LegendController.prototype._bindFilterEvent = function _bindFilterEvent(legend, scale) { var self = this; var chart = this.chart; var field = scale.field; legend.on('itemfilter', function (ev) { var range = ev.range; chart.filterShape(function (obj, shape, geom) { if (obj[field]) { var filtered = obj[field] >= range[0] && obj[field] <= range[1]; // shape 带 label,则还需要隐藏 label self._filterLabels(shape, geom, filtered); return filtered; } return true; }); var geoms = chart.getAllGeoms() || []; var _loop = function _loop(i) { var geom = geoms[i]; if (geom.get('type') === 'heatmap') { requireAnimationFrameFn(function () { geom.drawWithRange(range); }); } }; for (var i = 0; i < geoms.length; i++) { _loop(i); } }); }; LegendController.prototype._getShapeData = function _getShapeData(shape) { var originData = shape.get('origin'); if (Util.isArray(originData)) { originData = originData[0]; } return originData[FIELD_ORIGIN]; }; LegendController.prototype._bindHoverEvent = function _bindHoverEvent(legend, field) { var self = this; var chart = self.chart; var geoms = chart.getAllGeoms(); var options = self.options; var canvas = chart.get('canvas'); legend.on('itemhover', function (ev) { var value = ev.item.value; var pre = self.pre; if (!pre) { Util.each(geoms, function (geom) { var shapeContainer = geom.get('shapeContainer'); var shapes = geom.getShapes(); var activeShapes = []; if (field) { var scale = geom.get('scales')[field]; Util.each(shapes, function (shape) { var origin = self._getShapeData(shape); if (origin && _snapEqual(origin[field], value, scale)) { activeShapes.push(shape); } }); } else if (geom.getYScale().field === value) { activeShapes = shapes; } if (!Util.isEmpty(activeShapes)) { ev.shapes = activeShapes; ev.geom = geom; if (options.onHover) { options.onHover(ev); shapeContainer.sort(); canvas.draw(); } else { geom.setShapesActived(activeShapes); } } }); self.pre = value; } else if (pre === value) { return; } }); legend.on('itemunhover', function () { self.pre = null; Util.each(geoms, function (geom) { if (geom.get('activeShapes')) { geom.clearActivedShapes(); canvas.draw(); } }); }); }; LegendController.prototype._isFiltered = function _isFiltered(scale, values, value) { if (!scale.isCategory) { return true; } var rst = false; value = scale.invert(value); Util.each(values, function (val) { rst = rst || scale.getText(val) === scale.getText(value); if (rst) { return false; } }); return rst; }; LegendController.prototype._alignLegend = function _alignLegend(legend, pre, region, position) { var self = this; var container = self.container; var canvas = container.get('canvas'); var width = canvas.get('width'); var height = canvas.get('height'); var plotRange = self.plotRange; var offsetX = legend.get('offsetX') || 0; var offsetY = legend.get('offsetY') || 0; var offset = Util.isNil(legend.get('offset')) ? MARGIN : legend.get('offset'); var legendHeight = legend.getHeight(); var x = 0; var y = 0; if (position === 'left' || position === 'right') { // 垂直 height = plotRange.br.y; x = position === 'left' ? offset : plotRange.br.x + offset; y = height - legendHeight; if (pre) { y = pre.get('y') - legendHeight - MARGIN_LEGEND; } } else { x = (width - region.totalWidth) / 2; y = position === 'top' ? offset : plotRange.bl.y + offset; if (pre) { var preWidth = pre.getWidth(); x = pre.get('x') + preWidth + MARGIN_LEGEND; } } legend.move(x + offsetX, y + offsetY); }; LegendController.prototype._getRegion = function _getRegion(legends) { var maxWidth = 0; var totalWidth = 0; Util.each(legends, function (legend) { var width = legend.getWidth(); if (maxWidth < width) { maxWidth = width; } totalWidth += width; }); return { maxWidth: maxWidth, totalWidth: totalWidth }; }; LegendController.prototype._addCategroyLegend = function _addCategroyLegend(scale, attr, geom, filterVals, position) { var self = this; var field = scale.field; var legendOptions = self.options; var legends = self.legends; legends[position] = legends[position] || []; var container = self.container; var items = []; var ticks = scale.getTicks(); var isByAttr = true; var shapeType = geom.get('shapeType') || 'point'; var shape = geom.getDefaultValue('shape') || 'circle'; if (legendOptions[field] && legendOptions[field].marker) { // 用户为 field 对应的图例定义了 marker shape = legendOptions[field].marker; shapeType = 'point'; isByAttr = false; } else if (legendOptions.marker) { shape = legendOptions.marker; shapeType = 'point'; isByAttr = false; } var chart = self.chart; var canvas = chart.get('canvas'); var plotRange = self.plotRange; var maxLength = position === 'right' || position === 'left' ? plotRange.bl.y - plotRange.tr.y : canvas.get('width'); Util.each(ticks, function (tick) { var text = tick.text; var name = text; var scaleValue = tick.value; var value = scale.invert(scaleValue); var cfg = { isInCircle: geom.isInCircle() }; var checked = filterVals ? self._isFiltered(scale, filterVals, scaleValue) : true; var colorAttr = geom.getAttr('color'); var shapeAttr = geom.getAttr('shape'); if (colorAttr) { // 存在颜色映射 if (colorAttr.callback && colorAttr.callback.length > 1) { // 多参数映射,阻止程序报错 var restArgs = Array(colorAttr.callback.length - 1).fill(''); cfg.color = colorAttr.mapping.apply(colorAttr, [value].concat(restArgs)).join('') || Global.defaultColor; } else { cfg.color = colorAttr.mapping(value).join('') || Global.defaultColor; } } if (isByAttr && shapeAttr) { // 存在形状映射 if (shapeAttr.callback && shapeAttr.callback.length > 1) { // 多参数映射,阻止程序报错 var _restArgs = Array(shapeAttr.callback.length - 1).fill(''); shape = shapeAttr.mapping.apply(shapeAttr, [value].concat(_restArgs)).join(''); } else { shape = shapeAttr.mapping(value).join(''); } } var shapeObject = Shape.getShapeFactory(shapeType); var marker = shapeObject.getMarkerCfg(shape, cfg); if (Util.isFunction(shape)) { marker.symbol = shape; } items.push({ value: name, // 图例项显示文本的内容 dataValue: value, // 图例项对应原始数据中的数值 checked: checked, marker: marker }); }); var legendCfg = Util.deepMix({ title: { text: scale.alias || scale.field } }, Global.legend[position], legendOptions[field] || legendOptions, { maxLength: maxLength, items: items }); var legend = container.addGroup(Legend.Category, legendCfg); self._bindClickEvent(legend, scale, filterVals); legends[position].push(legend); return legend; }; LegendController.prototype._addContinuousLegend = function _addContinuousLegend(scale, attr, position) { var self = this; var legends = self.legends; legends[position] = legends[position] || []; var container = self.container; var field = scale.field; var ticks = scale.getTicks(); var items = []; var legend = void 0; var minValue = void 0; var maxValue = void 0; Util.each(ticks, function (tick) { var scaleValue = tick.value; var invertValue = scale.invert(scaleValue); var attrValue = attr.mapping(invertValue).join(''); items.push({ value: tick.text, attrValue: attrValue, scaleValue: scaleValue }); if (scaleValue === 0) { minValue = true; } if (scaleValue === 1) { maxValue = true; } }); if (!minValue) { items.push({ value: scale.getText(scale.invert(0)), attrValue: attr.mapping(0).join(''), scaleValue: 0 }); } if (!maxValue) { items.push({ value: scale.getText(scale.invert(1)), attrValue: attr.mapping(1).join(''), scaleValue: 1 }); } var options = self.options; var defaultCfg = Global.legend[position]; if (options && options.slidable === false || options[field] && options[field].slidable === false) { defaultCfg = Util.mix({}, defaultCfg, Global.legend.gradient); } var legendCfg = Util.deepMix({ title: { text: scale.alias || scale.field } }, defaultCfg, options[field] || options, { items: items, attr: attr }); if (attr.type === 'color') { legend = container.addGroup(Legend.Color, legendCfg); } else if (attr.type === 'size') { legend = container.addGroup(Legend.Size, legendCfg); } self._bindFilterEvent(legend, scale); legends[position].push(legend); return legend; }; LegendController.prototype.addLegend = function addLegend(scale, attr, geom, filterVals) { var self = this; var legendOptions = self.options; var field = scale.field; var fieldOption = legendOptions[field]; if (fieldOption === false) { // 如果不显示此图例 return null; } if (fieldOption && fieldOption.custom) { self.addCustomLegend(field); } else { var position = legendOptions.position || Global.defaultLegendPosition; if (fieldOption && fieldOption.position) { // 如果对某个图例单独设置 position,则对 position 重新赋值 position = fieldOption.position; } var legend = void 0; if (scale.isLinear) { legend = self._addContinuousLegend(scale, attr, position); } else { legend = self._addCategroyLegend(scale, attr, geom, filterVals, position); } self._bindHoverEvent(legend, field); } }; /** * 自定义图例 * @param {string} field 自定义图例的数据字段名,可以为空 */ LegendController.prototype.addCustomLegend = function addCustomLegend(field) { var self = this; var chart = self.chart; var container = self.container; var legendOptions = self.options; if (field) { legendOptions = legendOptions[field]; } var position = legendOptions.position || Global.defaultLegendPosition; var legends = self.legends; legends[position] = legends[position] || []; var items = legendOptions.items; if (!items) { return; } var geoms = chart.getAllGeoms(); Util.each(items, function (item) { var geom = findGeom(geoms, item.value); if (!Util.isObject(item.marker)) { item.marker = { symbol: item.marker ? item.marker : 'circle', fill: item.fill, radius: 4.5 }; } item.checked = Util.isNil(item.checked) ? true : item.checked; item.geom = geom; }); var canvas = chart.get('canvas'); var plotRange = self.plotRange; var maxLength = position === 'right' || position === 'left' ? plotRange.bl.y - plotRange.tr.y : canvas.get('width'); var legendCfg = Util.deepMix({}, Global.legend[position], legendOptions, { maxLength: maxLength, items: items }); var legend = container.addGroup(Legend.Category, legendCfg); legends[position].push(legend); legend.on('itemclick', function (ev) { if (legendOptions.onClick) { // 用户自定义了图例点击事件 legendOptions.onClick(ev); } }); self._bindHoverEvent(legend); }; LegendController.prototype.alignLegends = function alignLegends() { var self = this; var legends = self.legends; Util.each(legends, function (legendItems, position) { var region = self._getRegion(legendItems); Util.each(legendItems, function (legend, index) { var pre = legendItems[index - 1]; if (!(legend.get('useHtml') && !legend.get('autoPosition'))) { self._alignLegend(legend, pre, region, position); } }); }); return this; }; return LegendController; }(); module.exports = LegendController; /***/ }), /* 357 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview The controller of tooltip * @author sima.zhang */ var Util = __webpack_require__(0); var Global = __webpack_require__(1); var _require = __webpack_require__(25), Tooltip = _require.Tooltip; var MatrixUtil = __webpack_require__(2).MatrixUtil; var Vector2 = MatrixUtil.vec2; var TYPE_SHOW_MARKERS = ['line', 'area', 'path', 'areaStack']; // 默认展示 tooltip marker 的几何图形 var TYPE_SHOW_CROSSHAIRS = ['line', 'area']; // 默认展示十字瞄准线的几何图形 function _indexOfArray(items, item) { var rst = -1; Util.each(items, function (sub, index) { if (sub.title === item.title && sub.name === item.name && sub.value === item.value && sub.color === item.color) { rst = index; return false; } }); return rst; } // 判断是否有样式 function _hasClass(dom, className) { if (!dom) { return false; } var cls = ''; if (!dom.className) return false; if (!Util.isNil(dom.className.baseVal)) { cls = dom.className.baseVal; } else { cls = dom.className; } return cls.indexOf(className) !== -1; } function _isParent(dom, cls) { var parent = dom.parentNode; var rst = false; while (parent && parent !== document.body) { if (_hasClass(parent, cls)) { rst = true; break; } parent = parent.parentNode; } return rst; } // 去除重复的值, 去除不同图形相同数据,只展示一份即可 function _uniqItems(items) { var tmp = []; Util.each(items, function (item) { var index = _indexOfArray(tmp, item); if (index === -1) { tmp.push(item); } else { tmp[index] = item; } }); return tmp; } var TooltipController = function () { function TooltipController(cfg) { _classCallCheck(this, TooltipController); Util.assign(this, cfg); this.timeStamp = 0; } TooltipController.prototype._normalizeEvent = function _normalizeEvent(event) { var chart = this.chart; var canvas = this._getCanvas(); var point = canvas.getPointByClient(event.clientX, event.clientY); var pixelRatio = canvas.get('pixelRatio'); point.x = point.x / pixelRatio; point.y = point.y / pixelRatio; var views = chart.getViewsByPoint(point); point.views = views; return point; }; TooltipController.prototype._getCanvas = function _getCanvas() { return this.chart.get('canvas'); }; TooltipController.prototype._getTriggerEvent = function _getTriggerEvent() { var options = this.options; var triggerOn = options.triggerOn; var eventName = void 0; if (!triggerOn || triggerOn === 'mousemove') { eventName = 'plotmove'; } else if (triggerOn === 'click') { eventName = 'plotclick'; } else if (triggerOn === 'none') { eventName = null; } return eventName; }; TooltipController.prototype._getDefaultTooltipCfg = function _getDefaultTooltipCfg() { var self = this; var options = self.options; var defaultCfg = Util.mix({}, Global.tooltip); var chart = self.chart; var geoms = chart.getAllGeoms().filter(function (geom) { return geom.get('visible'); }); var shapes = []; Util.each(geoms, function (geom) { var type = geom.get('type'); var adjusts = geom.get('adjusts'); var isSymmetric = false; if (adjusts) { Util.each(adjusts, function (adjust) { if (adjust.type === 'symmetric' || adjust.type === 'Symmetric') { isSymmetric = true; return false; } }); } if (Util.indexOf(shapes, type) === -1 && !isSymmetric) { shapes.push(type); } }); var crosshairsCfg = void 0; if (geoms.length && geoms[0].get('coord') && geoms[0].get('coord').type === 'cartesian' && shapes.length === 1) { if (shapes[0] === 'interval' && options.shared !== false) { // 直角坐标系下 interval 的 crosshair 为矩形背景框 crosshairsCfg = { zIndex: 0, // 矩形背景框不可覆盖 geom crosshairs: Global.tooltipCrosshairsRect }; } else if (Util.indexOf(TYPE_SHOW_CROSSHAIRS, shapes[0]) > -1) { crosshairsCfg = { crosshairs: Global.tooltipCrosshairsLine }; } } return Util.mix(defaultCfg, crosshairsCfg, { isTransposed: geoms[0].get('coord').isTransposed }); }; TooltipController.prototype._bindEvent = function _bindEvent() { var chart = this.chart; var triggerEvent = this._getTriggerEvent(); if (triggerEvent) { chart.on(triggerEvent, Util.wrapBehavior(this, 'onMouseMove')); chart.on('plotleave', Util.wrapBehavior(this, 'onMouseOut')); } }; TooltipController.prototype._offEvent = function _offEvent() { var chart = this.chart; var triggerEvent = this._getTriggerEvent(); if (triggerEvent) { chart.off(triggerEvent, Util.getWrapBehavior(this, 'onMouseMove')); chart.off('plotleave', Util.getWrapBehavior(this, 'onMouseOut')); } }; TooltipController.prototype._setTooltip = function _setTooltip(title, point, items, markersItems, target) { var self = this; var tooltip = self.tooltip; var prePoint = self.prePoint; if (!prePoint || prePoint.x !== point.x || prePoint.y !== point.y) { items = _uniqItems(items); self.prePoint = point; var chart = self.chart; var x = Util.isArray(point.x) ? point.x[point.x.length - 1] : point.x; var y = Util.isArray(point.y) ? point.y[point.y.length - 1] : point.y; if (!tooltip.get('visible')) { chart.emit('tooltip:show', { x: x, y: y, tooltip: tooltip }); } chart.emit('tooltip:change', { tooltip: tooltip, x: x, y: y, items: items }); tooltip.setContent(title, items); if (!Util.isEmpty(markersItems)) { if (self.options.hideMarkers === true) { // 不展示 tooltip marker tooltip.set('markerItems', markersItems); // 用于 tooltip 辅助线的定位 } else { tooltip.setMarkers(markersItems, Global.tooltipMarker); } } else { tooltip.clearMarkers(); } tooltip.setPosition(x, y, target); tooltip.show(); } }; TooltipController.prototype.hideTooltip = function hideTooltip() { var tooltip = this.tooltip; var chart = this.chart; var canvas = this._getCanvas(); this.prePoint = null; tooltip.hide(); chart.emit('tooltip:hide', { tooltip: tooltip }); canvas.draw(); }; TooltipController.prototype.onMouseMove = function onMouseMove(ev) { if (Util.isEmpty(ev.views)) { return; } var lastTimeStamp = this.timeStamp; var timeStamp = +new Date(); var point = { x: ev.x, y: ev.y }; if (timeStamp - lastTimeStamp > 16) { var target = void 0; if (ev.shape && Util.inArray(['point', 'interval', 'polygon', 'schema'], ev.shape.name)) { target = ev.shape; } this.showTooltip(point, ev.views, target); this.timeStamp = timeStamp; } }; TooltipController.prototype.onMouseOut = function onMouseOut(ev) { var tooltip = this.tooltip; var canvas = this._getCanvas(); if (!tooltip.get('visible')) { return; } if (ev && ev.target !== canvas) { return; } if (ev && ev.toElement && (_hasClass(ev.toElement, 'g2-tooltip') || _isParent(ev.toElement, 'g2-tooltip'))) { return; } this.hideTooltip(); }; TooltipController.prototype.renderTooltip = function renderTooltip() { var self = this; if (self.tooltip) { // tooltip 对象已经创建 return; } var chart = self.chart; var canvas = self._getCanvas(); var defaultCfg = self._getDefaultTooltipCfg(); var options = self.options; options = Util.deepMix({ plotRange: chart.get('plotRange'), capture: false, canvas: canvas, frontPlot: chart.get('frontPlot'), backPlot: chart.get('backPlot') }, defaultCfg, options); if (options.crosshairs && options.crosshairs.type === 'rect') { options.zIndex = 0; // toolip 背景框不可遮盖住 geom,防止用户配置了 crosshairs } options.visible = false; if (options.shared === false && Util.isNil(options.position)) { options.position = 'top'; } var tooltip = new Tooltip(options); self.tooltip = tooltip; var triggerEvent = self._getTriggerEvent(); if (!tooltip.get('enterable') && triggerEvent === 'plotmove') { // 鼠标不允许进入 tooltip 容器 var tooltipContainer = tooltip.get('container'); if (tooltipContainer) { tooltipContainer.onmousemove = function (e) { // 避免 tooltip 频繁闪烁 var eventObj = self._normalizeEvent(e); chart.emit(triggerEvent, eventObj); }; } } self._bindEvent(); }; TooltipController.prototype.showTooltip = function showTooltip(point, views, target) { var self = this; if (Util.isEmpty(views) || !point) { return; } if (!this.tooltip) { this.renderTooltip(); // 如果一开始 tooltip 关闭,用户重新调用的时候需要先生成 tooltip } var options = self.options; var markersItems = []; var items = []; Util.each(views, function (view) { if (!view.get('tooltipEnable')) { // 如果不显示tooltip,则跳过 return true; } var geoms = view.get('geoms'); var coord = view.get('coord'); Util.each(geoms, function (geom) { var type = geom.get('type'); if (geom.get('visible') && geom.get('tooltipCfg') !== false) { var dataArray = geom.get('dataArray'); if (geom.isShareTooltip() || options.shared === false && Util.inArray(['area', 'line', 'path'], type)) { Util.each(dataArray, function (obj) { var tmpPoint = geom.findPoint(point, obj); if (tmpPoint) { var subItems = geom.getTipItems(tmpPoint, options.title); if (Util.indexOf(TYPE_SHOW_MARKERS, type) !== -1) { Util.each(subItems, function (v) { var point = v.point; if (point && point.x && point.y) { // hotfix: make sure there is no null value var x = Util.isArray(point.x) ? point.x[point.x.length - 1] : point.x; var y = Util.isArray(point.y) ? point.y[point.y.length - 1] : point.y; point = coord.applyMatrix(x, y, 1); v.x = point[0]; v.y = point[1]; v.showMarker = true; markersItems.push(v); } }); } items = items.concat(subItems); } }); } else { var geomContainer = geom.get('shapeContainer'); var canvas = geomContainer.get('canvas'); var pixelRatio = canvas.get('pixelRatio'); var shape = geomContainer.getShape(point.x * pixelRatio, point.y * pixelRatio); if (shape && shape.get('visible') && shape.get('origin')) { items = geom.getTipItems(shape.get('origin'), options.title); } } } }); Util.each(items, function (item) { var point = item.point; var x = Util.isArray(point.x) ? point.x[point.x.length - 1] : point.x; var y = Util.isArray(point.y) ? point.y[point.y.length - 1] : point.y; point = coord.applyMatrix(x, y, 1); item.x = point[0]; item.y = point[1]; }); }); if (items.length) { var first = items[0]; // bugfix: multiple tooltip items with different titles if (!items.every(function (item) { return item.title === first.title; })) { var nearestItem = first; var nearestDistance = Infinity; items.forEach(function (item) { var distance = Vector2.distance([point.x, point.y], [item.x, item.y]); if (distance < nearestDistance) { nearestDistance = distance; nearestItem = item; } }); items = items.filter(function (item) { return item.title === nearestItem.title; }); markersItems = markersItems.filter(function (item) { return item.title === nearestItem.title; }); } if (options.shared === false && items.length > 1) { var snapItem = items[0]; var min = Math.abs(point.y - snapItem.y); Util.each(items, function (aItem) { if (Math.abs(point.y - aItem.y) <= min) { snapItem = aItem; min = Math.abs(point.y - aItem.y); } }); if (snapItem && snapItem.x && snapItem.y) { markersItems = [snapItem]; } items = [snapItem]; } // 3.0 采用当前鼠标位置作为 tooltip 的参考点 // if (!Util.isEmpty(markersItems)) { // point = markersItems[0]; // } var title = first.title || first.name; self._setTooltip(title, point, items, markersItems, target); } else { self.hideTooltip(); } }; TooltipController.prototype.clear = function clear() { var tooltip = this.tooltip; tooltip && tooltip.destroy(); this.tooltip = null; this.prePoint = null; this._offEvent(); }; return TooltipController; }(); module.exports = TooltipController; /***/ }), /* 358 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview The controller of chart's events * @author sima.zhang */ var Util = __webpack_require__(0); function isSameShape(shape1, shape2) { if (Util.isNil(shape1) || Util.isNil(shape2)) { return false; } var shape1Origin = shape1.get('origin'); var shape2Origin = shape2.get('origin'); // hotfix: if both shapes have no data,just compare shapes. if (Util.isNil(shape1Origin) && Util.isNil(shape2Origin)) { return Util.isEqual(shape1, shape2); } return Util.isEqual(shape1Origin, shape2Origin); } function registerData(eventObj) { if (eventObj.shape && eventObj.shape.get('origin')) { eventObj.data = eventObj.shape.get('origin'); } } var EventController = function () { function EventController(cfg) { _classCallCheck(this, EventController); this.view = null; this.canvas = null; Util.assign(this, cfg); this._init(); } EventController.prototype._init = function _init() { this.pixelRatio = this.canvas.get('pixelRatio'); }; EventController.prototype._getShapeEventObj = function _getShapeEventObj(ev) { return { x: ev.x / this.pixelRatio, y: ev.y / this.pixelRatio, target: ev.target, // canvas 元素 toElement: ev.event.toElement || ev.event.relatedTarget }; }; EventController.prototype._getShape = function _getShape(x, y) { var view = this.view; var container = view.get('canvas'); return container.getShape(x, y); }; EventController.prototype._getPointInfo = function _getPointInfo(ev) { var view = this.view; var point = { x: ev.x / this.pixelRatio, y: ev.y / this.pixelRatio }; var views = view.getViewsByPoint(point); point.views = views; return point; }; EventController.prototype._getEventObj = function _getEventObj(ev, point, views) { return { x: point.x, y: point.y, target: ev.target, // canvas 元素 toElement: ev.event.toElement || ev.event.relatedTarget, // 目标元素 views: views }; }; EventController.prototype.bindEvents = function bindEvents() { var canvas = this.canvas; canvas.on('mousedown', Util.wrapBehavior(this, 'onDown')); canvas.on('mousemove', Util.wrapBehavior(this, 'onMove')); canvas.on('mouseleave', Util.wrapBehavior(this, 'onOut')); canvas.on('mouseup', Util.wrapBehavior(this, 'onUp')); canvas.on('click', Util.wrapBehavior(this, 'onClick')); canvas.on('dblclick', Util.wrapBehavior(this, 'onClick')); canvas.on('touchstart', Util.wrapBehavior(this, 'onTouchstart')); canvas.on('touchmove', Util.wrapBehavior(this, 'onTouchmove')); canvas.on('touchend', Util.wrapBehavior(this, 'onTouchend')); }; EventController.prototype._triggerShapeEvent = function _triggerShapeEvent(shape, eventName, eventObj) { if (shape && shape.name) { var view = this.view; if (view.isShapeInView(shape)) { var name = shape.name + ':' + eventName; eventObj.view = view; eventObj.appendInfo = shape.get('appendInfo'); // appendInfo is defined by user view.emit(name, eventObj); } // const parent = view.get('parent'); // if (parent) { // chart 上也需要抛出该事件,本期先不抛出 // parent.emit(name, eventObj); // } } }; EventController.prototype.onDown = function onDown(ev) { var view = this.view; var eventObj = this._getShapeEventObj(ev); eventObj.shape = this.currentShape; registerData(eventObj); view.emit('mousedown', eventObj); this._triggerShapeEvent(this.currentShape, 'mousedown', eventObj); }; EventController.prototype.onMove = function onMove(ev) { var self = this; var view = self.view; var currentShape = self.currentShape; var shape = self._getShape(ev.x, ev.y); var eventObj = self._getShapeEventObj(ev); eventObj.shape = shape; registerData(eventObj); view.emit('mousemove', eventObj); self._triggerShapeEvent(shape, 'mousemove', eventObj); if (currentShape && !isSameShape(currentShape, shape)) { var leaveObj = self._getShapeEventObj(ev); leaveObj.shape = currentShape; leaveObj.toShape = shape; registerData(leaveObj); self._triggerShapeEvent(currentShape, 'mouseleave', leaveObj); } if (shape && !isSameShape(currentShape, shape)) { var enterObj = self._getShapeEventObj(ev); enterObj.shape = shape; enterObj.fromShape = currentShape; registerData(enterObj); self._triggerShapeEvent(shape, 'mouseenter', enterObj); } self.currentShape = shape; var point = self._getPointInfo(ev); var preViews = self.curViews || []; if (preViews.length === 0 && point.views.length) { view.emit('plotenter', self._getEventObj(ev, point, point.views)); } if (preViews.length && point.views.length === 0) { view.emit('plotleave', self._getEventObj(ev, point, preViews)); } if (point.views.length) { eventObj = self._getEventObj(ev, point, point.views); eventObj.shape = shape; registerData(eventObj); view.emit('plotmove', eventObj); } self.curViews = point.views; }; EventController.prototype.onOut = function onOut(ev) { var self = this; var view = self.view; var point = self._getPointInfo(ev); view.emit('plotleave', self._getEventObj(ev, point, self.curViews)); }; EventController.prototype.onUp = function onUp(ev) { var view = this.view; var eventObj = this._getShapeEventObj(ev); eventObj.shape = this.currentShape; view.emit('mouseup', eventObj); this._triggerShapeEvent(this.currentShape, 'mouseup', eventObj); }; EventController.prototype.onClick = function onClick(ev) { var self = this; var view = self.view; var shape = self._getShape(ev.x, ev.y); var shapeEventObj = self._getShapeEventObj(ev); shapeEventObj.shape = shape; registerData(shapeEventObj); view.emit('click', shapeEventObj); self._triggerShapeEvent(shape, ev.type, shapeEventObj); self.currentShape = shape; var point = self._getPointInfo(ev); var views = point.views; if (!Util.isEmpty(views)) { var eventObj = self._getEventObj(ev, point, views); if (self.currentShape) { var _shape = self.currentShape; eventObj.shape = _shape; registerData(eventObj); // eventObj.data = shape.get('origin'); } view.emit('plotclick', eventObj); if (ev.type === 'dblclick') { view.emit('plotdblclick', eventObj); view.emit('dblclick', shapeEventObj); } } }; EventController.prototype.onTouchstart = function onTouchstart(ev) { var view = this.view; var shape = this._getShape(ev.x, ev.y); var eventObj = this._getShapeEventObj(ev); eventObj.shape = shape; registerData(eventObj); view.emit('touchstart', eventObj); this._triggerShapeEvent(shape, 'touchstart', eventObj); this.currentShape = shape; }; EventController.prototype.onTouchmove = function onTouchmove(ev) { var view = this.view; var shape = this._getShape(ev.x, ev.y); var eventObj = this._getShapeEventObj(ev); eventObj.shape = shape; registerData(eventObj); view.emit('touchmove', eventObj); this._triggerShapeEvent(shape, 'touchmove', eventObj); this.currentShape = shape; }; EventController.prototype.onTouchend = function onTouchend(ev) { var view = this.view; var eventObj = this._getShapeEventObj(ev); eventObj.shape = this.currentShape; registerData(eventObj); view.emit('touchend', eventObj); this._triggerShapeEvent(this.currentShape, 'touchend', eventObj); }; EventController.prototype.clearEvents = function clearEvents() { var canvas = this.canvas; canvas.off('mousemove', Util.getWrapBehavior(this, 'onMove')); canvas.off('mouseleave', Util.getWrapBehavior(this, 'onOut')); canvas.off('mousedown', Util.getWrapBehavior(this, 'onDown')); canvas.off('mouseup', Util.getWrapBehavior(this, 'onUp')); canvas.off('click', Util.getWrapBehavior(this, 'onClick')); canvas.off('dblclick', Util.getWrapBehavior(this, 'onClick')); canvas.off('touchstart', Util.getWrapBehavior(this, 'onTouchstart')); canvas.off('touchmove', Util.getWrapBehavior(this, 'onTouchmove')); canvas.off('touchend', Util.getWrapBehavior(this, 'onTouchend')); }; return EventController; }(); module.exports = EventController; /***/ }), /* 359 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview The entry of chart's animation * @author sima.zhang */ var Util = __webpack_require__(0); var Animate = __webpack_require__(68); var _require = __webpack_require__(2), MatrixUtil = _require.MatrixUtil; var mat3 = MatrixUtil.mat3; // 获取图组内所有的shapes function getShapes(container, viewId) { var shapes = []; if (container.get('animate') === false) { return []; } var children = container.get('children'); Util.each(children, function (child) { if (child.isGroup) { shapes = shapes.concat(getShapes(child, viewId)); } else if (child.isShape && child._id) { var id = child._id; id = id.split('-')[0]; if (id === viewId) { shapes.push(child); } } }); return shapes; } function cache(shapes) { var rst = {}; Util.each(shapes, function (shape) { if (!shape._id || shape.isClip) return; var id = shape._id; rst[id] = { _id: id, type: shape.get('type'), attrs: Util.cloneDeep(shape.__attrs), // 原始属性 name: shape.name, index: shape.get('index'), animateCfg: shape.get('animateCfg'), coord: shape.get('coord') }; }); return rst; } function getAnimate(geomType, coord, animationType, animationName) { var result = void 0; if (animationName) { result = Animate.Action[animationType][animationName]; } else { result = Animate.getAnimation(geomType, coord, animationType); } return result; } function getAnimateCfg(geomType, animationType, animateCfg) { var defaultCfg = Animate.getAnimateCfg(geomType, animationType); if (animateCfg && animateCfg[animationType]) { return Util.deepMix({}, defaultCfg, animateCfg[animationType]); } return defaultCfg; } function addAnimate(cache, shapes, canvas, isUpdate) { var animate = void 0; var animateCfg = void 0; var canvasDrawn = false; if (isUpdate) { // Step: leave -> update -> enter var updateShapes = []; // 存储的是 shapes var newShapes = []; // 存储的是 shapes Util.each(shapes, function (shape) { var result = cache[shape._id]; if (!result) { newShapes.push(shape); } else { shape.setSilent('cacheShape', result); updateShapes.push(shape); delete cache[shape._id]; } }); Util.each(cache, function (deletedShape) { var name = deletedShape.name, coord = deletedShape.coord, _id = deletedShape._id, attrs = deletedShape.attrs, index = deletedShape.index, type = deletedShape.type; animateCfg = getAnimateCfg(name, 'leave', deletedShape.animateCfg); animate = getAnimate(name, coord, 'leave', animateCfg.animation); if (Util.isFunction(animate)) { var tempShape = canvas.addShape(type, { attrs: attrs, index: index }); tempShape._id = _id; tempShape.name = name; if (coord) { var tempShapeMatrix = tempShape.getMatrix(); var finalMatrix = mat3.multiply([], tempShapeMatrix, coord.matrix); tempShape.setMatrix(finalMatrix); } canvasDrawn = true; animate(tempShape, animateCfg, coord); } }); Util.each(updateShapes, function (updateShape) { var name = updateShape.name; var coord = updateShape.get('coord'); var cacheAttrs = updateShape.get('cacheShape').attrs; // 判断如果属性相同的话就不进行变换 if (!Util.isEqual(cacheAttrs, updateShape.__attrs)) { animateCfg = getAnimateCfg(name, 'update', updateShape.get('animateCfg')); animate = getAnimate(name, coord, 'update', animateCfg.animation); if (Util.isFunction(animate)) { animate(updateShape, animateCfg, coord); } else { var endState = Util.cloneDeep(updateShape.__attrs); // updateShape.__attrs = cacheAttrs; updateShape.attr(cacheAttrs); updateShape.animate(endState, animateCfg.duration, animateCfg.easing, function () { updateShape.setSilent('cacheShape', null); }); } canvasDrawn = true; } }); Util.each(newShapes, function (newShape) { var name = newShape.name; var coord = newShape.get('coord'); animateCfg = getAnimateCfg(name, 'enter', newShape.get('animateCfg')); animate = getAnimate(name, coord, 'enter', animateCfg.animation); if (Util.isFunction(animate)) { animate(newShape, animateCfg, coord); canvasDrawn = true; } }); } else { Util.each(shapes, function (shape) { var name = shape.name; var coord = shape.get('coord'); animateCfg = getAnimateCfg(name, 'appear', shape.get('animateCfg')); animate = getAnimate(name, coord, 'appear', animateCfg.animation); if (Util.isFunction(animate)) { animate(shape, animateCfg, coord); canvasDrawn = true; } }); } return canvasDrawn; } module.exports = { execAnimation: function execAnimation(view, isUpdate) { var viewContainer = view.get('middlePlot'); var axisContainer = view.get('backPlot'); var viewId = view.get('_id'); var canvas = view.get('canvas'); var caches = canvas.get(viewId + 'caches') || []; var shapes = getShapes(viewContainer, viewId); var axisShapes = getShapes(axisContainer, viewId); var cacheShapes = shapes.concat(axisShapes); canvas.setSilent(viewId + 'caches', cache(cacheShapes)); var drawn = void 0; if (isUpdate) { drawn = addAnimate(caches, cacheShapes, canvas, isUpdate); } else { drawn = addAnimate(caches, shapes, canvas, isUpdate); } if (!drawn) { canvas.draw(); } } }; /***/ }), /* 360 */ /***/ (function(module, exports, __webpack_require__) { /** * @fileOverview Facet 的入口 * @author dxq613@gmail.com */ var Facets = {}; Facets.Rect = __webpack_require__(124); Facets.List = __webpack_require__(125); Facets.Circle = __webpack_require__(361); Facets.Tree = __webpack_require__(362); Facets.Mirror = __webpack_require__(363); Facets.Matrix = __webpack_require__(364); module.exports = Facets; /***/ }), /* 361 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview circle facets * @author dxq613@gmail.com */ var Base = __webpack_require__(45); function getPoint(center, r, angle) { return { x: center.x + r * Math.cos(angle), y: center.y + r * Math.sin(angle) }; } var Circle = function (_Base) { _inherits(Circle, _Base); function Circle() { _classCallCheck(this, Circle); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Circle.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); cfg.type = 'circle'; return cfg; }; Circle.prototype.getRegion = function getRegion(count, index) { var r = 1 / 2; // 画布半径 var avgAngle = Math.PI * 2 / count; var angle = -1 * Math.PI / 2 + avgAngle * index; // 当前分面所在的弧度 var facetR = r / (1 + 1 / Math.sin(avgAngle / 2)); var center = { x: 0.5, y: 0.5 }; // 画布圆心 var middle = getPoint(center, r - facetR, angle); // 分面的中心点 var startAngle = Math.PI * 5 / 4; // 右上角 var endAngle = Math.PI * 1 / 4; // 左下角 return { start: getPoint(middle, facetR, startAngle), end: getPoint(middle, facetR, endAngle) }; }; Circle.prototype.generateFacets = function generateFacets(data) { var self = this; var fields = self.fields; var field = fields[0]; if (!field) { throw 'Please specify for the field for facet!'; } var values = self.getFieldValues(field, data); var count = values.length; var rst = []; values.forEach(function (value, index) { var conditions = [{ field: field, value: value, values: values }]; var filter = self.getFilter(conditions); var subData = data.filter(filter); var facet = { type: self.type, colValue: value, colField: field, colIndex: index, cols: count, rows: 1, rowIndex: 0, data: subData, region: self.getRegion(count, index) }; rst.push(facet); }); return rst; }; return Circle; }(Base); module.exports = Circle; /***/ }), /* 362 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview tree facets * @author dxq613@gmail.com */ var assign = __webpack_require__(60); var Base = __webpack_require__(45); var Tree = function (_Base) { _inherits(Tree, _Base); function Tree() { _classCallCheck(this, Tree); return _possibleConstructorReturn(this, _Base.apply(this, arguments)); } Tree.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Base.prototype.getDefaultCfg.call(this); cfg.type = 'tree'; cfg.line = { lineWidth: 1, stroke: '#ddd' }; cfg.lineSmooth = false; return cfg; }; Tree.prototype.generateFacets = function generateFacets(data) { var self = this; var fields = self.fields; if (!fields.length) { throw 'Please specify for the fields for facet!'; } var rst = []; var root = self.getRootFacet(data); // if (self.showRoot) { rst.push(root); // } root.children = self.getChildFacets(data, 1, rst); self.setRegion(rst); return rst; }; Tree.prototype.getRootFacet = function getRootFacet(data) { var self = this; var facet = { type: self.type, rows: self.getRows(), rowIndex: 0, colIndex: 0, colValue: self.rootTitle, data: data }; return facet; }; Tree.prototype.getRows = function getRows() { return this.fields.length + 1; }; // get child Tree.prototype.getChildFacets = function getChildFacets(data, level, arr) { var self = this; var fields = self.fields; var length = fields.length; if (length < level) { return; } var rst = []; var field = fields[level - 1]; var values = self.getFieldValues(field, data); values.forEach(function (value, index) { var conditions = [{ field: field, value: value, values: values }]; var filter = self.getFilter(conditions); var subData = data.filter(filter); if (subData.length) { var facet = { type: self.type, colValue: value, colField: field, colIndex: index, rows: self.getRows(), rowIndex: level, data: subData, children: self.getChildFacets(subData, level + 1, arr) }; rst.push(facet); arr.push(facet); } }); return rst; }; // 设置 region Tree.prototype.setRegion = function setRegion(facets) { var self = this; self.forceColIndex(facets); facets.forEach(function (facet) { facet.region = self.getRegion(facet.rows, facet.cols, facet.colIndex, facet.rowIndex); }); }; // set column index of facets Tree.prototype.forceColIndex = function forceColIndex(facets) { var self = this; var leafs = []; var index = 0; facets.forEach(function (facet) { if (self.isLeaf(facet)) { leafs.push(facet); facet.colIndex = index; index++; } }); leafs.forEach(function (facet) { facet.cols = leafs.length; }); var maxLevel = self.fields.length; for (var i = maxLevel - 1; i >= 0; i--) { var levelFacets = self.getFacetsByLevel(facets, i); // var yIndex = maxLevel - i; for (var j = 0; j < levelFacets.length; j++) { var facet = levelFacets[j]; if (!self.isLeaf(facet)) { facet.originColIndex = facet.colIndex; facet.colIndex = self.getRegionIndex(facet.children); facet.cols = leafs.length; } } } }; // get facet use level Tree.prototype.getFacetsByLevel = function getFacetsByLevel(facets, level) { var rst = []; facets.forEach(function (facet) { if (facet.rowIndex === level) { rst.push(facet); } }); return rst; }; // set facets region Tree.prototype.getRegion = function getRegion(rows, cols, xIndex, yIndex) { var xWidth = 1 / cols; // x轴方向的每个分面的偏移 var yWidth = 1 / rows; // y轴方向的每个分面的偏移 var start = { x: xWidth * xIndex, y: yWidth * yIndex }; var end = { x: start.x + xWidth, y: start.y + yWidth * 2 / 3 // 预留1/3的空隙,方便添加连接线 }; return { start: start, end: end }; }; // if the facet has children , make it's column index in the middle of it's children Tree.prototype.getRegionIndex = function getRegionIndex(children) { var first = children[0]; var last = children[children.length - 1]; return (last.colIndex - first.colIndex) / 2 + first.colIndex; }; // is a leaf without children Tree.prototype.isLeaf = function isLeaf(facet) { return !facet.children || !facet.children.length; }; Tree.prototype.setXAxis = function setXAxis(xField, axes, facet) { // 当是最后一行或者下面没有 view 时文本不显示 if (facet.rowIndex !== facet.rows - 1) { axes[xField].label = null; axes[xField].title = null; } }; // 设置 y 坐标轴的文本、title 是否显示 Tree.prototype.setYAxis = function setYAxis(yField, axes, facet) { if (facet.originColIndex !== 0 && facet.colIndex !== 0) { axes[yField].title = null; axes[yField].label = null; } }; // 绘制完成后 Tree.prototype.onPaint = function onPaint() { _Base.prototype.onPaint.call(this); this.group.clear(); if (this.facets && this.line) { this.drawLines(this.facets, this.group); } }; Tree.prototype.drawLines = function drawLines(facets, group) { var self = this; var lineGroup = group.addGroup(); facets.forEach(function (facet) { if (!self.isLeaf(facet)) { var children = facet.children; self._addFacetLines(facet, children, lineGroup); } }); }; // add lines with it's children Tree.prototype._addFacetLines = function _addFacetLines(facet, children, group) { var self = this; var view = facet.view; var region = view.getViewRegion(); var start = { x: region.start.x + (region.end.x - region.start.x) / 2, y: region.start.y }; children.forEach(function (subFacet) { var subRegion = subFacet.view.getViewRegion(); var end = { x: subRegion.start.x + (subRegion.end.x - subRegion.start.x) / 2, y: subRegion.end.y }; var middle1 = { x: start.x, y: start.y + (end.y - start.y) / 2 }; var middle2 = { x: end.x, y: middle1.y }; self._drawLine([start, middle1, middle2, end], group); }); }; Tree.prototype._getPath = function _getPath(points) { var self = this; var path = []; var smooth = self.lineSmooth; if (smooth) { path.push(['M', points[0].x, points[0].y]); path.push(['C', points[1].x, points[1].y, points[2].x, points[2].y, points[3].x, points[3].y]); } else { points.forEach(function (point, index) { if (index === 0) { path.push(['M', point.x, point.y]); } else { path.push(['L', point.x, point.y]); } }); } return path; }; // draw line width points Tree.prototype._drawLine = function _drawLine(points, group) { var self = this; var path = self._getPath(points); var line = self.line; group.addShape('path', { attrs: assign({ path: path }, line) }); }; return Tree; }(Base); module.exports = Tree; /***/ }), /* 363 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview mirror facets * @author dxq613@gmail.com */ var List = __webpack_require__(125); var Mirror = function (_List) { _inherits(Mirror, _List); function Mirror() { _classCallCheck(this, Mirror); return _possibleConstructorReturn(this, _List.apply(this, arguments)); } Mirror.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _List.prototype.getDefaultCfg.call(this); cfg.type = 'mirror'; this.transpose = false; return cfg; }; Mirror.prototype.init = function init() { var self = this; if (self.transpose) { self.cols = 2; self.rows = 1; } else { self.cols = 1; self.rows = 2; } _List.prototype.init.call(this); }; Mirror.prototype.beforeProcessView = function beforeProcessView(view, facet) { if (this.transpose) { if (facet.colIndex % 2 === 0) { view.coord().transpose().scale(-1, 1); } else { view.coord().transpose(); } } else { if (facet.rowIndex % 2 !== 0) { view.coord().scale(1, -1); } } }; Mirror.prototype.renderTitle = function renderTitle(view, facet) { if (this.transpose) { this.drawColTitle(view, facet); } else { this.drawRowTitle(view, facet); } }; Mirror.prototype.setXAxis = function setXAxis(xField, axes, facet) { // 当是最后一行或者下面没有 view 时文本不显示 if (facet.colIndex === 1 || facet.rowIndex === 1) { axes[xField].label = null; axes[xField].title = null; } }; Mirror.prototype.setYAxis = function setYAxis() /* yField, axes, facet */{}; return Mirror; }(List); module.exports = Mirror; /***/ }), /* 364 */ /***/ (function(module, exports, __webpack_require__) { 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; } /** * @fileOverview Use matrices to compare different fields * @author dxq613@gmail.com */ var Rect = __webpack_require__(124); var Matrix = function (_Rect) { _inherits(Matrix, _Rect); function Matrix() { _classCallCheck(this, Matrix); return _possibleConstructorReturn(this, _Rect.apply(this, arguments)); } Matrix.prototype.getDefaultCfg = function getDefaultCfg() { var cfg = _Rect.prototype.getDefaultCfg.call(this); cfg.type = 'matrix'; cfg.showTitle = false; return cfg; }; Matrix.prototype.generateFacets = function generateFacets(data) { var self = this; var fields = self.fields; var rows = fields.length; var cols = rows; // 矩阵中行列相等,等于指定的字段个数 var rst = []; for (var i = 0; i < cols; i++) { var colField = fields[i]; for (var j = 0; j < rows; j++) { var rowField = fields[j]; var facet = { type: self.type, colValue: colField, rowValue: rowField, colField: colField, rowField: rowField, colIndex: i, rowIndex: j, cols: cols, rows: rows, data: data, region: self.getRegion(rows, cols, i, j) }; rst.push(facet); } } return rst; }; // 设置 x 坐标轴的文本、title 是否显示 Matrix.prototype.setXAxis = function setXAxis(xField, axes, facet) { if (facet.rowIndex !== facet.rows - 1) { axes[xField].title = null; axes[xField].label = null; } }; // 设置 y 坐标轴的文本、title 是否显示 Matrix.prototype.setYAxis = function setYAxis(yField, axes, facet) { if (facet.colIndex !== 0) { axes[yField].title = null; axes[yField].label = null; } }; return Matrix; }(Rect); module.exports = Matrix; /***/ }), /* 365 */ /***/ (function(module, exports, __webpack_require__) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * @fileOverview track g2 * @author dxq613@gmail.com */ var Global = __webpack_require__(1); var SERVER_URL = 'https://kcart.alipay.com/web/bi.do'; var Util = __webpack_require__(0); var Monitor = function () { function Monitor(opt) { _classCallCheck(this, Monitor); var _self = this; var config = opt || {}; var image = new Image(); Util.mix(_self, { image: image, server: SERVER_URL }, config); } /** * 发送请求 * @param {object} opt 埋点记录参数 * opt.pg:访问的页面url */ Monitor.prototype.log = function log(opt) { var _self = this; var config = opt || {}; var newObj = Util.mix({ pg: document.URL, r: new Date().getTime() }, config); var d = encodeURIComponent(JSON.stringify([newObj])); _self.image.src = _self.server + '?BIProfile=merge&d=' + d; }; return Monitor; }(); // 延迟发送请求 setTimeout(function () { if (Global.trackable) { var m = new Monitor(); m.log({ g2: true, version: Global.version, page_type: 'syslog' }); } }, 3000); /***/ }) /******/ ]); }); //# sourceMappingURL=g2.js.map