1 | "use strict";
|
2 | var __rest = (this && this.__rest) || function (s, e) {
|
3 | var t = {};
|
4 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
5 | t[p] = s[p];
|
6 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
7 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
8 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
9 | t[p[i]] = s[p[i]];
|
10 | }
|
11 | return t;
|
12 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | exports.DodgeX = void 0;
|
15 | const util_1 = require("@antv/util");
|
16 | const helper_1 = require("./utils/helper");
|
17 | const order_1 = require("./utils/order");
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | const DodgeX = (options = {}) => {
|
24 | const { groupBy = 'x', reverse = false, orderBy, padding } = options, rest = __rest(options, ["groupBy", "reverse", "orderBy", "padding"]);
|
25 | return (I, mark) => {
|
26 | const { data, encode, scale } = mark;
|
27 | const { series: scaleSeries } = scale;
|
28 | const [Y] = (0, helper_1.columnOf)(encode, 'y');
|
29 | const [S] = (0, helper_1.maybeColumnOf)(encode, 'series', 'color');
|
30 | const domainSeries = (0, order_1.domainOf)(S, scaleSeries);
|
31 | const newMark = (0, util_1.deepMix)({}, mark, {
|
32 | scale: {
|
33 | series: {
|
34 | domain: domainSeries,
|
35 | paddingInner: padding,
|
36 | },
|
37 | },
|
38 | });
|
39 |
|
40 | const groups = (0, order_1.createGroups)(groupBy, I, mark);
|
41 | const createComparator = (0, order_1.normalizeComparator)(orderBy);
|
42 | if (!createComparator) {
|
43 | return [I, (0, util_1.deepMix)(newMark, { encode: { series: (0, helper_1.column)(S) } })];
|
44 | }
|
45 |
|
46 | const comparator = createComparator(data, Y, S);
|
47 | if (comparator)
|
48 | (0, order_1.applyOrder)(groups, comparator);
|
49 | const newS = new Array(I.length);
|
50 | for (const G of groups) {
|
51 | if (reverse)
|
52 | G.reverse();
|
53 | for (let i = 0; i < G.length; i++) {
|
54 | newS[G[i]] = domainSeries[i];
|
55 | }
|
56 | }
|
57 | return [
|
58 | I,
|
59 | (0, util_1.deepMix)(newMark, {
|
60 | encode: {
|
61 | series: (0, helper_1.column)(orderBy ? newS : S),
|
62 | },
|
63 | }),
|
64 | ];
|
65 | };
|
66 | };
|
67 | exports.DodgeX = DodgeX;
|
68 | exports.DodgeX.props = {};
|
69 |
|
\ | No newline at end of file |