Improved age chart. Refactored code.

This commit is contained in:
Christian P. MOMON 2020-01-29 20:28:14 +01:00
parent bc3f4fc26f
commit 5dffbcb888
6 changed files with 86 additions and 11 deletions

View File

@ -179,6 +179,50 @@ public class Issue
return result; 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) public void setClosedOn(final LocalDateTime closedOn)
{ {
this.closedOn = closedOn; this.closedOn = closedOn;

View File

@ -115,4 +115,31 @@ public class Issues extends ArrayList<Issue>
// //
return result; 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;
}
} }

View File

@ -35,7 +35,7 @@ var myChart = new Chart(ctx,
pointBorderWidth: 0.00000001 pointBorderWidth: 0.00000001
}, },
{ {
label: 'Concluded', label: 'Closedᴿ',
data: [1, 5, 9, 13, 15, 22] , data: [1, 5, 9, 13, 15, 22] ,
backgroundColor: 'rgba(75, 192, 192, 0.2)', backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderColor: 'rgba(75, 192, 192, 1)', borderColor: 'rgba(75, 192, 192, 1)',
@ -60,11 +60,15 @@ var myChart = new Chart(ctx,
ticks: ticks:
{ {
beginAtZero: false beginAtZero: false
},
gridLines:
{
offsetGridLines: false
} }
}], }],
yAxes: yAxes:
[{ [{
ticks: ticks:
{ {
beginAtZero: false, beginAtZero: false,
suggestedMax: 10, suggestedMax: 10,

View File

@ -24,7 +24,7 @@ var myChart = new Chart(ctx,
datasets: datasets:
[ [
{ {
label: 'Active', label: 'Active Issues',
data: [2, 9, 13, 15, 22, 23], data: [2, 9, 13, 15, 22, 23],
backgroundColor: 'rgba(255, 159, 64, 0.2)', backgroundColor: 'rgba(255, 159, 64, 0.2)',
borderColor: 'rgba(255, 159, 64, 1)', borderColor: 'rgba(255, 159, 64, 1)',

View File

@ -11,7 +11,7 @@
<script src="Chart.bundle.min.js"></script> <script src="Chart.bundle.min.js"></script>
</head> </head>
<body> <body>
<div style="width: 100%; height: 100%; text-align: center; margin: 0 0; border: 1px solid red;"> <div style="width: 100%; height: 100%; text-align: center; margin: 0 0; border: 1px solid red;" title="Issues Age">
<canvas id="myChart" width="100%" height="100%"></canvas> <canvas id="myChart" width="100%" height="100%"></canvas>
<script> <script>
var ctx = document.getElementById('myChart'); var ctx = document.getElementById('myChart');
@ -63,7 +63,7 @@ var myChart = new Chart(ctx,
maintainAspectRatio: false, maintainAspectRatio: false,
title: { title: {
display: false, display: false,
text: 'Min and Max Settings' text: 'Issue Age'
}, },
scales: scales:
{ {

View File

@ -41,9 +41,9 @@
<div id="created-ClosedPreviousYearChart" style="display: inline-block; width: 33%; height: 400px;">CREATED-CLOSED PREVIOUS YEAR CHART</div> <div id="created-ClosedPreviousYearChart" style="display: inline-block; width: 33%; height: 400px;">CREATED-CLOSED PREVIOUS YEAR CHART</div>
<div id="agePreviousYearChart" style="display: inline-block; width: 33%; height: 400px;">AGE PREVIOUS YEAR CHART</div> <div id="agePreviousYearChart" style="display: inline-block; width: 33%; height: 400px;">AGE PREVIOUS YEAR CHART</div>
</div> </div>
<div id="fullBox"> <div id="fullBox" style="">
<div id="createdClosedFullChart" style="height: 400px;" onclick="javascript: selectMainChart('C-C');">CREATED/CLOSED FULL CHART</div> <div id="createdClosedFullChart" style="height: 400px;" onclick="javascript: selectMainChart('C-C');">CREATED/CLOSED FULL CHART</div>
<div id="created-ClosedFullChart" style="height: 400px; display: none;" onclick="javascript: selectMainChart('AGE');">CREATED-CLOSED FULL CHART</div> <div id="created-ClosedFullChart" style="display: none; height: 400px;" onclick="javascript: selectMainChart('AGE');">CREATED-CLOSED FULL CHART</div>
<div id="ageFullChart" style="display: none; height: 400px;" onclick="javascript: selectMainChart('CC');">ISSUE AGE CHART</div> <div id="ageFullChart" style="display: none; height: 400px;" onclick="javascript: selectMainChart('CC');">ISSUE AGE CHART</div>
</div> </div>
</div> </div>
@ -59,8 +59,8 @@
<div> <div>
<div id="issueRawChart" style="width: 400px; height: 200px; display: inline-block;">ISSUES BAR CHART</div> <div id="issueRawChart" style="width: 400px; height: 200px; display: inline-block;">ISSUES BAR CHART</div>
<div id="unassignedRawChart" style="width: 360px; height: 200px; display: inline-block;"></div> <div id="unassignedRawChart" style="width: 360px; height: 200px; display: inline-block;"></div>
<div id="createdClosed6MonthsChartA" style="width: 340px; height: 200px; display: inline-block;">CREATED/CLOSED 6 MONTHS CHART A</div> <div id="createdClosed6MonthsChartA" style="width: 220px; height: 200px; display: inline-block;">CREATED/CLOSED 6 MONTHS CHART A</div>
<div id="created-Closed6MonthsChartA" style="width: 340px; height: 200px; display: inline-block;">CREATED-CLOSED 6 MONTHS CHART A</div> <div id="created-Closed6MonthsChartA" style="width: 220px; height: 200px; display: inline-block;">CREATED-CLOSED 6 MONTHS CHART A</div>
</div> </div>
<br/> <br/>
<div> <div>
@ -71,8 +71,8 @@
<div> <div>
<div id="issueGroupedChart" style="width: 400px; height: 200px; display: inline-block;">ISSUES BAR CHART</div> <div id="issueGroupedChart" style="width: 400px; height: 200px; display: inline-block;">ISSUES BAR CHART</div>
<div id="unassignedGroupedChart" style="width: 360px; height: 200px; display: inline-block;"></div> <div id="unassignedGroupedChart" style="width: 360px; height: 200px; display: inline-block;"></div>
<div id="createdClosed6MonthsChartB" style="width: 340px; height: 200px; display: inline-block;">CREATED/CLOSED 6 MONTHS CHARTB</div> <div id="createdClosed6MonthsChartB" style="width: 220px; height: 200px; display: inline-block;">CREATED/CLOSED 6 MONTHS CHARTB</div>
<div id="created-Closed6MonthsChartB" style="width: 340px; height: 200px; display: inline-block;">CREATED-CLOSED 6 MONTHS CHART B</div> <div id="created-Closed6MonthsChartB" style="width: 220px; height: 200px; display: inline-block;">CREATED-CLOSED 6 MONTHS CHART B</div>
</div> </div>
<br/> <br/>
<div> <div>