https://github.com/observedobserver/auto-annotation
automated insight annotation on visualization. 自动化可视化标注。
https://github.com/observedobserver/auto-annotation
annotation auto-visualization
Last synced: 3 months ago
JSON representation
automated insight annotation on visualization. 自动化可视化标注。
- Host: GitHub
- URL: https://github.com/observedobserver/auto-annotation
- Owner: ObservedObserver
- License: mit
- Created: 2021-03-02T13:37:25.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-17T06:17:30.000Z (almost 5 years ago)
- Last Synced: 2025-02-28T16:10:57.878Z (11 months ago)
- Topics: annotation, auto-visualization
- Language: TypeScript
- Homepage:
- Size: 121 KB
- Stars: 18
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# auto-annotations

auto-annotations是一个帮助你在可视化图表中自动标注出有价值的信息的工具。
```bash
npm i --save auto-annotations
```
## 自动化感知推荐标记 AutoAnnotation
`AutoAnnotation` 会识别视图中的洞察信息,并根据洞察的显著性推荐最合适的洞察,并返回一个标注函数。后续调用这个标注函数,即可完成在图表上的标注。
+ 构建参数: `view`,为一个G2.View
+ 方法
+ `recommand()` 返回一个annotation函数,这个函数获得参数后可以用来绘制。
以cars数据集为例,这里原视图是一张["Displacement", "Acceleration"]两个数值字段构成的散点图。
```typescript
import { annotations, AutoAnnotation } from 'auto-annotations';
// 声明一个G2图表
chart.point().position(["Displacement", "Acceleration"]);
chart.data(dataSource);
// 创建一个AutoAnnotation类
const ann = new AutoAnnotation(chart);
// 推荐一种标注,并获得标注绘制函数。
const annotate = ann.recommand()
annotate(chart);
chart.render();
```
最终的推荐结果如下, `auto-annotations` 识别到图中存在一些异常值,并将它们标注了出来。

## 自定义标记
除了自动推荐标注外,当你有明确的分析目的时,你也可以直接使用你想要的标注。这些标注函数可以识别特定的洞察类型,并进行标注。标注函数本身并不是纯粹的绘制函数,其必须先识别到视图中的某个具体的洞察,根据洞察的一些数理信息,进行标注。
### 回归 annotateGeneralRegression
```typescript
annotations.annotateGeneralRegression(
view: View,
order?: number
)
```
#### 线性回归
```typescript
import {annotations} from 'auto-annotations';
chart.line().position([xField, yField]);
chart.data(mockData);
annotations.annotateGeneralRegression(chart);
chart.render()
```

#### 多项式回归
```typescript
import {annotations} from 'auto-annotations';
chart.line().position([xField, yField]);
chart.data(mockData);
annotations.annotateGeneralRegression(chart, 4);
chart.render()
```

#### 散点图回归
对auto-annotation而言,散点图回归和折线图回归是没有本质区别的。
```typescript
import {annotations} from 'auto-annotations';
chart.line().position([xField, yField]);
chart.data(data);
annotations.annotateGeneralRegression(chart);
chart.render()
```

### 异常/离群值 annotateOutlier
```typescript
import {annotations} from 'auto-annotations';
chart.point().shape('circle').position([xField, yField]);
chart.data(dataSource);
annotations.annotateOutlier(chart);
chart.render();
```

### 群簇 annotateCluster
```typescript
import {annotations} from 'auto-annotations';
chart.point().position([xField, yField]);
chart.data(dataSource);
annotations.annotateCluster(chart);
chart.render();
```
