Skip to content
Snippets Groups Projects
Commit ef260aa4 authored by ramoncalabozo's avatar ramoncalabozo
Browse files

Primera versión de barchart

parent e107f38b
No related branches found
No related tags found
No related merge requests found
package controller;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
......@@ -24,6 +26,10 @@ public class UniversidadController {
@GetMapping(value = "allUniversidades", produces = MediaType.APPLICATION_JSON_VALUE)
public List<Universidad> getUniversidades() {
return this.universidadService.getAllUniversidadades();
/*List<Universidad> uni = new ArrayList<Universidad>();
uni.add(this.universidadService.getAllUniversidadades().get(0));
uni.add(this.universidadService.getAllUniversidadades().get(1));
return uni;*/
return universidadService.getAllUniversidadades();
}
}
......@@ -11,42 +11,49 @@ import { Universidad } from '../../model/universidad';
})
export class LineChartComponent implements OnInit{
private universidades!: Universidad[]
lineChartData: ChartDataset[] = [ // Datos
{ data: [12, 72, 78, 75, 17, 75], label: 'Crude oil prices' },
{ data: [85, 12, 28, 85, 17, 75], label: 'Another crud' }
];
lineChartLabels = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio'];
graphData!: any[]
graphLabels!: any[]
// Estos datos están aquí por defecto
lineChartData: ChartDataset[] = [];
lineChartLabels:string[] = [];
lineChartOptions = { responsive: true, };
lineChartLegend = true;
lineChartPlugins = [];
lineChartType = 'line';
constructor(
private UniversidadService: UniversidadService
) {}
ngOnInit():void {
this.getUniversidades();
this.graphData = []
this.UniversidadService.getAllUniversidades().subscribe((universidades: Universidad[]) =>{
if(universidades) {
this.universidades = universidades
this.createGraph()
}
getUniversidades(){
this.UniversidadService.getAllUniversidades().subscribe((d) =>{
// console.log(d);
/*this.lineChartData = [ // Datos
{ data: [12, 72, 78, 75, 17, 75], label: 'Crude oil prices' },
{ data: [85, 12, 28, 85, 17, 75], label: 'Another crud' }
];*/
});
}
createGraph(){
this.graphData = []
let auxData: number[] = []
for(let uni of this.universidades) {
auxData.push(uni.totalPublicaciones)
this.graphData.push({ data: auxData , label: "Publicaciones " + uni.siglas })
auxData=[]
}
this.lineChartData = this.graphData
this.lineChartLabels = ["Total Publicaciones"]
}
shuffeData() {
this.lineChartData = [ // Datos
{ data: [12, 72, 78, 75, 17, 75], label: 'Crude oil prices' },
{ data: [85, 12, 28, 85, 17, 75], label: 'Another crud' }
];
this.lineChartLabels = ['Enero', 'Febrero',' Marzo', 'Abril', 'Mayo', 'Junio']
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment