Commit 8ae410d 1 parent eb164d9 commit 8ae410d Copy full SHA for 8ae410d
File tree 3 files changed +12
-22
lines changed
views/json/advanced_statistics/entity_view_counter
3 files changed +12
-22
lines changed Original file line number Diff line number Diff line change 4
4
5
5
$ entity = elgg_extract ('entity ' , $ vars );
6
6
7
- $ result = [
8
- 'options ' => advanced_statistics_get_default_chart_options ('date ' ),
9
- ];
7
+ $ result = advanced_statistics_get_default_chart_options ('date ' );
10
8
11
9
$ qb = Select::fromTable ('annotations ' , 'a ' );
12
10
$ qb ->select ("FROM_UNIXTIME(a.time_created, '%Y-%m-%d') AS date_created " );
22
20
if ($ query_result ) {
23
21
foreach ($ query_result as $ row ) {
24
22
$ data [] = [
25
- $ row ['date_created ' ],
26
- (int ) $ row ['total ' ],
23
+ ' x ' => $ row ['date_created ' ],
24
+ ' y ' => (int ) $ row ['total ' ],
27
25
];
28
26
}
29
27
}
30
28
31
- $ result ['data ' ] = [$ data ];
32
- $ result ['options ' ]['series ' ] = [['showMarker ' => false ]];
33
- $ result ['options ' ]['axes ' ]['yaxis ' ]['tickOptions ' ]['show ' ] = false ;
29
+ $ result ['data ' ]['datasets ' ][] = ['data ' => $ data ];
34
30
35
31
echo json_encode ($ result );
Original file line number Diff line number Diff line change 4
4
5
5
$ user = elgg_extract ('entity ' , $ vars );
6
6
7
- $ result = [
8
- 'options ' => advanced_statistics_get_default_chart_options ('date ' ),
9
- ];
7
+ $ result = advanced_statistics_get_default_chart_options ('date ' );
10
8
11
9
$ qb = Select::fromTable ('annotations ' , 'a ' );
12
10
$ qb ->select ("FROM_UNIXTIME(a.time_created, '%x-%v') AS yearweek " );
25
23
list ($ year , $ week ) = explode ('- ' , $ row ['yearweek ' ]);
26
24
27
25
$ 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 ' ],
30
28
];
31
29
}
32
30
}
33
31
34
- $ result ['data ' ] = [$ data ];
32
+ $ result ['data ' ][ ' datasets ' ][] = [' data ' => $ data ];
35
33
36
34
echo json_encode ($ result );
Original file line number Diff line number Diff line change 4
4
5
5
$ entity = elgg_extract ('entity ' , $ vars );
6
6
7
- $ result = [
8
- 'options ' => advanced_statistics_get_default_chart_options ('bar ' ),
9
- ];
7
+ $ result = advanced_statistics_get_default_chart_options ('bar ' );
10
8
11
9
$ qb = Select::fromTable ('annotations ' , 'a ' );
12
10
$ qb ->select ("FROM_UNIXTIME(a.time_created, '%Y') AS year " );
22
20
if ($ query_result ) {
23
21
foreach ($ query_result as $ row ) {
24
22
$ data [] = [
25
- $ row ['year ' ],
26
- (int ) $ row ['total ' ],
23
+ ' x ' => $ row ['year ' ],
24
+ ' y ' => (int ) $ row ['total ' ],
27
25
];
28
26
}
29
27
}
30
28
31
- $ result ['data ' ] = [$ data ];
32
- $ result ['options ' ]['series ' ] = [['showMarker ' => false ]];
33
- $ result ['options ' ]['axes ' ]['yaxis ' ]['tickOptions ' ]['show ' ] = false ;
29
+ $ result ['data ' ]['datasets ' ][] = ['data ' => $ data ];
34
30
35
31
echo json_encode ($ result );
You can’t perform that action at this time.
0 commit comments