Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Computes the layout for <i>nodes</i>. Per default, the layout tries to keep the
* x – the computed <i>x</i>-coordinate of the node position.
* y – the computed <i>y</i>-coordinate of the node position.

In addition, <i>row</i> and <i>col</i> are added to each node so that they can be queried and used, for example,
to look up row- or column-specific data.

<a name="points" href="#points">#</a> grid.<b>points</b>()

Configure the grid to treat nodes as points, cf. [d3.scale.ordinal().rangePoints()](https://github.com/mbostock/d3/wiki/Ordinal-Scales#wiki-ordinal_rangePoints).
Expand Down Expand Up @@ -59,6 +62,14 @@ If <i>nodeSize</i> is set, returns the current <i>nodeSize</i>.

If instead [size](#size) is set, returns the actual size of a node <i>after</i> [grid](#grid) has been called.

<a name="xScale" href="#xScale">#</a> grid.<b>xScale</b>()

Returns the x scale used by this instance.

<a name="yScale" href="#yScale">#</a> grid.<b>yScale</b>()

Returns the y scale used by this instance.


## Examples

Expand Down
9 changes: 8 additions & 1 deletion d3-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@

nodes[i].x = x(col);
nodes[i].y = y(row);

nodes[i].col = col;
nodes[i].row = row;
}

return nodes;
Expand Down Expand Up @@ -118,6 +121,10 @@
return grid;
}

grid.xScale = function() { return x }

grid.yScale = function() { return y }

return grid;
};
})();
})();