Compare commits
2 Commits
5d94be1c09
...
b05f227a10
Author | SHA1 | Date |
---|---|---|
HardiReady | b05f227a10 | |
HardiReady | 327797813b |
|
@ -4,6 +4,8 @@ import {CampaignService} from '../../../services/logs/campaign.service';
|
||||||
import {ChartUtils} from '../../../utils/chart-utils';
|
import {ChartUtils} from '../../../utils/chart-utils';
|
||||||
import {Fraction} from '../../../utils/fraction.enum';
|
import {Fraction} from '../../../utils/fraction.enum';
|
||||||
import {WarService} from '../../../services/logs/war.service';
|
import {WarService} from '../../../services/logs/war.service';
|
||||||
|
import {FractionHelpers} from '../../../utils/global.helpers';
|
||||||
|
import {War} from '../../../models/model-interfaces';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -22,9 +24,7 @@ export class StatisticOverviewComponent implements OnInit {
|
||||||
playerData: any[] = [];
|
playerData: any[] = [];
|
||||||
currentData: any[] = [];
|
currentData: any[] = [];
|
||||||
|
|
||||||
colorScheme = {
|
colorScheme;
|
||||||
domain: [Fraction.COLOR_BLUFOR, Fraction.COLOR_OPFOR]
|
|
||||||
};
|
|
||||||
gradient = false;
|
gradient = false;
|
||||||
xAxis = true;
|
xAxis = true;
|
||||||
yAxis = true;
|
yAxis = true;
|
||||||
|
@ -81,44 +81,71 @@ export class StatisticOverviewComponent implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initChart(wars: any[]) {
|
initChart(wars: War[]) {
|
||||||
const pointsObj = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
|
const fractions: string[] = [];
|
||||||
const pointsSumObj = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
|
this.colorScheme = {
|
||||||
const playersObj = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
|
domain: []
|
||||||
|
};
|
||||||
|
|
||||||
|
if (wars.find(war => war.fractionMappingBlufor === 'BLUFOR' || war.fractionMappingOpfor === 'BLUFOR')) {
|
||||||
|
fractions.push(Fraction.BLUFOR);
|
||||||
|
this.colorScheme.domain.push(FractionHelpers.getFractionColor('BLUFOR'));
|
||||||
|
}
|
||||||
|
if (wars.find(war => war.fractionMappingBlufor === 'OPFOR' || war.fractionMappingOpfor === 'OPFOR')) {
|
||||||
|
fractions.push(Fraction.OPFOR);
|
||||||
|
this.colorScheme.domain.push(FractionHelpers.getFractionColor('OPFOR'));
|
||||||
|
}
|
||||||
|
if (wars.find(war => war.fractionMappingBlufor === Fraction.ARF || war.fractionMappingOpfor === Fraction.ARF)) {
|
||||||
|
fractions.push(Fraction.ARF);
|
||||||
|
this.colorScheme.domain.push(FractionHelpers.getFractionColor(Fraction.ARF));
|
||||||
|
}
|
||||||
|
if (wars.find(war => war.fractionMappingBlufor === Fraction.SWORD || war.fractionMappingOpfor === Fraction.SWORD)) {
|
||||||
|
fractions.push(Fraction.SWORD);
|
||||||
|
this.colorScheme.domain.push(FractionHelpers.getFractionColor(Fraction.SWORD));
|
||||||
|
}
|
||||||
|
|
||||||
|
const pointsObj = ChartUtils.getMultiDataArray(...fractions);
|
||||||
|
const pointsSumObj = ChartUtils.getMultiDataArray(...fractions);
|
||||||
|
const playersObj = ChartUtils.getMultiDataArray(...fractions);
|
||||||
|
|
||||||
for (let i = wars.length - 1; i >= 0; i--) {
|
for (let i = wars.length - 1; i >= 0; i--) {
|
||||||
const war = wars[i];
|
const war = wars[i];
|
||||||
if (!war) {
|
if (!war) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bluforIndex = fractions.findIndex(fraction =>
|
||||||
|
fraction === FractionHelpers.getFractionName(war, 'BLUFOR'));
|
||||||
|
const opforIndex = fractions.findIndex(
|
||||||
|
fraction => fraction === FractionHelpers.getFractionName(war, 'OPFOR'));
|
||||||
|
|
||||||
const j = wars.length - i - 1;
|
const j = wars.length - i - 1;
|
||||||
const warDate = (this.id === 'all') ? new Date(war.date) : ChartUtils.getShortDateString(war.date);
|
const warDate = (this.id === 'all') ? new Date(war.date) : ChartUtils.getShortDateString(war.date);
|
||||||
|
pointsObj[bluforIndex].series.push({
|
||||||
pointsObj[0].series.push({
|
|
||||||
name: warDate,
|
name: warDate,
|
||||||
value: war.ptBlufor
|
value: war.ptBlufor
|
||||||
});
|
});
|
||||||
pointsObj[1].series.push({
|
pointsObj[opforIndex].series.push({
|
||||||
name: warDate,
|
name: warDate,
|
||||||
value: war.ptOpfor
|
value: war.ptOpfor
|
||||||
});
|
});
|
||||||
pointsSumObj[0].series.push({
|
pointsSumObj[bluforIndex].series.push({
|
||||||
name: warDate,
|
name: warDate,
|
||||||
value: pointsSumObj[0].series[j - 1] ?
|
value: pointsSumObj[bluforIndex].series[j - 1] ?
|
||||||
pointsSumObj[0].series[j - 1].value + war.ptBlufor :
|
pointsSumObj[bluforIndex].series[j - 1].value + war.ptBlufor :
|
||||||
war.ptBlufor
|
war.ptBlufor
|
||||||
});
|
});
|
||||||
pointsSumObj[1].series.push({
|
pointsSumObj[opforIndex].series.push({
|
||||||
name: warDate,
|
name: warDate,
|
||||||
value: pointsSumObj[1].series[j - 1]
|
value: pointsSumObj[opforIndex].series[j - 1]
|
||||||
? pointsSumObj[1].series[j - 1].value + war.ptOpfor :
|
? pointsSumObj[opforIndex].series[j - 1].value + war.ptOpfor :
|
||||||
war.ptOpfor
|
war.ptOpfor
|
||||||
});
|
});
|
||||||
playersObj[0].series.push({
|
playersObj[bluforIndex].series.push({
|
||||||
name: warDate,
|
name: warDate,
|
||||||
value: war.playersBlufor
|
value: war.playersBlufor
|
||||||
});
|
});
|
||||||
playersObj[1].series.push({
|
playersObj[opforIndex].series.push({
|
||||||
name: warDate,
|
name: warDate,
|
||||||
value: war.playersOpfor
|
value: war.playersOpfor
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="fractionMappingOpfor">{{'stats.war.submit.mapping.blufor' | translate}}</label>
|
<label for="fractionMappingOpfor">{{'stats.war.submit.mapping.opfor' | translate}}</label>
|
||||||
<select id="fractionMappingOpfor" name="fractionMappingOpfor" class="form-control btn dropdown-toggle"
|
<select id="fractionMappingOpfor" name="fractionMappingOpfor" class="form-control btn dropdown-toggle"
|
||||||
required
|
required
|
||||||
[(ngModel)]="war.fractionMappingOpfor">
|
[(ngModel)]="war.fractionMappingOpfor">
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
<option value="OPFOR">{{fraction.OPFOR}}</option>
|
<option value="OPFOR">{{fraction.OPFOR}}</option>
|
||||||
<option value="BLUFOR">{{fraction.BLUFOR}}</option>
|
<option value="BLUFOR">{{fraction.BLUFOR}}</option>
|
||||||
</select>
|
</select>
|
||||||
<show-error displayName="{{'stats.war.submit.mapping.blufor' | translate}}" controlPath="fraction"></show-error>
|
<show-error displayName="{{'stats.war.submit.mapping.opfor' | translate}}" controlPath="fraction"></show-error>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
export enum Fraction {
|
export enum Fraction {
|
||||||
|
COLOR_NEUTRAL = '#222222',
|
||||||
ARF = 'ARF',
|
ARF = 'ARF',
|
||||||
COLOR_ARF = '#336699',
|
COLOR_ARF = '#336699',
|
||||||
COLOR_ARF_GREY = '#336699',
|
COLOR_ARF_LIGHT = '#6666dd',
|
||||||
COLOR_ARF_DARK = '#336699',
|
COLOR_ARF_DARK = '#0C0CA6',
|
||||||
COLOR_ARF_LIGHT = '#336699',
|
COLOR_ARF_GREY = '#515179',
|
||||||
SWORD = 'SWORD',
|
SWORD = 'SWORD',
|
||||||
COLOR_SWORD = '#8b8b8b',
|
COLOR_SWORD = '#8b8b8b',
|
||||||
COLOR_SWORD_GREY = '#8b8b8b',
|
COLOR_SWORD_GREY = '#282828',
|
||||||
COLOR_SWORD_DARK = '#8b8b8b',
|
COLOR_SWORD_DARK = '#101010',
|
||||||
COLOR_SWORD_LIGHT = '#8b8b8b',
|
COLOR_SWORD_LIGHT = '#b8b8b8',
|
||||||
BLUFOR = 'NATO',
|
BLUFOR = 'NATO',
|
||||||
OPFOR = 'CSAT',
|
|
||||||
COLOR_BLUFOR = '#3c5fa1',
|
COLOR_BLUFOR = '#3c5fa1',
|
||||||
COLOR_BLUFOR_LIGHT = '#6666dd',
|
COLOR_BLUFOR_LIGHT = '#6666dd',
|
||||||
COLOR_BLUFOR_DARK = '#0C0CA6',
|
COLOR_BLUFOR_DARK = '#0C0CA6',
|
||||||
COLOR_BLUFOR_GREY = '#515179',
|
COLOR_BLUFOR_GREY = '#515179',
|
||||||
|
OPFOR = 'CSAT',
|
||||||
COLOR_OPFOR = '#a90100',
|
COLOR_OPFOR = '#a90100',
|
||||||
COLOR_OPFOR_DARK = '#890F0F',
|
COLOR_OPFOR_DARK = '#890F0F',
|
||||||
COLOR_OPFOR_LIGHT = '#fb5555',
|
COLOR_OPFOR_LIGHT = '#fb5555',
|
||||||
COLOR_OPFOR_GREY = '#955c5f',
|
COLOR_OPFOR_GREY = '#955c5f',
|
||||||
COLOR_NEUTRAL = '#222222',
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue