forked from jbaroudi/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
google-apps-script.charts.d.ts
975 lines (941 loc) · 42.1 KB
/
google-apps-script.charts.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
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
// Type definitions for Google Apps Script 2015-11-12
// Project: https://developers.google.com/apps-script/
// Definitions by: motemen <https://github.com/motemen/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="google-apps-script.types.d.ts" />
/// <reference path="google-apps-script.base.d.ts" />
/// <reference path="google-apps-script.ui.d.ts" />
declare module GoogleAppsScript {
export module Charts {
/**
* Builder for area charts. For more details, see the
* Google Charts documentation.
*
* Here is an example that shows how to build an area chart.
*
* function doGet() {
* // Create a data table with some sample data.
* var sampleData = Charts.newDataTable()
* .addColumn(Charts.ColumnType.STRING, "Month")
* .addColumn(Charts.ColumnType.NUMBER, "Dining")
* .addColumn(Charts.ColumnType.NUMBER, "Total")
* .addRow(["Jan", 60, 520])
* .addRow(["Feb", 50, 430])
* .addRow(["Mar", 53, 440])
* .addRow(["Apr", 70, 410])
* .addRow(["May", 80, 390])
* .addRow(["Jun", 60, 500])
* .addRow(["Jul", 100, 450])
* .addRow(["Aug", 140, 431])
* .addRow(["Sep", 75, 488])
* .addRow(["Oct", 70, 521])
* .addRow(["Nov", 58, 388])
* .addRow(["Dec", 63, 400])
* .build();
*
* var chart = Charts.newAreaChart()
* .setTitle('Yearly Spending')
* .setXAxisTitle('Month')
* .setYAxisTitle('Spending (USD)')
* .setDimensions(600, 500)
* .setStacked()
* .setColors(['red', 'green'])
* .setDataTable(sampleData)
* .build();
*
* return UiApp.createApplication().add(chart);
* }
*/
export interface AreaChartBuilder {
build(): Chart;
reverseCategories(): AreaChartBuilder;
setBackgroundColor(cssValue: string): AreaChartBuilder;
setColors(cssValues: String[]): AreaChartBuilder;
setDataSourceUrl(url: string): AreaChartBuilder;
setDataTable(tableBuilder: DataTableBuilder): AreaChartBuilder;
setDataTable(table: DataTableSource): AreaChartBuilder;
setDataViewDefinition(dataViewDefinition: DataViewDefinition): AreaChartBuilder;
setDimensions(width: Integer, height: Integer): AreaChartBuilder;
setLegendPosition(position: Position): AreaChartBuilder;
setLegendTextStyle(textStyle: TextStyle): AreaChartBuilder;
setOption(option: string, value: Object): AreaChartBuilder;
setPointStyle(style: PointStyle): AreaChartBuilder;
setRange(start: Number, end: Number): AreaChartBuilder;
setStacked(): AreaChartBuilder;
setTitle(chartTitle: string): AreaChartBuilder;
setTitleTextStyle(textStyle: TextStyle): AreaChartBuilder;
setXAxisTextStyle(textStyle: TextStyle): AreaChartBuilder;
setXAxisTitle(title: string): AreaChartBuilder;
setXAxisTitleTextStyle(textStyle: TextStyle): AreaChartBuilder;
setYAxisTextStyle(textStyle: TextStyle): AreaChartBuilder;
setYAxisTitle(title: string): AreaChartBuilder;
setYAxisTitleTextStyle(textStyle: TextStyle): AreaChartBuilder;
useLogScale(): AreaChartBuilder;
}
/**
* Builder for bar charts. For more details, see the
* Google Charts documentation.
*
* Here is an example that shows how to build a bar chart. The data is
*
* imported from a Google spreadsheet.
*
* function doGet() {
* // Get sample data from a spreadsheet.
* var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=B1%3AC11' +
* '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=0&headers=-1';
*
* var chartBuilder = Charts.newBarChart()
* .setTitle('Top Grossing Films in US and Canada')
* .setXAxisTitle('USD')
* .setYAxisTitle('Film')
* .setDimensions(600, 500)
* .setLegendPosition(Charts.Position.BOTTOM)
* .setDataSourceUrl(dataSourceUrl);
*
* var chart = chartBuilder.build();
* return UiApp.createApplication().add(chart);
* }
*/
export interface BarChartBuilder {
build(): Chart;
reverseCategories(): BarChartBuilder;
reverseDirection(): BarChartBuilder;
setBackgroundColor(cssValue: string): BarChartBuilder;
setColors(cssValues: String[]): BarChartBuilder;
setDataSourceUrl(url: string): BarChartBuilder;
setDataTable(tableBuilder: DataTableBuilder): BarChartBuilder;
setDataTable(table: DataTableSource): BarChartBuilder;
setDataViewDefinition(dataViewDefinition: DataViewDefinition): BarChartBuilder;
setDimensions(width: Integer, height: Integer): BarChartBuilder;
setLegendPosition(position: Position): BarChartBuilder;
setLegendTextStyle(textStyle: TextStyle): BarChartBuilder;
setOption(option: string, value: Object): BarChartBuilder;
setRange(start: Number, end: Number): BarChartBuilder;
setStacked(): BarChartBuilder;
setTitle(chartTitle: string): BarChartBuilder;
setTitleTextStyle(textStyle: TextStyle): BarChartBuilder;
setXAxisTextStyle(textStyle: TextStyle): BarChartBuilder;
setXAxisTitle(title: string): BarChartBuilder;
setXAxisTitleTextStyle(textStyle: TextStyle): BarChartBuilder;
setYAxisTextStyle(textStyle: TextStyle): BarChartBuilder;
setYAxisTitle(title: string): BarChartBuilder;
setYAxisTitleTextStyle(textStyle: TextStyle): BarChartBuilder;
useLogScale(): BarChartBuilder;
}
/**
* A builder for category filter controls.
*
* A category filter is a picker to choose one or more between a set of defined values.
* Given a column of type string, this control will filter out the rows that
* don't match any of the picked values.
*
* Here is an example that creates a table chart a binds a category filter to it. This allows the
* user to filter the data the table displays.
*
* function doGet() {
* var app = UiApp.createApplication();
* var sampleData = Charts.newDataTable()
* .addColumn(Charts.ColumnType.STRING, "Month")
* .addColumn(Charts.ColumnType.NUMBER, "Dining")
* .addColumn(Charts.ColumnType.NUMBER, "Total")
* .addRow(["Jan", 60, 520])
* .addRow(["Feb", 50, 430])
* .addRow(["Mar", 53, 440])
* .addRow(["Apr", 70, 410])
* .addRow(["May", 80, 390])
* .addRow(["Jun", 60, 500])
* .addRow(["Jul", 100, 450])
* .addRow(["Aug", 140, 431])
* .addRow(["Sep", 75, 488])
* .addRow(["Oct", 70, 521])
* .addRow(["Nov", 58, 388])
* .addRow(["Dec", 63, 400])
* .build();
*
* var chart = Charts.newTableChart()
* .setDimensions(600, 500)
* .build();
*
* var categoryFilter = Charts.newCategoryFilter()
* .setFilterColumnLabel("Month")
* .setAllowMultiple(true)
* .setSortValues(true)
* .setLabelStacking(Charts.Orientation.VERTICAL)
* .setCaption('Choose categories...')
* .build();
*
* var panel = app.createVerticalPanel().setSpacing(10);
* panel.add(categoryFilter).add(chart);
*
* var dashboard = Charts.newDashboardPanel()
* .setDataTable(sampleData)
* .bind(categoryFilter, chart)
* .build();
*
* dashboard.add(panel);
* app.add(dashboard);
* return app;
* }
*
* documentation
*/
export interface CategoryFilterBuilder {
build(): Control;
setAllowMultiple(allowMultiple: boolean): CategoryFilterBuilder;
setAllowNone(allowNone: boolean): CategoryFilterBuilder;
setAllowTyping(allowTyping: boolean): CategoryFilterBuilder;
setCaption(caption: string): CategoryFilterBuilder;
setDataTable(tableBuilder: DataTableBuilder): CategoryFilterBuilder;
setDataTable(table: DataTableSource): CategoryFilterBuilder;
setFilterColumnIndex(columnIndex: Integer): CategoryFilterBuilder;
setFilterColumnLabel(columnLabel: string): CategoryFilterBuilder;
setLabel(label: string): CategoryFilterBuilder;
setLabelSeparator(labelSeparator: string): CategoryFilterBuilder;
setLabelStacking(orientation: Orientation): CategoryFilterBuilder;
setSelectedValuesLayout(layout: PickerValuesLayout): CategoryFilterBuilder;
setSortValues(sortValues: boolean): CategoryFilterBuilder;
setValues(values: String[]): CategoryFilterBuilder;
}
/**
* A Chart object, which can be embedded into documents, UI elements, or used as a static image. For
* charts embedded in spreadsheets, see
* EmbeddedChart.
*/
export interface Chart {
getAs(contentType: string): Base.Blob;
getBlob(): Base.Blob;
getId(): string;
getOptions(): ChartOptions;
getType(): string;
setId(id: string): Chart;
}
/**
* Exposes options currently configured for a Chart, such as height, color, etc.
*
* Please see the visualization
* reference documentation for information on what options are available. Specific options for
* each chart can be found by clicking on the specific chart in the chart gallery.
*
* These options are immutable.
*/
export interface ChartOptions {
get(option: string): Object;
}
/**
* Chart types supported by the Charts service.
*/
export enum ChartType { AREA, BAR, COLUMN, LINE, PIE, SCATTER, TABLE }
/**
* Entry point for creating Charts in scripts.
*
* This example creates a basic data table, populates an area chart with the data, and adds it into
* a UiApp:
*
* function doGet() {
* var data = Charts.newDataTable()
* .addColumn(Charts.ColumnType.STRING, "Month")
* .addColumn(Charts.ColumnType.NUMBER, "In Store")
* .addColumn(Charts.ColumnType.NUMBER, "Online")
* .addRow(["January", 10, 1])
* .addRow(["February", 12, 1])
* .addRow(["March", 20, 2])
* .addRow(["April", 25, 3])
* .addRow(["May", 30, 4])
* .build();
*
* var chart = Charts.newAreaChart()
* .setDataTable(data)
* .setStacked()
* .setRange(0, 40)
* .setTitle("Sales per Month")
* .build();
*
* var uiApp = UiApp.createApplication().setTitle("My Chart");
* uiApp.add(chart);
* return uiApp;
* }
*/
export interface Charts {
ChartType: ChartType
ColumnType: ColumnType
CurveStyle: CurveStyle
MatchType: MatchType
Orientation: Orientation
PickerValuesLayout: PickerValuesLayout
PointStyle: PointStyle
Position: Position
newAreaChart(): AreaChartBuilder;
newBarChart(): BarChartBuilder;
newCategoryFilter(): CategoryFilterBuilder;
newColumnChart(): ColumnChartBuilder;
newDashboardPanel(): DashboardPanelBuilder;
newDataTable(): DataTableBuilder;
newDataViewDefinition(): DataViewDefinitionBuilder;
newLineChart(): LineChartBuilder;
newNumberRangeFilter(): NumberRangeFilterBuilder;
newPieChart(): PieChartBuilder;
newScatterChart(): ScatterChartBuilder;
newStringFilter(): StringFilterBuilder;
newTableChart(): TableChartBuilder;
newTextStyle(): TextStyleBuilder;
}
/**
* Builder for column charts. For more details, see the
* Google Charts documentation.
*
* This example shows how to create a column chart with data from a data table.
*
* function doGet() {
* var sampleData = Charts.newDataTable()
* .addColumn(Charts.ColumnType.STRING, "Year")
* .addColumn(Charts.ColumnType.NUMBER, "Sales")
* .addColumn(Charts.ColumnType.NUMBER, "Expenses")
* .addRow(["2004", 1000, 400])
* .addRow(["2005", 1170, 460])
* .addRow(["2006", 660, 1120])
* .addRow(["2007", 1030, 540])
* .addRow(["2008", 800, 600])
* .addRow(["2009", 943, 678])
* .addRow(["2010", 1020, 550])
* .addRow(["2011", 910, 700])
* .addRow(["2012", 1230, 840])
* .build();
*
* var chart = Charts.newColumnChart()
* .setTitle('Sales vs. Expenses')
* .setXAxisTitle('Year')
* .setYAxisTitle('Amount (USD)')
* .setDimensions(600, 500)
* .setDataTable(sampleData)
* .build();
*
* return UiApp.createApplication().add(chart);
* }
*/
export interface ColumnChartBuilder {
build(): Chart;
reverseCategories(): ColumnChartBuilder;
setBackgroundColor(cssValue: string): ColumnChartBuilder;
setColors(cssValues: String[]): ColumnChartBuilder;
setDataSourceUrl(url: string): ColumnChartBuilder;
setDataTable(tableBuilder: DataTableBuilder): ColumnChartBuilder;
setDataTable(table: DataTableSource): ColumnChartBuilder;
setDataViewDefinition(dataViewDefinition: DataViewDefinition): ColumnChartBuilder;
setDimensions(width: Integer, height: Integer): ColumnChartBuilder;
setLegendPosition(position: Position): ColumnChartBuilder;
setLegendTextStyle(textStyle: TextStyle): ColumnChartBuilder;
setOption(option: string, value: Object): ColumnChartBuilder;
setRange(start: Number, end: Number): ColumnChartBuilder;
setStacked(): ColumnChartBuilder;
setTitle(chartTitle: string): ColumnChartBuilder;
setTitleTextStyle(textStyle: TextStyle): ColumnChartBuilder;
setXAxisTextStyle(textStyle: TextStyle): ColumnChartBuilder;
setXAxisTitle(title: string): ColumnChartBuilder;
setXAxisTitleTextStyle(textStyle: TextStyle): ColumnChartBuilder;
setYAxisTextStyle(textStyle: TextStyle): ColumnChartBuilder;
setYAxisTitle(title: string): ColumnChartBuilder;
setYAxisTitleTextStyle(textStyle: TextStyle): ColumnChartBuilder;
useLogScale(): ColumnChartBuilder;
}
/**
* An enumeration of the valid data types for columns in a DataTable.
*/
export enum ColumnType { DATE, NUMBER, STRING }
/**
* A user interface control object, that drives the data displayed by a DashboardPanel.
*
* A control can be embedded in a UI application. Controls are user interface widgets (category
* pickers, range sliders, autocompleters, etc.) users interact with in order to drive the data
* managed by a dashboard and the charts that are part of it.
* Controls collect user input and use the information to decide which of the data the
* dashboard is managing should be made available to the charts that are part of it.
* Given a data table, a control will filter out the data that doesn't comply with the
* conditions implied by its current state, and will expose the filtered data table as
* an output.
*
* For more details, see the Gviz
*
* documentation.
*/
export interface Control {
getId(): string;
getType(): string;
setId(id: string): Control;
}
/**
* An enumeration of the styles for curves in a chart.
*/
export enum CurveStyle { NORMAL, SMOOTH }
/**
* A dashboard is a visual structure that enables the organization and management
* of multiple charts that share the same underlying data.
*
* Controls are user interface widgets (category pickers, range sliders, autocompleters, etc.)
* users interact with in order to drive the data managed by a dashboard and the charts that
* are part of it. For example, a string filter control is a simple text input field that lets
* the user filter data via string matching. Given a column and matching options, the control
* will filter out the rows that don't match the term that's in the input field.
*
* The Gviz API defines a dashboard as a set of charts and controls bound together. The
* bindings between the different components define the data flow, the state of the
* controls filters views of the data which propagate in the dashboard and are
* eventually visualized with charts. For more details, see the Gviz
*
* documentation.
*
* The dashboard panel has two purposes, one is being a container for the charts and
* controls objects that compose the dashboard, and the other is holding the data and use
* as an interface for binding controls to charts.
*
* Here's an example of creating a dashboard and showing it in a UI app:
*
* function doGet() {
* // Create a data table with some sample data.
* var data = Charts.newDataTable()
* .addColumn(Charts.ColumnType.STRING, "Name")
* .addColumn(Charts.ColumnType.NUMBER, "Age")
* .addRow(["Michael", 18])
* .addRow(["Elisa", 12])
* .addRow(["John", 20])
* .addRow(["Jessica", 25])
* .addRow(["Aaron", 14])
* .addRow(["Margareth", 19])
* .addRow(["Miranda", 22])
* .addRow(["May", 20])
* .build();
*
* var chart = Charts.newBarChart()
* .setTitle("Ages")
* .build();
*
* var control = Charts.newStringFilter()
* .setFilterColumnLabel("Name")
* .build();
*
* // Bind the control to the chart in a dashboard panel.
* var dashboard = Charts.newDashboardPanel()
* .setDataTable(data)
* .bind(control, chart)
* .build();
*
* var uiApp = UiApp.createApplication().setTitle("My Dashboard");
*
* var panel = uiApp.createHorizontalPanel()
* .setVerticalAlignment(UiApp.VerticalAlignment.MIDDLE)
* .setSpacing(50);
*
* panel.add(control);
* panel.add(chart);
* dashboard.add(panel);
* uiApp.add(dashboard);
* return uiApp;
* }
*/
export interface DashboardPanel {
add(widget: UI.Widget): DashboardPanel;
getId(): string;
getType(): string;
setId(id: string): DashboardPanel;
}
/**
* A builder for a dashboard panel object. For an example of how to use
* DashboardPanelBuilder, refer to DashboardPanel.
*
* For more details, see the Gviz
*
* documentation.
*/
export interface DashboardPanelBuilder {
bind(control: Control, chart: Chart, controls: Control[], charts: Chart[]): DashboardPanelBuilder;
bind(control: Control, chart: Chart, controls: Control[], charts: Chart[]): DashboardPanelBuilder;
build(): DashboardPanel;
setDataTable(tableBuilder: DataTableBuilder): DashboardPanelBuilder;
setDataTable(source: DataTableSource): DashboardPanelBuilder;
}
/**
* A Data Table to be used in charts. A DataTable can come from sources such as Google
* Sheets or specified data-table URLs, or can be filled in by hand. This class intentionally has no
* methods: a DataTable can be passed around, but not manipulated directly.
*/
export interface DataTable {
}
/**
* Builder of DataTable objects. Building a data table consists of first specifying its columns,
* and then adding its rows, one at a time. Example:
*
* var data = Charts.newDataTable()
* .addColumn(Charts.ColumnType.STRING, "Month")
* .addColumn(Charts.ColumnType.NUMBER, "In Store")
* .addColumn(Charts.ColumnType.NUMBER, "Online")
* .addRow(["January", 10, 1])
* .addRow(["February", 12, 1])
* .addRow(["March", 20, 2])
* .addRow(["April", 25, 3])
* .addRow(["May", 30, 4])
* .build();
*/
export interface DataTableBuilder {
addColumn(type: ColumnType, label: string): DataTableBuilder;
addRow(values: Object[]): DataTableBuilder;
build(): DataTable;
setValue(row: Integer, column: Integer, value: Object): DataTableBuilder;
}
/**
* Interface for objects that can represent their data as a DataTable.
* Implementing classes
*
* NameBrief description
*
* DataTableA Data Table to be used in charts.
*
* RangeAccess and modify spreadsheet ranges.
*/
export interface DataTableSource {
getDataTable(): DataTable;
}
/**
* A data view definition for visualizing chart data.
*
* Data view definition can be set for charts to visualize a view derived from the given data table
* and not the data table itself. For example if the view definition of a chart states that the view
* columns are [0, 3], only the first and the third columns of the data table will be taken into
* consideration when drawing the chart. See DataViewDefinitionBuilder for an example on how
* to define and use a DataViewDefinition.
*/
export interface DataViewDefinition {
}
/**
* Builder for DataViewDefinition objects.
*
* Here's an example of using the builder. The data is imported from a Google spreadsheet.
*
* function doGet() {
* // This example creates two table charts side by side. One uses a data view definition to
* // restrict the number of displayed columns.
* var app = UiApp.createApplication();
* // Get sample data from a spreadsheet.
* var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AF' +
* '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1';
*
* // Create a chart to display all of the data.
* var originalChart = Charts.newTableChart()
* .setDimensions(600, 500)
* .setDataSourceUrl(dataSourceUrl)
* .build();
*
* // Create another chart to display a subset of the data (only columns 1 and 4).
* var dataViewDefinition = Charts.newDataViewDefinition().setColumns([0, 3]);
* var limitedChart = Charts.newTableChart()
* .setDimensions(200, 500)
* .setDataSourceUrl(dataSourceUrl)
* .setDataViewDefinition(dataViewDefinition)
* .build();
*
* var panel = app.createHorizontalPanel().setSpacing(15);
* panel.add(originalChart).add(limitedChart);
* return app.add(panel);
* }
*/
export interface DataViewDefinitionBuilder {
build(): DataViewDefinition;
setColumns(columns: Object[]): DataViewDefinitionBuilder;
}
/**
* Builder for line charts. For more details, see the
* Google Charts documentation.
*
* Here is an example that shows how to build a line chart. The data is
* imported from a Google spreadsheet.
*
* function doGet() {
* // Get sample data from a spreadsheet.
* var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AG5' +
* '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=2&headers=-1';
*
* var chartBuilder = Charts.newLineChart()
* .setTitle('Yearly Rainfall')
* .setXAxisTitle('Month')
* .setYAxisTitle('Rainfall (in)')
* .setDimensions(600, 500)
* .setCurveStyle(Charts.CurveStyle.SMOOTH)
* .setPointStyle(Charts.PointStyle.MEDIUM)
* .setDataSourceUrl(dataSourceUrl);
*
* var chart = chartBuilder.build();
* return UiApp.createApplication().add(chart);
* }
*/
export interface LineChartBuilder {
build(): Chart;
reverseCategories(): LineChartBuilder;
setBackgroundColor(cssValue: string): LineChartBuilder;
setColors(cssValues: String[]): LineChartBuilder;
setCurveStyle(style: CurveStyle): LineChartBuilder;
setDataSourceUrl(url: string): LineChartBuilder;
setDataTable(tableBuilder: DataTableBuilder): LineChartBuilder;
setDataTable(table: DataTableSource): LineChartBuilder;
setDataViewDefinition(dataViewDefinition: DataViewDefinition): LineChartBuilder;
setDimensions(width: Integer, height: Integer): LineChartBuilder;
setLegendPosition(position: Position): LineChartBuilder;
setLegendTextStyle(textStyle: TextStyle): LineChartBuilder;
setOption(option: string, value: Object): LineChartBuilder;
setPointStyle(style: PointStyle): LineChartBuilder;
setRange(start: Number, end: Number): LineChartBuilder;
setTitle(chartTitle: string): LineChartBuilder;
setTitleTextStyle(textStyle: TextStyle): LineChartBuilder;
setXAxisTextStyle(textStyle: TextStyle): LineChartBuilder;
setXAxisTitle(title: string): LineChartBuilder;
setXAxisTitleTextStyle(textStyle: TextStyle): LineChartBuilder;
setYAxisTextStyle(textStyle: TextStyle): LineChartBuilder;
setYAxisTitle(title: string): LineChartBuilder;
setYAxisTitleTextStyle(textStyle: TextStyle): LineChartBuilder;
useLogScale(): LineChartBuilder;
}
/**
* An enumeration of how a string value should be matched.
* Matching a string is a boolean operation. Given a string, a match term (string), and a match
* type, the operation will output true in the following cases:
*
* If the match type equals EXACT and the match term equals the string.
* If the match type equals PREFIX and the match term is a prefix of the string.
* If the match type equals ANY and the match term is a substring of the string.
*
* This enumeration can be used in by a string filter control to decide which rows to filter out
* of the data table. Given a column to filter on, leave only the rows that match the value
* entered in the filter input box, using one of the above matching types.
*/
export enum MatchType { EXACT, PREFIX, ANY }
/**
* A builder for number range filter controls.
*
* A number range filter is a slider with two thumbs that lets the user select ranges of
* numeric values. Given a column of type number and matching options, this control will
* filter out the rows that don't match the range that was selected.
*
* This example creates a table chart bound to a number range filter:
*
* function doGet() {
* var app = UiApp.createApplication();
* // Get sample data from a spreadsheet.
* var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AF' +
* '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1';
* var data = SpreadsheetApp.openByUrl(dataSourceUrl).getSheetByName('US_GDP').getRange("A1:F");
*
* var chart = Charts.newTableChart()
* .setDimensions(600, 500)
* .build();
*
* var numberRangeFilter = Charts.newNumberRangeFilter()
* .setFilterColumnLabel("Year")
* .setShowRangeValues(true)
* .setLabel("Restrict year range")
* .build();
*
* var panel = app.createVerticalPanel().setSpacing(10);
* panel.add(numberRangeFilter).add(chart);
*
* // Create a new dashboard panel to bind the filter and chart together.
* var dashboard = Charts.newDashboardPanel()
* .setDataTable(data)
* .bind(numberRangeFilter, chart)
* .build();
*
* dashboard.add(panel);
* app.add(dashboard);
* return app;
* }
*
* documentation
*/
export interface NumberRangeFilterBuilder {
build(): Control;
setDataTable(tableBuilder: DataTableBuilder): NumberRangeFilterBuilder;
setDataTable(table: DataTableSource): NumberRangeFilterBuilder;
setFilterColumnIndex(columnIndex: Integer): NumberRangeFilterBuilder;
setFilterColumnLabel(columnLabel: string): NumberRangeFilterBuilder;
setLabel(label: string): NumberRangeFilterBuilder;
setLabelSeparator(labelSeparator: string): NumberRangeFilterBuilder;
setLabelStacking(orientation: Orientation): NumberRangeFilterBuilder;
setMaxValue(maxValue: Integer): NumberRangeFilterBuilder;
setMinValue(minValue: Integer): NumberRangeFilterBuilder;
setOrientation(orientation: Orientation): NumberRangeFilterBuilder;
setShowRangeValues(showRangeValues: boolean): NumberRangeFilterBuilder;
setTicks(ticks: Integer): NumberRangeFilterBuilder;
}
/**
* An enumeration of the orientation of an object.
*/
export enum Orientation { HORIZONTAL, VERTICAL }
/**
* An enumeration of how to display selected values in picker widget.
*/
export enum PickerValuesLayout { ASIDE, BELOW, BELOW_WRAPPING, BELOW_STACKED }
/**
* A builder for pie charts. For more details, see the
* Google Charts documentation.
*
* Here is an example that shows how to build a pie chart. The data is
* imported from a Google spreadsheet.
*
* function doGet() {
* // Get sample data from a spreadsheet.
* var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AB8' +
* '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=3&headers=-1';
*
* var chartBuilder = Charts.newPieChart()
* .setTitle('World Population by Continent')
* .setDimensions(600, 500)
* .set3D()
* .setDataSourceUrl(dataSourceUrl);
*
* var chart = chartBuilder.build();
* return UiApp.createApplication().add(chart);
* }
*/
export interface PieChartBuilder {
build(): Chart;
reverseCategories(): PieChartBuilder;
set3D(): PieChartBuilder;
setBackgroundColor(cssValue: string): PieChartBuilder;
setColors(cssValues: String[]): PieChartBuilder;
setDataSourceUrl(url: string): PieChartBuilder;
setDataTable(tableBuilder: DataTableBuilder): PieChartBuilder;
setDataTable(table: DataTableSource): PieChartBuilder;
setDataViewDefinition(dataViewDefinition: DataViewDefinition): PieChartBuilder;
setDimensions(width: Integer, height: Integer): PieChartBuilder;
setLegendPosition(position: Position): PieChartBuilder;
setLegendTextStyle(textStyle: TextStyle): PieChartBuilder;
setOption(option: string, value: Object): PieChartBuilder;
setTitle(chartTitle: string): PieChartBuilder;
setTitleTextStyle(textStyle: TextStyle): PieChartBuilder;
}
/**
* An enumeration of the styles of points in a line.
*/
export enum PointStyle { NONE, TINY, MEDIUM, LARGE, HUGE }
/**
* An enumeration of legend positions within a chart.
*/
export enum Position { TOP, RIGHT, BOTTOM, NONE }
/**
* Builder for scatter charts. For more details, see the
* Google Charts documentation.
*
* Here is an example that shows how to build a scatter chart. The data is
* imported from a Google spreadsheet.
*
* function doGet() {
* // Get sample data from a spreadsheet.
* var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=C1%3AD' +
* '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1';
*
* var chartBuilder = Charts.newScatterChart()
* .setTitle('Adjusted GDP vs. U.S. Population')
* .setXAxisTitle('U.S. Population (millions)')
* .setYAxisTitle('Adjusted GDP ($ billions)')
* .setDimensions(600, 500)
* .setLegendPosition(Charts.Position.NONE)
* .setDataSourceUrl(dataSourceUrl);
*
* var chart = chartBuilder.build();
* return UiApp.createApplication().add(chart);
* }
*/
export interface ScatterChartBuilder {
build(): Chart;
setBackgroundColor(cssValue: string): ScatterChartBuilder;
setColors(cssValues: String[]): ScatterChartBuilder;
setDataSourceUrl(url: string): ScatterChartBuilder;
setDataTable(tableBuilder: DataTableBuilder): ScatterChartBuilder;
setDataTable(table: DataTableSource): ScatterChartBuilder;
setDataViewDefinition(dataViewDefinition: DataViewDefinition): ScatterChartBuilder;
setDimensions(width: Integer, height: Integer): ScatterChartBuilder;
setLegendPosition(position: Position): ScatterChartBuilder;
setLegendTextStyle(textStyle: TextStyle): ScatterChartBuilder;
setOption(option: string, value: Object): ScatterChartBuilder;
setPointStyle(style: PointStyle): ScatterChartBuilder;
setTitle(chartTitle: string): ScatterChartBuilder;
setTitleTextStyle(textStyle: TextStyle): ScatterChartBuilder;
setXAxisLogScale(): ScatterChartBuilder;
setXAxisRange(start: Number, end: Number): ScatterChartBuilder;
setXAxisTextStyle(textStyle: TextStyle): ScatterChartBuilder;
setXAxisTitle(title: string): ScatterChartBuilder;
setXAxisTitleTextStyle(textStyle: TextStyle): ScatterChartBuilder;
setYAxisLogScale(): ScatterChartBuilder;
setYAxisRange(start: Number, end: Number): ScatterChartBuilder;
setYAxisTextStyle(textStyle: TextStyle): ScatterChartBuilder;
setYAxisTitle(title: string): ScatterChartBuilder;
setYAxisTitleTextStyle(textStyle: TextStyle): ScatterChartBuilder;
}
/**
* A builder for string filter controls.
*
* A string filter is a simple text input field that lets the user filter data via string matching.
* Given a column of type string and matching options, this control will filter out the rows that
* don't match the term that's in the input field.
*
* This example creates a table chart and binds it to a string filter. Using the filter, it is
* possible to change the table chart to display a subset of its data.
*
* function doGet() {
* var app = UiApp.createApplication();
* var sampleData = Charts.newDataTable()
* .addColumn(Charts.ColumnType.STRING, "Month")
* .addColumn(Charts.ColumnType.NUMBER, "Dining")
* .addColumn(Charts.ColumnType.NUMBER, "Total")
* .addRow(["Jan", 60, 520])
* .addRow(["Feb", 50, 430])
* .addRow(["Mar", 53, 440])
* .addRow(["Apr", 70, 410])
* .addRow(["May", 80, 390])
* .addRow(["Jun", 60, 500])
* .addRow(["Jul", 100, 450])
* .addRow(["Aug", 140, 431])
* .addRow(["Sep", 75, 488])
* .addRow(["Oct", 70, 521])
* .addRow(["Nov", 58, 388])
* .addRow(["Dec", 63, 400])
* .build();
*
* var chart = Charts.newTableChart()
* .setDimensions(600, 500)
* .build();
*
* var stringFilter = Charts.newStringFilter()
* .setFilterColumnLabel("Month")
* .setRealtimeTrigger(true)
* .setCaseSensitive(true)
* .setLabel("Filter months shown")
* .build();
*
* var panel = app.createVerticalPanel().setSpacing(10);
* panel.add(stringFilter).add(chart);
*
* // Create a dashboard panel to bind the filter and the chart together.
* var dashboard = Charts.newDashboardPanel()
* .setDataTable(sampleData)
* .bind(stringFilter, chart)
* .build();
*
* dashboard.add(panel);
* app.add(dashboard);
* return app;
* }
*
* documentation
*/
export interface StringFilterBuilder {
build(): Control;
setCaseSensitive(caseSensitive: boolean): StringFilterBuilder;
setDataTable(tableBuilder: DataTableBuilder): StringFilterBuilder;
setDataTable(table: DataTableSource): StringFilterBuilder;
setFilterColumnIndex(columnIndex: Integer): StringFilterBuilder;
setFilterColumnLabel(columnLabel: string): StringFilterBuilder;
setLabel(label: string): StringFilterBuilder;
setLabelSeparator(labelSeparator: string): StringFilterBuilder;
setLabelStacking(orientation: Orientation): StringFilterBuilder;
setMatchType(matchType: MatchType): StringFilterBuilder;
setRealtimeTrigger(realtimeTrigger: boolean): StringFilterBuilder;
}
/**
* A builder for table charts. For more details, see the
* Google Charts documentation.
*
* Here is an example that shows how to build a table chart. The data is
* imported from a Google spreadsheet.
*
* function doGet() {
* // Get sample data from a spreadsheet.
* var dataSourceUrl = 'https://docs.google.com/spreadsheet/tq?range=A1%3AF' +
* '&key=0Aq4s9w_HxMs7dHpfX05JdmVSb1FpT21sbXd4NVE3UEE&gid=4&headers=-1';
*
* var chartBuilder = Charts.newTableChart()
* .setDimensions(600, 500)
* .enablePaging(20)
* .setDataSourceUrl(dataSourceUrl);
*
* var chart = chartBuilder.build();
* return UiApp.createApplication().add(chart);
* }
*/
export interface TableChartBuilder {
build(): Chart;
enablePaging(enablePaging: boolean): TableChartBuilder;
enablePaging(pageSize: Integer): TableChartBuilder;
enablePaging(pageSize: Integer, startPage: Integer): TableChartBuilder;
enableRtlTable(rtlEnabled: boolean): TableChartBuilder;
enableSorting(enableSorting: boolean): TableChartBuilder;
setDataSourceUrl(url: string): TableChartBuilder;
setDataTable(tableBuilder: DataTableBuilder): TableChartBuilder;
setDataTable(table: DataTableSource): TableChartBuilder;
setDataViewDefinition(dataViewDefinition: DataViewDefinition): TableChartBuilder;
setDimensions(width: Integer, height: Integer): TableChartBuilder;
setFirstRowNumber(number: Integer): TableChartBuilder;
setInitialSortingAscending(column: Integer): TableChartBuilder;
setInitialSortingDescending(column: Integer): TableChartBuilder;
setOption(option: string, value: Object): TableChartBuilder;
showRowNumberColumn(showRowNumber: boolean): TableChartBuilder;
useAlternatingRowStyle(alternate: boolean): TableChartBuilder;
}
/**
* A text style configuration object. Used in charts options to configure text style for
* elements that accepts it, such as title, horizontal axis, vertical axis, legend and tooltip.
*
* // This example creates a chart specifying different text styles for the title and axes.
* function doGet() {
* var sampleData = Charts.newDataTable()
* .addColumn(Charts.ColumnType.STRING, "Seasons")
* .addColumn(Charts.ColumnType.NUMBER, "Rainy Days")
* .addRow(["Winter", 5])
* .addRow(["Spring", 12])
* .addRow(["Summer", 8])
* .addRow(["Fall", 8])
* .build();
*
* var titleTextStyleBuilder = Charts.newTextStyle()
* .setColor('#0000FF').setFontSize(26).setFontName('Ariel');
* var axisTextStyleBuilder = Charts.newTextStyle()
* .setColor('#3A3A3A').setFontSize(20).setFontName('Ariel');
* var titleTextStyle = titleTextStyleBuilder.build();
* var axisTextStyle = axisTextStyleBuilder.build();
*
* var chart = Charts.newLineChart()
* .setTitleTextStyle(titleTextStyle)
* .setXAxisTitleTextStyle(axisTextStyle)
* .setYAxisTitleTextStyle(axisTextStyle)
* .setTitle('Rainy Days Per Season')
* .setXAxisTitle('Season')
* .setYAxisTitle('Number of Rainy Days')
* .setDataTable(sampleData)
* .build();
*
* return UiApp.createApplication().add(chart);
* }
*/
export interface TextStyle {
getColor(): string;
getFontName(): string;
getFontSize(): Number;
}
/**
* A builder used to create TextStyle objects. It allows configuration of the text's
* properties such as name, color, and size.
*
* The following example shows how to create a text style using the builder. For a more complete
* example, refer to the documentation for TextStyle.
*
* // Creates a new text style that uses 26-point, blue, Ariel font.
* var textStyleBuilder = Charts.newTextStyle()
* .setColor('#0000FF').setFontName('Ariel').setFontSize(26);
* var style = textStyleBuilder.build();
*/
export interface TextStyleBuilder {
build(): TextStyle;
setColor(cssValue: string): TextStyleBuilder;
setFontName(fontName: string): TextStyleBuilder;
setFontSize(fontSize: Number): TextStyleBuilder;
}
}
}
declare var Charts: GoogleAppsScript.Charts.Charts;