Browse Source

Feature/hide the performance chart of the home overview if it has less than three data points

pull/8267/head
mister-ideas 3 days ago
parent
commit
7757daca3b
  1. 8
      apps/client/src/app/components/home-overview/home-overview.component.ts
  2. 2
      apps/client/src/app/components/home-overview/home-overview.html

8
apps/client/src/app/components/home-overview/home-overview.component.ts

@ -38,6 +38,8 @@ import { MatCardModule } from '@angular/material/card';
import { Router, RouterModule } from '@angular/router';
import { DeviceDetectorService } from 'ngx-device-detector';
const MINIMUM_CHART_ITEMS = 3;
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
@ -56,6 +58,12 @@ export class GfHomeOverviewComponent implements OnInit {
protected readonly errors = signal<AssetProfileIdentifier[]>([]);
protected readonly hasImpersonationId = signal(false);
protected readonly historicalDataItems = signal<LineChartItem[] | null>(null);
// A line through only two points (e.g. the close of the previous day and
// now) is drawn as a misleading slope across the whole width
protected readonly hasEnoughChartData = computed(() => {
return (this.historicalDataItems()?.length ?? 0) >= MINIMUM_CHART_ITEMS;
});
protected readonly holdings = signal<PortfolioPosition[] | undefined>(
undefined
);

2
apps/client/src/app/components/home-overview/home-overview.html

@ -72,7 +72,7 @@
unit="%"
[class.pe-3]="deviceType() === 'mobile'"
[colorScheme]="user()?.settings?.colorScheme"
[hidden]="historicalDataItems()?.length === 0"
[hidden]="!hasEnoughChartData()"
[historicalDataItems]="historicalDataItems()"
[isAnimated]="user()?.settings?.dateRange === '1d' ? false : true"
[label]="performanceLabel"

Loading…
Cancel
Save