Skip to content

Commit ac04dcb

Browse files
committed
JS API TS declaration - event names, color palette/gradient added.
1 parent fa101c6 commit ac04dcb

File tree

1 file changed

+42
-8
lines changed

1 file changed

+42
-8
lines changed

src/apps/weblib/js-api/vizzu.d.ts

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ interface DataSeries {
66
values: string[]|number[];
77
}
88

9-
interface Record {
10-
[key: SeriesName]: string|number;
9+
interface DataRecord {
10+
[key: string]: string|number;
1111
}
1212

1313
interface DataSet {
1414
series: DataSeries[];
15-
filter: (record: any) => boolean;
15+
filter: (record: DataRecord) => boolean;
1616
}
1717

1818
interface Channel {
@@ -135,8 +135,19 @@ interface Legend extends Padding, Box {
135135
};
136136
}
137137

138-
type ColorGradient = string;
139-
type ColorPalette = string;
138+
type ColorStop = `${Color} ${number}`;
139+
140+
type ColorGradient = ColorStop
141+
| `${ColorStop},${ColorStop}`
142+
| `${ColorStop},${ColorStop},${ColorStop}`
143+
| `${ColorStop},${ColorStop},${ColorStop},${ColorStop}`
144+
| `${ColorStop},${ColorStop},${ColorStop},${ColorStop},${ColorStop}`;
145+
146+
type ColorPalette = Color
147+
| `${Color} ${Color}`
148+
| `${Color} ${Color} ${Color}`
149+
| `${Color} ${Color} ${Color} ${Color}`
150+
| `${Color} ${Color} ${Color} ${Color} ${Color}`;
140151

141152
interface Data {
142153
colorGradient: ColorGradient;
@@ -177,13 +188,36 @@ interface AnimControl {
177188
reverse(): void;
178189
}
179190

180-
type EventName = string;
191+
type EventName = 'click'
192+
|'update'
193+
|'background-draw'
194+
|'title-draw'
195+
|'logo-draw'
196+
|'legend-background-draw'
197+
|'legend-title-draw'
198+
|'legend-label-draw'
199+
|'legend-marker-draw'
200+
|'legend-bar-draw'
201+
|'plot-background-draw'
202+
|'plot-marker-draw'
203+
|'plot-marker-label-draw'
204+
|'plot-marker-guide-draw'
205+
|'plot-axis-draw'
206+
|'plot-axis-title-draw'
207+
|'plot-axis-label-draw'
208+
|'plot-axis-tick-draw'
209+
|'plot-axis-guide-draw'
210+
|'plot-axis-interlacing-draw';
211+
212+
interface Event {
213+
preventDefault: () => void;
214+
}
181215

182216
export default class Vizzu {
183217
constructor(container: string|HTMLElement);
184218
initializing: Promise<Vizzu>;
185-
on(eventName: EventName, handler: (event: any) => void): void;
186-
off(eventName: EventName, handler: (event: any) => void): void;
219+
on(eventName: EventName, handler: (event: Event) => void): void;
220+
off(eventName: EventName, handler: (event: Event) => void): void;
187221
animate(obj: AnimationTarget): Promise<Vizzu>;
188222
get animation(): AnimControl;
189223
version(): string;

0 commit comments

Comments
 (0)