+function make_table_team_wide(players) {
+ let globals = players['globals'];
+
+ let rows = [];
+ {
+ let header = document.createElement('tr');
+ add_th(header, '');
+ add_th(header, 'Our team', 6);
+ add_th(header, 'Opponents', 6);
+ rows.push(header);
+ }
+
+ // Turnovers.
+ {
+ let row = document.createElement('tr');
+ let name = add_3cell(row, 'Turnovers generated', 'name');
+ add_3cell(row, globals.turnovers_won);
+ add_3cell(row, '');
+ add_3cell(row, globals.turnovers_lost);
+ add_3cell(row, '');
+ rows.push(row);
+ }
+
+ // Clean holds.
+ {
+ let row = document.createElement('tr');
+ let name = add_3cell(row, 'Clean holds', 'name');
+ let our_clean_holds = make_binomial_ci(globals.clean_holds, globals.offensive_points_completed, z);
+ let their_clean_holds = make_binomial_ci(globals.their_clean_holds, globals.defensive_points_completed, z);
+ our_clean_holds.desired = 0.3; // Arbitrary.
+ our_clean_holds.format = 'percentage';
+ their_clean_holds.desired = 0.3;
+ their_clean_holds.format = 'percentage';
+ add_3cell(row, globals.clean_holds + ' / ' + globals.offensive_points_completed);
+ add_3cell_ci(row, our_clean_holds);
+ add_3cell(row, globals.their_clean_holds + ' / ' + globals.defensive_points_completed);
+ add_3cell_ci(row, their_clean_holds);
+ rows.push(row);
+ }
+
+ // Clean breaks.
+ {
+ let row = document.createElement('tr');
+ let name = add_3cell(row, 'Clean breaks', 'name');
+ let our_clean_breaks = make_binomial_ci(globals.clean_breaks, globals.defensive_points_completed, z);
+ let their_clean_breaks = make_binomial_ci(globals.their_clean_breaks, globals.offensive_points_completed, z);
+ our_clean_breaks.desired = 0.3; // Arbitrary.
+ our_clean_breaks.format = 'percentage';
+ their_clean_breaks.desired = 0.3;
+ their_clean_breaks.format = 'percentage';
+ add_3cell(row, globals.clean_breaks + ' / ' + globals.defensive_points_completed);
+ add_3cell_ci(row, our_clean_breaks);
+ add_3cell(row, globals.their_clean_breaks + ' / ' + globals.offensive_points_completed);
+ add_3cell_ci(row, their_clean_breaks);
+ rows.push(row);
+ }
+
+ // Touches. We only have information for our team here.
+ {
+ let goals = 0;
+ for (const [q,p] of get_sorted_players(players)) {
+ if (q === 'globals') continue;
+ goals += p.goals;
+ }
+
+ let row = document.createElement('tr');
+ let name = add_3cell(row, 'Touches per possession (all)', 'name');
+ let touches = globals.touches_for_turnover + globals.touches_for_goal;
+ let possessions = goals + globals.turnovers_lost;
+ add_3cell(row, '');
+ add_3cell_ci(row, make_poisson_ci_large(touches, possessions, z));
+ add_3cell(row, '');
+ add_3cell(row, '');
+ rows.push(row);
+
+ row = document.createElement('tr');
+ add_3cell(row, 'Touches per possession (goals)', 'name');
+ add_3cell(row, '');
+ add_3cell_ci(row, make_poisson_ci_large(globals.touches_for_goal, goals, z));
+ add_3cell(row, '');
+ add_3cell(row, '');
+ rows.push(row);
+
+ row = document.createElement('tr');
+ add_3cell(row, 'Touches per possession (turnovers)', 'name');
+ add_3cell(row, '');
+ add_3cell_ci(row, make_poisson_ci_large(globals.touches_for_turnover, globals.turnovers_lost, z));
+ add_3cell(row, '');
+ add_3cell(row, '');
+ rows.push(row);
+ }
+
+ return rows;
+}
+