diff --git a/api/api_v1/endpoints/query.py b/api/api_v1/endpoints/query.py index b56e58f..8e3cb7d 100644 --- a/api/api_v1/endpoints/query.py +++ b/api/api_v1/endpoints/query.py @@ -720,6 +720,10 @@ async def scatter_model( analysis = res['analysis'] groupby = res['groupby'] quota_interval_arr = res['quota_interval_arr'] + # 兼容合计的 + if res['time_particle'] == 'total': + df['date'] = '合计' + if analysis != 'number_of_days' and interval_type != 'discrete': max_v = int(df['values'].max()) min_v = int(df['values'].min()) @@ -740,9 +744,7 @@ async def scatter_model( for i, v in enumerate(quota_interval_arr[1:]): resp['label'].append(f'[{quota_interval_arr[i]},{v})') bins.append(v) - # 合计的 - if res['time_particle'] == 'total': - df['date'] = '合计' + # 这是整体的 for key, tmp_df in df.groupby('date'): @@ -783,12 +785,14 @@ async def scatter_model( 'end_date': res['end_date'], 'time_particle': res['time_particle'] } - total_dict = {} labels = [str(i) for i in sorted(df['values'].unique())] resp['label'] = labels for key, tmp_df in df.groupby(['date']): total = len(tmp_df) - dt = key.strftime('%Y-%m-%d') + if res['time_particle'] == 'total': + dt='合计' + else: + dt = key.strftime('%Y-%m-%d') labels_dict = {} for key2, tmp_df2 in tmp_df.groupby('values'): label = str(key2)