Browse Source

Improve value in benchmark detail dialog

pull/8260/head
Thomas Kaul 3 days ago
parent
commit
a9153228e4
  1. 6
      apps/api/src/app/endpoints/asset-profiles/asset.controller.ts
  2. 9
      libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts
  3. 5
      libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.html

6
apps/api/src/app/endpoints/asset-profiles/asset.controller.ts

@ -30,7 +30,11 @@ export class AssetController {
return {
marketData,
splits,
assetProfile: pick(assetProfile, ['dataSource', 'name', 'symbol'])
assetProfile: {
...pick(assetProfile, ['dataSource', 'name', 'symbol']),
// An index has no asset class and its value has no currency
currency: assetProfile.assetClass ? assetProfile.currency : undefined
}
};
}
}

9
libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts

@ -1,3 +1,4 @@
import { NUMERICAL_PRECISION_THRESHOLD_4_FIGURES } from '@ghostfolio/common/config';
import { DATE_FORMAT } from '@ghostfolio/common/helper';
import {
AdminMarketDataDetails,
@ -47,6 +48,7 @@ export class GfBenchmarkDetailDialogComponent implements OnInit {
public assetProfile?: AdminMarketDataDetails['assetProfile'];
public historicalDataItems: LineChartItem[];
public isLoading = true;
public precision = 2;
public value: number;
public constructor(
@ -80,6 +82,13 @@ export class GfBenchmarkDetailDialogComponent implements OnInit {
}
);
if (
this.data.deviceType === 'mobile' &&
this.value >= NUMERICAL_PRECISION_THRESHOLD_4_FIGURES
) {
this.precision = 0;
}
this.isLoading = false;
this.changeDetectorRef.markForCheck();

5
libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.html

@ -13,16 +13,17 @@
size="large"
[isLoading]="isLoading"
[locale]="data.locale"
[precision]="2"
[precision]="precision"
[unit]="assetProfile?.currency"
[value]="value"
/>
</div>
</div>
<gf-line-chart
benchmarkLabel="Average Unit Price"
class="mb-4"
[colorScheme]="data.colorScheme"
[currency]="assetProfile?.currency"
[historicalDataItems]="historicalDataItems"
[isAnimated]="true"
[label]="data.symbol"

Loading…
Cancel
Save