private function fillGapsInMetricsData(bool $tsAscending, array $allTimeUnits, array $originalTimeUnits, array &$metricsData): void
    {
        $zeroArray = array_fill_keys($allTimeUnits, 0);
        foreach ($metricsData as $key => $metric) {
            $metricsData[$key]['values'] = array_combine($originalTimeUnits, $metric['values']);
            $metricsData[$key]['values'] += $zeroArray;
            if ($tsAscending) {
                ksort($metricsData[$key]['values']);
            } else {
                krsort($metricsData[$key]['values']);
            }
            // Keep original numerical indexes.
            $metricsData[$key]['values'] = array_values($metricsData[$key]['values']);
        }
    }