Skip to content

Commit

Permalink
Swap "data" and "root" back
Browse files Browse the repository at this point in the history
  • Loading branch information
techniq committed Oct 12, 2017
1 parent 6203766 commit 636b64c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 32 deletions.
24 changes: 18 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,30 @@
"scripts": {
"test": "lerna exec npm install && jest",
"docs": "node ./scripts/docs/index.js",
"prepare-release":
"git checkout master && git pull --rebase origin master && npm run docs && lerna updated",
"prepare-release": "git checkout master && git pull --rebase origin master && npm run docs && lerna updated",
"release": "npm run prepare-release && lerna publish --exact"
},
"jest": {
"projects": ["<rootDir>/packages/*"],
"projects": [
"<rootDir>/packages/*"
],
"collectCoverage": true,
"coverageDirectory": "<rootDir>/coverage",
"coveragePathIgnorePatterns": ["/node_modules/"],
"coverageReporters": ["text", "lcov"]
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"coverageReporters": [
"text",
"lcov"
]
},
"keywords": ["react", "d3", "visualization", "vx", "charts"],
"keywords": [
"react",
"d3",
"visualization",
"vx",
"charts"
],
"author": "@hshoff",
"license": "MIT",
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions packages/vx-hierarchy/src/hierarchies/Cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import DefaultLink from '../HierarchyDefaultLink';
import DefaultNode from '../HierarchyDefaultNode';

Cluster.propTypes = {
data: PropTypes.object.isRequired,
root: PropTypes.object.isRequired,
children: PropTypes.func,
};

export default function Cluster({
top,
left,
className,
data,
root,
size,
nodeSize,
separation,
Expand All @@ -29,7 +29,7 @@ export default function Cluster({
if (nodeSize) cluster.nodeSize(nodeSize);
if (separation) cluster.separation(separation);

const root = cluster(data);
const data = cluster(root);

if (!!children) {
return (
Expand All @@ -38,7 +38,7 @@ export default function Cluster({
left={left}
className={cx('vx-cluster', className)}
>
{children({ root })}
{children({ data })}
</Group>
);
}
Expand All @@ -50,15 +50,15 @@ export default function Cluster({
className={cx('vx-cluster', className)}
>
{linkComponent &&
root.links().map((link, i) => {
data.links().map((link, i) => {
return (
<Group key={`cluster-link-${i}`}>
{React.createElement(linkComponent, { link })}
</Group>
);
})}
{nodeComponent &&
root.descendants().map((node, i) => {
data.descendants().map((node, i) => {
return (
<Group key={`cluster-node-${i}`}>
{React.createElement(nodeComponent, { node })}
Expand Down
10 changes: 5 additions & 5 deletions packages/vx-hierarchy/src/hierarchies/Pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { pack as d3pack } from 'd3-hierarchy';
import DefaultNode from '../HierarchyDefaultNode';

Pack.propTypes = {
data: PropTypes.object.isRequired,
root: PropTypes.object.isRequired,
children: PropTypes.func
};

export default function Pack({
top,
left,
className,
data,
root,
radius,
size,
padding,
Expand All @@ -27,20 +27,20 @@ export default function Pack({
if (radius) pack.radius(radius);
if (padding) pack.padding(padding);

const root = pack(data);
const data = pack(root);

if (!!children) {
return (
<Group top={top} left={left} className={cx('vx-pack', className)}>
{children({ root })}
{children({ data })}
</Group>
);
}

return (
<Group top={top} left={left} className={cx('vx-pack', className)}>
{nodeComponent &&
root.descendants().map((node, i) => {
data.descendants().map((node, i) => {
return (
<Group key={`pack-node-${i}`}>
{React.createElement(nodeComponent, { node })}
Expand Down
10 changes: 5 additions & 5 deletions packages/vx-hierarchy/src/hierarchies/Partition.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { partition as d3partition } from 'd3-hierarchy';
import DefaultNode from '../HierarchyDefaultNode';

Partition.propTypes = {
data: PropTypes.object.isRequired,
root: PropTypes.object.isRequired,
children: PropTypes.func
};

export default function Partition({
top,
left,
className,
data,
root,
size,
round,
padding,
Expand All @@ -27,20 +27,20 @@ export default function Partition({
if (round) partition.round(round);
if (padding) partition.padding(padding);

const root = partition(data);
const data = partition(root);

if (!!children) {
return (
<Group top={top} left={left} className={cx('vx-pack', className)}>
{children({ root })}
{children({ data })}
</Group>
);
}

return (
<Group top={top} left={left} className={cx('vx-pack', className)}>
{nodeComponent &&
root.descendants().map((node, i) => {
data.descendants().map((node, i) => {
return (
<Group key={`pack-node-${i}`}>
{React.createElement(nodeComponent, { node })}
Expand Down
12 changes: 6 additions & 6 deletions packages/vx-hierarchy/src/hierarchies/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import DefaultLink from '../HierarchyDefaultLink';
import DefaultNode from '../HierarchyDefaultNode';

Tree.propTypes = {
data: PropTypes.object.isRequired,
root: PropTypes.object.isRequired,
children: PropTypes.func,
};

export default function Tree({
top,
left,
className,
data,
root,
size,
nodeSize,
separation,
Expand All @@ -29,7 +29,7 @@ export default function Tree({
if (nodeSize) tree.nodeSize(nodeSize);
if (separation) tree.separation(separation);

const root = tree(data);
const data = tree(root);

if (!!children) {
return (
Expand All @@ -38,23 +38,23 @@ export default function Tree({
left={left}
className={cx('vx-tree', className)}
>
{children({ root })}
{children({ data })}
</Group>
);
}

return (
<Group top={top} left={left} className={cx('vx-tree', className)}>
{linkComponent &&
root.links().map((link, i) => {
data.links().map((link, i) => {
return (
<Group key={`tree-link-${i}`}>
{React.createElement(linkComponent, { link })}
</Group>
);
})}
{nodeComponent &&
root.descendants().map((node, i) => {
data.descendants().map((node, i) => {
return (
<Group key={`tree-node-${i}`}>
{React.createElement(nodeComponent, { node })}
Expand Down
8 changes: 4 additions & 4 deletions packages/vx-hierarchy/src/hierarchies/Treemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Treemap({
top,
left,
className,
data,
root,
tile,
size,
round,
Expand All @@ -41,20 +41,20 @@ export default function Treemap({
if (paddingBottom) treemap.paddingBottom(paddingBottom);
if (paddingLeft) treemap.paddingLeft(paddingLeft);

const root = treemap(data);
const data = treemap(root);

if (!!children) {
return (
<Group top={top} left={left} className={cx('vx-treemap', className)}>
{children({ root })}
{children({ data })}
</Group>
);
}

return (
<Group top={top} left={left} className={cx('vx-treemap', className)}>
{nodeComponent &&
root.descendants().map((node, i) => {
data.descendants().map((node, i) => {
return (
<Group key={`treemap-node-${i}`}>
{React.createElement(nodeComponent, { node })}
Expand Down

0 comments on commit 636b64c

Please sign in to comment.