VChart/README.zh-CN.md

157 lines
5.6 KiB
Markdown
Raw Normal View History

2023-06-05 05:42:06 +00:00
<div align="center">
<a href="" target="_blank">
<img alt="VisActor Logo" width="200" src="https://github.com/VisActor/.github/blob/main/profile/500_200.svg"/>
</a>
</div>
<div align="center">
<h1>VChart</h1>
</div>
<div align="center">
VChart不只是开箱即用的多端图表库更是生动灵活的数据故事讲述者。
<p align="center">
2023-07-19 08:16:11 +00:00
<a href="https://www.visactor.io/vchart">简介</a>
<a href="https://www.visactor.io/vchart/example">Demo</a>
<a href="https://www.visactor.io/vchart/guide/tutorial_docs/VChart_Website_Guide">教程</a>
<a href="https://www.visactor.io/vchart/option/barChart">API</a>
<a href="https://www.visactor.io/vchart/guide/tutorial_docs/cross-terminal_and_developer_ecology/node">跨端</a>
2023-06-05 05:42:06 +00:00
</p>
2023-06-20 04:54:34 +00:00
![](https://github.com/visactor/vchart/actions/workflows/bug-server.yml/badge.svg)
![](https://github.com/visactor/vchart/actions/workflows/unit-test.yml/badge.svg)
2023-06-05 05:42:06 +00:00
[![npm Version](https://img.shields.io/npm/v/@visactor/vchart.svg)](https://www.npmjs.com/package/@visactor/vchart)
[![npm Download](https://img.shields.io/npm/dm/@visactor/vchart.svg)](https://www.npmjs.com/package/@visactor/vchart)
2023-06-20 04:54:34 +00:00
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/VisActor/VChart/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/vchart/blob/main/LICENSE)
2023-06-05 05:42:06 +00:00
</div>
<div align="center">
[English](./README.md) | 简体中文
</div>
<div align="center">
(演示视频)
</div>
2023-06-20 04:54:34 +00:00
## 简介
2023-06-05 05:42:06 +00:00
VChart 是 VisActor 可视化体系中的图表组件库,基于可视化语法库[VGrammar](https://github.com/VisActor/VGrammar) 进行图表逻辑封装,基于可视化渲染引擎 [VRender](https://github.com/VisActor/VRender) 进行组件封装。核心能力如下:
2023-06-20 04:54:34 +00:00
1. **一码多端**自动适配桌面、H5、多个小程序环境
2. **面向叙事**:综合应用标注、动画、流程控制、叙事模板等一系列增强功能进行叙事可视化创作。
3. **场景沉淀**:面向最终用户沉淀可视化能力,解放开发者生产力
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
## 仓库简介
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
本仓库包含如下包:
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
1. [`vchart`](./packages/vchart/)核心包VChart 图表
2. [`react-vchart`](./packages/react-vchart/):基于 [React](https://react.dev/) 封装的 VChart 图表组件
3. [`taro-vchart`](./packages/taro-vchart/):基于 [Taro](https://docs.taro.zone/docs/) 封装的 VChart 图表组件
4. [`lark-vchart`](./packages/lark-vchart/):基于 [飞书小程序](https://open.feishu.cn/document/client-docs/gadget/introduction/host-environment) 封装的 VChart 图表组件
5. [`tt-vchart`](./packages/lark-vchart/): 基于 [抖音小程序](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/introduction/overview/) 封装的 VChart 图表组件
6. [`block-vchart`](./packages/block-vchart/):基于 [飞书小组件](https://open.feishu.cn/document/client-docs/block/block-introduction) 封装的 VChart 图表组件
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
## 🔨 使用
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
### 📦 安装
2023-06-05 05:42:06 +00:00
```bash
2023-06-20 04:54:34 +00:00
# npm
$ npm install @visactor/vchart
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
# yarn
$ yarn add @visactor/vchart
2023-06-05 05:42:06 +00:00
```
2023-06-20 04:54:34 +00:00
### 📊 一个简单的图表
<img src="https://user-images.githubusercontent.com/135952300/246996854-95cf0db3-42a2-41f9-8f15-8b7bbec1794c.png" style="width: 500px">
```typescript
import VChart from '@visactor/vchart';
2023-06-05 05:42:06 +00:00
const spec = {
2023-06-20 04:54:34 +00:00
type: 'bar',
data: [
2023-06-05 05:42:06 +00:00
{
2023-06-20 04:54:34 +00:00
id: 'barData',
values: [
{ month: 'Monday', sales: 22 },
{ month: 'Tuesday', sales: 13 },
{ month: 'Wednesday', sales: 25 },
{ month: 'Thursday', sales: 29 },
{ month: 'Friday', sales: 38 }
]
2023-06-05 05:42:06 +00:00
}
],
2023-06-20 04:54:34 +00:00
xField: 'month',
yField: 'sales',
crosshair: {
xField: { visible: true }
}
2023-06-05 05:42:06 +00:00
};
2023-06-20 04:54:34 +00:00
// 'chart' 是图表 dom 容器的 id比如 <div id="chart"></chart>
const vchart = new VChart(spec, { dom: 'chart' });
vchart.renderAsync();
2023-06-05 05:42:06 +00:00
```
2023-06-20 04:54:34 +00:00
## ⌨️ 开发
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
首先,全局安装 [@microsoft/rush](https://rushjs.io/pages/intro/get_started/)
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
```bash
$ npm i --global @microsoft/rush
```
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
接着将代码 clone 至本地:
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
```bash
# clone
$ git clone git@github.com:VisActor/VChart.git
$ cd VChart
# 安装依赖
$ rush update
# 开始 vchart 的本地开发
$ rush start
# 开始 react-vchart 的本地开发
$ rush react
```
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
## 🔗 相关链接
2023-06-05 05:42:06 +00:00
2023-07-14 09:41:50 +00:00
- [主页](https://www.visactor.io/vchart)
- [VCharts 图表示例](https://www.visactor.io/vchart/example)
- [VChart 图表教程](https://www.visactor.io/vchart/guide/tutorial_docs/VChart_Website_Guide)
- [VChart 图表配置项](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)
2023-06-20 09:03:34 +00:00
- [CodeSandbox 模板](https://codesandbox.io/s/the-template-of-visactor-vchart-vl84ww?file=/src/index.ts) 用于 bug 的提交
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
## 💫 生态
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
| 项目 | 介绍 |
| -------------------- | -------------------------- |
| [智能生成组件](https://github.com/VisActor/VChart/tree/develop/packages/react-vchart) | React for @VisActor/VChart |
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
## 🤝 参与贡献 [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/VisActor/VChart/blob/main/CONTRIBUTING.md#your-first-pull-request)
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
如想参与贡献,请先阅读[行为准则](./CODE_OF_CONDUCT.md) 和[贡献指南](./CONTRIBUTING.zh-CN.md)。
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
细流成河,终成大海!
2023-06-05 05:42:06 +00:00
2023-06-20 04:54:34 +00:00
<a href="https://github.com/visactor/vchart/graphs/contributors"><img src="https://contrib.rocks/image?repo=visactor/vchart" /></a>