Skip to content

Commit 8ae410d

Browse files
committed
fixed: advanced statistics graphs working again
1 parent eb164d9 commit 8ae410d

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

views/json/advanced_statistics/entity_view_counter/recent.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

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

7-
$result = [
8-
'options' => advanced_statistics_get_default_chart_options('date'),
9-
];
7+
$result = advanced_statistics_get_default_chart_options('date');
108

119
$qb = Select::fromTable('annotations', 'a');
1210
$qb->select("FROM_UNIXTIME(a.time_created, '%Y-%m-%d') AS date_created");
@@ -22,14 +20,12 @@
2220
if ($query_result) {
2321
foreach ($query_result as $row) {
2422
$data[] = [
25-
$row['date_created'],
26-
(int) $row['total'],
23+
'x' => $row['date_created'],
24+
'y' => (int) $row['total'],
2725
];
2826
}
2927
}
3028

31-
$result['data'] = [$data];
32-
$result['options']['series'] = [['showMarker' => false]];
33-
$result['options']['axes']['yaxis']['tickOptions']['show'] = false;
29+
$result['data']['datasets'][] = ['data' => $data];
3430

3531
echo json_encode($result);

views/json/advanced_statistics/entity_view_counter/views.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

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

7-
$result = [
8-
'options' => advanced_statistics_get_default_chart_options('date'),
9-
];
7+
$result = advanced_statistics_get_default_chart_options('date');
108

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

2725
$data[] = [
28-
date('Y-m-d', strtotime("first monday of january {$year} + {$week} weeks")),
29-
(int) $row['total'],
26+
'x' => date('Y-m-d', strtotime("first monday of january {$year} + {$week} weeks")),
27+
'y' => (int) $row['total'],
3028
];
3129
}
3230
}
3331

34-
$result['data'] = [$data];
32+
$result['data']['datasets'][] = ['data' => $data];
3533

3634
echo json_encode($result);

views/json/advanced_statistics/entity_view_counter/years.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

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

7-
$result = [
8-
'options' => advanced_statistics_get_default_chart_options('bar'),
9-
];
7+
$result = advanced_statistics_get_default_chart_options('bar');
108

119
$qb = Select::fromTable('annotations', 'a');
1210
$qb->select("FROM_UNIXTIME(a.time_created, '%Y') AS year");
@@ -22,14 +20,12 @@
2220
if ($query_result) {
2321
foreach ($query_result as $row) {
2422
$data[] = [
25-
$row['year'],
26-
(int) $row['total'],
23+
'x' => $row['year'],
24+
'y' => (int) $row['total'],
2725
];
2826
}
2927
}
3028

31-
$result['data'] = [$data];
32-
$result['options']['series'] = [['showMarker' => false]];
33-
$result['options']['axes']['yaxis']['tickOptions']['show'] = false;
29+
$result['data']['datasets'][] = ['data' => $data];
3430

3531
echo json_encode($result);

0 commit comments

Comments
 (0)