mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[@types/d3/v3] Partition Nodes Children are actually Nodes, not a number (#36179)
* d3 v3 Partition Nodes Childrenare actually See https://github.com/d3/d3-3.x-api-reference/blob/master/Partition-Layout.md#nodes for documentation. * Add test for d3.layout.partition
This commit is contained in:
parent
2d55bb107c
commit
a9a2c2784c
@ -1805,7 +1805,7 @@ namespace forceCollapsable2 {
|
||||
.attr("y1", function (d) { return (d.source as Node).y; } )
|
||||
.attr("x2", function (d) { return (d.target as Node).x; } )
|
||||
.attr("y2", function (d) { return (d.target as Node).y; } );
|
||||
|
||||
|
||||
node.attr("cx", function (d) { return d.x; } )
|
||||
.attr("cy", function (d) { return d.y; } );
|
||||
}
|
||||
@ -2750,4 +2750,33 @@ class BrushAxisTest {
|
||||
.x(colorScale) // Color scale
|
||||
.y(d3.scale.pow());
|
||||
}
|
||||
}
|
||||
|
||||
interface NodeWithText extends d3.layout.partition.Node { t: string; children?: NodeWithText[]; }
|
||||
function testPartition(data: Array<NodeWithText>) {
|
||||
var width = 1000;
|
||||
var height = 1000;
|
||||
|
||||
var div = d3.select('#partition').style('width', width)
|
||||
.style('height', height).style('position', 'relative');
|
||||
var partition = d3.layout.partition().size([width, height]);
|
||||
|
||||
const root: NodeWithText = { t: 'root', children: data};
|
||||
var nodes = partition.nodes(root);
|
||||
div.selectAll('.node').data(nodes).enter()
|
||||
.append('div')
|
||||
.style('position', 'absolute')
|
||||
.style('left', function (d) { return d.x })
|
||||
.style('top', function (d) { return d.y })
|
||||
.style('width', function (d) { return d.dx })
|
||||
.style('height', function (d) { return d.dy })
|
||||
.style('border', '1px solid black')
|
||||
.style('background-color', function (d: NodeWithText) {
|
||||
if (d.t === 'root') {
|
||||
return 'blue'
|
||||
} else {
|
||||
return 'red';
|
||||
}
|
||||
})
|
||||
.text(function (d: NodeWithText) { return d.t; });
|
||||
}
|
||||
5
types/d3/v3/index.d.ts
vendored
5
types/d3/v3/index.d.ts
vendored
@ -3,6 +3,7 @@
|
||||
// Definitions by: Alex Ford <https://github.com/gustavderdrache>
|
||||
// Boris Yankov <https://github.com/borisyankov>
|
||||
// Matthias Jobst <https://github.com/MatthiasJobst>
|
||||
// Mihai Cherej <https://github.com/cronco>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Latest patch version of module validated against: 3.5.17
|
||||
@ -235,7 +236,7 @@ declare namespace d3 {
|
||||
* @param name the element name to append. May be prefixed (see d3.ns.prefix).
|
||||
* @param before the selector to determine position (e.g., ":first-child")
|
||||
*/
|
||||
// https://github.com/d3/d3-3.x-api-reference/blob/master/Selections.md#insert
|
||||
// https://github.com/d3/d3-3.x-api-reference/blob/master/Selections.md#insert
|
||||
insert(name: string, before?: string): Update<Datum>;
|
||||
|
||||
/**
|
||||
@ -3075,7 +3076,7 @@ declare namespace d3 {
|
||||
|
||||
interface Node {
|
||||
parent?: Node;
|
||||
children?: number;
|
||||
children?: Node[];
|
||||
value?: number;
|
||||
depth?: number;
|
||||
x?: number;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user