forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chartist.d.ts
268 lines (229 loc) · 8.36 KB
/
chartist.d.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
// Type definitions for Chartist v0.9.4
// Project: https://github.com/gionkunz/chartist-js
// Definitions by: Matt Gibbs <https://github.com/mtgibbs>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module Chartist {
interface ChartistStatic {
Pie: IChartistPieChart;
Bar: IChartistBarChart;
Line: IChartistLineChart;
Svg: any;
noop: Function;
}
interface IResponsiveOptionTuple<T extends IChartOptions> extends Array<string | T> {
0: string;
1: T;
}
interface IChartistBase<T extends IChartOptions> {
container: any;
data: Object;
defaultOptions: T;
options: T;
responsiveOptions: Array<IResponsiveOptionTuple<T>>;
// this most likely doesn't need to be exposed to the user
eventEmitter: any;
supportsForeignObject: boolean;
supportsAnimations: boolean;
resizeListener: any;
update(data: Object, options?: T, override?: boolean): void;
detatch(): void;
/**
* Use this function to register event handlers. The handler callbacks are synchronous and will run in the main thread rather than the event loop.
*
* @method on
* @param event {string} Name of the event. Check the examples for supported events.
* @param handler {Function} The handler function that will be called when an event with the given name was emitted. This function will receive a data argument which contains event data. See the example for more details.
*/
on(event: string, handler: Function): IChartistBase<T>;
/**
* Use this function to un-register event handlers. If the handler function parameter is omitted all handlers for the given event will be un-registered.
*
* @method off
* @param event {string} Name of the event for which a handler should be removed
* @param handler {Function} The handler function that that was previously used to register a new event handler. This handler will be removed from the event handler list. If this parameter is omitted then all event handlers for the given event are removed from the list.
*/
off(event: string, handler?: Function): IChartistBase<T>;
}
interface IChartistPieChart extends IChartistBase<IPieChartOptions> {
new (target: any, data: Object, options?: IPieChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<IPieChartOptions>>): IChartistPieChart;
}
interface IChartistLineChart extends IChartistBase<ILineChartOptions> {
new (target: any, data: Object, options?: ILineChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<ILineChartOptions>>): IChartistLineChart;
}
interface IChartistBarChart extends IChartistBase<IBarChartOptions> {
new (target: any, data: Object, options?: IBarChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<IBarChartOptions>>): IChartistBarChart;
}
interface IChartOptions {
/**
* If true the whole data is reversed including labels, the series order as well as the whole series data arrays.
*/
reverseData?: boolean;
}
interface IPieChartOptions extends IChartOptions {
/**
* Specify a fixed width for the chart as a string (i.e. '100px' or '50%')
*/
width?: number | string;
/**
* Specify a fixed height for the chart as a string (i.e. '100px' or '50%')
*/
height?: number | string;
/**
* Padding of the chart drawing area to the container element and labels as a number or padding object {top: 5, right: 5, bottom: 5, left: 5}
*/
chartPadding?: IChartPadding | number;
/**
* Override the class names that are used to generate the SVG structure of the chart
*/
classNames?: IPieChartClasses;
/**
* The start angle of the pie chart in degrees where 0 points north. A higher value offsets the start angle clockwise.
*/
startAngle?: number;
/**
* An optional total you can specify. By specifying a total value, the sum of the values in the series must be this total in order to draw a full pie. You can use this parameter to draw only parts of a pie or gauge charts.
*/
total?: number;
/**
* If specified the donut CSS classes will be used and strokes will be drawn instead of pie slices.
*/
donut?: boolean;
/**
* Specify the donut stroke width, currently done in javascript for convenience.
*/
donutWidth?: number;
/**
* Specify if a label should be shown or not
*/
showLabel?: boolean;
/**
* Label position offset from the standard position which is half distance of the radius. This value can be either positive or negative. Positive values will position the label away from the center.
*/
labelOffset?: number;
/**
* This option can be set to 'inside', 'outside' or 'center'. Positioned with 'inside' the labels will be placed on half the distance of the radius to the border of the Pie by respecting the 'labelOffset'. The 'outside' option will place the labels at the border of the pie and 'center' will place the labels in the absolute center point of the chart. The 'center' option only makes sense in conjunction with the 'labelOffset' option.
*/
labelPosition?: string;
/**
* An interpolation function for the label value
*/
labelInterpolationFnc?: Function;
/**
* Label direction can be 'neutral', 'explode' or 'implode'. Default is 'neutral'. The labels anchor will be positioned based on those settings as well as the fact if the labels are on the right or left side of the center of the chart. Usually explode is useful when labels are positioned far away from the center.
*/
labelDirection?: string;
}
interface IChartPadding {
top?: number;
right?: number;
bottom?: number;
left?: number;
}
interface IPieChartClasses {
chartPie?: string;
chartDonut?: string;
series?: string;
slicePie?: string;
sliceDonut?: string;
label?: string;
}
interface IBarChartOptions extends IChartOptions {
axisX?: IBarChartAxis;
axisY?: IBarChartAxis;
width?: number | string;
height?: number | string;
high?: number;
low?: number;
onlyInteger?: boolean;
chartPadding?: IChartPadding;
seriesBarDistance?: number;
/**
* If set to true this property will cause the series bars to be stacked and form a total for each series point. This will also influence the y-axis and the overall bounds of the chart. In stacked mode the seriesBarDistance property will have no effect.
*/
stackBars?: boolean;
horizontalBars?: boolean;
distributeSeries?: boolean;
}
interface IBarChartAxis {
offset?: number;
position?: string;
labelOffset?: {
x?: number;
y?: number;
};
showLabel?: boolean;
showGrid?: boolean;
labelInterpolationFnc?: Function;
scaleMinSpace?: number;
onlyInteger?: boolean;
}
interface IBarChartClasses {
chart?: string;
horizontalBars?: string;
label?: string;
labelGroup?: string;
series?: string;
bar?: string;
grid?: string;
gridGroup?: string;
vertical?: string;
horizontal?: string;
start?: string;
end?: string;
}
interface ILineChartOptions extends IChartOptions {
axisX?: ILineChartXAxis;
axisY?: ILineChartYAxis;
width?: number | string;
height?: number | string;
showLine?: boolean;
showPoint?: boolean;
showArea?: boolean;
areaBase?: number;
lineSmooth?: boolean;
low?: number;
high?: number;
chartPadding?: IChartPadding;
fullWidth?: boolean;
reverseData?: boolean;
classNames?: ILineChartClasses;
}
interface ILineChartAxis {
offset?: number;
position?: string;
labelOffset?: {
x?: number;
y?: number;
};
showLabel?: boolean;
showGrid?: boolean;
labelInterpolationFnc?: Function;
type?: any;
}
interface ILineChartXAxis extends ILineChartAxis {
}
interface ILineChartYAxis extends ILineChartAxis {
scaleMinSpace?: number;
onlyInteger?: boolean;
}
// TODO: Finish documenting all of the defaults
interface ILineChartClasses {
/**
* Default is 'ct-chart-line'
*/
chart?: string;
label?: string;
labelGroup?: string;
series?: string;
line?: string;
point?: string;
area?: string;
grid?: string;
gridGroup?: string;
vertical?: string;
horizontal?: string;
start?: string;
end?: string;
}
}
declare var Chartist: Chartist.ChartistStatic;