diff --git a/examples/demo02.yml b/examples/demo02.yml
index 00ee5546..f03e7a2b 100644
--- a/examples/demo02.yml
+++ b/examples/demo02.yml
@@ -13,6 +13,7 @@ ferrules:
ferrule_crimp:
type: Crimp ferrule
subtype: 0.25 mm²
+ color: YE
connectors:
X1:
diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py
index c92053e3..d47aa048 100644
--- a/src/wireviz/Harness.py
+++ b/src/wireviz/Harness.py
@@ -59,40 +59,27 @@ def create_graph(self):
for key, connector in self.connectors.items():
if connector.category == 'ferrule':
- subtype = f', {connector.subtype}' if connector.subtype else ''
- color = wv_colors.translate_color(connector.color, self.color_mode) if connector.color else ''
- infostring = f'{connector.type}{subtype} {color}'
- # id = identification
- identification = [connector.manufacturer,
- f'MPN: {connector.manufacturer_part_number}' if connector.manufacturer_part_number else '',
- f'IPN: {connector.internal_part_number}' if connector.internal_part_number else '']
- identification = list(filter(None, identification))
- if(len(identification) > 0):
- infostring = f'{infostring}
'
- for attrib in identification:
- infostring = f'{infostring}{attrib}, '
- infostring = infostring[:-2] # remove trainling comma and space
-
- infostring_l = infostring if connector.ports_right else ''
- infostring_r = infostring if connector.ports_left else ''
-
- # INFO: Leaving this one as a string.format form because f-strings do not work well with triple quotes
- colorbar = f'
| ' if connector.color else ''
- dot.node(key, shape='none',
- style='filled',
- margin='0',
- orientation='0' if connector.ports_left else '180',
- label='''<
-
-
- {infostring_l} |
- {colorbar}
- {infostring_r} |
-
-
-
- >'''.format(infostring_l=infostring_l, infostring_r=infostring_r, colorbar=colorbar))
+ rows = [[connector.type, connector.subtype, connector.color, '' if connector.color else None],
+ [connector.manufacturer,
+ f'MPN: {connector.manufacturer_part_number}' if connector.manufacturer_part_number else None,
+ f'IPN: {connector.internal_part_number}' if connector.internal_part_number else None]]
+ rows = [list(filter(None, row)) for row in rows] # remove missing attributes
+
+ html = ''
+ for row in rows:
+ if len(row) > 0:
+ html = f'{html}'
+ for cell in row:
+ html = f'{html}{cell} | '
+ html = f'{html}
|
'
+ html = f'{html}
'
+
+ if connector.color: # add color bar next to color info, if present
+ colorbar = f' | '
+ html = html.replace(' | ', colorbar)
+
+ dot.node(key, label=f'<{html}>', shape='none', margin='0', style='filled', fillcolor='white')
else: # not a ferrule
identification = [connector.manufacturer,
diff --git a/tutorial/tutorial06.yml b/tutorial/tutorial06.yml
index f69499c3..7ff042f8 100644
--- a/tutorial/tutorial06.yml
+++ b/tutorial/tutorial06.yml
@@ -5,7 +5,7 @@ connectors:
subtype: female
F_10_1: # manually define a ferrule (with unique designator)
category: ferrule
- type: Ferrule, crimp
+ type: Crimp ferrule
subtype: 1.0 mm²
color: YE