mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-14 22:40:03 +08:00
3198 lines
101 KiB
TypeScript
3198 lines
101 KiB
TypeScript
// Type definitions for d3JS
|
|
// Project: http://d3js.org/
|
|
// Definitions by: TypeScript samples
|
|
// 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;
|
|
}
|
|
|
|
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>(arr: T[], map?: (v: T) => number): number;
|
|
/**
|
|
* Find the maximum value in an array
|
|
*
|
|
* @param arr Array to search
|
|
* @param map Accsessor function
|
|
*/
|
|
max<T>(arr: T[], map?: (v: T) => number): number;
|
|
/**
|
|
* Find the minimum and maximum value in an array
|
|
*
|
|
* @param arr Array to search
|
|
* @param map Accsessor function
|
|
*/
|
|
extent<T>(arr: T[], map?: (v: T) => number): number[];
|
|
/**
|
|
* 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 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 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 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 serch 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[]): any[];
|
|
/**
|
|
* 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<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 : any): 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;
|
|
};
|
|
|
|
property: {
|
|
(name: string): void;
|
|
(name: string, value: any): Selection;
|
|
(name: string, valueFunction: (data: any, index: number) => any): 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;
|
|
|
|
data: {
|
|
(values: (data: any, index?: number) => any[], key?: (data: any, index?: number) => string): UpdateSelection;
|
|
(values: any[], key?: (data: any, index?: number) => string): UpdateSelection;
|
|
};
|
|
|
|
datum: {
|
|
(values: (data: any, index: number) => any): UpdateSelection;
|
|
(values: any): UpdateSelection;
|
|
};
|
|
|
|
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;
|
|
};
|
|
|
|
transition(): Transition.Transition;
|
|
/**
|
|
* sort elements in the document based on data.
|
|
*
|
|
* params comparator the specified comparator function
|
|
*/
|
|
sort<T>(comparator?: (a: T, b: T) => number): Selection;
|
|
order: () => Selection;
|
|
node: () => Element;
|
|
}
|
|
|
|
export interface EnterSelection {
|
|
append: (name: string) => Selection;
|
|
insert: (name: string, before: string) => Selection;
|
|
select: (selector: string) => Selection;
|
|
empty: () => boolean;
|
|
node: () => Element;
|
|
}
|
|
|
|
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(): 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 {
|
|
(layers: any[], index?: number): any[];
|
|
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): D3.Svg.Arc;
|
|
(angle: () => number): D3.Svg.Arc;
|
|
(angle: (d : any) => number): D3.Svg.Arc;
|
|
(angle: (d : any, i: number) => number): D3.Svg.Arc;
|
|
};
|
|
endAngle: {
|
|
(): number;
|
|
(angle: number): D3.Svg.Arc;
|
|
(angle: () => number): D3.Svg.Arc;
|
|
(angle: (d : any) => number): D3.Svg.Arc;
|
|
(angle: (d : any, i: number) => number): D3.Svg.Arc;
|
|
};
|
|
}
|
|
|
|
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<GraphNode>;
|
|
}
|
|
|
|
export interface ChordLayout {
|
|
matrix: {
|
|
(): Array<Array<number>>;
|
|
(matrix: Array<Array<number>>): ChordLayout;
|
|
}
|
|
padding: {
|
|
(): number;
|
|
(padding: number): ChordLayout;
|
|
}
|
|
sortGroups: {
|
|
(): Array<number>;
|
|
(comparator: (a: number, b: number) => number): ChordLayout;
|
|
}
|
|
sortSubgroups: {
|
|
(): Array<number>;
|
|
(comparator: (a: number, b: number) => number): ChordLayout;
|
|
}
|
|
sortChords: {
|
|
(): Array<GraphLink>;
|
|
(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{
|
|
/**
|
|
* convert from RGB to HSL.
|
|
*/
|
|
hsl(): HSLColor;
|
|
}
|
|
|
|
export interface HSLColor extends Color{
|
|
/**
|
|
* convert from HSL to RGB.
|
|
*/
|
|
rgb(): RGBColor;
|
|
}
|
|
|
|
export interface LABColor extends Color{
|
|
/**
|
|
* convert from LAB to RGB.
|
|
*/
|
|
rgb(): RGBColor;
|
|
}
|
|
|
|
export interface HCLColor extends Color{
|
|
/**
|
|
* convert from HCL to RGB.
|
|
*/
|
|
rgb(): RGBColor;
|
|
}
|
|
}
|
|
|
|
// SVG
|
|
export module Svg {
|
|
export interface Svg {
|
|
/**
|
|
* Create a new symbol generator
|
|
*/
|
|
symbol(): Symbol;
|
|
/**
|
|
* Create a new axis generator
|
|
*/
|
|
axis(): Axis;
|
|
/**
|
|
* Create a new arc generator
|
|
*/
|
|
arc(): Arc;
|
|
/**
|
|
* Create a new line generator
|
|
*/
|
|
line: {
|
|
(): Line;
|
|
radial(): LineRadial;
|
|
}
|
|
/**
|
|
* Create a new area generator
|
|
*/
|
|
area: {
|
|
(): Area;
|
|
radial(): AreaRadial;
|
|
}
|
|
/**
|
|
* Create a new brush generator
|
|
*/
|
|
brush(): Brush;
|
|
/**
|
|
* Create a new chord generator
|
|
*/
|
|
chord(): Chord;
|
|
/**
|
|
* Create a new diagonal generator
|
|
*/
|
|
diagonal: {
|
|
(): Diagonal;
|
|
radial(): Diagonal;
|
|
}
|
|
/**
|
|
* The array of supported symbol types.
|
|
*/
|
|
symbolTypes: Array<string>;
|
|
}
|
|
|
|
export interface Symbol {
|
|
type: (string:string) => Symbol;
|
|
size: (number:number) => Symbol;
|
|
}
|
|
|
|
export interface Brush {
|
|
/**
|
|
* Draws or redraws this brush into the specified selection of elements
|
|
*/
|
|
(selection: Selection): void;
|
|
/**
|
|
* Gets or sets the x-scale associated with the brush
|
|
*/
|
|
x: {
|
|
/**
|
|
* Gets the x-scale associated with the brush
|
|
*/
|
|
(): D3.Scale.Scale;
|
|
/**
|
|
* Sets the x-scale associated with the brush
|
|
*
|
|
* @param accessor The new Scale
|
|
*/
|
|
(scale: D3.Scale.Scale): Brush;
|
|
};
|
|
/**
|
|
* Gets or sets the x-scale associated with the brush
|
|
*/
|
|
y: {
|
|
/**
|
|
* Gets the x-scale associated with the brush
|
|
*/
|
|
(): D3.Scale.Scale;
|
|
/**
|
|
* Sets the x-scale associated with the brush
|
|
*
|
|
* @param accessor The new Scale
|
|
*/
|
|
(scale: D3.Scale.Scale): Brush;
|
|
};
|
|
/**
|
|
* Gets or sets the current brush extent
|
|
*/
|
|
extent: {
|
|
/**
|
|
* Gets the current brush extent
|
|
*/
|
|
(): any[];
|
|
/**
|
|
* Sets the current brush extent
|
|
*/
|
|
(values: any[]): Brush;
|
|
};
|
|
/**
|
|
* Clears the extent, making the brush extent empty.
|
|
*/
|
|
clear(): Brush;
|
|
/**
|
|
* Returns true if and only if the brush extent is empty
|
|
*/
|
|
empty(): boolean;
|
|
/**
|
|
* Gets or sets the listener for the specified event type
|
|
*/
|
|
on: {
|
|
/**
|
|
* Gets the listener for the specified event type
|
|
*/
|
|
(type: string): (data: any, index: number) => any;
|
|
/**
|
|
* Sets the listener for the specified event type
|
|
*/
|
|
(type: string, listener: (data: any, index: number) => any, capture?: boolean): Brush;
|
|
};
|
|
}
|
|
|
|
export interface Axis {
|
|
(selection: Selection): void;
|
|
scale: {
|
|
(): any;
|
|
(scale: any): Axis;
|
|
};
|
|
|
|
orient: {
|
|
(): string;
|
|
(orientation: string): Axis;
|
|
};
|
|
|
|
ticks: {
|
|
(): any[];
|
|
(...arguments: any[]): Axis;
|
|
};
|
|
|
|
tickPadding: {
|
|
(): number;
|
|
(padding: number): Axis;
|
|
};
|
|
|
|
tickValues: {
|
|
(): any[];
|
|
(values: any[]): Axis;
|
|
};
|
|
|
|
tickSubdivide(count: number): Axis;
|
|
tickSize(major?: number, minor?: number, end?: number): Axis;
|
|
tickFormat(formatter: (value: any) => string): Axis;
|
|
}
|
|
|
|
export interface Arc {
|
|
/**
|
|
* Returns the path data string
|
|
*
|
|
* @param data Array of data elements
|
|
* @param index Optional index
|
|
*/
|
|
(data: any, index?: number): string;
|
|
innerRadius: {
|
|
(): (data: any, index?: number) => number;
|
|
(radius: number): Arc;
|
|
(radius: () => number): Arc;
|
|
(radius: (data: any) => number): Arc;
|
|
(radius: (data: any, index: number) => number): Arc;
|
|
};
|
|
outerRadius: {
|
|
(): (data: any, index?: number) => number;
|
|
(radius: number): Arc;
|
|
(radius: () => number): Arc;
|
|
(radius: (data: any) => number): Arc;
|
|
(radius: (data: any, index: number) => number): Arc;
|
|
};
|
|
startAngle: {
|
|
(): (data: any, index?: number) => number;
|
|
(angle: number): Arc;
|
|
(angle: () => number): Arc;
|
|
(angle: (data: any) => number): Arc;
|
|
(angle: (data: any, index: number) => number): Arc;
|
|
};
|
|
endAngle: {
|
|
(): (data: any, index?: number) => number;
|
|
(angle: number): Arc;
|
|
(angle: () => number): Arc;
|
|
(angle: (data: any) => number): Arc;
|
|
(angle: (data: any, index: number) => number): Arc;
|
|
};
|
|
centroid(data: any, index?: number): number[];
|
|
}
|
|
|
|
export interface Line {
|
|
/**
|
|
* Returns the path data string
|
|
*
|
|
* @param data Array of data elements
|
|
* @param index Optional index
|
|
*/
|
|
(data: any[], index?: number): string;
|
|
/**
|
|
* Get or set the x-coordinate accessor.
|
|
*/
|
|
x: {
|
|
/**
|
|
* Get the x-coordinate accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the x-coordinate accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): Line;
|
|
(accessor: (data: any, index: number) => number): Line;
|
|
/**
|
|
* Set the x-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): Line;
|
|
};
|
|
/**
|
|
* Get or set the y-coordinate accessor.
|
|
*/
|
|
y: {
|
|
/**
|
|
* Get the y-coordinate accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the y-coordinate accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): Line;
|
|
(accessor: (data: any, index: number) => number): Line;
|
|
/**
|
|
* Set the y-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): Line;
|
|
};
|
|
/**
|
|
* Get or set the interpolation mode.
|
|
*/
|
|
interpolate: {
|
|
/**
|
|
* Get the interpolation accessor.
|
|
*/
|
|
(): string;
|
|
/**
|
|
* Set the interpolation accessor.
|
|
*
|
|
* @param interpolate The interpolation mode
|
|
*/
|
|
(interpolate: string): Line;
|
|
};
|
|
/**
|
|
* Get or set the cardinal spline tension.
|
|
*/
|
|
tension: {
|
|
/**
|
|
* Get the cardinal spline accessor.
|
|
*/
|
|
(): number;
|
|
/**
|
|
* Set the cardinal spline accessor.
|
|
*
|
|
* @param tension The Cardinal spline interpolation tension
|
|
*/
|
|
(tension: number): Line;
|
|
};
|
|
/**
|
|
* Control whether the line is defined at a given point.
|
|
*/
|
|
defined: {
|
|
/**
|
|
* Get the accessor function that controls where the line is defined.
|
|
*/
|
|
(): (data: any, index ?: number) => boolean;
|
|
/**
|
|
* Set the accessor function that controls where the area is defined.
|
|
*
|
|
* @param defined The new accessor function
|
|
*/
|
|
(defined: (data: any) => boolean): Line;
|
|
};
|
|
}
|
|
|
|
export interface LineRadial {
|
|
/**
|
|
* Returns the path data string
|
|
*
|
|
* @param data Array of data elements
|
|
* @param index Optional index
|
|
*/
|
|
(data: any[], index?: number): string;
|
|
/**
|
|
* Get or set the x-coordinate accessor.
|
|
*/
|
|
x: {
|
|
/**
|
|
* Get the x-coordinate accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the x-coordinate accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): LineRadial;
|
|
(accessor: (data: any, index: number) => number): LineRadial;
|
|
|
|
/**
|
|
* Set the x-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): LineRadial;
|
|
};
|
|
/**
|
|
* Get or set the y-coordinate accessor.
|
|
*/
|
|
y: {
|
|
/**
|
|
* Get the y-coordinate accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the y-coordinate accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): LineRadial;
|
|
(accessor: (data: any, index: number) => number): LineRadial;
|
|
/**
|
|
* Set the y-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): LineRadial;
|
|
};
|
|
/**
|
|
* Get or set the interpolation mode.
|
|
*/
|
|
interpolate: {
|
|
/**
|
|
* Get the interpolation accessor.
|
|
*/
|
|
(): string;
|
|
/**
|
|
* Set the interpolation accessor.
|
|
*
|
|
* @param interpolate The interpolation mode
|
|
*/
|
|
(interpolate: string): LineRadial;
|
|
};
|
|
/**
|
|
* Get or set the cardinal spline tension.
|
|
*/
|
|
tension: {
|
|
/**
|
|
* Get the cardinal spline accessor.
|
|
*/
|
|
(): number;
|
|
/**
|
|
* Set the cardinal spline accessor.
|
|
*
|
|
* @param tension The Cardinal spline interpolation tension
|
|
*/
|
|
(tension: number): LineRadial;
|
|
};
|
|
/**
|
|
* Control whether the line is defined at a given point.
|
|
*/
|
|
defined: {
|
|
/**
|
|
* Get the accessor function that controls where the line is defined.
|
|
*/
|
|
(): (data: any) => any;
|
|
/**
|
|
* Set the accessor function that controls where the area is defined.
|
|
*
|
|
* @param defined The new accessor function
|
|
*/
|
|
(defined: (data: any) => any): LineRadial;
|
|
};
|
|
radius: {
|
|
(): (d: any, i?: number) => number;
|
|
(radius: number): LineRadial;
|
|
(radius: (d: any) => number): LineRadial;
|
|
(radius: (d: any, i: number) => number): LineRadial;
|
|
}
|
|
angle: {
|
|
(): (d: any, i?: any) => number;
|
|
(angle: number): LineRadial;
|
|
(angle: (d: any) => number): LineRadial;
|
|
(angle: (d: any, i: any) => number): LineRadial;
|
|
}
|
|
}
|
|
|
|
export interface Area {
|
|
/**
|
|
* Generate a piecewise linear area, as in an area chart.
|
|
*/
|
|
(data: any[], index?: number): string;
|
|
/**
|
|
* Get or set the x-coordinate accessor.
|
|
*/
|
|
x: {
|
|
/**
|
|
* Get the x-coordinate accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the x-coordinate accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): Area;
|
|
(accessor: (data: any, index: number) => number): Area;
|
|
/**
|
|
* Set the x-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): Area;
|
|
};
|
|
/**
|
|
* Get or set the x0-coordinate (baseline) accessor.
|
|
*/
|
|
x0: {
|
|
/**
|
|
* Get the x0-coordinate (baseline) accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the x0-coordinate (baseline) accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): Area;
|
|
(accessor: (data: any, index: number) => number): Area;
|
|
/**
|
|
* Set the x0-coordinate (baseline) to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): Area;
|
|
};
|
|
/**
|
|
* Get or set the x1-coordinate (topline) accessor.
|
|
*/
|
|
x1: {
|
|
/**
|
|
* Get the x1-coordinate (topline) accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the x1-coordinate (topline) accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): Area;
|
|
(accessor: (data: any, index: number) => number): Area;
|
|
/**
|
|
* Set the x1-coordinate (topline) to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): Area;
|
|
};
|
|
/**
|
|
* Get or set the y-coordinate accessor.
|
|
*/
|
|
y: {
|
|
/**
|
|
* Get the y-coordinate accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the y-coordinate accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): Area;
|
|
(accessor: (data: any, index: number) => number): Area;
|
|
/**
|
|
* Set the y-coordinate to a constant.
|
|
*
|
|
* @param cnst The constant value
|
|
*/
|
|
(cnst: number): Area;
|
|
};
|
|
/**
|
|
* Get or set the y0-coordinate (baseline) accessor.
|
|
*/
|
|
y0: {
|
|
/**
|
|
* Get the y0-coordinate (baseline) accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the y0-coordinate (baseline) accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): Area;
|
|
(accessor: (data: any, index: number) => number): Area;
|
|
/**
|
|
* Set the y0-coordinate (baseline) to a constant.
|
|
*
|
|
* @param cnst The constant value
|
|
*/
|
|
(cnst: number): Area;
|
|
};
|
|
/**
|
|
* Get or set the y1-coordinate (topline) accessor.
|
|
*/
|
|
y1: {
|
|
/**
|
|
* Get the y1-coordinate (topline) accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the y1-coordinate (topline) accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): Area;
|
|
(accessor: (data: any, index: number) => number): Area;
|
|
/**
|
|
* Set the y1-coordinate (baseline) to a constant.
|
|
*
|
|
* @param cnst The constant value
|
|
*/
|
|
(cnst: number): Area;
|
|
};
|
|
/**
|
|
* Get or set the interpolation mode.
|
|
*/
|
|
interpolate: {
|
|
/**
|
|
* Get the interpolation accessor.
|
|
*/
|
|
(): string;
|
|
/**
|
|
* Set the interpolation accessor.
|
|
*
|
|
* @param interpolate The interpolation mode
|
|
*/
|
|
(interpolate: string): Area;
|
|
};
|
|
/**
|
|
* Get or set the cardinal spline tension.
|
|
*/
|
|
tension: {
|
|
/**
|
|
* Get the cardinal spline accessor.
|
|
*/
|
|
(): number;
|
|
/**
|
|
* Set the cardinal spline accessor.
|
|
*
|
|
* @param tension The Cardinal spline interpolation tension
|
|
*/
|
|
(tension: number): Area;
|
|
};
|
|
/**
|
|
* Control whether the area is defined at a given point.
|
|
*/
|
|
defined: {
|
|
/**
|
|
* Get the accessor function that controls where the area is defined.
|
|
*/
|
|
(): (data: any) => any;
|
|
/**
|
|
* Set the accessor function that controls where the area is defined.
|
|
*
|
|
* @param defined The new accessor function
|
|
*/
|
|
(defined: (data: any) => any): Area;
|
|
};
|
|
}
|
|
|
|
export interface AreaRadial {
|
|
/**
|
|
* Generate a piecewise linear area, as in an area chart.
|
|
*/
|
|
(data: any[], index?: number): string;
|
|
/**
|
|
* Get or set the x-coordinate accessor.
|
|
*/
|
|
x: {
|
|
/**
|
|
* Get the x-coordinate accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the x-coordinate accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): AreaRadial;
|
|
(accessor: (data: any, index: number) => number): AreaRadial;
|
|
/**
|
|
* Set the x-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): AreaRadial;
|
|
};
|
|
/**
|
|
* Get or set the x0-coordinate (baseline) accessor.
|
|
*/
|
|
x0: {
|
|
/**
|
|
* Get the x0-coordinate (baseline) accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the x0-coordinate (baseline) accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): AreaRadial;
|
|
(accessor: (data: any, index: number) => number): AreaRadial;
|
|
/**
|
|
* Set the x0-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): AreaRadial;
|
|
};
|
|
/**
|
|
* Get or set the x1-coordinate (topline) accessor.
|
|
*/
|
|
x1: {
|
|
/**
|
|
* Get the x1-coordinate (topline) accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the x1-coordinate (topline) accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): AreaRadial;
|
|
(accessor: (data: any, index: number) => number): AreaRadial;
|
|
/**
|
|
* Set the x1-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): AreaRadial;
|
|
};
|
|
/**
|
|
* Get or set the y-coordinate accessor.
|
|
*/
|
|
y: {
|
|
/**
|
|
* Get the y-coordinate accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the y-coordinate accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): AreaRadial;
|
|
(accessor: (data: any, index: number) => number): AreaRadial;
|
|
/**
|
|
* Set the y-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): AreaRadial;
|
|
};
|
|
/**
|
|
* Get or set the y0-coordinate (baseline) accessor.
|
|
*/
|
|
y0: {
|
|
/**
|
|
* Get the y0-coordinate (baseline) accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the y0-coordinate (baseline) accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): AreaRadial;
|
|
(accessor: (data: any, index: number) => number): AreaRadial;
|
|
/**
|
|
* Set the y0-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): AreaRadial;
|
|
};
|
|
/**
|
|
* Get or set the y1-coordinate (topline) accessor.
|
|
*/
|
|
y1: {
|
|
/**
|
|
* Get the y1-coordinate (topline) accessor.
|
|
*/
|
|
(): (data: any, index ?: number) => number;
|
|
/**
|
|
* Set the y1-coordinate (topline) accessor.
|
|
*
|
|
* @param accessor The new accessor function
|
|
*/
|
|
(accessor: (data: any) => number): AreaRadial;
|
|
(accessor: (data: any, index: number) => number): AreaRadial;
|
|
/**
|
|
* Set the y1-coordinate to a constant.
|
|
*
|
|
* @param cnst The new constant value.
|
|
*/
|
|
(cnst: number): AreaRadial;
|
|
};
|
|
/**
|
|
* Get or set the interpolation mode.
|
|
*/
|
|
interpolate: {
|
|
/**
|
|
* Get the interpolation accessor.
|
|
*/
|
|
(): string;
|
|
/**
|
|
* Set the interpolation accessor.
|
|
*
|
|
* @param interpolate The interpolation mode
|
|
*/
|
|
(interpolate: string): AreaRadial;
|
|
};
|
|
/**
|
|
* Get or set the cardinal spline tension.
|
|
*/
|
|
tension: {
|
|
/**
|
|
* Get the cardinal spline accessor.
|
|
*/
|
|
(): number;
|
|
/**
|
|
* Set the cardinal spline accessor.
|
|
*
|
|
* @param tension The Cardinal spline interpolation tension
|
|
*/
|
|
(tension: number): AreaRadial;
|
|
};
|
|
/**
|
|
* Control whether the area is defined at a given point.
|
|
*/
|
|
defined: {
|
|
/**
|
|
* Get the accessor function that controls where the area is defined.
|
|
*/
|
|
(): (data: any) => any;
|
|
/**
|
|
* Set the accessor function that controls where the area is defined.
|
|
*
|
|
* @param defined The new accessor function
|
|
*/
|
|
(defined: (data: any) => any): AreaRadial;
|
|
};
|
|
radius: {
|
|
(): number;
|
|
(radius: number): AreaRadial;
|
|
(radius: () => number): AreaRadial;
|
|
(radius: (data: any) => number): AreaRadial;
|
|
(radius: (data: any, index: number) => number): AreaRadial;
|
|
};
|
|
innerRadius: {
|
|
(): number;
|
|
(radius: number): AreaRadial;
|
|
(radius: () => number): AreaRadial;
|
|
(radius: (data: any) => number): AreaRadial;
|
|
(radius: (data: any, index: number) => number): AreaRadial;
|
|
};
|
|
outerRadius: {
|
|
(): number;
|
|
(radius: number): AreaRadial;
|
|
(radius: () => number): AreaRadial;
|
|
(radius: (data: any) => number): AreaRadial;
|
|
(radius: (data: any, index: number) => number): AreaRadial;
|
|
};
|
|
angle: {
|
|
(): number;
|
|
(angle: number): AreaRadial;
|
|
(angle: () => number): AreaRadial;
|
|
(angle: (data: any) => number): AreaRadial;
|
|
(angle: (data: any, index: number) => number): AreaRadial;
|
|
};
|
|
startAngle: {
|
|
(): number;
|
|
(angle: number): AreaRadial;
|
|
(angle: () => number): AreaRadial;
|
|
(angle: (data: any) => number): AreaRadial;
|
|
(angle: (data: any, index: number) => number): AreaRadial;
|
|
};
|
|
endAngle: {
|
|
(): number;
|
|
(angle: number): AreaRadial;
|
|
(angle: () => number): AreaRadial;
|
|
(angle: (data: any) => number): AreaRadial;
|
|
(angle: (data: any, index: number) => number): AreaRadial;
|
|
};
|
|
}
|
|
|
|
export interface Chord {
|
|
(datum: any, index?: number): string;
|
|
radius: {
|
|
(): number;
|
|
(radius: number): Chord;
|
|
(radius: () => number): Chord;
|
|
};
|
|
startAngle: {
|
|
(): number;
|
|
(angle: number): Chord;
|
|
(angle: () => number): Chord;
|
|
};
|
|
endAngle: {
|
|
(): number;
|
|
(angle: number): Chord;
|
|
(angle: () => number): Chord;
|
|
};
|
|
source: {
|
|
(): any;
|
|
(angle: any): Chord;
|
|
(angle: (d: any, i?: number) => any): Chord;
|
|
};
|
|
target: {
|
|
(): any;
|
|
(angle: any): Chord;
|
|
(angle: (d: any, i?: number) => any): Chord;
|
|
};
|
|
}
|
|
|
|
export interface Diagonal {
|
|
(datum: any, index?: number): string;
|
|
projection: {
|
|
(): (datum: any, index?: number) => Array<number>;
|
|
(proj: (datum: any) => Array<number>): Diagonal;
|
|
(proj: (datum: any, index: number) => Array<number>): Diagonal;
|
|
};
|
|
source: {
|
|
(): (datum: any, index?: number) => any;
|
|
(src: (datum: any) => any): Diagonal;
|
|
(src: (datum: any, index: number) => any): Diagonal;
|
|
(src: any): Diagonal;
|
|
};
|
|
target: {
|
|
(): (datum: any, index?: number) => any;
|
|
(target: (d: any) => any): Diagonal;
|
|
(target: (d: any, i: number) => any): Diagonal;
|
|
(target: any): Diagonal;
|
|
};
|
|
}
|
|
}
|
|
|
|
// Scales
|
|
export module Scale {
|
|
export interface ScaleBase {
|
|
/**
|
|
* Construct a linear quantitative scale.
|
|
*/
|
|
linear(): LinearScale;
|
|
/*
|
|
* Construct an ordinal scale.
|
|
*/
|
|
ordinal(): OrdinalScale;
|
|
/**
|
|
* Construct a linear quantitative scale with a discrete output range.
|
|
*/
|
|
quantize(): QuantizeScale;
|
|
/*
|
|
* Construct an ordinal scale with ten categorical colors.
|
|
*/
|
|
category10(): OrdinalScale;
|
|
/*
|
|
* Construct an ordinal scale with twenty categorical colors
|
|
*/
|
|
category20(): OrdinalScale;
|
|
/*
|
|
* Construct an ordinal scale with twenty categorical colors
|
|
*/
|
|
category20b(): OrdinalScale;
|
|
/*
|
|
* Construct an ordinal scale with twenty categorical colors
|
|
*/
|
|
category20c(): OrdinalScale;
|
|
/*
|
|
* Construct a linear identity scale.
|
|
*/
|
|
identity(): IdentityScale;
|
|
/*
|
|
* Construct a quantitative scale with an logarithmic transform.
|
|
*/
|
|
log(): LogScale;
|
|
/*
|
|
* Construct a quantitative scale with an exponential transform.
|
|
*/
|
|
pow(): PowScale;
|
|
/*
|
|
* Construct a quantitative scale mapping to quantiles.
|
|
*/
|
|
quantile(): QuantileScale;
|
|
/*
|
|
* Construct a quantitative scale with a square root transform.
|
|
*/
|
|
sqrt(): SqrtScale;
|
|
/*
|
|
* Construct a threshold scale with a discrete output range.
|
|
*/
|
|
theshold(): ThresholdScale;
|
|
}
|
|
|
|
export interface Scale {
|
|
(value: any): any;
|
|
domain: {
|
|
(values: any[]): Scale;
|
|
(): any[];
|
|
};
|
|
range: {
|
|
(values: any[]): Scale;
|
|
(): any[];
|
|
};
|
|
copy(): Scale;
|
|
}
|
|
|
|
export interface QuantitiveScale 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 or set the scale's input domain.
|
|
*/
|
|
domain: {
|
|
/**
|
|
* Set the scale's input domain.
|
|
*
|
|
* @param value The input domain
|
|
*/
|
|
(values: any[]): QuantitiveScale;
|
|
/**
|
|
* Get the scale's input domain.
|
|
*/
|
|
(): any[];
|
|
};
|
|
/**
|
|
* get or set the scale's output range.
|
|
*/
|
|
range: {
|
|
/**
|
|
* Set the scale's output range.
|
|
*
|
|
* @param value The output range.
|
|
*/
|
|
(values: any[]): QuantitiveScale;
|
|
/**
|
|
* Get the scale's output range.
|
|
*/
|
|
(): any[];
|
|
};
|
|
/**
|
|
* Set the scale's output range, and enable rounding.
|
|
*
|
|
* @param value The output range.
|
|
*/
|
|
rangeRound: (values: any[]) => QuantitiveScale;
|
|
/**
|
|
* get or set the scale's output interpolator.
|
|
*/
|
|
interpolate: {
|
|
(): D3.Transition.Interpolate;
|
|
(factory: D3.Transition.Interpolate): QuantitiveScale;
|
|
};
|
|
/**
|
|
* enable or disable clamping of the output range.
|
|
*
|
|
* @param clamp Enable or disable
|
|
*/
|
|
clamp(clamp: boolean): QuantitiveScale;
|
|
/**
|
|
* extend the scale domain to nice round numbers.
|
|
*/
|
|
nice(): QuantitiveScale;
|
|
/**
|
|
* 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;
|
|
/**
|
|
* create a new scale from an existing scale..
|
|
*/
|
|
copy(): QuantitiveScale;
|
|
}
|
|
|
|
export interface LinearScale extends QuantitiveScale {
|
|
/**
|
|
* Get the range value corresponding to a given domain value.
|
|
*
|
|
* @param value Domain Value
|
|
*/
|
|
(value: number): number;
|
|
}
|
|
|
|
export interface IdentityScale extends QuantitiveScale {
|
|
/**
|
|
* Get the range value corresponding to a given domain value.
|
|
*
|
|
* @param value Domain Value
|
|
*/
|
|
(value: number): number;
|
|
}
|
|
|
|
export interface SqrtScale extends QuantitiveScale {
|
|
/**
|
|
* Get the range value corresponding to a given domain value.
|
|
*
|
|
* @param value Domain Value
|
|
*/
|
|
(value: number): number;
|
|
}
|
|
|
|
export interface PowScale extends QuantitiveScale {
|
|
/**
|
|
* Get the range value corresponding to a given domain value.
|
|
*
|
|
* @param value Domain Value
|
|
*/
|
|
(value: number): number;
|
|
}
|
|
|
|
export interface LogScale extends QuantitiveScale {
|
|
/**
|
|
* Get the range value corresponding to a given domain value.
|
|
*
|
|
* @param value Domain Value
|
|
*/
|
|
(value: number): number;
|
|
}
|
|
|
|
export interface OrdinalScale extends Scale {
|
|
/**
|
|
* Get the range value corresponding to a given domain value.
|
|
*
|
|
* @param value Domain Value
|
|
*/
|
|
(value: any): any;
|
|
/**
|
|
* Get or set the scale's input domain.
|
|
*/
|
|
domain: {
|
|
/**
|
|
* Set the scale's input domain.
|
|
*
|
|
* @param value The input domain
|
|
*/
|
|
(values: any[]): OrdinalScale;
|
|
/**
|
|
* Get the scale's input domain.
|
|
*/
|
|
(): any[];
|
|
};
|
|
/**
|
|
* get or set the scale's output range.
|
|
*/
|
|
range: {
|
|
/**
|
|
* Set the scale's output range.
|
|
*
|
|
* @param value The output range.
|
|
*/
|
|
(values: any[]): OrdinalScale;
|
|
/**
|
|
* Get the scale's output range.
|
|
*/
|
|
(): any[];
|
|
};
|
|
rangePoints(interval: any[], padding?: number): OrdinalScale;
|
|
rangeBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale;
|
|
rangeRoundBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale;
|
|
rangeBand(): number;
|
|
rangeExtent(): any[];
|
|
/**
|
|
* create a new scale from an existing scale..
|
|
*/
|
|
copy(): OrdinalScale;
|
|
}
|
|
|
|
export interface QuantizeScale extends Scale {
|
|
(value: any): any;
|
|
domain: {
|
|
(values: number[]): QuantizeScale;
|
|
(): any[];
|
|
};
|
|
range: {
|
|
(values: any[]): QuantizeScale;
|
|
(): any[];
|
|
};
|
|
copy(): QuantizeScale;
|
|
}
|
|
|
|
export interface ThresholdScale extends Scale {
|
|
(value: any): any;
|
|
domain: {
|
|
(values: number[]): ThresholdScale;
|
|
(): any[];
|
|
};
|
|
range: {
|
|
(values: any[]): ThresholdScale;
|
|
(): any[];
|
|
};
|
|
copy(): ThresholdScale;
|
|
}
|
|
|
|
export interface QuantileScale extends Scale {
|
|
(value: any): any;
|
|
domain: {
|
|
(values: number[]): QuantileScale;
|
|
(): any[];
|
|
};
|
|
range: {
|
|
(values: any[]): QuantileScale;
|
|
(): any[];
|
|
};
|
|
quantiles(): any[];
|
|
copy(): QuantileScale;
|
|
}
|
|
|
|
export interface TimeScale extends Scale {
|
|
(value: Date): number;
|
|
invert(value: number): Date;
|
|
domain: {
|
|
(values: any[]): TimeScale;
|
|
(): any[];
|
|
};
|
|
range: {
|
|
(values: any[]): TimeScale;
|
|
(): any[];
|
|
};
|
|
rangeRound: (values: any[]) => TimeScale;
|
|
interpolate: {
|
|
(): D3.Transition.Interpolate;
|
|
(factory: D3.Transition.InterpolateFactory): TimeScale;
|
|
};
|
|
clamp(clamp: boolean): TimeScale;
|
|
ticks: {
|
|
(count: number): any[];
|
|
(range: Range, count: number): any[];
|
|
};
|
|
tickFormat(count: number): (n: number) => string;
|
|
copy(): TimeScale;
|
|
}
|
|
}
|
|
|
|
// Behaviour
|
|
export module Behavior {
|
|
export interface Behavior{
|
|
/**
|
|
* Constructs a new drag behaviour
|
|
*/
|
|
drag(): Drag;
|
|
/**
|
|
* Constructs a new zoom behaviour
|
|
*/
|
|
zoom(): Zoom;
|
|
}
|
|
|
|
export interface Zoom {
|
|
/**
|
|
* Execute zoom method
|
|
*/
|
|
(): any;
|
|
|
|
/**
|
|
* 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) => Zoom;
|
|
|
|
/**
|
|
* Gets or set the current zoom scale
|
|
*/
|
|
scale: {
|
|
/**
|
|
* Get the current current zoom scale
|
|
*/
|
|
(): number;
|
|
/**
|
|
* Set the current current zoom scale
|
|
*
|
|
* @param origin Zoom scale
|
|
*/
|
|
(scale: number): Zoom;
|
|
};
|
|
|
|
/**
|
|
* Gets or set the current zoom translation vector
|
|
*/
|
|
translate: {
|
|
/**
|
|
* Get the current zoom translation vector
|
|
*/
|
|
(): number[];
|
|
/**
|
|
* Set the current zoom translation vector
|
|
*
|
|
* @param translate Tranlation vector
|
|
*/
|
|
(translate: number[]): Zoom;
|
|
};
|
|
|
|
/**
|
|
* Gets or set the allowed scale range
|
|
*/
|
|
scaleExtent: {
|
|
/**
|
|
* Get the current allowed zoom range
|
|
*/
|
|
(): number[];
|
|
/**
|
|
* Set the allowable zoom range
|
|
*
|
|
* @param extent Allowed zoom range
|
|
*/
|
|
(extent: number[]): Zoom;
|
|
};
|
|
|
|
/**
|
|
* Gets or set the X-Scale that should be adjusted when zooming
|
|
*/
|
|
x: {
|
|
/**
|
|
* Get the X-Scale
|
|
*/
|
|
(): D3.Scale.Scale;
|
|
/**
|
|
* Set the X-Scale to be adjusted
|
|
*
|
|
* @param x The X Scale
|
|
*/
|
|
(x: D3.Scale.Scale): Zoom;
|
|
|
|
};
|
|
|
|
/**
|
|
* Gets or set the Y-Scale that should be adjusted when zooming
|
|
*/
|
|
y: {
|
|
/**
|
|
* Get the Y-Scale
|
|
*/
|
|
(): D3.Scale.Scale;
|
|
/**
|
|
* Set the Y-Scale to be adjusted
|
|
*
|
|
* @param y The Y Scale
|
|
*/
|
|
(y: D3.Scale.Scale): Zoom;
|
|
};
|
|
}
|
|
|
|
export interface Drag {
|
|
/**
|
|
* Execute drag method
|
|
*/
|
|
(): any;
|
|
|
|
/**
|
|
* 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) => Drag;
|
|
|
|
/**
|
|
* Gets or set the current origin accessor function
|
|
*/
|
|
origin: {
|
|
/**
|
|
* Get the current origin accessor function
|
|
*/
|
|
(): any;
|
|
/**
|
|
* Set the origin accessor function
|
|
*
|
|
* @param origin Accessor function
|
|
*/
|
|
(origin?: any): Drag;
|
|
};
|
|
}
|
|
}
|
|
|
|
// Geography
|
|
export module Geo {
|
|
export interface Geo {
|
|
/**
|
|
* create a new geographic path generator
|
|
*/
|
|
path(): Path;
|
|
/**
|
|
* create a circle generator.
|
|
*/
|
|
circle(): Circle;
|
|
/**
|
|
* compute the spherical area of a given feature.
|
|
*/
|
|
area(feature: any): number;
|
|
/**
|
|
* compute the latitude-longitude bounding box for a given feature.
|
|
*/
|
|
bounds(feature: any): Array<Array<number>>;
|
|
/**
|
|
* compute the spherical centroid of a given feature.
|
|
*/
|
|
centroid(feature: any): Array<number>;
|
|
/**
|
|
* compute the great-arc distance between two points.
|
|
*/
|
|
distance(a: Array<number>, b: Array<number>): number;
|
|
/**
|
|
* interpolate between two points along a great arc.
|
|
*/
|
|
interpolate(a: Array<number>, b: Array<number>): (t: number) => Array<number>;
|
|
/**
|
|
* compute the length of a line string or the circumference of a polygon.
|
|
*/
|
|
length(feature: any): number;
|
|
/**
|
|
* create a standard projection from a raw projection.
|
|
*/
|
|
projection(raw: (lambda: any, phi: any) => any): Projection;
|
|
/**
|
|
* create a standard projection from a mutable raw projection.
|
|
*/
|
|
projectionMutator(rawFactory: (lambda: number, phi: number) => Array<number>): Projection;
|
|
/**
|
|
* the Albers equal-area conic projection.
|
|
*/
|
|
albers(): Projection;
|
|
/**
|
|
* a composite Albers projection for the United States.
|
|
*/
|
|
albersUsa(): Projection;
|
|
/**
|
|
* the azimuthal equal-area projection.
|
|
*/
|
|
azimuthalEqualArea: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* the azimuthal equidistant projection.
|
|
*/
|
|
azimuthalEquidistant: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* the conic conformal projection.
|
|
*/
|
|
conicConformal: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* the conic equidistant projection.
|
|
*/
|
|
conicEquidistant: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* the conic equal-area (a.k.a. Albers) projection.
|
|
*/
|
|
conicEqualArea: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* the equirectangular (plate carreé) projection.
|
|
*/
|
|
equirectangular: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* the gnomonic projection.
|
|
*/
|
|
gnomonic: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* the spherical Mercator projection.
|
|
*/
|
|
mercator: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* the azimuthal orthographic projection.
|
|
*/
|
|
othographic: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* the azimuthal stereographic projection.
|
|
*/
|
|
stereographic: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* the transverse Mercator projection.
|
|
*/
|
|
transverseMercator: {
|
|
(): Projection;
|
|
raw(): Projection;
|
|
}
|
|
/**
|
|
* convert a GeoJSON object to a geometry stream.
|
|
*/
|
|
stream(object: GeoJSON, listener: any): Stream;
|
|
/**
|
|
*
|
|
*/
|
|
graticule(): Graticule;
|
|
/**
|
|
*
|
|
*/
|
|
greatArc: GreatArc;
|
|
/**
|
|
*
|
|
*/
|
|
rotation(rotation: Array<number>): Rotation;
|
|
}
|
|
|
|
export interface Path {
|
|
/**
|
|
* Returns the path data string for the given feature
|
|
*/
|
|
(feature: any, index?: any): string;
|
|
/**
|
|
* get or set the geographic projection.
|
|
*/
|
|
projection: {
|
|
/**
|
|
* get the geographic projection.
|
|
*/
|
|
(): Projection;
|
|
/**
|
|
* set the geographic projection.
|
|
*/
|
|
(projection: Projection): Path;
|
|
}
|
|
/**
|
|
* get or set the render context.
|
|
*/
|
|
context: {
|
|
/**
|
|
* return an SVG path string invoked on the given feature.
|
|
*/
|
|
(): string;
|
|
/**
|
|
* sets the render context and returns the path generator
|
|
*/
|
|
(context: Context): Path;
|
|
}
|
|
/**
|
|
* Computes the projected area
|
|
*/
|
|
area(feature: any): any;
|
|
/**
|
|
* Computes the projected centroid
|
|
*/
|
|
centroid(feature: any): any;
|
|
/**
|
|
* Computes the projected bounding box
|
|
*/
|
|
bounds(feature: any): any;
|
|
/**
|
|
* get or set the radius to display point features.
|
|
*/
|
|
pointRadius: {
|
|
/**
|
|
* returns the current radius
|
|
*/
|
|
(): number;
|
|
/**
|
|
* sets the radius used to display Point and MultiPoint features to the specified number
|
|
*/
|
|
(radius: number): Path;
|
|
/**
|
|
* sets the radius used to display Point and MultiPoint features to the specified number
|
|
*/
|
|
(radius: (feature: any, index: number) => number): Path;
|
|
}
|
|
}
|
|
|
|
export interface Context {
|
|
beginPath(): any;
|
|
moveTo(x: number, y: number): any;
|
|
lineTo(x: number, y: number): any;
|
|
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number): any;
|
|
closePath(): any;
|
|
}
|
|
|
|
export interface Circle {
|
|
(...args: Array<any>): GeoJSON;
|
|
origin: {
|
|
(): Array<number>;
|
|
(origin: Array<number>): Circle;
|
|
(origin: (...args: Array<any>) => Array<number>): Circle;
|
|
}
|
|
angle: {
|
|
(): number;
|
|
(angle: number): Circle;
|
|
}
|
|
precision: {
|
|
(): number;
|
|
(precision: number): Circle;
|
|
}
|
|
}
|
|
|
|
export interface Graticule{
|
|
(): GeoJSON;
|
|
lines(): GeoJSON;
|
|
outline(): GeoJSON;
|
|
extent: {
|
|
(): Array<Array<number>>;
|
|
(extent: Array<Array<number>>): Graticule;
|
|
}
|
|
minorExtent: {
|
|
(): Array<Array<number>>;
|
|
(extent: Array<Array<number>>): Graticule;
|
|
}
|
|
majorExtent: {
|
|
(): Array<Array<number>>;
|
|
(extent: Array<Array<number>>): Graticule;
|
|
}
|
|
step: {
|
|
(): Array<Array<number>>;
|
|
(extent: Array<Array<number>>): Graticule;
|
|
}
|
|
minorStep: {
|
|
(): Array<Array<number>>;
|
|
(extent: Array<Array<number>>): Graticule;
|
|
}
|
|
majorStep: {
|
|
(): Array<Array<number>>;
|
|
(extent: Array<Array<number>>): Graticule;
|
|
}
|
|
precision: {
|
|
(): number;
|
|
(precision: number): Graticule;
|
|
}
|
|
}
|
|
|
|
export interface GreatArc {
|
|
(): GeoJSON;
|
|
distance(): number;
|
|
source: {
|
|
(): any;
|
|
(source: any): GreatArc;
|
|
}
|
|
target: {
|
|
(): any;
|
|
(target: any): GreatArc;
|
|
}
|
|
precision: {
|
|
(): number;
|
|
(precision: number): GreatArc;
|
|
}
|
|
}
|
|
|
|
export interface GeoJSON {
|
|
coordinates: Array<Array<number>>;
|
|
type: string;
|
|
}
|
|
|
|
export interface Projection {
|
|
(coordinates: Array<number>): Array<number>;
|
|
invert(point: Array<number>): Array<number>;
|
|
rotate: {
|
|
(): Array<number>;
|
|
(rotation: Array<number>): Projection;
|
|
};
|
|
center: {
|
|
(): Array<number>;
|
|
(location: Array<number>): Projection;
|
|
};
|
|
translate: {
|
|
(): Array<number>;
|
|
(point: Array<number>): Projection;
|
|
};
|
|
scale: {
|
|
(): number;
|
|
(scale: number): Projection;
|
|
};
|
|
clipAngle: {
|
|
(): number;
|
|
(angle: number): Projection;
|
|
};
|
|
clipExtent: {
|
|
(): Array<Array<number>>;
|
|
(extent: Array<Array<number>>): Projection;
|
|
};
|
|
precision: {
|
|
(): number;
|
|
(precision: number): Projection;
|
|
};
|
|
stream(listener?: any): Stream;
|
|
}
|
|
|
|
export interface Stream {
|
|
point(x: number, y: number, z?: number): void;
|
|
lineStart(): void;
|
|
lineEnd(): void;
|
|
polygonStart(): void;
|
|
polygonEnd(): void;
|
|
sphere(): void;
|
|
}
|
|
|
|
export interface Rotation extends Array<any> {
|
|
(location: Array<number>): Rotation;
|
|
invert(location: Array<number>): Rotation;
|
|
}
|
|
}
|
|
|
|
// Geometry
|
|
export module Geom {
|
|
export interface Geom {
|
|
/**
|
|
* compute the Voronoi diagram for the specified points.
|
|
*/
|
|
voronoi: Voronoi
|
|
/**
|
|
* compute the Delaunay triangulation for the specified points.
|
|
*/
|
|
delaunay(vertices?: Array<Vertice>): Array<Polygon>;
|
|
/**
|
|
* constructs a quadtree for an array of points.
|
|
*/
|
|
quadtree: Quadtree;
|
|
/**
|
|
* constructs a polygon
|
|
*/
|
|
polygon: Polygon;
|
|
/**
|
|
* creates a new hull layout with the default settings.
|
|
*/
|
|
hull: Hull;
|
|
}
|
|
|
|
export interface Vertice extends Array<number> {
|
|
/**
|
|
* Returns the angle of the vertice
|
|
*/
|
|
angle?: number;
|
|
}
|
|
|
|
export interface Polygon extends Array<Vertice> {
|
|
/**
|
|
* Returns the input array of vertices with additional methods attached
|
|
*/
|
|
(vertices: Array<Vertice>): Polygon;
|
|
/**
|
|
* Returns the signed area of this polygon
|
|
*/
|
|
area(): number;
|
|
/**
|
|
* Returns a two-element array representing the centroid of this polygon.
|
|
*/
|
|
centroid(): Array<number>;
|
|
/**
|
|
* Clips the subject polygon against this polygon
|
|
*/
|
|
clip(subject: Polygon): Polygon;
|
|
}
|
|
|
|
export interface Quadtree {
|
|
/**
|
|
* Constructs a new quadtree for the specified array of points.
|
|
*/
|
|
(): Quadtree;
|
|
/**
|
|
* Constructs a new quadtree for the specified array of points.
|
|
*/
|
|
(points: Array<Point>, x1: number, y1: number, x2: number, y2: number): Quadtree;
|
|
/**
|
|
* Constructs a new quadtree for the specified array of points.
|
|
*/
|
|
(points: Array<Point>, 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;
|
|
|
|
}
|
|
y: {
|
|
(): (d: any) => any;
|
|
(accesor: (d: any) => any): Quadtree;
|
|
|
|
}
|
|
size(size: Array<number>): Quadtree;
|
|
}
|
|
|
|
export interface Point {
|
|
x: number;
|
|
y: number;
|
|
}
|
|
|
|
export interface Voronoi {
|
|
(vertices?: Array<Vertice>): Array<Polygon>;
|
|
x: {
|
|
(): (d: any) => any;
|
|
(accesor: (d: any) => any): any;
|
|
}
|
|
y: {
|
|
(): (d: any) => any;
|
|
(accesor: (d: any) => any): any;
|
|
}
|
|
}
|
|
|
|
export interface Hull {
|
|
(vertices: Array<Vertice>): Hull;
|
|
x: {
|
|
(): (d: any) => any;
|
|
(accesor: (d: any) => any): any;
|
|
}
|
|
y: {
|
|
(): (d: any) => any;
|
|
(accesor: (d: any) => any): any;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
declare var d3: D3.Base;
|