// Type definitions for D3JS d3-array module v1.0.1 // Project: https://github.com/d3/d3-array // Definitions by: Alex Ford , Boris Yankov , Tom Wanzek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // -------------------------------------------------------------------------- // Shared Types and Interfaces // -------------------------------------------------------------------------- /** * Administrivia: JavaScript primitive types and Date */ export type Primitive = number | string | boolean | Date; /** * Administrivia: anything with a valueOf(): number method is comparable, so we allow it in numeric operations */ interface Numeric { valueOf(): number; } // -------------------------------------------------------------------------------------- // Descriptive Statistics // -------------------------------------------------------------------------------------- /** * Return the maximum value in the array of numbers using natural order. */ export function max(array: number[]): number | undefined; /** * Return the maximum value in the array of strings using natural order. */ export function max(array: string[]): string | undefined; /** * Return the maximum value in the array of numbers using natural order. */ export function max(array: T[]): T | undefined; /** * Return the maximum value in the array using natural order and a projection function to map values to numbers. */ export function max(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined; /** * Return the maximum value in the array using natural order and a projection function to map values to strings. */ export function max(array: T[], accessor: (datum: T, index: number, array: T[]) => string): string | undefined; /** * Return the maximum value in the array using natural order and a projection function to map values to easily-sorted values. */ export function max(array: T[], accessor: (datum: T, index: number, array: T[]) => U): U | undefined; /** * Return the minimum value in the array using natural order. */ export function min(array: number[]): number | undefined; /** * Return the minimum value in the array using natural order. */ export function min(array: string[]): string | undefined; /** * Return the minimum value in the array using natural order. */ export function min(array: T[]): T | undefined; /** * Return the minimum value in the array using natural order. */ export function min(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined; /** * Return the minimum value in the array using natural order. */ export function min(array: T[], accessor: (datum: T, index: number, array: T[]) => string): string | undefined; /** * Return the minimum value in the array using natural order. */ export function min(array: T[], accessor: (datum: T, index: number, array: T[]) => U): U | undefined; /** * Return the min and max simultaneously. */ export function extent(array: number[]): [number, number] | [undefined, undefined]; /** * Return the min and max simultaneously. */ export function extent(array: string[]): [string, string] | [undefined, undefined]; /** * Return the min and max simultaneously. */ export function extent(array: T[]): [T, T] | [undefined, undefined]; /** * Return the min and max simultaneously. */ export function extent(array: Array): [T | Primitive, T | Primitive] | [undefined, undefined]; /** * Return the min and max simultaneously. */ export function extent(array: T[], accessor: (datum: T, index: number, array: T[]) => number): [number, number] | [undefined, undefined]; /** * Return the min and max simultaneously. */ export function extent(array: T[], accessor: (datum: T, index: number, array: T[]) => string): [string, string] | [undefined, undefined]; /** * Return the min and max simultaneously. */ export function extent(array: T[], accessor: (datum: T, index: number, array: T[]) => U): [U | Primitive, U | Primitive] | [undefined, undefined]; /** * Return the mean of an array of numbers */ export function mean(array: number[]): number | undefined; export function mean(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined; /** * Return the median of an array of numbers */ export function median(array: number[]): number | undefined; export function median(array: T[], accessor: (element: T, i: number, array: T[]) => number): number | undefined; /** * Returns the p-quantile of an array of numbers */ export function quantile(array: number[], p: number): number | undefined; export function quantile(array: T[], p: number, accessor: (element: T, i: number, array: T[]) => number): number | undefined; /** * Compute the sum of an array of numbers. */ export function sum(array: number[]): number; /** * Compute the sum of an array, using the given accessor to convert values to numbers. */ export function sum(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number; /** * Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array of numbers. */ export function deviation(array: number[]): number | undefined; /** * Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array, * using the given accessor to convert values to numbers. */ export function deviation(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined; /** * Compute an unbiased estimator of the population variance of the given array of numbers. */ export function variance(array: number[]): number | undefined; /** * Compute an unbiased estimator of the population variance of the given array, * using the given accessor to convert values to numbers. */ export function variance(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined; // -------------------------------------------------------------------------------------- // Searching Arrays // -------------------------------------------------------------------------------------- export function scan(array: T[], comparator: (a: T, b: T) => number): number; export function bisectLeft(array: number[], x: number, lo?: number, hi?: number): number; export function bisectLeft(array: string[], x: string, lo?: number, hi?: number): number; export function bisectLeft(array: Date[], x: Date, lo?: number, hi?: number): number; export function bisectRight(array: number[], x: number, lo?: number, hi?: number): number; export function bisectRight(array: string[], x: string, lo?: number, hi?: number): number; export function bisectRight(array: Date[], x: Date, lo?: number, hi?: number): number; export var bisect: typeof bisectRight; export interface Bisector { left: (array: T[], x: U, lo?: number, hi?: number) => number; right: (array: T[], x: U, lo?: number, hi?: number) => number; } export function bisector(accessor: (x: T) => U): Bisector; export function bisector(comparator: (a: T, b: U) => number): Bisector // NB. this is limited to primitive values due to D3's use of the <, >, and >= operators. Results get weird for object instances. /** * Compares two primitive values for sorting (in ascending order). */ export function ascending(a: Primitive, b: Primitive): number; // NB. this is limited to primitive values due to D3's use of the <, >, and >= operators. Results get weird for object instances. /** * Compares two primitive values for sorting (in ascending order). */ export function descending(a: Primitive, b: Primitive): number; // -------------------------------------------------------------------------------------- // Transforming Arrays // -------------------------------------------------------------------------------------- /** * Merges the specified arrays into a single array. */ export function merge(arrays: T[][]): T[]; /** * For each adjacent pair of elements in the specified array, returns a new array of tuples of elements i and i - 1. * Returns the empty array if the input array has fewer than two elements. */ export function pairs(array: T[]): Array<[T, T]>; /** * Given the specified array, return an array corresponding to the list of indices in 'keys'. */ export function permute(array: { [key: number]: T }, keys: number[]): T[]; /** * Given the specified object, return an array corresponding to the list of property names in 'keys'. */ export function permute(object: { [key: string]: T }, keys: string[]): T[]; /** * Generates a 0-based numeric sequence. The output range does not include 'stop'. */ export function range(stop: number): number[]; /** * Generates a numeric sequence starting from the given start and stop values. 'step' defaults to 1. The output range does not include 'stop'. */ export function range(start: number, stop: number, step?: number): number[]; /** * Randomizes the order of the specified array using the Fisher–Yates shuffle. */ export function shuffle(array: T[], lo?: number, hi?: number): T[]; /** * Generate an array of approximately count + 1 uniformly-spaced, nicely-rounded values between start and stop (inclusive). */ export function ticks(start: number, stop: number, count: number): number[]; /** * Generate an array of with the differences between adjecent ticks, had the same arguments * been passed to ticks(start, stop, count) */ export function tickStep(start: number, stop: number, count: number): number[]; /** * Transpose a matrix provided in Array of Arrays format. */ export function transpose(matrix: T[][]): T[][]; /** * Returns an array of arrays, where the ith array contains the ith element from each of the argument arrays. * The returned array is truncated in length to the shortest array in arrays. If arrays contains only a single array, the returned array * contains one-element arrays. With no arguments, the returned array is empty. */ export function zip(...arrays: T[][]): T[][]; // -------------------------------------------------------------------------------------- // Histogram // -------------------------------------------------------------------------------------- export interface Bin extends Array { x0: Value; x1: Value; } /** * Type definition for threshold generator which returns the count of recommended thresholds */ export type ThresholdCountGenerator = (values: number[], min?: number, max?: number) => number; /** * Type definition for threshold generator which returns an array of recommended thresholds */ export type ThresholdArrayGenerator = (values: Value[], min?: Value, max?: Value) => Value[]; export interface HistogramGenerator { (data: Datum[]): Array>; value(): (d: Datum, i: number, data: Datum[]) => Value; value(valueAccessor: (d: Datum, i: number, data: Datum[]) => Value): this; domain(): (values: Value[]) => [Value, Value]; domain(domain: [Value, Value]): this; domain(domainAccessor: (values: Value[]) => [Value, Value]): this; thresholds(): ThresholdCountGenerator | ThresholdArrayGenerator; /** * Divide the domain uniformly into approximately count bins. IMPORTANT: This threshold * setting approach only works, when the materialized values are numbers! * * @param count The desired number of uniform bins. */ thresholds(count: number): this; /** * Set a threshold accessor function, which returns the desired number of bins. * Divides the domain uniformly into approximately count bins. IMPORTANT: This threshold * setting approach only works, when the materialized values are numbers! * * @param count A function which accepts as arguments the array of materialized values, and * optionally the domain minimum and maximum. The function calcutates and returns the suggested * number of bins. */ thresholds(count: ThresholdCountGenerator): this; /** * Set the array of values to be used as thresholds in determining the bins. * @param thresholds Array of threshold values used for binning. The elements must * be of the same type as the materialized values of the histogram. */ thresholds(thresholds: Value[]): this; /** * Set a threshold accessor function, which returns the array of values to be used as * thresholds in determining the bins. * * @param thresholds A function which accepts as arguments the array of materialized values, and * optionally the domain minimum and maximum. The function calcutates and returns the array of values to be used as * thresholds in determining the bins. */ thresholds(thresholds: ThresholdArrayGenerator): this; } export function histogram(): HistogramGenerator; export function histogram(): HistogramGenerator; // -------------------------------------------------------------------------------------- // Histogram Thresholds // -------------------------------------------------------------------------------------- export function thresholdFreedmanDiaconis(values: number[], min: number, max: number): number; // of type ThresholdCountGenerator export function thresholdScott(values: number[], min: number, max: number): number; // of type ThresholdCountGenerator export function thresholdSturges(values: number[]): number; // of type ThresholdCountGenerator // Type definitions for D3JS d3-axis module v1.0.3 // Project: https://github.com/d3/d3-axis/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { Selection, TransitionLike } from '../d3-selection'; // -------------------------------------------------------------------------- // Shared Types and Interfaces // -------------------------------------------------------------------------- /** * A helper interface to describe the minimal contract to be met by a time interval * which can be passed into the Axis.ticks(...) or Axis.tickArguments(...) methods when * creating time series axes. Under normal circumstances the argument will be of type * TimeInterval or CountableTimeInterval as defined in d3-time. * NB: This helper interface has been created to avoid tight coupling of d3-axis to * d3-time at the level of definition files. I.e. d3-time is not a * dependency of d3-axis in the D3 Javascript implementation. This minimal contract * is based on an analysis of how d3-axis passes a time interval argument into a time scale, * if a time scale was set using Axis.scale(...). And in turn on how a time scale uses * the time interval when creating ticks from it. */ export interface AxisTimeInterval { range(start: Date, stop: Date, step?: number): Date[]; } /** * A helper interface to which a scale passed into axis must conform (at a minimum) * for axis to use the scale without error */ export interface AxisScale { (x: Domain): number; domain(): Array; range(): Array; copy(): AxisScale; bandwidth?(): number; ticks?(count: number | AxisTimeInterval): Array | Array; tickFormat?(count: number | AxisTimeInterval, specifier?: string): ((d: number) => string) | ((d: Date) => string); } /** * A helper type to alias elements which can serve as a container for an axis */ export type AxisContainerElement = SVGSVGElement | SVGGElement; /** * Interface defining an axis generator. The generic is the type of the axis domain */ export interface Axis { /** * Render the axis to the given context. * * @param context A selection of SVG containers (either SVG or G elements). */ (context: Selection): void; /** * Render the axis to the given context. * * @param context A transition defined on SVG containers (either SVG or G elements). */ (context: TransitionLike): void; /** * Gets the current scale underlying the axis. */ scale>(): A; /** * Sets the scale and returns the axis. * * @param scale The scale to be used for axis generation */ scale(scale: AxisScale): this; /** * Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. * * @param count Number of ticks that should be rendered * @param specifier An optional format specifier to customize how the tick values are formatted. */ ticks(count: number, specifier?: string): this; /** * Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. * Use with a TIME SCALE ONLY. * * @param interval A time interval used to generate date-based ticks. This is typically a TimeInterval/CountableTimeInterval as defined * in d3-time. E.g. as obtained by passing in d3.timeMinute.every(15). * @param specifier An optional format specifier to customize how the tick values are formatted. */ ticks(interval: AxisTimeInterval, specifier?: string): this; /** * Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. */ ticks(arg0: any, ...args: any[]): this; /** * Get an array containing the currently set arguments to be passed into scale.ticks and scale.tickFormat. */ tickArguments(): any[]; /** * Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. * * @param args An array containing a single element representing the count, i.e. number of ticks to be rendered. */ tickArguments(args: [number]): this; /** * Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. * * @param args An array containing two elements. The first element represents the count, i.e. number of ticks to be rendered. The second * element is a string representing the format specifier to customize how the tick values are formatted. */ tickArguments(args: [number, string]): this; /** * Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. * Use with a TIME SCALE ONLY. * * @param args An array containing a single element representing a time interval used to generate date-based ticks. * This is typically a TimeInterval/CountableTimeInterval as defined in d3-time. E.g. as obtained by passing in d3.timeMinute.every(15). */ tickArguments(args: [AxisTimeInterval]): this; /** * Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. * Use with a TIME SCALE ONLY. * * @param args An array containing two elements. The first element represents a time interval used to generate date-based ticks. * This is typically a TimeInterval/CountableTimeInterval as defined in d3-time. E.g. as obtained by passing in d3.timeMinute.every(15). * The second element is a string representing the format specifier to customize how the tick values are formatted. */ tickArguments(args: [AxisTimeInterval, string]): this; /** * Sets the arguments that will be passed to scale.ticks and scale.tickFormat when the axis is rendered, and returns the axis generator. * * @param args An array with arguments suitable for the scale to be used for tick generation */ tickArguments(args: any[]): this; /** * Returns the current tick values, which defaults to null. */ tickValues(): Domain[] | null; /** * Specified values to be used for ticks rather than using the scale’s automatic tick generator. * The explicit tick values take precedent over the tick arguments set by axis.tickArguments. * However, any tick arguments will still be passed to the scale’s tickFormat function if a * tick format is not also set. * * @param values An array with values from the Domain of the scale underlying the axis. */ tickValues(values: Domain[]): this; /** * Clears any previously-set explicit tick values and reverts back to the scale’s tick generator. * * @param values null */ tickValues(values: null): this; /** * Returns the currently set tick format function, which defaults to null. */ tickFormat(): ((domainValue: Domain) => string) | null; /** * Sets the tick format function and returns the axis. * * @param format A function mapping a value from the axis Domain to a formatted string * for display purposes. */ tickFormat(format: (domainValue: Domain) => string): this; /** * Reset the tick format function. A null format indicates that the scale’s * default formatter should be used, which is generated by calling scale.tickFormat. * In this case, the arguments specified by axis.tickArguments * are likewise passed to scale.tickFormat. * * @param format null */ tickFormat(format: null): this; /** * Get the current inner tick size, which defaults to 6. */ tickSize(): number; /** * Set the inner and outer tick size to the specified value and return the axis. * * @param size Tick size in pixels (Default is 6). */ tickSize(size: number): this; /** * Get the current inner tick size, which defaults to 6. * The inner tick size controls the length of the tick lines, * offset from the native position of the axis. */ tickSizeInner(): number; /** * Set the inner tick size to the specified value and return the axis. * The inner tick size controls the length of the tick lines, * offset from the native position of the axis. * * @param size Tick size in pixels (Default is 6). */ tickSizeInner(size: number): this; /** * Get the current outer tick size, which defaults to 6. * The outer tick size controls the length of the square ends of the domain path, * offset from the native position of the axis. Thus, the “outer ticks” are not actually * ticks but part of the domain path, and their position is determined by the associated * scale’s domain extent. Thus, outer ticks may overlap with the first or last inner tick. * An outer tick size of 0 suppresses the square ends of the domain path, * instead producing a straight line. */ tickSizeOuter(): number; /** * Set the current outer tick size and return the axis. * The outer tick size controls the length of the square ends of the domain path, * offset from the native position of the axis. Thus, the “outer ticks” are not actually * ticks but part of the domain path, and their position is determined by the associated * scale’s domain extent. Thus, outer ticks may overlap with the first or last inner tick. * An outer tick size of 0 suppresses the square ends of the domain path, * instead producing a straight line. * * @param size Tick size in pixels (Default is 6). */ tickSizeOuter(size: number): this; /** * Get the current padding, which defaults to 3. */ tickPadding(): number; /** * Set the current padding and return the axis. * * @param padding Padding in pixels (Default is 3). */ tickPadding(padding: number): this; } /** * Constructs a new top-oriented axis generator for the given scale, with empty tick arguments, * a tick size of 6 and padding of 3. In this orientation, ticks are drawn above the horizontal domain path. * * @param scale The scale to be used for axis generation */ export function axisTop(scale: AxisScale): Axis; /** * Constructs a new right-oriented axis generator for the given scale, with empty tick arguments, * a tick size of 6 and padding of 3. In this orientation, ticks are drawn to the right of the vertical domain path. * * @param scale The scale to be used for axis generation */ export function axisRight(scale: AxisScale): Axis; /** * Constructs a new bottom-oriented axis generator for the given scale, with empty tick arguments, * a tick size of 6 and padding of 3. In this orientation, ticks are drawn below the horizontal domain path. * * @param scale The scale to be used for axis generation */ export function axisBottom(scale: AxisScale): Axis; /** * Constructs a new left-oriented axis generator for the given scale, with empty tick arguments, * a tick size of 6 and padding of 3. In this orientation, ticks are drawn to the left of the vertical domain path. * * @param scale The scale to be used for axis generation */ export function axisLeft(scale: AxisScale): Axis; // Type definitions for D3JS d3-brush module v1.0.2 // Project: https://github.com/d3/d3-brush/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { ArrayLike, Selection, TransitionLike, ValueFn } from '../d3-selection'; /** * Type alias for a BrushSelection. For a two-dimensional brush, it must be defined as [[x0, y0], [x1, y1]], * where x0 is the minimum x-value, y0 is the minimum y-value, x1 is the maximum x-value, and y1 is the maximum y-value. * For an x-brush, it must be defined as [x0, x1]; for a y-brush, it must be defined as [y0, y1]. */ export type BrushSelection = [[number, number], [number, number]] | [number, number]; export interface BrushBehavior { (group: Selection, ...args: any[]): void; move(group: Selection, selection: BrushSelection): void; move(group: Selection, selection: ValueFn): void; move(group: TransitionLike, selection: BrushSelection): void; move(group: TransitionLike, selection: ValueFn): void; extent(): ValueFn; extent(extent: [[number, number], [number, number]]): this; extent(extent: ValueFn): this; filter(): ValueFn; filter(filterFn: ValueFn): this; handleSize(): number; handleSize(size: number): this; on(typenames: string): ValueFn; on(typenames: string, callback: null): this; on(typenames: string, callback: ValueFn): this; } export function brush(): BrushBehavior; export function brushX(): BrushBehavior; export function brushY(): BrushBehavior; export function brushSelection(node: SVGGElement): BrushSelection; export interface D3BrushEvent { target: BrushBehavior; type: 'start' | 'brush' | 'end' | string; // Leave failsafe string type for cases like 'brush.foo' selection: BrushSelection; sourceEvent: any; } // Type definitions for D3JS d3-chord module v1.0.2 // Project: https://github.com/d3/d3-chord/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // --------------------------------------------------------------------- // Chord // --------------------------------------------------------------------- export interface ChordSubgroup { startAngle: number; endAngle: number; value: number; index: number; subindex: number; } export interface Chord { source: ChordSubgroup; target: ChordSubgroup; } export interface ChordGroup { startAngle: number; endAngle: number; value: number; index: number; } export interface Chords extends Array { groups: Array; } export interface ChordLayout { (matrix: number[][]): Chords; padAngle(): number; padAngle(angle: number): this; sortGroups(): ((a: number, b: number) => number) | null; sortGroups(compare: null): this; sortGroups(compare: (a: number, b: number) => number): this; sortSubgroups(): ((a: number, b: number) => number) | null; sortSubgroups(compare: null): this; sortSubgroups(compare: (a: number, b: number) => number): this; sortChords(): ((a: number, b: number) => number) | null; sortChords(compare: null): this; sortChords(compare: (a: number, b: number) => number): this; } export function chord(): ChordLayout; // --------------------------------------------------------------------- // Ribbon // --------------------------------------------------------------------- export interface RibbonGenerator { (this: This, d: ChordDatum, ...args: any[]): string | undefined; source(): (this: This, d: ChordDatum, ...args: any[]) => ChordSubgroupDatum; source(source: (this: This, d: ChordDatum, ...args: any[]) => ChordSubgroupDatum): this; target(): (this: This, d: ChordDatum, ...args: any[]) => ChordSubgroupDatum; target(target: (this: This, d: ChordDatum, ...args: any[]) => ChordSubgroupDatum): this; radius(): (this: This, d: ChordSubgroupDatum, ...args: any[]) => number; radius(radius: number): this; radius(radius: (this: This, d: ChordSubgroupDatum, ...args: any[]) => number): this; startAngle(): (this: This, d: ChordSubgroupDatum, ...args: any[]) => number; startAngle(angle: number): this; startAngle(angle: (this: This, d: ChordSubgroupDatum, ...args: any[]) => number): this; endAngle(): (this: This, d: ChordSubgroupDatum, ...args: any[]) => number; endAngle(angle: number): this; endAngle(angle: (this: This, d: ChordSubgroupDatum, ...args: any[]) => number): this; context(): CanvasRenderingContext2D | null; context(context: CanvasRenderingContext2D): this; context(context: null): this; } export function ribbon(): RibbonGenerator; export function ribbon(): RibbonGenerator; export function ribbon(): RibbonGenerator; // Type definitions for D3JS d3-collection module v1.0.1 // Project: https://github.com/d3/d3-collection/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * Reference type things that can be coerced to string implicitely */ type Stringifiable = { toString(): string; }; // --------------------------------------------------------------------- // Objects // --------------------------------------------------------------------- export function keys(object: { [key: string]: any }): Array; export function keys(object: Object): Array; export function values(object: { [key: string]: T }): Array; export function values(object: Object): Array; export function entries(object: { [key: string]: T }): Array<{ key: string, value: T }>; export function entries(object: Object): Array<{ key: string, value: any }>; // --------------------------------------------------------------------- // map / Map // --------------------------------------------------------------------- export interface Map { has(key: string): boolean; get(key: string): T | undefined; set(key: string, value: T): this; remove(key: string): boolean; clear(): void; keys(): Array; values(): Array; entries(): Array<{ key: string, value: T }>; each(func: (value: T, key: string, map: Map) => void): void; empty(): boolean; size(): number; } export function map(): Map; export function map(d3Map: Map): Map; export function map(object: { [key: string]: T }): Map; export function map(object: { [key: number]: T }): Map; export function map(array: Array, key?: (value: T, i?: number, array?: Array) => string): Map; export function map(object: Object): Map; // --------------------------------------------------------------------- // set / Set // --------------------------------------------------------------------- export interface Set { has(value: string | Stringifiable): boolean; add(value: string | Stringifiable): this; remove(value: string | Stringifiable): boolean; clear(): void; values(): Array; /** * The first and second parameter of the function are both passed * the 'value' of the set entry for consistency with map.each(...) * signature */ each(func: (value: string, valueRepeat: string, set: Set) => void): void; empty(): boolean; size(): number; } export function set(): Set; export function set(d3Set: Set): Set; export function set(array: Array): Set; export function set(array: Array, key: (value: T, index?: number, array?: Array) => string): Set; // --------------------------------------------------------------------- // nest / Nest // --------------------------------------------------------------------- // NB: the following three interfaces NestedArray, NestedMap and NestedObject provide a more formal definitions // of the return values provided by Nest.entries(...), Nest.map(...) and Nest.object(...), respectively. However, // the union types cannot be ex ante simplified without knowledge of the nesting level (number of key(...) operations) // and whether the data were rolled-up. The latter question also determins whether NestedArray has the 'values' property // with an array of type Datum at leaf level, or has a rolled-up 'value' property. // The interfaces are not used as return types, as they are cumbersome to work with on the consuming side (Determining the // applicable type from the respective union, i. p. for array elements). // It is preferable to carefully define appropriate use-case-specific interfaces for the variables that // are assigned the return values of the Nest.entries(...), Nest.map(...) and Nest.object(...) operations. The downside // is an overly permissive return type. // Also note, that the below return types for Nest.entries(...), Nest.map(...) and Nest.object(...) strictly only work, // if AT LEAST ONE KEY was set. This seems a reasonable constraint in practice, given the intent of the nest operator. // Otherwise, an additional '| Array | RollupType` would have to be added to the union type. This would cover // cases (a) without key or rollup (b) without key but with rollup. However, again, the union types make it cumbersome // without much gain. export interface NestedArray extends Array<{ key: string, values: NestedArray | Array | undefined, value: RollupType | undefined }> { } export interface NestedMap extends Map | Array | RollupType> { } export interface NestedObject { [key: string]: NestedObject | Array | RollupType; } interface Nest { key(func: (datum: Datum) => string): this; sortKeys(comparator: (a: string, b: string) => number): this; sortValues(comparator: (a: Datum, b: Datum) => number): this; rollup(func: (values: Datum[]) => RollupType): this; map(array: Datum[]): Map; // more specifically it returns NestedMap object(array: Datum[]): { [key: string]: any }; // more specifically it returns NestedObject entries(array: Datum[]): Array<{ key: string; values: any; value: RollupType | undefined }>; // more specifically it returns NestedArray } export function nest(): Nest; export function nest(): Nest; // Type definitions for D3JS d3-color module v1.0.1 // Project: https://github.com/d3/d3-color/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // --------------------------------------------------------------------------- // Shared Type Definitions and Interfaces // --------------------------------------------------------------------------- /** * Type allowing for color objects from a specified color space */ export type ColorSpaceObject = RGBColor | HSLColor | LabColor | HCLColor | CubehelixColor; /** * A helper interface of methods common to color objects (including colors defined outside the d3-color standard module, * e.g. in d3-hsv). This interface */ export interface ColorCommonInstance { displayable(): boolean; toString(): string; brighter(k?: number): this; darker(k?: number): this; rgb(): RGBColor; } export interface Color { displayable(): boolean; // Note: While this method is used in prototyping for colors of specific colorspaces, it should not be called directly, as 'this.rgb' would not be implemented on Color toString(): string; // Note: While this method is used in prototyping for colors of specific colorspaces, it should not be called directly, as 'this.rgb' would not be implemented on Color } export interface ColorFactory extends Function { (cssColorSpecifier: string): RGBColor | HSLColor; (color: ColorSpaceObject | ColorCommonInstance): RGBColor | HSLColor; // prototype: Color; } export interface RGBColor extends Color { r: number; g: number; b: number; opacity: number; brighter(k?: number): this; darker(k?: number): this; displayable(): boolean; rgb(): RGBColor; toString(): string; } export interface RGBColorFactory extends Function { (r: number, g: number, b: number, opacity?: number): RGBColor; (cssColorSpecifier: string): RGBColor; (color: ColorSpaceObject | ColorCommonInstance): RGBColor; // prototype: RGBColor; } export interface HSLColor extends Color { h: number; s: number; l: number; opacity: number; brighter(k?: number): this; darker(k?: number): this; displayable(): boolean; rgb(): RGBColor; } export interface HSLColorFactory extends Function { (h: number, s: number, l: number, opacity?: number): HSLColor; (cssColorSpecifier: string): HSLColor; (color: ColorSpaceObject | ColorCommonInstance): HSLColor; // prototype: HSLColor; } export interface LabColor extends Color { l: number; a: number; b: number; opacity: number; brighter(k?: number): this; darker(k?: number): this; rgb(): RGBColor; } export interface LabColorFactory extends Function { (l: number, a: number, b: number, opacity?: number): LabColor; (cssColorSpecifier: string): LabColor; (color: ColorSpaceObject | ColorCommonInstance): LabColor; // prototype: LabColor; } export interface HCLColor extends Color { h: number; c: number; l: number; opacity: number; brighter(k?: number): this; darker(k?: number): this; rgb(): RGBColor; } export interface HCLColorFactory extends Function { (h: number, l: number, c: number, opacity?: number): HCLColor; (cssColorSpecifier: string): HCLColor; (color: ColorSpaceObject | ColorCommonInstance): HCLColor; // prototype: HCLColor; } export interface CubehelixColor extends Color { h: number; s: number; l: number; opacity: number; brighter(k?: number): this; darker(k?: number): this; rgb(): RGBColor; } export interface CubehelixColorFactory extends Function { (h: number, s: number, l: number, opacity?: number): CubehelixColor; (cssColorSpecifier: string): CubehelixColor; (color: ColorSpaceObject | ColorCommonInstance): CubehelixColor; // prototype: CubehelixColor; } // -------------------------------------------------------------------------- // Color object factories // -------------------------------------------------------------------------- export var color: ColorFactory; export var rgb: RGBColorFactory; export var hsl: HSLColorFactory; export var lab: LabColorFactory; export var hcl: HCLColorFactory; export var cubehelix: CubehelixColorFactory; // Type definitions for D3JS d3-dispatch module v1.0.1 // Project: https://github.com/d3/d3-dispatch/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface Dispatch { apply(type: string, that?: T, args?: any[]): void; call(type: string, that?: T, ...args: any[]): void; copy(): Dispatch; on(typenames: string): (this: T, ...args: any[]) => void; on(typenames: string, callback: null): this; on(typenames: string, callback: (this: T, ...args: any[]) => void): this; } export function dispatch(...types: string[]): Dispatch; // Type definitions for D3JS d3-drag module v1.0.1 // Project: https://github.com/d3/d3-drag/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { ArrayLike, Selection, ValueFn } from '../d3-selection'; // -------------------------------------------------------------------------- // Shared Type Definitions and Interfaces // -------------------------------------------------------------------------- /** * DraggedElementBaseType serves as an alias for the 'minimal' data type which can be selected * without 'd3-drag' (and related code in 'd3-selection') trying to use properties internally which would otherwise not * be supported. */ export type DraggedElementBaseType = Element; /** * Container element type usable for mouse/touch functions */ export type DragContainerElement = HTMLElement | SVGSVGElement | SVGGElement; // HTMLElement includes HTMLCanvasElement /** * The subject datum should at a minimum expose x and y properties, so that the relative position * of the subject and the pointer can be preserved during the drag gesture. */ export interface SubjectPosition { x: number; y: number; } export interface DragBehavior extends Function { (selection: Selection, ...args: any[]): void; container(): ValueFn; container(accessor: ValueFn): this; container(container: DragContainerElement): this; filter(): ValueFn; filter(filterFn: ValueFn): this; subject(): ValueFn; subject(accessor: ValueFn): this; on(typenames: string): ValueFn; on(typenames: string, callback: null): this; on(typenames: string, callback: ValueFn): this; } export function drag(): DragBehavior; export function drag(): DragBehavior; export interface D3DragEvent { target: DragBehavior; type: 'start' | 'drag' | 'end' | string; // Leave failsafe string type for cases like 'drag.foo' subject: Subject; x: number; y: number; dx: number; dy: number; identifier: 'mouse' | number; active: number; sourceEvent: any; on(typenames: string): ValueFn; on(typenames: string, callback: null): this; on(typenames: string, callback: ValueFn): this; } export function dragDisable(window: Window): void; export function dragEnable(window: Window, noClick?: boolean): void; // Type definitions for D3JS d3-dsv module v1.0.1 // Project: https://github.com/d3/d3-dsv/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // ------------------------------------------------------------------------------------------ // Shared Types and Interfaces // ------------------------------------------------------------------------------------------ export interface DSVRowString { [key: string]: string; } export interface DSVRowAny { [key: string]: any; } export interface DSVParsedArray extends Array { columns: Array; } // ------------------------------------------------------------------------------------------ // CSV Parsers and Formatters // ------------------------------------------------------------------------------------------ // csvParse(...) ============================================================================ export function csvParse(csvString: string): DSVParsedArray; export function csvParse(csvString: string, row: (rawRow: DSVRowString, index: number, columns: Array) => ParsedRow): DSVParsedArray; // csvParseRows(...) ======================================================================== export function csvParseRows(csvString: string): Array>; export function csvParseRows(csvString: string, row: (rawRow: Array, index: number) => ParsedRow): Array; // csvFormat(...) ============================================================================ export function csvFormat(rows: Array): string; export function csvFormat(rows: Array, columns: Array): string; // csvFormatRows(...) ======================================================================== export function csvFormatRows(rows: Array>): string; // ------------------------------------------------------------------------------------------ // TSV Parsers and Formatters // ------------------------------------------------------------------------------------------ // tsvParse(...) ============================================================================ export function tsvParse(tsvString: string): DSVParsedArray; export function tsvParse(tsvString: string, row: (rawRow: DSVRowString, index: number, columns: Array) => MappedRow): DSVParsedArray; // tsvParseRows(...) ======================================================================== export function tsvParseRows(tsvString: string): Array>; export function tsvParseRows(tsvString: string, row: (rawRow: Array, index: number) => MappedRow): Array; // tsvFormat(...) ============================================================================ export function tsvFormat(rows: Array): string; export function tsvFormat(rows: Array, columns: Array): string; // tsvFormatRows(...) ======================================================================== export function tsvFormatRows(rows: Array>): string; // ------------------------------------------------------------------------------------------ // DSV Generalized Parsers and Formatters // ------------------------------------------------------------------------------------------ export interface DSV { parse(dsvString: string): DSVParsedArray; parse(dsvString: string, row: (rawRow: DSVRowString, index: number, columns: Array) => ParsedRow): DSVParsedArray; parseRows(dsvString: string): Array>; parseRows(dsvString: string, row: (rawRow: Array, index: number) => ParsedRow): Array; format(rows: Array): string; format(rows: Array, columns: Array): string; formatRows(rows: Array>): string; } export function dsvFormat(delimiter: string): DSV; // Type definitions for D3JS d3-ease module v1.0.1 // Project: https://github.com/d3/d3-ease/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // -------------------------------------------------------------------------- // Easing Functions // -------------------------------------------------------------------------- export function easeLinear(normalizedTime: number): number; export function easeQuad(normalizedTime: number): number; export function easeQuadIn(normalizedTime: number): number; export function easeQuadOut(normalizedTime: number): number; export function easeQuadInOut(normalizedTime: number): number; export function easeCubic(normalizedTime: number): number; export function easeCubicIn(normalizedTime: number): number; export function easeCubicOut(normalizedTime: number): number; export function easeCubicInOut(normalizedTime: number): number; export function easePoly(normalizedTime: number): number; export function easePolyIn(normalizedTime: number): number; export function easePolyOut(normalizedTime: number): number; export function easePolyInOut(normalizedTime: number): number; export function easeSin(normalizedTime: number): number; export function easeSinIn(normalizedTime: number): number; export function easeSinOut(normalizedTime: number): number; export function easeSinInOut(normalizedTime: number): number; export function easeExp(normalizedTime: number): number; export function easeExpIn(normalizedTime: number): number; export function easeExpOut(normalizedTime: number): number; export function easeExpInOut(normalizedTime: number): number; export function easeCircle(normalizedTime: number): number; export function easeCircleIn(normalizedTime: number): number; export function easeCircleOut(normalizedTime: number): number; export function easeCircleInOut(normalizedTime: number): number; export function easeBounce(normalizedTime: number): number; export function easeBounceIn(normalizedTime: number): number; export function easeBounceOut(normalizedTime: number): number; export function easeBounceInOut(normalizedTime: number): number; export function easeBack(normalizedTime: number): number; export function easeBackIn(normalizedTime: number): number; export function easeBackOut(normalizedTime: number): number; export function easeBackInOut(normalizedTime: number): number; export function easeElastic(normalizedTime: number): number; export function easeElasticIn(normalizedTime: number): number; export function easeElasticOut(normalizedTime: number): number; export function easeElasticInOut(normalizedTime: number): number; // Type definitions for D3JS d3-force module v1.0.2 // Project: https://github.com/d3/d3-force/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // ----------------------------------------------------------------------- // Force Simulation // ----------------------------------------------------------------------- // TODO: Review below: fx and fy should be optional as a matter of principle. The other properties, are optional prior to initialization, but once the // the nodes array is passed into the simulation, will be initialized. export interface SimulationNodeDatum { // NB: index is assigned internally by simulation, once initialized it is defined index?: number; x?: number; y?: number; vx?: number; vy?: number; fx?: number; fy?: number; } export interface SimulationLinkDatum { // TODO: Strictly speaking, the string or number typing of source and target is only used when (re)initializing links // Once initialized, links' source and target fields will be of type NodeDatum source: NodeDatum | string | number; target: NodeDatum | string | number; // NB: index is assigned internally by force, once initialized it is defined index?: number; } export interface Simulation> { restart(): this; stop(): this; tick(): void; nodes(): Array; nodes(nodesData: Array): this; alpha(): number; alpha(alpha: number): this; alphaMin(): number; alphaMin(min: number): this; alphaDecay(): number; alphaDecay(decay: number): this; alphaTarget(): number; alphaTarget(target: number): this; velocityDecay(): number; velocityDecay(decay: number): this; force>(name: string): F; // force names are arbitrary, so return type inference is not possible force(name: string, force: null): this; force(name: string, force: Force): this; find(x: number, y: number, radius?: number): NodeDatum | undefined; on(typenames: 'tick' | 'end' | string): (this: Simulation) => void; on(typenames: 'tick' | 'end' | string, listener: null): this; on(typenames: 'tick' | 'end' | string, listener: (this: this) => void): this; } export function forceSimulation(nodesData?: Array): Simulation; export function forceSimulation>(nodesData?: Array): Simulation; // ---------------------------------------------------------------------- // Forces // ---------------------------------------------------------------------- export interface Force> { (alpha: number): void; initialize?(nodes: Array): void; } // Centering ------------------------------------------------------------ export interface ForceCenter extends Force { x(): number; x(x: number): this; y(): number; y(y: number): this; } export function forceCenter(x?: number, y?: number): ForceCenter; // Collision ------------------------------------------------------------ export interface ForceCollide extends Force { radius(): (node: NodeDatum, i: number, nodes: Array) => number; radius(radius: number): this; radius(radius: (node: NodeDatum, i: number, nodes: Array) => number): this; strength(): number; strength(strength: number): this; iterations(): number; iterations(iterations: number): this; } export function forceCollide(): ForceCollide; export function forceCollide(radius: number): ForceCollide; export function forceCollide(radius: (node: NodeDatum, i: number, nodes: Array) => number): ForceCollide; // Link ---------------------------------------------------------------- export interface ForceLink> extends Force { links(): Array; links(links: Array): this; id(): (node: NodeDatum, i: number, nodesData: Array) => (string | number); id(id: (node: NodeDatum, i: number, nodesData: Array) => string): this; distance(): (link: LinkDatum, i: number, links: Array) => number; distance(distance: number): this; distance(distance: (link: LinkDatum, i: number, links: Array) => number): this; strength(): (link: LinkDatum, i: number, links: Array) => number; strength(strength: number): this; strength(strength: (link: LinkDatum, i: number, links: Array) => number): this; iterations(): number; iterations(iterations: number): this; } export function forceLink>(): ForceLink; export function forceLink>(links: Array): ForceLink; // Many Body ---------------------------------------------------------------- export interface ForceManyBody extends Force { strength(): (d: NodeDatum, i: number, data: Array) => number; strength(strength: number): this; strength(strength: (d: NodeDatum, i: number, data: Array) => number): this; theta(): number; theta(theta: number): this; distanceMin(): number; distanceMin(distance: number): this; distanceMax(): number; distanceMax(distance: number): this; } export function forceManyBody(): ForceManyBody; // Positioning ---------------------------------------------------------------- export interface ForceX extends Force { strength(): (d: NodeDatum, i: number, data: Array) => number; strength(strength: number): this; strength(strength: (d: NodeDatum, i: number, data: Array) => number): this; x(): (d: NodeDatum, i: number, data: Array) => number; x(x: number): this; x(x: (d: NodeDatum, i: number, data: Array) => number): this; } export function forceX(): ForceX; export function forceX(x: number): ForceX; export function forceX(x: (d: NodeDatum, i: number, data: Array) => number): ForceX; export interface ForceY extends Force { strength(): (d: NodeDatum, i: number, data: Array) => number; strength(strength: number): this; strength(strength: (d: NodeDatum, i: number, data: Array) => number): this; y(): (d: NodeDatum, i: number, data: Array) => number; y(y: number): this; y(y: (d: NodeDatum, i: number, data: Array) => number): this; } export function forceY(): ForceY; export function forceY(y: number): ForceY; export function forceY(y: (d: NodeDatum, i: number, data: Array) => number): ForceY; // Type definitions for D3JS d3-format module v1.0.2 // Project: https://github.com/d3/d3-format/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * Specification of locale to use when creating a new FormatLocaleObject */ export interface FormatLocaleDefinition { /** * The decimal point (e.g., ".") */ decimal: '.' | ','; /** * The group separator (e.g., ","). Note that the thousands property is a misnomer, as\ * the grouping definition allows groups other than thousands. */ thousands: '.' | ','; /** * The array of group sizes (e.g., [3]), cycled as needed. */ grouping: number[]; /** * The currency prefix and suffix (e.g., ["$", ""]) */ currency: [string, string]; } export interface FormatLocaleObject { /** * Returns a new format function for the given string specifier. The returned function * takes a number as the only argument, and returns a string representing the formatted number. * * @param specifier A Specifier string */ format(specifier: string): (n: number) => string; /** * Returns a new format function for the given string specifier. The returned function * takes a number as the only argument, and returns a string representing the formatted number. * The returned function will convert values to the units of the appropriate SI prefix for the * specified numeric reference value before formatting in fixed point notation. * * @param specifier A Specifier string * @param value The reference value to determine the appropriate SI prefix. */ formatPrefix(specifier: string, value: number): (n: number) => string; } export interface FormatSpecifier { fill: string; align: string; sign: string; symbol: string; zero: boolean; width: number; comma: boolean; precision: number; type: string; toString(): string; } /** * Create a new locale-based object which exposes format(...) and formatPrefix(...) * methods for the specified locale. */ export function formatLocale(locale: FormatLocaleDefinition): FormatLocaleObject; /** * Create a new locale-based object which exposes format(...) and formatPrefix(...) * methods for the specified locale definition. The specified locale definition will be * set as the new default locale definition. */ export function formatDefaultLocale(defaultLocale: FormatLocaleDefinition): FormatLocaleObject; /** * Returns a new format function for the given string specifier. The returned function * takes a number as the only argument, and returns a string representing the formatted number. * * Uses the current default locale. * * @param specifier A Specifier string */ export function format(specifier: string): (n: number) => string; /** * Returns a new format function for the given string specifier. The returned function * takes a number as the only argument, and returns a string representing the formatted number. * The returned function will convert values to the units of the appropriate SI prefix for the * specified numeric reference value before formatting in fixed point notation. * * Uses the current default locale. * * @param specifier A Specifier string * @param value The reference value to determine the appropriate SI prefix. */ export function formatPrefix(specifier: string, value: number): (n: number) => string; /** * Parses the specified specifier, returning an object with exposed fields that correspond to the * format specification mini-language and a toString method that reconstructs the specifier. * * @param specifier A specifier string. */ export function formatSpecifier(specifier: string): FormatSpecifier; /** * Returns a suggested decimal precision for fixed point notation given the specified numeric step value. * * @param step The step represents the minimum absolute difference between values that will be formatted. * (This assumes that the values to be formatted are also multiples of step.) */ export function precisionFixed(step: number): number; /** * Returns a suggested decimal precision for use with locale.formatPrefix given the specified * numeric step and reference value. * * @param step The step represents the minimum absolute difference between values that will be formatted. * (This assumes that the values to be formatted are also multiples of step.) * @param value Reference value determines which SI prefix will be used. */ export function precisionPrefix(step: number, value: number): number; /** * Returns a suggested decimal precision for format types that round to significant digits * given the specified numeric step and max values. * * @param step The step represents the minimum absolute difference between values that will be formatted. * (This assumes that the values to be formatted are also multiples of step.) * @param max max represents the largest absolute value that will be formatted. */ export function precisionRound(step: number, max: number): number; // Type definitions for D3JS d3-geo module v1.2.4 // Project: https://github.com/d3/d3-geo/ // Definitions by: Hugues Stefanski , Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// // ---------------------------------------------------------------------- // Shared Interfaces and Types // ---------------------------------------------------------------------- /** * A basic geometry for a sphere, which is supported by d3-geo * beyond the GeoJSON geometries. */ export interface GeoSphere { type: 'Sphere'; } /** * Type Alias for GeoJSON Geometry Object and GeoSphere additional * geometry supported by d3-geo */ export type GeoGeometryObjects = GeoJSON.GeometryObject | GeoSphere; /** * A GeoJSON-style GeometryCollection which supports GeoJSON geometry objects * and additionally GeoSphere */ export interface ExtendedGeometryCollection { type: string; bbox?: number[]; crs?: GeoJSON.CoordinateReferenceSystem; geometries: GeometryType[]; } /** * A GeoJSON-style Feature which support features built on GeoJSON GeometryObjects * or GeoSphere */ export interface ExtendedFeature extends GeoJSON.GeoJsonObject { geometry: GeometryType; properties: Properties; id?: string; } /** * A GeoJSON-style FeatureCollection which supports GeoJSON features * and features built on GeoSphere */ export interface ExtendedFeatureCollection> extends GeoJSON.GeoJsonObject { features: FeatureType[]; } /** * Type Alias for permissible objects which can be used with d3-geo * methods */ export type GeoPermissibleObjects = GeoGeometryObjects | ExtendedGeometryCollection | ExtendedFeature | ExtendedFeatureCollection>; // ---------------------------------------------------------------------- // Spherical Math // ---------------------------------------------------------------------- /**Returns the spherical area of the specified GeoJSON feature in steradians. */ export function geoArea(feature: ExtendedFeature): number; export function geoArea(feature: ExtendedFeatureCollection>): number; export function geoArea(feature: GeoGeometryObjects): number; export function geoArea(feature: ExtendedGeometryCollection): number; /**Returns the spherical bounding box for the specified GeoJSON feature. The bounding box is represented by a two-dimensional array: [[left, bottom], [right, top]], where left is the minimum longitude, bottom is the minimum latitude, right is maximum longitude, and top is the maximum latitude. All coordinates are given in degrees. */ export function geoBounds(feature: ExtendedFeature): [[number, number], [number, number]]; export function geoBounds(feature: ExtendedFeatureCollection>): [[number, number], [number, number]]; export function geoBounds(feature: GeoGeometryObjects): [[number, number], [number, number]]; export function geoBounds(feature: ExtendedGeometryCollection): [[number, number], [number, number]]; /**Returns the spherical centroid of the specified GeoJSON feature. See also path.centroid, which computes the projected planar centroid.*/ export function geoCentroid(feature: ExtendedFeature): [number, number]; export function geoCentroid(feature: ExtendedFeatureCollection>): [number, number]; export function geoCentroid(feature: GeoGeometryObjects): [number, number]; export function geoCentroid(feature: ExtendedGeometryCollection): [number, number]; /**Returns the great-arc distance in radians between the two points a and b. Each point must be specified as a two-element array [longitude, latitude] in degrees. */ export function geoDistance(a: [number, number], b: [number, number]): number; /**Returns the great-arc length of the specified GeoJSON feature in radians.*/ export function geoLength(feature: ExtendedFeature): number; export function geoLength(feature: ExtendedFeatureCollection>): number; export function geoLength(feature: GeoGeometryObjects): number; export function geoLength(feature: ExtendedGeometryCollection): number; /**Returns an interpolator function given two points a and b. Each point must be specified as a two-element array [longitude, latitude] in degrees. */ export function geoInterpolate(a: [number, number], b: [number, number]): (t: number) => [number, number]; export interface GeoRotation { (point: [number, number]): [number, number]; invert(point: [number, number]): [number, number]; } /**Returns a rotation function for the given angles, which must be a two- or three-element array of numbers [lambda, phi, gamma] specifying the rotation angles in degrees about each spherical axis. */ export function geoRotation(angles: [number, number] | [number, number, number]): GeoRotation; // ---------------------------------------------------------------------- // Spherical Shapes // ---------------------------------------------------------------------- // geoCircle ============================================================ export interface GeoCircleGenerator { /**Returns a new GeoJSON geometry object of type “Polygon” approximating a circle on the surface of a sphere, with the current center, radius and precision. */ (this: This, d?: Datum, ...args: any[]): GeoJSON.Polygon; center(): ((this: This, d: Datum, ...args: any[]) => [number, number]); center(center: [number, number]): this; center(center: ((this: This, d: Datum, ...args: any[]) => [number, number])): this; radius(): ((this: This, d: Datum, ...args: any[]) => number); radius(radius: number): this; radius(radius: ((this: This, d: Datum, ...args: any[]) => number)): this; precision(): ((this: This, d: Datum, ...args: any[]) => number); precision(precision: number): this; precision(precision: (this: This, d: Datum, ...args: any[]) => number): this; } export function geoCircle(): GeoCircleGenerator; export function geoCircle(): GeoCircleGenerator; export function geoCircle(): GeoCircleGenerator; // geoGraticule ============================================================ export interface GeoGraticuleGenerator { /**Returns a GeoJSON MultiLineString geometry object representing all meridians and parallels for this graticule. */ (): GeoJSON.MultiLineString; lines(): GeoJSON.LineString[]; outline(): GeoJSON.Polygon; extent(): [[number, number], [number, number]]; extent(extent: [[number, number], [number, number]]): this; extentMajor(): [[number, number], [number, number]]; extentMajor(extent: [[number, number], [number, number]]): this; extentMinor(): [[number, number], [number, number]]; extentMinor(extent: [[number, number], [number, number]]): this; step(): [number, number]; step(step: [number, number]): this; stepMajor(): [number, number]; stepMajor(step: [number, number]): this; stepMinor(): [number, number]; stepMinor(step: [number, number]): this; precision(): number; precision(angle: number): this; } export function geoGraticule(): GeoGraticuleGenerator; // ---------------------------------------------------------------------- // Projections // ---------------------------------------------------------------------- export interface GeoStream { lineEnd(): void; lineStart(): void; point(x: number, y: number, z?: number): void; polygonEnd(): void; polygonStart(): void; sphere?(): void; } export interface GeoStreamWrapper { stream(stream: GeoStream): GeoStream; } export interface GeoRawProjection { (longitude: number, latitude: number): [number, number]; invert?(x: number, y: number): [number, number]; } export interface GeoProjection extends GeoStreamWrapper { /**Returns a new array x, y representing the projected point of the given point. The point must be specified as a two-element array [longitude, latitude] in degrees. */ (point: [number, number]): [number, number] | null; center(): [number, number]; center(point: [number, number]): this; clipAngle(): number | null; clipAngle(angle: null): this; clipAngle(angle: number): this; clipExtent(): [[number, number], [number, number]] | null; clipExtent(extent: null): this; clipExtent(extent: [[number, number], [number, number]]): this; /**Sets the projection’s scale and translate to fit the specified GeoJSON object in the center of the given extent. */ fitExtent(extent: [[number, number], [number, number]], object: ExtendedFeature): this; fitExtent(extent: [[number, number], [number, number]], object: ExtendedFeatureCollection>): this; fitExtent(extent: [[number, number], [number, number]], object: GeoGeometryObjects): this; fitExtent(extent: [[number, number], [number, number]], object: ExtendedGeometryCollection): this; /**A convenience method for projection.fitExtent where the top-left corner of the extent is [0,0]. */ fitSize(size: [number, number], object: ExtendedFeature): this; fitSize(size: [number, number], object: ExtendedFeatureCollection>): this; fitSize(size: [number, number], object: GeoGeometryObjects): this; fitSize(size: [number, number], object: ExtendedGeometryCollection): this; /**Returns a new array [longitude, latitude] in degrees representing the unprojected point of the given projected point. */ invert?(point: [number, number]): [number, number] | null; precision(): number; precision(precision: number): this; rotate(): [number, number, number]; rotate(angles: [number, number] | [number, number, number]): this; scale(): number; scale(scale: number): this; translate(): [number, number]; translate(point: [number, number]): this; } export interface GeoConicProjection extends GeoProjection { parallels(value: [number, number]): this; parallels(): [number, number]; } // geoPath ============================================================== export interface GeoContext { arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; beginPath(): void; closePath(): void; lineTo(x: number, y: number): void; moveTo(x: number, y: number): void; } export interface GeoPath { (this: This, object: DatumObject, ...args: any[]): string; area(object: DatumObject): number; bounds(object: DatumObject): [[number, number], [number, number]]; centroid(object: DatumObject): [number, number]; context(): C | null; context(context: GeoContext | null): this; /** * Get the current projection. The generic parameter can be used to cast the result to the * correct, known type of the projection, e.g. GeoProjection or GeoConicProjection. Otherwise, * the return type defaults to the minimum type requirement for a projection which * can be passed into a GeoPath. */ projection

