Skip to content

Commit 403bd30

Browse files
committed
cleanup
1 parent fb7ff04 commit 403bd30

File tree

13 files changed

+62
-61
lines changed

13 files changed

+62
-61
lines changed

src/power_grid_model_ds/_core/visualizer/callbacks/element_scaling.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
from dash import Input, Output, callback
21
from copy import deepcopy
3-
from power_grid_model_ds._core.visualizer.layout.cytoscape_styling import DEFAULT_STYLESHEET, BRANCH_WIDTH, NODE_SIZE
2+
3+
from dash import Input, Output, callback
4+
5+
from power_grid_model_ds._core.visualizer.layout.cytoscape_styling import BRANCH_WIDTH, DEFAULT_STYLESHEET, NODE_SIZE
46

57

68
@callback(
7-
Output('cytoscape-graph', 'stylesheet', allow_duplicate=True),
8-
Input('node-scale-input', 'value'),
9-
Input('edge-scale-input', 'value'),
10-
prevent_initial_call=True
9+
Output("cytoscape-graph", "stylesheet", allow_duplicate=True),
10+
Input("node-scale-input", "value"),
11+
Input("edge-scale-input", "value"),
12+
prevent_initial_call=True,
1113
)
1214
def scale_elements(node_scale, edge_scale):
15+
"""Callback to scale the elements of the graph."""
1316
new_stylesheet = deepcopy(DEFAULT_STYLESHEET)
1417
edge_style = {
1518
"selector": "edge",

src/power_grid_model_ds/_core/visualizer/callbacks/element_selection.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from typing import Any
22

3-
from dash import Input, Output, callback, dash_table, dcc
3+
from dash import Input, Output, callback, dash_table
44

55
from power_grid_model_ds._core.visualizer.layout.selection_output import (
6-
SELECTION_OUTPUT_HEADER_STYLE,
76
SELECTION_OUTPUT_HTML,
87
)
98

@@ -24,8 +23,6 @@ def display_selected_element(node_data, edge_data):
2423

2524
def _to_data_table(data: dict[str, Any]):
2625
# del data["timeStamp"]
27-
group = data.pop("group")
28-
header = dcc.Markdown(f"↓ A **{group}** is selected ↓", style=SELECTION_OUTPUT_HEADER_STYLE)
2926
columns = data.keys()
3027
data_table = dash_table.DataTable(
3128
data=[data], columns=[{"name": key, "id": key} for key in columns], editable=False
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from dash import callback, Output, Input
1+
from dash import Input, Output, callback
22

33

4-
@callback(Output('cytoscape-graph', 'layout'), Input('dropdown-update-layout', 'value'),
5-
prevent_initial_call=True)
4+
@callback(Output("cytoscape-graph", "layout"), Input("dropdown-update-layout", "value"), prevent_initial_call=True)
65
def update_layout(layout):
7-
return {'name': layout, 'animate': True}
6+
"""Callback to update the layout of the graph."""
7+
return {"name": layout, "animate": True}

src/power_grid_model_ds/_core/visualizer/callbacks/search_form.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dash import Input, Output, State, callback
1+
from dash import Input, Output, callback
22

33
from power_grid_model_ds._core.visualizer.layout.colors import CYTO_COLORS
44
from power_grid_model_ds._core.visualizer.layout.cytoscape_styling import DEFAULT_STYLESHEET
@@ -28,7 +28,7 @@ def search_element(group, column, operator, value):
2828
if column == "id":
2929
selector = f'[{column} {operator} "{value}"]'
3030
else:
31-
selector = f'[{column} {operator} {value}]'
31+
selector = f"[{column} {operator} {value}]"
3232

3333
new_style = {
3434
"selector": selector,
@@ -37,7 +37,6 @@ def search_element(group, column, operator, value):
3737
return DEFAULT_STYLESHEET + [new_style]
3838

3939

40-
4140
@callback(
4241
Output("search-form-column-input", "options"),
4342
Output("search-form-column-input", "value"),

src/power_grid_model_ds/_core/visualizer/layout/colors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
YELLOW = "#facc37"
32
CYTO_COLORS = {
43
"line": YELLOW,

src/power_grid_model_ds/_core/visualizer/layout/cytoscape_config.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dash import html, dcc
1+
from dash import dcc, html
22

33
from power_grid_model_ds._core.visualizer.layout.colors import CYTO_COLORS
44
from power_grid_model_ds._core.visualizer.layout.cytoscape_html import LAYOUT_OPTIONS
@@ -14,7 +14,6 @@
1414
style={"width": "75px"},
1515
),
1616
html.Span(style={"margin-right": "10px"}),
17-
1817
]
1918

2019
EDGE_SCALE_HTML = [
@@ -37,12 +36,15 @@
3736
]
3837

3938
LAYOUT_DROPDOWN_HTML = [
40-
html.Div(dcc.Dropdown(
41-
id='dropdown-update-layout',
42-
placeholder="Select layout",
43-
value="",
44-
clearable=False,
45-
options=[{'label': name.capitalize(), 'value': name} for name in LAYOUT_OPTIONS],
46-
style={"width": "200px"}),
47-
style={"margin": "0 20px 0 10px"}
48-
)]
39+
html.Div(
40+
dcc.Dropdown(
41+
id="dropdown-update-layout",
42+
placeholder="Select layout",
43+
value="",
44+
clearable=False,
45+
options=[{"label": name.capitalize(), "value": name} for name in LAYOUT_OPTIONS],
46+
style={"width": "200px"},
47+
),
48+
style={"margin": "0 20px 0 10px"},
49+
)
50+
]

src/power_grid_model_ds/_core/visualizer/layout/cytoscape_html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Literal
1+
from typing import Any
22

33
import dash_cytoscape as cyto
44
from dash import html
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
import dash_bootstrap_components as dbc
2-
from dash import html, dcc
32

43
from power_grid_model_ds._core.visualizer.layout.colors import BACKGROUND_COLOR
54
from power_grid_model_ds._core.visualizer.layout.cytoscape_config import LAYOUT_DROPDOWN_HTML, SCALE_INPUTS
65
from power_grid_model_ds._core.visualizer.layout.legenda import LEGENDA_HTML
76
from power_grid_model_ds._core.visualizer.layout.search_form import SEARCH_FORM_HTML
87

9-
_SEARCH_FORM_CARD_STYLE={"background-color": "#555555", "color": "white", "border-left": "1px solid white",
10-
"border-right": "1px solid white", "border-radius": 0}
8+
_SEARCH_FORM_CARD_STYLE = {
9+
"background-color": "#555555",
10+
"color": "white",
11+
"border-left": "1px solid white",
12+
"border-right": "1px solid white",
13+
"border-radius": 0,
14+
}
1115

1216

1317
HEADER_HTML = dbc.Row(
1418
[
1519
dbc.Col(LEGENDA_HTML, className="d-flex align-items-center"),
1620
dbc.Col(
1721
dbc.Card(SEARCH_FORM_HTML, style=_SEARCH_FORM_CARD_STYLE),
18-
className="d-flex justify-content-center align-items-center"
22+
className="d-flex justify-content-center align-items-center",
1923
),
20-
dbc.Col(
21-
SCALE_INPUTS + LAYOUT_DROPDOWN_HTML
22-
, className="d-flex justify-content-end align-items-center"),
24+
dbc.Col(SCALE_INPUTS + LAYOUT_DROPDOWN_HTML, className="d-flex justify-content-end align-items-center"),
2325
],
2426
style={"background-color": BACKGROUND_COLOR},
25-
)
27+
)

src/power_grid_model_ds/_core/visualizer/layout/legenda.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from dash import html
21
import dash_bootstrap_components as dbc
2+
from dash import html
33

44
from power_grid_model_ds._core.visualizer.layout.colors import CYTO_COLORS
55

@@ -29,6 +29,6 @@
2929
"align-items": "center",
3030
"margin": "0 10px",
3131
"width": "100%",
32-
"text-shadow": "0 0 5px #000"
33-
}
32+
"text-shadow": "0 0 5px #000",
33+
},
3434
)

src/power_grid_model_ds/_core/visualizer/layout/search_form.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,17 @@
1414
{"label": "branch", "value": "branch"},
1515
],
1616
value="node", # Default value
17-
style=_INPUT_STYLE
17+
style=_INPUT_STYLE,
1818
)
1919

2020
COLUMN_INPUT = dbc.Select(
2121
id="search-form-column-input",
2222
options=[{"label": "id", "value": "id"}],
2323
value="id", # Default value
24-
style=_INPUT_STYLE
24+
style=_INPUT_STYLE,
2525
)
2626

27-
VALUE_INPUT = dbc.Input(
28-
id="search-form-value-input",
29-
placeholder="Enter value",
30-
type="text",
31-
style=_INPUT_STYLE
32-
)
27+
VALUE_INPUT = dbc.Input(id="search-form-value-input", placeholder="Enter value", type="text", style=_INPUT_STYLE)
3328

3429
OPERATOR_INPUT = dbc.Select(
3530
id="search-form-operator-input",
@@ -40,7 +35,7 @@
4035
{"label": "!=", "value": "!="},
4136
],
4237
value="=", # Default value
43-
style={"width": "60px", "display": "inline-block", "margin": "0 8px"}
38+
style={"width": "60px", "display": "inline-block", "margin": "0 8px"},
4439
)
4540

4641

@@ -54,13 +49,12 @@
5449
OPERATOR_INPUT,
5550
VALUE_INPUT,
5651
],
57-
style={
52+
style={
5853
"display": "flex",
5954
"align-items": "center",
6055
"justify-content": "center", # Centers items horizontally
6156
"padding": "10px",
6257
"margin": "0 auto", # Centers the container itself
63-
"width": "100%" # Ensures the container takes full width
64-
}
58+
"width": "100%", # Ensures the container takes full width
59+
},
6560
)
66-

0 commit comments

Comments
 (0)