From 5dffbcb8889b163cede31d052f078985b46ac3c4 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Wed, 29 Jan 2020 20:28:14 +0100 Subject: [PATCH] Improved age chart. Refactored code. --- src/org/april/agirstatool/core/Issue.java | 44 +++++++++++++++++++ src/org/april/agirstatool/core/Issues.java | 27 ++++++++++++ .../core/pages/chartLineView.xhtml | 8 +++- .../core/pages/chartLineView2.xhtml | 2 +- .../core/pages/issueAgeChartView.xhtml | 4 +- .../agirstatool/core/pages/project.xhtml | 12 ++--- 6 files changed, 86 insertions(+), 11 deletions(-) diff --git a/src/org/april/agirstatool/core/Issue.java b/src/org/april/agirstatool/core/Issue.java index eb65b40..d52090e 100644 --- a/src/org/april/agirstatool/core/Issue.java +++ b/src/org/april/agirstatool/core/Issue.java @@ -179,6 +179,50 @@ public class Issue return result; } + /** + * Checks if is active between. + * + * @param start + * the start + * @param end + * the end + * @return true, if is active between + */ + public boolean isActiveBetween(final LocalDate start, final LocalDate end) + { + boolean result; + + if ((start == null) || (end == null)) + { + result = false; + } + else + { + LocalDate createdDate = this.createdOn.toLocalDate(); + LocalDate closedDate; + if (this.closedOn == null) + { + closedDate = null; + } + else + { + closedDate = this.closedOn.toLocalDate(); + } + + if ((!createdDate.isAfter(start)) && ((closedDate == null) || (end.isBefore(closedDate)))) + { + result = true; + } + else + { + result = false; + } + } + + // + return result; + } + public void setClosedOn(final LocalDateTime closedOn) { this.closedOn = closedOn; diff --git a/src/org/april/agirstatool/core/Issues.java b/src/org/april/agirstatool/core/Issues.java index e228d2b..2be8d94 100644 --- a/src/org/april/agirstatool/core/Issues.java +++ b/src/org/april/agirstatool/core/Issues.java @@ -115,4 +115,31 @@ public class Issues extends ArrayList // return result; } + + /** + * Extract actived between. + * + * @param start + * the start + * @param end + * the end + * @return the issues + */ + public Issues extractActivedBetween(final LocalDate start, final LocalDate end) + { + Issues result; + + result = new Issues(); + + for (Issue issue : this) + { + if (issue.isActiveBetween(start, end)) + { + result.add(issue); + } + } + + // + return result; + } } \ No newline at end of file diff --git a/src/org/april/agirstatool/core/pages/chartLineView.xhtml b/src/org/april/agirstatool/core/pages/chartLineView.xhtml index bd7530c..3b61280 100644 --- a/src/org/april/agirstatool/core/pages/chartLineView.xhtml +++ b/src/org/april/agirstatool/core/pages/chartLineView.xhtml @@ -35,7 +35,7 @@ var myChart = new Chart(ctx, pointBorderWidth: 0.00000001 }, { - label: 'Concluded', + label: 'Closedá´¿', data: [1, 5, 9, 13, 15, 22] , backgroundColor: 'rgba(75, 192, 192, 0.2)', borderColor: 'rgba(75, 192, 192, 1)', @@ -60,11 +60,15 @@ var myChart = new Chart(ctx, ticks: { beginAtZero: false + }, + gridLines: + { + offsetGridLines: false } }], yAxes: [{ - ticks: + ticks: { beginAtZero: false, suggestedMax: 10, diff --git a/src/org/april/agirstatool/core/pages/chartLineView2.xhtml b/src/org/april/agirstatool/core/pages/chartLineView2.xhtml index 24feebf..b315c9c 100644 --- a/src/org/april/agirstatool/core/pages/chartLineView2.xhtml +++ b/src/org/april/agirstatool/core/pages/chartLineView2.xhtml @@ -24,7 +24,7 @@ var myChart = new Chart(ctx, datasets: [ { - label: 'Active', + label: 'Active Issues', data: [2, 9, 13, 15, 22, 23], backgroundColor: 'rgba(255, 159, 64, 0.2)', borderColor: 'rgba(255, 159, 64, 1)', diff --git a/src/org/april/agirstatool/core/pages/issueAgeChartView.xhtml b/src/org/april/agirstatool/core/pages/issueAgeChartView.xhtml index f156f66..dd3cf92 100644 --- a/src/org/april/agirstatool/core/pages/issueAgeChartView.xhtml +++ b/src/org/april/agirstatool/core/pages/issueAgeChartView.xhtml @@ -11,7 +11,7 @@ -
+