UNPKG

@visactor/vchart

Version:

charts lib based @visactor/VGrammar

36 lines (29 loc) 1.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.getGroupAnimationParams = exports.sortDataInAxisHelper = exports.isPolarAxisSeries = void 0; const type_1 = require("../interface/type"), vscale_1 = require("@visactor/vscale"); function isPolarAxisSeries(type) { return [ type_1.SeriesTypeEnum.rose, type_1.SeriesTypeEnum.radar, type_1.SeriesTypeEnum.circularProgress ].includes(type); } function sortDataInAxisHelper(axisHelper, field, dataList) { const scale = axisHelper.getScale(0), isRevert = "isInverse" in axisHelper && axisHelper.isInverse(); (0, vscale_1.isContinuous)(scale.type) ? dataList.sort(((datumA, datumB) => (datumA[field] - datumB[field]) * (isRevert ? -1 : 1))) : dataList.sort(((datumA, datumB) => (scale.index(datumA[field]) - scale.index(datumB[field])) * (isRevert ? -1 : 1))); } function getGroupAnimationParams(series) { return { dataIndex: datum => { var _a, _b; const indexField = "horizontal" === series.direction ? series.fieldY[0] : series.fieldX[0], indexValue = null == datum ? void 0 : datum[indexField], scale = "horizontal" === series.direction ? series.scaleY : series.scaleX; return (null !== (_b = null === (_a = null == scale ? void 0 : scale.domain) || void 0 === _a ? void 0 : _a.call(scale)) && void 0 !== _b ? _b : []).indexOf(indexValue) || 0; }, dataCount: () => { var _a, _b, _c; const scale = "horizontal" === series.direction ? series.scaleY : series.scaleX; return null !== (_c = (null !== (_b = null === (_a = null == scale ? void 0 : scale.domain) || void 0 === _a ? void 0 : _a.call(scale)) && void 0 !== _b ? _b : []).length) && void 0 !== _c ? _c : 0; } }; } exports.isPolarAxisSeries = isPolarAxisSeries, exports.sortDataInAxisHelper = sortDataInAxisHelper, exports.getGroupAnimationParams = getGroupAnimationParams; //# sourceMappingURL=utils.js.map