# visual-array

> canvas可视化数组。

Latest version **1.1.4** (published 2021-02-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install visual-array
pnpm add visual-array
yarn add visual-array
bun add visual-array
```

## 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.1.4 |
| Published | 2021-02-16 |
| First published | 2021-02-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | frankkai |

## Links

- npm: https://www.npmjs.com/package/visual-array
- Repository: https://github.com/FrankKai/visual-array
- Homepage: https://github.com/FrankKai/visual-array#readme
- Issues: https://github.com/FrankKai/visual-array/issues
- npm.io page: https://npm.io/package/visual-array

## Recent versions

- 1.1.4 (latest) — 2021-02-16
- 1.1.3 — 2021-02-16
- 1.1.2 — 2021-02-16
- 1.1.1 — 2021-02-16
- 1.1.0 — 2021-02-16
- 1.0.23 — 2021-02-16
- 1.0.22 — 2021-02-16
- 1.0.21 — 2021-02-16
- 1.0.20 — 2021-02-16
- 1.0.19 — 2021-02-16
- 1.0.18 — 2021-02-16
- 1.0.17 — 2021-02-16
- 1.0.16 — 2021-02-16
- 1.0.14 — 2021-02-15
- 1.0.13 — 2021-02-15
- … 11 more at https://npm.io/package/visual-array/versions

## README

# visual-array
基于canvas的数组可视化类，支持了一些常用功能。

### 功能介绍
- 支持通过一组数字，生成一个可视化的数组结构
- 支持自定义单个元素的width和height，支持动态伸缩
- 支持自定义单个元素font，strokeStyle，fillStyle
- 支持选择暴露出底部的index: all, 头尾, 关闭
- 支持自定义数组顶部的文字：{index0: value0, index1: value1}
- 支持导出图片
- 支持shift、pop、unshift、push功能
- 支持在vue，react中使用

### 效果图
<img src="https://i.imgur.com/SlqTNPE.png" >

### 使用说明

#### 安装
```shell
npm i visual-array
yarn add visual-array
```

#### vue demo
```html
<template>
  <div id="canvas"></div>
</template>

<script>
import VisualArray from "visual-array";

export default {
  name: "vue-demo",
  mounted() {
    const canvasConfig = {
      array: [1, 2, 3, 4],
      cw: 60,
      ch: 60,
      bottomIndex: null,
      topText: null,
      customStyle: null,
      _canvas: null,
    };
    const visualArray = new VisualArray({
      containerId: "canvas",
      array: canvasConfig.array,
      cw: canvasConfig.cw,
      ch: canvasConfig.ch
    });
    canvasConfig._canvas = visualArray;
  },
};
</script>

<style lang="scss" scoped></style>
```

#### react demo
```js
import { useEffect } from "react";
import VisualArray from "visual-array";

function Demo() {
  useEffect(() => {
    const canvasConfig = {
      array: [1, 2, 3, 4],
      cw: 60,
      ch: 60,
      bottomIndex: null,
      topText: null,
      customStyle: null,
      _canvas: null,
    };
    const visualArray = new VisualArray({
      containerId: "canvas",
      array: canvasConfig.array,
      cw: canvasConfig.cw,
      ch: canvasConfig.ch,
    });
    canvasConfig._canvas = visualArray;
  }, []);
  return (
    <div className="demo">
      <div id="canvas"></div>
    </div>
  );
}

export default Demo;
```

enjoy it!

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