#23-Create statistic method

This commit is contained in:
Anton Romanov 2021-04-19 16:52:00 +04:00
parent 0b41ef37ae
commit f3df5f5ad1
2 changed files with 88 additions and 44 deletions

View File

@ -38,13 +38,6 @@ public class StatisticController {
url[i] = urlCommits().get(i)[0].toString().substring(urlCommits().get(i)[0].toString().lastIndexOf("/") + 1); url[i] = urlCommits().get(i)[0].toString().substring(urlCommits().get(i)[0].toString().lastIndexOf("/") + 1);
} }
model.addAttribute("urls", url); model.addAttribute("urls", url);
for (int i = 0; i < entityCommits().size(); i++) {
entityCommits().get(i)[0] = Boolean.TRUE.equals(entityCommits().get(i)[0])
? "Есть сущности"
: (entityCommits().get(i)[0] == null
? "Нет данных"
: "Нет сущностей");
}
model.addAttribute("commitEntityData", entityCommits()); model.addAttribute("commitEntityData", entityCommits());
model.addAttribute("commitTimeEntityData", allTimeEntityCommits()); model.addAttribute("commitTimeEntityData", allTimeEntityCommits());
return STATISTIC; return STATISTIC;
@ -75,6 +68,13 @@ public class StatisticController {
List<Object[]> entityCommits = commitRepository.getCommitEntityStatistic().stream() List<Object[]> entityCommits = commitRepository.getCommitEntityStatistic().stream()
.map(stat -> new Object[]{stat.getEntity(), stat.getCountCommit()}) .map(stat -> new Object[]{stat.getEntity(), stat.getCountCommit()})
.collect(Collectors.toList()); .collect(Collectors.toList());
for (int i = 0; i < entityCommits.size(); i++) {
entityCommits.get(i)[0] = Boolean.TRUE.equals(entityCommits.get(i)[0])
? "Есть сущности"
: (entityCommits.get(i)[0] == null
? "Нет данных"
: "Нет сущностей");
}
return entityCommits; return entityCommits;
} }

View File

@ -79,44 +79,44 @@
$('#container').highcharts(json); $('#container').highcharts(json);
}); });
</script> </script>
<script th:inline="javascript"> <!-- <script th:inline="javascript">-->
$(document).ready(function () { <!-- $(document).ready(function () {-->
var chart = { <!-- var chart = {-->
plotBackgroundColor: null, <!-- plotBackgroundColor: null,-->
plotBorderWidth: null, <!-- plotBorderWidth: null,-->
plotShadow: false <!-- plotShadow: false-->
}; <!-- };-->
var title = { <!-- var title = {-->
text: '% коммитов авторов' <!-- text: '% коммитов авторов'-->
}; <!-- };-->
var tooltip = { <!-- var tooltip = {-->
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' <!-- pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'-->
}; <!-- };-->
var plotOptions = { <!-- var plotOptions = {-->
pie: { <!-- pie: {-->
allowPointSelect: true, <!-- allowPointSelect: true,-->
cursor: 'pointer', <!-- cursor: 'pointer',-->
dataLabels: { <!-- dataLabels: {-->
enabled: false <!-- enabled: false-->
}, <!-- },-->
showInLegend: true <!-- showInLegend: true-->
} <!-- }-->
}; <!-- };-->
var series = [{ <!-- var series = [{-->
type: 'pie', <!-- type: 'pie',-->
name: 'Browser share', <!-- name: 'Browser share',-->
data: [[${commitAuthorData}]] <!-- data: [[${commitAuthorData}]]-->
}]; <!-- }];-->
var json = {}; <!-- var json = {};-->
json.chart = chart; <!-- json.chart = chart;-->
json.title = title; <!-- json.title = title;-->
json.tooltip = tooltip; <!-- json.tooltip = tooltip;-->
json.series = series; <!-- json.series = series;-->
json.plotOptions = plotOptions; <!-- json.plotOptions = plotOptions;-->
$('#containerPie').highcharts(json); <!-- $('#containerPie').highcharts(json);-->
}); <!-- });-->
</script> <!-- </script>-->
<script th:inline="javascript"> <script th:inline="javascript">
$(document).ready(function () { $(document).ready(function () {
var chart = { var chart = {
@ -212,11 +212,55 @@
$('#containerEntityPie').highcharts(json); $('#containerEntityPie').highcharts(json);
}); });
</script> </script>
<script th:inline="javascript">
document.getElementById('pie')
function createPie(idElement, data, title) {
var chart = {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
};
var title = {
text: title
};
var tooltip = {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
};
var plotOptions = {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
};
var series = [{
type: 'pie',
name: 'Browser share',
data: data
}];
var json = {};
json.chart = chart;
json.title = title;
json.tooltip = tooltip;
json.series = series;
json.plotOptions = plotOptions;
$('#containerPie').highcharts(json);
};
// createPie([[${commitEntityData}]], '#containerEntityPie_');
// createPie([[${commitAuthorData}]],'#containerPie_');
$(document).ready(createPie('pieSuper', [[${commitAuthorData}]], 'title'));
</script>
<div class="row"> <div class="row">
<div id="container" style="width: 550px; height: 400px; margin: 0 auto"></div> <div id="container" style="width: 550px; height: 400px; margin: 0 auto"></div>
<div id="containerPie" style="width: 550px; height: 400px; margin: 0 auto"></div> <div id="containerPie" style="width: 550px; height: 400px; margin: 0 auto"></div>
<div id="containerColumn" style="width: 550px; height: 400px; margin: 0 auto"></div> <div id="containerColumn" style="width: 550px; height: 400px; margin: 0 auto"></div>
<div id="containerEntityPie" style="width: 550px; height: 400px; margin: 0 auto"></div> <div id="containerEntityPie" style="width: 550px; height: 400px; margin: 0 auto"></div>
<div id="pieSuper" style="width: 550px; height: 400px; margin: 0 auto"></div>
</div> </div>
</div> </div>
</html> </html>