Commit
•
55d5f91
1
Parent(s):
c530d16
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,45 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import plotly.graph_objects as go
|
4 |
-
import pandas as pd
|
5 |
from datasets import load_dataset
|
6 |
|
|
|
7 |
ds = load_dataset("Esmaeilkiani/moghayesecroplogging")
|
|
|
|
|
8 |
st.set_page_config(page_title="اداره زراعت و کنترل محصول", layout="wide")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
def show_dashboard():
|
10 |
st.title("داشبورد")
|
11 |
uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
|
@@ -65,22 +99,7 @@ def show_growth_comparison():
|
|
65 |
st.plotly_chart(plot_3d_chart(data_1403, 'هفته', 'ارتفاع', title="سال 1403"))
|
66 |
st.plotly_chart(compare_growth(data_1399, data_1403, 'هفته', 'ارتفاع'))
|
67 |
|
68 |
-
|
69 |
-
fig = go.Figure(data=[go.Scatter3d(x=data[x_column], y=data[y_column], z=data[y_column],
|
70 |
-
mode='markers+lines', marker=dict(size=5))])
|
71 |
-
fig.update_layout(title=title, scene=dict(xaxis_title=x_column, yaxis_title=y_column, zaxis_title='ارتفاع'))
|
72 |
-
return fig
|
73 |
-
|
74 |
-
def compare_growth(data1, data2, x_column, y_column):
|
75 |
-
fig = go.Figure()
|
76 |
-
fig.add_trace(go.Scatter3d(x=data1[x_column], y=data1[y_column], z=data1[y_column],
|
77 |
-
mode='markers+lines', name="سال 1399", marker=dict(size=5)))
|
78 |
-
fig.add_trace(go.Scatter3d(x=data2[x_column], y=data2[y_column], z=data2[y_column],
|
79 |
-
mode='markers+lines', name="سال 1403", marker=dict(size=5)))
|
80 |
-
fig.update_layout(title="مقایسه رشد و ارتفاع 1399 با 1403",
|
81 |
-
scene=dict(xaxis_title=x_column, yaxis_title=y_column, zaxis_title='ارتفاع'))
|
82 |
-
return fig
|
83 |
-
|
84 |
st.sidebar.title("منو")
|
85 |
menu = st.sidebar.selectbox("انتخاب کنید", ["داشبورد", "تحلیل رشد محصول", "دادههای هواشناسی", "پایش سلامت محصول", "گزارشها", "مقایسه رشد و ارتفاع 1399 با 1403"])
|
86 |
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import plotly.graph_objects as go
|
|
|
4 |
from datasets import load_dataset
|
5 |
|
6 |
+
# Load the dataset
|
7 |
ds = load_dataset("Esmaeilkiani/moghayesecroplogging")
|
8 |
+
|
9 |
+
# Set page configuration
|
10 |
st.set_page_config(page_title="اداره زراعت و کنترل محصول", layout="wide")
|
11 |
+
|
12 |
+
# Apply custom CSS and JavaScript
|
13 |
+
def local_css(file_name):
|
14 |
+
with open(file_name) as f:
|
15 |
+
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
|
16 |
+
|
17 |
+
def local_js(file_name):
|
18 |
+
with open(file_name) as f:
|
19 |
+
st.markdown(f'<script>{f.read()}</script>', unsafe_allow_html=True)
|
20 |
+
|
21 |
+
local_css("styles.css")
|
22 |
+
local_js("scripts.js")
|
23 |
+
|
24 |
+
# Function to plot 3D chart
|
25 |
+
def plot_3d_chart(data, x_column, y_column, title=""):
|
26 |
+
fig = go.Figure(data=[go.Scatter3d(x=data[x_column], y=data[y_column], z=data[y_column],
|
27 |
+
mode='markers+lines', marker=dict(size=5))])
|
28 |
+
fig.update_layout(title=title, scene=dict(xaxis_title=x_column, yaxis_title=y_column, zaxis_title='ارتفاع'))
|
29 |
+
return fig
|
30 |
+
|
31 |
+
# Function to compare growth
|
32 |
+
def compare_growth(data1, data2, x_column, y_column):
|
33 |
+
fig = go.Figure()
|
34 |
+
fig.add_trace(go.Scatter3d(x=data1[x_column], y=data1[y_column], z=data1[y_column],
|
35 |
+
mode='markers+lines', name="سال 1399", marker=dict(size=5)))
|
36 |
+
fig.add_trace(go.Scatter3d(x=data2[x_column], y=data2[y_column], z=data2[y_column],
|
37 |
+
mode='markers+lines', name="سال 1403", marker=dict(size=5)))
|
38 |
+
fig.update_layout(title="مقایسه رشد و ارتفاع 1399 با 1403",
|
39 |
+
scene=dict(xaxis_title=x_column, yaxis_title=y_column, zaxis_title='ارتفاع'))
|
40 |
+
return fig
|
41 |
+
|
42 |
+
# Functions for different pages
|
43 |
def show_dashboard():
|
44 |
st.title("داشبورد")
|
45 |
uploaded_file = st.file_uploader("بارگذاری فایل CSV", type=["csv"])
|
|
|
99 |
st.plotly_chart(plot_3d_chart(data_1403, 'هفته', 'ارتفاع', title="سال 1403"))
|
100 |
st.plotly_chart(compare_growth(data_1399, data_1403, 'هفته', 'ارتفاع'))
|
101 |
|
102 |
+
# Sidebar menu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
st.sidebar.title("منو")
|
104 |
menu = st.sidebar.selectbox("انتخاب کنید", ["داشبورد", "تحلیل رشد محصول", "دادههای هواشناسی", "پایش سلامت محصول", "گزارشها", "مقایسه رشد و ارتفاع 1399 با 1403"])
|
105 |
|