UNPKG

16.8 kBTypeScriptView Raw
1/// <reference types="react" />
2export declare type GoogleVizDrawToolbar = (toolbarContainer: HTMLDivElement, components: GoogleChartToolbarItem[]) => any;
3export declare type GoogleViz = {
4 charts: GoogleChartLoader;
5 visualization: {
6 ChartWrapper: GoogleChartWrapper;
7 ChartEditor: GoogleChartEditor;
8 DataTable: GoogleDataTable;
9 events: GoogleVizEvents;
10 arrayToDataTable: GoogleArrayToDataTable;
11 drawToolbar: GoogleVizDrawToolbar;
12 [otherKeys: string]: any;
13 };
14};
15export declare type GoogleChartTicks = (number | Date)[];
16export declare type GoogleChartEditor = {
17 new (): GoogleChartEditor;
18 openDialog: (chartWrapper: GoogleChartWrapper, chartEditorOptions?: {
19 dataSourceInput?: any;
20 [otherKeyMaybe: string]: any;
21 }) => null;
22 getChartWrapper: () => GoogleChartWrapper;
23 setChartWrapper: (chartWrapper: GoogleChartWrapper) => GoogleChartWrapper;
24 closeDialog: () => null;
25};
26export declare type GoogleChartLoaderOptions = {
27 packages?: GoogleChartPackages[];
28 language?: string;
29 mapsApiKey?: string;
30};
31export declare type GoogleChartLoader = {
32 load: (version: GoogleChartVersion, googleChartOptions: GoogleChartLoaderOptions) => void;
33 setOnLoadCallback: (callback: () => void) => void;
34};
35export interface ChartWrapperProps {
36 chartType: GoogleChartWrapperChartType;
37 containerId?: string;
38 options?: {
39 width?: number;
40 height?: number;
41 is3D?: boolean;
42 title?: string;
43 backgroundColor: string;
44 };
45 dataTable?: {};
46 dataSourceUrl?: string;
47 query?: string;
48 refreshInterval?: number;
49 view?: any[] | {};
50 render?: (props: ChartWrapperProps, chartWrapper: GoogleChartWrapper) => any;
51 children?: (props: ChartWrapperProps, chartWrapper: GoogleChartWrapper) => any;
52}
53export declare type VizEventsProps = {
54 chartWrapper: GoogleChartWrapper;
55 onReady?: (chartWrapper: GoogleChartWrapper) => any;
56 onError?: (chartWrapper: GoogleChartWrapper) => any;
57 onSelect?: (selection: Array<{
58 row?: any;
59 column?: any;
60 }>) => any;
61 render?: (props: VizEventsProps, chartWrapper: GoogleChartWrapper) => any;
62 children?: (props: VizEventsProps, chartWrapper: GoogleChartWrapper) => any;
63};
64export declare type GoogleChartWrapperChartType = "AnnotationChart" | "AreaChart" | "BarChart" | "BubbleChart" | "Calendar" | "CandlestickChart" | "ColumnChart" | "ComboChart" | "DiffChart" | "DonutChart" | "Gantt" | "Gauge" | "GeoChart" | "Histogram" | "LineChart" | "Line" | "Bar" | "Map" | "OrgChart" | "PieChart" | "Sankey" | "ScatterChart" | "Scatter" | "SteppedAreaChart" | "Table" | "Timeline" | "TreeMap" | "WaterfallChart" | "WordTree";
65export interface ChartWrapperOptions {
66 chartType: string;
67 containerId: string;
68 options: Partial<{
69 width: number;
70 height: number;
71 is3D: boolean;
72 title: string;
73 backgroundColor: string;
74 hAxis?: {
75 minValue?: any;
76 maxValue?: any;
77 ticks?: GoogleChartTicks;
78 title?: string;
79 viewWindow?: {
80 max?: any;
81 min?: any;
82 };
83 [otherOptionKey: string]: any;
84 };
85 vAxis?: {
86 minValue?: any;
87 maxValue?: any;
88 ticks?: GoogleChartTicks;
89 title?: string;
90 viewWindow?: {
91 max?: any;
92 min?: any;
93 };
94 [otherOptionKey: string]: any;
95 };
96 legend: any;
97 colors: string[];
98 [otherOptionKey: string]: any;
99 }>;
100 dataTable?: GoogleDataTable;
101 dataSourceUrl?: string;
102 query?: string;
103 refreshInterval?: number;
104 view: any[] | {};
105 [otherOptionKey: string]: any;
106}
107export declare type GoogleChartAction = {
108 id: string;
109 text: string;
110 action: (chartWrapper: GoogleChartWrapper) => void;
111};
112export declare type GoogleChartControlProp = {
113 controlType: "CategoryFilter" | "ChartRangeFilter" | "DateRangeFilter" | "NumberRangeFilter" | "StringFilter";
114 options: {};
115 controlWrapperParams?: {};
116 controlID?: string;
117 controlPosition?: "top" | "bottom";
118 controlEvents?: ReactGoogleChartEvent[];
119};
120export declare type GoogleChartWrapper = {
121 new (chartWrapperOptions: Partial<ChartWrapperOptions>): GoogleChartWrapper;
122 draw: (chartArgs?: ChartWrapperProps) => any;
123 toJSON: () => string;
124 clone: () => GoogleChartWrapper;
125 getDataSourceUrl: () => string;
126 getDataTable: () => GoogleDataTable | null;
127 getChartType: () => GoogleChartWrapperChartType;
128 getChartName: () => string;
129 getChart: () => {
130 removeAction: (actionID: string) => void;
131 getSelection: () => {
132 row?: any;
133 column?: any;
134 }[];
135 setAction: (ChartAction: GoogleChartAction) => void;
136 getImageURI: () => void;
137 clearChart: () => void;
138 };
139 getContainerId: () => string;
140 getQuery: () => string;
141 getRefreshInterval: () => number;
142 getOption: (key: string, opt_default_value?: any) => any;
143 getOptions: () => {};
144 getSelection: () => {
145 row?: any;
146 column?: any;
147 }[];
148 getView: () => {} | any[];
149 setDataSourceUrl: (url: string) => void;
150 setDataTable: (table: any) => void;
151 setChartType: (chartType: GoogleChartWrapperChartType) => void;
152 setChartName: (name: string) => void;
153 setContainerId: (id: string) => void;
154 setQuery: (query_string: string) => void;
155 setRefreshInterval: (interval: number) => void;
156 setOption: (key: string, value: any) => void;
157 setOptions: (options_obj: Partial<ChartWrapperOptions["options"]>) => void;
158};
159export declare type GoogleVizEventName = "ready" | "error" | "select" | "animationfinish" | "statechange" | "ok" | "cancel" | "animationstart";
160export declare type GoogleVizEvents = {
161 addListener: (chartWrapper: GoogleChartWrapper | GoogleChartControl | GoogleChartEditor, name: GoogleVizEventName, onEvent: (chartWrapper: GoogleChartWrapper) => any) => any;
162 removeListener: (chartWrapper: GoogleChartWrapper, name: GoogleVizEventName, callback: Function) => any;
163 removeAllListeners: (chartWrapper: GoogleChartWrapper) => any;
164};
165export declare type GoogleChartPackages = "corechart" | "charteditor" | "controls" | "calendar" | "gantt" | "gauge" | "geochart" | "map" | "orgchart" | "sankey" | "table" | "timeline" | "treemap" | "wordtree";
166export declare type GoogleChartVersion = "current" | "upcoming";
167export declare type GoogleDataTableColumnType = "string" | "number" | "boolean" | "date" | "datetime" | "timeofday";
168export declare enum GoogleDataTableColumnRoleType {
169 annotation = "annotation",
170 annotationText = "annotationText",
171 certainty = "certainty",
172 emphasis = "emphasis",
173 interval = "interval",
174 scope = "scope",
175 style = "style",
176 tooltip = "tooltip",
177 domain = "domain"
178}
179export declare type GoogleDataTableColumn = {
180 type: GoogleDataTableColumnType;
181 label?: string;
182 role?: GoogleDataTableColumnRoleType;
183 pattern?: string;
184 p?: {};
185 id?: string;
186} | string;
187export declare type GoogleDataTableCell = {
188 v?: any;
189 f?: string;
190 p?: {};
191} | string | number | boolean | Date;
192export declare type GoogleDataTableRow = GoogleDataTableCell[];
193export declare type GoogleDataTableJS = {
194 cols: GoogleDataTableColumn[];
195 rows: {
196 c: GoogleDataTableRow;
197 }[];
198 p?: {};
199};
200export declare type GoogleDataTableRowFilter = {
201 column: number;
202 value: any;
203 minValue?: any;
204 maxValue?: any;
205};
206export declare type GoogleDataTableSortColumns = number | {
207 column: number;
208 desc: boolean;
209} | number[] | {
210 column: number;
211 desc: boolean;
212}[];
213export declare type GoogleDataTable = {
214 new (dataParam: any): GoogleDataTable;
215 addColumn: (column: GoogleDataTableColumn) => number;
216 addRow: (row?: GoogleDataTableRow) => number;
217 addRows: (rows?: GoogleDataTableRow[] | number[] | any[]) => number;
218 clone: () => GoogleDataTable;
219 getColumnId: (columnIndex: number) => string;
220 getColumnLabel: (columnIndex: number) => string;
221 getColumnPattern: (columnIndex: number) => string;
222 getColumnProperties: (columnIndex: number) => {};
223 getColumnProperty: (columnIndex: number, name: string) => any;
224 getColumnRange: (columnIndex: number) => {
225 min: number | null;
226 max: number | null;
227 };
228 getColumnRole: (columnIndex: number) => GoogleDataTableColumnRoleType;
229 getColumnType: (columnIndex: number) => GoogleDataTableColumnType;
230 getDistinctValues: (columnIndex: number) => any[];
231 getFilteredRows: (filters: GoogleDataTableRowFilter[]) => number[];
232 getFormattedValue: (rowIndex: number, columnIndex: number) => string;
233 getNumberOfColumns: () => number;
234 getNumberOfRows: () => number;
235 getProperties: (rowIndex: number, columnIndex: number) => {};
236 getProperty: (rowIndex: number, columnIndex: number, name: string) => any;
237 getRowProperties: (rowIndex: number) => {};
238 getRowProperty: (rowIndex: number, name: string) => any;
239 getSortedRows: (sortColumns: GoogleDataTableSortColumns) => number[];
240 getTableProperties: () => {};
241 getTableProperty: (name: string) => any;
242 getValue: (rowIndex: number, columnIndex: number) => boolean | string | number | Date | number[] | null;
243 insertColumn: (columnIndex: number, type: GoogleDataTableColumnType, label?: string, id?: string) => void;
244 insertRows: (rowIndex: number, numberOrArray: GoogleDataTableRow[] | number) => void;
245 removeColumn: (columnIndex: number) => void;
246 removeColumns: (columnIndex: number, numberOfColumns: number) => void;
247 removeRow: (rowIndex: number) => void;
248 removeRows: (rowIndex: number, numberOfColumns: number) => void;
249 setCell: (rowIndex: number, columnIndex: number, value?: any, formattedValue?: string, properties?: {}) => {};
250 setColumnLabel: (columnIndex: number, label: string) => void;
251 setColumnProperty: (columnIndex: number, name: string, value: any) => void;
252 setColumnProperties: (columnIndex: number, properties: {} | null) => void;
253 setFormattedValue: (rowIndex: number, columnIndex: number, formattedValue: string) => void;
254 setProperty: (rowIndex: number, columnIndex: number, name: string, value: any) => void;
255 setProperties: (rowIndex: number, columnIndex: number, properties: {} | null) => void;
256 setRowProperty: (rowIndex: number, name: string, value: any) => void;
257 setRowProperties: (rowIndex: number, properties: {} | null) => void;
258 setTableProperties: (properties: {} | null) => void;
259 setValue: (rowIndex: number, columnIndex: number, value: string) => void;
260 sort: (sortColumns: GoogleDataTableSortColumns) => void;
261 toJSON: () => string;
262};
263export declare type GoogleArrayToDataTable = (data: any[][], isFirstRowLabels?: boolean) => GoogleDataTable;
264export declare type GoogleChartOptions = {
265 width?: number;
266 height?: number;
267 is3D?: boolean;
268 backgroundColor: string;
269 title?: string;
270 hAxis?: {
271 minValue?: any;
272 maxValue?: any;
273 ticks?: GoogleChartTicks;
274 title?: string;
275 viewWindow?: {
276 max?: any;
277 min?: any;
278 [otherOptionKey: string]: any;
279 };
280 [otherOptionKey: string]: any;
281 };
282 vAxis?: {
283 minValue?: any;
284 maxValue?: any;
285 ticks?: GoogleChartTicks;
286 title?: string;
287 viewWindow?: {
288 max?: any;
289 min?: any;
290 [otherOptionKey: string]: any;
291 };
292 [otherOptionKey: string]: any;
293 };
294 bubble?: {};
295 pieHole?: number;
296 redFrom?: number;
297 redTo?: number;
298 yellowFrom?: number;
299 yellowTo?: number;
300 minorTicks?: number;
301 legend?: string | {
302 position?: string;
303 maxLines?: number;
304 [otherOptionKey: string]: any;
305 };
306 curveType?: string;
307 showTooltip?: boolean;
308 showInfoWindow?: boolean;
309 allowHtml?: boolean;
310 isStacked?: string | boolean;
311 minColor?: string;
312 midColor?: string;
313 maxColor?: string;
314 headerHeight?: number;
315 fontColor?: string;
316 showScale?: boolean;
317 bar?: {
318 groupWidth?: string;
319 };
320 candlestick?: {
321 fallingColor?: {
322 strokeWidth?: number;
323 fill?: string;
324 };
325 risingColor?: {
326 strokeWidth?: number;
327 fill?: string;
328 };
329 [otherOptionKey: string]: any;
330 };
331 wordtree?: {
332 format?: string;
333 word?: string;
334 [otherOptionKey: string]: any;
335 };
336 [otherOptionKey: string]: any;
337};
338export declare type WindowWithMaybeGoogle = Window & {
339 google?: any;
340};
341export declare type ReactGoogleChartEvent = {
342 eventName: GoogleVizEventName;
343 callback: (eventCallbackArgs: {
344 chartWrapper: GoogleChartWrapper;
345 controlWrapper?: GoogleChartControl;
346 props: ReactGoogleChartProps;
347 google: GoogleViz;
348 eventArgs: any;
349 }) => void;
350};
351export declare type GoogleChartToolbarItem = {
352 type: "igoogle" | "html" | "csv" | "htmlcode";
353 datasource: string;
354 gadget?: string;
355 userPrefs?: {
356 "3d": number;
357 [otherKeyMaybe: string]: any;
358 };
359};
360export declare type ReactGoogleChartProps = {
361 height?: string | number;
362 width?: string | number;
363 graphID?: string;
364 chartType: GoogleChartWrapperChartType;
365 diffdata?: {
366 old: any;
367 new: any;
368 };
369 options?: ChartWrapperOptions["options"];
370 loader?: JSX.Element;
371 errorElement?: JSX.Element;
372 data?: any[] | {};
373 rows?: GoogleDataTableRow[];
374 columns?: GoogleDataTableColumn[];
375 chartActions?: GoogleChartAction[];
376 chartEvents?: ReactGoogleChartEvent[];
377 chartVersion?: GoogleChartVersion;
378 chartPackages?: GoogleChartPackages[];
379 chartLanguage?: string;
380 mapsApiKey?: string;
381 graph_id?: string;
382 legendToggle?: boolean;
383 legend_toggle?: boolean;
384 onLoad?: (google: GoogleViz) => void;
385 getChartWrapper?: (chartWrapper: GoogleChartWrapper, google: GoogleViz) => void;
386 getChartEditor?: (args: {
387 chartEditor: GoogleChartEditor;
388 chartWrapper: GoogleChartWrapper;
389 google: GoogleViz;
390 }) => void;
391 className?: string;
392 style?: React.CSSProperties;
393 formatters?: {
394 column: number | number[];
395 type: "ArrowFormat" | "BarFormat" | "ColorFormat" | "DateFormat" | "NumberFormat" | "PatternFormat";
396 options?: {};
397 }[];
398 spreadSheetUrl?: string;
399 spreadSheetQueryParameters?: {
400 headers: number;
401 gid?: number | string;
402 sheet?: string;
403 query?: string;
404 access_token?: string;
405 };
406 rootProps?: any;
407 controls?: GoogleChartControlProp[];
408 render?: ReactGoogleChartDashboardRender;
409 toolbarItems?: GoogleChartToolbarItem[];
410 toolbarID?: string;
411 chartWrapperParams?: any;
412};
413export declare type GoogleChartDashboard = {
414 draw: (data: GoogleDataTable) => void;
415 bind: (controlWrapperOrWrappers: GoogleChartControl | GoogleChartControl[], chartWrapper: GoogleChartWrapper) => void;
416};
417export declare type ReactGoogleChartDashboardRender = ({ renderControl, renderChart, renderToolbar, }: {
418 renderControl: (filter: ({ control, controlProp, }: {
419 control: GoogleChartControl;
420 controlProp: GoogleChartControlProp;
421 }) => boolean) => any;
422 renderChart: () => any;
423 renderToolbar: () => any;
424}) => any;
425export declare type GoogleChartControlOptions = any;
426export declare type GoogleChartControl = {
427 getContainerId: () => string;
428 getOptions: () => GoogleChartControlOptions;
429 getState: () => any;
430 setState: (state: any) => void;
431 setOptions: (options: GoogleChartControlOptions) => void;
432 setControlType: (controlType: string) => void;
433};
434export declare type ReactGoogleChartState = {
435 loadingStatus: "loading" | "errored" | "ready";
436 google: null | GoogleViz;
437};
438export declare type ReactGoogleChartContext = {
439 data: ReactGoogleChartProps["data"];
440 rows: ReactGoogleChartProps["rows"] | null;
441 columns: ReactGoogleChartProps["columns"] | null;
442 diffdata: ReactGoogleChartProps["diffdata"] | null;
443 options: ReactGoogleChartProps["options"] | null;
444 legend_toggle: ReactGoogleChartProps["legend_toggle"] | null;
445 legendToggle: ReactGoogleChartProps["legendToggle"] | null;
446 chartType: ReactGoogleChartProps["chartType"] | null;
447 formatters: ReactGoogleChartProps["formatters"] | null;
448 spreadSheetUrl: ReactGoogleChartProps["spreadSheetUrl"] | null;
449 spreadSheetQueryParameters: ReactGoogleChartProps["spreadSheetQueryParameters"] | null;
450};