(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: '