Skip to content

Commit

Permalink
feat: add colors to cobol
Browse files Browse the repository at this point in the history
  • Loading branch information
zieka committed Aug 10, 2023
1 parent f9ea0c9 commit 96cfd4f
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions moderne_visualizations_misc/cobol_relationships.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"outputs": [],
"source": [
"import graphviz\n",
"import re\n",
"from code_data_science import data_table as dt\n",
"import code_data_science.palette as palette\n",
"\n",
"df = dt.read_csv('../samples/cobol_relationships.csv')"
]
Expand All @@ -29,14 +31,31 @@
"graphviz.set_default_engine('sfdp')\n",
"dot = graphviz.Digraph('cobol-relationships', comment='COBOL relationships')\n",
"\n",
"def style_node(value):\n",
" if value == 'true': \n",
" return 'red'\n",
"# clean dependent field remove all content up to first slash\n",
"df['dependent'] = df['dependent'].apply(lambda x: re.sub(r'^.*\\/', \"\", x))\n",
"\n",
"\n",
"def style_node(isMissing, dependencyType):\n",
" if isMissing == 'true': \n",
" return palette.__moderneColorMap['red'][200]\n",
" if dependencyType == 'COBOL':\n",
" return palette.__moderneColorMap['blue'][400]\n",
" if dependencyType == 'COPYBOOK':\n",
" return palette.__moderneColorMap['blue'][200]\n",
" if dependencyType == 'LINKEDIT':\n",
" return palette.__moderneColorMap['yellow'][200]\n",
" if dependencyType == 'BINDPACKAGE':\n",
" return palette.__moderneColorMap['green'][200]\n",
" if dependencyType == 'BINDPLAN':\n",
" return palette.__moderneColorMap['green'][400]\n",
" return 'white'\n",
"\n",
"def addAnnotation(value, docType):\n",
" return f'<<b>{value}</b><br/><i>({docType})</i>>'\n",
"\n",
"def map_relationship(row):\n",
" dot.node(row['dependent'])\n",
" dot.node(row['dependency'], style='filled', fillcolor=style_node(row['dependencyMissing']))\n",
" dot.node(row['dependent'], label=addAnnotation(row['dependent'], row['dependentType']), style='filled', fillcolor=style_node(row['dependencyMissing'], row['dependentType']))\n",
" dot.node(row['dependency'], label=addAnnotation(row['dependency'], row['dependencyType']), style='filled', fillcolor=style_node(row['dependencyMissing'], row['dependencyType']))\n",
" dot.edge(row['dependent'], row['dependency'], row['action'])\n",
"\n",
"df.apply(map_relationship, axis=1)\n",
Expand All @@ -61,7 +80,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 96cfd4f

Please sign in to comment.