DefinitelyTyped/d3/d3.d.ts
2015-05-03 01:10:35 -04:00

3493 lines
112 KiB
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: {
/**
* Returns the empty selection
*/
(): _Selection<any>;
/**
* Selects the first element that matches the specified selector string
*
* @param selector Selection String to match
*/
(selector: string): _Selection<any>;
/**
* Selects the specified node
*
* @param element Node element to select
*/
(element: EventTarget): _Selection<any>;
};
/**
* 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<any>;
/**
* Selects the specified array of elements
*
* @param elements Array of node elements to select
*/
(elements: EventTarget[]): _Selection<any>;
};
}
export interface D3Event extends Event{
dx: number;
dy: number;
clientX: number;
clientY: number;
translate: number[];
scale: number;
sourceEvent: D3Event;
x: number;
y: number;
keyCode: number;
altKey?: boolean;
ctrlKey?: boolean;
metaKey?: boolean;
shiftKey?: boolean;
type: string;
}
export interface Base extends Selectors {
/**
* Create a behavior
*/
behavior: Behavior.Behavior;
/**
* Access the current user event for interaction
*/
event: D3Event;
/**
* 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, i?: number) => 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, i?: number) => 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[];
/**
* Creates an array containing tuples of adjacent pairs
*
* @param arr An array containing entries to pair
* @returns any[][] An array of 2-element tuples for each pair
*/
pairs(arr: 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 an arbitrary char-separated values file parser, like semicolon or what ever
*/
dsv: 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: 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<any>;
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): number[];
/**
* gets the touch positions relative to a specified container.
*/
touches(container: any): 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: {
(): Map<any>;
<T>(object: {[key: string]: T; }): Map<T>;
<T>(map: Map<T>): Map<T>;
<T>(array: T[]): Map<T>;
<T>(array: T[], keyFn: (object: T, index?: number) => string): Map<T>;
};
set: {
(): Set<any>;
<T>(array: T[]): Set<T>;
};
dispatch(...types: string[]): Dispatch;
rebind(target: any, source: any, ...names: 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;
/**
* Arbitrary Delimiters:
* Constructs a new parser for the given delimiter and mime type. For example, to parse values separated by "|", the vertical bar character, use:
* var dsv = d3.dsv("|", "text/plain");
*
* returns the new parser
*
* @param separator seperator character
* @param contentType
*/
(separator: string, contentType:string): (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
* @param accessor to modify properties of each row
*/
parse(string: string, accessor?: (row: any, index?: number) => any): 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<T> extends Selectors, Array<any> {
attr: {
(name: string): string;
(name: string, value: any): _Selection<T>;
(name: string, valueFunction: (data: T, index: number) => any): _Selection<T>;
(attrValueMap: Object): _Selection<T>;
};
classed: {
(name: string): boolean;
(name: string, value: any): _Selection<T>;
(name: string, valueFunction: (data: T, index: number) => any): _Selection<T>;
(classValueMap: Object): _Selection<T>;
};
style: {
(name: string): string;
(name: string, value: any, priority?: string): _Selection<T>;
(name: string, valueFunction: (data: T, index: number) => any, priority?: string): _Selection<T>;
(styleValueMap: Object): _Selection<T>;
};
property: {
(name: string): void;
(name: string, value: any): _Selection<T>;
(name: string, valueFunction: (data: T, index: number) => any): _Selection<T>;
(propertyValueMap: Object): _Selection<T>;
};
text: {
(): string;
(value: any): _Selection<T>;
(valueFunction: (data: T, index: number) => any): _Selection<T>;
};
html: {
(): string;
(value: any): _Selection<T>;
(valueFunction: (data: T, index: number) => any): _Selection<T>;
};
append: (name: string) => _Selection<T>;
insert: (name: string, before: string) => _Selection<T>;
remove: () => _Selection<T>;
empty: () => boolean;
data: {
<U>(values: (data: T, index?: number) => U[], key?: (data: U, index?: number) => any): _UpdateSelection<U>;
<U>(values: U[], key?: (data: U, index?: number) => any): _UpdateSelection<U>;
(): T[];
};
datum: {
/**
* Sets the element's bound data to the return value of the specified function evaluated
* for each selected element.
* Unlike the D3.Selection.data method, this method does not compute a join (and thus
* does not compute enter and exit selections).
* @param values The function to be evaluated for each selected element, being passed the
* previous datum d and the current index i, with the this context as the current DOM
* element. The function is then used to set each element's data. A null value will
* delete the bound data. This operator has no effect on the index.
*/
<U>(values: (data: U, index: number) => any): _UpdateSelection<U>;
/**
* Sets the element's bound data to the specified value on all selected elements.
* Unlike the D3.Selection.data method, this method does not compute a join (and thus
* does not compute enter and exit selections).
* @param values The same data to be given to all elements.
*/
<U>(values: U): _UpdateSelection<U>;
/**
* Returns the bound datum for the first non-null element in the selection.
* This is generally useful only if you know the selection contains exactly one element.
*/
(): T;
};
filter: {
(filter: (data: T, index: number) => boolean, thisArg?: any): _UpdateSelection<T>;
(filter: string): _UpdateSelection<T>;
};
call(callback: (selection: _Selection<T>, ...args: any[]) => void, ...args: any[]): _Selection<T>;
each(eachFunction: (data: T, index: number) => any): _Selection<T>;
on: {
(type: string): (data: any, index: number) => any;
(type: string, listener: (data: any, index: number) => any, capture?: boolean): _Selection<T>;
};
/**
* 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(comparator?: (a: T, b: T) => number): _Selection<T>;
/**
* 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<T>;
/**
* Returns the first non-null element in the current selection. If the selection is empty,
* returns null.
*/
node: <E extends Element>() => E;
}
export interface Selection extends _Selection<any> { }
export interface _EnterSelection<T> {
append: (name: string) => _Selection<T>;
insert: (name: string, before?: string) => _Selection<T>;
select: (selector: string) => _Selection<T>;
empty: () => boolean;
node: () => Element;
call: (callback: (selection: _EnterSelection<T>) => void) => _EnterSelection<T>;
size: () => number;
}
export interface EnterSelection extends _EnterSelection<any> { }
export interface _UpdateSelection<T> extends _Selection<T> {
enter: () => _EnterSelection<T>;
update: () => _Selection<T>;
exit: () => _Selection<T>;
}
export interface UpdateSelection extends _UpdateSelection<any> { }
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[], mapType?: any): any;
entries(values: any[]): NestKeyValue[];
}
export interface MapKeyValue<T> {
key: string;
value: T;
}
export interface Map<T> {
has(key: string): boolean;
get(key: string): T;
set(key: string, value: T): T;
remove(key: string): boolean;
keys(): string[];
values(): T[];
entries(): MapKeyValue<T>[];
forEach(func: (key: string, value: T) => void ): void;
empty(): boolean;
size(): number;
}
export interface Set<T> {
has(value: T): boolean;
add(value: T): T;
remove(value: T): boolean;
values(): string[];
forEach(func: (value: string) => void ): void;
empty(): boolean;
size(): number;
}
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: (transition: Transition, ...args: any[]) => void, ...args: any[]): 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: {
/**
* Immediately invokes the specified function for each element in the current
* transition, passing in the current datum and index, with the this context
* of the current DOM element. Similar to D3.Selection.each.
*
* @param eachFunction The function to be invoked for each element in the
* current transition, passing in the current datum and index, with the this
* context of the current DOM element.
*/
(eachFunction: (data: any, index: number) => any): Transition;
/**
* Adds a listener for transition events, supporting "start", "end" and
* "interrupt" events. The listener will be invoked for each individual
* element in the transition.
*
* @param type Type of transition event. Supported values are "start", "end"
* and "interrupt".
* @param listener The listener to be invoked for each individual element in
* the transition.
*/
(type: string, listener: (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: {
/**
* Constructs a new local time formatter using the given specifier.
*/
(specifier: string): TimeFormat;
/**
* Returns a new multi-resolution time format given the specified array of predicated formats.
*/
multi: (formats: any[][]) => TimeFormat;
utc: {
/**
* Constructs a new local time formatter using the given specifier.
*/
(specifier: string): TimeFormat;
/**
* Returns a new multi-resolution UTC time format given the specified array of predicated formats.
*/
multi: (formats: any[][]) => TimeFormat;
};
/**
* The full ISO 8601 UTC time format: "%Y-%m-%dT%H:%M:%S.%LZ".
*/
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;
x(accessor: (d: any, i: number) => any): StackLayout;
y(accessor: (d: any, i: number) => any): StackLayout;
out(setter: (d: any, y0: number, y: number) => void): 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): GraphNode[];
/**
* 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: GraphNode[]): 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
*/
separation: {
/**
* Gets the current separation function
*/
(): (a: GraphNode, b: GraphNode) => number;
/**
* Sets the specified function to compute separation between neighboring nodes
*/
(separation: (a: GraphNode, b: GraphNode) => number): TreeLayout;
};
/**
* Gets or sets the available layout size
*/
size: {
/**
* Gets the available layout size
*/
(): number[];
/**
* Sets the available layout size
*/
(size: number[]): TreeLayout;
};
/**
* Gets or sets the available node size
*/
nodeSize: {
/**
* Gets the available node size
*/
(): number[];
/**
* Sets the available node size
*/
(size: 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;
};
padAngle: {
(): 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 GraphNodeForce {
index?: number;
x?: number;
y?: number;
px?: number;
py?: number;
fixed?: boolean;
weight?: number;
}
export interface GraphLinkForce {
source: GraphNodeForce;
target: GraphNodeForce;
}
export interface ForceLayout {
(): ForceLayout;
size: {
(): number[];
(mysize: 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;
};
/**
* If distance is specified, sets the maximum distance over which
* charge forces are applied. If distance is not specified, returns
* the current maximum charge distance, which defaults to infinity.
* Specifying a finite charge distance improves the performance of
* the force layout and produces a more localized layout;
* distance-limited charge forces are especially useful in
* conjunction with custom gravity.
*/
chargeDistance: {
(): number;
(distance: 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: {
(): GraphLinkForce[];
(arLinks: GraphLinkForce[]): ForceLayout;
};
nodes:
{
(): GraphNodeForce[];
(arNodes: GraphNodeForce[]): ForceLayout;
};
start(): ForceLayout;
resume(): ForceLayout;
stop(): ForceLayout;
tick(): ForceLayout;
on(type: string, listener: () => void ): ForceLayout;
drag(): ForceLayout;
}
export interface BundleLayout{
(links: GraphLink[]): GraphNode[][];
}
export interface ChordLayout {
matrix: {
(): number[][];
(matrix: 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(): GraphLink[];
groups(): ArcDescriptor[];
}
export interface ClusterLayout{
sort: {
(): (a: GraphNode, b: GraphNode) => number;
(comparator: (a: GraphNode, b: GraphNode) => number): ClusterLayout;
}
children: {
(): (d: any, i?: number) => GraphNode[];
(children: (d: any, i?: number) => GraphNode[]): ClusterLayout;
}
nodes(root: GraphNode): GraphNode[];
links(nodes: GraphNode[]): GraphLink[];
separation: {
(): (a: GraphNode, b: GraphNode) => number;
(separation: (a: GraphNode, b: GraphNode) => number): ClusterLayout;
}
size: {
(): number[];
(size: 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) => GraphNode[];
(children: (d: any, i?: number) => GraphNode[]): HierarchyLayout;
}
nodes(root: GraphNode): GraphNode[];
links(nodes: GraphNode[]): 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: any[], index?: number): Bin[];
value: {
(): (value: any) => any;
(accessor: (value: any) => any): HistogramLayout
}
range: {
(): (value: any, index: number) => number[];
(range: (value: any, index: number) => number[]): HistogramLayout;
(range: number[]): HistogramLayout;
}
bins: {
(): (range: any[], index: number) => number[];
(bins: (range: any[], index: number) => number[]): HistogramLayout;
(bins: number): HistogramLayout;
(bins: 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) => GraphNode[];
(children: (d: any, i?: number) => GraphNode[]): PackLayout;
}
nodes(root: GraphNode): GraphNode[];
links(nodes: GraphNode[]): GraphLink[];
value: {
(): (node: GraphNode) => number;
(value: (node: GraphNode) => number): PackLayout;
}
size: {
(): number[];
(size: 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) => GraphNode[];
(children: (d: any, i?: number) => GraphNode[]): PackLayout;
}
nodes(root: GraphNode): GraphNode[];
links(nodes: GraphNode[]): GraphLink[];
value: {
(): (node: GraphNode) => number;
(value: (node: GraphNode) => number): PackLayout;
}
size: {
(): number[];
(size: number[]): PackLayout;
}
}
export interface TreeMapLayout {
sort: {
(): (a: GraphNode, b: GraphNode) => number;
(comparator: (a: GraphNode, b: GraphNode) => number): TreeMapLayout;
}
children: {
(): (d: any, i?: number) => GraphNode[];
(children: (d: any, i?: number) => GraphNode[]): TreeMapLayout;
}
nodes(root: GraphNode): GraphNode[];
links(nodes: GraphNode[]): GraphLink[];
value: {
(): (node: GraphNode) => number;
(value: (node: GraphNode) => number): TreeMapLayout;
}
size: {
(): number[];
(size: 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
*/
c: number;
/**
* luminance
*/
l: number;
/**
* 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: string[];
}
export interface Symbol {
type: (symbolType: string | ((datum: any, index: number) => string)) => Symbol;
size: (size: number | ((datum: any, index: number) => number)) => Symbol;
(datum?: any, index?: number): string;
}
export interface Brush {
/**
* Draws or redraws this brush into the specified selection of elements
*/
(selection: _Selection<any>): 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<any>): void;
(transition: Transition.Transition): 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: {
(): number;
(inner: number, outer?: number): Axis;
}
innerTickSize: {
(): number;
(value: number): Axis;
}
outerTickSize: {
(): number;
(value: number): Axis;
}
tickFormat(formatter: (value: any, index?: number) => string): Axis;
nice(count?: number): 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 | ((points: number[][]) => string);
/**
* Set the interpolation accessor.
*
* @param interpolate The interpolation mode
*/
(interpolate: string | ((points: number[][]) => 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, index?: number) => 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 | ((points: number[][]) => string);
/**
* Set the interpolation accessor.
*
* @param interpolate The interpolation mode
*/
(interpolate: string | ((points: number[][]) => 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, index?: number) => any;
/**
* Set the accessor function that controls where the area is defined.
*
* @param defined The new accessor function
*/
(defined: (data: any, index?: number) => 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) => number[];
(proj: (datum: any) => number[]): Diagonal;
(proj: (datum: any, index: number) => 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.
*/
threshold(): ThresholdScale;
}
export interface GenericScale<S> {
(value: any): any;
domain: {
(values: any[]): S;
(): any[];
};
range: {
(values: any[]): S;
(): any[];
};
invertExtent?(y: any): any[];
copy(): S;
}
export interface Scale extends GenericScale<Scale> { }
export interface GenericQuantitativeScale<S> extends GenericScale<S> {
/**
* 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;
/**
* Set the scale's output range, and enable rounding.
*
* @param value The output range.
*/
rangeRound: (values: any[]) => S;
/**
* get or set the scale's output interpolator.
*/
interpolate: {
(): D3.Transition.Interpolate;
(factory: D3.Transition.Interpolate): S;
};
/**
* enable or disable clamping of the output range.
*
* @param clamp Enable or disable
*/
clamp: {
(): boolean;
(clamp: boolean): S;
}
/**
* extend the scale domain to nice round numbers.
*
* @param count Optional number of ticks to exactly fit the domain
*/
nice(count?: number): S;
/**
* 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, format?: string): (n: number) => string;
}
export interface QuantitativeScale extends GenericQuantitativeScale<QuantitativeScale> { }
export interface LinearScale extends GenericQuantitativeScale<LinearScale> { }
export interface IdentityScale extends GenericScale<IdentityScale> {
/**
* Get the range value corresponding to a given domain value.
*
* @param value Domain Value
*/
(value: number): number;
/**
* Get the domain value corresponding to a given range value.
*
* @param value Range Value
*/
invert(value: number): number;
/**
* get representative values from the input domain.
*
* @param count Aproximate representative values to return.
*/
ticks(count: number): any[];
/**
* get a formatter for displaying tick values
*
* @param count Aproximate representative values to return
*/
tickFormat(count: number): (n: number) => string;
}
export interface SqrtScale extends GenericQuantitativeScale<SqrtScale> { }
export interface PowScale extends GenericQuantitativeScale<PowScale> { }
export interface LogScale extends GenericQuantitativeScale<LogScale> { }
export interface OrdinalScale extends GenericScale<OrdinalScale> {
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[];
}
export interface QuantizeScale extends GenericScale<QuantizeScale> { }
export interface ThresholdScale extends GenericScale<ThresholdScale> { }
export interface QuantileScale extends GenericScale<QuantileScale> {
quantiles(): any[];
}
export interface TimeScale extends GenericScale<TimeScale> {
(value: Date): number;
invert(value: number): Date;
rangeRound: (values: any[]) => TimeScale;
interpolate: {
(): D3.Transition.Interpolate;
(factory: D3.Transition.InterpolateFactory): TimeScale;
};
clamp(clamp: boolean): TimeScale;
ticks: {
(count: number): any[];
(range: D3.Time.Range, count: number): any[];
};
tickFormat(count: number): (n: number) => string;
nice(count?: number): 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 {
/**
* Applies the zoom behavior to the specified selection,
* registering the necessary event listeners to support
* panning and zooming.
*/
(selection: _Selection<any>): void;
/**
* 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): number[][];
/**
* compute the spherical centroid of a given feature.
*/
centroid(feature: any): number[];
/**
* compute the great-arc distance between two points.
*/
distance(a: number[], b: number[]): number;
/**
* interpolate between two points along a great arc.
*/
interpolate(a: number[], b: number[]): (t: number) => 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: RawProjection): Projection;
/**
* create a standard projection from a mutable raw projection.
*/
projectionMutator(rawFactory: RawProjection): ProjectionMutator;
/**
* 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: RawProjection;
}
/**
* the azimuthal equidistant projection.
*/
azimuthalEquidistant: {
(): Projection;
raw: RawProjection;
}
/**
* the conic conformal projection.
*/
conicConformal: {
(): Projection;
raw(phi1:number, phi2:number): RawProjection;
}
/**
* the conic equidistant projection.
*/
conicEquidistant: {
(): Projection;
raw(phi1:number, phi2:number): RawProjection;
}
/**
* the conic equal-area (a.k.a. Albers) projection.
*/
conicEqualArea: {
(): Projection;
raw(phi1:number, phi2:number): RawProjection;
}
/**
* the equirectangular (plate carreé) projection.
*/
equirectangular: {
(): Projection;
raw: RawProjection;
}
/**
* the gnomonic projection.
*/
gnomonic: {
(): Projection;
raw: RawProjection;
}
/**
* the spherical Mercator projection.
*/
mercator: {
(): Projection;
raw: RawProjection;
}
/**
* the azimuthal orthographic projection.
*/
orthographic: {
(): Projection;
raw: RawProjection;
}
/**
* the azimuthal stereographic projection.
*/
stereographic: {
(): Projection;
raw: RawProjection;
}
/**
* the transverse Mercator projection.
*/
transverseMercator: {
(): Projection;
raw: RawProjection;
}
/**
* convert a GeoJSON object to a geometry stream.
*/
stream(object: GeoJSON, listener: Stream): void;
/**
*
*/
graticule(): Graticule;
/**
*
*/
greatArc(): GreatArc;
/**
*
*/
rotation(rotation: 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: any[]): GeoJSON;
origin: {
(): number[];
(origin: number[]): Circle;
(origin: (...args: any[]) => number[]): Circle;
}
angle: {
(): number;
(angle: number): Circle;
}
precision: {
(): number;
(precision: number): Circle;
}
}
export interface Graticule{
(): GeoJSON;
lines(): GeoJSON[];
outline(): GeoJSON;
extent: {
(): number[][];
(extent: number[][]): Graticule;
}
minorExtent: {
(): number[][];
(extent: number[][]): Graticule;
}
majorExtent: {
(): number[][];
(extent: number[][]): Graticule;
}
step: {
(): number[][];
(extent: number[][]): Graticule;
}
minorStep: {
(): number[][];
(extent: number[][]): Graticule;
}
majorStep: {
(): number[][];
(extent: 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: number[][];
type: string;
}
export interface RawProjection {
(lambda: number, phi: number): number[];
invert?(x: number, y: number): number[];
}
export interface Projection {
(coordinates: number[]): number[];
invert?(point: number[]): number[];
rotate: {
(): number[];
(rotation: number[]): Projection;
};
center: {
(): number[];
(location: number[]): Projection;
};
parallels: {
(): number[];
(location: number[]): Projection;
};
translate: {
(): number[];
(point: number[]): Projection;
};
scale: {
(): number;
(scale: number): Projection;
};
clipAngle: {
(): number;
(angle: number): Projection;
};
clipExtent: {
(): number[][];
(extent: number[][]): Projection;
};
precision: {
(): number;
(precision: number): Projection;
};
stream(listener?: Stream): 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: number[]): Rotation;
invert(location: number[]): Rotation;
}
export interface ProjectionMutator {
(lambda: number, phi: number): Projection;
}
}
// Geometry
export module Geom {
export interface Geom {
voronoi<T>(): Voronoi<T>;
/**
* compute the Voronoi diagram for the specified points.
*/
voronoi(vertices: Vertice[]): Polygon[];
/**
* compute the Delaunay triangulation for the specified points.
*/
delaunay(vertices?: Vertice[]): Polygon[];
/**
* constructs a quadtree for an array of points.
*/
quadtree(): QuadtreeFactory;
/**
* Constructs a new quadtree for the specified array of points.
*/
quadtree(points: Point[], x1: number, y1: number, x2: number, y2: number): Quadtree;
/**
* Constructs a new quadtree for the specified array of points.
*/
quadtree(points: Point[], width: number, height: number): Quadtree;
/**
* Returns the input array of vertices with additional methods attached
*/
polygon(vertices:Vertice[]): Polygon;
/**
* creates a new hull layout with the default settings.
*/
hull(): Hull;
hull(vertices:Vertice[]): Vertice[];
}
export interface Vertice extends Array<number> {
/**
* Returns the angle of the vertice
*/
angle?: number;
}
export interface Polygon extends Array<Vertice> {
/**
* Returns the signed area of this polygon
*/
area(): number;
/**
* Returns a two-element array representing the centroid of this polygon.
*/
centroid(): number[];
/**
* Clips the subject polygon against this polygon
*/
clip(subject: Polygon): Polygon;
}
export interface QuadtreeFactory {
/**
* Constructs a new quadtree for the specified array of points.
*/
(): Quadtree;
/**
* Constructs a new quadtree for the specified array of points.
*/
(points: Point[], x1: number, y1: number, x2: number, y2: number): Quadtree;
/**
* Constructs a new quadtree for the specified array of points.
*/
(points: Point[], width: number, height: number): Quadtree;
x: {
(): (d: any) => any;
(accesor: (d: any) => any): QuadtreeFactory;
}
y: {
(): (d: any) => any;
(accesor: (d: any) => any): QuadtreeFactory;
}
size(): number[];
size(size: number[]): QuadtreeFactory;
extent(): number[][];
extent(points: number[][]): QuadtreeFactory;
}
export interface Quadtree {
/**
* Adds a new point to the quadtree.
*/
add(point: Point): void;
visit(callback: any): void;
}
export interface Point {
x: number;
y: number;
}
export interface Voronoi<T> {
/**
* Compute the Voronoi diagram for the specified data.
*/
(data: T[]): Polygon[];
/**
* Compute the graph links for the Voronoi diagram for the specified data.
*/
links(data: T[]): Layout.GraphLink[];
/**
* Compute the triangles for the Voronoi diagram for the specified data.
*/
triangles(data: T[]): number[][];
x: {
/**
* Get the x-coordinate accessor.
*/
(): (data: T, index ?: number) => number;
/**
* Set the x-coordinate accessor.
*
* @param accessor The new accessor function
*/
(accessor: (data: T, index: number) => number): Voronoi<T>;
/**
* Set the x-coordinate to a constant.
*
* @param constant The new constant value.
*/
(constant: number): Voronoi<T>;
}
y: {
/**
* Get the y-coordinate accessor.
*/
(): (data: T, index ?: number) => number;
/**
* Set the y-coordinate accessor.
*
* @param accessor The new accessor function
*/
(accessor: (data: T, index: number) => number): Voronoi<T>;
/**
* Set the y-coordinate to a constant.
*
* @param constant The new constant value.
*/
(constant: number): Voronoi<T>;
}
clipExtent: {
/**
* Get the clip extent.
*/
(): number[][];
/**
* Set the clip extent.
*
* @param extent The new clip extent.
*/
(extent: number[][]): Voronoi<T>;
}
size: {
/**
* Get the size.
*/
(): number[];
/**
* Set the size, equivalent to a clip extent starting from (0,0).
*
* @param size The new size.
*/
(size: number[]): Voronoi<T>;
}
}
export interface Hull {
(vertices: Vertice[]): Vertice[];
x: {
(): (d: any) => any;
(accesor: (d: any) => any): any;
}
y: {
(): (d: any) => any;
(accesor: (d: any) => any): any;
}
}
}
}
declare var d3: D3.Base;
declare module "d3" {
export = d3;
}