mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
D3 Update to 4.8.0 (d3-array 1.2 [Feature/Fix] and d3-format 1.2 [Feature]) (#15904)
* Update d3-format to v1.2 * [Feature] Adds support for optional "percent" suffix in locale definition. * Added tslint.json file * [d3-array] Update to version 1.2 * [Feature]: Add `tickIncrement(...)` * [Fix]: Fix incorrect return type of tickStep(...). The correct return type is `number` instead of `number[]` * [Chore]: Updated related comments * [d3] Update minor version to 4.8 * Fix d3-format related linting errors.
This commit is contained in:
@@ -389,9 +389,13 @@ mergedArray = d3Array.shuffle(mergedArray, 1, 3);
|
||||
|
||||
numbersArray = d3Array.ticks(1, 10, 5);
|
||||
|
||||
// tickIncrement() ------------------------------------------------------------------
|
||||
|
||||
let numDiff: number = d3Array.tickIncrement(1, 10, 5);
|
||||
|
||||
// tickStep() ------------------------------------------------------------------
|
||||
|
||||
numbersArray = d3Array.tickStep(1, 10, 5);
|
||||
numDiff = d3Array.tickStep(1, 10, 5);
|
||||
|
||||
// transpose() -----------------------------------------------------------------
|
||||
|
||||
|
||||
Vendored
+49
-5
@@ -1,9 +1,9 @@
|
||||
// Type definitions for D3JS d3-array module 1.1
|
||||
// Type definitions for D3JS d3-array module 1.2
|
||||
// Project: https://github.com/d3/d3-array
|
||||
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Last module patch version validated against: 1.1.0
|
||||
// Last module patch version validated against: 1.2.0
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Shared Types and Interfaces
|
||||
@@ -246,14 +246,45 @@ export function shuffle<T>(array: T[], lo?: number, hi?: number): T[];
|
||||
|
||||
/**
|
||||
* Generate an array of approximately count + 1 uniformly-spaced, nicely-rounded values between start and stop (inclusive).
|
||||
* Each value is a power of ten multiplied by 1, 2 or 5. See also d3.tickIncrement, d3.tickStep and linear.ticks.
|
||||
*
|
||||
* Ticks are inclusive in the sense that they may include the specified start and stop values if (and only if) they are exact,
|
||||
* nicely-rounded values consistent with the inferred step. More formally, each returned tick t satisfies start ≤ t and t ≤ stop.
|
||||
*
|
||||
* @param start Start value for ticks
|
||||
* @param stop Stop value for ticks
|
||||
* @param count count + 1 is the approximate number of ticks to be returned by d3.ticks.
|
||||
*/
|
||||
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)
|
||||
* Returns the difference between adjacent tick values if the same arguments were passed to d3.ticks:
|
||||
* a nicely-rounded value that is a power of ten multiplied by 1, 2 or 5.
|
||||
*
|
||||
* Like d3.tickStep, except requires that start is always less than or equal to step, and if the tick step for the given start,
|
||||
* stop and count would be less than one, returns the negative inverse tick step instead.
|
||||
*
|
||||
* This method is always guaranteed to return an integer, and is used by d3.ticks to avoid guarantee that the returned tick values
|
||||
* are represented as precisely as possible in IEEE 754 floating point.
|
||||
*
|
||||
* @param start Start value for ticks
|
||||
* @param stop Stop value for ticks
|
||||
* @param count count + 1 is the approximate number of ticks to be returned by d3.ticks.
|
||||
*/
|
||||
export function tickStep(start: number, stop: number, count: number): number[];
|
||||
export function tickIncrement(start: number, stop: number, count: number): number;
|
||||
|
||||
/**
|
||||
* Returns the difference between adjacent tick values if the same arguments were passed to d3.ticks:
|
||||
* a nicely-rounded value that is a power of ten multiplied by 1, 2 or 5.
|
||||
*
|
||||
* Note that due to the limited precision of IEEE 754 floating point, the returned value may not be exact decimals;
|
||||
* use d3-format to format numbers for human consumption.
|
||||
*
|
||||
* @param start Start value for ticks
|
||||
* @param stop Stop value for ticks
|
||||
* @param count count + 1 is the approximate number of ticks to be returned by d3.ticks.
|
||||
*/
|
||||
export function tickStep(start: number, stop: number, count: number): number;
|
||||
|
||||
/**
|
||||
* Transpose a matrix provided in Array of Arrays format.
|
||||
@@ -298,6 +329,9 @@ export interface HistogramGenerator<Datum, Value extends number | Date> {
|
||||
* Divide the domain uniformly into approximately count bins. IMPORTANT: This threshold
|
||||
* setting approach only works, when the materialized values are numbers!
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @param count The desired number of uniform bins.
|
||||
*/
|
||||
thresholds(count: number): this;
|
||||
@@ -306,6 +340,9 @@ export interface HistogramGenerator<Datum, Value extends number | Date> {
|
||||
* Divides the domain uniformly into approximately count bins. IMPORTANT: This threshold
|
||||
* setting approach only works, when the materialized values are numbers!
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @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.
|
||||
@@ -313,6 +350,10 @@ export interface HistogramGenerator<Datum, Value extends number | Date> {
|
||||
thresholds(count: ThresholdCountGenerator): this;
|
||||
/**
|
||||
* Set the array of values to be used as thresholds in determining the bins.
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @param thresholds Array of threshold values used for binning. The elements must
|
||||
* be of the same type as the materialized values of the histogram.
|
||||
*/
|
||||
@@ -321,6 +362,9 @@ export interface HistogramGenerator<Datum, Value extends number | Date> {
|
||||
* Set a threshold accessor function, which returns the array of values to be used as
|
||||
* thresholds in determining the bins.
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @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.
|
||||
|
||||
@@ -48,7 +48,6 @@ let type: 'e' | 'f' | 'g' | 'r' | 's' | '%' | 'p' | 'b' | 'o' | 'd' | 'x' | 'X'
|
||||
|
||||
let formatString: string = specifier.toString();
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test Precision Suggestors
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -76,13 +75,22 @@ localeDef = {
|
||||
grouping: [3],
|
||||
currency: ["", ""],
|
||||
numerals : ["\u0660", "\u0661", "\u0662", "\u0663", "\u0664", "\u0665", "\u0666", "\u0667", "\u0668", "\u0669"]
|
||||
}
|
||||
};
|
||||
|
||||
localeDef = {
|
||||
decimal: "\u066b",
|
||||
thousands: "\u066c",
|
||||
grouping: [3],
|
||||
currency: ["", ""],
|
||||
percent : "\u202f%"
|
||||
};
|
||||
|
||||
let decimal: string = localeDef.decimal;
|
||||
let thousands: string = localeDef.thousands;
|
||||
let grouping: Array<number> = localeDef.grouping;
|
||||
let grouping: number[] = localeDef.grouping;
|
||||
let currency: [string, string] = localeDef.currency;
|
||||
let numerals: string[] | undefined = localeDef.numerals;
|
||||
let percent: string | undefined = localeDef.percent;
|
||||
|
||||
localeObj = d3Format.formatLocale(localeDef);
|
||||
|
||||
|
||||
Vendored
+7
-5
@@ -1,9 +1,9 @@
|
||||
// Type definitions for D3JS d3-format module 1.1
|
||||
// Type definitions for D3JS d3-format module 1.2
|
||||
// Project: https://github.com/d3/d3-format/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Last module patch version validated against: 1.1.0
|
||||
// Last module patch version validated against: 1.2.0
|
||||
|
||||
/**
|
||||
* Specification of locale to use when creating a new FormatLocaleObject
|
||||
@@ -27,16 +27,19 @@ export interface FormatLocaleDefinition {
|
||||
*/
|
||||
currency: [string, string];
|
||||
/**
|
||||
* An array of ten strings to replace the numerals 0-9.
|
||||
* An optional array of ten strings to replace the numerals 0-9.
|
||||
*/
|
||||
numerals?: string[];
|
||||
/**
|
||||
* An optional symbol to replace the `percent` suffix; the percent suffix (defaults to "%")
|
||||
*/
|
||||
percent?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Format Locale Object
|
||||
*/
|
||||
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.
|
||||
@@ -219,7 +222,6 @@ export function precisionFixed(step: number): number;
|
||||
*/
|
||||
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.
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for D3JS d3 standard bundle 4.7
|
||||
// Type definitions for D3JS d3 standard bundle 4.8
|
||||
// Project: https://github.com/d3/d3
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
Reference in New Issue
Block a user