Open s4m0r4m4 opened 4 years ago
Hello, I'm just following up on this - is there any restriction on what version of DOT I can use? Or are certain DOT features not supported? I don't necessarily need the code updated, I just need to know what it can support so that I can work around the features that are not supported.
It also looks like it does not support subgraphs:
digraph Tree { fontsize=25;
subgraph cluster_1 {
node [color=black fontname=helvetica shape=box style="filled, rounded"]
edge [fontname=helvetica labelangel=45 labeldistance=2.5]
V1_0 [label="Intensity Threshold: < 170
Defect (#): 256
Okay (#): 2294
Split Gain: 0.081" fillcolor="#199750"]
V1_0 -> V1_1 [xlabel="Area >= 967"]
V1_1 [label="Intensity Threshold: > 50
Defect (#): 149
Okay (#): 30
Split Gain: 0.068" fillcolor="#ea5739"]
label = "View 1"
}
subgraph cluster_2 {
node [color=black fontname=helvetica shape=box style="filled, rounded"]
edge [fontname=helvetica labelangel=45 labeldistance=2.5]
V2_0 [label="Intensity Threshold: > 60
Defect (#): 1049
Okay (#): 2067
Split Gain: 0.111" fillcolor="#b9e176"]
V2_0 -> V2_1 [xlabel="Std >= 22.2"]
V2_1 [label="Intensity Threshold: > 160
Defect (#): 818
Okay (#): 532
Split Gain: 0.048" fillcolor="#fedc88"]
label = "View 2"
}
}
Another gap: It also does not render "xlabels" on edges nor nodes.
Looking at the old vis.js (which I believe this demo runs on), it seems to render that stuff no problem. Maybe there is some old code from there that you guys can use?
Ping - just checking in on this
Hi @s4m0r4m4,
the DOT parser is old, definitely incomplete, not exactly specs compliant even where implemented and yeah, I can't rule out that it is indeed broken.
Would you (@s4m0r4m4 or whoever is reading this) be willing to work on this? All the logic is neatly confined (not a single import/require statement) within https://github.com/visjs/vis-network/blob/master/lib/network/dotparser.js so not much insight into the library is needed (DOT string is the input and the output is directly supplied to network.setData({ nodes, edges })
).
Hi Thomassh, thanks for the message. I will have to see when this rises to the priority queue for me, it does sound nicely compartmentalized. Are you open to replacing most of that functionality with a separate lib (e.g. https://github.com/anvaka/dotparser/ or something similar)?
Hi @s4m0r4m4,
I'm a bit concerned about the maintenance status of Dotparser. The last commit is from March when the author just noticed it's 2020 and decided to update the year in the license, the last commit that actually changed something important is from January 2019 (I don't know, maybe it was perfect back then and the format didn't change at all?). Bigger issue is that it's based on PEG.js which is dead (though, in case of issues, we could fork it and maintain it as yet another Vis project as there doesn't seem to be a decent alternative).
I'm not opposed to using a parser or even a dedicated DOT library for this (if there's a good one, it would be ideal actually), however it has to be done in treeshakable way as many people don't use DOT at all and this would be just bloat to them. Luckily, we just need a DOT string on input and an object, that can be passed to network.setData(…)
, on output. A function can do that and an exported function can easily be treeshaken if unused. It would be a breaking change, but if the parsing is going to be noticeably better, I'm all for it.
PS: The treeshakeability is mostly a note to myself, if you keep it contained within dotparser.ts and export a function from it, I'll rework the rest.
PPS: How I imagine the API.
import { Network, parseDOTNetwork } from "vis-network/standalone";
// The function parseDOTNetwork is available to be used.
new Network({}, parseDOTNetwork(myDOT));
import { Network } from "vis-network/standalone";
// The function parseDOTNetwork was not imported so Rollup/Webpack/whatnot can
// just throw it away with all of it's dependencies as if none of it ever even
// existed.
new Network(
{},
{
nodes: [
/* … */
],
edges: [
/* … */
],
}
);
The following will be removed (it's already deprecated).
import { Network } from "vis-network/standalone";
// The function parseDOTNetwork is used internaly and can't be treeshaken.
new Network({}, { dot: myDOT });
Hi,
I've also noticed problem with double quotes parsing. Example:
27 [IconPath="\"C:\Program Files (x86)\Microsoft Office\Root\Office16\SDXHelper.exe\" -Embedding"].
I looked into the source code and it looks like it does not handle those cases when there are double quotes. Parser takes the first (") and thinks that the second one is the end of string and the rest of the string shouldn't be there.
Do you know any workaround ? :)
It also doesn't like comments. If I remove comments (//) it works.
I've run into this as well while trying to render Graphviz from (my) Enola.dev RDF Graph Generation with Vis.js. (In my specific case, after finding and reading this issue, I'm going to "skip" this Dotparser and just "directly" turn my Things data structure into what Vis.js "natively" needs.)
PS: If any maintainers are reading this, I would duplicate #1957 to this issue.
Hello, I am using
vis.parseDOTNetwork(sTemp);
to parse this DOT-style string:The DOT string was created using scikit-learn's
sklearn.tree.export_graphviz(...)
(see https://scikit-learn.org/stable/modules/generated/sklearn.tree.export_graphviz.html#sklearn.tree.export_graphviz). I have verified that this is a valid DOT string using GraphViz Online.When I call
parseDOTNetwork
, it throws the following error: "Syntax error in part "<Intensity < 120 | Heigh..."
" from line 7283 of vis-network.js.It seems like vis-network is not set up to parse more complex labels with HTML formatting, but I could not find anything in the docs describing the limitations or workarounds. What do I need to do to be able to parse this DOT string?
Here are my versions from package-lock.json: