summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-21 21:12:24 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-21 21:12:24 -0400
commit81e40e2c910f0be3f6031445a4d2c1714cdeb385 (patch)
treed571857cff71af4e351327edc70e971758259239 /app
parent1465ca1ae1510cd399b8f408ce7bf8058ed26955 (diff)
Replace dimplejs by c3js for chart drawing
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Analytic.php122
-rw-r--r--app/Locale/da_DK/translations.php3
-rw-r--r--app/Locale/de_DE/translations.php3
-rw-r--r--app/Locale/es_ES/translations.php3
-rw-r--r--app/Locale/fi_FI/translations.php3
-rw-r--r--app/Locale/fr_FR/translations.php3
-rw-r--r--app/Locale/hu_HU/translations.php3
-rw-r--r--app/Locale/it_IT/translations.php3
-rw-r--r--app/Locale/ja_JP/translations.php3
-rw-r--r--app/Locale/nl_NL/translations.php3
-rw-r--r--app/Locale/pl_PL/translations.php3
-rw-r--r--app/Locale/pt_BR/translations.php3
-rw-r--r--app/Locale/ru_RU/translations.php3
-rw-r--r--app/Locale/sr_Latn_RS/translations.php3
-rw-r--r--app/Locale/sv_SE/translations.php3
-rw-r--r--app/Locale/th_TH/translations.php3
-rw-r--r--app/Locale/tr_TR/translations.php3
-rw-r--r--app/Locale/zh_CN/translations.php3
-rw-r--r--app/Model/ProjectDailySummary.php5
-rw-r--r--app/Template/analytic/burndown.php2
-rw-r--r--app/Template/analytic/cfd.php4
-rw-r--r--app/Template/analytic/layout.php4
-rw-r--r--app/Template/analytic/tasks.php2
-rw-r--r--app/Template/analytic/users.php2
-rw-r--r--app/Template/budget/index.php7
25 files changed, 105 insertions, 94 deletions
diff --git a/app/Controller/Analytic.php b/app/Controller/Analytic.php
index f31870e0..41fe7169 100644
--- a/app/Controller/Analytic.php
+++ b/app/Controller/Analytic.php
@@ -34,24 +34,12 @@ class Analytic extends Base
public function tasks()
{
$project = $this->getProject();
- $metrics = $this->projectAnalytic->getTaskRepartition($project['id']);
-
- if ($this->request->isAjax()) {
- $this->response->json(array(
- 'metrics' => $metrics,
- 'labels' => array(
- 'column_title' => t('Column'),
- 'nb_tasks' => t('Number of tasks'),
- )
- ));
- }
- else {
- $this->response->html($this->layout('analytic/tasks', array(
- 'project' => $project,
- 'metrics' => $metrics,
- 'title' => t('Task repartition for "%s"', $project['name']),
- )));
- }
+
+ $this->response->html($this->layout('analytic/tasks', array(
+ 'project' => $project,
+ 'metrics' => $this->projectAnalytic->getTaskRepartition($project['id']),
+ 'title' => t('Task repartition for "%s"', $project['name']),
+ )));
}
/**
@@ -62,24 +50,12 @@ class Analytic extends Base
public function users()
{
$project = $this->getProject();
- $metrics = $this->projectAnalytic->getUserRepartition($project['id']);
-
- if ($this->request->isAjax()) {
- $this->response->json(array(
- 'metrics' => $metrics,
- 'labels' => array(
- 'user' => t('User'),
- 'nb_tasks' => t('Number of tasks'),
- )
- ));
- }
- else {
- $this->response->html($this->layout('analytic/users', array(
- 'project' => $project,
- 'metrics' => $metrics,
- 'title' => t('User repartition for "%s"', $project['name']),
- )));
- }
+
+ $this->response->html($this->layout('analytic/users', array(
+ 'project' => $project,
+ 'metrics' => $this->projectAnalytic->getUserRepartition($project['id']),
+ 'title' => t('User repartition for "%s"', $project['name']),
+ )));
}
/**
@@ -100,30 +76,20 @@ class Analytic extends Base
$to = $values['to'];
}
- if ($this->request->isAjax()) {
- $this->response->json(array(
- 'columns' => array_values($this->board->getColumnsList($project['id'])),
- 'metrics' => $this->projectDailySummary->getRawMetrics($project['id'], $from, $to),
- 'labels' => array(
- 'column' => t('Column'),
- 'day' => t('Date'),
- 'total' => t('Tasks'),
- )
- ));
- }
- else {
- $this->response->html($this->layout('analytic/cfd', array(
- 'values' => array(
- 'from' => $from,
- 'to' => $to,
- ),
- 'display_graph' => $this->projectDailySummary->countDays($project['id'], $from, $to) >= 2,
- 'project' => $project,
- 'date_format' => $this->config->get('application_date_format'),
- 'date_formats' => $this->dateParser->getAvailableFormats(),
- 'title' => t('Cumulative flow diagram for "%s"', $project['name']),
- )));
- }
+ $display_graph = $this->projectDailySummary->countDays($project['id'], $from, $to) >= 2;
+
+ $this->response->html($this->layout('analytic/cfd', array(
+ 'values' => array(
+ 'from' => $from,
+ 'to' => $to,
+ ),
+ 'display_graph' => $display_graph,
+ 'metrics' => $display_graph ? $this->projectDailySummary->getAggregatedMetrics($project['id'], $from, $to) : array(),
+ 'project' => $project,
+ 'date_format' => $this->config->get('application_date_format'),
+ 'date_formats' => $this->dateParser->getAvailableFormats(),
+ 'title' => t('Cumulative flow diagram for "%s"', $project['name']),
+ )));
}
/**
@@ -144,27 +110,19 @@ class Analytic extends Base
$to = $values['to'];
}
- if ($this->request->isAjax()) {
- $this->response->json(array(
- 'metrics' => $this->projectDailySummary->getRawMetricsByDay($project['id'], $from, $to),
- 'labels' => array(
- 'day' => t('Date'),
- 'score' => t('Complexity'),
- )
- ));
- }
- else {
- $this->response->html($this->layout('analytic/burndown', array(
- 'values' => array(
- 'from' => $from,
- 'to' => $to,
- ),
- 'display_graph' => $this->projectDailySummary->countDays($project['id'], $from, $to) >= 2,
- 'project' => $project,
- 'date_format' => $this->config->get('application_date_format'),
- 'date_formats' => $this->dateParser->getAvailableFormats(),
- 'title' => t('Burndown chart for "%s"', $project['name']),
- )));
- }
+ $display_graph = $this->projectDailySummary->countDays($project['id'], $from, $to) >= 2;
+
+ $this->response->html($this->layout('analytic/burndown', array(
+ 'values' => array(
+ 'from' => $from,
+ 'to' => $to,
+ ),
+ 'display_graph' => $display_graph,
+ 'metrics' => $display_graph ? $this->projectDailySummary->getAggregatedMetrics($project['id'], $from, $to, 'score') : array(),
+ 'project' => $project,
+ 'date_format' => $this->config->get('application_date_format'),
+ 'date_formats' => $this->dateParser->getAvailableFormats(),
+ 'title' => t('Burndown chart for "%s"', $project['name']),
+ )));
}
}
diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php
index bb3c7c81..82f9534c 100644
--- a/app/Locale/da_DK/translations.php
+++ b/app/Locale/da_DK/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php
index 7d28b219..b004905b 100644
--- a/app/Locale/de_DE/translations.php
+++ b/app/Locale/de_DE/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php
index a169abfa..8aa56f6c 100644
--- a/app/Locale/es_ES/translations.php
+++ b/app/Locale/es_ES/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php
index 00514ab1..601ab9fd 100644
--- a/app/Locale/fi_FI/translations.php
+++ b/app/Locale/fi_FI/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php
index 4a792d07..4f077e93 100644
--- a/app/Locale/fr_FR/translations.php
+++ b/app/Locale/fr_FR/translations.php
@@ -945,4 +945,7 @@ return array(
'New due date: %B %e, %Y' => 'Nouvelle date d\'échéance : %d/%m/%Y',
'Start date changed: %B %e, %Y' => 'Date de début modifiée : %d/%m/%Y',
'%k:%M %p' => '%H:%M',
+ '%%Y-%%m-%%d' => '%%d/%%m/%%Y',
+ 'Total for all columns' => 'Total pour toutes les colonnes',
+ 'You need at least 2 days of data to show the chart.' => 'Vous avez besoin d\'au minimum 2 jours de données pour afficher le graphique.',
);
diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php
index dc5dbeeb..6c1861eb 100644
--- a/app/Locale/hu_HU/translations.php
+++ b/app/Locale/hu_HU/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php
index 950bfcd0..7bfa506a 100644
--- a/app/Locale/it_IT/translations.php
+++ b/app/Locale/it_IT/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php
index 7c64d54d..210621d0 100644
--- a/app/Locale/ja_JP/translations.php
+++ b/app/Locale/ja_JP/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php
index d7111b38..9e0cf6fe 100644
--- a/app/Locale/nl_NL/translations.php
+++ b/app/Locale/nl_NL/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php
index 8e2ac4a0..d2650a89 100644
--- a/app/Locale/pl_PL/translations.php
+++ b/app/Locale/pl_PL/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php
index f94f0911..041434a2 100644
--- a/app/Locale/pt_BR/translations.php
+++ b/app/Locale/pt_BR/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php
index 1f3be94f..7e94ecbb 100644
--- a/app/Locale/ru_RU/translations.php
+++ b/app/Locale/ru_RU/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php
index 028b21e4..8ac8ea31 100644
--- a/app/Locale/sr_Latn_RS/translations.php
+++ b/app/Locale/sr_Latn_RS/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php
index 93fe05b5..770a68d4 100644
--- a/app/Locale/sv_SE/translations.php
+++ b/app/Locale/sv_SE/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php
index 122c5f73..b1fb0417 100644
--- a/app/Locale/th_TH/translations.php
+++ b/app/Locale/th_TH/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php
index 31f2fd39..cdd4d8cf 100644
--- a/app/Locale/tr_TR/translations.php
+++ b/app/Locale/tr_TR/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php
index 0260aa26..60634686 100644
--- a/app/Locale/zh_CN/translations.php
+++ b/app/Locale/zh_CN/translations.php
@@ -943,4 +943,7 @@ return array(
// 'New due date: %B %e, %Y' => '',
// 'Start date changed: %B %e, %Y' => '',
// '%k:%M %p' => '',
+ // '%%Y-%%m-%%d' => '',
+ // 'Total for all columns' => '',
+ // 'You need at least 2 days of data to show the chart.' => '',
);
diff --git a/app/Model/ProjectDailySummary.php b/app/Model/ProjectDailySummary.php
index 65a612f6..acffa3a9 100644
--- a/app/Model/ProjectDailySummary.php
+++ b/app/Model/ProjectDailySummary.php
@@ -149,9 +149,10 @@ class ProjectDailySummary extends Base
* @param integer $project_id Project id
* @param string $from Start date (ISO format YYYY-MM-DD)
* @param string $to End date
+ * @param string $column Column to aggregate
* @return array
*/
- public function getAggregatedMetrics($project_id, $from, $to)
+ public function getAggregatedMetrics($project_id, $from, $to, $column = 'total')
{
$columns = $this->board->getColumnsList($project_id);
$column_ids = array_keys($columns);
@@ -172,7 +173,7 @@ class ProjectDailySummary extends Base
$aggregates[$record['day']] = array($record['day']);
}
- $aggregates[$record['day']][$record['column_id']] = $record['total'];
+ $aggregates[$record['day']][$record['column_id']] = $record[$column];
}
// Aggregate by row
diff --git a/app/Template/analytic/burndown.php b/app/Template/analytic/burndown.php
index 839573be..48a4c1c1 100644
--- a/app/Template/analytic/burndown.php
+++ b/app/Template/analytic/burndown.php
@@ -6,7 +6,7 @@
<p class="alert"><?= t('Not enough data to show the graph.') ?></p>
<?php else: ?>
<section id="analytic-burndown">
- <div id="chart" data-url="<?= $this->url->href('analytic', 'burndown', array('project_id' => $project['id'], 'from' => $values['from'], 'to' => $values['to'])) ?>"></div>
+ <div id="chart" data-metrics='<?= json_encode($metrics) ?>' data-date-format="<?= e('%%Y-%%m-%%d') ?>" data-label-total="<?= t('Total for all columns') ?>"></div>
</section>
<?php endif ?>
diff --git a/app/Template/analytic/cfd.php b/app/Template/analytic/cfd.php
index 26696b31..ab706d56 100644
--- a/app/Template/analytic/cfd.php
+++ b/app/Template/analytic/cfd.php
@@ -3,10 +3,10 @@
</div>
<?php if (! $display_graph): ?>
- <p class="alert"><?= t('Not enough data to show the graph.') ?></p>
+ <p class="alert"><?= t('You need at least 2 days of data to show the chart.') ?></p>
<?php else: ?>
<section id="analytic-cfd">
- <div id="chart" data-url="<?= $this->url->href('analytic', 'cfd', array('project_id' => $project['id'], 'from' => $values['from'], 'to' => $values['to'])) ?>"></div>
+ <div id="chart" data-metrics='<?= json_encode($metrics) ?>' data-date-format="<?= e('%%Y-%%m-%%d') ?>"></div>
</section>
<?php endif ?>
diff --git a/app/Template/analytic/layout.php b/app/Template/analytic/layout.php
index de8d0de9..72aab4d8 100644
--- a/app/Template/analytic/layout.php
+++ b/app/Template/analytic/layout.php
@@ -1,5 +1,5 @@
-<?= $this->asset->js('assets/js/vendor/d3.v3.4.8.min.js') ?>
-<?= $this->asset->js('assets/js/vendor/dimple.v2.1.2.min.js') ?>
+<?= $this->asset->js('assets/js/vendor/d3.v3.min.js') ?>
+<?= $this->asset->js('assets/js/vendor/c3.min.js') ?>
<section id="main">
<div class="page-header">
diff --git a/app/Template/analytic/tasks.php b/app/Template/analytic/tasks.php
index faa4bacc..36f36a23 100644
--- a/app/Template/analytic/tasks.php
+++ b/app/Template/analytic/tasks.php
@@ -7,7 +7,7 @@
<?php else: ?>
<section id="analytic-task-repartition">
- <div id="chart" data-url="<?= $this->url->href('analytic', 'tasks', array('project_id' => $project['id'])) ?>"></div>
+ <div id="chart" data-metrics='<?= json_encode($metrics) ?>'></div>
<table>
<tr>
diff --git a/app/Template/analytic/users.php b/app/Template/analytic/users.php
index 982ef206..263ea0ef 100644
--- a/app/Template/analytic/users.php
+++ b/app/Template/analytic/users.php
@@ -7,7 +7,7 @@
<?php else: ?>
<section id="analytic-user-repartition">
- <div id="chart" data-url="<?= $this->url->href('analytic', 'users', array('project_id' => $project['id'])) ?>"></div>
+ <div id="chart" data-metrics='<?= json_encode($metrics) ?>'></div>
<table>
<tr>
diff --git a/app/Template/budget/index.php b/app/Template/budget/index.php
index 4fe8ac69..3b594017 100644
--- a/app/Template/budget/index.php
+++ b/app/Template/budget/index.php
@@ -1,5 +1,5 @@
-<?= $this->asset->js('assets/js/vendor/d3.v3.4.8.min.js') ?>
-<?= $this->asset->js('assets/js/vendor/dimple.v2.1.2.min.js') ?>
+<?= $this->asset->js('assets/js/vendor/d3.v3.min.js') ?>
+<?= $this->asset->js('assets/js/vendor/c3.min.js') ?>
<div class="page-header">
<h2><?= t('Budget overview') ?></h2>
@@ -8,7 +8,8 @@
<?php if (! empty($daily_budget)): ?>
<div id="budget-chart">
<div id="chart"
- data-serie='<?= json_encode($daily_budget) ?>'
+ data-date-format="<?= e('%%Y-%%m-%%d') ?>"
+ data-metrics='<?= json_encode($daily_budget) ?>'
data-labels='<?= json_encode(array('in' => t('Budget line'), 'out' => t('Expenses'), 'left' => t('Remaining'), 'value' => t('Amount'), 'date' => t('Date'), 'type' => t('Type'))) ?>'></div>
</div>
<hr/>