diff --git a/nvd3/nvd3.d.ts b/nvd3/nvd3.d.ts index 0fb9db4ed..97e1ebf92 100644 --- a/nvd3/nvd3.d.ts +++ b/nvd3/nvd3.d.ts @@ -1,6 +1,6 @@ // Type definitions for nvd3 1.8.1 // Project: https://github.com/novus/nvd3 -// Definitions by: Maxime LUCE +// Definitions by: Peter Mitchell // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -19,29 +19,29 @@ declare module nv { bottom?: number } - interface Legend extends Chart { + interface Legend extends Chart { key(): any; - key(value: any): Legend; + key(value: any): this; align(): boolean; - align(value: boolean): Legend; + align(value: boolean): this; maxKeyLength(): number; - maxKeyLength(value: number): Legend; + maxKeyLength(value: number): this; rightAlign(): boolean; - rightAlign(value: boolean): Legend; + rightAlign(value: boolean): this; //define how much space between legend items. - recommend 32 for furious version padding(): number; //define how much space between legend items. - recommend 32 for furious version - padding(value: number): Legend; + padding(value: number): this; //If true, legend will update data.disabled and trigger a 'stateChange' dispatch. updateState(): boolean; //If true, legend will update data.disabled and trigger a 'stateChange' dispatch. - updateState(value: boolean): Legend; + updateState(value: boolean): this; //If true, clicking legend items will cause it to behave like a radio button. (only one can be selected at radioButtonMode(): boolean; //If true, clicking legend items will cause it to behave like a radio button. (only one can be selected at - radioButtonMode(value: boolean): Legend; + radioButtonMode(value: boolean): this; expanded(): boolean; - expanded(value: boolean): Legend; + expanded(value: boolean): this; //Options are "classic" and "furious" vers(): string; //Options are "classic" and "furious" @@ -112,117 +112,118 @@ declare module nv { } interface ChartBase { - update(): void; - interactiveLayer :InteractiveLayer; - (transition: d3.Transition, ...args: any[]) :any; - (selection: d3.Selection, ...args: any[]) :any; - (transition: d3.Transition, ...args: any[]) :any; - (selection: d3.Selection, ...args: any[]) :any; } - interface Chart extends ChartBase { + interface Chart { margin() : Margin; - margin(value: Margin) : TChart; + margin(value: Margin) : this; width(): number; - width(value: number) : TChart; + width(value: number) : this; height(): number; - height(value: number) : TChart; - color(value:string[]) : TChart; - color(value:string) : TChart; - dispatch : d3.Dispatch; + height(value: number) : this; + color(value:string[]) : this; + color(value:string) : this; + dispatch: d3.Dispatch; + + update(): void; + interactiveLayer: InteractiveLayer; + + (transition: d3.Transition, ...args: any[]): any; + (selection: d3.Selection, ...args: any[]): any; + (transition: d3.Transition, ...args: any[]): any; + (selection: d3.Selection, ...args: any[]): any; } - interface TwoDimensionalChart extends Chart + interface TwoDimensionalChart extends Chart { xAxis : NvAxis; yAxis : NvAxis; - x(func: (any)=> any) : TChart; - y(func: (any)=> any) : TChart; - xScale(scale: d3.time.Scale) : TChart; + x(func: (any)=> any) : this; + y(func: (any) => any): this; + xScale(scale: d3.time.Scale): this; xScale() : d3.time.Scale; - yScale(scale: d3.time.Scale) : TChart; + yScale(scale: d3.time.Scale): this; yScale() : d3.time.Scale - forceX([xMin, xMax] : [number,number]) : TChart; - forceY([xMin, xMax] : [number,number]) : TChart; + forceX([xMin, xMax]: [number, number]): this; + forceY([xMin, xMax]: [number, number]): this; } - interface HistoricalBarBase extends TwoDimensionalChart{ + interface HistoricalBarBase extends TwoDimensionalChart{ } - interface HistoricalBar extends HistoricalBarBase{ + interface HistoricalBar extends HistoricalBarBase{ } - interface HistoricalBarChart extends HistoricalBarBase{ + interface HistoricalBarChart extends HistoricalBarBase{ bars: HistoricalBar; legend: Legend; noData(): any //todo; - noData(value: any): HistoricalBarChart //todo; + noData(value: any): this //todo; defaultState(): any //todo; - defaultState(value: any): HistoricalBarChart //todo; + defaultState(value: any): this //todo; showXAxis(): boolean //todo; - showXAxis(value: boolean): HistoricalBarChart //todo; + showXAxis(value: boolean): this //todo; showLegend(): boolean //todo; - showLegend(value: boolean): HistoricalBarChart //todo; + showLegend(value: boolean): this //todo; showYAxis(): boolean //todo; - showYAxis(value: boolean): HistoricalBarChart //todo; + showYAxis(value: boolean): this //todo; rightAlignYAxis(): boolean //todo; - rightAlignYAxis(value: boolean): HistoricalBarChart //todo; - useInteractiveGuideline(value : boolean) : HistoricalBarChart; - duration(value: number) : HistoricalBarChart; - interactiveLayer :InteractiveLayer; + rightAlignYAxis(value: boolean): this //todo; + useInteractiveGuideline(value: boolean): this; + duration(value: number): this; } - interface BoxPlotChart extends TwoDimensionalChart{ - useInteractiveGuideline(value : boolean) : BoxPlotChart; - duration(value: number) : BoxPlotChart; + interface BoxPlotChart extends TwoDimensionalChart{ + useInteractiveGuideline(value : boolean) : this; + duration(value: number): this; - staggerLabels(value : boolean) : BoxPlotChart; - maxBoxWidth(value: number) : BoxPlotChart; - yDomain([xMin, xMax] : [number,number]): BoxPlotChart; - xDomain([xMin, xMax] : [number,number]): BoxPlotChart; + staggerLabels(value: boolean): this; + maxBoxWidth(value: number): this; + yDomain([xMin, xMax]: [number, number]): this; + xDomain([xMin, xMax]: [number, number]): this; showXAxis(): boolean //todo; - showXAxis(value: boolean): BoxPlotChart //todo; + showXAxis(value: boolean): this //todo; showYAxis(): boolean //todo; - showYAxis(value: boolean): BoxPlotChart //todo; + showYAxis(value: boolean): this //todo; rightAlignYAxis(): boolean //todo; - rightAlignYAxis(value: boolean): BoxPlotChart //todo; + rightAlignYAxis(value: boolean): this //todo; } - interface BulletBase extends Chart { + interface BulletBase extends Chart { orient(): string; - orient(orientation: string): TBullet; + orient(orientation: string): this; tickFormat(): (t: any) => string; - tickFormat(format: (t: any) => string): TBullet; + tickFormat(format: (t: any) => string): this; tickFormat(format:string): NvAxis; - tickFormat(format: (t: any, i: any) => string): TBullet; - forceX([xMin, xMax] : [number,number]) : TBullet; + tickFormat(format: (t: any, i: any) => string): this; + forceX([xMin, xMax]: [number, number]): this; ranges(): any //todo; - ranges(value: any): TBullet //todo; + ranges(value: any): this //todo; markers(): any //todo; - markers(value: any): TBullet //todo; + markers(value: any): this //todo; measures(): any //todo; - measures(value: any): TBullet //todo; + measures(value: any): this //todo; } - interface Bullet extends BulletBase{ + interface Bullet extends BulletBase{ } - interface BulletChart extends BulletBase{ + interface BulletChart extends BulletBase{ bullet: Bullet ticks(): any //todo; - ticks(value: any): BulletChart //todo; + ticks(value: any): this //todo; noData(): any //todo; - noData(value: any): BulletChart //todo; + noData(value: any): this //todo; } interface Models{ historicalBar(): HistoricalBar; @@ -235,9 +236,9 @@ declare module nv { tooltip(): Tooltip; } - interface ChartFactory { - generate: ()=> Chart; - callback?: (chart:Chart)=> void; + interface ChartFactory { + generate: () => TChart; + callback?: (chart: TChart)=> void; } @@ -245,8 +246,8 @@ declare module nv { models: Models; tooltip: Tooltip; utils: Utils; - addGraph(factory: ChartFactory); - addGraph(generate : ()=> Chart, callBack?: (chart:Chart)=> void) ; + addGraph(factory: ChartFactory); + addGraph(generate: () => TChart, callBack?: (chart: TChart)=> void) ; } } declare var nv : nv.nvStatic; \ No newline at end of file