Added Graph to Company page again

This commit is contained in:
Tim 2023-11-10 18:39:12 +01:00
parent e5769b3c25
commit fdbb6b5fd4
3 changed files with 6 additions and 52 deletions

View File

@ -380,9 +380,6 @@ def network_layout(selected_company_id: int) -> html.Div:
""" """
person_relations, company_relations = find_company_relations(selected_company_id) person_relations, company_relations = find_company_relations(selected_company_id)
# get_all_metrics_from_id(selected_company_id)
# get_relations_number_from_id(f"c_{selected_company_id}")
# Create Edge and Node List from data # Create Edge and Node List from data
nodes, edges = create_edge_and_node_list_for_company(company_relations) nodes, edges = create_edge_and_node_list_for_company(company_relations)
# Initialize the Network and receive the Graph and a DataFrame with Metrics # Initialize the Network and receive the Graph and a DataFrame with Metrics

View File

@ -39,28 +39,10 @@ dash.register_page(
], ],
) )
# 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
# graph, metrics = initialize_network(nodes=nodes, edges=edges)
metric = "None" metric = "None"
# layout = "Spring"
# # switch_node_annotaion_value = False
switch_edge_annotaion_value = False switch_edge_annotaion_value = False
egde_thickness = 1 egde_thickness = 1
network = None network = None
# create_3d_graph(
# graph,
# nodes,
# edges,
# metrics,
# metric,
# layout,
# switch_edge_annotaion_value,
# egde_thickness,
# )
# Get the possible Filter values for the Dropdowns.
def person_relation_type_filter() -> np.ndarray: def person_relation_type_filter() -> np.ndarray:
@ -146,26 +128,6 @@ def layout() -> list[html.Div]:
className="networkx_style", className="networkx_style",
children=[ children=[
html.H1(className="header", children=["Social Graph"]), 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( html.Div(
className="filter-wrapper", className="filter-wrapper",
id="company_dropdown", id="company_dropdown",

View File

@ -237,7 +237,7 @@ def find_company_relations(
""" """
session = SessionHandler.session session = SessionHandler.session
assert session # noqa: S101 assert session # noqa: S101
relations_company_query = ( relations_company = (
session.query( session.query(
to_company.id.label("id_company_to"), to_company.id.label("id_company_to"),
to_company.name.label("name_company_to"), to_company.name.label("name_company_to"),
@ -257,18 +257,11 @@ def find_company_relations(
(from_company.id == selected_company_id) (from_company.id == selected_company_id)
| (to_company.id == selected_company_id) | (to_company.id == selected_company_id)
) )
.all()
) )
company_relations = pd.DataFrame(relations_company_query.all())
# logger.debug(str(relations_company_query))
# relations_company_query = relations_company_query.filter(entities.CompanyRelation.company2_id == selected_company_id) # or (entities.CompanyRelation.company2_id == selected_company_id))
# logger.debug(str(relations_company_query))
# tmp = str(relations_company_query) + " WHERE from_company.id = " + str(selected_company_id)
# print(tmp)
# query = str(relations_company_query.filter((entities.CompanyRelation.company_id == selected_company_id) or (entities.CompanyRelation.company2_id == selected_company_id)))
# print(query)
# company_relations = get_all_company_relations()
company_relations = pd.DataFrame( company_relations = pd.DataFrame(
relations_company_query.all(), relations_company,
columns=[ columns=[
"id_company_to", "id_company_to",
"name_company_to", "name_company_to",
@ -309,12 +302,14 @@ def create_edge_and_node_list_for_company(
"id": row["id_company_from"], "id": row["id_company_from"],
"name": row["name_company_from"], "name": row["name_company_from"],
"color": COLOR_COMPANY, "color": COLOR_COMPANY,
"type": "company",
} }
if nodes.get(row["id_company_to"]) is None: if nodes.get(row["id_company_to"]) is None:
nodes[row["id_company_to"]] = { nodes[row["id_company_to"]] = {
"id": row["id_company_to"], "id": row["id_company_to"],
"name": row["name_company_to"], "name": row["name_company_to"],
"color": COLOR_COMPANY, "color": COLOR_COMPANY,
"type": "company",
} }
edges.append( edges.append(
{ {