Skip to content

Commit

Permalink
Merge pull request #52 from VisActor/release/1.2.6
Browse files Browse the repository at this point in the history
[Auto release] release 1.2.7
  • Loading branch information
da730 authored Mar 26, 2024
2 parents ecc3bd9 + b9a711a commit 564621f
Show file tree
Hide file tree
Showing 19 changed files with 302 additions and 22 deletions.
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,49 @@
# @visactor/vmind

<div align="center">
<a href="https://github.com/VisActor#gh-light-mode-only" target="_blank">
<img alt="VisActor Logo" width="200" src="https://github.com/VisActor/.github/blob/main/profile/logo_500_200_light.svg"/>
</a>
<a href="https://github.com/VisActor#gh-dark-mode-only" target="_blank">
<img alt="VisActor Logo" width="200" src="https://github.com/VisActor/.github/blob/main/profile/logo_500_200_dark.svg"/>
</a>
</div>

<div align="center">
<h1>VMind</h1>
</div>

<div align="center">

Not just automatic, but also fantastic.Open-source solution for intelligent visualization.

<p align="center">
<a href="https://www.visactor.io/vmind">Introduction</a> •
<a href="https://www.visactor.io/vmind/example">Demo</a> •
<a href="https://www.visactor.io/vmind/guide/Intro_to_VMind">Tutorial</a> •
<a href="https://www.visactor.io/vmind/api/VMind_Instance">API</a>•
<a href="https://www.visactor.io/vmind/openapi">OpenApi</a>
</p>

