question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Style drawNode() with Attributer

See original GitHub issue

Is it possible to style nodes created with drawNode() with the specified attributer? For example:

const dot = `
digraph {
  a -> b
  a -> c
}`;

const graphviz = d3.select("#graph")
  .graphviz(false)
  .attributer(function(d) {
    if (d.tag == "ellipse") {
        d.attributes.fill = "red";
      }
    })
  .renderDot(dot);

graphviz.drawNode(100, 0, 'New node')

I would expect the newly drawn node to have fill: red, but that is not the case. The docs specify that you can specify styles using DOT attributes, but it would be nice to to both a) only have to specify node styles once and b) be able to use CSS to style drawNode() nodes.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tuckergordoncommented, Apr 22, 2021

Yup, sorry - markdown removed my text that looked like HTML elements. Fixed it

0reactions
magjaccommented, Apr 22, 2021

Thanks so much for the Codepen. It helps a lot to see something in action.

  1. The first point seems to be possible to solve with something like color="black;0.99:red". See this example. I don’t know why it works though.
  2. The second point is not a bug, but an unfortunate consequence of the principles of operation. External CSS is not considered at all since it’s not part of the data that can be extracted from the generated SVG. AFAIU, it’s not until that SVG is rendered some program (typically a browser) which applies the external stylesheet, that those style properties can be known. It might be possible to extract it after the transition has started, but it doesn’t seem so from a modified slower Codepen i did.
  3. It may be possible to utilize the attributer also in drawNode(). I have to think about this some more.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial — NetworkX 2.8.8 documentation
Attributes such as weights, labels, colors, or whatever Python object you like, can be attached to graphs, nodes, or edges. Each graph, node,...
Read more >
Nodes and Edges - PGF/TikZ Manual
Styles for nodes.​​ This option causes ⟨code⟩ to be executed at the beginning of a node. Using this option multiple times will cause...
Read more >
c# - TreeView custom DrawNode .NET 3.5 Windows Forms
1 Answer 1 · int Compare(object x, object y) · ExplorerTreeView() · void PopulateTreeView(string DirectoryName) · bool PathIsDirectory(string ...
Read more >
TikZ and pgf
\end{tikzpicture}. • style=key attribute This style is intended for key attributes. By default, the will cause the attribute to be typeset in italics....
Read more >
Drawing basics | NetworkX Guide
There are numerous styling options which let you customize your graph. For example, you can define colors of the nodes, draw node and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found