1 | import { LineStyleProps, TextStyleProps, MarkerStyleProps } from '@antv/f-engine';
|
2 | import Coord from '../../coord';
|
3 | import { DataRecord, DataField, DataValue } from '../../chart/Data';
|
4 |
|
5 | interface TickLine extends LineStyleProps {
|
6 | length?: number;
|
7 | }
|
8 |
|
9 | interface Text extends TextStyleProps {
|
10 | align?: 'left' | 'right' | 'start' | 'center' | 'end' | 'between' | 'auto';
|
11 | text?: string;
|
12 | }
|
13 |
|
14 |
|
15 | type StyleText<T = any> = T extends 'bottom' | void ? Text : Omit<Text, 'align'>;
|
16 |
|
17 | type LabelCallback<Type = void> = (
|
18 | text: Tick['text'],
|
19 | index: number,
|
20 | total: number
|
21 | ) => StyleText<Type>;
|
22 | type GridCallBack = (text: Tick['text'], index: number, total: number) => LineStyleProps;
|
23 |
|
24 | interface symbolStyleProps extends MarkerStyleProps {
|
25 | type?: MarkerStyleProps.symbol;
|
26 | }
|
27 | export interface Style<Type = void> {
|
28 | grid?: LineStyleProps;
|
29 | tickLine?: TickLine;
|
30 | line?: LineStyleProps;
|
31 | symbol?: symbolStyleProps | symbolStyleProps[];
|
32 | labelOffset?: number;
|
33 | label?: StyleText<Type>;
|
34 | }
|
35 |
|
36 | export interface StyleProps<Type = void> extends Omit<Style, 'label' | 'grid' | 'labelOffset'> {
|
37 | width?: number | string;
|
38 | height?: number | string;
|
39 | label?: StyleText<Type> | LabelCallback<Type>;
|
40 | grid?: LineStyleProps | GridCallBack;
|
41 | labelOffset?: number | string;
|
42 | }
|
43 |
|
44 | interface Point {
|
45 | x: number;
|
46 | y: number;
|
47 | }
|
48 |
|
49 | export interface Tick {
|
50 | value: number;
|
51 | points: Point[];
|
52 | text: string;
|
53 | tickValue: string | number;
|
54 | labelStyle?: Text;
|
55 | gridStyle?: LineStyleProps;
|
56 | gridPoints?: Point[];
|
57 | }
|
58 |
|
59 | type PolarCord = Pick<Coord, 'center'>;
|
60 | type RectCord = Pick<Coord, 'left' | 'right' | 'bottom' | 'top'>;
|
61 |
|
62 | export interface RectProps<Type = void> {
|
63 | ticks?: Tick[];
|
64 | coord?: RectCord;
|
65 | style?: Style<Type>;
|
66 | animation?: any;
|
67 | }
|
68 |
|
69 | export interface PolarProps {
|
70 | ticks?: Tick[];
|
71 | coord?: PolarCord;
|
72 | style?: Style;
|
73 | animation?: any;
|
74 | grid?: 'line' | 'arc';
|
75 | gridPoints?: Point[][];
|
76 | }
|
77 |
|
78 | export class RectOrPolarCoord<T extends boolean> extends Coord {
|
79 | isPolar: T;
|
80 | }
|
81 |
|
82 | export interface RectAxisProps {
|
83 | coord: RectOrPolarCoord<true>;
|
84 | position: 'right' | 'left' | 'top' | 'bottom';
|
85 | ticks?: Tick[];
|
86 | style?: Style;
|
87 | animation?: any;
|
88 | }
|
89 |
|
90 | export interface PolarAxisProps {
|
91 | coord: RectOrPolarCoord<false>;
|
92 | dimType: 'x' | 'y';
|
93 | ticks?: Tick[];
|
94 | style?: Style;
|
95 | animation?: any;
|
96 | }
|
97 |
|
98 | export interface AxisProps<
|
99 | TRecord extends DataRecord = DataRecord,
|
100 | TField extends DataField<TRecord> = DataField<TRecord>
|
101 | > {
|
102 | |
103 |
|
104 |
|
105 | visible?: boolean;
|
106 | |
107 |
|
108 |
|
109 | field: TField;
|
110 | |
111 |
|
112 |
|
113 | position?: 'right' | 'left' | 'top' | 'bottom';
|
114 | |
115 |
|
116 |
|
117 |
|
118 | formatter?: (value: DataValue<TRecord, TField>) => string | number;
|
119 | type?: string;
|
120 | tickCount?: number;
|
121 | range?: any;
|
122 | mask?: string;
|
123 | min?: number;
|
124 | max?: number;
|
125 | nice?: boolean;
|
126 | ticks?: Array;
|
127 | |
128 |
|
129 |
|
130 | style?: StyleProps;
|
131 |
|
132 | grid?: 'arc' | 'line';
|
133 | }
|