Skip to content

Commit 85189c8

Browse files
committed
fixed y-scale cut off issues, scales are adjusted as per max value
1 parent 7ad5511 commit 85189c8

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

survey_dashboard/plots.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,17 @@ def bokeh_barchart(df, x='x_value', y=['y_value'], factors=None, figure=None, da
206206
# x_range = source.data[x]
207207
# Handle None ranges to prevent Bokeh validation error
208208
if y_range is None:
209-
y_range = (0, 10) # Default range
209+
# Automatically calculate y_range based on data
210+
max_values = []
211+
for y_key in y_keys:
212+
if y_key in source.data:
213+
max_values.extend(source.data[y_key])
214+
if max_values:
215+
y_max = max(max_values)
216+
# Add 10% padding to the top
217+
y_range = (0, y_max * 1.1)
218+
else:
219+
y_range = (0, 10) # Fallback default range
210220
if x_range is None:
211221
x_range = ['Category 1', 'Category 2', 'Category 3'] # Default categories
212222
fig = bokeh_figure(x_range=x_range, y_range=y_range, title=title, #y_range=(0, 280),

0 commit comments

Comments
 (0)