![](https://github.com/visactor/vmind/actions/workflows/bug-server.yml/badge.svg)
![](https://github.com/visactor/vmind/actions/workflows/unit-test.yml/badge.svg)
[![npm Version](https://img.shields.io/npm/v/@visactor/vmind.svg)](https://www.npmjs.com/package/@visactor/vmind)
[![npm Download](https://img.shields.io/npm/dm/@visactor/vmind.svg)](https://www.npmjs.com/package/@visactor/vmind)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/VisActor/VMind/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/vmind/blob/main/LICENSE)

</div>



<div align="center">

English | [简体中文](readme-zh.md)

</div>

## 简介

`@visactor/vmind` is an intelligent chart component based on LLM provided by [VisActor](https://www.visactor.io/), including dialog-based chart generation and editing capabilities. It provides a natural language interaction interface, allowing you to easily create chart narrative works with `@visactor/VMind` with just one sentence, and edit them through continuous dialogue, greatly improving your efficiency in creating data visualization works.

The main features of `@visactor/vmind` include:
Expand All @@ -17,9 +55,9 @@ The main features of `@visactor/vmind` include:

## Development Guide

### Demo Page
### Docs Page

Enter the VChart repository and execute:
Enter the VMind repository and execute:

```bash
# Install dependencies
Expand All @@ -28,11 +66,10 @@ $ rush update
$ rush docs
```

Select VMind from the top navigation bar, enter your OpenAI Key, click generate chart, and you can experience VMind.

### Start the Development Page

Enter the VChart repository and execute:
Enter the VMind repository and execute:

```bash
# Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion common/config/rush/version-policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"definitionName": "lockStepVersion",
"policyName": "vmindMin",
"version": "1.2.5",
"version": "1.2.7",
"mainProject": "@visactor/vmind",
"nextBump": "patch"
}
Expand Down
1 change: 1 addition & 0 deletions docs/assets/api/en/dataQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The dataQuery function is a powerful data aggregation tool. It takes three param
## Supported Models:
- GPT-3.5
- GPT-4
- [skylark2-pro](https://www.volcengine.com/product/yunque)

## Interface Parameters:

Expand Down
6 changes: 5 additions & 1 deletion docs/assets/api/en/generateChart.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The generateChart function is used for intelligent chart generation.
- GPT-3.5
- GPT-4
- [skylark2-pro](https://www.volcengine.com/product/yunque)
- [chart-advisor](../guide/Basic_tutorial/Chart_Advisor)

## Interface Parameters:

Expand Down Expand Up @@ -65,6 +66,9 @@ const { spec, time } = await vmind.generateChart(userPrompt, fieldInfo, dataset,
- The generateChart method will pass the userPrompt and fieldInfo to the large language model for chart generation, but the detailed data in the dataset will not be passed.
- In the process of generating the chart, VMind will first use the large language model, according to the userPrompt and fieldInfo, to recommend a suitable chart type. Then, it will map the fields in the fieldInfo to the x-axis, y-axis, color, size and other visual channels of the chart.
- VMind will add an entrance animation to the generated chart by default, so it will also return the duration of the chart animation time. If you want to turn off the chart animation, you can set spec.animation to false.
- When the model type is set to chart-advisor, it will not call a large language model to generate charts. The results generated will include multiple types of charts. For details, please refer to [Rule-based Chart Generation](../guide/Basic_Tutorial/Chart_Advisor).

## Related Tutorials
[Intelligent Chart Generation](../guide/Basic_Tutorial/Chart_Generation)
- [Intelligent Chart Generation](../guide/Basic_Tutorial/Chart_Generation)
- [Rule-based Chart Generation](../guide/Basic_Tutorial/Chart_Advisor)

1 change: 1 addition & 0 deletions docs/assets/api/zh/dataQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dataQuery函数是一个强大的数据聚合工具,它接收三个参数:
## 支持模型:
- GPT-3.5
- GPT-4
- [skylark2-pro](https://www.volcengine.com/product/yunque)

## 接口参数:

Expand Down
5 changes: 4 additions & 1 deletion docs/assets/api/zh/generateChart.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ generateChart函数用于图表智能生成。
- GPT-3.5
- GPT-4
- [skylark2-pro](https://www.volcengine.com/product/yunque)
- [chart-advisor](../guide/Basic_tutorial/Chart_Advisor)

## 接口参数:

Expand Down Expand Up @@ -65,6 +66,8 @@ const { spec, time } = await vmind.generateChart(userPrompt, fieldInfo, dataset,
- generateChart方法会将userPrompt和fieldInfo传递给大语言模型用于生成图表,但是dataset中的详细数据并不会被传递。
- 在生成图表的过程中,VMind首先会利用大语言模型,根据userPrompt和fieldInfo,推荐一个适合的图表类型。然后,它会将fieldInfo中的字段映射到图表的x轴、y轴、颜色、尺寸等视觉通道上。
- VMind默认会为生成的图表添加入场动画,因此它还会返回图表动画的时长time。如果你想关闭图表动画,可以将spec.animation设为false。
- 当设定模型类型为chart-advisor时,将不需调用大型语言模型生成图表,产生的结果将包括多种图表,详情可参见[基于规则的图表生成](../guide/Basic_Tutorial/Chart_Advisor)

## 相关教程
[图表智能生成](../guide/Basic_Tutorial/Chart_Generation)
- [图表智能生成](../guide/Basic_Tutorial/Chart_Generation)
- [基于规则的图表生成](../guide/Basic_Tutorial/Chart_Advisor)
84 changes: 84 additions & 0 deletions docs/assets/guide/en/Basic_Tutorial/Chart_Advisor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Rule-based Chart Generation
VMind can automatically generate charts based on the current dataset in combination with the built-in @visactor/chart-advisor. Chart-advisor is fully dependent on visualization rules and does not need to call large language models. When you use generateChart, and the large model cannot successfully generate a chart, VMind will use chart-advisor as an alternative to create a chart.

You can also actively choose to use chart-advisor to generate charts, just set the model type to chart-advisor when initializing the VMind object:
```ts
import VMind, { Model } from '@visactor/vmind'

const vmind = new VMind({
model: Model.CHART_ADVISOR,
})
const userPrompt = '';
const advisorResult = await vmind.generateChart(userPrompt, fieldInfo, dataset);
```
Since chart-advisor does not rely on large language models, userPrompt can be set to empty.
You can learn more about fieldInfo and dataset in the [Data Format and Data Processing](./Data_Process) section.

Chart-advisor will generate several available charts based on a series of rules, at which time generateChart will return a list containing chart types, scores, and spec.

## Example
Here is an example of a chart generated by chart-advisor using product sales data:

```ts
const dataset = [
{
"Product name": "Coke",
"Sales": 2350
},
{
"Product name": "Sprite",
"total_sales": 1056
},
{
"Product name": "Fanta",
"total_sales": 4778
},
{
"Product name": "Mirinda",
"total_sales": 3336
}
// ...more data
]

const fieldInfo = [
{
"fieldName": "Product name",
"type": "string",
"role": "dimension"
},
{
"fieldName": "Sales",
"type": "int",
"role": "measure"
}
]

const advisorResult = await vmind.generateChart(userPrompt, fieldInfo, dataset);

```
The advisorResult result is as follows:
```json
[
{
"chartSource": "chartAdvisor", // Chart source
"spec": ..., // Generated chart spec
"chartType": "BAR CHART", // Chart type
"score": 1, // Current chart score
},
{
"chartSource": "chartAdvisor",
"spec": ..., // Generated chart spec
"chartType": "RADAR CHART", // Chart type
"score": 0.16666666666666666 // Current chart score
}
]
```

Here, score represents the degree of fit between the current chart type and the input data, the higher the score means that the chart type is more suitable for displaying the current data.


The generated chart is as follows:

![](https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/vmind/tutorials/VMind_advisor.png)

According to the characteristics of the input data and the field information in fieldInfo, chart-advisor will score each type of chart based on a full set of visualization rules and sort each type of chart based on the score. These rules ensure the accuracy and aesthetics of the visualization results and minimize visual confusion and visual errors in the chart.
1 change: 0 additions & 1 deletion docs/assets/guide/en/Basic_Tutorial/Data_Aggregation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Data Aggregation
📢 Note: Currently, the data aggregation feature only supports GPT series models, and we are working hard to integrate more models.

## Overview of Data Aggregation
When we use chart libraries like VChart to draw bar charts, line charts, etc., if the dataset used has not been aggregated, it may have a negative impact on the visualization effect.
Expand Down
9 changes: 8 additions & 1 deletion docs/assets/guide/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@
"en": "Intelligent Chart Generation"
}
},
{
"path": "Chart_Advisor",
"title": {
"zh": "基于规则的图表生成",
"en": "Rule-based Chart Generation"
}
},
{
"path": "Custom_Request",
"title": {
Expand All @@ -90,4 +97,4 @@
]
}
]
}
}
84 changes: 84 additions & 0 deletions docs/assets/guide/zh/Basic_Tutorial/Chart_Advisor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 基于规则的图表生成
VMind可以结合内建的@visactor/chart-advisor,自动根据当前数据集生成图表。chart-advisor完整依赖于可视化规则,不需要调用大型语言模型。当你使用generateChart,而大模型无法成功生成图表时,VMind会使用chart-advisor作为备选方案来创建一个图表。

你同样可以主动选择使用chart-advisor来生成图表,只需在初始化VMind对象时,将模型类型设置为chart-advisor:
```ts
import VMind, { Model } from '@visactor/vmind'

const vmind = new VMind({
model: Model.CHART_ADVISOR,
})
const userPrompt = '';
const advisorResult = await vmind.generateChart(userPrompt, fieldInfo, dataset);
```
由于chart-advisor不依赖大型模型,userPrompt可以设为空。
你可以在[数据格式与数据处理](./Data_Process)章节了解fieldInfo和dataset的更多相关信息。

chart-advisor会根据一系列规则生成几种可用的图表,此时generateChart将返回包含图表类型、得分以及spec的列表。

## 示例
下面是一个使用商品销售额数据,通过chart-advisor生成图表的示例:

```ts
const dataset = [
{
"Product name": "Coke",
"Sales": 2350
},
{
"Product name": "Sprite",
"total_sales": 1056
},
{
"Product name": "Fanta",
"total_sales": 4778
},
{
"Product name": "Mirinda",
"total_sales": 3336
}
// ...more data
]

const fieldInfo = [
{
"fieldName": "Product name",
"type": "string",
"role": "dimension"
},
{
"fieldName": "Sales",
"type": "int",
"role": "measure"
}
]

const advisorResult = await vmind.generateChart(userPrompt, fieldInfo, dataset);

```
advisorResult结果如下:
```json
[
{
"chartSource": "chartAdvisor", //图表来源
"spec": ..., //生成的图表spec
"chartType": "BAR CHART", //图表类型
"score": 1, //当前图表得分
},
{
"chartSource": "chartAdvisor",
"spec": ..., //生成的图表spec
"chartType": "RADAR CHART", //图表类型
"score": 0.16666666666666666 //当前图表得分
}
]
```

其中,score表示当前图表类型与输入数据的匹配程度,分数越高表示该类型的图表越适用于展示当前数据。


生成的图表如下:

![](https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/vmind/tutorials/VMind_advisor.png)

根据输入数据的特性以及fieldInfo中的字段信息,chart-advisor会基于一整套可视化规则,为每种图表类型打分,并依分数将各图表类型排序。这些规则确保了可视化结果的准确度和美观性,并尽可能地减少图表中的视觉混乱和视觉错误。
1 change: 0 additions & 1 deletion docs/assets/guide/zh/Basic_Tutorial/Data_Aggregation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# 数据聚合
📢 注意:目前数据聚合功能仅支持GPT系列模型,我们正在努力接入更多模型。

## 数据聚合概述
当我们使用VChart等图表库来绘制柱状图、折线图等图表时,如果使用的数据集dataset并未经过聚合处理,可能会对可视化效果产生不良影响。
Expand Down
2 changes: 1 addition & 1 deletion packages/calculator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/calculator",
"version": "1.2.5",
"version": "1.2.7",
"description": "SQL-like query executor with DSL",
"main": "lib",
"module": "es",
Expand Down
2 changes: 1 addition & 1 deletion packages/chart-advisor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@visactor/chart-advisor",
"version": "1.2.5",
"version": "1.2.7",
"description": "图表推荐模块",
"main": "lib",
"module": "es",
Expand Down
8 changes: 4 additions & 4 deletions packages/chart-advisor/src/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1183,17 +1183,17 @@ export const scorer: Scorer = params => {
calBar,
calBarPercent,
calBarParallel,
calCombination,
//calCombination,
calScatterplot,
calLineChart,
// calLineChartCombine,
calPieChart,
calMeasureCard,
//calMeasureCard,
calRadar,
calWordCloud,
calFunnelChart,
calDualAxis,
calTable
calDualAxis
//calTable
];

return scoreCalculators;
Expand Down
Loading

0 comments on commit 564621f

Please sign in to comment.