mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-22 22:12:53 +02:00
Checkpoint commit
This commit is contained in:
parent
c5721362ac
commit
31d7098d48
@ -8,7 +8,7 @@ from sqlalchemy.engine import Engine
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from aki_prj23_transparenzregister.utils.sql import entities
|
from aki_prj23_transparenzregister.utils.sql import entities
|
||||||
from aki_prj23_transparenzregister.ui.networkx_dash import networkx_component
|
from aki_prj23_transparenzregister.ui.archive.networkx_dash import networkx_component
|
||||||
|
|
||||||
COLORS = {
|
COLORS = {
|
||||||
"light": "#edefef",
|
"light": "#edefef",
|
@ -10,7 +10,6 @@ from dash import dash_table, dcc, html
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from aki_prj23_transparenzregister.ui import data_elements, finance_elements
|
from aki_prj23_transparenzregister.ui import data_elements, finance_elements
|
||||||
from aki_prj23_transparenzregister.ui.networkx_dash import networkx_component
|
|
||||||
from aki_prj23_transparenzregister.utils.networkx.network_2d import create_2d_graph
|
from aki_prj23_transparenzregister.utils.networkx.network_2d import create_2d_graph
|
||||||
from aki_prj23_transparenzregister.utils.networkx.network_base import initialize_network
|
from aki_prj23_transparenzregister.utils.networkx.network_base import initialize_network
|
||||||
from aki_prj23_transparenzregister.utils.networkx.networkx_data import (
|
from aki_prj23_transparenzregister.utils.networkx.networkx_data import (
|
||||||
|
@ -27,6 +27,7 @@ from aki_prj23_transparenzregister.utils.networkx.networkx_data import (
|
|||||||
return_metric_table_df
|
return_metric_table_df
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dash.register_page(__name__, path="/")
|
||||||
|
|
||||||
# Get Data
|
# Get Data
|
||||||
person_relation = filter_relation_type(
|
person_relation = filter_relation_type(
|
||||||
@ -63,19 +64,16 @@ nodes, edges = create_edge_and_node_list(person_relation, company_relation)
|
|||||||
graph, metrics = initialize_network(nodes=nodes, edges=edges)
|
graph, metrics = initialize_network(nodes=nodes, edges=edges)
|
||||||
metric = "None"
|
metric = "None"
|
||||||
layout = "Spring"
|
layout = "Spring"
|
||||||
switch_node_annotaion_value = False
|
# switch_node_annotaion_value = False
|
||||||
switch_edge_annotaion_value = False
|
switch_edge_annotaion_value = False
|
||||||
egde_thickness = 1
|
egde_thickness = 1
|
||||||
network = create_3d_graph(graph, nodes, edges, metrics, metric, layout, switch_node_annotaion_value, switch_edge_annotaion_value, egde_thickness)
|
network = create_3d_graph(graph, nodes, edges, metrics, metric, layout, switch_edge_annotaion_value, egde_thickness)
|
||||||
|
|
||||||
# Get the possible Filter values for the Dropdowns.
|
# Get the possible Filter values for the Dropdowns.
|
||||||
company_relation_type_filter = get_all_person_relations()["relation_type"].unique()
|
person_relation_type_filter = get_all_person_relations()["relation_type"].unique()
|
||||||
person_relation_type_filter = get_all_company_relations()["relation_type"].unique()
|
company_relation_type_filter = get_all_company_relations()["relation_type"].unique()
|
||||||
|
|
||||||
|
|
||||||
top_companies_df = return_metric_table_df(metrics, nodes, "closeness") #find_top_companies()
|
top_companies_df = return_metric_table_df(metrics, nodes, "closeness") #find_top_companies()
|
||||||
# with open("src/aki_prj23_transparenzregister/ui/assets/network_graph.html") as file:
|
|
||||||
# html_content = file.read()
|
|
||||||
|
|
||||||
layout = html.Div(
|
layout = html.Div(
|
||||||
children=html.Div(
|
children=html.Div(
|
||||||
@ -248,19 +246,19 @@ layout = html.Div(
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
html.Div(
|
# html.Div(
|
||||||
className="filter-wrapper-item",
|
# className="filter-wrapper-item",
|
||||||
children=[
|
# children=[
|
||||||
html.H5(
|
# html.H5(
|
||||||
className="filter-description",
|
# className="filter-description",
|
||||||
children=["Enable Node Annotation"],
|
# children=["Enable Node Annotation"],
|
||||||
),
|
# ),
|
||||||
html.Div(
|
# html.Div(
|
||||||
className="switch-style",
|
# className="switch-style",
|
||||||
children=[daq.BooleanSwitch(id="switch_node_annotation", on=False)],
|
# children=[daq.BooleanSwitch(id="switch_node_annotation", on=False)],
|
||||||
),
|
# ),
|
||||||
],
|
# ],
|
||||||
),
|
# ),
|
||||||
html.Div(
|
html.Div(
|
||||||
className="filter-wrapper-item",
|
className="filter-wrapper-item",
|
||||||
children=[
|
children=[
|
||||||
@ -292,7 +290,6 @@ def update_graph_data(
|
|||||||
# Get Data
|
# Get Data
|
||||||
person_df = get_all_person_relations()
|
person_df = get_all_person_relations()
|
||||||
company_df = get_all_company_relations()
|
company_df = get_all_company_relations()
|
||||||
# print(company_df)
|
|
||||||
|
|
||||||
person_relation = filter_relation_type(person_df, person_relation_type)
|
person_relation = filter_relation_type(person_df, person_relation_type)
|
||||||
company_relation = filter_relation_type(company_df, company_relation_type)
|
company_relation = filter_relation_type(company_df, company_relation_type)
|
||||||
@ -311,7 +308,7 @@ def update_graph_data(
|
|||||||
[
|
[
|
||||||
Input("dropdown", "value"),
|
Input("dropdown", "value"),
|
||||||
Input("switch", "on"),
|
Input("switch", "on"),
|
||||||
Input("switch_node_annotation", "on"),
|
# Input("switch_node_annotation", "on"),
|
||||||
Input("switch_edge_annotation", "on"),
|
Input("switch_edge_annotation", "on"),
|
||||||
Input("dropdown_company_relation_filter", "value"),
|
Input("dropdown_company_relation_filter", "value"),
|
||||||
Input("dropdown_person_relation_filter", "value"),
|
Input("dropdown_person_relation_filter", "value"),
|
||||||
@ -325,7 +322,7 @@ def update_graph_data(
|
|||||||
def update_figure(
|
def update_figure(
|
||||||
selected_metric: str,
|
selected_metric: str,
|
||||||
switch_value: bool,
|
switch_value: bool,
|
||||||
switch_node_annotaion_value: bool,
|
# switch_node_annotaion_value: bool,
|
||||||
switch_edge_annotaion_value: bool,
|
switch_edge_annotaion_value: bool,
|
||||||
c_relation_filter_value: str,
|
c_relation_filter_value: str,
|
||||||
p_relation_filter_value: str,
|
p_relation_filter_value: str,
|
||||||
@ -344,18 +341,13 @@ def update_figure(
|
|||||||
Network Graph(Plotly Figure): Plotly Figure in 3 or 2D
|
Network Graph(Plotly Figure): Plotly Figure in 3 or 2D
|
||||||
"""
|
"""
|
||||||
_ = c_relation_filter_value, p_relation_filter_value
|
_ = c_relation_filter_value, p_relation_filter_value
|
||||||
# triggered_id = ctx.triggered_id
|
|
||||||
|
|
||||||
# if triggered_id == 'dropdown_companyrelation_filter' or triggered_id == 'dropdown_personrelation_filter':
|
graph, metrics, nodes, edges = update_graph_data(person_relation_type= p_relation_filter_value, company_relation_type= c_relation_filter_value)
|
||||||
# print(selected_value)
|
|
||||||
# print(metrics)
|
|
||||||
# print(graph)
|
|
||||||
graph, metrics, nodes, edges = update_graph_data(person_relation_type= p_relation_filter_value, company_relation_type= c_relation_filter_value)
|
|
||||||
|
|
||||||
if switch_value:
|
if switch_value:
|
||||||
return create_2d_graph(graph, nodes, edges, metrics, selected_metric, layout, switch_node_annotaion_value, switch_edge_annotaion_value, slider_value)
|
return create_2d_graph(graph, nodes, edges, metrics, selected_metric, layout, switch_edge_annotaion_value, slider_value)
|
||||||
else:
|
else:
|
||||||
return create_3d_graph(graph, nodes, edges, metrics, selected_metric, layout, switch_node_annotaion_value, switch_edge_annotaion_value, slider_value)
|
return create_3d_graph(graph, nodes, edges, metrics, selected_metric, layout, switch_edge_annotaion_value, slider_value)
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
@ -367,10 +359,7 @@ def update_figure(
|
|||||||
def update_table(metric_dropdown_value: str) -> dict:
|
def update_table(metric_dropdown_value: str) -> dict:
|
||||||
table_df = return_metric_table_df(metrics, nodes, metric_dropdown_value)
|
table_df = return_metric_table_df(metrics, nodes, metric_dropdown_value)
|
||||||
table_df.to_dict("records")
|
table_df.to_dict("records")
|
||||||
# print(table_df.to_dict("records"))
|
columns =[{"name": i, "id": i} for i in table_df.columns]
|
||||||
columns =[{"name": i, "id": i} for i in table_df.columns]
|
|
||||||
# print(columns)
|
|
||||||
|
|
||||||
return table_df.to_dict("records")
|
return table_df.to_dict("records")
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import plotly.graph_objects as go
|
|||||||
|
|
||||||
|
|
||||||
def create_2d_graph(
|
def create_2d_graph(
|
||||||
graph: nx.Graph, nodes: dict, edges: list, metrics: pd.DataFrame, metric: str | None, layout: str, node_annotation: bool, edge_annotation: bool, edge_thickness: int
|
graph: nx.Graph, nodes: dict, edges: list, metrics: pd.DataFrame, metric: str | None, layout: str, edge_annotation: bool, edge_thickness: int
|
||||||
) -> go.Figure:
|
) -> go.Figure:
|
||||||
"""This Method creates a 2d Network in Plotly with a Scatter Graph and retuns it.
|
"""This Method creates a 2d Network in Plotly with a Scatter Graph and retuns it.
|
||||||
|
|
||||||
@ -141,9 +141,7 @@ def create_2d_graph(
|
|||||||
edge_weights_trace.text = edge_type_list
|
edge_weights_trace.text = edge_type_list
|
||||||
# print(edge_type_list)
|
# print(edge_type_list)
|
||||||
|
|
||||||
if node_annotation:
|
|
||||||
print("Test")
|
|
||||||
# node_trace.text = nodes.
|
|
||||||
|
|
||||||
# Return the Plotly Figure
|
# Return the Plotly Figure
|
||||||
return go.Figure(
|
return go.Figure(
|
||||||
|
@ -6,7 +6,7 @@ import plotly.graph_objects as go
|
|||||||
|
|
||||||
|
|
||||||
def create_3d_graph(
|
def create_3d_graph(
|
||||||
graph: nx.Graph, nodes: dict, edges: list, metrics: pd.DataFrame, metric: str | None, layout: str, node_annotation: bool, edge_annotation: bool, edge_thickness: int
|
graph: nx.Graph, nodes: dict, edges: list, metrics: pd.DataFrame, metric: str | None, layout: str, edge_annotation: bool, edge_thickness: int
|
||||||
) -> go.Figure:
|
) -> go.Figure:
|
||||||
"""This Method creates a 3D Network in Plotly with a Scatter Graph and retuns it.
|
"""This Method creates a 3D Network in Plotly with a Scatter Graph and retuns it.
|
||||||
|
|
||||||
|
@ -158,10 +158,7 @@ def filter_relation_type(
|
|||||||
Returns:
|
Returns:
|
||||||
relation_dataframe (pd.DataFrame): The filtered DataFrame which now only contains entries with the selected Relation Type.
|
relation_dataframe (pd.DataFrame): The filtered DataFrame which now only contains entries with the selected Relation Type.
|
||||||
"""
|
"""
|
||||||
print(selected_relation_type)
|
|
||||||
print(relation_dataframe.loc[
|
|
||||||
relation_dataframe["relation_type"] == selected_relation_type
|
|
||||||
])
|
|
||||||
return relation_dataframe.loc[
|
return relation_dataframe.loc[
|
||||||
relation_dataframe["relation_type"] == selected_relation_type
|
relation_dataframe["relation_type"] == selected_relation_type
|
||||||
]
|
]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Test for the Home Page."""
|
"""Test for the Home Page."""
|
||||||
# from aki_prj23_transparenzregister.ui.pages.home import networkx_dash
|
from aki_prj23_transparenzregister.ui.pages import home
|
||||||
|
|
||||||
|
|
||||||
# def networkGraph(Edges: None) -> None:
|
def test_import() -> None:
|
||||||
# """Checks if an import co company_stats_dash can be made."""
|
"""Checks if an import co company_stats_dash can be made."""
|
||||||
# assert networkx_dash is not None
|
assert home is not None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user