Refactored label for time way.
This commit is contained in:
parent
0300e19c82
commit
d5d189a0be
7 changed files with 122 additions and 52 deletions
|
@ -22,6 +22,7 @@ import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -113,7 +114,7 @@ public class AgirStatoolUtils
|
||||||
LocalDate date = AgirStatoolUtils.normaliseWeekDate(start);
|
LocalDate date = AgirStatoolUtils.normaliseWeekDate(start);
|
||||||
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
|
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);
|
result.add(label);
|
||||||
date = date.plusWeeks(1);
|
date = date.plusWeeks(1);
|
||||||
}
|
}
|
||||||
|
@ -530,6 +531,38 @@ public class AgirStatoolUtils
|
||||||
return result;
|
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<String> labelIterator = labels.iterator();
|
||||||
|
Iterator<String> 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.
|
* To Json strings.
|
||||||
*
|
*
|
||||||
|
|
|
@ -69,15 +69,14 @@ public class CreatedClosedCountChartView
|
||||||
code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "lineChart"));
|
code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "lineChart"));
|
||||||
|
|
||||||
StringList labels = AgirStatoolUtils.buildWeekLabels(start, end);
|
StringList labels = AgirStatoolUtils.buildWeekLabels(start, end);
|
||||||
code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels));
|
|
||||||
|
|
||||||
DateCountList dates = project.issueStats().getWeekCreatedIssueCounts();
|
DateCountList dates = project.issueStats().getWeekCreatedIssueCounts();
|
||||||
StringList values = AgirStatoolUtils.normalizedWeekCountList(dates, start, end).toValueList();
|
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();
|
dates = project.issueStats().getWeekConcludedIssueCounts();
|
||||||
values = AgirStatoolUtils.normalizedWeekCountList(dates, start, end).toValueList();
|
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();
|
result = code.toString();
|
||||||
}
|
}
|
||||||
|
@ -122,13 +121,12 @@ public class CreatedClosedCountChartView
|
||||||
code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "lineBar"));
|
code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "lineBar"));
|
||||||
|
|
||||||
StringList labels = AgirStatoolUtils.buildWeekLabels(project.issueStats().getFirstCreate().toLocalDate());
|
StringList labels = AgirStatoolUtils.buildWeekLabels(project.issueStats().getFirstCreate().toLocalDate());
|
||||||
code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels));
|
|
||||||
|
|
||||||
StringList values = project.issueStats().getWeekCreatedIssueCounts().toValueList();
|
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();
|
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();
|
result = code.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,9 +69,6 @@ public class CreatedClosedDiffChartView
|
||||||
|
|
||||||
code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "line2Chart"));
|
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 createdDates = project.issueStats().getWeekCreatedIssueCounts();
|
||||||
DateCountList closedDates = project.issueStats().getWeekConcludedIssueCounts();
|
DateCountList closedDates = project.issueStats().getWeekConcludedIssueCounts();
|
||||||
DateCountList dates = new DateCountList(createdDates.size());
|
DateCountList dates = new DateCountList(createdDates.size());
|
||||||
|
@ -82,8 +79,9 @@ public class CreatedClosedDiffChartView
|
||||||
dates.add(new DateCount(createdDate.getDate(), createdDate.getCount() - closedDate.getCount()));
|
dates.add(new DateCount(createdDate.getDate(), createdDate.getCount() - closedDate.getCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringList labels = AgirStatoolUtils.buildWeekLabels(start, end);
|
||||||
StringList values = AgirStatoolUtils.normalizedWeekCountList(dates, start, end).toValueList();
|
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();
|
result = code.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,16 +68,15 @@ public class IssueAgeChartView
|
||||||
code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "ageStatsChart"));
|
code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "ageStatsChart"));
|
||||||
|
|
||||||
StringList labels = AgirStatoolUtils.buildWeekLabels(start, end);
|
StringList labels = AgirStatoolUtils.buildWeekLabels(start, end);
|
||||||
code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels));
|
|
||||||
|
|
||||||
StringList values = AgirStatoolUtils.buildWeekMinAges(project, start, end);
|
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);
|
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);
|
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();
|
result = code.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,29 +20,28 @@ var myChart = new Chart(ctx,
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data:
|
data:
|
||||||
{
|
{
|
||||||
labels: ['S01', 'S02', 'S03', 'S04', 'S05'],
|
|
||||||
datasets:
|
datasets:
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
label: 'Created',
|
label: 'Created',
|
||||||
data: [2, 9, 13, 15, 22, 23],
|
|
||||||
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
||||||
borderColor: 'rgba(255, 99, 132, 1)',
|
borderColor: 'rgba(255, 99, 132, 1)',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
fill: true,
|
fill: true,
|
||||||
/* cubicInterpolationMode: 'monotone', */
|
/* cubicInterpolationMode: 'monotone', */
|
||||||
lineTension: 0,
|
lineTension: 0,
|
||||||
pointBorderWidth: 0.00000001
|
pointBorderWidth: 0.00000001,
|
||||||
|
data: [2, 9, 13, 15, 22, 23]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Closedᴿ',
|
label: 'Closedᴿ',
|
||||||
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)',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
fill: true,
|
fill: true,
|
||||||
lineTension: 0,
|
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:
|
xAxes:
|
||||||
[{
|
[{
|
||||||
ticks:
|
type: 'time',
|
||||||
|
time:
|
||||||
|
{
|
||||||
|
unit: 'month',
|
||||||
|
isoWeekday: true,
|
||||||
|
displayFormats:
|
||||||
{
|
{
|
||||||
beginAtZero: false
|
month: 'YYYY MMM'
|
||||||
},
|
|
||||||
gridLines:
|
|
||||||
{
|
|
||||||
offsetGridLines: false
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
distribution: 'linear',
|
||||||
|
ticks:
|
||||||
|
{
|
||||||
|
beginAtZero: false,
|
||||||
|
maxTicksLimit: 0
|
||||||
|
},
|
||||||
|
gridLines:
|
||||||
|
{
|
||||||
|
zeroLineColor: 'rgba(0, 0, 0, 0.1)',
|
||||||
|
offsetGridLines: false
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
yAxes:
|
yAxes:
|
||||||
[{
|
[{
|
||||||
ticks:
|
ticks:
|
||||||
{
|
{
|
||||||
beginAtZero: false,
|
beginAtZero: false,
|
||||||
suggestedMax: 10,
|
suggestedMax: 10,
|
||||||
precision: 0
|
precision: 0
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,19 +20,18 @@ var myChart = new Chart(ctx,
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data:
|
data:
|
||||||
{
|
{
|
||||||
labels: ['S01', 'S02', 'S03', 'S04', 'S05'],
|
|
||||||
datasets:
|
datasets:
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
label: 'Active Issues',
|
label: 'Active Issues',
|
||||||
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)',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
fill: true,
|
fill: true,
|
||||||
/* cubicInterpolationMode: 'monotone', */
|
/* cubicInterpolationMode: 'monotone', */
|
||||||
lineTension: 0,
|
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:
|
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:
|
yAxes:
|
||||||
[{
|
[{
|
||||||
ticks:
|
ticks:
|
||||||
{
|
{
|
||||||
beginAtZero: false,
|
beginAtZero: false,
|
||||||
suggestedMax: 10,
|
suggestedMax: 10,
|
||||||
precision: 0
|
precision: 0
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,41 +20,40 @@ var myChart = new Chart(ctx,
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data:
|
data:
|
||||||
{
|
{
|
||||||
labels: ['S01', 'S02', 'S03', 'S04', 'S05'],
|
|
||||||
datasets:
|
datasets:
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
label: 'min',
|
label: 'min',
|
||||||
data: [2, 9, 13, 15, 22, 23],
|
|
||||||
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
||||||
borderColor: 'rgba(255, 99, 132, 1)',
|
borderColor: 'rgba(255, 99, 132, 1)',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
fill: +1,
|
fill: +1,
|
||||||
cubicInterpolationMode: 'monotone',
|
cubicInterpolationMode: 'monotone',
|
||||||
lineTension: 0,
|
lineTension: 0,
|
||||||
pointBorderWidth: 0.00000001
|
pointBorderWidth: 0.00000001,
|
||||||
|
data: [2, 9, 13, 15, 22, 23],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'mean',
|
label: 'mean',
|
||||||
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)',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
fill: +2,
|
fill: +2,
|
||||||
cubicInterpolationMode: 'monotone',
|
cubicInterpolationMode: 'monotone',
|
||||||
lineTension: 0,
|
lineTension: 0,
|
||||||
pointBorderWidth: 0.00000001
|
pointBorderWidth: 0.00000001,
|
||||||
|
data : [1, 5, 9, 13, 15, 22],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'max',
|
label: 'max',
|
||||||
data : [1, 5, 9, 13, 15, 22],
|
|
||||||
backgroundColor: 'rgba(153, 102, 255, 0.2)',
|
backgroundColor: 'rgba(153, 102, 255, 0.2)',
|
||||||
borderColor: 'rgba(153, 102, 255, 1)',
|
borderColor: 'rgba(153, 102, 255, 1)',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
fill: false,
|
fill: false,
|
||||||
cubicInterpolationMode: 'monotone',
|
cubicInterpolationMode: 'monotone',
|
||||||
lineTension: 0,
|
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:
|
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:
|
yAxes:
|
||||||
[{
|
[{
|
||||||
|
|
Loading…
Reference in a new issue