An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

        

# data2grid
[![Build Status](https://travis-ci.org/HarryStevens/data2grid.svg?branch=master)](https://travis-ci.org/HarryStevens/data2grid) [![Coverage Status](https://coveralls.io/repos/github/HarryStevens/data2grid/badge.svg?branch=master)](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.