Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to d3@7.4 #60427

Merged
merged 5 commits into from May 22, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions types/d3-array/d3-array-tests.ts
Expand Up @@ -369,6 +369,13 @@ float64Array = d3Array.rank(mixedObjectArray, accessorMixedObjectToNum);
float64Array = d3Array.rank(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
float64Array = d3Array.rank(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);

float64Array = d3Array.rank(mixedObjectArray, (a: any, b: any) =>
a.date.valueOf() - b.date.valueOf());
float64Array = d3Array.rank(mixedObjectOrUndefinedArray, (a: any, b: any) =>
a?.date.valueOf() - b?.date.valueOf());
float64Array = d3Array.rank(readonlyMixedObjectOrUndefinedArray, (a: any, b: any) =>
a?.date.valueOf() - b?.date.valueOf());

// variance() ------------------------------------------------------------------

numOrUndefined = d3Array.variance(numbersArray);
Expand Down
15 changes: 9 additions & 6 deletions types/d3-array/index.d.ts
Expand Up @@ -6,9 +6,10 @@
// denisname <https://github.com/denisname>
// Hugues Stefanski <https://github.com/ledragon>
// Nathan Bierema <https://github.com/Methuselah96>
// Fil <https://github.com/Fil>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

// Last module patch version validated against: 3.1.0
// Last module patch version validated against: 3.1.6

// --------------------------------------------------------------------------
// Shared Types and Interfaces
Expand Down Expand Up @@ -235,21 +236,23 @@ export function quantileSorted<T>(
): number | undefined;

/**
* Returns an array with the rank of each value in the iterable, i.e. the index of the value when the iterable is sorted.
* Returns an array with the rank of each value in the iterable, i.e. the zero-based index of the value when the iterable is sorted.
* Nullish values are sorted to the end and ranked NaN.
* An optional accessor function may be specified, which is equivalent to calling array.map(accessor) before computing the ranks.
* An optional comparator or accessor function may be specified; the latter is equivalent to calling array.map(accessor) before computing the ranks.
* If comparator is not specified, it defaults to ascending.
* Ties (equivalent values) all get the same rank, defined as the first time the value is found.
*/
export function rank(iterable: Iterable<Numeric | undefined | null>): Float64Array;
/**
* Returns an array with the rank of each value in the iterable, i.e. the index of the value when the iterable is sorted.
* Returns an array with the rank of each value in the iterable, i.e. the zero-based index of the value when the iterable is sorted.
* Nullish values are sorted to the end and ranked NaN.
* An optional accessor function may be specified, which is equivalent to calling array.map(accessor) before computing the ranks.
* An optional comparator or accessor function may be specified; the latter is equivalent to calling array.map(accessor) before computing the ranks.
* If comparator is not specified, it defaults to ascending.
* Ties (equivalent values) all get the same rank, defined as the first time the value is found.
*/
export function rank<T>(
iterable: Iterable<T>,
accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null
accessorOrComparator: ((datum: T, index: number, array: Iterable<T>) => number | undefined | null) | ((a: T, b: T) => number | undefined | null)
): Float64Array;

/**
Expand Down
7 changes: 7 additions & 0 deletions types/d3-color/d3-color-tests.ts
Expand Up @@ -36,10 +36,12 @@ cRGB = cRGB.darker(0.2);
cRGB = cRGB.copy();
cRGB = cRGB.copy({ r: 0.5 });
cRGB = cRGB.rgb();
cRGB = cRGB.clamp();
displayable = cRGB.displayable();
cString = cRGB.toString();
cString = cRGB.hex();
cString = cRGB.formatHex();
cString = cRGB.formatHex8();
cString = cRGB.formatHsl();
cString = cRGB.formatRgb();
console.log('Channels = (r : %d, g: %d, b: %d)', cRGB.r, cRGB.g, cRGB.b);
Expand All @@ -57,10 +59,12 @@ cHSL = cHSL.darker(0.2);
cHSL = cHSL.copy();
cHSL = cHSL.copy({ opacity: 0.5 });
cRGB = cHSL.rgb();
cHSL = cHSL.clamp();
displayable = cHSL.displayable();
cString = cHSL.toString();
cString = cHSL.hex();
cString = cHSL.formatHex();
cString = cHSL.formatHex8();
cString = cHSL.formatHsl();
cString = cHSL.formatRgb();
console.log('Channels = (h : %d, s: %d, l: %d)', cHSL.h, cHSL.s, cHSL.l);
Expand All @@ -86,6 +90,7 @@ displayable = cLab.displayable();
cString = cLab.toString();
cString = cLab.hex();
cString = cLab.formatHex();
cString = cLab.formatHex8();
cString = cLab.formatHsl();
cString = cLab.formatRgb();
console.log('Channels = (l : %d, a: %d, b: %d)', cLab.l, cLab.a, cLab.b);
Expand Down Expand Up @@ -115,6 +120,7 @@ displayable = cHcl.displayable();
cString = cHcl.toString();
cString = cHcl.hex();
cString = cHcl.formatHex();
cString = cHcl.formatHex8();
cString = cHcl.formatHsl();
cString = cHcl.formatRgb();
console.log('Channels = (h : %d, c: %d, l: %d)', cHcl.h, cHcl.c, cHcl.l);
Expand Down Expand Up @@ -146,6 +152,7 @@ displayable = cCubehelix.displayable();
cString = cCubehelix.toString();
cString = cCubehelix.hex();
cString = cCubehelix.formatHex();
cString = cCubehelix.formatHex8();
cString = cCubehelix.formatHsl();
cString = cCubehelix.formatRgb();
console.log('Channels = (h : %d, s: %d, l: %d)', cCubehelix.h, cCubehelix.s, cCubehelix.l);
Expand Down
18 changes: 17 additions & 1 deletion types/d3-color/index.d.ts
Expand Up @@ -6,9 +6,10 @@
// denisname <https://github.com/denisname>
// Hugues Stefanski <https://github.com/ledragon>
// Nathan Bierema <https://github.com/Methuselah96>
// Fil <https://github.com/Fil>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

// Last module patch version validated against: 3.0.1
// Last module patch version validated against: 3.1.0
Fil marked this conversation as resolved.
Show resolved Hide resolved

// ---------------------------------------------------------------------------
// Shared Type Definitions and Interfaces
Expand Down Expand Up @@ -85,6 +86,12 @@ export interface Color {
* For example, RGB channel values greater than 255 are clamped to 255.
*/
formatHex(): string;
/**
* Returns a hexadecimal string representing this color in RGBA space, such as #f7eaba90.
* If this color is not displayable, a suitable displayable color is returned instead.
* For example, RGB channel values greater than 255 are clamped to 255.
*/
formatHex8(): string;
/**
* Returns a string representing this color according to the CSS Color Module Level 3 specification, such as hsl(257, 50%, 80%) or hsla(257, 50%, 80%, 0.2).
* If this color is not displayable, a suitable displayable color is returned instead by clamping S and L channel values to the interval [0, 100].
Expand Down Expand Up @@ -168,6 +175,11 @@ export interface RGBColor extends Color {
* @param values If values is specified, any enumerable own properties of values are assigned to the new returned color.
*/
copy(values?: { r?: number | undefined; g?: number | undefined; b?: number | undefined; opacity?: number | undefined }): this;
/**
* Returns a new RGB color where the r, g, and b channels are clamped to the range [0, 255] and rounded to the nearest integer value,
* and the opacity is clamped to the range [0, 1].
*/
clamp(): this;
}

