# vue-tree-chart2

> A vue component to display tree chart

Latest version **0.1.1** (published 2019-11-26) · 0 weekly downloads

## Install

```sh
npm install vue-tree-chart2
pnpm add vue-tree-chart2
yarn add vue-tree-chart2
bun add vue-tree-chart2
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-11-26 |
| First published | 2019-11-26 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 330.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | mcuking |
| Keywords | chart, tree, tree-chart, vue-tree-chart2 |

## Links

- npm: https://www.npmjs.com/package/vue-tree-chart2
- Repository: https://github.com/mcuking/vue-tree-chart2
- Homepage: https://github.com/mcuking/vue-tree-chart2#readme
- Issues: https://github.com/mcuking/vue-tree-chart2/issues
- npm.io page: https://npm.io/package/vue-tree-chart2

## Dependencies (2)

- [vue](https://npm.io/package/vue.md) ^2.6.10
- [core-js](https://npm.io/package/core-js.md) ^3.3.2

## Recent versions

- 0.1.1 (latest) — 2019-11-26
- 0.1.0 — 2019-11-26

## README

# vue-tree-chart2

A vue component to display tree chart

<img src="./assets/tree-chart-demo.png" width=600/>

## Install

```bash
npm install vue-tree-chart2 --save
```

## Usage

```js
<template>
  <div id="app">
    <tree-chart :datasource="ds" @node-click="handleNodeClick">
      <template slot-scope="{ treeData }">
        <div class="chart-card">
          <div class="chart-card-header">{{ treeData.name }}</div>
          <div>
            <span>{{ `leader：${treeData.leader}` }}</span>
          </div>
        </div>
      </template>
    </tree-chart>
  </div>
</template>

<script>
import TreeChart from 'vue-tree-chart2'
import 'vue-tree-chart2/dist/treechart.css'

export default {
  name: 'app',

  components: {
    TreeChart,
  },

  data() {
    return {
      ds: {
        name: 'Empire',
        leader: 'Tom',
        extend: true,
        children: [
          {
            name: 'Department of Education',
            leader: 'Jack',
            extend: false,
          },
          {
            name: 'Department of Defense',
            leader: 'Lily',
            extend: false,
            children: [
              {
                name: 'Army',
                leader: 'Lucy',
              },
              {
                name: 'Navy',
                leader: 'Jerry',
                children: [
                  {
                    name: 'Marine Corps',
                    leader: 'Marry',
                  },
                  {
                    name: 'Coast Guard',
                    leader: 'Rose',
                  },
                ],
              },
              {
                name: 'Airforce',
                leader: 'Cooper',
              },
            ],
          },
        ],
      },
    };
  },

  methods: {
    handleNodeClick(treeData) {
      console.log('node ' + treeData.name + ' is selected');
    },
  },
};
</script>
```

## Attributes

| Name       | Type | Required | Default | Description                            |
| ---------- | ---- | -------- | ------- | -------------------------------------- |
| datasource | json | yes      |         | Used to build structure of tree chart. |

## Events

| Name       | Parameters | Description                          |
| ---------- | ---------- | ------------------------------------ |
| node-click | node data  | Triggered when the node was clicked. |

## Scoped Slots

```js
<template slot-scope="{ treeData }">
  <!-- feel free to customize the internal structure of node -->
</template>
```

## Inspiration

[vue-orgchart](https://github.com/dabeng/vue-orgchart)

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