glejeune / node-graphviz Goto Github PK
View Code? Open in Web Editor NEWNode.js interface to the GraphViz graphing tool
Home Page: http://algorithmique.net
License: MIT License
Node.js interface to the GraphViz graphing tool
Home Page: http://algorithmique.net
License: MIT License
The documentation for "headport" and "tailport" says that it Indicates where on the head/tail node to attach the head/tail of the edge. In the default case, the edge is aimed towards the center of the node, and then clipped at the node boundary.
The code given below -
`digraph {
rankdir=LR;
node [ shape=record ];
struct1 [
label = "a|b|<port1> c";
];
struct2 [
label = "a|{ <port2> b1|b2}|c";
];
struct1->struct2 [ label="xyz", headport="port1", tailport="port2" ];
}`
should generate an edge from node:struct1 port "c" to node:struct2 port "b1" like this -
however it generates an edge like this , using default behavior.
I understand that struct1:port1 -> struct2:port2 [ label="xyz" ];
can be used for the purpose ,but I don't know how to use addEdge method to generate such a dot string (open to suggestions ).
I request you to please help me out , to generate an edge like in image 1.
I have also tried other versions of port attribute argument such as such , "c","port0:c" etc yet no use.
I try to change the class of the edges in the rendered SVG. So I pass the class
property as attribute.
After that, the error TypeError: Cannot read property 'type' of undefined
occurs in the mustBeQuoted
function (graphviz\lib\deps\attributs.js:191:42
)
Reason is that class
attribute is not implemented in attributs.js
(graphviz\lib\deps\attributs.js
)
var attrs = {
"Damping" : { "usage" : "G", "type" : "double" },
"K" : { "usage" : "GC", "type" : "double" },
"URL" : { "usage" : "ENGC", "type" : "escString" },
"area" : { "usage" : "NC", "type" : "double" },
"arrowhead" : { "usage" : "E", "type" : "arrowType" },
"arrowsize" : { "usage" : "E", "type" : "double" },
"arrowtail" : { "usage" : "E", "type" : "arrowType" },
"aspect" : { "usage" : "G", "type" : "aspectType" },
"bb" : { "usage" : "G", "type" : "rect" },
"bgcolor" : { "usage" : "GC", "type" : "color" },
"center" : { "usage" : "G", "type" : "bool" },
"charset" : { "usage" : "G", "type" : "string" },
"clusterrank" : { "usage" : "G", "type" : "clusterMode" },
"color" : { "usage" : "ENC", "type" : "color" },
"colorscheme" : { "usage" : "ENCG", "type" : "string" },
...
Is it possible to add class
attribute as feature?
After I finished install of Graphviz app & npm package of node-graphviz,,
when I type this command "node hello_world.js" at Mac terminal, I've noticed under error message.
I use Graphviz ver 1.13 , node.js ver 0.3.1, npm ver 0.2.10-1.
If you know how to solve this error, tell me solution, please.
node.js:50
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: EPIPE, Broken pipe
at Stream._writeImpl (net.js:139:14)
at Stream._writeOut (net.js:558:25)
at Stream.write (net.js:491:17)
at [object Object].render (/usr/local/lib/node/.npm/graphviz/0.0.3/package/lib/deps/graph.js:330:18)
at [object Object].output (/usr/local/lib/node/.npm/graphviz/0.0.3/package/lib/deps/graph.js:335:8)
at Object. (/Users/user/Documents/workspace/testNodeJS/graphviz-0.0.3/tests/hello_world.js:20:3)
at Module._compile (node.js:329:23)
at Object..js (node.js:337:12)
at Module.load (node.js:260:25)
Fixes graphviz.parse() but hasn't been pushed to npm.
I want to remove duplicate edges. I need to set the graph strict. How to do that ?
I can't seem to find imagepos for nodes.
I manually updated my Attributes.js file and it appears to work fine.
This will position the image in the node where you would like it.
Options are as follows;
"imagepos" : { "usage" : "N", "type" : "string" }
Reference: https://www.graphviz.org/doc/info/attrs.html#d:height
Thanks,
I have some code which ends up creating duplicate edges because I can't figure out how to check if an exact same edge already exists.
Is there a way by which I can tell this library to simply ignore duplicate edges?
For example: https://github.com/hpcc-systems/hpcc-js-wasm
Disclaimer - I am a contributor to the above project (and can answer any questions)...
On npmjs, the package is reported as GPL-3.0 (see https://www.npmjs.com/package/graphviz)
From the history, the package.json is fixed, but without updating the version number (and without publishing to NPM?)
(see 162db2c)
Please publish a new version to NPM with the fixed license information.
Thanks,
Sven
line 222 of lib/deps/graph.js you have Graph.prototype.getNodeAttribut, I believe it should be Graph.prototype.getEdgeAttribut. Keep up the good work.
Graphviz _parse on data event calls eval(data) each time the event occurs instead of just appending the data and calling eval on the exit event.
I would like to express "{rank=same; node1 node2}", but could not find any sample.
Is it possible to do this with node-graphviz?
Thank you.
I think you need to release the last changes in the repository, in the current code there is a removeNode
function on the graph object but the npm version is missing that feature
The attribute 'newrank' is missing in the list of available attributes.
"newrank" : { "usage" : "G", "type" : "bool" },
And it would be great to get an error message like:
Error: The attribute 'newrank' is not support.
or something like this.
This might be just an issue I have come across, but it appears that dox
no longer supports generating documentation from a list of files or directories but instead operates only over stdio
. I'm working on fixing Jakefile.js
to use dox properly, but if you know why this doesn't build I would be greatly appreciative!
Dot specification has HTML-like labels.
They are generally like:
label=<<FONT POINT-SIZE='12'>Some Text</FONT>>
The issue is that Graphviz doesn't understand it if that html label is quoted like this:
label="<<FONT POINT-SIZE='12'>Some Text</FONT>>"
In the attributes js file, lbl
is of type lblString
, which means it would be quoted.
https://github.com/glejeune/node-graphviz/blob/master/lib/deps/attributs.js#L59
We need a way to say if our label is a string or an html markup. Based on that it must be quoted or not.
I don't know what would be an elegant solution to this.
Any fixes (or even ideas) would be awesome?
@glejeune , would you be able to push a new version to npm please? thanks!
The license field in the package.json says this module is licensed under the GPL v3 but there's an MIT LICENSE file in the root of the repo.
Can you clarify the license of this module and update one or the other location?
Thanks!
P.S. It would be wonderful if this were licensed as MIT :)
Using Graph.render, there are some race conditions with graphviz.on("exit", …)
, where exit
fires before the graphviz.stdout is ended.
So instead of using exit
, you can use close
in node 0.8. So a solution would be, in graph.js:373
var version = process.version.split('.')[1]
graphviz.on(version < 8 ? 'exit' : 'close', function(code) {
// ...
});
With #32 my understanding is that the valid license is MIT
. However in this file (https://github.com/glejeune/node-graphviz/blob/master/lib/ext/gvpr/dot2js.g) there is still a GPL license referenced. Can that be removed as well?
digraph G {
a -> b [label="a to b"];
b -> c [label="another label"];
}
Hi @glejeune,
trying to use your library with my vscode extension. Problem, the super weird Array
hashmap stuff is breaking as the for(var name in this.attributs.items) {
will not only return added items but also functionnames. no clue why this does not happen on the console but breaks in vscode (maybe more strict?) but the usage feels a bit strange anyway.
I quickly checked the open PR's and #23 appears to solve that problem with an hasOwnProperty
check. I guess there are likely more people having the same issues. #23 is a hack but will probably fix the problem as a short-term solution. Any thoughts on merging it? Otherwise I'll have to switch to a different lib.
TypeError: Cannot read property 'type' of undefined
soljson.js:28
at mustBeQuoted (node_modules/surya/node_modules/graphviz/lib/deps/attributs.js:190:42)
at quoteMe (node_modules/surya/node_modules/graphviz/lib/deps/attributs.js:194:6)
at exports.Attributs.Attributs.to_dot (node_modules/surya/node_modules/graphviz/lib/deps/attributs.js:241:56)
at exports.Graph.Graph.to_dot (node_modules/surya/node_modules/graphviz/lib/deps/graph.js:249:61)
at Object.graph (node_modules/surya/lib/graph.js:462:63)
at Commands.surya (src/features/commands.js:53:29)
at src/extension.js:625:30
it is undefined because the in
op returned GetEnumerator
which is an array method and not an item. see screenshot. left side contents of the hash-array-thing, right side tooltip contents of name
(GetEnumerator
). this will later break in mustBeQuoted
as GetEnumerator
is no valid attrib (was never set by our code).
cheers,
tin
This inst really an issue, but more of a question. How do I get the coordinates of a node? I am using the example provided, but have not been able to find where/if the coordinates are stored.
I explored the graph object but such attributes do not seem to be there.
// Print the dot script
console.log( g.to_dot() );
console.log(g); // There does not seem to be any such info in this object, nor is there any info on an individual node.
Any help on this would be much appreciated. Thank you.
Hi,
This is a great Node module for Graphviz diagrams. Unfortunately this can't work in browsers because graphviz isn't available. But what if we could have a browser friendly stripped down version that generates dot code string.
And then I can use https://github.com/mdaines/viz.js to greate diagrams with that dot code in browsers without Node.JS.
Since the author understands his code best, I am requesting you if you can please create a stripped down version that just generates dot code?
Thanks...
Hi,
I tried setting href attribute for nodes like this:
node.set( 'href', 'http://google.com');
but I am getting the following error:
DEBUG: Warning : Invalid attribut `href' for a node
How can we have clickable nodes?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.