setType("doughnut"); $chart->setTitle("Tests by Cleanliness $date_range_label"); $chart->setLabels(["Very dirty", "Dirty", "Adequate", "Clean", "Very Clean"]); $chart->addDataset("Tests", [ $total_data->cleanlinessCounts[0], $total_data->cleanlinessCounts[1], $total_data->cleanlinessCounts[2], $total_data->cleanlinessCounts[3], $total_data->cleanlinessCounts[4], ], [ "background_colours" => [ "#F44336", "#FFAB91", "#FBC02D", "#FFEB3B", "#4CAF50", ], "datalabels" => Chart::DATALABELS_BOX, ]); $chart->setPrintSuffixes(""); $chart->print = true; $chart->printTotalColumn = true; $chart->printPercentages = true; $charts[] = $chart; // Cleanliness (Each Period) foreach($keys as $index => $key) { $key_label = $key_labels[$index]; $period_data = $data[$key]; if($period_data->testCount == 0) continue; $chart = new Chart; $chart->setType("pie"); $chart->setTitle("$key_label Cleanliness"); $chart->setLabels(["Very dirty", "Dirty", "Adequate", "Clean", "Very Clean"]); $chart->addDataset("Counts", [ $period_data->cleanlinessCounts[0], $period_data->cleanlinessCounts[1], $period_data->cleanlinessCounts[2], $period_data->cleanlinessCounts[3], $period_data->cleanlinessCounts[4], ], [ "background_colours" => [ "#F44336", "#FFAB91", "#FBC02D", "#FFEB3B", "#4CAF50", ], "datalabels" => Chart::DATALABELS_BOX, ]); $charts[] = $chart; } // Tester Gender $chart = new Chart; $chart->setType("pie"); $chart->setTitle("Tester Gender $date_range_label"); $chart->setLabels(["Male", "Female"]); $chart->addDataset("Counts", [ $total_data->maleTesterCount, $total_data->femaleTesterCount, ], [ "background_colours" => [ "#2196F3", "#E91E63", ], "datalabels" => Chart::DATALABELS_BOX, ]); $charts[] = $chart; // Staff Badge Worn $staff_badge_worn_counts = array_column($data, "staffBadgeWornCounts"); $unknown_counts = array_column($staff_badge_worn_counts, 0); $no_counts = array_column($staff_badge_worn_counts, 1); $yes_counts = array_column($staff_badge_worn_counts, 2); $chart = new Chart; $chart->setType("bar"); $chart->setTitle("Staff Badge Worn by $resolution_name"); $chart->setLabels($x_data_labels); $chart->addDataset("Don't know", $unknown_counts, [ "background_colours" => "#CCCCCC" ]); $chart->addDataset("No", $no_counts, [ "background_colours" => "#F44336" ]); $chart->addDataset("Yes", $yes_counts, [ "background_colours" => "#4CAF50" ]); $charts[] = $chart; // Staff Offered Drink $staff_offered_drink_counts = array_column($data, "staffOfferedDrinkCounts"); $no_counts = array_column($staff_offered_drink_counts, 0); $yes_counts = array_column($staff_offered_drink_counts, 1); $chart = new Chart; $chart->setType("bar"); $chart->setTitle("Staff Offered Drink by $resolution_name"); $chart->setLabels($x_data_labels); $chart->addDataset("No", $no_counts, [ "background_colours" => "#F44336" ]); $chart->addDataset("Yes", $yes_counts, [ "background_colours" => "#4CAF50" ]); $charts[] = $chart; // Staff Offered Promotion $staff_offered_promotion_counts = array_column($data, "staffOfferedPromotionCounts"); $no_counts = array_column($staff_offered_promotion_counts, 0); $yes_counts = array_column($staff_offered_promotion_counts, 1); $chart = new Chart; $chart->setType("bar"); $chart->setTitle("Staff Offered Promotion by $resolution_name"); $chart->setLabels($x_data_labels); $chart->addDataset("No", $no_counts, [ "background_colours" => "#F44336" ]); $chart->addDataset("Yes", $yes_counts, [ "background_colours" => "#4CAF50" ]); $charts[] = $chart; // Staff Offered Help $staff_offered_help_counts = array_column($data, "staffOfferedHelpCounts"); $no_counts = array_column($staff_offered_help_counts, 0); $yes_counts = array_column($staff_offered_help_counts, 1); $chart = new Chart; $chart->setType("bar"); $chart->setTitle("Staff Offered Help by $resolution_name"); $chart->setLabels($x_data_labels); $chart->addDataset("No", $no_counts, [ "background_colours" => "#F44336" ]); $chart->addDataset("Yes", $yes_counts, [ "background_colours" => "#4CAF50" ]); $charts[] = $chart; // Staff Behaviour (Each Period) foreach($keys as $index => $key) { $key_label = $key_labels[$index]; $period_data = $data[$key]; if($period_data->testCount == 0) continue; $chart = new Chart; $chart->setType("pie"); $chart->setTitle("$key_label Staff Behaviour"); $chart->setLabels(["N/A", "Rude", "Slightly rude", "Neither rude or polite", "Polite", "Very polite"]); $chart->addDataset("Counts", [ $period_data->staffBehaviourCounts[0], $period_data->staffBehaviourCounts[1], $period_data->staffBehaviourCounts[2], $period_data->staffBehaviourCounts[3], $period_data->staffBehaviourCounts[4], $period_data->staffBehaviourCounts[5], ], [ "background_colours" => [ "#CCCCCC", "#F44336", "#FFAB91", "#FBC02D", "#FFEB3B", "#4CAF50", ], "datalabels" => Chart::DATALABELS_BOX, ]); $charts[] = $chart; } // Staff Uniform $staff_uniform_counts = array_column($data, "staffUniformCounts"); $no_counts = array_column($staff_uniform_counts, 0); $yes_counts = array_column($staff_uniform_counts, 1); $chart = new Chart; $chart->setType("bar"); $chart->setTitle("Staff Uniform by $resolution_name"); $chart->setLabels($x_data_labels); $chart->addDataset("No", $no_counts, [ "background_colours" => "#F44336" ]); $chart->addDataset("Yes", $yes_counts, [ "background_colours" => "#4CAF50" ]); $charts[] = $chart; // Tester Genders by Period $male_counts = array_values(array_map(function($d) { return $d->maleTesterCount; }, $data)); $female_counts = array_values(array_map(function($d) { return $d->femaleTesterCount; }, $data)); $chart = new Chart; $chart->addYAxis([ "id" => "y-axis-1", "tick_config" => ["min" => 0, "max" => ceil(max(max($male_counts), max($female_counts)) / 10) * 10] ]); $chart->setType("bar"); $chart->setTitle("Tester Gender by $resolution_name"); $chart->setLabels($x_data_labels); $chart->addDataset("Male", $male_counts, [ "background_colours" => "#2196F3" ]); $chart->addDataset("Female", $female_counts, [ "background_colours" => "#E91E63" ]); $charts[] = $chart; // Test Count by Period $test_counts = array_values(array_map(function($d) { return $d->testCount; }, $data)); $chart = new Chart; $chart->addYAxis([ "id" => "y-axis-1", "tick_config" => ["min" => 0, "max" => ceil(max($test_counts) / 10) * 10] ]); $chart->setType("bar"); $chart->setTitle("Tests by $resolution_name"); $chart->setLabels($x_data_labels); $chart->addDataset("Tests", $test_counts, [ "background_colours" => "#2196F3" ]); $charts[] = $chart; ?>