index.js.map 33 KB

1
  1. {"version":3,"sources":["adjust.js"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"adjust\"] = factory();\n\telse\n\t\troot[\"adjust\"] = factory();\n})(typeof self !== 'undefined' ? self : this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 10);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar isObject = __webpack_require__(12);\n\nvar isArray = __webpack_require__(1);\n\nvar each = function each(elements, func) {\n if (!elements) {\n return;\n }\n\n var rst = void 0;\n\n if (isArray(elements)) {\n for (var i = 0, len = elements.length; i < len; i++) {\n rst = func(elements[i], i);\n\n if (rst === false) {\n break;\n }\n }\n } else if (isObject(elements)) {\n for (var k in elements) {\n if (elements.hasOwnProperty(k)) {\n rst = func(elements[k], k);\n\n if (rst === false) {\n break;\n }\n }\n }\n }\n};\n\nmodule.exports = each;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar isType = __webpack_require__(5);\n\nvar isArray = Array.isArray ? Array.isArray : function (value) {\n return isType(value, 'Array');\n};\nmodule.exports = isArray;\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar mix = __webpack_require__(3);\n\nvar Adjust =\n/*#__PURE__*/\nfunction () {\n var _proto = Adjust.prototype;\n\n _proto._initDefaultCfg = function _initDefaultCfg() {\n this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整\n };\n\n function Adjust(cfg) {\n this._initDefaultCfg();\n\n mix(this, cfg);\n }\n /**\n * @override\n */\n\n\n _proto.processAdjust = function processAdjust()\n /* dataArray */\n {};\n\n return Adjust;\n}();\n\nmodule.exports = Adjust;\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\nfunction _mix(dist, obj) {\n for (var key in obj) {\n if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {\n dist[key] = obj[key];\n }\n }\n}\n\nvar mix = function mix(dist, src1, src2, src3) {\n if (src1) _mix(dist, src1);\n if (src2) _mix(dist, src2);\n if (src3) _mix(dist, src3);\n return dist;\n};\n\nmodule.exports = mix;\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\nvar merge = function merge(dataArray) {\n var rst = [];\n\n for (var i = 0; i < dataArray.length; i++) {\n rst = rst.concat(dataArray[i]);\n }\n\n return rst;\n};\n\nmodule.exports = merge;\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports) {\n\nvar toString = {}.toString;\n\nvar isType = function isType(value, type) {\n return toString.call(value) === '[object ' + type + ']';\n};\n\nmodule.exports = isType;\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports) {\n\n// isFinite,\nvar isNil = function isNil(value) {\n /**\n * isNil(null) => true\n * isNil() => true\n */\n return value === null || value === undefined;\n};\n\nmodule.exports = isNil;\n\n/***/ }),\n/* 7 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar DEFAULT_Y = 0; // 默认的y的值\n\nvar each = __webpack_require__(0);\n\nvar ArrayUtil = {\n values: __webpack_require__(8)\n};\nmodule.exports = {\n /**\n * 对应的维度是否可以调整\n * @protected\n * @param {String} dimName 可以调整的维度 x,y\n * @return {Boolean} 是否可以调整\n */\n isAdjust: function isAdjust(dimName) {\n return this.adjustNames.indexOf(dimName) >= 0;\n },\n\n /**\n * @protected\n * 获取可调整度量对应的值\n * @param {Frame} mergeData 数据\n * @return {Object} 值的映射\n */\n _getDimValues: function _getDimValues(mergeData) {\n var self = this;\n var valuesMap = {};\n var dims = [];\n\n if (self.xField && self.isAdjust('x')) {\n dims.push(self.xField);\n }\n\n if (self.yField && self.isAdjust('y')) {\n dims.push(self.yField);\n }\n\n each(dims, function (dim) {\n var values = ArrayUtil.values(mergeData, dim);\n values.sort(function (v1, v2) {\n return v1 - v2;\n });\n valuesMap[dim] = values;\n });\n\n if (!self.yField && self.isAdjust('y')) {\n // 只有一维的情况下,同时调整y\n var dim = 'y';\n var values = [DEFAULT_Y, 1]; // 默认分布在y轴的 0.1 与 0.2 之间\n\n valuesMap[dim] = values;\n }\n\n return valuesMap;\n },\n adjustData: function adjustData(dataArray, mergeData) {\n var self = this;\n\n var valuesMap = self._getDimValues(mergeData);\n\n each(dataArray, function (data, index) {\n // 遍历所有数据集合\n each(valuesMap, function (values, dim) {\n // 根据不同的度量分别调整位置\n self.adjustDim(dim, values, data, dataArray.length, index);\n });\n });\n },\n getAdjustRange: function getAdjustRange(dim, key, values) {\n var self = this;\n var index = values.indexOf(key);\n var length = values.length;\n var pre;\n var next;\n\n if (!self.yField && self.isAdjust('y')) {\n pre = 0;\n next = 1;\n } else if (length > 1) {\n pre = index === 0 ? values[0] : values[index - 1];\n next = index === length - 1 ? values[length - 1] : values[index + 1];\n\n if (index !== 0) {\n pre += (key - pre) / 2;\n } else {\n pre -= (next - key) / 2;\n }\n\n if (index !== length - 1) {\n next -= (next - key) / 2;\n } else {\n next += (key - values[length - 2]) / 2;\n }\n } else {\n pre = key === 0 ? 0 : key - 0.5;\n next = key === 0 ? 1 : key + 0.5;\n }\n\n return {\n pre: pre,\n next: next\n };\n },\n\n /**\n * 对数据进行分组\n * @param {Array} data 数据\n * @param {String} dim 分组的字段\n * @return {Object} 分组的键值对映射\n */\n groupData: function groupData(data, dim) {\n var groups = {};\n each(data, function (record) {\n var value = record[dim];\n\n if (value === undefined) {\n value = record[dim] = DEFAULT_Y;\n }\n\n if (!groups[value]) {\n groups[value] = [];\n }\n\n groups[value].push(record);\n });\n return groups;\n }\n};\n\n/***/ }),\n/* 8 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar isNil = __webpack_require__(6);\n\nvar isArray = __webpack_require__(1);\n\nvar each = __webpack_require__(0);\n\nmodule.exports = function valuesOfKey(data, name) {\n var rst = [];\n var tmpMap = {};\n\n for (var i = 0; i < data.length; i++) {\n var obj = data[i];\n var value = obj[name];\n\n if (!isNil(value)) {\n if (!isArray(value)) {\n value = [value];\n }\n\n each(value, function (val) {\n if (!tmpMap[val]) {\n rst.push(val);\n tmpMap[val] = true;\n }\n });\n }\n }\n\n return rst;\n};\n\n/***/ }),\n/* 9 */\n/***/ (function(module, exports, __webpack_require__) {\n\n/**\n * 是否为函数\n * @param {*} fn 对象\n * @return {Boolean} 是否函数\n */\nvar isType = __webpack_require__(5);\n\nvar isFunction = function isFunction(value) {\n return isType(value, 'Function');\n};\n\nmodule.exports = isFunction;\n\n/***/ }),\n/* 10 */\n/***/ (function(module, exports, __webpack_require__) {\n\n// 完整版下使用支持按照某个字段进行分组的 dodge\nvar mix = __webpack_require__(3);\n\nvar Adjust = __webpack_require__(2);\n\nvar Dodge = __webpack_require__(11);\n\nvar Stack = __webpack_require__(13);\n\nvar AdjustMixin = __webpack_require__(7);\n\nvar DodgeMixin = __webpack_require__(14);\n\nvar StackMixin = __webpack_require__(18);\n\nmix(Adjust.prototype, AdjustMixin);\nmix(Dodge.prototype, AdjustMixin, DodgeMixin);\nmix(Stack.prototype, StackMixin);\nAdjust.Jitter = __webpack_require__(19);\nAdjust.Symmetric = __webpack_require__(20);\nAdjust.Dodge = Dodge;\nAdjust.Stack = Stack;\nmodule.exports = Adjust;\n\n/***/ }),\n/* 11 */\n/***/ (function(module, exports, __webpack_require__) {\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\nvar Adjust = __webpack_require__(2);\n\nvar each = __webpack_require__(0);\n\nvar MARGIN_RATIO = 1 / 2;\nvar DODGE_RATIO = 1 / 2;\n\nvar Dodge =\n/*#__PURE__*/\nfunction (_Adjust) {\n _inheritsLoose(Dodge, _Adjust);\n\n function Dodge() {\n return _Adjust.apply(this, arguments) || this;\n }\n\n var _proto = Dodge.prototype;\n\n _proto._initDefaultCfg = function _initDefaultCfg() {\n /**\n * 调整过程中,2个数据的间距\n * @type {Number}\n */\n this.marginRatio = MARGIN_RATIO;\n /**\n * 调整占单位宽度的比例,例如:占2个分类间距的 1/2\n * @type {Number}\n */\n\n this.dodgeRatio = DODGE_RATIO;\n this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整\n };\n\n _proto.getDodgeOffset = function getDodgeOffset(range, index, count) {\n var self = this;\n var pre = range.pre;\n var next = range.next;\n var tickLength = next - pre;\n var width = tickLength * self.dodgeRatio / count;\n var margin = self.marginRatio * width;\n var offset = 1 / 2 * (tickLength - count * width - (count - 1) * margin) + ((index + 1) * width + index * margin) - 1 / 2 * width - 1 / 2 * tickLength;\n return (pre + next) / 2 + offset;\n };\n\n _proto.processAdjust = function processAdjust(dataArray) {\n var self = this;\n var count = dataArray.length;\n var xField = self.xField;\n each(dataArray, function (data, index) {\n for (var i = 0, len = data.length; i < len; i++) {\n var obj = data[i];\n var value = obj[xField];\n var range = {\n pre: len === 1 ? value - 1 : value - 0.5,\n next: len === 1 ? value + 1 : value + 0.5\n };\n var dodgeValue = self.getDodgeOffset(range, index, count);\n obj[xField] = dodgeValue;\n }\n });\n };\n\n return Dodge;\n}(Adjust);\n\nAdjust.Dodge = Dodge;\nmodule.exports = Dodge;\n\n/***/ }),\n/* 12 */\n/***/ (function(module, exports) {\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n} : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n};\n\nvar isObject = function isObject(value) {\n /**\n * isObject({}) => true\n * isObject([1, 2, 3]) => true\n * isObject(Function) => true\n * isObject(null) => false\n */\n var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);\n return value !== null && type === 'object' || type === 'function';\n};\n\nmodule.exports = isObject;\n\n/***/ }),\n/* 13 */\n/***/ (function(module, exports, __webpack_require__) {\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\nvar isArray = __webpack_require__(1);\n\nvar isNil = __webpack_require__(6);\n\nvar Adjust = __webpack_require__(2);\n\nvar Stack =\n/*#__PURE__*/\nfunction (_Adjust) {\n _inheritsLoose(Stack, _Adjust);\n\n function Stack() {\n return _Adjust.apply(this, arguments) || this;\n }\n\n var _proto = Stack.prototype;\n\n _proto._initDefaultCfg = function _initDefaultCfg() {\n this.xField = null; // 调整对应的 x 方向对应的字段名称\n\n this.yField = null; // 调整对应的 y 方向对应的字段名称\n };\n\n _proto.processAdjust = function processAdjust(dataArray) {\n this.processStack(dataArray);\n };\n\n _proto.processStack = function processStack(dataArray) {\n var self = this;\n var xField = self.xField;\n var yField = self.yField;\n var count = dataArray.length;\n var stackCache = {\n positive: {},\n negative: {}\n }; // 层叠顺序翻转\n\n if (self.reverseOrder) {\n dataArray = dataArray.slice(0).reverse();\n }\n\n for (var i = 0; i < count; i++) {\n var data = dataArray[i];\n\n for (var j = 0, len = data.length; j < len; j++) {\n var item = data[j];\n var x = item[xField] || 0;\n var y = item[yField];\n var xkey = x.toString();\n y = isArray(y) ? y[1] : y;\n\n if (!isNil(y)) {\n var direction = y >= 0 ? 'positive' : 'negative';\n\n if (!stackCache[direction][xkey]) {\n stackCache[direction][xkey] = 0;\n }\n\n item[yField] = [stackCache[direction][xkey], y + stackCache[direction][xkey]];\n stackCache[direction][xkey] += y;\n }\n }\n }\n };\n\n return Stack;\n}(Adjust);\n\nAdjust.Stack = Stack;\nmodule.exports = Stack;\n\n/***/ }),\n/* 14 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar ArrayUtil = {\n merge: __webpack_require__(4),\n values: __webpack_require__(8)\n};\n\nvar group = __webpack_require__(15);\n\nvar each = __webpack_require__(0);\n\nmodule.exports = {\n /**\n * @protected\n * @override\n */\n processAdjust: function processAdjust(dataArray) {\n var self = this;\n var mergeData = ArrayUtil.merge(dataArray);\n var dodgeDim = self.dodgeBy;\n var adjDataArray = dataArray;\n\n if (dodgeDim) {\n // 如果指定了分组dim的字段\n adjDataArray = group(mergeData, dodgeDim);\n }\n\n self.cacheMap = {};\n self.adjDataArray = adjDataArray;\n self.mergeData = mergeData;\n self.adjustData(adjDataArray, mergeData);\n self.adjDataArray = null;\n self.mergeData = null;\n },\n getDistribution: function getDistribution(dim) {\n var self = this;\n var dataArray = self.adjDataArray;\n var cacheMap = self.cacheMap;\n var map = cacheMap[dim];\n\n if (!map) {\n map = {};\n each(dataArray, function (data, index) {\n var values = ArrayUtil.values(data, dim);\n\n if (!values.length) {\n values.push(0);\n }\n\n each(values, function (val) {\n if (!map[val]) {\n map[val] = [];\n }\n\n map[val].push(index);\n });\n });\n cacheMap[dim] = map;\n }\n\n return map;\n },\n adjustDim: function adjustDim(dim, values, data, frameCount, frameIndex) {\n var self = this;\n var map = self.getDistribution(dim);\n var groupData = self.groupData(data, dim); // 根据值分组\n\n each(groupData, function (group, key) {\n key = parseFloat(key);\n var range;\n\n if (values.length === 1) {\n range = {\n pre: values[0] - 1,\n next: values[0] + 1\n };\n } else {\n range = self.getAdjustRange(dim, key, values);\n }\n\n each(group, function (record) {\n var value = record[dim];\n var valueArr = map[value];\n var valIndex = valueArr.indexOf(frameIndex);\n record[dim] = self.getDodgeOffset(range, valIndex, valueArr.length);\n });\n });\n }\n};\n\n/***/ }),\n/* 15 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar groupToMap = __webpack_require__(16);\n\nvar group = function group(data, condition) {\n if (!condition) {\n return [data];\n }\n\n var groups = groupToMap(data, condition);\n var array = [];\n\n for (var i in groups) {\n array.push(groups[i]);\n }\n\n return array;\n};\n\nmodule.exports = group;\n\n/***/ }),\n/* 16 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar isFunction = __webpack_require__(9);\n\nvar isArray = __webpack_require__(1);\n\nvar groupBy = __webpack_require__(17);\n\nvar groupToMap = function groupToMap(data, condition) {\n if (!condition) {\n return {\n 0: data\n };\n }\n\n if (!isFunction(condition)) {\n var paramsCondition = isArray(condition) ? condition : condition.replace(/\\s+/g, '').split('*');\n\n condition = function condition(row) {\n var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序\n\n for (var i = 0, l = paramsCondition.length; i < l; i++) {\n unique += row[paramsCondition[i]] && row[paramsCondition[i]].toString();\n }\n\n return unique;\n };\n }\n\n var groups = groupBy(data, condition);\n return groups;\n};\n\nmodule.exports = groupToMap;\n\n/***/ }),\n/* 17 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar each = __webpack_require__(0);\n\nvar isArray = __webpack_require__(1);\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar groupBy = function groupBy(data, condition) {\n if (!condition || !isArray(data)) {\n return data;\n }\n\n var result = {};\n var key = null;\n each(data, function (item) {\n key = condition(item);\n\n if (hasOwnProperty.call(result, key)) {\n result[key].push(item);\n } else {\n result[key] = [item];\n }\n });\n return result;\n};\n\nmodule.exports = groupBy;\n\n/***/ }),\n/* 18 */\n/***/ (function(module, exports) {\n\nmodule.exports = {\n _initDefaultCfg: function _initDefaultCfg() {\n this.xField = null; // 调整对应的 x 方向对应的字段名称\n\n this.yField = null; // 调整对应的 y 方向对应的字段名称\n\n this.height = null; // 仅有一个维度调整时,总的高度\n\n this.size = 10; // 单个点的大小\n\n this.reverseOrder = false; // 是否反序进行层叠\n\n this.adjustNames = ['y']; // Only support stack y\n },\n processOneDimStack: function processOneDimStack(dataArray) {\n var self = this;\n var xField = self.xField;\n var yField = self.yField || 'y';\n var height = self.height;\n var stackY = {}; // 如果层叠的顺序翻转\n\n if (self.reverseOrder) {\n dataArray = dataArray.slice(0).reverse();\n }\n\n for (var i = 0, len = dataArray.length; i < len; i++) {\n var data = dataArray[i]; // cates\n\n for (var j = 0, dataLen = data.length; j < dataLen; j++) {\n var item = data[j];\n var size = item.size || self.size;\n var stackHeight = size * 2 / height;\n var x = item[xField];\n\n if (!stackY[x]) {\n stackY[x] = stackHeight / 2;\n }\n\n item[yField] = stackY[x];\n stackY[x] += stackHeight;\n }\n }\n },\n processAdjust: function processAdjust(dataArray) {\n if (this.yField) {\n this.processStack(dataArray);\n } else {\n this.processOneDimStack(dataArray);\n }\n }\n};\n\n/***/ }),\n/* 19 */\n/***/ (function(module, exports, __webpack_require__) {\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\nvar each = __webpack_require__(0);\n\nvar mix = __webpack_require__(3);\n\nvar ArrayUtil = {\n merge: __webpack_require__(4)\n};\n\nvar Adjust = __webpack_require__(2);\n\nvar AdjustMixin = __webpack_require__(7);\n\nvar Jitter =\n/*#__PURE__*/\nfunction (_Adjust) {\n _inheritsLoose(Jitter, _Adjust);\n\n function Jitter() {\n return _Adjust.apply(this, arguments) || this;\n }\n\n var _proto = Jitter.prototype;\n\n _proto._initDefaultCfg = function _initDefaultCfg() {\n this.xField = null; // 调整对应的 x 方向对应的字段名称\n\n this.yField = null; // 调整对应的 y 方向对应的字段名称\n\n this.adjustNames = ['x', 'y']; // 指x,y\n\n this.groupFields = null; // 参与分组的数据维度\n };\n\n _proto.processAdjust = function processAdjust(dataArray) {\n var self = this;\n var mergeData = ArrayUtil.merge(dataArray);\n self.adjDataArray = dataArray;\n self.mergeData = mergeData;\n self.adjustData(dataArray, mergeData);\n self.adjFrames = null;\n self.mergeData = null;\n };\n\n _proto.getAdjustOffset = function getAdjustOffset(pre, next) {\n var r = Math.random(); // 随机位置,均匀分布\n\n var avg = next - pre; // * length\n\n var append = avg * 0.05;\n return pre + append + avg * 0.9 * r;\n }; // adjust group data\n\n\n _proto._adjustGroup = function _adjustGroup(group, dim, key, values) {\n var self = this;\n var range = self.getAdjustRange(dim, key, values);\n each(group, function (record) {\n record[dim] = self.getAdjustOffset(range.pre, range.next); // 获取调整的位置\n });\n };\n\n _proto.adjustDim = function adjustDim(dim, values, data) {\n var self = this;\n var groupData = self.groupData(data, dim);\n each(groupData, function (group, key) {\n key = parseFloat(key);\n\n self._adjustGroup(group, dim, key, values);\n });\n };\n\n return Jitter;\n}(Adjust);\n\nmix(Jitter.prototype, AdjustMixin);\nAdjust.Jitter = Jitter;\nmodule.exports = Jitter;\n\n/***/ }),\n/* 20 */\n/***/ (function(module, exports, __webpack_require__) {\n\nfunction _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }\n\nvar each = __webpack_require__(0);\n\nvar maxBy = __webpack_require__(21);\n\nvar isArray = __webpack_require__(1);\n\nvar ArrayUtil = {\n merge: __webpack_require__(4)\n};\n\nvar Adjust = __webpack_require__(2);\n\nvar Symmetric =\n/*#__PURE__*/\nfunction (_Adjust) {\n _inheritsLoose(Symmetric, _Adjust);\n\n function Symmetric() {\n return _Adjust.apply(this, arguments) || this;\n }\n\n var _proto = Symmetric.prototype;\n\n _proto._initDefaultCfg = function _initDefaultCfg() {\n this.xField = null; // 调整对应的 x 方向对应的字段名称\n\n this.yField = null; // 调整对应的 y 方向对应的字段名称\n\n this.cacheMax = null; // 缓存的最大值\n\n this.adjustNames = ['y']; // Only support stack y\n\n this.groupFields = null; // 参与分组的数据维度\n }; // 获取最大的y值\n\n\n _proto._getMax = function _getMax(dim) {\n var self = this;\n var mergeData = self.mergeData;\n var maxRecord = maxBy(mergeData, function (obj) {\n var value = obj[dim];\n\n if (isArray(value)) {\n return Math.max.apply(null, value);\n }\n\n return value;\n });\n var maxValue = maxRecord[dim];\n var max = isArray(maxValue) ? Math.max.apply(null, maxValue) : maxValue;\n return max;\n }; // 获取每个字段最大的值\n\n\n _proto._getXValuesMax = function _getXValuesMax() {\n var self = this;\n var yField = self.yField;\n var xField = self.xField;\n var cache = {};\n var mergeData = self.mergeData;\n each(mergeData, function (obj) {\n var xValue = obj[xField];\n var yValue = obj[yField];\n var max = isArray(yValue) ? Math.max.apply(null, yValue) : yValue;\n cache[xValue] = cache[xValue] || 0;\n\n if (cache[xValue] < max) {\n cache[xValue] = max;\n }\n });\n return cache;\n }; // 入口函数\n\n\n _proto.processAdjust = function processAdjust(dataArray) {\n var self = this;\n var mergeData = ArrayUtil.merge(dataArray);\n self.mergeData = mergeData;\n\n self._processSymmetric(dataArray);\n\n self.mergeData = null;\n }; // 处理对称\n\n\n _proto._processSymmetric = function _processSymmetric(dataArray) {\n var self = this;\n var xField = self.xField;\n var yField = self.yField;\n\n var max = self._getMax(yField);\n\n var first = dataArray[0][0];\n var cache;\n\n if (first && isArray(first[yField])) {\n cache = self._getXValuesMax();\n }\n\n each(dataArray, function (data) {\n each(data, function (obj) {\n var value = obj[yField];\n var offset;\n\n if (isArray(value)) {\n var xValue = obj[xField];\n var valueMax = cache[xValue];\n offset = (max - valueMax) / 2;\n var tmp = [];\n /* eslint-disable no-loop-func */\n\n each(value, function (subVal) {\n // 多个字段\n tmp.push(offset + subVal);\n });\n /* eslint-enable no-loop-func */\n\n obj[yField] = tmp;\n } else {\n offset = (max - value) / 2;\n obj[yField] = [offset, value + offset];\n }\n });\n });\n };\n\n return Symmetric;\n}(Adjust);\n\nAdjust.Symmetric = Symmetric;\nmodule.exports = Symmetric;\n\n/***/ }),\n/* 21 */\n/***/ (function(module, exports, __webpack_require__) {\n\nvar isArray = __webpack_require__(1);\n\nvar isFunction = __webpack_require__(9);\n\nvar each = __webpack_require__(0);\n/**\n * @param {Array} arr The array to iterate over.\n * @param {Function} [fn] The iteratee invoked per element.\n * @return {*} Returns the maximum value.\n * @example\n *\n * var objects = [{ 'n': 1 }, { 'n': 2 }];\n *\n * maxBy(objects, function(o) { return o.n; });\n * // => { 'n': 2 }\n *\n * maxBy(objects, 'n');\n * // => { 'n': 2 }\n */\n\n\nvar maxBy = function maxBy(arr, fn) {\n if (!isArray(arr)) {\n return undefined;\n }\n\n var max = arr[0];\n var maxData = void 0;\n\n if (isFunction(fn)) {\n maxData = fn(arr[0]);\n } else {\n maxData = arr[0][fn];\n }\n\n var data = void 0;\n each(arr, function (val) {\n if (isFunction(fn)) {\n data = fn(val);\n } else {\n data = val[fn];\n }\n\n if (data > maxData) {\n max = val;\n maxData = data;\n }\n });\n return max;\n};\n\nmodule.exports = maxBy;\n\n/***/ })\n/******/ ]);\n});\n//# sourceMappingURL=adjust.js.map"]}