Files
DefinitelyTyped/d3.cloud.layout/index.d.ts
Tom Wanzek 0500bd3558 Replace D3 Legacy (#12256)
* Replace D3 v3 definition with D3 v4 (bundle)
* Replaces the legacy D3 v3 definitions in `d3` with a definition file representing the D3 version 4 standard bundle
* Add `package.json` file with legacy dependency to @types/d3 version >=3.5.36 <4.0.0

* Updated tsconfig.json, package.json, versions
* Updated tsconfig.json to control typings resolution for D3 v3
* Updated package.json to use caret notation of D3 typings
* Updated certain affected definitions header comments with version numbers, where version number was missing buit seemed reasonably ascertainable as latest.
* Added comments to each affected definition file with TODO once upgrade to D3 v4 is considered

* Chore changes as per review.

* Removed TODO "upgrade-to-v4" comments

* Removed added empty lines.
2016-10-27 13:35:57 -07:00

82 lines
3.1 KiB
TypeScript

// Type definitions for d3JS cloud layout plugin by Jason Davies v1.2.2
// Project: https://github.com/jasondavies/d3-cloud
// Definitions by: hans windhoff <https://github.com/hansrwindhoff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as d3 from 'd3';
declare module 'd3' {
namespace layout {
export function cloud(): Cloud<cloud.Word>;
export function cloud<T extends cloud.Word>(): Cloud<T>;
namespace cloud {
interface Word {
text?: string;
font?: string;
style?: string;
weight?: string | number;
rotate?: number;
size?: number;
padding?: number;
x?: number;
y?: number;
}
}
interface Cloud<T extends cloud.Word> {
start(): Cloud<T>;
stop(): Cloud<T>;
timeInterval(): number;
timeInterval(interval: number): Cloud<T>;
words(): T[];
words(words: T[]): Cloud<T>;
size(): [number, number];
size(size: [number, number]): Cloud<T>;
font(): (datum: T, index: number) => string;
font(font: string): Cloud<T>;
font(font: (datum: T, index: number) => string): Cloud<T>;
fontStyle(): (datum: T, index: number) => string;
fontStyle(style: string): Cloud<T>;
fontStyle(style: (datum: T, index: number) => string): Cloud<T>;
fontWeight(): (datum: T, index: number) => string | number;
fontWeight(weight: string | number): Cloud<T>;
fontWeight(weight: (datum: T, index: number) => string | number): Cloud<T>;
rotate(): (datum: T, index: number) => number;
rotate(rotate: number): Cloud<T>;
rotate(rotate: (datum: T, index: number) => number): Cloud<T>;
text(): (datum: T, index: number) => string;
text(text: string): Cloud<T>;
text(text: (datum: T, index: number) => string): Cloud<T>;
spiral(): (size: number) => (t: number) => [number, number];
spiral(name: string): Cloud<T>;
spiral(spiral: (size: number) => (t: number) => [number, number]): Cloud<T>;
fontSize(): (datum: T, index: number) => number;
fontSize(size: number): Cloud<T>;
fontSize(size: (datum: T, index: number) => number): Cloud<T>;
padding(): (datum: T, index: number) => number;
padding(padding: number): Cloud<T>;
padding(padding: (datum: T, index: number) => number): Cloud<T>;
on(type: "word", listener: (word: T) => void): Cloud<T>;
on(type: "end", listener: (tags: T[], bounds: { x: number; y: number }[]) => void): Cloud<T>;
on(type: string, listener: (...args: any[]) => void): Cloud<T>;
on(type: "word"): (word: T) => void;
on(type: "end"): (tags: T[], bounds: { x: number; y: number }[]) => void;
on(type: string): (...args: any[]) => void;
}
}
}