1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.DiffY = void 0;
|
4 | const util_1 = require("@antv/util");
|
5 | const helper_1 = require("./utils/helper");
|
6 | const order_1 = require("./utils/order");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | const DiffY = (options = {}) => {
|
12 | const { groupBy = 'x', series = true } = options;
|
13 | return (I, mark) => {
|
14 | const { encode } = mark;
|
15 | const [Y] = (0, helper_1.columnOf)(encode, 'y');
|
16 | const [_, fy1] = (0, helper_1.columnOf)(encode, 'y1');
|
17 | const [S] = series
|
18 | ? (0, helper_1.maybeColumnOf)(encode, 'series', 'color')
|
19 | : (0, helper_1.columnOf)(encode, 'color');
|
20 |
|
21 | const groups = (0, order_1.createGroups)(groupBy, I, mark);
|
22 |
|
23 | const newY1 = new Array(I.length);
|
24 | for (const G of groups) {
|
25 | const YG = G.map((i) => +Y[i]);
|
26 |
|
27 | for (let idx = 0; idx < G.length; idx++) {
|
28 | const i = G[idx];
|
29 |
|
30 | const max = Math.max(...YG.filter((_, _i) => _i !== idx));
|
31 |
|
32 | newY1[i] = +Y[i] > max ? max : Y[i];
|
33 | }
|
34 | }
|
35 | return [
|
36 | I,
|
37 | (0, util_1.deepMix)({}, mark, {
|
38 | encode: {
|
39 | y1: (0, helper_1.column)(newY1, fy1),
|
40 | },
|
41 | }),
|
42 | ];
|
43 | };
|
44 | };
|
45 | exports.DiffY = DiffY;
|
46 | exports.DiffY.props = {};
|
47 |
|
\ | No newline at end of file |