@@ -372,14 +372,23 @@ def _extract_advanced(df: pd.DataFrame) -> List[Dict[str, Any]]:
372372 weekly = weekly .reindex (weekly .sum ().sort_values (ascending = False ).index , axis = 1 )
373373 if not weekly .empty :
374374 weeks = [d .strftime ("%Y-%m-%d" ) for d in weekly .index ]
375- series = [{"name" : c , "data" : weekly [c ].tolist ()} for c in weekly .columns ]
375+ mapping = load_team_mapping ()
376+ series = [
377+ {
378+ "name" : c ,
379+ "data" : weekly [c ].tolist (),
380+ "team" : mapping .get (c , "" ),
381+ }
382+ for c in weekly .columns
383+ ]
376384 charts .append ({
377385 "id" : "21" ,
378386 "type" : "multiLine" ,
379387 "title" : "Developer Velocity by Week" ,
380388 "subtitle" : "Complexity per developer per week" ,
381389 "x" : weeks ,
382390 "series" : series ,
391+ "hasPicker" : True ,
383392 })
384393
385394 # 15: Complexity trend by team (multi-line)
@@ -405,18 +414,20 @@ def _extract_advanced(df: pd.DataFrame) -> List[Dict[str, Any]]:
405414 "series" : series_list ,
406415 })
407416
408- # 16: Cumulative complexity (area/line)
409- df_sorted = df .sort_values ("date" )
410- df_sorted ["cumulative" ] = df_sorted ["complexity" ].cumsum ()
411- if not df_sorted ["cumulative" ].empty :
412- dates = pd .to_datetime (df_sorted ["date" ]).dt .strftime ("%Y-%m-%d" ).tolist ()
417+ # 16: Cumulative complexity by week (area/line)
418+ df_cum = df .copy ()
419+ df_cum ["week" ] = pd .to_datetime (df_cum ["date" ]).dt .to_period ("W" ).dt .start_time
420+ weekly_sum = df_cum .groupby ("week" )["complexity" ].sum ().sort_index ()
421+ cumulative = weekly_sum .cumsum ()
422+ if not cumulative .empty :
423+ weeks = [d .strftime ("%Y-%m-%d" ) for d in cumulative .index ]
413424 charts .append ({
414425 "id" : "16" ,
415426 "type" : "area" ,
416427 "title" : "Cumulative Velocity Over Time" ,
417- "subtitle" : "Running total of complexity" ,
418- "x" : dates ,
419- "y" : df_sorted [ " cumulative" ] .tolist (),
428+ "subtitle" : "Running total of complexity (by week) " ,
429+ "x" : weeks ,
430+ "y" : cumulative .tolist (),
420431 })
421432
422433 return charts
0 commit comments