Compare commits

..

2 Commits

5 changed files with 80 additions and 22 deletions

View File

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

View File

@ -39,24 +39,15 @@ export class FractionStatsComponent implements OnInit, OnChanges {
tmpReviveData; tmpReviveData;
tmpStabilizeData; tmpStabilizeData;
tmpFlagCaptureData; tmpFlagCaptureData;
tmpPlayerCountData;
colorScheme = { colorScheme = {
domain: [Fraction.COLOR_BLUFOR, Fraction.COLOR_OPFOR, Fraction.COLOR_BLUFOR_LIGHT, Fraction.COLOR_OPFOR_LIGHT, 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] Fraction.COLOR_BLUFOR_DARK, Fraction.COLOR_OPFOR_DARK, Fraction.COLOR_BLUFOR_GREY, Fraction.COLOR_OPFOR_GREY]
}; };
readonly labels = { labels;
points: 'stats.fraction.select.points', labelsKeys;
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]);
lineChartLabel: string; lineChartLabel: string;
@ -87,8 +78,12 @@ export class FractionStatsComponent implements OnInit, OnChanges {
kill: false, kill: false,
revive: false, revive: false,
transport: false, transport: false,
flag: false flag: false,
playerCount: false
}; };
this.initializeToggleButtons();
Object.assign(this, [this.lineChartData, this.areaChartData]); Object.assign(this, [this.lineChartData, this.areaChartData]);
this.activeChartSelect = this.labels.points; 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) { selectChart(newSelection) {
this.activeChartSelect = newSelection; this.activeChartSelect = newSelection;
if (this.activeChartSelect !== this.labels.flag) { if (this.activeChartSelect !== this.labels.flag) {
@ -136,6 +167,10 @@ export class FractionStatsComponent implements OnInit, OnChanges {
this.initTransportData(); this.initTransportData();
this.lineChartData = this.tmpTransportData; this.lineChartData = this.tmpTransportData;
break; break;
case this.labels.playerCount:
this.initPlayerCountData();
this.lineChartData = this.tmpPlayerCountData;
break;
} }
} else { } else {
this.initFlagHoldData(); this.initFlagHoldData();
@ -347,6 +382,15 @@ export class FractionStatsComponent implements OnInit, OnChanges {
this.initialized.transport = true; this.initialized.transport = true;
} }
initPlayerCountData() {
if (this.initialized.playerCount) {
return;
}
this.addFinalTimeData(this.tmpPlayerCountData);
this.initialized.playerCount = true;
}
initFlagHoldData() { initFlagHoldData() {
if (this.initialized.flag) { if (this.initialized.flag) {
return; return;

View File

@ -36,11 +36,11 @@ export class ServerStatsComponent implements OnInit, OnChanges {
tmpFlagCaptureData; tmpFlagCaptureData;
readonly labels = { readonly labels = {
points: 'stats.fraction.select.points', singleAvg: 'stats.performance.select.single.avg',
budget: 'stats.fraction.select.budget', singleMin: 'stats.performance.select.single.min',
kill: 'stats.fraction.select.kills', avgTimeline: 'stats.performance.select.timeline.avg',
friendlyFire: 'stats.fraction.select.friendly.fire', minTimeline: 'stats.performance.select.timeline.min',
vehicle: 'stats.fraction.select.vehicle.kills', serverFps: 'stats.performance.select.timeline.server',
}; };
readonly labelsAsString = Object.keys(this.labels) readonly labelsAsString = Object.keys(this.labels)
.map((key) => this.labels[key]); .map((key) => this.labels[key]);
@ -62,7 +62,7 @@ export class ServerStatsComponent implements OnInit, OnChanges {
} }
ngOnInit() { ngOnInit() {
this.setLineChartLabel(this.labels.points); this.setLineChartLabel(this.labels.singleAvg);
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
@ -75,7 +75,7 @@ export class ServerStatsComponent implements OnInit, OnChanges {
flag: false flag: false
}; };
Object.assign(this, [this.lineChartData]); Object.assign(this, [this.lineChartData]);
this.activeChartSelect = this.labels.points; this.activeChartSelect = this.labels.singleAvg;
this.startDateObj = new Date(this.war.date); this.startDateObj = new Date(this.war.date);
this.startDateObj.setHours(0); this.startDateObj.setHours(0);

View File

@ -27,6 +27,13 @@
"stats.fraction.select.revive": "Revive", "stats.fraction.select.revive": "Revive",
"stats.fraction.select.stabilize": "Stabilisiert", "stats.fraction.select.stabilize": "Stabilisiert",
"stats.fraction.select.flag": "Flaggenbesitz", "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 FPS Durchschnitt",
"stats.performance.select.timeline.min": "Verlauf FPS Minimum",
"stats.performance.select.timeline.server": "Server FPS",
"stats.player.detail.headline": "Kampagnendetails - {{name}}", "stats.player.detail.headline": "Kampagnendetails - {{name}}",
"stats.player.detail.button.back": "Zurück", "stats.player.detail.button.back": "Zurück",

View File

@ -35,6 +35,13 @@
"stats.fraction.select.revive": "Revive", "stats.fraction.select.revive": "Revive",
"stats.fraction.select.stabilize": "Stabilized", "stats.fraction.select.stabilize": "Stabilized",
"stats.fraction.select.flag": "Flag Possession", "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 FPS Average",
"stats.performance.select.timeline.min": "Timeline FPS Minimum",
"stats.performance.select.timeline.server": "Server FPS",
"stats.player.detail.headline": "Campaign Details - {{name}}", "stats.player.detail.headline": "Campaign Details - {{name}}",
"stats.player.detail.button.back": "Back", "stats.player.detail.button.back": "Back",