Prepare fraction stats page select buttons for alternating data availability

pull/51/head
HardiReady 2019-02-08 22:34:50 +01:00
parent 2d64c32598
commit 712071865f
4 changed files with 65 additions and 19 deletions

View File

@ -4,8 +4,8 @@
#group="matButtonToggleGroup"
[(ngModel)]="activeChartSelect"
(change)="selectChart(group.value)">
<mat-button-toggle *ngFor="let label of labelsAsString" value="{{label}}">
{{label | translate}}
<mat-button-toggle *ngFor="let labelKey of labelsKeys" value="{{labels[labelKey]}}">
{{labels[labelKey] | translate}}
</mat-button-toggle>
</mat-button-toggle-group>

View File

@ -39,24 +39,15 @@ export class FractionStatsComponent implements OnInit, OnChanges {
tmpReviveData;
tmpStabilizeData;
tmpFlagCaptureData;
tmpPlayerCountData;
colorScheme = {
domain: [Fraction.COLOR_BLUFOR, Fraction.COLOR_OPFOR, Fraction.COLOR_BLUFOR_LIGHT, Fraction.COLOR_OPFOR_LIGHT,
Fraction.COLOR_BLUFOR_DARK, Fraction.COLOR_OPFOR_DARK, Fraction.COLOR_BLUFOR_GREY, Fraction.COLOR_OPFOR_GREY]
};
readonly labels = {
points: 'stats.fraction.select.points',
budget: 'stats.fraction.select.budget',
kill: 'stats.fraction.select.kills',
friendlyFire: 'stats.fraction.select.friendly.fire',
vehicle: 'stats.fraction.select.vehicle.kills',
transport: 'stats.fraction.select.air.transport',
revive: 'stats.fraction.select.revive',
stabilize: 'stats.fraction.select.stabilize',
flag: 'stats.fraction.select.flag'
};
readonly labelsAsString = Object.keys(this.labels).map((key) => this.labels[key]);
labels;
labelsKeys;
lineChartLabel: string;
@ -87,8 +78,12 @@ export class FractionStatsComponent implements OnInit, OnChanges {
kill: false,
revive: false,
transport: false,
flag: false
flag: false,
playerCount: false
};
this.initializeToggleButtons();
Object.assign(this, [this.lineChartData, this.areaChartData]);
this.activeChartSelect = this.labels.points;
@ -99,6 +94,42 @@ export class FractionStatsComponent implements OnInit, OnChanges {
}
}
/**
* show only labels for for data that is available,
* to not end up with empty charts in old battles
*/
initializeToggleButtons() {
const newLabels = {};
if (this.logData.points && this.logData.points.length > 0) {
newLabels['points'] = 'stats.fraction.select.points';
}
if (this.logData.budget && this.logData.budget.length > 0) {
newLabels['budget'] = 'stats.fraction.select.budget';
}
if (this.logData.kill && this.logData.kill.length > 0) {
newLabels['kill'] = 'stats.fraction.select.kills';
newLabels['friendlyFire'] = 'stats.fraction.select.friendly.fire';
}
if (this.logData.vehicle && this.logData.vehicle.length > 0) {
newLabels['vehicle'] = 'stats.fraction.select.vehicle.kills';
}
if (this.logData.transport && this.logData.transport.length > 0) {
newLabels['transport'] = 'stats.fraction.select.air.transport';
}
if (this.logData.revive && this.logData.revive.length > 0) {
newLabels['revive'] = 'stats.fraction.select.revive';
newLabels['stabilize'] = 'stats.fraction.select.stabilize';
}
if (this.logData.flag && this.logData.flag.length > 0) {
newLabels['flag'] = 'stats.fraction.select.flag';
}
if (this.logData.playerCount && this.logData.playerCount.length > 0) {
newLabels['playerCount'] = 'stats.fraction.select.player.count';
}
this.labels = newLabels;
this.labelsKeys = Object.keys(this.labels);
}
selectChart(newSelection) {
this.activeChartSelect = newSelection;
if (this.activeChartSelect !== this.labels.flag) {
@ -136,6 +167,10 @@ export class FractionStatsComponent implements OnInit, OnChanges {
this.initTransportData();
this.lineChartData = this.tmpTransportData;
break;
case this.labels.playerCount:
this.initPlayerCountData();
this.lineChartData = this.tmpPlayerCountData;
break;
}
} else {
this.initFlagHoldData();
@ -347,6 +382,15 @@ export class FractionStatsComponent implements OnInit, OnChanges {
this.initialized.transport = true;
}
initPlayerCountData() {
if (this.initialized.playerCount) {
return;
}
this.addFinalTimeData(this.tmpPlayerCountData);
this.initialized.playerCount = true;
}
initFlagHoldData() {
if (this.initialized.flag) {
return;

View File

@ -27,11 +27,12 @@
"stats.fraction.select.revive": "Revive",
"stats.fraction.select.stabilize": "Stabilisiert",
"stats.fraction.select.flag": "Flaggenbesitz",
"stats.fraction.select.player.count": "Spieleranzahl",
"stats.performance.select.single.avg": "Spieler FPS Durchschnitt",
"stats.performance.select.single.min": "Spieler FPS Minimum",
"stats.performance.select.timeline.avg": "Verlauf Gesamt FPS",
"stats.performance.select.timeline.min": "Verlauf Minimum FPS",
"stats.performance.select.timeline.avg": "Verlauf FPS Durchschnitt",
"stats.performance.select.timeline.min": "Verlauf FPS Minimum",
"stats.performance.select.timeline.server": "Server FPS",
"stats.player.detail.headline": "Kampagnendetails - {{name}}",

View File

@ -35,11 +35,12 @@
"stats.fraction.select.revive": "Revive",
"stats.fraction.select.stabilize": "Stabilized",
"stats.fraction.select.flag": "Flag Possession",
"stats.fraction.select.player.count": "Player Count",
"stats.performance.select.single.avg": "Player FPS Average",
"stats.performance.select.single.min": "Player FPS Minimum",
"stats.performance.select.timeline.avg": "Timeline Overall FPS",
"stats.performance.select.timeline.min": "Timeline Minimum FPS",
"stats.performance.select.timeline.avg": "Timeline FPS Average",
"stats.performance.select.timeline.min": "Timeline FPS Minimum",
"stats.performance.select.timeline.server": "Server FPS",
"stats.player.detail.headline": "Campaign Details - {{name}}",