Skip to content

Commit

Permalink
feat(components):add Legend demos
Browse files Browse the repository at this point in the history
  • Loading branch information
pomelo-nwu committed Jan 10, 2021
1 parent d578d91 commit c242677
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/graphin-components/src/Legend/demos/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from 'react';
import Graphin, { Utils } from '@antv/graphin';
import { Legend } from '@antv/graphin-components';

const data = Utils.mock(5).circle().graphin();
data.nodes.forEach((node, index) => {
const isCompany = index % 3 === 0;
node.data.type = isCompany ? 'company' : 'person';
node.style = {
fill: isCompany ? 'red' : '#f79e26',
icon: {
type: 'font',
fontFamily: 'graphin',
value: isCompany ? 'company' : 'user',
},
};
});

const Demo = () => {
return (
<Graphin data={data}>
<Legend bindType="node" sortKey="data.type" colorKey="style.fill">
<Legend.Node />
</Legend>
</Graphin>
);
};

export default Demo;
2 changes: 2 additions & 0 deletions packages/graphin-components/src/Legend/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ nav:

Legend 图例是一种常见的图分析配套组件,通常将节点和边分类后进行染色,方便用户交互分析。其中点击图例有两种逻辑,一是高亮,即高亮选中的图例所对应的节点;二是过滤,即将未选中的节点隐藏。

<code src='./demos/index.tsx'>

## 功能特性

- 支持用户自定义 legend 的颜色映射
Expand Down

0 comments on commit c242677

Please sign in to comment.