// dashboard improvements

This commit is contained in:
Damien Metzger
2013-10-24 15:04:06 +02:00
parent a9f75a02a7
commit 6a2e847970
5 changed files with 64 additions and 49 deletions
+5 -4
View File
@@ -243,16 +243,17 @@ class Dashtrends extends Module
if (!$count = count($this->dashboard_data[$chart_key]))
continue;
// We calibrate 100% to the mean
$calibration = array_sum($this->dashboard_data[$chart_key]) / $count;
foreach ($this->dashboard_data[$chart_key] as $key => $value)
$chart_data[$chart_key][] = array(1000 * $key, $calibration ? 100 * $value / $calibration : 0);
// min(10) is there to limit the growth to 1000%, beyond this limit it becomes unreadable
$chart_data[$chart_key][] = array(1000 * $key, $calibration ? min(10, $value / $calibration) : 0);
if ($this->dashboard_data_compare)
{
foreach ($this->dashboard_data_compare[$chart_key] as $key => $value)
$chart_data_compare[$chart_key][] = array(1000 * $key, $calibration ? 100 * $value / $calibration : 0);
}
// min(10) is there to limit the growth to 1000%, beyond this limit it becomes unreadable
$chart_data_compare[$chart_key][] = array(1000 * $key, $calibration ? min(10, $value / $calibration) : 0);
}
$charts = array(
+7 -10
View File
@@ -5,18 +5,15 @@ function line_chart_trends(widget_name, chart_details)
{
nv.addGraph(function() {
var chart = nv.models.lineChart()
.useInteractiveGuideline(true)
.x(function(d) { return d[0] })
.y(function(d) { return d[1]/100 })
.color(d3.scale.category10().range());
.useInteractiveGuideline(true)
.x(function(d) { return (d !== undefined ? d[0] : 0); })
.y(function(d) { return (d !== undefined ? d[1] : 0); })
chart.xAxis
.tickFormat(function(d) {
return d3.time.format('%m/%d/%y')(new Date(d))
});
chart.xAxis.tickFormat(function(d) {
return d3.time.format('%m/%d/%y')(new Date(d))
});
chart.yAxis
.tickFormat(d3.format(',.1%'));
chart.yAxis.tickFormat(d3.format('%'));
dashtrends_data = chart_details.data;
dashtrends_chart = chart;