Commit 3b75c161 authored by Matija Obreza's avatar Matija Obreza

Use /wiews/{instCode}/stat-genus, assigned new DOM id to chart

Removed new genesysService method, resorted syronex-colorpicker.min.js
parent 19ebd712
......@@ -603,6 +603,7 @@
<include>leaflet.min.js</include>
<include>leaflet.locationfilter.min.js</include>
<include>crophub.min.js</include>
<include>syronex-colorpicker.min.js</include>
<include>jquery.flot.min.js</include>
<include>jquery.flot.pie.min.js</include>
</includes>
......
......@@ -53,9 +53,6 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
@Query(value = "select t.genus, count(a.id) from Accession a inner join a.taxonomy t where a.institute = ?1 group by t.genus order by count(a) desc", countQuery = "select count(distinct a.taxGenus) from Accession a where a.institute = ?1")
Page<Object[]> statisticsGenusInInstitute(FaoInstitute institute, Pageable pageable);
@Query(value = "select t.genus, count(a.id) from Accession a inner join a.taxonomy t where a.institute = ?1 group by t.genus order by count(a) desc", countQuery = "select count(distinct a.taxGenus) from Accession a where a.institute = ?1")
List<Object[]> statisticsGenusInInstitute(FaoInstitute institute);
@Query(value = "select a.taxSpecies, count(a) from Accession a where a.institute = ?1 group by a.taxSpecies order by count(a) desc", countQuery = "select count(distinct a.taxSpecies) from Accession a where a.institute = ?1")
Page<Object[]> statisticsSpeciesInInstitute(FaoInstitute institute, Pageable pageable);
......
......@@ -101,8 +101,6 @@ public interface GenesysService {
Page<Object[]> statisticsGenusByInstitute(FaoInstitute faoInstitute, Pageable pageable);
List<Object[]> statisticsGenusByInstitute(FaoInstitute institute);
Page<Object[]> statisticsSpeciesByInstitute(FaoInstitute faoInstitute, Pageable pageable);
// Page<Object[]> statisticsCropByInstitute(FaoInstitute faoInstitute,
......
......@@ -424,11 +424,6 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
}
@Override
public List<Object[]> statisticsGenusByInstitute(FaoInstitute institute) {
return accessionRepository.statisticsGenusInInstitute(institute);
}
@Override
public Page<Object[]> statisticsSpeciesByInstitute(FaoInstitute institute, Pageable pageable) {
final Page<Object[]> page = accessionRepository.statisticsSpeciesInInstitute(institute, pageable);
for (final Object[] r : page.getContent()) {
......
......@@ -116,14 +116,24 @@ public class WiewsController extends BaseController {
return "/wiews/details";
}
@RequestMapping(value = "/statJson",produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/{wiewsCode}/stat-genus",produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Object getStatisticForFlot(@RequestParam("wiewsCode") String wiewsCode){
public Object getGenusStats(@PathVariable(value = "wiewsCode") String wiewsCode){
final FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode);
if (faoInstitute == null) {
throw new ResourceNotFoundException();
}
return genesysService.statisticsGenusByInstitute(faoInstitute);
return genesysService.statisticsGenusByInstitute(faoInstitute, new PageRequest(0, 10)).getContent();
}
@RequestMapping(value = "/{wiewsCode}/stat-species",produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Object getSpeciesStats(@PathVariable(value = "wiewsCode") String wiewsCode){
final FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode);
if (faoInstitute == null) {
throw new ResourceNotFoundException();
}
return genesysService.statisticsSpeciesByInstitute(faoInstitute, new PageRequest(0, 10)).getContent();
}
@RequestMapping("/{wiewsCode}/datasets")
......
......@@ -113,11 +113,6 @@
</h3> --%>
<div class="row">
<div id="flot" style="width:555px;height:300px"></div>
</div>
<div class="row" style="margin-top: 2em;">
<%-- <c:if test="${statisticsCrop ne null}">
<div class="col-sm-4">
......@@ -132,6 +127,9 @@
<div class="col-sm-6">
<h4><spring:message code="faoInstitute.stat-by-genus" arguments="${statisticsGenus.numberOfElements}" /></h4>
<div id="chartStatsByGenus" style="height:300px"></div>
<ul class="funny-list statistics">
<c:forEach items="${statisticsGenus.content}" var="stat" varStatus="status">
<li class="clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}"><span class="stats-number"><fmt:formatNumber value="${stat[1]}" /></span> <a href="<c:url value="/wiews/${faoInstitute.code.toLowerCase()}/t/${stat[0]}" />"><c:out value="${stat[0]}" /></a></li>
......@@ -141,6 +139,9 @@
<div class="col-sm-6">
<h4><spring:message code="faoInstitute.stat-by-species" arguments="${statisticsTaxonomy.numberOfElements}" /></h4>
<div id="chartStatsBySpecies" style="height:300px"></div>
<ul class="funny-list statistics">
<c:forEach items="${statisticsTaxonomy.content}" var="stat" varStatus="status">
<li class="clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}"><span class="stats-number"><fmt:formatNumber value="${stat[1]}" /></span> <a href="<c:url value="/wiews/${faoInstitute.code}/t/${stat[0].genus}/${stat[0].species}" />"><c:out value="${stat[0].taxonName}" /></a></li>
......@@ -187,28 +188,17 @@
var other = 0;
$.each(data, function (idx, statistic) {
if (idx < 9) {
dataFlot[idx] = {
label: statistic[0],
data: statistic[1]
}
} else {
other = statistic[1] + other;
dataFlot[9] = {
label: "Other",
data: other
}
dataFlot[idx] = {
label: statistic[0],
data: statistic[1]
}
});
return dataFlot;
}
$.ajax("/wiews/statJson", {
data: "wiewsCode=" + "${faoInstitute.code}",
$.ajax("/wiews/${faoInstitute.code}/stat-genus", {
success: function (data) {
var placeholder = $('#flot');
var placeholder = $('#chartStatsByGenus');
$("<div id='tooltip'></div>").css({
position: "absolute",
display: "none",
......@@ -221,7 +211,10 @@
$.plot(placeholder, makeDataForFlot(data), {
series: {
pie: {
show: true
show: true,
label: {
show: false
}
}
},
grid: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment