Test Bugs

This commit is contained in:
Tim 2023-11-04 10:31:27 +01:00
parent 4fe97dfd86
commit c5721362ac
5 changed files with 79 additions and 66 deletions

View File

@ -383,15 +383,10 @@ def network_layout(selected_company_id: int) -> html.Div:
# Create Edge and Node List from data
nodes, edges = create_edge_and_node_list_for_company(company_relations)
# Initialize the Network and receive the Graph and a DataFrame with Metrics
# print(nodes)
# print(edges)
# print(pd.DataFrame(edges))
if nodes != {}:
graph, metrics = initialize_network(nodes=nodes, edges=edges)
metric = "None"
figure = create_2d_graph(graph, nodes, edges, metrics, metric, layout="Spring", edge_annotation=True, node_annotation=False, edge_thickness=1)
# selected_company_id
# print(company_relations)
return html.Div( children=[dcc.Graph(figure=figure, id="company-graph", className="graph-style")])
# return networkx_component(selected_company_id)
return html.Div([html.H3(f"Leider gibt es keine Verbindungen vom Unternehmen mit ID: {selected_company_id}")])

View File

@ -60,8 +60,6 @@ network = create_3d_graph(graph, nodes, edges, metrics, metric)
# Create Edge and Node List from data
nodes, edges = create_edge_and_node_list(person_relation, company_relation)
# Initialize the Network and receive the Graph and a DataFrame with Metrics
node_count = len(nodes)
edge_count = len(edges)
graph, metrics = initialize_network(nodes=nodes, edges=edges)
metric = "None"
layout = "Spring"
@ -117,30 +115,30 @@ layout = html.Div(
className="networkx_style",
children=[
html.H1(className="header", children=["Social Graph"]),
html.Div(
className="filter-wrapper",
children=[
html.Div(
className="filter-wrapper-item",
children=[
html.H5(
className="filter-description",
children=["Data Source:"],
),
dcc.Dropdown(
["Company Data only", "Person Data only", "Company & Person Data"],
"Company Data only",
id="dropdown_data_soruce_filter",
className="dropdown_style",
),
],
),
],
),
# html.Div(
# className="filter-wrapper",
# children=[
# html.Div(
# className="filter-wrapper-item",
# children=[
# html.H5(
# className="filter-description",
# children=["Data Source:"],
# ),
# dcc.Dropdown(
# ["Company Data only", "Person Data only", "Company & Person Data"],
# "Company Data only",
# id="dropdown_data_soruce_filter",
# className="dropdown_style",
# ),
# ],
# ),
# ],
# ),
html.Div(
className="filter-wrapper",
id= "company_dropdown",
# style="display: inline;",
# style="visibility: hidden;",
children=[
html.Div(
className="filter-wrapper-item",
@ -159,7 +157,7 @@ layout = html.Div(
),
html.Div(
className="filter-wrapper-item",
# style="display: None;",
# style="visibility: visible;",
children=[
html.H5(
className="filter-description",
@ -278,27 +276,6 @@ layout = html.Div(
),
],
),
html.Div(
className="filter-wrapper",
children=[
html.Div(
className="filter-wrapper-item",
children=[
html.H5(
className="filter-description",
children=[f"""Number of shown Nodes: {node_count}"""],
),
],),
html.Div(
className="filter-wrapper-item",
children=[
html.H5(
className="filter-description",
children=[f"""Number of shown Edges: {edge_count}"""],
),
],),
],
),
dcc.Graph(figure=network, id="my-graph", className="graph-style"),
],
@ -321,13 +298,9 @@ def update_graph_data(
company_relation = filter_relation_type(company_df, company_relation_type)
# company_relation = filter_relation_with_more_than_one_connection(company_relation, "id_company_to", "id_company_from")
# print(company_relation)
# print(len(company_relation))
# Create Edge and Node List from data
nodes_tmp, edges_tmp = create_edge_and_node_list(person_relation, company_relation)
node_count = len(nodes_tmp)
edge_count = len(edges_tmp)
# print(edges_tmp)
graph, metrics = initialize_network(nodes=nodes_tmp, edges=edges_tmp)
return graph, metrics, nodes_tmp, edges_tmp
@ -378,9 +351,6 @@ def update_figure(
# 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)
node_count = len(nodes)
edge_count = len(edges)
if switch_value:
return create_2d_graph(graph, nodes, edges, metrics, selected_metric, layout, switch_node_annotaion_value, switch_edge_annotaion_value, slider_value)
@ -414,9 +384,9 @@ def update_Dropdown(datasource_value: str) -> str:
style = ""
match datasource_value:
case "Company Data only":
style = "display: inline"
style = "visibility: visible;"
case "Person Data only":
style = "display: none"
style = "visibility: hidden;"
case "Company & Person Data":
style = "display: inline"
style = "visibility: visible;"
return style

View File

@ -154,7 +154,18 @@ def create_2d_graph(
showlegend=False,
hovermode="closest",
margin={"b": 20, "l": 5, "r": 5, "t": 20},
# annotations=,
annotations=[{
"showarrow": False,
"text": f"Companies (Blue) & Person (Red) Relation \n node_count: {len(nodes)}, edge_count: {len(edges)}",
"xref": "paper",
"yref": "paper",
"x": 0,
"y": 0.1,
"xanchor": "left",
"yanchor": "bottom",
"font": {"size": 14},
}
],
xaxis={"showgrid": False, "zeroline": False, "showticklabels": False},
yaxis={"showgrid": False, "zeroline": False, "showticklabels": False},
),

View File

@ -147,7 +147,7 @@ def create_3d_graph(
annotations=[
{
"showarrow": False,
"text": "Companies (Blue) & Person (Red) Relation",
"text": f"Companies (Blue) & Person (Red) Relation \n node_count: {len(nodes)}, edge_count: {len(edges)}",
"xref": "paper",
"yref": "paper",
"x": 0,

View File

@ -158,6 +158,10 @@ 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
]
@ -356,6 +360,16 @@ def create_edge_and_node_list_for_company(
def return_metric_table_df(metrics: pd.DataFrame, nodes: dict, metric: str)-> pd.DataFrame:
"""_summary_
Args:
metrics (pd.DataFrame): _description_
nodes (dict): _description_
metric (str): _description_
Returns:
pd.DataFrame: _description_
"""
# tmp = pd.DataFrame(columns=["Platzierung", "company_name", "Umsatz M€"])
tmp_list = []
@ -376,3 +390,26 @@ def return_metric_table_df(metrics: pd.DataFrame, nodes: dict, metric: str)-> pd
tmp_df.rename(columns={metric: "Metric"}, inplace=True)
# print(tmp_df[["designation", metric, "category"]].head(10))
return tmp_df
def get_all_metrics_from_id(company_id: int)-> pd.DataFrame:
"""_summary_
Args:
company_id (int): _description_
Returns:
pd.DataFrame: _description_
"""
return pd.DataFrame
def get_relations_number_from_id(company_id: int)->tuple[int,int,int]:
"""_summary_
Args:
company_id (int): _description_
Returns:
tuple[int,int,int]: _description_
"""
return (1,2,3)