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

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

parents f554abdd 346c57e4
...@@ -47,6 +47,21 @@ if (!defined('CRON')) { ...@@ -47,6 +47,21 @@ if (!defined('CRON')) {
if (!empty($data['jsondata'])) { if (!empty($data['jsondata'])) {
$jsondata = json_decode($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['datastr'] = json_encode($jsondata[0]);
$data['configstr'] = json_encode($data['configs']); $data['configstr'] = json_encode($data['configs']);
json_reply(false, array('data' => $data)); json_reply(false, array('data' => $data));
......
...@@ -956,7 +956,7 @@ function user_institution_graph($type = null) { ...@@ -956,7 +956,7 @@ function user_institution_graph($type = null) {
} }
arsort($dataarray); arsort($dataarray);
// Truncate to avoid trying to fit too many results onto graph // 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'] = ($type) ? $type : 'bar';
$data['graph_function_name'] = 'user_institution_graph'; $data['graph_function_name'] = 'user_institution_graph';
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<script type="application/javascript"> <script type="application/javascript">
{literal} {literal}
jQuery(function() { 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} {/literal}
</script> </script>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<script type="application/javascript"> <script type="application/javascript">
{literal} {literal}
jQuery(function() { 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}'} 'extradata': {'institution': '{/literal}{$institutiondata.institution}{literal}'}
}); });
}); });
......
...@@ -11,7 +11,15 @@ ...@@ -11,7 +11,15 @@
<script type="application/javascript"> <script type="application/javascript">
{literal} {literal}
jQuery(function() { 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} {/literal}
</script> </script>
......
Supports Markdown
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