ZahirJS commited on
Commit
c5a9b0f
·
verified ·
1 Parent(s): ea2df3b

Update entity_relationship_generator.py

Browse files
Files changed (1) hide show
  1. entity_relationship_generator.py +9 -24
entity_relationship_generator.py CHANGED
@@ -840,25 +840,10 @@ def generate_entity_relationship_diagram(json_input: str, output_format: str) ->
840
  dot.attr('node', fontname='Arial', fontsize='10', color='#404040')
841
  dot.attr('edge', fontname='Arial', fontsize='9', color='#4a4a4a')
842
 
843
- entity_colors = {
844
- 'strong': '#BEBEBE',
845
- 'weak': '#FFF9C4'
846
- }
847
-
848
- attribute_colors = {
849
- 'primary_key': '#A8E6CF',
850
- 'partial_key': '#FFB3BA',
851
- 'multivalued': '#B8D4F1',
852
- 'derived': '#F0F8FF',
853
- 'composite': '#E8E8E8',
854
- 'regular': '#D4D4D4'
855
- }
856
-
857
- relationship_colors = {
858
- 'regular': '#E8E8E8',
859
- 'identifying': '#B8D4F1',
860
- 'isa': '#F0F0F0'
861
- }
862
 
863
  font_color = 'black'
864
 
@@ -873,7 +858,7 @@ def generate_entity_relationship_diagram(json_input: str, output_format: str) ->
873
  if not entity_name:
874
  continue
875
 
876
- entity_color = entity_colors.get(entity_type, entity_colors['strong'])
877
 
878
  if entity_type == 'weak':
879
  dot.node(
@@ -909,7 +894,7 @@ def generate_entity_relationship_diagram(json_input: str, output_format: str) ->
909
  attr_type = attr.get('type', 'regular')
910
 
911
  attr_id = f"{entity_name}_attr_{i}"
912
- attr_color = attribute_colors.get(attr_type, attribute_colors['regular'])
913
 
914
  if attr_type == 'primary_key':
915
  dot.node(
@@ -1009,7 +994,7 @@ def generate_entity_relationship_diagram(json_input: str, output_format: str) ->
1009
 
1010
  if parent and children:
1011
  isa_id = f"isa_{rel_name}"
1012
- isa_color = relationship_colors.get('isa', relationship_colors['regular'])
1013
 
1014
  dot.node(
1015
  isa_id,
@@ -1031,7 +1016,7 @@ def generate_entity_relationship_diagram(json_input: str, output_format: str) ->
1031
  dot.edge(isa_id, child, color='#4a4a4a', len='2.0')
1032
 
1033
  elif len(entities_involved) >= 2:
1034
- rel_color = relationship_colors.get(rel_type, relationship_colors['regular'])
1035
 
1036
  if rel_type == 'identifying':
1037
  dot.node(
@@ -1065,7 +1050,7 @@ def generate_entity_relationship_diagram(json_input: str, output_format: str) ->
1065
  for j, attr in enumerate(rel_attributes):
1066
  attr_name = attr.get('name', '')
1067
  attr_id = f"{rel_name}_attr_{j}"
1068
- attr_color = attribute_colors['regular']
1069
 
1070
  dot.node(
1071
  attr_id,
 
840
  dot.attr('node', fontname='Arial', fontsize='10', color='#404040')
841
  dot.attr('edge', fontname='Arial', fontsize='9', color='#4a4a4a')
842
 
843
+ entity_color = '#BEBEBE'
844
+ attribute_color = '#B8D4F1'
845
+ relationship_color = '#FFF9C4'
846
+ isa_color = '#A8E6CF'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
847
 
848
  font_color = 'black'
849
 
 
858
  if not entity_name:
859
  continue
860
 
861
+ entity_color = '#BEBEBE'
862
 
863
  if entity_type == 'weak':
864
  dot.node(
 
894
  attr_type = attr.get('type', 'regular')
895
 
896
  attr_id = f"{entity_name}_attr_{i}"
897
+ attr_color = attribute_color
898
 
899
  if attr_type == 'primary_key':
900
  dot.node(
 
994
 
995
  if parent and children:
996
  isa_id = f"isa_{rel_name}"
997
+ isa_color = isa_color
998
 
999
  dot.node(
1000
  isa_id,
 
1016
  dot.edge(isa_id, child, color='#4a4a4a', len='2.0')
1017
 
1018
  elif len(entities_involved) >= 2:
1019
+ rel_color = relationship_color
1020
 
1021
  if rel_type == 'identifying':
1022
  dot.node(
 
1050
  for j, attr in enumerate(rel_attributes):
1051
  attr_name = attr.get('name', '')
1052
  attr_id = f"{rel_name}_attr_{j}"
1053
+ attr_color = attribute_color
1054
 
1055
  dot.node(
1056
  attr_id,