An open API service indexing awesome lists of open source software.

https://github.com/visactor/univer-vchart-plugin


https://github.com/visactor/univer-vchart-plugin

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          



VisActor Logo


VisActor Logo


univer-vchart-plugin


The vchart univer plugin encapsulates the capability to create chart overlays within [Univer](https://univer.ai/zh-CN).

![](https://github.com/visactor/univer-vchart-plugin/actions/workflows/bug-server.yml/badge.svg)
![](https://github.com/visactor/univer-vchart-plugin/actions/workflows/unit-test.yml/badge.svg)
[![npm Version](https://img.shields.io/npm/v/@visactor/univer-vchart-plugin.svg)](https://www.npmjs.com/package/@visactor/univer-vchart-plugin)
[![npm Download](https://img.shields.io/npm/dm/@visactor/univer-vchart-plugin.svg)](https://www.npmjs.com/package/@visactor/univer-vchart-plugin)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/visactor/univer-vchart-plugin/blob/main/CONTRIBUTING.md#your-first-pull-request)

![](https://img.shields.io/badge/language-TypeScript-red.svg) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/visactor/univer-vchart-plugin/blob/main/LICENSE)

[English](./README.md) | įŽ€äŊ“中文

## Introduction

VChart is a chart component library within the VisActor visualization system. [Univer](https://univer.ai/) is an open-source Office suite. Using the univer-vchart-plugin, you can easily create chart overlays.

## 🔨 Usage

### đŸ“Ļ Installation

```bash
# npm
$ npm install @visactor/univer-vchart-plugin

# pnpm
$ pnpm add @visactor/univer-vchart-plugin
```

### 📊 A Simple Chart

```typescript
import {
UniverVChartPlugin,
CREATE_VCHART_COMMAND_ID,
} from "@visactor/univer-vchart-plugin";

export function setupUniver() {
const univer = new Univer({
theme: defaultTheme,
locale: LocaleType.EN_US,
locales: {
[LocaleType.EN_US]: enUS,
},
});
univer.registerPlugin(UniverVChartPlugin);
}

export function setupVChartDemo($toolbar: HTMLElement, univerAPI: FUniver) {
const $button = document.createElement("a");
$button.textContent = "Create vchart demo";
$toolbar.appendChild($button);

$button.addEventListener("click", async () => {
if (!univerAPI) throw new Error("univerAPI is not defined");

const activeWorkbook = univerAPI.getActiveWorkbook();
if (!activeWorkbook) throw new Error("activeWorkbook is not defined");
const activeSheet = activeWorkbook.getActiveSheet();
if (!activeSheet) throw new Error("activeSheet is not defined");

await univerAPI.executeCommand(CREATE_VCHART_COMMAND_ID, {
spec: {
type: "line",
data: {
values: [
{
time: "2:00",
value: 8,
},
{
time: "4:00",
value: 9,
},
{
time: "6:00",
value: 11,
},
{
time: "8:00",
value: 14,
},
{
time: "10:00",
value: 16,
},
{
time: "12:00",
value: 17,
},
{
time: "14:00",
value: 17,
},
{
time: "16:00",
value: 16,
},
{
time: "18:00",
value: 15,
},
],
},
xField: "time",
yField: "value",
},
});
});
}
```

## 🔗 Related Links

- [Homepage](https://www.visactor.io/vchart)
- [VCharts Chart Examples](https://www.visactor.io/vchart/example)
- [VChart Chart Tutorial](https://www.visactor.io/vchart/guide/tutorial_docs/VChart_Website_Guide)
- [VChart Chart Configuration Options](https://www.visactor.io/vchart/option/)
- [VChart API](https://www.visactor.io/vchart/api/API/vchart)
- [VGrammar](https://www.visactor.io/vgrammar)
- [VRender](https://www.visactor.io/vrender)
- [FAQ](https://www.visactor.io/vchart/guide/tutorial_docs/FAQ)
- [CodeSandbox Template](https://codesandbox.io/s/the-template-of-visactor-vchart-vl84ww?file=/src/index.ts) for submitting bugs

## 🤝 Contributing [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/visactor/univer-vchart-plugin/blob/main/CONTRIBUTING.md#your-first-pull-request)

If you would like to contribute, please read the [Code of Conduct](./CODE_OF_CONDUCT.md) and the [Contribution Guide](./CONTRIBUTING.zh-CN.md) first.

Small streams make big rivers!