Skip to content

Commit

Permalink
fixed: advanced statistics graphs working again
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalsem committed Sep 2, 2024
1 parent eb164d9 commit 8ae410d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
12 changes: 4 additions & 8 deletions views/json/advanced_statistics/entity_view_counter/recent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

$entity = elgg_extract('entity', $vars);

$result = [
'options' => advanced_statistics_get_default_chart_options('date'),
];
$result = advanced_statistics_get_default_chart_options('date');

$qb = Select::fromTable('annotations', 'a');
$qb->select("FROM_UNIXTIME(a.time_created, '%Y-%m-%d') AS date_created");
Expand All @@ -22,14 +20,12 @@
if ($query_result) {
foreach ($query_result as $row) {
$data[] = [
$row['date_created'],
(int) $row['total'],
'x' => $row['date_created'],
'y' => (int) $row['total'],
];
}
}

$result['data'] = [$data];
$result['options']['series'] = [['showMarker' => false]];
$result['options']['axes']['yaxis']['tickOptions']['show'] = false;
$result['data']['datasets'][] = ['data' => $data];

echo json_encode($result);
10 changes: 4 additions & 6 deletions views/json/advanced_statistics/entity_view_counter/views.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

$user = elgg_extract('entity', $vars);

$result = [
'options' => advanced_statistics_get_default_chart_options('date'),
];
$result = advanced_statistics_get_default_chart_options('date');

$qb = Select::fromTable('annotations', 'a');
$qb->select("FROM_UNIXTIME(a.time_created, '%x-%v') AS yearweek");
Expand All @@ -25,12 +23,12 @@
list ($year, $week) = explode('-', $row['yearweek']);

$data[] = [
date('Y-m-d', strtotime("first monday of january {$year} + {$week} weeks")),
(int) $row['total'],
'x' => date('Y-m-d', strtotime("first monday of january {$year} + {$week} weeks")),
'y' => (int) $row['total'],
];
}
}

$result['data'] = [$data];
$result['data']['datasets'][] = ['data' => $data];

echo json_encode($result);
12 changes: 4 additions & 8 deletions views/json/advanced_statistics/entity_view_counter/years.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

$entity = elgg_extract('entity', $vars);

$result = [
'options' => advanced_statistics_get_default_chart_options('bar'),
];
$result = advanced_statistics_get_default_chart_options('bar');

$qb = Select::fromTable('annotations', 'a');
$qb->select("FROM_UNIXTIME(a.time_created, '%Y') AS year");
Expand All @@ -22,14 +20,12 @@
if ($query_result) {
foreach ($query_result as $row) {
$data[] = [
$row['year'],
(int) $row['total'],
'x' => $row['year'],
'y' => (int) $row['total'],
];
}
}

$result['data'] = [$data];
$result['options']['series'] = [['showMarker' => false]];
$result['options']['axes']['yaxis']['tickOptions']['show'] = false;
$result['data']['datasets'][] = ['data' => $data];

echo json_encode($result);

0 comments on commit 8ae410d

Please sign in to comment.