Commit 346c57e4 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1472889: Adjustments to some of the stats graphs



1) Allowing the labels for the institutions graph be on mouseover

2) Restrict the number of items on graph to be 12 instead of 25

3) Allowing the weekly stats be line graphs

4) Allowing the template to override the colours for stored graph jsondata

Change-Id: Ie0b157fa1493755383b5207bc77e7b35ba140c7a
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent eb205d6d
......@@ -47,6 +47,21 @@ if (!defined('CRON')) {
if (!empty($data['jsondata'])) {
$jsondata = json_decode($data['jsondata']);
if (!empty($colours)) {
// Update the stored graph jsondata with colours passed in via .tpl file
// This allows us to display the graph in the theme's colours rather than
// default colours the graph jsondata was saved in.
$colours = get_graph_colours($data, $colours);
$x = 0;
foreach ($jsondata[0] as $key => $option) {
foreach ($option as $optkey => $optval) {
if (preg_match('/^rgba\(/', $optval)) {
$jsondata[0][$key]->$optkey = preg_replace('/\((.*\,)/', '(' . $colours[$x] . ',', $optval);
}
}
$x = empty($colours[$x+1]) ? 0 : $x + 1;
}
}
$data['datastr'] = json_encode($jsondata[0]);
$data['configstr'] = json_encode($data['configs']);
json_reply(false, array('data' => $data));
......
......@@ -955,7 +955,7 @@ function user_institution_graph($type = null) {
}
arsort($dataarray);
// Truncate to avoid trying to fit too many results onto graph
$dataarray = array_slice($dataarray, 0, 25, true);
$dataarray = array_slice($dataarray, 0, 12, true);
$data['graph'] = ($type) ? $type : 'bar';
$data['graph_function_name'] = 'user_institution_graph';
......
......@@ -4,7 +4,7 @@
<script type="application/javascript">
{literal}
jQuery(function() {
fetch_graph_data({'id':'sitestatsgraph','type':'bar','graph':'graph_site_data_weekly'});
fetch_graph_data({'id':'sitestatsgraph','type':'line','graph':'graph_site_data_weekly'});
});
{/literal}
</script>
......@@ -12,7 +12,7 @@
{/if}
<table class="table">
<tr>
<th>{str tag=siteinstalled section=admin}</th>
<th>{str tag=siteinstalled section=admin}</th>
<td>{$sitedata.installdate}</td>
</tr>
......@@ -23,11 +23,11 @@
{$sitedata.users}
<small>{str tag=activeusers section=admin}: {$sitedata.usersloggedin}</small>
</td>
</tr>
</tr>
{/if}
{if $sitedata.groups}
<tr>
<th>{str tag=groups}</th>
<th>{str tag=groups}</th>
<td>{$sitedata.groups}
<small>{$sitedata.strgroupmemberaverage}</small>
</td>
......@@ -35,7 +35,7 @@
{/if}
{if $sitedata.views}
<tr>
<th>{str tag=Views section=view}</th>
<th>{str tag=Views section=view}</th>
<td>
{$sitedata.views}
<small>{$sitedata.strviewsperuser}</small>
......
......@@ -4,7 +4,7 @@
<script type="application/javascript">
{literal}
jQuery(function() {
fetch_graph_data({'id':'sitestatsgraph','type':'bar','graph':'graph_institution_data_weekly',
fetch_graph_data({'id':'sitestatsgraph','type':'line','graph':'graph_institution_data_weekly',
'extradata': {'institution': '{/literal}{$institutiondata.institution}{literal}'}
});
});
......
......@@ -11,7 +11,15 @@
<script type="application/javascript">
{literal}
jQuery(function() {
fetch_graph_data({'id':'sitestatsusersgraph','type':'bar','graph':'user_institution_graph'});
fetch_graph_data({'id':'sitestatsusersgraph',
'type':'bar',
'graph':'user_institution_graph',
'extradata': {
'configs': {
'multiTooltipTemplate': "<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>"
}
}
});
});
{/literal}
</script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment