| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <?php
- // Tests by Cleanliness
- $chart = new Chart;
- $chart->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->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;
- ?>
|