= _t('admin.stats.main') ?>
= _t('admin.stats.entry_repartition') ?>
| |
= _t('admin.stats.main_stream') ?> |
= _t('admin.stats.all_feeds') ?> |
| = _t('admin.stats.status_total') ?> |
= format_number($this->repartitions['main_stream']['total'] ?? -1) ?> |
= format_number($this->repartitions['all_feeds']['total'] ?? -1) ?> |
| = _t('admin.stats.status_read') ?> |
= format_number($this->repartitions['main_stream']['count_reads'] ?? -1) ?> |
= format_number($this->repartitions['all_feeds']['count_reads'] ?? -1) ?> |
| = _t('admin.stats.status_unread') ?> |
= format_number($this->repartitions['main_stream']['count_unreads'] ?? -1) ?> |
= format_number($this->repartitions['all_feeds']['count_unreads'] ?? -1) ?> |
| = _t('admin.stats.status_favorites') ?> |
= format_number($this->repartitions['main_stream']['count_favorites'] ?? -1) ?> |
= format_number($this->repartitions['all_feeds']['count_favorites'] ?? -1) ?> |
= _t('admin.stats.top_feed') ?>
| = _t('admin.stats.feed') ?> |
= _t('admin.stats.category') ?> |
= _t('admin.stats.entry_count') ?> |
= _t('admin.stats.percent_of_total') ?> |
topFeed as $feed): ?>
| = $feed['name'] ?> |
= $feed['category'] ?> |
= format_number($feed['count']) ?> |
repartitions['all_feeds']['total'])) {
echo format_number($feed['count'] / $this->repartitions['all_feeds']['total'] * 100, 1);
}
?> |
= _t('admin.stats.entry_per_day') ?>
An array of HSL color strings.
*/
function generateColorPalette(int $count): array {
$colors = [];
for ($i = 0; $i < $count; $i++) {
$hue = ($i / $count) * 360; // Distribute colors evenly around the color wheel
$saturation = 70; // Fixed saturation
$lightness = 50; // Fixed lightness
$colors[] = "hsl($hue, {$saturation}%, {$lightness}%)";
}
return $colors;
}
// 1. Get all unique category labels and sort them
$allLabels = array_unique(array_merge($this->feedByCategory['label'], $this->entryByCategory['label']));
sort($allLabels); // Ensure consistent order
// 2. Generate a color palette based on the number of unique categories
$colorPalette = generateColorPalette(count($allLabels));
// 3. Map categories to colors
$colorMap = array_combine($allLabels, $colorPalette);
// 4. Align data and labels for both charts
$feedData = array_fill_keys($allLabels, 0); // Initialize data with all categories
foreach ($this->feedByCategory['label'] as $index => $label) {
$feedData[$label] = $this->feedByCategory['data'][$index];
}
$entryData = array_fill_keys($allLabels, 0); // Initialize data with all categories
foreach ($this->entryByCategory['label'] as $index => $label) {
$entryData[$label] = $this->entryByCategory['data'][$index];
}
// Final data and labels
$feedLabels = array_keys($feedData);
$feedColors = array_map(fn($label) => $colorMap[$label], $feedLabels);
$feedValues = array_values($feedData);
$entryLabels = array_keys($entryData);
$entryColors = array_map(fn($label) => $colorMap[$label], $entryLabels);
$entryValues = array_values($entryData);
?>
= _t('admin.stats.feed_per_category') ?>
+-
= _t('admin.stats.entry_per_category') ?>
+-