typescript-closure-tools
Version:
Command-line tools to convert closure-style JSDoc annotations to typescript, and to convert typescript sources to closure externs files
1,536 lines (1,460 loc) • 111 kB
TypeScript
// Type definitions for d3JS
// Project: http://d3js.org/
// Definitions by: Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module D3 {
export interface Selectors {
/**
* Select an element from the current document
*/
select: {
/**
* Selects the first element that matches the specified selector string
*
* @param selector Selection String to match
*/
(selector: string): Selection;
/**
* Selects the specified node
*
* @param element Node element to select
*/
(element: EventTarget): Selection;
};
/**
* Select multiple elements from the current document
*/
selectAll: {
/**
* Selects all elements that match the specified selector
*
* @param selector Selection String to match
*/
(selector: string): Selection;
/**
* Selects the specified array of elements
*
* @param elements Array of node elements to select
*/
(elements: EventTarget[]): Selection;
};
}
export interface Event {
dx: number;
dy: number;
clientX: number;
clientY: number;
translate: number[];
scale: number;
sourceEvent: Event;
x: number;
y: number;
keyCode: number;
altKey: any;
type: string;
}
export interface Base extends Selectors {
/**
* Create a behavior
*/
behavior: Behavior.Behavior;
/**
* Access the current user event for interaction
*/
event: Event;
/**
* Compare two values for sorting.
* Returns -1 if a is less than b, or 1 if a is greater than b, or 0
*
* @param a First value
* @param b Second value
*/
ascending<T>(a: T, b: T): number;
/**
* Compare two values for sorting.
* Returns -1 if a is greater than b, or 1 if a is less than b, or 0
*
* @param a First value
* @param b Second value
*/
descending<T>(a: T, b: T): number;
/**
* Find the minimum value in an array
*
* @param arr Array to search
* @param map Accsessor function
*/
min<T, U>(arr: T[], map: (v: T) => U): U;
/**
* Find the minimum value in an array
*
* @param arr Array to search
*/
min<T>(arr: T[]): T;
/**
* Find the maximum value in an array
*
* @param arr Array to search
* @param map Accsessor function
*/
max<T, U>(arr: T[], map: (v: T) => U): U;
/**
* Find the maximum value in an array
*
* @param arr Array to search
*/
max<T>(arr: T[]): T;
/**
* Find the minimum and maximum value in an array
*
* @param arr Array to search
* @param map Accsessor function
*/
extent<T, U>(arr: T[], map: (v: T) => U): U[];
/**
* Find the minimum and maximum value in an array
*
* @param arr Array to search
*/
extent<T>(arr: T[]): T[];
/**
* Compute the sum of an array of numbers
*
* @param arr Array to search
* @param map Accsessor function
*/
sum<T>(arr: T[], map: (v: T) => number): number;
/**
* Compute the sum of an array of numbers
*
* @param arr Array to search
*/
sum(arr: number[]): number;
/**
* Compute the arithmetic mean of an array of numbers
*
* @param arr Array to search
* @param map Accsessor function
*/
mean<T>(arr: T[], map: (v: T) => number): number;
/**
* Compute the arithmetic mean of an array of numbers
*
* @param arr Array to search
*/
mean(arr: number[]): number;
/**
* Compute the median of an array of numbers (the 0.5-quantile).
*
* @param arr Array to search
* @param map Accsessor function
*/
median<T>(arr: T[], map: (v: T) => number): number;
/**
* Compute the median of an array of numbers (the 0.5-quantile).
*
* @param arr Array to search
*/
median(arr: number[]): number;
/**
* Compute a quantile for a sorted array of numbers.
*
* @param arr Array to search
* @param p The quantile to return
*/
quantile: (arr: number[], p: number) => number;
/**
* Locate the insertion point for x in array to maintain sorted order
*
* @param arr Array to search
* @param x Value to search for insertion point
* @param low Minimum value of array subset
* @param hihg Maximum value of array subset
*/
bisect<T>(arr: T[], x: T, low?: number, high?: number): number;
/**
* Locate the insertion point for x in array to maintain sorted order
*
* @param arr Array to search
* @param x Value to serch for insertion point
* @param low Minimum value of array subset
* @param high Maximum value of array subset
*/
bisectLeft<T>(arr: T[], x: T, low?: number, high?: number): number;
/**
* Locate the insertion point for x in array to maintain sorted order
*
* @param arr Array to search
* @param x Value to serch for insertion point
* @param low Minimum value of array subset
* @param high Maximum value of array subset
*/
bisectRight<T>(arr: T[], x: T, low?: number, high?: number): number;
/**
* Bisect using an accessor.
*
* @param accessor Accessor function
*/
bisector(accessor: (data: any, index: number) => any): any;
/**
* Randomize the order of an array.
*
* @param arr Array to randomize
*/
shuffle<T>(arr: T[]): T[];
/**
* Reorder an array of elements according to an array of indexes
*
* @param arr Array to reorder
* @param indexes Array containing the order the elements should be returned in
*/
permute(arr: any[], indexes: any[]): any[];
/**
* Transpose a variable number of arrays.
*
* @param arrs Arrays to transpose
*/
zip(...arrs: any[]): any[];
/**
* Parse the given 2D affine transform string, as defined by SVG's transform attribute.
*
* @param definition 2D affine transform string
*/
transform(definition: string): any;
/**
* Transpose an array of arrays.
*
* @param matrix Two dimensional array to transpose
*/
transpose(matrix: any[]): any[];
/**
* List the keys of an associative array.
*
* @param map Array of objects to get the key values from
*/
keys(map: any): string[];
/**
* List the values of an associative array.
*
* @param map Array of objects to get the values from
*/
values(map: any[]): any[];
/**
* List the key-value entries of an associative array.
*
* @param map Array of objects to get the key-value pairs from
*/
entries(map: any): any[];
/**
* merge multiple arrays into one array
*
* @param map Arrays to merge
*/
merge(...map: any[]): any[];
/**
* Generate a range of numeric values.
*/
range: {
/**
* Generate a range of numeric values from 0.
*
* @param stop Value to generate the range to
* @param step Step between each value
*/
(stop: number, step?: number): number[];
/**
* Generate a range of numeric values.
*
* @param start Value to start
* @param stop Value to generate the range to
* @param step Step between each value
*/
(start: number, stop?: number, step?: number): number[];
};
/**
* Create new nest operator
*/
nest(): Nest;
/**
* Request a resource using XMLHttpRequest.
*/
xhr: {
/**
* Creates an asynchronous request for specified url
*
* @param url Url to request
* @param callback Function to invoke when resource is loaded or the request fails
*/
(url: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr;
/**
* Creates an asynchronous request for specified url
*
* @param url Url to request
* @param mime MIME type to request
* @param callback Function to invoke when resource is loaded or the request fails
*/
(url: string, mime: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr;
};
/**
* Request a text file
*/
text: {
/**
* Request a text file
*
* @param url Url to request
* @param callback Function to invoke when resource is loaded or the request fails
*/
(url: string, callback?: (response: string) => void ): Xhr;
/**
* Request a text file
*
* @param url Url to request
* @param mime MIME type to request
* @param callback Function to invoke when resource is loaded or the request fails
*/
(url: string, mime: string, callback?: (response: string) => void ): Xhr;
};
/**
* Request a JSON blob
*
* @param url Url to request
* @param callback Function to invoke when resource is loaded or the request fails
*/
json: (url: string, callback?: (error: any, data: any) => void ) => Xhr;
/**
* Request an HTML document fragment.
*/
xml: {
/**
* Request an HTML document fragment.
*
* @param url Url to request
* @param callback Function to invoke when resource is loaded or the request fails
*/
(url: string, callback?: (response: Document) => void ): Xhr;
/**
* Request an HTML document fragment.
*
* @param url Url to request
* @param mime MIME type to request
* @param callback Function to invoke when resource is loaded or the request fails
*/
(url: string, mime: string, callback?: (response: Document) => void ): Xhr;
};
/**
* Request an XML document fragment.
*
* @param url Url to request
* @param callback Function to invoke when resource is loaded or the request fails
*/
html: (url: string, callback?: (response: DocumentFragment) => void ) => Xhr;
/**
* Request a comma-separated values (CSV) file.
*/
csv: Dsv;
/**
* Request a tab-separated values (TSV) file
*/
tsv: Dsv;
/**
* Time Functions
*/
time: Time.Time;
/**
* Scales
*/
scale: Scale.ScaleBase;
/*
* Interpolate two values
*/
interpolate: Transition.BaseInterpolate;
/*
* Interpolate two numbers
*/
interpolateNumber: Transition.BaseInterpolate;
/*
* Interpolate two integers
*/
interpolateRound: Transition.BaseInterpolate;
/*
* Interpolate two strings
*/
interpolateString: Transition.BaseInterpolate;
/*
* Interpolate two RGB colors
*/
interpolateRgb: Transition.BaseInterpolate;
/*
* Interpolate two HSL colors
*/
interpolateHsl: Transition.BaseInterpolate;
/*
* Interpolate two HCL colors
*/
interpolateHcl: Transition.BaseInterpolate;
/*
* Interpolate two L*a*b* colors
*/
interpolateLab: Transition.BaseInterpolate;
/*
* Interpolate two arrays of values
*/
interpolateArray: Transition.BaseInterpolate;
/*
* Interpolate two arbitary objects
*/
interpolateObject: Transition.BaseInterpolate;
/*
* Interpolate two 2D matrix transforms
*/
interpolateTransform: Transition.BaseInterpolate;
/*
* The array of built-in interpolator factories
*/
interpolators: Array<Transition.InterpolateFactory>;
/**
* Layouts
*/
layout: Layout.Layout;
/**
* Svg's
*/
svg: Svg.Svg;
/**
* Random number generators
*/
random: Random;
/**
* Create a function to format a number as a string
*
* @param specifier The format specifier to use
*/
format(specifier: string): (value: number) => string;
/**
* Returns the SI prefix for the specified value at the specified precision
*/
formatPrefix(value: number, precision?: number): MetricPrefix;
/**
* The version of the d3 library
*/
version: string;
/**
* Returns the root selection
*/
selection(): Selection;
ns: {
/**
* The map of registered namespace prefixes
*/
prefix: {
svg: string;
xhtml: string;
xlink: string;
xml: string;
xmlns: string;
};
/**
* Qualifies the specified name
*/
qualify(name: string): { space: string; local: string; };
};
/**
* Returns a built-in easing function of the specified type
*/
ease: (type: string, ...arrs: any[]) => D3.Transition.Transition;
/**
* Constructs a new RGB color.
*/
rgb: {
/**
* Constructs a new RGB color with the specified r, g and b channel values
*/
(r: number, g: number, b: number): D3.Color.RGBColor;
/**
* Constructs a new RGB color by parsing the specified color string
*/
(color: string): D3.Color.RGBColor;
};
/**
* Constructs a new HCL color.
*/
hcl: {
/**
* Constructs a new HCL color.
*/
(h: number, c: number, l: number): Color.HCLColor;
/**
* Constructs a new HCL color by parsing the specified color string
*/
(color: string): Color.HCLColor;
};
/**
* Constructs a new HSL color.
*/
hsl: {
/**
* Constructs a new HSL color with the specified hue h, saturation s and lightness l
*/
(h: number, s: number, l: number): Color.HSLColor;
/**
* Constructs a new HSL color by parsing the specified color string
*/
(color: string): Color.HSLColor;
};
/**
* Constructs a new RGB color.
*/
lab: {
/**
* Constructs a new LAB color.
*/
(l: number, a: number, b: number): Color.LABColor;
/**
* Constructs a new LAB color by parsing the specified color string
*/
(color: string): Color.LABColor;
};
geo: Geo.Geo;
geom: Geom.Geom;
/**
* gets the mouse position relative to a specified container.
*/
mouse(container: any): Array<number>;
/**
* gets the touch positions relative to a specified container.
*/
touches(container: any): Array<Array<number>>;
/**
* If the specified value is a function, returns the specified value.
* Otherwise, returns a function that returns the specified value.
*/
functor<R,T>(value: (p : R) => T): (p : R) => T;
functor<T>(value: T): (p : any) => T;
map(object?: any): Map;
set(array?: Array<any>): Set;
dispatch(...types: Array<string>): Dispatch;
rebind(target: any, source: any, ...names: Array<any>): any;
requote(str: string): string;
timer: {
(funct: () => boolean, delay?: number, mark?: number): void;
flush(): void;
}
transition(): Transition.Transition;
round(x: number, n: number): number;
}
export interface Dispatch {
[event: string]: any;
on: {
(type: string): any;
(type: string, listener: any): any;
}
}
export interface MetricPrefix {
/**
* the scale function, for converting numbers to the appropriate prefixed scale.
*/
scale: (d: number) => number;
/**
* the prefix symbol
*/
symbol: string;
}
export interface Xhr {
/**
* Get or set request header
*/
header: {
/**
* Get the value of specified request header
*
* @param name Name of header to get the value for
*/
(name: string): string;
/**
* Set the value of specified request header
*
* @param name Name of header to set the value for
* @param value Value to set the header to
*/
(name: string, value: string): Xhr;
};
/**
* Get or set MIME Type
*/
mimeType: {
/**
* Get the current MIME Type
*/
(): string;
/**
* Set the MIME Type for the request
*
* @param type The MIME type for the request
*/
(type: string): Xhr;
};
/*
* Get or Set the function used to map the response to the associated data value
*/
response: {
/**
* Get function used to map the response to the associated data value
*/
(): (xhr: XMLHttpRequest) => any;
/**
* Set function used to map the response to the associated data value
*
* @param value The function used to map the response to a data value
*/
(value: (xhr: XMLHttpRequest) => any): Xhr;
};
/**
* Issue the request using the GET method
*
* @param callback Function to invoke on completion of request
*/
get(callback?: (xhr: XMLHttpRequest) => void ): Xhr;
/**
* Issue the request using the POST method
*/
post: {
/**
* Issue the request using the POST method
*
* @param callback Function to invoke on completion of request
*/
(callback?: (xhr: XMLHttpRequest) => void ): Xhr;
/**
* Issue the request using the POST method
*
* @param data Data to post back in the request
* @param callback Function to invoke on completion of request
*/
(data: any, callback?: (xhr: XMLHttpRequest) => void ): Xhr;
};
/**
* Issues this request using the specified method
*/
send: {
/**
* Issues this request using the specified method
*
* @param method Method to use to make the request
* @param callback Function to invoke on completion of request
*/
(method: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr;
/**
* Issues this request using the specified method
*
* @param method Method to use to make the request
* @param data Data to post back in the request
* @param callback Function to invoke on completion of request
*/
(method: string, data: any, callback?: (xhr: XMLHttpRequest) => void ): Xhr;
};
/**
* Aborts this request, if it is currently in-flight
*/
abort(): Xhr;
/**
* Registers a listener to receive events
*
* @param type Enent name to attach the listener to
* @param listener Function to attach to event
*/
on: (type: string, listener: (data: any, index?: number) => any) => Xhr;
}
export interface Dsv {
/**
* Request a delimited values file
*
* @param url Url to request
* @param callback Function to invoke when resource is loaded or the request fails
*/
(url: string, callback?: (error: any, response: any[]) => void ): Xhr;
/**
* Parse a delimited string into objects using the header row.
*
* @param string delimited formatted string to parse
*/
parse(string: string): any[];
/**
* Parse a delimited string into tuples, ignoring the header row.
*
* @param string delimited formatted string to parse
*/
parseRows(string: string, accessor: (row: any[], index: number) => any): any;
/**
* Format an array of tuples into a delimited string.
*
* @param rows Array to convert to a delimited string
*/
format(rows: any[]): string;
}
export interface Selection extends Selectors, Array<any> {
attr: {
(name: string): string;
(name: string, value: any): Selection;
(name: string, valueFunction: (data: any, index: number) => any): Selection;
(attrValueMap : Object): Selection;
};
classed: {
(name: string): string;
(name: string, value: any): Selection;
(name: string, valueFunction: (data: any, index: number) => any): Selection;
};
style: {
(name: string): string;
(name: string, value: any, priority?: string): Selection;
(name: string, valueFunction: (data: any, index: number) => any, priority?: string): Selection;
(styleValueMap : Object): Selection;
};
property: {
(name: string): void;
(name: string, value: any): Selection;
(name: string, valueFunction: (data: any, index: number) => any): Selection;
(propertyValueMap : Object): Selection;
};
text: {
(): string;
(value: any): Selection;
(valueFunction: (data: any, index: number) => any): Selection;
};
html: {
(): string;
(value: any): Selection;
(valueFunction: (data: any, index: number) => any): Selection;
};
append: (name: string) => Selection;
insert: (name: string, before: string) => Selection;
remove: () => Selection;
empty: () => boolean;
data: {
(values: (data: any, index?: number) => any[], key?: (data: any, index?: number) => string): UpdateSelection;
(values: any[], key?: (data: any, index?: number) => string): UpdateSelection;
(): any[];
};
datum: {
(values: (data: any, index: number) => any): UpdateSelection;
(values: any): UpdateSelection;
() : any;
};
filter: {
(filter: (data: any, index: number) => boolean, thisArg?: any): UpdateSelection;
//(filter: string): UpdateSelection;
};
call(callback: (selection: Selection) => void ): Selection;
each(eachFunction: (data: any, index: number) => any): Selection;
on: {
(type: string): (data: any, index: number) => any;
(type: string, listener: (data: any, index: number) => any, capture?: boolean): Selection;
};
/**
* Returns the total number of elements in the current selection.
*/
size(): number;
/**
* Starts a transition for the current selection. Transitions behave much like selections,
* except operators animate smoothly over time rather than applying instantaneously.
*/
transition(): Transition.Transition;
/**
* Sorts the elements in the current selection according to the specified comparator
* function.
*
* @param comparator a comparison function, which will be passed two data elements a and b
* to compare, and should return either a negative, positive, or zero value to indicate
* their relative order.
*/
sort<T>(comparator?: (a: T, b: T) => number): Selection;
/**
* Re-inserts elements into the document such that the document order matches the selection
* order. This is equivalent to calling sort() if the data is already sorted, but much
* faster.
*/
order: () => Selection;
/**
* Returns the first non-null element in the current selection. If the selection is empty,
* returns null.
*/
node: () => Element;
}
export interface EnterSelection {
append: (name: string) => Selection;
insert: (name: string, before: string) => Selection;
select: (selector: string) => Selection;
empty: () => boolean;
node: () => Element;
call: (callback: (selection: EnterSelection) => void) => EnterSelection;
size: () => number;
}
export interface UpdateSelection extends Selection {
enter: () => EnterSelection;
update: () => Selection;
exit: () => Selection;
}
export interface NestKeyValue {
key: string;
values: any;
}
export interface Nest {
key(keyFunction: (data: any, index: number) => string): Nest;
sortKeys(comparator: (d1: any, d2: any) => number): Nest;
sortValues(comparator: (d1: any, d2: any) => number): Nest;
rollup(rollupFunction: (data: any, index: number) => any): Nest;
map(values: any[]): any;
entries(values: any[]): NestKeyValue[];
}
export interface Map {
has(key: string): boolean;
get(key: string): any;
set<T>(key: string, value: T): T;
remove(key: string): boolean;
keys(): Array<string>;
values(): Array<any>;
entries(): Array<any>;
forEach(func: (key: string, value: any) => void ): void;
}
export interface Set{
has(value: any): boolean;
add(value: any): any;
remove(value: any): boolean;
values(): Array<any>;
forEach(func: (value: any) => void ): void;
}
export interface Random {
/**
* Returns a function for generating random numbers with a normal distribution
*
* @param mean The expected value of the generated pseudorandom numbers
* @param deviation The given standard deviation
*/
normal(mean?: number, deviation?: number): () => number;
/**
* Returns a function for generating random numbers with a log-normal distribution
*
* @param mean The expected value of the generated pseudorandom numbers
* @param deviation The given standard deviation
*/
logNormal(mean?: number, deviation?: number): () => number;
/**
* Returns a function for generating random numbers with an Irwin-Hall distribution
*
* @param count The number of independent variables
*/
irwinHall(count: number): () => number;
}
// Transitions
export module Transition {
export interface Transition {
duration: {
(duration: number): Transition;
(duration: (data: any, index: number) => any): Transition;
};
delay: {
(delay: number): Transition;
(delay: (data: any, index: number) => any): Transition;
};
attr: {
(name: string): string;
(name: string, value: any): Transition;
(name: string, valueFunction: (data: any, index: number) => any): Transition;
(attrValueMap : any): Transition;
};
style: {
(name: string): string;
(name: string, value: any, priority?: string): Transition;
(name: string, valueFunction: (data: any, index: number) => any, priority?: string): Transition;
};
call(callback: (selection: Selection) => void ): Transition;
/**
* Select an element from the current document
*/
select: {
/**
* Selects the first element that matches the specified selector string
*
* @param selector Selection String to match
*/
(selector: string): Transition;
/**
* Selects the specified node
*
* @param element Node element to select
*/
(element: EventTarget): Transition;
};
/**
* Select multiple elements from the current document
*/
selectAll: {
/**
* Selects all elements that match the specified selector
*
* @param selector Selection String to match
*/
(selector: string): Transition;
/**
* Selects the specified array of elements
*
* @param elements Array of node elements to select
*/
(elements: EventTarget[]): Transition;
}
each: (type?: string, eachFunction?: (data: any, index: number) => any) => Transition;
transition: () => Transition;
ease: (value: string, ...arrs: any[]) => Transition;
attrTween(name: string, tween: (d: any, i: number, a: any) => BaseInterpolate): Transition;
styleTween(name: string, tween: (d: any, i: number, a: any) => BaseInterpolate, priority?: string): Transition;
text: {
(text: string): Transition;
(text: (d: any, i: number) => string): Transition;
}
tween(name: string, factory: InterpolateFactory): Transition;
filter: {
(selector: string): Transition;
(selector: (data: any, index: number) => boolean): Transition;
};
remove(): Transition;
}
export interface InterpolateFactory {
(a?: any, b?: any): BaseInterpolate;
}
export interface BaseInterpolate {
(a: any, b?: any): any;
}
export interface Interpolate {
(t: any): any;
}
}
//Time
export module Time {
export interface Time {
second: Interval;
minute: Interval;
hour: Interval;
day: Interval;
week: Interval;
sunday: Interval;
monday: Interval;
tuesday: Interval;
wednesday: Interval;
thursday: Interval;
friday: Interval;
saturday: Interval;
month: Interval;
year: Interval;
seconds: Range;
minutes: Range;
hours: Range;
days: Range;
weeks: Range;
months: Range;
years: Range;
sundays: Range;
mondays: Range;
tuesdays: Range;
wednesdays: Range;
thursdays: Range;
fridays: Range;
saturdays: Range;
format: {
(specifier: string): TimeFormat;
utc: (specifier: string) => TimeFormat;
iso: TimeFormat;
};
scale: {
/**
* Constructs a new time scale with the default domain and range;
* the ticks and tick format are configured for local time.
*/
(): Scale.TimeScale;
/**
* Constructs a new time scale with the default domain and range;
* the ticks and tick format are configured for UTC time.
*/
utc(): Scale.TimeScale;
};
}
export interface Range {
(start: Date, end: Date, step?: number): Date[];
}
export interface Interval {
(date: Date): Date;
floor: (date: Date) => Date;
round: (date: Date) => Date;
ceil: (date: Date) => Date;
range: Range;
offset: (date: Date, step: number) => Date;
utc?: Interval;
}
export interface TimeFormat {
(date: Date): string;
parse: (string: string) => Date;
}
}
// Layout
export module Layout {
export interface Layout {
/**
* Creates a new Stack layout
*/
stack(): StackLayout;
/**
* Creates a new pie layout
*/
pie(): PieLayout;
/**
* Creates a new force layout
*/
force(): ForceLayout;
/**
* Creates a new tree layout
*/
tree(): TreeLayout;
bundle(): BundleLayout;
chord(): ChordLayout;
cluster(): ClusterLayout;
hierarchy(): HierarchyLayout;
histogram(): HistogramLayout;
pack(): PackLayout;
partition(): PartitionLayout;
treemap(): TreeMapLayout;
}
export interface StackLayout {
<T>(layers: T[], index?: number): T[];
values(accessor?: (d: any) => any): StackLayout;
offset(offset: string): StackLayout;
}
export interface TreeLayout {
/**
* Gets or sets the sort order of sibling nodes for the layout using the specified comparator function
*/
sort: {
/**
* Gets the sort order function of sibling nodes for the layout
*/
(): (d1: any, d2: any) => number;
/**
* Sets the sort order of sibling nodes for the layout using the specified comparator function
*/
(comparator: (d1: any, d2: any) => number): TreeLayout;
};
/**
* Gets or sets the specified children accessor function
*/
children: {
/**
* Gets the children accessor function
*/
(): (d: any) => any;
/**
* Sets the specified children accessor function
*/
(children: (d: any) => any): TreeLayout;
};
/**
* Runs the tree layout
*/
nodes(root: GraphNode): TreeLayout;
/**
* Given the specified array of nodes, such as those returned by nodes, returns an array of objects representing the links from parent to child for each node
*/
links(nodes: Array<GraphNode>): Array<GraphLink>;
/**
* If separation is specified, uses the specified function to compute separation between neighboring nodes. If separation is not specified, returns the current separation function
*/
seperation: {
/**
* Gets the current separation function
*/
(): (a: GraphNode, b: GraphNode) => number;
/**
* Sets the specified function to compute separation between neighboring nodes
*/
(seperation: (a: GraphNode, b: GraphNode) => number): TreeLayout;
};
/**
* Gets or sets the available layout size
*/
size: {
/**
* Gets the available layout size
*/
(): Array<number>;
/**
* Sets the available layout size
*/
(size: Array<number>): TreeLayout;
};
}
export interface PieLayout {
(values: any[], index?: number): ArcDescriptor[];
value: {
(): (d: any, index: number) => number;
(accessor: (d: any, index: number) => number): PieLayout;
};
sort: {
(): (d1: any, d2: any) => number;
(comparator: (d1: any, d2: any) => number): PieLayout;
};
startAngle: {
(): number;
(angle: number): PieLayout;
(angle: () => number): PieLayout;
(angle: (d : any) => number): PieLayout;
(angle: (d : any, i: number) => number): PieLayout;
};
endAngle: {
(): number;
(angle: number): PieLayout;
(angle: () => number): PieLayout;
(angle: (d : any) => number): PieLayout
(angle: (d : any, i: number) => number): PieLayout;
};
}
export interface ArcDescriptor {
value: any;
data: any;
startAngle: number;
endAngle: number;
index: number;
}
export interface GraphNode {
id: number;
index: number;
name: string;
px: number;
py: number;
size: number;
weight: number;
x: number;
y: number;
subindex: number;
startAngle: number;
endAngle: number;
value: number;
fixed: boolean;
children: GraphNode[];
_children: GraphNode[];
parent: GraphNode;
depth: number;
}
export interface GraphLink {
source: GraphNode;
target: GraphNode;
}
export interface ForceLayout {
(): ForceLayout;
size: {
(): number;
(mysize: number[]): ForceLayout;
(accessor: (d: any, index: number) => {}): ForceLayout;
};
linkDistance: {
(): number;
(number:number): ForceLayout;
(accessor: (d: any, index: number) => number): ForceLayout;
};
linkStrength:
{
(): number;
(number:number): ForceLayout;
(accessor: (d: any, index: number) => number): ForceLayout;
};
friction:
{
(): number;
(number:number): ForceLayout;
(accessor: (d: any, index: number) => number): ForceLayout;
};
alpha: {
(): number;
(number:number): ForceLayout;
(accessor: (d: any, index: number) => number): ForceLayout;
};
charge: {
(): number;
(number:number): ForceLayout;
(accessor: (d: any, index: number) => number): ForceLayout;
};
theta: {
(): number;
(number:number): ForceLayout;
(accessor: (d: any, index: number) => number): ForceLayout;
};
gravity: {
(): number;
(number:number): ForceLayout;
(accessor: (d: any, index: number) => number): ForceLayout;
};
links: {
(): GraphLink[];
(arLinks: GraphLink[]): ForceLayout;
};
nodes:
{
(): GraphNode[];
(arNodes: GraphNode[]): ForceLayout;
};
start(): ForceLayout;
resume(): ForceLayout;
stop(): ForceLayout;
tick(): ForceLayout;
on(type: string, listener: () => void ): ForceLayout;
drag(): ForceLayout;
}
export interface BundleLayout{
(links: Array<GraphLink>): Array<Array<GraphNode>>;
}
export interface ChordLayout {
matrix: {
(): Array<Array<number>>;
(matrix: Array<Array<number>>): ChordLayout;
}
padding: {
(): number;
(padding: number): ChordLayout;
}
sortGroups: {
(): (a: number, b: number) => number;
(comparator: (a: number, b: number) => number): ChordLayout;
}
sortSubgroups: {
(): (a: number, b: number) => number;
(comparator: (a: number, b: number) => number): ChordLayout;
}
sortChords: {
(): (a: number, b: number) => number;
(comparator: (a: number, b: number) => number): ChordLayout;
}
chords(): Array<GraphLink>;
groups(): Array<ArcDescriptor>;
}
export interface ClusterLayout{
sort: {
(): (a: GraphNode, b: GraphNode) => number;
(comparator: (a: GraphNode, b: GraphNode) => number): ClusterLayout;
}
children: {
(): (d: any, i?: number) => Array<GraphNode>;
(children: (d: any, i?: number) => Array<GraphNode>): ClusterLayout;
}
nodes(root: GraphNode): Array<GraphNode>;
links(nodes: Array<GraphNode>): Array<GraphLink>;
seperation: {
(): (a: GraphNode, b: GraphNode) => number;
(seperation: (a: GraphNode, b: GraphNode) => number): ClusterLayout;
}
size: {
(): Array<number>;
(size: Array<number>): ClusterLayout;
}
value: {
(): (node: GraphNode) => number;
(value: (node: GraphNode) => number): ClusterLayout;
}
}
export interface HierarchyLayout {
sort: {
(): (a: GraphNode, b: GraphNode) => number;
(comparator: (a: GraphNode, b: GraphNode) => number): HierarchyLayout;
}
children: {
(): (d: any, i?: number) => Array<GraphNode>;
(children: (d: any, i?: number) => Array<GraphNode>): HierarchyLayout;
}
nodes(root: GraphNode): Array<GraphNode>;
links(nodes: Array<GraphNode>): Array<GraphLink>;
value: {
(): (node: GraphNode) => number;
(value: (node: GraphNode) => number): HierarchyLayout;
}
reValue(root: GraphNode): HierarchyLayout;
}
export interface Bin extends Array<any> {
x: number;
dx: number;
y: number;
}
export interface HistogramLayout {
(values: Array<any>, index?: number): Array<Bin>;
value: {
(): (value: any) => any;
(accessor: (value: any) => any): HistogramLayout
}
range: {
(): (value: any, index: number) => Array<number>;
(range: (value: any, index: number) => Array<number>): HistogramLayout;
(range: Array<number>): HistogramLayout;
}
bins: {
(): (range: Array<any>, index: number) => Array<number>;
(bins: (range: Array<any>, index: number) => Array<number>): HistogramLayout;
(bins: number): HistogramLayout;
(bins: Array<number>): HistogramLayout;
}
frequency: {
(): boolean;
(frequency: boolean): HistogramLayout;
}
}
export interface PackLayout {
sort: {
(): (a: GraphNode, b: GraphNode) => number;
(comparator: (a: GraphNode, b: GraphNode) => number): PackLayout;
}
children: {
(): (d: any, i?: number) => Array<GraphNode>;
(children: (d: any, i?: number) => Array<GraphNode>): PackLayout;
}
nodes(root: GraphNode): Array<GraphNode>;
links(nodes: Array<GraphNode>): Array<GraphLink>;
value: {
(): (node: GraphNode) => number;
(value: (node: GraphNode) => number): PackLayout;
}
size: {
(): Array<number>;
(size: Array<number>): PackLayout;
}
padding: {
(): number;
(padding: number): PackLayout;
}
}
export interface PartitionLayout {
sort: {
(): (a: GraphNode, b: GraphNode) => number;
(comparator: (a: GraphNode, b: GraphNode) => number): PackLayout;
}
children: {
(): (d: any, i?: number) => Array<GraphNode>;
(children: (d: any, i?: number) => Array<GraphNode>): PackLayout;
}
nodes(root: GraphNode): Array<GraphNode>;
links(nodes: Array<GraphNode>): Array<GraphLink>;
value: {
(): (node: GraphNode) => number;
(value: (node: GraphNode) => number): PackLayout;
}
size: {
(): Array<number>;
(size: Array<number>): PackLayout;
}
}
export interface TreeMapLayout {
sort: {
(): (a: GraphNode, b: GraphNode) => number;
(comparator: (a: GraphNode, b: GraphNode) => number): TreeMapLayout;
}
children: {
(): (d: any, i?: number) => Array<GraphNode>;
(children: (d: any, i?: number) => Array<GraphNode>): TreeMapLayout;
}
nodes(root: GraphNode): Array<GraphNode>;
links(nodes: Array<GraphNode>): Array<GraphLink>;
value: {
(): (node: GraphNode) => number;
(value: (node: GraphNode) => number): TreeMapLayout;
}
size: {
(): Array<number>;
(size: Array<number>): TreeMapLayout;
}
padding: {
(): number;
(padding: number): TreeMapLayout;
}
round: {
(): boolean;
(round: boolean): TreeMapLayout;
}
sticky: {
(): boolean;
(sticky: boolean): TreeMapLayout;
}
mode: {
(): string;
(mode: string): TreeMapLayout;
}
}
}
// Color
export module Color {
export interface Color {
/**
* increase lightness by some exponential factor (gamma)
*/
brighter(k: number): Color;
/**
* decrease lightness by some exponential factor (gamma)
*/
darker(k: number): Color;
/**
* convert the color to a string.
*/
toString(): string;
}
export interface RGBColor extends Color{
/**
* the red color channel.
*/
r: number;
/**
* the green color channel.
*/
g: number;
/**
* the blue color channel.
*/
b: number;
/**
* convert from RGB to HSL.
*/
hsl(): HSLColor;
}
export interface HSLColor extends Color{
/**
* hue
*/
h: number;
/**
* saturation
*/
s: number;
/**
* lightness
*/
l: number;
/**
* convert from HSL to RGB.
*/
rgb(): RGBColor;
}
export interface LABColor extends Color{
/**
* lightness
*/
l: number;
/**
* a-dimension
*/
a: number;
/**
* b-dimension
*/
b: number;
/**
* convert from LAB to RGB.
*/
rgb(): RGBColor;
}
export interface HCLColor extends Color{
/**
* hue
*/
h: number;
/**
* chroma