美文网首页AntvX6
AntvX6-Graph-Edge

AntvX6-Graph-Edge

作者: 泛滥的小愤青 | 来源:发表于2021-04-08 16:55 被阅读0次
来两个Node,添加Edge
      const source = this.graph.addNode({
        // shape: 'react',
        x: 250,
        y: 50,
        width: 100,
        height: 40,
        shape: 'rect',
        attrs: { label: { text: 'source-起点' } }
      })
      // C
      const target = this.graph.addNode({
        x: 350,
        y: 150,
        width: 100,
        height: 40,
        shape: 'circle',
        attrs: { label: { text: 'target-终点' } }
      })
      // 添加边
      this.graph.addEdge({
        source,
        target,
        attrs: {
          line: {
            stroke: 'red', // #a0a0a0
            strokeWidth: 1
          }
        }
      })
image.png
可以自定义边
      // 添加边
      this.graph.addEdge({
        source,
        target,
        attrs: {
          line: {
            stroke: 'red', // #a0a0a0
            strokeWidth: 1,
            // 自定义的
            targetMarker: {
              tagName: 'path',
              fill: 'yellow', // 使用自定义填充色
              stroke: 'green', // 使用自定义边框色
              strokeWidth: 2,
              d: 'M 20 -10 0 0 20 10 Z'
            }
          }
        }
      })
image.png

相关文章

网友评论

    本文标题:AntvX6-Graph-Edge

    本文链接:https://www.haomeiwen.com/subject/ipsvkltx.html