1 |
|
2 |
|
3 |
|
4 |
|
5 | export interface Axis {
|
6 | |
7 |
|
8 |
|
9 | rotated?: boolean;
|
10 | x?: XAxisConfiguration;
|
11 | y?: YAxisConfiguration;
|
12 | y2?: YAxisConfiguration;
|
13 | }
|
14 |
|
15 | export interface XAxisConfiguration {
|
16 | |
17 |
|
18 |
|
19 | show?: boolean;
|
20 |
|
21 | |
22 |
|
23 |
|
24 | type?: string;
|
25 |
|
26 | |
27 |
|
28 |
|
29 |
|
30 | localtime?: boolean;
|
31 |
|
32 | |
33 |
|
34 |
|
35 |
|
36 |
|
37 | categories?: string[];
|
38 |
|
39 | tick?: XTickConfiguration;
|
40 |
|
41 | |
42 |
|
43 |
|
44 | max?: string | number | Date;
|
45 |
|
46 | |
47 |
|
48 |
|
49 | min?: string | number | Date;
|
50 |
|
51 | |
52 |
|
53 |
|
54 |
|
55 |
|
56 | padding?: {
|
57 | left?: number;
|
58 | right?: number;
|
59 | };
|
60 |
|
61 | |
62 |
|
63 |
|
64 |
|
65 |
|
66 | height?: number;
|
67 |
|
68 | |
69 |
|
70 |
|
71 |
|
72 | extent?: number[] | (() => number[]);
|
73 |
|
74 | /**
|
75 | * Set label on x axis.
|
76 | * You can set x axis label and change its position by this option.
|
77 | * string and object can be passed and we can change the poisiton by passing object that has position key.
|
78 | *
|
79 | * Available position differs according to the axis direction (vertical or horizontal). If string set, the position will be the default.
|
80 | * - Valid horizontal positions: inner-right (Default), inner-center, inner-left, outer-right, outer-center, outer-left
|
81 | * - Valid vertical positions: inner-top, inner-middle, inner-bottom, outer-top, outer-middle, outer-bottom
|
82 | */
|
83 | label?: string | { text: string; position: string };
|
84 |
|
85 | /**
|
86 | * Set clip-path attribute for x axis element.
|
87 | */
|
88 | clipPath?: boolean;
|
89 |
|
90 | /**
|
91 | * Set additional axes for Axis
|
92 | */
|
93 | axes: AxesConfiguration[];
|
94 | }
|
95 |
|
96 | export interface YAxisConfiguration {
|
97 | /**
|
98 | * Show or hide y axis.
|
99 | */
|
100 | show?: boolean;
|
101 |
|
102 | /**
|
103 | * Show y axis inside of the chart.
|
104 | */
|
105 | inner?: boolean;
|
106 |
|
107 | /**
|
108 | * Set max value of y axis.
|
109 | */
|
110 | max?: number;
|
111 |
|
112 | /**
|
113 | * Set min value of y axis.
|
114 | */
|
115 | min?: number;
|
116 |
|
117 | /**
|
118 | * Change the direction of y axis.
|
119 | * If true set, the direction will be from the top to the bottom.
|
120 | */
|
121 | inverted?: boolean;
|
122 |
|
123 | /**
|
124 | * Set center value of y axis.
|
125 | */
|
126 | center?: number;
|
127 |
|
128 | /**
|
129 | * Set label on y axis. This option works in the same way as axis.x.label.
|
130 | *
|
131 | * - Valid horizontal positions:
|
132 | * - inner-right (Default), inner-center, inner-left, outer-right, outer-center, outer-left
|
133 | * - Valid vertical positions:
|
134 | * - inner-top, inner-middle, inner-bottom, outer-top, outer-middle, outer-bottom
|
135 | */
|
136 | label?: string | { text: string; position: string };
|
137 |
|
138 | tick?: YTickConfiguration;
|
139 |
|
140 | /**
|
141 | * Set padding for y axis.
|
142 | * You can set padding for y axis to create more space on the edge of the axis.
|
143 | * This option accepts object and it can include top and bottom. top, bottom will be treated as pixels.
|
144 | */
|
145 | padding?: {
|
146 | top?: number;
|
147 | bottom?: number;
|
148 | };
|
149 |
|
150 | /**
|
151 | * Set default range of y axis.
|
152 | * This option set the default value for y axis when there is no data on init.
|
153 | */
|
154 | default?: number[];
|
155 |
|
156 | /**
|
157 | * Set clip-path attribute for x axis element.
|
158 | */
|
159 | clipPath?: boolean;
|
160 |
|
161 | /**
|
162 | * Set additional axes for Axis
|
163 | */
|
164 | axes: AxesConfiguration[];
|
165 | }
|
166 |
|
167 | export interface XTickConfiguration {
|
168 | /**
|
169 | * Centerise ticks on category axis
|
170 | */
|
171 | centered?: boolean;
|
172 |
|
173 | /**
|
174 | * A function to format tick value. Format string is also available for timeseries data.
|
175 | */
|
176 | format?: string
|
177 | | ((x: number | Date) => string | number)
|
178 | | ((index: number, categoryName: string) => string);
|
179 |
|
180 | /**
|
181 | * Setting for culling ticks.
|
182 | * If true is set, the ticks will be culled, then only limitted tick text will be shown.
|
183 | * This option does not hide the tick lines. If false is set, all of ticks will be shown.
|
184 | */
|
185 | culling?: boolean | {
|
186 | /**
|
187 | * The number of tick texts will be adjusted to less than this value.
|
188 | */
|
189 | max?: number;
|
190 | };
|
191 |
|
192 | /**
|
193 | * The number of x axis ticks to show.
|
194 | * This option hides tick lines together with tick text. If this option is used on timeseries axis, the ticks position will be determined precisely and not nicely positioned (e.g. it will
|
195 | * have rough second value).
|
196 | */
|
197 | count?: number;
|
198 |
|
199 | /**
|
200 | * Fit x axis ticks.
|
201 | * If true set, the ticks will be positioned nicely. If false set, the ticks will be positioned according to x value of the data points.
|
202 | */
|
203 | fit?: boolean;
|
204 |
|
205 | /**
|
206 | * Set the x values of ticks manually.
|
207 | * If this option is provided, the position of the ticks will be determined based on those values.
|
208 | * This option works with timeseries data and the x values will be parsed accoding to the type of the value and data.xFormat option.
|
209 | */
|
210 | values?: number[] | string[];
|
211 |
|
212 | /**
|
213 | * Rotate x axis tick text. If you set negative value, it will rotate to opposite direction.
|
214 | */
|
215 | rotate?: number;
|
216 |
|
217 | /**
|
218 | * Show x axis outer tick.
|
219 | */
|
220 | outer?: boolean;
|
221 |
|
222 | /**
|
223 | * Set width of x axis tick.
|
224 | */
|
225 | width?: number;
|
226 |
|
227 | /**
|
228 | * Set tick text to be multiline
|
229 | * - NOTE: When x tick text contains \n, it's used as line break and 'axis.x.tick.width' option is ignored.
|
230 | */
|
231 | multiline?: boolean;
|
232 |
|
233 | /**
|
234 | * Set to display system tooltip(via 'title' attribute) for tick text
|
235 | * - NOTE: Only available for category axis type (axis.x.type='category')
|
236 | */
|
237 | tooltip?: boolean;
|
238 |
|
239 | text?: {
|
240 | /**
|
241 | * Set the x Axis tick text's position relatively its original position
|
242 | */
|
243 | position?: {
|
244 | x?: number;
|
245 | y?: number;
|
246 | }
|
247 | };
|
248 | }
|
249 |
|
250 | export interface YTickConfiguration {
|
251 | /**
|
252 | * Show or hide outer tick.
|
253 | */
|
254 | outer?: boolean;
|
255 |
|
256 | /**
|
257 | * Set the y values of ticks manually.
|
258 | */
|
259 | values?: number[];
|
260 |
|
261 | /**
|
262 | * The number of y axis ticks to show.
|
263 | * The position of the ticks will be calculated precisely, so the values on the ticks will not be rounded nicely.
|
264 | * In the case, axis.y.tick.format or axis.y.tick.values will be helpful.
|
265 | */
|
266 | count?: number;
|
267 |
|
268 | /**
|
269 | * Set formatter for y axis tick text.
|
270 | * This option accepts d3.format object as well as a function you define.
|
271 | */
|
272 | format?(x: number): string;
|
273 |
|
274 | text?: {
|
275 | /**
|
276 | * Set the x Axis tick text's position relatively its original position
|
277 | */
|
278 | position?: {
|
279 | x?: number;
|
280 | y?: number;
|
281 | }
|
282 | };
|
283 | }
|
284 |
|
285 | export interface AxesConfiguration {
|
286 | tick?: {
|
287 | /**
|
288 | * Show outer tick
|
289 | */
|
290 | outer?: boolean;
|
291 |
|
292 | /**
|
293 | * Set formatter for tick text
|
294 | */
|
295 | format?: (x: string) => string;
|
296 |
|
297 | |
298 |
|
299 |
|
300 | count?: number;
|
301 |
|
302 | |
303 |
|
304 |
|
305 | values?: number|string|Date[];
|
306 | };
|
307 | }
|