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

Publicaciones por comunidad funcionando

parent 8f7bdcb7
No related branches found
No related tags found
No related merge requests found
......@@ -2,11 +2,11 @@
<div class="col-12">
<div class="row">
<div class="col-5 pl-5 mt-5">
<h1> Visionado publicaciones por Universidad</h1>
<h3> Visionado publicaciones</h3>
<br>
<h3>Shufle Data</h3>
<br>
<button class= "btn btn-outline-primary" (click)="shuffeData()">Graficos</button>
<button class= "btn btn-outline-primary" (click)="Comunidades()">Graficos Por Comunidades</button>
<br> <br>
<button class= "btn btn-outline-primary" (click)="GUniversidades()">Graficos Por Universidad</button>
</div>
<div class="col-5">
......
......@@ -3,6 +3,7 @@ import { ChartDataset, ChartConfiguration} from 'chart.js';
import { NgChartsModule} from 'ng2-charts';
import { UniversidadService } from '../../service/universidad.service';
import { Universidad } from '../../model/universidad';
import { Comunidad } from '../../model/comunidad';
@Component({
selector: 'app-line-chart',
......@@ -11,6 +12,7 @@ import { Universidad } from '../../model/universidad';
})
export class LineChartComponent implements OnInit{
private universidades!: Universidad[]
private comunidades!: Comunidad[]
graphData!: any[]
graphLabels!: any[]
......@@ -26,34 +28,50 @@ export class LineChartComponent implements OnInit{
private UniversidadService: UniversidadService
) {}
ngOnInit():void {
}
Comunidades() {
this.graphData = []
this.UniversidadService.getTotalPorComunidad().subscribe((comunidades: Comunidad[]) =>{
if(comunidades) {
this.comunidades = comunidades
this.createGraphCom()
}
});
this.lineChartLabels = ["Publicaciones"]
}
GUniversidades(){
this.graphData = []
this.UniversidadService.getAllUniversidades().subscribe((universidades: Universidad[]) =>{
if(universidades) {
this.universidades = universidades
this.createGraph()
this.createGraphUniv()
}
});
this.lineChartLabels = ["Publicaciones"]
}
createGraph(){
createGraphCom(){
this.graphData = []
let auxData: number[] = []
for(let uni of this.universidades) {
auxData.push(uni.totalPublicaciones)
this.graphData.push({ data: auxData , label: "Publicaciones " + uni.siglas })
for(let com of this.comunidades) {
auxData.push(com.total)
this.graphData.push({ data: auxData , label: com.comunidad })
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']
createGraphUniv(){
this.graphData = []
let auxData: number[] = []
for(let uni of this.universidades) {
auxData.push(uni.totalPublicaciones)
this.graphData.push({ data: auxData , label: uni.siglas })
auxData=[]
}
this.lineChartData = this.graphData
}
}
export interface Comunidad {
comunidad: string,
total: number
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ import { Universidad } from '../model/universidad';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { Comunidad } from '../model/comunidad';
@Injectable({
providedIn: 'root'
......@@ -14,6 +15,10 @@ export class UniversidadService {
) { }
getAllUniversidades(): Observable<Universidad[]> {
return this.http.get<Universidad[]>(`${environment.url}`)
return this.http.get<Universidad[]>(`${environment.urlAllUniversidades}`)
}
getTotalPorComunidad(): Observable<Comunidad[]> {
return this.http.get<Comunidad[]>(`${environment.urlTotalPorComunidad}`)
}
}
export const environment = {
production: false,
url: 'http://localhost:8000/allUniversidades/' // recoge todas las Universidades
urlAllUniversidades: 'http://localhost:8000/allUniversidades/', // recoge todas las Universidades
urlTotalPorComunidad: 'http://localhost:8000/totalPorComunidad/'
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment