Skip to content

Commit 55f1711

Browse files
authored
Merge pull request #266 from antvis/release/2.1.0
chore: release graphin 2.1.0
2 parents 24362d4 + 9d49a7f commit 55f1711

File tree

19 files changed

+161
-155
lines changed

19 files changed

+161
-155
lines changed

package.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"docs:build": "dumi build && node cname.js",
1212
"docs:deploy": "gh-pages -d dist",
1313
"docs:deploy-2": "gh-pages -d ./dist -r https://github.com/antvis/graphin-docs.git",
14-
"bootstrap": "lerna bootstrap --ignore @antv/graphin-studio --ignore graphin-site --ignore dumi-theme-graphin",
14+
"bootstrap": "lerna bootstrap --ignore @antv/graphin-studio --ignore graphin-site && npm run remove:deps",
15+
"remove:deps": "rm -rf packages/graphin/node_modules/antd && rm -rf packages/graphin/node_modules/@ant-design/icons && rm -rf packages/graphin-components/node_modules/antd && rm -rf packages/graphin-components/node_modules/@ant-design/icons && rm -rf packages/graphin-icons/node_modules/@ant-design/icons && rm -rf packages/graphin-icons/node_modules/antd && rm -rf packages/dumi-theme-graphin/node_modules/@ant-design/icons && rm -rf packages/dumi-theme-graphin/node_modules/antd",
1516
"bootstrap:ci": "lerna bootstrap --ignore @antv/graphin-studio --ignore graphin-site --ignore @antv/graphin-graphscope",
1617
"build": "lerna run build",
1718
"contributor": "git-contributor",
@@ -40,7 +41,7 @@
4041
"d3": "^6.3.1",
4142
"d3-selection": "^2.0.0",
4243
"dumi": "^1.1.0",
43-
"dumi-theme-graphin": "0.1.3",
44+
"dumi-theme-graphin": "file:packages/dumi-theme-graphin",
4445
"eslint": "^7.18.0",
4546
"eslint-config-airbnb": "^18.2.1",
4647
"eslint-config-prettier": "^7.2.0",
@@ -56,7 +57,7 @@
5657
"lint-staged": "^10.2.2",
5758
"prettier": "^2.2.1",
5859
"react-color": "^2.19.3",
59-
"react-pie-menu": "^0.2.5",
60+
"react-pie-menu": "^0.3.0",
6061
"styled-components": "^5.2.1",
6162
"typescript": "^4.1.3"
6263
},
@@ -73,11 +74,14 @@
7374
]
7475
},
7576
"dependencies": {
76-
"@ant-design/icons": "^4.5.0",
77-
"@antv/gatsby-theme-antv": "^1.0.8",
77+
"@ant-design/create-react-context": "^0.2.5",
78+
"@ant-design/icons": "^4.6.2",
79+
"@ant-design/icons-react": "^2.0.1",
80+
"@antv/gatsby-theme-antv": "latest",
7881
"antd": "^4.12.3",
79-
"react": "^16.11.0",
80-
"react-dom": "^16.11.0"
82+
"rc-footer": "^0.6.6",
83+
"react": "^17.0.1",
84+
"react-dom": "^17.0.1"
8185
},
8286
"repository": {
8387
"type": "git",

packages/dumi-theme-graphin/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"homepage": "http://github.com/antvis/graphin",
1717
"authors": [],
1818
"dependencies": {
19+
"@ant-design/icons": "^4.6.2",
1920
"prism-react-renderer": "^1.1.1",
2021
"prismjs": "^1.21.0",
2122
"rc-tabs": "^11.7.1",
@@ -29,11 +30,12 @@
2930
"dumi": "1.1.5-0",
3031
"father": "^2.30.1",
3132
"global-dirs": "^2.1.0",
32-
"react-test-renderer": "^16.13.1"
33+
"react-test-renderer": "^17.0.1"
3334
},
3435
"peerDependencies": {
36+
"@antv/gatsby-theme-antv": "latest",
3537
"@umijs/preset-dumi": "1.x",
36-
"react": "^16.13.1"
38+
"react": "^17.0.1"
3739
},
3840
"license": "MIT"
3941
}

packages/dumi-theme-graphin/src/components/Products/getProducts.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import {
42
AreaChartOutlined,
53
DingdingOutlined,
@@ -8,8 +6,10 @@ import {
86
HomeOutlined,
97
PieChartOutlined,
108
ReadOutlined,
11-
YuqueOutlined,
9+
YuqueOutlined
1210
} from '@ant-design/icons';
11+
import React from 'react';
12+
1313

1414
const tuple = <T extends string[]>(...args: T) => args;
1515
const Categories = tuple('basic', 'extension', 'ecology');
@@ -35,7 +35,7 @@ export type ValuesOf<T extends any[]> = T[number];
3535

3636
export const getProducts = ({
3737
t,
38-
language,
38+
language = 'zh',
3939
}: {
4040
t: (key: string) => string;
4141
language: string;

packages/graphin-components/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/graphin-components",
3-
"version": "2.0.7",
3+
"version": "2.1.0",
44
"description": "Components for graphin",
55
"main": "lib/index.js",
66
"module": "es/index.js",
@@ -52,9 +52,9 @@
5252
"@antv/util": "^2.0.10"
5353
},
5454
"peerDependencies": {
55-
"react": "^16.x",
56-
"react-dom": "^16.x",
57-
"@antv/graphin": "^2.0.0"
55+
"react": ">=16.9.0",
56+
"react-dom": ">=16.9.0",
57+
"@antv/graphin": "^2.*"
5858
},
5959
"publishConfig": {
6060
"access": "public"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
import { HullCfg as hullcfg, HullCfgStyle as hullcfgstyle, IHullProps as ihullprops } from './index';
3+
4+
export const IHullProps = (props: ihullprops) => {};
5+
6+
export const HullCfg = (props: hullcfg) => {};
7+
8+
export const HullCfgStyle = (props: hullcfgstyle) => {};

packages/graphin-components/src/Hull/demos/Simple.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import React from 'react';
21
import Graphin, { Utils } from '@antv/graphin';
2+
import React from 'react';
33
import Hull, { HullCfg } from '../index';
44
// Do not forget to import CSS
55

66
const Demo = () => {
77
const hullOptions: HullCfg[] = [
88
{
9-
members: ['node-1', 'node-2'], // 必须参数
9+
members: ['node-1', 'node-2', 'node-9'], // 必须参数
1010
},
1111
{
12-
members: ['node-node-3', 'node-4'],
12+
members: ['node-3', 'node-4'],
1313
type: 'bubble',
1414
padding: 10,
1515
style: {

packages/graphin-components/src/Hull/index.md

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,7 @@ Hull 轮廓包裹,是常见的一种图分析组件,可以将所属在一组
1818

1919
<code src='./demos/Simple.tsx'></code>
2020

21-
<API src='./index.tsx'></API>
22-
23-
## 用法
24-
25-
```tsx | pure
26-
import React from 'react';
27-
import ReactDOM from 'react-dom';
28-
import Graphin, { Utils } from '@antv/graphin';
29-
import { Hull } from '@antv/graphin-components';
30-
// Do not forget to import CSS
31-
32-
const App = () => {
33-
const hullOptions = [
34-
{
35-
members: ['node-1', 'node-2', 'node-7'], // 必须参数
36-
},
37-
{
38-
members: ['node-4', 'node-5'],
39-
type: 'bubble',
40-
padding: 10,
41-
style: {
42-
fill: 'lightgreen',
43-
stroke: 'green',
44-
},
45-
},
46-
];
47-
return (
48-
<div className="App">
49-
<Graphin data={Utils.mock(10).graphin()}>
50-
<Hull options={hullOptions} />
51-
</Graphin>
52-
</div>
53-
);
54-
};
55-
56-
const rootElement = document.getElementById('root');
57-
ReactDOM.render(<App />, rootElement);
58-
```
21+
<API src='./api-docs.ts'></API>
5922

6023
## 功能特性
6124

packages/graphin-components/src/Hull/index.tsx

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1+
import { GraphinContext, GraphinContextType } from '@antv/graphin';
12
import React from 'react';
23

3-
// @ts-ignore
4-
import { GraphinContext } from '@antv/graphin';
5-
64
const defaultHullCfg = {
7-
id: `${Math.random()}`, // Utils.uuid(),
85
members: [],
96
type: 'round-convex',
107
nonMembers: [],
@@ -34,30 +31,51 @@ const deepMergeCfg = (defaultCfg: typeof defaultHullCfg, cfg: HullCfg) => {
3431
};
3532
};
3633

34+
export interface HullCfgStyle {
35+
/**
36+
* @description 填充颜色
37+
* @default 'lightblue'
38+
*/
39+
fill: string;
40+
/**
41+
* @description 描边颜色
42+
* @default 'blue'
43+
*/
44+
stroke: string;
45+
/**
46+
*
47+
* @description 透明度
48+
* @default 0.2
49+
*/
50+
opacity: number;
51+
}
3752
export interface HullCfg {
38-
/** 在包裹内部的节点实例或节点 Id 数组 */
53+
/**
54+
* @description 在包裹内部的节点实例或节点 Id 数组
55+
* @default []
56+
*
57+
*/
3958
members: string[];
40-
/** 包裹的 id */
59+
/**
60+
* 包裹的 id
61+
*/
4162
id?: string;
4263
/**
43-
* 包裹的类型
64+
* @description 包裹的类型
4465
* round-convex: 生成圆角凸包轮廓,
4566
* smooth-convex: 生成平滑凸包轮廓
4667
* bubble: 产生一种可以避开 nonMembers 的平滑凹包轮廓(算法)。
47-
* 默认值是 round-convex。 */
68+
* @default round-convex
69+
*/
4870
type?: 'round-convex' | 'smooth-convex' | 'bubble';
4971
/** 不在轮廓内部的节点数组,只在 bubble 类型的包裹中生效 */
5072
nonMembers?: string[];
5173
/** 轮廓的样式属性 */
52-
style?: Partial<{
53-
/** 填充颜色 */
54-
fill: string;
55-
/** 描边颜色 */
56-
stroke: string;
57-
/** 透明度 */
58-
opacity: number;
59-
}>;
60-
/** 轮廓边缘和内部成员的间距 */
74+
style?: Partial<HullCfgStyle>;
75+
/**
76+
* @description 轮廓边缘和内部成员的间距
77+
* @default 10
78+
*/
6179
padding?: number;
6280
}
6381

@@ -71,20 +89,25 @@ export interface IHullProps {
7189
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7290
let hullInstances: any[];
7391

74-
const Hull: React.FunctionComponent<IHullProps> = (props) => {
75-
const graphin = React.useContext(GraphinContext);
92+
const Hull: React.FunctionComponent<IHullProps> = props => {
93+
const graphin = React.useContext<GraphinContextType>(GraphinContext);
94+
const { graph } = graphin;
7695

7796
React.useEffect(() => {
78-
// @ts-ignore
79-
const { graph } = graphin;
8097
const { options } = props;
8198

82-
hullInstances = options.map((item) => {
83-
return graph.createHull(deepMergeCfg(defaultHullCfg, item));
99+
hullInstances = options.map(item => {
100+
return graph.createHull(
101+
// @ts-ignore
102+
deepMergeCfg(defaultHullCfg, {
103+
id: `${Math.random()}`, // Utils.uuid(),
104+
...item,
105+
}),
106+
);
84107
});
85108

86109
const handleAfterUpdateItem = () => {
87-
hullInstances.forEach((item) => {
110+
hullInstances.forEach(item => {
88111
item.updateData(item.members);
89112
});
90113
};
@@ -93,7 +116,7 @@ const Hull: React.FunctionComponent<IHullProps> = (props) => {
93116
return () => {
94117
graph.on('afterupdateitem', handleAfterUpdateItem);
95118
};
96-
}, []);
119+
}, [graph]);
97120

98121
return <div className="graphin-hull-container" />;
99122
};

packages/graphin-components/src/LayoutSelector/demos/LayoutSelectorDemo.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ const LayoutConfigPanel = ({ updateLayout, layoutConfig = graphLayoutConfig }) =
118118

119119
// 更新布局参数
120120
const updateLayoutConfig = (changedField, allFields, layoutType) => {
121-
const currentFileds = { ...allFields, ...changedField };
122-
Object.keys(currentFileds).forEach(key => {
123-
defaultValue[key] = currentFileds[key];
121+
const currentFields = { ...allFields, ...changedField };
122+
Object.keys(currentFields).forEach(key => {
123+
defaultValue[key] = currentFields[key];
124124
});
125-
const { x, y, ...others } = currentFileds;
125+
const { x, y, ...others } = currentFields;
126126
const config = others;
127127
if (layoutType === 'grid') {
128128
config.begin = [x, y];
@@ -146,7 +146,7 @@ const LayoutConfigPanel = ({ updateLayout, layoutConfig = graphLayoutConfig }) =
146146

147147
/**
148148
* 当字段值改变后,自动更新布局
149-
* @param changedFiled 改变了的字段
149+
* @param changedField 改变了的字段
150150
* @param allFields 所有字段
151151
*/
152152
const handleFieldValueChange = (changedField, allFields) => {

packages/graphin-components/src/Legend/index.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React from 'react';
21
import {
3-
GraphinContext,
2+
EdgeConfig,
43
Graph,
54
GraphData,
6-
TreeGraphData,
7-
NodeConfig,
8-
EdgeConfig,
5+
GraphinContext,
96
GraphinContextType,
7+
NodeConfig,
8+
TreeGraphData,
109
} from '@antv/graphin';
10+
import React from 'react';
1111
import Node from './Node';
1212

1313
export interface LegendProps {
@@ -43,6 +43,9 @@ const getEnumValue = (keyString: string, data) => {
4343
const enumValue = keyArray.reduce((acc, curr) => {
4444
return acc[curr] || {};
4545
}, data) as string;
46+
if (typeof enumValue === 'object') {
47+
return 'others';
48+
}
4649
return enumValue;
4750
};
4851

0 commit comments

Comments
 (0)