Use min interval for fraction stats
parent
8f34d44139
commit
4ea1239a75
|
@ -97,23 +97,24 @@
|
|||
<img src="../../../assets/fraction-btn.png"> Fraktionen
|
||||
</ng-template>
|
||||
|
||||
<div class="btn-group" style="position: absolute; margin-left: 5%;" dropdown>
|
||||
<button dropdownToggle type="button" class="btn btn-default dropdown-toggle dropdown-toggle-split">
|
||||
{{dataMode}} <span class="caret"></span>
|
||||
</button>
|
||||
<ul *dropdownMenu class="dropdown-menu" role="menu">
|
||||
<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(0, 'Summe')">Summe</a></li>
|
||||
<li class="divider dropdown-divider"></li>
|
||||
<li class="disabled" role="menuitem">
|
||||
<a class="dropdown-item" style="cursor: default!important;">Interval:</a>
|
||||
</li>
|
||||
<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(5, '5 Minuten')">5 Minuten</a></li>
|
||||
<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(10, '10 Minuten')">10 Minuten</a>
|
||||
<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(20, '20 Minuten')">20 Minuten</a>
|
||||
<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(40, '40 Minuten')">40 Minuten</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--<div class="btn-group" style="position: absolute; margin-left: 5%;" dropdown>-->
|
||||
<!--<button dropdownToggle type="button" class="btn btn-default dropdown-toggle dropdown-toggle-split">-->
|
||||
<!--{{dataMode}} <span class="caret"></span>-->
|
||||
<!--</button>-->
|
||||
<!--<ul *dropdownMenu class="dropdown-menu" role="menu">-->
|
||||
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(0, 'Summe')">Summe</a></li>-->
|
||||
<!--<li class="divider dropdown-divider"></li>-->
|
||||
<!--<li class="disabled" role="menuitem">-->
|
||||
<!--<a class="dropdown-item" style="cursor: default!important;">Interval:</a>-->
|
||||
<!--</li>-->
|
||||
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(1, '1 Minute')">1 Minute</a></li>-->
|
||||
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(5, '5 Minuten')">5 Minuten</a></li>-->
|
||||
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(10, '10 Minuten')">10 Minuten</a>-->
|
||||
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(20, '20 Minuten')">20 Minuten</a>-->
|
||||
<!--<li role="menuitem"><a class="dropdown-item" (click)="toggleDataMode(40, '40 Minuten')">40 Minuten</a>-->
|
||||
<!--</li>-->
|
||||
<!--</ul>-->
|
||||
<!--</div>-->
|
||||
|
||||
<div class="chart-select-group btn-group" (click)="selectChart()">
|
||||
<label class="btn btn-default" [(ngModel)]="chartSelectModel" btnRadio="{{labelPoints}}">{{labelPoints}}</label>
|
||||
|
|
|
@ -79,7 +79,11 @@ export class WarDetailComponent {
|
|||
roundDomains = true;
|
||||
fractionChartsInitialized: boolean = false;
|
||||
|
||||
startDateObj;
|
||||
|
||||
dataMode: string = 'Summe';
|
||||
dataInterval: number = 0;
|
||||
logData;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
|
@ -101,6 +105,10 @@ export class WarDetailComponent {
|
|||
Object.assign(this, [this.playerChart, this.lineChartData, this.areaChartData]);
|
||||
this.chartSelectModel = this.labelPoints;
|
||||
|
||||
this.startDateObj = new Date(this.war.date);
|
||||
this.startDateObj.setHours(0);
|
||||
this.startDateObj.setMinutes(1);
|
||||
|
||||
this.fractionRadioSelect = undefined;
|
||||
this.staticTabs.tabs[0].active = true;
|
||||
this.scrollOverviewTop();
|
||||
|
@ -165,7 +173,10 @@ export class WarDetailComponent {
|
|||
}
|
||||
|
||||
toggleDataMode(interval, entryString) {
|
||||
this.dataInterval = interval;
|
||||
this.dataMode = entryString;
|
||||
this.initTransportData();
|
||||
this.lineChartData = this.tmpTransportData;
|
||||
}
|
||||
|
||||
loadFractionData() {
|
||||
|
@ -182,120 +193,151 @@ export class WarDetailComponent {
|
|||
this.tmpStabilizeData = ChartUtils.getMultiDataArray('NATO', 'CSAT');
|
||||
this.tmpFlagCaptureData = ChartUtils.getMultiDataArray('NATO', 'CSAT');
|
||||
|
||||
const newFractionGraphEntry = (entry: any, val1: any, val2: any) => {
|
||||
return ChartUtils.getSeriesEntry(new Date(entry.time), entry.fraction === 'BLUFOR' ? val1 : val2);
|
||||
};
|
||||
|
||||
const startDateObj = new Date(this.war.date);
|
||||
startDateObj.setHours(0);
|
||||
startDateObj.setMinutes(1);
|
||||
|
||||
[this.tmpKillData, this.tmpFrienlyFireData, this.tmpReviveData, this.tmpStabilizeData, this.tmpTransportData].forEach(tmp => {
|
||||
[0, 1].forEach(index => {
|
||||
tmp[index].series.push(ChartUtils.getSeriesEntry(startDateObj, 0));
|
||||
tmp[index].series.push(ChartUtils.getSeriesEntry(this.startDateObj, 0));
|
||||
})
|
||||
});
|
||||
|
||||
let killCountBlufor = 0, killCountOpfor = 0, ffKillCountBlufor = 0, ffKillCountOpfor = 0, reviveCountBlufor = 0,
|
||||
reviveCountOpfor = 0, stabilizeCountBlufor = 0, stabilizeCountOpfor = 0, transportCountBlufor = 0,
|
||||
transportCountOpfor = 0;
|
||||
|
||||
this.logsService.getFullLog(this.war._id).subscribe((data) => {
|
||||
// POINTS
|
||||
data.points.forEach(pointEntry => {
|
||||
this.logData = data;
|
||||
|
||||
this.initPointData();
|
||||
this.initBudgetData();
|
||||
|
||||
this.initKillData();
|
||||
|
||||
this.initRevive();
|
||||
|
||||
|
||||
this.initTransportData();
|
||||
|
||||
this.initFlagHoldData();
|
||||
|
||||
this.addFinalTimeDataEntriesAndPopulate(new Date(this.war.endDate));
|
||||
|
||||
this.fractionChartsInitialized = true;
|
||||
});
|
||||
}
|
||||
|
||||
initPointData() {
|
||||
this.logData.points.forEach(pointEntry => {
|
||||
this.tmpPointData[0].series.push(ChartUtils.getSeriesEntry(new Date(pointEntry.time), pointEntry.ptBlufor));
|
||||
this.tmpPointData[1].series.push(ChartUtils.getSeriesEntry(new Date(pointEntry.time), pointEntry.ptOpfor));
|
||||
});
|
||||
}
|
||||
|
||||
// BUDGET
|
||||
this.tmpBudgetData[0].series.push(ChartUtils.getSeriesEntry(startDateObj, this.war.budgetBlufor));
|
||||
this.tmpBudgetData[1].series.push(ChartUtils.getSeriesEntry(startDateObj, this.war.budgetOpfor));
|
||||
initBudgetData() {
|
||||
this.tmpBudgetData[0].series.push(ChartUtils.getSeriesEntry(this.startDateObj, this.war.budgetBlufor));
|
||||
this.tmpBudgetData[1].series.push(ChartUtils.getSeriesEntry(this.startDateObj, this.war.budgetOpfor));
|
||||
// This adds an entry for both fractions on every event
|
||||
for (let i = 0; i < data.budget.length; i++) {
|
||||
const budgetEntry = data.budget[i];
|
||||
for (let i = 0; i < this.logData.budget.length; i++) {
|
||||
const budgetEntry = this.logData.budget[i];
|
||||
const fractionChange = budgetEntry.fraction === 'BLUFOR' ? 0 : 1;
|
||||
const fractionOld = budgetEntry.fraction !== 'BLUFOR' ? 0 : 1;
|
||||
|
||||
if (WarDetailComponent.isTwoMinutesAhead(budgetEntry, this.tmpBudgetData, i, this.logData.budget.length)) {
|
||||
this.tmpBudgetData[fractionChange].series.push(ChartUtils.getSeriesEntry(new Date(budgetEntry.time), budgetEntry.newBudget));
|
||||
this.tmpBudgetData[fractionOld].series.push(ChartUtils.getSeriesEntry(new Date(budgetEntry.time),
|
||||
this.tmpBudgetData[fractionOld].series[this.tmpBudgetData[fractionOld].series.length - 1].value));
|
||||
}
|
||||
}
|
||||
this.tmpBudgetData[0].series.push(ChartUtils.getSeriesEntry(new Date(this.war.endDate), this.war.endBudgetBlufor));
|
||||
this.tmpBudgetData[1].series.push(ChartUtils.getSeriesEntry(new Date(this.war.endDate), this.war.endBudgetOpfor));
|
||||
}
|
||||
|
||||
// KILLS & FRIENDLY FIRE
|
||||
data.kill.forEach(killEntry => {
|
||||
initKillData() {
|
||||
let killCountBlufor = 0, killCountOpfor = 0, ffKillCountBlufor = 0, ffKillCountOpfor = 0
|
||||
for (let i = 0; i < this.logData.kill.length; i++) {
|
||||
const killEntry = this.logData.kill[i];
|
||||
if (killEntry.friendlyFire === false) {
|
||||
if (killEntry.fraction === 'BLUFOR') {
|
||||
killCountBlufor++;
|
||||
} else {
|
||||
killCountOpfor++;
|
||||
}
|
||||
if (WarDetailComponent.isTwoMinutesAhead(killEntry, this.tmpKillData, i, this.logData.kill.length)) {
|
||||
this.tmpKillData[0].series.push(ChartUtils.getSeriesEntry(new Date(killEntry.time), killCountBlufor));
|
||||
this.tmpKillData[1].series.push(ChartUtils.getSeriesEntry(new Date(killEntry.time), killCountOpfor));
|
||||
}
|
||||
} else {
|
||||
if (killEntry.fraction === 'BLUFOR') {
|
||||
ffKillCountBlufor++;
|
||||
} else {
|
||||
ffKillCountOpfor++;
|
||||
}
|
||||
if (WarDetailComponent.isTwoMinutesAhead(killEntry, this.tmpFrienlyFireData, i, this.logData.kill.length)) {
|
||||
this.tmpFrienlyFireData[0].series.push(ChartUtils.getSeriesEntry(new Date(killEntry.time), ffKillCountBlufor));
|
||||
this.tmpFrienlyFireData[1].series.push(ChartUtils.getSeriesEntry(new Date(killEntry.time), ffKillCountOpfor));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// REVIVE & STABILIZE
|
||||
data.revive.forEach(reviveEntry => {
|
||||
initRevive() {
|
||||
let reviveCountBlufor = 0, reviveCountOpfor = 0, stabilizeCountBlufor = 0, stabilizeCountOpfor = 0;
|
||||
for (let i = 0; i < this.logData.revive.length; i++) {
|
||||
const reviveEntry = this.logData.revive[i];
|
||||
if (reviveEntry.stabilized === false) {
|
||||
if (reviveEntry.fraction === 'BLUFOR') {
|
||||
reviveCountBlufor++;
|
||||
} else {
|
||||
reviveCountOpfor++;
|
||||
}
|
||||
if (WarDetailComponent.isTwoMinutesAhead(reviveEntry, this.tmpReviveData, i, this.logData.revive.length)) {
|
||||
this.tmpReviveData[0].series.push(ChartUtils.getSeriesEntry(new Date(reviveEntry.time), reviveCountBlufor));
|
||||
this.tmpReviveData[1].series.push(ChartUtils.getSeriesEntry(new Date(reviveEntry.time), reviveCountOpfor));
|
||||
}
|
||||
} else {
|
||||
if (reviveEntry.fraction === 'BLUFOR') {
|
||||
stabilizeCountBlufor++;
|
||||
} else {
|
||||
stabilizeCountOpfor++;
|
||||
}
|
||||
if (WarDetailComponent.isTwoMinutesAhead(reviveEntry, this.tmpStabilizeData, i, this.logData.revive.length)) {
|
||||
this.tmpStabilizeData[0].series.push(ChartUtils.getSeriesEntry(new Date(reviveEntry.time), stabilizeCountBlufor));
|
||||
this.tmpStabilizeData[1].series.push(ChartUtils.getSeriesEntry(new Date(reviveEntry.time), stabilizeCountOpfor));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TRANSPORT
|
||||
data.transport.forEach(transportEntry => {
|
||||
initTransportData() {
|
||||
let transportCountBlufor = 0, transportCountOpfor = 0;
|
||||
for (let i = 0; i < this.logData.transport.length; i++) {
|
||||
const transportEntry = this.logData.transport[i];
|
||||
if (transportEntry.fraction === 'BLUFOR') {
|
||||
transportCountBlufor++;
|
||||
} else {
|
||||
transportCountOpfor++;
|
||||
}
|
||||
if (WarDetailComponent.isTwoMinutesAhead(transportEntry, this.tmpTransportData, i, this.logData.transport.length)) {
|
||||
this.tmpTransportData[0].series.push(ChartUtils.getSeriesEntry(new Date(transportEntry.time), transportCountBlufor));
|
||||
this.tmpTransportData[1].series.push(ChartUtils.getSeriesEntry(new Date(transportEntry.time), transportCountOpfor));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FLAG
|
||||
initFlagHoldData() {
|
||||
let flagStatusBlufor = true;
|
||||
let flagStatusOpfor = true;
|
||||
this.tmpFlagCaptureData[0].series.push(ChartUtils.getSeriesEntry(startDateObj, flagStatusBlufor));
|
||||
this.tmpFlagCaptureData[1].series.push(ChartUtils.getSeriesEntry(startDateObj, flagStatusOpfor));
|
||||
this.tmpFlagCaptureData[0].series.push(ChartUtils.getSeriesEntry(this.startDateObj, flagStatusBlufor));
|
||||
this.tmpFlagCaptureData[1].series.push(ChartUtils.getSeriesEntry(this.startDateObj, flagStatusOpfor));
|
||||
|
||||
data.flag.forEach(flagEntry => {
|
||||
this.logData.flag.forEach(flagEntry => {
|
||||
if (flagEntry.flagFraction === 'BLUFOR') {
|
||||
flagStatusBlufor = !flagEntry.capture
|
||||
} else {
|
||||
flagStatusOpfor = !flagEntry.capture;
|
||||
}
|
||||
this.tmpFlagCaptureData[flagEntry.flagFraction === 'BLUFOR' ? 0 : 1].series.push(
|
||||
newFractionGraphEntry(flagEntry, flagStatusBlufor, flagStatusOpfor)
|
||||
);
|
||||
ChartUtils.getSeriesEntry(new Date(flagEntry.time), flagEntry.fraction === 'BLUFOR' ? flagStatusBlufor : flagStatusOpfor)
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
this.addFinalTimeDataEntriesAndPopulate(new Date(this.war.endDate));
|
||||
|
||||
this.fractionChartsInitialized = true;
|
||||
});
|
||||
private static isTwoMinutesAhead(entry: any, tmpData: any, index: number, logDataLength: number): boolean {
|
||||
return new Date(entry.time).getTime() >= tmpData[0].series[tmpData[0].series.length - 1].name.getTime() + (1.5 * 60000) || index === logDataLength - 1
|
||||
}
|
||||
|
||||
addFinalTimeDataEntriesAndPopulate(endDate) {
|
||||
|
|
Loading…
Reference in New Issue