https://github.com/harrystevens/data2grid
Add a row and a column to a set of data so you can lay it out.
https://github.com/harrystevens/data2grid
Last synced: 18 days ago
JSON representation
Add a row and a column to a set of data so you can lay it out.
- Host: GitHub
- URL: https://github.com/harrystevens/data2grid
- Owner: HarryStevens
- License: mit
- Created: 2017-12-01T09:04:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-01T11:28:54.000Z (about 2 years ago)
- Last Synced: 2025-04-25T10:21:19.004Z (29 days ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/data2grid
- Size: 93.8 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# data2grid
[](https://travis-ci.org/HarryStevens/data2grid) [](https://coveralls.io/github/HarryStevens/data2grid?branch=master)Add a row and a column to a set of data so you can lay it out. [See it in action](https://bl.ocks.org/HarryStevens/81e7699d43b2373ba805e23c5eafa21e).
## Installation
### npm
```bash
npm install data2grid --save
```
```js
var data2grid = require("data2grid");
```### Web browser
In vanilla, a `data2grid` global is exported. You can use the CDN from unpkg.
```html```
If you'd rather host it yourself, download `data2grid.js` or `data2grid.min.js` from the [`build` directory](https://github.com/HarryStevens/data2grid/tree/master/build).
```html```
## API
# data2grid.grid(data array[, number of rows])
For each object in your `data array`, adds properties for `row` and `column` so you can lay out the data. If you do not specify `number of rows`, uses `calcRows(data.length)` to calculate an optimal `number of rows`.
# data2grid.calcRows(number of data points)
Calculates the optimal number of rows for a `number of data points`. You can often pass `data.length` to get an optimal number of rows for a data array.