diff --git a/src/org/april/agirstatool/core/AgirStatoolUtils.java b/src/org/april/agirstatool/core/AgirStatoolUtils.java index 8dde07d..45f8414 100644 --- a/src/org/april/agirstatool/core/AgirStatoolUtils.java +++ b/src/org/april/agirstatool/core/AgirStatoolUtils.java @@ -22,6 +22,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Date; +import java.util.Iterator; import java.util.Locale; import org.apache.commons.lang3.StringUtils; @@ -113,7 +114,7 @@ public class AgirStatoolUtils LocalDate date = AgirStatoolUtils.normaliseWeekDate(start); while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) { - String label = date.format(DateTimeFormatter.ofPattern("yyyy-MMM", Locale.FRANCE)); + String label = date.format(DateTimeFormatter.ISO_DATE); result.add(label); date = date.plusWeeks(1); } @@ -530,6 +531,38 @@ public class AgirStatoolUtils return result; } + /** + * To J son numbers. + * + * @param labels + * the labels + * @param values + * the source + * @return the string + */ + public static String toJSonNumbers(final StringList labels, final StringList values) + { + String result; + + Iterator labelIterator = labels.iterator(); + Iterator valueIterator = values.iterator(); + + StringList buffer = new StringList(); + while (labelIterator.hasNext()) + { + String label = labelIterator.next(); + String value = valueIterator.next(); + + // buffer.append("{t: new Date('" + label + "'), y: " + value + + // "}"); + buffer.append("{t: '" + label + "', y: " + value + "}"); + } + result = StringsUtils.toString(buffer, "[", ",", "]"); + + // + return result; + } + /** * To Json strings. * diff --git a/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java b/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java index 8aab103..af17077 100644 --- a/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java +++ b/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java @@ -69,15 +69,14 @@ public class CreatedClosedCountChartView code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "lineChart")); StringList labels = AgirStatoolUtils.buildWeekLabels(start, end); - code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels)); DateCountList dates = project.issueStats().getWeekCreatedIssueCounts(); StringList values = AgirStatoolUtils.normalizedWeekCountList(dates, start, end).toValueList(); - code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(labels, values)); dates = project.issueStats().getWeekConcludedIssueCounts(); values = AgirStatoolUtils.normalizedWeekCountList(dates, start, end).toValueList(); - code = code.replaceAll("data: \\[.*\\] ", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + code = code.replaceAll("data: \\[.*\\] ", "data: " + AgirStatoolUtils.toJSonNumbers(labels, values)); result = code.toString(); } @@ -122,13 +121,12 @@ public class CreatedClosedCountChartView code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "lineBar")); StringList labels = AgirStatoolUtils.buildWeekLabels(project.issueStats().getFirstCreate().toLocalDate()); - code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels)); StringList values = project.issueStats().getWeekCreatedIssueCounts().toValueList(); - code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(labels, values)); values = project.issueStats().getWeekConcludedIssueCounts().toValueList(); - code = code.replaceAll("data: \\[.*\\] ", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + code = code.replaceAll("data: \\[.*\\] ", "data: " + AgirStatoolUtils.toJSonNumbers(labels, values)); result = code.toString(); } diff --git a/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java b/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java index fc77a78..f600e3e 100644 --- a/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java +++ b/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java @@ -69,9 +69,6 @@ public class CreatedClosedDiffChartView code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "line2Chart")); - StringList labels = AgirStatoolUtils.buildWeekLabels(start, end); - code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels)); - DateCountList createdDates = project.issueStats().getWeekCreatedIssueCounts(); DateCountList closedDates = project.issueStats().getWeekConcludedIssueCounts(); DateCountList dates = new DateCountList(createdDates.size()); @@ -82,8 +79,9 @@ public class CreatedClosedDiffChartView dates.add(new DateCount(createdDate.getDate(), createdDate.getCount() - closedDate.getCount())); } + StringList labels = AgirStatoolUtils.buildWeekLabels(start, end); StringList values = AgirStatoolUtils.normalizedWeekCountList(dates, start, end).toValueList(); - code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(labels, values)); result = code.toString(); } diff --git a/src/org/april/agirstatool/core/pages/IssueAgeChartView.java b/src/org/april/agirstatool/core/pages/IssueAgeChartView.java index 9e1068a..55e4732 100644 --- a/src/org/april/agirstatool/core/pages/IssueAgeChartView.java +++ b/src/org/april/agirstatool/core/pages/IssueAgeChartView.java @@ -68,16 +68,15 @@ public class IssueAgeChartView code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "ageStatsChart")); StringList labels = AgirStatoolUtils.buildWeekLabels(start, end); - code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels)); StringList values = AgirStatoolUtils.buildWeekMinAges(project, start, end); - code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(labels, values)); values = AgirStatoolUtils.buildWeekMeanAges(project, start, end); - code = code.replaceAll("data : \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + code = code.replaceAll("data : \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(labels, values)); values = AgirStatoolUtils.buildWeekMaxAges(project, start, end); - code = code.replaceAll("data : \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + code = code.replaceAll("data : \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(labels, values)); result = code.toString(); } diff --git a/src/org/april/agirstatool/core/pages/createdClosedCountChartView.xhtml b/src/org/april/agirstatool/core/pages/createdClosedCountChartView.xhtml index d13d0d1..cb359c5 100644 --- a/src/org/april/agirstatool/core/pages/createdClosedCountChartView.xhtml +++ b/src/org/april/agirstatool/core/pages/createdClosedCountChartView.xhtml @@ -20,29 +20,28 @@ var myChart = new Chart(ctx, type: 'line', data: { - labels: ['S01', 'S02', 'S03', 'S04', 'S05'], datasets: [ { label: 'Created', - data: [2, 9, 13, 15, 22, 23], backgroundColor: 'rgba(255, 99, 132, 0.2)', borderColor: 'rgba(255, 99, 132, 1)', borderWidth: 1, fill: true, /* cubicInterpolationMode: 'monotone', */ lineTension: 0, - pointBorderWidth: 0.00000001 + pointBorderWidth: 0.00000001, + data: [2, 9, 13, 15, 22, 23] }, { label: 'Closedá´¿', - data: [1, 5, 9, 13, 15, 22] , backgroundColor: 'rgba(75, 192, 192, 0.2)', borderColor: 'rgba(75, 192, 192, 1)', borderWidth: 1, fill: true, lineTension: 0, - pointBorderWidth: 0.00000001 + pointBorderWidth: 0.00000001, + data: [1, 5, 9, 13, 15, 22] } ] }, @@ -57,23 +56,36 @@ var myChart = new Chart(ctx, { xAxes: [{ - ticks: + type: 'time', + time: + { + unit: 'month', + isoWeekday: true, + displayFormats: { - beginAtZero: false - }, - gridLines: - { - offsetGridLines: false + month: 'YYYY MMM' } + }, + distribution: 'linear', + ticks: + { + beginAtZero: false, + maxTicksLimit: 0 + }, + gridLines: + { + zeroLineColor: 'rgba(0, 0, 0, 0.1)', + offsetGridLines: false + } }], yAxes: [{ - ticks: - { - beginAtZero: false, - suggestedMax: 10, - precision: 0 - } + ticks: + { + beginAtZero: false, + suggestedMax: 10, + precision: 0 + } }] } } diff --git a/src/org/april/agirstatool/core/pages/createdClosedDiffChartView.xhtml b/src/org/april/agirstatool/core/pages/createdClosedDiffChartView.xhtml index 193287e..d088428 100644 --- a/src/org/april/agirstatool/core/pages/createdClosedDiffChartView.xhtml +++ b/src/org/april/agirstatool/core/pages/createdClosedDiffChartView.xhtml @@ -20,19 +20,18 @@ var myChart = new Chart(ctx, type: 'line', data: { - labels: ['S01', 'S02', 'S03', 'S04', 'S05'], datasets: [ { label: 'Active Issues', - data: [2, 9, 13, 15, 22, 23], backgroundColor: 'rgba(255, 159, 64, 0.2)', borderColor: 'rgba(255, 159, 64, 1)', borderWidth: 1, fill: true, /* cubicInterpolationMode: 'monotone', */ lineTension: 0, - pointBorderWidth: 0.00000001 + pointBorderWidth: 0.00000001, + data: [2, 9, 13, 15, 22, 23] }, ] }, @@ -47,19 +46,34 @@ var myChart = new Chart(ctx, { xAxes: [{ - ticks: + type: 'time', + time: + { + unit: 'month', + isoWeekday: true, + displayFormats: { - beginAtZero: false + month: 'YYYY MMM' } + }, + distribution: 'linear', + ticks: + { + }, + gridLines: + { + zeroLineColor: 'rgba(0, 0, 0, 0.1)', + offsetGridLines: false + } }], yAxes: [{ - ticks: - { - beginAtZero: false, - suggestedMax: 10, - precision: 0 - } + ticks: + { + beginAtZero: false, + suggestedMax: 10, + precision: 0 + } }] } } diff --git a/src/org/april/agirstatool/core/pages/issueAgeChartView.xhtml b/src/org/april/agirstatool/core/pages/issueAgeChartView.xhtml index 7f55ac4..41429af 100644 --- a/src/org/april/agirstatool/core/pages/issueAgeChartView.xhtml +++ b/src/org/april/agirstatool/core/pages/issueAgeChartView.xhtml @@ -20,41 +20,40 @@ var myChart = new Chart(ctx, type: 'line', data: { - labels: ['S01', 'S02', 'S03', 'S04', 'S05'], datasets: [ { label: 'min', - data: [2, 9, 13, 15, 22, 23], backgroundColor: 'rgba(255, 99, 132, 0.2)', borderColor: 'rgba(255, 99, 132, 1)', borderWidth: 1, fill: +1, cubicInterpolationMode: 'monotone', lineTension: 0, - pointBorderWidth: 0.00000001 + pointBorderWidth: 0.00000001, + data: [2, 9, 13, 15, 22, 23], }, { label: 'mean', - data : [1, 5, 9, 13, 15, 22], backgroundColor: 'rgba(75, 192, 192, 0.2)', borderColor: 'rgba(75, 192, 192, 1)', borderWidth: 1, fill: +2, cubicInterpolationMode: 'monotone', lineTension: 0, - pointBorderWidth: 0.00000001 + pointBorderWidth: 0.00000001, + data : [1, 5, 9, 13, 15, 22], }, { label: 'max', - data : [1, 5, 9, 13, 15, 22], backgroundColor: 'rgba(153, 102, 255, 0.2)', borderColor: 'rgba(153, 102, 255, 1)', borderWidth: 1, fill: false, cubicInterpolationMode: 'monotone', lineTension: 0, - pointBorderWidth: 0.00000001 + pointBorderWidth: 0.00000001, + data : [1, 5, 9, 13, 15, 22], } ] }, @@ -69,10 +68,27 @@ var myChart = new Chart(ctx, { xAxes: [{ - ticks: + type: 'time', + time: + { + unit: 'month', + isoWeekday: true, + displayFormats: { - beginAtZero: false + month: 'YYYY MMM' } + }, + distribution: 'linear', + ticks: + { + beginAtZero: false, + maxTicksLimit: 0 + }, + gridLines: + { + zeroLineColor: 'rgba(0, 0, 0, 0.1)', + offsetGridLines: false + } }], yAxes: [{