1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.MaybeTooltip = void 0;
|
4 | const util_1 = require("@antv/util");
|
5 | const helper_1 = require("../utils/helper");
|
6 |
|
7 |
|
8 |
|
9 | const MaybeTooltip = (options) => {
|
10 | const { channel } = options;
|
11 | return (I, mark) => {
|
12 | const { encode, tooltip } = mark;
|
13 | if ((0, helper_1.isUnset)(tooltip))
|
14 | return [I, mark];
|
15 | const { items = [] } = tooltip;
|
16 | if (!items || items.length > 0)
|
17 | return [I, mark];
|
18 | const channels = Array.isArray(channel) ? channel : [channel];
|
19 | const newItems = channels.flatMap((channel) => Object.keys(encode)
|
20 | .filter((key) => key.startsWith(channel))
|
21 | .map((key) => {
|
22 | const { field, value, inferred = false, aggregate } = encode[key];
|
23 | if (inferred)
|
24 | return null;
|
25 |
|
26 | if (aggregate && value)
|
27 | return { channel: key };
|
28 | if (field)
|
29 | return { field };
|
30 | if (value)
|
31 | return { channel: key };
|
32 | return null;
|
33 | })
|
34 | .filter((d) => d !== null));
|
35 | return [I, (0, util_1.deepMix)({}, mark, { tooltip: { items: newItems } })];
|
36 | };
|
37 | };
|
38 | exports.MaybeTooltip = MaybeTooltip;
|
39 | exports.MaybeTooltip.props = {};
|
40 |
|
\ | No newline at end of file |