diff --git a/google.visualization/google.visualization-tests.ts b/google.visualization/google.visualization-tests.ts new file mode 100644 index 000000000..0f0082816 --- /dev/null +++ b/google.visualization/google.visualization-tests.ts @@ -0,0 +1,41 @@ +/// + +function test_arrayToDataTable() { + var array = [ + ['City', 'Population', 'Area'], + ['Rome', 2761477, 1285.31], + ['Milan', 1324110, 181.76], + ['Naples', 959574, 117.27], + ['Turin', 907563, 130.17], + ['Palermo', 655875, 158.9], + ['Genoa', 607906, 243.60], + ['Bologna', 380181, 140.7], + ['Florence', 371282, 102.41], + ['Fiumicino', 67370, 213.44], + ['Anzio', 52192, 43.43], + ['Ciampino', 38262, 11], + ]; + + var dataTable = google.visualization.arrayToDataTable(array); +} + +function test_ctorDataTable() { + var dataTable = new google.visualization.DataTable(); + return dataTable; +} + +function test_dataTableAddColumn() { + var dataTable = test_ctorDataTable(); + dataTable.addColumn('string', 'First Column'); + dataTable.addColumn('number', 'Second Column'); +} + +function test_dataTableAddRow() { + var dataTable = test_ctorDataTable(); + dataTable.addRow(['row1', 6]); + dataTable.addRow(['row2', -1]); + dataTable.addRow(['row3', 0]); +} + + + diff --git a/google.visualization/google.visualization.d.ts b/google.visualization/google.visualization.d.ts new file mode 100644 index 000000000..13d9421bc --- /dev/null +++ b/google.visualization/google.visualization.d.ts @@ -0,0 +1,121 @@ +declare module google { + + function load(visualization: string, version: string, packages: any): void; + function setOnLoadCallback(handler: Function): void; + function setOnLoadCallback(handler: () => void): void; + + module visualization { + + // https://developers.google.com/chart/interactive/docs/reference#DataTable + + export interface DataTableColumnDescription { + type?: string; + label?: string; + id?: string; + role?: string; + pattern?: string; + } + + export interface DataObjectCell { + v?: any; + f?: string; + p?: any; + } + + export interface DataObjectColumn { + type: string; + id?: string; + label?: string; + pattern?: string; + p?: any; + } + + export interface DataObjectRow { + c: DataObjectCell[]; + p?: any; + } + + export interface DataObject { + cols: DataObjectColumn[]; + rows: DataObjectRow[]; + p: any; + } + + export class DataTable { + constructor(data?: any, version?: any); + addColumn(type: string, label?: string, id?: string): number; + addColumn(descriptionObject: DataTableColumnDescription): number; + addRow(cellObject: DataObjectCell): number; + addRow(cellArray?: any[]): number; + addRows(count: number): number; + addRows(array: DataObjectCell[][]): number; + addRows(array: any[]): number; + } + + function arrayToDataTable(data: any[]): DataTable; + + //https://google-developers.appspot.com/chart/interactive/docs/gallery/geochart + export class GeoChart { + constructor(element: Element); + draw(chart: DataTable, options: GeoChartOptions): void; + } + export interface GeoChartOptions { + backgroundColor?: any; + colorAxis?: GeoChartColorAxis; + datalessRegionColor?: string; + displayMode?: string; + enableRegionInteractivity?: boolean; + height?: number; + keepAspectRatio?: boolean; + legend?: GeoChartLegend; + region?: string; + magnifyingGlass?: GeoChartMagnifyingGlass; + markerOpacity?: number; + resolution?: string; + sizeAxis?: GeoChartAxis; + tooltip?: GeoChartTooltip; + width?: number; + } + //export interface GeoChartColor { + // fill?: string; + // stroke?: string; + // strokeWidth: number; + //} + export interface GeoChartColorAxis extends GeoChartAxis { + minValue?: number; + maxValue?: number; + values?: number[]; + colors?: string[]; + } + export interface GeoChartTextStyle { + color?: string; + fontName?: string; + fontSize?: number; + bold?: boolean; + italic?: boolean; + } + export interface GeoChartLegend { + numberFormat?: string; + textStyle?: GeoChartTextStyle; + } + export interface GeoChartMagnifyingGlass { + enable?: boolean; + zoomFactor?: number; + } + export interface GeoChartAxis { + maxSize?: number; + maxValue?: number; + minSize?: number; + minValue?: number; + } + export interface GeoChartTooltip { + textStyle?: GeoChartTextStyle; + trigger?: string; + } + + module events { + function addListener(chart: any, eventName: string, callback: Function): any; + function addListener(chart: any, eventName: string, callback: () => any): any; + } + } +} \ No newline at end of file