/**
Expand Down Expand Up @@ -249,6 +261,10 @@ export interface HSLColor extends Color {
* @param values If values is specified, any enumerable own properties of values are assigned to the new returned color.
*/
copy(values?: { h?: number | undefined; s?: number | undefined; l?: number | undefined; opacity?: number | undefined }): this;
/**
* Returns a new HSL color where the h channel is clamped to the range [0, 360), and the s, l, and opacity channels are clamped to the range [0, 1].
*/
clamp(): this;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions types/d3-hierarchy/d3-hierarchy-tests.ts
Expand Up @@ -250,6 +250,13 @@ stratificatorizer = stratificatorizer.parentId((d, i, data) => {

idStringAccessor = stratificatorizer.parentId();

// path(...)

stratificatorizer = stratificatorizer.path((d, i, data) => d.name);

let pathStringAccessor: ((d: TabularHierarchyDatum, i: number, data: TabularHierarchyDatum[]) => string) | null | undefined;
pathStringAccessor = stratificatorizer.path();

// Use Stratify Operator ------------------------------------------------

const stratifiedRootNode: d3Hierarchy.HierarchyNode<TabularHierarchyDatum> = stratificatorizer(tabularData);
Expand Down
18 changes: 17 additions & 1 deletion types/d3-hierarchy/index.d.ts
Expand Up @@ -5,9 +5,10 @@
// Boris Yankov <https://github.com/borisyankov>
// denisname <https://github.com/denisname>
// Nathan Bierema <https://github.com/Methuselah96>
// Fil <https://github.com/Fil>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

// Last module patch version validated against: 3.0.1
// Last module patch version validated against: 3.1.2
Fil marked this conversation as resolved.
Show resolved Hide resolved

// -----------------------------------------------------------------------
// Hierarchy
Expand Down Expand Up @@ -216,6 +217,21 @@ export interface StratifyOperator<Datum> {
* @param parentId The parent id accessor.
*/
parentId(parentId: (d: Datum, i: number, data: Datum[]) => (string | null | '' | undefined)): this;

/**
* Returns the current path accessor, which defaults to undefined.
*/
path(): ((d: Datum, i: number, data: Datum[]) => string) | null | undefined;
/**
* If path is specified, sets the path accessor to the given function and returns this stratify operator.
* Otherwise, returns the current path accessor, which defaults to undefined.
* If a path accessor is set, the id and parentId arguments are ignored,
* and a unix-like hierarchy is computed on the slash-delimited strings
* returned by the path accessor, imputing parent nodes and ids as necessary.
*
* @param path The path accessor.
*/
path(path: ((d: Datum, i: number, data: Datum[]) => string) | null | undefined): this;
}

/**
Expand Down
9 changes: 8 additions & 1 deletion types/d3-shape/d3-shape-tests.ts
Expand Up @@ -1384,15 +1384,22 @@ pathStringMaybe = sym.getPathString({ size: 10, type: 'circle' });

// Test pre-fab symbols ===============================================================

const symbolArray: d3Shape.SymbolType[] = d3Shape.symbols;
let symbolArray: d3Shape.SymbolType[] = d3Shape.symbolsFill;
symbolArray = d3Shape.symbolsStroke;

customSymbol = d3Shape.symbolAsterisk;
customSymbol = d3Shape.symbolCircle;
customSymbol = d3Shape.symbolCross;
customSymbol = d3Shape.symbolDiamond;
customSymbol = d3Shape.symbolDiamond2;
customSymbol = d3Shape.symbolPlus;
customSymbol = d3Shape.symbolSquare;
customSymbol = d3Shape.symbolSquare2;
customSymbol = d3Shape.symbolStar;
customSymbol = d3Shape.symbolTriangle;
customSymbol = d3Shape.symbolTriangle2;
customSymbol = d3Shape.symbolWye;
customSymbol = d3Shape.symbolX;

// -----------------------------------------------------------------------------------
// Test pointRadial
Expand Down