# canvas-datatable

> Small library with zero dependencies for datagrid rendering inside a canvas

Latest version **0.1.6** (published 2020-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install canvas-datatable
pnpm add canvas-datatable
yarn add canvas-datatable
bun add canvas-datatable
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2020-02-26 |
| First published | 2020-02-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 43.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | viniciusfonseca |

## Links

- npm: https://www.npmjs.com/package/canvas-datatable
- Repository: https://github.com/viniciusfonseca/canvas-datatable
- Homepage: https://github.com/viniciusfonseca/canvas-datatable#readme
- Issues: https://github.com/viniciusfonseca/canvas-datatable/issues
- npm.io page: https://npm.io/package/canvas-datatable

## Recent versions

- 0.1.6 (latest) — 2020-02-26
- 0.1.5 — 2020-02-21
- 0.1.4 — 2020-02-21
- 0.1.3 — 2020-02-20
- 0.1.2 — 2020-02-20
- 0.1.1 — 2020-02-20
- 0.1.0 — 2020-02-20

## README

canvas-datatable
================

Small library with zero dependencies for datagrid rendering inside a canvas.
It has features like custom web fonts, row selecting, column resizing and custom cell rendering.

__Demo__: https://codesandbox.io/s/canvas-datatable-cro4b

## Usage

Install with `npm`:

```
npm install --save canvas-datatable
```

Then import it and instantiate it with a `HTMLCanvasElement`:

```js
import { CanvasDatatable } from 'canvas-datatable'

const html = String.raw
const canvas = document.getElementsByTagName('canvas')[0]

const canvasDatatable = new CanvasDatatable(canvas, {
    columns: [{
        key: 'name',
        label: 'Name',
        // set some custom rendering for a column
        render(value) {
            return html`
                <span style="white-space: nowrap"> ${value} </span>
            `
        }
    }, {
        key: 'email',
        label: 'E-mail'
    }],
    initialData: [{
        name: 'foo',
        email: 'foo@example.com'
    }, {
        name: 'bar',
        email: 'bar@example.com'
    }, {
        name: 'John Doe',
        email: 'john.doe@example.com'
    }]
})

// updating the data when needed (the array passed to setData() will replace the current array)
canvasDatatable.setData([
    {
        name: 'only user in database',
        email: 'unique@example.com'
    }
])

// add some custom web font (note that you must use the class static method)
CanvasDatatable.addWebFont('https://fonts.googleapis.com/css?family=Titillium+Web')

// disposing it when the canvas isn't used anymore
canvasDatatable.dispose()
```

This project is still in development. If you want to contribute, send a mail to `vfonseca1618@gmail.com`.

---
_Source: https://npm.io/package/canvas-datatable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
