MCPcopy Index your code
hub / github.com/VisActor/VGrammar

github.com/VisActor/VGrammar @v0.16.9

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.16.9 ↗ · + Follow
2,920 symbols 8,547 edges 672 files 74 documented · 3% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

VisActor Logo VisActor Logo

VGrammar

VGrammar,不只是生成万千图表的可视化语法,更是化枯燥为神奇的数据魔法师。

简介Demo教程API配置

image test unit test npm Version npm Download license

English | 简体中文 | 日本語

(演示视频)

简介

VGrammar 是 VisActor 可视化体系中的可视化语法库,基于可视化渲染引擎 VRender 进行组件封装。核心能力如下:

  1. 默认好用:语法简洁,接口完备,组件丰富,开发简单;
  2. 能力丰富:图表定义,动画编排,艺术表达,完整覆盖;
  3. 灵活扩展:图元渲染,数据映射,自动布局,轻松扩展;

仓库简介

本仓库包含如下 package

  1. VGrammar: 图形语法

使用

安装

npm package

// npm
npm install @visactor/vgrammar

// yarn
yarn add @visactor/vgrammar

快速上手

import { View } from '@visactor/vgrammar';

const spec = {
  data: [
    {
      id: 'table',
      values: [
        {
          value: 3676,
          name: ' ~ 29'
        },
        {
          value: 3872,
          name: '30 ~ 39'
        },
        {
          value: 1668,
          name: '40 ~ 49'
        },
        {
          value: 610,
          name: '50 ~'
        }
      ]
    },
    {
      id: 'pie',
      source: 'table',
      transform: [
        {
          type: 'pie',
          field: 'value',
          asStartAngle: 'startAngle',
          asEndAngle: 'endAngle'
        }
      ]
    }
  ],

  scales: [
    {
      id: 'colorScale',
      type: 'ordinal',
      domain: { data: 'table', field: 'name' },
      range: [
        '#6690F2',
        '#70D6A3',
        '#B4E6E2',
        '#63B5FC',
        '#FF8F62',
        '#FFDC83',
        '#BCC5FD',
        '#A29BFE',
        '#63C4C7',
        '#F68484'
      ]
    }
  ],

  marks: [
    {
      type: 'arc',
      from: { data: 'pie' },
      dependency: ['viewBox', 'colorScale'],
      encode: {
        update: (datum, element, params) => {
          const viewBox = params.viewBox;
          const maxR = Math.min(viewBox.width() / 2, viewBox.height() / 2);
          return {
            x: viewBox.x1 + viewBox.width() / 2,
            y: viewBox.y1 + viewBox.height() / 2,
            startAngle: datum.startAngle,
            endAngle: datum.endAngle,
            innerRadius: 100,
            outerRadius: maxR,
            fill: params.colorScale.scale(datum.name)
          };
        },
        hover: {
          fill: 'red'
        }
      }
    }
  ]
};

const vGrammarView = new View({
  autoFit: true,
  container: 'chart',
  hover: true
});
vGrammarView.parseSpec(spec);

vGrammarView.runAsync();

更多 demo 和详细教程

相关链接

生态

项目 介绍

| VChart | 基于 VisActor/VGrammar 封装的图表库。 | | React 组件库 | 基于 VisActor/VChart 的 React 图表 组件库。 | | 智能生成组件 | 基于 AI 的智能图表生成组件 |

参与贡献

如想参与贡献,请先阅读 行为准则贡献指南

细流成河,终成大海!

许可证

MIT 协议

Extension points exported contracts — how you extend this code

IProgressiveTransformResult (Interface)
(no doc) [3 implementers]
packages/vgrammar-core/src/types/transform.ts
ICartesianCoordinate (Interface)
(no doc) [1 implementers]
packages/vgrammar-coordinate/src/interface.ts
CLIArgs (Interface)
(no doc)
tools/bundler/src/logic/config.ts
FieldGetterGeneratorOptions (Interface)
(no doc)
packages/vgrammar-util/src/types/function.ts
TreemapOptions (Interface)
(no doc)
packages/vgrammar-hierarchy/src/interface.ts
IGridLayoutOptions (Interface)
(no doc)
packages/vgrammar-wordcloud/src/grid-layout.ts
SankeyOptions (Interface)
(no doc)
packages/vgrammar-sankey/src/interface.ts
IVennTransformOptions (Interface)
(no doc)
packages/vgrammar-venn/src/interface.ts

Core symbols most depended-on inside this repo

forEach
called by 457
packages/vgrammar-core/src/util/unique-list.ts
getGraphicAttribute
called by 412
packages/vgrammar-core/src/graph/element.ts
push
called by 401
packages/vgrammar-core/src/util/grammar-heap.ts
scale
called by 271
packages/vgrammar-core/src/view/View.ts
encode
called by 269
packages/vgrammar-core/src/view/mark.ts
domain
called by 161
packages/vgrammar-core/src/view/scale.ts
range
called by 151
packages/vgrammar-core/src/view/scale.ts
getGraphicItem
called by 145
packages/vgrammar-core/src/graph/element.ts

Shape

Function 1,224
Method 1,052
Interface 381
Class 242
Enum 21

Languages

TypeScript100%

Modules by API surface

packages/vgrammar-core/src/view/View.ts96 symbols
packages/vgrammar-plot/src/semantic-mark.ts73 symbols
packages/vgrammar-core/src/view/mark.ts67 symbols
packages/vgrammar-core/src/types/interaction.ts64 symbols
packages/vgrammar-core/src/types/transform.ts49 symbols
packages/vgrammar-core/src/graph/element.ts46 symbols
packages/vgrammar-plot/src/plot.ts38 symbols
packages/vgrammar-core/src/graph/animation/animate.ts37 symbols
packages/vgrammar-core/src/parse/scale.ts36 symbols
packages/vgrammar-sankey/src/layout.ts32 symbols
packages/vgrammar-core/src/view/grammar-record.ts32 symbols
docs/site/libs/template-parse/etpl.js31 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add VGrammar \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact