On branch feature/visualize-verflechtungen

This commit is contained in:
Tim
2023-09-26 18:16:42 +02:00
parent af0578bb00
commit 6a313f9803
2 changed files with 33 additions and 17 deletions

View File

@ -1,7 +1,7 @@
import pandas as pd
import networkx as nx
import plotly.graph_objects as go
from dash import Dash, Input, Output, dcc, html, callback
from dash import Dash, Input, Output, dcc, html
from aki_prj23_transparenzregister.config.config_providers import JsonFileConfigProvider
from aki_prj23_transparenzregister.utils.sql import connector, entities
@ -32,10 +32,10 @@ def find_company_relations(company_id: int) -> pd.DataFrame:
return companies_relations_df
# Plotly figure
def networkGraph(company_id: int) -> go.Figure:
def networkGraph(EGDE_VAR: None) -> go.Figure:
# df = find_company_relations(test_company)
edges = []
for index, row in find_company_relations(company_id).iterrows():
for index, row in find_company_relations(test_company).iterrows():
edges.append([row["company_name"], row["connected_company_name"]])
# print(row["company_name"], row["connected_company_name"])
# print(edges)
@ -109,13 +109,31 @@ def networkGraph(company_id: int) -> go.Figure:
# figure
return go.Figure(data=[edge_trace, node_trace], layout=layout)
def networkx_component(company_id: int):
layout = html.Div(
[
dcc.Graph(id="my-graph", figure=networkGraph(company_id)),
]
)
return layout
# Dash App
app = Dash(__name__)
app.title = "Dash Networkx"
app.layout = html.Div(
[
html.I("Write your EDGE_VAR"),
html.Br(),
dcc.Input(id="EGDE_VAR", type="text", value="K", debounce=True),
dcc.Graph(id="my-graph"),
]
)
@app.callback(
Output("my-graph", "figure"),
[Input("EGDE_VAR", "value")],
)
def update_output(EGDE_VAR: None) -> None:
return networkGraph(EGDE_VAR)
if __name__ == "__main__":
app.run(debug=True)

View File

@ -148,16 +148,14 @@ def networkGraph(EGDE_VAR: None) -> go.Figure:
app = Dash(__name__)
app.title = "Dash Networkx"
# className="networkx_style"
app.layout = html.Div(
style={'width': '49%'},
children = [
[
html.I("Write your EDGE_VAR"),
html.Br(),
# dcc.Dropdown(['eigenvector', 'degree', 'betweeness', 'closeness'], 'eigenvector', id='metric-dropdown'),
dcc.Input(id="EGDE_VAR", type="text", value="K", debounce=True),
dcc.Graph(id="my-graph", style={'width': '49%'}),
dcc.Graph(id="my-graph"),
]
)