Add translations for server stats charts (CC-80)

pull/51/head
HardiReady 2019-02-10 10:33:25 +01:00
parent 1f176e0256
commit 24fcb05f70
3 changed files with 36 additions and 22 deletions

View File

@ -5,10 +5,10 @@ import {ChartUtils} from '../../../utils/chart-utils';
@Component({
selector: 'cc-server-statistics',
templateUrl: './server-stats.component.html',
styleUrls: ['./server-stats.component.css', '../../../style/list-entry.css', '../../../style/hide-scrollbar.css']
})
selector: 'cc-server-statistics',
templateUrl: './server-stats.component.html',
styleUrls: ['./server-stats.component.css', '../../../style/list-entry.css', '../../../style/hide-scrollbar.css']
})
export class ServerStatsComponent implements OnInit, OnChanges {
@ViewChild('overview') private overviewContainer: ElementRef;
@ -42,6 +42,7 @@ export class ServerStatsComponent implements OnInit, OnChanges {
};
readonly labelsAsString = Object.keys(this.labels)
.map((key) => this.labels[key]);
lineChartSeriesLabels;
gradient = false;
yAxis = true;
@ -53,7 +54,7 @@ export class ServerStatsComponent implements OnInit, OnChanges {
autoscale = true;
timeline = false;
roundDomains = true;
colorScheme = {
colorScheme = {
name: 'nightLights',
selectable: false,
group: 'Ordinal',
@ -72,7 +73,13 @@ export class ServerStatsComponent implements OnInit, OnChanges {
ngOnChanges(changes: SimpleChanges) {
if ((changes.war || changes.performanceData) && this.performanceData) {
this.initializeChartData();
this.translate.get([
'stats.performance.select.timeline.label.minimum',
'stats.performance.select.timeline.label.average',
'stats.performance.select.timeline.label.maximum']).subscribe((res) => {
const resValues = Object.keys(res).map(val => res[val]);
this.initializeChartData(resValues[2], resValues[0], resValues[1]);
});
Object.assign(this, [this.barChartData]);
this.activeChartSelect = this.labels.singleAvg;
}
@ -107,10 +114,10 @@ export class ServerStatsComponent implements OnInit, OnChanges {
}
}
initializeChartData() {
this.tmpAvgTimeline = ChartUtils.getMultiDataArray('min', 'avg', 'max');
this.tmpMinTimeline = ChartUtils.getMultiDataArray('min', 'avg', 'max');
this.tmpServerTimeline = ChartUtils.getMultiDataArray('min', 'avg');
initializeChartData(labelMax: string, labelMin: string, labelAvg: string) {
this.tmpAvgTimeline = ChartUtils.getMultiDataArray(labelMax, labelAvg, labelMin);
this.tmpMinTimeline = ChartUtils.getMultiDataArray(labelMax, labelAvg, labelMin);
this.tmpServerTimeline = ChartUtils.getMultiDataArray(labelAvg, labelMin);
const diffMs = (new Date(this.war.endDate).getTime() - new Date(this.war.date).getTime());
const warDurationMinutes = Math.round(diffMs / 60000);
@ -150,33 +157,33 @@ export class ServerStatsComponent implements OnInit, OnChanges {
// SERVER TIMELINE DATA
for (let i = 0; i < entry.avgFps.length && i < warDurationMinutes; i++) {
const currDate = new Date(dateObj.getTime() + i * 60000);
this.tmpServerTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, entry.minFps[i]));
this.tmpServerTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, entry.avgFps[i]));
this.tmpServerTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, entry.avgFps[i]));
this.tmpServerTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, entry.minFps[i]));
}
}
this.tmpSingleAvg.push({
name: entry.entityName,
value: entry.singleAvgFps
});
name: entry.entityName,
value: entry.singleAvgFps
});
this.tmpSingleMin.push({
name: entry.entityName,
value: entry.singleMinFps
});
name: entry.entityName,
value: entry.singleMinFps
});
});
tmpAvgArray = tmpAvgArray.map(x => Math.round(x / this.performanceData.length));
for (let i = 0; i < tmpAvgArray.length; i++) {
const currDate = new Date(dateObj.getTime() + i * 60000);
this.tmpAvgTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgMin[i]));
this.tmpAvgTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgMax[i]));
this.tmpAvgTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgArray[i]));
this.tmpAvgTimeline[2].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgMax[i]));
this.tmpAvgTimeline[2].series.push(ChartUtils.getSeriesEntry(currDate, tmpAvgMin[i]));
}
tmpMinArray = tmpMinArray.map(x => Math.round(x / this.performanceData.length));
for (let i = 0; i < tmpMinArray.length; i++) {
const currDate = new Date(dateObj.getTime() + i * 60000);
this.tmpMinTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinMin[i]));
this.tmpMinTimeline[0].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinMax[i]));
this.tmpMinTimeline[1].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinArray[i]));
this.tmpMinTimeline[2].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinMax[i]));
this.tmpMinTimeline[2].series.push(ChartUtils.getSeriesEntry(currDate, tmpMinMin[i]));
}
this.tmpSingleAvg.sort((a, b) => a.value - b.value);
this.tmpSingleMin.sort((a, b) => a.value - b.value);

View File

@ -34,6 +34,10 @@
"stats.performance.select.timeline.avg": "Verlauf FPS Durchschnitt",
"stats.performance.select.timeline.min": "Verlauf FPS Minimum",
"stats.performance.select.timeline.server": "Server FPS",
"stats.performance.select.timeline.label.minimum": "Minimum",
"stats.performance.select.timeline.label.average": "Mittelwert",
"stats.performance.select.timeline.label.maximum": "Maximum",
"stats.player.detail.headline": "Kampagnendetails - {{name}}",
"stats.player.detail.button.back": "Zurück",

View File

@ -42,6 +42,9 @@
"stats.performance.select.timeline.avg": "Timeline FPS Average",
"stats.performance.select.timeline.min": "Timeline FPS Minimum",
"stats.performance.select.timeline.server": "Server FPS",
"stats.performance.select.timeline.label.minimum": "Minimum",
"stats.performance.select.timeline.label.average": "Average",
"stats.performance.select.timeline.label.maximum": "Maximum",
"stats.player.detail.headline": "Campaign Details - {{name}}",
"stats.player.detail.button.back": "Back",