visual for total spend fixed,
This commit is contained in:
@@ -2,7 +2,6 @@ import polars as pl
|
||||
import plotly.express as px
|
||||
import pandas as pd
|
||||
import logging
|
||||
import sys
|
||||
import config.exit_codes as ec
|
||||
# import datetime
|
||||
|
||||
@@ -115,10 +114,13 @@ class data_components():
|
||||
font_color='white'
|
||||
)
|
||||
|
||||
total_spend_line = f"### £{total_spend:,.2f}"
|
||||
|
||||
data = {"spend_per_day_line": spend_per_day_line,
|
||||
"spend_per_category_bar": spend_per_category_bar,
|
||||
"spend_per_payee_bar": spend_per_payee_bar,
|
||||
"total_spend": total_spend}
|
||||
"total_spend": total_spend_line}
|
||||
|
||||
if callback == 0:
|
||||
return data
|
||||
else:
|
||||
|
||||
+1
-2
@@ -26,11 +26,10 @@ app = dash.Dash(__name__, external_stylesheets=[dbc.themes.DARKLY])
|
||||
Input('date-picker-range', 'start_date'),
|
||||
Input('date-picker-range', 'end_date')
|
||||
)
|
||||
def update_layout(start_date,end_date):
|
||||
def update_date_range(start_date,end_date):
|
||||
actual_start_date = datetime.date.fromisoformat(start_date)
|
||||
actual_end_date = datetime.date.fromisoformat(end_date)
|
||||
master_data = data_components.update_dates(actual_start_date,actual_end_date)
|
||||
# spend_per_day_line,spend_per_category_bar,spend_per_payee_bar,total_spend = data_components.update_data(master_data,callback=1)
|
||||
return data_components.update_data(master_data,callback=1)
|
||||
|
||||
app.layout = create_layout(data)
|
||||
|
||||
+77
-85
@@ -16,25 +16,34 @@ def create_layout(data):
|
||||
|
||||
def create_topbar():
|
||||
return [
|
||||
dbc.Container(
|
||||
dbc.Row(
|
||||
[
|
||||
dbc.Col(
|
||||
dcc.DatePickerRange(
|
||||
first_day_of_week=1,
|
||||
display_format="YYYY-MM-DD",
|
||||
id="date-picker-range",
|
||||
start_date=one_year_ago,
|
||||
end_date=today,
|
||||
dbc.Container([
|
||||
dbc.Row(
|
||||
dbc.Col(
|
||||
html.Div(html.H1("Data Pipeline For YNAB, Preview Visualisations"),
|
||||
className="text-center text-light",
|
||||
),
|
||||
width=12,
|
||||
)
|
||||
),
|
||||
dbc.Row(
|
||||
[
|
||||
dbc.Col(
|
||||
dcc.DatePickerRange(
|
||||
first_day_of_week=1,
|
||||
display_format="YYYY-MM-DD",
|
||||
id="date-picker-range",
|
||||
start_date=one_year_ago,
|
||||
end_date=today,
|
||||
),
|
||||
width=4,
|
||||
),
|
||||
width=4,
|
||||
),
|
||||
dbc.Col(
|
||||
html.Button("Change Date Range", id="date-range-confirm-button"),
|
||||
width=2,
|
||||
),
|
||||
]
|
||||
dbc.Col(
|
||||
html.Button("Change Date Range", id="date-range-confirm-button"),
|
||||
width=2,
|
||||
),
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
@@ -42,80 +51,63 @@ def create_main_body(data):
|
||||
return [
|
||||
dbc.Container(
|
||||
[
|
||||
dbc.Row(
|
||||
dbc.Col(
|
||||
html.Div(
|
||||
"Data Pipeline For YNAB, Preview Visualisations",
|
||||
className="text-center text-light",
|
||||
dbc.Row(
|
||||
[dbc.Col(
|
||||
dbc.Card(
|
||||
dbc.CardBody(
|
||||
[html.H4(
|
||||
"Spend Per Day", className="card-title"
|
||||
),
|
||||
dcc.Graph(figure=data['spend_per_day_line'],id='spend_per_day'),
|
||||
]
|
||||
),
|
||||
width=12,
|
||||
)
|
||||
className="mb-4",
|
||||
),
|
||||
width=12,
|
||||
)]
|
||||
),
|
||||
dbc.Row(
|
||||
[dbc.Col(
|
||||
dbc.Card(
|
||||
dbc.CardBody(
|
||||
[html.H4(
|
||||
"Spend Per Category", className="card-title"
|
||||
),
|
||||
dcc.Graph(figure=data['spend_per_category_bar'],id='spend_per_category'),
|
||||
]
|
||||
),
|
||||
className="mb-4",
|
||||
),
|
||||
width=5,
|
||||
),
|
||||
dbc.Row(
|
||||
[
|
||||
dbc.Col(
|
||||
dbc.Card(
|
||||
dbc.CardBody(
|
||||
[
|
||||
html.H4(
|
||||
"Spend Per Day", className="card-title"
|
||||
),
|
||||
dcc.Graph(figure=data['spend_per_day_line'],id='spend_per_day'),
|
||||
]
|
||||
),
|
||||
className="mb-4",
|
||||
),
|
||||
width=12,
|
||||
)
|
||||
]
|
||||
dbc.Col(
|
||||
dbc.Card(
|
||||
dbc.CardBody(
|
||||
[
|
||||
dcc.Markdown('## Total Spend:'),
|
||||
dcc.Markdown(data['total_spend'],id='total_spend'),
|
||||
],
|
||||
),
|
||||
className="text-center text-light",
|
||||
),
|
||||
width=2,
|
||||
),
|
||||
dbc.Row(
|
||||
[
|
||||
dbc.Col(
|
||||
dbc.Card(
|
||||
dbc.CardBody(
|
||||
[
|
||||
html.H4(
|
||||
"Spend Per Category", className="card-title"
|
||||
),
|
||||
dcc.Graph(figure=data['spend_per_category_bar'],id='spend_per_category'),
|
||||
]
|
||||
dbc.Col(
|
||||
dbc.Card(
|
||||
dbc.CardBody(
|
||||
[
|
||||
html.H4(
|
||||
"Spend Per Payee", className="card-title"
|
||||
),
|
||||
className="mb-4",
|
||||
),
|
||||
width=5,
|
||||
dcc.Graph(figure=data['spend_per_payee_bar'],id='spend_per_payee'),
|
||||
]
|
||||
),
|
||||
dbc.Col(
|
||||
dbc.Card(
|
||||
dbc.CardBody(
|
||||
[
|
||||
dcc.Markdown(f"""
|
||||
## Total Spend:
|
||||
### £{data['total_spend']:,}
|
||||
"""),
|
||||
]
|
||||
),
|
||||
id='total_spend',
|
||||
className="mb-4",
|
||||
),
|
||||
width=2,
|
||||
),
|
||||
dbc.Col(
|
||||
dbc.Card(
|
||||
dbc.CardBody(
|
||||
[
|
||||
html.H4(
|
||||
"Spend Per Payee", className="card-title"
|
||||
),
|
||||
dcc.Graph(figure=data['spend_per_payee_bar'],id='spend_per_payee'),
|
||||
]
|
||||
),
|
||||
className="mb-4",
|
||||
),
|
||||
width=5,
|
||||
),
|
||||
]
|
||||
className="mb-4",
|
||||
),
|
||||
width=5,
|
||||
),
|
||||
]
|
||||
),
|
||||
],
|
||||
fluid=True,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user