Skip to content
Snippets Groups Projects
Commit 5205f77c authored by Lukas Mauß's avatar Lukas Mauß
Browse files

Add some i18n to statistic-component

parent 1cce1def
No related merge requests found
...@@ -3,6 +3,8 @@ import { Chart } from 'chart.js'; ...@@ -3,6 +3,8 @@ import { Chart } from 'chart.js';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { ContentService } from '../../../services/http/content.service'; import { ContentService } from '../../../services/http/content.service';
import { ContentChoice } from '../../../models/content-choice'; import { ContentChoice } from '../../../models/content-choice';
import { TranslateService } from '@ngx-translate/core';
import { LanguageService } from '../../../services/util/language.service';
export class AnswerList { export class AnswerList {
label: string; label: string;
...@@ -35,9 +37,14 @@ export class StatisticComponent implements OnInit { ...@@ -35,9 +37,14 @@ export class StatisticComponent implements OnInit {
isLoading = true; isLoading = true;
constructor(protected route: ActivatedRoute, constructor(protected route: ActivatedRoute,
private contentService: ContentService) { } private contentService: ContentService,
private translateService: TranslateService,
protected langService: LanguageService) {
langService.langEmitter.subscribe(lang => translateService.use(lang));
}
ngOnInit() { ngOnInit() {
this.translateService.use(localStorage.getItem('currentLang'));
this.maxLength = innerWidth / 12; this.maxLength = innerWidth / 12;
this.answers = new Array<string>(); this.answers = new Array<string>();
this.labels = new Array<string>(); this.labels = new Array<string>();
...@@ -65,11 +72,12 @@ export class StatisticComponent implements OnInit { ...@@ -65,11 +72,12 @@ export class StatisticComponent implements OnInit {
this.answerList[i].answer = content.options[i].label; this.answerList[i].answer = content.options[i].label;
} }
} }
this.labels.push('Abstentions'); this.translateService.get('statistic.abstentions').subscribe(label => {
this.labels.push(label);
});
this.contentService.getAnswer(content.id).subscribe(answer => { this.contentService.getAnswer(content.id).subscribe(answer => {
this.data = answer.roundStatistics[0].independentCounts; this.data = answer.roundStatistics[0].independentCounts;
this.data.push(answer.roundStatistics[0].abstentionCount); this.data.push(answer.roundStatistics[0].abstentionCount);
console.log(this.data);
this.chart = new Chart('chart', { this.chart = new Chart('chart', {
type: 'bar', type: 'bar',
data: { data: {
......
...@@ -27,7 +27,7 @@ export class StatisticsPageComponent implements OnInit { ...@@ -27,7 +27,7 @@ export class StatisticsPageComponent implements OnInit {
private roomService: RoomService, private roomService: RoomService,
private translateService: TranslateService, private translateService: TranslateService,
protected langService: LanguageService, protected langService: LanguageService,
public dialog: MatDialog,) { public dialog: MatDialog) {
langService.langEmitter.subscribe(lang => translateService.use(lang)); langService.langEmitter.subscribe(lang => translateService.use(lang));
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment