You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want to show "the changes in sales rankings of various car brands". Call the generateChart method and pass the data and display content description directly to VMind:
137
137
138
138
```typescript
139
-
constdescribe='show me the changes in sales rankings of various car brand';
139
+
constuserPrompt='show me the changes in sales rankings of various car brand';
140
140
//Call the chart generation interface to get spec and chart animation duration
141
-
const { spec, time } =awaitvmind.generateChart(userInput, fieldInfo, dataset);
141
+
const { spec, time } =awaitvmind.generateChart(userPrompt, fieldInfo, dataset);
142
142
```
143
143
144
144
In this way, we get the VChart spec of the corresponding dynamic chart. We can render the chart based on this spec:
@@ -161,19 +161,19 @@ Thanks to the capabilities of the large language model, users can describe more
161
161
Users can specify different theme styles (currently only gpt chart generation supports this feature). For example, users can specify to generate a tech-style chart:
162
162
163
163
```typescript
164
-
//describe can be in both Chinese and English
164
+
//userPrompt can be in both Chinese and English
165
165
//Specify to generate a tech-style chart
166
-
constdescribe='show me the changes in sales rankings of various car brand,tech style';
167
-
const { spec, time } =awaitvmind.generateChart(userInput, fieldInfo, dataset);
166
+
constuserPrompt='show me the changes in sales rankings of various car brand,tech style';
167
+
const { spec, time } =awaitvmind.generateChart(userPrompt, fieldInfo, dataset);
168
168
```
169
169
170
170
You can also specify the chart type, field mapping, etc. supported by VMind. For example:
171
171
172
172
```typescript
173
173
//Specify to generate a line chart, with car manufacturers as the x-axis
174
-
constdescribe=
174
+
constuserPrompt=
175
175
'show me the changes in sales rankings of various car brands,tech style.Using a line chart, Manufacturer makes the x-axis';
176
-
const { spec, time } =await(vmind.generateChart(csvData, describe));
176
+
const { spec, time } =awaitvmind.generateChart(userPrompt, fieldInfo, dataset);
177
177
```
178
178
179
179
#### Customizing LLM Request Method
@@ -196,6 +196,35 @@ temperature?: number;//recommended to set to 0
196
196
Specify your LLM service url in url (default is https://api.openai.com/v1/chat/completions)
197
197
In subsequent calls, VMind will use the parameters in params to request the LLM service url.
198
198
199
+
200
+
201
+
#### Data Aggregation
202
+
📢 Note: The data aggregation function only supports GPT series models, more models will come soon.
203
+
204
+
When using the chart library to draw bar charts, line charts, etc., if the data is not aggregated, it will affect the visualization effect. At the same time, because no filtering and sorting of fields has been done, some visualization intentions cannot be met, for example: show me the top 10 departments with the most cost, show me the sales of various products in the north, etc.
205
+
206
+
VMind supports intelligent data aggregation since version 1.2.2. This function uses the data input by the user as a data table, uses a LLM to generate SQL queries according to the user's command, queries data from the data table, and uses GROUP BY and SQL aggregation methods to group, aggregate, sort, and filter data. Supported SQL statements include: SELECT, GROUP BY, WHERE, HAVING, ORDER BY, LIMIT. Supported aggregation methods are: MAX(), MIN(), SUM(), COUNT(), AVG(). Complex SQL operations such as subqueries, JOIN, and conditional statements are not supported.
207
+
208
+
209
+
Use the `dataQuery` function of the VMind object to aggregate data. This method has three parameters:
210
+
- userInput: user input. You can use the same input as generateChart
211
+
- fieldInfo: Dataset field information. The same as generateChart, it can be obtained by parseCSVData, or built by the user.
212
+
- dataset: Dataset. The same as generateChart, it can be obtained by parseCSVData, or built by the user.
The fieldInfo and dataset returned by this method are the field information and dataset after data aggregation, which can be used for chart generation.
221
+
By default, the `generateChart` function will perform a data aggregation using the same user input before generating the chart. You can disable data aggregation by passing in the fourth parameter:
222
+
```typescript
223
+
const userInput ='show me the changes in sales rankings of various car brand';
224
+
const { spec, time } =awaitvmind.generateChart(userInput, fieldInfo, dataset, false); //pass false as the forth parameter to disable data aggregation before generating a chart.
0 commit comments