1 |
|
2 |
|
3 | import { Selection, TransitionLike } from "d3-selection";
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export type AxisDomain = number | string | Date | { valueOf(): number };
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | export interface AxisTimeInterval {
|
27 | range(start: Date, stop: Date, step?: number): Date[];
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | export interface AxisScale<Domain> {
|
35 | (x: Domain): number | undefined;
|
36 | domain(): Domain[];
|
37 | range(): number[];
|
38 | copy(): this;
|
39 | bandwidth?(): number;
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | }
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | export type AxisContainerElement = SVGSVGElement | SVGGElement;
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | export interface Axis<Domain> {
|
56 | |
57 |
|
58 |
|
59 |
|
60 |
|
61 | (
|
62 | context:
|
63 | | Selection<SVGSVGElement, any, any, any>
|
64 | | Selection<SVGGElement, any, any, any>
|
65 | | TransitionLike<SVGSVGElement, any>
|
66 | | TransitionLike<SVGGElement, any>,
|
67 | ): void;
|
68 |
|
69 | |
70 |
|
71 |
|
72 |
|
73 | scale<A extends AxisScale<Domain>>(): A;
|
74 |
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 | scale(scale: AxisScale<Domain>): this;
|
81 |
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | ticks(count: number, specifier?: string): this;
|
93 |
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | ticks(interval: AxisTimeInterval, specifier?: string): this;
|
106 |
|
107 | |
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | ticks(arg0: any, ...args: any[]): this;
|
120 |
|
121 | |
122 |
|
123 |
|
124 | tickArguments(): any[];
|
125 |
|
126 | |
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | tickArguments(args: any[]): this;
|
139 |
|
140 | |
141 |
|
142 |
|
143 | tickValues(): Domain[] | null;
|
144 |
|
145 | |
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 | tickValues(values: Iterable<Domain>): this;
|
154 |
|
155 | |
156 |
|
157 |
|
158 |
|
159 |
|
160 | tickValues(values: null): this;
|
161 |
|
162 | |
163 |
|
164 |
|
165 | tickFormat(): ((domainValue: Domain, index: number) => string) | null;
|
166 |
|
167 | /**
|
168 | * Sets the tick format function and returns the axis.
|
169 | *
|
170 | * @param format A function mapping a value from the axis Domain to a formatted string
|
171 | * for display purposes. When invoked, the format function is also passed a second argument representing the zero-based index
|
172 | * of the tick label in the array of generated tick labels.
|
173 | */
|
174 | tickFormat(format: (domainValue: Domain, index: number) => string): this;
|
175 |
|
176 | /**
|
177 | * Reset the tick format function. A null format indicates that the scale’s
|
178 | * default formatter should be used, which is generated by calling scale.tickFormat.
|
179 | * In this case, the arguments specified by axis.tickArguments
|
180 | * are likewise passed to scale.tickFormat.
|
181 | *
|
182 | * @param format null
|
183 | */
|
184 | tickFormat(format: null): this;
|
185 |
|
186 | /**
|
187 | * Get the current inner tick size, which defaults to 6.
|
188 | */
|
189 | tickSize(): number;
|
190 | /**
|
191 | * Set the inner and outer tick size to the specified value and return the axis.
|
192 | *
|
193 | * @param size Tick size in pixels (Default is 6).
|
194 | */
|
195 | tickSize(size: number): this;
|
196 |
|
197 | /**
|
198 | * Get the current inner tick size, which defaults to 6.
|
199 | * The inner tick size controls the length of the tick lines,
|
200 | * offset from the native position of the axis.
|
201 | */
|
202 | tickSizeInner(): number;
|
203 |
|
204 | /**
|
205 | * Set the inner tick size to the specified value and return the axis.
|
206 | * The inner tick size controls the length of the tick lines,
|
207 | * offset from the native position of the axis.
|
208 | *
|
209 | * @param size Tick size in pixels (Default is 6).
|
210 | */
|
211 | tickSizeInner(size: number): this;
|
212 |
|
213 | /**
|
214 | * Get the current outer tick size, which defaults to 6.
|
215 | * The outer tick size controls the length of the square ends of the domain path,
|
216 | * offset from the native position of the axis. Thus, the “outer ticks” are not actually
|
217 | * ticks but part of the domain path, and their position is determined by the associated
|
218 | * scale’s domain extent. Thus, outer ticks may overlap with the first or last inner tick.
|
219 | * An outer tick size of 0 suppresses the square ends of the domain path,
|
220 | * instead producing a straight line.
|
221 | */
|
222 | tickSizeOuter(): number;
|
223 |
|
224 | /**
|
225 | * Set the current outer tick size and return the axis.
|
226 | * The outer tick size controls the length of the square ends of the domain path,
|
227 | * offset from the native position of the axis. Thus, the “outer ticks” are not actually
|
228 | * ticks but part of the domain path, and their position is determined by the associated
|
229 | * scale’s domain extent. Thus, outer ticks may overlap with the first or last inner tick.
|
230 | * An outer tick size of 0 suppresses the square ends of the domain path,
|
231 | * instead producing a straight line.
|
232 | *
|
233 | * @param size Tick size in pixels (Default is 6).
|
234 | */
|
235 | tickSizeOuter(size: number): this;
|
236 |
|
237 | /**
|
238 | * Get the current padding, which defaults to 3.
|
239 | */
|
240 | tickPadding(): number;
|
241 |
|
242 | /**
|
243 | * Set the current padding and return the axis.
|
244 | *
|
245 | * @param padding Padding in pixels (Default is 3).
|
246 | */
|
247 | tickPadding(padding: number): this;
|
248 |
|
249 | /**
|
250 | * Returns the current offset which defaults to 0 on devices with a devicePixelRatio greater than 1, and 0.5px otherwise.
|
251 | * This default offset ensures crisp edges on low-resolution devices.
|
252 | */
|
253 | offset(): number;
|
254 |
|
255 | /**
|
256 | * Sets the offset to the specified value in pixels and returns the axis.
|
257 | * Defaults to 0 on devices with a devicePixelRatio greater than 1, and 0.5px otherwise.
|
258 | * This default offset ensures crisp edges on low-resolution devices.
|
259 | */
|
260 | offset(offset: number): this;
|
261 | }
|
262 |
|
263 | /**
|
264 | * Constructs a new top-oriented axis generator for the given scale, with empty tick arguments,
|
265 | * a tick size of 6 and padding of 3. In this orientation, ticks are drawn above the horizontal domain path.
|
266 | *
|
267 | * @param scale The scale to be used for axis generation.
|
268 | */
|
269 | export function axisTop<Domain extends AxisDomain>(scale: AxisScale<Domain>): Axis<Domain>;
|
270 |
|
271 | /**
|
272 | * Constructs a new right-oriented axis generator for the given scale, with empty tick arguments,
|
273 | * a tick size of 6 and padding of 3. In this orientation, ticks are drawn to the right of the vertical domain path.
|
274 | *
|
275 | * @param scale The scale to be used for axis generation.
|
276 | */
|
277 | export function axisRight<Domain extends AxisDomain>(scale: AxisScale<Domain>): Axis<Domain>;
|
278 |
|
279 | /**
|
280 | * Constructs a new bottom-oriented axis generator for the given scale, with empty tick arguments,
|
281 | * a tick size of 6 and padding of 3. In this orientation, ticks are drawn below the horizontal domain path.
|
282 | *
|
283 | * @param scale The scale to be used for axis generation.
|
284 | */
|
285 | export function axisBottom<Domain extends AxisDomain>(scale: AxisScale<Domain>): Axis<Domain>;
|
286 |
|
287 | /**
|
288 | * Constructs a new left-oriented axis generator for the given scale, with empty tick arguments,
|
289 | * a tick size of 6 and padding of 3. In this orientation, ticks are drawn to the left of the vertical domain path.
|
290 | *
|
291 | * @param scale The scale to be used for axis generation.
|
292 | */
|
293 | export function axisLeft<Domain extends AxisDomain>(scale: AxisScale<Domain>): Axis<Domain>;
|
294 |
|
\ | No newline at end of file |