M17idd commited on
Commit
ad18196
·
verified ·
1 Parent(s): 16f58d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -33
app.py CHANGED
@@ -74,35 +74,21 @@ with ui.layout_columns(col_widths=[6, 6, 12]):
74
  ui.card_header("Tips data")
75
 
76
  @render.data_frame
77
- def table():
78
- return render.DataGrid(tips_data())
79
-
80
- with ui.card(full_screen=True):
81
- with ui.card_header(class_="d-flex justify-content-between align-items-center"):
82
- "Total bill vs tip"
83
- with ui.popover(title="Add a color variable", placement="top"):
84
- ICONS["ellipsis"]
85
- ui.input_radio_buttons(
86
- "scatter_color",
87
- None,
88
- ["none", "جنسیت", "تأثیر", "سطح ", "موضوع"],
89
- inline=True,
90
- )
91
-
92
- @render_plotly
93
- def scatterplot():
94
- color = input.scatter_color()
95
- data = tips_data()
96
- if data.shape[0] == 0:
97
- return {} # return empty plot if no data available
98
- return px.scatter(
99
- data,
100
- x="سن",
101
- y="id",
102
- color=None if color == "none" else color,
103
- trendline="lowess",
104
- )
105
-
106
  with ui.card(full_screen=True):
107
  with ui.card_header(class_="d-flex justify-content-between align-items-center"):
108
  "Tip percentages"
@@ -156,10 +142,12 @@ ui.include_css(app_dir / "styles.css")
156
 
157
  @reactive.calc
158
  def tips_data():
159
- سنی = input.سن()
160
- idx1 = tips.سن.between(سنی[0], سنی[1]) # Corrected range filter
161
- idx2 = tips.تاریخ.isin(input.time()) # Filter based on selected time (Twitter, Instagram)
162
- return tips[idx1 & idx2] # Apply filters to the tips data
 
 
163
 
164
  @reactive.effect
165
  @reactive.event(input.reset)
 
74
  ui.card_header("Tips data")
75
 
76
  @render.data_frame
77
+ def table():
78
+ return tips_data() # جدول با داده‌های فیلتر شده
79
+
80
+ @render_plotly
81
+ def scatterplot():
82
+ data = tips_data() # داده‌های فیلتر شده برای نمودار
83
+ if data.shape[0] == 0:
84
+ return {} # اگر هیچ داده‌ای نیست، نمودار خالی برگردانده می‌شود
85
+ return px.scatter(
86
+ data,
87
+ x="سن", # استفاده از ستون "سن"
88
+ y="id", # استفاده از ستون "id"
89
+ color=None if input.scatter_color() == "none" else input.scatter_color(), # رنگ بر اساس انتخاب
90
+ trendline="lowess", # اضافه کردن trendline به نمودار
91
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  with ui.card(full_screen=True):
93
  with ui.card_header(class_="d-flex justify-content-between align-items-center"):
94
  "Tip percentages"
 
142
 
143
  @reactive.calc
144
  def tips_data():
145
+ سنی = input.سن() # رنج سنی
146
+ idx1 = tips["سن"].between(سنی[0], سنی[1]) # فیلتر کردن بر اساس سن
147
+ idx2 = tips["تاریخ"].isin(input.time()) # فیلتر کردن بر اساس تاریخ (خدمات)
148
+ filtered_data = tips[idx1 & idx2] # داده‌های فیلتر شده
149
+ print(filtered_data) # برای دیباگ کردن و اطمینان از فیلتر درست
150
+ return filtered_dat
151
 
152
  @reactive.effect
153
  @reactive.event(input.reset)