-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaybeVisualPosition.ts
37 lines (34 loc) · 1.04 KB
/
maybeVisualPosition.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
27
28
29
30
31
32
33
34
35
36
37
import { deepMix } from '@antv/util';
import { TransformComponent as TC } from '../runtime';
import { column } from './utils/helper';
export type MaybeVisualPositionOptions = Record<string, never>;
/**
* Set visual position with style.x and style.y.
* The priority of style.x, style.y is higher than data.
*/
export const MaybeVisualPosition: TC<MaybeVisualPositionOptions> = () => {
return (I, mark) => {
const { data, style = {}, ...restMark } = mark;
const { x: x0, y: y0, ...rest } = style;
if (x0 == undefined || y0 == undefined) return [I, mark];
const x = x0 || 0;
const y = y0 || 0;
return [
[0],
deepMix({}, restMark, {
data: [0],
cartesian: true,
encode: {
x: column([x]),
y: column([y]),
},
scale: {
x: { type: 'identity', independent: true, guide: null }, // hide axis
y: { type: 'identity', independent: true, guide: null }, // hide axis
},
style: rest,
}),
];
};
};
MaybeVisualPosition.props = {};