Lively Kernel canvas Draft-ProtoVis40true savefalsenulltruenull http://services.odata.org/Northwind/Northwind.svc14true ServiceURL:14true Getmetadatafalsenulltruefalsetrue Displaymetadatafalsenulltruefalsetrue Removediagramfalsenulltruefalsetrue true AlternativeURLs:http://services.odata.org/Northwind/Northwind.svchttp://services.odata.org/(S(asp33mq1bcq1qqxbcgikeccu))/OData/OData.svc142 Wikicontroltruetrue ProtoVisDrawing.subclass('NodeLinkTreeDiagram',{initialize:function($super,data,url){$super();this.data=data;this.url=url||'http://services.odata.org/Northwind/Northwind.svc'},createRootNode:function(){if(this._rootNode)returnthis._rootNode;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(this.data).$map);root.nodeName='Metadata';this._rootNode=root;returnroot;},nodeClickHandler:function(data){if(data.nodeName=='Name'){vars=newSys.Data.OpenDataServiceProxy(this.url);varquery=data.nodeValue;functioncbSuccess(result,context,operation){console.log('Success:'+result);varexplObj={};explObj[query]=result;explObj.toString=function(){returnquery};varexplorer=newObjectExplorer({objectToExplore:explObj});explorer.openIn(WorldMorph.current(),pt(500,100));}functioncbFailure(error,context,operation){console.log('Error:'+error);errorObj=error;varexplorer=newObjectExplorer({objectToExplore:serviceData});explorer.openIn(WorldMorph.current(),pt(500,100));}withLayers([Microsoft2LKLayer],function(){s.query('/'+query,cbSuccess,cbFailure);});}elseif(data.nodeName=='EntityType'){varspace=data.nodeValue.split('.');varns=space[0];varet=space[1];varschema=this.data.DataServices[0].Schema.detect(function(ea){returnea.Namespace&&(ea.Namespace==ns);});if(schema){varentityType=schema.EntityType.detect(function(ea){returnea.Name&&(ea.Name==et);});varexplObj=Object.clone(entityType);varexplorer=newObjectExplorer({objectToExplore:explObj});explorer.openIn(WorldMorph.current(),pt(500,100));}}},draw:function(){varself=this;varw=400,h=650,colors=pv.Colors.category19();varvis=newpv.Panel().width(w).height(h).margin(5).fillStyle("white").event("mousedown",pv.Behavior.pan()).event("mousewheel",pv.Behavior.zoom());varroot=this.createRootNode().sort(function(a,b){returnpv.naturalOrder(a.nodeName,b.nodeName)});varlayout=vis.add(pv.Layout.Indent).nodes(function(){returnroot.nodes()}).depth(12).breadth(12);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?"#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.nodeName:n.nodeName+'='+n.nodeValue)});node.anchor('right').add(pv.Dot).strokeStyle('white').shape('diamond').fillStyle(function(n){if((n.parentNode)&&(n.parentNode.parentNode)&&(n.parentNode.parentNode.nodeName=='EntitySet')){if(n.nodeName=='Name')return'green';if(n.nodeName=='EntityType')return'red';}return'white';}).event("click",function(){self.nodeClickHandler(this.data());});functiontoggle(n){n.toggle(pv.event.altKey);returnlayout.reset().root;}root.nodes().each(function(ea){ea.toggle();});returnvis;},});147truetruefalse truetruefalse false00.11 true false truefalse nullfalsetruenullfalse Graphbuildingfalsenulltruefalse Xfalsenulltrue false false Mfalsenulltrue false false falsenulltrue false falsenullfalse nullnullnullnullnullnullnullnullnullnullnullnull504 nullnull503.9 nullnull507falsefalse createLayer('SmartObjectLayer');layerClass(SmartObjectLayer,Object,{each:function(proceed,func){for(varkeyinthis){if(typeofthis[key]!='function'){func(key,this[key]);}}},select:function(proceed,func,asObject){asObject=asObject||false;varres;if(asObject)res={};elseres=[];for(varkeyinthis){if((typeofthis[key]!='function')&&func(key,this[key])){if(asObject)res[key]=this[key];elseres.push(key);}}returnres;},detect:function(proceed,func,asObject){asObject=asObject||false;varres=null;for(varkeyinthis){if((typeofthis[key]!='function')&&func(key,this[key])){if(asObject){res={};res[key]=this[key];}elseres=key;break;}}returnres;},});enableLayer(SmartObjectLayer);Object.subclass('XMLJSONPrettifier',{});Object.extend(XMLJSONPrettifier,{makePretty:function(input){varoutput={};input.each(function(key,value){if((key=='children')&&(valueinstanceofArray)){varsubs=output;value.each(function(ea){vartagName=ea['tagName'];varns=undefined;if(tagName.indexOf(':')>=0){ns=tagName.substring(0,tagName.indexOf(':'));tagName=tagName.substring(tagName.indexOf(':')+1);}if(tagName&&(tagName!='textNode')){subs[tagName]=subs[tagName]||[];subs[tagName].push(XMLJSONPrettifier.makePretty(ea));}if(ns)subs[tagName]._namespace=ns;});}elseif(key.startsWith('xmlns:')){output['_namespaces']=output['_namespaces']||{};output['_namespaces'][key.substr(6)]=value;}elseif(key=='tagName'){//donothing}else{varns;if(key.indexOf(':')>=0){ns=key.substring(0,key.indexOf(':'));key=key.substring(key.indexOf(':')+1);}if(parseInt(value).toString()==value)output[key]=parseInt(value);elseif(value=='true')output[key]=true;elseif(value=='false')output[key]=false;elseoutput[key]=value;if(ns)output[key]._namespace=ns;}});returnoutput;}});= 0) {\n\t\t\t\t\t\tns = tagName.substring(0, tagName.indexOf(':'));\n\t\t\t\t\t\ttagName = tagName.substring(tagName.indexOf(':') + 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (tagName && (tagName != 'textNode')) {\n\t\t\t\t\t\tsubs[tagName] = subs[tagName] || [];\n\t\t\t\t\t\tsubs[tagName].push(XMLJSONPrettifier.makePretty(ea));\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ns)\n\t\t\t\t\t\tsubs[tagName]._namespace = ns;\n\t\t\t\t});\n\t\t\t} else if (key.startsWith('xmlns:')) {\n\t\t\t\toutput['_namespaces'] = output['_namespaces'] || {};\n\t\t\t\toutput['_namespaces'][key.substr(6)] = value;\n\t\t\t} else if (key == 'tagName') {\n\t\t\t\t// do nothing\n\t\t\t} else {\n\t\t\t\tvar ns;\n\t\t\t\tif (key.indexOf(':') >= 0) {\n\t\t\t\t\tns = key.substring(0, key.indexOf(':'));\n\t\t\t\t\tkey = key.substring(key.indexOf(':') + 1);\n\t\t\t\t}\n\n\t\t\t\tif (parseInt(value).toString() == value)\n\t\t\t\t\toutput[key] = parseInt(value);\n\t\t\t\telse if (value == 'true')\n\t\t\t\t\toutput[key] = true;\n\t\t\t\telse if (value == 'false')\n\t\t\t\t\toutput[key] = false;\n\t\t\t\telse\n\t\t\t\t\toutput[key] = value;\n\n\t\t\t\tif (ns)\n\t\t\t\t\toutput[key]._namespace = ns;\n\t\t\t}\n\t\t});\n\n\t\treturn output;\n\t}\n});\n"]]>= 0) {\n\t\t\t\t\t\tns = tagName.substring(0, tagName.indexOf(':'));\n\t\t\t\t\t\ttagName = tagName.substring(tagName.indexOf(':') + 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (tagName && (tagName != 'textNode')) {\n\t\t\t\t\t\tsubs[tagName] = subs[tagName] || [];\n\t\t\t\t\t\tsubs[tagName].push(XMLJSONPrettifier.makePretty(ea));\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ns)\n\t\t\t\t\t\tsubs[tagName]._namespace = ns;\n\t\t\t\t});\n\t\t\t} else if (key.startsWith('xmlns:')) {\n\t\t\t\toutput['_namespaces'] = output['_namespaces'] || {};\n\t\t\t\toutput['_namespaces'][key.substr(6)] = value;\n\t\t\t} else if (key == 'tagName') {\n\t\t\t\t// do nothing\n\t\t\t} else {\n\t\t\t\tvar ns;\n\t\t\t\tif (key.indexOf(':') >= 0) {\n\t\t\t\t\tns = key.substring(0, key.indexOf(':'));\n\t\t\t\t\tkey = key.substring(key.indexOf(':') + 1);\n\t\t\t\t}\n\n\t\t\t\tif (parseInt(value).toString() == value)\n\t\t\t\t\toutput[key] = parseInt(value);\n\t\t\t\telse if (value == 'true')\n\t\t\t\t\toutput[key] = true;\n\t\t\t\telse if (value == 'false')\n\t\t\t\t\toutput[key] = false;\n\t\t\t\telse\n\t\t\t\t\toutput[key] = value;\n\n\t\t\t\tif (ns)\n\t\t\t\t\toutput[key]._namespace = ns;\n\t\t\t}\n\t\t});\n\n\t\treturn output;\n\t}\n});\n"]]>10truetruefalse truetruefalse false00.11 true false truefalse nullfalsetruenullfalse Helpersfalsenulltruefalse Xfalsenulltrue false false Mfalsenulltrue false false falsenulltrue false falsenullfalse nullnullnullnullnullnullnullnullnullnullnullnull509.7falsefalse null238