# react-canvas-treemap

> Canvas based Treemap data visualization using React.

Latest version **1.0.6** (published 2021-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-canvas-treemap
pnpm add react-canvas-treemap
yarn add react-canvas-treemap
bun add react-canvas-treemap
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2021-05-18 |
| First published | 2020-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 6 |
| Unpacked size | 557.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | wsoeltz |
| Maintainers | wsoeltz |

## Links

- npm: https://www.npmjs.com/package/react-canvas-treemap
- Repository: https://github.com/cid-harvard/react-canvas-treemap
- Homepage: https://github.com/cid-harvard/react-canvas-treemap#readme
- Issues: https://github.com/cid-harvard/react-canvas-treemap/issues
- npm.io page: https://npm.io/package/react-canvas-treemap

## Dependencies (6)

- [gsap](https://npm.io/package/gsap.md) ^3.4.2
- [color](https://npm.io/package/color.md) ^3.1.2
- [d3-scale](https://npm.io/package/d3-scale.md) ^3.2.1
- [squarify](https://npm.io/package/squarify.md) ^1.1.0
- [d3-format](https://npm.io/package/d3-format.md) ^1.4.4
- [interval-tree-1d](https://npm.io/package/interval-tree-1d.md) ^1.0.3

## Recent versions

- 1.0.6 (latest) — 2021-05-18
- 1.0.5 — 2021-05-18
- 1.0.4 — 2021-02-01
- 1.0.3 — 2020-10-28
- 1.0.2 — 2020-10-05
- 1.0.1 — 2020-10-05
- 1.0.0 — 2020-10-05

## README

# react-canvas-treemap

## by the Growth Lab at Harvard's Center for International Development

Canvas based Treemap data visualization using React.

> This package is part of Harvard Growth Lab’s portfolio of software packages, digital products and interactive data visualizations. To browse our entire portfolio, please visit The Viz Hub at [growthlab.app](https://growthlab.app/). To learn more about our research, please visit [Harvard Growth Lab’s](https://growthlab.cid.harvard.edu/) home page.

[![NPM](https://img.shields.io/npm/v/react-canvas-treemap.svg)](https://www.npmjs.com/package/react-canvas-treemap) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

### [View live examples ↗](https://cid-harvard.github.io/react-canvas-treemap/)

## Install

```bash
npm install --save react-canvas-treemap
```

## Usage

```tsx
import React from 'react'
import TreeMap, {transformData} from 'react-canvas-treemap';

const App = () => {

  ...
  const data = transformData({
    data: fetchedData,
    width: 500,
    height: 500,
    colorMap: colorMap,
  });

  return (
    <TreeMap
      highlighted={undefined}
      cells={data.treeMapCells}
      numCellsTier={0}
      chartContainerWidth={500}
      chartContainerHeight={500}
      onCellClick={id => console.log(id)}
      onMouseOverCell={id => console.log(id)}
      onMouseLeaveChart={() => {}}
    />
  )
}

export default App

```
The TreeMap component takes the following props:

- **highlighted**: `string | undefined`
- **cells**: `ITreeMapCell[]`
- **comparisonTreeMap** *(optional)*: `boolean`
- **fallbackTitle** *(optional)*: `string`
- **numCellsTier**: `NumCellsTier`
- **chartContainerWidth**: `number `
- **chartContainerHeight**: `number`
- **onCellClick**: `(id: string) => void`
- **onMouseOverCell**: `(id: string) => void`
- **onMouseLeaveChart**: `() => void`

## License

MIT © [The President and Fellows of Harvard College](https://www.harvard.edu/)

> :warning: **License**: While this package has a MIT license, it uses [Greensock](https://greensock.com/), which is not an Open-Source software. All of the Greensock Code used here falls within their "No Charge" License. If you intend to use this package, make sure to familiarize yourself with the [Greensock "No Charge" License](https://greensock.com/standard-license/).

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