Skip to content

Commit 06eb25d

Browse files
committed
got data from multiple filters to show in the community profile plots
1 parent 1b2f718 commit 06eb25d

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

survey_dashboard/main.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,20 @@ def select_data(question, data_filters, data_filters_method, filter_by=FILTER_BY
280280
df, q_index_clean, display_dict=HCS_MCsubquestions_flattened
281281
)
282282

283-
print('data_all', data_all)
284-
# Handle "All" filter differently - when "All" is selected, show aggregated data
285-
if "All" in data_filters:
286-
# Restructure data_all to match expected plotting format
283+
# Handle data filtering based on what's selected
284+
if "All" in data_filters and len(data_filters) == 1:
285+
# Only "All" is selected - use the aggregated data from all research areas
287286
if len(q_index_clean) == 1:
288287
key = q_index_clean[0]
289288
data = {
290289
"All": data_all["All"],
291290
key: data_all.get(key, []),
292291
"x_value": data_all.get(key, []) # Add missing x_value column
293292
}
293+
else:
294+
# Multiple columns case
295+
data = data_all
296+
y_keys = ["All"] + [data_all.get(q_index_clean[0], [])]
294297
else:
295298
# Specific research areas are selected - filter the data
296299
exclude = []
@@ -300,9 +303,25 @@ def select_data(question, data_filters, data_filters_method, filter_by=FILTER_BY
300303
for filter_key in exclude:
301304
df = df[df[filter_by] != filter_key]
302305
data, y_keys = prepare_data_research_field(df, q_index) # this add also Cum. Sum.
303-
# Add "All" data if it's also selected
306+
print('data before adding All:', data)
307+
print('data_all keys:', list(data_all.keys()))
308+
print('data_all["All"] length:', len(data_all.get("All", [])))
309+
310+
# Add "All" data if it's selected in the filters
304311
if "All" in data_filters:
305-
data["All"] = data_all["All"]
312+
all_data = data_all.get("All", [])
313+
print('Adding All data, length:', len(all_data), 'x_value length:', len(data["x_value"]))
314+
315+
# Simple approach: truncate "All" data to match x_value length
316+
if len(all_data) > len(data["x_value"]):
317+
data["All"] = all_data[:len(data["x_value"])]
318+
print('All data truncated to match x_value length')
319+
else:
320+
# If "All" data is shorter, just use what we have
321+
data["All"] = all_data
322+
print('All data added (shorter than x_value)')
323+
324+
print('data after adding All:', data)
306325

307326
# print(data)
308327
# We create two ColumnDataSources, because they have to be n*n and

0 commit comments

Comments
 (0)