Optimize graph printing and data assignment

pull/15/head
HardiReady 2017-10-30 08:59:08 +01:00
parent efbc078aea
commit a37ca55a3b
7 changed files with 62 additions and 20 deletions

View File

@ -8,12 +8,30 @@ _MEAN Application_
### Setup mongoDB ### Setup mongoDB
https://docs.mongodb.com/manual/administration/install-community/
### Setup node and npm ### Setup node and npm
sudo apt-get install npm nodejs-legacy
update to latest npm version
sudo npm install -g npm@latest
update node to latest version
sudo npm install -g n@latest
n latest
check versions
npm -v
node -v
## Development and Execution ## Development and Execution
### First run in dev mode ### First run in dev mode
### Run in Prodction ### Run in Production
## License Information ## License Information

View File

@ -11,6 +11,10 @@ const WarSchema = new Schema({
date: { date: {
type: Date, type: Date,
}, },
endDate : {
type: Date,
required: true
},
ptBlufor: { ptBlufor: {
type: Number, type: Number,
get: v => Math.round(v), get: v => Math.round(v),
@ -61,7 +65,7 @@ const WarSchema = new Schema({
get: v => Math.round(v), get: v => Math.round(v),
set: v => Math.round(v), set: v => Math.round(v),
default: 0 default: 0
}, }
}, { }, {
collection: 'war', collection: 'war',
timestamps: {createdAt: 'timestamp'} timestamps: {createdAt: 'timestamp'}

View File

@ -65,6 +65,9 @@ const parseWarLog = (lineArray, war) => {
if (line.includes('Endbudget')) { if (line.includes('Endbudget')) {
stats.war['endBudgetBlufor'] = transformMoneyString(budg[11]); stats.war['endBudgetBlufor'] = transformMoneyString(budg[11]);
stats.war['endBudgetOpfor'] = transformMoneyString(budg[14]); stats.war['endBudgetOpfor'] = transformMoneyString(budg[14]);
console.log(budg)
console.log(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T' + budg[5] +'.000+02:00')
war.endDate = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T0' + budg[5] +'.000+02:00');
} else if (line.includes('Startbudget')) { } else if (line.includes('Startbudget')) {
stats.war.date = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T22:00:00.000+02:00'); stats.war.date = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T22:00:00.000+02:00');
stats.war['budgetBlufor'] = transformMoneyString(budg[11]); stats.war['budgetBlufor'] = transformMoneyString(budg[11]);

View File

@ -46,6 +46,7 @@ export interface War {
_id?: string; _id?: string;
title?: string; title?: string;
date?: string; date?: string;
endDate?: string;
ptBlufor?: number; ptBlufor?: number;
ptOpfor?: number; ptOpfor?: number;
playersBlufor?: number; playersBlufor?: number;

View File

@ -43,11 +43,11 @@
} }
.chart-container { .chart-container {
width: 95%; width: 90%;
min-width: 500px; margin: 2%;
min-width: 900px;
height: 400px; height: 400px;
padding: 15px; padding: 15px;
margin: 2%;
float: left; float: left;
} }

View File

@ -221,7 +221,7 @@
</ngx-charts-line-chart> </ngx-charts-line-chart>
</div> </div>
<div class="fade-in chart-container"> <div class="fade-in chart-container">
<ngx-charts-line-chart <ngx-charts-area-chart
[scheme]="colorScheme" [scheme]="colorScheme"
[results]="flagData" [results]="flagData"
[xAxis]="xAxis" [xAxis]="xAxis"
@ -235,7 +235,7 @@
[autoScale]="autoscale" [autoScale]="autoscale"
[timeline]="timeline" [timeline]="timeline"
[roundDomains]="roundDomains"> [roundDomains]="roundDomains">
</ngx-charts-line-chart> </ngx-charts-area-chart>
</div> </div>
</tab> </tab>
</tabset> </tabset>

View File

@ -177,7 +177,6 @@ export class WarDetailComponent {
"value": pointEntry.ptOpfor "value": pointEntry.ptOpfor
}); });
}); });
this.pointData = this.tmpPointData;
// BUDGET // BUDGET
this.tmpBudgetData[0].series.push({ this.tmpBudgetData[0].series.push({
@ -194,7 +193,6 @@ export class WarDetailComponent {
"value": budgetEntry.newBudget "value": budgetEntry.newBudget
}); });
}); });
this.budgetData = this.tmpBudgetData;
// KILLS // KILLS
let killCountBlufor = 0; let killCountBlufor = 0;
@ -241,8 +239,6 @@ export class WarDetailComponent {
"value": killEntry.fraction === 'BLUFOR' ? ffKillCountBlufor : ffKillCountOpfor "value": killEntry.fraction === 'BLUFOR' ? ffKillCountBlufor : ffKillCountOpfor
}); });
}); });
this.killData = this.tmpKillData;
this.friendlyFireData = this.tmpFrienlyFireData;
// TRANSPORT // TRANSPORT
let transportCountBlufor = 0; let transportCountBlufor = 0;
@ -267,7 +263,6 @@ export class WarDetailComponent {
"value": transportEntry.fraction === 'BLUFOR' ? transportCountBlufor : transportCountOpfor "value": transportEntry.fraction === 'BLUFOR' ? transportCountBlufor : transportCountOpfor
}); });
}); });
this.transportData = this.tmpTransportData;
// REVIVE & STABILIZE // REVIVE & STABILIZE
let reviveCountBlufor = 0; let reviveCountBlufor = 0;
@ -313,13 +308,10 @@ export class WarDetailComponent {
"value": reviveEntry.fraction === 'BLUFOR' ? stabilizeCountBlufor : stabilizeCountOpfor "value": reviveEntry.fraction === 'BLUFOR' ? stabilizeCountBlufor : stabilizeCountOpfor
}); });
}); });
this.reviveData = this.tmpReviveData;
this.stabilizedData = this.tmpStabilizeData;
// FLAG // FLAG
let flagStatusBlufor = 1; let flagStatusBlufor = true;
let flagStatusOpfor = 1; let flagStatusOpfor = true;
this.tmpFlagCaptureData[0].series.push({ this.tmpFlagCaptureData[0].series.push({
"name": startDateObj, "name": startDateObj,
"value": flagStatusBlufor "value": flagStatusBlufor
@ -331,20 +323,44 @@ export class WarDetailComponent {
data.flag.forEach(flagEntry => { data.flag.forEach(flagEntry => {
if (flagEntry.flagFraction === 'BLUFOR') { if (flagEntry.flagFraction === 'BLUFOR') {
flagStatusBlufor = flagEntry.capture ? 0 : 1 flagStatusBlufor = !flagEntry.capture
} else { } else {
flagStatusOpfor = flagEntry.capture ? 0 : 1; flagStatusOpfor = !flagEntry.capture;
} }
this.tmpFlagCaptureData[flagEntry.flagFraction === 'BLUFOR' ? 0 : 1].series.push({ this.tmpFlagCaptureData[flagEntry.flagFraction === 'BLUFOR' ? 0 : 1].series.push({
"name": new Date(flagEntry.time), "name": new Date(flagEntry.time),
"value": flagEntry.flagFraction === 'BLUFOR' ? flagStatusBlufor : flagStatusOpfor "value": flagEntry.flagFraction === 'BLUFOR' ? flagStatusBlufor : flagStatusOpfor
}); });
}); });
this.flagData = this.tmpFlagCaptureData;
this.addFinalTimeDataEntriesAndPopulate(new Date(this.war.endDate));
this.fractionChartsInitialized = true; this.fractionChartsInitialized = true;
}); });
} }
} }
addFinalTimeDataEntriesAndPopulate(endDate) {
[this.tmpPointData, this.tmpBudgetData, this.tmpTransportData, this.tmpReviveData, this.tmpStabilizeData,
this.tmpKillData, this.tmpFrienlyFireData, this.tmpFlagCaptureData].forEach(tmp => {
for (let j in [0, 1]) {
if (tmp[j].series[tmp[j].series.length - 1].name < endDate) {
tmp[j].series.push({
'name': endDate,
'value': tmp[j].series[tmp[j].series.length - 1].value
}
)
}
}
});
this.pointData = this.tmpPointData;
this.budgetData = this.tmpBudgetData;
this.transportData = this.tmpTransportData;
this.reviveData = this.tmpReviveData;
this.stabilizedData = this.tmpStabilizeData;
this.killData = this.tmpKillData;
this.friendlyFireData = this.tmpFrienlyFireData;
this.flagData = this.tmpFlagCaptureData;
}
} }