Skip to content

Commit d7b1f67

Browse files
feat: 新增画布onloaded方法
feat: 新增画布onloaded方法
2 parents 0a44119 + 6c14935 commit d7b1f67

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

README.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ the configuration of canvas
8585
| delayDraw | Delayed rendering. This component must ensure that the canvas container rendering (including animation execution) is completed before rendering, otherwise the coordinates will be offset, for example:Animation of Ant Design Modal | <font color="c41d7f"> number</font> | 0 |
8686
| autoLayout | custom layout | [autoLayout Prop](#auto-layout-prop)<font color="c41d7f"> {}</font> | - |
8787
| diffOptions | Collection of diff fields for node updates| Array&#60; string&#62; | - |
88+
| onLoaded | canvas loaded event| (data: {nodes, edges, groups}) => {} | - |
8889

8990
<br>
9091

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ npm install react-monitor-dag
8383
| delayDraw | 是否延迟加载 | <font color="c41d7f"> number</font> | 0 |
8484
| autoLayout | 自定义布局 | [autoLayout Prop](#auto-layout-prop)<font color="c41d7f"> {}</font> | - |
8585
| diffOptions | 节点更新时diff的字段集合| Array&#60; string&#62; | - |
86+
| onLoaded | 画布渲染之后的回调| (data: {nodes, edges, groups}) => {} | - |
87+
8688
<br>
8789

8890
### <a name='edge-prop'></a><b>edge</b>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-monitor-dag",
3-
"version": "1.0.18",
3+
"version": "1.0.19",
44
"description": "一个基于React的运维/监控DAG图",
55
"main": "dist/index.js",
66
"pack": "pack/index.js",

src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ interface ComProps {
8484
onContextmenuEdge?(edge: any): void, // 右键线段事件
8585
onContextmenuGroup?(edge: any): void, // 右键线段事件
8686
onChangePage?(data:any): void, // 分页事件
87+
onLoaded?(data: any): void // 画布加载完成之后的回调
8788
}
8889

8990
export default class MonitorDag extends React.Component<ComProps, any> {
@@ -178,7 +179,8 @@ export default class MonitorDag extends React.Component<ComProps, any> {
178179
}
179180
this.canvas = new Canvas(canvasObj);
180181
setTimeout(() => {
181-
this.canvas.draw(result, () => {
182+
this.canvas.draw(result, (data) => {
183+
this.props.onLoaded && this.props.onLoaded(data);
182184
let minimap = _.get(this, 'props.config.minimap', {});
183185
const minimapCfg = _.assign({}, minimap.config, {
184186
events: [

0 commit comments

Comments
 (0)