diff --git a/README.md b/README.md index 1f76573..20e3c18 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,9 @@ Computes the layout for nodes. Per default, the layout tries to keep the * x – the computed x-coordinate of the node position. * y – the computed y-coordinate of the node position. +In addition, row and col are added to each node so that they can be queried and used, for example, +to look up row- or column-specific data. + # grid.points() Configure the grid to treat nodes as points, cf. [d3.scale.ordinal().rangePoints()](https://github.com/mbostock/d3/wiki/Ordinal-Scales#wiki-ordinal_rangePoints). @@ -59,6 +62,14 @@ If nodeSize is set, returns the current nodeSize. If instead [size](#size) is set, returns the actual size of a node after [grid](#grid) has been called. +# grid.xScale() + +Returns the x scale used by this instance. + +# grid.yScale() + +Returns the y scale used by this instance. + ## Examples diff --git a/d3-grid.js b/d3-grid.js index 88f7d04..911d8f3 100644 --- a/d3-grid.js +++ b/d3-grid.js @@ -61,6 +61,9 @@ nodes[i].x = x(col); nodes[i].y = y(row); + + nodes[i].col = col; + nodes[i].row = row; } return nodes; @@ -118,6 +121,10 @@ return grid; } + grid.xScale = function() { return x } + + grid.yScale = function() { return y } + return grid; }; -})(); \ No newline at end of file +})();