@antv/adjust
Advanced tools
Comparing version 0.0.6 to 0.0.7
module.exports = { | ||
babelrc: { | ||
presets: [ | ||
'env' | ||
'@babel/preset-env' | ||
], | ||
@@ -6,0 +6,0 @@ sourceMaps: 'inline' |
@@ -81,2 +81,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var isObject = __webpack_require__(12); | ||
var isArray = __webpack_require__(1); | ||
@@ -88,6 +89,9 @@ | ||
} | ||
var rst = void 0; | ||
if (isArray(elements)) { | ||
for (var i = 0, len = elements.length; i < len; i++) { | ||
rst = func(elements[i], i); | ||
if (rst === false) { | ||
@@ -101,2 +105,3 @@ break; | ||
rst = func(elements[k], k); | ||
if (rst === false) { | ||
@@ -116,3 +121,3 @@ break; | ||
var isType = __webpack_require__(6); | ||
var isType = __webpack_require__(5); | ||
@@ -122,3 +127,2 @@ var isArray = Array.isArray ? Array.isArray : function (value) { | ||
}; | ||
module.exports = isArray; | ||
@@ -130,8 +134,10 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var mix = __webpack_require__(3); | ||
var mix = __webpack_require__(4); | ||
var Adjust = | ||
/*#__PURE__*/ | ||
function () { | ||
var _proto = Adjust.prototype; | ||
var Adjust = function () { | ||
Adjust.prototype._initDefaultCfg = function _initDefaultCfg() { | ||
_proto._initDefaultCfg = function _initDefaultCfg() { | ||
this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整 | ||
@@ -141,8 +147,6 @@ }; | ||
function Adjust(cfg) { | ||
_classCallCheck(this, Adjust); | ||
this._initDefaultCfg(); | ||
this._initDefaultCfg(); | ||
mix(this, cfg); | ||
} | ||
/** | ||
@@ -153,3 +157,5 @@ * @override | ||
Adjust.prototype.processAdjust = function processAdjust() /* dataArray */{}; | ||
_proto.processAdjust = function processAdjust() | ||
/* dataArray */ | ||
{}; | ||
@@ -163,33 +169,2 @@ return Adjust; | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var each = __webpack_require__(0); | ||
var isNil = __webpack_require__(7); | ||
var isArray = __webpack_require__(1); | ||
var 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 (!isNil(value)) { | ||
if (!isArray(value)) { | ||
value = [value]; | ||
} | ||
each(value, function (val) { | ||
if (!tmpMap[val]) { | ||
rst.push(val); | ||
tmpMap[val] = true; | ||
} | ||
}); | ||
} | ||
} | ||
return rst; | ||
}; | ||
module.exports = values; | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports) { | ||
@@ -215,3 +190,3 @@ | ||
/***/ }), | ||
/* 5 */ | ||
/* 4 */ | ||
/***/ (function(module, exports) { | ||
@@ -221,5 +196,7 @@ | ||
var rst = []; | ||
for (var i = 0; i < dataArray.length; i++) { | ||
rst = rst.concat(dataArray[i]); | ||
} | ||
return rst; | ||
@@ -231,6 +208,7 @@ }; | ||
/***/ }), | ||
/* 6 */ | ||
/* 5 */ | ||
/***/ (function(module, exports) { | ||
var toString = {}.toString; | ||
var isType = function isType(value, type) { | ||
@@ -243,3 +221,3 @@ return toString.call(value) === '[object ' + type + ']'; | ||
/***/ }), | ||
/* 7 */ | ||
/* 6 */ | ||
/***/ (function(module, exports) { | ||
@@ -259,9 +237,11 @@ | ||
/***/ }), | ||
/* 8 */ | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var DEFAULT_Y = 0; // 默认的y的值 | ||
var each = __webpack_require__(0); | ||
var ArrayUtil = { | ||
values: __webpack_require__(3) | ||
values: __webpack_require__(8) | ||
}; | ||
@@ -289,8 +269,11 @@ module.exports = { | ||
var dims = []; | ||
if (self.xField && self.isAdjust('x')) { | ||
dims.push(self.xField); | ||
} | ||
if (self.yField && self.isAdjust('y')) { | ||
dims.push(self.yField); | ||
} | ||
each(dims, function (dim) { | ||
@@ -303,2 +286,3 @@ var values = ArrayUtil.values(mergeData, dim); | ||
}); | ||
if (!self.yField && self.isAdjust('y')) { | ||
@@ -308,4 +292,6 @@ // 只有一维的情况下,同时调整y | ||
var values = [DEFAULT_Y, 1]; // 默认分布在y轴的 0.1 与 0.2 之间 | ||
valuesMap[dim] = values; | ||
} | ||
return valuesMap; | ||
@@ -315,3 +301,5 @@ }, | ||
var self = this; | ||
var valuesMap = self._getDimValues(mergeData); | ||
each(dataArray, function (data, index) { | ||
@@ -329,4 +317,5 @@ // 遍历所有数据集合 | ||
var length = values.length; | ||
var pre = void 0; | ||
var next = void 0; | ||
var pre; | ||
var next; | ||
if (!self.yField && self.isAdjust('y')) { | ||
@@ -344,2 +333,3 @@ pre = 0; | ||
} | ||
if (index !== length - 1) { | ||
@@ -369,14 +359,15 @@ next -= (next - key) / 2; | ||
var groups = {}; | ||
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; | ||
@@ -387,2 +378,37 @@ } | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNil = __webpack_require__(6); | ||
var isArray = __webpack_require__(1); | ||
var each = __webpack_require__(0); | ||
module.exports = function valuesOfKey(data, name) { | ||
var rst = []; | ||
var tmpMap = {}; | ||
for (var i = 0; i < data.length; i++) { | ||
var obj = data[i]; | ||
var value = obj[name]; | ||
if (!isNil(value)) { | ||
if (!isArray(value)) { | ||
value = [value]; | ||
} | ||
each(value, function (val) { | ||
if (!tmpMap[val]) { | ||
rst.push(val); | ||
tmpMap[val] = true; | ||
} | ||
}); | ||
} | ||
} | ||
return rst; | ||
}; | ||
/***/ }), | ||
/* 9 */ | ||
@@ -396,3 +422,3 @@ /***/ (function(module, exports, __webpack_require__) { | ||
*/ | ||
var isType = __webpack_require__(6); | ||
var isType = __webpack_require__(5); | ||
@@ -410,13 +436,19 @@ var isFunction = function isFunction(value) { | ||
// 完整版下使用支持按照某个字段进行分组的 dodge | ||
var mix = __webpack_require__(4); | ||
var mix = __webpack_require__(3); | ||
var Adjust = __webpack_require__(2); | ||
var Dodge = __webpack_require__(11); | ||
var Stack = __webpack_require__(13); | ||
var AdjustMixin = __webpack_require__(8); | ||
var AdjustMixin = __webpack_require__(7); | ||
var DodgeMixin = __webpack_require__(14); | ||
var StackMixin = __webpack_require__(18); | ||
mix(Adjust.prototype, AdjustMixin); | ||
mix(Dodge.prototype, AdjustMixin, DodgeMixin); | ||
mix(Stack.prototype, StackMixin); | ||
Adjust.Jitter = __webpack_require__(19); | ||
@@ -426,3 +458,2 @@ Adjust.Symmetric = __webpack_require__(20); | ||
Adjust.Stack = Stack; | ||
module.exports = Adjust; | ||
@@ -434,9 +465,6 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
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; } | ||
var Adjust = __webpack_require__(2); | ||
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 Adjust = __webpack_require__(2); | ||
var each = __webpack_require__(0); | ||
@@ -447,12 +475,14 @@ | ||
var Dodge = function (_Adjust) { | ||
_inherits(Dodge, _Adjust); | ||
var Dodge = | ||
/*#__PURE__*/ | ||
function (_Adjust) { | ||
_inheritsLoose(Dodge, _Adjust); | ||
function Dodge() { | ||
_classCallCheck(this, Dodge); | ||
return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); | ||
return _Adjust.apply(this, arguments) || this; | ||
} | ||
Dodge.prototype._initDefaultCfg = function _initDefaultCfg() { | ||
var _proto = Dodge.prototype; | ||
_proto._initDefaultCfg = function _initDefaultCfg() { | ||
/** | ||
@@ -467,2 +497,3 @@ * 调整过程中,2个数据的间距 | ||
*/ | ||
this.dodgeRatio = DODGE_RATIO; | ||
@@ -472,3 +503,3 @@ this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整 | ||
Dodge.prototype.getDodgeOffset = function getDodgeOffset(range, index, count) { | ||
_proto.getDodgeOffset = function getDodgeOffset(range, index, count) { | ||
var self = this; | ||
@@ -484,3 +515,3 @@ var pre = range.pre; | ||
Dodge.prototype.processAdjust = function processAdjust(dataArray) { | ||
_proto.processAdjust = function processAdjust(dataArray) { | ||
var self = this; | ||
@@ -513,8 +544,6 @@ var count = dataArray.length; | ||
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; }; | ||
var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { | ||
return typeof obj === "undefined" ? "undefined" : _typeof2(obj); | ||
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 === "undefined" ? "undefined" : _typeof2(obj); | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
@@ -539,31 +568,32 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
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; } | ||
var isArray = __webpack_require__(1); | ||
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 isNil = __webpack_require__(6); | ||
var isArray = __webpack_require__(1); | ||
var isNil = __webpack_require__(7); | ||
var Adjust = __webpack_require__(2); | ||
var Stack = function (_Adjust) { | ||
_inherits(Stack, _Adjust); | ||
var Stack = | ||
/*#__PURE__*/ | ||
function (_Adjust) { | ||
_inheritsLoose(Stack, _Adjust); | ||
function Stack() { | ||
_classCallCheck(this, Stack); | ||
return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); | ||
return _Adjust.apply(this, arguments) || this; | ||
} | ||
Stack.prototype._initDefaultCfg = function _initDefaultCfg() { | ||
var _proto = Stack.prototype; | ||
_proto._initDefaultCfg = function _initDefaultCfg() { | ||
this.xField = null; // 调整对应的 x 方向对应的字段名称 | ||
this.yField = null; // 调整对应的 y 方向对应的字段名称 | ||
}; | ||
Stack.prototype.processAdjust = function processAdjust(dataArray) { | ||
_proto.processAdjust = function processAdjust(dataArray) { | ||
this.processStack(dataArray); | ||
}; | ||
Stack.prototype.processStack = function processStack(dataArray) { | ||
_proto.processStack = function processStack(dataArray) { | ||
var self = this; | ||
@@ -576,9 +606,11 @@ var xField = self.xField; | ||
negative: {} | ||
}; | ||
// 层叠顺序翻转 | ||
}; // 层叠顺序翻转 | ||
if (self.reverseOrder) { | ||
dataArray = dataArray.slice(0).reverse(); | ||
} | ||
for (var i = 0; i < count; i++) { | ||
var data = dataArray[i]; | ||
for (var j = 0, len = data.length; j < len; j++) { | ||
@@ -590,7 +622,10 @@ var item = data[j]; | ||
y = isArray(y) ? y[1] : y; | ||
if (!isNil(y)) { | ||
var direction = y >= 0 ? 'positive' : 'negative'; | ||
if (!stackCache[direction][xkey]) { | ||
stackCache[direction][xkey] = 0; | ||
} | ||
item[yField] = [stackCache[direction][xkey], y + stackCache[direction][xkey]]; | ||
@@ -614,7 +649,8 @@ stackCache[direction][xkey] += y; | ||
var ArrayUtil = { | ||
merge: __webpack_require__(5), | ||
values: __webpack_require__(3) | ||
merge: __webpack_require__(4), | ||
values: __webpack_require__(8) | ||
}; | ||
var group = __webpack_require__(15); | ||
var each = __webpack_require__(0); | ||
@@ -632,2 +668,3 @@ | ||
var adjDataArray = dataArray; | ||
if (dodgeDim) { | ||
@@ -637,2 +674,3 @@ // 如果指定了分组dim的字段 | ||
} | ||
self.cacheMap = {}; | ||
@@ -642,3 +680,2 @@ self.adjDataArray = adjDataArray; | ||
self.adjustData(adjDataArray, mergeData); | ||
self.adjDataArray = null; | ||
@@ -652,2 +689,3 @@ self.mergeData = null; | ||
var map = cacheMap[dim]; | ||
if (!map) { | ||
@@ -657,5 +695,7 @@ map = {}; | ||
var values = ArrayUtil.values(data, dim); | ||
if (!values.length) { | ||
values.push(0); | ||
} | ||
each(values, function (val) { | ||
@@ -665,2 +705,3 @@ if (!map[val]) { | ||
} | ||
map[val].push(index); | ||
@@ -681,3 +722,4 @@ }); | ||
key = parseFloat(key); | ||
var range = void 0; | ||
var range; | ||
if (values.length === 1) { | ||
@@ -691,2 +733,3 @@ range = { | ||
} | ||
each(group, function (record) { | ||
@@ -712,7 +755,10 @@ var value = record[dim]; | ||
} | ||
var groups = groupToMap(data, condition); | ||
var array = []; | ||
for (var i in groups) { | ||
array.push(groups[i]); | ||
} | ||
return array; | ||
@@ -728,3 +774,5 @@ }; | ||
var isFunction = __webpack_require__(9); | ||
var isArray = __webpack_require__(1); | ||
var groupBy = __webpack_require__(17); | ||
@@ -738,12 +786,17 @@ | ||
} | ||
if (!isFunction(condition)) { | ||
var paramsCondition = 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 = groupBy(data, condition); | ||
@@ -760,4 +813,7 @@ return groups; | ||
var each = __webpack_require__(0); | ||
var isArray = __webpack_require__(1); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
var groupBy = function groupBy(data, condition) { | ||
@@ -767,2 +823,3 @@ if (!condition || !isArray(data)) { | ||
} | ||
var result = {}; | ||
@@ -772,2 +829,3 @@ var key = null; | ||
key = condition(item); | ||
if (hasOwnProperty.call(result, key)) { | ||
@@ -791,6 +849,11 @@ result[key].push(item); | ||
this.xField = null; // 调整对应的 x 方向对应的字段名称 | ||
this.yField = null; // 调整对应的 y 方向对应的字段名称 | ||
this.height = null; // 仅有一个维度调整时,总的高度 | ||
this.size = 10; // 单个点的大小 | ||
this.reverseOrder = false; // 是否反序进行层叠 | ||
this.adjustNames = ['y']; // Only support stack y | ||
@@ -803,11 +866,11 @@ }, | ||
var height = self.height; | ||
var stackY = {}; // 如果层叠的顺序翻转 | ||
var stackY = {}; | ||
// 如果层叠的顺序翻转 | ||
if (self.reverseOrder) { | ||
dataArray = dataArray.slice(0).reverse(); | ||
} | ||
for (var i = 0, len = dataArray.length; i < len; i++) { | ||
var data = dataArray[i]; | ||
// cates | ||
var data = dataArray[i]; // cates | ||
for (var j = 0, dataLen = data.length; j < dataLen; j++) { | ||
@@ -818,5 +881,7 @@ var item = data[j]; | ||
var x = item[xField]; | ||
if (!stackY[x]) { | ||
stackY[x] = stackHeight / 2; | ||
} | ||
item[yField] = stackY[x]; | ||
@@ -840,38 +905,40 @@ stackY[x] += stackHeight; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
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; } | ||
var each = __webpack_require__(0); | ||
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 mix = __webpack_require__(3); | ||
var each = __webpack_require__(0); | ||
var mix = __webpack_require__(4); | ||
var ArrayUtil = { | ||
merge: __webpack_require__(5), | ||
values: __webpack_require__(3) | ||
merge: __webpack_require__(4) | ||
}; | ||
var Adjust = __webpack_require__(2); | ||
var AdjustMixin = __webpack_require__(8); | ||
var Jitter = function (_Adjust) { | ||
_inherits(Jitter, _Adjust); | ||
var AdjustMixin = __webpack_require__(7); | ||
var Jitter = | ||
/*#__PURE__*/ | ||
function (_Adjust) { | ||
_inheritsLoose(Jitter, _Adjust); | ||
function Jitter() { | ||
_classCallCheck(this, Jitter); | ||
return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); | ||
return _Adjust.apply(this, arguments) || this; | ||
} | ||
Jitter.prototype._initDefaultCfg = function _initDefaultCfg() { | ||
var _proto = Jitter.prototype; | ||
_proto._initDefaultCfg = function _initDefaultCfg() { | ||
this.xField = null; // 调整对应的 x 方向对应的字段名称 | ||
this.yField = null; // 调整对应的 y 方向对应的字段名称 | ||
this.adjustNames = ['x', 'y']; // 指x,y | ||
this.groupFields = null; // 参与分组的数据维度 | ||
}; | ||
Jitter.prototype.processAdjust = function processAdjust(dataArray) { | ||
_proto.processAdjust = function processAdjust(dataArray) { | ||
var self = this; | ||
var mergeData = ArrayUtil.merge(dataArray); | ||
self.adjDataArray = dataArray; | ||
@@ -884,16 +951,15 @@ self.mergeData = mergeData; | ||
Jitter.prototype.getAdjustOffset = function getAdjustOffset(pre, next) { | ||
_proto.getAdjustOffset = function getAdjustOffset(pre, next) { | ||
var r = Math.random(); // 随机位置,均匀分布 | ||
var avg = next - pre; // * length | ||
var append = avg * 0.05; | ||
return pre + append + avg * 0.9 * r; | ||
}; | ||
}; // adjust group data | ||
// adjust group data | ||
Jitter.prototype._adjustGroup = function _adjustGroup(group, dim, key, values) { | ||
_proto._adjustGroup = function _adjustGroup(group, dim, key, values) { | ||
var self = this; | ||
var range = self.getAdjustRange(dim, key, values); | ||
each(group, function (record) { | ||
@@ -904,3 +970,3 @@ record[dim] = self.getAdjustOffset(range.pre, range.next); // 获取调整的位置 | ||
Jitter.prototype.adjustDim = function adjustDim(dim, values, data) { | ||
_proto.adjustDim = function adjustDim(dim, values, data) { | ||
var self = this; | ||
@@ -910,2 +976,3 @@ var groupData = self.groupData(data, dim); | ||
key = parseFloat(key); | ||
self._adjustGroup(group, dim, key, values); | ||
@@ -919,3 +986,2 @@ }); | ||
mix(Jitter.prototype, AdjustMixin); | ||
Adjust.Jitter = Jitter; | ||
@@ -928,38 +994,41 @@ module.exports = Jitter; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
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; } | ||
var each = __webpack_require__(0); | ||
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 maxBy = __webpack_require__(21); | ||
var each = __webpack_require__(0); | ||
var maxBy = __webpack_require__(21); | ||
var isArray = __webpack_require__(1); | ||
var ArrayUtil = { | ||
merge: __webpack_require__(5), | ||
values: __webpack_require__(3) | ||
merge: __webpack_require__(4) | ||
}; | ||
var Adjust = __webpack_require__(2); | ||
var Symmetric = function (_Adjust) { | ||
_inherits(Symmetric, _Adjust); | ||
var Symmetric = | ||
/*#__PURE__*/ | ||
function (_Adjust) { | ||
_inheritsLoose(Symmetric, _Adjust); | ||
function Symmetric() { | ||
_classCallCheck(this, Symmetric); | ||
return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); | ||
return _Adjust.apply(this, arguments) || this; | ||
} | ||
Symmetric.prototype._initDefaultCfg = function _initDefaultCfg() { | ||
var _proto = Symmetric.prototype; | ||
_proto._initDefaultCfg = function _initDefaultCfg() { | ||
this.xField = null; // 调整对应的 x 方向对应的字段名称 | ||
this.yField = null; // 调整对应的 y 方向对应的字段名称 | ||
this.cacheMax = null; // 缓存的最大值 | ||
this.adjustNames = ['y']; // Only support stack y | ||
this.groupFields = null; // 参与分组的数据维度 | ||
}; | ||
}; // 获取最大的y值 | ||
// 获取最大的y值 | ||
Symmetric.prototype._getMax = function _getMax(dim) { | ||
_proto._getMax = function _getMax(dim) { | ||
var self = this; | ||
@@ -969,5 +1038,7 @@ var mergeData = self.mergeData; | ||
var value = obj[dim]; | ||
if (isArray(value)) { | ||
return Math.max.apply(null, value); | ||
} | ||
return value; | ||
@@ -978,8 +1049,6 @@ }); | ||
return max; | ||
}; | ||
}; // 获取每个字段最大的值 | ||
// 获取每个字段最大的值 | ||
Symmetric.prototype._getXValuesMax = function _getXValuesMax() { | ||
_proto._getXValuesMax = function _getXValuesMax() { | ||
var self = this; | ||
@@ -995,2 +1064,3 @@ var yField = self.yField; | ||
cache[xValue] = cache[xValue] || 0; | ||
if (cache[xValue] < max) { | ||
@@ -1001,33 +1071,35 @@ cache[xValue] = max; | ||
return cache; | ||
}; | ||
}; // 入口函数 | ||
// 入口函数 | ||
Symmetric.prototype.processAdjust = function processAdjust(dataArray) { | ||
_proto.processAdjust = function processAdjust(dataArray) { | ||
var self = this; | ||
var mergeData = ArrayUtil.merge(dataArray); | ||
self.mergeData = mergeData; | ||
self._processSymmetric(dataArray); | ||
self.mergeData = null; | ||
}; | ||
}; // 处理对称 | ||
// 处理对称 | ||
Symmetric.prototype._processSymmetric = function _processSymmetric(dataArray) { | ||
_proto._processSymmetric = function _processSymmetric(dataArray) { | ||
var self = this; | ||
var xField = self.xField; | ||
var yField = self.yField; | ||
var max = self._getMax(yField); | ||
var first = dataArray[0][0]; | ||
var cache; | ||
var cache = void 0; | ||
if (first && isArray(first[yField])) { | ||
cache = self._getXValuesMax(); | ||
} | ||
each(dataArray, function (data) { | ||
each(data, function (obj) { | ||
var value = obj[yField]; | ||
var offset = void 0; | ||
var offset; | ||
if (isArray(value)) { | ||
@@ -1039,2 +1111,3 @@ var xValue = obj[xField]; | ||
/* eslint-disable no-loop-func */ | ||
each(value, function (subVal) { | ||
@@ -1045,2 +1118,3 @@ // 多个字段 | ||
/* eslint-enable no-loop-func */ | ||
obj[yField] = tmp; | ||
@@ -1066,3 +1140,5 @@ } else { | ||
var isArray = __webpack_require__(1); | ||
var isFunction = __webpack_require__(9); | ||
var each = __webpack_require__(0); | ||
@@ -1083,2 +1159,4 @@ /** | ||
*/ | ||
var maxBy = function maxBy(arr, fn) { | ||
@@ -1088,4 +1166,6 @@ if (!isArray(arr)) { | ||
} | ||
var max = arr[0]; | ||
var maxData = void 0; | ||
if (isFunction(fn)) { | ||
@@ -1096,2 +1176,3 @@ maxData = fn(arr[0]); | ||
} | ||
var data = void 0; | ||
@@ -1104,2 +1185,3 @@ each(arr, function (val) { | ||
} | ||
if (data > maxData) { | ||
@@ -1106,0 +1188,0 @@ max = val; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.adjust=e():t.adjust=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=10)}([function(t,e,n){var r=n(12),o=n(1);t.exports=function(t,e){if(t)if(o(t))for(var n=0,i=t.length;n<i&&!1!==e(t[n],n);n++);else if(r(t))for(var u in t)if(t.hasOwnProperty(u)&&!1===e(t[u],u))break}},function(t,e,n){var r=n(6),o=Array.isArray?Array.isArray:function(t){return r(t,"Array")};t.exports=o},function(t,e,n){var r=n(4),o=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._initDefaultCfg(),r(this,e)}return t.prototype._initDefaultCfg=function(){this.adjustNames=["x","y"]},t.prototype.processAdjust=function(){},t}();t.exports=o},function(t,e,n){var r=n(0),o=n(7),i=n(1);t.exports=function(t,e){for(var n=[],u={},s=0;s<t.length;s++){var a=t[s][e];o(a)||(i(a)||(a=[a]),r(a,function(t){u[t]||(n.push(t),u[t]=!0)}))}return n}},function(t,e){function n(t,e){for(var n in e)e.hasOwnProperty(n)&&"constructor"!==n&&void 0!==e[n]&&(t[n]=e[n])}t.exports=function(t,e,r,o){return e&&n(t,e),r&&n(t,r),o&&n(t,o),t}},function(t,e){t.exports=function(t){for(var e=[],n=0;n<t.length;n++)e=e.concat(t[n]);return e}},function(t,e){var n={}.toString;t.exports=function(t,e){return n.call(t)==="[object "+e+"]"}},function(t,e){t.exports=function(t){return null===t||void 0===t}},function(t,e,n){var r=n(0),o={values:n(3)};t.exports={isAdjust:function(t){return this.adjustNames.indexOf(t)>=0},_getDimValues:function(t){var e={},n=[];if(this.xField&&this.isAdjust("x")&&n.push(this.xField),this.yField&&this.isAdjust("y")&&n.push(this.yField),r(n,function(n){var r=o.values(t,n);r.sort(function(t,e){return t-e}),e[n]=r}),!this.yField&&this.isAdjust("y")){var i=[0,1];e.y=i}return e},adjustData:function(t,e){var n=this,o=n._getDimValues(e);r(t,function(e,i){r(o,function(r,o){n.adjustDim(o,r,e,t.length,i)})})},getAdjustRange:function(t,e,n){var r=n.indexOf(e),o=n.length,i=void 0,u=void 0;return!this.yField&&this.isAdjust("y")?(i=0,u=1):o>1?(i=0===r?n[0]:n[r-1],u=r===o-1?n[o-1]:n[r+1],0!==r?i+=(e-i)/2:i-=(u-e)/2,r!==o-1?u-=(u-e)/2:u+=(e-n[o-2])/2):(i=0===e?0:e-.5,u=0===e?1:e+.5),{pre:i,next:u}},groupData:function(t,e){var n={};return r(t,function(t){var r=t[e];void 0===r&&(r=t[e]=0),n[r]||(n[r]=[]),n[r].push(t)}),n}}},function(t,e,n){var r=n(6);t.exports=function(t){return r(t,"Function")}},function(t,e,n){var r=n(4),o=n(2),i=n(11),u=n(13),s=n(8),a=n(14),f=n(18);r(o.prototype,s),r(i.prototype,s,a),r(u.prototype,f),o.Jitter=n(19),o.Symmetric=n(20),o.Dodge=i,o.Stack=u,t.exports=o},function(t,e,n){var r=n(2),o=n(0),i=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype._initDefaultCfg=function(){this.marginRatio=.5,this.dodgeRatio=.5,this.adjustNames=["x","y"]},e.prototype.getDodgeOffset=function(t,e,n){var r=t.pre,o=t.next,i=o-r,u=i*this.dodgeRatio/n,s=this.marginRatio*u;return(r+o)/2+(.5*(i-n*u-(n-1)*s)+((e+1)*u+e*s)-.5*u-.5*i)},e.prototype.processAdjust=function(t){var e=this,n=t.length,r=e.xField;o(t,function(t,o){for(var i=0,u=t.length;i<u;i++){var s=t[i],a=s[r],f={pre:a-.5,next:a+.5},c=e.getDodgeOffset(f,o,n);s[r]=c}})},e}(r);r.Dodge=i,t.exports=i},function(t,e){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(t){return void 0===t?"undefined":n(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":void 0===t?"undefined":n(t)};t.exports=function(t){var e=void 0===t?"undefined":r(t);return null!==t&&"object"===e||"function"===e}},function(t,e,n){var r=n(1),o=n(7),i=n(2),u=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype._initDefaultCfg=function(){this.xField=null,this.yField=null},e.prototype.processAdjust=function(t){this.processStack(t)},e.prototype.processStack=function(t){var e=this.xField,n=this.yField,i=t.length,u={positive:{},negative:{}};this.reverseOrder&&(t=t.slice(0).reverse());for(var s=0;s<i;s++)for(var a=t[s],f=0,c=a.length;f<c;f++){var p=a[f],l=p[e]||0,h=p[n],y=l.toString();if(h=r(h)?h[1]:h,!o(h)){var d=h>=0?"positive":"negative";u[d][y]||(u[d][y]=0),p[n]=[u[d][y],h+u[d][y]],u[d][y]+=h}}},e}(i);i.Stack=u,t.exports=u},function(t,e,n){var r={merge:n(5),values:n(3)},o=n(15),i=n(0);t.exports={processAdjust:function(t){var e=r.merge(t),n=this.dodgeBy,i=t;n&&(i=o(e,n)),this.cacheMap={},this.adjDataArray=i,this.mergeData=e,this.adjustData(i,e),this.adjDataArray=null,this.mergeData=null},getDistribution:function(t){var e=this.adjDataArray,n=this.cacheMap,o=n[t];return o||(o={},i(e,function(e,n){var u=r.values(e,t);u.length||u.push(0),i(u,function(t){o[t]||(o[t]=[]),o[t].push(n)})}),n[t]=o),o},adjustDim:function(t,e,n,r,o){var u=this,s=u.getDistribution(t),a=u.groupData(n,t);i(a,function(n,r){r=parseFloat(r);var a=void 0;a=1===e.length?{pre:e[0]-1,next:e[0]+1}:u.getAdjustRange(t,r,e),i(n,function(e){var n=e[t],r=s[n],i=r.indexOf(o);e[t]=u.getDodgeOffset(a,i,r.length)})})}}},function(t,e,n){var r=n(16);t.exports=function(t,e){if(!e)return[t];var n=r(t,e),o=[];for(var i in n)o.push(n[i]);return o}},function(t,e,n){var r=n(9),o=n(1),i=n(17);t.exports=function(t,e){if(!e)return{0:t};if(!r(e)){var n=o(e)?e:e.replace(/\s+/g,"").split("*");e=function(t){for(var e="_",r=0,o=n.length;r<o;r++)e+=t[n[r]]&&t[n[r]].toString();return e}}return i(t,e)}},function(t,e,n){var r=n(0),o=n(1),i=Object.prototype.hasOwnProperty;t.exports=function(t,e){if(!e||!o(t))return t;var n={},u=null;return r(t,function(t){u=e(t),i.call(n,u)?n[u].push(t):n[u]=[t]}),n}},function(t,e){t.exports={_initDefaultCfg:function(){this.xField=null,this.yField=null,this.height=null,this.size=10,this.reverseOrder=!1,this.adjustNames=["y"]},processOneDimStack:function(t){var e=this.xField,n=this.yField||"y",r=this.height,o={};this.reverseOrder&&(t=t.slice(0).reverse());for(var i=0,u=t.length;i<u;i++)for(var s=t[i],a=0,f=s.length;a<f;a++){var c=s[a],p=2*(c.size||this.size)/r,l=c[e];o[l]||(o[l]=p/2),c[n]=o[l],o[l]+=p}},processAdjust:function(t){this.yField?this.processStack(t):this.processOneDimStack(t)}}},function(t,e,n){var r=n(0),o=n(4),i={merge:n(5),values:n(3)},u=n(2),s=n(8),a=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype._initDefaultCfg=function(){this.xField=null,this.yField=null,this.adjustNames=["x","y"],this.groupFields=null},e.prototype.processAdjust=function(t){var e=i.merge(t);this.adjDataArray=t,this.mergeData=e,this.adjustData(t,e),this.adjFrames=null,this.mergeData=null},e.prototype.getAdjustOffset=function(t,e){var n=e-t;return t+.05*n+.9*n*Math.random()},e.prototype._adjustGroup=function(t,e,n,o){var i=this,u=i.getAdjustRange(e,n,o);r(t,function(t){t[e]=i.getAdjustOffset(u.pre,u.next)})},e.prototype.adjustDim=function(t,e,n){var o=this,i=o.groupData(n,t);r(i,function(n,r){r=parseFloat(r),o._adjustGroup(n,t,r,e)})},e}(u);o(a.prototype,s),u.Jitter=a,t.exports=a},function(t,e,n){var r=n(0),o=n(21),i=n(1),u={merge:n(5),values:n(3)},s=n(2),a=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype._initDefaultCfg=function(){this.xField=null,this.yField=null,this.cacheMax=null,this.adjustNames=["y"],this.groupFields=null},e.prototype._getMax=function(t){var e=this.mergeData,n=o(e,function(e){var n=e[t];return i(n)?Math.max.apply(null,n):n})[t];return i(n)?Math.max.apply(null,n):n},e.prototype._getXValuesMax=function(){var t=this.yField,e=this.xField,n={},o=this.mergeData;return r(o,function(r){var o=r[e],u=r[t],s=i(u)?Math.max.apply(null,u):u;n[o]=n[o]||0,n[o]<s&&(n[o]=s)}),n},e.prototype.processAdjust=function(t){var e=u.merge(t);this.mergeData=e,this._processSymmetric(t),this.mergeData=null},e.prototype._processSymmetric=function(t){var e=this.xField,n=this.yField,o=this._getMax(n),u=t[0][0],s=void 0;u&&i(u[n])&&(s=this._getXValuesMax()),r(t,function(t){r(t,function(t){var u=t[n],a=void 0;if(i(u)){var f=t[e],c=s[f];a=(o-c)/2;var p=[];r(u,function(t){p.push(a+t)}),t[n]=p}else a=(o-u)/2,t[n]=[a,u+a]})})},e}(s);s.Symmetric=a,t.exports=a},function(t,e,n){var r=n(1),o=n(9),i=n(0);t.exports=function(t,e){if(r(t)){var n=t[0],u=void 0;u=o(e)?e(t[0]):t[0][e];var s=void 0;return i(t,function(t){(s=o(e)?e(t):t[e])>u&&(n=t,u=s)}),n}}}])}); | ||
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.adjust=n():t.adjust=n()}("undefined"!=typeof self?self:this,function(){return function(t){function n(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var r={};return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:e})},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=10)}([function(t,n,r){var e=r(12),i=r(1);t.exports=function(t,n){if(t)if(i(t))for(var r=0,o=t.length;r<o&&!1!==n(t[r],r);r++);else if(e(t))for(var u in t)if(t.hasOwnProperty(u)&&!1===n(t[u],u))break}},function(t,n,r){var e=r(5),i=Array.isArray?Array.isArray:function(t){return e(t,"Array")};t.exports=i},function(t,n,r){var e=r(3),i=function(){function t(t){this._initDefaultCfg(),e(this,t)}var n=t.prototype;return n._initDefaultCfg=function(){this.adjustNames=["x","y"]},n.processAdjust=function(){},t}();t.exports=i},function(t,n){function r(t,n){for(var r in n)n.hasOwnProperty(r)&&"constructor"!==r&&void 0!==n[r]&&(t[r]=n[r])}t.exports=function(t,n,e,i){return n&&r(t,n),e&&r(t,e),i&&r(t,i),t}},function(t,n){t.exports=function(t){for(var n=[],r=0;r<t.length;r++)n=n.concat(t[r]);return n}},function(t,n){var r={}.toString;t.exports=function(t,n){return r.call(t)==="[object "+n+"]"}},function(t,n){t.exports=function(t){return null===t||void 0===t}},function(t,n,r){var e=r(0),i={values:r(8)};t.exports={isAdjust:function(t){return this.adjustNames.indexOf(t)>=0},_getDimValues:function(t){var n={},r=[];if(this.xField&&this.isAdjust("x")&&r.push(this.xField),this.yField&&this.isAdjust("y")&&r.push(this.yField),e(r,function(r){var e=i.values(t,r);e.sort(function(t,n){return t-n}),n[r]=e}),!this.yField&&this.isAdjust("y")){var o=[0,1];n.y=o}return n},adjustData:function(t,n){var r=this,i=r._getDimValues(n);e(t,function(n,o){e(i,function(e,i){r.adjustDim(i,e,n,t.length,o)})})},getAdjustRange:function(t,n,r){var e,i,o=r.indexOf(n),u=r.length;return!this.yField&&this.isAdjust("y")?(e=0,i=1):u>1?(e=0===o?r[0]:r[o-1],i=o===u-1?r[u-1]:r[o+1],0!==o?e+=(n-e)/2:e-=(i-n)/2,o!==u-1?i-=(i-n)/2:i+=(n-r[u-2])/2):(e=0===n?0:n-.5,i=0===n?1:n+.5),{pre:e,next:i}},groupData:function(t,n){var r={};return e(t,function(t){var e=t[n];void 0===e&&(e=t[n]=0),r[e]||(r[e]=[]),r[e].push(t)}),r}}},function(t,n,r){var e=r(6),i=r(1),o=r(0);t.exports=function(t,n){for(var r=[],u={},s=0;s<t.length;s++){var a=t[s][n];e(a)||(i(a)||(a=[a]),o(a,function(t){u[t]||(r.push(t),u[t]=!0)}))}return r}},function(t,n,r){var e=r(5);t.exports=function(t){return e(t,"Function")}},function(t,n,r){var e=r(3),i=r(2),o=r(11),u=r(13),s=r(7),a=r(14),f=r(18);e(i.prototype,s),e(o.prototype,s,a),e(u.prototype,f),i.Jitter=r(19),i.Symmetric=r(20),i.Dodge=o,i.Stack=u,t.exports=i},function(t,n,r){var e=r(2),i=r(0),o=function(t){function n(){return t.apply(this,arguments)||this}!function(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}(n,t);var r=n.prototype;return r._initDefaultCfg=function(){this.marginRatio=.5,this.dodgeRatio=.5,this.adjustNames=["x","y"]},r.getDodgeOffset=function(t,n,r){var e=t.pre,i=t.next,o=i-e,u=o*this.dodgeRatio/r,s=this.marginRatio*u;return(e+i)/2+(.5*(o-r*u-(r-1)*s)+((n+1)*u+n*s)-.5*u-.5*o)},r.processAdjust=function(t){var n=this,r=t.length,e=n.xField;i(t,function(t,i){for(var o=0,u=t.length;o<u;o++){var s=t[o],a=s[e],f={pre:a-.5,next:a+.5},c=n.getDodgeOffset(f,i,r);s[e]=c}})},n}(e);e.Dodge=o,t.exports=o},function(t,n){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){var n=void 0===t?"undefined":r(t);return null!==t&&"object"===n||"function"===n}},function(t,n,r){var e=r(1),i=r(6),o=r(2),u=function(t){function n(){return t.apply(this,arguments)||this}!function(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}(n,t);var r=n.prototype;return r._initDefaultCfg=function(){this.xField=null,this.yField=null},r.processAdjust=function(t){this.processStack(t)},r.processStack=function(t){var n=this.xField,r=this.yField,o=t.length,u={positive:{},negative:{}};this.reverseOrder&&(t=t.slice(0).reverse());for(var s=0;s<o;s++)for(var a=t[s],f=0,c=a.length;f<c;f++){var p=a[f],l=p[n]||0,h=p[r],d=l.toString();if(h=e(h)?h[1]:h,!i(h)){var v=h>=0?"positive":"negative";u[v][d]||(u[v][d]=0),p[r]=[u[v][d],h+u[v][d]],u[v][d]+=h}}},n}(o);o.Stack=u,t.exports=u},function(t,n,r){var e={merge:r(4),values:r(8)},i=r(15),o=r(0);t.exports={processAdjust:function(t){var n=e.merge(t),r=this.dodgeBy,o=t;r&&(o=i(n,r)),this.cacheMap={},this.adjDataArray=o,this.mergeData=n,this.adjustData(o,n),this.adjDataArray=null,this.mergeData=null},getDistribution:function(t){var n=this.adjDataArray,r=this.cacheMap,i=r[t];return i||(i={},o(n,function(n,r){var u=e.values(n,t);u.length||u.push(0),o(u,function(t){i[t]||(i[t]=[]),i[t].push(r)})}),r[t]=i),i},adjustDim:function(t,n,r,e,i){var u=this,s=u.getDistribution(t),a=u.groupData(r,t);o(a,function(r,e){e=parseFloat(e);var a;a=1===n.length?{pre:n[0]-1,next:n[0]+1}:u.getAdjustRange(t,e,n),o(r,function(n){var r=n[t],e=s[r],o=e.indexOf(i);n[t]=u.getDodgeOffset(a,o,e.length)})})}}},function(t,n,r){var e=r(16);t.exports=function(t,n){if(!n)return[t];var r=e(t,n),i=[];for(var o in r)i.push(r[o]);return i}},function(t,n,r){var e=r(9),i=r(1),o=r(17);t.exports=function(t,n){if(!n)return{0:t};if(!e(n)){var r=i(n)?n:n.replace(/\s+/g,"").split("*");n=function(t){for(var n="_",e=0,i=r.length;e<i;e++)n+=t[r[e]]&&t[r[e]].toString();return n}}return o(t,n)}},function(t,n,r){var e=r(0),i=r(1),o=Object.prototype.hasOwnProperty;t.exports=function(t,n){if(!n||!i(t))return t;var r={},u=null;return e(t,function(t){u=n(t),o.call(r,u)?r[u].push(t):r[u]=[t]}),r}},function(t,n){t.exports={_initDefaultCfg:function(){this.xField=null,this.yField=null,this.height=null,this.size=10,this.reverseOrder=!1,this.adjustNames=["y"]},processOneDimStack:function(t){var n=this.xField,r=this.yField||"y",e=this.height,i={};this.reverseOrder&&(t=t.slice(0).reverse());for(var o=0,u=t.length;o<u;o++)for(var s=t[o],a=0,f=s.length;a<f;a++){var c=s[a],p=2*(c.size||this.size)/e,l=c[n];i[l]||(i[l]=p/2),c[r]=i[l],i[l]+=p}},processAdjust:function(t){this.yField?this.processStack(t):this.processOneDimStack(t)}}},function(t,n,r){var e=r(0),i=r(3),o={merge:r(4)},u=r(2),s=r(7),a=function(t){function n(){return t.apply(this,arguments)||this}!function(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}(n,t);var r=n.prototype;return r._initDefaultCfg=function(){this.xField=null,this.yField=null,this.adjustNames=["x","y"],this.groupFields=null},r.processAdjust=function(t){var n=o.merge(t);this.adjDataArray=t,this.mergeData=n,this.adjustData(t,n),this.adjFrames=null,this.mergeData=null},r.getAdjustOffset=function(t,n){var r=n-t;return t+.05*r+.9*r*Math.random()},r._adjustGroup=function(t,n,r,i){var o=this,u=o.getAdjustRange(n,r,i);e(t,function(t){t[n]=o.getAdjustOffset(u.pre,u.next)})},r.adjustDim=function(t,n,r){var i=this,o=i.groupData(r,t);e(o,function(r,e){e=parseFloat(e),i._adjustGroup(r,t,e,n)})},n}(u);i(a.prototype,s),u.Jitter=a,t.exports=a},function(t,n,r){var e=r(0),i=r(21),o=r(1),u={merge:r(4)},s=r(2),a=function(t){function n(){return t.apply(this,arguments)||this}!function(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}(n,t);var r=n.prototype;return r._initDefaultCfg=function(){this.xField=null,this.yField=null,this.cacheMax=null,this.adjustNames=["y"],this.groupFields=null},r._getMax=function(t){var n=this.mergeData,r=i(n,function(n){var r=n[t];return o(r)?Math.max.apply(null,r):r})[t];return o(r)?Math.max.apply(null,r):r},r._getXValuesMax=function(){var t=this.yField,n=this.xField,r={},i=this.mergeData;return e(i,function(e){var i=e[n],u=e[t],s=o(u)?Math.max.apply(null,u):u;r[i]=r[i]||0,r[i]<s&&(r[i]=s)}),r},r.processAdjust=function(t){var n=u.merge(t);this.mergeData=n,this._processSymmetric(t),this.mergeData=null},r._processSymmetric=function(t){var n,r=this.xField,i=this.yField,u=this._getMax(i),s=t[0][0];s&&o(s[i])&&(n=this._getXValuesMax()),e(t,function(t){e(t,function(t){var s,a=t[i];if(o(a)){var f=t[r],c=n[f];s=(u-c)/2;var p=[];e(a,function(t){p.push(s+t)}),t[i]=p}else s=(u-a)/2,t[i]=[s,a+s]})})},n}(s);s.Symmetric=a,t.exports=a},function(t,n,r){var e=r(1),i=r(9),o=r(0);t.exports=function(t,n){if(e(t)){var r=t[0],u=void 0;u=i(n)?n(t[0]):t[0][n];var s=void 0;return o(t,function(t){(s=i(n)?n(t):t[n])>u&&(r=t,u=s)}),r}}}])}); |
@@ -1,7 +0,9 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var mix = require('@antv/util/lib/mix'); | ||
var Adjust = function () { | ||
Adjust.prototype._initDefaultCfg = function _initDefaultCfg() { | ||
var Adjust = | ||
/*#__PURE__*/ | ||
function () { | ||
var _proto = Adjust.prototype; | ||
_proto._initDefaultCfg = function _initDefaultCfg() { | ||
this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整 | ||
@@ -11,8 +13,6 @@ }; | ||
function Adjust(cfg) { | ||
_classCallCheck(this, Adjust); | ||
this._initDefaultCfg(); | ||
this._initDefaultCfg(); | ||
mix(this, cfg); | ||
} | ||
/** | ||
@@ -23,3 +23,5 @@ * @override | ||
Adjust.prototype.processAdjust = function processAdjust() /* dataArray */{}; | ||
_proto.processAdjust = function processAdjust() | ||
/* dataArray */ | ||
{}; | ||
@@ -26,0 +28,0 @@ return Adjust; |
@@ -1,8 +0,5 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
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; } | ||
var Adjust = require('./base'); | ||
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 Adjust = require('./base'); | ||
var each = require('@antv/util/lib/each'); | ||
@@ -13,12 +10,14 @@ | ||
var Dodge = function (_Adjust) { | ||
_inherits(Dodge, _Adjust); | ||
var Dodge = | ||
/*#__PURE__*/ | ||
function (_Adjust) { | ||
_inheritsLoose(Dodge, _Adjust); | ||
function Dodge() { | ||
_classCallCheck(this, Dodge); | ||
return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); | ||
return _Adjust.apply(this, arguments) || this; | ||
} | ||
Dodge.prototype._initDefaultCfg = function _initDefaultCfg() { | ||
var _proto = Dodge.prototype; | ||
_proto._initDefaultCfg = function _initDefaultCfg() { | ||
/** | ||
@@ -33,2 +32,3 @@ * 调整过程中,2个数据的间距 | ||
*/ | ||
this.dodgeRatio = DODGE_RATIO; | ||
@@ -38,3 +38,3 @@ this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整 | ||
Dodge.prototype.getDodgeOffset = function getDodgeOffset(range, index, count) { | ||
_proto.getDodgeOffset = function getDodgeOffset(range, index, count) { | ||
var self = this; | ||
@@ -50,3 +50,3 @@ var pre = range.pre; | ||
Dodge.prototype.processAdjust = function processAdjust(dataArray) { | ||
_proto.processAdjust = function processAdjust(dataArray) { | ||
var self = this; | ||
@@ -53,0 +53,0 @@ var count = dataArray.length; |
// 完整版下使用支持按照某个字段进行分组的 dodge | ||
var mix = require('@antv/util/lib/mix'); | ||
var Adjust = require('./base'); | ||
var Dodge = require('./dodge'); | ||
var Stack = require('./stack'); | ||
var AdjustMixin = require('./mixin/adjust'); | ||
var DodgeMixin = require('./mixin/dodge'); | ||
var StackMixin = require('./mixin/stack'); | ||
mix(Adjust.prototype, AdjustMixin); | ||
mix(Dodge.prototype, AdjustMixin, DodgeMixin); | ||
mix(Stack.prototype, StackMixin); | ||
Adjust.Jitter = require('./jitter'); | ||
@@ -17,3 +23,2 @@ Adjust.Symmetric = require('./symmetric'); | ||
Adjust.Stack = Stack; | ||
module.exports = Adjust; |
@@ -1,37 +0,39 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
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; } | ||
var each = require('@antv/util/lib/each'); | ||
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 mix = require('@antv/util/lib/mix'); | ||
var each = require('@antv/util/lib/each'); | ||
var mix = require('@antv/util/lib/mix'); | ||
var ArrayUtil = { | ||
merge: require('@antv/util/lib/array/merge'), | ||
values: require('@antv/util/lib/array/values') | ||
merge: require('@antv/util/lib/array/merge') | ||
}; | ||
var Adjust = require('./base'); | ||
var AdjustMixin = require('./mixin/adjust'); | ||
var Jitter = function (_Adjust) { | ||
_inherits(Jitter, _Adjust); | ||
var Jitter = | ||
/*#__PURE__*/ | ||
function (_Adjust) { | ||
_inheritsLoose(Jitter, _Adjust); | ||
function Jitter() { | ||
_classCallCheck(this, Jitter); | ||
return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); | ||
return _Adjust.apply(this, arguments) || this; | ||
} | ||
Jitter.prototype._initDefaultCfg = function _initDefaultCfg() { | ||
var _proto = Jitter.prototype; | ||
_proto._initDefaultCfg = function _initDefaultCfg() { | ||
this.xField = null; // 调整对应的 x 方向对应的字段名称 | ||
this.yField = null; // 调整对应的 y 方向对应的字段名称 | ||
this.adjustNames = ['x', 'y']; // 指x,y | ||
this.groupFields = null; // 参与分组的数据维度 | ||
}; | ||
Jitter.prototype.processAdjust = function processAdjust(dataArray) { | ||
_proto.processAdjust = function processAdjust(dataArray) { | ||
var self = this; | ||
var mergeData = ArrayUtil.merge(dataArray); | ||
self.adjDataArray = dataArray; | ||
@@ -44,16 +46,15 @@ self.mergeData = mergeData; | ||
Jitter.prototype.getAdjustOffset = function getAdjustOffset(pre, next) { | ||
_proto.getAdjustOffset = function getAdjustOffset(pre, next) { | ||
var r = Math.random(); // 随机位置,均匀分布 | ||
var avg = next - pre; // * length | ||
var append = avg * 0.05; | ||
return pre + append + avg * 0.9 * r; | ||
}; | ||
}; // adjust group data | ||
// adjust group data | ||
Jitter.prototype._adjustGroup = function _adjustGroup(group, dim, key, values) { | ||
_proto._adjustGroup = function _adjustGroup(group, dim, key, values) { | ||
var self = this; | ||
var range = self.getAdjustRange(dim, key, values); | ||
each(group, function (record) { | ||
@@ -64,3 +65,3 @@ record[dim] = self.getAdjustOffset(range.pre, range.next); // 获取调整的位置 | ||
Jitter.prototype.adjustDim = function adjustDim(dim, values, data) { | ||
_proto.adjustDim = function adjustDim(dim, values, data) { | ||
var self = this; | ||
@@ -70,2 +71,3 @@ var groupData = self.groupData(data, dim); | ||
key = parseFloat(key); | ||
self._adjustGroup(group, dim, key, values); | ||
@@ -79,4 +81,3 @@ }); | ||
mix(Jitter.prototype, AdjustMixin); | ||
Adjust.Jitter = Jitter; | ||
module.exports = Jitter; |
var DEFAULT_Y = 0; // 默认的y的值 | ||
var each = require('@antv/util/lib/each'); | ||
var ArrayUtil = { | ||
values: require('@antv/util/lib/array/values') | ||
values: require('@antv/util/lib/array/values-of-key') | ||
}; | ||
@@ -27,8 +29,11 @@ module.exports = { | ||
var dims = []; | ||
if (self.xField && self.isAdjust('x')) { | ||
dims.push(self.xField); | ||
} | ||
if (self.yField && self.isAdjust('y')) { | ||
dims.push(self.yField); | ||
} | ||
each(dims, function (dim) { | ||
@@ -41,2 +46,3 @@ var values = ArrayUtil.values(mergeData, dim); | ||
}); | ||
if (!self.yField && self.isAdjust('y')) { | ||
@@ -46,4 +52,6 @@ // 只有一维的情况下,同时调整y | ||
var values = [DEFAULT_Y, 1]; // 默认分布在y轴的 0.1 与 0.2 之间 | ||
valuesMap[dim] = values; | ||
} | ||
return valuesMap; | ||
@@ -53,3 +61,5 @@ }, | ||
var self = this; | ||
var valuesMap = self._getDimValues(mergeData); | ||
each(dataArray, function (data, index) { | ||
@@ -67,4 +77,5 @@ // 遍历所有数据集合 | ||
var length = values.length; | ||
var pre = void 0; | ||
var next = void 0; | ||
var pre; | ||
var next; | ||
if (!self.yField && self.isAdjust('y')) { | ||
@@ -82,2 +93,3 @@ pre = 0; | ||
} | ||
if (index !== length - 1) { | ||
@@ -107,16 +119,17 @@ next -= (next - key) / 2; | ||
var groups = {}; | ||
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; | ||
} | ||
}; |
var ArrayUtil = { | ||
merge: require('@antv/util/lib/array/merge'), | ||
values: require('@antv/util/lib/array/values') | ||
values: require('@antv/util/lib/array/values-of-key') | ||
}; | ||
var group = require('@antv/util/lib/group'); | ||
var each = require('@antv/util/lib/each'); | ||
@@ -19,2 +20,3 @@ | ||
var adjDataArray = dataArray; | ||
if (dodgeDim) { | ||
@@ -24,2 +26,3 @@ // 如果指定了分组dim的字段 | ||
} | ||
self.cacheMap = {}; | ||
@@ -29,3 +32,2 @@ self.adjDataArray = adjDataArray; | ||
self.adjustData(adjDataArray, mergeData); | ||
self.adjDataArray = null; | ||
@@ -39,2 +41,3 @@ self.mergeData = null; | ||
var map = cacheMap[dim]; | ||
if (!map) { | ||
@@ -44,5 +47,7 @@ map = {}; | ||
var values = ArrayUtil.values(data, dim); | ||
if (!values.length) { | ||
values.push(0); | ||
} | ||
each(values, function (val) { | ||
@@ -52,2 +57,3 @@ if (!map[val]) { | ||
} | ||
map[val].push(index); | ||
@@ -68,3 +74,4 @@ }); | ||
key = parseFloat(key); | ||
var range = void 0; | ||
var range; | ||
if (values.length === 1) { | ||
@@ -78,2 +85,3 @@ range = { | ||
} | ||
each(group, function (record) { | ||
@@ -80,0 +88,0 @@ var value = record[dim]; |
module.exports = { | ||
_initDefaultCfg: function _initDefaultCfg() { | ||
this.xField = null; // 调整对应的 x 方向对应的字段名称 | ||
this.yField = null; // 调整对应的 y 方向对应的字段名称 | ||
this.height = null; // 仅有一个维度调整时,总的高度 | ||
this.size = 10; // 单个点的大小 | ||
this.reverseOrder = false; // 是否反序进行层叠 | ||
this.adjustNames = ['y']; // Only support stack y | ||
@@ -15,11 +20,11 @@ }, | ||
var height = self.height; | ||
var stackY = {}; // 如果层叠的顺序翻转 | ||
var stackY = {}; | ||
// 如果层叠的顺序翻转 | ||
if (self.reverseOrder) { | ||
dataArray = dataArray.slice(0).reverse(); | ||
} | ||
for (var i = 0, len = dataArray.length; i < len; i++) { | ||
var data = dataArray[i]; | ||
// cates | ||
var data = dataArray[i]; // cates | ||
for (var j = 0, dataLen = data.length; j < dataLen; j++) { | ||
@@ -30,5 +35,7 @@ var item = data[j]; | ||
var x = item[xField]; | ||
if (!stackY[x]) { | ||
stackY[x] = stackHeight / 2; | ||
} | ||
item[yField] = stackY[x]; | ||
@@ -35,0 +42,0 @@ stackY[x] += stackHeight; |
@@ -1,30 +0,31 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
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; } | ||
var isArray = require('@antv/util/lib/type/is-array'); | ||
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 isNil = require('@antv/util/lib/type/is-nil'); | ||
var isArray = require('@antv/util/lib/type/isArray'); | ||
var isNil = require('@antv/util/lib/type/isNil'); | ||
var Adjust = require('./base'); | ||
var Stack = function (_Adjust) { | ||
_inherits(Stack, _Adjust); | ||
var Stack = | ||
/*#__PURE__*/ | ||
function (_Adjust) { | ||
_inheritsLoose(Stack, _Adjust); | ||
function Stack() { | ||
_classCallCheck(this, Stack); | ||
return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); | ||
return _Adjust.apply(this, arguments) || this; | ||
} | ||
Stack.prototype._initDefaultCfg = function _initDefaultCfg() { | ||
var _proto = Stack.prototype; | ||
_proto._initDefaultCfg = function _initDefaultCfg() { | ||
this.xField = null; // 调整对应的 x 方向对应的字段名称 | ||
this.yField = null; // 调整对应的 y 方向对应的字段名称 | ||
}; | ||
Stack.prototype.processAdjust = function processAdjust(dataArray) { | ||
_proto.processAdjust = function processAdjust(dataArray) { | ||
this.processStack(dataArray); | ||
}; | ||
Stack.prototype.processStack = function processStack(dataArray) { | ||
_proto.processStack = function processStack(dataArray) { | ||
var self = this; | ||
@@ -37,9 +38,11 @@ var xField = self.xField; | ||
negative: {} | ||
}; | ||
// 层叠顺序翻转 | ||
}; // 层叠顺序翻转 | ||
if (self.reverseOrder) { | ||
dataArray = dataArray.slice(0).reverse(); | ||
} | ||
for (var i = 0; i < count; i++) { | ||
var data = dataArray[i]; | ||
for (var j = 0, len = data.length; j < len; j++) { | ||
@@ -51,7 +54,10 @@ var item = data[j]; | ||
y = isArray(y) ? y[1] : y; | ||
if (!isNil(y)) { | ||
var direction = y >= 0 ? 'positive' : 'negative'; | ||
if (!stackCache[direction][xkey]) { | ||
stackCache[direction][xkey] = 0; | ||
} | ||
item[yField] = [stackCache[direction][xkey], y + stackCache[direction][xkey]]; | ||
@@ -58,0 +64,0 @@ stackCache[direction][xkey] += y; |
@@ -1,37 +0,40 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
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; } | ||
var each = require('@antv/util/lib/each'); | ||
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 maxBy = require('@antv/util/lib/math/max-by'); | ||
var each = require('@antv/util/lib/each'); | ||
var maxBy = require('@antv/util/lib/math/maxBy'); | ||
var isArray = require('@antv/util/lib/type/isArray'); | ||
var isArray = require('@antv/util/lib/type/is-array'); | ||
var ArrayUtil = { | ||
merge: require('@antv/util/lib/array/merge'), | ||
values: require('@antv/util/lib/array/values') | ||
merge: require('@antv/util/lib/array/merge') | ||
}; | ||
var Adjust = require('./base'); | ||
var Symmetric = function (_Adjust) { | ||
_inherits(Symmetric, _Adjust); | ||
var Symmetric = | ||
/*#__PURE__*/ | ||
function (_Adjust) { | ||
_inheritsLoose(Symmetric, _Adjust); | ||
function Symmetric() { | ||
_classCallCheck(this, Symmetric); | ||
return _possibleConstructorReturn(this, _Adjust.apply(this, arguments)); | ||
return _Adjust.apply(this, arguments) || this; | ||
} | ||
Symmetric.prototype._initDefaultCfg = function _initDefaultCfg() { | ||
var _proto = Symmetric.prototype; | ||
_proto._initDefaultCfg = function _initDefaultCfg() { | ||
this.xField = null; // 调整对应的 x 方向对应的字段名称 | ||
this.yField = null; // 调整对应的 y 方向对应的字段名称 | ||
this.cacheMax = null; // 缓存的最大值 | ||
this.adjustNames = ['y']; // Only support stack y | ||
this.groupFields = null; // 参与分组的数据维度 | ||
}; | ||
}; // 获取最大的y值 | ||
// 获取最大的y值 | ||
Symmetric.prototype._getMax = function _getMax(dim) { | ||
_proto._getMax = function _getMax(dim) { | ||
var self = this; | ||
@@ -41,5 +44,7 @@ var mergeData = self.mergeData; | ||
var value = obj[dim]; | ||
if (isArray(value)) { | ||
return Math.max.apply(null, value); | ||
} | ||
return value; | ||
@@ -50,8 +55,6 @@ }); | ||
return max; | ||
}; | ||
}; // 获取每个字段最大的值 | ||
// 获取每个字段最大的值 | ||
Symmetric.prototype._getXValuesMax = function _getXValuesMax() { | ||
_proto._getXValuesMax = function _getXValuesMax() { | ||
var self = this; | ||
@@ -67,2 +70,3 @@ var yField = self.yField; | ||
cache[xValue] = cache[xValue] || 0; | ||
if (cache[xValue] < max) { | ||
@@ -73,33 +77,35 @@ cache[xValue] = max; | ||
return cache; | ||
}; | ||
}; // 入口函数 | ||
// 入口函数 | ||
Symmetric.prototype.processAdjust = function processAdjust(dataArray) { | ||
_proto.processAdjust = function processAdjust(dataArray) { | ||
var self = this; | ||
var mergeData = ArrayUtil.merge(dataArray); | ||
self.mergeData = mergeData; | ||
self._processSymmetric(dataArray); | ||
self.mergeData = null; | ||
}; | ||
}; // 处理对称 | ||
// 处理对称 | ||
Symmetric.prototype._processSymmetric = function _processSymmetric(dataArray) { | ||
_proto._processSymmetric = function _processSymmetric(dataArray) { | ||
var self = this; | ||
var xField = self.xField; | ||
var yField = self.yField; | ||
var max = self._getMax(yField); | ||
var first = dataArray[0][0]; | ||
var cache; | ||
var cache = void 0; | ||
if (first && isArray(first[yField])) { | ||
cache = self._getXValuesMax(); | ||
} | ||
each(dataArray, function (data) { | ||
each(data, function (obj) { | ||
var value = obj[yField]; | ||
var offset = void 0; | ||
var offset; | ||
if (isArray(value)) { | ||
@@ -111,2 +117,3 @@ var xValue = obj[xField]; | ||
/* eslint-disable no-loop-func */ | ||
each(value, function (subVal) { | ||
@@ -117,2 +124,3 @@ // 多个字段 | ||
/* eslint-enable no-loop-func */ | ||
obj[yField] = tmp; | ||
@@ -119,0 +127,0 @@ } else { |
{ | ||
"name": "@antv/adjust", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Data Adjust module for G2, F2.", | ||
@@ -25,8 +25,8 @@ "browser": "build/adjust.js", | ||
"devDependencies": { | ||
"babel-cli": "~6.26.0", | ||
"babel-core": "~6.26.0", | ||
"@babel/cli": "^7.0.0", | ||
"@babel/core": "^7.0.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"babel-eslint": "~8.0.3", | ||
"babel-loader": "~7.1.4", | ||
"babel-loader": "^8.0.0", | ||
"babel-plugin-transform-remove-strict-mode": "~0.0.2", | ||
"babel-preset-env": "~1.6.1", | ||
"body-parser": "~1.18.2", | ||
@@ -56,3 +56,3 @@ "chai": "~4.1.2", | ||
"string-replace-loader": "~1.3.0", | ||
"torchjs": "~2.0.4", | ||
"torchjs": "~2.1.0", | ||
"uglify-js": "~3.1.10", | ||
@@ -97,4 +97,4 @@ "webpack": "~3.10.0" | ||
"dependencies": { | ||
"@antv/util": "~1.0.11" | ||
"@antv/util": "~1.2.5" | ||
} | ||
} |
const each = require('@antv/util/lib/each'); | ||
const mix = require('@antv/util/lib/mix'); | ||
const ArrayUtil = { | ||
merge: require('@antv/util/lib/array/merge'), | ||
values: require('@antv/util/lib/array/values') | ||
merge: require('@antv/util/lib/array/merge') | ||
}; | ||
@@ -7,0 +6,0 @@ |
const DEFAULT_Y = 0; // 默认的y的值 | ||
const each = require('@antv/util/lib/each'); | ||
const ArrayUtil = { | ||
values: require('@antv/util/lib/array/values') | ||
values: require('@antv/util/lib/array/values-of-key') | ||
}; | ||
@@ -6,0 +6,0 @@ module.exports = { |
const ArrayUtil = { | ||
merge: require('@antv/util/lib/array/merge'), | ||
values: require('@antv/util/lib/array/values') | ||
values: require('@antv/util/lib/array/values-of-key') | ||
}; | ||
@@ -5,0 +5,0 @@ |
@@ -1,3 +0,3 @@ | ||
const isArray = require('@antv/util/lib/type/isArray'); | ||
const isNil = require('@antv/util/lib/type/isNil'); | ||
const isArray = require('@antv/util/lib/type/is-array'); | ||
const isNil = require('@antv/util/lib/type/is-nil'); | ||
const Adjust = require('./base'); | ||
@@ -4,0 +4,0 @@ |
const each = require('@antv/util/lib/each'); | ||
const maxBy = require('@antv/util/lib/math/maxBy'); | ||
const isArray = require('@antv/util/lib/type/isArray'); | ||
const maxBy = require('@antv/util/lib/math/max-by'); | ||
const isArray = require('@antv/util/lib/type/is-array'); | ||
const ArrayUtil = { | ||
merge: require('@antv/util/lib/array/merge'), | ||
values: require('@antv/util/lib/array/values') | ||
merge: require('@antv/util/lib/array/merge') | ||
}; | ||
@@ -8,0 +7,0 @@ const Adjust = require('./base'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
134964
2243
+ Added@antv/gl-matrix@2.7.1(transitive)
+ Added@antv/util@1.2.5(transitive)
- Removed@antv/util@1.0.12(transitive)
Updated@antv/util@~1.2.5