// dashboard improvements
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user