mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 09:01:45 +08:00
Update d3-hierarchy 1.1/d3 4.5
* [d3-hierarchy] Add `count()` method to hierarchy node interfaces * [d3-hierarchy] Update header to reflect v1.1 minor version * [d3] Bump minor version to 4.5
This commit is contained in:
@@ -125,6 +125,13 @@ hierarchyRootNode = hierarchyRootNode.sum(function (d) { return d.val; });
|
||||
|
||||
num = hierarchyRootNode.value;
|
||||
|
||||
// count() and value ----------------------------------------------------------
|
||||
|
||||
hierarchyRootNode = hierarchyRootNode.count();
|
||||
|
||||
num = hierarchyRootNode.value;
|
||||
|
||||
|
||||
// sort ---------------------------------------------------------------------
|
||||
|
||||
hierarchyRootNode = hierarchyRootNode.sort(function (a, b) {
|
||||
@@ -307,6 +314,12 @@ clusterRootNode = clusterRootNode.sum(function (d) { return d.val; });
|
||||
|
||||
num = clusterRootNode.value;
|
||||
|
||||
// count() and value ----------------------------------------------------------
|
||||
|
||||
clusterRootNode = clusterRootNode.count();
|
||||
|
||||
num = clusterRootNode.value;
|
||||
|
||||
// sort ---------------------------------------------------------------------
|
||||
|
||||
clusterRootNode = clusterRootNode.sort(function (a, b) {
|
||||
@@ -584,6 +597,11 @@ treemapRootNode = treemapRootNode.sum(function (d) { return d.val; });
|
||||
|
||||
num = treemapRootNode.value;
|
||||
|
||||
// count() and value ----------------------------------------------------------
|
||||
|
||||
treemapRootNode = treemapRootNode.count();
|
||||
|
||||
num = treemapRootNode.value;
|
||||
// sort ---------------------------------------------------------------------
|
||||
|
||||
treemapRootNode = treemapRootNode.sort(function (a, b) {
|
||||
@@ -766,6 +784,11 @@ packRootNode = packRootNode.sum(function (d) { return d.val; });
|
||||
|
||||
num = packRootNode.value;
|
||||
|
||||
// count() and value ----------------------------------------------------------
|
||||
|
||||
packRootNode = packRootNode.count();
|
||||
|
||||
num = packRootNode.value;
|
||||
// sort ---------------------------------------------------------------------
|
||||
|
||||
packRootNode = packRootNode.sort(function (a, b) {
|
||||
|
||||
32
d3-hierarchy/index.d.ts
vendored
32
d3-hierarchy/index.d.ts
vendored
@@ -1,8 +1,10 @@
|
||||
// Type definitions for D3JS d3-hierarchy module v1.0.2
|
||||
// Type definitions for D3JS d3-hierarchy module 1.1
|
||||
// Project: https://github.com/d3/d3-hierarchy/
|
||||
// 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.1
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Hierarchy
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -20,7 +22,7 @@ export interface HierarchyNode<Datum> {
|
||||
parent: HierarchyNode<Datum> | null;
|
||||
children?: Array<HierarchyNode<Datum>>;
|
||||
/**
|
||||
* Aggregated numeric value as calculated by sum(value),
|
||||
* Aggregated numeric value as calculated by sum(value) or count(),
|
||||
* if previously invoked.
|
||||
*/
|
||||
readonly value?: number;
|
||||
@@ -35,6 +37,7 @@ export interface HierarchyNode<Datum> {
|
||||
path(target: HierarchyNode<Datum>): Array<HierarchyNode<Datum>>;
|
||||
links(): Array<HierarchyLink<Datum>>;
|
||||
sum(value: (d: Datum) => number): this;
|
||||
count(): this;
|
||||
sort(compare: (a: HierarchyNode<Datum>, b: HierarchyNode<Datum>) => number): this;
|
||||
each(func: (node: HierarchyNode<Datum>) => void): this;
|
||||
eachAfter(func: (node: HierarchyNode<Datum>) => void): this;
|
||||
@@ -43,7 +46,7 @@ export interface HierarchyNode<Datum> {
|
||||
}
|
||||
|
||||
|
||||
export function hierarchy<Datum>(data: Datum, children?: (d: Datum) => (Array<Datum> | null)): HierarchyNode<Datum>;
|
||||
export function hierarchy<Datum>(data: Datum, children?: (d: Datum) => (Datum[] | null)): HierarchyNode<Datum>;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Stratify
|
||||
@@ -53,11 +56,11 @@ export function hierarchy<Datum>(data: Datum, children?: (d: Datum) => (Array<Da
|
||||
|
||||
|
||||
export interface StratifyOperator<Datum> {
|
||||
(data: Array<Datum>): HierarchyNode<Datum>;
|
||||
id(): (d: Datum, i: number, data: Array<Datum>) => (string | null | '' | undefined);
|
||||
id(id: (d: Datum, i?: number, data?: Array<Datum>) => (string | null | '' | undefined)): this;
|
||||
parentId(): (d: Datum, i: number, data: Array<Datum>) => (string | null | '' | undefined);
|
||||
parentId(parentId: (d: Datum, i?: number, data?: Array<Datum>) => (string | null | '' | undefined)): this;
|
||||
(data: Datum[]): HierarchyNode<Datum>;
|
||||
id(): (d: Datum, i: number, data: Datum[]) => (string | null | '' | undefined);
|
||||
id(id: (d: Datum, i?: number, data?: Datum[]) => (string | null | '' | undefined)): this;
|
||||
parentId(): (d: Datum, i: number, data: Datum[]) => (string | null | '' | undefined);
|
||||
parentId(parentId: (d: Datum, i?: number, data?: Datum[]) => (string | null | '' | undefined)): this;
|
||||
}
|
||||
|
||||
export function stratify<Datum>(): StratifyOperator<Datum>;
|
||||
@@ -80,7 +83,7 @@ export interface HierarchyPointNode<Datum> {
|
||||
parent: HierarchyPointNode<Datum> | null;
|
||||
children?: Array<HierarchyPointNode<Datum>>;
|
||||
/**
|
||||
* Aggregated numeric value as calculated by sum(value),
|
||||
* Aggregated numeric value as calculated by sum(value) or count(),
|
||||
* if previously invoked.
|
||||
*/
|
||||
readonly value?: number;
|
||||
@@ -95,6 +98,7 @@ export interface HierarchyPointNode<Datum> {
|
||||
path(target: HierarchyPointNode<Datum>): Array<HierarchyPointNode<Datum>>;
|
||||
links(): Array<HierarchyPointLink<Datum>>;
|
||||
sum(value: (d: Datum) => number): this;
|
||||
count(): this;
|
||||
sort(compare: (a: HierarchyPointNode<Datum>, b: HierarchyPointNode<Datum>) => number): this;
|
||||
each(func: (node: HierarchyPointNode<Datum>) => void): this;
|
||||
eachAfter(func: (node: HierarchyPointNode<Datum>) => void): this;
|
||||
@@ -150,7 +154,7 @@ export interface HierarchyRectangularNode<Datum> {
|
||||
parent: HierarchyRectangularNode<Datum> | null;
|
||||
children?: Array<HierarchyRectangularNode<Datum>>;
|
||||
/**
|
||||
* Aggregated numeric value as calculated by sum(value),
|
||||
* Aggregated numeric value as calculated by sum(value) or count(),
|
||||
* if previously invoked.
|
||||
*/
|
||||
readonly value?: number;
|
||||
@@ -165,6 +169,7 @@ export interface HierarchyRectangularNode<Datum> {
|
||||
path(target: HierarchyRectangularNode<Datum>): Array<HierarchyRectangularNode<Datum>>;
|
||||
links(): Array<HierarchyRectangularLink<Datum>>;
|
||||
sum(value: (d: Datum) => number): this;
|
||||
count(): this;
|
||||
sort(compare: (a: HierarchyRectangularNode<Datum>, b: HierarchyRectangularNode<Datum>) => number): this;
|
||||
each(func: (node: HierarchyRectangularNode<Datum>) => void): this;
|
||||
eachAfter(func: (node: HierarchyRectangularNode<Datum>) => void): this;
|
||||
@@ -258,7 +263,7 @@ export interface HierarchyCircularNode<Datum> {
|
||||
parent: HierarchyCircularNode<Datum> | null;
|
||||
children?: Array<HierarchyCircularNode<Datum>>;
|
||||
/**
|
||||
* Aggregated numeric value as calculated by sum(value),
|
||||
* Aggregated numeric value as calculated by sum(value) or count(),
|
||||
* if previously invoked.
|
||||
*/
|
||||
readonly value?: number;
|
||||
@@ -273,6 +278,7 @@ export interface HierarchyCircularNode<Datum> {
|
||||
path(target: HierarchyCircularNode<Datum>): Array<HierarchyCircularNode<Datum>>;
|
||||
links(): Array<HierarchyCircularLink<Datum>>;
|
||||
sum(value: (d: Datum) => number): this;
|
||||
count(): this;
|
||||
sort(compare: (a: HierarchyCircularNode<Datum>, b: HierarchyCircularNode<Datum>) => number): this;
|
||||
each(func: (node: HierarchyCircularNode<Datum>) => void): this;
|
||||
eachAfter(func: (node: HierarchyCircularNode<Datum>) => void): this;
|
||||
@@ -310,6 +316,6 @@ export interface PackCircle {
|
||||
// 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<Datum extends PackCircle>(circles: Array<Datum>): Array<Datum>;
|
||||
export function packSiblings<Datum extends PackCircle>(circles: Datum[]): Datum[];
|
||||
|
||||
export function packEnclose<Datum extends PackCircle>(circles: Array<Datum>): { r: number, x: number, y: number };
|
||||
export function packEnclose<Datum extends PackCircle>(circles: Datum[]): { r: number, x: number, y: number };
|
||||
|
||||
2
d3/index.d.ts
vendored
2
d3/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for D3JS d3 standard bundle 4.4
|
||||
// Type definitions for D3JS d3 standard bundle 4.5
|
||||
// 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