Lively Kernel canvas
Draft-ProtoVisIntegration40true
savefalsenulltruenull
true
Wikicontroltruetrue
errorObj={}cbSuccess=function(result,context,operation){console.log('Success:'+result);varexplorer=newObjectExplorer({objectToExplore:result});explorer.openIn(WorldMorph.current(),pt(20,100));}cbFailure=function(error,context,operation){console.log('Error:'+error);errorObj=error;}svc=newSys.Data.OpenDataServiceProxy('http://services.odata.org/Northwind/Northwind.svc');truetruefalse
2truetrue
false00.11
true
false
true
nullfalsetruenull
Workspacefalsenulltruefalse
Xfalsenulltrue
false
false
–falsenulltrue
false
falsenullfalsefalsenullnullnullnullfalse
enableLayer(Microsoft2LKLayer);svc.query('/',function(result){successObj=result;if(typeofgraph!='undefined'){graph.remove();}graph=newDynamicNodeLinkTreeDiagram($morph('ProtoVisContainer'));functiontransform1(data){varres={};data.EntitySets.each(function(ea){res[ea]=undefined});returnres;}graph.setData(transform1(result));graph.render();/*graph.remove();*/},cbFailure);16truetruefalse
truetrue
false00.11
true
false
true
nullfalsetruenull
Workspacefalsenulltruefalse
Xfalsenulltrue
false
false
–falsenulltrue
false
falsenullfalsefalsenullnullnullnullfalse
ProtoVisDrawing.subclass('DynamicNodeLinkTreeDiagram',{initialize:function($super,parent){$super();this._LKparent=parent;this.setData({});this.isNative=false;},removeCanvas:function(){varc=this.canvas();if(!c||!c.parentNode)return;c.parentNode.removeChild(c);},render:function($super){$super();varself=this;functiontoLively(){vardrawingElems=[];varimporter=newImporter();varshapes=[];functionallChildNodesFrom(node,parent){$A(node.childNodes).each(function(ea){varshape=lively.scene.Shape.importFromNode(importer,ea);if(shape){if(parent)parent.add(shape);elseshapes.push(shape);}drawingElems.push(ea);allChildNodesFrom(ea,(shapeinstanceoflively.scene.Group?shape:undefined));});}allChildNodesFrom(self.vis.$canvas[0].firstChild);vardiagMorph=newMorph(newlively.scene.Group());diagMorph.shape.setFill(null);diagMorph.shape.setStroke(null);diagMorph.shape.rawNode.setAttributeNS(null,'stroke-width','1.5');diagMorph.shape.setContent(shapes);if(self._LKparent)self._LKparent.addMorph(diagMorph);elsediagMorph.openInWorld();self.removeCanvas();}this.isNative&&this._LKparent&&toLively();if(this._LKparent&&this._LKparent.origin){this.setPosition(this._LKparent.origin.subPt(pt(3,3)));}},setData:function(newData,rootName){functioncreate(data){varignoreKeys=['_namespace','_namespaces','_layer_object_id','xmlns'];varnode=newpv.Dom.Node;for(varkeyindata){if(!data.hasOwnProperty(key)||ignoreKeys.member(key))continue;varvalue=data[key];varsubNode=node.appendChild((typeofvalue!='object')?newpv.Dom.Node(value):create(value));subNode.nodeName=key;}returnnode;}varroot=create(pv.dom(newData).$map);root.nodeName=rootName||'root';root.nodeValue=null;this._rootNode=root;},createSubNodes:function(node){varsubNode=node.appendChild(newpv.Dom.Node());subNode.nodeName='SubNode';node.nodeValue=null;},draw:function(){varself=this;varw=(this._LKparent&&this._LKparent.getExtent())?this._LKparent.getExtent().x-4:400,h=(this._LKparent&&this._LKparent.getExtent())?this._LKparent.getExtent().y-4:650,colors=pv.Colors.category19();varvis=newpv.Panel().width(w).height(h).margin(2).fillStyle("white").event("mousedown",pv.Behavior.pan()).event("mousewheel",pv.Behavior.zoom());varroot=this._rootNode.sort(function(a,b){returnpv.naturalOrder(a.nodeName,b.nodeName)});varlayout=vis.add(pv.Layout.Indent).nodes(function(){returnroot.nodes()}).depth(12).breadth(15);layout.link.add(pv.Line);varnode=layout.node.add(pv.Panel).top(function(n){returnn.y-6}).height(12).right(6).strokeStyle(null).events("all").event("mousedown",toggle);node.anchor("left").add(pv.Dot).strokeStyle("#1f77b4").fillStyle(function(n){returnn.toggled||(typeofn.nodeValue=='undefined')?"#1f77b4":(n.firstChild?"#aec7e8":"#ff7f0e");}).title(functiont(d){returnd.parentNode?(t(d.parentNode)+"."+d.nodeName):d.nodeName;}).anchor('right').add(pv.Label).text(function(n){return(n.firstChild||n.toggled|| n.nodeValue==undefined?n.nodeName:n.nodeName+'='+n.nodeValue)}).font('14pxHelvetica');functiontoggle(n){if(typeofn.nodeValue=='undefined')self.createSubNodes(n);elsen.toggle(pv.event.altKey);returnlayout.reset().root;}root.nodes().each(function(ea){//ea.toggle();});returnvis;},});truetruefalse
78truetrue
false0.60425531914893620.11
true
false
true
nullfalsetruenull
Workspacefalsenulltruefalse
Xfalsenulltrue
false
false
–falsenulltrue
false
falsenullfalsefalsenullnullnullnullfalse
null228