html定义不同的类,定义不同的节点类型.html

定义不同的节点类型

* {

margin: 0;

padding: 0;

}

.container {

display: flex;

height: 100vh;

}

.left-nav {

width: 275px;

background-color: rgba(154, 205, 50, 0.3);

}

.right-container {

flex: 1;

background-color: rgba(0, 0, 255, 0.2);

}

if (window.goSamples) goSamples()

var $ = go.GraphObject.make;

var dragContent = $(go.Diagram, "dragContent", {

initialContentAlignment: go.Spot.Center,

"toolManager.mouseWheelBehavior": go.ToolManager.WheelZoom,//缩放

"clickCreatingTool.archetypeNodeData": {text: "new node"},//通过点击创建一个节点

allowDrop: true, // must be true to accept drops from the Palette

"animationManager.duration": 800, // slightly longer than default (600ms) animation

"undoManager.isEnabled": true, // enable undo & redo

"grid.visible": true//绘制网格

})

//position 面板(Panels)

dragContent.add(

$(go.Node, "Position", {background: "lightgray"},

$(go.TextBlock, "100,100", {position: new go.Point(100, 100), background: "red"}),

$(go.TextBlock, "500,200", {position: new go.Point(500, 200)})

)

)

//Vertical 垂直 面板(Panels)isOpposite:true 限定从上往下还是从下往上

dragContent.add(

$(go.Node, "Vertical", {background: "lightgray", isOpposite: true},

$(go.Shape, "Rectangle", {

width: "50", height: "50", alignment: go.Spot.Top, stroke: "red"

}),

$(go.Shape, "Rectangle", {

width: "50", height: "50", alignment: go.Spot.Top, stroke: "blue "

}),

$(go.TextBlock, "测试", {})

)

)

//Horizontal 水平 面板(Panels) isOpposite:true 限定从左往右还是从右往左

dragContent.add(

$(go.Node, "Horizontal", {background: "lightgray", isOpposite: true},

$(go.Shape, "Rectangle", {

width: "50", height: "50"

}),

$(go.TextBlock, "测试", {})

)

)

//Spot 水平 面板(Panels) isClipping: true 截取图形

dragContent.add(

$(go.Part, "Spot", {scale: 1, isClipping: true},

$(go.Shape, "Circle", {

width: 55, height: 55

}),

$(go.Picture, "cat1.jpg", {width: 50, height: 50})

)

)

dragContent.add(

// all Parts are Panels

$(go.Part, "Table", // or "Table"

$(go.TextBlock, "row 0\ncol 0",

{row: 0, column: 0, margin: 2, background: "lightgray"}),

$(go.TextBlock, "row 0\ncol 1",

{row: 0, column: 1, margin: 2, background: "lightgray"}),

$(go.TextBlock, "row 1\ncol 0",

{row: 1, column: 0, margin: 2, background: "lightgray"}),

$(go.TextBlock, "row 1\ncol 2",

{row: 1, column: 2, margin: 2, background: "lightgray"})

));

dragContent.add(

// all Parts are Panels

$(go.Part, "Table", // or "Table"

$(go.Shape, "Rectangle", {

fill: "red",

row: 0, column: 1

}),

$(go.Shape, "Rectangle", {

fill: "red",

row: 1, column: 2

}),

$(go.Shape, "Rectangle", {

fill: "red",

row: 2, column: 3

}),

$(go.Shape, "Rectangle", {

fill: "red",

row: 3, column: 4

}),

$(go.Shape, "Rectangle", {

fill: "red",

row: 4, column: 5

})

));

dragContent.addDiagramListener("ViewportBoundsChanged", function (e) {//图形中有变动执行此事件

console.log(dragContent.scale)

// dragContent.add(

// $(go.Node, "Position",

// $(go.TextBlock, dragContent.scale, {color: "red", position: new go.Point(100, 100)})

// )

// )

})

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值