美文网首页
18.1 节点工具

18.1 节点工具

作者: skoll | 来源:发表于2022-01-05 09:34 被阅读0次

自定义按钮上的节点工具

1 .点击实现一些别的操作
2 .

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/@antv/x6@1.1.1/dist/x6.js"></script>
</head>
<body>
    <h3>基本图形和属性</h3>
    <div id="container">

    </div>
    <script>
        const graph=new X6.Graph({
            container:document.getElementById('container'),
            width:800,
            height:600,
            grid:true,  
        })

        //这个竟然是都写在一起的,包括结构,样式,操作逻辑
        let button={
            name:"button",
            args:{
                markup:[
                  //结构:一个圆圈,一段文字
                  {
                      tagName:'circle',
                      selector:'button',
                      attrs:{
                          //这个圆圈的样式
                          r:14,
                          stroke:"#fe854f",
                          strokeWidth:2,
                          fill:"white",
                          cursor:'pointer'
                      }
                  },{
                      tagName:"text",
                      selector:"icon",
                      textContent:"删除",
                      attrs:{
                          fill:"#fe854f",
                          fontSize:5,
                          textAnchor:'middle',
                          pointerEvents:'none',
                          y:'0.3em',
                      }
                  }
                ],
                x:'100%',
                //整体调,直接到最右边

                offset:{
                    x:-20,
                    y:20
                    //细节调节,注意,这俩还必须一起出来使用,单独使用一个有报错
                },
                onClick(e){
                    console.log('cell被点击',e)
                }
            }
            
        }

        let node=graph.addNode({
            x:180,
            y:60,
            width:300,
            height:150,
            attrs:{
                body:{
                    fill:"#f5f5f5",
                    stroke:"#d9d9d9",
                    strokeWidth:1,
                }
            },
            tools:[button,]
            //单个节点带有的节点工具
        })
    </script>
</body>
</html>

上面是一个自定义的删除点击节点的工具,下面是库自带的

const source = graph.addNode({
  x: 180,
  y: 60,
  width: 100,
  height: 40,
  attrs: {
    body: {
      fill: '#f5f5f5',
      stroke: '#d9d9d9',
      strokeWidth: 1,
    },
  },
  tools: [
    {
      name: 'button-remove',
      args: {
        x: '100%',
        y: 0,
        offset: { x: -10, y: 10 },
      },
    },
  ],
})

工具包含

1 .删除按钮,包围盒,节点提示,节点文字可编辑
2 .节点提示.这个竟然是放在了react里面,onPortRendered函数里面,这里面实现这个功能就不是自带的了,而且能实现的也可以不仅仅在这里

let button={
            name:"button",
            args:{
                markup:[
                  //结构:一个圆圈,一段文字
                  {
                      tagName:'circle',
                      selector:'button',
                      attrs:{
                          //这个圆圈的样式
                          r:14,
                          stroke:"#fe854f",
                          strokeWidth:2,
                          fill:"white",
                          cursor:'pointer'
                      }
                  },{
                      tagName:"text",
                      selector:"icon",
                      textContent:"删除",
                      attrs:{
                          fill:"#fe854f",
                          fontSize:5,
                          textAnchor:'middle',
                          pointerEvents:'none',
                          y:'0.3em',
                      }
                  }
                ],
                x:'100%',
                //整体调,直接到最右边

                offset:{
                    x:-20,
                    y:20
                    //细节调节,注意,这俩还必须一起出来使用,单独使用一个有报错
                },
                onClick(e){
                    console.log('cell被点击',e)
                }
            }
            
        }

        graph.addNode({
            x: 350,
            y: 150,
            width: 80,
            height: 40,
            label: 'target',
          })

          graph.on('cell:dblclick', ({ cell, e }) => {
            cell.addTools([
              {
                name: cell.isEdge() ? 'edge-editor' : 'node-editor',
                args: {
                  event: e,
                },
              },
            ])
          })

相关文章

  • 18.1 节点工具

    自定义按钮上的节点工具 1 .点击实现一些别的操作2 . 上面是一个自定义的删除点击节点的工具,下面是库自带的 工...

  • 剑指offer(第二版)题目分类整理

    链表 ~~~6. 从尾到头打印链表 ###18.1 在 O(1) 时间内删除链表节点 需要分情况,是否是尾节点...

  • 【Excel系列】Excel数据分析:时间序列预测

    移动平均 18.1 移动平均工具的功能 “移动平均”分析工具可以基于特定的过去某段时期中变量的平均值,对未来值进行...

  • The Road of DBA 17_NoSQL_Some To

    工具扩容节点 扩容流程图 在db01上创建2个新节点 工具收缩节点 8.12 忘记节点 由于我们的集群是做了高可用...

  • 18 工具Tools

    简介 1 .工具是渲染在节点上/边上的小部件,用来增强节点/边的交互能力 节点的相关工具 1 .button2 ....

  • 2019-07-05 redis 工具扩容、收缩节点

    redis 工具扩容节点 1.在db01上创建新节点 2.在db01上启动新节点 3.使用工具发现节点并重新分配槽...

  • 论语18.1

    18.1微子去之①,箕子为之奴②,比干谏而死③。 孔子曰:“殷有三仁焉。” 注释 ①微子:名启,商王武乙的长子。据...

  • DatistEQ之2020 Q4 正式版更新说明

    一、根据科学研究一般流程,重新组织节点工具箱,节点分组更切合科学研究的需求。 参考:DatistEQ节点工具箱调整...

  • 程序化建模(三)

    copy节点工具 新建geo节点进入里面 Copy and Transfrom copy stamp 小案例 楼梯...

  • 节点信息工具组合

    本地使用DIG命令查询命中的结果可能来自缓存服务器——在不同的机器上执行dig +short domain.com...

网友评论

      本文标题:18.1 节点工具

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