Skip to content

Commit a57d078

Browse files
committed
fix: floor crimerate to nearest integer
1 parent e260e4b commit a57d078

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/app/map/map.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class MapComponent implements AfterViewInit, OnInit {
103103
<p>${type} in ${state}</p>
104104
<p>
105105
<span style="color: ${this.getColorByCrimeRate(crimeRate)}">
106-
${crimeRate ? crimeRate * 100000 : '--'}
106+
${crimeRate ? Math.floor(crimeRate * 100000) : '--'}
107107
</span>
108108
Straftaten pro 100.000 Einwohner (Stand 2019)
109109
</p>`;

src/app/search-details/county-table/county-table.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Krimnialtität
2323
<mat-icon matTooltip="Straftaten pro 100T Einwohner (2019)" matTooltipPosition="above" style="font-size: 15px">info</mat-icon>
2424
</th>
25-
<td mat-cell *matCellDef="let element">{{ element.crimeRate * 100000 }}</td>
25+
<td mat-cell *matCellDef="let element">{{ element.crimeRate | crimeRate }}</td>
2626
</ng-container>
2727

2828
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
3+
@Pipe({
4+
name: 'crimeRate',
5+
})
6+
export class CrimeRatePipe implements PipeTransform {
7+
transform(crimeRate: number): number {
8+
return Math.floor(crimeRate * 100000);
9+
}
10+
}

src/app/search-details/search-details.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { SharedModule } from '../shared/shared.module';
44
import { CityNamesPipe } from './city-names.pipe';
55
import { CountyTableComponent } from './county-table/county-table.component';
66
import { CountyTypePipe } from './county-table/county-type.pipe';
7+
import { CrimeRatePipe } from './county-table/crime-rate.pipe';
78

89
@NgModule({
9-
declarations: [SearchDetailsComponent, CityNamesPipe, CountyTableComponent, CountyTypePipe],
10+
declarations: [SearchDetailsComponent, CityNamesPipe, CountyTableComponent, CountyTypePipe, CrimeRatePipe],
1011
imports: [SharedModule],
1112
exports: [SearchDetailsComponent],
1213
})

0 commit comments

Comments
 (0)