(): P | null; /** * Set the projection to the identity projection */ projection(projection: null): this; /** * Set the projection to be used with the geo path generator. */ projection(projection: GeoProjection): this; /** * Set the projection to be used with the geo path generator to a custom projection. * Custom projections must minimally contain a stream method. */ projection(projection: GeoStreamWrapper): this; pointRadius(): (this: This, object: DatumObject, ...args: any[]) => number; pointRadius(value: number): this; pointRadius(value: (this: This, object: DatumObject, ...args: any[]) => number): this; } export function geoPath(): GeoPath; export function geoPath(): GeoPath; export function geoPath(): GeoPath; // Raw Projections ======================================================== export function geoAzimuthalEqualAreaRaw(): GeoRawProjection; export function geoAzimuthalEquidistantRaw(): GeoRawProjection; export function geoConicConformalRaw(phi0: number, phi1: number): GeoRawProjection; export function geoConicEqualAreaRaw(phi0: number, phi1: number): GeoRawProjection; export function geoConicEquidistantRaw(phi0: number, phi1: number): GeoRawProjection; export function geoEquirectangularRaw(): GeoRawProjection; export function geoGnomonicRaw(): GeoRawProjection; export function geoMercatorRaw(): GeoRawProjection; export function geoOrthographicRaw(): GeoRawProjection; export function geoStereographicRaw(): GeoRawProjection; export function geoTransverseMercatorRaw(): GeoRawProjection; // geoProjection ========================================================== export function geoProjection(project: GeoRawProjection): GeoProjection; // geoProjectionMutator ==================================================== export function geoProjectionMutator(factory: (...args: any[]) => GeoRawProjection): () => GeoProjection; // Pre-Defined Projections ================================================= export function geoAlbers(): GeoConicProjection; export function geoAlbersUsa(): GeoProjection; export function geoAzimuthalEqualArea(): GeoProjection; export function geoAzimuthalEquidistant(): GeoProjection; export function geoConicConformal(): GeoConicProjection; export function geoConicEqualArea(): GeoConicProjection; export function geoConicEquidistant(): GeoConicProjection; export function geoEquirectangular(): GeoProjection; export function geoGnomonic(): GeoProjection; export function geoMercator(): GeoProjection; export function geoOrthographic(): GeoProjection; export function geoStereographic(): GeoProjection; export function geoTransverseMercator(): GeoProjection; // geoClipExtent ============================================================= export interface GeoExtent { extent(): [[number, number], [number, number]]; extent(extent: [[number, number], [number, number]]): this; stream(stream: GeoStream): GeoStream; } export function geoClipExtent(): GeoExtent; // ---------------------------------------------------------------------- // Projection Streams // ---------------------------------------------------------------------- // geoTransform(...) ==================================================== export interface GeoTransformPrototype { lineEnd?(this: this & { stream: GeoStream }): void; lineStart?(this: this & { stream: GeoStream }): void; point?(this: this & { stream: GeoStream }, x: number, y: number, z?: number): void; polygonEnd?(this: this & { stream: GeoStream }): void; polygonStart?(this: this & { stream: GeoStream }): void; sphere?(this: this & { stream: GeoStream }): void; } // TODO: Review whether GeoStreamWrapper should be included into return value union type, i.e. ({ stream: (s: GeoStream) => (T & GeoStream & GeoStreamWrapper)})? // It probably should be omitted for purposes of this API. The stream method added to (T & GeoStream) is more of a private member used internally to // implement the Transform factory export function geoTransform(prototype: T): { stream: (s: GeoStream) => (T & GeoStream) }; // geoStream(...) ======================================================= export function geoStream(object: ExtendedFeature, stream: GeoStream): void; export function geoStream(object: ExtendedFeatureCollection>, stream: GeoStream): void; export function geoStream(object: GeoGeometryObjects, stream: GeoStream): void; export function geoStream(object: ExtendedGeometryCollection, stream: GeoStream): void; // Type definitions for D3JS d3-geo-projection module v1.0.3 // Project: https://github.com/d3/d3-geo-projection/ // Definitions by: // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Type definitions for D3JS d3-hexbin module v0.2.0 // Project: https://github.com/d3/d3-hexbin/ // Definitions by: // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Type definitions for D3JS d3-hierarchy module v1.0.2 // Project: https://github.com/d3/d3-hierarchy/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // ----------------------------------------------------------------------- // Hierarchy // ----------------------------------------------------------------------- export interface HierarchyLink { source: HierarchyNode; target: HierarchyNode; } export interface HierarchyNode { data: Datum; readonly depth: number; readonly height: number; parent: HierarchyNode | null; children?: Array>; /** * Aggregated numeric value as calculated by sum(value), * if previously invoked. */ readonly value?: number; /** * Optional Node Id string set by StratifyOperator, if * hierarchical data was created from tabular data using stratify() */ readonly id?: string; ancestors(): Array>; descendants(): Array>; leaves(): Array>; path(target: HierarchyNode): Array>; links(): Array>; sum(value: (d: Datum) => number): this; sort(compare: (a: HierarchyNode, b: HierarchyNode) => number): this; each(func: (node: HierarchyNode) => void): this; eachAfter(func: (node: HierarchyNode) => void): this; eachBefore(func: (node: HierarchyNode) => void): this; copy(): HierarchyNode; } export function hierarchy(data: Datum, children?: (d: Datum) => (Array | null)): HierarchyNode; // ----------------------------------------------------------------------- // Stratify // ----------------------------------------------------------------------- // TODO: Review the comment in the API documentation related to 'reserved properties': id, parentId, children. If this is refering to the element on node, it should be 'parent'? export interface StratifyOperator { (data: Array): HierarchyNode; id(): (d: Datum, i: number, data: Array) => (string | null | '' | undefined); id(id: (d: Datum, i?: number, data?: Array) => (string | null | '' | undefined)): this; parentId(): (d: Datum, i: number, data: Array) => (string | null | '' | undefined); parentId(parentId: (d: Datum, i?: number, data?: Array) => (string | null | '' | undefined)): this; } export function stratify(): StratifyOperator; // ----------------------------------------------------------------------- // Cluster // ----------------------------------------------------------------------- export interface HierarchyPointLink { source: HierarchyPointNode; target: HierarchyPointNode; } export interface HierarchyPointNode { x: number; y: number; data: Datum; readonly depth: number; readonly height: number; parent: HierarchyPointNode | null; children?: Array>; /** * Aggregated numeric value as calculated by sum(value), * if previously invoked. */ readonly value?: number; /** * Optional Node Id string set by StratifyOperator, if * hierarchical data was created from tabular data using stratify() */ readonly id?: string; ancestors(): Array>; descendants(): Array>; leaves(): Array>; path(target: HierarchyPointNode): Array>; links(): Array>; sum(value: (d: Datum) => number): this; sort(compare: (a: HierarchyPointNode, b: HierarchyPointNode) => number): this; each(func: (node: HierarchyPointNode) => void): this; eachAfter(func: (node: HierarchyPointNode) => void): this; eachBefore(func: (node: HierarchyPointNode) => void): this; copy(): HierarchyPointNode; } export interface ClusterLayout { (root: HierarchyNode): HierarchyPointNode; size(): [number, number] | null; size(size: [number, number]): this; nodeSize(): [number, number] | null; nodeSize(size: [number, number]): this; separation(): (a: HierarchyPointNode, b: HierarchyPointNode) => number; separation(separation: (a: HierarchyPointNode, b: HierarchyPointNode) => number): this; } export function cluster(): ClusterLayout; // ----------------------------------------------------------------------- // Tree // ----------------------------------------------------------------------- export interface TreeLayout { (root: HierarchyNode): HierarchyPointNode; size(): [number, number] | null; size(size: [number, number]): this; nodeSize(): [number, number] | null; nodeSize(size: [number, number]): this; separation(): (a: HierarchyPointNode, b: HierarchyPointNode) => number; separation(separation: (a: HierarchyPointNode, b: HierarchyPointNode) => number): this; } export function tree(): TreeLayout; // ----------------------------------------------------------------------- // Treemap // ----------------------------------------------------------------------- export interface HierarchyRectangularLink { source: HierarchyRectangularNode; target: HierarchyRectangularNode; } export interface HierarchyRectangularNode { x0: number; y0: number; x1: number; y1: number; data: Datum; readonly depth: number; readonly height: number; parent: HierarchyRectangularNode | null; children?: Array>; /** * Aggregated numeric value as calculated by sum(value), * if previously invoked. */ readonly value?: number; /** * Optional Node Id string set by StratifyOperator, if * hierarchical data was created from tabular data using stratify() */ readonly id?: string; ancestors(): Array>; descendants(): Array>; leaves(): Array>; path(target: HierarchyRectangularNode): Array>; links(): Array>; sum(value: (d: Datum) => number): this; sort(compare: (a: HierarchyRectangularNode, b: HierarchyRectangularNode) => number): this; each(func: (node: HierarchyRectangularNode) => void): this; eachAfter(func: (node: HierarchyRectangularNode) => void): this; eachBefore(func: (node: HierarchyRectangularNode) => void): this; copy(): HierarchyRectangularNode; } export interface TreemapLayout { (root: HierarchyNode): HierarchyRectangularNode; tile(): (node: HierarchyRectangularNode, x0: number, y0: number, x1: number, y1: number) => void; tile(tile: (node: HierarchyRectangularNode, x0: number, y0: number, x1: number, y1: number) => void): this; size(): [number, number]; size(size: [number, number]): this; round(): boolean; round(round: boolean): this; padding(): (node: HierarchyRectangularNode) => number; padding(padding: number): this; padding(padding: (node: HierarchyRectangularNode) => number): this; paddingInner(): (node: HierarchyRectangularNode) => number; paddingInner(padding: number): this; paddingInner(padding: (node: HierarchyRectangularNode) => number): this; paddingOuter(): (node: HierarchyRectangularNode) => number; paddingOuter(padding: number): this; paddingOuter(padding: (node: HierarchyRectangularNode) => number): this; paddingTop(): (node: HierarchyRectangularNode) => number; paddingTop(padding: number): this; paddingTop(padding: (node: HierarchyRectangularNode) => number): this; paddingRight(): (node: HierarchyRectangularNode) => number; paddingRight(padding: number): this; paddingRight(padding: (node: HierarchyRectangularNode) => number): this; paddingBottom(): (node: HierarchyRectangularNode) => number; paddingBottom(padding: number): this; paddingBottom(padding: (node: HierarchyRectangularNode) => number): this; paddingLeft(): (node: HierarchyRectangularNode) => number; paddingLeft(padding: number): this; paddingLeft(padding: (node: HierarchyRectangularNode) => number): this; } export function treemap(): TreemapLayout; // Tiling functions --------------------------------------------------------------------------------- export function treemapBinary(node: HierarchyRectangularNode, x0: number, y0: number, x1: number, y1: number): void; export function treemapDice(node: HierarchyRectangularNode, x0: number, y0: number, x1: number, y1: number): void; export function treemapSlice(node: HierarchyRectangularNode, x0: number, y0: number, x1: number, y1: number): void; export function treemapSliceDice(node: HierarchyRectangularNode, x0: number, y0: number, x1: number, y1: number): void; // TODO: Test Factory code export interface RatioSquarifyTilingFactory { (node: HierarchyRectangularNode, x0: number, y0: number, x1: number, y1: number): void; ratio(ratio: number): RatioSquarifyTilingFactory; } export var treemapSquarify: RatioSquarifyTilingFactory; export var treemapResquarify: RatioSquarifyTilingFactory; // ----------------------------------------------------------------------- // Partition // ----------------------------------------------------------------------- export interface PartitionLayout { (root: HierarchyNode): HierarchyRectangularNode; size(): [number, number]; size(size: [number, number]): this; round(): boolean; round(round: boolean): this; padding(): number; padding(padding: number): this; } export function partition(): PartitionLayout; // ----------------------------------------------------------------------- // Pack // ----------------------------------------------------------------------- export interface HierarchyCircularLink { source: HierarchyCircularNode; target: HierarchyCircularNode; } export interface HierarchyCircularNode { x: number; y: number; r: number; data: Datum; readonly depth: number; readonly height: number; parent: HierarchyCircularNode | null; children?: Array>; /** * Aggregated numeric value as calculated by sum(value), * if previously invoked. */ readonly value?: number; /** * Optional Node Id string set by StratifyOperator, if * hierarchical data was created from tabular data using stratify() */ readonly id?: string; ancestors(): Array>; descendants(): Array>; leaves(): Array>; path(target: HierarchyCircularNode): Array>; links(): Array>; sum(value: (d: Datum) => number): this; sort(compare: (a: HierarchyCircularNode, b: HierarchyCircularNode) => number): this; each(func: (node: HierarchyCircularNode) => void): this; eachAfter(func: (node: HierarchyCircularNode) => void): this; eachBefore(func: (node: HierarchyCircularNode) => void): this; copy(): HierarchyCircularNode; } export interface PackLayout { (root: HierarchyNode): HierarchyCircularNode; radius(): null | ((node: HierarchyCircularNode) => number); radius(radius: (node: HierarchyCircularNode) => number): this; size(): [number, number]; size(size: [number, number]): this; padding(): (node: HierarchyCircularNode) => number; padding(padding: number): this; padding(padding: (node: HierarchyCircularNode) => number): this; } export function pack(): PackLayout; // ----------------------------------------------------------------------- // Pack Siblings and Enclosure // ----------------------------------------------------------------------- export interface PackCircle { r: number; x?: number; y?: number; } // TODO: Since packSiblings manipulates the circles array in place, technically the x and y properties // are optional on invocation, but will be created after execution for each entry. // For invocation of packEnclose the x and y coordinates are mandatory. It seems easier to just comment // on the mandatory nature, then to create separate interfaces and having to deal with recasting. export function packSiblings(circles: Array): Array; export function packEnclose(circles: Array): { r: number, x: number, y: number }; // Type definitions for D3JS d3-hsv module v0.0.3 // Project: https://github.com/d3/d3-hsv/ // Definitions by: Yuri Feldman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import {Color, RGBColor, ColorSpaceObject, ColorCommonInstance} from '../d3-color'; type ColorSpaceObjectWithHSV = ColorSpaceObject | HSVColor; export interface HSVColorFactory extends Function { (h: number, s: number, v: number, opacity?: number): HSVColor; (cssColorSpecifier: string): HSVColor; (color: HSVColor | ColorSpaceObject | ColorCommonInstance): HSVColor; } export interface HSVColor extends Color { h: number; s: number; v: number; opacity: number; brighter(k?: number): this; darker(k?: number): this; rgb(): RGBColor; } export var hsv: HSVColorFactory; // Type definitions for D3JS d3-interpolate module v1.1.1 // Project: https://github.com/d3/d3-interpolate/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { ColorCommonInstance } from '../d3-color'; // -------------------------------------------------------------------------- // Shared Type Definitions and Interfaces // -------------------------------------------------------------------------- export interface ZoomInterpolator extends Function { (t: number): ZoomView; /** * Recommended duration of zoom transition in ms */ duration: number; } export interface ColorGammaInterpolationFactory extends Function { (a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string); gamma(g: number): ColorGammaInterpolationFactory; } /** * Type zoomView is used to represent a numeric array with three elements. * In order of appearance the elements correspond to: * - cx: x-coordinate of the center of the viewport * - cy: y-coordinate of the center of the viewport * - width: size of the viewport */ export type ZoomView = [number, number, number]; // -------------------------------------------------------------------------- // Interpolation Function Factories // -------------------------------------------------------------------------- export function interpolate(a: any, b: null): ((t: number) => null); export function interpolate(a: number | { valueOf(): number }, b: number): ((t: number) => number); export function interpolate(a: any, b: ColorCommonInstance): ((t: number) => string); export function interpolate(a: Date, b: Date): ((t: number) => Date); export function interpolate(a: string | { toString(): string }, b: string): ((t: number) => string); export function interpolate>(a: Array, b: U): ((t: number) => U); export function interpolate(a: number | { valueOf(): number }, b: { valueOf(): number }): ((t: number) => number); export function interpolate(a: any, b: U): ((t: number) => U); export function interpolate(a: any, b: { [key: string]: any }): ((t: number) => { [key: string]: any }); export function interpolateNumber(a: number | { valueOf(): number }, b: number | { valueOf(): number }): ((t: number) => number); export function interpolateRound(a: number | { valueOf(): number }, b: number | { valueOf(): number }): ((t: number) => number); export function interpolateString(a: string | { toString(): string }, b: string | { toString(): string }): ((t: number) => string); export function interpolateDate(a: Date, b: Date): ((t: number) => Date); export function interpolateArray>(a: Array, b: A): ((t: number) => A); export function interpolateObject(a: any, b: U): ((t: number) => U); export function interpolateObject(a: { [key: string]: any }, b: { [key: string]: any }): ((t: number) => { [key: string]: any }); export function interpolateTransformCss(a: string, b: string): ((t: number) => string); export function interpolateTransformSvg(a: string, b: string): ((t: number) => string); /** * Create Interpolator for zoom views */ export function interpolateZoom(a: ZoomView, b: ZoomView): ZoomInterpolator; export function quantize(interpolator: ((t: number) => T), n: number): Array; // Color interpolation related export var interpolateRgb: ColorGammaInterpolationFactory; export function interpolateRgbBasis(colors: Array): ((t: number) => string); export function interpolateRgbBasisClosed(colors: Array): ((t: number) => string); export function interpolateHsl(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string); export function interpolateHslLong(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string); export function interpolateLab(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string); export function interpolateHcl(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string); export function interpolateHclLong(a: string | ColorCommonInstance, b: string | ColorCommonInstance): ((t: number) => string); export var interpolateCubehelix: ColorGammaInterpolationFactory; export var interpolateCubehelixLong: ColorGammaInterpolationFactory; // Spline related export function interpolateBasis(splineNodes: Array): ((t: number) => number); export function interpolateBasisClosed(splineNodes: Array): ((t: number) => number); // Type definitions for D3JS d3-path module v1.0.1 // Project: https://github.com/d3/d3-path/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface Path { moveTo(x: number, y: number): void; closePath(): void; lineTo(x: number, y: number): void; quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; bezierCurveTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number): void; arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; rect(x: number, y: number, w: number, h: number): void; toString(): string; } export function path(): Path; // Type definitions for D3JS d3-polygon module v1.0.1 // Project: https://github.com/d3/d3-polygon/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * Returns the signed area of the specified polygon. If the vertices of the polygon are in counterclockwise order ( * assuming a coordinate system where the origin ⟨0,0⟩ is in the top-left corner), the returned area is positive; * otherwise it is negative, or zero. * * @param polygon Array of coordinates , and so on. */ export function polygonArea(polygon: Array<[number, number]>): number; /** * Returns the centroid of the specified polygon. * * @param polygon Array of coordinates , and so on. */ export function polygonCentroid(polygon: Array<[number, number]>): [number, number]; /** * Returns the convex hull of the specified points using Andrew’s monotone chain algorithm. * The returned hull is represented as an array containing a subset of the input points arranged in * counterclockwise order. Returns null if points has fewer than three elements. * * @param points Array of coordinates , and so on. */ export function polygonHull(points: Array<[number, number]>): Array<[number, number]> | null; /** * Returns true if and only if the specified point is inside the specified polygon. * * @param polygon Array of coordinates , and so on. * @param point Coordinates of point */ export function polygonContains(polygon: Array<[number, number]>, point: [number, number]): boolean; /** * Returns the length of the perimeter of the specified polygon. * * @param polygon Array of coordinates , and so on. */ export function polygonLength(polygon: Array<[number, number]>): number; // Type definitions for D3JS d3-quadtree module v1.0.1 // Project: https://github.com/d3/d3-quadtree/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * Leaf node of the quadtree. */ export interface QuadtreeLeaf { data: T; next?: QuadtreeLeaf; } /** * Internal nodes of the quadtree are represented as four-element arrays in left-to-right, top-to-bottom order: * * 0 - the top-left quadrant, if any. * 1 - the top-right quadrant, if any. * 2 - the bottom-left quadrant, if any. * 3 - the bottom-right quadrant, if any. * * A child quadrant may be undefined if it is empty. */ export interface QuadtreeInternalNode extends Array | QuadtreeLeaf | undefined> { } export interface Quadtree { x(): (d: T) => number; x(x: (d: T) => number): this; y(): (d: T) => number; y(y: (d: T) => number): this; extent(): [[number, number], [number, number]] | undefined; extent(extend: [[number, number], [number, number]]): this; cover(x: number, y: number): this; add(datum: T): this; addAll(data: Array): this; remove(datum: T): this; removeAll(data: Array): this; copy(): Quadtree; root(): QuadtreeInternalNode | QuadtreeLeaf; data(): Array; size(): number; find(x: number, y: number, radius?: number): T | undefined; visit(callback: (node: QuadtreeInternalNode | QuadtreeLeaf, x0: number, y0: number, x1: number, y1: number) => (void | boolean)): this; visitAfter(callback: (node: QuadtreeInternalNode | QuadtreeLeaf, x0: number, y0: number, x1: number, y1: number) => void): this; } export function quadtree(): Quadtree<[number, number]>; export function quadtree(data: Array<[number, number]>): Quadtree<[number, number]>; export function quadtree(): Quadtree; export function quadtree(data: Array, x?: (d: T) => number, y?: (d: T) => number): Quadtree; // Type definitions for D3JS d3-queue module v3.0.2 // Project: https://github.com/d3/d3-queue/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * A d3-queue queue object as returned by queue(...) */ export interface Queue { /** * Adds the specified asynchronous task callback to the queue, with any optional arguments. * * @param task Task to be executed.The task is a function that will be called when the task should start. It is passed the * specified optional arguments and an additional callback as the last argument; * the callback must be invoked by the task when it finishes. * The task must invoke the callback with two arguments: the error, if any, and the result of the task. * To return multiple results from a single callback, wrap the results in an object or array. * @param args Additional, optional arguments to be passed into deferred task on invocation */ defer(task: (...args: Array) => void, ...args: any[]): this; /** * Aborts any active tasks, invoking each active task’s task.abort function, if any. * Also prevents any new tasks from starting, and immediately invokes the queue.await or * queue.awaitAll callback with an error indicating that the queue was aborted. */ abort(): this; /** * Sets the callback to be invoked when all deferred tasks have finished (individual result arguments). * * @param callback Callback function to be executed, when error occured or all deferred tasks * have completed. The first argument to the callback is the first error that occurred, or null if no error occurred. * If an error occurred, there are no additional arguments to the callback. Otherwise, * the callback is passed each result as an additional argument. */ await(callback: (error: any | null, ...results: Array) => void): this; /** * Sets the callback to be invoked when all deferred tasks have finished (results array). * * @param callback Callback function to be executed, when error occured or all deferred tasks * have completed. The first argument to the callback is the first error that occurred, * or null if no error occurred. If an error occurred, there are no additional arguments to the callback. * Otherwise, the callback is also passed an array of results as the second argument. */ awaitAll(callback: (error: any | null, results?: Array) => void): this; } /** * Construct a new queue with the specified concurrency. If concurrency is not specified, the queue has infinite concurrency. * Otherwise, concurrency is a positive integer. For example, if concurrency is 1, then all tasks will be run in series. * If concurrency is 3, then at most three tasks will be allowed to proceed concurrently; this is useful, for example, * when loading resources in a web browser. * * @param concurrency Maximum number of deferred tasks to execute concurrently. */ export function queue(concurrency?: number): Queue; // Type definitions for D3JS d3-random module v1.0.1 // Project: https://github.com/d3/d3-random/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * Returns a function for generating random numbers with a uniform distribution). * The minimum allowed value of a returned number is min, and the maximum is max. * If min is not specified, it defaults to 0; if max is not specified, it defaults to 1. */ export function randomUniform(min?: number, max?: number): () => number; /** * Returns a function for generating random numbers with a normal (Gaussian) distribution. * The expected value of the generated numbers is mu, with the given standard deviation sigma. * If mu is not specified, it defaults to 0; if sigma is not specified, it defaults to 1. */ export function randomNormal(mu?: number, sigma?: number): () => number; /** * Returns a function for generating random numbers with a log-normal distribution. The expected value of the random variable’s natural logrithm is mu, * with the given standard deviation sigma. If mu is not specified, it defaults to 0; if sigma is not specified, it defaults to 1. */ export function randomLogNormal(mu?: number, sigma?: number): () => number; /** * Returns a function for generating random numbers with a Bates distribution with n independent variables. */ export function randomBates(n: number): () => number; /** * Returns a function for generating random numbers with an Irwin–Hall distribution with n independent variables. */ export function randomIrwinHall(n: number): () => number; /** * Returns a function for generating random numbers with an exponential distribution with the rate lambda; * equivalent to time between events in a Poisson process with a mean of 1 / lambda. */ export function randomExponential(lambda: number): () => number; // Type definitions for D3JS d3-request module v1.0.2 // Project: https://github.com/d3/d3-request/ // Definitions by: Hugues Stefanski , Alex Ford , Boris Yankov , Tom Wanzek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { DSVParsedArray, DSVRowString, DSVRowAny } from '../d3-dsv'; export interface Request { abort(): this; get(): this; get(data: RequestData): this; get(callback: (error: any, d: ResponseData) => void): this; get(data: RequestData, callback: (error: any, d: ResponseData) => void): this; header(name: string): string; header(name: string, value: string | null): this; mimeType(): string | null; mimeType(value: string | null): this; on(type: 'beforesend'): (this: this, xhr: XMLHttpRequest) => void; on(type: 'progress'): (this: this, progressEvent: ProgressEvent) => void; on(type: 'error'): (this: this, error: any) => void; on(type: 'load'): (this: this, data: ResponseData) => void; on(type: string): (this: this, data: any) => void; on(type: string, listener: null): this; on(type: 'beforesend', listener: (this: this, xhr: XMLHttpRequest) => void): this; on(type: 'progress', listener: (this: this, progressEvent: ProgressEvent) => void): this; on(type: 'error', listener: (this: this, error: any) => void): this; on(type: 'load', listener: (this: this, data: ResponseData) => void): this; on(type: string, listener: (this: this, data: any) => void): this; password(): string | null; password(value: string): this; post(): this; post(data: RequestData): this; post(callback: (this: this, error: any, d: ResponseData) => void): this; post(data: RequestData, callback: (this: this, error: any, d: ResponseData) => void): this; response(callback: (this: this, response: XMLHttpRequest) => ResponseData): this; responseType(): string | null; responseType(value: string): this; send(method: string): this; send(method: string, data: RequestData): this; send(method: string, callback: (this: this, error: any | null, d: ResponseData | null) => void): this; send(method: string, data: RequestData, callback: (this: this, error: any | null, d: ResponseData | null) => void): this; timeout(): number; timeout(value: number): this; user(): string | null; user(value: string): this; } export interface DsvRequest extends Request { row(value: (rawRow: DSVRowString, index: number, columns: Array) => ParsedRow): DsvRequest; } export function csv(url: string): DsvRequest; export function csv(url: string, callback: (this: DsvRequest, error: any, d: DSVParsedArray) => void): DsvRequest; export function csv(url: string, row: (rawRow: DSVRowString, index: number, columns: Array) => ParsedRow, callback: (this: DsvRequest, error: any, d: DSVParsedArray) => void): DsvRequest; export function html(url: string): Request; export function html(url: string, callback: (this: Request, error: any, d: DocumentFragment) => void): Request; export function json(url: string): Request; export function json(url: string, callback: (this: Request, error: any, d: ParsedObject) => void): Request; export function request(url: string): Request; export function request(url: string, callback: (this: Request, error: any, d: XMLHttpRequest) => void): Request; export function text(url: string): Request; export function text(url: string, callback: (this: Request, error: any, d: string) => void): Request; export function tsv(url: string): DsvRequest; export function tsv(url: string, callback: (this: DsvRequest, error: any, d: DSVParsedArray) => void): DsvRequest; export function tsv(url: string, row: (rawRow: DSVRowString, index: number, columns: Array) => ParsedRow, callback: (this: DsvRequest, error: any, d: DSVParsedArray) => void): DsvRequest; export function xml(url: string): Request; export function xml(url: string, callback: (this: Request, error: any, d: any) => void): Request; // Type definitions for D3JS d3-sankey module v0.2.0 // Project: https://github.com/d3/d3-sankey/ // Definitions by: // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Type definitions for D3JS d3-scale module v1.0.3 // Project: https://github.com/d3/d3-scale/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { CountableTimeInterval, TimeInterval } from '../d3-time'; // ------------------------------------------------------------------------------- // Shared Types and Interfaces // ------------------------------------------------------------------------------- export interface InterpolatorFactory { (a: T, b: T): ((t: number) => U); } // ------------------------------------------------------------------------------- // Linear Scale Factory // ------------------------------------------------------------------------------- export interface ScaleLinear { (value: number | { valueOf(): number }): Output; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. Otherwise, returns NaN */ invert(value: number | { valueOf(): number }): number; domain(): Array; domain(domain: Array): this; range(): Array; range(range: Array): this; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. */ rangeRound(range: Array): this; clamp(): boolean; clamp(clamp: boolean): ScaleLinear; interpolate(): InterpolatorFactory; interpolate(interpolate: InterpolatorFactory): this; interpolate(interpolate: InterpolatorFactory): ScaleLinear; ticks(count?: number): Array; tickFormat(count?: number, specifier?: string): ((d: number | { valueOf(): number }) => string); nice(count?: number): this; copy(): ScaleLinear; } export function scaleLinear(): ScaleLinear; export function scaleLinear(): ScaleLinear; export function scaleLinear(): ScaleLinear; // ------------------------------------------------------------------------------- // Power Scale Factories // ------------------------------------------------------------------------------- export interface ScalePower { (value: number | { valueOf(): number }): Output; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. Otherwise, returns NaN */ invert(value: number | { valueOf(): number }): number; domain(): Array; domain(domain: Array): this; range(): Array; range(range: Array): this; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. */ rangeRound(range: Array): this; clamp(): boolean; clamp(clamp: boolean): this; interpolate(): InterpolatorFactory; interpolate(interpolate: InterpolatorFactory): this; interpolate(interpolate: InterpolatorFactory): ScalePower; ticks(count?: number): Array; tickFormat(count?: number, specifier?: string): ((d: number | { valueOf(): number }) => string); nice(count?: number): this; copy(): ScalePower; exponent(): number; exponent(exponent: number): this; } export function scalePow(): ScalePower; export function scalePow(): ScalePower; export function scalePow(): ScalePower; export function scaleSqrt(): ScalePower; export function scaleSqrt(): ScalePower; export function scaleSqrt(): ScalePower; // ------------------------------------------------------------------------------- // Logarithmic Scale Factory // ------------------------------------------------------------------------------- export interface ScaleLogarithmic { (value: number | { valueOf(): number }): Output; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. Otherwise, returns NaN */ invert(value: number | { valueOf(): number }): number; domain(): Array; domain(domain: Array): this; range(): Array; range(range: Array): this; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. */ rangeRound(range: Array): this; clamp(): boolean; clamp(clamp: boolean): this; interpolate(): InterpolatorFactory; interpolate(interpolate: InterpolatorFactory): this; interpolate(interpolate: InterpolatorFactory): ScaleLogarithmic; ticks(count?: number): Array; tickFormat(count?: number, specifier?: string): ((d: number | { valueOf(): number }) => string); nice(count?: number): this; copy(): ScaleLogarithmic; base(): number; base(base: number): this; } export function scaleLog(): ScaleLogarithmic; export function scaleLog(): ScaleLogarithmic; export function scaleLog(): ScaleLogarithmic; // ------------------------------------------------------------------------------- // Identity Scale Factory // ------------------------------------------------------------------------------- export interface ScaleIdentity { (value: number | { valueOf(): number }): number; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. Otherwise, returns NaN */ invert(value: number | { valueOf(): number }): number; domain(): Array; domain(domain: Array): this; range(): Array; range(range: Array): this; ticks(count?: number): Array; tickFormat(count?: number, specifier?: string): ((d: number | { valueOf(): number }) => string); nice(count?: number): this; copy(): ScaleIdentity; } export function scaleIdentity(): ScaleIdentity; // ------------------------------------------------------------------------------- // Time Scale Factories // ------------------------------------------------------------------------------- export interface ScaleTime { (value: Date): Output; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. Otherwise, returns NaN */ invert(value: number | { valueOf(): number }): Date; domain(): Array; domain(domain: Array): this; range(): Array; range(range: Array): this; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. */ rangeRound(range: Array): this; clamp(): boolean; clamp(clamp: boolean): this; interpolate(): InterpolatorFactory; interpolate(interpolate: InterpolatorFactory): this; interpolate(interpolate: InterpolatorFactory): ScaleTime; ticks(): Array; ticks(count: number): Array; ticks(interval: TimeInterval): Array; tickFormat(): ((d: Date) => string); tickFormat(count: number, specifier?: string): ((d: Date) => string); tickFormat(interval: TimeInterval, specifier?: string): ((d: Date) => string); nice(): this; nice(count: number): this; nice(interval: CountableTimeInterval, step?: number): this; copy(): ScaleTime; } export function scaleTime(): ScaleTime; export function scaleTime(): ScaleTime; export function scaleTime(): ScaleTime; export function scaleUtc(): ScaleTime; export function scaleUtc(): ScaleTime; export function scaleUtc(): ScaleTime; // ------------------------------------------------------------------------------- // Sequential Scale Factory // ------------------------------------------------------------------------------- export interface ScaleSequential { (value: number | { valueOf(): number }): Output; domain(): [number, number]; domain(domain: [number | { valueOf(): number }, number | { valueOf(): number }]): this; clamp(): boolean; clamp(clamp: boolean): this; interpolator(): ((t: number) => Output); interpolator(interpolator: ((t: number) => Output)): this; interpolator(interpolator: ((t: number) => NewOutput)): ScaleSequential; copy(): ScaleSequential; } export function scaleSequential(interpolator: ((t: number) => Output)): ScaleSequential; // ------------------------------------------------------------------------------- // Color Interpolators for Sequential Scale Factory // ------------------------------------------------------------------------------- export function interpolateViridis(t: number): string; export function interpolateMagma(t: number): string; export function interpolateInferno(t: number): string; export function interpolatePlasma(t: number): string; export function interpolateRainbow(t: number): string; export function interpolateWarm(t: number): string; export function interpolateCool(t: number): string; export function interpolateCubehelixDefault(t: number): string; // ------------------------------------------------------------------------------- // Quantize Scale Factory // ------------------------------------------------------------------------------- export interface ScaleQuantize { (value: number | { valueOf(): number }): Range; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. Otherwise, returns NaN */ invertExtent(value: Range): [number, number]; domain(): [number, number]; domain(domain: [number | { valueOf(): number }, number | { valueOf(): number }]): this; range(): Array; range(range: Array): this; ticks(count?: number): Array; tickFormat(count?: number, specifier?: string): ((d: number | { valueOf(): number }) => string); nice(count?: number): this; copy(): ScaleQuantize; } export function scaleQuantize(): ScaleQuantize; export function scaleQuantize(): ScaleQuantize; // ------------------------------------------------------------------------------- // Quantile Scale Factory // ------------------------------------------------------------------------------- export interface ScaleQuantile { (value: number | { valueOf(): number }): Range; invertExtent(value: Range): [number, number]; domain(): Array; domain(domain: Array): this; range(): Array; range(range: Array): this; quantiles(): Array; copy(): ScaleQuantile; } export function scaleQuantile(): ScaleQuantile; export function scaleQuantile(): ScaleQuantile; // ------------------------------------------------------------------------------- // Threshold Scale Factory // ------------------------------------------------------------------------------- // TODO: review Domain Type, should be naturally orderable export interface ScaleThreshold { (value: Domain): Range; /** * Important: While value should come out of range R, this is method is only applicable to * values that can be coerced to numeric. Otherwise, returns NaN */ invertExtent(value: Range): [Domain, Domain] | [undefined, Domain] | [Domain, undefined] | [undefined, undefined]; domain(): Array; domain(domain: Array): this; range(): Array; range(range: Array): this; copy(): ScaleThreshold; } export function scaleThreshold(): ScaleThreshold; export function scaleThreshold(): ScaleThreshold; // ------------------------------------------------------------------------------- // Ordinal Scale Factory // ------------------------------------------------------------------------------- export interface ScaleOrdinal { (x: Domain): Range; domain(): Array; domain(domain: Array): this; range(): Array; range(range: Array): this; unknown(): Range | { name: 'implicit' }; unknown(value: Range | { name: 'implicit' }): this; copy(): ScaleOrdinal; } export function scaleOrdinal(range?: Array): ScaleOrdinal; export function scaleOrdinal(range?: Array): ScaleOrdinal; export const scaleImplicit: { name: 'implicit' }; // ------------------------------------------------------------------------------- // Band Scale Factory // ------------------------------------------------------------------------------- export interface ScaleBand { (x: Domain): number | undefined; domain(): Array; domain(domain: Array): this; range(): [number, number]; range(range: [number | { valueOf(): number }, number | { valueOf(): number }]): this; rangeRound(range: [number | { valueOf(): number }, number | { valueOf(): number }]): this; round(): boolean; round(round: boolean): this; paddingInner(): number; paddingInner(padding: number): this; paddingOuter(): number; paddingOuter(padding: number): this; /** * Returns the inner padding. */ padding(): number; /** * A convenience method for setting the inner and outer padding to the same padding value. */ padding(padding: number): this; align(): number; align(align: number): this; bandwidth(): number; step(): number; copy(): ScaleBand; } export function scaleBand(): ScaleBand; export function scaleBand(): ScaleBand; // ------------------------------------------------------------------------------- // Point Scale Factory // ------------------------------------------------------------------------------- export interface ScalePoint { (x: Domain): number | undefined; domain(): Array; domain(domain: Array): this; range(): [number, number]; range(range: [number | { valueOf(): number }, number | { valueOf(): number }]): this; rangeRound(range: [number | { valueOf(): number }, number | { valueOf(): number }]): this; round(): boolean; round(round: boolean): this; /** * Returns the current outer padding which defaults to 0. * The outer padding determines the ratio of the range that is reserved for blank space * before the first point and after the last point. */ padding(): number; /** * Sets the outer padding to the specified value which must be in the range [0, 1]. * The outer padding determines the ratio of the range that is reserved for blank space * before the first point and after the last point. */ padding(padding: number): this; align(): number; align(align: number): this; bandwidth(): number; step(): number; copy(): ScalePoint; } export function scalePoint(): ScalePoint; export function scalePoint(): ScalePoint; // ------------------------------------------------------------------------------- // Categorical Color Schemas for Ordinal Scales // ------------------------------------------------------------------------------- export const schemeCategory10: Array; export const schemeCategory20: Array; export const schemeCategory20b: Array; export const schemeCategory20c: Array; // Type definitions for D3JS d3-scale-chromatic module 1.0.2 // Project: https://github.com/d3/d3-scale-chromatic/ // Definitions by: Hugues Stefanski , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // ----------------------------------------------------------------------- // Categorical // ----------------------------------------------------------------------- /**An array of eight categorical colors represented as RGB hexadecimal strings. */ export const schemeAccent: Array; /**An array of eight categorical colors represented as RGB hexadecimal strings. */ export const schemeDark2: Array; /**An array of twelve categorical colors represented as RGB hexadecimal strings. */ export const schemePaired: Array; /**An array of nine categorical colors represented as RGB hexadecimal strings. */ export const schemePastel1: Array; /**An array of eight categorical colors represented as RGB hexadecimal strings. */ export const schemePastel2: Array; /**An array of nine categorical colors represented as RGB hexadecimal strings. */ export const schemeSet1: Array; /**An array of eight categorical colors represented as RGB hexadecimal strings. */ export const schemeSet2: Array; /**An array of twelve categorical colors represented as RGB hexadecimal strings. */ export const schemeSet3: Array; // ----------------------------------------------------------------------- // Diverging // ----------------------------------------------------------------------- /**Given a number value in the range [0,1], returns the corresponding color from the “BrBG” diverging color scheme represented as an RGB string. */ export function interpolateBrBG(value: number): string; /** Given a number t in the range [0,1], returns the corresponding color from the “PRGn” diverging color scheme represented as an RGB string.*/ export function interpolatePRGn(value: number): string; /** Given a number t in the range [0,1], returns the corresponding color from the “PiYG” diverging color scheme represented as an RGB string.*/ export function interpolatePiYG(value: number): string; /** Given a number t in the range [0,1], returns the corresponding color from the “PuOr” diverging color scheme represented as an RGB string.*/ export function interpolatePuOr(value: number): string; /** Given a number t in the range [0,1], returns the corresponding color from the “RdBu” diverging color scheme represented as an RGB string.*/ export function interpolateRdBu(value: number): string; /** Given a number t in the range [0,1], returns the corresponding color from the “RdGy” diverging color scheme represented as an RGB string.*/ export function interpolateRdGy(value: number): string; /** Given a number t in the range [0,1], returns the corresponding color from the “RdYlBu” diverging color scheme represented as an RGB string.*/ export function interpolateRdYlBu(value: number): string; /** Given a number t in the range [0,1], returns the corresponding color from the “RdYlGn” diverging color scheme represented as an RGB string.*/ export function interpolateRdYlGn(value: number): string; /** Given a number t in the range [0,1], returns the corresponding color from the “Spectral” diverging color scheme represented as an RGB string.*/ export function interpolateSpectral(value: number): string; // ----------------------------------------------------------------------- // Sequential // ----------------------------------------------------------------------- /**Given a number t in the range [0,1], returns the corresponding color from the “Blues” sequential color scheme represented as an RGB string. */ export function interpolateBlues(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “Greens” sequential color scheme represented as an RGB string. */ export function interpolateGreens(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “Greys” sequential color scheme represented as an RGB string. */ export function interpolateGreys(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “Oranges” sequential color scheme represented as an RGB string. */ export function interpolateOranges(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “Purples” sequential color scheme represented as an RGB string. */ export function interpolatePurples(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “Reds” sequential color scheme represented as an RGB string. */ export function interpolateReds(value: number): string; // ----------------------------------------------------------------------- // Sequential(Multi-Hue) // ----------------------------------------------------------------------- /**Given a number t in the range [0,1], returns the corresponding color from the “BuGn” sequential color scheme represented as an RGB string. */ export function interpolateBuGn(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “BuPu” sequential color scheme represented as an RGB string. */ export function interpolateBuPu(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “GnBu” sequential color scheme represented as an RGB string. */ export function interpolateGnBu(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “OrRd” sequential color scheme represented as an RGB string. */ export function interpolateOrRd(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “PuBuGn” sequential color scheme represented as an RGB string. */ export function interpolatePuBuGn(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “PuBu” sequential color scheme represented as an RGB string. */ export function interpolatePuBu(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “PuRd” sequential color scheme represented as an RGB string. */ export function interpolatePuRd(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “RdPu” sequential color scheme represented as an RGB string. */ export function interpolateRdPu(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “YlGnBu” sequential color scheme represented as an RGB string. */ export function interpolateYlGnBu(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “YlGn” sequential color scheme represented as an RGB string. */ export function interpolateYlGn(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “YlOrBr” sequential color scheme represented as an RGB string. */ export function interpolateYlOrBr(value: number): string; /**Given a number t in the range [0,1], returns the corresponding color from the “YlOrRd” sequential color scheme represented as an RGB string. */ export function interpolateYlOrRd(value: number): string; // Type definitions for D3JS d3-selection module v1.0.2 // Project: https://github.com/d3/d3-selection/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // -------------------------------------------------------------------------- // Shared Type Definitions and Interfaces // -------------------------------------------------------------------------- /** * BaseType serves as an alias for the 'minimal' data type which can be selected * without 'd3-selection' trying to use properties internally which would otherwise not * be supported. */ export type BaseType = Element | EnterElement | Window; // export type BaseType = any; // Alternative, very permissive BaseType specification for edge cases export interface ArrayLike { length: number; item(index: number): T; [index: number]: T; } export interface EnterElement { ownerDocument: Document; namespaceURI: string; appendChild(newChild: Node): Node; insertBefore(newChild: Node, refChild: Node): Node; querySelector(selectors: string): Element; querySelectorAll(selectors: string): NodeListOf; } /** * Container element type usable for mouse/touch functions */ export type ContainerElement = HTMLElement | SVGSVGElement | SVGGElement; /** * Type for optional parameters map, when dispatching custom events * on a selection */ export type CustomEventParameters = { /** * If true, the event is dispatched to ancestors in reverse tree order */ bubbles: boolean; /** * If true, event.preventDefault is allowed */ cancelable: boolean; /** * Any custom data associated with the event */ detail: any; } /** * Callback type for selections and transitions */ export type ValueFn = (this: Element, datum: Datum, index: number, groups: Array | ArrayLike) => Result; /** * TransitionLike is a helper interface to represent a quasi-Transition, without specifying the full Transition interface in this file. * For example, whereever d3-zoom allows a Transition to be passed in as an argument, it internally immediately invokes its `selection()` * method to retrieve the underlying Selection object before proceeding. * d3-brush uses a subset of Transition methods internally. * The use of this interface instead of the full imported Transition interface is [referred] to achieve * two things: * (1) the d3-transition module may not be required by a projects use case, * (2) it avoid avoids possible complications from 'module augmentation' from d3-transition to Selection. */ export interface TransitionLike { selection(): Selection; on(type: string, listener: null): TransitionLike; on(type: string, listener: ValueFn): TransitionLike; tween(name: string, tweenFn: null): TransitionLike; tween(name: string, tweenFn: ValueFn void)>): TransitionLike; } // -------------------------------------------------------------------------- // All Selection related interfaces and function // -------------------------------------------------------------------------- // NB: Note that, d3.select does not generate the same parent element, when targeting the same DOM element with string selector // or node element export function select(selector: string): Selection; export function select(node: GElement): Selection; export function selectAll(): Selection; // _groups are set to empty array, first generic type is set to null by convention export function selectAll(selector: null): Selection; // _groups are set to empty array, first generic type is set to null by convention export function selectAll(selector: string): Selection; export function selectAll(nodes: GElement[]): Selection; export function selectAll(nodes: ArrayLike): Selection; interface Selection { // Sub-selection ------------------------- select(selector: string): Selection; select(selector: null): Selection; // _groups are set to empty array, first generic type is set to null by convention select(selector: ValueFn): Selection; selectAll(): Selection; // _groups are set to empty array, first generic type is set to null by convention selectAll(selector: null): Selection; // _groups are set to empty array, first generic type is set to null by convention selectAll(selector: string): Selection; selectAll(selector: ValueFn | ArrayLike>): Selection; // Modifying ------------------------------- attr(name: string): string; attr(name: string, value: null): this; attr(name: string, value: string | number | boolean): this; attr(name: string, value: ValueFn): this; classed(name: string): boolean; classed(name: string, value: boolean): this; classed(name: string, value: ValueFn): this; style(name: string): string; style(name: string, value: null): this; style(name: string, value: string | number | boolean, priority?: null | 'important'): this; style(name: string, value: ValueFn, priority?: null | 'important'): this; property(name: string): any; /** * Look up a local variable on the first node of this selection. Note that this is not equivalent to `local.get(selection.node())` in that it will not look up locals set on the parent node(s). * * @param name The `d3.local` variable to look up. */ property(name: Local): T | undefined; property(name: string, value: ValueFn): this; property(name: string, value: null): this; property(name: string, value: any): this; /** * Store a value in a `d3.local` variable. This is equivalent to `selection.each(function (d, i, g) { name.set(this, value.call(this, d, i, g)); })` but more concise. * * @param name A `d3.local` variable * @param value A callback that returns the value to store */ property(name: Local, value: ValueFn): this; /** * Store a value in a `d3.local` variable for each node in the selection. This is equivalent to `selection.each(function () { name.set(this, value); })` but more concise. * * @param name A `d3.local` variable * @param value A callback that returns the value to store */ property(name: Local, value: T): this; text(): string; text(value: string | number | boolean): this; text(value: ValueFn): this; html(): string; html(value: string): this; html(value: ValueFn): this; append(type: string): Selection; append(type: ValueFn): Selection; insert(type: string, before: string): Selection; insert(type: ValueFn, before: string): Selection; insert(type: string, before: ValueFn): Selection; insert(type: ValueFn, before: ValueFn): Selection; /** * Removes the selected elements from the document. * Returns this selection (the removed elements) which are now detached from the DOM. */ remove(): this; merge(other: Selection): Selection; filter(selector: string): this; filter(selector: ValueFn): this; sort(comparator?: (a: Datum, b: Datum) => number): this; order(): this; raise(): this; lower(): this; // Data Join --------------------------------- datum(): Datum; datum(value: null): Selection; datum(value: ValueFn): Selection; datum(value: NewDatum): Selection; data(): Datum[]; data(data: Array, key?: ValueFn): Selection; data(data: ValueFn>, key?: ValueFn): Selection; enter(): Selection; // The type Datum on the exit items is actually of the type prior to calling data(...), as by definition, no new data of type NewDatum exists for these // elements. Due to the chaining, .data(...).exit(...), however, the definition would imply that the exit group elements have assumed the NewDatum type. // This seems to imply the following workaroud: Recast the exit Selection to OldDatum, if needed, or ommit and allow exit group elements to be of type any. exit(): Selection; // Event Handling ------------------- on(type: string): ValueFn; on(type: string, listener: null): this; on(type: string, listener: ValueFn, capture?: boolean): this; dispatch(type: string, parameters?: CustomEventParameters): this; dispatch(type: string, parameters?: ValueFn): this; // Control Flow ---------------------- each(valueFn: ValueFn): this; call(func: (selection: Selection, ...args: any[]) => void, ...args: any[]): this; empty(): boolean; node(): GElement; nodes(): Array; size(): number; } interface SelectionFn extends Function { (): Selection; } export var selection: SelectionFn; // --------------------------------------------------------------------------- // on.js event and customEvent related // --------------------------------------------------------------------------- // See issue #3 (https://github.com/tomwanzek/d3-v4-definitelytyped/issues/3) interface BaseEvent { type: string; sourceEvent?: any; // Could be of all sorts of types, too general: BaseEvent | Event | MouseEvent | TouchEvent | ... | OwnCustomEventType; } export var event: any; // Could be of all sorts of types, too general: BaseEvent | Event | MouseEvent | TouchEvent | ... | OwnCustomEventType; export function customEvent(event: BaseEvent, listener: (this: Context, ...args: any[]) => Result, that: Context, ...args: any[]): Result; // --------------------------------------------------------------------------- // mouse.js related // --------------------------------------------------------------------------- /** * Get (x, y)-coordinates of the current event relative to the specified container element. * The coordinates are returned as a two-element array of numbers [x, y]. * @param container */ export function mouse(container: ContainerElement): [number, number]; // --------------------------------------------------------------------------- // touch.js and touches.js related // --------------------------------------------------------------------------- export function touch(container: ContainerElement, identifier: number): [number, number]; export function touch(container: ContainerElement, touches: TouchList, identifier: number): [number, number]; export function touches(container: ContainerElement, touches?: TouchList): Array<[number, number]>; // --------------------------------------------------------------------------- // local.js related // --------------------------------------------------------------------------- export interface Local { /** * Retrieves a local variable stored on the node (or one of its parents). */ get(node: Element): T | undefined; /** * Deletes the value associated with the given node. Values stored on ancestors are not affected, meaning that child nodes will still see inherited values. * * This function returns true if there was a value stored directly on the node, and false otherwise. */ remove(node: Element): boolean; /** * Store a value for this local variable. Calling `.get()` on children of this node will also retrieve the variable's value. */ set(node: Element, value: T): Element; /** * Obtain a string with the internally assigned property name for the local * which is used to store the value on a node */ toString(): string; } /** * Obtain a new local variable */ export function local(): Local; // --------------------------------------------------------------------------- // namespace.js related // --------------------------------------------------------------------------- /** * Type for object literal containing local name with related fully qualified namespace */ export type NamespaceLocalObject = { /** * Fully qualified namespace */ space: string, /** * Name of the local to be namespaced. */ local: string } /** * Obtain an object with properties of fully qualified namespace string and * name of local by parsing a shorthand string "prefix:local". If the prefix * does not exist in the "namespaces" object provided by d3-selection, then * the local name is returned as a simple string. * * @param prefixedLocal A string composed of the namespace prefix and local * name separated by colon, e.g. "svg:text". */ export function namespace(prefixedLocal: string): NamespaceLocalObject | string; // --------------------------------------------------------------------------- // namespaces.js related // --------------------------------------------------------------------------- /** * Type for maps of namespace prefixes to corresponding fully qualified namespace strings */ export type NamespaceMap = { [prefix: string]: string }; /** * Map of namespace prefixes to corresponding fully qualified namespace strings */ export var namespaces: NamespaceMap; // --------------------------------------------------------------------------- // window.js related // --------------------------------------------------------------------------- export function window(DOMNode: Window | Document | Element): Window; // --------------------------------------------------------------------------- // creator.js and matcher.js Complex helper closure generating functions // for explicit bound-context dependent use // --------------------------------------------------------------------------- /** * Returns a closure structure which can be invoked in the 'this' context * of a group element. Depending on the use of namespacing, the NewGElement can be HTMLElement, * SVGElement an extension thereof or an element from a different namespace. * * @param elementName Name of the element to be added */ export function creator(elementName: string): (this: BaseType) => NewGElement; /** * Returns a closure structure which can be invoked in the 'this' context * of a group element. Returns true, if the element in the 'this' context matches the selector * * @param selector A valid selector string */ export function matcher(selector: string): (this: BaseType) => boolean; // ---------------------------------------------------------------------------- // selector.js and selectorAll.js related functions // ---------------------------------------------------------------------------- export function selector(selector: string): (this: BaseType) => DescElement export function selectorAll(selector: string): (this: BaseType) => NodeListOf; // Type definitions for D3JS d3-selection-multi module v1.0.0 // Project: https://github.com/d3/d3-selection-multi/ // Definitions by: Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import {Selection, BaseType, ArrayLike, ValueFn} from '../d3-selection'; import {Transition} from '../d3-transition'; // An object mapping attribute (or style or property) names to value accessors export type ValueMap = { [key: string]: number | string | boolean | null | ValueFn }; declare module '../d3-selection' { export interface Selection { /** * Set multiple attributes on the given selection. Attribute values may be constant or derived from each node and its bound data. * * @param attrs An object used as a map of attribute names to set */ attrs(attrs: ValueMap): this; /** * Derive a map of attributes to be set on the selection. * * @param attrs A function that returns an object of attribute names and values to set. */ attrs(attrs: ValueFn>): this; /** * Set multiple CSS style properties on the given selection. Style properties may be constant or derived from each node and its bound data. * * @param style An object used as a map of style properties to set. * @param priority The CSS priority (either "important" or undefined). */ styles(style: ValueMap, priority?: 'important'): this; /** * Derive a map of style properties to be set on the selection. * * @param style A function that returns an object of style properties and the values to be set. * @param priority The CSS priority (either "important" or undefined) */ styles(style: ValueFn>, priority?: 'important'): this; /** * Set multiple object properties directly on the selection's node(s). Property values may be constants or derived from each node and its bound data. * * @param props An object used as a map of object properties to be set. */ properties(props: ValueMap): this; /** * Derive a map of object properties to be set on the selection's node(s). * * @param props A function that returns an object of properties and their values. */ properties(props: ValueFn>): this; } } declare module '../d3-transition' { export interface Transition { /** * Set multiple attribute values. The transition will animate from the present value to the new value. Attribute values may be constant or derived from each node and its bound data. * * @param attrs An object used as a map of attributes and their values. */ attrs(attrs: ValueMap): this; /** * Derive a map of attribute values to set. * * @param attrs A function returning a map of attributes and their values. */ attrs(attrs: ValueFn>): this; /** * Set multiple style properties. The transition will animate from the present value to the new value. Attribute values may be constant or derived from each node and its bound data. * * @param style A map of style properties and their values * @param priority The CSS priority (either "important" or undefined) */ styles(style: ValueMap, priority?: 'important'): this; /** * Derive a map of style properties to be set. * * @param style A function returning a map of style properties and their values * @param priority The CSS priority (either "important" or undefined) */ styles(style: ValueFn>, priority?: 'important'): this; } } // Type definitions for D3JS d3-shape module v1.0.3 // Project: https://github.com/d3/d3-shape/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // ----------------------------------------------------------------------------------- // Arc Generator // ----------------------------------------------------------------------------------- export interface DefaultArcObject { innerRadius: number; outerRadius: number; startAngle: number; endAngle: number; padAngle: number; } export interface Arc { (this: This, d: Datum, ...args: any[]): string | undefined; centroid(d: Datum, ...args: any[]): [number, number]; innerRadius(): (this: This, d: Datum, ...args: any[]) => number; innerRadius(radius: number): this; innerRadius(radius: (this: This, d: Datum, ...args: any[]) => number): this; outerRadius(): (this: This, d: Datum, ...args: any[]) => number; outerRadius(radius: number): this; outerRadius(radius: (this: This, d: Datum, ...args: any[]) => number): this; cornerRadius(): (this: This, d: Datum, ...args: any[]) => number; cornerRadius(radius: number): this; cornerRadius(radius: (this: This, d: Datum, ...args: any[]) => number): this; startAngle(): (this: This, d: Datum, ...args: any[]) => number; startAngle(angle: number): this; startAngle(angle: (this: This, d: Datum, ...args: any[]) => number): this; endAngle(): (this: This, d: Datum, ...args: any[]) => number; endAngle(angle: number): this; endAngle(angle: (this: This, d: Datum, ...args: any[]) => number): this; padAngle(): (this: This, d: Datum, ...args: any[]) => number; padAngle(angle: number): this; padAngle(angle: (this: This, d: Datum, ...args: any[]) => number): this; context(): CanvasRenderingContext2D | null; context(context: CanvasRenderingContext2D): this; context(context: null): this; } export function arc(): Arc; export function arc(): Arc; export function arc(): Arc; // ----------------------------------------------------------------------------------- // Pie Generator // ----------------------------------------------------------------------------------- export interface PieArcDatum { data: T; value: number; index: number; startAngle: number; endAngle: number; padAngle: number; } export interface Pie { (this: This, data: Array, ...args: any[]): Array>; value(): (d: Datum, i: number, data: Array) => number; value(value: number): this; value(value: (d: Datum, i: number, data: Array) => number): this; sort(): ((a: Datum, b: Datum) => number) | null; sort(comparator: (a: Datum, b: Datum) => number): this; sort(comparator: null): this; sortValues(): ((a: number, b: number) => number) | null; sortValues(comparator: (a: number, b: number) => number): this; sortValues(comparator: null): this; startAngle(): (this: This, data: Array, ...args: any[]) => number; startAngle(angle: number): this; startAngle(angle: (this: This, data: Array, ...args: any[]) => number): this; endAngle(): (this: This, data: Array, ...args: any[]) => number; endAngle(angle: number): this; endAngle(angle: (this: This, data: Array, ...args: any[]) => number): this; padAngle(): (this: This, data: Array, ...args: any[]) => number; padAngle(angle: number): this; padAngle(angle: (this: This, data: Array, ...args: any[]) => number): this; } export function pie(): Pie; export function pie(): Pie; export function pie(): Pie; // ----------------------------------------------------------------------------------- // Line Generators // ----------------------------------------------------------------------------------- export interface Line { (data: Array): string | undefined; x(): (d: Datum, index: number, data: Array) => number; x(x: number): this; x(x: (d: Datum, index: number, data: Array) => number): this; y(): (d: Datum, index: number, data: Array) => number; y(y: number): this; y(y: (d: Datum, index: number, data: Array) => number): this; defined(): (d: Datum, index: number, data: Array) => boolean; defined(defined: boolean): this; defined(defined: (d: Datum, index: number, data: Array) => boolean): this; curve(): CurveFactory | CurveFactoryLineOnly; curve(curve: CurveFactory | CurveFactoryLineOnly): this; context(): CanvasRenderingContext2D | null; context(context: CanvasRenderingContext2D): this; context(context: null): this; } export function line(): Line<[number, number]>; export function line(): Line; export function line(): Line; export interface RadialLine { (data: Array): string | undefined; angle(): (d: Datum, index: number, data: Array) => number; angle(angle: number): this; angle(angle: (d: Datum, index: number, data: Array) => number): this; radius(): (d: Datum, index: number, data: Array) => number; radius(radius: number): this; radius(radius: (d: Datum, index: number, data: Array) => number): this; defined(): (d: Datum, index: number, data: Array) => boolean; defined(defined: boolean): this; defined(defined: (d: Datum, index: number, data: Array) => boolean): this; curve(): CurveFactory | CurveFactoryLineOnly; curve(curve: CurveFactory | CurveFactoryLineOnly): this; context(): CanvasRenderingContext2D | null; context(context: CanvasRenderingContext2D): this; context(context: null): this; } export function radialLine(): RadialLine<[number, number]>; export function radialLine(): RadialLine; // ----------------------------------------------------------------------------------- // Area Generators // ----------------------------------------------------------------------------------- export interface Area { (data: Array): string | undefined; x(): (d: Datum, index: number, data: Array) => number; x(x: number): this; x(x: (d: Datum, index: number, data: Array) => number): this; x0(): (d: Datum, index: number, data: Array) => number; x0(x0: number): this; x0(x0: (d: Datum, index: number, data: Array) => number): this; x1(): ((d: Datum, index: number, data: Array) => number) | null; x1(x: number): this; x1(x: (d: Datum, index: number, data: Array) => number): this; y(): (d: Datum, index: number, data: Array) => number; y(y: number): this; y(y: (d: Datum, index: number, data: Array) => number): this; y0(): (d: Datum, index: number, data: Array) => number; y0(y: number): this; y0(y: (d: Datum, index: number, data: Array) => number): this; y1(): (d: Datum, index: number, data: Array) => number; y1(y: number): this; y1(y: (d: Datum, index: number, data: Array) => number): this; defined(): (d: Datum, index: number, data: Array) => boolean; defined(defined: boolean): this; defined(defined: (d: Datum, index: number, data: Array) => boolean): this; curve(): CurveFactory; curve(curve: CurveFactory): this; context(): CanvasRenderingContext2D | null; context(context: CanvasRenderingContext2D): this; context(context: null): this; lineX0(): Line; lineY0(): Line; lineX1(): Line; lineY1(): Line; } export function area(): Area<[number, number]>; export function area(): Area; export interface RadialArea { (data: Array): string | undefined; angle(): (d: Datum, index: number, data: Array) => number; angle(angle: number): this; angle(angle: (d: Datum, index: number, data: Array) => number): this; startAngle(): (d: Datum, index: number, data: Array) => number; startAngle(angle: number): this; startAngle(angle: (d: Datum, index: number, data: Array) => number): this; endAngle(): ((d: Datum, index: number, data: Array) => number) | null; endAngle(angle: number): this; endAngle(angle: (d: Datum, index: number, data: Array) => number): this; radius(): (d: Datum, index: number, data: Array) => number; radius(radius: number): this; radius(radius: (d: Datum, index: number, data: Array) => number): this; innerRadius(): (d: Datum, index: number, data: Array) => number; innerRadius(radius: number): this; innerRadius(radius: (d: Datum, index: number, data: Array) => number): this; outerRadius(): (d: Datum, index: number, data: Array) => number; outerRadius(radius: number): this; outerRadius(radius: (d: Datum, index: number, data: Array) => number): this; defined(): (d: Datum, index: number, data: Array) => boolean; defined(defined: boolean): this; defined(defined: (d: Datum, index: number, data: Array) => boolean): this; curve(): CurveFactory; curve(curve: CurveFactory): this; context(): CanvasRenderingContext2D | null; context(context: CanvasRenderingContext2D): this; context(context: null): this; lineStartAngle(): RadialLine; lineInnerRadius(): RadialLine; lineEndAngle(): RadialLine; lineOuterRadius(): RadialLine; } export function radialArea(): RadialArea<[number, number]>; export function radialArea(): RadialArea; // ----------------------------------------------------------------------------------- // Curve Factories // ----------------------------------------------------------------------------------- export interface CurveGeneratorLineOnly { lineStart(): void; lineEnd(): void; point(x: number, y: number): void; } export interface CurveFactoryLineOnly { (context: CanvasRenderingContext2D | null): CurveGeneratorLineOnly; } export interface CurveGenerator extends CurveGeneratorLineOnly { areaStart(): void; areaEnd(): void; } export interface CurveFactory { (context: CanvasRenderingContext2D | null): CurveGenerator; } export var curveBasis: CurveFactory; export var curveBasisOpen: CurveFactory; export var curveBasisClosed: CurveFactory; export interface CurveBundleFactory extends CurveFactoryLineOnly { beta(beta: number): this; } export var curveBundle: CurveBundleFactory; export interface CurveCardinalFactory extends CurveFactory { tension(tension: number): this; } export var curveCardinal: CurveCardinalFactory; export var curveCardinalOpen: CurveCardinalFactory; export var curveCardinalClosed: CurveCardinalFactory; export interface CurveCatmullRomFactory extends CurveFactory { alpha(alpha: number): this; } export var curveCatmullRom: CurveCatmullRomFactory; export var curveCatmullRomOpen: CurveCatmullRomFactory; export var curveCatmullRomClosed: CurveCatmullRomFactory; export var curveLinear: CurveFactory; export var curveLinearClosed: CurveFactory; export var curveMonotoneX: CurveFactory; export var curveMonotoneY: CurveFactory; export var curveNatural: CurveFactory; export var curveStep: CurveFactory; export var curveStepAfter: CurveFactory; export var curveStepBefore: CurveFactory; // ----------------------------------------------------------------------------------- // SYMBOLS // ----------------------------------------------------------------------------------- export interface SymbolType { draw(context: CanvasPathMethods, size: number): void; } export interface Symbol { (this: This, d?: Datum, ...args: any[]): undefined | string; size(): (this: This, d: Datum, ...args: any[]) => number; size(size: number): this; size(size: (this: This, d: Datum, ...args: any[]) => number): this; type(): (this: This, d: Datum, ...args: any[]) => SymbolType; type(type: SymbolType): this; type(type: (this: This, d: Datum, ...args: any[]) => SymbolType): this; context(): CanvasRenderingContext2D | null; context(context: CanvasRenderingContext2D): this; context(context: null): this; } export function symbol(): Symbol; export function symbol(): Symbol; export function symbol(): Symbol; export var symbols: Array; export var symbolCircle: SymbolType; export var symbolCross: SymbolType; export var symbolDiamond: SymbolType; export var symbolSquare: SymbolType; export var symbolStar: SymbolType; export var symbolTriangle: SymbolType; export var symbolWye: SymbolType; // ----------------------------------------------------------------------------------- // STACKS // ----------------------------------------------------------------------------------- // SeriesPoint is a [number, number] two-element Array with added // data and index properties related to the data element which formed the basis for the // SeriesPoint export interface SeriesPoint extends Array { 0: number; 1: number; index: number; data: Datum; } export interface Series extends Array> { key: Key; } export interface Stack { (data: Array, ...args: any[]): Array>; keys(): (this: This, data: Array, ...args: any[]) => Array; keys(keys: Array): this; keys(keys: (this: This, data: Array, ...args: any[]) => Array): this; value(): (d: Datum, key: Key, j: number, data: Array) => number; value(value: number): this; value(value: (d: Datum, key: Key, j: number, data: Array) => number): this; order(): (series: Series) => Array; order(order: null): this; order(order: Array): this; order(order: (series: Series) => Array): this; offset(): (series: Series, order: Array) => void; offset(offset: null): this; offset(offset: (series: Series, order: Array) => void): this; } export function stack(): Stack; export function stack(): Stack; export function stack(): Stack; export function stack(): Stack; export function stackOrderAscending(series: Series): Array; export function stackOrderDescending(series: Series): Array export function stackOrderInsideOut(series: Series): Array export function stackOrderNone(series: Series): Array export function stackOrderReverse(series: Series): Array export function stackOffsetExpand(series: Series, order: Array): void; export function stackOffsetNone(series: Series, order: Array): void; export function stackOffsetSilhouette(series: Series, order: Array): void; export function stackOffsetWiggle(series: Series, order: Array): void; // Type definitions for D3JS d3-tile module v0.0.3 // Project: https://github.com/d3/d3-tile/ // Definitions by: // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Type definitions for D3JS d3-time module v1.0.2 // Project: https://github.com/d3/d3-time/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // --------------------------------------------------------------- // Interfaces // --------------------------------------------------------------- export interface TimeInterval { (date: Date): Date; floor(date: Date): Date; round(date: Date): Date; ceil(date: Date): Date; offset(date: Date, step?: number): Date; range(start: Date, stop: Date, step?: number): Date[]; filter(test: (date: Date) => boolean): this; } export interface CountableTimeInterval extends TimeInterval { count(start: Date, end: Date): number; every(step: number): TimeInterval | null; } // --------------------------------------------------------------- // Custom (Countable)Interval Factories // --------------------------------------------------------------- export function timeInterval( floor: (date: Date) => void, offset: (date: Date, step: number) => void, ): TimeInterval; export function timeInterval( floor: (date: Date) => void, offset: (date: Date, step: number) => void, count: (start: Date, end: Date) => number, field?: (date: Date) => number ): CountableTimeInterval; // --------------------------------------------------------------- // Built-In Factories and Date Array Creators // --------------------------------------------------------------- // local time ---------------------------------------------------------- export var timeMillisecond: CountableTimeInterval; export function timeMilliseconds(start: Date, stop: Date, step?: number): Date[]; export var timeSecond: CountableTimeInterval; export function timeSeconds(start: Date, stop: Date, step?: number): Date[]; export var timeMinute: CountableTimeInterval; export function timeMinutes(start: Date, stop: Date, step?: number): Date[]; export var timeHour: CountableTimeInterval; export function timeHours(start: Date, stop: Date, step?: number): Date[]; export var timeDay: CountableTimeInterval; export function timeDays(start: Date, stop: Date, step?: number): Date[]; export var timeWeek: CountableTimeInterval; export function timeWeeks(start: Date, stop: Date, step?: number): Date[]; export var timeSunday: CountableTimeInterval; export function timeSundays(start: Date, stop: Date, step?: number): Date[]; export var timeMonday: CountableTimeInterval; export function timeMondays(start: Date, stop: Date, step?: number): Date[]; export var timeTuesday: CountableTimeInterval; export function timeTuesdays(start: Date, stop: Date, step?: number): Date[]; export var timeWednesday: CountableTimeInterval; export function timeWednesdays(start: Date, stop: Date, step?: number): Date[]; export var timeThursday: CountableTimeInterval; export function timeThursdays(start: Date, stop: Date, step?: number): Date[]; export var timeFriday: CountableTimeInterval; export function timeFridays(start: Date, stop: Date, step?: number): Date[]; export var timeSaturday: CountableTimeInterval; export function timeSaturdays(start: Date, stop: Date, step?: number): Date[]; export var timeMonth: CountableTimeInterval; export function timeMonths(start: Date, stop: Date, step?: number): Date[]; export var timeYear: CountableTimeInterval; export function timeYears(start: Date, stop: Date, step?: number): Date[]; // utc Universal Coordinated Time ---------------------------------------------------------- export var utcMillisecond: CountableTimeInterval; export function utcMilliseconds(start: Date, stop: Date, step?: number): Date[]; export var utcSecond: CountableTimeInterval; export function utcSeconds(start: Date, stop: Date, step?: number): Date[]; export var utcMinute: CountableTimeInterval; export function utcMinutes(start: Date, stop: Date, step?: number): Date[]; export var utcHour: CountableTimeInterval; export function utcHours(start: Date, stop: Date, step?: number): Date[]; export var utcDay: CountableTimeInterval; export function utcDays(start: Date, stop: Date, step?: number): Date[]; export var utcWeek: CountableTimeInterval; export function utcWeeks(start: Date, stop: Date, step?: number): Date[]; export var utcSunday: CountableTimeInterval; export function utcSundays(start: Date, stop: Date, step?: number): Date[]; export var utcMonday: CountableTimeInterval; export function utcMondays(start: Date, stop: Date, step?: number): Date[]; export var utcTuesday: CountableTimeInterval; export function utcTuesdays(start: Date, stop: Date, step?: number): Date[]; export var utcWednesday: CountableTimeInterval; export function utcWednesdays(start: Date, stop: Date, step?: number): Date[]; export var utcThursday: CountableTimeInterval; export function utcThursdays(start: Date, stop: Date, step?: number): Date[]; export var utcFriday: CountableTimeInterval; export function utcFridays(start: Date, stop: Date, step?: number): Date[]; export var utcSaturday: CountableTimeInterval; export function utcSaturdays(start: Date, stop: Date, step?: number): Date[]; export var utcMonth: CountableTimeInterval; export function utcMonths(start: Date, stop: Date, step?: number): Date[]; export var utcYear: CountableTimeInterval; export function utcYears(start: Date, stop: Date, step?: number): Date[]; // Type definitions for d3JS d3-time-format module v2.0.2 // Project: https://github.com/d3/d3-time-format/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * Specification of time locale to use when creating a new TimeLocaleObject */ export interface TimeLocaleDefinition { /** * The date and time (%c) format specifier (e.g., "%a %b %e %X %Y"). */ dateTime: string; /** * The date (%x) format specifier (e.g., "%m/%d/%Y"). */ date: string; /** * The time (%X) format specifier (e.g., "%H:%M:%S"). */ time: string; /** * The A.M. and P.M. equivalents (e.g., ["AM", "PM"]). */ periods: [string, string]; /** * The full names of the weekdays, starting with Sunday. */ days: [string, string, string, string, string, string, string]; /** * The abbreviated names of the weekdays, starting with Sunday. */ shortDays: [string, string, string, string, string, string, string]; /** * The full names of the months (starting with January). */ months: [string, string, string, string, string, string, string, string, string, string, string, string]; /** * the abbreviated names of the months (starting with January). */ shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string]; } export interface TimeLocaleObject { format(specifier: string): (date: Date) => string; parse(specifier: string): (dateString: string) => (Date | null); utcFormat(specifier: string): (date: Date) => string; utcParse(specifier: string): (dateString: string) => (Date | null); } /** * Create a new time-locale-based object which exposes time-formatting * methods for the specified locale definition. */ export function timeFormatLocale(timeLocale: TimeLocaleDefinition): TimeLocaleObject; /** * Create a new time-locale-based object which exposes time-formatting * methods for the specified locale definition. The new time locale definition * will be set as the new default time locale. */ export function timeFormatDefaultLocale(defaultTimeLocale: TimeLocaleDefinition): TimeLocaleObject; export function timeFormat(specifier: string): (date: Date) => string; export function timeParse(specifier: string): (dateString: string) => (Date | null); export function utcFormat(specifier: string): (date: Date) => string; export function utcParse(specifier: string): (dateString: string) => (Date | null); export function isoFormat(date: Date): string; export function isoParse(dateString: string): Date; // Type definitions for d3JS d3-timer module v1.0.2 // Project: https://github.com/d3/d3-timer/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** * Returns the current time as defined by performance.now if available, and Date.now if not. * The current time is updated at the start of a frame; it is thus consistent during the frame, and any timers scheduled during the same frame will be synchronized. * If this method is called outside of a frame, such as in response to a user event, the current time is calculated and then fixed until the next frame, * again ensuring consistent timing during event handling. */ export function now(): number; export interface Timer { /** * Restart a timer with the specified callback and optional delay and time. * This is equivalent to stopping this timer and creating a new timer with the specified arguments, * although this timer retains the original invocation priority. * @param callback A callback function to be invoked and passed in the apparent * elapsed time since the timer became active in milliseconds. * @param [delay] An optional numeric delay in milliseconds (default = 0) relative to time. * @param [time] An optional time in milliseconds relative to which the delay is calculated (default = now). */ restart(callbackFn: (elapsed: number) => void, delay?: number, time?: number): void; /** * Stop the timer. */ stop(): void; } /** * Schedules and returns a new timer, invoking the specified callback repeatedly until the timer is stopped. * The callback is passed the (apparent) elapsed time since the timer became active. * * @param callback A callback function to be invoked and passed in the apparent * elapsed time since the timer became active in milliseconds. * @param [delay] An optional numeric delay in milliseconds (default = 0) relative to time. * @param [time] An optional time in milliseconds relative to which the delay is calculated (default = now). */ export function timer(callback: (elapsed: number) => void, delay?: number, time?: number): Timer; /** * Immediately invoke any eligible timer callbacks */ export function timerFlush(): void; /** * Schedules and returns a new timer, invoking the specified callback. The timer is stopped automatically * on its first callback. The callback is passed the (apparent) elapsed time since the timer became active. * * @param callback A callback function to be invoked and passed in the apparent * elapsed time since the timer became active in milliseconds. * @param [delay] An optional numeric delay in milliseconds (default = 0) relative to time. * @param [time] An optional time in milliseconds relative to which the delay is calculated (default = now). */ export function timeout(callback: (elapsed: number) => void, delay?: number, time?: number): Timer; /** * Schedules and returns a new timer, invoking the specified callback repeatedly every 'delay' milliseconds * until the timer is stopped. * The callback is passed the (apparent) elapsed time since the timer became active. * * @param callback A callback function to be invoked and passed in the apparent * elapsed time since the timer became active in milliseconds. * @param [delay] An optional numeric delay in milliseconds between repeat invocations of the callback. * If not specified, the interval timer behaves like the regular timer. * @param [time] An optional time in milliseconds relative to which the initial delay is calculated (default = now). */ export function interval(callback: (elapsed: number) => void, delay?: number, time?: number): Timer; // Type definitions for D3JS d3-transition module v1.0.1 // Project: https://github.com/d3/d3-transition/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { ArrayLike, BaseType, Selection, ValueFn } from '../d3-selection'; /** * Extend interface 'Selection' by declaration merging with 'd3-selection' */ declare module '../d3-selection' { export interface Selection { interrupt(name?: string): Transition; transition(name?: string): Transition; transition(transition: Transition): Transition; } } export function active(node: GElement, name?: string): Transition | null; export function interrupt(node: BaseType, name?: string): void; export interface Transition { // Sub-selection ------------------------- select(selector: string): Transition; select(selector: ValueFn): Transition; // NB: while the empty selections (null or undefined selector) are defined on the underlying object, they should not be exposed in the type definition API // as they are meaningless on transitions.) // selectAll(): Transition; // _groups are set to empty array, first generic type is set to undefined by convention // selectAll(selector: null): Transition; // _groups are set to empty array, first generic type is set to undefined by convention selectAll(selector: string): Transition; selectAll(selector: ValueFn | ArrayLike>): Transition; selection(): Selection; transition(): Transition; // Modifying ------------------------------- attr(name: string, value: null): this; attr(name: string, value: string | number | boolean): this; attr(name: string, value: ValueFn): this; attrTween(name: string, tweenFn: ValueFn (string | number | boolean)>): this; style(name: string, value: null): this; style(name: string, value: string | number | boolean, priority?: null | 'important'): this; style(name: string, value: ValueFn, priority?: null | 'important'): this; styleTween(name: string, tweenFn: ValueFn (string | number | boolean)>, priority?: null | 'important'): this; text(value: null): this; text(value: string | number | boolean): this; text(value: ValueFn): this; tween(name: string): ValueFn void>; tween(name: string, tweenFn: null): this; tween(name: string, tweenFn: ValueFn void>): this; remove(): this; merge(other: Transition): Transition; filter(filter: string): this; filter(filter: ValueFn): this; // Event Handling ------------------- on(type: string): ValueFn; on(type: string, listener: null): this; on(type: string, listener: ValueFn): this; // Control Flow ---------------------- each(valueFn: ValueFn): this; call(func: (transition: Transition, ...args: any[]) => any, ...args: any[]): this; empty(): boolean; node(): GElement; nodes(): Array; size(): number; // Transition Configuration ---------------------- delay(): number; delay(milliseconds: number): this; duration(): number; duration(milliseconds: number): this; ease(): (normalizedTime: number) => number; ease(easingFn: (normalizedTime: number) => number): this; } export function transition(name: string): Transition; export function transition(transition: Transition): Transition; // Type definitions for D3JS d3-voronoi module v1.0.2 // Project: https://github.com/d3/d3-voronoi/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // -------------------------------------------------------------------------- // Shared Type Definitions and Interfaces // -------------------------------------------------------------------------- /** * The VoronoiPoint interface is defined as a cue that the array is strictly of type [number, number] with two elements * for x and y coordinates. However, it is used as a base for interface definitions, and [number, number] * cannot be extended. */ export interface VoronoiPoint extends Array { 0: number; 1: number; } /** * The VoronoiPointPair interface is defined as a cue that the array is strictly of type [[number, number], [number, number]] with two elements, one * for each point containing the respective x and y coordinates. However, it is used as a base for interface definitions, and * [[number, number], [number, number]] cannot be extended. */ export interface VoronoiPointPair extends Array<[number, number]> { 0: [number, number]; 1: [number, number]; } export interface VoronoiPolygon extends Array<[number, number]> { data: T; } export type VoronoiTriangle = [T, T, T]; export interface VoronoiSite extends VoronoiPoint { index: number; data: T; } export interface VoronoiCell { site: VoronoiSite; halfEdges: Array; } export interface VoronoiEdge extends VoronoiPointPair { left: VoronoiSite; right: VoronoiSite | null; } export interface VoronoiLink { source: T; target: T; } export interface VoronoiLayout { (data: Array): VoronoiDiagram; x(): (d: T) => number; x(x: (d: T) => number): this; y(): (d: T) => number; y(y: (d: T) => number): this; extent(): [[number, number], [number, number]] | null; extent(extent: [[number, number], [number, number]]): this; size(): [number, number] | null; size(size: [number, number]): this; polygons(data: Array): Array>; triangles(data: Array): Array>; links(data: Array): Array>; } export interface VoronoiDiagram { edges: Array>; cells: Array | null>; polygons(): Array>; triangles(): Array>; links(): Array>; } // -------------------------------------------------------------------------- // voronoi Export // -------------------------------------------------------------------------- export function voronoi(): VoronoiLayout<[number, number]>; export function voronoi(): VoronoiLayout; // Type definitions for d3JS d3-zoom module v1.0.3 // Project: https://github.com/d3/d3-zoom/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import { ArrayLike, Selection, TransitionLike, ValueFn } from '../d3-selection'; // -------------------------------------------------------------------------- // Shared Type Definitions and Interfaces // -------------------------------------------------------------------------- /** * ZoomedElementBaseType serves as an alias for the 'minimal' data type which can be selected * without 'd3-zoom' (and related code in 'd3-selection') trying to use properties internally which would otherwise not * be supported. */ type ZoomedElementBaseType = Element; /** * Minimal interface for a continuous scale. * This interface is used as a minimum contract for scale objects * that can be passed into zoomTransform methods rescaleX and rescaleY */ export interface ZoomScale { domain(): Array; domain(domain: Array): this; range(): Array; range(range: Array): this; copy(): ZoomScale; invert(value: number): number; } // -------------------------------------------------------------------------- // Zoom Behavior // -------------------------------------------------------------------------- export interface ZoomBehavior extends Function { (selection: Selection, ...args: any[]): void; transform(selection: Selection, transform: ZoomTransform): void; transform(selection: Selection, transform: ValueFn): void; transform(transition: TransitionLike, transform: ZoomTransform): void; transform(transition: TransitionLike, transform: ValueFn): void; translateBy(selection: Selection, x: number, y: number): void; translateBy(selection: Selection, x: ValueFn, y: number): void; translateBy(selection: Selection, x: number, y: ValueFn): void; translateBy(selection: Selection, x: ValueFn, y: ValueFn): void; translateBy(transition: TransitionLike, x: number, y: number): void; translateBy(transition: TransitionLike, x: ValueFn, y: number): void; translateBy(transition: TransitionLike, x: number, y: ValueFn): void; translateBy(transition: TransitionLike, x: ValueFn, y: ValueFn): void; scaleBy(selection: Selection, k: number): void; scaleBy(selection: Selection, k: ValueFn): void; scaleBy(transition: TransitionLike, k: number): void; scaleBy(transition: TransitionLike, k: ValueFn): void; scaleTo(selection: Selection, k: number): void; scaleTo(selection: Selection, k: ValueFn): void; scaleTo(transition: TransitionLike, k: number): void; scaleTo(transition: TransitionLike, k: ValueFn): void; filter(): ValueFn; filter(filterFn: ValueFn): this; extent(): ValueFn; extent(extent: [[number, number], [number, number]]): this; extent(extent: ValueFn): this; scaleExtent(): [number, number]; scaleExtent(extent: [number, number]): this; translateExtent(): [[number, number], [number, number]]; translateExtent(extent: [[number, number], [number, number]]): this; duration(): number; duration(duration: number): this; on(typenames: string): ValueFn; on(typenames: string, callback: null): this; on(typenames: string, callback: ValueFn): this; } export function zoom(): ZoomBehavior; // -------------------------------------------------------------------------- // Zoom Event // -------------------------------------------------------------------------- export interface D3ZoomEvent { target: ZoomBehavior; type: 'start' | 'zoom' | 'end' | string; // Leave failsafe string type for cases like 'zoom.foo' transform: ZoomTransform; sourceEvent: any; } // -------------------------------------------------------------------------- // Zoom Transforms // -------------------------------------------------------------------------- export interface ZoomTransform { readonly x: number; readonly y: number; readonly k: number; apply(point: [number, number]): [number, number]; applyX(x: number): number; applyY(y: number): number; invert(point: [number, number]): [number, number]; invertX(x: number): number; invertY(y: number): number; rescaleX(xScale: S): S; rescaleY(yScale: S): S; scale(k: number): ZoomTransform; toString(): string; translate(x: number, y: number): ZoomTransform; } export function zoomTransform(node: ZoomedElementBaseType): ZoomTransform; export const zoomIdentity: ZoomTransform;