-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] about nodes #306
Comments
Hello, nice idea. import random Or you could try to set the node_attr of that node |
Thanks for the help. I liked the second option, but it didn't changed the bg color at all: ` node_attr = { node_attr_json = json.dumps(node_attr) with Diagram("Advanced Web Service with On-Premise", show=False):
` After doing the json.dumps no exception is given, but the bg color is the same as default (cluster) If this is not possible, maybe I should use your first option. Thanks. |
Hello @steschuser Any idea why node_attr doesn't work for me ? Thanks. |
Hello again, My suggestion would be to check out the genrated .dot file #182 Its on my agenda to take a look into this but time is limited... |
Thank you @steschuser ! |
The first issue is that setting bgcolor doesn't seem to be the attribute you are really after the link steschuser posted goes into all the different ways to define a color attribute and when they will matter(honestly I still don't understand its logic fully). However how exactly to pass in attributes any place besides Diagram() is at best unclear if not confusing to be point of it being called "bugged" in my mind. Here is a modified version of your code and the resultant diagram: from diagrams import Cluster, Diagram
from diagrams.onprem.database import PostgreSQL
from diagrams.onprem.network import Nginx
offline_node_attrs = {"fillcolor": "red", "style": "filled"}
with Diagram("Advanced Web Service with On-Premise", show=False) as diag:
ingress = Nginx("ingress")
with Cluster("Database HA"):
master = PostgreSQL("users")
master - PostgreSQL("slave", **offline_node_attrs)
diag Besides changing what attributes are being set, notice how the dictionary has to be passed in: master - PostgreSQL("slave", **offline_node_attrs) A more standardized name for these attribute variables in the __init__ function of Node, Edge and Cluster would be "kwargs". To make it clearer about why the dictionary containing attributes needs to be unpacked during the initialization call, consider that this line works the same as the one above and produces the same result: `master - PostgreSQL("slave", fillcolor="red", style="filled") |
Hi @redNixon !! That's awesome, thank you so much. I also have issues with the nodes position within a clúster. I have approx 50 Tomcat nodes in a cluster and when I visualized them, they are all positioned in the same column, so the diagram looks very strange for me. There's anyway to specify the number of columns in a cluster or change the position of the nodes? Sorry to ask you all this, but I couldn't find much info. Thank you again. |
Can you post the code? The answer is yes but what is making it "weird" can often changes and have a simple fix that can be found most often to make graphviz start flowing as expected instead of trying to position everything manually. When using graphviz indirectly(ie via diagrams) edges, line breaks and transparent clusters are some methods to force some behavior without getting into the graphviz logic though. I will say that while diagrams is an amazing library to let you quickly code out a diagram, if you start creating real large or have real complex interconnected graphs then utilizing the graphviz library directly will probably be easier(50 nodes is not large btw) to use. |
Hey @redNixon Sure, my code is not complex. graph_attr = { with Diagram("DC1 DIAGRAM", show=False):
` So basically, app_group appear all in the same column, with a few nodes it's ok, but when you have 50 nodes in the same column, it's not great. Thank you! |
This looks like the problem in #276 |
Hello @steschuser and @redNixon Thanks a lot for your help!! |
Tried adding size & ratio, but I can't see any difference. |
See if you can adapt the following to fit your needs:
|
Hello everyone, first of all, apologies if here it's not the principal way to ask my doubts.
I want to dynamically create diagrams. For example, if you have a server that's not healthy, you want to show it with a cross over it or maybe just red around the node.
For example:
`from diagrams.onprem.network import Nginx
from diagrams.onprem.database import PostgreSQL
with Diagram("Advanced Web Service with On-Premise", show=False):
ingress = Nginx("ingress")
with Cluster("Database HA"):
master = PostgreSQL("users")
master - PostgreSQL("slave") <-- And this server is not healthy`
So "master - PostgreSQL("slave")" is not healthy and I want to show it as non-healthy in the diagram. Which should be the best way to do it ?
The text was updated successfully, but these errors were encountered: