result simple bar width calculations

This commit is contained in:
Tykayn 2022-02-11 09:36:22 +01:00 committed by tykayn
parent e3b9a82928
commit e3b2e685f1
7 changed files with 43 additions and 18 deletions

View File

@ -109,7 +109,7 @@
[(visible)]="display_cancel_dialog" [(visible)]="display_cancel_dialog"
[breakpoints]="{ '960px': '75vw' }" [breakpoints]="{ '960px': '75vw' }"
[style]="{ width: '50vw', 'border-radius': '1rem' }" [style]="{ width: '50vw', 'border-radius': '1rem' }"
[styleClass]="'round-borders'" [styleClass]="'roundToPercentWidth-borders'"
[draggable]="false" [draggable]="false"
[showHeader]="false" [showHeader]="false"
[resizable]="false" [resizable]="false"

View File

@ -4,8 +4,13 @@
{{ 'participation.yes' | translate }} {{ 'participation.yes' | translate }}
</div> </div>
<div class="column"> <div class="column">
<div class="bar has-text-centered has-background-yes" *ngIf="choice.yes"> <div
class="bar has-text-centered has-background-yes"
*ngIf="choice.yes"
[style.width]="roundToPercentWidth(choice.yes.count)"
>
{{ choice.yes.count }} {{ choice.yes.count }}
<!-- sur {{countMaxVotesForThisAnswer}}. {{roundToPercentWidth(choice.yes.count) }}-->
</div> </div>
</div> </div>
</div> </div>
@ -14,7 +19,10 @@
{{ 'participation.maybe' | translate }} {{ 'participation.maybe' | translate }}
</div> </div>
<div class="column"> <div class="column">
<div class="bar has-text-centered has-background-maybe"> <div
class="bar has-text-centered has-background-maybe"
[style.width]="roundToPercentWidth(choice.maybe.count)"
>
{{ choice.maybe.count }} {{ choice.maybe.count }}
</div> </div>
</div> </div>
@ -24,7 +32,7 @@
{{ 'participation.no' | translate }} {{ 'participation.no' | translate }}
</div> </div>
<div class="column"> <div class="column">
<div class="bar has-text-centered has-background-no"> <div class="bar has-text-centered has-background-no" [style.width]="roundToPercentWidth(choice.no.count)">
{{ choice.no.count }} {{ choice.no.count }}
</div> </div>
</div> </div>

View File

@ -9,7 +9,13 @@ import { Choice } from '../../../core/models/choice.model';
export class ChoiceTableComponent implements OnInit { export class ChoiceTableComponent implements OnInit {
@Input() detailledDisplay: boolean; @Input() detailledDisplay: boolean;
@Input() choice: Choice; @Input() choice: Choice;
@Input() countMaxVotesForThisAnswer: number = 5;
constructor() {} constructor() {}
ngOnInit(): void {} ngOnInit(): void {}
roundToPercentWidth(number: number) {
return Math.ceil((number / this.countMaxVotesForThisAnswer) * 100) + '%';
}
} }

View File

@ -106,18 +106,18 @@
<app-poll-results-dinum [poll]="poll" [detailledDisplay]="detailledDisplay"></app-poll-results-dinum> <app-poll-results-dinum [poll]="poll" [detailledDisplay]="detailledDisplay"></app-poll-results-dinum>
</section> </section>
<section class="poll-comments"> <!-- <section class="poll-comments">-->
<h2 class="title is-3"> <!-- <h2 class="title is-3">-->
{{ 'participation.comments' | translate }} <!-- {{ 'participation.comments' | translate }}-->
</h2> <!-- </h2>-->
<div class="rounded-block"> <!-- <div class="rounded-block">-->
<!-- *ngIf="poll.allow_comments"--> <!-- &lt;!&ndash; *ngIf="poll.allow_comments"&ndash;&gt;-->
<app-comments [poll]="poll" [vote_stack]="storageService.vote_stack"></app-comments> <!-- <app-comments [poll]="poll" [vote_stack]="storageService.vote_stack"></app-comments>-->
<div class="alert has-background-info" *ngIf="!poll.allow_comments"> <!-- <div class="alert has-background-info" *ngIf="!poll.allow_comments">-->
Ce sondage ne permet pas d'ajouter de commentaires <!-- Ce sondage ne permet pas d'ajouter de commentaires-->
</div> <!-- </div>-->
</div> <!-- </div>-->
</section> <!-- </section>-->
</div> </div>
</section> </section>
<section class="loadin_poll" *ngIf="fetching"> <section class="loadin_poll" *ngIf="fetching">

View File

@ -31,7 +31,11 @@
</div> </div>
<div class="choice-header" *ngIf="poll.max_score > 0"></div> <div class="choice-header" *ngIf="poll.max_score > 0"></div>
<app-choice-table [choice]="choice" [detailledDisplay]="detailledDisplay"></app-choice-table> <app-choice-table
[choice]="choice"
[detailledDisplay]="detailledDisplay"
[countMaxVotesForThisAnswer]="getMax(choice)"
></app-choice-table>
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,6 +3,7 @@ import { Poll } from '../../../core/models/poll.model';
import { Answer } from '../../../core/enums/answer.enum'; import { Answer } from '../../../core/enums/answer.enum';
import { ModalService } from '../../../core/services/modal.service'; import { ModalService } from '../../../core/services/modal.service';
import { StorageService } from '../../../core/services/storage.service'; import { StorageService } from '../../../core/services/storage.service';
import { Choice, ChoiceGroup } from '../../../core/models/choice.model';
@Component({ @Component({
selector: 'app-poll-results-dinum', selector: 'app-poll-results-dinum',
@ -12,7 +13,6 @@ import { StorageService } from '../../../core/services/storage.service';
export class PollResultsDinumComponent implements OnInit { export class PollResultsDinumComponent implements OnInit {
@Input() public poll: Poll; @Input() public poll: Poll;
@Input() public detailledDisplay: boolean = false; @Input() public detailledDisplay: boolean = false;
public answerEnum = Answer;
constructor(private modalService: ModalService, private storageService: StorageService) {} constructor(private modalService: ModalService, private storageService: StorageService) {}
ngOnInit(): void {} ngOnInit(): void {}
@ -24,4 +24,8 @@ export class PollResultsDinumComponent implements OnInit {
showAsDate(date_string: string) { showAsDate(date_string: string) {
return new Date(date_string); return new Date(date_string);
} }
getMax(c: Choice) {
return Math.max(c[Answer.YES].count, c[Answer.MAYBE].count, c[Answer.NO].count);
}
} }

View File

@ -360,6 +360,9 @@ label {
} }
} }
.people {
max-width: $main-column-width/2;
}
.bar-div { .bar-div {
padding: 0.25rem 0.025rem; padding: 0.25rem 0.025rem;
text-align: center; text-align: center;