diagrams icon indicating copy to clipboard operation
diagrams copied to clipboard

How to change the fontsize of all labels

Open seanw2020 opened this issue 3 years ago • 2 comments

First, thanks for this software!

Second, how can we change the fontsize of all labels in a diagram? Changing the "fontsize": "40", value to "10" or "20" below makes no difference, BUT doing Edge(label="howdy", fontsize="40") works. I'd rather not do the latter on every label though...

from diagrams import Diagram, Edge
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB

ea = {
    "fontsize": "40",
}
with Diagram("foo", show=False, direction="TB", edge_attr=ea):
    ELB("lb") >> Edge(label="howdy") >> [EC2("worker1"),
                  EC2("worker2"),
                  EC2("worker3"),
                  EC2("worker4"),
                  EC2("worker5")] >> RDS("events")

seanw2020 avatar Oct 04 '21 22:10 seanw2020

This still does not seem to work. Also, is there a way to set the fontsize for all Cluster labels?

anders-elastisys avatar Sep 16 '22 11:09 anders-elastisys

@seanw2020 @anders-elastisys how about that?

from functools import partial

# define your custom objects
Edge = partial(Edge, labelloc="t", fontsize="20")
Custom = partial(Custom, labelloc="b", fontsize="16")

then all your Edge and Custom objects will have the same attribute you specify and you still can override it for the specific item

streanger avatar May 18 '23 19:05 streanger