From 0e143ef3e724cb2ae51e6d2e25dc41fd2a688f65 Mon Sep 17 00:00:00 2001 From: Asger Feldthaus Date: Mon, 31 Mar 2014 14:26:26 +0200 Subject: [PATCH] various bugfixes in d3.d.ts --- d3/d3.d.ts | 132 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 86 insertions(+), 46 deletions(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 50d9eb6e6..1fcf3917d 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -528,7 +528,7 @@ declare module D3 { /** * gets the touch positions relative to a specified container. */ - touches(container: any): Array; + touches(container: any): Array>; /** * If the specified value is a function, returns the specified value. @@ -1031,7 +1031,7 @@ declare module D3 { ceil: (date: Date) => Date; range: Range; offset: (date: Date, step: number) => Date; - utc: Interval; + utc?: Interval; } export interface TimeFormat { @@ -1066,7 +1066,7 @@ declare module D3 { histogram(): HistogramLayout; pack(): PackLayout; partition(): PartitionLayout; - treeMap(): TreeMapLayout; + treemap(): TreeMapLayout; } export interface StackLayout { @@ -1266,7 +1266,7 @@ declare module D3 { } export interface BundleLayout{ - (links: Array): Array; + (links: Array): Array>; } export interface ChordLayout { @@ -1279,15 +1279,15 @@ declare module D3 { (padding: number): ChordLayout; } sortGroups: { - (): Array; + (): (a: number, b: number) => number; (comparator: (a: number, b: number) => number): ChordLayout; } sortSubgroups: { - (): Array; + (): (a: number, b: number) => number; (comparator: (a: number, b: number) => number): ChordLayout; } sortChords: { - (): Array; + (): (a: number, b: number) => number; (comparator: (a: number, b: number) => number): ChordLayout; } chords(): Array; @@ -2480,7 +2480,7 @@ declare module D3 { (values: any[]): Scale; (): any[]; }; - invertExtent(y: any): any[]; + invertExtent?(y: any): any[]; copy(): Scale; } @@ -2579,13 +2579,31 @@ declare module D3 { (value: number): number; } - export interface IdentityScale extends QuantitiveScale { + export interface IdentityScale extends Scale { /** * Get the range value corresponding to a given domain value. * * @param value Domain Value */ (value: number): number; + /** + * Get the domain value corresponding to a given range value. + * + * @param value Range Value + */ + invert(value: number): number; + /** + * get representative values from the input domain. + * + * @param count Aproximate representative values to return. + */ + ticks(count: number): any[]; + /** + * get a formatter for displaying tick values + * + * @param count Aproximate representative values to return + */ + tickFormat(count: number): (n: number) => string; } export interface SqrtScale extends QuantitiveScale { @@ -2910,11 +2928,11 @@ declare module D3 { /** * create a standard projection from a raw projection. */ - projection(raw: (lambda: any, phi: any) => any): Projection; + projection(raw: RawProjection): Projection; /** * create a standard projection from a mutable raw projection. */ - projectionMutator(rawFactory: (lambda: number, phi: number) => Array): Projection; + projectionMutator(rawFactory: RawProjection): ProjectionMutator; /** * the Albers equal-area conic projection. */ @@ -2928,82 +2946,82 @@ declare module D3 { */ azimuthalEqualArea: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * the azimuthal equidistant projection. */ azimuthalEquidistant: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * the conic conformal projection. */ conicConformal: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * the conic equidistant projection. */ conicEquidistant: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * the conic equal-area (a.k.a. Albers) projection. */ conicEqualArea: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * the equirectangular (plate carreƩ) projection. */ equirectangular: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * the gnomonic projection. */ gnomonic: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * the spherical Mercator projection. */ mercator: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * the azimuthal orthographic projection. */ - othographic: { + orthographic: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * the azimuthal stereographic projection. */ stereographic: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * the transverse Mercator projection. */ transverseMercator: { (): Projection; - raw(): Projection; + raw: RawProjection; } /** * convert a GeoJSON object to a geometry stream. */ - stream(object: GeoJSON, listener: any): Stream; + stream(object: GeoJSON, listener: Stream); /** * */ @@ -3011,7 +3029,7 @@ declare module D3 { /** * */ - greatArc: GreatArc; + greatArc(): GreatArc; /** * */ @@ -3107,7 +3125,7 @@ declare module D3 { export interface Graticule{ (): GeoJSON; - lines(): GeoJSON; + lines(): Array; outline(): GeoJSON; extent: { (): Array>; @@ -3161,9 +3179,14 @@ declare module D3 { type: string; } + export interface RawProjection { + (lambda: number, phi: number): Array; + invert?(x: number, y: number): Array; + } + export interface Projection { (coordinates: Array): Array; - invert(point: Array): Array; + invert?(point: Array): Array; rotate: { (): Array; (rotation: Array): Projection; @@ -3192,7 +3215,7 @@ declare module D3 { (): number; (precision: number): Projection; }; - stream(listener?: any): Stream; + stream(listener?: Stream): Stream; } export interface Stream { @@ -3208,6 +3231,10 @@ declare module D3 { (location: Array): Rotation; invert(location: Array): Rotation; } + + export interface ProjectionMutator { + (lambda: number, phi: number): Projection; + } } // Geometry @@ -3225,15 +3252,25 @@ declare module D3 { /** * constructs a quadtree for an array of points. */ - quadtree: Quadtree; + quadtree(): QuadtreeFactory; /** - * constructs a polygon + * Constructs a new quadtree for the specified array of points. */ - polygon: Polygon; + quadtree(points: Array, x1: number, y1: number, x2: number, y2: number): Quadtree; + /** + * Constructs a new quadtree for the specified array of points. + */ + quadtree(points: Array, width: number, height: number): Quadtree; + /** + * Returns the input array of vertices with additional methods attached + */ + polygon(vertices:Array): Polygon; /** * creates a new hull layout with the default settings. */ - hull: Hull; + hull(): Hull; + + hull(vertices:Array): Array; } export interface Vertice extends Array { @@ -3244,10 +3281,6 @@ declare module D3 { } export interface Polygon extends Array { - /** - * Returns the input array of vertices with additional methods attached - */ - (vertices: Array): Polygon; /** * Returns the signed area of this polygon */ @@ -3262,7 +3295,7 @@ declare module D3 { clip(subject: Polygon): Polygon; } - export interface Quadtree { + export interface QuadtreeFactory { /** * Constructs a new quadtree for the specified array of points. */ @@ -3275,22 +3308,29 @@ declare module D3 { * Constructs a new quadtree for the specified array of points. */ (points: Array, width: number, height: number): Quadtree; - /** - * Adds a new point to the quadtree. - */ - add(point: Point): Quadtree; - visit(callback: any): Quadtree; + x: { (): (d: any) => any; - (accesor: (d: any) => any): Quadtree; + (accesor: (d: any) => any): QuadtreeFactory; } y: { (): (d: any) => any; - (accesor: (d: any) => any): Quadtree; + (accesor: (d: any) => any): QuadtreeFactory; } - size(size: Array): Quadtree; + size(): Array; + size(size: Array): QuadtreeFactory; + extent(): Array>; + extent(points: Array>): QuadtreeFactory; + } + + export interface Quadtree { + /** + * Adds a new point to the quadtree. + */ + add(point: Point); + visit(callback: any); } export interface Point { @@ -3378,7 +3418,7 @@ declare module D3 { } export interface Hull { - (vertices: Array): Hull; + (vertices: Array): Array; x: { (): (d: any) => any; (accesor: (d: any) => any): any;