1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.MaybeTitle = void 0;
|
4 | const util_1 = require("@antv/util");
|
5 | const helper_1 = require("../utils/helper");
|
6 | const dateFormat_1 = require("../utils/dateFormat");
|
7 | const helper_2 = require("./utils/helper");
|
8 |
|
9 |
|
10 |
|
11 | const MaybeTitle = (options = {}) => {
|
12 | const { channel = 'x' } = options;
|
13 | return (I, mark) => {
|
14 | const { encode } = mark;
|
15 | const { tooltip } = mark;
|
16 | if ((0, helper_1.isUnset)(tooltip))
|
17 | return [I, mark];
|
18 | const { title } = tooltip;
|
19 | if (title !== undefined)
|
20 | return [I, mark];
|
21 | const titles = Object.keys(encode)
|
22 | .filter((key) => key.startsWith(channel))
|
23 | .filter((key) => !encode[key].inferred)
|
24 | .map((key) => (0, helper_2.columnOf)(encode, key))
|
25 | .filter(([T]) => T)
|
26 | .map((d) => d[0]);
|
27 | if (titles.length === 0)
|
28 | return [I, mark];
|
29 | const T = [];
|
30 | for (const i of I) {
|
31 | T[i] = {
|
32 | value: titles
|
33 | .map((t) => t[i] instanceof Date ? (0, dateFormat_1.dynamicFormatDateTime)(t[i]) : t[i])
|
34 | .join(', '),
|
35 | };
|
36 | }
|
37 | return [
|
38 | I,
|
39 | (0, util_1.deepMix)({}, mark, {
|
40 | tooltip: {
|
41 | title: T,
|
42 | },
|
43 | }),
|
44 | ];
|
45 | };
|
46 | };
|
47 | exports.MaybeTitle = MaybeTitle;
|
48 | exports.MaybeTitle.props = {};
|
49 |
|
\ | No newline at end of file |