-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmark.ts
26 lines (22 loc) · 867 Bytes
/
mark.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { deepMix } from '@antv/util';
import { isUnset, subObject } from './helper';
export function subTooltip(tooltip, name, defaults = {}, main = false) {
if (isUnset(tooltip)) return tooltip;
if (Array.isArray(tooltip) && main) return tooltip;
const sub = subObject(tooltip, name);
return deepMix(defaults, sub);
}
export function maybeTooltip(tooltip, defaults = {}) {
if (isUnset(tooltip)) return tooltip;
if (Array.isArray(tooltip)) return tooltip;
if (!isFullTooltip(tooltip)) return tooltip;
return deepMix(defaults, tooltip);
}
export function isFullTooltip(tooltip) {
if (Object.keys(tooltip).length === 0) return true;
const { title, items } = tooltip;
return title !== undefined || items !== undefined;
}
export function maybeAnimation(animate, sub) {
return typeof animate === 'object' ? subObject(animate, sub) : animate;
}