Add war playerCount + stats
parent
9070964adb
commit
dad3cbe067
|
@ -24,6 +24,18 @@ const WarSchema = new Schema({
|
|||
set: v => Math.round(v),
|
||||
required: true
|
||||
},
|
||||
playersBlufor: {
|
||||
type: Number,
|
||||
get: v => Math.round(v),
|
||||
set: v => Math.round(v),
|
||||
required: true
|
||||
},
|
||||
playersOpfor: {
|
||||
type: Number,
|
||||
get: v => Math.round(v),
|
||||
set: v => Math.round(v),
|
||||
required: true
|
||||
},
|
||||
bestPlayerId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'Player',
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
h3 {
|
||||
width: 920px;
|
||||
margin-bottom: 50px;
|
||||
margin-left: 25%
|
||||
margin-left: 25%;
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
width: 1200px;
|
||||
margin-left: 25%;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<h3>Statistik</h3>
|
||||
<h3>Punkte</h3>
|
||||
|
||||
<div style="width: 1200px; margin-left: 25%">
|
||||
<div class="chart-container">
|
||||
|
||||
<ngx-charts-line-chart
|
||||
[view]="[1050, 400]"
|
||||
[scheme]="colorScheme"
|
||||
[results]="chartData"
|
||||
[results]="playerData"
|
||||
[gradient]="false"
|
||||
[xAxis]="true"
|
||||
[yAxis]="true"
|
||||
|
@ -20,3 +20,26 @@
|
|||
</ngx-charts-line-chart>
|
||||
|
||||
</div>
|
||||
|
||||
<h3 style="margin-top: 370px;">Spielerzahlen</h3>
|
||||
|
||||
<div class="chart-container">
|
||||
|
||||
<ngx-charts-line-chart
|
||||
[view]="[1050, 350]"
|
||||
[scheme]="colorScheme"
|
||||
[results]="pointData"
|
||||
[gradient]="false"
|
||||
[xAxis]="true"
|
||||
[yAxis]="true"
|
||||
[legend]="true"
|
||||
[legendTitle]="''"
|
||||
[showXAxisLabel]="true"
|
||||
[showYAxisLabel]="true"
|
||||
[xAxisLabel]="'Schlachtdatum'"
|
||||
[yAxisLabel]="'Anzahl Spieler'"
|
||||
[autoScale]="true"
|
||||
(select)="onSelect($event)">
|
||||
</ngx-charts-line-chart>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -10,10 +10,11 @@ import {WarService} from "../services/war-service/war.service";
|
|||
})
|
||||
export class StatisticComponent {
|
||||
|
||||
chartData: any[] = [];
|
||||
pointData: any[] = [];
|
||||
playerData: any[] = [];
|
||||
|
||||
colorScheme = {
|
||||
domain: ['#0000FF', '#B22222', '#595DC7', '#B25D62']
|
||||
domain: ['#0000FF', '#B22222']
|
||||
};
|
||||
|
||||
constructor(private appComponent: AppComponent,
|
||||
|
@ -31,7 +32,7 @@ export class StatisticComponent {
|
|||
}
|
||||
|
||||
initChart(wars: any[]) {
|
||||
let updateObj = [
|
||||
let pointsObj = [
|
||||
{
|
||||
"name": "NATO",
|
||||
"series": []
|
||||
|
@ -39,43 +40,49 @@ export class StatisticComponent {
|
|||
{
|
||||
"name": "CSAT",
|
||||
"series": []
|
||||
},
|
||||
{
|
||||
"name": "Anz. Spieler NATO",
|
||||
"series": []
|
||||
},
|
||||
{
|
||||
"name": "Anz. Spieler CSAT",
|
||||
"series": []
|
||||
}];
|
||||
let playersObj = [
|
||||
{
|
||||
"name": "NATO",
|
||||
"series": []
|
||||
},
|
||||
{
|
||||
"name": "CSAT",
|
||||
"series": []
|
||||
}
|
||||
];
|
||||
for (let i = wars.length - 1; i >= 0; i--) {
|
||||
let isoDate = wars[i].date.slice(0, 10);
|
||||
let dayDate = parseInt(isoDate.slice(8, 10)) + 1;
|
||||
let warDateString = (dayDate < 10 ? "0" + dayDate : dayDate) + '.'
|
||||
const isoDate = wars[i].date.slice(0, 10);
|
||||
const dayDate = parseInt(isoDate.slice(8, 10)) + 1;
|
||||
const warDateString = (dayDate < 10 ? "0" + dayDate : dayDate) + '.'
|
||||
+ isoDate.slice(5, 7) + '.' + isoDate.slice(0, 4);
|
||||
let bluforData = {
|
||||
|
||||
const bluforData = {
|
||||
name: warDateString,
|
||||
value: wars[i].ptBlufor
|
||||
};
|
||||
updateObj[0].series.push(bluforData);
|
||||
let opforData = {
|
||||
const opforData = {
|
||||
name: warDateString,
|
||||
value: wars[i].ptOpfor
|
||||
};
|
||||
updateObj[1].series.push(opforData);
|
||||
let bluforPlayers = {
|
||||
const bluforPlayers = {
|
||||
name: warDateString,
|
||||
value: 13
|
||||
value: wars[i].playersBlufor
|
||||
};
|
||||
updateObj[2].series.push(bluforPlayers);
|
||||
let opforPlayers = {
|
||||
const opforPlayers = {
|
||||
name: warDateString,
|
||||
value: 13
|
||||
value: wars[i].playersOpfor
|
||||
};
|
||||
updateObj[3].series.push(opforPlayers);
|
||||
|
||||
playersObj[0].series.push(bluforData);
|
||||
playersObj[1].series.push(opforData);
|
||||
pointsObj[0].series.push(bluforPlayers);
|
||||
pointsObj[1].series.push(opforPlayers);
|
||||
}
|
||||
this.chartData = updateObj;
|
||||
Object.assign(this, this.chartData)
|
||||
|
||||
this.pointData = pointsObj;
|
||||
this.playerData = playersObj;
|
||||
Object.assign(this, [this.playerData, this.pointData])
|
||||
}
|
||||
|
||||
onSelect(event) {
|
||||
|
|
Loading…
Reference in New Issue