Browse Source

fix stats

master
drfelfel 1 year ago
parent
commit
eb970b4cc5
2 changed files with 78 additions and 72 deletions
  1. +4
    -6
      src/routes/panel/dashboard/app/app.component.html
  2. +74
    -66
      src/routes/panel/dashboard/app/app.component.ts

+ 4
- 6
src/routes/panel/dashboard/app/app.component.html View File

@ -1,4 +1,4 @@
<div class="selector">
<div class="selector" *ngIf="false">
<mat-form-field appearance="outline">
<mat-label>انتخاب مرکز / دانشگاه</mat-label>
@ -16,9 +16,7 @@
</div>
<p>
به دلیل شرایط توسعه و کانورت اطلاعات این سیستم در حالت توسعه شدید است. از دستکاری اطلاعات در حالت دمو خود داری کنید
</p>
<section>
<ng-container *ngFor="let item of data">
<div class="stats">
@ -35,8 +33,8 @@
[data]="item"
[type]="item.type"
[options]="options"
width="500"
height="250"
width="800"
height="400"
></ngx-chartjs>
</mat-card-content>
</mat-card>

+ 74
- 66
src/routes/panel/dashboard/app/app.component.ts View File

@ -3,7 +3,6 @@ import { MatDialog } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { DialogComponent } from '../dialog/dialog.component';
import { Rayconnect } from '../../../../services/rayconnect/rayconnect.service';
import * as moment from 'jalali-moment';
import { Chart } from 'chart.js'
import { FormControl } from '@angular/forms';
@ -29,14 +28,7 @@ export class AppComponent implements OnInit {
universityControl = new FormControl();
univeristygroups: UniversityGroup[] = [
{
name: 'تهران',
value: "tehran",
universities: [
{ value: 'ps1', viewValue: 'مرکز پسران ۱' },
{ value: 'ps2', viewValue: 'مرکز پسران ۲' },
]
},
{
name: 'مرکزی',
value: "markazi",
@ -54,31 +46,8 @@ export class AppComponent implements OnInit {
responsive: true,
}
data: any = [{
labels: ['داوطلبین', 'در مرحله تایید کارشناس', 'تایید شده', 'مرحله خوابگاه', 'اتمام ثبت نام', 'اشکال در ثبت نام'],
type: "bar",
datasets: [{
label: 'آمار کاربران کاتب',
data: [40, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.9)',
'rgba(54, 162, 235, 0.9)',
'rgba(255, 206, 86, 0.9)',
'rgba(75, 192, 192, 0.9)',
'rgba(153, 102, 255, 0.9)',
'rgba(255, 159, 64, 0.9)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
}];
data: any = []
constructor(private dialog: MatDialog, private rayconnect: Rayconnect, private snackbar: MatSnackBar) { }
@ -89,8 +58,48 @@ export class AppComponent implements OnInit {
this.universityControl.setValue("all")
this.subscribe()
let cachedColor = null
let cachedLabel = null
this.rayconnect.Query({
scope: "kateb",
address: "volunteers/stats/live",
method: "LIVE",
}, (res => {
if (!cachedColor) cachedColor = this.RandomColor(res['data']['counts'].length)
if (!cachedLabel) cachedLabel = res['data']['counts'].map((major) => {
return major._id
}),
this.buildMajorsStats(res['data']['counts'], cachedColor, cachedLabel)
}));
}
subscribe() {
this.rayconnect.RequestBack({
scope: 'kateb',
uniqueID: 'profile',
TokenID: '*',
address: 'volunteers/stats/subscribe',
info: {
method: 'SUB',
data: {
}
}
}).then(res => {
if (res['data']['status'] == true) { }
})
}
RandomColor(len) {
@ -104,25 +113,23 @@ export class AppComponent implements OnInit {
return colors
}
buildMajorsStats(majors) {
buildMajorsStats(majors, colors, labels) {
this.data[1] = {
labels: majors.map((major) => {
return major.name
}),
this.data[0] = {
labels: labels,
type: "doughnut",
datasets: [{
label: 'تعداد ثبت نام تایید شده در مرحله پنجم (آموزش)',
data: majors.map(() => {
return Math.floor(Math.random() * 6) + 1
label: 'تعداد ثبت نامی به تفکیک رشته',
data: majors.map((major) => {
return major.count
}),
backgroundColor: this.RandomColor(majors.length),
backgroundColor: colors,
borderWidth: 1
}]
}
this.data[2] = {
/* this.data[2] = {
labels: majors.map((major) => {
return major.name
}),
@ -135,9 +142,9 @@ export class AppComponent implements OnInit {
backgroundColor: this.RandomColor(majors.length),
borderWidth: 1
}]
}
} */
this.data[3] = {
/* this.data[3] = {
labels: majors.map((major) => {
return major.name
}),
@ -153,29 +160,30 @@ export class AppComponent implements OnInit {
}
*/
let labels = []
let m = moment()
for (let index = 0; index < 10; index++) {
m = m.add(1, 'd')
labels.push(m.format('jYYYY/jM/jD'));
/* let labels = []
let m = moment()
for (let index = 0; index < 10; index++) {
m = m.add(1, 'd')
labels.push(m.format('jYYYY/jM/jD'));
}
this.data[4] = {
labels: labels,
type: "line",
datasets: [{
label: 'آمار مراجعات حضوری بر اساس تاریخ',
data: labels.map((da) => {
return Math.floor(Math.random() * 6) + 1;
}),
borderColor: 'rgb(75, 192, 192)',
lineTension: 0.1,
borderWidth: 1
}]
}
/* this.data[4] = {
labels: labels,
type: "line",
datasets: [{
label: 'آمار مراجعات حضوری بر اساس تاریخ',
data: labels.map((da) => {
return Math.floor(Math.random() * 6) + 1;
}),
borderColor: 'rgb(75, 192, 192)',
lineTension: 0.1,
borderWidth: 1
}]
}
} */
}
@ -190,7 +198,7 @@ export class AppComponent implements OnInit {
data: {}
}
}).then(res => {
if (res['data']['status'] == true) this.buildMajorsStats(res[';data']['result'])
if (res['data']['status'] == true) return;
})
}

Loading…
Cancel
Save