-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from adarshkannada/AUG6
show monthly charts
- Loading branch information
Showing
9 changed files
with
97 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import streamlit as st | ||
from dotenv import load_dotenv | ||
|
||
from src.main.data.core_data import CoreData | ||
from src.main.data.data_import import ImportData | ||
from loguru import logger | ||
from streamlit_echarts import st_echarts | ||
|
||
from src.main.data.sqlite_conn import Sql | ||
from src.main.utils.utils import Utils | ||
|
||
load_dotenv() | ||
|
||
|
||
# streamlit app | ||
st.title('My Analytics') | ||
st.markdown("# Home 🎈") | ||
st.sidebar.markdown("# Home 🎈") | ||
# Create a text element and let the reader know the data is loading. | ||
data_load_state = st.text('Loading data...') | ||
|
||
|
||
# @st.cache_data | ||
def get_data(): | ||
return Sql().get_data_from_table(query=f"select * from Jul2023 where Date = 'Jul2023'") | ||
|
||
|
||
data = get_data() | ||
|
||
# Notify the reader that the data was successfully loaded. | ||
|
||
bardf = Sql().get_data_from_table(query=f"select * from {Utils().get_current_month_year()} where Date = " | ||
f"'{Utils().get_current_month_year()}'") | ||
home_bar = bardf['Home'].values[0] | ||
bills_bar = bardf['Bills'].values[0] | ||
shopping_bar = bardf['Shopping'].values[0] | ||
food_bar = bardf['Food'].values[0] | ||
travel_bar = bardf['Travel'].values[0] | ||
clothes_bar = bardf['Clothes'].values[0] | ||
fuel_bar = bardf['Fuel'].values[0] | ||
gifts_bar = bardf['Gifts'].values[0] | ||
general_bar = bardf['General'].values[0] | ||
invest_bar = bardf['Investment'].values[0] | ||
meds_bar = bardf['Medicine'].values[0] | ||
|
||
|
||
options = { | ||
"xAxis": { | ||
"type": "category", | ||
"data": CoreData().columns, | ||
}, | ||
"yAxis": {"type": "value"}, | ||
"series": [{"data": [home_bar, bills_bar, shopping_bar, food_bar, travel_bar, clothes_bar, | ||
fuel_bar, gifts_bar, general_bar, invest_bar, meds_bar], | ||
"type": "bar"}], | ||
} | ||
|
||
st.write("# Current Month") | ||
st_echarts(options=options, height="500px") | ||
|
||
data_load_state.text(f'Data for the current month') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import streamlit as st | ||
import pandas as pd | ||
from src.main.data.core_data import CoreData | ||
from src.main.data.sqlite_conn import Sql | ||
|
||
st.markdown("# Monthly Chart ❄️") | ||
st.sidebar.markdown("# Monthly Chart ❄️") | ||
|
||
data_load_state = st.text('Loading data...') | ||
data_load_state.text(f'Data for the months of 2023') | ||
|
||
df_jul2023 = Sql().get_data_from_table(query=f"select * from Jul2023 where Date = 'Jul2023'") | ||
df_jun2023 = Sql().get_data_from_table(query=f"select * from Jun2023 where Date = 'Jun2023'") | ||
df_may2023 = Sql().get_data_from_table(query=f"select * from May2023 where Date = 'May2023'") | ||
df_apr2023 = Sql().get_data_from_table(query=f"select * from Apr2023 where Date = 'Apr2023'") | ||
df_mar2023 = Sql().get_data_from_table(query=f"select * from Mar2023 where Date = 'Mar2023'") | ||
df_feb2023 = Sql().get_data_from_table(query=f"select * from Feb2023 where Date = 'Feb2023'") | ||
df_jan2023 = Sql().get_data_from_table(query=f"select * from Jan2023 where Date = 'Jan2023'") | ||
|
||
frames = [df_jul2023, df_jun2023, df_may2023, df_apr2023, df_mar2023, | ||
df_feb2023, df_jan2023] | ||
df_merged = pd.concat(frames) | ||
st.write(df_merged) | ||
for each in CoreData().columns: | ||
st.line_chart(data=df_merged, x='Date', y=[each], | ||
width=0, height=0, use_container_width=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class CoreData: | ||
columns = ["Home", "Bills", "Shopping", "Food", "Travel", "Clothes", | ||
"Fuel", "Gifts", "General", "Investment", "Medicine"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.