AW-2388 Fixed mixed decimal in histogram

This commit is contained in:
Peter Bastiani 2021-05-26 14:58:03 +02:00
parent 6f77df0f61
commit bcfa13de60
2 changed files with 3 additions and 3 deletions

View File

@ -23,7 +23,7 @@
<div *ngIf="showHistogram()">
<span class="bar" [style.background-color]="getHex(entry.color)" [style.width]="getPart(layer.renderer, i)">
</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>
</td>
</tr>

View File

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