Skip to content

Commit

Permalink
add rahavard chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuttlas90 committed Jul 24, 2024
1 parent afbfe4a commit 6342c88
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pages/helper/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ def get_stock_data(self):
"""
return string

def get_daily_social(self):
def get_daily_social(self, source):
"""return query to monthly sell value data"""
string = f"""select
index,
number,
date
from
public.social_data
INNER JOIN stocks ON public.social_data.stock_id = stocks.id
where
stocks.name = '{self.name}'
and source = '{source}'
LIMIT
30
Expand Down
23 changes: 20 additions & 3 deletions pages/social_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@

queries = Queries(name)

error, stock_data = vasahm_query(queries.get_daily_social())
error, stock_data = vasahm_query(queries.get_daily_social('sahamyab'))
if error:
st.error(stock_data, icon="🚨")
else:
if len(stock_data) > 0:
st.header("اقبال به سهم", divider='rainbow')
stock_data_history = pd.DataFrame(stock_data, columns=[
st.header("اقبال به سهم - سهامیاب", divider='rainbow')
stock_data_history = pd.DataFrame(stock_data, columns=["index",
"number",
"date"])
# stock_data_history["date"] = stock_data_history[
Expand All @@ -50,3 +50,20 @@
alt.X('date:N',title="تاریخ")
)
st.altair_chart(chart, use_container_width=True)

error, stock_data = vasahm_query(queries.get_daily_social('rahavard'))
if error:
st.error(stock_data, icon="🚨")
else:
if len(stock_data) > 0:
st.header("اقبال به سهم - رهآورد", divider='rainbow')
stock_data_history = pd.DataFrame(stock_data, columns=["index",
"number",
"date"])

chart = alt.Chart(stock_data_history).mark_bar().encode(
alt.Color('index:N', title="سرفصلها"),
alt.Y('number:Q', title="تعداد کامنت"),
alt.X('date:N',title="تاریخ")
)
st.altair_chart(chart, use_container_width=True)

0 comments on commit 6342c88

Please sign in to comment.