# tree2table

> make an dyadic array with colspan and rowspan from a tree, so you can easily display a table view to describe a tree structure.

Latest version **1.0.0** (published 2016-06-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install tree2table
pnpm add tree2table
yarn add tree2table
bun add tree2table
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-06-12 |
| First published | 2016-06-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | yuyangvi |
| Maintainers | yuyangvi |
| Keywords | tree, table, nodejs |

## Links

- npm: https://www.npmjs.com/package/tree2table
- Repository: https://github.com/yuyangvi/tree2table
- Homepage: https://github.com/yuyangvi/tree2table#readme
- Issues: https://github.com/yuyangvi/tree2table/issues
- npm.io page: https://npm.io/package/tree2table

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-06-12

## README

# tree2table
=====
make an dyadic array with colspan and rowspan from a tree, so you can easily display a table view to describe a tree structure.
这个模块是用来将一个任意的树形结构体转换成表格的工具。
它会计算出每个节点所需要的跨行跨列数，并将其按表格的要求格式生成二维数组。
Usage
-----
```sh
npm install tree2table --save
```

example
-----
``` javascript
var schema = {
  name: 'Sue',
  personal:{
    birthsday: '1871-02-05',
    gender: 'female',
    contact: {
      address: 'xxx street',
      zipcode: '100',
      mobile: '0141145114'
    }
  },
  education: {
    degree: 'Bachelor of Law',
    CA: 'Yale'
  }
};

var tree2table = require(tree2table);
var result = tree2table(schema);
console.log(result);
```
result
-----
```
[ [ { trace: 'name', colspan: 3, rowspan: 1 } ],
  [ { trace: 'personal', colspan: 1, rowspan: 5 },
    { trace: 'birthsday', colspan: 2, rowspan: 1 } ],
  [ { trace: 'gender', colspan: 2, rowspan: 1 } ],
  [ { trace: 'contact', colspan: 1, rowspan: 3 },
    { trace: 'address', colspan: 1, rowspan: 1 } ],
  [ { trace: 'zipcode', colspan: 1, rowspan: 1 } ],
  [ { trace: 'mobile', colspan: 1, rowspan: 1 } ],
  [ { trace: 'education', colspan: 2, rowspan: 2 },
    { trace: 'degree', colspan: 1, rowspan: 1 } ],
  [ { trace: 'CA', colspan: 1, rowspan: 1 } ] ]
```  
####at last you get this:
<table>
<tbody>
<tr><td colspan="3">name</td></tr>
<tr><td rowspan="5">personal</td><td colspan="2">birthday</tr>
<tr><td colspan="2">gender</td></tr>
<tr><td rowspan="3">contact</td><td>address</td></tr>
<tr><td>zipcode</td></tr>
<tr><td>mobile</td></tr>
<tr><td colspan="2" rowspan="2">education</td><td>degree</td></tr>
<tr><td>CA</td></tr>
</tbody>
</table>

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