gojs实现可折叠类实例属性方法关系图效果代码
代码语言:html
所属分类:图表
代码描述:gojs实现可折叠类实例属性方法关系图效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" /> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/go.js"></script> <script type="text/javascript"> function init() { // Since 2.2 you can also author concise templates with method chaining instead of GraphObject.make // For details, see https://gojs.net/latest/intro/buildingObjects.html const $ = go.GraphObject.make; myDiagram = new go.Diagram("myDiagramDiv", { "undoManager.isEnabled": true, layout: $(go.TreeLayout, { // this only lays out in trees nodes connected by "generalization" links angle: 90, path: go.TreeLayout.PathSource, // links go from child to parent setsPortSpot: false, // keep Spot.AllSides for link connection spot setsChildPortSpot: false, // keep Spot.AllSides // nodes not connected by "generalization" links are laid out horizontally arrangement: go.TreeLayout.ArrangementHorizontal }) }); // show visibility or access as a single character at the beginning of each property or method function convertVisibility(v) { switch (v) { case "public": return "+"; case "private": return "-"; case "protected": return "#"; case "package": return "~"; default: return v; } } // the item template for properties var propertyTemplate = $(go.Panel, "Horizontal", // property visibility/access $(go.TextBlock, { isMultiline: false, editable: false, width: 12 }, new go.Binding("text", "visibility", convertVisibility)), // property name, underlined if scope=="class" to indicate static property $(go.TextBlock, { isMultiline: false, editable: true }, new go.Binding("text", "name").makeTwoWay(), new go.Binding("isUnderline", "scope", s => s[0] === 'c')), // property type, if known $(go.TextBlock, "", new go.Binding("text", "type", t => t ? ": " : "")), $(go.TextBlock, { isMultiline: false, editable: true }, new go.Binding("text", "type").makeTwoWay()), // property default value, if any $(go.TextBlock, { isMultiline: false, editable: false }, new go.Binding("text", "default", s => s ? " = " + s : "")) ); // the item template for methods var methodTemplate = $(go.Panel, "Horizontal", // method visibility/access $(go.TextBlock, { isMultiline: false, editable: false, width: 12 }, new go.Binding("text", "visibility", convertVisibility)), // method name, underlined if scope=="class" to indicate static method $(go.TextBlock, { isMultiline: false, editable: true }, new go.Binding("text", "name").makeTwoWay(), new go.Binding("isUnderline", "scope", s => s[0] === 'c')), // method parameters $(go.TextBlock, "()", // this does not permit adding/editing/removing of parameters via inplace edits new go.Binding("text", "parameters", parr => { var s .........完整代码请登录后点击上方下载按钮下载查看
网友评论0