Compare commits

...

2 Commits

Author SHA1 Message Date
880eb26a99 getPercentage
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
2021-05-26 14:59:03 +02:00
bcfa13de60 AW-2388 Fixed mixed decimal in histogram 2021-05-26 14:58:03 +02:00
2 changed files with 3 additions and 3 deletions

View File

@ -23,7 +23,7 @@
<div *ngIf="showHistogram()"> <div *ngIf="showHistogram()">
<span class="bar" [style.background-color]="getHex(entry.color)" [style.width]="getPart(layer.renderer, i)"> <span class="bar" [style.background-color]="getHex(entry.color)" [style.width]="getPart(layer.renderer, i)">
</span> </span>
<span class="bar-label">{{getLabel(layer.renderer,i)}}</span> <span *ngIf="getPercentage(layer.renderer,i) as percentage" class="bar-label">{{percentage | number:'1.0-2'}}</span>
</div> </div>
</td> </td>
</tr> </tr>

View File

@ -78,10 +78,10 @@ export class LegendComponent implements OnInit,AfterViewInit {
return v; return v;
} }
public getLabel(renderer: IRenderer, index: number): string { public getPercentage(renderer: IRenderer, index: number): number {
let scale = 100 / renderer.band.histogram.entries.reduce((sum, entry) => sum + entry.freqency, 0); let scale = 100 / renderer.band.histogram.entries.reduce((sum, entry) => sum + entry.freqency, 0);
let percent = renderer.band.histogram.entries[index].freqency * scale; let percent = renderer.band.histogram.entries[index].freqency * scale;
return percent < 0.1 ? "" : percent.toFixed(1) + " %"; return percent < 0.1 ? null : percent;
} }
showLegend(): boolean { showLegend(): boolean {