Commit a7116259 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1472889: Adjustments to some of the stats graphs"

parents f554abdd 346c57e4
......@@ -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));
......
......@@ -956,7 +956,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>
......
......@@ -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