1 | import { MarkComponent } from '../runtime';
|
2 | import { Encode } from './encode';
|
3 | import { Transform } from './transform';
|
4 | import { Scale } from './scale';
|
5 | import { Coordinate } from './coordinate';
|
6 | import { Animation } from './animate';
|
7 | import { Interaction } from './interaction';
|
8 | import { Theme } from './theme';
|
9 | import { Data } from './data';
|
10 | import { AxisComponent, LegendComponent, ScrollbarComponent, SliderComponent, TitleComponent, TooltipComponent } from './component';
|
11 | import { Closeable, Literal2Object, Padding } from './utils';
|
12 | export type Mark = IntervalMark | RectMark | LineMark | PointMark | TextMark | CellMark | AreaMark | NodeMark | EdgeMark | ImageMark | PolygonMark | BoxMark | VectorMark | LineXMark | LineYMark | RangeMark | RangeXMark | RangeYMark | ConnectorMark | SankeyMark | ChordMark | PathMark | TreemapMark | PackMark | BoxPlotMark | ShapeMark | ForceGraphMark | TreeMark | WordCloudMark | DensityMark | CustomMark | CompositeMark;
|
13 | export type MarkTypes = 'auto' | 'interval' | 'rect' | 'line' | 'point' | 'text' | 'cell' | 'area' | 'node' | 'edge' | 'link' | 'image' | 'polygon' | 'box' | 'vector' | 'lineX' | 'lineY' | 'connector' | 'range' | 'rangeX' | 'rangeY' | 'sankey' | 'chord' | 'path' | 'treemap' | 'pack' | 'boxplot' | 'shape' | 'forceGraph' | 'tree' | 'wordCloud' | 'gauge' | 'density' | 'heatmap' | 'liquid' | MarkComponent | CompositeMarkType;
|
14 | export type ChannelTypes = 'x' | 'y' | 'z' | 'x1' | 'y1' | 'series' | 'color' | 'opacity' | 'shape' | 'size' | 'key' | 'groupKey' | 'position' | 'series' | 'enterType' | 'enterEasing' | 'enterDuration' | 'enterDelay' | 'updateType' | 'updateEasing' | 'updateDuration' | 'updateDelay' | 'exitType' | 'exitEasing' | 'exitDuration' | 'exitDelay' | `position${number}`;
|
15 | export type PositionChannelTypes = 'x' | 'y' | 'z' | 'position' | `position${number}`;
|
16 | export type AtheisticChanelTypes = 'size' | 'color' | 'shape' | 'opacity';
|
17 | export type BaseMark<T extends MarkTypes, C extends string = ChannelTypes> = {
|
18 | type?: T | string;
|
19 | class?: string;
|
20 | key?: string;
|
21 | x?: number;
|
22 | y?: number;
|
23 | width?: number;
|
24 | height?: number;
|
25 | paddingLeft?: Padding;
|
26 | paddingRight?: Padding;
|
27 | paddingBottom?: Padding;
|
28 | paddingTop?: Padding;
|
29 | padding?: Padding;
|
30 | inset?: number;
|
31 | insetLeft?: number;
|
32 | insetBottom?: number;
|
33 | insetTop?: number;
|
34 | insetRight?: number;
|
35 | margin?: number;
|
36 | marginLeft?: number;
|
37 | marginBottom?: number;
|
38 | marginTop?: number;
|
39 | marginRight?: number;
|
40 | facet?: boolean;
|
41 | frame?: boolean;
|
42 | zIndex?: number;
|
43 | cartesian?: boolean;
|
44 | clip?: boolean;
|
45 | data?: Data;
|
46 | transform?: Transform[];
|
47 | layout?: Record<string, any>;
|
48 | encode?: Partial<Record<C, Encode | Encode[]>>;
|
49 | scale?: Partial<Record<C, Scale>>;
|
50 | coordinate?: Coordinate;
|
51 | style?: Record<string, any>;
|
52 | viewStyle?: Record<string, any>;
|
53 | state?: Partial<Record<'active' | 'selected' | 'inactive' | 'unselected', Record<string, any>>>;
|
54 | animate?: Closeable<Partial<Record<'enter' | 'update' | 'exit', Closeable<Animation>>>>;
|
55 | labels?: Record<string, any>[];
|
56 | tooltip?: TooltipComponent;
|
57 | axis?: Closeable<Partial<Record<PositionChannelTypes, Closeable<AxisComponent>>>>;
|
58 | legend?: Closeable<Partial<Record<AtheisticChanelTypes, Closeable<LegendComponent>>>>;
|
59 | slider?: Closeable<Partial<Record<PositionChannelTypes, Closeable<SliderComponent>>>>;
|
60 | scrollbar?: Closeable<Partial<Record<PositionChannelTypes, Closeable<ScrollbarComponent>>>>;
|
61 | title?: string | TitleComponent;
|
62 | interaction?: Literal2Object<Interaction> & Record<string, any>;
|
63 | theme?: Theme;
|
64 | };
|
65 | export type CompositeMarkType = (options: Record<string, any>, context: Record<string, any>) => any[];
|
66 | export type CompositeMark = BaseMark<CompositeMarkType>;
|
67 | export type IntervalMark = BaseMark<'interval', ChannelTypes | 'series'>;
|
68 | export type RectMark = BaseMark<'rect', ChannelTypes>;
|
69 | export type LineMark = BaseMark<'line', ChannelTypes | 'position' | `position${number}`>;
|
70 | export type PointMark = BaseMark<'point'>;
|
71 | export type TextMark = BaseMark<'text', ChannelTypes | 'text' | 'fontSize' | 'fontWeight' | 'rotate'>;
|
72 | export type LineXMark = BaseMark<'lineX', ChannelTypes>;
|
73 | export type LineYMark = BaseMark<'lineY', ChannelTypes>;
|
74 | export type RangeMark = BaseMark<'range', ChannelTypes>;
|
75 | export type RangeXMark = BaseMark<'rangeX', ChannelTypes>;
|
76 | export type RangeYMark = BaseMark<'rangeY', ChannelTypes>;
|
77 | export type ConnectorMark = BaseMark<'connector', ChannelTypes>;
|
78 | export type CellMark = BaseMark<'cell', ChannelTypes>;
|
79 | export type AreaMark = BaseMark<'area', ChannelTypes>;
|
80 | export type NodeMark = BaseMark<'node', ChannelTypes>;
|
81 | export type EdgeMark = BaseMark<'edge', ChannelTypes>;
|
82 | export type LinkMark = BaseMark<'link', ChannelTypes>;
|
83 | export type ImageMark = BaseMark<'image', ChannelTypes | 'src'>;
|
84 | export type PolygonMark = BaseMark<'polygon', ChannelTypes>;
|
85 | export type BoxMark = BaseMark<'box', ChannelTypes>;
|
86 | export type BoxPlotMark = BaseMark<'box', ChannelTypes>;
|
87 | export type ShapeMark = BaseMark<'shape', ChannelTypes>;
|
88 | export type VectorMark = BaseMark<'vector', ChannelTypes | 'rotate' | 'size'>;
|
89 | export type SankeyMark = BaseMark<'sankey', 'source' | 'target' | 'value' | `node${Capitalize<ChannelTypes>}` | `link${Capitalize<ChannelTypes>}` | ChannelTypes> & {
|
90 | layout?: {
|
91 | nodeId?: (node: any) => string;
|
92 | nodes?: (graph: any) => any;
|
93 | links?: (graph: any) => any;
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 | nodeSort?: null | undefined | ((a: any, b: any) => number);
|
100 | /**
|
101 | * sankey.linkSort(undefined) is the default, indicating that vertical order of links within each node will be determined automatically by the layout. If
|
102 | * sankey.linkSort(null) will resort by the input.
|
103 | * sankey.linkSort(function) specifies the given order as a comparator function and sorts once on initialization.
|
104 | */
|
105 | linkSort?: null | undefined | ((a: any, b: any) => number);
|
106 | nodeAlign?: 'left' | 'center' | 'right' | 'justify' | ((node: any, n: number) => number);
|
107 | nodeWidth?: number;
|
108 | nodePadding?: number;
|
109 | iterations?: number;
|
110 | nodeDepth?: (datum: any, maxDepth: number) => number;
|
111 | };
|
112 | nodeLabels: Record<string, any>[];
|
113 | linkLabels: Record<string, any>[];
|
114 | };
|
115 | export type ChordMark = BaseMark<'chord', 'source' | 'target' | 'value' | `node${Capitalize<ChannelTypes>}` | `link${Capitalize<ChannelTypes>}` | ChannelTypes> & {
|
116 | layout?: {
|
117 | nodes?: (graph: any) => any;
|
118 | links?: (graph: any) => any;
|
119 | y?: number;
|
120 | id?: (node: any) => any;
|
121 | sortBy?: 'id' | 'weight' | 'frequency' | null | ((a: any, b: any) => number);
|
122 | nodeWidthRatio?: number;
|
123 | nodePaddingRatio?: number;
|
124 | sourceWeight?(edge: any): number;
|
125 | targetWeight?(edge: any): number;
|
126 | };
|
127 | nodeLabels: Record<string, any>[];
|
128 | linkLabels: Record<string, any>[];
|
129 | };
|
130 | export type PathMark = BaseMark<'path', ChannelTypes | 'd'>;
|
131 | export type TreemapMark = BaseMark<'treemap', 'value' | ChannelTypes> & {
|
132 | layout?: Record<string, any>;
|
133 | };
|
134 | export type PackMark = BaseMark<'pack', 'value' | ChannelTypes> & {
|
135 | layout?: Record<string, any>;
|
136 | };
|
137 | export type ForceGraphMark = BaseMark<'forceGraph', 'source' | 'target' | 'color' | 'value' | `node${Capitalize<ChannelTypes>}` | `link${Capitalize<ChannelTypes>}`> & {
|
138 | layout?: Record<string, any>;
|
139 | nodeLabels: Record<string, any>[];
|
140 | linkLabels: Record<string, any>[];
|
141 | };
|
142 | export type TreeMark = BaseMark<'tree', 'value' | ChannelTypes> & {
|
143 | layout?: {
|
144 | /**
|
145 | * Layout field. Default: 'value'.
|
146 | */
|
147 | field?: string;
|
148 | /**
|
149 | * Sets this cluster layout’s node size to the specified two-element array of numbers [width, height] and returns this cluster layout.
|
150 | * Default: null.
|
151 | */
|
152 | nodeSize?: any;
|
153 | /**
|
154 | * The separation accessor is used to separate neighboring leaves. Default: (a, b) => a.parent == b.parent ? 1 : 2;
|
155 | */
|
156 | separation?: (a: any, b: any) => number;
|
157 | |
158 |
|
159 |
|
160 | sortBy?: (a: any, b: any) => number;
|
161 | |
162 |
|
163 |
|
164 | as?: [string, string];
|
165 | };
|
166 | nodeLabels: Record<string, any>[];
|
167 | linkLabels: Record<string, any>[];
|
168 | };
|
169 | export type WordCloudMark = BaseMark<'wordCloud', 'value' | ChannelTypes | 'text'> & {
|
170 | layout?: {
|
171 | |
172 |
|
173 |
|
174 |
|
175 | size?: [number, number];
|
176 | font?: string | ((word: any) => string);
|
177 | fontStyle?: string | ((word: any) => string);
|
178 | fontWeight?: any | ((word: any) => any);
|
179 | fontSize?: number | [number, number] | ((word: any) => number);
|
180 | padding?: number | ((word: any) => number);
|
181 | /**
|
182 | * @description sets the text accessor function, which indicates the text for each word
|
183 | * @default (d) => d.text
|
184 | */
|
185 | text?: (word: any) => number;
|
186 | rotate?: number | ((word: any) => number);
|
187 | timeInterval?: number;
|
188 | random?: number | (() => number);
|
189 | /**
|
190 | * @description sets the current type of spiral used for positioning words. This can either be one of the two built-in spirals, "archimedean" and "rectangular"
|
191 | * @default "archimedean"
|
192 | */
|
193 | spiral?: 'archimedean' | 'rectangular' | ((size: [number, number]) => (t: number) => number[]);
|
194 | imageMask?: HTMLImageElement | string;
|
195 | on?: ((type: 'end', details?: {
|
196 | cloud: any;
|
197 | words: any;
|
198 | bounds: any;
|
199 | }) => void) | ((type: 'word', details?: {
|
200 | cloud: any;
|
201 | word: any;
|
202 | }) => void);
|
203 | };
|
204 | };
|
205 | export type GaugeMark = BaseMark<'gauge', `arc${Capitalize<ChannelTypes>}` | `indicator${Capitalize<ChannelTypes>}` | `pointer${Capitalize<ChannelTypes>}` | `pin${Capitalize<ChannelTypes>}` | ChannelTypes>;
|
206 | export type DensityMark = BaseMark<'density', ChannelTypes | 'series'>;
|
207 | export type HeatmapMark = BaseMark<'heatmap'>;
|
208 | export type LiquidMark = BaseMark<'liquid'>;
|
209 | export type CustomMark = BaseMark<MarkComponent, ChannelTypes>;
|
210 |
|
\ | No newline at end of file |