VarunRavichander commited on
Commit
405fcf9
ยท
verified ยท
1 Parent(s): 5806ec4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -33
app.py CHANGED
@@ -12,23 +12,23 @@ st.set_page_config(
12
 
13
  # Style input fields with black text and Times New Roman
14
  st.markdown("""
15
- <style>
16
- * {
17
- font-family: 'Times New Roman', Times, serif !important;
18
- }
19
- .stTextInput input {
20
- color: black !important;
21
- font-family: 'Times New Roman', Times, serif !important;
22
- }
23
- .stSelectbox select {
24
- color: black !important;
25
- font-family: 'Times New Roman', Times, serif !important;
26
- }
27
- .stMultiSelect select {
28
- color: black !important;
29
- font-family: 'Times New Roman', Times, serif !important;
30
- }
31
- </style>
32
  """, unsafe_allow_html=True)
33
 
34
  # Title and description
@@ -60,6 +60,13 @@ if uploaded_file:
60
  x_axis_label = st.text_input("X-axis Label", x_column)
61
  y_axis_label = st.text_input("Y-axis Label", "Values")
62
 
 
 
 
 
 
 
 
63
  # Legend position controls
64
  st.subheader("Legend Position Control")
65
  col1, col2 = st.columns(2)
@@ -68,24 +75,40 @@ if uploaded_file:
68
  with col2:
69
  legend_y = st.slider("Legend Y Position", -0.5, 2.0, 1.0, 0.05)
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  # Legend customization
72
  st.subheader("Customize Legend Names")
73
  legend_names = {}
74
  for col in y_columns:
75
  legend_names[col] = st.text_input(f"Legend name for {col}", col)
76
 
77
- # Define vibrant colors
78
- vibrant_colors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEEAD',
79
- '#FF9F1C', '#E71D36', '#2EC4B6', '#011627']
80
-
81
  # Generate plot
82
  if st.button("Generate Graph"):
83
  # Convert date column to datetime
84
  df[x_column] = pd.to_datetime(df[x_column])
85
 
86
- # Create figure with vibrant colors
 
 
 
 
 
 
87
  fig = px.line(df, x=x_column, y=y_columns,
88
- color_discrete_sequence=vibrant_colors)
89
 
90
  # Update legend names and hover template with date and time
91
  for i, trace in enumerate(fig.data):
@@ -99,7 +122,7 @@ if uploaded_file:
99
  x=0.5,
100
  xanchor='center',
101
  yanchor='top',
102
- font=dict(family="Times New Roman", color="black")
103
  ),
104
  showlegend=True,
105
  legend=dict(
@@ -111,7 +134,7 @@ if uploaded_file:
111
  bgcolor="white",
112
  bordercolor="Black",
113
  borderwidth=1,
114
- font=dict(family="Times New Roman", color="black"),
115
  title=dict(text="")
116
  ),
117
  hovermode='x unified',
@@ -127,8 +150,8 @@ if uploaded_file:
127
  mirror=True,
128
  tickangle=-90,
129
  title_text=x_axis_label,
130
- title_font=dict(family="Times New Roman", color="black"),
131
- tickfont=dict(family="Times New Roman", color="black", size=10),
132
  type='date',
133
  tickformat='%d-%m-%Y',
134
  dtick='D1',
@@ -143,8 +166,8 @@ if uploaded_file:
143
  linecolor='black',
144
  mirror=True,
145
  title_text=y_axis_label,
146
- title_font=dict(family="Times New Roman", color="black"),
147
- tickfont=dict(family="Times New Roman", color="black")
148
  ),
149
  margin=dict(l=80, r=150, t=100, b=100),
150
  width=900,
@@ -189,17 +212,17 @@ st.markdown("""
189
  - Black text for all elements
190
  - Clean legend display with custom names
191
  - Customizable plot title, axes labels, and legend names
192
- - Vibrant color schemes
 
193
  - Interactive legend positioning with precise controls
194
  - Interactive plot with hover details
195
  - Download options in HTML format
196
  """
197
  """
198
  ### ๐Ÿ“ For Support And Assistance:
199
-
200
  Contact:
201
  - Harshitha Gunnam
202
- gunnamharshitha2@gmail.com
203
  - Varun Ravichander
204
- varunravichander2007@gmail.com
205
  """)
 
12
 
13
  # Style input fields with black text and Times New Roman
