Commit 060a1194 authored by 周远喜's avatar 周远喜

gojs

parent 328e4b3d
...@@ -87,12 +87,16 @@ export default { ...@@ -87,12 +87,16 @@ export default {
let $ = go.GraphObject.make; let $ = go.GraphObject.make;
this.go = $(go.Diagram, "card", { this.go = $(go.Diagram, "card", {
"undoManager.isEnabled": true, // enable Ctrl-Z to undo and Ctrl-Y to redo "undoManager.isEnabled": true, // enable Ctrl-Z to undo and Ctrl-Y to redo
layout: $( // layout: $(
go.TreeLayout, // specify a Diagram.layout that arranges trees // go.TreeLayout, // specify a Diagram.layout that arranges trees
{ angle: 90, layerSpacing: 35 } // { angle: 90, layerSpacing: 35 }
) // ),
// nodeSelectionAdornmentTemplate:
// $(go.Adornment, "Auto",
// $(go.Shape, "Rectangle", { fill: "red", stroke: "red" ,strokeWidth:2}),
// )
}); });
var myModel = $(go.TreeModel); var myModel = $(go.TreeModel);
// in the model data, each node is represented by a JavaScript object: // in the model data, each node is represented by a JavaScript object:
...@@ -105,16 +109,39 @@ export default { ...@@ -105,16 +109,39 @@ export default {
"Hi,henq", "Hi,henq",
{ margin: 12, stroke: "#fff", font: "bold 16px '宋体'" }, { margin: 12, stroke: "#fff", font: "bold 16px '宋体'" },
new go.Binding("text", "name") new go.Binding("text", "name")
),{ ),
contextClick:(e,obj)=>{ {
contextClick: (e, obj) => {
// alert(obj.data.key+":"+obj.data.name); // alert(obj.data.key+":"+obj.data.name);
console.warn("info",e,obj) console.warn("info", e, obj);
this.onContextmenu(e.event,obj.data) this.onContextmenu(e.event, obj.data);
}, },
doubleClick:(e,obj)=>{ doubleClick: (e, obj) => {
alert(321); alert(321);
} },
} angle: 45,
// mouseEnter:(e,obj)=>{
// console.warn(e,obj);
// if(obj.part){
// obj.part.fill="red"
// }
// }
// mouseEnter: function(e, obj) {
// console.log(obj)
// obj.background = "green";
// obj.stroke = "dodgerblue";
// obj.toolTip="hello henq!"
// },
// mouseLeave: function(e, obj) {
// obj.background = "orange";
// obj.opacity = 1;
// obj.strokeWidth = 2;
// obj.stroke = "gray";
// }
},
new go.Binding("background","isSelected",(v)=>{
return v?"green":"red"
}).ofObject()
); );
this.go.linkTemplate = $( this.go.linkTemplate = $(
go.Link, go.Link,
...@@ -122,8 +149,9 @@ export default { ...@@ -122,8 +149,9 @@ export default {
$(go.Shape, { strokeWidth: 1, stroke: "#ddd" }) $(go.Shape, { strokeWidth: 1, stroke: "#ddd" })
); // the link shape ); // the link shape
myModel.nodeDataArray = this.data; // myModel.nodeDataArray = this.data;
this.go.model = myModel; this.go.model = myModel;
this.go.add($(go.Part, "Table",$(go.Picture,{source:"/static/logo.png",margin:10,column:1})))
}, },
svg() { svg() {
this.show = !this.show; this.show = !this.show;
...@@ -134,9 +162,9 @@ export default { ...@@ -134,9 +162,9 @@ export default {
maxSize: new go.Size(1200, NaN) maxSize: new go.Size(1200, NaN)
}); });
console.log(this.$refs.svg); console.log(this.$refs.svg);
this.$nextTick(()=>{ this.$nextTick(() => {
document.getElementById("svg").appendChild(svg); document.getElementById("svg").appendChild(svg);
}) });
} }
}, },
onContextmenu(event, a) { onContextmenu(event, a) {
...@@ -208,11 +236,11 @@ export default { ...@@ -208,11 +236,11 @@ export default {
background-color: white; background-color: white;
top: 150px; top: 150px;
left: 0; left: 0;
rect{ rect {
// fill:wheat; // fill:wheat;
cursor: pointer; cursor: pointer;
} }
rect:hover{ rect:hover {
fill: tomato; fill: tomato;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment