refactor: update app code for domain-scoped schema migration
Some checks failed
CI / lint-and-test (pull_request) Has been cancelled
Some checks failed
CI / lint-and-test (pull_request) Has been cancelled
- Update dbt model references to use new schema naming (stg_toronto, int_toronto, mart_toronto) - Refactor figure factories to use consistent column naming from new schema - Update callbacks to work with refactored data structures - Add centralized design tokens module for consistent styling - Streamline CLAUDE.md documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,17 @@ import pandas as pd
|
||||
import plotly.express as px
|
||||
import plotly.graph_objects as go
|
||||
|
||||
from portfolio_app.design import (
|
||||
CHART_PALETTE,
|
||||
COLOR_NEGATIVE,
|
||||
COLOR_POSITIVE,
|
||||
GRID_COLOR,
|
||||
PAPER_BG,
|
||||
PLOT_BG,
|
||||
TEXT_PRIMARY,
|
||||
TEXT_SECONDARY,
|
||||
)
|
||||
|
||||
|
||||
def create_ranking_bar(
|
||||
data: list[dict[str, Any]],
|
||||
@@ -14,8 +25,8 @@ def create_ranking_bar(
|
||||
title: str | None = None,
|
||||
top_n: int = 10,
|
||||
bottom_n: int = 10,
|
||||
color_top: str = "#4CAF50",
|
||||
color_bottom: str = "#F44336",
|
||||
color_top: str = COLOR_POSITIVE,
|
||||
color_bottom: str = COLOR_NEGATIVE,
|
||||
value_format: str = ",.0f",
|
||||
) -> go.Figure:
|
||||
"""Create horizontal bar chart showing top and bottom rankings.
|
||||
@@ -87,10 +98,10 @@ def create_ranking_bar(
|
||||
barmode="group",
|
||||
showlegend=True,
|
||||
legend={"orientation": "h", "yanchor": "bottom", "y": 1.02},
|
||||
paper_bgcolor="rgba(0,0,0,0)",
|
||||
plot_bgcolor="rgba(0,0,0,0)",
|
||||
font_color="#c9c9c9",
|
||||
xaxis={"gridcolor": "rgba(128,128,128,0.2)", "title": None},
|
||||
paper_bgcolor=PAPER_BG,
|
||||
plot_bgcolor=PLOT_BG,
|
||||
font_color=TEXT_PRIMARY,
|
||||
xaxis={"gridcolor": GRID_COLOR, "title": None},
|
||||
yaxis={"autorange": "reversed", "title": None},
|
||||
margin={"l": 10, "r": 10, "t": 40, "b": 10},
|
||||
)
|
||||
@@ -126,10 +137,10 @@ def create_stacked_bar(
|
||||
|
||||
df = pd.DataFrame(data)
|
||||
|
||||
# Default color scheme
|
||||
# Default color scheme using accessible palette
|
||||
if color_map is None:
|
||||
categories = df[category_column].unique()
|
||||
colors = px.colors.qualitative.Set2[: len(categories)]
|
||||
colors = CHART_PALETTE[: len(categories)]
|
||||
color_map = dict(zip(categories, colors, strict=False))
|
||||
|
||||
fig = px.bar(
|
||||
@@ -147,11 +158,11 @@ def create_stacked_bar(
|
||||
|
||||
fig.update_layout(
|
||||
title=title,
|
||||
paper_bgcolor="rgba(0,0,0,0)",
|
||||
plot_bgcolor="rgba(0,0,0,0)",
|
||||
font_color="#c9c9c9",
|
||||
xaxis={"gridcolor": "rgba(128,128,128,0.2)", "title": None},
|
||||
yaxis={"gridcolor": "rgba(128,128,128,0.2)", "title": None},
|
||||
paper_bgcolor=PAPER_BG,
|
||||
plot_bgcolor=PLOT_BG,
|
||||
font_color=TEXT_PRIMARY,
|
||||
xaxis={"gridcolor": GRID_COLOR, "title": None},
|
||||
yaxis={"gridcolor": GRID_COLOR, "title": None},
|
||||
legend={"orientation": "h", "yanchor": "bottom", "y": 1.02},
|
||||
margin={"l": 10, "r": 10, "t": 60, "b": 10},
|
||||
)
|
||||
@@ -164,7 +175,7 @@ def create_horizontal_bar(
|
||||
name_column: str,
|
||||
value_column: str,
|
||||
title: str | None = None,
|
||||
color: str = "#2196F3",
|
||||
color: str = CHART_PALETTE[0],
|
||||
value_format: str = ",.0f",
|
||||
sort: bool = True,
|
||||
) -> go.Figure:
|
||||
@@ -204,10 +215,10 @@ def create_horizontal_bar(
|
||||
|
||||
fig.update_layout(
|
||||
title=title,
|
||||
paper_bgcolor="rgba(0,0,0,0)",
|
||||
plot_bgcolor="rgba(0,0,0,0)",
|
||||
font_color="#c9c9c9",
|
||||
xaxis={"gridcolor": "rgba(128,128,128,0.2)", "title": None},
|
||||
paper_bgcolor=PAPER_BG,
|
||||
plot_bgcolor=PLOT_BG,
|
||||
font_color=TEXT_PRIMARY,
|
||||
xaxis={"gridcolor": GRID_COLOR, "title": None},
|
||||
yaxis={"title": None},
|
||||
margin={"l": 10, "r": 10, "t": 40, "b": 10},
|
||||
)
|
||||
@@ -225,13 +236,13 @@ def _create_empty_figure(title: str) -> go.Figure:
|
||||
x=0.5,
|
||||
y=0.5,
|
||||
showarrow=False,
|
||||
font={"size": 14, "color": "#888888"},
|
||||
font={"size": 14, "color": TEXT_SECONDARY},
|
||||
)
|
||||
fig.update_layout(
|
||||
title=title,
|
||||
paper_bgcolor="rgba(0,0,0,0)",
|
||||
plot_bgcolor="rgba(0,0,0,0)",
|
||||
font_color="#c9c9c9",
|
||||
paper_bgcolor=PAPER_BG,
|
||||
plot_bgcolor=PLOT_BG,
|
||||
font_color=TEXT_PRIMARY,
|
||||
xaxis={"visible": False},
|
||||
yaxis={"visible": False},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user