14
  st.markdown("""
15
+ <style>
16
+ * {
17
+ font-family: 'Times New Roman', Times, serif !important;
18
+ }
19
+ .stTextInput input {
20
+ color: black !important;
21
+ font-family: 'Times New Roman', Times, serif !important;
22
+ }
23
+ .stSelectbox select {
24
+ color: black !important;
25
+ font-family: 'Times New Roman', Times, serif !important;
26
+ }
27
+ .stMultiSelect select {
28
+ color: black !important;
29
+ font-family: 'Times New Roman', Times, serif !important;
30
+ }
31
+ </style>
32
  """, unsafe_allow_html=True)
33
 
34
  # Title and description
 
60
  x_axis_label = st.text_input("X-axis Label", x_column)
61
  y_axis_label = st.text_input("Y-axis Label", "Values")
62
 
63
+ # Font size customization
64
+ st.subheader("Font Size Customization")
65
+ title_font_size = st.slider("Title Font Size", 10, 40, 20)
66
+ axis_label_font_size = st.slider("Axis Label Font Size", 8, 30, 14)
67
+ tick_font_size = st.slider("Tick Label Font Size", 8, 24, 10)
68
+ legend_font_size = st.slider("Legend Font Size", 8, 24, 12)
69
+
70
  # Legend position controls
71
  st.subheader("Legend Position Control")
72
  col1, col2 = st.columns(2)
 
75
  with col2:
76
  legend_y = st.slider("Legend Y Position", -0.5, 2.0, 1.0, 0.05)
77
 
78
+ # Define vibrant colors
79
+ default_colors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEEAD',
80
+ '#FF9F1C', '#E71D36', '#2EC4B6', '#011627']
81
+
82
+ # Color customization
83
+ st.subheader("Color Customization")
84
+ use_custom_colors = st.checkbox("Use custom colors for lines")
85
+
86
+ custom_colors = {}
87
+ if use_custom_colors:
88
+ for i, col in enumerate(y_columns):
89
+ default_color = default_colors[i % len(default_colors)]
90
+ custom_colors[col] = st.color_picker(f"Color for {col}", default_color)
91
+
92
  # Legend customization
93
  st.subheader("Customize Legend Names")
94
  legend_names = {}
95
  for col in y_columns:
96
  legend_names[col] = st.text_input(f"Legend name for {col}", col)
97
 
 
 
 
 
98
  # Generate plot
99
  if st.button("Generate Graph"):
100
  # Convert date column to datetime
101
  df[x_column] = pd.to_datetime(df[x_column])
102
 
103
+ # Choose colors based on user selection
104
+ if use_custom_colors:
105
+ colors_to_use = [custom_colors[col] for col in y_columns]
106
+ else:
107
+ colors_to_use = default_colors[:len(y_columns)]
108
+
109
+ # Create figure with selected colors
110
  fig = px.line(df, x=x_column, y=y_columns,
111
+ color_discrete_sequence=colors_to_use)
112
 
113
  # Update legend names and hover template with date and time
114
  for i, trace in enumerate(fig.data):
 
122
  x=0.5,
123
  xanchor='center',
124
  yanchor='top',
125
+ font=dict(family="Times New Roman", color="black", size=title_font_size)
126
  ),
127
  showlegend=True,
128
  legend=dict(
 
134
  bgcolor="white",
135
  bordercolor="Black",
136
  borderwidth=1,
137
+ font=dict(family="Times New Roman", color="black", size=legend_font_size),
138
  title=dict(text="")
139
  ),
140
  hovermode='x unified',
 
150
  mirror=True,
151
  tickangle=-90,
152
  title_text=x_axis_label,
153
+ title_font=dict(family="Times New Roman", color="black", size=axis_label_font_size),
154
+ tickfont=dict(family="Times New Roman", color="black", size=tick_font_size),
155
  type='date',
156
  tickformat='%d-%m-%Y',
157
  dtick='D1',
 
166
  linecolor='black',
167
  mirror=True,
168
  title_text=y_axis_label,
169
+ title_font=dict(family="Times New Roman", color="black", size=axis_label_font_size),
170
+ tickfont=dict(family="Times New Roman", color="black", size=tick_font_size)
171
  ),
172
  margin=dict(l=80, r=150, t=100, b=100),
173
  width=900,
 
212
  - Black text for all elements
213
  - Clean legend display with custom names
214
  - Customizable plot title, axes labels, and legend names
215
+ - Custom color selection for each line
216
+ - Adjustable font sizes for all text elements
217
  - Interactive legend positioning with precise controls
218
  - Interactive plot with hover details
219
  - Download options in HTML format
220
  """
221
  """
222
  ### ๐Ÿ“ For Support And Assistance:
 
223
  Contact:
224
  - Harshitha Gunnam
225
+ gunnamharshitha2@gmail.com
226
  - Varun Ravichander
227
+ varunravichander2007@gmail.com
228
  """)