diff --git a/src/aki_prj23_transparenzregister/ui/networkx_dash.py b/src/aki_prj23_transparenzregister/ui/archive/networkx_dash.py similarity index 100% rename from src/aki_prj23_transparenzregister/ui/networkx_dash.py rename to src/aki_prj23_transparenzregister/ui/archive/networkx_dash.py diff --git a/src/aki_prj23_transparenzregister/ui/ui_elements.py b/src/aki_prj23_transparenzregister/ui/archive/ui_elements.py similarity index 99% rename from src/aki_prj23_transparenzregister/ui/ui_elements.py rename to src/aki_prj23_transparenzregister/ui/archive/ui_elements.py index 39dcf93..c432e8a 100644 --- a/src/aki_prj23_transparenzregister/ui/ui_elements.py +++ b/src/aki_prj23_transparenzregister/ui/archive/ui_elements.py @@ -8,7 +8,7 @@ from sqlalchemy.engine import Engine from sqlalchemy.orm import Session 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 = { "light": "#edefef", diff --git a/src/aki_prj23_transparenzregister/ui/company_elements.py b/src/aki_prj23_transparenzregister/ui/company_elements.py index 3e7b065..647805c 100644 --- a/src/aki_prj23_transparenzregister/ui/company_elements.py +++ b/src/aki_prj23_transparenzregister/ui/company_elements.py @@ -10,7 +10,6 @@ from dash import dash_table, dcc, html from sqlalchemy.orm import Session 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_base import initialize_network from aki_prj23_transparenzregister.utils.networkx.networkx_data import ( diff --git a/src/aki_prj23_transparenzregister/ui/pages/home.py b/src/aki_prj23_transparenzregister/ui/pages/home.py index 510a9de..1aa661b 100644 --- a/src/aki_prj23_transparenzregister/ui/pages/home.py +++ b/src/aki_prj23_transparenzregister/ui/pages/home.py @@ -27,6 +27,7 @@ from aki_prj23_transparenzregister.utils.networkx.networkx_data import ( return_metric_table_df ) +dash.register_page(__name__, path="/") # Get Data 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) metric = "None" layout = "Spring" -switch_node_annotaion_value = False +# switch_node_annotaion_value = False switch_edge_annotaion_value = False 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. -company_relation_type_filter = get_all_person_relations()["relation_type"].unique() -person_relation_type_filter = get_all_company_relations()["relation_type"].unique() - +person_relation_type_filter = get_all_person_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() -# with open("src/aki_prj23_transparenzregister/ui/assets/network_graph.html") as file: -# html_content = file.read() layout = html.Div( children=html.Div( @@ -248,19 +246,19 @@ layout = html.Div( ), ], ), - html.Div( - className="filter-wrapper-item", - children=[ - html.H5( - className="filter-description", - children=["Enable Node Annotation"], - ), - html.Div( - className="switch-style", - children=[daq.BooleanSwitch(id="switch_node_annotation", on=False)], - ), - ], - ), + # html.Div( + # className="filter-wrapper-item", + # children=[ + # html.H5( + # className="filter-description", + # children=["Enable Node Annotation"], + # ), + # html.Div( + # className="switch-style", + # children=[daq.BooleanSwitch(id="switch_node_annotation", on=False)], + # ), + # ], + # ), html.Div( className="filter-wrapper-item", children=[ @@ -292,7 +290,6 @@ def update_graph_data( # Get Data person_df = get_all_person_relations() company_df = get_all_company_relations() - # print(company_df) person_relation = filter_relation_type(person_df, person_relation_type) company_relation = filter_relation_type(company_df, company_relation_type) @@ -311,7 +308,7 @@ def update_graph_data( [ Input("dropdown", "value"), Input("switch", "on"), - Input("switch_node_annotation", "on"), + # Input("switch_node_annotation", "on"), Input("switch_edge_annotation", "on"), Input("dropdown_company_relation_filter", "value"), Input("dropdown_person_relation_filter", "value"), @@ -325,7 +322,7 @@ def update_graph_data( def update_figure( selected_metric: str, switch_value: bool, - switch_node_annotaion_value: bool, + # switch_node_annotaion_value: bool, switch_edge_annotaion_value: bool, c_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 """ _ = 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': - # 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) + graph, metrics, nodes, edges = update_graph_data(person_relation_type= p_relation_filter_value, company_relation_type= c_relation_filter_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: - 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( @@ -367,10 +359,7 @@ def update_figure( def update_table(metric_dropdown_value: str) -> dict: table_df = return_metric_table_df(metrics, nodes, metric_dropdown_value) table_df.to_dict("records") - # print(table_df.to_dict("records")) - columns =[{"name": i, "id": i} for i in table_df.columns] - # print(columns) - + columns =[{"name": i, "id": i} for i in table_df.columns] return table_df.to_dict("records") diff --git a/src/aki_prj23_transparenzregister/utils/networkx/network_2d.py b/src/aki_prj23_transparenzregister/utils/networkx/network_2d.py index d305f3b..fdf959b 100644 --- a/src/aki_prj23_transparenzregister/utils/networkx/network_2d.py +++ b/src/aki_prj23_transparenzregister/utils/networkx/network_2d.py @@ -6,7 +6,7 @@ import plotly.graph_objects as go 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: """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 # print(edge_type_list) - if node_annotation: - print("Test") - # node_trace.text = nodes. + # Return the Plotly Figure return go.Figure( diff --git a/src/aki_prj23_transparenzregister/utils/networkx/network_3d.py b/src/aki_prj23_transparenzregister/utils/networkx/network_3d.py index e05ebad..4b195c1 100644 --- a/src/aki_prj23_transparenzregister/utils/networkx/network_3d.py +++ b/src/aki_prj23_transparenzregister/utils/networkx/network_3d.py @@ -6,7 +6,7 @@ import plotly.graph_objects as go 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: """This Method creates a 3D Network in Plotly with a Scatter Graph and retuns it. diff --git a/src/aki_prj23_transparenzregister/utils/networkx/networkx_data.py b/src/aki_prj23_transparenzregister/utils/networkx/networkx_data.py index a85a238..adcc720 100644 --- a/src/aki_prj23_transparenzregister/utils/networkx/networkx_data.py +++ b/src/aki_prj23_transparenzregister/utils/networkx/networkx_data.py @@ -158,10 +158,7 @@ def filter_relation_type( Returns: 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[ relation_dataframe["relation_type"] == selected_relation_type ] diff --git a/tests/ui/home_page_test.py b/tests/ui/home_page_test.py index ce75cdd..1bb3bb3 100644 --- a/tests/ui/home_page_test.py +++ b/tests/ui/home_page_test.py @@ -1,7 +1,7 @@ """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: -# """Checks if an import co company_stats_dash can be made.""" -# assert networkx_dash is not None +def test_import() -> None: + """Checks if an import co company_stats_dash can be made.""" + assert home is not None