Diagram

A Diagram consists of one or more elements.

class visigoth.Diagram(title='', description='', fill=None, margin_left=50, margin_right=50, margin_top=50, margin_bottom=50, spacing=20)

Represent a diagram contining one or more maps and other elements

Keyword Arguments
  • title (str) – title string to add to the output document

  • description (str) – description to place in the output document

  • fill (str) – background colour for the diagram

  • margin_top (int) – margin around the top of the diagram

  • margin_bottom (int) – margin around the bottom of the diagram

  • margin_left (int) – margin around the left of the diagram

  • margin_right (int) – margin around the right of the diagram

  • spacing (int) – spacing between elements in pixels

A way you might use me is:

>>> d = Diagram(fill="white")
>>> from visigoth.common.text import Text
>>> d.add(Text("Hello World!")
>>> print(d.draw()) # print the svg to the console
add(element)

Add an element to the diagram

Parameters

element (visigoth.common.DiagramElement) – the element to add

Returns

the Diagram object

Notes:

addStyle(style)

Add CSS styles to the diagram

Parameters

style (str) –

Returns

the Diagram object

setDefaultTextAttributes(text_attributes)

Define default attributes for text displayed in the diagram

Parameters

text_attributes (dict) – dict containing SVG name,value attributes to apply to text by default

Returns

the Diagram object

Notes

default attributes are overridden by those defined on diagram elements

setFontEmbedding(embed)

Enable or disable font embedding

Parameters

embed (bool) – whether to embed fonts or link to them

Notes

By default fonts are not embedded into the output SVG but are linked from google’s servers. Fonts should be embedded if you want content to render correctly when offline or when the SVG file is to be rendered as an image. If enabled, only fonts that were used will be embedded.

connect(source, dest, channel)

Connect two elements in the diagram with a channel to allow one to recieve events sent by the other

Parameters
Returns

the Diagram object

draw()

Draw the diagram to create an SVG document

Returns

a string containing the SVG document