-
Notifications
You must be signed in to change notification settings - Fork 182
/
components.ts
360 lines (344 loc) · 6.94 KB
/
components.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
import type {
LayoutGrowth,
LegendOrientations,
LegendPositions,
Alignments,
ToolbarControlTypes,
ZoomBarTypes
} from './enums'
import type { Component } from '../components'
import type { TruncationOptions } from './truncation'
/**
*Locale Options Interface
*/
export interface Locale {
code?: string // BCP 47 language tag
number?: (value: number, language: string) => string
date?: (
value: Date,
language: string,
options: Intl.DateTimeFormatOptions,
preformattedLocaleValue?: string
) => string
time?: (
value: Date,
language: string,
options: Intl.DateTimeFormatOptions,
preformattedLocaleValue?: string
) => string
optionsObject?: {
'15seconds'?: LocaleTimeScaleOptions
minute?: LocaleTimeScaleOptions
'30minutes'?: LocaleTimeScaleOptions
hourly?: LocaleTimeScaleOptions
daily?: LocaleTimeScaleOptions
weekly?: LocaleTimeScaleOptions
monthly?: LocaleTimeScaleOptions
quarterly?: LocaleTimeScaleOptions
yearly?: LocaleTimeScaleOptions
}
translations?: {
group?: string // used by Tooltip and Toolbar / Tabular Representation
total?: string // ditto
meter?: {
title?: string
}
tabularRep: {
title?: string
downloadAsCSV?: string
}
toolbar: {
exportAsCSV?: string
exportAsJPG?: string
exportAsPNG?: string
zoomIn?: string
zoomOut?: string
resetZoom?: string
moreOptions?: string
makeFullScreen?: string
exitFullScreen?: string
showAsTable?: string
}
}
}
export interface LocaleTimeScaleOptions {
primary?: Record<
string,
{
month?: string
day?: string
hour?: string
minute?: string
second?: string
fractionalSecondDigits?: number
weekday?: string
year?: string
hourCycle?: string
hour12?: boolean
dayPeriod?: string
}
>
secondary?: Record<
string,
{
month?: string
day?: string
hour?: string
minute?: string
second?: string
fractionalSecondDigits?: number
weekday?: string
year?: string
hourCycle?: string
hour12?: boolean
dayPeriod?: string
}
>
type?: string
}
/**
* customize the overlay contents
*/
export interface LayoutComponentChild {
id: string
/**
* the component that'll be rendered inside layout child
*/
components: Component[]
/**
* size of the layout child
*/
size?: number
/**
* how the layout child will grow or shrink
*/
growth: LayoutGrowth | string
}
/**
* customize the legend component
*/
export interface LegendOptions {
enabled?: boolean
position?: LegendPositions | string
/**
* the clickability of legend items
*/
clickable?: boolean
truncation?: TruncationOptions
alignment?: Alignments | string
order?: string[]
/**
* customized legend items
*/
additionalItems?: LegendItem[]
orientation?: LegendOrientations
}
/**
* customize the legend item
*/
export interface LegendItem {
type: string
name: string
fill?: string
stroke?: string
}
export interface TooltipOptions {
/**
* enable or disable tooltip
*/
enabled?: boolean
/**
* a function to format the tooltip values
*/
valueFormatter?: (value: any, label: string) => string
/**
* custom function for returning tooltip HTML
* passed an array or object with the data, and then the default tooltip markup
*/
customHTML?: (data: any, defaultHTML: string) => string
/**
* customizes the `Group` label shown inside tooltips
*/
groupLabel?: string
/**
* show total of items
*/
showTotal?: boolean
/**
* customizes the `Total` label shown inside tooltips
*/
totalLabel?: string
truncation?: TruncationOptions
}
/**
* Threshold options
*/
export interface ThresholdOptions {
/**
* threshold value
*/
value: number | Date
/**
* a function to format the threshold values
*/
valueFormatter?: (value: any) => string
/**
* hex threshold line color
*/
fillColor?: string
/**
* threshold label
*/
label?: string
}
export interface GridOptions {
y?: {
enabled?: boolean
numberOfTicks?: number
alignWithAxisTicks?: boolean
}
x?: {
enabled?: boolean
numberOfTicks?: number
alignWithAxisTicks?: boolean
}
}
/**
* Ruler options
*/
export interface RulerOptions {
enabled?: boolean
}
export interface BarOptions {
width?: number
maxWidth?: number
/*
* can be used to manually modify spacing between bars
* @default 0.25
*/
spacingFactor?: number
}
export interface StackedBarOptions extends BarOptions {
dividerSize?: number
}
/**
* customize the Toolbar component
*/
export interface ToolbarOptions {
/**
* is the toolbar visible or not
*/
enabled?: boolean
/**
* the maximum toolbar controls to be displayed as icons
* controls more than this number will appear in the overflow menu
* minimum is 1. (all toolbar controls are in overflow menu)
*/
numberOfIcons?: number
/**
* toolbar controls which will be displayed following the array order
*/
controls?: ToolbarControl[]
}
/**
* options for each toolbar control
*/
export interface ToolbarControl {
/**
* the toolbar control type
*/
type: ToolbarControlTypes | string
/**
* used as aria-label for toolbar control
*/
title?: string
/**
* the text to display (if this control is displayed in overflow menu)
* type value will be displayed if text is not available
*/
text?: string
/**
* custom id for button
*/
id?: string
/**
* SVG HTML element
*/
iconSVG?: {
content?: string
height?: string
width?: string
}
shouldBeDisabled?: () => boolean
/**
* function to execute on button click
* alternatively, users can choose to not pass in a function and can
* listen for events to execute asynchronously
*/
clickFunction?: () => void
}
/**
* customize the ZoomBars in a chart
*/
export interface ZoomBarsOptions {
/**
* a variable to handle default zoom in ratio (0 ~ 1.0)
* ex: shift click zoom in ratio
*/
zoomRatio?: number
/**
* a variable to define the minimum zoom ratio (0 ~ 1.0)
* If ( zoom domain / max domain ) < minZoomRatio, zoom-in functions will be disabled
*/
minZoomRatio?: number
/**
* currently only the top position is supported
*/
top?: ZoomBarOptions
/**
* whether keep updating range axis in real time while zoom domain is changing
*/
updateRangeAxis?: boolean
}
/**
* customize the ZoomBar component
*/
export interface ZoomBarOptions {
/**
* is the zoom-bar visible or not
*/
enabled?: boolean
/**
* is the zoom-bar in loading state
*/
loading?: boolean
/**
* is the zoom-bar in locked state
*/
locked?: boolean
/**
* whether the zoom bar is showing a slider view or a graph view etc.
*/
type?: ZoomBarTypes | string
/**
* an two element array which represents the initial zoom domain
*/
initialZoomDomain?: object[]
/**
* options related to zoom bar data
*/
data?: object[]
}
/**
* customize the Tabular Data
*/
export interface TabularRepCustomizationOptions {
/**
* option to customize the Table Headers
*/
tableHeadingFormatter?: (headings: string[]) => string[]
/**
* option to customize the Table Cells
*/
tableCellFormatter?: (cells: string[][]) => string[][]
}