Skip to content

Commit

Permalink
docs: add demo for config interacting for one node (antvis#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector authored Feb 25, 2021
1 parent 806507e commit 7ee3bc3
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions sites/x6-sites/examples/showcase/faq/demo/change-mode.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { Graph } from '@antv/x6'
import { Graph, CellView } from '@antv/x6'
import { Switch } from 'antd'

const interactingLabel = {
nodeMovable: '移动节点',
magnetConnectable: '连接连接桩',
edgeMovable: '移动边',
edgeLabelMovable: '移动标签',
Expand All @@ -19,7 +18,10 @@ class Example extends React.Component {

state = {
interactingMap: {
nodeMovable: true,
nodeMovable: (view: CellView) => {
const cell = view.cell
return cell.prop('movable') === true
},
magnetConnectable: true,
edgeMovable: true,
edgeLabelMovable: true,
Expand All @@ -45,6 +47,7 @@ class Example extends React.Component {
y: 80,
width: 80,
height: 40,
label: 'A',
attrs: {
body: {
stroke: '#9254de',
Expand All @@ -63,7 +66,25 @@ class Example extends React.Component {
},
},
}
]
],
})

graph.addNode({
shape: 'rect',
x: 80,
y: 180,
width: 80,
height: 40,
label: 'B',
attrs: {
body: {
stroke: '#9254de',
fill: '#efdbff',
rx: 2,
ry: 2,
}
},
movable: true
})

graph.addEdge({
Expand Down Expand Up @@ -103,7 +124,7 @@ class Example extends React.Component {
<div className="x6-graph-wrap" style={{ width: '100%', height: '100%' }}>
<div ref={this.refContainer} className="x6-graph" />
<div style={{ position: 'absolute', top: 116, right: 16, lineHeight: 3, textAlign: 'right' }}>
{Object.keys(this.state.interactingMap).map((item: keyof typeof interactingLabel) => (
{Object.keys(interactingLabel).map((item: keyof typeof interactingLabel) => (
<div key={item}>
<span>{interactingLabel[item]}</span>
<Switch
Expand Down

0 comments on commit 7ee3bc3

Please sign in to comment.