Skip to content

Commit

Permalink
Fix wrap typo (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored Apr 22, 2024
1 parent 37e050a commit afc2e84
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/nowrap.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function nowrap(node) {
return node.data.warp ?? node.children.length;
return node.data.wrap ?? node.children.length;
}
8 changes: 4 additions & 4 deletions src/treemapFlex.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { nowrap } from "./nowrap.js";

export function treemapFlex() {
let direction = directionSliceDice;
let warp = nowrap;
let wrap = nowrap;

function partition(parent, x0, y0, x1, y1) {
const nodes = parent.children;
const F = nodes.map((d) => d.value ?? 1);
const f = sum(F);
const c = warp(parent);
const c = wrap(parent);
const n = nodes.length;
const m = Math.ceil(n / c);

Expand Down Expand Up @@ -48,8 +48,8 @@ export function treemapFlex() {
return arguments.length ? ((direction = typeof x === "function" ? x : constant(x)), partition) : direction;
};

partition.warp = function (x) {
return arguments.length ? ((warp = typeof x === "function" ? x : constant(+x)), partition) : warp;
partition.wrap = function (x) {
return arguments.length ? ((wrap = typeof x === "function" ? x : constant(+x)), partition) : wrap;
};

return partition;
Expand Down
2 changes: 1 addition & 1 deletion test/data/alphabet.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"children": [
{
"name": "group",
"warp": 2,
"wrap": 2,
"children": [{ "name": "h" }, { "name": "i" }, { "name": "j" }, { "name": "k" }]
},
{ "name": "g" }
Expand Down
14 changes: 7 additions & 7 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const alphabet = JSON.parse(readFileSync("./test/data/alphabet.json"));
it("treemapFlex() has the expected defaults", () => {
const t = treemapFlex();
expect(t.direction()).toBe(directionSliceDice);
expect(t.warp()).toBe(nowrap);
expect(t.wrap()).toBe(nowrap);
});

it("treemapFlex should compute the expected layout", () => {
Expand Down Expand Up @@ -95,9 +95,9 @@ it("treemapFlex should observe the specified functional direction", () => {
]);
});

it("treemapFlex should observe the specified constant warp", () => {
const tile = treemapFlex().warp(2);
expect(tile.warp()()).toBe(2);
it("treemapFlex should observe the specified constant wrap", () => {
const tile = treemapFlex().wrap(2);
expect(tile.wrap()()).toBe(2);

const t = treemap().size([640, 640]).tile(tile).round(true);
const root = t(hierarchy(alphabet));
Expand All @@ -123,10 +123,10 @@ it("treemapFlex should observe the specified constant warp", () => {
]);
});

it("treemapFlex should observe the specified functional warp", () => {
it("treemapFlex should observe the specified functional wrap", () => {
const two = () => 2;
const tile = treemapFlex().warp(two);
expect(tile.warp()).toBe(two);
const tile = treemapFlex().wrap(two);
expect(tile.wrap()).toBe(two);

const t = treemap().size([640, 640]).tile(tile).round(true);
const root = t(hierarchy(alphabet));
Expand Down

0 comments on commit afc2e84

Please sign in to comment.