From e6d1f7c5ba8e7deb1b33e35191b5a7aca6620e83 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sat, 2 Sep 2017 10:43:23 +0200 Subject: [PATCH] Add summed up points graph --- package.json | 2 +- .../overview/stats-overview.component.html | 35 ++++++++++--- .../overview/stats-overview.component.ts | 49 +++++++++++++------ 3 files changed, 63 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 004bca1..b9b8dd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opt-cc", - "version": "1.3.1", + "version": "1.3.2", "license": "MIT", "private": true, "scripts": { diff --git a/static/src/app/statistic/overview/stats-overview.component.html b/static/src/app/statistic/overview/stats-overview.component.html index d6c6c1d..0f8cfcb 100644 --- a/static/src/app/statistic/overview/stats-overview.component.html +++ b/static/src/app/statistic/overview/stats-overview.component.html @@ -1,13 +1,13 @@

{{title}}

-

Punkte

+

Gesamtpunktzahl

+ [yAxisLabel]="'Gesamtpunkte'" + [autoScale]="true" + (select)="onSelect($event)">
-

Spielerzahlen

+

Punkte je Schlacht

@@ -38,6 +39,28 @@ [showXAxisLabel]="true" [showYAxisLabel]="true" [xAxisLabel]="'Schlachtdatum'" + [yAxisLabel]="'Punkte'" + [autoScale]="false"> + + +
+ +

Spielerzahlen

+ +
+ + diff --git a/static/src/app/statistic/overview/stats-overview.component.ts b/static/src/app/statistic/overview/stats-overview.component.ts index 138c62e..0d5e17a 100644 --- a/static/src/app/statistic/overview/stats-overview.component.ts +++ b/static/src/app/statistic/overview/stats-overview.component.ts @@ -1,7 +1,5 @@ import {Component} from "@angular/core"; import {WarService} from "../../services/war-service/war.service"; -import {Campaign, War} from "../../models/model-interfaces"; -import {WarListComponent} from "../war-list/war-list.component"; import {ActivatedRoute} from "@angular/router"; @@ -16,6 +14,7 @@ export class StatisticOverviewComponent { title = ""; pointData: any[] = []; + pointSumData: any[] = []; playerData: any[] = []; colorScheme = { @@ -69,6 +68,15 @@ export class StatisticOverviewComponent { "name": "CSAT", "series": [] }]; + let pointsSumObj = [ + { + "name": "NATO", + "series": [] + }, + { + "name": "CSAT", + "series": [] + }]; let playersObj = [ { "name": "NATO", @@ -80,37 +88,46 @@ export class StatisticOverviewComponent { } ]; for (let i = wars.length - 1; i >= 0; i--) { + let j = wars.length - i - 1; 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); - const bluforData = { + pointsObj[0].series.push({ name: warDateString, value: wars[i].ptBlufor - }; - const opforData = { + }); + pointsObj[1].series.push({ name: warDateString, value: wars[i].ptOpfor - }; - const bluforPlayers = { + }); + pointsSumObj[0].series.push({ + name: warDateString, + value: pointsSumObj[0].series[j - 1] ? + pointsSumObj[0].series[j - 1].value + wars[i].ptBlufor : + wars[i].ptBlufor + }); + pointsSumObj[1].series.push({ + name: warDateString, + value: pointsSumObj[1].series[j - 1] + ? pointsSumObj[1].series[j - 1].value + wars[i].ptOpfor : + wars[i].ptOpfor + }); + playersObj[0].series.push({ name: warDateString, value: wars[i].playersBlufor - }; - const opforPlayers = { + }); + playersObj[1].series.push({ name: warDateString, value: wars[i].playersOpfor - }; - - playersObj[0].series.push(bluforData); - playersObj[1].series.push(opforData); - pointsObj[0].series.push(bluforPlayers); - pointsObj[1].series.push(opforPlayers); + }); } this.pointData = pointsObj; + this.pointSumData = pointsSumObj; this.playerData = playersObj; - Object.assign(this, [this.playerData, this.pointData]) + Object.assign(this, [this.pointData, this.pointSumData, this.playerData]) } }