Created: 2023-08-16 | Updated: 2024-05-17

Customizing Vertex

New (v0.3.13)

Table of contents

  1. Use Style Object to override any parameter
  2. Changing FillColor to RED (node with Error or Alarm):
  3. Adding Opacity and Background Shadow:
  4. Gradient Fill
  5. Change the Direction of Vertex:
  6. Vertex without any labels:
  7. Applying Colors to Table
  8. Hiding NODE ID information when rendering

Use Style Object to override any parameter

When passing style parameter, we can customize the representation of particular Vertex. Here is the list of most widely used parameters of style.

style = {
    'fillColor': '#FF0000',
    'fillOpacity': '50',
    'shadow': '1',
    'gradientColor': '#FFFF33',
    'gradientDirection': 'north'
}

Each Node in this documentation has full list of its style parameters. You can check all styles at Advanced for Geeks section.

Changing FillColor to RED (node with Error or Alarm):

Code Snippet:

# given
mcd = MultiCloudDiagrams()

# when
mcd.add_vertex(node_id="arn:aws:lambda:eu-west-1:123456789012:function:prod-lambda-name",
               node_name='prod-lambda-name',
               node_type='lambda_function',
               style={'fillColor': '#FF0000'})

Rendering:

layers

Adding Opacity and Background Shadow:

Code Snippet:

# given
mcd = MultiCloudDiagrams()

# when
mcd.add_vertex(node_id="arn:aws:lambda:eu-west-1:123456789012:function:prod-lambda-name",
               node_name='prod-lambda-name',
               node_type='lambda_function',
               style={
                   'fillColor': '#00FF00',
                   'fillOpacity': '50',
                   'shadow': '1'
               })

Rendering:

layers

Gradient Fill

When specifying gradient fill it is mandatory to set 3 style params:

  • fillColor
  • gradientColor
  • gradientDirection

gradientDirection can have the following values:

  • north
  • south
  • west
  • east
  • radial

Code Snippet:

# given
mcd = MultiCloudDiagrams()
input_file_previous_version = 'docs/docs/core-components/output/drawio/color_gradient.drawio'
mcd.read_coords_from_file(input_file_previous_version)
style = {
    'fillColor': '#FFFF33',
    'gradientColor': '#3399FF',
    'noLabel': '1'
}

# when
for gradientDirection in ['north', 'south', 'east', 'west', 'radial']:
    style['gradientDirection'] = gradientDirection
    mcd.add_vertex(node_id=f"arn:aws:lambda:eu-west-1:123456789012:function:{gradientDirection}",
                   node_name=f'gradientDirection:{gradientDirection}',
                   node_type='lambda_function',
                   style=style)

Rendering:

layers

Change the Direction of Vertex:

Code Snippet:

# given
mcd = MultiCloudDiagrams()
input_file_previous_version = 'docs/docs/core-components/output/drawio/color_direction.drawio'
mcd.read_coords_from_file(input_file_previous_version)

style = {
    'noLabel': '1'
}

# when
for direction in ['north', 'south', 'east', 'west']:
    style['direction'] = direction
    mcd.add_vertex(node_id=f"arn:aws:lambda:eu-west-1:123456789012:function:{direction}",
                   node_name=f'gradientDirection:{direction}',
                   node_type='lambda_function',
                   style=style)

Rendering:

layers

Vertex without any labels:

Code Snippet:

# given
mcd = MultiCloudDiagrams()
input_file_previous_version = 'docs/docs/core-components/output/drawio/color_nolabel.drawio'
mcd.read_coords_from_file(input_file_previous_version)

# when
mcd.add_vertex(node_id="arn:aws:lambda:eu-west-1:123456789012:function:nolabel",
               node_name='no-label',
               node_type='lambda_function',
               style={'noLabel': '1'})

Rendering:

layers

Applying Colors to Table

Code Snippet:

# given
mcd = MultiCloudDiagrams()
rows = [
    'IndexName',
    'IndexSizeBytes',
    'IndexStatus',
]
style = {
    'fillColor': '#FF9933',
}

# when
mcd.add_list(table_name='LSI:users_to_model-users-idx', rows=rows, style=style)

Rendering

layers

Hiding NODE ID information when rendering

Extra parameter, hide_id = true allows to render only node name avoiding any additional information.

Code Snippet:

# given
mcd = MultiCloudDiagrams()

# when
sns_arn = 'arn:aws:sns:eu-west-1:123456789012:internal.fifo'
metadata = {
    "Owner": 123456789012,
    "SubscriptionsConfirmed": 3,
    "SubscriptionsPending": 0
}
mcd.add_vertex(node_id=sns_arn, node_name='internal.fifo', node_type='sns', metadata=metadata, hide_id=True)

Rendering

layers