{"id":16200899,"url":"https://github.com/observedobserver/auto-annotation","last_synced_at":"2025-10-29T10:18:14.901Z","repository":{"id":102837569,"uuid":"343786570","full_name":"ObservedObserver/auto-annotation","owner":"ObservedObserver","description":"automated insight annotation on visualization. 自动化可视化标注。","archived":false,"fork":false,"pushed_at":"2021-03-17T06:17:30.000Z","size":124,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-28T16:10:57.878Z","etag":null,"topics":["annotation","auto-visualization"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ObservedObserver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-02T13:37:25.000Z","updated_at":"2024-05-08T01:37:06.000Z","dependencies_parsed_at":"2023-03-11T16:15:18.785Z","dependency_job_id":null,"html_url":"https://github.com/ObservedObserver/auto-annotation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ObservedObserver%2Fauto-annotation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ObservedObserver%2Fauto-annotation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ObservedObserver%2Fauto-annotation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ObservedObserver%2Fauto-annotation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ObservedObserver","download_url":"https://codeload.github.com/ObservedObserver/auto-annotation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243971180,"owners_count":20376784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["annotation","auto-visualization"],"created_at":"2024-10-10T09:34:44.359Z","updated_at":"2025-10-29T10:18:09.841Z","avatar_url":"https://github.com/ObservedObserver.png","language":"TypeScript","readme":"# auto-annotations\n\n![](https://img.shields.io/npm/v/auto-annotations#align=left\u0026display=inline\u0026height=20\u0026margin=%5Bobject%20Object%5D\u0026name=\u0026originHeight=20\u0026originWidth=80\u0026status=done\u0026style=none\u0026width=80)\u003cbr /\u003eauto-annotations是一个帮助你在可视化图表中自动标注出有价值的信息的工具。\u003cbr /\u003e\n\n```bash\nnpm i --save auto-annotations\n```\n\n## 自动化感知推荐标记 AutoAnnotation\n\n`AutoAnnotation` 会识别视图中的洞察信息，并根据洞察的显著性推荐最合适的洞察，并返回一个标注函数。后续调用这个标注函数，即可完成在图表上的标注。\n\n+ 构建参数: `view`，为一个G2.View\n+ 方法\n    + `recommand()` 返回一个annotation函数，这个函数获得参数后可以用来绘制。\n\n\n以cars数据集为例，这里原视图是一张[\"Displacement\", \"Acceleration\"]两个数值字段构成的散点图。\n\n```typescript\nimport { annotations, AutoAnnotation } from 'auto-annotations';\n\n// 声明一个G2图表\nchart.point().position([\"Displacement\", \"Acceleration\"]);\nchart.data(dataSource);\n\n// 创建一个AutoAnnotation类\nconst ann = new AutoAnnotation(chart);\n\n// 推荐一种标注，并获得标注绘制函数。\nconst annotate = ann.recommand()\nannotate(chart);\n\nchart.render();\n```\n\n最终的推荐结果如下, `auto-annotations` 识别到图中存在一些异常值，并将它们标注了出来。\n\n![](https://cdn.nlark.com/yuque/0/2021/png/171008/1614741461882-35a6af2e-9437-4755-9ea3-10714e6ae282.png)\n\n## 自定义标记\n除了自动推荐标注外，当你有明确的分析目的时，你也可以直接使用你想要的标注。这些标注函数可以识别特定的洞察类型，并进行标注。标注函数本身并不是纯粹的绘制函数，其必须先识别到视图中的某个具体的洞察，根据洞察的一些数理信息，进行标注。\n\n### 回归 annotateGeneralRegression\n```typescript\nannotations.annotateGeneralRegression(\n    view: View,\n    order?: number\n) \n```\n#### 线性回归\n```typescript\nimport {annotations} from 'auto-annotations';\n\nchart.line().position([xField, yField]);\nchart.data(mockData);\n\nannotations.annotateGeneralRegression(chart);\n\nchart.render()\n```\n![image.png](https://cdn.nlark.com/yuque/0/2021/png/171008/1614695346877-1b2d6e77-4975-49ef-9beb-0c07310d60ef.png#align=left\u0026display=inline\u0026height=420\u0026margin=%5Bobject%20Object%5D\u0026name=image.png\u0026originHeight=840\u0026originWidth=1000\u0026size=48302\u0026status=done\u0026style=none\u0026width=500)\u003cbr /\u003e\n\n#### 多项式回归\n```typescript\nimport {annotations} from 'auto-annotations';\n\nchart.line().position([xField, yField]);\nchart.data(mockData);\n\nannotations.annotateGeneralRegression(chart, 4);\n\nchart.render()\n```\n![image.png](https://cdn.nlark.com/yuque/0/2021/png/171008/1614695359069-2305b839-0b89-4115-a210-8b2f8f2ce4e9.png#align=left\u0026display=inline\u0026height=360\u0026margin=%5Bobject%20Object%5D\u0026name=image.png\u0026originHeight=720\u0026originWidth=1000\u0026size=50623\u0026status=done\u0026style=none\u0026width=500)\n#### 散点图回归\n对auto-annotation而言，散点图回归和折线图回归是没有本质区别的。\n```typescript\nimport {annotations} from 'auto-annotations';\n\nchart.line().position([xField, yField]);\nchart.data(data);\n\nannotations.annotateGeneralRegression(chart);\n\nchart.render()\n```\n![image.png](https://cdn.nlark.com/yuque/0/2021/png/171008/1614695366621-f89d9725-d69b-4cf4-8163-648b5140bb7e.png#align=left\u0026display=inline\u0026height=360\u0026margin=%5Bobject%20Object%5D\u0026name=image.png\u0026originHeight=720\u0026originWidth=1000\u0026size=91731\u0026status=done\u0026style=none\u0026width=500)\u003cbr /\u003e\n\u003cbr /\u003e\n\n### 异常/离群值 annotateOutlier\n```typescript\nimport {annotations} from 'auto-annotations';\n\nchart.point().shape('circle').position([xField, yField]);\nchart.data(dataSource);\n\nannotations.annotateOutlier(chart);\n\nchart.render();\n```\n![image.png](https://cdn.nlark.com/yuque/0/2021/png/171008/1614695373907-d4f5cae7-c8ab-4450-aecc-087391ce1193.png#align=left\u0026display=inline\u0026height=360\u0026margin=%5Bobject%20Object%5D\u0026name=image.png\u0026originHeight=720\u0026originWidth=1000\u0026size=88431\u0026status=done\u0026style=none\u0026width=500)\u003cbr /\u003e\n\n### 群簇 annotateCluster\n```typescript\nimport {annotations} from 'auto-annotations';\n\nchart.point().position([xField, yField]);\nchart.data(dataSource);\n\nannotations.annotateCluster(chart);\n\nchart.render();\n```\n![image.png](https://cdn.nlark.com/yuque/0/2021/png/171008/1614695380407-df7fb420-e0fc-485a-9f04-a4aa3610217c.png#align=left\u0026display=inline\u0026height=360\u0026margin=%5Bobject%20Object%5D\u0026name=image.png\u0026originHeight=720\u0026originWidth=1000\u0026size=90207\u0026status=done\u0026style=none\u0026width=500)\u003cbr /\u003e\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobservedobserver%2Fauto-annotation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobservedobserver%2Fauto-annotation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobservedobserver%2Fauto-annotation/lists"}